From Jason Turner

[temp.friend]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmprabqzq17/{from.md → to.md} +10 -10
tmp/tmprabqzq17/{from.md → to.md} RENAMED
@@ -1,24 +1,24 @@
1
  ### Friends <a id="temp.friend">[[temp.friend]]</a>
2
 
3
  A friend of a class or class template can be a function template or
4
  class template, a specialization of a function template or class
5
- template, or an ordinary (non-template) function or class. For a friend
6
- function declaration that is not a template declaration:
7
 
8
  - if the name of the friend is a qualified or unqualified *template-id*,
9
  the friend declaration refers to a specialization of a function
10
- template, otherwise
11
  - if the name of the friend is a *qualified-id* and a matching
12
  non-template function is found in the specified class or namespace,
13
  the friend declaration refers to that function, otherwise,
14
  - if the name of the friend is a *qualified-id* and a matching function
15
  template is found in the specified class or namespace, the friend
16
  declaration refers to the deduced specialization of that function
17
  template ([[temp.deduct.decl]]), otherwise,
18
- - the name shall be an *unqualified-id* that declares (or redeclares) an
19
- ordinary (non-template) function.
20
 
21
  ``` cpp
22
  template<class T> class task;
23
  template<class T> task<T>* preempt(task<T>*);
24
 
@@ -36,11 +36,11 @@ template<class T> class task {
36
  Here, each specialization of the `task` class template has the function
37
  `next_time` as a friend; because `process` does not have explicit
38
  *template-argument*s, each specialization of the `task` class template
39
  has an appropriately typed function `process` as a friend, and this
40
  friend is not a function template specialization; because the friend
41
- `preempt` has an explicit *template-argument* `<T>`, each specialization
42
  of the `task` class template has the appropriate specialization of the
43
  function template `preempt` as a friend; and each specialization of the
44
  `task` class template has all specializations of the function template
45
  `func` as friends. Similarly, each specialization of the `task` class
46
  template has the class template specialization `task<int>` as a friend,
@@ -75,14 +75,14 @@ class X {
75
  template<class T> struct A { X::Y ab; }; // OK
76
  template<class T> struct A<T*> { X::Y ab; }; // OK
77
  ```
78
 
79
  When a function is defined in a friend function declaration in a class
80
- template, the function is instantiated when the function is odr-used.
81
- The same restrictions on multiple declarations and definitions that
82
- apply to non-template function declarations and definitions also apply
83
- to these implicit definitions.
84
 
85
  A member of a class template may be declared to be a friend of a
86
  non-template class. In this case, the corresponding member of every
87
  specialization of the class template is a friend of the class granting
88
  friendship. For explicit specializations the corresponding member is the
 
1
  ### Friends <a id="temp.friend">[[temp.friend]]</a>
2
 
3
  A friend of a class or class template can be a function template or
4
  class template, a specialization of a function template or class
5
+ template, or a non-template function or class. For a friend function
6
+ declaration that is not a template declaration:
7
 
8
  - if the name of the friend is a qualified or unqualified *template-id*,
9
  the friend declaration refers to a specialization of a function
10
+ template, otherwise,
11
  - if the name of the friend is a *qualified-id* and a matching
12
  non-template function is found in the specified class or namespace,
13
  the friend declaration refers to that function, otherwise,
14
  - if the name of the friend is a *qualified-id* and a matching function
15
  template is found in the specified class or namespace, the friend
16
  declaration refers to the deduced specialization of that function
17
  template ([[temp.deduct.decl]]), otherwise,
18
+ - the name shall be an *unqualified-id* that declares (or redeclares) a
19
+ non-template function.
20
 
21
  ``` cpp
22
  template<class T> class task;
23
  template<class T> task<T>* preempt(task<T>*);
24
 
 
36
  Here, each specialization of the `task` class template has the function
37
  `next_time` as a friend; because `process` does not have explicit
38
  *template-argument*s, each specialization of the `task` class template
39
  has an appropriately typed function `process` as a friend, and this
40
  friend is not a function template specialization; because the friend
41
+ `preempt` has an explicit *template-argument* `T`, each specialization
42
  of the `task` class template has the appropriate specialization of the
43
  function template `preempt` as a friend; and each specialization of the
44
  `task` class template has all specializations of the function template
45
  `func` as friends. Similarly, each specialization of the `task` class
46
  template has the class template specialization `task<int>` as a friend,
 
75
  template<class T> struct A { X::Y ab; }; // OK
76
  template<class T> struct A<T*> { X::Y ab; }; // OK
77
  ```
78
 
79
  When a function is defined in a friend function declaration in a class
80
+ template, the function is instantiated when the function is odr-used (
81
+ [[basic.def.odr]]). The same restrictions on multiple declarations and
82
+ definitions that apply to non-template function declarations and
83
+ definitions also apply to these implicit definitions.
84
 
85
  A member of a class template may be declared to be a friend of a
86
  non-template class. In this case, the corresponding member of every
87
  specialization of the class template is a friend of the class granting
88
  friendship. For explicit specializations the corresponding member is the