[basic.namespace]

# 9 Declarations [[dcl]](./#dcl)

## 9.9 Namespaces [basic.namespace]

### [9.9.1](#general) General [[basic.namespace.general]](basic.namespace.general)

[1](#general-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[.](#general-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[.](#general-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[.](#general-1.sentence-3)

[2](#general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8199)

[*Note [1](#general-note-1)*:

A [*namespace-definition*](#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"))[.](#general-2.sentence-1)

A namespace is never attached to a named module
and never has a name with module linkage[.](#general-2.sentence-2)

â *end note*]

[*Example [1](#general-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](#general-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")[.](#general-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"))[.](#general-3.sentence-2)

[*Note [2](#general-note-2)*:

Lacking a declaration, it cannot be found by name lookup[.](#general-3.sentence-3)

â *end note*]

### [9.9.2](#namespace.def) Namespace definition [[namespace.def]](namespace.def)

#### [9.9.2.1](#namespace.def.general) General [[namespace.def.general]](namespace.def.general)

[namespace-name:](#nt:namespace-name "9.9.2.1 General [namespace.def.general]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")  
[*namespace-alias*](#nt:namespace-alias "9.9.3 Namespace alias [namespace.alias]")

[namespace-definition:](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]")  
[*named-namespace-definition*](#nt:named-namespace-definition "9.9.2.1 General [namespace.def.general]")  
[*unnamed-namespace-definition*](#nt:unnamed-namespace-definition "9.9.2.1 General [namespace.def.general]")  
[*nested-namespace-definition*](#nt:nested-namespace-definition "9.9.2.1 General [namespace.def.general]")

[named-namespace-definition:](#nt:named-namespace-definition "9.9.2.1 General [namespace.def.general]")  
inlineopt namespace [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") { [*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") }

[unnamed-namespace-definition:](#nt:unnamed-namespace-definition "9.9.2.1 General [namespace.def.general]")  
inlineopt namespace [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt { [*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") }

[nested-namespace-definition:](#nt:nested-namespace-definition "9.9.2.1 General [namespace.def.general]")  
namespace [*enclosing-namespace-specifier*](#nt:enclosing-namespace-specifier "9.9.2.1 General [namespace.def.general]") :: inlineopt [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") { [*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") }

[enclosing-namespace-specifier:](#nt:enclosing-namespace-specifier "9.9.2.1 General [namespace.def.general]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")  
[*enclosing-namespace-specifier*](#nt:enclosing-namespace-specifier "9.9.2.1 General [namespace.def.general]") :: inlineopt [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")

[namespace-body:](#nt:namespace-body "9.9.2.1 General [namespace.def.general]")  
[*declaration-seq*](dcl.pre#nt:declaration-seq "9.1 Preamble [dcl.pre]")opt

[1](#namespace.def.general-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8270)

Every [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") shall inhabit a namespace scope ([[basic.scope.namespace]](basic.scope.namespace "6.4.6 Namespace scope"))[.](#namespace.def.general-1.sentence-1)

[2](#namespace.def.general-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8273)

In a [*named-namespace-definition*](#nt:named-namespace-definition "9.9.2.1 General [namespace.def.general]") D,
the [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") is the name of the namespace[.](#namespace.def.general-2.sentence-1)

The [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") is looked up
by searching for it in the scopes of the namespace A in which D appears
and of every element of the inline namespace set of A[.](#namespace.def.general-2.sentence-2)

If the lookup finds a [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") for a namespace N,D [*extends*](#def:namespace,extend "9.9.2.1 General [namespace.def.general]") N,
and the target scope of D is the scope to which N belongs[.](#namespace.def.general-2.sentence-3)

If the lookup finds nothing, the [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") is introduced
as a [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]") into A[.](#namespace.def.general-2.sentence-4)

[3](#namespace.def.general-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8287)

Because a [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") contains[*declaration*](dcl.pre#nt:declaration "9.1 Preamble [dcl.pre]")*s* in its [*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") and a[*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") is itself a [*declaration*](dcl.pre#nt:declaration "9.1 Preamble [dcl.pre]"), it
follows that [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]")*s* can be nested[.](#namespace.def.general-3.sentence-1)

[*Example [1](#namespace.def.general-example-1)*: namespace Outer {int i; namespace Inner {void f() { i++; } // Outer​::​iint i; void g() { i++; } // Inner​::​i}} â *end example*]

[4](#namespace.def.general-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8305)

If the optional initial inline keyword appears in a[*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") for a particular namespace, that namespace is
declared to be an [*inline namespace*](#def:namespace,inline "9.9.2.1 General [namespace.def.general]")[.](#namespace.def.general-4.sentence-1)

The inline keyword may be
used on a [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") that extends a namespace
only if it was previously used on the [*namespace-definition*](#nt:namespace-definition "9.9.2.1 General [namespace.def.general]") that initially declared the [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]") for that namespace[.](#namespace.def.general-4.sentence-2)

[5](#namespace.def.general-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8313)

The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") in a [*named-namespace-definition*](#nt:named-namespace-definition "9.9.2.1 General [namespace.def.general]") appertains to the namespace being defined or extended[.](#namespace.def.general-5.sentence-1)

[6](#namespace.def.general-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8318)

Members of an inline namespace can be used in most respects as though they were members
of the innermost enclosing namespace[.](#namespace.def.general-6.sentence-1)

Specifically, the inline namespace and its enclosing
namespace are both added to the set of associated namespaces used in[argument-dependent lookup](basic.lookup.argdep "6.5.4 Argument-dependent name lookup [basic.lookup.argdep]") whenever one of them is,
and a [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") ([[namespace.udir]](#namespace.udir "9.9.4 Using namespace directive")) that names the inline
namespace is implicitly inserted into the enclosing namespace as for an unnamed
namespace ([[namespace.unnamed]](#namespace.unnamed "9.9.2.2 Unnamed namespaces"))[.](#namespace.def.general-6.sentence-2)

Furthermore, each
member of the inline namespace can subsequently be partially
specialized ([[temp.spec.partial]](temp.spec.partial "13.7.6 Partial specialization")), explicitly
instantiated ([[temp.explicit]](temp.explicit "13.9.3 Explicit instantiation")), or explicitly specialized ([[temp.expl.spec]](temp.expl.spec "13.9.4 Explicit specialization")) as
though it were a member of the enclosing namespace[.](#namespace.def.general-6.sentence-3)

Finally, looking up a name in the
enclosing namespace via explicit qualification ([[namespace.qual]](namespace.qual "6.5.5.3 Namespace members")) will include
members of the inline namespace even if
there are declarations of that name in the enclosing namespace[.](#namespace.def.general-6.sentence-4)

[7](#namespace.def.general-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8334)

These properties are transitive: if a namespace N contains an inline namespaceM, which in turn contains an inline namespace O, then the members ofO can be used as though they were members of M or N[.](#namespace.def.general-7.sentence-1)

The [*inline namespace set*](#def:inline_namespace_set "9.9.2.1 General [namespace.def.general]") of N is the transitive closure of all
inline namespaces in N[.](#namespace.def.general-7.sentence-2)

[8](#namespace.def.general-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8341)

A [*nested-namespace-definition*](#nt:nested-namespace-definition "9.9.2.1 General [namespace.def.general]") with an[*enclosing-namespace-specifier*](#nt:enclosing-namespace-specifier "9.9.2.1 General [namespace.def.general]") E,[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") I and[*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") B is equivalent tonamespace E { inlineopt namespace I { B } } where the optional inline is present if and only if
the [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") I is preceded by inline[.](#namespace.def.general-8.sentence-1)

[*Example [2](#namespace.def.general-example-2)*: namespace A::inline B::C {int i;}

The above has the same effect as:namespace A {inline namespace B {namespace C {int i; }}}

â *end example*]

#### [9.9.2.2](#namespace.unnamed) Unnamed namespaces [[namespace.unnamed]](namespace.unnamed)

[1](#namespace.unnamed-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8373)

An [*unnamed-namespace-definition*](#nt:unnamed-namespace-definition "9.9.2.1 General [namespace.def.general]") behaves as if it were
replaced by

inlineopt namespace *unique* { /* empty body */ }  
using namespace *unique* ;  
namespace *unique* { [*namespace-body*](#nt:namespace-body "9.9.2.1 General [namespace.def.general]") }

whereinline appears if and only if it appears in the[*unnamed-namespace-definition*](#nt:unnamed-namespace-definition "9.9.2.1 General [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[.](#namespace.unnamed-1.sentence-1)

The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") in the [*unnamed-namespace-definition*](#nt:unnamed-namespace-definition "9.9.2.1 General [namespace.def.general]") appertains to *unique*[.](#namespace.unnamed-1.sentence-2)

[*Example [1](#namespace.unnamed-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*]

### [9.9.3](#namespace.alias) Namespace alias [[namespace.alias]](namespace.alias)

[1](#namespace.alias-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8417)

A [*namespace-alias-definition*](#nt:namespace-alias-definition "9.9.3 Namespace alias [namespace.alias]") declares a [*namespace alias*](#def:alias,namespace "9.9.3 Namespace alias [namespace.alias]") according to the following grammar:

[namespace-alias:](#nt:namespace-alias "9.9.3 Namespace alias [namespace.alias]")  
[*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]")

[namespace-alias-definition:](#nt:namespace-alias-definition "9.9.3 Namespace alias [namespace.alias]")  
namespace [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") = [*qualified-namespace-specifier*](#nt:qualified-namespace-specifier "9.9.3 Namespace alias [namespace.alias]") ;  
namespace [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") = [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") ;  

[qualified-namespace-specifier:](#nt:qualified-namespace-specifier "9.9.3 Namespace alias [namespace.alias]")  
[*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]")

[2](#namespace.alias-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8436)

The [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") (if any)
shall designate a namespace that is not the global namespace[.](#namespace.alias-2.sentence-1)

[3](#namespace.alias-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8440)

The [*identifier*](lex.name#nt:identifier "5.11 Identifiers [lex.name]") in a [*namespace-alias-definition*](#nt:namespace-alias-definition "9.9.3 Namespace alias [namespace.alias]") becomes a [*namespace-alias*](#nt:namespace-alias "9.9.3 Namespace alias [namespace.alias]")[.](#namespace.alias-3.sentence-1)

[4](#namespace.alias-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8444)

The underlying entity ([[basic.pre]](basic.pre "6.1 Preamble")) of the namespace alias is
the namespace either
denoted by the [*qualified-namespace-specifier*](#nt:qualified-namespace-specifier "9.9.3 Namespace alias [namespace.alias]") or
designated by the [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]")[.](#namespace.alias-4.sentence-1)

[*Note [1](#namespace.alias-note-1)*:

When looking up a [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]") in a[*namespace-alias-definition*](#nt:namespace-alias-definition "9.9.3 Namespace alias [namespace.alias]"), only namespace names are
considered, see [[basic.lookup.udir]](basic.lookup.udir "6.5.7 Using-directives and namespace aliases")[.](#namespace.alias-4.sentence-2)

â *end note*]

### [9.9.4](#namespace.udir) Using namespace directive [[namespace.udir]](namespace.udir)

[using-directive:](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt using namespace [*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]")opt [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]") ;  
[*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]")opt using namespace [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") ;

[1](#namespace.udir-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8464)

The [*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") (if any) shall designate a namespace
that is not the global namespace[.](#namespace.udir-1.sentence-1)

The [*nested-name-specifier*](expr.prim.id.qual#nt:nested-name-specifier "7.5.5.3 Qualified names [expr.prim.id.qual]"),[*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]"), and[*splice-specifier*](basic.splice#nt:splice-specifier "6.6 Splice specifiers [basic.splice]") shall not be dependent[.](#namespace.udir-1.sentence-2)

[2](#namespace.udir-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8472)

A [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") shall not appear in class scope, but may
appear in namespace scope or in block scope[.](#namespace.udir-2.sentence-1)

[*Note [1](#namespace.udir-note-1)*:

When looking up a [*namespace-name*](#nt:namespace-name "9.9.2.1 General [namespace.def.general]") in a[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]"), only namespace names are considered,
see [[basic.lookup.udir]](basic.lookup.udir "6.5.7 Using-directives and namespace aliases")[.](#namespace.udir-2.sentence-2)

â *end note*]

The optional [*attribute-specifier-seq*](dcl.attr.grammar#nt:attribute-specifier-seq "9.13.1 Attribute syntax and semantics [dcl.attr.grammar]") appertains to the [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")[.](#namespace.udir-2.sentence-3)

[3](#namespace.udir-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8482)

[*Note [2](#namespace.udir-note-2)*:

A [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") makes the names in the designated
namespace usable in the scope in which the[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") appears after
the [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") ([[basic.lookup.unqual]](basic.lookup.unqual "6.5.3 Unqualified name lookup"), [[namespace.qual]](namespace.qual "6.5.5.3 Namespace members"))[.](#namespace.udir-3.sentence-1)

During unqualified name lookup, the names
appear as if they were declared in the nearest enclosing namespace which
contains both the [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") and the designated
namespace[.](#namespace.udir-3.sentence-2)

â *end note*]

[4](#namespace.udir-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8494)

[*Note [3](#namespace.udir-note-3)*:

A [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") does not introduce any names[.](#namespace.udir-4.sentence-1)

â *end note*]

[*Example [1](#namespace.udir-example-1)*: namespace A {int i; namespace B {namespace C {int i; }using namespace A::B::C; void f1() { i = 5; // OK, C​::​i visible in B and hides A​::​i}}namespace D {using namespace B; using namespace C; void f2() { i = 5; // ambiguous, B​::​C​::​i or A​::​i?}}void f3() { i = 5; // uses A​::​i}}void f4() { i = 5; // error: neither i is visible} â *end example*]

[5](#namespace.udir-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8528)

[*Note [4](#namespace.udir-note-4)*:

A [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") is transitive: if a scope contains a[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") that designates a namespace that itself
contains [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")*s*, the namespaces designated by those[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")*s* are also eligible to be considered[.](#namespace.udir-5.sentence-1)

â *end note*]

[*Example [2](#namespace.udir-example-2)*: namespace M {int i;}namespace N {int i; using namespace M;}void f() {using namespace N;
 i = 7; // error: both M​::​i and N​::​i are visible}

For another example,namespace A {int i;}namespace B {int i; int j; namespace C {namespace D {using namespace A; int j; int k; int a = i; // B​::​i hides A​::​i}using namespace D; int k = 89; // no problem yetint l = k; // ambiguous: C​::​k or D​::​kint m = i; // B​::​i hides A​::​iint n = j; // D​::​j hides B​::​j}}

â *end example*]

[6](#namespace.udir-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8578)

[*Note [5](#namespace.udir-note-5)*:

Declarations in a namespace
that appear after a [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") for that namespace
can be found through that [*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]") after they appear[.](#namespace.udir-6.sentence-1)

â *end note*]

[7](#namespace.udir-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8585)

[*Note [6](#namespace.udir-note-6)*:

If name lookup finds a declaration for a name in two different
namespaces, and the declarations do not declare the same entity and do
not declare functions or function templates, the use of the name is ill-formed ([[basic.lookup]](basic.lookup "6.5 Name lookup"))[.](#namespace.udir-7.sentence-1)

In particular, the name of a variable, function or enumerator does not
hide the name of a class or enumeration declared in a different
namespace[.](#namespace.udir-7.sentence-2)

For example,namespace A {class X { }; extern "C" int g(); extern "C++" int h();}namespace B {void X(int); extern "C" int g(); extern "C++" int h(int);}using namespace A;using namespace B;

void f() { X(1); // error: name X found in two namespaces g(); // OK, name g refers to the same entity h(); // OK, overload resolution selects A​::​h}

â *end note*]

[8](#namespace.udir-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/declarations.tex#L8615)

[*Note [7](#namespace.udir-note-7)*:

The order in which namespaces are considered and the
relationships among the namespaces implied by the[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")*s* do not affect overload resolution[.](#namespace.udir-8.sentence-1)

Neither is any function excluded because another has the same
signature, even if one is in a namespace reachable through[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")*s* in the namespace of the other[.](#namespace.udir-8.sentence-2)[83](#footnote-83 "During name lookup in a class hierarchy, some ambiguities can be resolved by considering whether one member hides the other along some paths ([class.member.lookup]). There is no such disambiguation when considering the set of names found as a result of following using-directives.")

â *end note*]

[*Example [3](#namespace.udir-example-3)*: namespace D {int d1; void f(char);}using namespace D;

int d1; // OK, no conflict with D​::​d1namespace E {int e; void f(int);}namespace D { // namespace extensionint d2; using namespace E; void f(int);}void f() { d1++; // error: ambiguous ​::​d1 or D​::​d1?::d1++; // OK D::d1++; // OK d2++; // OK, D​::​d2 e++; // OK, E​::​e f(1); // error: ambiguous: D​::​f(int) or E​::​f(int)? f('a'); // OK, D​::​f(char)} â *end example*]

[83)](#footnote-83)[83)](#footnoteref-83)

During
name lookup in a class hierarchy, some ambiguities can be
resolved by considering whether one member hides the other along some
paths ([[class.member.lookup]](class.member.lookup "6.5.2 Member name lookup"))[.](#footnote-83.sentence-1)

There is no such disambiguation when
considering the set of names found as a result of following[*using-directive*](#nt:using-directive "9.9.4 Using namespace directive [namespace.udir]")*s*[.](#footnote-83.sentence-2)
