summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/template/sfinae21.C
blob: 6086f2f9e7d70c7337d07336a350aaf52f5f0034 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// PR c++/44908

struct A { };

struct B
: public virtual A { };

template<bool, typename T = void> struct enable_if { typedef T type; };
template<typename T> struct enable_if<false, T> { };

template<typename From, typename To>
  class mini_is_convertible
  {
    typedef char one;
    typedef struct { char arr[2]; } two;

    template<typename To1>
      static void test_aux(To1);

    template<typename To1, typename From1>
      static typename
      enable_if<(sizeof(test_aux<To1>(From1()), 1) > 0), one>::type
      test(int);

    template<typename, typename>
      static two test(...);

    public:
      static const bool value = sizeof(test<To, From>(0)) == 1;
  }; 

template<typename From, typename To>
  const bool mini_is_convertible<From, To>::value;

int Test1[mini_is_convertible<int (B::*) (int),
	  int (A::*) (int)>::value ? -1 : 1];
int Test2[mini_is_convertible<int (B::*), int (A::*)>::value ? -1 : 1];
int Test3[mini_is_convertible<int (A::*) (int),
	  int (B::*) (int)>::value ? -1 : 1];
int Test4[mini_is_convertible<int (A::*), int (B::*)>::value ? -1 : 1];