<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1151</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="1151"></A><H4>1151.
  
Overload resolution with initializer-list and non-list constructors
</H4>
<B>Section: </B>12.2.2.8&#160; [<A href="https://wg21.link/over.match.list">over.match.list</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++11
 &#160;&#160;&#160;

 <B>Submitter: </B>US
 &#160;&#160;&#160;

 <B>Date: </B>2010-08-03<BR><BR>


<P>[Voted into the WP at the March, 2011 meeting as part of paper N3262.]</P>

<A href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3296.html#US66">N3092 comment
  US&#160;66<BR></A>

<P>Overload resolution should first look for a viable list
constructor, then look for a non-list constructor if no list
constructor is viable.</P>

<P><B>Proposed resolution (August, 2010) [SUPERSEDED]:</B></P>

<OL>
<LI><P>Change 9.5.5 [<A href="https://wg21.link/dcl.init.list#3.5">dcl.init.list</A>] bullet 3.5
as follows:</P></LI>

<UL><LI><P>Otherwise, if <TT>T</TT> is a class type,
constructors are considered. <DEL>If <TT>T</TT> has an
initializer-list constructor, the argument list consists of
the initializer list as a single argument; otherwise, the
argument list consists of the elements of the initializer
list.</DEL> The applicable constructors are enumerated
<DEL>(12.2.2.8 [<A href="https://wg21.link/over.match.list">over.match.list</A>])</DEL> and the best one
is chosen through overload resolution (<INS>12.2.2.8 [<A href="https://wg21.link/over.match.list">over.match.list</A>],</INS> 12.2 [<A href="https://wg21.link/over.match">over.match</A>]). If a
narrowing conversion (see below) is required to convert any
of the arguments, the program is ill-formed.
[<I>Example:</I>...</P></LI></UL>

<LI><P>Change 12.2.2.8 [<A href="https://wg21.link/over.match.list">over.match.list</A>] as follows:</P></LI>

<BLOCKQUOTE>

<P>When objects of non-aggregate class type
<INS><TT>T</TT></INS> are list-initialized (9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>]), overload resolution selects the constructor
<INS>in two phases</INS>
<DEL>as follows, where <TT>T</TT> is the cv-unqualified class
type of the object being initialized</DEL>:</P>

<UL>
<LI><P>
<DEL>If <TT>T</TT> has an initializer-list
constructor (9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>]),</DEL>
<INS>Initially, the candidate functions are the
initializer-list constructors (9.5.5 [<A href="https://wg21.link/dcl.init.list">dcl.init.list</A>])
of the class <TT>T</TT> and</INS> the argument list consists
of the initializer list as a single argument<INS>.</INS>
</P></LI>

<LI><P>
<DEL>; otherwise,</DEL> <INS>If no viable
initializer-list constructor is found, overload resolution is
performed again, where the candidate functions are all the
constructors of the class <TT>T</TT> and</INS> the
argument list consists of the elements of the initializer
list.</P></LI>

<LI><P><DEL>For direct-list-initialization, the candidate
functions are all the constructors of the class
<TT>T</TT>.</DEL></P></LI>

</UL>

<P>
<DEL>For</DEL> <INS>In</INS>
copy-list-initialization, <DEL>the candidate functions are
all the constructors of <TT>T</TT>.  However,</DEL> if an
<TT>explicit</TT> constructor is chosen, the initialization
is ill-formed. [<I>Note:</I> <INS>This differs from other
situations (12.2.2.4 [<A href="https://wg21.link/over.match.ctor">over.match.ctor</A>], 12.2.2.5 [<A href="https://wg21.link/over.match.copy">over.match.copy</A>]), where only converting constructors are
considered for copy-initialization.</INS> This restriction
only applies if this initialization is part of the final
result of overload resolution<INS>.</INS> &#8212;<I>end
note</I>]</P>

</BLOCKQUOTE>

</OL>

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