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

[dcl.init.ref] Cv-qualification adjustments before temporary materialization CWG2657 #5821

Open
frederick-vs-ja opened this issue Sep 9, 2022 · 0 comments

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Sep 9, 2022

[dcl.init.ref]/5 mentions "temporary materialization" twice in (5.3) and (5.4.2). Both appears alongwith cv-qualification adjustments.

If the converted initializer is a prvalue, its type T4 is adjusted to type “cv1 T4” ([conv.qual]) and the temporary materialization conversion ([conv.rval]) is applied.

The temporary materialization conversion is applied, considering the type of the prvalue to be “cv1 T1”, and the reference is bound to the result.

The adjustments in 5.4.2 was added via CWG2481, and it's clear that in the case of 5.4.2, the cv-qualification won't be stripped.

Are the adjustments in 5.3 (pre-existing in published C++17) samely treated? If so, should we make wording for these adjustments more consistent? (Or just say it once?)


BTW, consider these following definitions.

const int& ref1 = 42;
const int& ref2 = 42L;

It's clear that the definition of ref2 falls into the case of [dcl.init.ref]/(5.4.2). However, it seems that the definition of ref1 is handled by [dcl.init.ref]/(5.3.1) (because it's "rvalue" but not "xvalue" that is used in 5.3.1).

Is it intended that they fall in different cases while the treatments should be very similar?

(These are raised from a question on Stack Overflow).


This is now CWG2657.

@frederick-vs-ja frederick-vs-ja changed the title [dcl.init.ref] Cv-qualification adjustments before temporary materialization [dcl.init.ref] Cv-qualification adjustments before temporary materialization CWG2657 Nov 29, 2022
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

1 participant