Title
Overload resolution with initializer-list and non-list constructors
Status
c++11
Section
12.2.2.8 [over.match.list]
Submitter
US

Created on 2010-08-03.00:00:00 last changed 123 months ago

Messages

Date: 2011-03-15.00:00:00

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

Date: 2010-08-15.00:00:00

Proposed resolution (August, 2010) [SUPERSEDED]:

  1. Change 9.4.5 [dcl.init.list] bullet 3.5 as follows:

    • Otherwise, if T is a class type, constructors are considered. If T 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. The applicable constructors are enumerated (12.2.2.8 [over.match.list]) and the best one is chosen through overload resolution (12.2.2.8 [over.match.list], 12.2 [over.match]). If a narrowing conversion (see below) is required to convert any of the arguments, the program is ill-formed. [Example:...

  2. Change 12.2.2.8 [over.match.list] as follows:

  3. When objects of non-aggregate class type T are list-initialized (9.4.5 [dcl.init.list]), overload resolution selects the constructor in two phases as follows, where T is the cv-unqualified class type of the object being initialized:

    • If T has an initializer-list constructor (9.4.5 [dcl.init.list]), Initially, the candidate functions are the initializer-list constructors (9.4.5 [dcl.init.list]) of the class T and the argument list consists of the initializer list as a single argument.

    • ; otherwise, If no viable initializer-list constructor is found, overload resolution is performed again, where the candidate functions are all the constructors of the class T and the argument list consists of the elements of the initializer list.

    • For direct-list-initialization, the candidate functions are all the constructors of the class T.

    For In copy-list-initialization, the candidate functions are all the constructors of T. However, if an explicit constructor is chosen, the initialization is ill-formed. [Note: This differs from other situations (12.2.2.4 [over.match.ctor], 12.2.2.5 [over.match.copy]), where only converting constructors are considered for copy-initialization. This restriction only applies if this initialization is part of the final result of overload resolution.end note]

Date: 2010-08-03.00:00:00
N3092 comment US 66

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

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3373
2011-04-10 00:00:00adminsetstatus: ready -> fdis
2010-11-29 00:00:00adminsetstatus: review -> ready
2010-08-23 00:00:00adminsetmessages: + msg2831
2010-08-03 00:00:00admincreate