|
2092 | 2092 |
|
2093 | 2093 | \begin{bnf} |
2094 | 2094 | \nontermdef{namespace-name}\br |
2095 | | - original-namespace-name\br |
| 2095 | + identifier\br |
2096 | 2096 | namespace-alias |
2097 | 2097 | \end{bnf} |
2098 | 2098 |
|
2099 | | -\begin{bnf} |
2100 | | -\nontermdef{original-namespace-name}\br |
2101 | | - identifier |
2102 | | -\end{bnf} |
2103 | | - |
2104 | 2099 | \begin{bnf} |
2105 | 2100 | \nontermdef{namespace-definition}\br |
2106 | 2101 | named-namespace-definition\br |
|
2109 | 2104 |
|
2110 | 2105 | \begin{bnf} |
2111 | 2106 | \nontermdef{named-namespace-definition}\br |
2112 | | - original-namespace-definition\br |
2113 | | - extension-namespace-definition |
2114 | | -\end{bnf} |
2115 | | - |
2116 | | -\begin{bnf} |
2117 | | -\nontermdef{original-namespace-definition}\br |
2118 | 2107 | \terminal{inline\opt} \terminal{namespace} identifier \terminal{\{} namespace-body \terminal{\}} |
2119 | 2108 | \end{bnf} |
2120 | 2109 |
|
2121 | | -\begin{bnf} |
2122 | | -\nontermdef{extension-namespace-definition}\br |
2123 | | - \terminal{inline\opt} \terminal{namespace} original-namespace-name \terminal{\{} namespace-body \terminal{\}} |
2124 | | -\end{bnf} |
2125 | | - |
2126 | 2110 | \begin{bnf} |
2127 | 2111 | \nontermdef{unnamed-namespace-definition}\br |
2128 | 2112 | \terminal{inline\opt} \terminal{namespace \{} namespace-body \terminal{\}} |
|
2133 | 2117 | declaration-seq\opt |
2134 | 2118 | \end{bnf} |
2135 | 2119 |
|
2136 | | -\pnum |
2137 | | -The \grammarterm{identifier} in an \grammarterm{original-namespace-definition} |
2138 | | -shall not have been previously defined in the declarative region in |
2139 | | -which the \grammarterm{original-namespace-definition} appears. The |
2140 | | -\grammarterm{identifier} in an \grammarterm{original-namespace-definition} is |
2141 | | -the name of the namespace. Subsequently in that declarative region, it |
2142 | | -is treated as an \grammarterm{original-namespace-name}. |
2143 | | - |
2144 | | -\pnum |
2145 | | -The \grammarterm{original-namespace-name} in an |
2146 | | -\grammarterm{extension-namespace-definition} shall have previously been |
2147 | | -defined in an \grammarterm{original-namespace-definition} in the same |
2148 | | -declarative region. |
2149 | | - |
2150 | 2120 | \pnum |
2151 | 2121 | Every \grammarterm{namespace-definition} shall appear in the global scope |
2152 | 2122 | or in a namespace scope~(\ref{basic.scope.namespace}). |
2153 | 2123 |
|
| 2124 | +\pnum |
| 2125 | +In a \grammarterm{named-namespace-definition}, |
| 2126 | +the \grammarterm{identifier} is the name of the namespace. |
| 2127 | +If the \grammarterm{identifier}, when looked up~(\ref{basic.lookup.unqual}), |
| 2128 | +refers to a \grammarterm{namespace-name} (but not a \grammarterm{namespace-alias}) |
| 2129 | +introduced in the declarative region |
| 2130 | +in which the \grammarterm{named-namespace-definition} appears, |
| 2131 | +the \grammarterm{namespace-definition} |
| 2132 | +\indextext{extend|see{namespace, extend}} |
| 2133 | +\defnx{extends}{namespace!extend} the previously-declared namespace. |
| 2134 | +Otherwise, the \grammarterm{identifier} is introduced |
| 2135 | +as a \grammarterm{namespace-name} into the declarative region |
| 2136 | +in which the \grammarterm{named-namespace-definition} appears. |
| 2137 | + |
2154 | 2138 | \pnum |
2155 | 2139 | Because a \grammarterm{namespace-definition} contains |
2156 | 2140 | \grammarterm{declaration}{s} in its \grammarterm{namespace-body} and a |
|
2197 | 2181 | If the optional initial \tcode{inline} keyword appears in a |
2198 | 2182 | \grammarterm{namespace-definition} for a particular namespace, that namespace is |
2199 | 2183 | declared to be an \term{inline namespace}. The \tcode{inline} keyword may be |
2200 | | -used on an \grammarterm{extension-namespace-definition} only if it was |
2201 | | -previously used on the \grammarterm{original-namespace-definition} for that |
2202 | | -namespace. |
| 2184 | +used on a \grammarterm{namespace-definition} that extends a namespace |
| 2185 | +only if it was previously used on the \grammarterm{namespace-definition} |
| 2186 | +that initially declared the \grammarterm{namespace-name} for that namespace. |
2203 | 2187 |
|
2204 | 2188 | \pnum |
2205 | 2189 | Members of an inline namespace can be used in most respects as though they were members |
|
2424 | 2408 | \end{codeblock} |
2425 | 2409 | \exitexample |
2426 | 2410 |
|
2427 | | -\pnum |
2428 | | -A \grammarterm{namespace-name} or \grammarterm{namespace-alias} shall not be |
2429 | | -declared as the name of any other entity in the same declarative region. |
2430 | | -A \grammarterm{namespace-name} defined at global scope shall not be |
2431 | | -declared as the name of any other entity in any global scope of the |
2432 | | -program. No diagnostic is required for a violation of this rule by |
2433 | | -declarations in different translation units. |
2434 | | - |
2435 | 2411 | \rSec2[namespace.udecl]{The \tcode{using} declaration}% |
2436 | 2412 | \indextext{using-declaration|(} |
2437 | 2413 |
|
|
2976 | 2952 | \end{codeblock} |
2977 | 2953 | \exitexample |
2978 | 2954 |
|
| 2955 | + |
2979 | 2956 | \pnum |
2980 | | -If a namespace is extended by an |
2981 | | -\grammarterm{extension-namespace-definition} after a |
| 2957 | +If a namespace is extended~(\ref{namespace.def}) after a |
2982 | 2958 | \grammarterm{using-directive} for that namespace is given, the additional |
2983 | 2959 | members of the extended namespace and the members of namespaces |
2984 | 2960 | nominated by \grammarterm{using-directive}{s} in the |
2985 | | -\grammarterm{extension-namespace-definition} can be used after the |
2986 | | -\grammarterm{extension-namespace-definition}. |
| 2961 | +extending \grammarterm{namespace-definition} can be used after the |
| 2962 | +extending \grammarterm{namespace-definition}. |
2987 | 2963 |
|
2988 | 2964 | \pnum |
2989 | 2965 | If name lookup finds a declaration for a name in two different |
|
0 commit comments