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