c++: variant: add more assertions

* data/variant.hh (variant::as): Check yytypeid_ before
checking *yytypeid_.
This commit is contained in:
Akim Demaille
2018-08-09 07:33:23 +02:00
parent ccc759e81a
commit 4410084223

View File

@@ -140,6 +140,7 @@ m4_define([b4_variant_define],
T&
as ()
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();
@@ -150,6 +151,7 @@ m4_define([b4_variant_define],
const T&
as () const
{]b4_parse_assert_if([
YYASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= S);])[
return *yyas_<T> ();