Movatterモバイル変換


[0]ホーム

URL:


Issue 727 - WG21 CWG Issues
Title
In-class explicit specializations
Status
c++17
Section
13.9.4 [temp.expl.spec]
Submitter
Faisal Vali

Created on2008-10-05.00:00:00 last changed96 months ago

Messages

msg6171 (view)
Date: 2017-03-15.00:00:00

Proposed resolution (March, 2017):

  1. Change 13.7.6.1 [temp.spec.partial.general] paragraph 6 as follows:

  2. A class template partial specialization may be declaredorredeclared in anynamespace scope 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]

  3. Change 13.9.4 [temp.expl.spec] paragraph 2 as follows:

  4. 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]).
msg5229 (view)
Date: 2014-11-24.00:00:00

Additional note, November, 2014:

See also paper N4090.

msg4668 (view)
Date: 2013-10-15.00:00:00

Additional note (October, 2013):

EWG has requested CWG to consider resolving this issue. See EWGissue 41.

msg1858 (view)
Date: 2017-02-15.00:00:00

[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
DateUserActionArgs
2018-02-27 00:00:00adminsetmessages: +msg6171
2018-02-27 00:00:00adminsetstatus: drafting -> c++17
2014-11-24 00:00:00adminsetmessages: +msg5229
2014-03-03 00:00:00adminsetstatus: open -> drafting
2013-10-14 00:00:00adminsetmessages: +msg4668
2013-10-14 00:00:00adminsetstatus: extension -> open
2009-03-23 00:00:00adminsetstatus: open -> extension
2008-10-05 00:00:00admincreate

[8]ページ先頭

©2009-2026 Movatter.jp