X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/fc51acddb45242904128a7637dc2ab9216ba0662..55fb68aabf15f6c2a9046c0bc3ad21a4aa2ca760:/data/variant.hh diff --git a/data/variant.hh b/data/variant.hh index 303e1c67..f918e34c 100644 --- a/data/variant.hh +++ b/data/variant.hh @@ -1,6 +1,6 @@ # C++ skeleton for Bison -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2015 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -95,13 +95,13 @@ m4_define([b4_variant_define], /// Empty construction. variant ()]b4_parse_assert_if([ - : yytname_ (YY_NULLPTR)])[ + : yytypeid_ (YY_NULLPTR)])[ {} /// Construct and fill. template variant (const T& t)]b4_parse_assert_if([ - : yytname_ (typeid (T).name ())])[ + : yytypeid_ (&typeid (T))])[ { YYASSERT (sizeof (T) <= S); new (yyas_ ()) T (t); @@ -110,7 +110,7 @@ m4_define([b4_variant_define], /// Destruction, allowed only if empty. ~variant () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); ])[} /// Instantiate an empty \a T in here. @@ -118,9 +118,9 @@ m4_define([b4_variant_define], T& build () {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ + yytypeid_ = & typeid (T);])[ return *new (yyas_ ()) T; } @@ -129,9 +129,9 @@ m4_define([b4_variant_define], T& build (const T& t) {]b4_parse_assert_if([ - YYASSERT (!yytname_); + YYASSERT (!yytypeid_); YYASSERT (sizeof (T) <= S); - yytname_ = typeid (T).name ();])[ + yytypeid_ = & typeid (T);])[ return *new (yyas_ ()) T (t); } @@ -140,7 +140,7 @@ m4_define([b4_variant_define], T& as () {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_ (); } @@ -150,7 +150,7 @@ m4_define([b4_variant_define], const T& as () const {]b4_parse_assert_if([ - YYASSERT (yytname_ == typeid (T).name ()); + YYASSERT (*yytypeid_ == typeid (T)); YYASSERT (sizeof (T) <= S);])[ return *yyas_ (); } @@ -167,8 +167,8 @@ m4_define([b4_variant_define], void swap (self_type& other) {]b4_parse_assert_if([ - YYASSERT (yytname_); - YYASSERT (yytname_ == other.yytname_);])[ + YYASSERT (yytypeid_); + YYASSERT (*yytypeid_ == *other.yytypeid_);])[ std::swap (as (), other.as ()); } @@ -198,7 +198,7 @@ m4_define([b4_variant_define], destroy () { as ().~T ();]b4_parse_assert_if([ - yytname_ = YY_NULLPTR;])[ + yytypeid_ = YY_NULLPTR;])[ } private: @@ -233,7 +233,7 @@ m4_define([b4_variant_define], } yybuffer_;]b4_parse_assert_if([ /// Whether the content is built: if defined, the name of the stored type. - const char *yytname_;])[ + const std::type_info *yytypeid_;])[ }; ]])