1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
|
// -*- C++ -*-
// typelist for the C++ library testsuite.
//
// Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
//
// As a special exception, you may use this file as part of a free software
// library without restriction. Specifically, if other files instantiate
// templates or use macros or inline functions from this file, or you compile
// this file and link it with other files to produce an executable, this
// file does not by itself cause the resulting executable to be covered by
// the GNU General Public License. This exception does not however
// invalidate any other reasons why the executable file might be covered by
// the GNU General Public License.
#ifndef _TESTSUITE_COMMON_TYPES_H
#define _TESTSUITE_COMMON_TYPES_H 1
#include <ext/typelist.h>
#include <ext/new_allocator.h>
#include <ext/malloc_allocator.h>
#include <ext/mt_allocator.h>
#include <ext/bitmap_allocator.h>
#include <ext/pool_allocator.h>
#include <algorithm>
#include <vector>
#include <list>
#include <deque>
#include <string>
#include <map>
#include <set>
#include <tr1/functional>
#include <tr1/unordered_map>
#include <tr1/unordered_set>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <cstdatomic>
#include <type_traits>
#endif
namespace __gnu_test
{
using __gnu_cxx::typelist::node;
using __gnu_cxx::typelist::transform;
using __gnu_cxx::typelist::append;
// All the allocators to test.
template<typename Tp, bool Thread>
struct allocator_policies
{
typedef Tp value_type;
typedef __gnu_cxx::new_allocator<Tp> a1;
typedef __gnu_cxx::malloc_allocator<Tp> a2;
typedef __gnu_cxx::__common_pool_policy<__gnu_cxx::__pool, Thread> pool_policy;
typedef __gnu_cxx::__mt_alloc<Tp, pool_policy> a3;
typedef __gnu_cxx::bitmap_allocator<Tp> a4;
typedef __gnu_cxx::__pool_alloc<Tp> a5;
typedef node<_GLIBCXX_TYPELIST_CHAIN5(a1, a2, a3, a4, a5)> type;
};
// Typelists for vector, string, list, deque.
// XXX should just use template templates
template<typename Tp, bool Thread>
struct vectors
{
typedef Tp value_type;
template<typename Tl>
struct vector_shell
{
typedef Tl allocator_type;
typedef std::vector<value_type, allocator_type> type;
};
typedef allocator_policies<value_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, vector_shell>::type type;
};
template<typename Tp, bool Thread>
struct lists
{
typedef Tp value_type;
template<typename Tl>
struct list_shell
{
typedef Tl allocator_type;
typedef std::list<value_type, allocator_type> type;
};
typedef allocator_policies<value_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, list_shell>::type type;
};
template<typename Tp, bool Thread>
struct deques
{
typedef Tp value_type;
template<typename Tl>
struct deque_shell
{
typedef Tl allocator_type;
typedef std::deque<value_type, allocator_type> type;
};
typedef allocator_policies<value_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, deque_shell>::type type;
};
template<typename Tp, bool Thread>
struct strings
{
typedef Tp value_type;
template<typename Tl>
struct string_shell
{
typedef Tl allocator_type;
typedef std::char_traits<value_type> traits_type;
typedef std::basic_string<value_type, traits_type, allocator_type> type;
};
typedef allocator_policies<value_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, string_shell>::type type;
};
// A typelist of vector, list, deque, and string all instantiated
// with each of the allocator policies.
template<typename Tp, bool Thread>
struct sequence_containers
{
typedef Tp value_type;
typedef typename vectors<value_type, Thread>::type vector_typelist;
typedef typename lists<value_type, Thread>::type list_typelist;
typedef typename deques<value_type, Thread>::type deque_typelist;
typedef typename strings<value_type, Thread>::type string_typelist;
typedef typename append<vector_typelist, list_typelist>::type a1;
typedef typename append<deque_typelist, string_typelist>::type a2;
typedef typename append<a1, a2>::type type;
};
// Typelists for map, set, unordered_set, unordered_map.
template<typename Tp, bool Thread>
struct maps
{
typedef Tp value_type;
typedef Tp key_type;
typedef std::pair<const key_type, value_type> pair_type;
typedef std::less<key_type> compare_function;
template<typename Tl>
struct container
{
typedef Tl allocator_type;
typedef std::map<key_type, value_type, compare_function, allocator_type> type;
};
typedef allocator_policies<pair_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, container>::type type;
};
template<typename Tp, bool Thread>
struct unordered_maps
{
typedef Tp value_type;
typedef Tp key_type;
typedef std::pair<const key_type, value_type> pair_type;
typedef std::tr1::hash<key_type> hash_function;
typedef std::equal_to<key_type> equality_function;
template<typename Tl>
struct container
{
typedef Tl allocator_type;
typedef std::tr1::unordered_map<key_type, value_type, hash_function, equality_function, allocator_type> type;
};
typedef allocator_policies<pair_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, container>::type type;
};
template<typename Tp, bool Thread>
struct sets
{
typedef Tp value_type;
typedef Tp key_type;
typedef std::less<key_type> compare_function;
template<typename Tl>
struct container
{
typedef Tl allocator_type;
typedef std::set<key_type, compare_function, allocator_type> type;
};
typedef allocator_policies<key_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, container>::type type;
};
template<typename Tp, bool Thread>
struct unordered_sets
{
typedef Tp value_type;
typedef Tp key_type;
typedef std::tr1::hash<key_type> hash_function;
typedef std::equal_to<key_type> equality_function;
template<typename Tl>
struct container
{
typedef Tl allocator_type;
typedef std::tr1::unordered_set<key_type, hash_function, equality_function, allocator_type> type;
};
typedef allocator_policies<key_type, Thread> allocator_types;
typedef typename allocator_types::type allocator_typelist;
typedef typename transform<allocator_typelist, container>::type type;
};
// A typelist of all associated container types, with each of the
// allocator policies.
template<typename Tp, bool Thread>
struct associative_containers
{
typedef Tp value_type;
typedef typename maps<value_type, Thread>::type map_typelist;
typedef typename sets<value_type, Thread>::type set_typelist;
typedef typename unordered_maps<value_type, Thread>::type unordered_map_typelist;
typedef typename unordered_sets<value_type, Thread>::type unordered_set_typelist;
typedef typename append<map_typelist, unordered_map_typelist>::type a1;
typedef typename append<set_typelist, unordered_set_typelist>::type a2;
typedef typename append<a1, a2>::type type;
};
// A typelist of all integral types.
struct integral_types
{
typedef bool a1;
typedef char a2;
typedef signed char a3;
typedef unsigned char a4;
typedef short a5;
typedef unsigned short a6;
typedef int a7;
typedef unsigned int a8;
typedef long a9;
typedef unsigned long a10;
typedef long long a11;
typedef unsigned long long a12;
typedef wchar_t a13;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
typedef char16_t a14;
typedef char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
#else
typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13)> type;
#endif
};
#ifdef __GXX_EXPERIMENTAL_CXX0X__
struct atomic_integrals_no_bool
{
typedef std::atomic_char a2;
typedef std::atomic_schar a3;
typedef std::atomic_uchar a4;
typedef std::atomic_short a5;
typedef std::atomic_ushort a6;
typedef std::atomic_int a7;
typedef std::atomic_uint a8;
typedef std::atomic_long a9;
typedef std::atomic_ulong a10;
typedef std::atomic_llong a11;
typedef std::atomic_ullong a12;
typedef std::atomic_wchar_t a13;
typedef std::atomic_char16_t a14;
typedef std::atomic_char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
};
struct atomic_integrals
{
typedef std::atomic_bool a1;
typedef std::atomic_char a2;
typedef std::atomic_schar a3;
typedef std::atomic_uchar a4;
typedef std::atomic_short a5;
typedef std::atomic_ushort a6;
typedef std::atomic_int a7;
typedef std::atomic_uint a8;
typedef std::atomic_long a9;
typedef std::atomic_ulong a10;
typedef std::atomic_llong a11;
typedef std::atomic_ullong a12;
typedef std::atomic_wchar_t a13;
typedef std::atomic_char16_t a14;
typedef std::atomic_char32_t a15;
typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
a10, a11, a12, a13, a14, a15)> type;
};
template<typename Tp>
struct atomics
{
typedef Tp value_type;
typedef std::atomic<value_type> type;
};
typedef transform<integral_types::type, atomics>::type atomics_tl;
#endif
struct has_increment_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tp a;
++a; // prefix
a++; // postfix
a += a;
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
struct has_decrement_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tp a;
--a; // prefix
a--; // postfix
a -= a;
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
template<typename _Tp>
void
bitwise_operators()
{
_Tp a;
_Tp b;
a | b;
a & b;
a ^ b;
~b;
}
template<typename _Tp>
void
bitwise_assignment_operators()
{
_Tp a;
_Tp b;
a |= b; // set
a &= ~b; // clear
a ^= b;
}
// 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
// bitmask_operators
template<typename _BitmTp>
void
bitmask_operators()
{
bitwise_operators<_BitmTp>();
bitwise_assignment_operators<_BitmTp>();
}
struct has_bitwise_operators
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
bitwise_assignment_operators<_Tp>();
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test standard layout
#ifdef __GXX_EXPERIMENTAL_CXX0X__
struct has_trivial_cons_dtor
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
typedef std::has_trivial_default_constructor<_Tp> ctor_p;
static_assert(ctor_p::value, "default constructor not trivial");
typedef std::has_trivial_destructor<_Tp> dtor_p;
static_assert(dtor_p::value, "destructor not trivial");
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
struct standard_layout
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{
// libstdc++/37907
// typedef std::is_standard_layout<_Tp> standard_layout_p;
// static_assert(standard_layout_p::value, "not standard_layout");
typedef std::has_virtual_destructor<_Tp> ctor_p;
static_assert(!ctor_p::value, "has virtual destructor");
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
#endif
// Generator to test base class
struct has_required_base_class
{
template<typename _TBase, typename _TDerived>
void
operator()()
{
struct _Concept
{
void __constraint()
{
const _TDerived& obj = __a;
const _TBase* base __attribute__((unused)) = &obj;
}
_TDerived __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test assignment operator.
struct assignable
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{ __v1 = __v2; }
_Tp __v1;
_Tp __v2;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test default constructor.
struct default_constructible
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{ _Tp __v; }
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test copy constructor.
struct copy_constructible
{
template<typename _Tp>
void
operator()()
{
struct _Concept
{
void __constraint()
{ _Tp __v2(__v1); }
_Tp __v1;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test direct initialization, single value constructor.
struct single_value_constructible
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{ _Ttype __v(__a); }
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test direct list initialization
#ifdef __GXX_EXPERIMENTAL_CXX0X__
struct direct_list_initializable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Ttype __v1 { }; // default ctor
_Ttype __v2 { __a }; // single-argument ctor
}
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
#endif
// Generator to test copy list initialization, aggregate initialization
struct copy_list_initializable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{ _Ttype __v = {__a}; }
_Tvalue __a;
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test integral conversion operator
struct integral_convertable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tvalue __v0(0);
_Tvalue __v1(1);
_Ttype __a(__v1);
__v0 = __a;
bool test __attribute__((unused)) = true;
VERIFY( __v1 == __v0 );
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
// Generator to test integral assignment operator
struct integral_assignable
{
template<typename _Ttype, typename _Tvalue>
void
operator()()
{
struct _Concept
{
void __constraint()
{
_Tvalue __v0(0);
_Tvalue __v1(1);
_Ttype __a(__v0);
__a = __v1;
_Tvalue __vr = __a;
bool test __attribute__((unused)) = true;
VERIFY( __v1 == __vr );
}
};
void (_Concept::*__x)() __attribute__((unused))
= &_Concept::__constraint;
}
};
} // namespace __gnu_test
#endif
|