This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-11-11
Consider:
#include <initializer_list>
struct A { A(int) {} };
void f(int) = delete;
void f(std::initializer_list<A>) {} // #1
int main() { f({10}); }
The intent of issue 1467 was to make this example well-formed by choosing #1, according to this rule and a corresponding example in 12.2.4.3 [over.ics.rank] bullet 3.1:
- List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if
even if one of the other rules in this paragraph would otherwise apply.
- L1 converts to std::initializer_list<X> for some X and L2 does not, or, if not that,
- ...
- ...
See also issue 2137 and gcc issue 64665.
Possible resolution:
Move 12.2.4.3 [over.ics.rank] paragraph 2 into paragraph 3 as follows:
When comparing the basic forms of implicit conversion sequences (as defined in 12.2.4.2 [over.best.ics])
- a standard conversion sequence (12.2.4.2.2 [over.ics.scs]) is a better conversion sequence than a user-defined conversion sequence or an ellipsis conversion sequence, and
- a user-defined conversion sequence (12.2.4.2.3 [over.ics.user]) is a better conversion sequence than an ellipsis conversion sequence (12.2.4.2.4 [over.ics.ellipsis]).
Two implicit conversion sequences
of the same formare indistinguishable conversion sequences unless one of the following rules applies:
- List-initialization sequence L1 is a better conversion sequence than list-initialization sequence L2 if
- L1 converts to std::initializer_list<X> for some X and L2 does not, or, if not that,
- ...
even if one of the other rules in this paragraph would otherwise apply.- Otherwise, a standard conversion sequence (12.2.4.2.2 [over.ics.scs]) is a better conversion sequence than a user-defined conversion sequence or an ellipsis conversion sequence, and
- a user-defined conversion sequence (12.2.4.2.3 [over.ics.user]) is a better conversion sequence than an ellipsis conversion sequence (12.2.4.2.4 [over.ics.ellipsis]).
- Standard conversion sequence S1 is a better conversion sequence than ...