<!DOCTYPE html><html lang='en'><head><title>[namespace.def]</title><meta charset='UTF-8'/><link rel='stylesheet' type='text/css' href='14882.css'/><link rel='stylesheet' type='text/css' href='expanded.css' title='Notes and examples expanded'/><link rel='alternate stylesheet' type='text/css' href='colored.css' title='Notes and examples colored'/><link rel='alternate stylesheet' type='text/css' href='collapsed.css' title='Notes and examples collapsed'/><link rel='icon' href='icon.png'/></head><body><div class='wrapper'><h1 ><a class='secnum' style='min-width:73pt'>9</a> Declarations <a class='abbr_ref' href='./#dcl.dcl'>[dcl.dcl]</a></h1><h2 ><a class='secnum' style='min-width:88pt'>9.7</a> Namespaces <a class='abbr_ref' href='basic.namespace#namespace.def'>[basic.namespace]</a></h2><h3 ><a class='secnum' style='min-width:103pt'>9.7.1</a> Namespace definition <a class='abbr_ref'>[namespace.def]</a></h3><span class='indexparent'><a class='index' id=':definition,namespace'></a></span><span class='indexparent'><a class='index' id=':namespace,definition'></a></span><pre class='bnf'><a class='nontermdef' href='#nt:namespace-name' id='nt:namespace-name'>namespace-name:</a>
&#9;<i ><a href='lex.name#nt:identifier'>identifier</a></i>
&#9;<i ><a href='namespace.alias#nt:namespace-alias'>namespace-alias</a></i>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:namespace-definition' id='nt:namespace-definition'>namespace-definition:</a>
&#9;<i ><a href='#nt:named-namespace-definition'>named-namespace-definition</a></i>
&#9;<i ><a href='#nt:unnamed-namespace-definition'>unnamed-namespace-definition</a></i>
&#9;<i ><a href='#nt:nested-namespace-definition'>nested-namespace-definition</a></i>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:named-namespace-definition' id='nt:named-namespace-definition'>named-namespace-definition:</a>
&#9;<span class='terminal'><span class='keyword'>inline</span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span></span> <span class='terminal'><span class='keyword'>namespace</span></span> <i ><a href='dcl.attr.grammar#nt:attribute-specifier-seq'>attribute-specifier-seq</a></i><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <i ><a href='lex.name#nt:identifier'>identifier</a></i> <span class='terminal'><span class='curlybracket'>{</span></span> <i ><a href='#nt:namespace-body'>namespace-body</a></i> <span class='terminal'><span class='curlybracket'>}</span></span>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:unnamed-namespace-definition' id='nt:unnamed-namespace-definition'>unnamed-namespace-definition:</a>
&#9;<span class='terminal'><span class='keyword'>inline</span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span></span> <span class='terminal'><span class='keyword'>namespace</span></span> <i ><a href='dcl.attr.grammar#nt:attribute-specifier-seq'>attribute-specifier-seq</a></i><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <span class='terminal'><span class='curlybracket'>{</span></span> <i ><a href='#nt:namespace-body'>namespace-body</a></i> <span class='terminal'><span class='curlybracket'>}</span></span>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:nested-namespace-definition' id='nt:nested-namespace-definition'>nested-namespace-definition:</a>
&#9;<span class='terminal'><span class='keyword'>namespace</span></span> <i ><a href='#nt:enclosing-namespace-specifier'>enclosing-namespace-specifier</a></i> <span class='terminal'><span class='operator'>:</span><span class='operator'>:</span></span> <span class='terminal'><span class='keyword'>inline</span></span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <i ><a href='lex.name#nt:identifier'>identifier</a></i> <span class='terminal'><span class='curlybracket'>{</span></span> <i ><a href='#nt:namespace-body'>namespace-body</a></i> <span class='terminal'><span class='curlybracket'>}</span></span>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:enclosing-namespace-specifier' id='nt:enclosing-namespace-specifier'>enclosing-namespace-specifier:</a>
&#9;<i ><a href='lex.name#nt:identifier'>identifier</a></i>
&#9;<i ><a href='#nt:enclosing-namespace-specifier'>enclosing-namespace-specifier</a></i> <span class='terminal'><span class='operator'>:</span><span class='operator'>:</span></span> <span class='terminal'><span class='keyword'>inline</span></span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <i ><a href='lex.name#nt:identifier'>identifier</a></i>
</pre><pre class='bnf'><a class='nontermdef' href='#nt:namespace-body' id='nt:namespace-body'>namespace-body:</a>
&#9;<i ><a href='dcl.dcl#nt:declaration-seq'>declaration-seq</a></i><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span>
</pre><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6487'>#</a></div><div id='1.sentence-1' class='sentence'>Every <i ><a href='#nt:namespace-definition'>namespace-definition</a></i> shall appear in the global scope
or in a namespace scope (<a href='basic.scope.namespace'>[basic.scope.namespace]</a>)<a class='hidden_link' href='#1.sentence-1'>.</a></div></div><div class='para' id='2'><div class='marginalizedparent'><a class='marginalized' href='#2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6491'>#</a></div><div id='2.sentence-1' class='sentence'>In a <i ><a href='#nt:named-namespace-definition'>named-namespace-definition</a></i>,
the <i ><a href='lex.name#nt:identifier'>identifier</a></i> is the name of the namespace<a class='hidden_link' href='#2.sentence-1'>.</a></div> <div id='2.sentence-2' class='sentence'>If the <i ><a href='lex.name#nt:identifier'>identifier</a></i>, when <a href='basic.lookup.unqual'>looked up</a>,
refers to a <i ><a href='#nt:namespace-name'>namespace-name</a></i> (but not a <i ><a href='namespace.alias#nt:namespace-alias'>namespace-alias</a></i>)
that was introduced in the namespace
in which the <i ><a href='#nt:named-namespace-definition'>named-namespace-definition</a></i> appears
or that was introduced in a member of the inline namespace set of that namespace,
the <i ><a href='#nt:namespace-definition'>namespace-definition</a></i>

<a class='hidden_link' href='#def:namespace,extend' id='def:namespace,extend'><i >extends</i></a> the previously-declared namespace<a class='hidden_link' href='#2.sentence-2'>.</a></div> <div id='2.sentence-3' class='sentence'>Otherwise, the <i ><a href='lex.name#nt:identifier'>identifier</a></i> is introduced
as a <i ><a href='#nt:namespace-name'>namespace-name</a></i> into the declarative region
in which the <i ><a href='#nt:named-namespace-definition'>named-namespace-definition</a></i> appears<a class='hidden_link' href='#2.sentence-3'>.</a></div></div><div class='para' id='3'><div class='marginalizedparent'><a class='marginalized' href='#3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6506'>#</a></div><div id='3.sentence-1' class='sentence'>Because a <i ><a href='#nt:namespace-definition'>namespace-definition</a></i> contains
<i ><a href='dcl.dcl#nt:declaration'>declaration</a></i><span class='textit'>s</span> in its <i ><a href='#nt:namespace-body'>namespace-body</a></i> and a
<i ><a href='#nt:namespace-definition'>namespace-definition</a></i> is itself a <i ><a href='dcl.dcl#nt:declaration'>declaration</a></i>, it
follows that <i ><a href='#nt:namespace-definition'>namespace-definition</a></i><span class='textit'>s</span> can be nested<a class='hidden_link' href='#3.sentence-1'>.</a></div> <div id='3.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#3.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> Outer <span class='curlybracket'>{</span>
  <span class='keyword'>int</span> i;
  <span class='keyword'>namespace</span> Inner <span class='curlybracket'>{</span>
    <span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> i<span class='operator'>+</span><span class='operator'>+</span>; <span class='curlybracket'>}</span>           <span class='comment'>// <span class='tcode_in_codeblock'>Outer&#x200b;::&#x200b;i</span></span>
    <span class='keyword'>int</span> i;
    <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> i<span class='operator'>+</span><span class='operator'>+</span>; <span class='curlybracket'>}</span>           <span class='comment'>// <span class='tcode_in_codeblock'>Inner&#x200b;::&#x200b;i</span></span>
  <span class='curlybracket'>}</span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='para' id='4'><div class='marginalizedparent'><a class='marginalized' href='#4'>4</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6524'>#</a></div><div id='4.sentence-1' class='sentence'>The <a class='hidden_link' href='#def:namespace,enclosing' id='def:namespace,enclosing'><i >enclosing namespaces</i></a> of a declaration are those
namespaces in which the declaration lexically appears, except for a
redeclaration of a namespace member outside its original namespace
(e.g., a definition as specified in <a href='#namespace.memdef'>[namespace.memdef]</a>)<a class='hidden_link' href='#4.sentence-1'>.</a></div> <div id='4.sentence-2' class='sentence'>Such a
redeclaration has the same enclosing namespaces as the original
declaration<a class='hidden_link' href='#4.sentence-2'>.</a></div> <div id='4.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#4.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> Q <span class='curlybracket'>{</span>
  <span class='keyword'>namespace</span> V <span class='curlybracket'>{</span>
    <span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                   <span class='comment'>// enclosing namespaces are the global namespace, <span class='tcode_in_codeblock'>Q</span>, and <span class='tcode_in_codeblock'>Q&#x200b;::&#x200b;V</span></span>
    <span class='keyword'>class</span> C <span class='curlybracket'>{</span> <span class='keyword'>void</span> m<span class='parenthesis'>(</span><span class='parenthesis'>)</span>; <span class='curlybracket'>}</span>;
  <span class='curlybracket'>}</span>
  <span class='keyword'>void</span> V<span class='operator'>:</span><span class='operator'>:</span>f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>                 <span class='comment'>// enclosing namespaces are the global namespace, <span class='tcode_in_codeblock'>Q</span>, and <span class='tcode_in_codeblock'>Q&#x200b;::&#x200b;V</span></span>
    <span class='keyword'>extern</span> <span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;            <span class='comment'>// ... so this declares <span class='tcode_in_codeblock'>Q&#x200b;::&#x200b;V&#x200b;::&#x200b;h</span></span>
  <span class='curlybracket'>}</span>
  <span class='keyword'>void</span> V<span class='operator'>:</span><span class='operator'>:</span>C<span class='operator'>:</span><span class='operator'>:</span>m<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>              <span class='comment'>// enclosing namespaces are the global namespace, <span class='tcode_in_codeblock'>Q</span>, and <span class='tcode_in_codeblock'>Q&#x200b;::&#x200b;V</span></span>
  <span class='curlybracket'>}</span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='para' id='5'><div class='marginalizedparent'><a class='marginalized' href='#5'>5</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6547'>#</a></div><div id='5.sentence-1' class='sentence'>If the optional initial <span class='texttt'><span class='keyword'>inline</span></span> keyword appears in a
<i ><a href='#nt:namespace-definition'>namespace-definition</a></i> for a particular namespace, that namespace is
declared to be an <a class='hidden_link' href='#def:namespace,inline' id='def:namespace,inline'><i >inline namespace</i></a><a class='hidden_link' href='#5.sentence-1'>.</a></div> <div id='5.sentence-2' class='sentence'>The <span class='texttt'><span class='keyword'>inline</span></span> keyword may be
used on a <i ><a href='#nt:namespace-definition'>namespace-definition</a></i> that extends a namespace
only if it was previously used on the <i ><a href='#nt:namespace-definition'>namespace-definition</a></i>
that initially declared the <i ><a href='#nt:namespace-name'>namespace-name</a></i> for that namespace<a class='hidden_link' href='#5.sentence-2'>.</a></div></div><div class='para' id='6'><div class='marginalizedparent'><a class='marginalized' href='#6'>6</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6555'>#</a></div><div id='6.sentence-1' class='sentence'>The optional <i ><a href='dcl.attr.grammar#nt:attribute-specifier-seq'>attribute-specifier-seq</a></i>
in a <i ><a href='#nt:named-namespace-definition'>named-namespace-definition</a></i>
appertains to the namespace being defined or extended<a class='hidden_link' href='#6.sentence-1'>.</a></div></div><div class='para' id='7'><div class='marginalizedparent'><a class='marginalized' href='#7'>7</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6560'>#</a></div><div id='7.sentence-1' class='sentence'>Members of an inline namespace can be used in most respects as though they were members
of the enclosing namespace<a class='hidden_link' href='#7.sentence-1'>.</a></div> <div id='7.sentence-2' class='sentence'>Specifically, the inline namespace and its enclosing
namespace are both added to the set of associated namespaces used in
<a href='basic.lookup.argdep'>argument-dependent lookup</a> whenever one of them is,
and a <i ><a href='namespace.udir#nt:using-directive'>using-directive</a></i> (<a href='namespace.udir'>[namespace.udir]</a>) that names the inline
namespace is implicitly inserted into the enclosing namespace as for an <a href='#namespace.unnamed'>unnamed
namespace</a><a class='hidden_link' href='#7.sentence-2'>.</a></div> <div id='7.sentence-3' class='sentence'>Furthermore, each
member of the inline namespace can subsequently be <a href='temp.class.spec'>partially
specialized</a>, <a href='temp.explicit'>explicitly
instantiated</a>, or <a href='temp.expl.spec'>explicitly specialized</a> as
though it were a member of the enclosing namespace<a class='hidden_link' href='#7.sentence-3'>.</a></div> <div id='7.sentence-4' class='sentence'>Finally, looking up a name in the
enclosing namespace via explicit qualification (<a href='namespace.qual'>[namespace.qual]</a>) will include
members of the inline namespace brought in by the <i ><a href='namespace.udir#nt:using-directive'>using-directive</a></i> even if
there are declarations of that name in the enclosing namespace<a class='hidden_link' href='#7.sentence-4'>.</a></div></div><div class='para' id='8'><div class='marginalizedparent'><a class='marginalized' href='#8'>8</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6576'>#</a></div><div id='8.sentence-1' class='sentence'>These properties are transitive: if a namespace <span class='texttt'>N</span> contains an inline namespace
<span class='texttt'>M</span>, which in turn contains an inline namespace <span class='texttt'>O</span>, then the members of
<span class='texttt'>O</span> can be used as though they were members of <span class='texttt'>M</span> or <span class='texttt'>N</span><a class='hidden_link' href='#8.sentence-1'>.</a></div> <div id='8.sentence-2' class='sentence'>The <a class='hidden_link' href='#def:inline_namespace_set' id='def:inline_namespace_set'><i >inline namespace set</i></a> of <span class='texttt'>N</span> is the transitive closure of all
inline namespaces in <span class='texttt'>N</span><a class='hidden_link' href='#8.sentence-2'>.</a></div> <div id='8.sentence-3' class='sentence'>The <a class='hidden_link' href='#def:enclosing_namespace_set' id='def:enclosing_namespace_set'><i >enclosing namespace set</i></a> of <span class='texttt'>O</span> is the set of namespaces
consisting of the innermost non-inline namespace enclosing
an inline namespace <span class='texttt'>O</span>, together with any intervening inline namespaces<a class='hidden_link' href='#8.sentence-3'>.</a></div></div><div class='para' id='9'><div class='marginalizedparent'><a class='marginalized' href='#9'>9</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6586'>#</a></div><div id='9.sentence-1' class='sentence'>A <i ><a href='#nt:nested-namespace-definition'>nested-namespace-definition</a></i> with an
<i ><a href='#nt:enclosing-namespace-specifier'>enclosing-namespace-specifier</a></i> <span class='texttt'>E</span>,
<i ><a href='lex.name#nt:identifier'>identifier</a></i> <span class='texttt'>I</span> and
<i ><a href='#nt:namespace-body'>namespace-body</a></i> <span class='texttt'>B</span>
is equivalent to
<pre class='codeblock'>
<span class='keyword'>namespace</span> E <span class='curlybracket'>{</span> <span class='keyword'>inline</span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <span class='keyword'>namespace</span> I <span class='curlybracket'>{</span> B <span class='curlybracket'>}</span> <span class='curlybracket'>}</span>
</pre>
where the optional <span class='texttt'><span class='keyword'>inline</span></span> is present if and only if
the <i ><a href='lex.name#nt:identifier'>identifier</a></i> <span class='texttt'>I</span> is preceded by <span class='texttt'><span class='keyword'>inline</span></span><a class='hidden_link' href='#9.sentence-1'>.</a></div> <div id='9.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#9.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> A<span class='operator'>:</span><span class='operator'>:</span><span class='keyword'>inline</span> B<span class='operator'>:</span><span class='operator'>:</span>C <span class='curlybracket'>{</span>
  <span class='keyword'>int</span> i;
<span class='curlybracket'>}</span>
</pre> <div id='9.sentence-2' class='sentence'>
The above has the same effect as:
<pre class='codeblock'>
<span class='keyword'>namespace</span> A <span class='curlybracket'>{</span>
  <span class='keyword'>inline</span> <span class='keyword'>namespace</span> B <span class='curlybracket'>{</span>
    <span class='keyword'>namespace</span> C <span class='curlybracket'>{</span>
      <span class='keyword'>int</span> i;
    <span class='curlybracket'>}</span>
  <span class='curlybracket'>}</span>
<span class='curlybracket'>}</span>
</pre></div> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div id='namespace.unnamed' class='section'><h4 ><a class='secnum' href='#namespace.unnamed' style='min-width:118pt'>9.7.1.1</a> Unnamed namespaces <a class='abbr_ref' href='namespace.unnamed'>[namespace.unnamed]</a></h4><span class='indexparent'><a class='index' id=':namespace,unnamed'></a></span><div class='para' id='namespace.unnamed-1'><div class='marginalizedparent'><a class='marginalized' href='#namespace.unnamed-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6618'>#</a></div><div id='namespace.unnamed-1.sentence-1' class='sentence'>An <i ><a href='#nt:unnamed-namespace-definition'>unnamed-namespace-definition</a></i> behaves as if it were
replaced by
<pre class='ncsimplebnf'><span class='terminal'><span class='keyword'>inline</span></span><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <span class='terminal'><span class='keyword'>namespace</span></span> <span class='terminal'><span class='textit'>unique</span></span> <span class='terminal'><span class='curlybracket'>{</span> <span class='comment'>/* empty body */</span> <span class='curlybracket'>}</span></span>
<span class='terminal'><span class='keyword'>using</span> <span class='keyword'>namespace</span></span> <span class='terminal'><span class='textit'>unique</span></span> <span class='terminal'>;</span>
<span class='terminal'><span class='keyword'>namespace</span></span> <span class='terminal'><span class='textit'>unique</span></span> <span class='terminal'><span class='curlybracket'>{</span></span> <i ><a href='#nt:namespace-body'>namespace-body</a></i> <span class='terminal'><span class='curlybracket'>}</span></span>
</pre>
where
<span class='texttt'><span class='keyword'>inline</span></span> appears if and only if it appears in the
<i ><a href='#nt:unnamed-namespace-definition'>unnamed-namespace-definition</a></i>
and all occurrences of <span class='texttt'><span class='textit'>unique</span></span> in a translation unit are replaced by
the same identifier, and this identifier differs from all other
identifiers in the translation unit<a class='hidden_link' href='#namespace.unnamed-1.sentence-1'>.</a></div> <div id='namespace.unnamed-1.sentence-2' class='sentence'>The optional <i ><a href='dcl.attr.grammar#nt:attribute-specifier-seq'>attribute-specifier-seq</a></i>
in the <i ><a href='#nt:unnamed-namespace-definition'>unnamed-namespace-definition</a></i>
appertains to <span class='texttt'><span class='textit'>unique</span></span><a class='hidden_link' href='#namespace.unnamed-1.sentence-2'>.</a></div> <div id='namespace.unnamed-1.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#namespace.unnamed-1.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> <span class='curlybracket'>{</span> <span class='keyword'>int</span> i; <span class='curlybracket'>}</span>            <span class='comment'>// <span class='tcode_in_codeblock'><span class='textit'>unique</span>&#x200b;::&#x200b;i</span></span>
<span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> i<span class='operator'>+</span><span class='operator'>+</span>; <span class='curlybracket'>}</span>               <span class='comment'>// <span class='tcode_in_codeblock'><span class='textit'>unique</span>&#x200b;::&#x200b;i++</span></span>

<span class='keyword'>namespace</span> A <span class='curlybracket'>{</span>
  <span class='keyword'>namespace</span> <span class='curlybracket'>{</span>
    <span class='keyword'>int</span> i;                      <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;i</span></span>
    <span class='keyword'>int</span> j;                      <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;j</span></span>
  <span class='curlybracket'>}</span>
  <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> i<span class='operator'>+</span><span class='operator'>+</span>; <span class='curlybracket'>}</span>             <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;i++</span></span>
<span class='curlybracket'>}</span>

<span class='keyword'>using</span> <span class='keyword'>namespace</span> A;
<span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  i<span class='operator'>+</span><span class='operator'>+</span>;                          <span class='comment'>// error: <span class='tcode_in_codeblock'><span class='textit'>unique</span>&#x200b;::&#x200b;i</span> or <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;i</span></span>
  A<span class='operator'>:</span><span class='operator'>:</span>i<span class='operator'>+</span><span class='operator'>+</span>;                       <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;i</span></span>
  j<span class='operator'>+</span><span class='operator'>+</span>;                          <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;<span class='textit'>unique</span>&#x200b;::&#x200b;j</span></span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div></div><div id='namespace.memdef' class='section'><h4 ><a class='secnum' href='#namespace.memdef' style='min-width:118pt'>9.7.1.2</a> Namespace member definitions <a class='abbr_ref' href='namespace.memdef'>[namespace.memdef]</a></h4><span class='indexparent'><a class='index' id=':namespace,member_definition'></a></span><div class='para' id='namespace.memdef-1'><div class='marginalizedparent'><a class='marginalized' href='#namespace.memdef-1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6660'>#</a></div><div id='namespace.memdef-1.sentence-1' class='sentence'>A declaration in a namespace <span class='texttt'>N</span> (excluding declarations in nested scopes)
whose <i ><a href='dcl.decl#nt:declarator-id'>declarator-id</a></i> is an <i ><a href='expr.prim.id.unqual#nt:unqualified-id'>unqualified-id</a></i> (<a href='dcl.meaning'>[dcl.meaning]</a>),
whose <i ><a href='class#nt:class-head-name'>class-head-name</a></i> (<a href='class'>[class]</a>) or
<i ><a href='dcl.enum#nt:enum-head-name'>enum-head-name</a></i> (<a href='dcl.enum'>[dcl.enum]</a>) is an <i ><a href='lex.name#nt:identifier'>identifier</a></i>, or
whose <i ><a href='dcl.type.elab#nt:elaborated-type-specifier'>elaborated-type-specifier</a></i> is of the form <i ><a href='class#nt:class-key'>class-key</a></i>
<i ><a href='dcl.attr.grammar#nt:attribute-specifier-seq'>attribute-specifier-seq</a></i><span class="mjx-chtml"><span class="mjx-math" aria-label="_\mathit{opt}"><span class="mjx-mrow" aria-hidden="true"><span class="mjx-msubsup"><span class="mjx-base"><span class="mjx-mi"><span class="mjx-char"></span></span></span><span class="mjx-sub" style="font-size: 70.7%; vertical-align: -0.212em; padding-right: 0.071em;"><span class="mjx-texatom"><span class="mjx-mrow"><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.298em;">o</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.225em; padding-bottom: 0.446em;">p</span></span><span class="mjx-mi"><span class="mjx-char MJXc-TeX-main-I" style="padding-top: 0.372em; padding-bottom: 0.298em;">t</span></span></span></span></span></span></span></span></span> <i ><a href='lex.name#nt:identifier'>identifier</a></i> (<a href='dcl.type.elab'>[dcl.type.elab]</a>), or
that is an <i ><a href='dcl.enum#nt:opaque-enum-declaration'>opaque-enum-declaration</a></i>,
declares (or redeclares) its <i ><a href='expr.prim.id.unqual#nt:unqualified-id'>unqualified-id</a></i> or
<i ><a href='lex.name#nt:identifier'>identifier</a></i> as a member of <span class='texttt'>N</span><a class='hidden_link' href='#namespace.memdef-1.sentence-1'>.</a></div> <div id='namespace.memdef-1.note-1' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#namespace.memdef-1.note-1'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='namespace.memdef-1.sentence-2' class='sentence'>An <a href='temp.explicit'>explicit instantiation</a> or
<a href='temp.expl.spec'>explicit specialization</a> of a template
does not introduce a name and thus may be declared using an
<i ><a href='expr.prim.id.unqual#nt:unqualified-id'>unqualified-id</a></i> in a member of the enclosing namespace set,
if the primary template is declared in an inline namespace<a class='hidden_link' href='#namespace.memdef-1.sentence-2'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div>  <div id='namespace.memdef-1.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#namespace.memdef-1.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> X <span class='curlybracket'>{</span>
  <span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>        <span class='comment'>// OK: introduces <span class='tcode_in_codeblock'>X&#x200b;::&#x200b;f()</span></span>

  <span class='keyword'>namespace</span> M <span class='curlybracket'>{</span>
    <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                   <span class='comment'>// OK: introduces <span class='tcode_in_codeblock'>X&#x200b;::&#x200b;M&#x200b;::&#x200b;g()</span></span>
  <span class='curlybracket'>}</span>
  <span class='keyword'>using</span> M<span class='operator'>:</span><span class='operator'>:</span>g;
  <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                     <span class='comment'>// error: conflicts with <span class='tcode_in_codeblock'>X&#x200b;::&#x200b;M&#x200b;::&#x200b;g()</span></span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='para' id='namespace.memdef-2'><div class='marginalizedparent'><a class='marginalized' href='#namespace.memdef-2'>2</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6691'>#</a></div><div id='namespace.memdef-2.sentence-1' class='sentence'>Members of a named namespace can also be
defined outside that namespace by explicit
qualification (<a href='namespace.qual'>[namespace.qual]</a>) of the name being defined, provided
that the entity being defined was already declared in the namespace and
the definition appears after the point of declaration in a namespace
that encloses the declaration's namespace<a class='hidden_link' href='#namespace.memdef-2.sentence-1'>.</a></div> <div id='namespace.memdef-2.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#namespace.memdef-2.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='keyword'>namespace</span> Q <span class='curlybracket'>{</span>
  <span class='keyword'>namespace</span> V <span class='curlybracket'>{</span>
    <span class='keyword'>void</span> f<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
  <span class='curlybracket'>}</span>
  <span class='keyword'>void</span> V<span class='operator'>:</span><span class='operator'>:</span>f<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>     <span class='comment'>// OK</span>
  <span class='keyword'>void</span> V<span class='operator'>:</span><span class='operator'>:</span>g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>     <span class='comment'>// error: <span class='tcode_in_codeblock'>g()</span> is not yet a member of <span class='tcode_in_codeblock'>V</span></span>
  <span class='keyword'>namespace</span> V <span class='curlybracket'>{</span>
    <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;
  <span class='curlybracket'>}</span>
<span class='curlybracket'>}</span>

<span class='keyword'>namespace</span> R <span class='curlybracket'>{</span>
  <span class='keyword'>void</span> Q<span class='operator'>:</span><span class='operator'>:</span>V<span class='operator'>:</span><span class='operator'>:</span>g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>  <span class='comment'>// error: <span class='tcode_in_codeblock'>R</span> doesn't enclose <span class='tcode_in_codeblock'>Q</span></span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='para' id='namespace.memdef-3'><div class='marginalizedparent'><a class='marginalized' href='#namespace.memdef-3'>3</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/Eelis/draft73ca144c7e48612fe72742f9f6a5ec9ad6a934d2/source/declarations.tex#L6717'>#</a></div><div id='namespace.memdef-3.sentence-1' class='sentence'>If a friend declaration in a non-local class first declares a
class, function, class template or function template<a class='footnotenum' href='#footnote-101'>101</a>
the friend is a member of the innermost enclosing
namespace<a class='hidden_link' href='#namespace.memdef-3.sentence-1'>.</a></div> <div id='namespace.memdef-3.sentence-2' class='sentence'>The friend declaration does not by itself make the name
visible to <a href='basic.lookup.unqual'>unqualified lookup</a> or <a href='basic.lookup.qual'>qualified
lookup</a><a class='hidden_link' href='#namespace.memdef-3.sentence-2'>.</a></div> <div id='namespace.memdef-3.note-1' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#namespace.memdef-3.note-1'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='namespace.memdef-3.sentence-3' class='sentence'>The name of the friend will be
visible in its namespace if a matching declaration is provided at namespace
scope (either before or after the class definition granting friendship)<a class='hidden_link' href='#namespace.memdef-3.sentence-3'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div>  <div id='namespace.memdef-3.sentence-4' class='sentence'> If a friend
function or function template is called, its name may be found by the
name lookup that considers functions from namespaces and classes
associated with the types of the function
arguments (<a href='basic.lookup.argdep'>[basic.lookup.argdep]</a>)<a class='hidden_link' href='#namespace.memdef-3.sentence-4'>.</a></div> <div id='namespace.memdef-3.sentence-5' class='sentence'>If the
name in a friend declaration is neither qualified nor a
<i ><a href='temp.names#nt:template-id'>template-id</a></i> and the declaration is a function or an
<i ><a href='dcl.type.elab#nt:elaborated-type-specifier'>elaborated-type-specifier</a></i>, the lookup to determine whether
the entity has been previously declared shall not consider any scopes
outside the innermost enclosing namespace<a class='hidden_link' href='#namespace.memdef-3.sentence-5'>.</a></div> <div id='namespace.memdef-3.note-2' class='note'>[<span style='white-space:nowrap'> </span><a class='note_link' href='#namespace.memdef-3.note-2'><span class='textit'>Note</span></a><div class='noteBody'><span class='textit'>:</span> <div id='namespace.memdef-3.sentence-6' class='sentence'>The other forms of
friend declarations cannot declare a new member of the innermost
enclosing namespace and thus follow the usual lookup rules<a class='hidden_link' href='#namespace.memdef-3.sentence-6'>.</a></div> —<span style='white-space:nowrap'> </span><i>end note</i></div><span style='white-space:nowrap'> </span>]</div>  <div id='namespace.memdef-3.example-1' class='example'>[<span style='white-space:nowrap'> </span><a class='example_link' href='#namespace.memdef-3.example-1'><span class='textit'>Example</span></a><div class='exampleBody'><span class='textit'>:</span> <pre class='codeblock'>
<span class='comment'>// Assume <span class='tcode_in_codeblock'>f</span> and <span class='tcode_in_codeblock'>g</span> have not yet been declared.</span>
<span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='keyword'>int</span><span class='parenthesis'>)</span>;
<span class='keyword'>template</span> <span class='anglebracket'>&lt;</span><span class='keyword'>class</span> T<span class='anglebracket'>&gt;</span> <span class='keyword'>void</span> f2<span class='parenthesis'>(</span>T<span class='parenthesis'>)</span>;
<span class='keyword'>namespace</span> A <span class='curlybracket'>{</span>
  <span class='keyword'>class</span> X <span class='curlybracket'>{</span>
    <span class='keyword'>friend</span> <span class='keyword'>void</span> f<span class='parenthesis'>(</span>X<span class='parenthesis'>)</span>;           <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;f(X)</span> is a friend</span>
    <span class='keyword'>class</span> Y <span class='curlybracket'>{</span>
      <span class='keyword'>friend</span> <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;          <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;g</span> is a friend</span>
      <span class='keyword'>friend</span> <span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='keyword'>int</span><span class='parenthesis'>)</span>;       <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;h</span> is a friend</span>
                                <span class='comment'>// <span class='tcode_in_codeblock'>&#x200b;::&#x200b;h</span> not considered</span>
      <span class='keyword'>friend</span> <span class='keyword'>void</span> f2<span class='anglebracket'>&lt;</span><span class='anglebracket'>&gt;</span><span class='parenthesis'>(</span><span class='keyword'>int</span><span class='parenthesis'>)</span>;    <span class='comment'>// <span class='tcode_in_codeblock'>&#x200b;::&#x200b;f2&lt;&gt;(int)</span> is a friend</span>
    <span class='curlybracket'>}</span>;
  <span class='curlybracket'>}</span>;

  <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;f</span>, <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;g</span> and <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;h</span> are not visible here</span>
  X x;
  <span class='keyword'>void</span> g<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> f<span class='parenthesis'>(</span>x<span class='parenthesis'>)</span>; <span class='curlybracket'>}</span>            <span class='comment'>// definition of <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;g</span></span>
  <span class='keyword'>void</span> f<span class='parenthesis'>(</span>X<span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>       <span class='comment'>// definition of <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;f</span></span>
  <span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='keyword'>int</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span> <span class='comment'>/* ... */</span> <span class='curlybracket'>}</span>     <span class='comment'>// definition of <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;h</span></span>
  <span class='comment'>// <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;f</span>, <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;g</span> and <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;h</span> are visible here and known to be friends</span>
<span class='curlybracket'>}</span>

<span class='keyword'>using</span> A<span class='operator'>:</span><span class='operator'>:</span>x;

<span class='keyword'>void</span> h<span class='parenthesis'>(</span><span class='parenthesis'>)</span> <span class='curlybracket'>{</span>
  A<span class='operator'>:</span><span class='operator'>:</span>f<span class='parenthesis'>(</span>x<span class='parenthesis'>)</span>;
  A<span class='operator'>:</span><span class='operator'>:</span>X<span class='operator'>:</span><span class='operator'>:</span>f<span class='parenthesis'>(</span>x<span class='parenthesis'>)</span>;                   <span class='comment'>// error: <span class='tcode_in_codeblock'>f</span> is not a member of <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;X</span></span>
  A<span class='operator'>:</span><span class='operator'>:</span>X<span class='operator'>:</span><span class='operator'>:</span>Y<span class='operator'>:</span><span class='operator'>:</span>g<span class='parenthesis'>(</span><span class='parenthesis'>)</span>;                 <span class='comment'>// error: <span class='tcode_in_codeblock'>g</span> is not a member of <span class='tcode_in_codeblock'>A&#x200b;::&#x200b;X&#x200b;::&#x200b;Y</span></span>
<span class='curlybracket'>}</span>
</pre> —<span style='white-space:nowrap'> </span><i>end example</i></div><span style='white-space:nowrap'> </span>]</div> </div><div class='footnote' id='footnote-101'><div class='footnoteNumberParent'><a class='marginalized' href='#footnote-101'>101)</a></div><div id='footnote-101.sentence-1' class='sentence'>this implies that the name of the class or function is unqualified<a class='hidden_link' href='#footnote-101.sentence-1'>.</a></div></div></div></div></body></html>