Use of Template Keyword to Disambiguate Template Names Sample

Description

Consider some C++ code:

	class A {
	public:
		template <class T> int f() {return 0;}
	};

	template <class T> void g(T& a)
	{
		int i = a.f<int>();
	}
A::f is a member template function with one template parameter. The function itself takes no parameters, meaning that any call of it requires explicit qualification using <>. In g() a call is made to A::f(). But a compiler can't know this, because it can't know the type of T until instantiation time. So a.f<int> can be parsed either as a function call with explicit qualification, or as a.f < int. The template qualifier is needed to resolve the ambiguity.

Concept

The sample program defines a class A with a member template. An object of A type is passed to g(), and A::f() is called using explicit qualification. The template qualifier is used to disambiguate the call.

Supported
Supported
Supported