Files
2025-10-25 03:02:53 +03:00

1.9 KiB
Raw Permalink Blame History

[namespace.unnamed]

9 Declarations [dcl]

9.9 Namespaces [basic.namespace]

9.9.2 Namespace definition [namespace.def]

9.9.2.2 Unnamed namespaces [namespace.unnamed]

1

#

An unnamed-namespace-definition behaves as if it were replaced by

inlineopt namespace unique { /* empty body */ }
using namespace unique ;
namespace unique { namespace-body }

whereinline appears if and only if it appears in theunnamed-namespace-definition and all occurrences of unique in a translation unit are replaced by the same identifier, and this identifier differs from all other identifiers in the program.

The optional attribute-specifier-seq in the unnamed-namespace-definition appertains to unique.

[Example 1: namespace { int i; } // unique::ivoid f() { i++; } // unique::i++namespace A {namespace {int i; // A::unique::iint j; // A::unique::j}void g() { i++; } // A::unique::i++}using namespace A;void h() { i++; // error: unique::i or A::unique::i A::i++; // A::unique::i j++; // A::unique::j} — end example]