$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: eric_at_[hidden]
Date: 2007-12-28 03:27:42
Author: eric_niebler
Date: 2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
New Revision: 42320
URL: http://svn.boost.org/trac/boost/changeset/42320
Log:
port call<>, make<> and bind<> to c++03, misc bug/portability fixes
Added:
   branches/proto/v3/boost/xpressive/proto/detail/as_lvalue.hpp   (contents, props changed)
   branches/proto/v3/boost/xpressive/proto/detail/bind.hpp   (contents, props changed)
   branches/proto/v3/boost/xpressive/proto/detail/call.hpp   (contents, props changed)
   branches/proto/v3/boost/xpressive/proto/detail/make.hpp   (contents, props changed)
   branches/proto/v3/boost/xpressive/proto/detail/when.hpp   (contents, props changed)
Text files modified: 
   branches/proto/v3/boost/xpressive/detail/static/grammar.hpp |     2                                         
   branches/proto/v3/boost/xpressive/proto/args.hpp            |    14 +++--                                   
   branches/proto/v3/boost/xpressive/proto/expr.hpp            |     2                                         
   branches/proto/v3/boost/xpressive/proto/extends.hpp         |    20 +++++---                                
   branches/proto/v3/boost/xpressive/proto/matches.hpp         |    25 ++++-------                             
   branches/proto/v3/boost/xpressive/proto/proto.hpp           |     2                                         
   branches/proto/v3/boost/xpressive/proto/proto_fwd.hpp       |    11 ++--                                    
   branches/proto/v3/boost/xpressive/proto/traits.hpp          |    16 +++---                                  
   branches/proto/v3/boost/xpressive/proto/transform/bind.hpp  |     5 +                                       
   branches/proto/v3/boost/xpressive/proto/transform/call.hpp  |    25 ++++------                              
   branches/proto/v3/boost/xpressive/proto/transform/make.hpp  |    90 +++++++++++++++++++++++++++++++++++---- 
   branches/proto/v3/boost/xpressive/proto/transform/when.hpp  |     4 +                                       
   12 files changed, 143 insertions(+), 73 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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -375,7 +375,7 @@
         };
 
         template<typename T>
-        T &uncv(T const volatile &t)
+        T &uncv(T const &t)
         {
             return const_cast<T &>(t);
         }
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -101,10 +101,10 @@
 
             namespace detail
             {
-                template<typename Cons, typename T, std::size_t N>
+                template<typename Cons, typename T>
                 struct make_cons_array
                 {
-                    static Cons make(T (&t)[N])
+                    static Cons make(T &t)
                     {
                         Cons that = {t};
                         return that;
@@ -112,7 +112,7 @@
                 };
 
                 template<typename U, typename T, std::size_t N>
-                struct make_cons_array<cons<U[N]>, T, N>
+                struct make_cons_array<cons<U[N]>, T[N]>
                 {
                     static cons<U[N]> make(T (&t)[N])
                     {
@@ -126,10 +126,10 @@
                 };
             }
 
-            template<typename Cons, typename T, std::size_t N>
-            inline Cons make_cons_(T (&t)[N])
+            template<typename Cons, typename T>
+            inline Cons make_cons_(T &t)
             {
-                return argsns_::detail::make_cons_array<Cons, T, N>::make(t);
+                return argsns_::detail::make_cons_array<Cons, T>::make(t);
             }
 
         }
@@ -174,12 +174,14 @@
         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 = {};
 
+        #if N > 1
         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;
         }
+        #endif
 
     #undef N
 
Added: branches/proto/v3/boost/xpressive/proto/detail/as_lvalue.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/as_lvalue.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -0,0 +1,36 @@
+///////////////////////////////////////////////////////////////////////////////
+/// \file as_lvalue.hpp
+/// Contains definition of the call<> transform.
+//
+//  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_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007
+#define BOOST_PROTO_TRANSFORM_AS_LVALUE_HPP_EAN_12_27_2007
+
+namespace boost { namespace proto
+{
+    namespace detail
+    {
+        template<typename T>
+        T &as_lvalue(T &t)
+        {
+            return t;
+        }
+
+        template<typename T>
+        T const &as_lvalue(T const &t)
+        {
+            return t;
+        }
+
+        template<typename T>
+        T &uncv(T const &t)
+        {
+            return const_cast<T &>(t);
+        }
+    }
+}}
+
+#endif
Added: branches/proto/v3/boost/xpressive/proto/detail/bind.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/bind.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -0,0 +1,44 @@
+#ifndef BOOST_PP_IS_ITERATING
+    ///////////////////////////////////////////////////////////////////////////////
+    /// \file bind.hpp
+    /// Contains definition of the bind<> transform.
+    //
+    //  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)
+
+    #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/bind.hpp>))
+    #include BOOST_PP_ITERATE()
+
+#else
+
+    #define N BOOST_PP_ITERATION()
+
+        template<typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        struct bind<Return(BOOST_PP_ENUM_PARAMS(N, A))> : 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(BOOST_PP_ENUM_PARAMS(N, A))
+                    >(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(BOOST_PP_ENUM_PARAMS(N, A))
+                >()(expr, state, visitor);
+            }
+        };
+
+    #undef N
+
+#endif
Added: branches/proto/v3/boost/xpressive/proto/detail/call.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/call.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -0,0 +1,47 @@
+#ifndef BOOST_PP_IS_ITERATING
+    ///////////////////////////////////////////////////////////////////////////////
+    /// \file call.hpp
+    /// Contains definition of the call<> transform.
+    //
+    //  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)
+
+    #if BOOST_PROTO_MAX_ARITY > 3
+    #define BOOST_PP_ITERATION_PARAMS_1 (3, (4, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/call.hpp>))
+    #include BOOST_PP_ITERATE()
+    #endif
+
+#else
+
+    #define N BOOST_PP_ITERATION()
+
+        template<typename Fun BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        struct call<Fun(BOOST_PP_ENUM_PARAMS(N, A))> : callable
+        {
+            template<typename Sig>
+            struct result;
+
+            template<typename This, typename Expr, typename State, typename Visitor>
+            struct result<This(Expr, State, Visitor)>
+              : boost::result_of<
+                    #define TMP(Z, M, DATA) typename boost::result_of<when<_, BOOST_PP_CAT(A, M)>(Expr, State, Visitor)>::type
+                    Fun(BOOST_PP_ENUM(N, TMP, ~))
+                    #undef TMP
+                >
+            {};
+
+            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;
+                #define TMP(Z, M, DATA) when<_, BOOST_PP_CAT(A, M)>()(expr, state, visitor)
+                return f(BOOST_PP_ENUM(N, TMP, ~));
+                #undef TMP
+            }
+        };
+
+    #undef N
+
+#endif
Added: branches/proto/v3/boost/xpressive/proto/detail/make.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/make.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -0,0 +1,99 @@
+#ifndef BOOST_PP_IS_ITERATING
+    ///////////////////////////////////////////////////////////////////////////////
+    /// \file make.hpp
+    /// Contains definition of the make<> transform.
+    //
+    //  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)
+
+    #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/make.hpp>))
+    #include BOOST_PP_ITERATE()
+
+#else
+
+    #define N BOOST_PP_ITERATION()
+
+        namespace detail
+        {
+            #if N > 0
+            template<typename T BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+            struct nested_type_if<
+                T
+              , typelist<BOOST_PP_ENUM_PARAMS(N, A)>
+              , typename typelist<
+                    BOOST_PP_ENUM_BINARY_PARAMS(N, typename A, ::not_applied_ BOOST_PP_INTERCEPT)
+                >::type
+            >
+            {
+                typedef T type;
+                typedef void not_applied_;
+            };
+
+            template<
+                template<BOOST_PP_ENUM_PARAMS(N, typename BOOST_PP_INTERCEPT)> class R
+                BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+              , typename Expr, typename State, typename Visitor
+            >
+            struct make_<R<BOOST_PP_ENUM_PARAMS(N, A)>, Expr, State, Visitor>
+              : nested_type_if<
+                    #define TMP0(Z, M, DATA) make_if_<BOOST_PP_CAT(A, M), Expr, State, Visitor>
+                    #define TMP1(Z, M, DATA) typename TMP0(Z, M, DATA) ::type
+                    R<BOOST_PP_ENUM(N, TMP1, ~)>
+                  , typelist<BOOST_PP_ENUM(N, TMP0, ~) >
+                    #undef TMP0
+                    #undef TMP1
+                >
+            {};
+            #endif
+
+            template<
+                typename R
+                BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+              , typename Expr, typename State, typename Visitor
+            >
+            struct make_if_<R(BOOST_PP_ENUM_PARAMS(N, A)), Expr, State, Visitor, false>
+              : remove_const<typename remove_reference<
+                    typename boost::result_of<when<_, R(BOOST_PP_ENUM_PARAMS(N, A))>(Expr, State, Visitor)>::type
+                >::type>
+            {};
+
+            template<
+                typename R
+                BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)
+              , typename Expr, typename State, typename Visitor
+            >
+            struct make_if_<R(*)(BOOST_PP_ENUM_PARAMS(N, A)), Expr, State, Visitor, false>
+              : remove_const<typename remove_reference<
+                    typename boost::result_of<when<_, R(BOOST_PP_ENUM_PARAMS(N, A))>(Expr, State, Visitor)>::type
+                >::type>
+            {};
+        }
+
+        template<typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        struct make<Return(BOOST_PP_ENUM_PARAMS(N, A))> : 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>
+            {};
+
+            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 detail::construct<result_type>(
+                    #define TMP(Z, M, DATA) detail::as_lvalue(when<_, BOOST_PP_CAT(A, M)>()(expr, state, visitor))
+                    BOOST_PP_ENUM(N, TMP, DATA)
+                    #undef TMP
+                );
+            }
+        };
+
+    #undef N
+
+#endif
Added: branches/proto/v3/boost/xpressive/proto/detail/when.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/when.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -0,0 +1,57 @@
+#ifndef BOOST_PP_IS_ITERATING
+    ///////////////////////////////////////////////////////////////////////////////
+    /// \file when.hpp
+    /// Contains definition of the when<> transform.
+    //
+    //  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)
+
+    #define BOOST_PP_ITERATION_PARAMS_1 (3, (0, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/detail/when.hpp>))
+    #include BOOST_PP_ITERATE()
+
+#else
+
+    #define N BOOST_PP_ITERATION()
+
+    template<typename Grammar, typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+    struct when<Grammar, Return(*)(BOOST_PP_ENUM_PARAMS(N, A))>
+      : when<Grammar, Return(BOOST_PP_ENUM_PARAMS(N, A))>
+    {};
+
+    template<typename Grammar, typename Return BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+    struct when<Grammar, Return(BOOST_PP_ENUM_PARAMS(N, A))>
+      : callable, detail::vararg_if<Grammar>
+    {
+        typedef Return when_function_type_(BOOST_PP_ENUM_PARAMS(N, A));
+        typedef typename Grammar::proto_base_expr proto_base_expr;
+
+        template<typename Sig>
+        struct result;
+
+        template<typename This, typename Expr, typename State, typename Visitor>
+        struct result<This(Expr, State, Visitor)>
+          : boost::result_of<
+                typename mpl::if_<
+                    is_callable<Return>
+                  , call<when_function_type_> // "Return" is a function to call
+                  , make<when_function_type_> // "Return" is an object to construct
+                >::type(Expr, State, Visitor)
+            >
+        {};
+
+        template<typename Expr, typename State, typename Visitor>
+        typename result<when(Expr const &, State const &, Visitor &)>::type
+        operator()(Expr const &expr, State const &state, Visitor &visitor) const
+        {
+            return typename mpl::if_<
+                is_callable<Return>
+              , call<when_function_type_>
+              , make<when_function_type_>
+            >::type()(expr, state, visitor);
+        }
+    };
+
+    #undef N
+
+#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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -227,7 +227,7 @@
         /// construct
         ///
         template<typename Expr, typename A>
-        inline Expr construct(A const &a)
+        inline Expr construct(A const &a, typename boost::disable_if<is_function<A> >::type * = 0)
         {
             typedef typename Expr::proto_args::cons_type cons_type;
             Expr that = {proto::argsns_::make_cons_<cons_type>(a)};
Modified: branches/proto/v3/boost/xpressive/proto/extends.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/extends.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/extends.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -254,18 +254,22 @@
         /// INTERNAL ONLY
         ///
     #define BOOST_PROTO_EXTENDS_FUNCTION_IMPL_9(Const)                                              \
-        typename boost::proto::result_of::make_expr_ref<                                            \
-            boost::proto::tag::function                                                             \
-          , proto_domain                                                                            \
-          , proto_derived_expr BOOST_PROTO_CONST ## Const &                                         \
+        typename boost::mpl::apply_wrap1<                                                           \
+            proto_domain                                                                            \
+          , boost::proto::expr<                                                                     \
+                boost::proto::tag::function                                                         \
+              , boost::proto::args<proto_derived_expr BOOST_PROTO_CONST ## Const &>                 \
+            >                                                                                       \
         >::type const                                                                               \
         operator ()() BOOST_PROTO_CONST ## Const                                                    \
         {                                                                                           \
-            return boost::proto::result_of::make_expr_ref<                                          \
+            typedef boost::proto::expr<                                                             \
                 boost::proto::tag::function                                                         \
-              , proto_domain                                                                        \
-              , proto_derived_expr BOOST_PROTO_CONST ## Const &                                     \
-            >::call(*static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this));           \
+              , boost::proto::args<proto_derived_expr BOOST_PROTO_CONST ## Const &>                 \
+            > expr_type;                                                                            \
+            return proto_domain::make(boost::proto::construct<expr_type>(                           \
+                *static_cast<proto_derived_expr BOOST_PROTO_CONST ## Const *>(this)                 \
+            ));                                                                                     \
         }
 
         /// INTERNAL ONLY
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -14,6 +14,7 @@
 #include <boost/mpl/void.hpp>
 #include <boost/mpl/apply.hpp>
 #include <boost/mpl/assert.hpp>
+#include <boost/mpl/print.hpp>
 #include <boost/mpl/identity.hpp>
 #include <boost/mpl/eval_if.hpp>
 #include <boost/type_traits.hpp>
@@ -100,10 +101,7 @@
             template<typename T, typename U
                 BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity = mpl::aux::template_arity<U>::value)
             >
-            struct lambda_matches;
-
-            template<typename T, typename U>
-            struct lambda_matches_aux_
+            struct lambda_matches
               : mpl::false_
             {};
 
@@ -112,8 +110,9 @@
                 template<typename, typename...> class T
               , typename E0, typename... ET
               , typename G0, typename... GT
+                BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long N)
             >
-            struct lambda_matches_aux_<T<E0, ET...>, T<G0, GT...> >
+            struct lambda_matches<T<E0, ET...>, T<G0, GT...> BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)>
               : and_<
                     lambda_matches<E0, G0>::value
                   , lambda_matches<ET, GT>...
@@ -127,7 +126,11 @@
               , BOOST_PP_ENUM_PARAMS_Z(Z, N, typename E)                                            \
               , BOOST_PP_ENUM_PARAMS_Z(Z, N, typename G)                                            \
             >                                                                                       \
-            struct lambda_matches_aux_<T<BOOST_PP_ENUM_PARAMS_Z(Z, N, E)>, T<BOOST_PP_ENUM_PARAMS_Z(Z, N, G)> >\
+            struct lambda_matches<                                                                  \
+                T<BOOST_PP_ENUM_PARAMS_Z(Z, N, E)>                                                  \
+              , T<BOOST_PP_ENUM_PARAMS_Z(Z, N, G)>                                                  \
+                BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(N)                                                 \
+            >                                                                                       \
               : and_<                                                                               \
                     lambda_matches<E0, G0>::value                                                   \
                     BOOST_PP_REPEAT_ ## Z(N, TMP0, ~)                                               \
@@ -139,16 +142,6 @@
         #undef TMP1
         #endif
 
-            template<typename T, typename U BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(long Arity)>
-            struct lambda_matches
-              : lambda_matches_aux_<T, U>
-            {};
-
-            template<typename T, typename U>
-            struct lambda_matches<T, U BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
-              : mpl::false_
-            {};
-
             template<typename T>
             struct lambda_matches<T, _ BOOST_MPL_AUX_LAMBDA_ARITY_PARAM(-1)>
               : mpl::true_
Modified: branches/proto/v3/boost/xpressive/proto/proto.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/proto.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto/proto.hpp	2007-12-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -14,7 +14,7 @@
 #include <boost/xpressive/proto/tags.hpp>
 #include <boost/xpressive/proto/eval.hpp>
 #include <boost/xpressive/proto/expr.hpp>
-#include <boost/xpressive/proto/debug.hpp>
+//#include <boost/xpressive/proto/debug.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/domain.hpp>
 #include <boost/xpressive/proto/matches.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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -13,6 +13,7 @@
 #include <boost/config.hpp>
 #include <boost/preprocessor.hpp>
 #include <boost/type_traits.hpp>
+#include <boost/utility/enable_if.hpp>
 #include <boost/mpl/bool.hpp>
 #include <boost/mpl/long.hpp>
 #include <boost/mpl/aux_/template_arity.hpp>
@@ -127,7 +128,7 @@
         struct is_proto_expr;
 
         template<typename Expr, typename A>
-        Expr construct(A const &a);
+        Expr construct(A const &a, typename boost::disable_if<is_function<A> >::type * = 0);
 
     #ifdef BOOST_HAS_VARIADIC_TMPL
         template<typename Expr, typename... A>
@@ -255,7 +256,7 @@
         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)
+        #ifdef BOOST_HAS_VARIADIC_TMPL
         template<typename Tag, typename... Args>
         struct make_expr_ref;
 
@@ -299,20 +300,20 @@
 
     template<long N, typename Expr>
     typename result_of::arg_c<Expr, N>::type
-    arg_c(Expr &expr);
+    arg_c(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr));
 
     template<long N, typename Expr>
     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)
+    #ifdef BOOST_HAS_RVALUE_REFS
     template<typename T>
     typename result_of::as_expr_ref<T>::type const
     as_expr_ref(T &&t);
     #else
     template<typename T>
     typename result_of::as_expr_ref<T &>::type const
-    as_expr_ref(T &t);
+    as_expr_ref(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T));
 
     template<typename T>
     typename result_of::as_expr_ref<T const &>::type const
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -404,7 +404,7 @@
     }
 
     template<typename Expr>
-    typename result_of::arg<Expr>::type arg(Expr &expr)
+    typename result_of::arg<Expr>::type arg(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
     {
         return result_of::arg<Expr>::call(expr.proto_base().proto_args_);
     }
@@ -416,7 +416,7 @@
     }
 
     template<typename Expr>
-    typename result_of::left<Expr>::type left(Expr &expr)
+    typename result_of::left<Expr>::type left(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
     {
         return result_of::left<Expr>::call(expr.proto_base().proto_args_);
     }
@@ -428,7 +428,7 @@
     }
 
     template<typename Expr>
-    typename result_of::right<Expr>::type right(Expr &expr)
+    typename result_of::right<Expr>::type right(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
     {
         return result_of::right<Expr>::call(expr.proto_base().proto_args_);
     }
@@ -440,7 +440,7 @@
     }
 
     template<long N, typename Expr>
-    typename result_of::arg_c<Expr, N>::type arg_c(Expr &expr)
+    typename result_of::arg_c<Expr, N>::type arg_c(Expr &expr BOOST_PROTO_DISABLE_IF_IS_CONST(Expr))
     {
         return result_of::arg_c<Expr, N>::call(expr.proto_base().proto_args_);
     }
@@ -477,13 +477,13 @@
     }
 #else
     template<typename T>
-    typename result_of::as_expr<T &>::type const as_expr(T &t)
+    typename result_of::as_expr<T &>::type const as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T))
     {
         return result_of::as_expr<T &>::call(t);
     }
 
     template<typename Domain, typename T>
-    typename result_of::as_expr<T &, Domain>::type const as_expr(T &t)
+    typename result_of::as_expr<T &, Domain>::type const as_expr(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T))
     {
         return result_of::as_expr<T &, Domain>::call(t);
     }
@@ -501,13 +501,13 @@
     }
 
     template<typename T>
-    typename result_of::as_expr_ref<T &>::type const as_expr_ref(T &t)
+    typename result_of::as_expr_ref<T &>::type const as_expr_ref(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T))
     {
         return result_of::as_expr_ref<T &>::call(t);
     }
 
     template<typename Domain, typename T>
-    typename result_of::as_expr_ref<T &, Domain>::type const as_expr_ref(T &t)
+    typename result_of::as_expr_ref<T &, Domain>::type const as_expr_ref(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T))
     {
         return result_of::as_expr_ref<T &, Domain>::call(t);
     }
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -44,6 +44,7 @@
             }
         };
 
+        #ifdef BOOST_HAS_VARIADIC_TMPL
         template<typename Return, typename... Args>
         struct bind<Return(Args...)> : callable
         {
@@ -68,7 +69,9 @@
                 >()(expr, state, visitor);
             }
         };
-
+        #else
+        #include <boost/xpressive/proto/detail/bind.hpp>
+        #endif
     }
 
     template<typename Fun>
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -13,6 +13,7 @@
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/detail/dont_care.hpp>
+#include <boost/xpressive/proto/detail/as_lvalue.hpp>
 #include <boost/xpressive/proto/detail/define.hpp>
 
 namespace boost { namespace proto
@@ -22,12 +23,7 @@
     {
         namespace detail
         {
-            template<typename T>
-            T &uncv(T const &t)
-            {
-                return const_cast<T &>(t);
-            }
-
+            using proto::detail::uncv;
             using proto::detail::dont_care;
             typedef char (&yes_type)[2];
             typedef char no_type;
@@ -107,8 +103,7 @@
             {
                 typedef typename boost::result_of<Fun(Expr, State, Visitor)>::type type;
 
-                template<typename A, typename B, typename C>
-                static type call(A &&expr, B &&state, C &&visitor)
+                static type call(CVREF(Expr) expr, CVREF(State) state, CVREF(Visitor) visitor)
                 {
                     Fun f;
                     return f(expr, state, visitor);
@@ -126,8 +121,7 @@
             {
                 typedef typename boost::result_of<Fun()>::type type;
 
-                template<typename A, typename B, typename C>
-                static type call(A &&, B &&, C &&)
+                static type call(CVREF(Expr) expr, CVREF(State) state, CVREF(Visitor) visitor)
                 {
                     Fun f;
                     return f();
@@ -145,8 +139,7 @@
             {
                 typedef typename boost::result_of<Fun(Expr)>::type type;
 
-                template<typename A, typename B, typename C>
-                static type call(A &&expr, B &&, C &&)
+                static type call(CVREF(Expr) expr, CVREF(State) state, CVREF(Visitor) visitor)
                 {
                     Fun f;
                     return f(expr);
@@ -164,8 +157,7 @@
             {
                 typedef typename boost::result_of<Fun(Expr, State)>::type type;
 
-                template<typename A, typename B, typename C>
-                static type call(A &&expr, B &&state, C &&)
+                static type call(CVREF(Expr) expr, CVREF(State) state, CVREF(Visitor) visitor)
                 {
                     Fun f;
                     return f(expr, state);
@@ -307,6 +299,7 @@
             }
         };
 
+        #ifdef BOOST_HAS_VARIADIC_TMPL
         template<typename Fun, typename... Args>
         struct call<Fun(Args...)> : callable
         {
@@ -328,7 +321,9 @@
                 return f(when<_, Args>()(expr, state, visitor)...);
             }
         };
-
+        #else
+        #include <boost/xpressive/proto/detail/call.hpp>
+        #endif
     }
 
     template<typename Fun>
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -15,6 +15,7 @@
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/args.hpp>
+#include <boost/xpressive/proto/detail/as_lvalue.hpp>
 
 namespace boost { namespace proto
 {
@@ -23,7 +24,13 @@
     {
         namespace detail
         {
+            using proto::detail::as_lvalue;
+
+            #ifdef BOOST_HAS_VARIADIC_TMPL
             template<typename... T>
+            #else
+            template<BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename A, void)>
+            #endif
             struct typelist
             {
                 typedef void type;
@@ -46,12 +53,14 @@
               : nested_type<T>
             {};
 
+            #ifdef BOOST_HAS_VARIADIC_TMPL
             template<typename T, typename... Args>
             struct nested_type_if<T, typelist<Args...>, typename typelist<typename Args::not_applied_...>::type>
             {
                 typedef T type;
                 typedef void not_applied_;
             };
+            #endif
 
             template<typename R, typename Expr, typename State, typename Visitor
                 , bool IsTransform = is_callable<R>::value
@@ -65,6 +74,7 @@
                 typedef void not_applied_;
             };
 
+            #ifdef BOOST_HAS_VARIADIC_TMPL
             template<template<typename...> class R, typename... Args, typename Expr, typename State, typename Visitor>
             struct make_<R<Args...>, Expr, State, Visitor>
               : nested_type_if<
@@ -72,7 +82,8 @@
                   , typelist<make_if_<Args, Expr, State, Visitor>...>
                 >
             {};
-
+            #endif
+            
             template<typename R, typename Expr, typename State, typename Visitor>
             struct make_if_<R, Expr, State, Visitor, false>
               : make_<R, Expr, State, Visitor>
@@ -85,6 +96,7 @@
                 >::type>
             {};
 
+            #ifdef BOOST_HAS_VARIADIC_TMPL
             template<typename R, typename... Args, typename Expr, typename State, typename Visitor>
             struct make_if_<R(Args...), Expr, State, Visitor, false>
               : remove_const<typename remove_reference<
@@ -98,17 +110,34 @@
                     typename boost::result_of<when<_, R(Args...)>(Expr, State, Visitor)>::type
                 >::type>
             {};
+            #endif
 
             template<typename Type, bool IsAggregate = is_aggregate<Type>::value>
             struct construct_
             {
                 typedef Type result_type;
 
+                #ifdef BOOST_HAS_VARIADIC_TMPL
                 template<typename... Args>
-                Type operator()(Args &&... args) const
+                Type operator()(Args &... args) const
                 {
                     return Type(args...);
                 }
+                #else
+                Type operator()() const
+                {
+                    return Type();
+                }
+
+                #define TMP(Z, N, DATA)                                                             \
+                template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)>                                  \
+                Type operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const                   \
+                {                                                                                   \
+                    return Type(BOOST_PP_ENUM_PARAMS_Z(Z, N, a));                                   \
+                }
+                BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+                #undef TMP
+                #endif
             };
 
             template<typename Type>
@@ -116,17 +145,29 @@
             {
                 typedef Type result_type;
 
+                Type operator()() const
+                {
+                    return Type();
+                }
+
+                #ifdef BOOST_HAS_VARIADIC_TMPL
                 template<typename... Args>
-                Type operator()(Args &&... args) const
+                Type operator()(Args &... args) const
                 {
                     Type that = {args...};
                     return that;
                 }
-
-                Type operator()() const
-                {
-                    return Type();
+                #else
+                #define TMP(Z, N, DATA)                                                             \
+                template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)>                                  \
+                Type operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const                   \
+                {                                                                                   \
+                    Type that = {BOOST_PP_ENUM_PARAMS_Z(Z, N, a)};                                  \
+                    return that;                                                                    \
                 }
+                BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+                #undef TMP
+                #endif
             };
 
             template<typename T, typename A, long N>
@@ -134,18 +175,40 @@
             {
                 typedef expr<T, A, N> result_type;
 
+                #ifdef BOOST_HAS_VARIADIC_TMPL
                 template<typename... Args>
-                result_type operator()(Args &&... args) const
+                result_type operator()(Args &... args) const
                 {
                     return proto::construct<result_type>(args...);
                 }
+                #else
+                #define TMP(Z, N, DATA)                                                             \
+                template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)>                                  \
+                result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a)) const            \
+                {                                                                                   \
+                    return proto::construct<result_type>(BOOST_PP_ENUM_PARAMS_Z(Z, N, a));          \
+                }
+                BOOST_PP_REPEAT_FROM_TO(1, BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), TMP, ~)
+                #undef TMP
+                #endif
             };
 
+            #ifdef BOOST_HAS_VARIADIC_TMPL
             template<typename Type, typename... Args>
-            Type construct(Args &&... args)
+            Type construct(Args &... args)
             {
                 return construct_<Type>()(args...);
             }
+            #else
+            #define TMP(Z, N, DATA)                                                                 \
+            template<typename Type BOOST_PP_ENUM_TRAILING_PARAMS_Z(Z, N, typename A)>               \
+            Type construct(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, A, &a))                              \
+            {                                                                                       \
+                return construct_<Type>()(BOOST_PP_ENUM_PARAMS_Z(Z, N, a));                         \
+            }
+            BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, TMP, ~)
+            #undef TMP
+            #endif
         }
 
         template<typename Fun>
@@ -168,6 +231,7 @@
             }
         };
 
+        #ifdef BOOST_HAS_VARIADIC_TMPL
         template<typename Return, typename... Args>
         struct make<Return(Args...)> : callable
         {
@@ -184,10 +248,14 @@
             operator()(Expr const &expr, State const &state, Visitor &visitor) const
             {
                 typedef typename result<make(Expr const &, State const &, Visitor &)>::type result_type;
-                return detail::construct<result_type>(when<_, Args>()(expr, state, visitor)...);
+                return detail::construct<result_type>(
+                    detail::as_lvalue(when<_, Args>()(expr, state, visitor))...
+                );
             }
         };
-
+        #else
+        #include <boost/xpressive/proto/detail/make.hpp>
+        #endif
     }
 
     template<typename Fun>
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-28 03:27:40 EST (Fri, 28 Dec 2007)
@@ -40,6 +40,7 @@
         typedef typename Grammar::proto_base_expr proto_base_expr;
     };
 
+    #ifdef BOOST_HAS_VARIADIC_TMPL
     // Function-style transforms, handled below...
     template<typename Grammar, typename Return, typename... Args>
     struct when<Grammar, Return(*)(Args...)>
@@ -80,6 +81,9 @@
             >::type()(expr, state, visitor);
         }
     };
+    #else
+    #include <boost/xpressive/proto/detail/when.hpp>
+    #endif
 
     template<typename Fun>
     struct otherwise