I had not realized that the assignment (the ‘copy’ one, the ‘old’ one) does not have to preserve its rhs. Which is want we want here (emulation of move-assignment).
commit 2116ad3a280f79ab28eba244a00d7d1358f141ef Author: Akim Demaille <[email protected]> Date: Sat Aug 25 11:41:08 2018 +0200 c++: the assignment operator does not have to be const * data/lalr1.cc (stack_symbol_type::operator=): Don't copy the argument, move it. diff --git a/data/lalr1.cc b/data/lalr1.cc index 143f3d4b..ab48d506 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -320,7 +320,7 @@ b4_location_define])])[ /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, symbol_type& sym); /// Assignment, needed by push_back. - stack_symbol_type& operator= (const stack_symbol_type& that); + stack_symbol_type& operator= (stack_symbol_type& that); }; /// Stack type. @@ -603,11 +603,11 @@ m4_if(b4_prefix, [yy], [], } ]b4_parser_class_name[::stack_symbol_type& - ]b4_parser_class_name[::stack_symbol_type::operator= (const stack_symbol_type& that) + ]b4_parser_class_name[::stack_symbol_type::operator= (stack_symbol_type& that) { state = that.state; ]b4_variant_if([b4_symbol_variant([that.type_get ()], - [value], [copy], [that.value])], + [value], [move], [that.value])], [[value = that.value;]])[]b4_locations_if([ location = that.location;])[ return *this;
