Created on 2022-08-22.00:00:00 last changed 30 months ago
Proposed resolution:
Change in 13.2 [temp.param] paragraph 10 as follows:
... A default template-argument may be specified in a template declaration. A default template-argument shall not be specified in the template-parameter-lists of the definition of a member of aclass templatetemplated class C that appears outside of themember's classclass-specifier of C. A default template-argument shall not be specified in a friend class template declaration. If a friend function template declaration D specifies a default template-argument, that declaration shall be a definition and there shall be no other declaration of the function template which is reachable from D or from which D is reachable.
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 |
| 2023-06-20 19:34:52 | admin | set | messages: + msg7336 |
| 2023-06-20 19:34:52 | admin | set | status: open -> review |
| 2022-08-22 00:00:00 | admin | create | |