c++: use modern idioms to make classes non-copyable

Reported by Don Macpherson.
https://lists.gnu.org/r/bug-bison/2019-05/msg00015.html
https://github.com/akimd/bison/issues/36

* data/skeletons/lalr1.cc, data/skeletons/stack.hh,
* data/skeletons/variant.hh: Delete the copy-ctor and the copy operator.
This commit is contained in:
Akim Demaille
2020-05-01 06:36:19 +02:00
parent fb1d76d9a9
commit 30357ae942
4 changed files with 37 additions and 5 deletions

View File

@@ -204,6 +204,13 @@ m4_define([b4_shared_declarations],
]b4_parser_class[ (]b4_parse_param_decl[);
virtual ~]b4_parser_class[ ();
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
]b4_parser_class[ (const ]b4_parser_class[&) = delete;
/// Non copyable.
]b4_parser_class[& operator= (const ]b4_parser_class[&) = delete;
#endif
/// Parse. An alias for parse ().
/// \returns 0 iff parsing succeeded.
int operator() ();
@@ -255,10 +262,13 @@ m4_define([b4_shared_declarations],
};
]])[
private:
/// This class is not copyable.
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
]b4_parser_class[ (const ]b4_parser_class[&);
]b4_parser_class[& operator= (const ]b4_parser_class[&);]b4_lac_if([[
/// Non copyable.
]b4_parser_class[& operator= (const ]b4_parser_class[&);
#endif
]b4_lac_if([[
/// Check the lookahead yytoken.
/// \returns true iff the token will be eventually shifted.
bool yy_lac_check_ (symbol_kind_type yytoken) const;