remove some usage of expr_list from read_rtx
[official-gcc.git] / libstdc++-v3 / testsuite / util / testsuite_tr1.h
blobda4002fc9e876633b10136292a965319b65b988f
1 // -*- C++ -*-
2 // Testing utilities for the tr1 testsuite.
3 //
4 // Copyright (C) 2004-2015 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.
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.
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/>.
22 #ifndef _GLIBCXX_TESTSUITE_TR1_H
23 #define _GLIBCXX_TESTSUITE_TR1_H
25 #include <ext/type_traits.h>
27 namespace __gnu_test
29 // For tr1/type_traits.
30 template<template<typename> class Category, typename Type>
31 #if __cplusplus >= 201103L
32 constexpr
33 #endif
34 bool
35 test_category(bool value)
37 return (Category<Type>::value == value
38 && Category<const Type>::value == value
39 && Category<volatile Type>::value == value
40 && Category<const volatile Type>::value == value
41 && Category<Type>::type::value == value
42 && Category<const Type>::type::value == value
43 && Category<volatile Type>::type::value == value
44 && Category<const volatile Type>::type::value == value);
47 template<template<typename> class Property, typename Type>
48 #if __cplusplus >= 201103L
49 constexpr
50 #endif
51 bool
52 test_property(typename Property<Type>::value_type value)
54 return (Property<Type>::value == value
55 && Property<Type>::type::value == value);
58 // For testing tr1/type_traits/extent, which has a second template
59 // parameter.
60 template<template<typename, unsigned> class Property,
61 typename Type, unsigned Uint>
62 #if __cplusplus >= 201103L
63 constexpr
64 #endif
65 bool
66 test_property(typename Property<Type, Uint>::value_type value)
68 return (Property<Type, Uint>::value == value
69 && Property<Type, Uint>::type::value == value);
72 #if __cplusplus >= 201103L
73 template<template<typename...> class Property,
74 typename Type1, typename... Types>
75 constexpr bool
76 test_property(typename Property<Type1, Types...>::value_type value)
78 return (Property<Type1, Types...>::value == value
79 && Property<Type1, Types...>::type::value == value);
81 #endif
83 template<template<typename, typename> class Relationship,
84 typename Type1, typename Type2>
85 #if __cplusplus >= 201103L
86 constexpr
87 #endif
88 bool
89 test_relationship(bool value)
91 return (Relationship<Type1, Type2>::value == value
92 && Relationship<Type1, Type2>::type::value == value);
95 // Test types.
96 class ClassType { };
97 typedef const ClassType cClassType;
98 typedef volatile ClassType vClassType;
99 typedef const volatile ClassType cvClassType;
101 class DerivedType : public ClassType { };
103 #if __cplusplus >= 201103L
104 class FinalType final : public DerivedType { };
105 #endif
107 enum EnumType { e0 };
109 struct ConvType
110 { operator int() const; };
112 class AbstractClass
114 virtual void rotate(int) = 0;
117 class PolymorphicClass
119 virtual void rotate(int);
122 class DerivedPolymorphic : public PolymorphicClass { };
124 class VirtualDestructorClass
126 virtual ~VirtualDestructorClass();
129 union UnionType { };
131 class IncompleteClass;
133 struct ExplicitClass
135 ExplicitClass(double&);
136 explicit ExplicitClass(int&);
137 ExplicitClass(double&, int&, double&);
140 struct NothrowExplicitClass
142 NothrowExplicitClass(double&) throw();
143 explicit NothrowExplicitClass(int&) throw();
144 NothrowExplicitClass(double&, int&, double&) throw();
147 struct ThrowExplicitClass
149 ThrowExplicitClass(double&) throw(int);
150 explicit ThrowExplicitClass(int&) throw(int);
151 ThrowExplicitClass(double&, int&, double&) throw(int);
154 struct ThrowDefaultClass
156 ThrowDefaultClass() throw(int);
159 struct ThrowCopyConsClass
161 ThrowCopyConsClass(const ThrowCopyConsClass&) throw(int);
164 #if __cplusplus >= 201103L
165 struct ThrowMoveConsClass
167 ThrowMoveConsClass(ThrowMoveConsClass&&) throw(int);
170 struct NoexceptExplicitClass
172 NoexceptExplicitClass(double&) noexcept(true);
173 explicit NoexceptExplicitClass(int&) noexcept(true);
174 NoexceptExplicitClass(double&, int&, double&) noexcept(true);
177 struct ExceptExplicitClass
179 ExceptExplicitClass(double&) noexcept(false);
180 explicit ExceptExplicitClass(int&) noexcept(false);
181 ExceptExplicitClass(double&, int&, double&) noexcept(false);
184 struct NoexceptDefaultClass
186 NoexceptDefaultClass() noexcept(true);
189 struct ExceptDefaultClass
191 ExceptDefaultClass() noexcept(false);
194 struct NoexceptCopyConsClass
196 NoexceptCopyConsClass(const NoexceptCopyConsClass&) noexcept(true);
199 struct ExceptCopyConsClass
201 ExceptCopyConsClass(const ExceptCopyConsClass&) noexcept(false);
204 struct NoexceptMoveConsClass
206 NoexceptMoveConsClass(NoexceptMoveConsClass&&) noexcept(true);
207 NoexceptMoveConsClass& operator=(NoexceptMoveConsClass&&) = default;
210 struct ExceptMoveConsClass
212 ExceptMoveConsClass(ExceptMoveConsClass&&) noexcept(false);
215 struct NoexceptCopyAssignClass
217 NoexceptCopyAssignClass&
218 operator=(const NoexceptCopyAssignClass&) noexcept(true);
221 struct ExceptCopyAssignClass
223 ExceptCopyAssignClass&
224 operator=(const ExceptCopyAssignClass&) noexcept(false);
227 struct NoexceptMoveAssignClass
229 NoexceptMoveAssignClass(NoexceptMoveAssignClass&&) = default;
230 NoexceptMoveAssignClass&
231 operator=(NoexceptMoveAssignClass&&) noexcept(true);
234 struct ExceptMoveAssignClass
236 ExceptMoveAssignClass&
237 operator=(ExceptMoveAssignClass&&) noexcept(false);
240 struct DeletedCopyAssignClass
242 DeletedCopyAssignClass&
243 operator=(const DeletedCopyAssignClass&) = delete;
246 struct DeletedMoveAssignClass
248 DeletedMoveAssignClass&
249 operator=(DeletedMoveAssignClass&&) = delete;
252 struct NoexceptMoveConsNoexceptMoveAssignClass
254 NoexceptMoveConsNoexceptMoveAssignClass
255 (NoexceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
257 NoexceptMoveConsNoexceptMoveAssignClass&
258 operator=(NoexceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
261 struct ExceptMoveConsNoexceptMoveAssignClass
263 ExceptMoveConsNoexceptMoveAssignClass
264 (ExceptMoveConsNoexceptMoveAssignClass&&) noexcept(false);
266 ExceptMoveConsNoexceptMoveAssignClass&
267 operator=(ExceptMoveConsNoexceptMoveAssignClass&&) noexcept(true);
270 struct NoexceptMoveConsExceptMoveAssignClass
272 NoexceptMoveConsExceptMoveAssignClass
273 (NoexceptMoveConsExceptMoveAssignClass&&) noexcept(true);
275 NoexceptMoveConsExceptMoveAssignClass&
276 operator=(NoexceptMoveConsExceptMoveAssignClass&&) noexcept(false);
279 struct ExceptMoveConsExceptMoveAssignClass
281 ExceptMoveConsExceptMoveAssignClass
282 (ExceptMoveConsExceptMoveAssignClass&&) noexcept(false);
284 ExceptMoveConsExceptMoveAssignClass&
285 operator=(ExceptMoveConsExceptMoveAssignClass&&) noexcept(false);
287 #endif
289 struct NType // neither trivial nor standard-layout
291 int i;
292 int j;
293 virtual ~NType();
296 struct TType // trivial but not standard-layout
298 int i;
299 private:
300 int j;
303 struct SLType // standard-layout but not trivial
305 int i;
306 int j;
307 ~SLType();
310 struct PODType // both trivial and standard-layout
312 int i;
313 int j;
316 #if __cplusplus >= 201103L
317 struct LType // literal type
319 int _M_i;
321 constexpr LType(int __i) : _M_i(__i) { }
324 struct LTypeDerived : public LType
326 constexpr LTypeDerived(int __i) : LType(__i) { }
329 struct NLType // not literal type
331 int _M_i;
333 NLType() : _M_i(0) { }
335 constexpr NLType(int __i) : _M_i(__i) { }
337 NLType(const NLType& __other) : _M_i(__other._M_i) { }
339 ~NLType() { _M_i = 0; }
341 #endif
343 int truncate_float(float x) { return (int)x; }
344 long truncate_double(double x) { return (long)x; }
346 struct do_truncate_float_t
348 do_truncate_float_t()
350 ++live_objects;
353 do_truncate_float_t(const do_truncate_float_t&)
355 ++live_objects;
358 ~do_truncate_float_t()
360 --live_objects;
363 int operator()(float x) { return (int)x; }
365 static int live_objects;
368 int do_truncate_float_t::live_objects = 0;
370 struct do_truncate_double_t
372 do_truncate_double_t()
374 ++live_objects;
377 do_truncate_double_t(const do_truncate_double_t&)
379 ++live_objects;
382 ~do_truncate_double_t()
384 --live_objects;
387 long operator()(double x) { return (long)x; }
389 static int live_objects;
392 int do_truncate_double_t::live_objects = 0;
394 struct X
396 int bar;
398 int foo() { return 1; }
399 int foo_c() const { return 2; }
400 int foo_v() volatile { return 3; }
401 int foo_cv() const volatile { return 4; }
404 // For use in 8_c_compatibility.
405 template<typename R, typename T>
406 typename __gnu_cxx::__enable_if<std::__are_same<R, T>::__value,
407 bool>::__type
408 check_ret_type(T)
409 { return true; }
411 #if __cplusplus >= 201103L
412 namespace construct
414 struct Empty {};
416 struct B { int i; B(){} };
417 struct D : B {};
419 enum E { ee1 };
420 enum E2 { ee2 };
421 enum class SE { e1 };
422 enum class SE2 { e2 };
424 enum OpE : int;
425 enum class OpSE : bool;
427 union U { int i; Empty b; };
429 struct Abstract
431 virtual ~Abstract() = 0;
434 struct AbstractDelDtor
436 ~AbstractDelDtor() = delete;
437 virtual void foo() = 0;
440 struct Ukn;
442 template<class To>
443 struct ImplicitTo
445 operator To();
448 template<class To>
449 struct DelImplicitTo
451 operator To() = delete;
454 template<class To>
455 struct ExplicitTo
457 explicit operator To();
460 struct Ellipsis
462 Ellipsis(...){}
465 struct DelEllipsis
467 DelEllipsis(...) = delete;
470 struct Any
472 template<class T>
473 Any(T&&){}
476 struct nAny
478 template<class... T>
479 nAny(T&&...){}
482 struct DelnAny
484 template<class... T>
485 DelnAny(T&&...) = delete;
488 template<class... Args>
489 struct FromArgs
491 FromArgs(Args...);
494 struct DelDef
496 DelDef() = delete;
499 struct DelCopy
501 DelCopy(const DelCopy&) = delete;
504 struct DelDtor
506 DelDtor() = default;
507 DelDtor(const DelDtor&) = default;
508 DelDtor(DelDtor&&) = default;
509 DelDtor(int);
510 DelDtor(int, B, U);
511 ~DelDtor() = delete;
514 struct Nontrivial
516 Nontrivial();
517 Nontrivial(const Nontrivial&);
518 Nontrivial& operator=(const Nontrivial&);
519 ~Nontrivial();
522 union NontrivialUnion
524 int i;
525 Nontrivial n;
528 struct UnusualCopy
530 UnusualCopy(UnusualCopy&);
534 namespace destruct
536 struct E
539 struct NTD1
541 ~NTD1() = default;
544 struct NTD2
546 ~NTD2();
549 struct NTD3
551 ~NTD3() throw();
554 struct TD1
556 ~TD1() noexcept(false);
559 struct TD2
561 ~TD2() throw(int);
564 struct Aggr
566 int i;
567 bool b;
568 E e;
571 struct Aggr2
573 int i;
574 bool b;
575 TD1 r;
578 struct Del
580 ~Del() = delete;
583 struct Del2
585 ~Del2() noexcept = delete;
588 struct Del3
590 ~Del3() noexcept(false) = delete;
593 struct Der : Aggr
596 struct Der2 : Aggr2
599 union U1
601 int i;
602 double d;
603 void* p;
604 TD1* pt;
607 union Ut
609 int i;
610 double d;
611 void* p;
612 TD1 pt;
615 enum class En { a, b, c, d };
616 enum En2 { En2a, En2b, En2c, En2d };
618 enum OpE : int;
619 enum class OpSE : bool;
621 struct Abstract1
623 virtual ~Abstract1() = 0;
626 struct AbstractDelDtor
628 ~AbstractDelDtor() = delete;
629 virtual void foo() = 0;
632 struct Abstract2
634 virtual ~Abstract2() noexcept(false) = 0;
637 struct Abstract3
639 ~Abstract3() noexcept(false);
640 virtual void foo() noexcept = 0;
643 struct Nontrivial
645 Nontrivial();
646 Nontrivial(const Nontrivial&);
647 Nontrivial& operator=(const Nontrivial&);
648 ~Nontrivial();
651 union NontrivialUnion
653 int i;
654 Nontrivial n;
657 struct UnusualCopy
659 UnusualCopy(UnusualCopy&);
662 struct Ellipsis
664 Ellipsis(...){}
667 struct DelEllipsis
669 DelEllipsis(...) = delete;
672 struct DelDef
674 DelDef() = delete;
677 struct DelCopy
679 DelCopy(const DelCopy&) = delete;
683 namespace assign
685 struct Empty {};
687 struct B { int i; B(){} };
688 struct D : B {};
690 enum E { ee1 };
691 enum E2 { ee2 };
692 enum class SE { e1 };
693 enum class SE2 { e2 };
695 enum OpE : int;
696 enum class OpSE : bool;
698 union U { int i; Empty b; };
700 union UAssignAll
702 bool b;
703 char c;
704 template<class T>
705 void operator=(T&&);
708 union UDelAssignAll
710 bool b;
711 char c;
712 template<class T>
713 void operator=(T&&) = delete;
716 struct Abstract
718 virtual ~Abstract() = 0;
721 struct AbstractDelDtor
723 ~AbstractDelDtor() = delete;
724 virtual void foo() = 0;
727 struct Ukn;
729 template<class To>
730 struct ImplicitTo
732 operator To();
735 template<class To>
736 struct ExplicitTo
738 explicit operator To();
741 template<class To>
742 struct DelImplicitTo
744 operator To() = delete;
747 template<class To>
748 struct DelExplicitTo
750 explicit operator To() = delete;
753 struct Ellipsis
755 Ellipsis(...){}
758 struct DelEllipsis
760 DelEllipsis(...) = delete;
763 struct Any
765 template<class T>
766 Any(T&&){}
769 struct nAny
771 template<class... T>
772 nAny(T&&...){}
775 struct DelnAny
777 template<class... T>
778 DelnAny(T&&...) = delete;
781 template<class... Args>
782 struct FromArgs
784 FromArgs(Args...);
787 template<class... Args>
788 struct DelFromArgs
790 DelFromArgs(Args...) = delete;
793 struct DelDef
795 DelDef() = delete;
798 struct DelCopy
800 DelCopy(const DelCopy&) = delete;
803 struct DelDtor
805 DelDtor() = default;
806 DelDtor(const DelDtor&) = default;
807 DelDtor(DelDtor&&) = default;
808 DelDtor(int);
809 DelDtor(int, B, U);
810 ~DelDtor() = delete;
813 struct Nontrivial
815 Nontrivial();
816 Nontrivial(const Nontrivial&);
817 Nontrivial& operator=(const Nontrivial&);
818 ~Nontrivial();
821 union NontrivialUnion
823 int i;
824 Nontrivial n;
827 struct UnusualCopy
829 UnusualCopy(UnusualCopy&);
832 struct AnyAssign
834 template<class T>
835 void operator=(T&&);
838 struct DelAnyAssign
840 template<class T>
841 void operator=(T&&) = delete;
844 struct DelCopyAssign
846 DelCopyAssign& operator=(const DelCopyAssign&) = delete;
847 DelCopyAssign& operator=(DelCopyAssign&&) = default;
850 struct MO
852 MO(MO&&) = default;
853 MO& operator=(MO&&) = default;
857 struct CopyConsOnlyType
859 CopyConsOnlyType(int) { }
860 CopyConsOnlyType(CopyConsOnlyType&&) = delete;
861 CopyConsOnlyType(const CopyConsOnlyType&) = default;
862 CopyConsOnlyType& operator=(const CopyConsOnlyType&) = delete;
863 CopyConsOnlyType& operator=(CopyConsOnlyType&&) = delete;
866 struct MoveConsOnlyType
868 MoveConsOnlyType(int) { }
869 MoveConsOnlyType(const MoveConsOnlyType&) = delete;
870 MoveConsOnlyType(MoveConsOnlyType&&) = default;
871 MoveConsOnlyType& operator=(const MoveConsOnlyType&) = delete;
872 MoveConsOnlyType& operator=(MoveConsOnlyType&&) = delete;
874 #endif
876 } // namespace __gnu_test
878 #endif // _GLIBCXX_TESTSUITE_TR1_H