c++ - Why is in-class partial specialization well-formed? -
according [temp.class.spec] 5/ (emphasis mine)
a class template partial specialization may declared or redeclared in namespace scope in corresponding primary template may defined
this suggest partial specialization (just in case of explicit specialization) have appear in namespace scope. confirmed example below paragraph:
template<class t> struct { struct c { template<class t2> struct b { }; }; }; // partial specialization of a<t>::c::b<t2> template<class t> template<class t2> struct a<t>::c::b<t2*> { }; //... a<short>::c::b<int*> absip; // uses partial specialization
on other hand c++ standard core language active issues no 727 example suggests in-class partial specialization formed:
struct { template<class t> struct b; template <class t> struct b<t*> { }; // well-formed template <> struct b<int*> { }; // ill-formed };
i'm sure core issues document correct here, cannot find appropriate reference confirm that. can me?
the intent is valid—see n4090:
following brief discussion of dr 17557 , dr 7278 in issaquah 2014, , based on discussion on core-reflector91011, seems if core converging on following rules member templates , specializations: partial specializations , explicit specializations can first declared at either innermost-enclosing-class scope or enclosing namespace scope (recognizing explicitly declaring specializations not constitute adding members class , hence can done after closing brace).
7 http://www.openstd.org/jtc1/sc22/wg21/docs/cwg_toc.html#727
8 http://www.openstd.org/jtc1/sc22/wg21/docs/cwg_toc.html#1755
9 http://accu.org/cgibin/wg21/message?wg=core&msg=24366(24033, 24290, 24309, 24368)
10 http://accu.org/cgibin/wg21/message?wg=core&msg=24731(24731, 24732, 24736, 24738)
11 http://accu.org/cgibin/wg21/message?wg=core&msg=25168 (25168-25179)
i filed core issue, because feel current wording not clear enough; paragraph quoted can interpreted disallow in-class partial specializations.
Comments
Post a Comment