Wednesday, October 20, 2010

Dependent Names

By default, dependent names are initially assumed by the compiler not to name a type.

This is why you sometimes need to use the 'typename' keyword to tell the compiler that something is a type. You cannot just use this keyword for every type using a template parameter. You can only use it for types that the compiler cannot figure out. Also, instead of peppering your code with 'typename', it is recommended that you use typedefs with the 'typename' keyword to simplify the code.

Reference: More Exceptional C++ by Herb Sutter. Addison-Wesley, 2001, p. 33.

No comments:

Post a Comment