]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/util/testsuite_common_types.h
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / util / testsuite_common_types.h
1 // -*- C++ -*-
2 // typelist for the C++ library testsuite.
3 //
4 // Copyright (C) 2005-2020 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.
11 //
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.
16 //
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/>.
20 //
21
22 #ifndef _TESTSUITE_COMMON_TYPES_H
23 #define _TESTSUITE_COMMON_TYPES_H 1
24
25 #include <ext/typelist.h>
26
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>
32
33 #include <algorithm>
34
35 #include <vector>
36 #include <list>
37 #include <deque>
38 #include <string>
39 #include <limits>
40
41 #include <map>
42 #include <set>
43 #include <tr1/functional>
44 #include <tr1/unordered_map>
45 #include <tr1/unordered_set>
46
47 #if __cplusplus >= 201103L
48 #include <atomic>
49 #include <type_traits>
50 #endif
51
52 namespace __gnu_test
53 {
54 using __gnu_cxx::typelist::null_type;
55 using __gnu_cxx::typelist::node;
56 using __gnu_cxx::typelist::transform;
57 using __gnu_cxx::typelist::append;
58
59 // All the allocators to test.
60 template<typename Tp, bool Thread>
61 struct allocator_policies
62 {
63 typedef Tp value_type;
64 typedef __gnu_cxx::new_allocator<Tp> a1;
65 typedef __gnu_cxx::malloc_allocator<Tp> a2;
66 typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, Thread> pool_policy;
67 typedef __gnu_cxx::__mt_alloc<Tp, pool_policy> a3;
68 typedef __gnu_cxx::bitmap_allocator<Tp> a4;
69 typedef __gnu_cxx::__pool_alloc<Tp> a5;
70 typedef node<_GLIBCXX_TYPELIST_CHAIN5(a1, a2, a3, a4, a5)> type;
71 };
72
73 // Typelists for vector, string, list, deque.
74 // XXX should just use template templates
75 template<typename Tp, bool Thread>
76 struct vectors
77 {
78 typedef Tp value_type;
79
80 template<typename Tl>
81 struct vector_shell
82 {
83 typedef Tl allocator_type;
84 typedef std::vector<value_type, allocator_type> type;
85 };
86
87 typedef allocator_policies<value_type, Thread> allocator_types;
88 typedef typename allocator_types::type allocator_typelist;
89 typedef typename transform<allocator_typelist, vector_shell>::type type;
90 };
91
92 template<typename Tp, bool Thread>
93 struct lists
94 {
95 typedef Tp value_type;
96
97 template<typename Tl>
98 struct list_shell
99 {
100 typedef Tl allocator_type;
101 typedef std::list<value_type, allocator_type> type;
102 };
103
104 typedef allocator_policies<value_type, Thread> allocator_types;
105 typedef typename allocator_types::type allocator_typelist;
106 typedef typename transform<allocator_typelist, list_shell>::type type;
107 };
108
109 template<typename Tp, bool Thread>
110 struct deques
111 {
112 typedef Tp value_type;
113
114 template<typename Tl>
115 struct deque_shell
116 {
117 typedef Tl allocator_type;
118 typedef std::deque<value_type, allocator_type> type;
119 };
120
121 typedef allocator_policies<value_type, Thread> allocator_types;
122 typedef typename allocator_types::type allocator_typelist;
123 typedef typename transform<allocator_typelist, deque_shell>::type type;
124 };
125
126 template<typename Tp, bool Thread>
127 struct strings
128 {
129 typedef Tp value_type;
130
131 template<typename Tl>
132 struct string_shell
133 {
134 typedef Tl allocator_type;
135 typedef std::char_traits<value_type> traits_type;
136 typedef std::basic_string<value_type, traits_type, allocator_type> type;
137 };
138
139 typedef allocator_policies<value_type, Thread> allocator_types;
140 typedef typename allocator_types::type allocator_typelist;
141 typedef typename transform<allocator_typelist, string_shell>::type type;
142 };
143
144 // A typelist of vector, list, deque, and string all instantiated
145 // with each of the allocator policies.
146 template<typename Tp, bool Thread>
147 struct sequence_containers
148 {
149 typedef Tp value_type;
150
151 typedef typename vectors<value_type, Thread>::type vector_typelist;
152 typedef typename lists<value_type, Thread>::type list_typelist;
153 typedef typename deques<value_type, Thread>::type deque_typelist;
154 typedef typename strings<value_type, Thread>::type string_typelist;
155
156 typedef typename append<vector_typelist, list_typelist>::type a1;
157 typedef typename append<deque_typelist, string_typelist>::type a2;
158 typedef typename append<a1, a2>::type type;
159 };
160
161 // Typelists for map, set, unordered_set, unordered_map.
162 template<typename Tp, bool Thread>
163 struct maps
164 {
165 typedef Tp value_type;
166 typedef Tp key_type;
167 typedef std::pair<const key_type, value_type> pair_type;
168 typedef std::less<key_type> compare_function;
169
170 template<typename Tl>
171 struct container
172 {
173 typedef Tl allocator_type;
174 typedef std::map<key_type, value_type, compare_function, allocator_type> type;
175 };
176
177 typedef allocator_policies<pair_type, Thread> allocator_types;
178 typedef typename allocator_types::type allocator_typelist;
179 typedef typename transform<allocator_typelist, container>::type type;
180 };
181
182 template<typename Tp, bool Thread>
183 struct unordered_maps
184 {
185 typedef Tp value_type;
186 typedef Tp key_type;
187 typedef std::pair<const key_type, value_type> pair_type;
188 typedef std::tr1::hash<key_type> hash_function;
189 typedef std::equal_to<key_type> equality_function;
190
191 template<typename Tl>
192 struct container
193 {
194 typedef Tl allocator_type;
195 typedef std::tr1::unordered_map<key_type, value_type, hash_function, equality_function, allocator_type> type;
196 };
197
198 typedef allocator_policies<pair_type, Thread> allocator_types;
199 typedef typename allocator_types::type allocator_typelist;
200 typedef typename transform<allocator_typelist, container>::type type;
201 };
202
203 template<typename Tp, bool Thread>
204 struct sets
205 {
206 typedef Tp value_type;
207 typedef Tp key_type;
208 typedef std::less<key_type> compare_function;
209
210 template<typename Tl>
211 struct container
212 {
213 typedef Tl allocator_type;
214 typedef std::set<key_type, compare_function, allocator_type> type;
215 };
216
217 typedef allocator_policies<key_type, Thread> allocator_types;
218 typedef typename allocator_types::type allocator_typelist;
219 typedef typename transform<allocator_typelist, container>::type type;
220 };
221
222 template<typename Tp, bool Thread>
223 struct unordered_sets
224 {
225 typedef Tp value_type;
226 typedef Tp key_type;
227 typedef std::tr1::hash<key_type> hash_function;
228 typedef std::equal_to<key_type> equality_function;
229
230 template<typename Tl>
231 struct container
232 {
233 typedef Tl allocator_type;
234 typedef std::tr1::unordered_set<key_type, hash_function, equality_function, allocator_type> type;
235 };
236
237 typedef allocator_policies<key_type, Thread> allocator_types;
238 typedef typename allocator_types::type allocator_typelist;
239 typedef typename transform<allocator_typelist, container>::type type;
240 };
241
242
243 // A typelist of all associated container types, with each of the
244 // allocator policies.
245 template<typename Tp, bool Thread>
246 struct associative_containers
247 {
248 typedef Tp value_type;
249
250 typedef typename maps<value_type, Thread>::type map_typelist;
251 typedef typename sets<value_type, Thread>::type set_typelist;
252 typedef typename unordered_maps<value_type, Thread>::type unordered_map_typelist;
253 typedef typename unordered_sets<value_type, Thread>::type unordered_set_typelist;
254
255 typedef typename append<map_typelist, unordered_map_typelist>::type a1;
256 typedef typename append<set_typelist, unordered_set_typelist>::type a2;
257 typedef typename append<a1, a2>::type type;
258 };
259
260 // A typelist of all standard integral types.
261 struct integral_types
262 {
263 typedef bool a1;
264 typedef char a2;
265 typedef signed char a3;
266 typedef unsigned char a4;
267 typedef short a5;
268 typedef unsigned short a6;
269 typedef int a7;
270 typedef unsigned int a8;
271 typedef long a9;
272 typedef unsigned long a10;
273 typedef long long a11;
274 typedef unsigned long long a12;
275 typedef wchar_t a13;
276 typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
277 a10, a11, a12, a13)> basic_typelist;
278 #if __cplusplus >= 201103L
279 typedef char16_t a14;
280 typedef char32_t a15;
281 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a14, a15)> cxx11_typelist;
282 #else
283 typedef node<null_type> cxx11_typelist;
284 #endif
285 #ifdef _GLIBCXX_USE_CHAR8_T
286 typedef char8_t a16;
287 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
288 #else
289 typedef node<null_type> char8_typelist;
290 #endif
291 typedef typename append<basic_typelist, cxx11_typelist>::type tl1;
292 typedef typename append<tl1, char8_typelist>::type type;
293 };
294
295 // A typelist of all standard integral types + the GNU 128-bit types.
296 struct integral_types_gnu
297 {
298 typedef bool a1;
299 typedef char a2;
300 typedef signed char a3;
301 typedef unsigned char a4;
302 typedef short a5;
303 typedef unsigned short a6;
304 typedef int a7;
305 typedef unsigned int a8;
306 typedef long a9;
307 typedef unsigned long a10;
308 typedef long long a11;
309 typedef unsigned long long a12;
310 typedef wchar_t a13;
311 typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
312 a10, a11, a12, a13)> basic_typelist;
313 #if __cplusplus >= 201103L
314 typedef char16_t a14;
315 typedef char32_t a15;
316 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a14, a15)> cxx11_typelist;
317 #else
318 typedef node<null_type> cxx11_typelist;
319 #endif
320 #ifdef _GLIBCXX_USE_CHAR8_T
321 typedef char8_t a16;
322 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
323 #else
324 typedef node<null_type> char8_typelist;
325 #endif
326 # if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
327 __extension__ typedef __int128 a17;
328 __extension__ typedef unsigned __int128 a18;
329 typedef node<_GLIBCXX_TYPELIST_CHAIN2(a17, a18)> int128_typelist;
330 #else
331 typedef node<null_type> int128_typelist;
332 #endif
333 typedef typename append<basic_typelist, cxx11_typelist>::type tl1;
334 typedef typename append<tl1, char8_typelist>::type tl2;
335 typedef typename append<tl2, int128_typelist>::type type;
336 };
337
338 #if __cplusplus >= 201103L
339 struct atomic_integrals_no_bool
340 {
341 typedef std::atomic_char a2;
342 typedef std::atomic_schar a3;
343 typedef std::atomic_uchar a4;
344 typedef std::atomic_short a5;
345 typedef std::atomic_ushort a6;
346 typedef std::atomic_int a7;
347 typedef std::atomic_uint a8;
348 typedef std::atomic_long a9;
349 typedef std::atomic_ulong a10;
350 typedef std::atomic_llong a11;
351 typedef std::atomic_ullong a12;
352 typedef std::atomic_wchar_t a13;
353 typedef std::atomic_char16_t a14;
354 typedef std::atomic_char32_t a15;
355 typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9, a10,
356 a11, a12, a13, a14, a15)> basic_typelist;
357 #ifdef _GLIBCXX_USE_CHAR8_T
358 typedef std::atomic_char8_t a16;
359 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
360 #else
361 typedef node<null_type> char8_typelist;
362 #endif
363 typedef typename append<basic_typelist, char8_typelist>::type type;
364 };
365
366 struct atomic_integrals
367 {
368 typedef std::atomic_bool a1;
369 typedef std::atomic_char a2;
370 typedef std::atomic_schar a3;
371 typedef std::atomic_uchar a4;
372 typedef std::atomic_short a5;
373 typedef std::atomic_ushort a6;
374 typedef std::atomic_int a7;
375 typedef std::atomic_uint a8;
376 typedef std::atomic_long a9;
377 typedef std::atomic_ulong a10;
378 typedef std::atomic_llong a11;
379 typedef std::atomic_ullong a12;
380 typedef std::atomic_wchar_t a13;
381 typedef std::atomic_char16_t a14;
382 typedef std::atomic_char32_t a15;
383 typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
384 a10, a11, a12, a13, a14, a15)> basic_typelist;
385 #ifdef _GLIBCXX_USE_CHAR8_T
386 typedef std::atomic_char8_t a16;
387 typedef node<_GLIBCXX_TYPELIST_CHAIN1(a16)> char8_typelist;
388 #else
389 typedef node<null_type> char8_typelist;
390 #endif
391 typedef typename append<basic_typelist, char8_typelist>::type type;
392 };
393
394
395 template<typename Tp>
396 struct atomics
397 {
398 typedef Tp value_type;
399 typedef std::atomic<value_type> type;
400 };
401
402 typedef transform<integral_types::type, atomics>::type atomics_tl;
403 #endif
404
405 template<typename Tp>
406 struct numeric_limits
407 {
408 typedef Tp value_type;
409 typedef std::numeric_limits<value_type> type;
410 };
411
412 typedef transform<integral_types_gnu::type, numeric_limits>::type limits_tl;
413
414 struct has_increment_operators
415 {
416 template<typename _Tp>
417 void
418 operator()()
419 {
420 struct _Concept
421 {
422 void __constraint()
423 {
424 _Tp a;
425 ++a; // prefix
426 a++; // postfix
427 a += a;
428 }
429 };
430
431 void (_Concept::*__x)() __attribute__((unused))
432 = &_Concept::__constraint;
433 }
434 };
435
436 struct has_decrement_operators
437 {
438 template<typename _Tp>
439 void
440 operator()()
441 {
442 struct _Concept
443 {
444 void __constraint()
445 {
446 _Tp a;
447 --a; // prefix
448 a--; // postfix
449 a -= a;
450 }
451 };
452
453 void (_Concept::*__x)() __attribute__((unused))
454 = &_Concept::__constraint;
455 }
456 };
457
458 #if __cplusplus >= 201103L
459 template<typename _Tp>
460 void
461 constexpr_bitwise_operators()
462 {
463 constexpr _Tp a = _Tp();
464 constexpr _Tp b = _Tp();
465 constexpr _Tp c1 __attribute__((unused)) = a | b;
466 constexpr _Tp c2 __attribute__((unused)) = a & b;
467 constexpr _Tp c3 __attribute__((unused)) = a ^ b;
468 constexpr _Tp c4 __attribute__((unused)) = ~b;
469 }
470 #endif
471
472 template<typename _Tp>
473 void
474 bitwise_operators()
475 {
476 _Tp a = _Tp();
477 _Tp b = _Tp();
478 a | b;
479 a & b;
480 a ^ b;
481 ~b;
482 }
483
484 template<typename _Tp>
485 void
486 bitwise_assignment_operators()
487 {
488 #if __cplusplus >= 201103L
489 _Tp a{};
490 _Tp b{};
491 #else
492 _Tp a = _Tp();
493 _Tp b = _Tp();
494 #endif
495 a |= b; // set
496 a &= ~b; // clear
497 a ^= b;
498 }
499
500 // 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
501 // bitmask_operators
502 template<typename _BitmTp>
503 void
504 bitmask_operators()
505 {
506 bitwise_operators<_BitmTp>();
507 bitwise_assignment_operators<_BitmTp>();
508 }
509
510 struct has_bitwise_operators
511 {
512 template<typename _Tp>
513 void
514 operator()()
515 {
516 struct _Concept
517 {
518 void __constraint()
519 {
520 a |= b; // set
521 a &= ~b; // clear
522 a ^= b;
523 }
524 _Tp a;
525 _Tp b;
526 };
527
528 void (_Concept::*__x)() __attribute__((unused))
529 = &_Concept::__constraint;
530 }
531 };
532
533 #if __cplusplus >= 201103L
534
535 struct constexpr_comparison_eq_ne
536 {
537 template<typename _Tp1, typename _Tp2 = _Tp1>
538 void
539 operator()()
540 {
541 static_assert(_Tp1() == _Tp2(), "eq");
542 static_assert(!(_Tp1() != _Tp2()), "ne");
543 }
544 };
545
546 struct constexpr_comparison_operators
547 {
548 template<typename _Tp>
549 void
550 operator()()
551 {
552 static_assert(!(_Tp() < _Tp()), "less");
553 static_assert(_Tp() <= _Tp(), "leq");
554 static_assert(!(_Tp() > _Tp()), "more");
555 static_assert(_Tp() >= _Tp(), "meq");
556 static_assert(_Tp() == _Tp(), "eq");
557 static_assert(!(_Tp() != _Tp()), "ne");
558 }
559 };
560
561 // Generator to test standard layout
562 struct has_trivial_cons_dtor
563 {
564 template<typename _Tp>
565 void
566 operator()()
567 {
568 struct _Concept
569 {
570 void __constraint()
571 {
572 typedef std::is_trivially_default_constructible<_Tp> ctor_p;
573 static_assert(ctor_p::value, "default constructor not trivial");
574
575 typedef std::is_trivially_destructible<_Tp> dtor_p;
576 static_assert(dtor_p::value, "destructor not trivial");
577 }
578 };
579
580 void (_Concept::*__x)() __attribute__((unused))
581 = &_Concept::__constraint;
582 }
583 };
584
585 struct standard_layout
586 {
587 template<typename _Tp>
588 void
589 operator()()
590 {
591 struct _Concept
592 {
593 void __constraint()
594 {
595 typedef std::is_standard_layout<_Tp> standard_layout_p;
596 static_assert(standard_layout_p::value, "not standard_layout");
597 }
598 };
599
600 void (_Concept::*__x)() __attribute__((unused))
601 = &_Concept::__constraint;
602 }
603 };
604 #endif
605
606 // Generator to test base class
607 struct has_required_base_class
608 {
609 template<typename _TBase, typename _TDerived>
610 void
611 operator()()
612 {
613 struct _Concept
614 {
615 void __constraint()
616 {
617 const _TDerived& obj = __a;
618 const _TBase* base __attribute__((unused)) = &obj;
619 }
620
621 _TDerived __a;
622 };
623
624 void (_Concept::*__x)() __attribute__((unused))
625 = &_Concept::__constraint;
626 }
627 };
628
629 // Generator to test assignment operator.
630 struct assignable
631 {
632 template<typename _Tp>
633 void
634 operator()()
635 {
636 struct _Concept
637 {
638 void __constraint()
639 { __v1 = __v2; }
640
641 _Tp __v1;
642 _Tp __v2;
643 };
644
645 void (_Concept::*__x)() __attribute__((unused))
646 = &_Concept::__constraint;
647 }
648 };
649
650 // Generator to test default constructor.
651 struct default_constructible
652 {
653 template<typename _Tp>
654 void
655 operator()()
656 {
657 struct _Concept
658 {
659 void __constraint()
660 { _Tp __v __attribute__((unused)); }
661 };
662
663 void (_Concept::*__x)() __attribute__((unused))
664 = &_Concept::__constraint;
665 }
666 };
667
668 // Generator to test copy constructor.
669 struct copy_constructible
670 {
671 template<typename _Tp>
672 void
673 operator()()
674 {
675 struct _Concept
676 {
677 void __constraint()
678 { _Tp __v2(__v1); }
679
680 _Tp __v1;
681 };
682
683 void (_Concept::*__x)() __attribute__((unused))
684 = &_Concept::__constraint;
685 }
686 };
687
688 // Generator to test direct initialization, single value constructor.
689 struct single_value_constructible
690 {
691 template<typename _Ttype, typename _Tvalue>
692 void
693 operator()()
694 {
695 struct _Concept
696 {
697 void __constraint()
698 { _Ttype __v(__a); }
699
700 _Tvalue __a;
701 };
702
703 void (_Concept::*__x)() __attribute__((unused))
704 = &_Concept::__constraint;
705 }
706 };
707
708 #if __cplusplus >= 201103L
709 // Generator to test non-explicit default constructor.
710 struct implicitly_default_constructible
711 {
712 template<typename _Tp>
713 void
714 operator()()
715 {
716 struct _Concept
717 {
718 struct Aggregate { _Tp v; };
719
720 void __constraint()
721 { Aggregate __v __attribute__((unused)) = { }; }
722 };
723
724 void (_Concept::*__x)() __attribute__((unused))
725 = &_Concept::__constraint;
726 }
727 };
728
729 // Generator to test default constructor.
730 struct constexpr_default_constructible
731 {
732 template<typename _Tp, bool _IsLitp = std::is_literal_type<_Tp>::value>
733 struct _Concept;
734
735 // NB: _Tp must be a literal type.
736 // Have to have user-defined default ctor for this to work,
737 // or implicit default ctor must initialize all members.
738 template<typename _Tp>
739 struct _Concept<_Tp, true>
740 {
741 void __constraint()
742 { constexpr _Tp __obj; }
743 };
744
745 // Non-literal type, declare local static and verify no
746 // constructors generated for _Tp within the translation unit.
747 template<typename _Tp>
748 struct _Concept<_Tp, false>
749 {
750 void __constraint()
751 { static _Tp __obj; }
752 };
753
754 template<typename _Tp>
755 void
756 operator()()
757 {
758 _Concept<_Tp> c;
759 c.__constraint();
760 }
761 };
762
763 // Generator to test defaulted default constructor.
764 struct constexpr_defaulted_default_constructible
765 {
766 template<typename _Tp>
767 void
768 operator()()
769 {
770 struct _Concept
771 {
772 void __constraint()
773 { constexpr _Tp __v __attribute__((unused)) { }; }
774 };
775
776 void (_Concept::*__x)() __attribute__((unused))
777 = &_Concept::__constraint;
778 }
779 };
780
781 struct constexpr_single_value_constructible
782 {
783 template<typename _Ttesttype, typename _Tvaluetype,
784 bool _IsLitp = std::is_literal_type<_Ttesttype>::value>
785 struct _Concept;
786
787 // NB: _Tvaluetype and _Ttesttype must be literal types.
788 // Additional constraint on _Tvaluetype needed. Either assume
789 // user-defined default ctor as per
790 // constexpr_default_constructible and provide no initializer,
791 // provide an initializer, or assume empty-list init-able. Choose
792 // the latter.
793 template<typename _Ttesttype, typename _Tvaluetype>
794 struct _Concept<_Ttesttype, _Tvaluetype, true>
795 {
796 void __constraint()
797 {
798 constexpr _Tvaluetype __v { };
799 constexpr _Ttesttype __obj(__v);
800 }
801 };
802
803 template<typename _Ttesttype, typename _Tvaluetype>
804 struct _Concept<_Ttesttype, _Tvaluetype, false>
805 {
806 void __constraint()
807 {
808 const _Tvaluetype __v { };
809 static _Ttesttype __obj(__v);
810 }
811 };
812
813 template<typename _Ttesttype, typename _Tvaluetype>
814 void
815 operator()()
816 {
817 _Concept<_Ttesttype, _Tvaluetype> c;
818 c.__constraint();
819 }
820 };
821 #endif
822
823 // Generator to test direct list initialization
824 #if __cplusplus >= 201103L
825 struct direct_list_initializable
826 {
827 template<typename _Ttype, typename _Tvalue>
828 void
829 operator()()
830 {
831 struct _Concept
832 {
833 void __constraint()
834 {
835 _Ttype __v1 { }; // default ctor
836 _Ttype __v2 { __a }; // single-argument ctor
837 }
838
839 _Tvalue __a;
840 };
841
842 void (_Concept::*__x)() __attribute__((unused))
843 = &_Concept::__constraint;
844 }
845 };
846 #endif
847
848 // Generator to test copy list initialization, aggregate initialization
849 struct copy_list_initializable
850 {
851 template<typename _Ttype, typename _Tvalue>
852 void
853 operator()()
854 {
855 struct _Concept
856 {
857 void __constraint()
858 { _Ttype __v __attribute__((unused)) = {__a}; }
859
860 _Tvalue __a;
861 };
862
863 void (_Concept::*__x)() __attribute__((unused))
864 = &_Concept::__constraint;
865 }
866 };
867
868 // Generator to test integral conversion operator
869 struct integral_convertable
870 {
871 template<typename _Ttype, typename _Tvalue>
872 void
873 operator()()
874 {
875 struct _Concept
876 {
877 void __constraint()
878 {
879 _Tvalue __v0(0);
880 _Tvalue __v1(1);
881 _Ttype __a(__v1);
882 __v0 = __a;
883
884 VERIFY( __v1 == __v0 );
885 }
886 };
887
888 void (_Concept::*__x)() __attribute__((unused))
889 = &_Concept::__constraint;
890 }
891 };
892
893 // Generator to test integral assignment operator
894 struct integral_assignable
895 {
896 template<typename _Ttype, typename _Tvalue>
897 void
898 operator()()
899 {
900 struct _Concept
901 {
902 void __constraint()
903 {
904 _Tvalue __v0(0);
905 _Tvalue __v1(1);
906 _Ttype __a(__v0);
907 __a = __v1;
908 _Tvalue __vr = __a;
909
910 VERIFY( __v1 == __vr );
911 }
912 };
913
914 void (_Concept::*__x)() __attribute__((unused))
915 = &_Concept::__constraint;
916 }
917 };
918
919 #if __cplusplus >= 201103L
920 // Generator to test lowering requirements for compare-and-exchange.
921 template<std::memory_order _Torder>
922 struct compare_exchange_order_lowering
923 {
924 template<typename _Tp>
925 void
926 operator()()
927 {
928 std::atomic<_Tp> __x;
929 _Tp __expected = 0;
930 __x.compare_exchange_strong(__expected, 1, _Torder);
931 __x.compare_exchange_weak(__expected, 1, _Torder);
932 }
933 };
934 #endif
935 } // namespace __gnu_test
936 #endif