0

On this site there is the following paragraph:

Out-of-namespace definitions and redeclarations are only allowed after the point of declaration, only at namespace scope, and only in namespaces that enclose the original namespace (including the global namespace) [and they must use qualified-id syntax (since C++14)]

I used [] to delimit the section that the (since C++14) construct refers to.

My question is how were out-of-namespace definitions made before C++14, if they did not have to use qualified-id syntax?

I looked at a C++11 standard draft and I found the following:

Members of a named namespace can also be defined outside that namespace by explicit qualification (3.4.3.2) 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. [...]

Is there a difference between qualified-id syntax and explicit qualification?

Thank you.

user42768
  • 1,951
  • 11
  • 22
  • 1
    Cppreference is just showing a (probably incorrect) summary of [CWG 1838](http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1838) – cpplearner Jul 19 '18 at 10:22
  • 2
    Looks like [Core Defect 1021](http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1021) might be relevant. (which relates to 1838 as mentioned by cpplearner^) – MSalters Jul 19 '18 at 10:22
  • Thank you both for your answers. So they explicitly say that one must `use qualified-id syntax` so that one is not allowed to make such a definition using a combination of `using` + `unqualified name definition`. Also, the resolution for defect 1838 also solves defect 1021. – user42768 Jul 19 '18 at 10:34
  • 1
    `namespace mine { void f(); } void mine::f() { /* whatever */ }`. – Pete Becker Jul 19 '18 at 11:32

0 Answers0