@@ -88,21 +88,21 @@ auto main() -> int;
88
88
[[nodiscard]] auto name_or_number::name () & -> std::string& {
89
89
cpp2::Default.expects (is_name (), " " );return *cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)); }
90
90
auto name_or_number::set_name (cpp2::in<std::string> _value) & -> void{if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), _value);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = _value;}_discriminator = 0 ;}
91
- auto name_or_number::set_name (auto && ..._args) & -> void{if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), _args...);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = std::string{_args...};}_discriminator = 0 ;}
91
+ auto name_or_number::set_name (auto && ..._args) & -> void{if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), CPP2_FORWARD ( _args) ...);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = std::string{CPP2_FORWARD ( _args) ...};}_discriminator = 0 ;}
92
92
[[nodiscard]] auto name_or_number::is_num () const & -> bool { return _discriminator == 1 ; }
93
93
[[nodiscard]] auto name_or_number::num () const & -> cpp2::i32 const & {
94
94
cpp2::Default.expects (is_num (), " " );return *cpp2::assert_not_null (reinterpret_cast <cpp2::i32 const *>(&_storage)); }
95
95
[[nodiscard]] auto name_or_number::num () & -> cpp2::i32& {
96
96
cpp2::Default.expects (is_num (), " " );return *cpp2::assert_not_null (reinterpret_cast <cpp2::i32 *>(&_storage)); }
97
97
auto name_or_number::set_num (cpp2::in<cpp2::i32 > _value) & -> void{if (!(is_num ())) {_destroy ();std::construct_at (reinterpret_cast <cpp2::i32 *>(&_storage), _value);}else {*cpp2::assert_not_null (reinterpret_cast <cpp2::i32 *>(&_storage)) = _value;}_discriminator = 1 ;}
98
- auto name_or_number::set_num (auto && ..._args) & -> void{if (!(is_num ())) {_destroy ();std::construct_at (reinterpret_cast <cpp2::i32 *>(&_storage), _args...);}else {*cpp2::assert_not_null (reinterpret_cast <cpp2::i32 *>(&_storage)) = cpp2::i32 {_args...};}_discriminator = 1 ;}
98
+ auto name_or_number::set_num (auto && ..._args) & -> void{if (!(is_num ())) {_destroy ();std::construct_at (reinterpret_cast <cpp2::i32 *>(&_storage), CPP2_FORWARD ( _args) ...);}else {*cpp2::assert_not_null (reinterpret_cast <cpp2::i32 *>(&_storage)) = cpp2::i32 {CPP2_FORWARD ( _args) ...};}_discriminator = 1 ;}
99
99
auto name_or_number::_destroy () & -> void{
100
100
if (_discriminator == 0 ) {std::destroy_at (reinterpret_cast <std::string*>(&_storage));}
101
101
if (_discriminator == 1 ) {std::destroy_at (reinterpret_cast <cpp2::i32 *>(&_storage));}
102
102
_discriminator = -1 ;
103
103
}
104
104
105
- name_or_number::~name_or_number () noexcept {_destroy ( );}
105
+ name_or_number::~name_or_number () noexcept {CPP2_UFCS ( _destroy)((* this )); static_cast < void >( std::move ((* this )) );}
106
106
name_or_number::name_or_number (){}
107
107
name_or_number::name_or_number (name_or_number const & that)
108
108
: _storage{ }
@@ -144,21 +144,21 @@ template <typename T> [[nodiscard]] auto name_or_other<T>::name() const& -> std:
144
144
template <typename T> [[nodiscard]] auto name_or_other<T>::name() & -> std::string& {
145
145
cpp2::Default.expects (is_name (), " " );return *cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)); }
146
146
template <typename T> auto name_or_other<T>::set_name(cpp2::in<std::string> _value) & -> void {if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), _value);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = _value;}_discriminator = 0 ;}
147
- template <typename T> auto name_or_other<T>::set_name(auto && ..._args) & -> void {if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), _args...);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = std::string{_args...};}_discriminator = 0 ;}
147
+ template <typename T> auto name_or_other<T>::set_name(auto && ..._args) & -> void {if (!(is_name ())) {_destroy ();std::construct_at (reinterpret_cast <std::string*>(&_storage), CPP2_FORWARD ( _args) ...);}else {*cpp2::assert_not_null (reinterpret_cast <std::string*>(&_storage)) = std::string{CPP2_FORWARD ( _args) ...};}_discriminator = 0 ;}
148
148
template <typename T> [[nodiscard]] auto name_or_other<T>::is_other() const & -> bool { return _discriminator == 1 ; }
149
149
template <typename T> [[nodiscard]] auto name_or_other<T>::other() const & -> T const & {
150
150
cpp2::Default.expects (is_other (), " " );return *cpp2::assert_not_null (reinterpret_cast <T const *>(&_storage)); }
151
151
template <typename T> [[nodiscard]] auto name_or_other<T>::other() & -> T& {
152
152
cpp2::Default.expects (is_other (), " " );return *cpp2::assert_not_null (reinterpret_cast <T*>(&_storage)); }
153
153
template <typename T> auto name_or_other<T>::set_other(cpp2::in<T> _value) & -> void {if (!(is_other ())) {_destroy ();std::construct_at (reinterpret_cast <T*>(&_storage), _value);}else {*cpp2::assert_not_null (reinterpret_cast <T*>(&_storage)) = _value;}_discriminator = 1 ;}
154
- template <typename T> auto name_or_other<T>::set_other(auto && ..._args) & -> void {if (!(is_other ())) {_destroy ();std::construct_at (reinterpret_cast <T*>(&_storage), _args...);}else {*cpp2::assert_not_null (reinterpret_cast <T*>(&_storage)) = T{_args...};}_discriminator = 1 ;}
154
+ template <typename T> auto name_or_other<T>::set_other(auto && ..._args) & -> void {if (!(is_other ())) {_destroy ();std::construct_at (reinterpret_cast <T*>(&_storage), CPP2_FORWARD ( _args) ...);}else {*cpp2::assert_not_null (reinterpret_cast <T*>(&_storage)) = T{CPP2_FORWARD ( _args) ...};}_discriminator = 1 ;}
155
155
template <typename T> auto name_or_other<T>::_destroy() & -> void {
156
156
if (_discriminator == 0 ) {std::destroy_at (reinterpret_cast <std::string*>(&_storage));}
157
157
if (_discriminator == 1 ) {std::destroy_at (reinterpret_cast <T*>(&_storage));}
158
158
_discriminator = -1 ;
159
159
}
160
160
161
- template <typename T> name_or_other<T>::~name_or_other () noexcept {_destroy ( );}
161
+ template <typename T> name_or_other<T>::~name_or_other () noexcept {CPP2_UFCS ( _destroy)((* this )); static_cast < void >( std::move ((* this )) );}
162
162
template <typename T> name_or_other<T>::name_or_other(){}
163
163
template <typename T> name_or_other<T>::name_or_other(name_or_other const & that)
164
164
: _storage{ }
0 commit comments