]>
Commit | Line | Data |
---|---|---|
ec087ba3 NDR |
1 | //{ dg-do run { target c++11 } } |
2 | ||
3 | // 2019-04-10 Nina Dinka Ranns <dinka.ranns@gmail.com> | |
4 | // | |
7adcbafe | 5 | // Copyright (C) 2019-2022 Free Software Foundation, Inc. |
ec087ba3 NDR |
6 | // |
7 | // This file is part of the GNU ISO C++ Library. This library is free | |
8 | // software; you can redistribute it and/or modify it under the | |
9 | // terms of the GNU General Public License as published by the | |
10 | // Free Software Foundation; either version 3, or (at your option) | |
11 | // any later version. | |
12 | // | |
13 | // This library is distributed in the hope that it will be useful, | |
14 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | // GNU General Public License for more details. | |
17 | // | |
18 | // You should have received a copy of the GNU General Public License along | |
19 | // with this library; see the file COPYING3. If not see | |
20 | // <http://www.gnu.org/licenses/>. | |
21 | ||
22 | #include <tuple> | |
23 | #include <testsuite_tr1.h> | |
24 | #include <utility> | |
25 | ||
26 | using namespace __gnu_test; | |
27 | ||
28 | bool throwing_ctor_called = false; | |
29 | ||
30 | namespace test_trait{ | |
31 | template <bool B> | |
32 | using bool_constant = std::integral_constant<bool, B>; | |
33 | ||
34 | template<typename From, typename To, | |
35 | bool = std::__or_<std::is_void<From>, std::is_function<To>, | |
36 | std::is_array<To>>::value> | |
37 | struct is_nt_convertible_helper | |
38 | : std::is_void<To> | |
39 | { }; | |
40 | ||
41 | template<typename From, typename To> | |
42 | class is_nt_convertible_helper<From, To, false> | |
43 | { | |
44 | template<typename To1> | |
45 | static void test_aux(To1) noexcept; | |
46 | ||
47 | template<typename From1, typename To1> | |
48 | static bool_constant<noexcept(test_aux<To1>({std::declval<From1>()}))> | |
49 | test(int); | |
50 | ||
51 | template<typename, typename> | |
52 | static std::false_type | |
53 | test(...); | |
54 | ||
55 | public: | |
56 | using type = decltype(test<From, To>(0)); | |
57 | }; | |
58 | ||
ce9f305e JW |
59 | // Similar to std::is_nothrow_convertible, but only considers whether the |
60 | // actual conversion can throw (and not any potential copies of From). | |
61 | // This means the result is not affected by copy elision of From in C++17. | |
ec087ba3 NDR |
62 | template<typename From, typename To> |
63 | struct is_nothrow_convertible | |
64 | : public is_nt_convertible_helper<From, To>::type | |
65 | { }; | |
66 | } | |
67 | ||
68 | template<typename T> | |
69 | bool checkDefaultThrowConstruct() | |
70 | { | |
71 | throwing_ctor_called = false; | |
72 | bool deduced_nothrow = std::is_nothrow_constructible<T>::value; | |
73 | T t{}; | |
74 | return throwing_ctor_called != deduced_nothrow; | |
75 | } | |
76 | template<typename T, typename U> | |
77 | bool checkCopyThrowConstruct() | |
78 | { | |
79 | throwing_ctor_called = false; | |
80 | bool deduced_nothrow = std::is_nothrow_constructible<T, U&>::value; | |
81 | U u; | |
82 | T t{u}; | |
83 | return throwing_ctor_called != deduced_nothrow; | |
84 | } | |
85 | template<typename T, typename U> | |
86 | bool checkMoveThrowConstruct() | |
87 | { | |
88 | throwing_ctor_called = false; | |
89 | bool deduced_nothrow = std::is_nothrow_constructible<T, U&&>::value; | |
90 | U u; | |
91 | T t{std::move(u)}; | |
92 | return throwing_ctor_called != deduced_nothrow; | |
93 | } | |
94 | ||
95 | typedef std::tuple<int> IT; | |
96 | typedef std::tuple<const int> CIT; | |
97 | typedef std::tuple<int&&> RVIT; | |
98 | typedef std::tuple<int, int> IIT; | |
99 | typedef std::pair<int, int> IIP; | |
100 | typedef std::tuple<int, int, int> IIIT; | |
101 | ||
102 | namespace DefaultConstructionTests | |
103 | { | |
104 | struct NoexceptDC | |
105 | { | |
106 | NoexceptDC() noexcept(true){} | |
107 | }; | |
108 | ||
109 | struct ExceptDC | |
110 | { | |
111 | ExceptDC() noexcept(false) | |
112 | { throwing_ctor_called = true; } | |
113 | }; | |
114 | ||
115 | struct ExplicitNoexceptDC | |
116 | { | |
117 | explicit ExplicitNoexceptDC() noexcept(true) | |
118 | {} | |
119 | }; | |
120 | ||
121 | struct ExplicitExceptDC | |
122 | { | |
123 | explicit ExplicitExceptDC() noexcept(false) | |
124 | { throwing_ctor_called = true; } | |
125 | }; | |
126 | ||
127 | typedef std::tuple<NoexceptDC> NDT; | |
128 | typedef std::tuple<ExceptDC> EDT; | |
129 | typedef std::tuple<ExplicitNoexceptDC> X_NDT; | |
130 | typedef std::tuple<ExplicitExceptDC> X_EDT; | |
131 | ||
132 | typedef std::tuple<NoexceptDC,NoexceptDC> NNDT; | |
133 | typedef std::tuple<ExceptDC,ExceptDC> EEDT; | |
134 | typedef std::tuple<ExceptDC,NoexceptDC> ENDT; | |
135 | typedef std::tuple<ExplicitNoexceptDC,NoexceptDC> X_NNDT; | |
136 | typedef std::tuple<ExplicitExceptDC,ExceptDC> X_EEDT; | |
137 | typedef std::tuple<ExceptDC,ExplicitNoexceptDC> X_ENDT; | |
138 | ||
139 | typedef std::tuple<long, NoexceptDC, NoexceptDC> LNDNDT; | |
140 | typedef std::tuple<long, NoexceptDC, ExceptDC> LNDEDT; | |
141 | typedef std::tuple<long, ExplicitNoexceptDC, NoexceptDC> X_LNEDNDT; | |
142 | typedef std::tuple<long, ExplicitNoexceptDC, ExceptDC> X_LNEDEDT; | |
143 | typedef std::tuple<long, ExplicitExceptDC, ExceptDC> X_LEEDEDT; | |
144 | ||
145 | ||
146 | /* if it has E in the name, it contains a type that throws when default constructed */ | |
147 | static_assert(std::is_nothrow_constructible<IT>::value, ""); | |
148 | static_assert(std::is_nothrow_constructible<NDT>::value, ""); | |
149 | static_assert(!std::is_nothrow_constructible<EDT>::value, ""); | |
150 | static_assert(std::is_nothrow_constructible<X_NDT>::value, ""); | |
151 | static_assert(!std::is_nothrow_constructible<X_EDT>::value, ""); | |
152 | ||
153 | static_assert(std::is_nothrow_constructible<IIT>::value, ""); | |
154 | static_assert(std::is_nothrow_constructible<NNDT>::value, ""); | |
155 | static_assert(!std::is_nothrow_constructible<EEDT>::value, ""); | |
156 | static_assert(!std::is_nothrow_constructible<ENDT>::value, ""); | |
157 | static_assert(std::is_nothrow_constructible<X_NNDT>::value, ""); | |
158 | static_assert(!std::is_nothrow_constructible<X_EEDT>::value, ""); | |
159 | static_assert(!std::is_nothrow_constructible<X_ENDT>::value, ""); | |
160 | ||
161 | static_assert(std::is_nothrow_constructible<IIIT>::value, ""); | |
162 | static_assert(std::is_nothrow_constructible<LNDNDT>::value, ""); | |
163 | static_assert(!std::is_nothrow_constructible<LNDEDT>::value, ""); | |
164 | static_assert(std::is_nothrow_constructible<X_LNEDNDT>::value, ""); | |
165 | static_assert(!std::is_nothrow_constructible<X_LNEDEDT>::value, ""); | |
166 | static_assert(!std::is_nothrow_constructible<X_LEEDEDT>::value, ""); | |
167 | ||
168 | void Run() | |
169 | { | |
170 | VERIFY( checkDefaultThrowConstruct<IT>() ); | |
171 | VERIFY( checkDefaultThrowConstruct<NDT>() ); | |
172 | VERIFY( checkDefaultThrowConstruct<EDT>() ); | |
173 | VERIFY( checkDefaultThrowConstruct<X_NDT>() ); | |
174 | VERIFY( checkDefaultThrowConstruct<X_EDT>() ); | |
175 | ||
176 | VERIFY( checkDefaultThrowConstruct<IIT>() ); | |
177 | VERIFY( checkDefaultThrowConstruct<NNDT>() ); | |
178 | VERIFY( checkDefaultThrowConstruct<EEDT>() ); | |
179 | VERIFY( checkDefaultThrowConstruct<ENDT>() ); | |
180 | VERIFY( checkDefaultThrowConstruct<X_NNDT>() ); | |
181 | VERIFY( checkDefaultThrowConstruct<X_EEDT>() ); | |
182 | VERIFY( checkDefaultThrowConstruct<X_ENDT>() ); | |
183 | ||
184 | VERIFY( checkDefaultThrowConstruct<IIIT>() ); | |
185 | VERIFY( checkDefaultThrowConstruct<LNDNDT>() ); | |
186 | VERIFY( checkDefaultThrowConstruct<LNDEDT>() ); | |
187 | VERIFY( checkDefaultThrowConstruct<X_LNEDNDT>() ); | |
188 | VERIFY( checkDefaultThrowConstruct<X_LNEDEDT>() ); | |
189 | } | |
190 | } | |
191 | namespace AllNoThrow | |
192 | { | |
193 | static_assert(std::is_nothrow_constructible<IT, int&>::value, ""); | |
194 | static_assert(std::is_nothrow_constructible<IT, const int&>::value, ""); | |
195 | static_assert(std::is_nothrow_constructible<IT, int&&>::value, ""); | |
196 | static_assert(std::is_nothrow_constructible<IT, const int&&>::value, ""); | |
197 | ||
198 | static_assert(std::is_nothrow_constructible<IT, IT>::value, ""); | |
199 | static_assert(std::is_nothrow_constructible<IT, const IT &>::value, ""); | |
200 | static_assert(std::is_nothrow_constructible<IT, CIT>::value, ""); | |
201 | ||
202 | static_assert(test_trait::is_nothrow_convertible<int&, IT>::value, ""); | |
203 | static_assert(test_trait::is_nothrow_convertible<const int&, IT>::value, ""); | |
204 | static_assert(test_trait::is_nothrow_convertible<int&&, IT>::value, ""); | |
205 | static_assert(test_trait::is_nothrow_convertible<const int&&, IT>::value, ""); | |
206 | ||
207 | static_assert(std::is_nothrow_constructible<IIT, int&, int&>::value, ""); | |
208 | static_assert(std::is_nothrow_constructible<IIT, const int&, const int&>::value, ""); | |
209 | static_assert(std::is_nothrow_constructible<IIT, int&&, int&&>::value, ""); | |
210 | static_assert(std::is_nothrow_constructible<IIT, const int&&, const int&&>::value, ""); | |
211 | ||
212 | static_assert(std::is_nothrow_constructible<IIT, IIT>::value, ""); | |
213 | static_assert(std::is_nothrow_constructible<IIT, const IIT &>::value, ""); | |
214 | static_assert(std::is_nothrow_constructible<IIT, IIP>::value, ""); | |
215 | static_assert(std::is_nothrow_constructible<IIT, const IIP>::value, ""); | |
216 | ||
217 | static_assert(test_trait::is_nothrow_convertible<IIT, IIT>::value, ""); | |
218 | static_assert(test_trait::is_nothrow_convertible<const IIT &, IIT>::value, ""); | |
219 | static_assert(test_trait::is_nothrow_convertible<IIP, IIT>::value, ""); | |
220 | static_assert(test_trait::is_nothrow_convertible<const IIP, IIT>::value, ""); | |
221 | ||
222 | static_assert(std::is_nothrow_constructible<IIIT, IIIT&>::value, ""); | |
223 | static_assert(std::is_nothrow_constructible<IIIT, const IIIT &>::value, ""); | |
224 | static_assert(std::is_nothrow_constructible<IIIT, IIIT&&>::value, ""); | |
225 | static_assert(std::is_nothrow_constructible<IIIT, const IIIT&&>::value, ""); | |
226 | ||
227 | static_assert(test_trait::is_nothrow_convertible<IIIT&, IIIT>::value, ""); | |
228 | static_assert(test_trait::is_nothrow_convertible<const IIIT &, IIIT>::value, ""); | |
229 | static_assert(test_trait::is_nothrow_convertible<IIIT&&, IIIT>::value, ""); | |
230 | static_assert(test_trait::is_nothrow_convertible<const IIIT&&, IIIT>::value, ""); | |
231 | ||
232 | static_assert(std::is_nothrow_constructible<IIIT, int&, int&, int&>::value, ""); | |
233 | static_assert(std::is_nothrow_constructible<IIIT, const int&, const int&, int&>::value, ""); | |
234 | static_assert(std::is_nothrow_constructible<IIIT, int&&, int&&, int&>::value, ""); | |
235 | static_assert(std::is_nothrow_constructible<IIIT, const int&&, const int&&, int&>::value, ""); | |
236 | } | |
237 | namespace ThrowCopyNothrowConversion | |
238 | { | |
239 | struct A | |
240 | { | |
241 | A() noexcept(true) | |
242 | {} | |
243 | ||
244 | A(const int&) noexcept(true) | |
245 | {} | |
246 | ||
247 | A(const A&) noexcept(false) | |
248 | { throwing_ctor_called = true; } | |
249 | ||
250 | }; | |
251 | ||
252 | typedef std::tuple<A> AT; | |
253 | typedef std::tuple<A,A> AAT; | |
254 | typedef std::pair<A,A> AAP; | |
255 | typedef std::tuple<int,A> IAT; | |
256 | typedef std::pair<int,A> IAP; | |
257 | typedef std::tuple<A,A,A> AAAT; | |
258 | typedef std::tuple<int,int,A> IIAT; | |
259 | ||
260 | /* one element tests */ | |
261 | static_assert(std::is_nothrow_constructible<AT,int>::value,""); | |
262 | static_assert(std::is_nothrow_constructible<AT,const int>::value,""); | |
263 | static_assert(std::is_nothrow_constructible<AT,int&>::value,""); | |
264 | static_assert(std::is_nothrow_constructible<AT,const int &>::value,""); | |
265 | ||
266 | static_assert(std::is_nothrow_constructible<AT,IT>::value,""); | |
267 | static_assert(std::is_nothrow_constructible<AT,const IT>::value,""); | |
268 | static_assert(std::is_nothrow_constructible<AT,IT&>::value,""); | |
269 | static_assert(std::is_nothrow_constructible<AT,const IT &>::value,""); | |
270 | static_assert(std::is_nothrow_constructible<AT,std::tuple<int&>>::value,""); | |
271 | static_assert(std::is_nothrow_constructible<AT,const std::tuple<int&&>>::value,""); | |
272 | ||
273 | static_assert(test_trait::is_nothrow_convertible<int,AT>::value,""); | |
274 | static_assert(test_trait::is_nothrow_convertible<const int,AT>::value,""); | |
275 | static_assert(test_trait::is_nothrow_convertible<int&,AT>::value,""); | |
276 | static_assert(test_trait::is_nothrow_convertible<const int &,AT>::value,""); | |
277 | ||
278 | static_assert(test_trait::is_nothrow_convertible<IT,AT>::value,""); | |
279 | static_assert(test_trait::is_nothrow_convertible<const IT,AT>::value,""); | |
280 | static_assert(test_trait::is_nothrow_convertible<IT&,AT>::value,""); | |
281 | static_assert(test_trait::is_nothrow_convertible<const IT &,AT>::value,""); | |
282 | static_assert(test_trait::is_nothrow_convertible<std::tuple<int&>,AT>::value,""); | |
283 | static_assert(test_trait::is_nothrow_convertible<const std::tuple<int&&>,AT>::value,""); | |
284 | ||
285 | static_assert(!std::is_nothrow_constructible<AT,A>::value,""); | |
286 | static_assert(!std::is_nothrow_constructible<AT,const A>::value,""); | |
287 | static_assert(!std::is_nothrow_constructible<AT,A&>::value,""); | |
288 | static_assert(!std::is_nothrow_constructible<AT,const A &>::value,""); | |
289 | ||
290 | static_assert(!std::is_nothrow_constructible<AT,AT>::value,""); | |
291 | static_assert(!std::is_nothrow_constructible<AT,const AT>::value,""); | |
292 | static_assert(!std::is_nothrow_constructible<AT,AT&>::value,""); | |
293 | static_assert(!std::is_nothrow_constructible<AT,const AT &>::value,""); | |
294 | static_assert(!std::is_nothrow_constructible<AT,std::tuple<A&>>::value,""); | |
295 | static_assert(!std::is_nothrow_constructible<AT,const std::tuple<A&&>>::value,""); | |
296 | ||
297 | static_assert(!test_trait::is_nothrow_convertible<A,AT>::value,""); | |
298 | static_assert(!test_trait::is_nothrow_convertible<const A,AT>::value,""); | |
299 | static_assert(!test_trait::is_nothrow_convertible<A&,AT>::value,""); | |
300 | static_assert(!test_trait::is_nothrow_convertible<const A &,AT>::value,""); | |
301 | ||
302 | static_assert(!test_trait::is_nothrow_convertible<AT,AT>::value,""); | |
303 | static_assert(!test_trait::is_nothrow_convertible<const AT,AT>::value,""); | |
304 | static_assert(!test_trait::is_nothrow_convertible<AT&,AT>::value,""); | |
305 | static_assert(!test_trait::is_nothrow_convertible<const AT &,AT>::value,""); | |
306 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<A&>,AT>::value,""); | |
307 | static_assert(!test_trait::is_nothrow_convertible<const std::tuple<A&&>,AT>::value,""); | |
308 | ||
309 | /* two element tests */ | |
310 | ||
311 | static_assert(std::is_nothrow_constructible<AAT,IIT>::value,""); | |
312 | static_assert(std::is_nothrow_constructible<AAT,const IIT>::value,""); | |
313 | static_assert(std::is_nothrow_constructible<AAT,IIT&>::value,""); | |
314 | static_assert(std::is_nothrow_constructible<AAT,const IIT &>::value,""); | |
315 | static_assert(std::is_nothrow_constructible<AAT,IIP>::value,""); | |
316 | static_assert(std::is_nothrow_constructible<AAT,const IIP>::value,""); | |
317 | static_assert(std::is_nothrow_constructible<AAT,IIP&>::value,""); | |
318 | static_assert(std::is_nothrow_constructible<AAT,const IIP &>::value,""); | |
319 | static_assert(std::is_nothrow_constructible<AAT,std::tuple<int&,int&>>::value,""); | |
320 | ||
321 | static_assert(test_trait::is_nothrow_convertible<IIT,AAT>::value,""); | |
322 | static_assert(test_trait::is_nothrow_convertible<const IIT,AAT>::value,""); | |
323 | static_assert(test_trait::is_nothrow_convertible<IIT&,AAT>::value,""); | |
324 | static_assert(test_trait::is_nothrow_convertible<const IIT &,AAT>::value,""); | |
325 | static_assert(test_trait::is_nothrow_convertible<IIP,AAT>::value,""); | |
326 | static_assert(test_trait::is_nothrow_convertible<const IIP,AAT>::value,""); | |
327 | static_assert(test_trait::is_nothrow_convertible<IIP&,AAT>::value,""); | |
328 | static_assert(test_trait::is_nothrow_convertible<const IIP &,AAT>::value,""); | |
329 | static_assert(test_trait::is_nothrow_convertible<std::tuple<int&,int&>,AAT>::value,""); | |
330 | ||
331 | ||
332 | static_assert(!std::is_nothrow_constructible<AAT,AAT>::value,""); | |
333 | static_assert(!std::is_nothrow_constructible<AAT,const AAT>::value,""); | |
334 | static_assert(!std::is_nothrow_constructible<AAT,AAT&>::value,""); | |
335 | static_assert(!std::is_nothrow_constructible<AAT,const AAT &>::value,""); | |
336 | static_assert(!std::is_nothrow_constructible<AAT,AAP>::value,""); | |
337 | static_assert(!std::is_nothrow_constructible<AAT,const AAP>::value,""); | |
338 | static_assert(!std::is_nothrow_constructible<AAT,AAP&>::value,""); | |
339 | static_assert(!std::is_nothrow_constructible<AAT,const AAP &>::value,""); | |
340 | static_assert(!std::is_nothrow_constructible<AAT,std::tuple<A&,A&>>::value,""); | |
341 | ||
342 | static_assert(!std::is_nothrow_constructible<AAT,IAT>::value,""); | |
343 | static_assert(!std::is_nothrow_constructible<AAT,const IAT>::value,""); | |
344 | static_assert(!std::is_nothrow_constructible<AAT,IAT&>::value,""); | |
345 | static_assert(!std::is_nothrow_constructible<AAT,const IAT &>::value,""); | |
346 | static_assert(!std::is_nothrow_constructible<AAT,IAP>::value,""); | |
347 | static_assert(!std::is_nothrow_constructible<AAT,const IAP>::value,""); | |
348 | static_assert(!std::is_nothrow_constructible<AAT,IAP&>::value,""); | |
349 | static_assert(!std::is_nothrow_constructible<AAT,const IAP &>::value,""); | |
350 | static_assert(!std::is_nothrow_constructible<AAT,std::tuple<A&,int&>>::value,""); | |
351 | ||
352 | static_assert(!test_trait::is_nothrow_convertible<AAT,AAT>::value,""); | |
353 | static_assert(!test_trait::is_nothrow_convertible<const AAT,AAT>::value,""); | |
354 | static_assert(!test_trait::is_nothrow_convertible<AAT&,AAT>::value,""); | |
355 | static_assert(!test_trait::is_nothrow_convertible<const AAT &,AAT>::value,""); | |
356 | static_assert(!test_trait::is_nothrow_convertible<AAP,AAT>::value,""); | |
357 | static_assert(!test_trait::is_nothrow_convertible<const AAP,AAT>::value,""); | |
358 | static_assert(!test_trait::is_nothrow_convertible<AAP&,AAT>::value,""); | |
359 | static_assert(!test_trait::is_nothrow_convertible<const AAP &,AAT>::value,""); | |
360 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<A&,A&>,AAT>::value,""); | |
361 | ||
362 | static_assert(!test_trait::is_nothrow_convertible<IAT,AAT>::value,""); | |
363 | static_assert(!test_trait::is_nothrow_convertible<const IAT,AAT>::value,""); | |
364 | static_assert(!test_trait::is_nothrow_convertible<IAT&,AAT>::value,""); | |
365 | static_assert(!test_trait::is_nothrow_convertible<const IAT &,AAT>::value,""); | |
366 | static_assert(!test_trait::is_nothrow_convertible<IAP,AAT>::value,""); | |
367 | static_assert(!test_trait::is_nothrow_convertible<const IAP,AAT>::value,""); | |
368 | static_assert(!test_trait::is_nothrow_convertible<IAP&,AAT>::value,""); | |
369 | static_assert(!test_trait::is_nothrow_convertible<const IAP &,AAT>::value,""); | |
370 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<A&,int&>,AAT>::value,""); | |
371 | ||
372 | ||
373 | static_assert(std::is_nothrow_constructible<AAT,int&,const int&>::value,""); | |
374 | static_assert(std::is_nothrow_constructible<AAT,int&&,const int&&>::value,""); | |
375 | ||
376 | static_assert(!std::is_nothrow_constructible<AAT,A&,const A&>::value,""); | |
377 | static_assert(!std::is_nothrow_constructible<AAT,A&&,const A&&>::value,""); | |
378 | static_assert(!std::is_nothrow_constructible<AAT,const A &&,const int&&>::value,""); | |
379 | ||
380 | /* three element tests */ | |
381 | static_assert(std::is_nothrow_constructible<AAAT,IIIT>::value,""); | |
382 | static_assert(std::is_nothrow_constructible<AAAT,const IIIT>::value,""); | |
383 | static_assert(std::is_nothrow_constructible<AAAT,IIIT&>::value,""); | |
384 | static_assert(std::is_nothrow_constructible<AAAT,const IIIT &>::value,""); | |
385 | ||
386 | static_assert(test_trait::is_nothrow_convertible<IIIT,AAAT>::value,""); | |
387 | static_assert(test_trait::is_nothrow_convertible<const IIIT,AAAT>::value,""); | |
388 | static_assert(test_trait::is_nothrow_convertible<IIIT&,AAAT>::value,""); | |
389 | static_assert(test_trait::is_nothrow_convertible<const IIIT &,AAAT>::value,""); | |
390 | ||
391 | static_assert(!std::is_nothrow_constructible<AAAT,IIAT>::value,""); | |
392 | static_assert(!std::is_nothrow_constructible<AAAT,const IIAT>::value,""); | |
393 | static_assert(!std::is_nothrow_constructible<AAAT,IIAT&>::value,""); | |
394 | static_assert(!std::is_nothrow_constructible<AAAT,const IIAT &>::value,""); | |
395 | ||
396 | static_assert(!test_trait::is_nothrow_convertible<IIAT,AAAT>::value,""); | |
397 | static_assert(!test_trait::is_nothrow_convertible<const IIAT,AAAT>::value,""); | |
398 | static_assert(!test_trait::is_nothrow_convertible<IIAT&,AAAT>::value,""); | |
399 | static_assert(!test_trait::is_nothrow_convertible<const IIAT &,AAAT>::value,""); | |
400 | ||
401 | static_assert(std::is_nothrow_constructible<AAAT,int&,const int&,int&&>::value,""); | |
402 | static_assert(!std::is_nothrow_constructible<AAAT,int &,const A &&,const int&&>::value,""); | |
403 | ||
404 | void Run() | |
405 | { | |
406 | VERIFY( (checkCopyThrowConstruct<AT,int>()) ); | |
407 | VERIFY( (checkMoveThrowConstruct<AT,int>()) ); | |
408 | VERIFY( (checkCopyThrowConstruct<AT,A>()) ); | |
409 | VERIFY( (checkMoveThrowConstruct<AT,A>()) ); | |
410 | VERIFY( (checkCopyThrowConstruct<AT,AT>()) ); | |
411 | VERIFY( (checkMoveThrowConstruct<AT,AT>()) ); | |
412 | VERIFY( (checkCopyThrowConstruct<AT,IT>()) ); | |
413 | VERIFY( (checkMoveThrowConstruct<AT,IT>()) ); | |
414 | VERIFY( (checkMoveThrowConstruct<AT,CIT>()) ); | |
415 | VERIFY( (checkCopyThrowConstruct<AAT,AAT>()) ); | |
416 | VERIFY( (checkMoveThrowConstruct<AAT,AAT>()) ); | |
417 | VERIFY( (checkCopyThrowConstruct<AAT,IIT>()) ); | |
418 | VERIFY( (checkMoveThrowConstruct<AAT,IIT>()) ); | |
419 | VERIFY( (checkCopyThrowConstruct<AAT,IIP>()) ); | |
420 | VERIFY( (checkMoveThrowConstruct<AAT,IIP>()) ); | |
421 | ||
422 | VERIFY( (checkCopyThrowConstruct<AAT,std::tuple<int,A>>()) ); | |
423 | VERIFY( (checkMoveThrowConstruct<AAT,std::tuple<int,A>>()) ); | |
424 | VERIFY( (checkCopyThrowConstruct<AAT,std::pair<int,A>>()) ); | |
425 | VERIFY( (checkMoveThrowConstruct<AAT,std::pair<int,A>>()) ); | |
426 | ||
427 | VERIFY( (checkCopyThrowConstruct<AAAT,AAAT>()) ); | |
428 | VERIFY( (checkMoveThrowConstruct<AAAT,AAAT>()) ); | |
429 | VERIFY( (checkCopyThrowConstruct<AAAT,IIAT>()) ); | |
430 | VERIFY( (checkMoveThrowConstruct<AAAT,IIAT>()) ); | |
431 | } | |
432 | } | |
433 | namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion | |
434 | { | |
435 | struct B | |
436 | { | |
437 | B() noexcept(true) | |
438 | {} | |
439 | ||
440 | B(const int&) noexcept(false) | |
441 | { throwing_ctor_called = true; } | |
442 | ||
443 | B(int&&) noexcept(true) | |
444 | {} | |
445 | ||
446 | B(const B&) noexcept(true) | |
447 | {} | |
448 | ||
449 | B(B&&) noexcept(false) | |
450 | { throwing_ctor_called = true; } | |
451 | }; | |
452 | ||
453 | ||
454 | struct D | |
455 | { | |
456 | D() noexcept(true) | |
457 | {} | |
458 | ||
459 | explicit | |
460 | D(const int&) noexcept(false) | |
461 | { throwing_ctor_called = true; } | |
462 | ||
463 | explicit | |
464 | D(int&&) noexcept(true) | |
465 | {} | |
466 | ||
467 | explicit | |
468 | D(const D&) noexcept(true) | |
469 | {} | |
470 | ||
471 | explicit | |
472 | D(D&&) noexcept(false) | |
473 | { throwing_ctor_called = true; } | |
474 | ||
475 | }; | |
476 | ||
477 | typedef std::tuple<B> BT; | |
478 | typedef std::tuple<B,B> BBT; | |
479 | typedef std::pair<B,B> BBP; | |
480 | typedef std::tuple<D> DT; | |
481 | typedef std::tuple<D,D> DDT; | |
482 | typedef std::pair<D,D> DDP; | |
483 | typedef std::tuple<int,D> IDT; | |
484 | typedef std::pair<int,D> IDP; | |
485 | typedef std::tuple<int,B> IBT; | |
486 | typedef std::pair<int,B> IBP; | |
487 | typedef std::tuple<D,B> DBT; | |
488 | typedef std::pair<D,B> DBP; | |
489 | typedef std::tuple<B,B,B> BBBT; | |
490 | typedef std::tuple<D,D,D> DDDT; | |
491 | typedef std::tuple<int,D,int> IDIT; | |
492 | typedef std::tuple<int,B,int> IBIT; | |
493 | typedef std::tuple<int,D,B> IDBT; | |
494 | ||
495 | /* one element tests */ | |
496 | static_assert(std::is_nothrow_constructible<BT, int>::value, ""); | |
497 | static_assert(!std::is_nothrow_constructible<BT, const int>::value, ""); | |
498 | static_assert(!std::is_nothrow_constructible<BT, int&>::value, ""); | |
499 | static_assert(!std::is_nothrow_constructible<BT, const int &>::value, ""); | |
500 | ||
501 | static_assert(std::is_nothrow_constructible<BT, IT>::value, ""); | |
502 | static_assert(!std::is_nothrow_constructible<BT,const IT>::value, ""); | |
503 | static_assert(!std::is_nothrow_constructible<BT, IT&>::value, ""); | |
504 | static_assert(!std::is_nothrow_constructible<BT, const IT &>::value, ""); | |
505 | static_assert(!std::is_nothrow_constructible<BT, std::tuple<int&>>::value, ""); | |
506 | static_assert(!std::is_nothrow_constructible<BT, const std::tuple<int&&>>::value, ""); | |
507 | ||
508 | static_assert(test_trait::is_nothrow_convertible<int,BT>::value,""); | |
509 | static_assert(!test_trait::is_nothrow_convertible<const int,BT>::value,""); | |
510 | static_assert(!test_trait::is_nothrow_convertible<int&,BT>::value,""); | |
511 | static_assert(!test_trait::is_nothrow_convertible<const int &,BT>::value,""); | |
512 | ||
513 | static_assert(test_trait::is_nothrow_convertible<IT,BT>::value,""); | |
514 | static_assert(!test_trait::is_nothrow_convertible<const IT,BT>::value,""); | |
515 | static_assert(!test_trait::is_nothrow_convertible<IT&,BT>::value,""); | |
516 | static_assert(!test_trait::is_nothrow_convertible<const IT &,BT>::value,""); | |
517 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<int&>,BT>::value,""); | |
518 | static_assert(!test_trait::is_nothrow_convertible<const std::tuple<int&&>,BT>::value,""); | |
519 | ||
520 | ||
521 | static_assert(!std::is_nothrow_constructible<BT, B>::value, ""); | |
522 | static_assert(std::is_nothrow_constructible<BT,const B>::value, ""); | |
523 | static_assert(std::is_nothrow_constructible<BT, B&>::value, ""); | |
524 | static_assert(std::is_nothrow_constructible<BT, const B &>::value, ""); | |
525 | ||
526 | static_assert(!std::is_nothrow_constructible<BT, BT>::value, ""); | |
527 | static_assert(std::is_nothrow_constructible<BT,const BT>::value, ""); | |
528 | static_assert(std::is_nothrow_constructible<BT, BT&>::value, ""); | |
529 | static_assert(std::is_nothrow_constructible<BT, const BT &>::value, ""); | |
530 | static_assert(std::is_nothrow_constructible<BT, std::tuple<B&>>::value, ""); | |
531 | static_assert(std::is_nothrow_constructible<BT, const std::tuple<B&&>>::value, ""); | |
532 | ||
533 | static_assert(!test_trait::is_nothrow_convertible<B,BT>::value,""); | |
534 | static_assert(test_trait::is_nothrow_convertible<const B,BT>::value,""); | |
535 | static_assert(test_trait::is_nothrow_convertible<B&,BT>::value,""); | |
536 | static_assert(test_trait::is_nothrow_convertible<const B &,BT>::value,""); | |
537 | ||
538 | static_assert(!test_trait::is_nothrow_convertible<BT,BT>::value,""); | |
539 | static_assert(test_trait::is_nothrow_convertible<const BT,BT>::value,""); | |
540 | static_assert(test_trait::is_nothrow_convertible<BT&,BT>::value,""); | |
541 | static_assert(test_trait::is_nothrow_convertible<const BT &,BT>::value,""); | |
542 | static_assert(test_trait::is_nothrow_convertible<std::tuple<B&>,BT>::value,""); | |
543 | static_assert(test_trait::is_nothrow_convertible<const std::tuple<B&&>,BT>::value,""); | |
544 | ||
545 | /* explicit */ | |
546 | static_assert(std::is_nothrow_constructible<DT, int>::value, ""); | |
547 | static_assert(!std::is_nothrow_constructible<DT, const int>::value, ""); | |
548 | static_assert(!std::is_nothrow_constructible<DT, int&>::value, ""); | |
549 | static_assert(!std::is_nothrow_constructible<DT, const int &>::value, ""); | |
550 | ||
551 | static_assert(std::is_nothrow_constructible<DT, IT>::value, ""); | |
552 | static_assert(!std::is_nothrow_constructible<DT,const IT>::value, ""); | |
553 | static_assert(!std::is_nothrow_constructible<DT, IT&>::value, ""); | |
554 | static_assert(!std::is_nothrow_constructible<DT, const IT &>::value, ""); | |
555 | static_assert(!std::is_nothrow_constructible<DT, std::tuple<int&>>::value, ""); | |
556 | static_assert(!std::is_nothrow_constructible<DT, const std::tuple<int&&>>::value, ""); | |
557 | ||
558 | static_assert(!std::is_nothrow_constructible<DT, D>::value, ""); | |
559 | static_assert(std::is_nothrow_constructible<DT,const D>::value, ""); | |
560 | static_assert(std::is_nothrow_constructible<DT, D&>::value, ""); | |
561 | static_assert(std::is_nothrow_constructible<DT, const D &>::value, ""); | |
562 | ||
563 | static_assert(!std::is_nothrow_constructible<DT, DT>::value, ""); | |
564 | static_assert(std::is_nothrow_constructible<DT,const DT>::value, ""); | |
565 | static_assert(std::is_nothrow_constructible<DT, DT&>::value, ""); | |
566 | static_assert(std::is_nothrow_constructible<DT, const DT &>::value, ""); | |
567 | static_assert(std::is_nothrow_constructible<DT, std::tuple<D&>>::value, ""); | |
568 | static_assert(std::is_nothrow_constructible<DT, const std::tuple<D&&>>::value, ""); | |
569 | ||
570 | static_assert(!test_trait::is_nothrow_convertible<DT,DT>::value,""); | |
571 | static_assert(test_trait::is_nothrow_convertible<const DT,DT>::value,""); | |
572 | static_assert(test_trait::is_nothrow_convertible<DT&,DT>::value,""); | |
573 | static_assert(test_trait::is_nothrow_convertible<const DT &,DT>::value,""); | |
574 | ||
575 | /* two elements tests */ | |
576 | static_assert(std::is_nothrow_constructible<BBT,IIT>::value,""); | |
577 | static_assert(!std::is_nothrow_constructible<BBT,const IIT>::value,""); | |
578 | static_assert(!std::is_nothrow_constructible<BBT,IIT&>::value,""); | |
579 | static_assert(!std::is_nothrow_constructible<BBT,const IIT &>::value,""); | |
580 | static_assert(std::is_nothrow_constructible<BBT,IIP>::value,""); | |
581 | static_assert(!std::is_nothrow_constructible<BBT,const IIP>::value,""); | |
582 | static_assert(!std::is_nothrow_constructible<BBT,IIP&>::value,""); | |
583 | static_assert(!std::is_nothrow_constructible<BBT,const IIP &>::value,""); | |
584 | static_assert(!std::is_nothrow_constructible<BBT,std::tuple<int&,int&>>::value,""); | |
585 | ||
586 | static_assert(test_trait::is_nothrow_convertible<IIT,BBT>::value,""); | |
587 | static_assert(!test_trait::is_nothrow_convertible<const IIT,BBT>::value,""); | |
588 | static_assert(!test_trait::is_nothrow_convertible<IIT&,BBT>::value,""); | |
589 | static_assert(!test_trait::is_nothrow_convertible<const IIT &,BBT>::value,""); | |
590 | static_assert(test_trait::is_nothrow_convertible<IIP,BBT>::value,""); | |
591 | static_assert(!test_trait::is_nothrow_convertible<const IIP,BBT>::value,""); | |
592 | static_assert(!test_trait::is_nothrow_convertible<IIP&,BBT>::value,""); | |
593 | static_assert(!test_trait::is_nothrow_convertible<const IIP &,BBT>::value,""); | |
594 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<int&,int&>,BBT>::value,""); | |
595 | ||
596 | static_assert(!std::is_nothrow_constructible<BBT,BBT>::value,""); | |
597 | static_assert(std::is_nothrow_constructible<BBT,const BBT>::value,""); | |
598 | static_assert(std::is_nothrow_constructible<BBT,BBT&>::value,""); | |
599 | static_assert(std::is_nothrow_constructible<BBT,const BBT &>::value,""); | |
600 | static_assert(!std::is_nothrow_constructible<BBT,BBP>::value,""); | |
601 | static_assert(std::is_nothrow_constructible<BBT,const BBP>::value,""); | |
602 | static_assert(std::is_nothrow_constructible<BBT,BBP&>::value,""); | |
603 | static_assert(std::is_nothrow_constructible<BBT,const BBP &>::value,""); | |
604 | static_assert(std::is_nothrow_constructible<BBT,std::tuple<B&,B&>>::value,""); | |
605 | ||
606 | static_assert(!std::is_nothrow_constructible<BBT,IBT>::value,""); | |
607 | static_assert(!std::is_nothrow_constructible<BBT,const IBT>::value,""); | |
608 | static_assert(!std::is_nothrow_constructible<BBT,IBT&>::value,""); | |
609 | static_assert(!std::is_nothrow_constructible<BBT,const IBT &>::value,""); | |
610 | static_assert(!std::is_nothrow_constructible<BBT,IBP>::value,""); | |
611 | static_assert(!std::is_nothrow_constructible<BBT,const IBP>::value,""); | |
612 | static_assert(!std::is_nothrow_constructible<BBT,IBP&>::value,""); | |
613 | static_assert(!std::is_nothrow_constructible<BBT,const IBP &>::value,""); | |
614 | static_assert(std::is_nothrow_constructible<BBT,std::tuple<const B&,int&&>>::value,""); | |
615 | ||
616 | static_assert(!test_trait::is_nothrow_convertible<BBT,BBT>::value,""); | |
617 | static_assert(test_trait::is_nothrow_convertible<const BBT,BBT>::value,""); | |
618 | static_assert(test_trait::is_nothrow_convertible<BBT&,BBT>::value,""); | |
619 | static_assert(test_trait::is_nothrow_convertible<const BBT &,BBT>::value,""); | |
620 | static_assert(!test_trait::is_nothrow_convertible<BBP,BBT>::value,""); | |
621 | static_assert(test_trait::is_nothrow_convertible<const BBP,BBT>::value,""); | |
622 | static_assert(test_trait::is_nothrow_convertible<BBP&,BBT>::value,""); | |
623 | static_assert(test_trait::is_nothrow_convertible<const BBP &,BBT>::value,""); | |
624 | static_assert(test_trait::is_nothrow_convertible<std::tuple<B&,int&&>,BBT>::value,""); | |
625 | ||
626 | static_assert(!test_trait::is_nothrow_convertible<IBT,BBT>::value,""); | |
627 | static_assert(!test_trait::is_nothrow_convertible<const IBT,BBT>::value,""); | |
628 | static_assert(!test_trait::is_nothrow_convertible<IBT&,BBT>::value,""); | |
629 | static_assert(!test_trait::is_nothrow_convertible<const IBT &,BBT>::value,""); | |
630 | static_assert(!test_trait::is_nothrow_convertible<IBP,BBT>::value,""); | |
631 | static_assert(!test_trait::is_nothrow_convertible<const IBP,BBT>::value,""); | |
632 | static_assert(!test_trait::is_nothrow_convertible<IBP&,BBT>::value,""); | |
633 | static_assert(!test_trait::is_nothrow_convertible<const IBP &,BBT>::value,""); | |
634 | static_assert(!test_trait::is_nothrow_convertible<std::tuple<B&,int&>,BBT>::value,""); | |
635 | ||
636 | ||
637 | static_assert(!std::is_nothrow_constructible<BBT,int&,const int&>::value,""); | |
638 | static_assert(std::is_nothrow_constructible<BBT,int&&,const B&>::value,""); | |
639 | ||
640 | static_assert(std::is_nothrow_constructible<BBT,B&,const B&>::value,""); | |
641 | static_assert(!std::is_nothrow_constructible<BBT,B&&,const B&&>::value,""); | |
642 | static_assert(!std::is_nothrow_constructible<BBT,const B &&,const int&&>::value,""); | |
643 | ||
644 | /* explicit */ | |
645 | static_assert(std::is_nothrow_constructible<DDT,IIT>::value,""); | |
646 | static_assert(!std::is_nothrow_constructible<DDT,const IIT>::value,""); | |
647 | static_assert(!std::is_nothrow_constructible<DDT,IIT&>::value,""); | |
648 | static_assert(!std::is_nothrow_constructible<DDT,const IIT &>::value,""); | |
649 | static_assert(std::is_nothrow_constructible<DDT,IIP>::value,""); | |
650 | static_assert(!std::is_nothrow_constructible<DDT,const IIP>::value,""); | |
651 | static_assert(!std::is_nothrow_constructible<DDT,IIP&>::value,""); | |
652 | static_assert(!std::is_nothrow_constructible<DDT,const IIP &>::value,""); | |
653 | static_assert(!std::is_nothrow_constructible<DDT,std::tuple<int&,int&>>::value,""); | |
654 | ||
655 | static_assert(!std::is_nothrow_constructible<DDT,DDT>::value,""); | |
656 | static_assert(std::is_nothrow_constructible<DDT,const DDT>::value,""); | |
657 | static_assert(std::is_nothrow_constructible<DDT,DDT&>::value,""); | |
658 | static_assert(std::is_nothrow_constructible<DDT,const DDT &>::value,""); | |
659 | static_assert(!std::is_nothrow_constructible<DDT,DDP>::value,""); | |
660 | static_assert(std::is_nothrow_constructible<DDT,const DDP>::value,""); | |
661 | static_assert(std::is_nothrow_constructible<DDT,DDP&>::value,""); | |
662 | static_assert(std::is_nothrow_constructible<DDT,const DDP &>::value,""); | |
663 | static_assert(std::is_nothrow_constructible<DDT,std::tuple<D&,D&>>::value,""); | |
664 | ||
665 | static_assert(!std::is_nothrow_constructible<DDT,IDT>::value,""); | |
666 | static_assert(!std::is_nothrow_constructible<DDT,const IDT>::value,""); | |
667 | static_assert(!std::is_nothrow_constructible<DDT,IDT&>::value,""); | |
668 | static_assert(!std::is_nothrow_constructible<DDT,const IDT &>::value,""); | |
669 | static_assert(!std::is_nothrow_constructible<DDT,IDP>::value,""); | |
670 | static_assert(!std::is_nothrow_constructible<DDT,const IDP>::value,""); | |
671 | static_assert(!std::is_nothrow_constructible<DDT,IDP&>::value,""); | |
672 | static_assert(!std::is_nothrow_constructible<DDT,const IDP &>::value,""); | |
673 | static_assert(std::is_nothrow_constructible<DDT,std::tuple<const D&,int&&>>::value,""); | |
674 | ||
675 | static_assert(!test_trait::is_nothrow_convertible<DDT,DDT>::value,""); | |
676 | static_assert(test_trait::is_nothrow_convertible<const DDT,DDT>::value,""); | |
677 | static_assert(test_trait::is_nothrow_convertible<DDT&,DDT>::value,""); | |
678 | static_assert(test_trait::is_nothrow_convertible<const DDT &,DDT>::value,""); | |
679 | ||
680 | static_assert(!std::is_nothrow_constructible<DDT,int&,const int&>::value,""); | |
681 | static_assert(std::is_nothrow_constructible<DDT,int&&,const D&>::value,""); | |
682 | ||
683 | static_assert(std::is_nothrow_constructible<DDT,D&,const D&>::value,""); | |
684 | static_assert(!std::is_nothrow_constructible<DDT,D&&,const D&&>::value,""); | |
685 | static_assert(!std::is_nothrow_constructible<DDT,const D &&,const int&&>::value,""); | |
686 | ||
687 | /* three elements tests */ | |
688 | static_assert(std::is_nothrow_constructible<BBBT,IIIT>::value,""); | |
689 | static_assert(!std::is_nothrow_constructible<BBBT,const IIIT>::value,""); | |
690 | static_assert(!std::is_nothrow_constructible<BBBT,IIIT&>::value,""); | |
691 | static_assert(!std::is_nothrow_constructible<BBBT,const IIIT &>::value,""); | |
692 | ||
693 | static_assert(test_trait::is_nothrow_convertible<IIIT,BBBT>::value,""); | |
694 | static_assert(!test_trait::is_nothrow_convertible<const IIIT,BBBT>::value,""); | |
695 | static_assert(!test_trait::is_nothrow_convertible<IIIT&,BBBT>::value,""); | |
696 | static_assert(!test_trait::is_nothrow_convertible<const IIIT &,BBBT>::value,""); | |
697 | ||
698 | static_assert(!std::is_nothrow_constructible<BBBT,BBBT>::value,""); | |
699 | static_assert(std::is_nothrow_constructible<BBBT,const BBBT>::value,""); | |
700 | static_assert(std::is_nothrow_constructible<BBBT,BBBT&>::value,""); | |
701 | static_assert(std::is_nothrow_constructible<BBBT,const BBBT &>::value,""); | |
702 | ||
703 | static_assert(!test_trait::is_nothrow_convertible<BBBT,BBBT>::value,""); | |
704 | static_assert(test_trait::is_nothrow_convertible<const BBBT,BBBT>::value,""); | |
705 | static_assert(test_trait::is_nothrow_convertible<BBBT&,BBBT>::value,""); | |
706 | static_assert(test_trait::is_nothrow_convertible<const BBBT &,BBBT>::value,""); | |
707 | ||
708 | static_assert(!std::is_nothrow_constructible<BBBT,int&,const int&,int&&>::value,""); | |
709 | static_assert(!std::is_nothrow_constructible<BBBT,int&, B&&,const int&&>::value,""); | |
710 | static_assert(std::is_nothrow_constructible<BBBT,int&&, B&,const B&&>::value,""); | |
711 | ||
712 | static_assert(!std::is_nothrow_constructible<BBBT,std::tuple<int&,const int&,int&&>>::value,""); | |
713 | static_assert(!std::is_nothrow_constructible<BBBT,std::tuple<int &, B&&,const int&&>>::value,""); | |
714 | static_assert(std::is_nothrow_constructible<BBBT,std::tuple<int &&, B&,const B&&>>::value,""); | |
715 | ||
716 | /* explicit */ | |
717 | static_assert(std::is_nothrow_constructible<DDDT,IIIT>::value,""); | |
718 | static_assert(!std::is_nothrow_constructible<DDDT,const IIIT>::value,""); | |
719 | static_assert(!std::is_nothrow_constructible<DDDT,IIIT&>::value,""); | |
720 | static_assert(!std::is_nothrow_constructible<DDDT,const IIIT &>::value,""); | |
721 | ||
722 | static_assert(!std::is_nothrow_constructible<DDDT,DDDT>::value,""); | |
723 | static_assert(std::is_nothrow_constructible<DDDT,const DDDT>::value,""); | |
724 | static_assert(std::is_nothrow_constructible<DDDT,DDDT&>::value,""); | |
725 | static_assert(std::is_nothrow_constructible<DDDT,const DDDT &>::value,""); | |
726 | ||
727 | static_assert(!test_trait::is_nothrow_convertible<DDDT,DDDT>::value,""); | |
728 | static_assert(test_trait::is_nothrow_convertible<const DDDT,DDDT>::value,""); | |
729 | static_assert(test_trait::is_nothrow_convertible<DDDT&,DDDT>::value,""); | |
730 | static_assert(test_trait::is_nothrow_convertible<const DDDT &,DDDT>::value,""); | |
731 | ||
732 | static_assert(!std::is_nothrow_constructible<DDDT,int&,const int&,int&&>::value,""); | |
733 | static_assert(!std::is_nothrow_constructible<DDDT,int &, D&&,const int&&>::value,""); | |
734 | static_assert(std::is_nothrow_constructible<DDDT,int &&, D&,const D&&>::value,""); | |
735 | ||
736 | static_assert(!std::is_nothrow_constructible<DDDT,std::tuple<int&,const int&,int&&>>::value,""); | |
737 | static_assert(!std::is_nothrow_constructible<DDDT,std::tuple<int &, D&&,const int&&>>::value,""); | |
738 | static_assert(std::is_nothrow_constructible<DDDT,std::tuple<int &&, D&,const D&&>>::value,""); | |
739 | ||
740 | ||
741 | void Run() | |
742 | { | |
743 | VERIFY( (checkCopyThrowConstruct<BT, int>()) ); | |
744 | VERIFY( (checkMoveThrowConstruct<BT, int>()) ); | |
745 | VERIFY( (checkCopyThrowConstruct<BT, B>()) ); | |
746 | VERIFY( (checkMoveThrowConstruct<BT, B>()) ); | |
747 | VERIFY( (checkCopyThrowConstruct<BT, IT>()) ); | |
748 | VERIFY( (checkMoveThrowConstruct<BT, IT>()) ); | |
749 | VERIFY( (checkMoveThrowConstruct<BT, CIT>()) ); | |
750 | VERIFY( (checkCopyThrowConstruct<BBT, IIT>()) ); | |
751 | VERIFY( (checkMoveThrowConstruct<BBT, IIT>()) ); | |
752 | VERIFY( (checkCopyThrowConstruct<BBT, IIP>()) ); | |
753 | VERIFY( (checkMoveThrowConstruct<BBT, IIP>()) ); | |
754 | VERIFY( (checkCopyThrowConstruct<BBT, BBP>()) ); | |
755 | VERIFY( (checkMoveThrowConstruct<BBT, BBP>()) ); | |
756 | VERIFY( (checkCopyThrowConstruct<BBT, std::tuple<B, int>>()) ); | |
757 | VERIFY( (checkMoveThrowConstruct<BBT, std::tuple<B, int>>()) ); | |
758 | ||
759 | VERIFY( (checkCopyThrowConstruct<DT, int>()) ); | |
760 | VERIFY( (checkMoveThrowConstruct<DT, int>()) ); | |
761 | VERIFY( (checkCopyThrowConstruct<DT, D>()) ); | |
762 | VERIFY( (checkMoveThrowConstruct<DT, D>()) ); | |
763 | VERIFY( (checkCopyThrowConstruct<DT, IT>()) ); | |
764 | VERIFY( (checkMoveThrowConstruct<DT, IT>()) ); | |
765 | VERIFY( (checkMoveThrowConstruct<DT, CIT>()) ); | |
766 | VERIFY( (checkCopyThrowConstruct<DDT, IIT>()) ); | |
767 | VERIFY( (checkMoveThrowConstruct<DDT, IIT>()) ); | |
768 | VERIFY( (checkCopyThrowConstruct<DDT, IIP>()) ); | |
769 | VERIFY( (checkMoveThrowConstruct<DDT, IIP>()) ); | |
770 | VERIFY( (checkCopyThrowConstruct<DDT, DDP>()) ); | |
771 | VERIFY( (checkMoveThrowConstruct<DDT, DDP>()) ); | |
772 | VERIFY( (checkCopyThrowConstruct<DDT, std::tuple<D, int>>()) ); | |
773 | VERIFY( (checkMoveThrowConstruct<DDT, std::tuple<D, int>>()) ); | |
774 | ||
775 | VERIFY( (checkCopyThrowConstruct<DBT, IIT>()) ); | |
776 | VERIFY( (checkMoveThrowConstruct<DBT, IIT>()) ); | |
777 | VERIFY( (checkCopyThrowConstruct<DBT, DBT>()) ); | |
778 | VERIFY( (checkMoveThrowConstruct<DBT, DBT>()) ); | |
779 | VERIFY( (checkCopyThrowConstruct<DBT, DBP>()) ); | |
780 | VERIFY( (checkMoveThrowConstruct<DBT, DBP>()) ); | |
781 | VERIFY( (checkCopyThrowConstruct<DBT, IIP>()) ); | |
782 | VERIFY( (checkMoveThrowConstruct<DBT, IIP>()) ); | |
783 | ||
784 | ||
785 | VERIFY( (checkCopyThrowConstruct<IDIT, IIIT>()) ); | |
786 | VERIFY( (checkMoveThrowConstruct<IDIT, IIIT>()) ); | |
787 | VERIFY( (checkCopyThrowConstruct<IDIT, IDIT>()) ); | |
788 | VERIFY( (checkMoveThrowConstruct<IDIT, IDIT>()) ); | |
789 | VERIFY( (checkCopyThrowConstruct<IBIT, IIIT>()) ); | |
790 | VERIFY( (checkMoveThrowConstruct<IBIT, IIIT>()) ); | |
791 | VERIFY( (checkCopyThrowConstruct<IBIT, IBIT>()) ); | |
792 | VERIFY( (checkMoveThrowConstruct<IBIT, IBIT>()) ); | |
793 | VERIFY( (checkCopyThrowConstruct<IDBT, IIIT>()) ); | |
794 | VERIFY( (checkMoveThrowConstruct<IDBT, IIIT>()) ); | |
795 | VERIFY( (checkCopyThrowConstruct<IDBT, IDBT>()) ); | |
796 | VERIFY( (checkMoveThrowConstruct<IDBT, IDBT>()) ); | |
797 | ||
798 | } | |
799 | } | |
800 | namespace ThrowCopy | |
801 | { | |
802 | struct C | |
803 | { | |
804 | C() noexcept(true) | |
805 | {} | |
806 | ||
807 | explicit | |
808 | C(const C&) noexcept(true) {} | |
809 | ||
810 | }; | |
811 | ||
812 | typedef std::tuple<C> CT; | |
813 | typedef std::tuple<C,C> CCT; | |
814 | typedef std::pair<C,C> CCP; | |
815 | typedef std::tuple<int,int,C> IICT; | |
816 | ||
817 | static_assert(std::is_nothrow_constructible<CT, C&>::value, ""); | |
818 | static_assert(std::is_nothrow_constructible<CT, const C&>::value, ""); | |
819 | static_assert(std::is_nothrow_constructible<CT, C&&>::value, ""); | |
820 | static_assert(std::is_nothrow_constructible<CT, const C &&>::value, ""); | |
821 | ||
822 | ||
823 | static_assert(std::is_nothrow_constructible<CCT, C&, C&>::value, ""); | |
824 | static_assert(std::is_nothrow_constructible<CCT, const C&, const C&>::value, ""); | |
825 | static_assert(std::is_nothrow_constructible<CCT, C&&, C&&>::value, ""); | |
826 | static_assert(std::is_nothrow_constructible<CCT, const C &&, const C &&>::value, ""); | |
827 | ||
828 | static_assert(std::is_nothrow_constructible<IICT, int, int, C&>::value, ""); | |
829 | static_assert(std::is_nothrow_constructible<IICT, int, int, const C&>::value, ""); | |
830 | static_assert(std::is_nothrow_constructible<IICT, int, int, C&&>::value, ""); | |
831 | static_assert(std::is_nothrow_constructible<IICT, int, int, const C &&>::value, ""); | |
832 | ||
833 | static_assert(std::is_nothrow_constructible<CT, CT&>::value, ""); | |
834 | static_assert(std::is_nothrow_constructible<CT, const CT&>::value, ""); | |
835 | static_assert(std::is_nothrow_constructible<CT, CT&&>::value, ""); | |
836 | static_assert(std::is_nothrow_constructible<CT, const CT &&>::value, ""); | |
837 | ||
838 | static_assert(std::is_nothrow_constructible<CCT, CCT&>::value, ""); | |
839 | static_assert(std::is_nothrow_constructible<CCT, const CCT&>::value, ""); | |
840 | static_assert(std::is_nothrow_constructible<CCT, CCT&&>::value, ""); | |
841 | static_assert(std::is_nothrow_constructible<CCT, const CCT &&>::value, ""); | |
842 | ||
843 | static_assert(std::is_nothrow_constructible<CCT, CCP&>::value, ""); | |
844 | static_assert(std::is_nothrow_constructible<CCT, const CCP&>::value, ""); | |
845 | static_assert(std::is_nothrow_constructible<CCT, CCP&&>::value, ""); | |
846 | static_assert(std::is_nothrow_constructible<CCT, const CCP &&>::value, ""); | |
847 | ||
848 | static_assert(std::is_nothrow_constructible<IICT, IICT&>::value, ""); | |
849 | static_assert(std::is_nothrow_constructible<IICT, const IICT&>::value, ""); | |
850 | static_assert(std::is_nothrow_constructible<IICT, IICT&&>::value, ""); | |
851 | static_assert(std::is_nothrow_constructible<IICT, const IICT &&>::value, ""); | |
852 | ||
853 | } | |
854 | namespace ThrowMoveNothrowConversion | |
855 | { | |
856 | struct D | |
857 | { | |
858 | D() noexcept(true) | |
859 | {} | |
860 | ||
861 | explicit | |
862 | D(const int&) noexcept(true) | |
863 | {} | |
864 | ||
865 | explicit | |
866 | D(int&&) noexcept(false) | |
867 | { throwing_ctor_called = true; } | |
868 | ||
869 | }; | |
870 | ||
871 | typedef std::tuple<D> DT; | |
872 | typedef std::tuple<D,D> DDT; | |
873 | typedef std::pair<D,D> DDP; | |
874 | typedef std::tuple<int,D,int> IDIT; | |
875 | ||
876 | ||
877 | static_assert(!std::is_nothrow_constructible<DT, int>::value, ""); | |
878 | static_assert(std::is_nothrow_constructible<DT, const int>::value, ""); | |
879 | static_assert(std::is_nothrow_constructible<DT, int&>::value, ""); | |
880 | static_assert(std::is_nothrow_constructible<DT, const int &>::value, ""); | |
881 | ||
882 | static_assert(!std::is_nothrow_constructible<DT, IT>::value, ""); | |
883 | static_assert(std::is_nothrow_constructible<DT,const IT>::value, ""); | |
884 | static_assert(std::is_nothrow_constructible<DT, IT&>::value, ""); | |
885 | static_assert(std::is_nothrow_constructible<DT, const IT &>::value, ""); | |
886 | static_assert(std::is_nothrow_constructible<DT, std::tuple<int&>>::value, ""); | |
887 | static_assert(std::is_nothrow_constructible<DT, const std::tuple<int&&>>::value, ""); | |
888 | ||
889 | static_assert(test_trait::is_nothrow_convertible<DT,DT>::value,""); | |
890 | static_assert(test_trait::is_nothrow_convertible<D,DT>::value,""); | |
891 | ||
892 | /* two elements tests */ | |
893 | static_assert(!std::is_nothrow_constructible<DDT,IIT>::value,""); | |
894 | static_assert(std::is_nothrow_constructible<DDT,const IIT>::value,""); | |
895 | static_assert(std::is_nothrow_constructible<DDT,IIT&>::value,""); | |
896 | static_assert(std::is_nothrow_constructible<DDT,const IIT &>::value,""); | |
897 | static_assert(!std::is_nothrow_constructible<DDT,IIP>::value,""); | |
898 | static_assert(std::is_nothrow_constructible<DDT,const IIP>::value,""); | |
899 | static_assert(std::is_nothrow_constructible<DDT,IIP&>::value,""); | |
900 | static_assert(std::is_nothrow_constructible<DDT,const IIP &>::value,""); | |
901 | static_assert(std::is_nothrow_constructible<DDT,std::tuple<int&,int&>>::value,""); | |
902 | ||
903 | static_assert(std::is_nothrow_constructible<DDT,DDT>::value,""); | |
904 | static_assert(std::is_nothrow_constructible<DDT,DDP>::value,""); | |
905 | static_assert(std::is_nothrow_constructible<DDT,std::tuple<int&,D>>::value,""); | |
906 | static_assert(!std::is_nothrow_constructible<DDT,std::pair<D,int&&>>::value,""); | |
907 | ||
908 | static_assert(std::is_convertible<DDT,DDT>::value,""); | |
909 | ||
910 | /* three elements tests */ | |
911 | static_assert(!std::is_nothrow_constructible<IDIT,IIIT>::value,""); | |
912 | static_assert(std::is_nothrow_constructible<IDIT,const IIIT>::value,""); | |
913 | static_assert(std::is_nothrow_constructible<IDIT,IIIT&>::value,""); | |
914 | static_assert(std::is_nothrow_constructible<IDIT,const IIIT &>::value,""); | |
915 | ||
916 | static_assert(test_trait::is_nothrow_convertible<IDIT,IDIT>::value,""); | |
917 | static_assert(test_trait::is_nothrow_convertible<IDIT,IDIT>::value,""); | |
918 | ||
919 | static_assert(std::is_nothrow_constructible<IDIT,int&,const int&,int&&>::value,""); | |
920 | static_assert(std::is_nothrow_constructible<IDIT,int &, D&&,const int&&>::value,""); | |
921 | static_assert(std::is_nothrow_constructible<IDIT,std::tuple<int&,const int&,int&&>>::value,""); | |
922 | static_assert(!std::is_nothrow_constructible<IDIT,std::tuple<int &, int&&,const int&&>>::value,""); | |
923 | ||
924 | void Run() | |
925 | { | |
926 | VERIFY( (checkCopyThrowConstruct<DDT, IIT>()) ); | |
927 | VERIFY( (checkMoveThrowConstruct<DDT, IIT>()) ); | |
928 | VERIFY( (checkCopyThrowConstruct<DDT, std::tuple<D, int>>()) ); | |
929 | VERIFY( (checkMoveThrowConstruct<DDT, std::tuple<D, int>>()) ); | |
930 | } | |
931 | } | |
932 | ||
933 | int main() | |
934 | { | |
935 | ||
936 | DefaultConstructionTests::Run(); | |
937 | ||
938 | ThrowCopyNothrowConversion::Run(); | |
939 | ||
940 | NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion::Run(); | |
941 | ||
942 | ThrowMoveNothrowConversion::Run(); | |
943 | ||
944 | } | |
945 |