This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


228. Use of template keyword with non-member templates

Section: 13.3  [temp.names]     Status: CD1     Submitter: Daveed Vandevoorde     Date: 4 May 2000

[Voted into WP at April 2003 meeting.]

Consider the following example:

    template<class T>
    struct X {
       virtual void f();
    };

    template<class T>
    struct Y {
       void g(X<T> *p) {
	  p->template X<T>::f();
       }
    };

This is an error because X is not a member template; 13.3 [temp.names] paragraph 5 says:

If a name prefixed by the keyword template is not the name of a member template, the program is ill-formed.

In a way this makes perfect sense: X is found to be a template using ordinary lookup even though p has a dependent type. However, I think this makes the use of the template prefix even harder to teach.

Was this intentionally outlawed?

Proposed Resolution (4/02):

Elide the first use of the word "member" in 13.3 [temp.names] paragraph 5 so that its first sentence reads:

If a name prefixed by the keyword template is not the name of a member template, the program is ill-formed.