From Jason Turner

[temp.friend]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmposv5bfvr/{from.md → to.md} +15 -23
tmp/tmposv5bfvr/{from.md → to.md} RENAMED
@@ -1,24 +1,10 @@
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
  [*Example 1*:
22
 
23
  ``` cpp
24
  template<class T> class task;
@@ -48,10 +34,19 @@ function template `preempt` as a friend; and each specialization of the
48
  template has the class template specialization `task<int>` as a friend,
49
  and has all specializations of the class template `frd` as friends.
50
 
51
  — *end example*]
52
 
 
 
 
 
 
 
 
 
 
53
  A friend template may be declared within a class or class template. A
54
  friend function template may be defined within a class or class
55
  template, but a friend class template may not be defined in a class or
56
  class template. In these cases, all specializations of the friend class
57
  or friend function template are friends of the class or class template
@@ -68,11 +63,11 @@ class A {
68
 
69
  — *end example*]
70
 
71
  A template friend declaration specifies that all specializations of that
72
  template, whether they are implicitly instantiated [[temp.inst]],
73
- partially specialized [[temp.class.spec]] or explicitly specialized
74
  [[temp.expl.spec]], are friends of the class containing the template
75
  friend declaration.
76
 
77
  [*Example 3*:
78
 
@@ -91,17 +86,17 @@ template<class T> struct A<T*> { X::Y ab; }; // OK
91
  A template friend declaration may declare a member of a dependent type
92
  to be a friend. The friend declaration shall declare a function or
93
  specify a type with an *elaborated-type-specifier*, in either case with
94
  a *nested-name-specifier* ending with a *simple-template-id*, *C*, whose
95
  *template-name* names a class template. The template parameters of the
96
- template friend declaration shall be deducible from *C* (
97
- [[temp.deduct.type]]). In this case, a member of a specialization *S* of
98
  the class template is a friend of the class granting friendship if
99
  deduction of the template parameters of *C* from *S* succeeds, and
100
  substituting the deduced template arguments into the friend declaration
101
- produces a declaration that would be a valid redeclaration of the member
102
- of the specialization.
103
 
104
  [*Example 4*:
105
 
106
  ``` cpp
107
  template<class T> struct A {
@@ -137,13 +132,10 @@ class C {
137
  }; // of those function templates
138
  ```
139
 
140
  — *end example*]
141
 
142
- [*Note 1*: A friend declaration may first declare a member of an
143
- enclosing namespace scope [[temp.inject]]. — *end note*]
144
-
145
  A friend template shall not be declared in a local class.
146
 
147
  Friend declarations shall not declare partial specializations.
148
 
149
  [*Example 5*:
 
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.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  [*Example 1*:
8
 
9
  ``` cpp
10
  template<class T> class task;
 
34
  template has the class template specialization `task<int>` as a friend,
35
  and has all specializations of the class template `frd` as friends.
36
 
37
  — *end example*]
38
 
39
+ Friend classes, class templates, functions, or function templates can be
40
+ declared within a class template. When a template is instantiated, its
41
+ friend declarations are found by name lookup as if the specialization
42
+ had been explicitly declared at its point of instantiation.
43
+
44
+ [*Note 1*: They can introduce entities that belong to an enclosing
45
+ namespace scope [[dcl.meaning]], in which case they are attached to the
46
+ same module as the class template [[module.unit]]. — *end note*]
47
+
48
  A friend template may be declared within a class or class template. A
49
  friend function template may be defined within a class or class
50
  template, but a friend class template may not be defined in a class or
51
  class template. In these cases, all specializations of the friend class
52
  or friend function template are friends of the class or class template
 
63
 
64
  — *end example*]
65
 
66
  A template friend declaration specifies that all specializations of that
67
  template, whether they are implicitly instantiated [[temp.inst]],
68
+ partially specialized [[temp.spec.partial]] or explicitly specialized
69
  [[temp.expl.spec]], are friends of the class containing the template
70
  friend declaration.
71
 
72
  [*Example 3*:
73
 
 
86
  A template friend declaration may declare a member of a dependent type
87
  to be a friend. The friend declaration shall declare a function or
88
  specify a type with an *elaborated-type-specifier*, in either case with
89
  a *nested-name-specifier* ending with a *simple-template-id*, *C*, whose
90
  *template-name* names a class template. The template parameters of the
91
+ template friend declaration shall be deducible from *C*
92
+ [[temp.deduct.type]]. In this case, a member of a specialization *S* of
93
  the class template is a friend of the class granting friendship if
94
  deduction of the template parameters of *C* from *S* succeeds, and
95
  substituting the deduced template arguments into the friend declaration
96
+ produces a declaration that corresponds to the member of the
97
+ specialization.
98
 
99
  [*Example 4*:
100
 
101
  ``` cpp
102
  template<class T> struct A {
 
132
  }; // of those function templates
133
  ```
134
 
135
  — *end example*]
136
 
 
 
 
137
  A friend template shall not be declared in a local class.
138
 
139
  Friend declarations shall not declare partial specializations.
140
 
141
  [*Example 5*: