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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// PR c++/54191
// { dg-do compile { target c++11 } }
struct B
{};
struct D
: private B
{};
template<typename T>
T &&declval();
template<typename From, typename = decltype(B{declval<From>()})>
constexpr bool test_braced_cast_to_base(int)
{ return true; }
template<typename>
constexpr bool test_braced_cast_to_base(bool)
{ return false; }
static_assert(!test_braced_cast_to_base<D>(0), "");
template<typename From, typename = decltype(D{declval<From>()})>
constexpr bool test_braced_cast_to_derived(int)
{ return true; }
template<typename>
constexpr bool test_braced_cast_to_derived(bool)
{ return false; }
static_assert(!test_braced_cast_to_derived<B>(0), "");
typedef B *PB;
template<typename From, typename = decltype(PB{declval<From>()})>
constexpr bool test_braced_cast_to_ptr_to_base(int)
{ return true; }
template<typename>
constexpr bool test_braced_cast_to_ptr_to_base(bool)
{ return false; }
static_assert(!test_braced_cast_to_ptr_to_base<D *>(0), "");
typedef D *PD;
template<typename From, typename = decltype(PD{declval<From>()})>
constexpr bool test_braced_cast_to_ptr_to_derived(int)
{ return true; }
template<typename>
constexpr bool test_braced_cast_to_ptr_to_derived(bool)
{ return false; }
static_assert(!test_braced_cast_to_ptr_to_derived<B *>(0), "");
template<typename From, typename To,
typename = decltype(static_cast<To>(declval<From>()))>
constexpr bool test_static_cast(int)
{ return true; }
template<typename, typename>
constexpr bool test_static_cast(bool)
{ return false; }
static_assert(!test_static_cast<B &, D &>(0), "");
static_assert(!test_static_cast<B *, D *>(0), "");
template<typename From, typename To,
typename = decltype(dynamic_cast<To>(declval<From>()))>
constexpr bool test_dynamic_cast(int)
{ return true; }
template<typename, typename>
constexpr bool test_dynamic_cast(bool)
{ return false; }
static_assert(!test_dynamic_cast<D &, B &>(0), "");
static_assert(!test_dynamic_cast<D *, B *>(0), "");
int B::*pm = 0;
template<typename T, typename = decltype(declval<T>().*pm)>
constexpr bool test_member_ptr_dot(int)
{ return true; }
template<typename>
constexpr bool test_member_ptr_dot(bool)
{ return false; }
static_assert(!test_member_ptr_dot<D>(0), "");
template<typename T, typename = decltype(declval<T>()->*pm)>
constexpr bool test_member_ptr_arrow(int)
{ return true; }
template<typename>
constexpr bool test_member_ptr_arrow(bool)
{ return false; }
static_assert(!test_member_ptr_arrow<D *>(0), "");
template<typename T, typename U,
typename = decltype(declval<T>() < declval<U>())>
constexpr bool test_rel_op(int)
{ return true; }
template<typename, typename>
constexpr bool test_rel_op(bool)
{ return false; }
static_assert(!test_rel_op<D *, B *>(0), "");
template<typename T, typename U,
typename = decltype(declval<T>() == declval<U>())>
constexpr bool test_eq(int)
{ return true; }
template<typename, typename>
constexpr bool test_eq(bool)
{ return false; }
static_assert(!test_eq<D *, B *>(0), "");
template<typename T, typename U,
typename = decltype(false ? declval<T>() : declval<U>())>
constexpr bool test_cond_op(int)
{ return true; }
template<typename, typename>
constexpr bool test_cond_op(bool)
{ return false; }
static_assert(!test_cond_op<B *, D *>(0), "");
|