New wording for [namespace.memdef] / 1

I believe the new wording [namespace.memdef] / 1 is trying to explain the conflict between the two declarations using M::g; and void g(); in the X namespace, but I do not understand the relationship between this new formulation and the intended conflict.

A declaration in the namespace N (excluding declarations in nested scopes) whose identifier identifier is unqualified-id ([dcl.meaning]), whose class is head-name (section [class]) or name-name-name ([dcl .enum]) is an identifier or qualifier of the developed type, it has the form class-key attribute-specifier-seq opt identifier ([dcl.type.elab]), or is it an opaque declaration that declares (or overrides) its unqualified identifier or identifier as a member N [Note: Explicit instantiation ([temp.explicit]) or explicit specialization ([temp.expl.spec]) of a template does not enter a name and therefore can be declared using an unqualified identifier in a member namespace if the main template is declared in line namespace. - end note] [Example:

 namespace X { void f() { /* ... */ } // OK: introduces Xโ€‹::โ€‹f() namespace M { void g(); // OK: introduces Xโ€‹::โ€‹Mโ€‹::โ€‹g() } using M::g; void g(); // error: conflicts with Xโ€‹::โ€‹Mโ€‹::โ€‹g() } 

- end of example]

Even when I look at DR 1838 , which probably gave rise to a change in this paragraph, I have some problems that the following sentence understands (emphasis mine):

It is not clear in the standard what happens when an entity is declared but not defined in the internal namespace and declared through using-declaration in the external namespace and the definition of an object with a name such as unqualified-id appears in the external Namespace. Is this a legal definition of the internal namespace as it would be if the definition used an identifier with qualifications or the definition is a member of the external namespace and, therefore, the conflict with the use of the declaration-declaration? There is a divergence of implementation for processing such definitions.

The example following this sentence is exactly the same as in [namespace.memdef]/1 . I highlighted the word definition above, because in the above example there is no definition for the function X::g() . What am I missing?

+5
source share

Source: https://habr.com/ru/post/1263279/


All Articles