tmp/tmpsxnpj3nv/{from.md → to.md}
RENAMED
|
@@ -1,21 +1,20 @@
|
|
| 1 |
#### Partial ordering of function templates <a id="temp.func.order">[[temp.func.order]]</a>
|
| 2 |
|
| 3 |
-
If
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
specialization refers:
|
| 10 |
|
| 11 |
- during overload resolution for a call to a function template
|
| 12 |
specialization [[over.match.best]];
|
| 13 |
- when the address of a function template specialization is taken;
|
| 14 |
- when a placement operator delete that is a function template
|
| 15 |
-
specialization is selected to match a placement operator new
|
| 16 |
-
[[basic.stc.dynamic.deallocation]], [[expr.new]]
|
| 17 |
- when a friend function declaration [[temp.friend]], an explicit
|
| 18 |
instantiation [[temp.explicit]] or an explicit specialization
|
| 19 |
[[temp.expl.spec]] refers to a function template specialization.
|
| 20 |
|
| 21 |
Partial ordering selects which of two function templates is more
|
|
@@ -165,12 +164,12 @@ template<class T, class... U> void f(T, U...); // #1
|
|
| 165 |
template<class T > void f(T); // #2
|
| 166 |
template<class T, class... U> void g(T*, U...); // #3
|
| 167 |
template<class T > void g(T); // #4
|
| 168 |
|
| 169 |
void h(int i) {
|
| 170 |
-
f(&i); // OK
|
| 171 |
-
g(&i); // OK
|
| 172 |
}
|
| 173 |
```
|
| 174 |
|
| 175 |
— *end example*]
|
| 176 |
|
|
@@ -220,20 +219,20 @@ template <typename T> concept C = True<T>;
|
|
| 220 |
|
| 221 |
void f(C auto &, auto &) = delete;
|
| 222 |
template <C Q> void f(Q &, C auto &);
|
| 223 |
|
| 224 |
void g(struct A *ap, struct B *bp) {
|
| 225 |
-
f(*ap, *bp); // OK
|
| 226 |
}
|
| 227 |
|
| 228 |
template <typename T, typename U> struct X {};
|
| 229 |
|
| 230 |
template <typename T, C U, typename V> bool operator==(X<T, U>, V) = delete;
|
| 231 |
template <C T, C U, C V> bool operator==(T, X<U, V>);
|
| 232 |
|
| 233 |
void h() {
|
| 234 |
-
X<void *, int>{} == 0; // OK
|
| 235 |
}
|
| 236 |
```
|
| 237 |
|
| 238 |
— *end example*]
|
| 239 |
|
|
|
|
| 1 |
#### Partial ordering of function templates <a id="temp.func.order">[[temp.func.order]]</a>
|
| 2 |
|
| 3 |
+
If multiple function templates share a name, the use of that name can be
|
| 4 |
+
ambiguous because template argument deduction [[temp.deduct]] may
|
| 5 |
+
identify a specialization for more than one function template. *Partial
|
| 6 |
+
ordering* of overloaded function template declarations is used in the
|
| 7 |
+
following contexts to select the function template to which a function
|
| 8 |
+
template specialization refers:
|
|
|
|
| 9 |
|
| 10 |
- during overload resolution for a call to a function template
|
| 11 |
specialization [[over.match.best]];
|
| 12 |
- when the address of a function template specialization is taken;
|
| 13 |
- when a placement operator delete that is a function template
|
| 14 |
+
specialization is selected to match a placement operator new
|
| 15 |
+
[[basic.stc.dynamic.deallocation]], [[expr.new]];
|
| 16 |
- when a friend function declaration [[temp.friend]], an explicit
|
| 17 |
instantiation [[temp.explicit]] or an explicit specialization
|
| 18 |
[[temp.expl.spec]] refers to a function template specialization.
|
| 19 |
|
| 20 |
Partial ordering selects which of two function templates is more
|
|
|
|
| 164 |
template<class T > void f(T); // #2
|
| 165 |
template<class T, class... U> void g(T*, U...); // #3
|
| 166 |
template<class T > void g(T); // #4
|
| 167 |
|
| 168 |
void h(int i) {
|
| 169 |
+
f(&i); // OK, calls #2
|
| 170 |
+
g(&i); // OK, calls #3
|
| 171 |
}
|
| 172 |
```
|
| 173 |
|
| 174 |
— *end example*]
|
| 175 |
|
|
|
|
| 219 |
|
| 220 |
void f(C auto &, auto &) = delete;
|
| 221 |
template <C Q> void f(Q &, C auto &);
|
| 222 |
|
| 223 |
void g(struct A *ap, struct B *bp) {
|
| 224 |
+
f(*ap, *bp); // OK, can use different methods to produce template parameters
|
| 225 |
}
|
| 226 |
|
| 227 |
template <typename T, typename U> struct X {};
|
| 228 |
|
| 229 |
template <typename T, C U, typename V> bool operator==(X<T, U>, V) = delete;
|
| 230 |
template <C T, C U, C V> bool operator==(T, X<U, V>);
|
| 231 |
|
| 232 |
void h() {
|
| 233 |
+
X<void *, int>{} == 0; // OK, correspondence of [T, U, V] and [U, V, T]
|
| 234 |
}
|
| 235 |
```
|
| 236 |
|
| 237 |
— *end example*]
|
| 238 |
|