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

55 lines
2.2 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.

[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.1General[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.1General[namespace.def.general]") is exported
if it contains any[*export-declaration*](module.interface#nt:export-declaration "10.2Export declaration[module.interface]")*s* ([[module.interface]](module.interface "10.2Export 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.1General[basic.namespace.general]") with no declaration;
see [[basic.scope.namespace]](basic.scope.namespace "6.4.6Namespace 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.2Unnamed namespaces"))[.](#3.sentence-2)
[*Note [2](#note-2)*:
Lacking a declaration, it cannot be found by name lookup[.](#3.sentence-3)
— *end note*]