-
Notifications
You must be signed in to change notification settings - Fork 782
[expr.mptr.oper] Clarify pointer-to-member operators. #4733
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
Open
jensmaurer
wants to merge
1
commit into
cplusplus:main
Choose a base branch
from
jensmaurer:c5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jensmaurer Maybe, we should say that
In order to make the name lookup rule can uniformed work here; for instance, in a derived class, there is a member with the name
m
hides the member of the same name declared in the base class. The purpose of this utterance prevents the lookup rule from recklessly starting to perform in the scope associated with the object expression.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think name lookup considerations are not really relevant here. I say "EM must name a member of T" below; plus EM has a unique name (it's hypothetical / invented), so there is no hiding in view.
All that's relevant is the type of EM and the fact it's non-static and non-mutable; everything else falls out of the expr.ref rules.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that the expression
E1.EM
can additionally state what the result is, after all, [expr.mptr.oper#2] merely says "The result is an object or a function of the type X", but it didn't specify which object or function is it, which needs the help of the relevant rule about the result ofE1.EM
cited below. Except for that, the original utterance is ok for stating type.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I think the paragraph [expr.mptr.oper#5] should be changed to that
Now, the [expr.mptr.oper#5] specifies all the respects regard the result of expression
E1.*E2
(e.g, which object or function does the result denote).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't we just say "E2 points to" instead of "the value of E2 points to"? It's a pointer, it points to things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E2 is an expression, so it presumably it has a value.
That said, I note that @xmh0511 also laments the absence of a specification what the result value actually is, so some massaging to the original wording is probably necessary. I would like to avoid talking in "identifiers" for anything but finding out the cv-qualification of the result type, if we can help it. There's too much name lookup / virtual function etc baggage around "identifier".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to use "the value of E2" to avoid a similar issue mentioned in #4662 (comment). But, it seems you're right that the meaning is unambiguous if using "E2 points to". However, the benefit of using "the value of ..." is that it implies the
lvalue-to-rvalue
conversion shall be applied to the operand(if necessary), which is also under-specified in many sections in [expr].Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jensmaurer Not strictly, a pointer to member records the information of the entity and its class, hence I think that we use
T::m
is equivalent to use the entity pointed to by the pointer to member in most respects. The exception is the virtual function, which has been listed in the proposed wording. IMHO, the wording could probably cover all cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider the second operand may result from Pointer-to-member conversions, I think we should separate [expr.mptr.oper#2] into two parts; One part phrases type of the result, the other phrases the entity of the result. Since the wording about the type of the result in the current changed file is ok, we should pay attention to the entity designated by the result.
Since the relevant rule defined in [conv.mem]
So, even if the operand E2 is taken from the result of Pointer-to-member conversions, its value still refers to the original member, which is the entity that E1.*E2 designates.