Debian Codegraph @

gcc/testsuite/g++.dg/template/sfinae19.C

raw
1 // PR c++/44907
2
3 struct A { };
4
5 struct B
6 : public A { };
7
8 struct C
9 : public A { };
10
11 struct D
12 : public B, public C { };
13
14 template<bool, typename T = void> struct enable_if { typedef T type; };
15 template<typename T> struct enable_if<false, T> { };
16
17 template<typename From, typename To>
18 class mini_is_convertible
19 {
20 typedef char one;
21 typedef struct { char arr[2]; } two;
22
23 template<typename To1>
24 static void test_aux(To1);
25
26 template<typename To1, typename From1>
27 static typename
28 enable_if<(sizeof(test_aux<To1>(From1()), 1) > 0), one>::type
29 test(int);
30
31 template<typename, typename>
32 static two test(...);
33
34 public:
35 static const bool value = sizeof(test<To, From>(0)) == 1;
36 };
37
38 template<typename From, typename To>
39 const bool mini_is_convertible<From, To>::value;
40
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];