Tuesday, October 19, 2010


The following code does not compile:

    template<typename T>
    void func()
        T::A a;

The compiler does not know if T::A is a type. It could be several other things, which will only be known when the template is instantiated. You need the 'typename' qualifier here.

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

No comments:

Post a Comment