OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [util/] [testsuite_common_types.h] - Blame information for rev 516

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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