c++: also prefer YY_ASSERT to YYASSERT

Like the other skeletons.

* data/skeletons/variant.hh: here.
This commit is contained in:
Akim Demaille
2019-12-07 09:49:22 +01:00
parent 357336d254
commit 9bf06f6963

View File

@@ -72,9 +72,9 @@ m4_map([ b4_symbol_tag_comment], [$@])dnl
# The needed includes for variants support. # The needed includes for variants support.
m4_define([b4_variant_includes], m4_define([b4_variant_includes],
[b4_parse_assert_if([[#include <typeinfo>]])[ [b4_parse_assert_if([[#include <typeinfo>]])[
#ifndef YYASSERT #ifndef YY_ASSERT
# include <cassert> # include <cassert>
# define YYASSERT assert # define YY_ASSERT assert
#endif #endif
]]) ]])
@@ -111,14 +111,14 @@ m4_define([b4_value_type_declare],
semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([ semantic_type (YY_RVREF (T) t)]b4_parse_assert_if([
: yytypeid_ (&typeid (T))])[ : yytypeid_ (&typeid (T))])[
{ {
YYASSERT (sizeof (T) <= size); YY_ASSERT (sizeof (T) <= size);
new (yyas_<T> ()) T (YY_MOVE (t)); new (yyas_<T> ()) T (YY_MOVE (t));
} }
/// Destruction, allowed only if empty. /// Destruction, allowed only if empty.
~semantic_type () YY_NOEXCEPT ~semantic_type () YY_NOEXCEPT
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (!yytypeid_); YY_ASSERT (!yytypeid_);
])[} ])[}
# if 201103L <= YY_CPLUSPLUS # if 201103L <= YY_CPLUSPLUS
@@ -127,8 +127,8 @@ m4_define([b4_value_type_declare],
T& T&
emplace (U&&... u) emplace (U&&... u)
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (!yytypeid_); YY_ASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size); YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[ yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (std::forward <U>(u)...); return *new (yyas_<T> ()) T (std::forward <U>(u)...);
} }
@@ -138,8 +138,8 @@ m4_define([b4_value_type_declare],
T& T&
emplace () emplace ()
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (!yytypeid_); YY_ASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size); YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[ yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (); return *new (yyas_<T> ()) T ();
} }
@@ -149,8 +149,8 @@ m4_define([b4_value_type_declare],
T& T&
emplace (const T& t) emplace (const T& t)
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (!yytypeid_); YY_ASSERT (!yytypeid_);
YYASSERT (sizeof (T) <= size); YY_ASSERT (sizeof (T) <= size);
yytypeid_ = & typeid (T);])[ yytypeid_ = & typeid (T);])[
return *new (yyas_<T> ()) T (t); return *new (yyas_<T> ()) T (t);
} }
@@ -179,9 +179,9 @@ m4_define([b4_value_type_declare],
T& T&
as () YY_NOEXCEPT as () YY_NOEXCEPT
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (yytypeid_); YY_ASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T)); YY_ASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= size);])[ YY_ASSERT (sizeof (T) <= size);])[
return *yyas_<T> (); return *yyas_<T> ();
} }
@@ -190,9 +190,9 @@ m4_define([b4_value_type_declare],
const T& const T&
as () const YY_NOEXCEPT as () const YY_NOEXCEPT
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (yytypeid_); YY_ASSERT (yytypeid_);
YYASSERT (*yytypeid_ == typeid (T)); YY_ASSERT (*yytypeid_ == typeid (T));
YYASSERT (sizeof (T) <= size);])[ YY_ASSERT (sizeof (T) <= size);])[
return *yyas_<T> (); return *yyas_<T> ();
} }
@@ -208,8 +208,8 @@ m4_define([b4_value_type_declare],
void void
swap (self_type& that) YY_NOEXCEPT swap (self_type& that) YY_NOEXCEPT
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (yytypeid_); YY_ASSERT (yytypeid_);
YYASSERT (*yytypeid_ == *that.yytypeid_);])[ YY_ASSERT (*yytypeid_ == *that.yytypeid_);])[
std::swap (as<T> (), that.as<T> ()); std::swap (as<T> (), that.as<T> ());
} }
@@ -401,7 +401,7 @@ m4_define([_b4_token_constructor_define],
b4_symbol_if([$1], [has_type], [std::move (v)]), b4_symbol_if([$1], [has_type], [std::move (v)]),
b4_locations_if([std::move (l)]))[) b4_locations_if([std::move (l)]))[)
{ {
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[); YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
} }
#else #else
symbol_type (]b4_join( symbol_type (]b4_join(
@@ -413,7 +413,7 @@ m4_define([_b4_token_constructor_define],
b4_symbol_if([$1], [has_type], [v]), b4_symbol_if([$1], [has_type], [v]),
b4_locations_if([l]))[) b4_locations_if([l]))[)
{ {
YYASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[); YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
} }
#endif #endif
]])]) ]])])