mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 04:13:03 +00:00
c++: introduce api.value.automove
Based on work by Frank Heckenbach. See http://lists.gnu.org/archive/html/bug-bison/2018-04/msg00000.html and http://lists.gnu.org/archive/html/bug-bison/2018-09/msg00019.html. * data/lalr1.cc (b4_rhs_value): Use YY_MOVE api.rhs.automove is set. * doc/bison.texi (%define Summary): Document api.rhs.automove. * examples/variant-11.yy: Use it. * tests/local.at (AT_AUTOMOVE_IF): New. * tests/c++.at (Variants): Check move semantics.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
%defines
|
||||
%define api.token.constructor
|
||||
%define api.value.type variant
|
||||
%define api.value.automove
|
||||
%define parse.assert
|
||||
%locations
|
||||
|
||||
@@ -96,11 +97,11 @@ result:
|
||||
|
||||
list:
|
||||
%empty { /* Generates an empty string list */ }
|
||||
| list item { $$ = std::move ($1); $$.emplace_back (std::move ($2)); }
|
||||
| list item { $$ = $1; $$.emplace_back ($2); }
|
||||
;
|
||||
|
||||
item:
|
||||
TEXT { $$ = std::move ($1); }
|
||||
TEXT { $$ = $1; }
|
||||
| NUMBER { $$ = make_string_uptr (to_string ($1)); }
|
||||
;
|
||||
%%
|
||||
|
||||
Reference in New Issue
Block a user