From Jason Turner

[namespace.memdef]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpqkwhthx0/{from.md → to.md} +19 -17
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 or
38
- function[^7] the friend class or function is a member of the innermost
39
- enclosing namespace. The name of the friend is not found by unqualified
40
- lookup ([[basic.lookup.unqual]]) or by qualified lookup (
41
- [[basic.lookup.qual]]) until a matching declaration is provided in that
42
- namespace scope (either before or after the class definition granting
43
- friendship). If a friend function is called, its name may be found by
44
- the name lookup that considers functions from namespaces and classes
45
- associated with the types of the function arguments (
46
- [[basic.lookup.argdep]]). If the name in a `friend` declaration is
47
- neither qualified nor a *template-id* and the declaration is a function
48
- or an *elaborated-type-specifier*, the lookup to determine whether the
49
- entity has been previously declared shall not consider any scopes
50
- outside the innermost enclosing namespace. The other forms of `friend`
51
- declarations cannot declare a new member of the innermost enclosing
52
- namespace and thus follow the usual lookup rules.
 
 
53
 
54
  ``` cpp
55
- // Assume f and g have not yet been defined.
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