tmp/tmpqkwhthx0/{from.md → to.md}
RENAMED
|
@@ -32,29 +32,31 @@ namespace R {
|
|
| 32 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 33 |
}
|
| 34 |
```
|
| 35 |
|
| 36 |
Every name first declared in a namespace is a member of that namespace.
|
| 37 |
-
If a `friend` declaration in a non-local class first declares a class
|
| 38 |
-
function[^
|
| 39 |
-
enclosing namespace. The
|
| 40 |
-
|
| 41 |
-
[[basic.lookup.
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
|
| 54 |
``` cpp
|
| 55 |
-
// Assume f and g have not yet been
|
| 56 |
void h(int);
|
| 57 |
template <class T> void f2(T);
|
| 58 |
namespace A {
|
| 59 |
class X {
|
| 60 |
friend void f(X); // A::f(X) is a friend
|
|
|
|
| 32 |
void Q::V::g() { /* ... */ } // error: R doesn't enclose Q
|
| 33 |
}
|
| 34 |
```
|
| 35 |
|
| 36 |
Every name first declared in a namespace is a member of that namespace.
|
| 37 |
+
If a `friend` declaration in a non-local class first declares a class,
|
| 38 |
+
function, class template or function template[^6] the friend is a member
|
| 39 |
+
of the innermost enclosing namespace. The `friend` declaration does not
|
| 40 |
+
by itself make the name visible to unqualified lookup (
|
| 41 |
+
[[basic.lookup.unqual]]) or qualified lookup ([[basic.lookup.qual]]).
|
| 42 |
+
The name of the friend will be visible in its namespace if a matching
|
| 43 |
+
declaration is provided at namespace scope (either before or after the
|
| 44 |
+
class definition granting friendship). If a friend function or function
|
| 45 |
+
template is called, its name may be found by the name lookup that
|
| 46 |
+
considers functions from namespaces and classes associated with the
|
| 47 |
+
types of the function arguments ([[basic.lookup.argdep]]). If the name
|
| 48 |
+
in a `friend` declaration is neither qualified nor a *template-id* and
|
| 49 |
+
the declaration is a function or an *elaborated-type-specifier*, the
|
| 50 |
+
lookup to determine whether the entity has been previously declared
|
| 51 |
+
shall not consider any scopes outside the innermost enclosing namespace.
|
| 52 |
+
The other forms of `friend` declarations cannot declare a new member of
|
| 53 |
+
the innermost enclosing namespace and thus follow the usual lookup
|
| 54 |
+
rules.
|
| 55 |
|
| 56 |
``` cpp
|
| 57 |
+
// Assume f and g have not yet been declared.
|
| 58 |
void h(int);
|
| 59 |
template <class T> void f2(T);
|
| 60 |
namespace A {
|
| 61 |
class X {
|
| 62 |
friend void f(X); // A::f(X) is a friend
|