diff options
author | Akim Demaille <akim.demaille@gmail.com> | 2021-09-07 07:00:32 +0200 |
---|---|---|
committer | Akim Demaille <akim.demaille@gmail.com> | 2021-09-12 12:03:58 +0200 |
commit | fdaedc780af0dd678a4f4fa3175a201a553be20a (patch) | |
tree | d2a52501ccff078cea27f9d598418b2e417e2319 /data | |
parent | 85f5e3b9d5188b093ad9e6b382b77044b9bdec1f (diff) | |
download | bison-fdaedc780af0dd678a4f4fa3175a201a553be20a.tar.gz |
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.
Diffstat (limited to 'data')
-rw-r--r-- | data/skeletons/c++.m4 | 28 |
1 files changed, 28 insertions, 0 deletions
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 { |