1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
2 | |
3 | template <class T> T* f(int); // #1 |
4 | template <class T, class U> T& f(U); // #2 |
5 | |
6 | void g() { |
7 | int *ip = f<int>(1); // calls #1 |
8 | } |
9 | |
10 | template<typename T> |
11 | struct identity { |
12 | typedef T type; |
13 | }; |
14 | |
15 | template <class T> |
16 | T* f2(int, typename identity<T>::type = 0); |
17 | template <class T, class U> |
18 | T& f2(U, typename identity<T>::type = 0); |
19 | |
20 | void g2() { |
21 | int* ip = f2<int>(1); |
22 | } |
23 | |
24 | template<class T, class U> struct A { }; |
25 | |
26 | template<class T, class U> inline int *f3( U, A<U,T>* p = 0 ); // #1 expected-note{{candidate function [with T = int, U = int]}} |
27 | template< class U> inline float *f3( U, A<U,U>* p = 0 ); // #2 expected-note{{candidate function [with U = int]}} |
28 | |
29 | void g3() { |
30 | float *fp = f3<int>( 42, (A<int,int>*)0 ); // Ok, picks #2. |
31 | f3<int>( 42 ); // expected-error{{call to 'f3' is ambiguous}} |
32 | |
33 | } |
34 | |
35 | namespace PR9006 { |
36 | struct X { |
37 | template <class Get> |
38 | int &f(char const* name, Get fget, char const* docstr = 0); |
39 | |
40 | template <class Get, class Set> |
41 | float &f(char const* name, Get fget, Set fset, char const* docstr = 0); |
42 | }; |
43 | |
44 | void test(X x) { |
45 | int &ir = x.f("blah", 0, "blah"); |
46 | } |
47 | } |
48 | |