1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 #define DEFINE_BASE(Name) ::ArchetypeBases::NullBase
12 #ifndef DEFINE_EXPLICIT
13 #define DEFINE_EXPLICIT
15 #ifndef DEFINE_NOEXCEPT
16 #define DEFINE_NOEXCEPT
18 #ifndef DEFINE_CONSTEXPR
19 #ifdef TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
20 #define DEFINE_CONSTEXPR
21 #else // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
22 #define DEFINE_CONSTEXPR constexpr
23 #endif // TEST_WORKAROUND_EDG_EXPLICIT_CONSTEXPR
25 #ifndef DEFINE_ASSIGN_CONSTEXPR
26 #if TEST_STD_VER >= 14
27 #define DEFINE_ASSIGN_CONSTEXPR DEFINE_CONSTEXPR
29 #define DEFINE_ASSIGN_CONSTEXPR
33 #define DEFINE_CTOR = default
35 #ifndef DEFINE_DEFAULT_CTOR
36 #define DEFINE_DEFAULT_CTOR DEFINE_CTOR
39 #define DEFINE_ASSIGN = default
42 #define DEFINE_DTOR(Name)
45 struct AllCtors : DEFINE_BASE(AllCtors) {
46 using Base = DEFINE_BASE(AllCtors);
48 using Base::operator=;
49 DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
50 DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors const&) DEFINE_NOEXCEPT DEFINE_CTOR;
51 DEFINE_EXPLICIT DEFINE_CONSTEXPR AllCtors(AllCtors &&) DEFINE_NOEXCEPT DEFINE_CTOR;
52 DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
53 DEFINE_ASSIGN_CONSTEXPR AllCtors& operator=(AllCtors &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
57 struct NoCtors : DEFINE_BASE(NoCtors) {
58 using Base = DEFINE_BASE(NoCtors);
59 DEFINE_EXPLICIT NoCtors() DEFINE_NOEXCEPT = delete;
60 DEFINE_EXPLICIT NoCtors(NoCtors const&) DEFINE_NOEXCEPT = delete;
61 NoCtors& operator=(NoCtors const&) DEFINE_NOEXCEPT = delete;
65 struct NoDefault : DEFINE_BASE(NoDefault) {
66 using Base = DEFINE_BASE(NoDefault);
68 DEFINE_EXPLICIT DEFINE_CONSTEXPR NoDefault() DEFINE_NOEXCEPT = delete;
69 DEFINE_DTOR(NoDefault)
72 struct DefaultOnly : DEFINE_BASE(DefaultOnly) {
73 using Base = DEFINE_BASE(DefaultOnly);
75 DEFINE_EXPLICIT DEFINE_CONSTEXPR DefaultOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
76 DefaultOnly(DefaultOnly const&) DEFINE_NOEXCEPT = delete;
77 DefaultOnly& operator=(DefaultOnly const&) DEFINE_NOEXCEPT = delete;
78 DEFINE_DTOR(DefaultOnly)
81 struct Copyable : DEFINE_BASE(Copyable) {
82 using Base = DEFINE_BASE(Copyable);
84 DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
85 DEFINE_EXPLICIT DEFINE_CONSTEXPR Copyable(Copyable const &) DEFINE_NOEXCEPT DEFINE_CTOR;
86 Copyable &operator=(Copyable const &) DEFINE_NOEXCEPT DEFINE_ASSIGN;
90 struct CopyOnly : DEFINE_BASE(CopyOnly) {
91 using Base = DEFINE_BASE(CopyOnly);
93 DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
94 DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly const &) DEFINE_NOEXCEPT DEFINE_CTOR;
95 DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyOnly(CopyOnly &&) DEFINE_NOEXCEPT = delete;
96 CopyOnly &operator=(CopyOnly const &) DEFINE_NOEXCEPT DEFINE_ASSIGN;
97 CopyOnly &operator=(CopyOnly &&) DEFINE_NOEXCEPT = delete;
101 struct NonCopyable : DEFINE_BASE(NonCopyable) {
102 using Base = DEFINE_BASE(NonCopyable);
104 DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
105 DEFINE_EXPLICIT DEFINE_CONSTEXPR NonCopyable(NonCopyable const &) DEFINE_NOEXCEPT = delete;
106 NonCopyable &operator=(NonCopyable const &) DEFINE_NOEXCEPT = delete;
107 DEFINE_DTOR(NonCopyable)
110 struct MoveOnly : DEFINE_BASE(MoveOnly) {
111 using Base = DEFINE_BASE(MoveOnly);
113 DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
114 DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveOnly(MoveOnly &&) DEFINE_NOEXCEPT DEFINE_CTOR;
115 MoveOnly &operator=(MoveOnly &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
116 DEFINE_DTOR(MoveOnly)
119 struct CopyAssignable : DEFINE_BASE(CopyAssignable) {
120 using Base = DEFINE_BASE(CopyAssignable);
122 DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignable() DEFINE_NOEXCEPT = delete;
123 CopyAssignable& operator=(CopyAssignable const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
124 DEFINE_DTOR(CopyAssignable)
127 struct CopyAssignOnly : DEFINE_BASE(CopyAssignOnly) {
128 using Base = DEFINE_BASE(CopyAssignOnly);
130 DEFINE_EXPLICIT DEFINE_CONSTEXPR CopyAssignOnly() DEFINE_NOEXCEPT = delete;
131 CopyAssignOnly& operator=(CopyAssignOnly const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
132 CopyAssignOnly& operator=(CopyAssignOnly &&) DEFINE_NOEXCEPT = delete;
133 DEFINE_DTOR(CopyAssignOnly)
136 struct MoveAssignOnly : DEFINE_BASE(MoveAssignOnly) {
137 using Base = DEFINE_BASE(MoveAssignOnly);
139 DEFINE_EXPLICIT DEFINE_CONSTEXPR MoveAssignOnly() DEFINE_NOEXCEPT = delete;
140 MoveAssignOnly& operator=(MoveAssignOnly const&) DEFINE_NOEXCEPT = delete;
141 MoveAssignOnly& operator=(MoveAssignOnly &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
142 DEFINE_DTOR(MoveAssignOnly)
145 struct ConvertingType : DEFINE_BASE(ConvertingType) {
146 using Base = DEFINE_BASE(ConvertingType);
148 DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType() DEFINE_NOEXCEPT DEFINE_DEFAULT_CTOR;
149 DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType const&) DEFINE_NOEXCEPT DEFINE_CTOR;
150 DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(ConvertingType &&) DEFINE_NOEXCEPT DEFINE_CTOR;
151 ConvertingType& operator=(ConvertingType const&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
152 ConvertingType& operator=(ConvertingType &&) DEFINE_NOEXCEPT DEFINE_ASSIGN;
153 template <class ...Args>
154 DEFINE_EXPLICIT DEFINE_CONSTEXPR ConvertingType(Args&&...) DEFINE_NOEXCEPT {}
156 ConvertingType& operator=(Arg&&) DEFINE_NOEXCEPT { return *this; }
157 DEFINE_DTOR(ConvertingType)
160 template <template <class...> class List>
161 using ApplyTypes = List<
177 #undef DEFINE_EXPLICIT
178 #undef DEFINE_NOEXCEPT
179 #undef DEFINE_CONSTEXPR
180 #undef DEFINE_ASSIGN_CONSTEXPR
182 #undef DEFINE_DEFAULT_CTOR