Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-27 14:39:36


Author: eric_niebler
Date: 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
New Revision: 42314
URL: http://svn.boost.org/trac/boost/changeset/42314

Log:
simplify call<>, make<>, bind<> interface
Text files modified:
   branches/proto/v3/boost/xpressive/detail/static/grammar.hpp | 2
   branches/proto/v3/boost/xpressive/proto/deep_copy.hpp | 2 +
   branches/proto/v3/boost/xpressive/proto/make_expr.hpp | 2
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 39 +++--------------------------------
   branches/proto/v3/boost/xpressive/proto/transform/bind.hpp | 40 ++++++++++++++++++++++++++----------
   branches/proto/v3/boost/xpressive/proto/transform/call.hpp | 43 ++++++++++++++++++++++++++-------------
   branches/proto/v3/boost/xpressive/proto/transform/make.hpp | 31 +++++++++++++++++++++-------
   branches/proto/v3/boost/xpressive/proto/transform/when.hpp | 8 +++---
   8 files changed, 93 insertions(+), 74 deletions(-)

Modified: branches/proto/v3/boost/xpressive/detail/static/grammar.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/detail/static/grammar.hpp (original)
+++ branches/proto/v3/boost/xpressive/detail/static/grammar.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -536,7 +536,7 @@
         struct DeepCopy
           : or_<
                 when< terminal<attribute_placeholder<_> >, as_read_attr(_arg) >
- , when< terminal<_>, _make_terminal(_arg) >
+ , when< terminal<_>, _deep_copy(_) >
               , otherwise< nary_expr<_, vararg<DeepCopy> > >
>
         {};

Modified: branches/proto/v3/boost/xpressive/proto/deep_copy.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/deep_copy.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/deep_copy.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -41,6 +41,8 @@
     {
         struct deep_copy
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 

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-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -219,7 +219,7 @@
       , BOOST_PP_INC(ARGCOUNT) \
       , BOOST_PROTO_VARARG_FUN_ \
       , (NAME, TAG, BOUNDARGS, DOMAIN) \
- )\
+ ) \
     /**/
 
 /// \code

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-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -483,46 +483,14 @@
         template<typename Fun>
         struct otherwise;
 
- #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
- template<typename Fun, typename... Args>
- struct call;
-
- template<typename Fun, typename... Args>
- struct make;
-
- template<typename Fun, typename... Args>
- struct bind;
- #else
- template<
- typename Fun
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
- BOOST_PROTO_MAX_ARITY
- , typename A
- , = void BOOST_PP_INTERCEPT
- )
- >
+ template<typename Fun>
         struct call;
 
- template<
- typename Fun
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
- BOOST_PROTO_MAX_ARITY
- , typename A
- , = void BOOST_PP_INTERCEPT
- )
- >
+ template<typename Fun>
         struct make;
 
- template<
- typename Fun
- BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
- BOOST_PROTO_MAX_ARITY
- , typename A
- , = void BOOST_PP_INTERCEPT
- )
- >
+ template<typename Fun>
         struct bind;
- #endif
 
         template<typename Sequence, typename State, typename Fun>
         struct fold;
@@ -842,6 +810,7 @@
     typedef functional::flatten _flatten;
     typedef functional::pop_front _pop_front;
     typedef functional::reverse _reverse;
+ typedef functional::deep_copy _deep_copy;
 
     template<typename T>
     struct is_extension;

Modified: branches/proto/v3/boost/xpressive/proto/transform/bind.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/bind.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/bind.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -19,7 +19,7 @@
 
     namespace transform
     {
- template<typename Return, typename... Args>
+ template<typename Fun>
         struct bind : callable
         {
             template<typename Sig>
@@ -29,8 +29,7 @@
             struct result<This(Expr, State, Visitor)>
               : boost::result_of<
                     call<
- typename boost::result_of<make<Return>(Expr, State, Visitor)>::type
- , Args...
+ typename boost::result_of<make<Fun>(Expr, State, Visitor)>::type
>(Expr, State, Visitor)
>
             {};
@@ -40,21 +39,40 @@
             operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
                 return call<
- typename boost::result_of<make<Return>(Expr const &, State const &, Visitor &)>::type
- , Args...
+ typename boost::result_of<make<Fun>(Expr const &, State const &, Visitor &)>::type
>()(expr, state, visitor);
             }
         };
 
- template<typename Fun, typename... Args>
- struct bind<Fun(Args...)>
- : bind<Fun, Args...>
- {};
+ template<typename Return, typename... Args>
+ struct bind<Return(Args...)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : boost::result_of<
+ call<
+ typename boost::result_of<make<Return>(Expr, State, Visitor)>::type(Args...)
+ >(Expr, State, Visitor)
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<bind(Expr const &, State const &, Visitor &)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ return call<
+ typename boost::result_of<make<Return>(Expr const &, State const &, Visitor &)>::type(Args...)
+ >()(expr, state, visitor);
+ }
+ };
 
     }
 
- template<typename Fun, typename... Args>
- struct is_callable<transform::bind<Fun, Args...> >
+ template<typename Fun>
+ struct is_callable<transform::bind<Fun> >
       : mpl::true_
     {};
 

Modified: branches/proto/v3/boost/xpressive/proto/transform/call.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/call.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/call.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -173,7 +173,7 @@
             };
         }
 
- template<typename Fun, typename... Args>
+ template<typename Fun>
         struct call : callable
         {
             template<typename Sig>
@@ -181,9 +181,7 @@
 
             template<typename This, typename Expr, typename State, typename Visitor>
             struct result<This(Expr, State, Visitor)>
- : boost::result_of<
- Fun(typename boost::result_of<when<_, Args>(Expr, State, Visitor)>::type...)
- >
+ : boost::result_of<Fun(Expr, State, Visitor)>
             {};
 
             template<typename Expr, typename State, typename Visitor>
@@ -191,12 +189,12 @@
             operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
                 Fun f;
- return f(when<_, Args>()(expr, state, visitor)...);
+ return f(expr, state, visitor);
             }
         };
 
         template<typename Fun>
- struct call<Fun> : callable
+ struct call<Fun()> : callable
         {
             template<typename Sig>
             struct result;
@@ -224,7 +222,7 @@
         };
 
         template<typename Fun, typename Arg0>
- struct call<Fun, Arg0> : callable
+ struct call<Fun(Arg0)> : callable
         {
             template<typename Sig>
             struct result;
@@ -252,7 +250,7 @@
         };
 
         template<typename Fun, typename Arg0, typename Arg1>
- struct call<Fun, Arg0, Arg1> : callable
+ struct call<Fun(Arg0, Arg1)> : callable
         {
             template<typename Sig>
             struct result;
@@ -280,7 +278,7 @@
         };
 
         template<typename Fun, typename Arg0, typename Arg1, typename Arg2>
- struct call<Fun, Arg0, Arg1, Arg2> : callable
+ struct call<Fun(Arg0, Arg1, Arg2)> : callable
         {
             template<typename Sig>
             struct result;
@@ -310,14 +308,31 @@
         };
 
         template<typename Fun, typename... Args>
- struct call<Fun(Args...)>
- : call<Fun, Args...>
- {};
+ struct call<Fun(Args...)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
+ : boost::result_of<
+ Fun(typename boost::result_of<when<_, Args>(Expr, State, Visitor)>::type...)
+ >
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<call(Expr const &, State const &, Visitor &)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ Fun f;
+ return f(when<_, Args>()(expr, state, visitor)...);
+ }
+ };
 
     }
 
- template<typename Fun, typename... Args>
- struct is_callable<transform::call<Fun, Args...> >
+ template<typename Fun>
+ struct is_callable<transform::call<Fun> >
       : mpl::true_
     {};
 

Modified: branches/proto/v3/boost/xpressive/proto/transform/make.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/make.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/make.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -148,7 +148,7 @@
             }
         }
 
- template<typename Return, typename... Args>
+ template<typename Fun>
         struct make : callable
         {
             template<typename Sig>
@@ -156,6 +156,26 @@
 
             template<typename This, typename Expr, typename State, typename Visitor>
             struct result<This(Expr, State, Visitor)>
+ : detail::make_<Fun, Expr, State, Visitor>
+ {};
+
+ template<typename Expr, typename State, typename Visitor>
+ typename result<make(Expr const &, State const &, Visitor &)>::type
+ operator()(Expr const &expr, State const &state, Visitor &visitor) const
+ {
+ typedef typename result<make(Expr const &, State const &, Visitor &)>::type result_type;
+ return result_type();
+ }
+ };
+
+ template<typename Return, typename... Args>
+ struct make<Return(Args...)> : callable
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Expr, typename State, typename Visitor>
+ struct result<This(Expr, State, Visitor)>
               : detail::make_<Return, Expr, State, Visitor>
             {};
 
@@ -168,15 +188,10 @@
             }
         };
 
- template<typename Fun, typename... Args>
- struct make<Fun(Args...)>
- : make<Fun, Args...>
- {};
-
     }
 
- template<typename Fun, typename... Args>
- struct is_callable<transform::make<Fun, Args...> >
+ template<typename Fun>
+ struct is_callable<transform::make<Fun> >
       : mpl::true_
     {};
 

Modified: branches/proto/v3/boost/xpressive/proto/transform/when.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/transform/when.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/transform/when.hpp 2007-12-27 14:39:35 EST (Thu, 27 Dec 2007)
@@ -63,8 +63,8 @@
           : boost::result_of<
                 typename mpl::if_<
                     is_callable<Return>
- , call<Return, Args...> // "Return" is a function to call
- , make<Return, Args...> // "Return" is an object to construct
+ , call<Return(Args...)> // "Return" is a function to call
+ , make<Return(Args...)> // "Return" is an object to construct
>::type(Expr, State, Visitor)
>
         {};
@@ -75,8 +75,8 @@
         {
             return typename mpl::if_<
                 is_callable<Return>
- , call<Return, Args...>
- , make<Return, Args...>
+ , call<Return(Args...)>
+ , make<Return(Args...)>
>::type()(expr, state, visitor);
         }
     };


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