bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] c++: remove useless inlines


From: Akim Demaille
Subject: Re: [PATCH 3/3] c++: remove useless inlines
Date: Mon, 21 Jan 2013 16:06:27 +0100

Le 15 janv. 2013 à 15:44, Theophile Ranquet <address@hidden> a écrit :

> * data/c++.m4 (basic_symbol): Keep 'inline' in the prototypes, but don't
> duplicate it in the implementation.

Actually, I'd prefer the converse: don't keep it in the
declaration, leave it in the implementation.  I know I have
changed my mind on this regard, sorry about this.

Beware that the FIXME stuff is unrelated.

> * data/variant.hh (variant): 'inline' is not needed when the implementation is
> provided in the class definition.

This is good.

> ---
> data/c++.m4     | 16 +++-------------
> data/variant.hh | 18 ++++++++----------
> 2 files changed, 11 insertions(+), 23 deletions(-)
> 
> diff --git a/data/c++.m4 b/data/c++.m4
> index 506d6a7..2d45bc8 100644
> --- a/data/c++.m4
> +++ b/data/c++.m4
> @@ -241,20 +241,17 @@ m4_define([b4_public_types_define],
> 
>   // basic_symbol.
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol ()
>     : value ()
>   {}
> ]b4_locations_if([
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const 
> location_type& l)
>     : value ()
>     , location (l)
>   {}])[
> 
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>&
>   ]b4_parser_class_name[::basic_symbol<Base>::operator= (const basic_symbol&)
>   {
> @@ -262,7 +259,6 @@ m4_define([b4_public_types_define],
>   }
> 
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (const 
> basic_symbol& other)
>     : Base (other)
>     , value ()]b4_locations_if([
> @@ -275,7 +271,6 @@ m4_define([b4_public_types_define],
> 
> 
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
>           [typename Base::value_type t],
>           [const semantic_type& v],
> @@ -284,14 +279,15 @@ m4_define([b4_public_types_define],
>     , value ()]b4_locations_if([
>     , 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],
>                                       [v])],
>                    [value = v;])[
>   }
> 
>   template <typename Base>
> -  inline
>   ]b4_parser_class_name[::basic_symbol<Base>::basic_symbol (]b4_join(
>           [typename Base::value_type t],
>           b4_locations_if([const location_type& l]))[)
> @@ -300,7 +296,6 @@ m4_define([b4_public_types_define],
>   {}
> 
>   template <typename Base>
> -  inline
>   void
>   ]b4_parser_class_name[::basic_symbol<Base>::move (basic_symbol& s)
>   {
> @@ -312,29 +307,24 @@ m4_define([b4_public_types_define],
>   }
> 
>   // by_type.
> -  inline
>   ]b4_parser_class_name[::by_type::by_type ()
>      : type ()
>   {}
> 
> -  inline
>   ]b4_parser_class_name[::by_type::by_type (const by_type& other)
>     : type (other.type)
>   {}
> 
> -  inline
>   ]b4_parser_class_name[::by_type::by_type (token_type t)
>     : type (yytranslate_ (t))
>   {}
> 
> -  inline
>   int
>   ]b4_parser_class_name[::by_type::type_get () const
>   {
>     return type;
>   }
> ]b4_token_ctor_if([[
> -  inline
>   ]b4_parser_class_name[::token_type
>   ]b4_parser_class_name[::by_type::token () const
>   {
> diff --git a/data/variant.hh b/data/variant.hh
> index 5ff0c54..1b03388 100644
> --- a/data/variant.hh
> +++ b/data/variant.hh
> @@ -95,7 +95,6 @@ m4_define([b4_variant_define],
>     typedef variant<S> self_type;
> 
>     /// Empty construction.
> -    inline
>     variant ()]b4_parse_assert_if([
>       : built (false)
>       , tname (YY_NULL)])[
> @@ -103,7 +102,7 @@ m4_define([b4_variant_define],
> 
>     /// Instantiate a \a T in here.
>     template <typename T>
> -    inline T&
> +    T&
>     build ()
>     {]b4_parse_assert_if([
>       //YYASSERT (!built);
> @@ -116,7 +115,7 @@ m4_define([b4_variant_define],
> 
>     /// Instantiate a \a T in here from \a t.
>     template <typename T>
> -    inline T&
> +    T&
>     build (const T& t)
>     {]b4_parse_assert_if([
>       //YYASSERT (!built);
> @@ -129,7 +128,6 @@ m4_define([b4_variant_define],
> 
>     /// Construct and fill.
>     template <typename T>
> -    inline
>     variant (const T& t)]b4_parse_assert_if([
>       : built (true)
>       , tname (typeid (T).name ())])[
> @@ -140,7 +138,7 @@ m4_define([b4_variant_define],
> 
>     /// Accessor to a built \a T.
>     template <typename T>
> -    inline T&
> +    T&
>     as ()
>     {]b4_parse_assert_if([
>       YYASSERT (built);
> @@ -151,7 +149,7 @@ m4_define([b4_variant_define],
> 
>     /// Const accessor to a built \a T (for %printer).
>     template <typename T>
> -    inline const T&
> +    const T&
>     as () const
>     {]b4_parse_assert_if([
>       YYASSERT (built);
> @@ -168,7 +166,7 @@ m4_define([b4_variant_define],
>     /// Swapping between built and ((possibly) non-built is done with
>     /// variant::move ().
>     template <typename T>
> -    inline void
> +    void
>     swap (variant<S>& other)
>     {]b4_parse_assert_if([
>       YYASSERT (built);
> @@ -180,7 +178,7 @@ m4_define([b4_variant_define],
>     /// Assign the content of \a other to this.
>     /// Destroys \a other.
>     template <typename T>
> -    inline void
> +    void
>     move (variant<S>& other)
>     {]b4_parse_assert_if([
>       YYASSERT (! built);])[
> @@ -192,7 +190,7 @@ m4_define([b4_variant_define],
>     /// Copy the content of \a other to this.
>     /// Destroys \a other.
>     template <typename T>
> -    inline void
> +    void
>     copy (const variant<S>& other)
>     {
>       build<T> (other.as<T> ());
> @@ -200,7 +198,7 @@ m4_define([b4_variant_define],
> 
>     /// Destroy the stored \a T.
>     template <typename T>
> -    inline void
> +    void
>     destroy ()
>     {
>       as<T> ().~T ();]b4_parse_assert_if([
> -- 
> 1.8.1
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]