@@ -32,11 +32,12 @@ public: auto set_num(cpp2::in<cpp2::i32> _value) & -> void;
32
32
public: auto set_num (auto && ..._args) & -> void;
33
33
private: auto _destroy () & -> void;
34
34
public: ~name_or_number () noexcept ;
35
+ public: explicit name_or_number ();
36
+ public: name_or_number(name_or_number const & that);
35
37
36
- public: name_or_number() = default ;
37
- public: name_or_number(name_or_number const &) = delete ; /* No 'that' constructor, suppress copy */
38
- public: auto operator =(name_or_number const &) -> void = delete ;
39
-
38
+ public: auto operator =(name_or_number const & that) -> name_or_number& ;
39
+ public: name_or_number(name_or_number&& that) noexcept ;
40
+ public: auto operator =(name_or_number&& that) noexcept -> name_or_number& ;
40
41
41
42
#line 5 "pure2-union.cpp2"
42
43
};
@@ -59,10 +60,12 @@ public: auto set_other(cpp2::in<T> _value) & -> void;
59
60
public: auto set_other (auto && ..._args) & -> void;
60
61
private: auto _destroy () & -> void;
61
62
public: ~name_or_other () noexcept ;
63
+ public: explicit name_or_other ();
64
+ public: name_or_other(name_or_other const & that);
65
+ public: auto operator =(name_or_other const & that) -> name_or_other& ;
66
+ public: name_or_other(name_or_other&& that) noexcept ;
67
+ public: auto operator =(name_or_other&& that) noexcept -> name_or_other& ;
62
68
63
- public: name_or_other() = default ;
64
- public: name_or_other(name_or_other const &) = delete ; /* No 'that' constructor, suppress copy */
65
- public: auto operator =(name_or_other const &) -> void = delete ;
66
69
#line 17 "pure2-union.cpp2"
67
70
};
68
71
@@ -98,6 +101,41 @@ auto name_or_number::_destroy() & -> void{
98
101
}
99
102
100
103
name_or_number::~name_or_number () noexcept {_destroy ();}
104
+ name_or_number::name_or_number ()
105
+ : _discriminator{ -1 }{}
106
+ name_or_number::name_or_number (name_or_number const & that)
107
+ : _storage{ that._storage }
108
+ , _discriminator{ that._discriminator }{
109
+ if (CPP2_UFCS_0 (is_name, that)) {set_name (CPP2_UFCS_0 (name, that));}
110
+ if (CPP2_UFCS_0 (is_num, that)) {set_num (CPP2_UFCS_0 (num, that));}
111
+ _discriminator = that._discriminator ;
112
+ }
113
+
114
+ auto name_or_number::operator =(name_or_number const & that) -> name_or_number& {
115
+ _storage = that._storage ;
116
+ _discriminator = that._discriminator ;
117
+ if (CPP2_UFCS_0 (is_name, that)) {set_name (CPP2_UFCS_0 (name, that));}
118
+ if (CPP2_UFCS_0 (is_num, that)) {set_num (CPP2_UFCS_0 (num, that));}
119
+ _discriminator = that._discriminator ;
120
+ return *this ;
121
+ }
122
+
123
+ name_or_number::name_or_number (name_or_number&& that) noexcept
124
+ : _storage{ std::move (that)._storage }
125
+ , _discriminator{ std::move (that)._discriminator }{
126
+ if (CPP2_UFCS_0 (is_name, std::move (that))) {set_name (CPP2_UFCS_0 (name, std::move (that)));}
127
+ if (CPP2_UFCS_0 (is_num, std::move (that))) {set_num (CPP2_UFCS_0 (num, std::move (that)));}
128
+ _discriminator = std::move (that)._discriminator ;
129
+ }
130
+
131
+ auto name_or_number::operator =(name_or_number&& that) noexcept -> name_or_number& {
132
+ _storage = std::move (that)._storage ;
133
+ _discriminator = std::move (that)._discriminator ;
134
+ if (CPP2_UFCS_0 (is_name, std::move (that))) {set_name (CPP2_UFCS_0 (name, std::move (that)));}
135
+ if (CPP2_UFCS_0 (is_num, std::move (that))) {set_num (CPP2_UFCS_0 (num, std::move (that)));}
136
+ _discriminator = std::move (that)._discriminator ;
137
+ return *this ;
138
+ }
101
139
#line 12 "pure2-union.cpp2"
102
140
template <typename T> [[nodiscard]] auto name_or_other<T>::to_string() const & -> std::string{
103
141
if (is_name ()) { return name (); }
@@ -128,7 +166,42 @@ template <typename T> auto name_or_other<T>::_destroy() & -> void{
128
166
}
129
167
130
168
template <typename T> name_or_other<T>::~name_or_other () noexcept {_destroy ();}
169
+ template <typename T> name_or_other<T>::name_or_other()
170
+ : _discriminator{ -1 }{}
171
+ template <typename T> name_or_other<T>::name_or_other(name_or_other const & that)
172
+ : _storage{ that._storage }
173
+ , _discriminator{ that._discriminator }{
174
+ if (CPP2_UFCS_0 (is_name, that)) {set_name (CPP2_UFCS_0 (name, that));}
175
+ if (CPP2_UFCS_0 (is_other, that)) {set_other (CPP2_UFCS_0 (other, that));}
176
+ _discriminator = that._discriminator ;
177
+ }
178
+
179
+
180
+ template <typename T> auto name_or_other<T>::operator =(name_or_other const & that) -> name_or_other& {
181
+ _storage = that._storage ;
182
+ _discriminator = that._discriminator ;
183
+ if (CPP2_UFCS_0 (is_name, that)) {set_name (CPP2_UFCS_0 (name, that));}
184
+ if (CPP2_UFCS_0 (is_other, that)) {set_other (CPP2_UFCS_0 (other, that));}
185
+ _discriminator = that._discriminator ;
186
+ return *this ;
187
+ }
131
188
189
+ template <typename T> name_or_other<T>::name_or_other(name_or_other&& that) noexcept
190
+ : _storage{ std::move (that)._storage }
191
+ , _discriminator{ std::move (that)._discriminator }{
192
+ if (CPP2_UFCS_0 (is_name, std::move (that))) {set_name (CPP2_UFCS_0 (name, std::move (that)));}
193
+ if (CPP2_UFCS_0 (is_other, std::move (that))) {set_other (CPP2_UFCS_0 (other, std::move (that)));}
194
+ _discriminator = std::move (that)._discriminator ;
195
+ }
196
+
197
+ template <typename T> auto name_or_other<T>::operator =(name_or_other&& that) noexcept -> name_or_other& {
198
+ _storage = std::move (that)._storage ;
199
+ _discriminator = std::move (that)._discriminator ;
200
+ if (CPP2_UFCS_0 (is_name, std::move (that))) {set_name (CPP2_UFCS_0 (name, std::move (that)));}
201
+ if (CPP2_UFCS_0 (is_other, std::move (that))) {set_other (CPP2_UFCS_0 (other, std::move (that)));}
202
+ _discriminator = std::move (that)._discriminator ;
203
+ return *this ;
204
+ }
132
205
#line 19 "pure2-union.cpp2"
133
206
auto print_name (cpp2::in<name_or_number> non) -> void{
134
207
if (CPP2_UFCS_0 (is_name, non)) {
0 commit comments