OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [template/] [sfinae9.C] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// DR 339
2
//
3
// Test of the use of various assignment operators with SFINAE
4
 
5
// Boilerplate helpers
6
typedef char yes_type;
7
struct no_type { char data[2]; };
8
 
9
template T create_a();
10
template struct type { };
11
 
12
template struct enable_if { typedef T type; };
13
template struct enable_if { };
14
 
15
#define JOIN( X, Y ) DO_JOIN( X, Y )
16
#define DO_JOIN( X, Y ) DO_JOIN2(X,Y)
17
#define DO_JOIN2( X, Y ) X##Y
18
 
19
#define DEFINE_INFIX_BINARY_TRAIT(Name,Op)                              \
20
template                                        \
21
  typename enable_if<(sizeof(create_a() Op create_a(), 1) > 0),  \
22
                     yes_type>::type                                    \
23
  JOIN(check_,Name)(type, type);                                        \
24
                                                                        \
25
no_type JOIN(check_,Name)(...);                                         \
26
                                                                        \
27
template                                        \
28
struct Name                                                             \
29
{                                                                       \
30
  static const bool value =                                             \
31
    (sizeof(JOIN(check_,Name)(type(), type())) == sizeof(yes_type)); \
32
}
33
 
34
#ifdef __GXX_EXPERIMENTAL_CXX0X__
35
#  define STATIC_ASSERT(Expr) static_assert(Expr, #Expr)
36
#else
37
#  define STATIC_ASSERT(Expr) int JOIN(a,__LINE__)[Expr? 1 : -1]
38
#endif
39
 
40
struct Y {
41
  Y& operator=(Y&);
42
};
43
 
44
struct X {
45
  X& operator=(Y);
46
  X& operator+=(X);
47
  X& operator-=(X);
48
  X& operator*=(X);
49
  X& operator/=(X);
50
  X& operator%=(X);
51
  X& operator^=(X);
52
  X& operator&=(X);
53
  X& operator|=(X);
54
  X& operator<<=(X);
55
  X& operator>>=(X);
56
};
57
struct Z { };
58
 
59
// is_assignable
60
DEFINE_INFIX_BINARY_TRAIT(is_assignable, =);
61
STATIC_ASSERT((is_assignable::value));
62
STATIC_ASSERT((is_assignable::value));
63
STATIC_ASSERT((is_assignable::value));
64
STATIC_ASSERT((!is_assignable::value));
65
STATIC_ASSERT((is_assignable::value));
66
STATIC_ASSERT((is_assignable::value));
67
STATIC_ASSERT((!is_assignable::value));
68
STATIC_ASSERT((!is_assignable::value));
69
STATIC_ASSERT((!is_assignable::value));
70
 
71
// has_plus_assign
72
DEFINE_INFIX_BINARY_TRAIT(has_plus_assign, +=);
73
X& operator+=(X&, Y);
74
STATIC_ASSERT((has_plus_assign::value));
75
STATIC_ASSERT((has_plus_assign::value));
76
STATIC_ASSERT((has_plus_assign::value));
77
STATIC_ASSERT((has_plus_assign::value));
78
STATIC_ASSERT((!has_plus_assign::value));
79
STATIC_ASSERT((has_plus_assign::value));
80
STATIC_ASSERT((!has_plus_assign::value));
81
STATIC_ASSERT((!has_plus_assign::value));
82
STATIC_ASSERT((!has_plus_assign::value));
83
 
84
// has_minus_assign
85
DEFINE_INFIX_BINARY_TRAIT(has_minus_assign, -=);
86
X& operator-=(X&, Y);
87
STATIC_ASSERT((has_minus_assign::value));
88
STATIC_ASSERT((has_minus_assign::value));
89
STATIC_ASSERT((has_minus_assign::value));
90
STATIC_ASSERT((has_minus_assign::value));
91
STATIC_ASSERT((!has_minus_assign::value));
92
STATIC_ASSERT((has_minus_assign::value));
93
STATIC_ASSERT((!has_minus_assign::value));
94
STATIC_ASSERT((!has_minus_assign::value));
95
STATIC_ASSERT((!has_minus_assign::value));
96
STATIC_ASSERT((!has_minus_assign::value));
97
 
98
// has_multiply_assign
99
DEFINE_INFIX_BINARY_TRAIT(has_multiply_assign, *=);
100
X& operator*=(X&, Y);
101
STATIC_ASSERT((has_multiply_assign::value));
102
STATIC_ASSERT((has_multiply_assign::value));
103
STATIC_ASSERT((has_multiply_assign::value));
104
STATIC_ASSERT((!has_multiply_assign::value));
105
STATIC_ASSERT((!has_multiply_assign::value));
106
STATIC_ASSERT((has_multiply_assign::value));
107
STATIC_ASSERT((!has_multiply_assign::value));
108
STATIC_ASSERT((!has_multiply_assign::value));
109
STATIC_ASSERT((!has_multiply_assign::value));
110
STATIC_ASSERT((!has_multiply_assign::value));
111
 
112
// has_divide_assign
113
DEFINE_INFIX_BINARY_TRAIT(has_divide_assign, /=);
114
X& operator/=(X&, Y);
115
STATIC_ASSERT((has_divide_assign::value));
116
STATIC_ASSERT((has_divide_assign::value));
117
STATIC_ASSERT((has_divide_assign::value));
118
STATIC_ASSERT((!has_divide_assign::value));
119
STATIC_ASSERT((!has_divide_assign::value));
120
STATIC_ASSERT((has_divide_assign::value));
121
STATIC_ASSERT((!has_divide_assign::value));
122
STATIC_ASSERT((!has_divide_assign::value));
123
STATIC_ASSERT((!has_divide_assign::value));
124
 
125
// has_remainder_assign
126
DEFINE_INFIX_BINARY_TRAIT(has_remainder_assign, %=);
127
X& operator%=(X&, Y);
128
STATIC_ASSERT((has_remainder_assign::value));
129
STATIC_ASSERT((has_remainder_assign::value));
130
STATIC_ASSERT((!has_remainder_assign::value));
131
STATIC_ASSERT((has_remainder_assign::value));
132
STATIC_ASSERT((!has_remainder_assign::value));
133
STATIC_ASSERT((!has_remainder_assign::value));
134
STATIC_ASSERT((has_remainder_assign::value));
135
STATIC_ASSERT((!has_remainder_assign::value));
136
STATIC_ASSERT((!has_remainder_assign::value));
137
STATIC_ASSERT((!has_remainder_assign::value));
138
 
139
// has_xor_assign
140
DEFINE_INFIX_BINARY_TRAIT(has_xor_assign, ^=);
141
X& operator^=(X&, Y);
142
STATIC_ASSERT((has_xor_assign::value));
143
STATIC_ASSERT((has_xor_assign::value));
144
STATIC_ASSERT((!has_xor_assign::value));
145
STATIC_ASSERT((has_xor_assign::value));
146
STATIC_ASSERT((!has_xor_assign::value));
147
STATIC_ASSERT((!has_xor_assign::value));
148
STATIC_ASSERT((has_xor_assign::value));
149
STATIC_ASSERT((!has_xor_assign::value));
150
STATIC_ASSERT((!has_xor_assign::value));
151
STATIC_ASSERT((!has_xor_assign::value));
152
 
153
// has_bitand_assign
154
DEFINE_INFIX_BINARY_TRAIT(has_bitand_assign, &=);
155
X& operator&=(X&, Y);
156
STATIC_ASSERT((has_bitand_assign::value));
157
STATIC_ASSERT((has_bitand_assign::value));
158
STATIC_ASSERT((!has_bitand_assign::value));
159
STATIC_ASSERT((has_bitand_assign::value));
160
STATIC_ASSERT((!has_bitand_assign::value));
161
STATIC_ASSERT((!has_bitand_assign::value));
162
STATIC_ASSERT((has_bitand_assign::value));
163
STATIC_ASSERT((!has_bitand_assign::value));
164
STATIC_ASSERT((!has_bitand_assign::value));
165
STATIC_ASSERT((!has_bitand_assign::value));
166
 
167
// has_bitor_assign
168
DEFINE_INFIX_BINARY_TRAIT(has_bitor_assign, |=);
169
X& operator|=(X&, Y);
170
STATIC_ASSERT((has_bitor_assign::value));
171
STATIC_ASSERT((has_bitor_assign::value));
172
STATIC_ASSERT((!has_bitor_assign::value));
173
STATIC_ASSERT((has_bitor_assign::value));
174
STATIC_ASSERT((!has_bitor_assign::value));
175
STATIC_ASSERT((!has_bitor_assign::value));
176
STATIC_ASSERT((has_bitor_assign::value));
177
STATIC_ASSERT((!has_bitor_assign::value));
178
STATIC_ASSERT((!has_bitor_assign::value));
179
STATIC_ASSERT((!has_bitor_assign::value));
180
 
181
// has_left_shift_assign
182
DEFINE_INFIX_BINARY_TRAIT(has_left_shift_assign, <<=);
183
X& operator<<=(X&, Y);
184
STATIC_ASSERT((has_left_shift_assign::value));
185
STATIC_ASSERT((has_left_shift_assign::value));
186
STATIC_ASSERT((!has_left_shift_assign::value));
187
STATIC_ASSERT((has_left_shift_assign::value));
188
STATIC_ASSERT((!has_left_shift_assign::value));
189
STATIC_ASSERT((!has_left_shift_assign::value));
190
STATIC_ASSERT((has_left_shift_assign::value));
191
STATIC_ASSERT((!has_left_shift_assign::value));
192
STATIC_ASSERT((!has_left_shift_assign::value));
193
STATIC_ASSERT((!has_left_shift_assign::value));
194
 
195
// has_right_shift_assign
196
DEFINE_INFIX_BINARY_TRAIT(has_right_shift_assign, >>=);
197
X& operator>>=(X&, Y);
198
STATIC_ASSERT((has_right_shift_assign::value));
199
STATIC_ASSERT((has_right_shift_assign::value));
200
STATIC_ASSERT((!has_right_shift_assign::value));
201
STATIC_ASSERT((has_right_shift_assign::value));
202
STATIC_ASSERT((!has_right_shift_assign::value));
203
STATIC_ASSERT((!has_right_shift_assign::value));
204
STATIC_ASSERT((has_right_shift_assign::value));
205
STATIC_ASSERT((!has_right_shift_assign::value));
206
STATIC_ASSERT((!has_right_shift_assign::value));
207
STATIC_ASSERT((!has_right_shift_assign::value));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.