annotate gcc/testsuite/g++.dg/template/sfinae22.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // PR c++/44908
kono
parents:
diff changeset
2 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 #include <utility>
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 struct A { };
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 struct B
kono
parents:
diff changeset
9 : public virtual A { };
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 template<typename From, typename To>
kono
parents:
diff changeset
12 class mini_is_convertible
kono
parents:
diff changeset
13 {
kono
parents:
diff changeset
14 typedef char one;
kono
parents:
diff changeset
15 typedef struct { char arr[2]; } two;
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 template<typename To1>
kono
parents:
diff changeset
18 static void test_aux(To1);
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 template<typename To1, typename From1>
kono
parents:
diff changeset
21 static decltype(test_aux<To1>(std::declval<From1>()), one())
kono
parents:
diff changeset
22 test(int);
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 template<typename, typename>
kono
parents:
diff changeset
25 static two test(...);
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 public:
kono
parents:
diff changeset
28 static const bool value = sizeof(test<To, From>(0)) == 1;
kono
parents:
diff changeset
29 };
kono
parents:
diff changeset
30
kono
parents:
diff changeset
31 template<typename From, typename To>
kono
parents:
diff changeset
32 const bool mini_is_convertible<From, To>::value;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 static_assert (!mini_is_convertible<int (B::*) (int),
kono
parents:
diff changeset
35 int (A::*) (int)>::value, "");
kono
parents:
diff changeset
36 static_assert (!mini_is_convertible<int (B::*), int (A::*)>::value, "");
kono
parents:
diff changeset
37 static_assert (!mini_is_convertible<int (A::*) (int),
kono
parents:
diff changeset
38 int (B::*) (int)>::value, "");
kono
parents:
diff changeset
39 static_assert (!mini_is_convertible<int (A::*), int (B::*)>::value, "");