Debian Codegraph @

clang/test/CXX/temp/temp.fct.spec/temp.deduct/sfinae-1.cpp

raw
1 // RUN: %clang_cc1 -verify %s
2 // expected-no-diagnostics
3
4 typedef char one_byte;
5 struct two_bytes { char data[2]; };
6
7 template<typename T> one_byte __is_class_check(int T::*);
8 template<typename T> two_bytes __is_class_check(...);
9
10 template<typename T> struct is_class {
11 static const bool value = sizeof(__is_class_check<T>(0)) == 1;
12 };
13
14 struct X { };
15
16 int array0[is_class<X>::value? 1 : -1];
17 int array1[is_class<int>::value? -1 : 1];
18 int array2[is_class<char[3]>::value? -1 : 1];
19
20 namespace instantiation_order1 {
21 template<typename T>
22 struct it_is_a_trap {
23 typedef typename T::trap type;
24 };
25
26 template<bool, typename T = void>
27 struct enable_if {
28 typedef T type;
29 };
30
31 template<typename T>
32 struct enable_if<false, T> { };
33
34 template<typename T>
35 typename enable_if<sizeof(T) == 17>::type
36 f(const T&, typename it_is_a_trap<T>::type* = 0);
37
38 void f(...);
39
40 void test_f() {
41 f('a');
42 }
43 }