1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 template<class T> void apply(T x, void (*f)(T)) { f(x); } // expected-note 2 {{failed template argument deduction}}\
5 // expected-note {{no overload of 'temp2' matching 'void (*)(int)'}}
7 template<class A> void temp(A);
9 // okay: deduce T=int from first argument, A=int during overload
13 // okay: deduce T=int from first and second arguments
16 // deduction failure: T=int from first, T=long from second
17 apply(0, &temp<long>); // expected-error {{no matching function for call to 'apply'}}
24 // okay: deductions match
27 // deduction failure: deduced T=long from first argument, T=int from second
28 apply(0L, &over); // expected-error {{no matching function for call to 'apply'}}
34 // deduce T=int from first arg, second arg is undeduced context,
35 // pick correct overload of 'over' during overload resolution for 'apply'
39 template<class A, class B> B temp2(A);
41 // deduce T=int from first arg, A=int B=void during overload resolution
44 apply(0, &temp2<int>);
47 apply(0, &temp2<long>); // expected-error {{no matching function for call to 'apply'}}
52 template<class T> void invoke(void (*f)(T)) { f(T()); } // expected-note 6 {{couldn't infer template argument}} \
53 // expected-note {{failed template argument deduction}}
55 template<class T> void temp(T);
57 // deduction failure: overload has template => undeduced context
58 invoke(&temp); // expected-error {{no matching function for call to 'invoke'}}
59 invoke(&temp<>); // expected-error {{no matching function for call to 'invoke'}}
61 // okay: full template-id
69 // okay: only one overload matches
76 // deduction failure: overload has multiple matches => undeduced context
77 invoke(&over); // expected-error {{no matching function for call to 'invoke'}}
80 template<class A, class B> B temp2(A);
82 // deduction failure: overload has template => undeduced context
83 // (even though partial application temp2<int> could in theory
84 // let us infer T=int)
85 invoke(&temp2); // expected-error {{no matching function for call to 'invoke'}}
86 invoke(&temp2<>); // expected-error {{no matching function for call to 'invoke'}}
87 invoke(&temp2<int>); // expected-error {{no matching function for call to 'invoke'}}
89 // okay: full template-id
90 invoke(&temp2<int, void>);
93 invoke(&temp2<int, int>); // expected-error {{no matching function for call to 'invoke'}}