<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 44</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="44"></A><H4>44.
  
Member specializations
</H4>
<B>Section: </B>13.9.4&#160; [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD1
 &#160;&#160;&#160;

 <B>Submitter: </B>Nathan Myers
 &#160;&#160;&#160;

 <B>Date: </B>19 Sep 1998<BR>



<P>[Moved to DR at 4/01 meeting.]</P>



<P>Some compilers reject the following:</P>
<PRE>
    struct A {
        template &lt;int I&gt; void f();
        template &lt;&gt; void f&lt;0&gt;();
    };
</PRE>
on the basis of 13.9.4 [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>]

paragraph 2:
<BLOCKQUOTE>An explicit specialization shall be declared in the namespace
of which the template is a member, or, for member templates, in the namespace
of which the enclosing class or enclosing class template is a member. An
explicit specialization of a member function, member class or static data
member of a class template shall be declared in the namespace of which
the class template is a member. ...</BLOCKQUOTE>
claiming that the specialization above is not "in the namespace of which
the enclosing class ... is a member". Elsewhere, declarations are sometimes
required to be "at" or "in" "namespace scope", which is not what it says
here. Paragraph 17 says:
<BLOCKQUOTE>A member or a member template may be nested within many enclosing
class templates. If the declaration of an explicit specialization for such
a member appears in namespace scope, the member declaration shall be preceded
by a <TT>template&lt;&gt;</TT> for each
enclosing class template that is explicitly
specialized.</BLOCKQUOTE>
The qualification "if the declaration ... appears in namespace scope",
implies that it might appear elsewhere. The only other place I can think
of for a member specialization is in class scope.

<P>Was it the intent of the committee to forbid the construction above?
(Note that A itself is not a template.) If so, why?</P>

<P>
<B>Proposed resolution (04/01):</B> In-class specializations
of member templates are not allowed. In
13.9.4 [<A href="https://wg21.link/temp.expl.spec#17">temp.expl.spec</A>] paragraph 17,
 replace</P>

<BLOCKQUOTE>
If the declaration of an explicit specialization for such a member
appears in namespace scope...
</BLOCKQUOTE>

with

<BLOCKQUOTE>
In an explicit specialization for such a member...
</BLOCKQUOTE>

<P><B>Notes from 04/00 meeting:</B></P>

<P>This issue was kept in "review" status for two major reasons:</P>

<OL>

<LI>It's not clear that a change is actually needed.  All uses of the
phrase "in the namespace" in the IS mean "directly in the namespace,"
not in a scope nested within the namespace.</LI>

<LI>There was substantial sentiment for actually adding support for
in-class specializations at a future time, and it might be perceived
as a reversal of direction to pass a change aimed at reinforcing the
absence of the feature, only to turn around afterward and add it.</LI>

</OL>

<P><B>Notes from 10/00 meeting:</B></P>

<P>The core working group felt that the value of additional
clarity here outweighs the potential disadvantages that were noted
at the preceding meeting.</P>

<BR><BR>
</BODY>
</HTML>
