OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libstdc++-v3/] [testsuite/] [util/] [testsuite_common_types.h] - Blame information for rev 746

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 742 jeremybenn
// -*- C++ -*-
2
// typelist for the C++ library testsuite. 
3
//
4
// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
5
// Free Software Foundation, Inc.
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
 
23
#ifndef _TESTSUITE_COMMON_TYPES_H
24
#define _TESTSUITE_COMMON_TYPES_H 1
25
 
26
#include <ext/typelist.h>
27
 
28
#include <ext/new_allocator.h>
29
#include <ext/malloc_allocator.h>
30
#include <ext/mt_allocator.h>
31
#include <ext/bitmap_allocator.h>
32
#include <ext/pool_allocator.h>
33
 
34
#include <algorithm>
35
 
36
#include <vector>
37
#include <list>
38
#include <deque>
39
#include <string>
40
#include <limits>
41
 
42
#include <map>
43
#include <set>
44
#include <tr1/functional>
45
#include <tr1/unordered_map>
46
#include <tr1/unordered_set>
47
 
48
#ifdef __GXX_EXPERIMENTAL_CXX0X__
49
#include <atomic>
50
#include <type_traits>
51
#endif
52
 
53
namespace __gnu_test
54
{
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
#ifdef __GXX_EXPERIMENTAL_CXX0X__
277
    typedef char16_t            a14;
278
    typedef char32_t            a15;
279
 
280
    typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
281
                                           a10, a11, a12, a13, a14, a15)> type;
282
#else
283
    typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
284
                                           a10, a11, a12, a13)> type;
285
#endif
286
  };
287
 
288
  // A typelist of all standard integral types + the GNU 128-bit types.
289
  struct integral_types_gnu
290
  {
291
    typedef bool                a1;
292
    typedef char                a2;
293
    typedef signed char         a3;
294
    typedef unsigned char       a4;
295
    typedef short               a5;
296
    typedef unsigned short      a6;
297
    typedef int                 a7;
298
    typedef unsigned int        a8;
299
    typedef long                a9;
300
    typedef unsigned long       a10;
301
    typedef long long           a11;
302
    typedef unsigned long long  a12;
303
    typedef wchar_t             a13;
304
#ifdef __GXX_EXPERIMENTAL_CXX0X__
305
    typedef char16_t            a14;
306
    typedef char32_t            a15;
307
# if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
308
    typedef __int128            a16;
309
    typedef unsigned __int128   a17;
310
 
311
    typedef node<_GLIBCXX_TYPELIST_CHAIN17(a1, a2, a3, a4, a5, a6, a7, a8, a9,
312
                                           a10, a11, a12, a13, a14, a15,
313
                                           a16, a17)> type;
314
# else
315
    typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
316
                                           a10, a11, a12, a13, a14, a15)> type;
317
# endif
318
#else
319
# if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
320
    typedef __int128            a14;
321
    typedef unsigned __int128   a15;
322
 
323
    typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
324
                                           a10, a11, a12, a13, a14, a15)> type;
325
# else
326
   typedef node<_GLIBCXX_TYPELIST_CHAIN13(a1, a2, a3, a4, a5, a6, a7, a8, a9,
327
                                          a10, a11, a12, a13)> type;
328
# endif
329
#endif
330
  };
331
 
332
#ifdef __GXX_EXPERIMENTAL_CXX0X__
333
  struct atomic_integrals_no_bool
334
  {
335
    typedef std::atomic_char            a2;
336
    typedef std::atomic_schar           a3;
337
    typedef std::atomic_uchar           a4;
338
    typedef std::atomic_short           a5;
339
    typedef std::atomic_ushort          a6;
340
    typedef std::atomic_int             a7;
341
    typedef std::atomic_uint            a8;
342
    typedef std::atomic_long            a9;
343
    typedef std::atomic_ulong           a10;
344
    typedef std::atomic_llong           a11;
345
    typedef std::atomic_ullong          a12;
346
    typedef std::atomic_wchar_t         a13;
347
    typedef std::atomic_char16_t        a14;
348
    typedef std::atomic_char32_t        a15;
349
 
350
    typedef node<_GLIBCXX_TYPELIST_CHAIN14(a2, a3, a4, a5, a6, a7, a8, a9,
351
                                           a10, a11, a12, a13, a14, a15)> type;
352
  };
353
 
354
  struct atomic_integrals
355
  {
356
    typedef std::atomic_bool            a1;
357
    typedef std::atomic_char            a2;
358
    typedef std::atomic_schar           a3;
359
    typedef std::atomic_uchar           a4;
360
    typedef std::atomic_short           a5;
361
    typedef std::atomic_ushort          a6;
362
    typedef std::atomic_int             a7;
363
    typedef std::atomic_uint            a8;
364
    typedef std::atomic_long            a9;
365
    typedef std::atomic_ulong           a10;
366
    typedef std::atomic_llong           a11;
367
    typedef std::atomic_ullong          a12;
368
    typedef std::atomic_wchar_t         a13;
369
    typedef std::atomic_char16_t        a14;
370
    typedef std::atomic_char32_t        a15;
371
 
372
    typedef node<_GLIBCXX_TYPELIST_CHAIN15(a1, a2, a3, a4, a5, a6, a7, a8, a9,
373
                                           a10, a11, a12, a13, a14, a15)> type;
374
  };
375
 
376
 
377
  template<typename Tp>
378
    struct atomics
379
    {
380
      typedef Tp                        value_type;
381
      typedef std::atomic<value_type>   type;
382
    };
383
 
384
  typedef transform<integral_types::type, atomics>::type atomics_tl;
385
#endif
386
 
387
  template<typename Tp>
388
    struct numeric_limits
389
    {
390
      typedef Tp                        value_type;
391
      typedef std::numeric_limits<value_type>   type;
392
    };
393
 
394
  typedef transform<integral_types_gnu::type, numeric_limits>::type limits_tl;
395
 
396
  struct has_increment_operators
397
  {
398
    template<typename _Tp>
399
      void
400
      operator()()
401
      {
402
        struct _Concept
403
        {
404
          void __constraint()
405
          {
406
            _Tp a;
407
            ++a; // prefix
408
            a++; // postfix
409
            a += a;
410
          }
411
        };
412
 
413
        void (_Concept::*__x)() __attribute__((unused))
414
          = &_Concept::__constraint;
415
      }
416
  };
417
 
418
  struct has_decrement_operators
419
  {
420
    template<typename _Tp>
421
      void
422
      operator()()
423
      {
424
        struct _Concept
425
        {
426
          void __constraint()
427
          {
428
            _Tp a;
429
            --a; // prefix
430
            a--; // postfix
431
            a -= a;
432
          }
433
        };
434
 
435
        void (_Concept::*__x)() __attribute__((unused))
436
          = &_Concept::__constraint;
437
      }
438
  };
439
 
440
#ifdef __GXX_EXPERIMENTAL_CXX0X__
441
  template<typename _Tp>
442
    void
443
    constexpr_bitwise_operators()
444
    {
445
      constexpr _Tp a = _Tp();
446
      constexpr _Tp b = _Tp();
447
      constexpr _Tp c1 __attribute__((unused)) = a | b;
448
      constexpr _Tp c2 __attribute__((unused)) = a & b;
449
      constexpr _Tp c3 __attribute__((unused)) = a ^ b;
450
      constexpr _Tp c4 __attribute__((unused)) = ~b;
451
    }
452
#endif
453
 
454
  template<typename _Tp>
455
    void
456
    bitwise_operators()
457
    {
458
      _Tp a = _Tp();
459
      _Tp b = _Tp();
460
      a | b;
461
      a & b;
462
      a ^ b;
463
      ~b;
464
    }
465
 
466
  template<typename _Tp>
467
    void
468
    bitwise_assignment_operators()
469
    {
470
      _Tp a = _Tp();
471
      _Tp b = _Tp();
472
      a |= b; // set
473
      a &= ~b; // clear
474
      a ^= b;
475
    }
476
 
477
  // 17.3.2.1.2 - Bitmask types [lib.bitmask.types]
478
  // bitmask_operators
479
  template<typename _BitmTp>
480
    void
481
    bitmask_operators()
482
    {
483
      bitwise_operators<_BitmTp>();
484
      bitwise_assignment_operators<_BitmTp>();
485
    }
486
 
487
  struct has_bitwise_operators
488
  {
489
    template<typename _Tp>
490
      void
491
      operator()()
492
      {
493
        struct _Concept
494
        {
495
          void __constraint()
496
          {
497
            a |= b; // set
498
            a &= ~b; // clear
499
            a ^= b;
500
          }
501
          _Tp a;
502
          _Tp b;
503
        };
504
 
505
        void (_Concept::*__x)() __attribute__((unused))
506
          = &_Concept::__constraint;
507
      }
508
  };
509
 
510
#ifdef __GXX_EXPERIMENTAL_CXX0X__
511
 
512
  struct constexpr_comparison_eq_ne
513
  {
514
    template<typename _Tp1, typename _Tp2 = _Tp1>
515
      void
516
      operator()()
517
      {
518
        static_assert(_Tp1() == _Tp2(), "eq");
519
        static_assert(!(_Tp1() != _Tp2()), "ne");
520
      }
521
  };
522
 
523
  struct constexpr_comparison_operators
524
  {
525
    template<typename _Tp>
526
      void
527
      operator()()
528
      {
529
        static_assert(!(_Tp() < _Tp()), "less");
530
        static_assert(_Tp() <= _Tp(), "leq");
531
        static_assert(!(_Tp() > _Tp()), "more");
532
        static_assert(_Tp() >= _Tp(), "meq");
533
        static_assert(_Tp() == _Tp(), "eq");
534
        static_assert(!(_Tp() != _Tp()), "ne");
535
      }
536
  };
537
 
538
  // Generator to test standard layout
539
  struct has_trivial_cons_dtor
540
  {
541
    template<typename _Tp>
542
      void
543
      operator()()
544
      {
545
        struct _Concept
546
        {
547
          void __constraint()
548
          {
549
            typedef std::has_trivial_default_constructor<_Tp> ctor_p;
550
            static_assert(ctor_p::value, "default constructor not trivial");
551
 
552
            typedef std::has_trivial_destructor<_Tp> dtor_p;
553
            static_assert(dtor_p::value, "destructor not trivial");
554
          }
555
        };
556
 
557
        void (_Concept::*__x)() __attribute__((unused))
558
          = &_Concept::__constraint;
559
      }
560
  };
561
 
562
  struct standard_layout
563
  {
564
    template<typename _Tp>
565
      void
566
      operator()()
567
      {
568
        struct _Concept
569
        {
570
          void __constraint()
571
          {
572
            typedef std::is_standard_layout<_Tp> standard_layout_p;
573
            static_assert(standard_layout_p::value, "not standard_layout");
574
          }
575
        };
576
 
577
        void (_Concept::*__x)() __attribute__((unused))
578
          = &_Concept::__constraint;
579
      }
580
  };
581
#endif
582
 
583
  // Generator to test base class
584
  struct has_required_base_class
585
  {
586
    template<typename _TBase, typename _TDerived>
587
      void
588
      operator()()
589
      {
590
        struct _Concept
591
        {
592
          void __constraint()
593
          {
594
            const _TDerived& obj = __a;
595
            const _TBase* base __attribute__((unused)) = &obj;
596
          }
597
 
598
          _TDerived __a;
599
        };
600
 
601
        void (_Concept::*__x)() __attribute__((unused))
602
          = &_Concept::__constraint;
603
      }
604
  };
605
 
606
  // Generator to test assignment operator.
607
  struct assignable
608
  {
609
    template<typename _Tp>
610
      void
611
      operator()()
612
      {
613
        struct _Concept
614
        {
615
          void __constraint()
616
          { __v1 = __v2; }
617
 
618
          _Tp __v1;
619
          _Tp __v2;
620
        };
621
 
622
        void (_Concept::*__x)() __attribute__((unused))
623
          = &_Concept::__constraint;
624
      }
625
  };
626
 
627
  // Generator to test default constructor.
628
  struct default_constructible
629
  {
630
    template<typename _Tp>
631
      void
632
      operator()()
633
      {
634
        struct _Concept
635
        {
636
          void __constraint()
637
          { _Tp __v __attribute__((unused)); }
638
        };
639
 
640
        void (_Concept::*__x)() __attribute__((unused))
641
          = &_Concept::__constraint;
642
      }
643
  };
644
 
645
  // Generator to test copy constructor.
646
  struct copy_constructible
647
  {
648
    template<typename _Tp>
649
      void
650
      operator()()
651
      {
652
        struct _Concept
653
        {
654
          void __constraint()
655
          { _Tp __v2(__v1); }
656
 
657
          _Tp __v1;
658
        };
659
 
660
        void (_Concept::*__x)() __attribute__((unused))
661
          = &_Concept::__constraint;
662
      }
663
  };
664
 
665
  // Generator to test direct initialization, single value constructor.
666
  struct single_value_constructible
667
  {
668
    template<typename _Ttype, typename _Tvalue>
669
      void
670
      operator()()
671
      {
672
        struct _Concept
673
        {
674
          void __constraint()
675
          { _Ttype __v(__a); }
676
 
677
          _Tvalue __a;
678
        };
679
 
680
        void (_Concept::*__x)() __attribute__((unused))
681
          = &_Concept::__constraint;
682
      }
683
  };
684
 
685
#ifdef __GXX_EXPERIMENTAL_CXX0X__
686
  // Generator to test default constructor.
687
  struct constexpr_default_constructible
688
  {
689
    template<typename _Tp, bool _IsLitp = std::is_literal_type<_Tp>::value>
690
      struct _Concept;
691
 
692
    // NB: _Tp must be a literal type.
693
    // Have to have user-defined default ctor for this to work.
694
    template<typename _Tp>
695
      struct _Concept<_Tp, true>
696
      {
697
        void __constraint()
698
        { constexpr _Tp __obj; }
699
      };
700
 
701
    // Non-literal type, declare local static and verify no
702
    // constructors generated for _Tp within the translation unit.
703
    template<typename _Tp>
704
      struct _Concept<_Tp, false>
705
      {
706
        void __constraint()
707
        { static _Tp __obj; }
708
      };
709
 
710
    template<typename _Tp>
711
      void
712
      operator()()
713
      {
714
        _Concept<_Tp> c;
715
        c.__constraint();
716
      }
717
  };
718
 
719
  // Generator to test defaulted default constructor.
720
  struct constexpr_defaulted_default_constructible
721
  {
722
    template<typename _Tp>
723
      void
724
      operator()()
725
      {
726
        struct _Concept
727
        {
728
          void __constraint()
729
          { constexpr _Tp __v __attribute__((unused)) { }; }
730
        };
731
 
732
        void (_Concept::*__x)() __attribute__((unused))
733
          = &_Concept::__constraint;
734
      }
735
  };
736
 
737
  struct constexpr_single_value_constructible
738
  {
739
    template<typename _Ttesttype, typename _Tvaluetype,
740
             bool _IsLitp = std::is_literal_type<_Ttesttype>::value>
741
      struct _Concept;
742
 
743
    // NB: _Tvaluetype and _Ttesttype must be literal types.
744
    // Additional constraint on _Tvaluetype needed.  Either assume
745
    // user-defined default ctor as per
746
    // constexpr_default_constructible and provide no initializer,
747
    // provide an initializer, or assume empty-list init-able. Choose
748
    // the latter.
749
    template<typename _Ttesttype, typename _Tvaluetype>
750
      struct _Concept<_Ttesttype, _Tvaluetype, true>
751
      {
752
        void __constraint()
753
        {
754
          constexpr _Tvaluetype __v { };
755
          constexpr _Ttesttype __obj(__v);
756
        }
757
      };
758
 
759
    template<typename _Ttesttype, typename _Tvaluetype>
760
      struct _Concept<_Ttesttype, _Tvaluetype, false>
761
      {
762
        void __constraint()
763
        {
764
          const _Tvaluetype __v { };
765
          static _Ttesttype __obj(__v);
766
        }
767
      };
768
 
769
    template<typename _Ttesttype, typename _Tvaluetype>
770
      void
771
      operator()()
772
      {
773
        _Concept<_Ttesttype, _Tvaluetype> c;
774
        c.__constraint();
775
      }
776
  };
777
#endif
778
 
779
  // Generator to test direct list initialization
780
#ifdef __GXX_EXPERIMENTAL_CXX0X__
781
  struct direct_list_initializable
782
  {
783
    template<typename _Ttype, typename _Tvalue>
784
      void
785
      operator()()
786
      {
787
        struct _Concept
788
        {
789
          void __constraint()
790
          {
791
            _Ttype __v1 { }; // default ctor
792
            _Ttype __v2 { __a };  // single-argument ctor
793
          }
794
 
795
          _Tvalue __a;
796
        };
797
 
798
        void (_Concept::*__x)() __attribute__((unused))
799
          = &_Concept::__constraint;
800
      }
801
  };
802
#endif
803
 
804
  // Generator to test copy list initialization, aggregate initialization
805
  struct copy_list_initializable
806
  {
807
    template<typename _Ttype, typename _Tvalue>
808
      void
809
      operator()()
810
      {
811
        struct _Concept
812
        {
813
          void __constraint()
814
          { _Ttype __v __attribute__((unused)) = {__a}; }
815
 
816
          _Tvalue __a;
817
        };
818
 
819
        void (_Concept::*__x)() __attribute__((unused))
820
          = &_Concept::__constraint;
821
      }
822
  };
823
 
824
  // Generator to test integral conversion operator
825
  struct integral_convertable
826
  {
827
    template<typename _Ttype, typename _Tvalue>
828
      void
829
      operator()()
830
      {
831
        struct _Concept
832
        {
833
          void __constraint()
834
          {
835
            _Tvalue __v0(0);
836
            _Tvalue __v1(1);
837
            _Ttype __a(__v1);
838
            __v0 = __a;
839
 
840
            bool test __attribute__((unused)) = true;
841
            VERIFY( __v1 == __v0 );
842
          }
843
        };
844
 
845
        void (_Concept::*__x)() __attribute__((unused))
846
          = &_Concept::__constraint;
847
      }
848
  };
849
 
850
  // Generator to test integral assignment operator 
851
  struct integral_assignable
852
  {
853
    template<typename _Ttype, typename _Tvalue>
854
      void
855
      operator()()
856
      {
857
        struct _Concept
858
        {
859
          void __constraint()
860
          {
861
            _Tvalue __v0(0);
862
            _Tvalue __v1(1);
863
            _Ttype __a(__v0);
864
            __a = __v1;
865
            _Tvalue __vr = __a;
866
 
867
            bool test __attribute__((unused)) = true;
868
            VERIFY( __v1 == __vr );
869
          }
870
        };
871
 
872
        void (_Concept::*__x)() __attribute__((unused))
873
          = &_Concept::__constraint;
874
      }
875
  };
876
} // namespace __gnu_test
877
#endif

powered by: WebSVN 2.1.0

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