Skip to content

Nested-name-specifier is not mentioned for member definition outside its target scope #4592

@xmh0511

Description

@xmh0511

In c++20 standard, For the member functions or static member data which are these members that can be defined outside its enclosing class, it has a normative rule for how to define them outside the enclosing class, they are
For member functions
class#mfct-3

If the definition of a member function is lexically outside its class definition, the member function name shall be qualified by its class name using the ​::​ operator.

For static data member
class#static.data-3

In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the ​::​operator.

As well as the definition of members of a namespace
namespace.memdef#2

Members of a named namespace can also be defined outside that namespace by explicit qualification ([namespace.qual]) of the name being defined, provided that the entity being defined was already declared in the namespace and the definition appears after the point of declaration in a namespace that encloses the declaration's namespace.

I tried to find out the alternative normative rule in the current draft that can replace these omission rules, however, I don't find them out. Is it considered a bit radical modification that excises these rules?

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions