From 7ab25ad0208d00f509613e1e151aa3043cf2862f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 12 Aug 2018 18:10:10 +0200 Subject: [PATCH] C++: remove useless copy-constructor We currently generate copy constructors such as the following one (taken from examples/variant.yy): parser::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that) : super_type (that.state, that.location) { switch (that.type_get ()) { case 3: // TEXT case 8: // item value.copy< ::std::string > (that.value); break; case 7: // list value.copy< ::std::vector > (that.value); break; case 4: // NUMBER value.copy< int > (that.value); break; default: break; } } they are actually useless: we never need it. * data/lalr1.cc: Don't generate the stack_symbol_type copy ctor. --- data/lalr1.cc | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/data/lalr1.cc b/data/lalr1.cc index afebda55..2c99aacf 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -314,8 +314,6 @@ b4_location_define])])[ typedef basic_symbol super_type; /// Construct an empty symbol. stack_symbol_type (); - /// Copy construct. - stack_symbol_type (const stack_symbol_type& that); /// Steal the contents from \a sym to build this. stack_symbol_type (state_type s, symbol_type& sym); /// Assignment, needed by push_back. @@ -575,14 +573,6 @@ m4_if(b4_prefix, [yy], [], ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type () {} - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (const stack_symbol_type& that) - : super_type (that.state]b4_locations_if([, that.location])[) - { - ]b4_variant_if([b4_symbol_variant([that.type_get ()], - [value], [copy], [that.value])], - [[value = that.value;]])[ - } - ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, symbol_type& that) : super_type (s]b4_locations_if([, that.location])[) {