Monday, October 4, 2010

Double const Allowed in Template

The following compiles:

       template <typename T>
       class ConstType {
          typedef const T MyConst;
       ConstType<const int>::MyConst i = 0;

Note the double const, and the compiler does not complain about it.

Reference: Modern C++ Design by Andrei Alexandrescu. Addison-Wesley, 2001, p. 37.

No comments:

Post a Comment