Created on 2000-03-22.00:00:00 last changed 262 months ago
Proposed resolution (10/00):
In 9.3.4.7 [dcl.fct.default] paragraph 6, replace
The default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition.
with
Except for member functions of class templates, the default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition. Default arguments for a member function of a class template must be specified on the initial declaration of the member function within the class template.
According to 9.3.4.7 [dcl.fct.default] paragraphs 4 and 6,
For non-template functions, default arguments can be added in later declarations of a function in the same scope.
The default arguments in a member function definition that appears outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition.
This would appear to allow the following example, in which a default argument is added to a non-template member function of a class template:
template <class T> struct S { void foo (int); }; template <class T> void S<T>::foo (int = 0) { }
John Spicer: The wording "non-template functions" is somewhat unclear with respect to member functions of class templates, but I know that this was intended to include them because it originates from issue 3.13 of the template issues list that I maintained for several years.
Having said that, the rationale for this restriction has since been made obsolete, so this could (in theory) be changed in the standard if it is problematic for users.
(See also issue 205.)
History | |||
---|---|---|---|
Date | User | Action | Args |
2003-04-25 00:00:00 | admin | set | status: dr -> tc1 |
2000-11-18 00:00:00 | admin | set | status: ready -> dr |
2000-05-21 00:00:00 | admin | set | messages: + msg308 |
2000-03-22 00:00:00 | admin | create |