| 1 |
// PR c++/12672 |
| 2 |
// Verify we don't substitute explicit template arguments into |
| 3 |
// candidate function templates when the arity of the function |
| 4 |
// template disagrees with the arity of the call. |
| 5 |
|
| 6 |
template<class T> |
| 7 |
struct A { typedef typename T::type type; }; |
| 8 |
|
| 9 |
template<class T> void f(T); // arity 1 |
| 10 |
template<class T> void f(T, T, T); // arity 3 |
| 11 |
|
| 12 |
template<class T> typename A<T>::type f(T, T); // arity 2 |
| 13 |
template<class T, class U> typename A<T>::type f(U, U); // arity 2 |
| 14 |
|
| 15 |
struct B { |
| 16 |
template<class T> void f(T); // arity 1 |
| 17 |
template<class T> void f(T, T, T); // arity 3 |
| 18 |
|
| 19 |
template<class T> typename A<T>::type f(T, T); // arity 2 |
| 20 |
template<class T, class U> typename A<T>::type f(U, U); // arity 2 |
| 21 |
}; |
| 22 |
|
| 23 |
int main() { |
| 24 |
// If overload resolution attempts deduction for any of the arity-2 function |
| 25 |
// templates, the substitution of explicit arguments into the template would |
| 26 |
// cause a hard error. |
| 27 |
f<int>(1); |
| 28 |
f<int>(1, 1, 1); |
| 29 |
|
| 30 |
B b; |
| 31 |
b.f<int>(1); |
| 32 |
b.f<int>(1, 1, 1); |
| 33 |
} |