Debian Codegraph @

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

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