tmp/tmpfb6l0fnb/{from.md → to.md}
RENAMED
|
@@ -9,20 +9,23 @@ 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
|
| 12 |
associated classes ([[basic.lookup.argdep]]).[^6]
|
| 13 |
|
|
|
|
|
|
|
| 14 |
``` cpp
|
| 15 |
template<typename T> struct number {
|
| 16 |
number(int);
|
| 17 |
friend number gcd(number x, number y) { return 0; };
|
| 18 |
};
|
| 19 |
|
| 20 |
void g() {
|
| 21 |
number<double> a(3), b(4);
|
| 22 |
-
a = gcd(a,b); // finds gcd because number<double> is an
|
| 23 |
-
//
|
| 24 |
-
// in its namespace (global scope)
|
| 25 |
b = gcd(3,4); // ill-formed; gcd is not visible
|
| 26 |
}
|
| 27 |
```
|
| 28 |
|
|
|
|
|
|
|
|
|
| 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
|
| 12 |
associated classes ([[basic.lookup.argdep]]).[^6]
|
| 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); // ill-formed; gcd is not visible
|
| 27 |
}
|
| 28 |
```
|
| 29 |
|
| 30 |
+
— *end example*]
|
| 31 |
+
|