c++: the assignment operator does not have to be const

* data/lalr1.cc (stack_symbol_type::operator=): Don't copy the
argument, move it.
This commit is contained in:
Akim Demaille
2018-08-25 11:41:08 +02:00
parent 15233a3728
commit 2116ad3a28

View File

@@ -320,7 +320,7 @@ b4_location_define])])[
/// Steal the contents from \a sym to build this. /// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, symbol_type& sym); stack_symbol_type (state_type s, symbol_type& sym);
/// Assignment, needed by push_back. /// Assignment, needed by push_back.
stack_symbol_type& operator= (const stack_symbol_type& that); stack_symbol_type& operator= (stack_symbol_type& that);
}; };
/// Stack type. /// 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&
]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; state = that.state;
]b4_variant_if([b4_symbol_variant([that.type_get ()], ]b4_variant_if([b4_symbol_variant([that.type_get ()],
[value], [copy], [that.value])], [value], [move], [that.value])],
[[value = that.value;]])[]b4_locations_if([ [[value = that.value;]])[]b4_locations_if([
location = that.location;])[ location = that.location;])[
return *this; return *this;