Skip to content

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

Closed
@RealLitb

Description

@RealLitb

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.

Activity

jensmaurer

jensmaurer commented on Mar 6, 2017

@jensmaurer
Member

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

RealLitb

RealLitb commented on Mar 7, 2017

@RealLitb
Author

Sure:

struct X { X(); };
struct B { operator X(); };
B b;
X x{{b}};         // error: X(X&&) and X(const X&) are not viable
changed the title [-]16[over.best.ics]p4 contains an irrelevant example (?)[/-] [+][over.best.ics]p4 contains an irrelevant example[/+] on Mar 14, 2017
jensmaurer

jensmaurer commented on Nov 30, 2017

@jensmaurer
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.

self-assigned this
on Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @RealLitb@jensmaurer

      Issue actions

        [over.best.ics]p4 contains an irrelevant example · Issue #1517 · cplusplus/draft