Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[over.best.ics]p4 contains an irrelevant example #1517

Closed
RealLitb opened this issue Mar 5, 2017 · 3 comments
Closed

[over.best.ics]p4 contains an irrelevant example #1517

RealLitb opened this issue Mar 5, 2017 · 3 comments
Assignees

Comments

@RealLitb
Copy link

RealLitb commented Mar 5, 2017

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

  1. The move and copy constructor is not a candidate by
    [over.match.list] but by [over.match.ctor]
  2. 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.

@jensmaurer
Copy link
Member

Could you show the full (modified) code you want to see for the example?

@RealLitb
Copy link
Author

RealLitb commented Mar 7, 2017

Sure:

struct X { X(); };
struct B { operator X(); };
B b;
X x{{b}};         // error: X(X&&) and X(const X&) are not viable

@jensmaurer jensmaurer changed the title 16[over.best.ics]p4 contains an irrelevant example (?) [over.best.ics]p4 contains an irrelevant example Mar 14, 2017
@jensmaurer
Copy link
Member

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants