<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2846</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="2846"></A><H4>2846.
  
Out-of-class definitions of explicit object member functions
</H4>
<B>Section: </B>9.3.4.6&#160; [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Krystian Stasiowski
 &#160;&#160;&#160;

 <B>Date: </B>2024-01-28<BR>


<P>[Accepted as a DR at the March, 2024 meeting.]</P>

<P>(From submission
<A HREF="https://github.com/cplusplus/CWG/issues/493">#493</A>.)</P>

<P>Consider:</P>

<PRE>
  struct A {
    void f(this A&amp;);
  };
  void A::f(this A&amp;) { }    // <SPAN CLASS="cmnt">#1</SPAN>
</PRE>

<P>This is accepted by all major implementations.  However,
9.3.4.6 [<A href="https://wg21.link/dcl.fct#6">dcl.fct</A>] paragraph 6 specifies:</P>

<BLOCKQUOTE>

An <I>explicit-object-parameter-declaration</I> is
a <I>parameter-declaration</I> with a this specifier. An
explicit-object-parameter-declaration shall appear only as the
first <I>parameter-declaration</I> of
a <I>parameter-declaration-list</I> of either:
<UL>
<LI>a <I>member-declarator</I> that declares a member function
(11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]), or</LI>
<LI>a <I>lambda-declarator</I> (7.5.6 [<A href="https://wg21.link/expr.prim.lambda">expr.prim.lambda</A>]).</LI>
</UL>
A <I>member-declarator</I> with an
explicit-object-parameter-declaration shall not include
a <I>ref-qualifier</I> or a <I>cv-qualifier-seq</I> and shall not be
declared static or virtual.

</BLOCKQUOTE>

<P>The <I>function-definition</I> at #1 is neither of the two allowed
options.</P>

<P>Similar concerns arise for explicit instantiations and explicit
specializations.</P>

<P><B>Proposed resolution (approved by CWG 2024-02-16):</B></P>

<P>Change in 9.3.4.6 [<A href="https://wg21.link/dcl.fct#6">dcl.fct</A>] paragraph 6 as follows:</P>

<BLOCKQUOTE>

An <I>explicit-object-parameter-declaration</I> is
a <I>parameter-declaration</I> with a this specifier. An
explicit-object-parameter-declaration shall appear only as the
first <I>parameter-declaration</I> of a
<I>parameter-declaration-list</I> of <DEL>either</DEL> <INS>one of</INS>:
<UL>
<LI>a <DEL><I>member-declarator</I> that declares</DEL>
<INS>declaration of</INS> a member function <INS>or member function
template</INS> (11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]), or</LI>
<LI class="ins">an explicit instantiation
(13.9.3 [<A href="https://wg21.link/temp.explicit">temp.explicit</A>]) or explicit specialization
(13.9.4 [<A href="https://wg21.link/temp.expl.spec">temp.expl.spec</A>]) of a templated member function, or</LI>
<LI>a <I>lambda-declarator</I> (7.5.6 [<A href="https://wg21.link/expr.prim.lambda">expr.prim.lambda</A>]).</LI>
</UL>
A <I>member-declarator</I> with an
explicit-object-parameter-declaration shall not include
a <I>ref-qualifier</I> or a <I>cv-qualifier-seq</I> and shall not be
declared static or virtual.

</BLOCKQUOTE>

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