Description
Copying the content of my std-discussion message:
The aforementioned paragraph contains this example
struct X { };
struct B { operator X(); };
B b;
X x({b}); // error: B::operator X() is not a candidate
I think that is supposed to demonstrate the last bullet, "the second
phase of [over.match.list]
when the initializer list has exactly one
element ...". However there are at least two problems with the example
- The move and copy constructor is not a candidate by
[over.match.list]
but by[over.match.ctor]
- X is an aggregate, so the reason that
B::operator X
is not
considered is that it will never be evaluated as a potential
candidate.[over.match.ctor]
consideres those constructors and
[over.ics.list]
then for both constructors end up with "In all cases
other than those enumerated above, no conversion is possible.".
This has nothing to do with the points of 16[over.best.ics]p4
though,
so the example appears to be irrelevant to me. In order to fix this, I
think the example should use {{b}}
, and make X
a non-aggregate
class, if the example was really supposed to demonstrate the last
bullet of 16[over.best.ics]p4
.
Personally I also find it confusing that the comment says that B::operator X
is not a candidate, even though it is the move/copy constructor of X
that would immediately be affected by the rules, if I am not mistaken? But, I suspect that's more of a matter of taste.
Activity
jensmaurer commentedon Mar 6, 2017
Could you show the full (modified) code you want to see for the example?
RealLitb commentedon Mar 7, 2017
Sure:
[-]16[over.best.ics]p4 contains an irrelevant example (?)[/-][+][over.best.ics]p4 contains an irrelevant example[/+]jensmaurer commentedon Nov 30, 2017
[over.best.ics]p4 says "under these conditions (long list), user-defined conversion sequences are not considered." So, it seems the conversion function is the one "not considered", not the copy/move constructor for X. I do agree with the brace-init and aggregate changes, though.