<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2507</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="2507"></A><H4>2507.
  
Default arguments for <TT>operator[]</TT>
</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>CD6
 &#160;&#160;&#160;

 <B>Submitter: </B>Jens Maurer
 &#160;&#160;&#160;

 <B>Date: </B>2021-12-07<BR>


<P>[Accepted at the July, 2022 meeting.]</P>

<P>The intent of paper P2128R6, which permitted multiple
parameters in overloaded subscript operators and was adopted
at the October, 2021 plenary, was that
overloaded <TT>operator[]</TT> should allow parameters with
default arguments. However, the adopted wording did not
address the following restriction from 12.4.1 [<A href="https://wg21.link/over.oper.general#10">over.oper.general</A>] paragraph 10:
</P>

<BLOCKQUOTE>

An operator function cannot have default arguments
(9.3.4.7 [<A href="https://wg21.link/dcl.fct.default">dcl.fct.default</A>]), except where explicitly
stated below.

</BLOCKQUOTE>

<P>Similar wording to that of <TT>operator()</TT> should
be added for <TT>operator[]</TT>.</P>

<P><B>Proposed resolution (December, 2021):</B></P>

<P>Change 12.4.5 [<A href="https://wg21.link/over.sub#1">over.sub</A>] paragraph 1 as follows:</P>

<BLOCKQUOTE>

A <I>subscripting operator function</I> is a function
named <TT>operator[]</TT> that is a non-static member
function <INS>with an arbitrary number of parameters.
It may have default arguments</INS>. For an expression...

</BLOCKQUOTE>



<P><B>Approved by EWG 2022-04-14.</B></P>

<P><B>Approved by CWG 2022-04-22.</B></P>

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