Daily bump.
[official-gcc.git] / libstdc++-v3 / testsuite / util / testsuite_common_types.h
blob1b8d8682cef981000ff35d5dd6592c03159e420e
1 // -*- C++ -*-
2 // typelist for the C++ library testsuite.
3 //
4 // Copyright (C) 2005-2024 Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
22 #ifndef _TESTSUITE_COMMON_TYPES_H
23 #define _TESTSUITE_COMMON_TYPES_H 1
25 #include <ext/typelist.h>
27 #include <ext/new_allocator.h>
28 #include <ext/malloc_allocator.h>
29 #include <ext/mt_allocator.h>
30 #include <ext/bitmap_allocator.h>
31 #include <ext/pool_allocator.h>
33 #include <algorithm>
35 #include <vector>
36 #include <list>
37 #include <deque>
38 #include <string>
39 #include <limits>
41 #include <map>
42 #include <set>
44 #if __cplusplus >= 201103L
45 #include <atomic>
46 #include <type_traits>
47 #include <unordered_map>
48 #include <unordered_set>
49 namespace unord = std;
50 #else
51 #include <tr1/unordered_map>
52 #include <tr1/unordered_set>
53 namespace unord = std::tr1;
54 #endif
56 namespace __gnu_test
58 using __gnu_cxx::typelist::null_type;
59 using __gnu_cxx::typelist::node;
60 using __gnu_cxx::typelist::transform;
61 using __gnu_cxx::typelist::append;
63 // All the allocators to test.
64 template<typename Tp, bool Thread>
65 struct allocator_policies
67 typedef Tp value_type;
68 typedef __gnu_cxx::new_allocator<Tp> a1;
69 typedef __gnu_cxx::malloc_allocator<Tp> a2;
70 typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, Thread> pool_policy;
71 typedef __gnu_cxx::__mt_alloc<Tp, pool_policy> a3;
72 typedef __gnu_cxx::bitmap_allocator<Tp> a4;
73 typedef __gnu_cxx::__pool_alloc<Tp> a5;
74 typedef node<_GLIBCXX_TYPELIST_CHAIN5(a1, a2, a3, a4, a5)> type;
77 // Typelists for vector, string, list, deque.
78 // XXX should just use template templates
79 template<typename Tp, bool Thread>
80 struct vectors
82 typedef Tp value_type;
84 template<typename Tl>
85 struct vector_shell
87 typedef Tl allocator_type;
88 typedef std::vector<value_type, allocator_type> type;
91 typedef allocator_policies<value_type, Thread> allocator_types;
92 typedef typename allocator_types::type allocator_typelist;
93 typedef typename transform<allocator_typelist, vector_shell>::type type;
96 template<typename Tp, bool Thread>
97 struct lists
99 typedef Tp value_type;
101 template<typename Tl>
102 struct list_shell
104 typedef Tl allocator_type;
105 typedef std::list<value_type, allocator_type> type;
108 typedef allocator_policies<value_type, Thread> allocator_types;
109 typedef typename allocator_types::type allocator_typelist;
110 typedef typename transform<allocator_typelist, list_shell>::type type;
113 template<typename Tp, bool Thread>
114 struct deques
116 typedef Tp value_type;
118 template<typename Tl>
119 struct deque_shell
121 typedef Tl allocator_type;
122 typedef std::deque<value_type, allocator_type> type;
125 typedef allocator_policies<value_type, Thread> allocator_types;
126 typedef typename allocator_types::type allocator_typelist;
127 typedef typename transform<allocator_typelist, deque_shell>::type type;
130 template<typename Tp, bool Thread>
131 struct strings
133 typedef Tp value_type;
135 template<typename Tl>
136 struct string_shell
138 typedef Tl allocator_type;
139 typedef std::char_traits<value_type> traits_type;
140 typedef std::basic_string<value_type, traits_type, allocator_type> type;
143 typedef allocator_policies<value_type, Thread> allocator_types;
144 typedef typename allocator_types::type allocator_typelist;
145 typedef typename transform<allocator_typelist, string_shell>::type type;
148 // A typelist of vector, list, deque, and string all instantiated
149 // with each of the allocator policies.
150 template<typename Tp, bool Thread>
151 struct sequence_containers
153 typedef Tp value_type;
155 typedef typename vectors<value_type, Thread>::type vector_typelist;
156 typedef typename lists<value_type, Thread>::type list_typelist;
157 typedef typename deques<value_type, Thread>::type deque_typelist;
158 typedef typename strings<value_type, Thread>::type string_typelist;
160 typedef typename append<vector_typelist, list_typelist>::type a1;
161 typedef typename append<deque_typelist, string_typelist>::type a2;
162 typedef typename append<a1, a2>::type type;
165 // Typelists for map, set, unordered_set, unordered_map.
166 template<typename Tp, bool Thread>
167 struct maps
169 typedef Tp value_type;
170 typedef Tp key_type;
171 typedef std::pair<const key_type, value_type> pair_type;
172 typedef std::less<key_type> compare_function;
174 template<typename Tl>
175 struct container
177 typedef Tl allocator_type;
178 typedef std::map<key_type, value_type, compare_function, allocator_type> type;
181 typedef allocator_policies<pair_type, Thread> allocator_types;
182 typedef typename allocator_types::type allocator_typelist;
183 typedef typename transform<allocator_typelist, container>::type type;
186 template<typename Tp, bool Thread>
187 struct unordered_maps
189 typedef Tp value_type;
190 typedef Tp key_type;
191 typedef std::pair<const key_type, value_type> pair_type;
192 typedef unord::hash<key_type> hash_function;
193 typedef std::equal_to<key_type> equality_function;
195 template<typename Tl>
196 struct container
198 typedef Tl allocator_type;
199 typedef unord::unordered_map<key_type, value_type, hash_function, equality_function, allocator_type> type;
202 typedef allocator_policies<pair_type, Thread> allocator_types;
203 typedef typename allocator_types::type allocator_typelist;
204 typedef typename transform<allocator_typelist, container>::type type;
207 template<typename Tp, bool Thread>
208 struct sets
210 typedef Tp value_type;
211 typedef Tp key_type;
212 typedef std::less<key_type> compare_function;
214 template<typename Tl>
215 struct container
217 typedef Tl allocator_type;
218 typedef std::set<key_type, compare_function, allocator_type> type;
221 typedef allocator_policies<key_type, Thread> allocator_types;
222 typedef typename allocator_types::type allocator_typelist;
223 typedef typename transform<allocator_typelist, container>::type type;
226 template<typename Tp, bool Thread>
227 struct unordered_sets
229 typedef Tp value_type;
230 typedef Tp key_type;
231 typedef unord::hash<key_type> hash_function;
232 typedef std::equal_to<key_type> equality_function;
234 template<typename Tl>
235 struct container
237 typedef Tl allocator_type;
238 typedef unord::unordered_set<key_type, hash_function, equality_function, allocator_type> type;
241 typedef allocator_policies<key_type, Thread> allocator_types;
242 typedef typename allocator_types::type allocator_typelist;
243 typedef typename transform<allocator_typelist, container>::type type;
247 // A typelist of all associated container types, with each of the
248 // allocator policies.
249 template<typename Tp, bool Thread>
250 struct associative_containers
252 typedef Tp value_type;
254 typedef typename maps<value_type, Thread>::type map_typelist;
255 typedef typename sets<value_type, Thread>::type set_typelist;
256 typedef typename unordered_maps<value_type, Thread>::type unordered_map_typelist;
257 typedef typename unordered_sets<value_type, Thread>::type unordered_set_typelist;
259 typedef typename append<map_typelist, unordered_map_typelist>::type a1;
260 typedef typename append<set_typelist, unordered_set_typelist>::type a2;
261 typedef typename append<a1, a2>::type type;
264 // A typelist of all standard integral types.
265 struct integral_types
267 typedef bool a1;
268 typedef char a2;
269 typedef signed char a3;
270 typedef unsigned char a4;
271 typedef short a5;
272 typedef unsigned short a6;
273 typedef int a7;
274 typedef unsigned int a8;
275 typedef long a9;
276 typedef unsigned long a10;
277 typedef long long a11;
278 typedef unsigned long long a12;
279 typedef wchar_t a13;
280 typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
281 a10, a11, a12, a13)> basic_typelist;
282 #if __cplusplus >= 201103L
283 typedef char16_t a14;
284 typedef char32_t a15;
285 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a14, a15)> cxx11_typelist;
286 #else
287 typedef node<null_type> cxx11_typelist;
288 #endif
289 #ifdef _GLIBCXX_USE_CHAR8_T
290 typedef char8_t a16;
291 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
292 #else
293 typedef node<null_type> char8_typelist;
294 #endif
295 typedef typename append<basic_typelist, cxx11_typelist>::type tl1;
296 typedef typename append<tl1, char8_typelist>::type type;
299 // A typelist of all standard integral types + the GNU 128-bit types.
300 struct integral_types_gnu
302 typedef bool a1;
303 typedef char a2;
304 typedef signed char a3;
305 typedef unsigned char a4;
306 typedef short a5;
307 typedef unsigned short a6;
308 typedef int a7;
309 typedef unsigned int a8;
310 typedef long a9;
311 typedef unsigned long a10;
312 typedef long long a11;
313 typedef unsigned long long a12;
314 typedef wchar_t a13;
315 typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
316 a10, a11, a12, a13)> basic_typelist;
317 #if __cplusplus >= 201103L
318 typedef char16_t a14;
319 typedef char32_t a15;
320 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a14, a15)> cxx11_typelist;
321 #else
322 typedef node<null_type> cxx11_typelist;
323 #endif
324 #ifdef _GLIBCXX_USE_CHAR8_T
325 typedef char8_t a16;
326 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
327 #else
328 typedef node<null_type> char8_typelist;
329 #endif
330 # if !defined(__STRICT_ANSI__) && defined(__SIZEOF_INT128__)
331 __extension__ typedef __int128 a17;
332 __extension__ typedef unsigned __int128 a18;
333 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a17, a18)> int128_typelist;
334 #else
335 typedef node<null_type> int128_typelist;
336 #endif
337 typedef typename append<basic_typelist, cxx11_typelist>::type tl1;
338 typedef typename append<tl1, char8_typelist>::type tl2;
339 typedef typename append<tl2, int128_typelist>::type type;
342 #if __cplusplus >= 201103L
343 struct atomic_integrals_no_bool
345 typedef std::atomic_char a2;
346 typedef std::atomic_schar a3;
347 typedef std::atomic_uchar a4;
348 typedef std::atomic_short a5;
349 typedef std::atomic_ushort a6;
350 typedef std::atomic_int a7;
351 typedef std::atomic_uint a8;
352 typedef std::atomic_long a9;
353 typedef std::atomic_ulong a10;
354 typedef std::atomic_llong a11;
355 typedef std::atomic_ullong a12;
356 typedef std::atomic_wchar_t a13;
357 typedef std::atomic_char16_t a14;
358 typedef std::atomic_char32_t a15;
359 typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9, a10,
360 a11, a12, a13, a14, a15)> basic_typelist;
361 #ifdef _GLIBCXX_USE_CHAR8_T
362 typedef std::atomic_char8_t a16;
363 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
364 #else
365 typedef node<null_type> char8_typelist;
366 #endif
367 typedef typename append<basic_typelist, char8_typelist>::type type;
370 struct atomic_integrals
372 typedef std::atomic_bool a1;
373 typedef std::atomic_char a2;
374 typedef std::atomic_schar a3;
375 typedef std::atomic_uchar a4;
376 typedef std::atomic_short a5;
377 typedef std::atomic_ushort a6;
378 typedef std::atomic_int a7;
379 typedef std::atomic_uint a8;
380 typedef std::atomic_long a9;
381 typedef std::atomic_ulong a10;
382 typedef std::atomic_llong a11;
383 typedef std::atomic_ullong a12;
384 typedef std::atomic_wchar_t a13;
385 typedef std::atomic_char16_t a14;
386 typedef std::atomic_char32_t a15;
387 typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
388 a10, a11, a12, a13, a14, a15)> basic_typelist;
389 #ifdef _GLIBCXX_USE_CHAR8_T
390 typedef std::atomic_char8_t a16;
391 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
392 #else
393 typedef node<null_type> char8_typelist;
394 #endif
395 typedef typename append<basic_typelist, char8_typelist>::type type;
399 template<typename Tp>
400 struct atomics
402 typedef Tp value_type;
403 typedef std::atomic<value_type> type;
406 typedef transform<integral_types::type, atomics>::type atomics_tl;
407 #endif
409 template<typename Tp>
410 struct numeric_limits
412 typedef Tp value_type;
413 typedef std::numeric_limits<value_type> type;
416 typedef transform<integral_types_gnu::type, numeric_limits>::type limits_tl;
418 struct has_increment_operators
420 template<typename _Tp>
421 void
422 operator()()
424 struct _Concept
426 void __constraint()
428 _Tp a;
429 ++a; // prefix
430 a++; // postfix
431 a += a;
435 void (_Concept::*__x)() __attribute__((unused))
436 = &_Concept::__constraint;
440 struct has_decrement_operators
442 template<typename _Tp>
443 void
444 operator()()
446 struct _Concept
448 void __constraint()
450 _Tp a;
451 --a; // prefix
452 a--; // postfix
453 a -= a;
457 void (_Concept::*__x)() __attribute__((unused))
458 = &_Concept::__constraint;
462 #if __cplusplus >= 201103L
463 template<typename _Tp>
464 void
465 constexpr_bitwise_operators()
467 constexpr _Tp a = _Tp();
468 constexpr _Tp b = _Tp();
469 constexpr _Tp c1 __attribute__((unused)) = a | b;
470 constexpr _Tp c2 __attribute__((unused)) = a & b;
471 constexpr _Tp c3 __attribute__((unused)) = a ^ b;
472 constexpr _Tp c4 __attribute__((unused)) = ~b;
474 #endif
476 template<typename _Tp>
477 void
478 bitwise_operators()
480 _Tp a = _Tp();
481 _Tp b = _Tp();
482 a | b;
483 a & b;
484 a ^ b;
488 template<typename _Tp>
489 void
490 bitwise_assignment_operators()
492 #if __cplusplus >= 201103L
493 _Tp a{};
494 _Tp b{};
495 #else
496 _Tp a = _Tp();
497 _Tp b = _Tp();
498 #endif
499 a |= b; // set
500 a &= ~b; // clear
501 a ^= b;
504 // 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
505 // bitmask_operators
506 template<typename _BitmTp>
507 void
508 bitmask_operators()
510 bitwise_operators<_BitmTp>();
511 bitwise_assignment_operators<_BitmTp>();
514 struct has_bitwise_operators
516 template<typename _Tp>
517 void
518 operator()()
520 struct _Concept
522 void __constraint()
524 a |= b; // set
525 a &= ~b; // clear
526 a ^= b;
528 _Tp a;
529 _Tp b;
532 void (_Concept::*__x)() __attribute__((unused))
533 = &_Concept::__constraint;
537 #if __cplusplus >= 201103L
539 struct constexpr_comparison_eq_ne
541 template<typename _Tp1, typename _Tp2 = _Tp1>
542 void
543 operator()()
545 static_assert(_Tp1() == _Tp2(), "eq");
546 static_assert(!(_Tp1() != _Tp2()), "ne");
550 struct constexpr_comparison_operators
552 template<typename _Tp>
553 void
554 operator()()
556 static_assert(!(_Tp() < _Tp()), "less");
557 static_assert(_Tp() <= _Tp(), "leq");
558 static_assert(!(_Tp() > _Tp()), "more");
559 static_assert(_Tp() >= _Tp(), "meq");
560 static_assert(_Tp() == _Tp(), "eq");
561 static_assert(!(_Tp() != _Tp()), "ne");
565 struct has_trivial_cons_dtor
567 template<typename _Tp>
568 void
569 operator()()
571 struct _Concept
573 void __constraint()
575 typedef std::is_trivially_default_constructible<_Tp> ctor_p;
576 static_assert(ctor_p::value, "default constructor not trivial");
578 typedef std::is_trivially_destructible<_Tp> dtor_p;
579 static_assert(dtor_p::value, "destructor not trivial");
583 void (_Concept::*__x)() __attribute__((unused))
584 = &_Concept::__constraint;
588 struct has_trivial_dtor
590 template<typename _Tp>
591 void
592 operator()()
594 struct _Concept
596 void __constraint()
598 typedef std::is_trivially_destructible<_Tp> dtor_p;
599 static_assert(dtor_p::value, "destructor not trivial");
603 void (_Concept::*__x)() __attribute__((unused))
604 = &_Concept::__constraint;
608 // Generator to test standard layout
609 struct standard_layout
611 template<typename _Tp>
612 void
613 operator()()
615 struct _Concept
617 void __constraint()
619 typedef std::is_standard_layout<_Tp> standard_layout_p;
620 static_assert(standard_layout_p::value, "not standard_layout");
624 void (_Concept::*__x)() __attribute__((unused))
625 = &_Concept::__constraint;
628 #endif
630 // Generator to test base class
631 struct has_required_base_class
633 template<typename _TBase, typename _TDerived>
634 void
635 operator()()
637 struct _Concept
639 void __constraint()
641 const _TDerived& obj = __a;
642 const _TBase* base __attribute__((unused)) = &obj;
645 _TDerived __a;
648 void (_Concept::*__x)() __attribute__((unused))
649 = &_Concept::__constraint;
653 // Generator to test assignment operator.
654 struct assignable
656 template<typename _Tp>
657 void
658 operator()()
660 struct _Concept
662 void __constraint()
663 { __v1 = __v2; }
665 _Tp __v1;
666 _Tp __v2;
669 void (_Concept::*__x)() __attribute__((unused))
670 = &_Concept::__constraint;
674 // Generator to test default constructor.
675 struct default_constructible
677 template<typename _Tp>
678 void
679 operator()()
681 struct _Concept
683 void __constraint()
684 { _Tp __v __attribute__((unused)); }
687 void (_Concept::*__x)() __attribute__((unused))
688 = &_Concept::__constraint;
692 // Generator to test copy constructor.
693 struct copy_constructible
695 template<typename _Tp>
696 void
697 operator()()
699 struct _Concept
701 void __constraint()
702 { _Tp __v2(__v1); }
704 _Tp __v1;
707 void (_Concept::*__x)() __attribute__((unused))
708 = &_Concept::__constraint;
712 // Generator to test direct initialization, single value constructor.
713 struct single_value_constructible
715 template<typename _Ttype, typename _Tvalue>
716 void
717 operator()()
719 struct _Concept
721 void __constraint()
722 { _Ttype __v(__a); }
724 _Tvalue __a;
727 void (_Concept::*__x)() __attribute__((unused))
728 = &_Concept::__constraint;
732 #if __cplusplus >= 201103L
733 // Generator to test non-explicit default constructor.
734 struct implicitly_default_constructible
736 template<typename _Tp>
737 void
738 operator()()
740 struct _Concept
742 struct Aggregate { _Tp v; };
744 void __constraint()
745 { Aggregate __v __attribute__((unused)) = { }; }
748 void (_Concept::*__x)() __attribute__((unused))
749 = &_Concept::__constraint;
753 // Generator to test default constructor.
754 struct constexpr_default_constructible
756 template<typename _Tp, bool _IsLitp = __is_literal_type(_Tp)>
757 struct _Concept;
759 // NB: _Tp must be a literal type.
760 // Have to have user-defined default ctor for this to work,
761 // or implicit default ctor must initialize all members.
762 template<typename _Tp>
763 struct _Concept<_Tp, true>
765 void __constraint()
766 { constexpr _Tp __obj; }
769 // Non-literal type, declare local static and verify no
770 // constructors generated for _Tp within the translation unit.
771 template<typename _Tp>
772 struct _Concept<_Tp, false>
774 void __constraint()
775 { static _Tp __obj; }
778 template<typename _Tp>
779 void
780 operator()()
782 _Concept<_Tp> c;
783 c.__constraint();
787 // Generator to test defaulted default constructor.
788 struct constexpr_defaulted_default_constructible
790 template<typename _Tp>
791 void
792 operator()()
794 struct _Concept
796 void __constraint()
797 { constexpr _Tp __v __attribute__((unused)) { }; }
800 void (_Concept::*__x)() __attribute__((unused))
801 = &_Concept::__constraint;
805 struct constexpr_single_value_constructible
807 template<typename _Ttesttype, typename _Tvaluetype,
808 bool _IsLitp = __is_literal_type(_Ttesttype)>
809 struct _Concept;
811 // NB: _Tvaluetype and _Ttesttype must be literal types.
812 // Additional constraint on _Tvaluetype needed. Either assume
813 // user-defined default ctor as per
814 // constexpr_default_constructible and provide no initializer,
815 // provide an initializer, or assume empty-list init-able. Choose
816 // the latter.
817 template<typename _Ttesttype, typename _Tvaluetype>
818 struct _Concept<_Ttesttype, _Tvaluetype, true>
820 void __constraint()
822 constexpr _Tvaluetype __v { };
823 constexpr _Ttesttype __obj(__v);
827 template<typename _Ttesttype, typename _Tvaluetype>
828 struct _Concept<_Ttesttype, _Tvaluetype, false>
830 void __constraint()
832 const _Tvaluetype __v { };
833 static _Ttesttype __obj(__v);
837 template<typename _Ttesttype, typename _Tvaluetype>
838 void
839 operator()()
841 _Concept<_Ttesttype, _Tvaluetype> c;
842 c.__constraint();
845 #endif
847 // Generator to test direct list initialization
848 #if __cplusplus >= 201103L
849 struct direct_list_initializable
851 template<typename _Ttype, typename _Tvalue>
852 void
853 operator()()
855 struct _Concept
857 void __constraint()
859 _Ttype __v1 { }; // default ctor
860 _Ttype __v2 { __a }; // single-argument ctor
863 _Tvalue __a;
866 void (_Concept::*__x)() __attribute__((unused))
867 = &_Concept::__constraint;
870 #endif
872 // Generator to test copy list initialization, aggregate initialization
873 struct copy_list_initializable
875 template<typename _Ttype, typename _Tvalue>
876 void
877 operator()()
879 struct _Concept
881 void __constraint()
882 { _Ttype __v __attribute__((unused)) = {__a}; }
884 _Tvalue __a;
887 void (_Concept::*__x)() __attribute__((unused))
888 = &_Concept::__constraint;
892 // Generator to test integral conversion operator
893 struct integral_convertable
895 template<typename _Ttype, typename _Tvalue>
896 void
897 operator()()
899 struct _Concept
901 void __constraint()
903 _Tvalue __v0(0);
904 _Tvalue __v1(1);
905 _Ttype __a(__v1);
906 __v0 = __a;
908 VERIFY( __v1 == __v0 );
912 void (_Concept::*__x)() __attribute__((unused))
913 = &_Concept::__constraint;
917 // Generator to test integral assignment operator
918 struct integral_assignable
920 template<typename _Ttype, typename _Tvalue>
921 void
922 operator()()
924 struct _Concept
926 void __constraint()
928 _Tvalue __v0(0);
929 _Tvalue __v1(1);
930 _Ttype __a(__v0);
931 __a = __v1;
932 _Tvalue __vr = __a;
934 VERIFY( __v1 == __vr );
938 void (_Concept::*__x)() __attribute__((unused))
939 = &_Concept::__constraint;
943 #if __cplusplus >= 201103L
944 // Generator to test lowering requirements for compare-and-exchange.
945 template<std::memory_order _Torder>
946 struct compare_exchange_order_lowering
948 template<typename _Tp>
949 void
950 operator()()
952 std::atomic<_Tp> __x;
953 _Tp __expected = 0;
954 __x.compare_exchange_strong(__expected, 1, _Torder);
955 __x.compare_exchange_weak(__expected, 1, _Torder);
958 #endif
960 #if __cplusplus >= 201402L
961 // Check that bitmask type T supports all the required operators,
962 // with the required semantics. Check that each bitmask element
963 // has a distinct, nonzero value, and that each bitmask constant
964 // has no bits set which do not correspond to a bitmask element.
965 template<typename T>
966 constexpr bool
967 test_bitmask_values(std::initializer_list<T> elements,
968 std::initializer_list<T> constants = {})
970 const T t0{};
972 if (!(t0 == t0))
973 return false;
974 if (t0 != t0)
975 return false;
977 if (t0 & t0)
978 return false;
979 if (t0 | t0)
980 return false;
981 if (t0 ^ t0)
982 return false;
984 T all = t0;
986 for (auto t : elements)
988 // Each bitmask element has a distinct value.
989 if (t & all)
990 return false;
992 // Each bitmask element has a nonzero value.
993 if (!bool(t))
994 return false;
996 // Check operators
998 if (!(t == t))
999 return false;
1000 if (t != t)
1001 return false;
1002 if (t == t0)
1003 return false;
1004 if (t == all)
1005 return false;
1007 if (t & t0)
1008 return false;
1009 if ((t | t0) != t)
1010 return false;
1011 if ((t ^ t0) != t)
1012 return false;
1014 if ((t & t) != t)
1015 return false;
1016 if ((t | t) != t)
1017 return false;
1018 if (t ^ t)
1019 return false;
1021 T t1 = t;
1022 if ((t1 &= t) != t)
1023 return false;
1024 if ((t1 |= t) != t)
1025 return false;
1026 if (t1 ^= t)
1027 return false;
1029 t1 = all;
1030 if ((t1 &= t) != (all & t))
1031 return false;
1032 t1 = all;
1033 if ((t1 |= t) != (all | t))
1034 return false;
1035 t1 = all;
1036 if ((t1 ^= t) != (all ^ t))
1037 return false;
1039 all |= t;
1040 if (!(all & t))
1041 return false;
1044 for (auto t : constants)
1046 // Check that bitmask constants are composed of the bitmask elements.
1047 if ((t & all) != t)
1048 return false;
1049 if ((t | all) != all)
1050 return false;
1053 return true;
1055 #endif // C++14
1058 } // namespace __gnu_test
1059 #endif