From Jason Turner

[namespace.def]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpmzl1g0q2/{from.md → to.md} +20 -18
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.[^6]
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 or
200
- function[^7] the friend class or function is a member of the innermost
201
- enclosing namespace. The name of the friend is not found by unqualified
202
- lookup ([[basic.lookup.unqual]]) or by qualified lookup (
203
- [[basic.lookup.qual]]) until a matching declaration is provided in that
204
- namespace scope (either before or after the class definition granting
205
- friendship). If a friend function is called, its name may be found by
206
- the name lookup that considers functions from namespaces and classes
207
- associated with the types of the function arguments (
208
- [[basic.lookup.argdep]]). If the name in a `friend` declaration is
209
- neither qualified nor a *template-id* and the declaration is a function
210
- or an *elaborated-type-specifier*, the lookup to determine whether the
211
- entity has been previously declared shall not consider any scopes
212
- outside the innermost enclosing namespace. The other forms of `friend`
213
- declarations cannot declare a new member of the innermost enclosing
214
- namespace and thus follow the usual lookup rules.
 
 
215
 
216
  ``` cpp
217
- // Assume f and g have not yet been defined.
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