tmp/tmp2xrrnlai/{from.md → to.md}
RENAMED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
### Friend names declared within a class template <a id="temp.inject">[[temp.inject]]</a>
|
| 2 |
-
|
| 3 |
-
Friend classes or functions can be declared within a class template.
|
| 4 |
-
When a template is instantiated, the names of its friends are treated as
|
| 5 |
-
if the specialization had been explicitly declared at its point of
|
| 6 |
-
instantiation.
|
| 7 |
-
|
| 8 |
-
As with non-template classes, the names of namespace-scope friend
|
| 9 |
-
functions of a class template specialization are not visible during an
|
| 10 |
-
ordinary lookup unless explicitly declared at namespace scope
|
| 11 |
-
[[class.friend]]. Such names may be found under the rules for associated
|
| 12 |
-
classes [[basic.lookup.argdep]].[^11]
|
| 13 |
-
|
| 14 |
-
[*Example 1*:
|
| 15 |
-
|
| 16 |
-
``` cpp
|
| 17 |
-
template<typename T> struct number {
|
| 18 |
-
number(int);
|
| 19 |
-
friend number gcd(number x, number y) { return 0; };
|
| 20 |
-
};
|
| 21 |
-
|
| 22 |
-
void g() {
|
| 23 |
-
number<double> a(3), b(4);
|
| 24 |
-
a = gcd(a,b); // finds gcd because number<double> is an associated class,
|
| 25 |
-
// making gcd visible in its namespace (global scope)
|
| 26 |
-
b = gcd(3,4); // error: gcd is not visible
|
| 27 |
-
}
|
| 28 |
-
```
|
| 29 |
-
|
| 30 |
-
— *end example*]
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|