55 lines
2.2 KiB
Markdown
55 lines
2.2 KiB
Markdown
[basic.namespace.general]
|
||
|
||
# 9 Declarations [[dcl]](./#dcl)
|
||
|
||
## 9.9 Namespaces [[basic.namespace]](basic.namespace#general)
|
||
|
||
### 9.9.1 General [basic.namespace.general]
|
||
|
||
[1](#1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8189)
|
||
|
||
A namespace is an optionally-named entity
|
||
whose scope can contain declarations of any kind of entity[.](#1.sentence-1)
|
||
|
||
The name of a
|
||
namespace can be used to access entities that belong to that namespace;
|
||
that is, the [*members*](#def:member,namespace "9.9.1 General [basic.namespace.general]") of the namespace[.](#1.sentence-2)
|
||
|
||
Unlike other entities,
|
||
the definition of a namespace can be split over several parts of one or
|
||
more translation units and modules[.](#1.sentence-3)
|
||
|
||
[2](#2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8199)
|
||
|
||
[*Note [1](#note-1)*:
|
||
|
||
A [*namespace-definition*](namespace.def.general#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") is exported
|
||
if it contains any[*export-declaration*](module.interface#nt:export-declaration "10.2 Export declaration [module.interface]")*s* ([[module.interface]](module.interface "10.2 Export declaration"))[.](#2.sentence-1)
|
||
|
||
A namespace is never attached to a named module
|
||
and never has a name with module linkage[.](#2.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[*Example [1](#example-1)*: export module M;namespace N1 {} // N1 is not exportedexport namespace N2 {} // N2 is exportednamespace N3 { export int n; } // N3 is exported â *end example*]
|
||
|
||
[3](#3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8216)
|
||
|
||
There is a [*global namespace*](#def:namespace,global "9.9.1 General [basic.namespace.general]") with no declaration;
|
||
see [[basic.scope.namespace]](basic.scope.namespace "6.4.6 Namespace scope")[.](#3.sentence-1)
|
||
|
||
The global namespace belongs to the global scope;
|
||
it is not an unnamed namespace ([[namespace.unnamed]](namespace.unnamed "9.9.2.2 Unnamed namespaces"))[.](#3.sentence-2)
|
||
|
||
[*Note [2](#note-2)*:
|
||
|
||
Lacking a declaration, it cannot be found by name lookup[.](#3.sentence-3)
|
||
|
||
â *end note*]
|