Sunday, November 21, 2010

Template Keyword

The following can be valid syntax:
    p->template MyClass<int>::f();
    p.template MyClass<int>::f();

I have only seen this used in book referenced below. Sometimes the template keyword is necessary, but only if the compiler has trouble figuring out that something is a template. If the compiler can figure it out, then it is an error to include the template keyword.

Reference: C++ Templates by David Vandevoorde and Nicolai M. Josuttis. Addison-Wesley, 2003, p. 131.

No comments:

Post a Comment