From fdaedc780af0dd678a4f4fa3175a201a553be20a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Tue, 7 Sep 2021 07:00:32 +0200 Subject: [PATCH] c++: add move assignments to the symbol type This will be used in glr2.cc, which requires C++11. * data/skeletons/c++.m4 (basic_symbol, by_kind): Add move assignment. --- data/skeletons/c++.m4 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/data/skeletons/c++.m4 b/data/skeletons/c++.m4 index 31ddb255..4645a5a0 100644 --- a/data/skeletons/c++.m4 +++ b/data/skeletons/c++.m4 @@ -346,6 +346,19 @@ m4_define([b4_symbol_type_define], clear (); } +#if 201103L <= YY_CPLUSPLUS + /// Move assignment. + basic_symbol& operator= (basic_symbol&& that) + { + Base::operator= (std::move (that));]b4_variant_if([[ + ]b4_symbol_variant([this->kind ()], [value], [move], + [std::move (that.value)])], [[ + value = std::move (that.value)]])[;]b4_locations_if([[ + location = std::move (that.location);]])[ + return *this; + } +#endif + /// Destroy contents, and record that is empty. void clear () YY_NOEXCEPT {]b4_variant_if([[ @@ -424,6 +437,11 @@ m4_define([b4_symbol_type_define], /// Copy constructor. by_kind (const by_kind& that); +#if 201103L <= YY_CPLUSPLUS + /// Move assignment. + by_kind& operator= (by_kind&& that); +#endif + /// The symbol kind as needed by the constructor. typedef token_kind_type kind_type; @@ -552,6 +570,16 @@ m4_define([b4_public_types_define], : kind_ (yytranslate_ (t)) {} +#if 201103L <= YY_CPLUSPLUS + ]b4_inline([$1])]b4_parser_class[::by_kind& + b4_parser_class[::by_kind::by_kind::operator= (by_kind&& that) + { + kind_ = that.kind_; + that.clear (); + return *this; + } +#endif + ]b4_inline([$1])[void ]b4_parser_class[::by_kind::clear () YY_NOEXCEPT {