Created on2008-10-05.00:00:00 last changed96 months ago
Proposed resolution (March, 2017):
Change 13.7.6.1 [temp.spec.partial.general] paragraph 6 as follows:
A class template partial specialization may be declared
orredeclaredin anynamespacescope in which thecorresponding primary template may be defined (_N4868_.9.8.2.3 [namespace.memdef]and, 11.4 [class.mem],13.7.3 [temp.mem]). [Example:template<class T> struct A { struct C { template<class T2> struct B { }; template<class T2> struct B<T2**> { }; // partial specialization #1 }; }; // partial specialization ofA<T>::C::B<T2> template<class T> template<class T2> struct A<T>::C::B<T2*> { };// #2 A<short>::C::B<int*> absip; // uses partial specialization#2—end example]
Change 13.9.4 [temp.expl.spec] paragraph 2 as follows:
An explicit specializationshall be declared in a namespace enclosing thespecialized template. An explicit specialization whosedeclarator-idorclass-head-name is not qualified shall be declared in the nearestenclosing namespace of the template, or, if the namespace is inline(9.9.2 [namespace.def]), any namespace from its enclosing namespaceset. Such a declaration may also be a definitionmay be declared in any scope in which the corresponding primarytemplate may be defined (_N4868_.9.8.2.3 [namespace.memdef],11.4 [class.mem], 13.7.3 [temp.mem]).If thedeclaration is not a definition, the specialization may be defined later(_N4868_.9.8.2.3 [namespace.memdef]).
Additional note, November, 2014:
See also paper N4090.
Additional note (October, 2013):
EWG has requested CWG to consider resolving this issue. See EWGissue 41.
[Adopted as a DR at the February/March, 2017 meeting.]
13.9.4 [temp.expl.spec] paragraph 2 requires that explicitspecializations of member templates be declared in namespace scope, notin the class definition. This restriction does not apply to partialspecializations of member templates; that is,
struct A { template<class T> struct B; template <class T> struct B<T*> { }; // well-formed template <> struct B<int*> { }; // ill-formed };There does not seem to be a good reason for this inconsistency.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2018-02-27 00:00:00 | admin | set | messages: +msg6171 |
| 2018-02-27 00:00:00 | admin | set | status: drafting -> c++17 |
| 2014-11-24 00:00:00 | admin | set | messages: +msg5229 |
| 2014-03-03 00:00:00 | admin | set | status: open -> drafting |
| 2013-10-14 00:00:00 | admin | set | messages: +msg4668 |
| 2013-10-14 00:00:00 | admin | set | status: extension -> open |
| 2009-03-23 00:00:00 | admin | set | status: open -> extension |
| 2008-10-05 00:00:00 | admin | create | |