1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 2 // expected-no-diagnostics 3 4 // Various tests related to partial ordering of variadic templates. 5 template<typename ...Types> struct tuple; 6 7 template<typename Tuple> 8 struct X1 { 9 static const unsigned value = 0; 10 }; 11 12 template<typename Head, typename ...Tail> 13 struct X1<tuple<Head, Tail...> > { 14 static const unsigned value = 1; 15 }; 16 17 template<typename Head, typename ...Tail> 18 struct X1<tuple<Head, Tail&...> > { 19 static const unsigned value = 2; 20 }; 21 22 template<typename Head, typename ...Tail> 23 struct X1<tuple<Head&, Tail&...> > { 24 static const unsigned value = 3; 25 }; 26 27 int check0[X1<tuple<>>::value == 0? 1 : -1]; 28 int check1[X1<tuple<int>>::value == 2? 1 : -1]; 29 int check2[X1<tuple<int, int>>::value == 1? 1 : -1]; 30 int check3[X1<tuple<int, int&>>::value == 2? 1 : -1]; 31 int check4[X1<tuple<int&, int&>>::value == 3? 1 : -1]; 32 33 // Partial ordering of function templates. 34 template<typename T1, typename T2, typename ...Rest> 35 int &f0(T1, T2, Rest...); 36 37 template<typename T1, typename T2> 38 float &f0(T1, T2); 39 40 void test_f0() { 41 int &ir1 = f0(1, 2.0, 'a'); 42 float &fr1 = f0(1, 2.0); 43 } 44 45 template<typename T1, typename T2, typename ...Rest> 46 int &f1(T1, T2, Rest...); 47 48 template<typename T1, typename T2> 49 float &f1(T1, T2, ...); 50 51 void test_f1() { 52 int &ir1 = f1(1, 2.0, 'a'); 53 } 54 55 template<typename T1, typename T2, typename ...Rest> 56 int &f2(T1, T2, Rest...); 57 58 float &f2(...); 59 60 void test_f2() { 61 int &ir1 = f2(1, 2.0, 'a'); 62 } 63