1. int32 shows how ugly a (nearly) standard implementation of a 32-bit int type can be in ISO C. It's possible to define a templated typedef to select ints with a desired number of bits: see Int<bits>.
  2. fibonaci defines a nice C++ multitype using a typelist.




It's interesting to note that typedef is often essential to be able to phrase these constructions! In C, typedef "just" defines an alias for the type, but could theoretically have been removed from the language. But in C++ typedef lets you do things that would be impossible had it not been in the language. The examples use typedef to "hoist" types out of a typelist at compile-time; I know of no other means to do so.

Log in or registerto write something here or to contact authors.