<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1435</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="1435"></A><H4>1435.
  
<I>template-id</I> as the declarator for a class template constructor
</H4>
<B>Section: </B>9.3.4&#160; [<A href="https://wg21.link/dcl.meaning">dcl.meaning</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Johannes Schaub
 &#160;&#160;&#160;

 <B>Date: </B>2011-12-24<BR>


<P>[Moved to DR at the April, 2013 meeting.]</P>



<P>The status of a declaration like the following is unclear:</P>

<PRE>
  template&lt;typename T&gt; struct A {
    A&lt;T&gt;();
  };
</PRE>

<P>9.3.4 [<A href="https://wg21.link/dcl.meaning#1">dcl.meaning</A>] paragraph 1 appears to say that it is
not allowed, but it is not clear.</P>

<P><B>Proposed resolution (October, 2012):</B></P>

<OL>
<LI><P>Change 9.3.4 [<A href="https://wg21.link/dcl.meaning#1">dcl.meaning</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

A list of declarators appears after an optional (9.1 [<A href="https://wg21.link/dcl.pre">dcl.pre</A>])
<I>decl-specifier-seq</I> (9.2 [<A href="https://wg21.link/dcl.spec">dcl.spec</A>]).  Each declarator
contains exactly one <I>declarator-id</I>; it names the identifier
that is declared. An <I>unqualified-id</I> occurring in a
<I>declarator-id</I> shall be a simple <I>identifier</I> except for
the declaration of some special functions (<INS>11.4.5 [<A href="https://wg21.link/class.ctor">class.ctor</A>],</INS> 11.4.8 [<A href="https://wg21.link/class.conv">class.conv</A>], 11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>], 12.4 [<A href="https://wg21.link/over.oper">over.oper</A>]) and for the declaration of
template specializations or partial specializations (13.9 [<A href="https://wg21.link/temp.spec">temp.spec</A>]).  A <I>declarator-id</I> shall not...

</BLOCKQUOTE>

<LI><P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#1">class.ctor</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

<P>Constructors do not have names.  <DEL>A special declarator syntax is
used to declare or define the constructor.  The syntax uses:</DEL>
</P>

<UL>
<LI><P><DEL>an optional <I>decl-specifier-seq</I> in which each
<I>decl-specifier</I> is either a <I>function-specifier</I> or
<TT>constexpr</TT>,</DEL></P></LI>

<LI><P><DEL>the constructor's class name, and</DEL></P></LI>

<LI><P><DEL>a parameter list</DEL></P></LI>

</UL>

<P>
<DEL>in that order. In such a declaration, optional parentheses
around the constructor class name are ignored.</DEL> <INS>A
declaration of a constructor uses a function declarator (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]) of the form</INS>
</P>

<UL><INS><I>ptr-declarator</I> <TT>(</TT> <I>parameter-declaration-clause</I> <TT>)</TT> <I>exception-specification<SUB>opt</SUB> attribute-specifier-seq<SUB>opt</SUB></I></INS></UL>

<P><INS>where the <I>ptr-declarator</I> consists solely of an
<I>id-expression</I>, an optional <I>attribute-specifier-seq</I>, and
optional surrounding parentheses, and the <I>id-expression</I> has
one of the following forms:</INS></P>

<UL>
<LI><P><INS>in a <I>member-declaration</I> that belongs to the
<I>member-specification</I> of a class but is not a friend declaration
(11.8.4 [<A href="https://wg21.link/class.friend">class.friend</A>]), the <I>id-expression</I> is the
injected-class-name (Clause 11 [<A href="https://wg21.link/class">class</A>]) of the
immediately-enclosing class;</INS></P></LI>

<LI><P><INS>in a <I>member-declaration</I> that belongs to the
<I>member-specification</I> of a class template but is not a friend
declaration, the <I>id-expression</I> is a <I>class-name</I> that
names the current instantiation (13.8.3.2 [<A href="https://wg21.link/temp.dep.type">temp.dep.type</A>]) of the
immediately-enclosing class template; or</INS></P></LI>

<LI><P><INS>in a declaration at namespace scope or in a friend declaration, the
<I>id-expression</I> is a <I>qualified-id</I> that names a constructor
(6.5.5.2 [<A href="https://wg21.link/class.qual">class.qual</A>]).</INS></P></LI>

</UL>

<P>
<INS>The <I>class-name</I> shall not be a
<I>typedef-name</I>.  In a constructor declaration, each
<I>decl-specifier</I> in the optional <I>decl-specifier-seq</I> shall
be <TT>friend</TT>, <TT>inline</TT>, <TT>explicit</TT>, or
<TT>constexpr</TT>.</INS> [<I>Example:</I>...</P>

</BLOCKQUOTE>

<LI><P>Delete 11.4.5 [<A href="https://wg21.link/class.ctor#3">class.ctor</A>] paragraph 3:</P></LI>

<BLOCKQUOTE>

<DEL>A <I>typedef-name</I> shall not be used as the <I>class-name</I> in
the <I>declarator-id</I> for a constructor declaration.</DEL>

</BLOCKQUOTE>

<LI><P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#4">class.ctor</A>] paragraph 4 as follows:</P></LI>

<BLOCKQUOTE>

<DEL>A constructor shall not be <TT>virtual</TT> (11.7.3 [<A href="https://wg21.link/class.virtual">class.virtual</A>]) or <TT>static</TT> (11.4.9 [<A href="https://wg21.link/class.static">class.static</A>]).</DEL> A
constructor can be invoked for a <TT>const</TT>, <TT>volatile</TT> or
<TT>const volatile</TT> object.  <DEL>A constructor shall not be
declared <TT>const</TT>, <TT>volatile</TT>, or <TT>const volatile</TT>
(_N4868_.11.4.3.2 [<A href="https://wg21.link/class.this">class.this</A>]).</DEL> <TT>const</TT> and
<TT>volatile</TT> semantics (9.2.9.2 [<A href="https://wg21.link/dcl.type.cv">dcl.type.cv</A>]) are not
applied on an object under construction.  They come into effect when
the constructor for the most derived object (6.8.2 [<A href="https://wg21.link/intro.object">intro.object</A>])
ends. <DEL>A constructor shall not be declared with a
<I>ref-qualifier</I>.</DEL>

</BLOCKQUOTE>

<LI><P>Change 11.4.5 [<A href="https://wg21.link/class.ctor#9">class.ctor</A>] paragraph 9 as follows:</P></LI>

<BLOCKQUOTE>

<DEL>No return type (not even <TT>void</TT>) shall be specified for a
constructor.</DEL> A <TT>return</TT> statement in the body of a
constructor shall not specify a return value. The address of a
constructor shall not be taken.

</BLOCKQUOTE>

<LI><P>Change 11.4.7 [<A href="https://wg21.link/class.dtor">class.dtor</A>] paragraphs 1-2 as follows:</P></LI>

<BLOCKQUOTE>

<P>
<DEL>A special declarator syntax using an optional
<I>function-specifier</I> (9.2.3 [<A href="https://wg21.link/dcl.fct.spec">dcl.fct.spec</A>]) followed by
<TT>~</TT> followed by the destructor's class name followed by an
empty parameter list is used to declare the destructor in a class
definition.  In such a declaration, the <TT>~</TT> followed by the
destructor's class name can be enclosed in optional parentheses; such
parentheses are ignored.  A <I>typedef-name</I> shall not be used as
the class-name following the <TT>~</TT> in the declarator for a
destructor declaration.</DEL> <INS>A declaration of a destructor uses a
function declarator (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]) of the form</INS>
</P>

<UL><INS><I>ptr-declarator</I> <TT>(</TT> <I>parameter-declaration-clause</I> <TT>)</TT> <I>exception-specification<SUB>opt</SUB> attribute-specifier-seq<SUB>opt</SUB></I></INS></UL>

<P><INS>where the <I>ptr-declarator</I> consists solely of an
<I>id-expression</I>, an optional <I>attribute-specifier-seq</I>,
and optional surrounding parentheses, and the <I>id-expression</I> has
one of the following forms:</INS></P>

<UL>
<LI><P><INS>in a <I>member-declaration</I> that belongs to the
<I>member-specification</I> of a class but is not a friend declaration
(11.8.4 [<A href="https://wg21.link/class.friend">class.friend</A>]), the <I>id-expression</I> is
<TT>~</TT><I>class-name</I> and the <I>class-name</I> is the
injected-class-name (Clause 11 [<A href="https://wg21.link/class">class</A>]) of the
immediately-enclosing class;</INS></P></LI>

<LI><P><INS>in a <I>member-declaration</I> that belongs to the
<I>member-specification</I> of a class template but is not a friend
declaration, the <I>id-expression</I> is <TT>~</TT><I>class-name</I> and the
<I>class-name</I> names the current instantiation (13.8.3.2 [<A href="https://wg21.link/temp.dep.type">temp.dep.type</A>]) of the immediately-enclosing class template;
or</INS></P></LI>

<LI><P><INS>in a declaration at namespace scope or in a friend declaration, the
<I>id-expression</I> is <I>nested-name-specifier</I>
<TT>~</TT><I>class-name</I> and the <I>class-name</I> names the same
class as the <I>nested-name-specifier</I>.</INS></P></LI>

</UL>

<P><INS> The <I>class-name</I> shall not be a <I>typedef-name</I>.  A
destructor shall take no arguments (9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]).  In a
destructor declaration, each <I>decl-specifier</I> of the optional
<I>decl-specifier-seq</I> shall be <TT>friend</TT>, <TT>inline</TT>,
or <TT>virtual</TT>.</INS></P>

<P>A destructor is used to destroy objects of its class type. <DEL>A
destructor takes no parameters, and no return type can be specified
for it (not even <TT>void</TT>).</DEL> The address of a destructor
shall not be taken.  <DEL>A destructor shall not be
<TT>static</TT>.</DEL> A destructor can be invoked for a
<TT>const</TT>, <TT>volatile</TT> or <TT>const volatile</TT>
object. <DEL>A destructor shall not be declared <TT>const</TT>,
<TT>volatile</TT> or <TT>const volatile</TT> (_N4868_.11.4.3.2 [<A href="https://wg21.link/class.this">class.this</A>]).</DEL> <TT>const</TT> and <TT>volatile</TT> semantics
(9.2.9.2 [<A href="https://wg21.link/dcl.type.cv">dcl.type.cv</A>]) are not applied on an object under
destruction. They stop being in effect when the destructor for the
most derived object (6.8.2 [<A href="https://wg21.link/intro.object">intro.object</A>]) starts. <DEL>A
destructor shall not be declared with a
<I>ref-qualifier</I>.</DEL>
</P>

</BLOCKQUOTE>

<P>This resolution also resolves <A HREF="344.html">issue 344</A>.</P>

</OL>

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