That's done in Linux in C already: see <linux/list.h>.
> This works, and has zero bloat; in fact it is *more* compact than the
> analogous magic-number-based implementation in C, relying instead upon
> the RTTI structures already generated by the compiler.
Nonsense. (a) RTTI has nothing to do with generic containers and
typesafe accessors; (b) the wrapper macros aren't typesafe in C but they
certainly don't use magic numbers; (c) when RTTI _is_ used for variant
types, a C switch is usually faster and smaller; (d) RTTI has other
overheads.
> So please stop saying templates are bloated. They *are* easy to produce
> bloated stuff in, and could probably be faulted for that; but they are
> *not* intrinsically bloat creators. It is perfectly possible (and easy)
> to produce non-bloating, typesafe stuff with templates.
We know. It doesn't happen in practice: even the STL does not work the
way you describe. (It can be, but you have to do it quite deliberately
and write the type conversions yourself).
-- Jamie
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/