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

29 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[namespace.unnamed]
# 9 Declarations [[dcl]](./#dcl)
## 9.9 Namespaces [[basic.namespace]](basic.namespace#namespace.unnamed)
### 9.9.2 Namespace definition [[namespace.def]](namespace.def#namespace.unnamed)
#### 9.9.2.2 Unnamed namespaces [namespace.unnamed]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8373)
An [*unnamed-namespace-definition*](namespace.def.general#nt:unnamed-namespace-definition "9.9.2.1General[namespace.def.general]") behaves as if it were
replaced by
inlineopt namespace *unique* { /* empty body */ }
using namespace *unique* ;
namespace *unique* { [*namespace-body*](namespace.def.general#nt:namespace-body "9.9.2.1General[namespace.def.general]") }
whereinline appears if and only if it appears in the[*unnamed-namespace-definition*](namespace.def.general#nt:unnamed-namespace-definition "9.9.2.1General[namespace.def.general]") 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[.](#1.sentence-1)
The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1Attribute syntax and semantics[dcl.attr.grammar]") in the [*unnamed-namespace-definition*](namespace.def.general#nt:unnamed-namespace-definition "9.9.2.1General[namespace.def.general]") appertains to *unique*[.](#1.sentence-2)
[*Example [1](#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*]