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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 742 jeremybenn
// -*- C++ -*-
2
// Testing utilities for the tr1 testsuite.
3
//
4
// Copyright (C) 2004, 2005, 2006, 2007, 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 _GLIBCXX_TESTSUITE_TR1_H
24
#define _GLIBCXX_TESTSUITE_TR1_H
25
 
26
#include <ext/type_traits.h>
27
 
28
namespace __gnu_test
29
{
30
  // For tr1/type_traits.
31
  template<template<typename> class Category, typename Type>
32
    bool
33
    test_category(bool value)
34
    {
35
      bool ret = true;
36
      ret &= Category<Type>::value == value;
37
      ret &= Category<const Type>::value == value;
38
      ret &= Category<volatile Type>::value == value;
39
      ret &= Category<const volatile Type>::value == value;
40
      ret &= Category<Type>::type::value == value;
41
      ret &= Category<const Type>::type::value == value;
42
      ret &= Category<volatile Type>::type::value == value;
43
      ret &= Category<const volatile Type>::type::value == value;
44
      return ret;
45
    }
46
 
47
  template<template<typename> class Property, typename Type>
48
    bool
49
    test_property(typename Property<Type>::value_type value)
50
    {
51
      bool ret = true;
52
      ret &= Property<Type>::value == value;
53
      ret &= Property<Type>::type::value == value;
54
      return ret;
55
    }
56
 
57
  // For testing tr1/type_traits/extent, which has a second template
58
  // parameter.
59
  template<template<typename, unsigned> class Property,
60
           typename Type, unsigned Uint>
61
    bool
62
    test_property(typename Property<Type, Uint>::value_type value)
63
    {
64
      bool ret = true;
65
      ret &= Property<Type, Uint>::value == value;
66
      ret &= Property<Type, Uint>::type::value == value;
67
      return ret;
68
    }
69
 
70
#ifdef __GXX_EXPERIMENTAL_CXX0X__
71
  template<template<typename...> class Property,
72
           typename Type1, typename... Types>
73
    bool
74
    test_property(typename Property<Type1, Types...>::value_type value)
75
    {
76
      bool ret = true;
77
      ret &= Property<Type1, Types...>::value == value;
78
      ret &= Property<Type1, Types...>::type::value == value;
79
      return ret;
80
    }
81
#endif
82
 
83
  template<template<typename, typename> class Relationship,
84
           typename Type1, typename Type2>
85
    bool
86
    test_relationship(bool value)
87
    {
88
      bool ret = true;
89
      ret &= Relationship<Type1, Type2>::value == value;
90
      ret &= Relationship<Type1, Type2>::type::value == value;
91
      return ret;
92
    }
93
 
94
  // Test types.
95
  class ClassType { };
96
  typedef const ClassType           cClassType;
97
  typedef volatile ClassType        vClassType;
98
  typedef const volatile ClassType  cvClassType;
99
 
100
  class DerivedType : public ClassType { };
101
 
102
  enum EnumType { e0 };
103
 
104
  struct ConvType
105
  { operator int() const; };
106
 
107
  class AbstractClass
108
  {
109
    virtual void rotate(int) = 0;
110
  };
111
 
112
  class PolymorphicClass
113
  {
114
    virtual void rotate(int);
115
  };
116
 
117
  class DerivedPolymorphic : public PolymorphicClass { };
118
 
119
  class VirtualDestructorClass
120
  {
121
    virtual ~VirtualDestructorClass();
122
  };
123
 
124
  union UnionType { };
125
 
126
  class IncompleteClass;
127
 
128
  struct ExplicitClass
129
  {
130
    ExplicitClass(double&);
131
    explicit ExplicitClass(int&);
132
    ExplicitClass(double&, int&, double&);
133
  };
134
 
135
  struct NothrowExplicitClass
136
  {
137
    NothrowExplicitClass(double&) throw();
138
    explicit NothrowExplicitClass(int&) throw();
139
    NothrowExplicitClass(double&, int&, double&) throw();
140
  };
141
 
142
  struct ThrowExplicitClass
143
  {
144
    ThrowExplicitClass(double&) throw(int);
145
    explicit ThrowExplicitClass(int&) throw(int);
146
    ThrowExplicitClass(double&, int&, double&) throw(int);
147
  };
148
 
149
  struct ThrowDefaultClass
150
  {
151
    ThrowDefaultClass() throw(int);
152
  };
153
 
154
  struct ThrowCopyConsClass
155
  {
156
    ThrowCopyConsClass(const ThrowCopyConsClass&) throw(int);
157
  };
158
 
159
#ifdef __GXX_EXPERIMENTAL_CXX0X__
160
  struct ThrowMoveConsClass
161
  {
162
    ThrowMoveConsClass(ThrowMoveConsClass&&) throw(int);
163
  };
164
 
165
  struct NoexceptExplicitClass
166
  {
167
    NoexceptExplicitClass(double&) noexcept(true);
168
    explicit NoexceptExplicitClass(int&) noexcept(true);
169
    NoexceptExplicitClass(double&, int&, double&) noexcept(true);
170
  };
171
 
172
  struct ExceptExplicitClass
173
  {
174
    ExceptExplicitClass(double&) noexcept(false);
175
    explicit ExceptExplicitClass(int&) noexcept(false);
176
    ExceptExplicitClass(double&, int&, double&) noexcept(false);
177
  };
178
 
179
  struct NoexceptDefaultClass
180
  {
181
    NoexceptDefaultClass() noexcept(true);
182
  };
183
 
184
  struct ExceptDefaultClass
185
  {
186
    ExceptDefaultClass() noexcept(false);
187
  };
188
 
189
  struct NoexceptCopyConsClass
190
  {
191
    NoexceptCopyConsClass(const NoexceptCopyConsClass&) noexcept(true);
192
  };
193
 
194
  struct ExceptCopyConsClass
195
  {
196
    ExceptCopyConsClass(const ExceptCopyConsClass&) noexcept(false);
197
  };
198
 
199
  struct NoexceptMoveConsClass
200
  {
201
    NoexceptMoveConsClass(NoexceptMoveConsClass&&) noexcept(true);
202
    NoexceptMoveConsClass& operator=(NoexceptMoveConsClass&&) = default;
203
  };
204
 
205
  struct ExceptMoveConsClass
206
  {
207
    ExceptMoveConsClass(ExceptMoveConsClass&&) noexcept(false);
208
  };
209
 
210
  struct NoexceptCopyAssignClass
211
  {
212
    NoexceptCopyAssignClass&
213
    operator=(const NoexceptCopyAssignClass&) noexcept(true);
214
  };
215
 
216
  struct ExceptCopyAssignClass
217
  {
218
    ExceptCopyAssignClass&
219
    operator=(const ExceptCopyAssignClass&) noexcept(false);
220
  };
221
 
222
  struct NoexceptMoveAssignClass
223
  {
224
    NoexceptMoveAssignClass(NoexceptMoveAssignClass&&) = default;
225
    NoexceptMoveAssignClass&
226
    operator=(NoexceptMoveAssignClass&&) noexcept(true);
227
  };
228
 
229
  struct ExceptMoveAssignClass
230
  {
231
    ExceptMoveAssignClass&
232
    operator=(ExceptMoveAssignClass&&) noexcept(false);
233
  };
234
 
235
  struct DeletedCopyAssignClass
236
  {
237
    DeletedCopyAssignClass&
238
    operator=(const DeletedCopyAssignClass&) = delete;
239
  };
240
 
241
  struct DeletedMoveAssignClass
242
  {
243
    DeletedMoveAssignClass&
244
    operator=(DeletedMoveAssignClass&&) = delete;
245
  };
246
 
247
  struct NoexceptMoveConsNoexceptMoveAssignClass
248
  {
249
    NoexceptMoveConsNoexceptMoveAssignClass
250
    (NoexceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
251
 
252
    NoexceptMoveConsNoexceptMoveAssignClass&
253
    operator=(NoexceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
254
  };
255
 
256
  struct ExceptMoveConsNoexceptMoveAssignClass
257
  {
258
    ExceptMoveConsNoexceptMoveAssignClass
259
    (ExceptMoveConsNoexceptMoveAssignClass&&) noexcept(false);
260
 
261
    ExceptMoveConsNoexceptMoveAssignClass&
262
    operator=(ExceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
263
  };
264
 
265
  struct NoexceptMoveConsExceptMoveAssignClass
266
  {
267
    NoexceptMoveConsExceptMoveAssignClass
268
    (NoexceptMoveConsExceptMoveAssignClass&&) noexcept(true);
269
 
270
    NoexceptMoveConsExceptMoveAssignClass&
271
    operator=(NoexceptMoveConsExceptMoveAssignClass&&) noexcept(false);
272
  };
273
 
274
  struct ExceptMoveConsExceptMoveAssignClass
275
  {
276
    ExceptMoveConsExceptMoveAssignClass
277
    (ExceptMoveConsExceptMoveAssignClass&&) noexcept(false);
278
 
279
    ExceptMoveConsExceptMoveAssignClass&
280
    operator=(ExceptMoveConsExceptMoveAssignClass&&) noexcept(false);
281
  };
282
#endif
283
 
284
  struct NType   // neither trivial nor standard-layout
285
  {
286
    int i;
287
    int j;
288
    virtual ~NType();
289
  };
290
 
291
  struct TType   // trivial but not standard-layout
292
  {
293
    int i;
294
  private:
295
    int j;
296
  };
297
 
298
  struct SLType  // standard-layout but not trivial
299
  {
300
    int i;
301
    int j;
302
    ~SLType();
303
  };
304
 
305
  struct PODType // both trivial and standard-layout
306
  {
307
    int i;
308
    int j;
309
  };
310
 
311
#ifdef __GXX_EXPERIMENTAL_CXX0X__
312
  struct LType // literal type
313
  {
314
    int _M_i;
315
 
316
    constexpr LType(int __i) : _M_i(__i) { }
317
  };
318
 
319
  struct LTypeDerived : public LType
320
  {
321
    constexpr LTypeDerived(int __i) : LType(__i) { }
322
  };
323
 
324
  struct NLType // not literal type
325
  {
326
    int _M_i;
327
 
328
    NLType() : _M_i(0) { }
329
 
330
    constexpr NLType(int __i) : _M_i(__i) { }
331
 
332
    NLType(const NLType& __other) : _M_i(__other._M_i) { }
333
 
334
    ~NLType() { _M_i = 0; }
335
  };
336
#endif
337
 
338
  int truncate_float(float x) { return (int)x; }
339
  long truncate_double(double x) { return (long)x; }
340
 
341
  struct do_truncate_float_t
342
  {
343
    do_truncate_float_t()
344
    {
345
      ++live_objects;
346
    }
347
 
348
    do_truncate_float_t(const do_truncate_float_t&)
349
    {
350
      ++live_objects;
351
    }
352
 
353
    ~do_truncate_float_t()
354
    {
355
      --live_objects;
356
    }
357
 
358
    int operator()(float x) { return (int)x; }
359
 
360
    static int live_objects;
361
  };
362
 
363
  int do_truncate_float_t::live_objects = 0;
364
 
365
  struct do_truncate_double_t
366
  {
367
    do_truncate_double_t()
368
    {
369
     ++live_objects;
370
    }
371
 
372
    do_truncate_double_t(const do_truncate_double_t&)
373
    {
374
      ++live_objects;
375
    }
376
 
377
    ~do_truncate_double_t()
378
    {
379
      --live_objects;
380
    }
381
 
382
    long operator()(double x) { return (long)x; }
383
 
384
    static int live_objects;
385
  };
386
 
387
  int do_truncate_double_t::live_objects = 0;
388
 
389
  struct X
390
  {
391
    int bar;
392
 
393
    int foo()                   { return 1; }
394
    int foo_c() const           { return 2; }
395
    int foo_v()  volatile       { return 3; }
396
    int foo_cv() const volatile { return 4; }
397
  };
398
 
399
  // For use in 8_c_compatibility.
400
  template<typename R, typename T>
401
    typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value,
402
                                    bool>::__type
403
    check_ret_type(T)
404
    { return true; }
405
 
406
#ifdef __GXX_EXPERIMENTAL_CXX0X__
407
  namespace construct_destruct
408
  {
409
    struct Empty {};
410
 
411
    struct B { int i; B(){} };
412
    struct D : B {};
413
 
414
    enum E { ee1 };
415
    enum E2 { ee2 };
416
    enum class SE { e1 };
417
    enum class SE2 { e2 };
418
 
419
    enum OpE : int;
420
    enum class OpSE : bool;
421
 
422
    union U { int i; Empty b; };
423
 
424
    struct Abstract
425
    {
426
      virtual ~Abstract() = 0;
427
    };
428
 
429
    struct AbstractDelDtor
430
    {
431
      ~AbstractDelDtor() = delete;
432
      virtual void foo() = 0;
433
    };
434
 
435
    struct Ukn;
436
 
437
    template<class To>
438
      struct ImplicitTo
439
      {
440
        operator To();
441
      };
442
 
443
    template<class To>
444
      struct DelImplicitTo
445
      {
446
        operator To() = delete;
447
      };
448
 
449
    template<class To>
450
      struct ExplicitTo
451
      {
452
        explicit operator To();
453
      };
454
 
455
    struct Ellipsis
456
    {
457
      Ellipsis(...){}
458
    };
459
 
460
    struct DelEllipsis
461
    {
462
      DelEllipsis(...) = delete;
463
    };
464
 
465
    struct Any
466
    {
467
      template<class T>
468
      Any(T&&){}
469
    };
470
 
471
    struct nAny
472
    {
473
      template<class... T>
474
      nAny(T&&...){}
475
    };
476
 
477
    struct DelnAny
478
    {
479
      template<class... T>
480
        DelnAny(T&&...) = delete;
481
    };
482
 
483
    template<class... Args>
484
      struct FromArgs
485
      {
486
        FromArgs(Args...);
487
      };
488
 
489
    struct DelDef
490
    {
491
      DelDef() = delete;
492
    };
493
 
494
    struct DelCopy
495
    {
496
      DelCopy(const DelCopy&) = delete;
497
    };
498
 
499
    struct DelDtor
500
    {
501
      DelDtor() = default;
502
      DelDtor(const DelDtor&) = default;
503
      DelDtor(DelDtor&&) = default;
504
      DelDtor(int);
505
      DelDtor(int, B, U);
506
      ~DelDtor() = delete;
507
    };
508
 
509
    struct Nontrivial
510
    {
511
      Nontrivial();
512
      Nontrivial(const Nontrivial&);
513
      Nontrivial& operator=(const Nontrivial&);
514
      ~Nontrivial();
515
    };
516
 
517
    union NontrivialUnion
518
    {
519
      int i;
520
      Nontrivial n;
521
    };
522
 
523
    struct UnusualCopy
524
    {
525
      UnusualCopy(UnusualCopy&);
526
    };
527
  }
528
 
529
  namespace assign
530
  {
531
    struct Empty {};
532
 
533
    struct B { int i; B(){} };
534
    struct D : B {};
535
 
536
    enum E { ee1 };
537
    enum E2 { ee2 };
538
    enum class SE { e1 };
539
    enum class SE2 { e2 };
540
 
541
    enum OpE : int;
542
    enum class OpSE : bool;
543
 
544
    union U { int i; Empty b; };
545
 
546
    union UAssignAll
547
    {
548
      bool b;
549
      char c;
550
      template<class T>
551
      void operator=(T&&);
552
    };
553
 
554
    union UDelAssignAll
555
    {
556
      bool b;
557
      char c;
558
      template<class T>
559
      void operator=(T&&) = delete;
560
    };
561
 
562
    struct Abstract
563
    {
564
      virtual ~Abstract() = 0;
565
    };
566
 
567
    struct AbstractDelDtor
568
    {
569
      ~AbstractDelDtor() = delete;
570
      virtual void foo() = 0;
571
    };
572
 
573
    struct Ukn;
574
 
575
    template<class To>
576
      struct ImplicitTo
577
      {
578
        operator To();
579
      };
580
 
581
    template<class To>
582
      struct ExplicitTo
583
      {
584
        explicit operator To();
585
      };
586
 
587
    template<class To>
588
      struct DelImplicitTo
589
      {
590
        operator To() = delete;
591
      };
592
 
593
    template<class To>
594
      struct DelExplicitTo
595
      {
596
        explicit operator To() = delete;
597
      };
598
 
599
    struct Ellipsis
600
    {
601
      Ellipsis(...){}
602
    };
603
 
604
    struct DelEllipsis
605
    {
606
      DelEllipsis(...) = delete;
607
    };
608
 
609
    struct Any
610
    {
611
      template<class T>
612
        Any(T&&){}
613
    };
614
 
615
    struct nAny
616
    {
617
      template<class... T>
618
        nAny(T&&...){}
619
    };
620
 
621
    struct DelnAny
622
    {
623
      template<class... T>
624
        DelnAny(T&&...) = delete;
625
    };
626
 
627
    template<class... Args>
628
      struct FromArgs
629
      {
630
        FromArgs(Args...);
631
      };
632
 
633
    template<class... Args>
634
      struct DelFromArgs
635
      {
636
        DelFromArgs(Args...) = delete;
637
      };
638
 
639
    struct DelDef
640
    {
641
      DelDef() = delete;
642
    };
643
 
644
    struct DelCopy
645
    {
646
      DelCopy(const DelCopy&) = delete;
647
    };
648
 
649
    struct DelDtor
650
    {
651
      DelDtor() = default;
652
      DelDtor(const DelDtor&) = default;
653
      DelDtor(DelDtor&&) = default;
654
      DelDtor(int);
655
      DelDtor(int, B, U);
656
      ~DelDtor() = delete;
657
    };
658
 
659
    struct Nontrivial
660
    {
661
      Nontrivial();
662
      Nontrivial(const Nontrivial&);
663
      Nontrivial& operator=(const Nontrivial&);
664
      ~Nontrivial();
665
    };
666
 
667
    union NontrivialUnion
668
    {
669
      int i;
670
      Nontrivial n;
671
    };
672
 
673
    struct UnusualCopy
674
    {
675
      UnusualCopy(UnusualCopy&);
676
    };
677
 
678
    struct AnyAssign
679
    {
680
      template<class T>
681
        void operator=(T&&);
682
    };
683
 
684
    struct DelAnyAssign
685
    {
686
      template<class T>
687
        void operator=(T&&) = delete;
688
    };
689
 
690
    struct DelCopyAssign
691
    {
692
      DelCopyAssign& operator=(const DelCopyAssign&) = delete;
693
      DelCopyAssign& operator=(DelCopyAssign&&) = default;
694
    };
695
 
696
    struct MO
697
    {
698
      MO(MO&&) = default;
699
      MO& operator=(MO&&) = default;
700
    };
701
  }
702
 
703
  struct CopyConsOnlyType
704
  {
705
    CopyConsOnlyType(int) { }
706
    CopyConsOnlyType(CopyConsOnlyType&&) = delete;
707
    CopyConsOnlyType(const CopyConsOnlyType&) = default;
708
    CopyConsOnlyType& operator=(const CopyConsOnlyType&) = delete;
709
    CopyConsOnlyType& operator=(CopyConsOnlyType&&) = delete;
710
  };
711
 
712
  struct MoveConsOnlyType
713
  {
714
    MoveConsOnlyType(int) { }
715
    MoveConsOnlyType(const MoveConsOnlyType&) = delete;
716
    MoveConsOnlyType(MoveConsOnlyType&&) = default;
717
    MoveConsOnlyType& operator=(const MoveConsOnlyType&) = delete;
718
    MoveConsOnlyType& operator=(MoveConsOnlyType&&) = delete;
719
  };
720
#endif
721
 
722
} // namespace __gnu_test
723
 
724
#endif // _GLIBCXX_TESTSUITE_TR1_H

powered by: WebSVN 2.1.0

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