Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-18 17:29:26


Author: eric_niebler
Date: 2007-12-18 17:29:25 EST (Tue, 18 Dec 2007)
New Revision: 42152
URL: http://svn.boost.org/trac/boost/changeset/42152

Log:
fix boundary case in apply_args

Text files modified:
   branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp | 24 ++++++++++++++----------
   branches/proto/v3/boost/xpressive/proto/make_expr.hpp | 13 +++----------
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 12 ------------
   3 files changed, 17 insertions(+), 32 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp 2007-12-18 17:29:25 EST (Tue, 18 Dec 2007)
@@ -23,12 +23,18 @@
             struct apply_args;
 
         #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
- template<typename... G>
+ template<typename Prev, typename... G>
             struct pad_args
             {
                 typedef args<G...> type;
             };
 
+ template<typename Prev>
+ struct pad_args<Prev>
+ {
+ typedef args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, Prev BOOST_PP_INTERCEPT)> type;
+ };
+
             template<
                 BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename E)
               , typename... ERest
@@ -41,16 +47,15 @@
                 args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, E), ERest...>
               , S
               , V
- , args<
- BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, G)
- , GRest...
- >
+ , args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, G), GRest...>
>
             {
+ typedef BOOST_PP_CAT(G, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY)) prev_type;
+ typedef apply_args<args<ERest...>, S, V, typename pad_args<prev_type, GRest...>::type> rest_args;
                 #define TMP(Z, N, DATA) typename boost::result_of<G##N(E##N, S, V)>::type
                 typedef typename proto::detail::cat_args<
                     args<BOOST_PP_ENUM(BOOST_PROTO_MAX_ARITY, TMP, ~) >
- , typename apply_args<args<ERest...>, S, V, typename pad_args<GRest...>::type>::type
+ , typename rest_args::type
>::type type;
                 #undef TMP
 
@@ -62,8 +67,7 @@
                     #define TMP2(Z, N, DATA) }
                     typename type::cons_type that =
                         BOOST_PP_ENUM(BOOST_PROTO_MAX_ARITY, TMP1, ~)
- , apply_args<args<ERest...>, S, V, typename pad_args<GRest...>::type>
- ::call(a BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP0, ~), s, v)
+ , rest_args::call(a BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP0, ~), s, v)
                         BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP2, ~);
                     return that;
                     #undef TMP0
@@ -86,8 +90,8 @@
 #else
 
         #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
- template<BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), typename G)>
- struct pad_args<BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), G)>
+ template<typename Prev BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), typename G)>
+ struct pad_args<Prev BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PP_ITERATION(), G)>
         {
             #define TMP(Z, N, DATA) , BOOST_PP_CAT(G, BOOST_PP_DEC(BOOST_PP_ITERATION()))
             typedef args<

Modified: branches/proto/v3/boost/xpressive/proto/make_expr.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/make_expr.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/make_expr.hpp 2007-12-18 17:29:25 EST (Tue, 18 Dec 2007)
@@ -360,6 +360,7 @@
             };
         };
 
+ // TODO use PP to loop-unroll for BOOST_PROTO_MAX_ARITY
         template<
             typename Tag
           , typename Domain
@@ -701,6 +702,7 @@
             }
         };
 
+ // BUGBUG this is not POD :-(
         template<typename Tag, typename Domain>
         struct make_arg
           : fusion::unfused_generic<unfused_arg_fun<Tag, Domain> >
@@ -735,6 +737,7 @@
             }
         };
 
+ // BUGBUG this is not POD :-(
         template<typename Tag, typename Domain>
         struct make_expr
           : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> >
@@ -845,11 +848,6 @@
     {};
 
     template<typename Tag, typename Domain>
- struct is_callable<functional::unfused_arg<Tag, Domain> >
- : mpl::true_
- {};
-
- template<typename Tag, typename Domain>
     struct is_callable<functional::make_expr<Tag, Domain> >
       : mpl::true_
     {};
@@ -859,11 +857,6 @@
       : mpl::true_
     {};
 
- template<typename Tag, typename Domain>
- struct is_callable<functional::unfused_expr<Tag, Domain> >
- : mpl::true_
- {};
-
 }}
 
 #include <boost/xpressive/proto/detail/undef.hpp>

Modified: branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp 2007-12-18 17:29:25 EST (Tue, 18 Dec 2007)
@@ -616,23 +616,11 @@
         struct unpack_arg;
 
         template<typename Tag, typename Domain = deduce_domain>
- struct unfused_arg_fun;
-
- template<typename Tag, typename Domain = deduce_domain>
- struct unfused_arg;
-
- template<typename Tag, typename Domain = deduce_domain>
         struct make_expr;
 
         template<typename Tag, typename Domain = deduce_domain>
         struct unpack_expr;
 
- template<typename Tag, typename Domain = deduce_domain>
- struct unfused_expr_fun;
-
- template<typename Tag, typename Domain = deduce_domain>
- struct unfused_expr;
-
         typedef make_expr<tag::terminal> make_terminal;
         typedef make_expr<tag::posit> make_posit;
         typedef make_expr<tag::negate> make_negate;


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