tmp/tmpmzl1g0q2/{from.md → to.md}
RENAMED
|
@@ -136,11 +136,11 @@ An *unnamed-namespace-definition* behaves as if it were replaced by
|
|
| 136 |
```
|
| 137 |
|
| 138 |
where `inline` appears if and only if it appears in the
|
| 139 |
*unnamed-namespace-definition*, all occurrences of *unique* in a
|
| 140 |
translation unit are replaced by the same identifier, and this
|
| 141 |
-
identifier differs from all other identifiers in the entire program.[^
|
| 142 |
|
| 143 |
``` cpp
|
| 144 |
namespace { int i; } // unique ::i
|
| 145 |
void f() { i++; } // unique ::i++
|
| 146 |
|
|
@@ -194,29 +194,31 @@ namespace R {
|
|
| 194 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 195 |
}
|
| 196 |
```
|
| 197 |
|
| 198 |
Every name first declared in a namespace is a member of that namespace.
|
| 199 |
-
If a `friend` declaration in a non-local class first declares a class
|
| 200 |
-
function[^
|
| 201 |
-
enclosing namespace. The
|
| 202 |
-
|
| 203 |
-
[[basic.lookup.
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
|
| 216 |
``` cpp
|
| 217 |
-
// Assume f and g have not yet been
|
| 218 |
void h(int);
|
| 219 |
template <class T> void f2(T);
|
| 220 |
namespace A {
|
| 221 |
class X {
|
| 222 |
friend void f(X); // A::f(X) is a friend
|
|
|
|
| 136 |
```
|
| 137 |
|
| 138 |
where `inline` appears if and only if it appears in the
|
| 139 |
*unnamed-namespace-definition*, all occurrences of *unique* in a
|
| 140 |
translation unit are replaced by the same identifier, and this
|
| 141 |
+
identifier differs from all other identifiers in the entire program.[^5]
|
| 142 |
|
| 143 |
``` cpp
|
| 144 |
namespace { int i; } // unique ::i
|
| 145 |
void f() { i++; } // unique ::i++
|
| 146 |
|
|
|
|
| 194 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 195 |
}
|
| 196 |
```
|
| 197 |
|
| 198 |
Every name first declared in a namespace is a member of that namespace.
|
| 199 |
+
If a `friend` declaration in a non-local class first declares a class,
|
| 200 |
+
function, class template or function template[^6] the friend is a member
|
| 201 |
+
of the innermost enclosing namespace. The `friend` declaration does not
|
| 202 |
+
by itself make the name visible to unqualified lookup (
|
| 203 |
+
[[basic.lookup.unqual]]) or qualified lookup ([[basic.lookup.qual]]).
|
| 204 |
+
The name of the friend will be visible in its namespace if a matching
|
| 205 |
+
declaration is provided at namespace scope (either before or after the
|
| 206 |
+
class definition granting friendship). If a friend function or function
|
| 207 |
+
template is called, its name may be found by the name lookup that
|
| 208 |
+
considers functions from namespaces and classes associated with the
|
| 209 |
+
types of the function arguments ([[basic.lookup.argdep]]). If the name
|
| 210 |
+
in a `friend` declaration is neither qualified nor a *template-id* and
|
| 211 |
+
the declaration is a function or an *elaborated-type-specifier*, the
|
| 212 |
+
lookup to determine whether the entity has been previously declared
|
| 213 |
+
shall not consider any scopes outside the innermost enclosing namespace.
|
| 214 |
+
The other forms of `friend` declarations cannot declare a new member of
|
| 215 |
+
the innermost enclosing namespace and thus follow the usual lookup
|
| 216 |
+
rules.
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
+
// Assume f and g have not yet been declared.
|
| 220 |
void h(int);
|
| 221 |
template <class T> void f2(T);
|
| 222 |
namespace A {
|
| 223 |
class X {
|
| 224 |
friend void f(X); // A::f(X) is a friend
|