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

Can we flatten the list in [dcl.init.ref]p5 #1750

Closed
tkoeppe opened this issue Sep 17, 2017 · 5 comments
Closed

Can we flatten the list in [dcl.init.ref]p5 #1750

tkoeppe opened this issue Sep 17, 2017 · 5 comments
Milestone

Comments

@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 17, 2017

Consider [dcl.init.ref]/(5.2.2.2), which is a list item containing a paragraph break. The entire nested list seems overly complex.

Suggestion from @zygoloid is to consider flattening the list by replacing nested "otherwise"s with "if not X, the program is ill-formed", which allows the subsequent conditions to appear at the same level of hierarchy.

@tkoeppe tkoeppe added this to the C++20 milestone Sep 17, 2017
@jensmaurer
Copy link
Member

@tkoeppe: The list seems a little less daunting these days, except that the last bullet could probably be un-nested.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 13, 2018
@zygoloid
Copy link
Member

This can be made somewhat less confusing by moving the "If T1 is reference-related to T2" and its two bullets inside the previous bullet (5.4.2 currently). It does not apply to bullet 5.4.1 because that says "If [...] T1 is not reference-related to T2, [...]".

But we don't want to convert 5.4.1 and 5.4.2 to higher-level bullets, because we think that the "In all cases except the last, [...]" wording below intends to refer to all of 5.4, and converting those bullets to being 5.4 and 5.5 would further obscure the meaning of that sentence.

@zygoloid zygoloid removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Mar 18, 2018
@cpplearner
Copy link
Contributor

cpplearner commented Apr 20, 2018

Is "bind directly" correctly defined? Consider this example (simplified from the example that follows [dcl.init.ref]/(5.3.2)):

struct B { };
struct X {
  operator B();
} x;
B&& rrb = x;                        // bound directly to the result of `operator B`

This reference initialization matches 5.3.2, and so is considered as binding directly. But isn't it implicitly converting the initializer expression (x) to the underlying type of the reference (B)? Should it match 5.4.1 instead?

@cpplearner
Copy link
Contributor

Ah, 5.3.2 uses [over.match.ref] while 5.4.1 uses [over.match.copy] or [over.match.conv]. So initialization by conversion function is "direct reference binding", while similar conversion by constructor is not 😕

struct B { B(struct X); };
struct X { } x;
B&& rrb = x; // bound indirectly

@zygoloid
Copy link
Member

The original problem has been addressed by converting some bullet nesting to an "otherwise, ill-formed" bullet. Further rework here seems possible, but should probably be conducted by CWG.

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

4 participants