Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-04-13 15:33:43


Author: eric_niebler
Date: 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
New Revision: 44373
URL: http://svn.boost.org/trac/boost/changeset/44373

Log:
gcc-4.0 portability fixes, misc optimizations
Text files modified:
   branches/proto/v4/boost/proto/make_expr.hpp | 62 ++++++++++++++++++++-------------------
   branches/proto/v4/boost/proto/proto_fwd.hpp | 8 ++--
   branches/proto/v4/boost/proto/traits.hpp | 26 +++++++++-------
   branches/proto/v4/boost/proto/transform/default.hpp | 4 +-
   branches/proto/v4/boost/proto/transform/fold.hpp | 4 +-
   branches/proto/v4/boost/proto/transform/make.hpp | 4 +-
   branches/proto/v4/boost/proto/transform/pass_through.hpp | 2
   7 files changed, 58 insertions(+), 52 deletions(-)

Modified: branches/proto/v4/boost/proto/make_expr.hpp
==============================================================================
--- branches/proto/v4/boost/proto/make_expr.hpp (original)
+++ branches/proto/v4/boost/proto/make_expr.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -801,6 +801,30 @@
 
         } // namespace functional
 
+ /// TODO document me
+ template<typename Tag, typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= deduce_domain)>
+ struct _make_expr : callable
+ {
+ template<typename Sig>
+ struct result
+ : functional::make_expr<Tag, Domain>::template result<Sig>
+ {};
+
+ #define M0(Z, N, DATA) \
+ template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
+ BOOST_PP_CAT(detail::implicit_expr_, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> \
+ operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const \
+ { \
+ BOOST_PP_CAT(detail::implicit_expr_, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> that = { \
+ BOOST_PP_ENUM_PARAMS_Z(Z, N, a) \
+ }; \
+ return that; \
+ } \
+ /**/
+ BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M0, ~)
+ #undef M0
+ };
+
         /// \brief Construct an expression of the requested tag type
         /// with a domain and with the specified arguments as children.
         ///
@@ -940,29 +964,6 @@
           : mpl::true_
         {};
 
- template<typename Tag, typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= deduce_domain)>
- struct _make_expr : callable
- {
- template<typename Sig>
- struct result
- : functional::make_expr<Tag, Domain>::template result<Sig>
- {};
-
- #define M0(Z, N, DATA) \
- template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
- BOOST_PP_CAT(detail::implicit_expr_, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> \
- operator ()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const \
- { \
- BOOST_PP_CAT(detail::implicit_expr_, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> that = { \
- BOOST_PP_ENUM_PARAMS_Z(Z, N, a) \
- }; \
- return that; \
- } \
- /**/
- BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), M0, ~)
- #undef M0
- };
-
         /// INTERNAL ONLY
         ///
         template<typename Tag, typename Domain>
@@ -1029,14 +1030,14 @@
>::type
             type;
             #else
- static sized<BOOST_PP_INC(BOOST_PROTO_MAX_ARITY)> deducer(
- BOOST_PP_ENUM_PARAMS(N, dont_care BOOST_PP_INTERCEPT)
- );
- #define M0(Z, X, DATA) \
+ #define M0(N, F) char (&F)[BOOST_PP_INC(N)]
+ static M0(BOOST_PROTO_MAX_ARITY, deducer(
+ BOOST_PP_ENUM_PARAMS(N, dont_care BOOST_PP_INTERCEPT)));
+ #define M1(Z, X, DATA) \
             typedef typename domain_of<BOOST_PP_CAT(A, X)>::type BOOST_PP_CAT(D, X); \
             static BOOST_PP_CAT(D, X) &BOOST_PP_CAT(d, X); \
             template<typename T> \
- static sized<BOOST_PP_INC(X)> deducer( \
+ static M0(X, deducer( \
                 BOOST_PP_ENUM_PARAMS_Z(Z, X, default_domain BOOST_PP_INTERCEPT) \
                 BOOST_PP_COMMA_IF(X) T \
                 BOOST_PP_ENUM_TRAILING_PARAMS_Z( \
@@ -1044,9 +1045,10 @@
                   , BOOST_PP_DEC(BOOST_PP_SUB(N, X)) \
                   , typename nondeduced_domain<T>::type BOOST_PP_INTERCEPT \
                 ) \
- );
- BOOST_PP_REPEAT(N, M0, ~)
+ ));
+ BOOST_PP_REPEAT(N, M1, ~)
             #undef M0
+ #undef M1
             BOOST_STATIC_CONSTANT(int, value = sizeof(deducer(BOOST_PP_ENUM_PARAMS(N, d))) - 1);
             typedef typename select_nth<value, BOOST_PP_ENUM_PARAMS(N, D)>::type type;
             #endif

Modified: branches/proto/v4/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v4/boost/proto/proto_fwd.hpp (original)
+++ branches/proto/v4/boost/proto/proto_fwd.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -456,9 +456,6 @@
         struct unpack_expr;
 
         template<typename T, typename Void = void>
- struct is_ref;
-
- template<typename T, typename Void = void>
         struct is_expr;
 
         template<typename T, typename Void = void>
@@ -467,6 +464,9 @@
         template<typename Expr>
         struct tag_of;
 
+ template<typename Expr>
+ struct arity_of;
+
         template<typename T, typename Void = void>
         struct domain_of;
 
@@ -474,10 +474,10 @@
         struct matches;
     }
 
- using result_of::is_ref;
     using result_of::is_expr;
     using result_of::is_domain;
     using result_of::tag_of;
+ using result_of::arity_of;
     using result_of::domain_of;
     using result_of::matches;
 

Modified: branches/proto/v4/boost/proto/traits.hpp
==============================================================================
--- branches/proto/v4/boost/proto/traits.hpp (original)
+++ branches/proto/v4/boost/proto/traits.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -120,7 +120,7 @@
           : mpl::false_
         {};
 
- #if BOOST_WORKAROUND(__GNUC__, == 3)
+ #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
         // work around GCC bug
         template<typename Tag, typename Args, long N>
         struct is_callable<proto::expr<Tag, Args, N> >
@@ -198,18 +198,22 @@
                 typedef typename Expr::proto_tag type;
             };
 
- /// INTERNAL ONLY
- ///
- template<typename T, typename Void BOOST_PROTO_WHEN_BUILDING_DOCS(= void)>
- struct is_ref
- : mpl::false_
+ template<typename Expr>
+ struct tag_of<Expr &>
+ {
+ typedef typename Expr::proto_tag type;
+ };
+
+ /// \brief A metafunction that returns the arity of a
+ /// Proto expression.
+ template<typename Expr>
+ struct arity_of
+ : Expr::proto_arity
             {};
 
- /// INTERNAL ONLY
- ///
- template<typename T>
- struct is_ref<T, typename T::proto_is_ref_>
- : mpl::true_
+ template<typename Expr>
+ struct arity_of<Expr &>
+ : Expr::proto_arity
             {};
 
             /// \brief A metafunction that computes the return type of the \c as_expr()

Modified: branches/proto/v4/boost/proto/transform/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/default.hpp (original)
+++ branches/proto/v4/boost/proto/transform/default.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -214,7 +214,7 @@
                 BOOST_PROTO_DECLTYPE_(
                     proto::detail::make<r0>()
                   ? proto::detail::make<r1>()
- : proto::detail::make<r2>();
+ : proto::detail::make<r2>()
                   , result_type
                 )
                 result_type operator ()(
@@ -228,7 +228,7 @@
                     typename Grammar::template impl<e2, State, Data> t2;
                     return t0(proto::child_c<0>(expr), state, data)
                          ? t1(proto::child_c<1>(expr), state, data)
- : t2(proto::child_c<2>(expr), state, data)
+ : t2(proto::child_c<2>(expr), state, data);
                 }
             };
 

Modified: branches/proto/v4/boost/proto/transform/fold.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/fold.hpp (original)
+++ branches/proto/v4/boost/proto/transform/fold.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -107,7 +107,7 @@
               , typename Expr
               , typename State
               , typename Data
- , long Arity = remove_reference<Expr>::type::proto_arity::value
+ , long Arity = arity_of<Expr>::value
>
             struct fold_impl
             {};
@@ -118,7 +118,7 @@
               , typename Expr
               , typename State
               , typename Data
- , long Arity = remove_reference<Expr>::type::proto_arity::value
+ , long Arity = arity_of<Expr>::value
>
             struct reverse_fold_impl
             {};

Modified: branches/proto/v4/boost/proto/transform/make.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/make.hpp (original)
+++ branches/proto/v4/boost/proto/transform/make.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -83,7 +83,7 @@
               : make_<R, Expr, State, Data>
             {};
 
- #if BOOST_WORKAROUND(__GNUC__, == 3)
+ #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
             // work around GCC bug
             template<typename Tag, typename Args, long N, typename Expr, typename State, typename Data>
             struct make_if_<proto::expr<Tag, Args, N>, Expr, State, Data, false>
@@ -347,7 +347,7 @@
             };
         };
 
- #if BOOST_WORKAROUND(__GNUC__, == 3)
+ #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0)
         // work around GCC bug
         template<typename Tag, typename Args, long Arity BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
         struct make<proto::expr<Tag, Args, Arity>(BOOST_PP_ENUM_PARAMS(N, A))>

Modified: branches/proto/v4/boost/proto/transform/pass_through.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/pass_through.hpp (original)
+++ branches/proto/v4/boost/proto/transform/pass_through.hpp 2008-04-13 15:33:42 EDT (Sun, 13 Apr 2008)
@@ -33,7 +33,7 @@
               , typename Expr
               , typename State
               , typename Data
- , long Arity = remove_reference<Expr>::type::proto_arity::value
+ , long Arity = arity_of<Expr>::value
>
             struct pass_through_impl
             {};


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk