bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/5] c++: add move assignments to the symbol type


From: Akim Demaille
Subject: [PATCH 2/5] c++: add move assignments to the symbol type
Date: Sun, 12 Sep 2021 12:05:46 +0200

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
   {
-- 
2.32.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]