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