member template explicit qualification in VC6
Attila
Attila
Sat Dec 13 15:52:27 CST 2003
Hi All,
Consider the following C++ class definition:
class A
{
public:
template <class T> T& getT();
};
Now, how do users of class A call getT()? The general problem is that the template member function presents its template parameter only as its return type, so T cannot be deduced:
A a;
typedef int T;
T t= a.getT(); // return types are not used in template parameter deduction
This would be the first idea I could come up with, but it is a syntax error:
A a;
a.getT<int>(); // does not compile
Stroustrup tells in his “The C++ Language”, that the explicit qualification can be written like this:
A a;
a.template getT<int>();
But this does not compile in VC6 on my machine.
Anyone knows the solution for calling template members of this kind?
Thanks,
Attila
More information about the gme-users
mailing list