<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2931</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="2931"></A><H4>2931.
  
Restrictions on operator functions that are explicit object member functions
</H4>
<B>Section: </B>12.4.1&#160; [<A href="https://wg21.link/over.oper.general">over.oper.general</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Barry Revzin
 &#160;&#160;&#160;

 <B>Date: </B>2024-08-26<BR>


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

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

<P>With the introduction of explicit object member functions, the
restrictions on operator functions became inconsistent.  Subclause
12.4.1 [<A href="https://wg21.link/over.oper.general#7">over.oper.general</A>] paragraph 7 specifies:</P>

<BLOCKQUOTE>

An operator function shall either
<UL>
<LI>be a member function or</LI>
<LI>be a non-member function that has at least one non-object
parameter whose type is a class, a reference to a class, an
enumeration, or a reference to an enumeration.</LI>
</UL>

</BLOCKQUOTE>

<P>Talking about non-object parameters in a bullet discussing
non-member functions makes no sense.  The following example ought to
be prohibited, for consistency with <TT>operator==(int, int)</TT>:</P>

<PRE>
  struct B {
    bool operator==(this int, int);
    operator int() const;
  };
</PRE>

<P><B>Proposed resolution (approved by CWG 2024-11-22):</B></P>

<P>Change in 12.4.1 [<A href="https://wg21.link/over.oper.general#7">over.oper.general</A>] paragraph 7 as follows, removing
the bullets:</P>

<BLOCKQUOTE>

An operator function shall <DEL>either</DEL>
<UL>
<LI><DEL>be a member function or</DEL></LI>
<LI>
<DEL>be a non-member function that has</DEL> <INS>have</INS> at
least one <DEL>non-object</DEL> <INS>function</INS> parameter <INS>or
implicit object parameter</INS> whose type is a class, a reference to
a class, an enumeration, or a reference to an enumeration.</LI>
</UL>

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