Debian Codegraph @

clang/test/CXX/temp/temp.decls/temp.variadic/deduction.cpp

raw
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
2 // expected-no-diagnostics
3
4 namespace DeductionForInstantiation {
5 template<unsigned I, typename ...Types>
6 struct X { };
7
8 template<typename ...Types>
9 void f0(X<sizeof...(Types), Types&...>) { }
10
11 // No explicitly-specified arguments
12 template void f0(X<0>);
13 template void f0(X<1, int&>);
14 template void f0(X<2, int&, short&>);
15
16 // One explicitly-specified argument
17 template void f0<float>(X<1, float&>);
18 template void f0<double>(X<1, double&>);
19
20 // Two explicitly-specialized arguments
21 template void f0<char, unsigned char>(X<2, char&, unsigned char&>);
22 template void f0<signed char, char>(X<2, signed char&, char&>);
23
24 // FIXME: Extension of explicitly-specified arguments
25 // template void f0<short, int>(X<3, short&, int&, long&>);
26 }
27
28 namespace DeductionWithConversion {
29 template<char...> struct char_values {
30 static const unsigned value = 0;
31 };
32
33 template<int C1, char C3>
34 struct char_values<C1, 12, C3> {
35 static const unsigned value = 1;
36 };
37
38 int check0[char_values<1, 12, 3>::value == 1? 1 : -1];
39
40 template<int...> struct int_values {
41 static const unsigned value = 0;
42 };
43
44 template<unsigned char C1, unsigned char C3>
45 struct int_values<C1, 12, C3> {
46 static const unsigned value = 1;
47 };
48
49 int check1[int_values<256, 12, 3>::value == 0? 1 : -1];
50 int check2[int_values<3, 12, 3>::value == 1? 1 : -1];
51 }