c++: remove useless inlines

* data/c++.m4 (basic_symbol): Keep 'inline' in the prototypes, but don't
duplicate it in the implementation.
* data/variant.hh (variant): 'inline' is not needed when the implementation is
provided in the class definition.
This commit is contained in:
Theophile Ranquet
2013-01-15 13:05:21 +01:00
parent 403febcac5
commit 733fb7c593
2 changed files with 11 additions and 23 deletions

View File

@@ -241,20 +241,17 @@ m4_define([b4_public_types_define],
// basic_symbol. // basic_symbol.
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol () ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
: value () : value ()
{} {}
]b4_locations_if([ ]b4_locations_if([
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const location_type& l) ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const location_type& l)
: value () : value ()
, location (l) , location (l)
{}])[ {}])[
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>& ]b4_parser_class_name[::basic_symbol<Base>&
]b4_parser_class_name[::basic_symbol<Base>::operator= (const basic_symbol&) ]b4_parser_class_name[::basic_symbol<Base>::operator= (const basic_symbol&)
{ {
@@ -262,7 +259,6 @@ m4_define([b4_public_types_define],
} }
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other) ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const basic_symbol& other)
: Base (other) : Base (other)
, value ()]b4_locations_if([ , value ()]b4_locations_if([
@@ -275,7 +271,6 @@ m4_define([b4_public_types_define],
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::value_type t], [typename Base::value_type t],
[const semantic_type& v], [const semantic_type& v],
@@ -284,14 +279,15 @@ m4_define([b4_public_types_define],
, value ()]b4_locations_if([ , value ()]b4_locations_if([
, location (l)])[ , location (l)])[
{ {
(void) v; /* FIXME: */ // FIXME: The YYUSE macro is only available in the .cc skeleton files. It
// is not available in .hh files, where this code is when using %defines.
(void) v;
]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [copy], ]b4_variant_if([b4_symbol_variant([this->type_get ()], [value], [copy],
[v])], [v])],
[value = v;])[ [value = v;])[
} }
template <typename Base> template <typename Base>
inline
]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join( ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
[typename Base::value_type t], [typename Base::value_type t],
b4_locations_if([const location_type& l]))[) b4_locations_if([const location_type& l]))[)
@@ -300,7 +296,6 @@ m4_define([b4_public_types_define],
{} {}
template <typename Base> template <typename Base>
inline
void void
]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s) ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
{ {
@@ -312,29 +307,24 @@ m4_define([b4_public_types_define],
} }
// by_type. // by_type.
inline
]b4_parser_class_name[::by_type::by_type () ]b4_parser_class_name[::by_type::by_type ()
: type () : type ()
{} {}
inline
]b4_parser_class_name[::by_type::by_type (const by_type& other) ]b4_parser_class_name[::by_type::by_type (const by_type& other)
: type (other.type) : type (other.type)
{} {}
inline
]b4_parser_class_name[::by_type::by_type (token_type t) ]b4_parser_class_name[::by_type::by_type (token_type t)
: type (yytranslate_ (t)) : type (yytranslate_ (t))
{} {}
inline
int int
]b4_parser_class_name[::by_type::type_get () const ]b4_parser_class_name[::by_type::type_get () const
{ {
return type; return type;
} }
]b4_token_ctor_if([[ ]b4_token_ctor_if([[
inline
]b4_parser_class_name[::token_type ]b4_parser_class_name[::token_type
]b4_parser_class_name[::by_type::token () const ]b4_parser_class_name[::by_type::token () const
{ {

View File

@@ -95,7 +95,6 @@ m4_define([b4_variant_define],
typedef variant<S> self_type; typedef variant<S> self_type;
/// Empty construction. /// Empty construction.
inline
variant ()]b4_parse_assert_if([ variant ()]b4_parse_assert_if([
: built (false) : built (false)
, tname (YY_NULL)])[ , tname (YY_NULL)])[
@@ -103,7 +102,7 @@ m4_define([b4_variant_define],
/// Instantiate a \a T in here. /// Instantiate a \a T in here.
template <typename T> template <typename T>
inline T& T&
build () build ()
{]b4_parse_assert_if([ {]b4_parse_assert_if([
//YYASSERT (!built); //YYASSERT (!built);
@@ -116,7 +115,7 @@ m4_define([b4_variant_define],
/// Instantiate a \a T in here from \a t. /// Instantiate a \a T in here from \a t.
template <typename T> template <typename T>
inline T& T&
build (const T& t) build (const T& t)
{]b4_parse_assert_if([ {]b4_parse_assert_if([
//YYASSERT (!built); //YYASSERT (!built);
@@ -129,7 +128,6 @@ m4_define([b4_variant_define],
/// Construct and fill. /// Construct and fill.
template <typename T> template <typename T>
inline
variant (const T& t)]b4_parse_assert_if([ variant (const T& t)]b4_parse_assert_if([
: built (true) : built (true)
, tname (typeid (T).name ())])[ , tname (typeid (T).name ())])[
@@ -140,7 +138,7 @@ m4_define([b4_variant_define],
/// Accessor to a built \a T. /// Accessor to a built \a T.
template <typename T> template <typename T>
inline T& T&
as () as ()
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (built); YYASSERT (built);
@@ -151,7 +149,7 @@ m4_define([b4_variant_define],
/// Const accessor to a built \a T (for %printer). /// Const accessor to a built \a T (for %printer).
template <typename T> template <typename T>
inline const T& const T&
as () const as () const
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (built); YYASSERT (built);
@@ -168,7 +166,7 @@ m4_define([b4_variant_define],
/// Swapping between built and ((possibly) non-built is done with /// Swapping between built and ((possibly) non-built is done with
/// variant::move (). /// variant::move ().
template <typename T> template <typename T>
inline void void
swap (variant<S>& other) swap (variant<S>& other)
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (built); YYASSERT (built);
@@ -180,7 +178,7 @@ m4_define([b4_variant_define],
/// Assign the content of \a other to this. /// Assign the content of \a other to this.
/// Destroys \a other. /// Destroys \a other.
template <typename T> template <typename T>
inline void void
move (variant<S>& other) move (variant<S>& other)
{]b4_parse_assert_if([ {]b4_parse_assert_if([
YYASSERT (! built);])[ YYASSERT (! built);])[
@@ -192,7 +190,7 @@ m4_define([b4_variant_define],
/// Copy the content of \a other to this. /// Copy the content of \a other to this.
/// Destroys \a other. /// Destroys \a other.
template <typename T> template <typename T>
inline void void
copy (const variant<S>& other) copy (const variant<S>& other)
{ {
build<T> (other.as<T> ()); build<T> (other.as<T> ());
@@ -200,7 +198,7 @@ m4_define([b4_variant_define],
/// Destroy the stored \a T. /// Destroy the stored \a T.
template <typename T> template <typename T>
inline void void
destroy () destroy ()
{ {
as<T> ().~T ();]b4_parse_assert_if([ as<T> ().~T ();]b4_parse_assert_if([