cplusplus / cplusplus/draft

[basic.lookup.qual.general] p2 Improve the definition of a member-qualified name

Open
#5,127 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

In the current draft, the definition of a member-qualified name is that

A member-qualified name is the (unique) component name ([expr.prim.id.unqual]), if any, of

  • an unqualified-id or
  • a nested-name-specifier of the form type-name ​::​ or namespace-name ​::​

in the id-expression of a class member access expression ([expr.ref]).

Here, "in" can be interpreted by its English meaning, which can result in an issue arisen from this example

struct C{
    int member;
};
struct D:C{};
struct E:D{};
struct F:E{};
int main(){
   E e;
   e.F::D::C::member = 0;  // #1
}

the id-expression of the class member access expression at #1 is F::D::C::member obeying the grammar nested-name-specifier template opt unqualified-id , that is, member is the unqualified-id in this id-expression of the class member access expression. Does it mean member is a member-qualified name? It seems this is not the intent of that rule. Conversely, F can be a member-qualified name since the nested-name-specifier to which it belongs obeys the form type-name ​::​ and is in the id-expression.

My opinion is that the above rule may be improved to be that

A member-qualified name is the (unique) component name ([expr.prim.id.unqual]), if any, of

  • an unqualified-id that is the id-expression or
  • a nested-name-specifier of the form type-name ​::​ or namespace-name ​::​ in the id-expression

of a class member access expression ([expr.ref]).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the [basic.lookup.qual.general] definition and the F::D::C::member example at #1. Check the proposed wording against the distinction between an unqualified-id that is the id-expression and a nested-name-specifier in that expression; done means the definition is unambiguous about which components are member-qualified names.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.