Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-17 00:20:28


Author: eric_niebler
Date: 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
New Revision: 42114
URL: http://svn.boost.org/trac/boost/changeset/42114

Log:
begin porting to c++03
Added:
   branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp (contents, props changed)
Text files modified:
   branches/proto/v3/boost/xpressive/proto/args.hpp | 305 ++++++++++++++++++++++-----------------
   branches/proto/v3/boost/xpressive/proto/expr.hpp | 2
   branches/proto/v3/boost/xpressive/proto/matches.hpp | 4
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp | 150 ++++++++++++++++++-
   branches/proto/v3/boost/xpressive/proto/traits.hpp | 81 ----------
   5 files changed, 319 insertions(+), 223 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/args.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/args.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/args.hpp 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -1,164 +1,209 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file args.hpp
-/// Contains definition of args\<\> and term\<\> class templates.
-//
-// Copyright 2007 Eric Niebler. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_PROTO_ARGS_HPP_EAN_10_28_2007
-#define BOOST_PROTO_ARGS_HPP_EAN_10_28_2007
-
-#include <utility>
-#include <boost/type_traits.hpp>
-#include <boost/utility/result_of.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/detail/define.hpp>
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file args.hpp
+ /// Contains definition of args\<\> and term\<\> class templates.
+ //
+ // Copyright 2007 Eric Niebler. Distributed under the Boost
+ // Software License, Version 1.0. (See accompanying file
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+ #ifndef BOOST_PROTO_ARGS_HPP_EAN_10_28_2007
+ #define BOOST_PROTO_ARGS_HPP_EAN_10_28_2007
+
+ #include <utility>
+ #include <boost/mpl/assert.hpp>
+ #include <boost/type_traits.hpp>
+ #include <boost/utility/result_of.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/detail/define.hpp>
 
-namespace boost { namespace proto
-{
-
- namespace argsns_
+ namespace boost { namespace proto
     {
 
- template<typename... Args>
- struct args
+ namespace argsns_
         {
- static long const size = sizeof...(Args);
- typedef cons<Args...> cons_type;
- };
 
- template<typename Arg>
- struct term
- {
- static long const size = 0;
- typedef cons<Arg> cons_type;
- };
+ template<>
+ struct args<>
+ {
+ BOOST_STATIC_CONSTANT(long, size = 0);
+ typedef cons<> cons_type;
+ };
 
- template<typename Args>
- struct back;
+ template<typename A>
+ struct term
+ {
+ BOOST_STATIC_CONSTANT(long, size = 0);
+ typedef cons<A> cons_type;
 
- template<typename Head, typename... Tail>
- struct back<args<Head, Tail...> >
- : back<args<Tail...> >
- {};
+ /// INTERNAL ONLY
+ ///
+ typedef A back_;
+ };
 
- template<typename Head>
- struct back<args<Head> >
- {
- typedef Head type;
- };
+ template<>
+ struct cons<>
+ {
+ BOOST_STATIC_CONSTANT(long, size = 0);
+ typedef void car_type;
+ typedef void cdr_type;
+ };
 
- template<typename Head>
- struct back<term<Head> >
- {
- typedef Head type;
- };
+ struct fanout_args_fun
+ {
+ template<typename Sig>
+ struct result;
 
- template<typename Head, typename... Tail>
- struct cons<Head, Tail...>
- {
- static long const size = 1 + sizeof...(Tail);
- typedef Head car_type;
- typedef cons<Tail...> cdr_type;
- car_type car;
- cdr_type cdr;
+ template<typename This, typename Fun, typename... Args>
+ struct result<This(Fun, cons<Args...>)>
+ : boost::result_of<UNCVREF(Fun)(UNCVREF(Args)...)>
+ {};
+
+ template<typename Fun, typename... Args>
+ typename boost::result_of<Fun(Args...)>::type
+ operator()(Fun const &fun, cons<Args...> const &cons) const
+ {
+ typedef typename boost::result_of<Fun(Args...)>::type type;
+ return this->call_<type>(fun, cons.cdr, cons.car);
+ }
+
+ private:
+
+ template<typename Ret, typename Fun, typename Tail, typename... Head>
+ static Ret call_(Fun const &fun, Tail const &cons, Head const &...head)
+ {
+ return call_<Ret>(fun, cons.cdr, head..., cons.car);
+ }
+
+ template<typename Ret, typename Fun, typename... Head>
+ static Ret call_(Fun const &fun, cons<> const &, Head const &... head)
+ {
+ return fun(head...);
+ }
+ };
 
- template<typename Head2, typename... Tail2>
- static cons<Head, Tail...> make(Head2 &&head, Tail2 &&... tail)
- {
- cons<Head, Tail...> that = {head, cdr_type::make(tail...)};
- return that;
- }
- };
+ fanout_args_fun const fanout_args = {};
 
- template<>
- struct cons<>
- {
- static long const size = 0;
- typedef void car_type;
- typedef void cdr_type;
- };
+ #define LBRACE(Z, N, DATA) {
+ #define RBRACE(Z, N, DATA) }
+ #define CDR_TYPE(Z, N, DATA) ::cdr_type
+ #define CAR(Z, N, DATA) typedef BOOST_PP_CAT(A, N) car_type; car_type car; struct BOOST_PP_CAT(S, N) {
+ #define CDR(Z, N, DATA) } cdr; typedef BOOST_PP_CAT(S, BOOST_PP_DEC(BOOST_PP_SUB(DATA, N))) cdr_type;
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/args.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Args>
+ struct args< BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Args... >
+ {
+ BOOST_STATIC_CONSTANT(long, size = BOOST_PROTO_MAX_ARITY + sizeof...(Args));
+ typedef cons<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Args... > cons_type;
+
+ /// INTERNAL ONLY
+ ///
+ typedef typename args<Args...>::back_ back_;
+ };
 
- template<typename Head>
- struct cons<Head>
- {
- static long const size = 1;
- typedef Head car_type;
- typedef cons<> cdr_type;
- car_type car;
- static cdr_type const cdr;
+ template< BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Args>
+ struct cons< BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, A), Args... >
+ {
+ BOOST_STATIC_CONSTANT(long, size = BOOST_PROTO_MAX_ARITY + sizeof...(Args));
+ BOOST_PP_REPEAT(BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), CAR, BOOST_PP_DEC(N))
+ typedef BOOST_PP_CAT(A, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY)) car_type;
+ car_type car;
+ cons<Args...> cdr;
+ typedef cons<Args...> cdr_type;
+ BOOST_PP_REPEAT(BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), CDR, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
+ };
 
- template<typename Head2>
- static cons<Head> make(Head2 &&head)
+ template<typename Cons BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A), typename... Rest >
+ inline Cons make_cons_(BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PROTO_MAX_ARITY, A, &a), Rest &... rest)
             {
- cons<Head> that = {head};
+ Cons that =
+ BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, {a)
+ , argsns_::make_cons_<typename Cons BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, CDR_TYPE, ~)>(rest...)
+ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, RBRACE, ~);
                 return that;
             }
- };
+ #endif
 
- template<typename Head>
- cons<> const cons<Head>::cdr = {};
+ #undef LBRACE
+ #undef RBRACE
+ #undef CDR_TYPE
+ #undef CAR
+ #undef CDR
+
+ struct make_cons_fun
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename... Args>
+ struct result<This(Args...)>
+ {
+ typedef cons<UNCV(Args)...> type;
+ };
+
+ template<typename... Args>
+ cons<UNCV(Args)...> operator()(Args &&... args) const
+ {
+ typedef cons<UNCV(Args)...> cons_type;
+ return argsns_::make_cons_<cons_type>(args...);
+ }
+ };
 
- struct make_cons_fun
- {
- template<typename Sig>
- struct result;
+ make_cons_fun const make_cons = {};
 
- template<typename This, typename... Args>
- struct result<This(Args...)>
- {
- typedef cons<UNCV(Args)...> type;
- };
+ }
 
- template<typename... Args>
- cons<UNCV(Args)...> operator()(Args &&... args) const
- {
- return cons<UNCV(Args)...>::make(args...);
- }
- };
+ }}
 
- make_cons_fun const make_cons = {};
+ #include <boost/xpressive/proto/detail/undef.hpp>
 
- struct fanout_args_fun
- {
- template<typename Sig>
- struct result;
+ #endif
 
- template<typename This, typename Fun, typename... Args>
- struct result<This(Fun, cons<Args...>)>
- : boost::result_of<UNCVREF(Fun)(UNCVREF(Args)...)>
- {};
-
- template<typename Fun, typename... Args>
- typename boost::result_of<Fun(Args...)>::type
- operator()(Fun const &fun, cons<Args...> const &cons) const
- {
- typedef typename boost::result_of<Fun(Args...)>::type type;
- return this->call_<type>(fun, cons.cdr, cons.car);
- }
+#else
 
- private:
+ #define N BOOST_PP_ITERATION()
 
- template<typename Ret, typename Fun, typename... Tail, typename... Head>
- static Ret call_(Fun const &fun, cons<Tail...> const &cons, Head const &...head)
- {
- return call_<Ret>(fun, cons.cdr, head..., cons.car);
- }
+ /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
+ ///
+ /// A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
+ /// The types in the sequence correspond to the children of a node in an expression tree.
+ template< BOOST_PP_ENUM_PARAMS(N, typename A) >
+ struct args< BOOST_PP_ENUM_PARAMS(N, A) >
+ {
+ BOOST_STATIC_CONSTANT(long, size = N);
+ typedef cons< BOOST_PP_ENUM_PARAMS(N, A) > cons_type;
 
- template<typename Ret, typename Fun, typename... Head>
- static Ret call_(Fun const &fun, cons<> const &, Head const &... head)
- {
- return fun(head...);
- }
+ /// INTERNAL ONLY
+ ///
+ typedef BOOST_PP_CAT(A, BOOST_PP_DEC(N)) back_;
         };
 
- fanout_args_fun const fanout_args = {};
+ template< BOOST_PP_ENUM_PARAMS(N, typename A) >
+ struct cons< BOOST_PP_ENUM_PARAMS(N, A) >
+ {
+ BOOST_STATIC_CONSTANT(long, size = N);
+ BOOST_PP_REPEAT(BOOST_PP_DEC(N), CAR, BOOST_PP_DEC(N))
+ typedef BOOST_PP_CAT(A, BOOST_PP_DEC(N)) car_type;
+ car_type car;
+ static cons<> const cdr;
+ typedef cons<> cdr_type;
+ BOOST_PP_REPEAT(BOOST_PP_DEC(N), CDR, BOOST_PP_DEC(N))
+ };
 
- }
+ template< BOOST_PP_ENUM_PARAMS(N, typename A) >
+ cons<> const cons< BOOST_PP_ENUM_PARAMS(N, A) > BOOST_PP_REPEAT(BOOST_PP_DEC(N), CDR_TYPE, ~) ::cdr = {};
 
-}}
+ template<typename Cons BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A) >
+ inline Cons make_cons_(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
+ {
+ Cons that = BOOST_PP_ENUM_PARAMS(N, {a) BOOST_PP_REPEAT(N, RBRACE, ~);
+ return that;
+ }
 
-#include <boost/xpressive/proto/detail/undef.hpp>
+ #undef N
 
 #endif

Added: branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/apply_args.hpp 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -0,0 +1,150 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file apply_args.hpp
+ /// Definintion of the pass-through transforms
+ //
+ // Copyright 2007 Eric Niebler. Distributed under the Boost
+ // Software License, Version 1.0. (See accompanying file
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+ #ifndef BOOST_PROTO_DETAIL_APPLY_ARGS_HPP_EAN_11_07_2007
+ #define BOOST_PROTO_DETAIL_APPLY_ARGS_HPP_EAN_11_07_2007
+
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/detail/define.hpp>
+
+ namespace boost { namespace proto { namespace op
+ {
+ namespace detail
+ {
+
+ template<typename E, typename S, typename V, typename G>
+ struct apply_args;
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<typename A0, typename A1>
+ struct cat_args;
+
+ template<typename... A0, typename... A1>
+ struct cat_args<args<A0...>, args<A1...> >
+ {
+ typedef args<A0..., A1...> type;
+ };
+
+ template<typename... G>
+ struct pad_args
+ {
+ typedef args<G...> type;
+ };
+
+ template<
+ BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename E)
+ , typename... ERest
+ , typename S
+ , typename V
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename G)
+ , typename... GRest
+ >
+ struct apply_args<
+ args<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, E), ERest...>
+ , S
+ , V
+ , args<
+ BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, G)
+ , GRest...
+ >
+ >
+ {
+ #define TMP(Z, N, DATA) typename boost::result_of<G##N(UNCVREF(E##N), S, V)>::type
+ typedef typename cat_args<
+ args<BOOST_PP_ENUM(BOOST_PROTO_MAX_ARITY, TMP, ~) >
+ , typename apply_args<args<ERest...>, S, V, typename pad_args<GRest...>::type>::type
+ >::type type;
+ #undef TMP
+
+ template<typename Cons>
+ static typename type::cons_type call(Cons const &a, S const &s, V &v)
+ {
+ #define TMP0(Z, N, DATA) .cdr
+ #define TMP1(Z, N, DATA) {G##N()(a BOOST_PP_REPEAT_ ## Z(N, TMP0, ~) .car, s, v)
+ #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)
+ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP2, ~);
+ #undef TMP0
+ #undef TMP1
+ #undef TMP2
+ return that;
+ }
+ };
+
+ #endif
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/apply_args.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ }
+ }}}
+
+ #include <boost/xpressive/proto/detail/undef.hpp>
+ #endif
+
+#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)>
+ {
+ #define TMP(Z, N, DATA) , BOOST_PP_CAT(G, BOOST_PP_DEC(BOOST_PP_ITERATION()))
+ typedef args<
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), G)
+ BOOST_PP_REPEAT_FROM_TO(BOOST_PP_ITERATION(), BOOST_PROTO_MAX_ARITY, TMP, ~)
+ > type;
+ #undef TMP
+ };
+ #endif
+
+ template<
+ BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), typename E)
+ , typename S
+ , typename V
+ BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename G)
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ , typename... GRest
+ #endif
+ >
+ struct apply_args<
+ args<BOOST_PP_ENUM_PARAMS(BOOST_PP_ITERATION(), E)>
+ , S
+ , V
+ , args<
+ BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, G)
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ , GRest...
+ #endif
+ >
+ >
+ {
+ #define TMP(Z, N, DATA) typename boost::result_of<G##N(UNCVREF(E##N), S, V)>::type
+ typedef args<BOOST_PP_ENUM(BOOST_PP_ITERATION(), TMP, ~)> type;
+ #undef TMP
+
+ template<typename Cons>
+ static typename type::cons_type call(Cons const &a, S const &s, V &v)
+ {
+ #define TMP0(Z, N, DATA) .cdr
+ #define TMP1(Z, N, DATA) {G##N()(a BOOST_PP_REPEAT_ ## Z(N, TMP0, ~) .car, s, v)
+ #define TMP2(Z, N, DATA) }
+ typename type::cons_type that =
+ BOOST_PP_ENUM(BOOST_PP_ITERATION(), TMP1, ~)
+ BOOST_PP_REPEAT(BOOST_PP_ITERATION(), TMP2, ~);
+ return that;
+ #undef TMP0
+ #undef TMP1
+ #undef TMP2
+ }
+ };
+
+#endif

Modified: branches/proto/v3/boost/xpressive/proto/expr.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/expr.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/expr.hpp 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -73,7 +73,7 @@
             template<typename... A>
             static expr make(A &&... a)
             {
- expr that = {Args::cons_type::make(a...)};
+ expr that = {argsns_::make_cons_<typename Args::cons_type>(a...)};
                 return that;
             }
 

Modified: branches/proto/v3/boost/xpressive/proto/matches.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/matches.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/matches.hpp 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -239,7 +239,7 @@
             template<
                 typename Args1
               , typename Args2
- , bool IsVararg = control::detail::is_vararg<typename back<Args2>::type>::value
+ , bool IsVararg = control::detail::is_vararg<typename Args2::back_>::value
>
             struct vararg_matches
               : mpl::false_
@@ -473,7 +473,7 @@
         };
 
         template<typename... Alts>
- struct and_ : back<args<Alts...> >::type
+ struct and_ : args<Alts...>::back_
         {
             typedef and_ proto_base_expr;
         };

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-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -10,21 +10,33 @@
 #define BOOST_PROTO_PROTO_FWD_EAN_10_28_2007
 
 #include <climits> // for INT_MAX
+#include <boost/config.hpp>
+#include <boost/preprocessor.hpp>
 #include <boost/type_traits.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/long.hpp>
 #include <boost/mpl/aux_/template_arity.hpp>
 #include <boost/mpl/aux_/lambda_arity_param.hpp>
 
+#ifndef BOOST_PROTO_MAX_ARITY
+# define BOOST_PROTO_MAX_ARITY 5
+#endif
+
+#ifndef BOOST_PROTO_MAX_LOGICAL_ARITY
+# define BOOST_PROTO_MAX_LOGICAL_ARITY 8
+#endif
+
 namespace boost { namespace proto
 {
     namespace detail
     {
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
         template<int... I>
         struct indices;
 
         template<int N, typename T = indices<> >
         struct make_indices;
+ #endif
     }
 
     namespace wildns_
@@ -69,22 +81,26 @@
 
     namespace argsns_
     {
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
         template<typename... Args>
         struct cons;
 
         template<typename... Args>
         struct args;
+ #else
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void), typename Dummy = void>
+ struct cons;
+
+ template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void), typename Dummy = void>
+ struct args;
+ #endif
 
         template<typename Arg>
         struct term;
-
- template<typename Args>
- struct back;
     }
 
     using argsns_::args;
     using argsns_::term;
- using argsns_::back;
 
     namespace exprns_
     {
@@ -200,17 +216,39 @@
         template<typename T, typename EnableIf = void>
         struct domain_of;
 
+ template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename EnableIf = void>
+ struct unpack_arg;
+
+ template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename EnableIf = void>
+ struct unpack_expr;
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
         template<typename Tag, typename... Args>
         struct make_arg;
 
- template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename _ = void>
- struct unpack_arg;
-
         template<typename Tag, typename... Args>
         struct make_expr;
+ #else
+ template<
+ typename Tag
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct make_arg;
 
- template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename _ = void>
- struct unpack_expr;
+ template<
+ typename Tag
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct make_expr;
+ #endif
     }
 
     using result_of::matches;
@@ -227,9 +265,19 @@
     typename result_of::arg_c<Expr const, N>::type
     arg_c(Expr const &expr);
 
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
     template<typename T>
     typename result_of::as_arg<T>::type
     as_arg(T &&t);
+ #else
+ template<typename T>
+ typename result_of::as_arg<T &>::type
+ as_arg(T &t);
+
+ template<typename T>
+ typename result_of::as_arg<T const &>::type
+ as_arg(T const &t);
+ #endif
 
     namespace op
     {
@@ -277,10 +325,30 @@
         template<typename T, typename U> struct bitwise_xor_assign;
         template<typename T, typename U> struct subscript;
         template<typename T, typename U, typename V> struct if_else_;
- template<typename... Args> struct function;
         template<typename Tag, typename T> struct unary_expr;
         template<typename Tag, typename T, typename U> struct binary_expr;
+
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ template<typename... Args> struct function;
         template<typename Tag, typename... Args> struct nary_expr;
+ #else
+ template<
+ BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)
+ , typename Dummy = void
+ >
+ struct function;
+
+ template<
+ typename Tag
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = void BOOST_PP_INTERCEPT
+ )
+ , typename Dummy = void
+ >
+ struct nary_expr;
+ #endif
     }
 
     using namespace op;
@@ -293,11 +361,35 @@
             struct is_vararg;
         }
 
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
         template<typename... Alts>
         struct or_;
 
         template<typename... Alts>
         struct and_;
+ #else
+ template<
+ typename Grammar0
+ , typename Grammar1
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2)
+ , typename G
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct or_;
+
+ template<
+ typename Grammar0
+ , typename Grammar1
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2)
+ , typename G
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct and_;
+ #endif
 
         template<typename Grammar>
         struct not_;
@@ -351,6 +443,7 @@
         template<typename Fun>
         struct otherwise;
 
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
         template<typename Fun, typename... Args>
         struct call;
 
@@ -359,6 +452,37 @@
 
         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
+ )
+ >
+ struct call;
+
+ template<
+ typename Fun
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct make;
+
+ template<
+ typename Fun
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+ BOOST_PROTO_MAX_ARITY
+ , typename A
+ , = void BOOST_PP_INTERCEPT
+ )
+ >
+ struct bind;
+ #endif
 
         template<typename Sequence, typename State, typename Fun>
         struct fold;
@@ -443,10 +567,12 @@
         template<typename Derived, typename DefaultCtx = default_context>
         struct callable_context;
 
- template<typename Expr, typename Context,
- typename Indices = typename proto::detail::make_indices<
+ template<typename Expr, typename Context
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
+ , typename Indices = typename proto::detail::make_indices<
                 Expr::proto_arity == 0 ? 1 : Expr::proto_arity
>::type
+ #endif
>
         struct callable_eval;
     }

Modified: branches/proto/v3/boost/xpressive/proto/traits.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/traits.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/traits.hpp 2007-12-17 00:20:26 EST (Mon, 17 Dec 2007)
@@ -13,6 +13,7 @@
 #include <boost/mpl/logical.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/args.hpp>
+#include <boost/xpressive/proto/detail/apply_args.hpp>
 #include <boost/xpressive/proto/detail/define.hpp>
 
 namespace boost { namespace proto
@@ -20,83 +21,6 @@
 
     namespace op
     {
-
- namespace detail
- {
- using argsns_::cons;
-
- template<typename G, typename E, typename S, typename V>
- struct apply_args;
-
- template<typename G, typename E, typename S, typename V>
- struct apply_args<args<G>, args<E>, S, V>
- {
- typedef args<
- typename boost::result_of<G(UNCVREF(E), S, V)>::type
- > type;
-
- static typename type::cons_type
- call(cons<E> const &a, S const &s, V &v)
- {
- typename type::cons_type that = {G()(a.car, s, v)};
- return that;
- }
- };
-
- template<typename G1, typename... G2, typename E1, typename... E2, typename S, typename V>
- struct apply_args<args<G1, G2...>, args<E1, E2...>, S, V>
- {
- typedef args<
- typename boost::result_of<G1(UNCVREF(E1), S, V)>::type
- , typename boost::result_of<G2(UNCVREF(E2), S, V)>::type...
- > type;
-
- static typename type::cons_type
- call(cons<E1, E2...> const &a, S const &s, V &v)
- {
- typename type::cons_type that = {
- G1()(a.car, s, v)
- , apply_args<args<G2...>, args<E2...>, S, V>::call(a.cdr, s, v)
- };
- return that;
- }
- };
-
- template<typename G, typename E1, typename... E2, typename S, typename V>
- struct apply_args<args<G>, args<E1, E2...>, S, V>
- {
- typedef args<
- typename boost::result_of<G(UNCVREF(E1), S, V)>::type
- , typename boost::result_of<G(UNCVREF(E2), S, V)>::type...
- > type;
-
- static typename type::cons_type
- call(cons<E1, E2...> const &a, S const &s, V &v)
- {
- typename type::cons_type that = {
- G()(a.car, s, v)
- , apply_args<args<G>, args<E2...>, S, V>::call(a.cdr, s, v)
- };
- return that;
- }
- };
-
- template<typename G1, typename... G2, typename E, typename S, typename V>
- struct apply_args<args<G1, G2...>, args<E>, S, V>
- {
- typedef args<
- typename boost::result_of<G1(UNCVREF(E), S, V)>::type
- > type;
-
- static typename type::cons_type
- call(cons<E> const &a, S const &s, V &v)
- {
- typename type::cons_type that = {G1()(a.car, s, v)};
- return that;
- }
- };
- }
-
         template<typename T>
         struct terminal
         {
@@ -237,7 +161,8 @@
             template<typename This, typename Expr, typename State, typename Visitor>
             struct result<This(Expr, State, Visitor)>
             {
- typedef detail::apply_args<args<Args...>, UNREF(Expr)::proto_args, State, Visitor> apply_;
+ typedef typename detail::pad_args<Args...>::type padded_args;
+ typedef detail::apply_args<UNREF(Expr)::proto_args, State, Visitor, padded_args> apply_;
                 typedef expr<UNREF(Expr)::proto_tag, typename apply_::type> type;
             };
 


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