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

"a possibly const value of type X" #1497

Open
jensmaurer opened this issue Mar 2, 2017 · 15 comments · Fixed by #1563
Open

"a possibly const value of type X" #1497

jensmaurer opened this issue Mar 2, 2017 · 15 comments · Fixed by #1563
Assignees

Comments

@jensmaurer
Copy link
Member

jensmaurer commented Mar 2, 2017

Change to "a value of type X or const X."

(library clauses)

26.2.6

@jensmaurer
Copy link
Member Author

What about "non-const value of type X" and similar phrasings? They also look wrong.

@hubert-reinterpretcast
Copy link
Contributor

For the "non-const value of type X" cases, I am not sure it is immediately clear that X cannot be a const-qualified type. Thus, LWG should probably inform as to whether remove_const_t was meant, or if "type X (X possibly being const)" was meant, or if "type X (X being non-const)" was meant.

@jwakely
Copy link
Member

jwakely commented Mar 2, 2017

"non-const value of type X" means a value of type X where X must be non-const.

@jwakely
Copy link
Member

jwakely commented Mar 2, 2017

For the container requirements tables we could define X as a non-const container type in the first place, then simply "type X" would mean the non-const case, and then when we want to talk about operations that are valid on const or non-const objects we can say "of type X or const X".

@jwakely
Copy link
Member

jwakely commented Mar 2, 2017

e.g. "X denotes a container class of a non-const type, containing objects of type T" (I would prefer not to say "denotes a non-const container class" in case someone thinks that implies there are such things as "const containers" and "non-const containers".

For table 86 "t denotes an lvalue or a const rvalue of type X" would become "t denotes an lvalue of type X or an rvalue of type const X" and so on.

@jensmaurer
Copy link
Member Author

This will likely cause editing conflicts with #117.

@jwakely
Copy link
Member

jwakely commented Sep 14, 2017

Do we agree that this change is correct and desirable (but not being done at this time)?

Because I made the same edits in the Networking TS and @mclow has questioned the validity of the change, as they weren't made by any approved motion. I consider it an editorial correction, assuming this issue is correct.

@jensmaurer
Copy link
Member Author

jensmaurer commented Sep 14, 2017

I agree that "const" applies to a type, not to a value (although a value has a type), and thus rephrasing this in terms of types is good. The remaining question is whether the X in "X or const X" phrasings might be const to start with. I don't remember whether we've got clearer phrasing the core language sections for this, and also for the distinction "X shall not be a cv-qualified type" vs. "remove top-level cv-qualifiers from X". Right now, C++17 is top priority, though.

@mclow
Copy link
Contributor

mclow commented Sep 14, 2017

Personally, I think the existing phrasing in the library requirements sections

a and b denote values of type (possibly const) P

is more clear than

a value of type X or const X.

But if you and Jens think that's not correct and the latter is preferable, I can live with that.

@jensmaurer
Copy link
Member Author

@mclow: The issue here is "a possibly const value of X". And that seems plain wrong (26.2.6p8). I do recognize "values of type (possibly const) P" is used in the library section, and that's an improvement, while still concise. I don't really fancy the repetition of X in "of type X or const X".

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

I think "of type (possibly const) P" is less clear: it can be read as saying "of type P (where P is possibly const)". Whereas "of type P or const P" does not admit such a misinterpretation. Let's try that and see how it looks.

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

tkoeppe commented Sep 9, 2022

Let's keep this issue open, as there is unresolved discussion in #1563 and a related LWG issue.

@tkoeppe tkoeppe reopened this Sep 9, 2022
@tkoeppe
Copy link
Contributor

tkoeppe commented Sep 9, 2022

And @jensmaurer asked:

I wish we had some shorthand along the lines of "value of type cv X" or so.

@jwakely
Copy link
Member

jwakely commented Sep 9, 2022

We don't want to include volatile, but I think we already have other places in the library where we say cv T and mean possibly const T.

@jwakely
Copy link
Member

jwakely commented Sep 9, 2022

We also have a mix of "T or const T" and "(possibly const) T" which isn't the end of the world, but could be harmonised.

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

Successfully merging a pull request may close this issue.

6 participants