aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/template/sfinae20.C
blob: 61bd8da93d98d8814b5d0ce88e968cdcd3449c3e (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
41
42
43
44
45
// PR c++/44907
// { dg-do compile { target c++11 } }

#include <utility>

struct A { };

struct B
: public A { };

struct C
: public A { };

struct D
: public B, public C { };

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 decltype(test_aux<To1>(std::declval<From1>()), one())
      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;

static_assert (!mini_is_convertible<D*, A*>::value, "");
static_assert (!mini_is_convertible<A*, D*>::value, "");
static_assert (!mini_is_convertible<D&, A&>::value, "");
static_assert (!mini_is_convertible<A&, D&>::value, "");
static_assert (!mini_is_convertible<D, A>::value, "");
static_assert (!mini_is_convertible<A, D>::value, "");