Title
Default template arguments for template members of non-template classes
Status
open
Section
13.2 [temp.param]
Submitter
Mike Miller

Created on 2022-08-22.00:00:00 last changed 1 month ago

Messages

Date: 2022-08-22.00:00:00

Consider:

struct S {
  template<typename> void f();
};

template<typename = int> void S::f() { }   // ok?

There is implementation divergence in the treatment of this example. The relevant wording appears to be 13.2 [temp.param] paragraph 12:

A default template-argument shall not be specified in the template-parameter-lists of the definition of a member of a class template that appears outside of the member's class.

However, the example above deals with a member of an ordinary class, not a class template, but it is not clear why there should be a difference between a member template of a class template and a member template of a non-template class.

Alternatively, it is not clear why the example above should be treated differently from a non-member function template, e.g.,

template<typename> void f();
template<typename = int> void f() { }

which is explicitly permitted.

History
Date User Action Args
2022-08-22 00:00:00admincreate