Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4139/proto

Modified Files:
        make_expr.hpp proto.hpp proto_fwd.hpp 
Log Message:
bring make_expr, unpack_expr and (new) unfused_expr into the fold

Index: make_expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/make_expr.hpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- make_expr.hpp       9 May 2007 06:55:32 -0000       1.11
+++ make_expr.hpp       24 May 2007 20:03:26 -0000      1.12
@@ -12,9 +12,7 @@
     #define BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
 
     #include <boost/xpressive/proto/detail/prefix.hpp>
-    #include <boost/preprocessor/inc.hpp>
     #include <boost/preprocessor/cat.hpp>
-    #include <boost/preprocessor/punctuation/paren.hpp>
     #include <boost/preprocessor/iterate.hpp>
     #include <boost/preprocessor/facilities/intercept.hpp>
     #include <boost/preprocessor/repetition/enum.hpp>
@@ -22,9 +20,10 @@
     #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
     #include <boost/preprocessor/repetition/enum_binary_params.hpp>
     #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
-    #include <boost/detail/workaround.hpp>
     #include <boost/ref.hpp>
-    #include <boost/type_traits/remove_const.hpp>
+    #include <boost/utility/enable_if.hpp>
+    #include <boost/type_traits/is_same.hpp>
+    #include <boost/type_traits/add_reference.hpp>
     #include <boost/type_traits/remove_reference.hpp>
     #include <boost/xpressive/proto/proto_fwd.hpp>
     #include <boost/xpressive/proto/traits.hpp>
@@ -33,124 +32,271 @@
     #include <boost/fusion/sequence/intrinsic/size.hpp>
     #include <boost/xpressive/proto/detail/suffix.hpp>
 
-    namespace boost { namespace proto
-    {
+    #define BOOST_PROTO_AS_ARG_TYPE(Z, N, DATA)                                
                     \
+        typename proto::result_of::as_arg<BOOST_PP_CAT(DATA, N)>::type         
                     \
+        /**/
 
-        namespace detail
-        {
-            template<typename Tag, long Arity>
-            struct make_expr_impl;
+    #define BOOST_PROTO_AS_ARG(Z, N, DATA)                                     
                     \
+        proto::as_arg(BOOST_PP_CAT(DATA, N))                                   
                     \
+        /**/
 
-        #define BOOST_PROTO_AS_ARG(z, n, data) proto::as_arg(BOOST_PP_CAT(a, 
n))
-        #define BOOST_PROTO_VALUE_AT(z, n, data) typename 
fusion::result_of::value_at_c< Sequence, n >::type
-        #define BOOST_PROTO_AT(z, n, data) fusion::at_c< n >(data)
-        #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 1))
-        #include BOOST_PP_ITERATE()
-        #undef BOOST_PP_ITERATION_PARAMS_1
-        #undef BOOST_PROTO_AS_ARG
-        #undef BOOST_PROTO_VALUE_AT
-        #undef BOOST_PROTO_AT
-        }
+    #define BOOST_PROTO_AT_TYPE(Z, N, DATA)                                    
                     \
+        typename result_of::as_arg<                                            
                     \
+            typename remove_reference<                                         
                     \
+                typename fusion::result_of::value_at_c<DATA, N >::type         
                     \
+            >::type                                                            
                     \
+        >::type                                                                
                     \
+        /**/
 
-        namespace result_of
-        {
-            template<typename Tag 
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(BOOST_PROTO_MAX_ARITY, typename A, = void 
BOOST_PP_INTERCEPT), typename Dummy = void>
-            struct make_expr;
-        }
+    #define BOOST_PROTO_AT(Z, N, DATA)                                         
                     \
+        proto::as_arg(fusion::at_c<N >(DATA))                                  
                     \
+        /**/
 
-    #define BOOST_PP_ITERATION_PARAMS_1 (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 2))
-    #include BOOST_PP_ITERATE()
-    #undef BOOST_PP_ITERATION_PARAMS_1
+    namespace boost { namespace fusion
+    {
+        template<typename Function>
+        class unfused_generic;
+    }}
 
+    namespace boost { namespace proto
+    {
         namespace result_of
         {
+            template<typename Tag, typename Sequence, std::size_t Size>
+            struct unpack_expr_detail
+            {};
+
+            template<typename Sequence>
+            struct unpack_expr_detail<tag::terminal, Sequence, 1u>
+            {
+                typedef expr<
+                    tag::terminal
+                  , args1<typename fusion::result_of::value_at_c<Sequence, 
0>::type>
+                > type;
+
+                static type const call(Sequence const &sequence)
+                {
+                    type that = {fusion::at_c<0>(sequence)};
+                    return that;
+                }
+            };
+
             template<typename Tag, typename Sequence>
             struct unpack_expr
-              : detail::make_expr_impl<Tag, 
fusion::result_of::size<Sequence>::type::value>
-                    ::template from_sequence_result_<Sequence>
+              : unpack_expr_detail<Tag, Sequence, 
fusion::result_of::size<Sequence>::type::value>
             {};
+
+        #define BOOST_PP_ITERATION_PARAMS_1                                    
                     \
+            (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 1))               \
+            /**/
+
+        #include BOOST_PP_ITERATE()
+
+            template<typename A>
+            struct make_expr<tag::terminal, A>
+            {
+                typedef typename add_reference<A>::type reference;
+                typedef expr<tag::terminal, args1<reference> > type;
+
+                static type const call(reference a)
+                {
+                    type that = {a};
+                    return that;
+                }
+            };
         }
 
-        template<typename Tag, typename Sequence>
-        typename result_of::unpack_expr<Tag, Sequence const>::type
-        unpack_expr(Sequence const &sequence)
+        namespace op
         {
-            typedef typename fusion::result_of::size<Sequence>::type size_type;
-            return detail::make_expr_impl<Tag, 
size_type::value>::from_sequence(sequence);
-        }
+            template<typename Tag>
+            struct make_expr
+            {
+                template<typename Sig>
+                struct result
+                {};
 
-    }}
+        #define BOOST_PP_ITERATION_PARAMS_1                                    
                     \
+            (4, (1, BOOST_PROTO_MAX_ARITY, 
<boost/xpressive/proto/make_expr.hpp>, 2))               \
+            /**/
 
-    #endif // BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
+        #include BOOST_PP_ITERATE()
+            };
 
-#elif 1 == BOOST_PP_ITERATION_FLAGS()
+            template<>
+            struct make_expr<tag::terminal>
+            {
+                template<typename Sig>
+                struct result
+                {};
 
-    #define N BOOST_PP_ITERATION()
+                template<typename This, typename A>
+                struct result<This(A)>
+                  : result_of::make_expr<tag::terminal, A>
+                {};
 
-            template<typename Tag>
-            struct make_expr_impl<Tag, N>
-            {
-                template<BOOST_PP_ENUM_PARAMS(N, typename A)>
-                struct result_
+                template<typename A>
+                typename result_of::make_expr<tag::terminal, A &>::type 
operator ()(A &a) const
                 {
-                    typedef expr<Tag, BOOST_PP_CAT(args, N)<
-                        BOOST_PP_ENUM_BINARY_PARAMS(N, typename 
result_of::as_arg<A, >::type BOOST_PP_INTERCEPT)
-                    > > type;
-                };
+                    return result_of::make_expr<tag::terminal, A &>::call(a);
+                }
 
+                template<typename A>
+                typename result_of::make_expr<tag::terminal, A const &>::type 
operator ()(A const &a) const
+                {
+                    return result_of::make_expr<tag::terminal, A const 
&>::call(a);
+                }
+            };
+
+            template<typename Tag>
+            struct unpack_expr
+            {
                 template<typename Sig>
-                struct result;
+                struct result
+                {};
 
-                template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, 
typename A)>
-                struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
-                  : result_<BOOST_PP_ENUM_BINARY_PARAMS(N, typename 
remove_reference<A, >::type BOOST_PP_INTERCEPT)>
+                template<typename This, typename Sequence>
+                struct result<This(Sequence)>
+                  : result_of::unpack_expr<Tag, typename 
detail::remove_cv_ref<Sequence>::type>
                 {};
 
-                template<BOOST_PP_ENUM_PARAMS(N, typename A)>
-                typename result_<BOOST_PP_ENUM_PARAMS(N, const A)>::type
-                operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
+                template<typename Sequence>
+                typename result_of::unpack_expr<Tag, Sequence>::type
+                operator ()(Sequence const &sequence) const
                 {
-                    typename result_<BOOST_PP_ENUM_PARAMS(N, const A)>::type 
that =
-                        {BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG, _)};
-                    return that;
+                    return result_of::unpack_expr<Tag, 
Sequence>::call(sequence);
                 }
+            };
 
+            template<typename Tag>
+            struct unfused_expr_fun
+            {
                 template<typename Sequence>
-                struct from_sequence_result_
-                  : result_<BOOST_PP_ENUM(N, BOOST_PROTO_VALUE_AT, _)>
+                struct result
+                  : result_of::unpack_expr<Tag, Sequence>
                 {};
 
                 template<typename Sequence>
-                static typename from_sequence_result_<Sequence>::type
-                from_sequence(Sequence &seq)
+                typename proto::result_of::unpack_expr<Tag, Sequence>::type
+                operator ()(Sequence const &sequence) const
                 {
-                    typename from_sequence_result_<Sequence>::type that =
-                        {BOOST_PP_ENUM(N, BOOST_PROTO_AT, seq)};
-                    return that;
+                    return result_of::unpack_expr<Tag, 
Sequence>::call(sequence);
                 }
             };
 
-    #undef N
+            template<typename Tag>
+            struct unfused_expr
+              : fusion::unfused_generic<unfused_expr_fun<Tag> >
+            {};
+        }
 
-#elif 2 == BOOST_PP_ITERATION_FLAGS()
+    #define BOOST_PP_ITERATION_PARAMS_1                                        
                     \
+        (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 
3))                   \
+        /**/
+
+    #include BOOST_PP_ITERATE()
+
+        template<typename Tag, typename Sequence>
+        typename result_of::unpack_expr<Tag, Sequence>::type const
+        unpack_expr(Sequence const &sequence)
+        {
+            return result_of::unpack_expr<Tag, Sequence>::call(sequence);
+        }
+
+        template<typename Tag, typename A0>
+        typename result_of::make_expr<Tag, A0>::type const
+        make_expr(A0 &a0 BOOST_PROTO_DISABLE_IF_IS_CONST(A0))
+        {
+            return result_of::make_expr<Tag, A0>::call(a0);
+        }
+    }}
+
+    #undef BOOST_PROTO_AS_ARG_TYPE
+    #undef BOOST_PROTO_AS_ARG
+    #undef BOOST_PROTO_AT_TYPE
+    #undef BOOST_PROTO_AT
+
+    #endif // BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
+
+#elif BOOST_PP_ITERATION_FLAGS() == 1
 
     #define N BOOST_PP_ITERATION()
 
-    namespace result_of
-    {
         template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
         struct make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
-          : detail::make_expr_impl<Tag, N>::template 
result_<BOOST_PP_ENUM_PARAMS(N, A)>
+        {
+            typedef expr<
+                Tag
+              , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, 
BOOST_PROTO_AS_ARG_TYPE, A) >
+            > type;
+
+            static type const call(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
+            {
+                type that = {
+                    BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG, a)
+                };
+                return that;
+            }
+        };
+
+        template<typename Tag, typename Sequence>
+        struct unpack_expr_detail<Tag, Sequence, N>
+        {
+            typedef expr<
+                Tag
+              , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, BOOST_PROTO_AT_TYPE, 
Sequence const) >
+            > type;
+
+            static type const call(Sequence const &sequence)
+            {
+                type that = {
+                    BOOST_PP_ENUM(N, BOOST_PROTO_AT, sequence)
+                };
+                return that;
+            }
+        };
+
+    #undef N
+
+#elif BOOST_PP_ITERATION_FLAGS() == 2
+
+    #define N BOOST_PP_ITERATION()
+
+        template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
+          : result_of::make_expr<
+                Tag
+                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+                    N
+                  , typename remove_reference<A
+                  , >::type BOOST_PP_INTERCEPT
+                )
+            >
         {};
-    }
 
-    template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
-    typename detail::make_expr_impl<Tag, N>::template 
result_<BOOST_PP_ENUM_PARAMS(N, const A)>::type
-    make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a))
-    {
-        return detail::make_expr_impl<Tag, N>()(BOOST_PP_ENUM_PARAMS(N, a));
-    }
+        template<BOOST_PP_ENUM_PARAMS(N, typename A)>
+        typename result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::type const
+        operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a)) const
+        {
+            return result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::call(
+                BOOST_PP_ENUM_PARAMS(N, a)
+            );
+        }
 
     #undef N
 
-#endif
+#elif BOOST_PP_ITERATION_FLAGS() == 3
+
+    #define N BOOST_PP_ITERATION()
+
+        template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+        typename result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::type const
+        make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a))
+        {
+            return result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, 
const A)>::call(
+                BOOST_PP_ENUM_PARAMS(N, a)
+            );
+        }
+
+    #undef N
+
+#endif // BOOST_PP_IS_ITERATING

Index: proto.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto.hpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- proto.hpp   15 Apr 2007 07:13:00 -0000      1.18
+++ proto.hpp   24 May 2007 20:03:26 -0000      1.19
@@ -24,6 +24,7 @@
 #include <boost/xpressive/proto/generate.hpp>
 #include <boost/xpressive/proto/operators.hpp>
 #include <boost/xpressive/proto/deep_copy.hpp>
+#include <boost/xpressive/proto/make_expr.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
 #endif

Index: proto_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/proto_fwd.hpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- proto_fwd.hpp       21 May 2007 03:21:33 -0000      1.62
+++ proto_fwd.hpp       24 May 2007 20:03:26 -0000      1.63
@@ -16,6 +16,7 @@
 #include <boost/detail/workaround.hpp>
 #include <boost/preprocessor/arithmetic/sub.hpp>
 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
+#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
 #include <boost/mpl/long.hpp>
 #include <boost/type_traits/remove_cv.hpp>
 #include <boost/type_traits/remove_reference.hpp>
@@ -245,6 +246,20 @@
 
         template<typename Expr, typename Context>
         struct eval;
+
+        template<
+            typename Tag
+            BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
+                BOOST_PROTO_MAX_ARITY
+              , typename A
+              , = void BOOST_PP_INTERCEPT
+            )
+          , typename _ = void
+        >
+        struct make_expr;
+
+        template<typename Tag, typename Sequence>
+        struct unpack_expr;
     }
 
     namespace detail
@@ -342,6 +357,18 @@
 
         template<long N>
         struct arg_c;
+
+        template<typename Tag>
+        struct make_expr;
+
+        template<typename Tag>
+        struct unpack_expr;
+
+        template<typename Tag>
+        struct unfused_expr_fun;
+
+        template<typename Tag>
+        struct unfused_expr;
     }
 
     namespace transform


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to