@@ -32,11 +32,12 @@ public: auto set_num(cpp2::in<cpp2::i32> _value) & -> void;
3232public: auto set_num (auto && ..._args) & -> void;
3333private: auto _destroy () & -> void;
3434public: ~name_or_number () noexcept ;
35+ public: explicit name_or_number ();
36+ public: name_or_number(name_or_number const & that);
3537
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& ;
4041
4142#line 5 "pure2-union.cpp2"
4243};
@@ -59,10 +60,12 @@ public: auto set_other(cpp2::in<T> _value) & -> void;
5960public: auto set_other (auto && ..._args) & -> void;
6061private: auto _destroy () & -> void;
6162public: ~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& ;
6268
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 ;
6669#line 17 "pure2-union.cpp2"
6770};
6871
@@ -98,6 +101,41 @@ auto name_or_number::_destroy() & -> void{
98101 }
99102
100103 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+ }
101139#line 12 "pure2-union.cpp2"
102140 template <typename T> [[nodiscard]] auto name_or_other<T>::to_string() const & -> std::string{
103141 if (is_name ()) { return name (); }
@@ -128,7 +166,42 @@ template <typename T> auto name_or_other<T>::_destroy() & -> void{
128166 }
129167
130168 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+ }
131188
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+ }
132205#line 19 "pure2-union.cpp2"
133206auto print_name (cpp2::in<name_or_number> non) -> void{
134207 if (CPP2_UFCS_0 (is_name, non)) {
0 commit comments