RAD Studio
ContentsIndex
PreviousUpNext
E2105: 'template' qualifier must specify a member template name (C++)

When parsing code that depends in some way upon a template parameter, it is sometimes impossible to know whether a member name will resolve to a template function name, or a regular parameter. In the following code, a 'template' qualifier is required in order to know if the '<' (less-then) operator should be parsed as the beginning character of a template argument list, or as a regular less-than operator:

template<class T>
void foo(T a)
{
a.member<10>();
}

Although it may be apparent to the reader what is meant, the compiler does not know that "member" refers to a member template function, and it will parse the line of code as follows:

a.member < (10>());

In order to tell the compiler that the less-than character begins a template argument list, the 'template' qualifier is needed:

a.template member<10>();   // "member" must be a member template

If the 'template' qualifier is used in a situation where "member" does not resolve to a member template, the above error will result.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!