PR c++/81917 - ICE with void_t and partial specialization.
[official-gcc.git] / gcc / testsuite / g++.dg / template / sfinae19.C
blob59be183feb5b89dfaa89f1a07784cd127613836b
1 // PR c++/44907
3 struct A { };
5 struct B
6 : public A { };
8 struct C
9 : public A { };
11 struct D
12 : public B, public C { };
14 template<bool, typename T = void> struct enable_if { typedef T type; };
15 template<typename T> struct enable_if<false, T> { };
17 template<typename From, typename To>
18   class mini_is_convertible
19   {
20     typedef char one;
21     typedef struct { char arr[2]; } two;
23     template<typename To1>
24       static void test_aux(To1);
26     template<typename To1, typename From1>
27       static typename
28       enable_if<(sizeof(test_aux<To1>(From1()), 1) > 0), one>::type
29       test(int);
31     template<typename, typename>
32       static two test(...);
34     public:
35       static const bool value = sizeof(test<To, From>(0)) == 1;
36   }; 
38 template<typename From, typename To>
39   const bool mini_is_convertible<From, To>::value;
41 int Test1[mini_is_convertible<D*, A*>::value ? -1 : 1]; 
42 int Test2[mini_is_convertible<A*, D*>::value ? -1 : 1];
43 int Test3[mini_is_convertible<D, A>::value ? -1 : 1]; 
44 int Test4[mini_is_convertible<A, D>::value ? -1 : 1];