Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-12-18 20:50:04


Author: eric_niebler
Date: 2007-12-18 20:50:04 EST (Tue, 18 Dec 2007)
New Revision: 42162
URL: http://svn.boost.org/trac/boost/changeset/42162

Log:
begin porting expr<> to c++03
Added:
   branches/proto/v3/boost/xpressive/proto/detail/fun_call_ex.hpp (contents, props changed)
Text files modified:
   branches/proto/v3/boost/xpressive/proto/detail/deep_copy.hpp | 1
   branches/proto/v3/boost/xpressive/proto/detail/make_expr_ex.hpp | 1
   branches/proto/v3/boost/xpressive/proto/expr.hpp | 136 ++++++++++++++++++++++++++++++++++-----
   3 files changed, 118 insertions(+), 20 deletions(-)

Modified: branches/proto/v3/boost/xpressive/proto/detail/deep_copy.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/detail/deep_copy.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/detail/deep_copy.hpp 2007-12-18 20:50:04 EST (Tue, 18 Dec 2007)
@@ -30,6 +30,7 @@
                 template<typename Cons>
                 static typename type::cons_type call(Cons const &a)
                 {
+ // BUGBUG doesn't handle arrays and function references
                     typename type::cons_type that = {a.car};
                     return that;
                 }

Added: branches/proto/v3/boost/xpressive/proto/detail/fun_call_ex.hpp
==============================================================================
--- (empty file)
+++ branches/proto/v3/boost/xpressive/proto/detail/fun_call_ex.hpp 2007-12-18 20:50:04 EST (Tue, 18 Dec 2007)
@@ -0,0 +1,82 @@
+#ifndef BOOST_PP_IS_ITERATING
+ ///////////////////////////////////////////////////////////////////////////////
+ /// \file make_expr_ex.hpp
+ /// Exploded instances of the make_expr and make_arg functions
+ //
+ // 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 M1(Z, N, _) ((0)(1))
+
+ #define M2(R, PRODUCT) M3(R, BOOST_PP_SEQ_SIZE(PRODUCT), PRODUCT)
+
+ #define M3(R, SIZE, PRODUCT) \
+ template<BOOST_PP_ENUM_PARAMS(SIZE, typename A)> \
+ expr<tag::function, args<expr &, BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT)> > \
+ operator()(BOOST_PP_SEQ_FOR_EACH_I_R(R, M4, ~, PRODUCT)) \
+ { \
+ typedef args<expr &, BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT)> args_type; \
+ expr<tag::function, args_type> that = { \
+ argsns_::make_cons_<typename args_type::cons_type>( \
+ *this \
+ , BOOST_PP_SEQ_FOR_EACH_I_R(R, M6, ~, PRODUCT) \
+ ) \
+ }; \
+ return that; \
+ } \
+ \
+ template<BOOST_PP_ENUM_PARAMS(SIZE, typename A)> \
+ expr<tag::function, args<expr const &, BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT)> > \
+ operator()(BOOST_PP_SEQ_FOR_EACH_I_R(R, M4, ~, PRODUCT)) const \
+ { \
+ typedef args<expr const &, BOOST_PP_SEQ_FOR_EACH_I_R(R, M5, ~, PRODUCT)> args_type; \
+ expr<tag::function, args_type> that = { \
+ argsns_::make_cons_<typename args_type::cons_type>( \
+ *this \
+ , BOOST_PP_SEQ_FOR_EACH_I_R(R, M6, ~, PRODUCT) \
+ ) \
+ }; \
+ return that; \
+ } \
+ /**/
+
+ #define M4(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) \
+ BOOST_PP_CAT(A, I) BOOST_PP_CAT(C, ELEM) &BOOST_PP_CAT(a, I) \
+ /**/
+
+ #define M5(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) \
+ typename result_of::as_arg<BOOST_PP_CAT(A, I) BOOST_PP_CAT(C, ELEM)&>::type \
+ /**/
+
+ #define M6(R, _, I, ELEM) \
+ BOOST_PP_COMMA_IF(I) \
+ result_of::as_arg<BOOST_PP_CAT(A, I) BOOST_PP_CAT(C, ELEM)&>::call(BOOST_PP_CAT(a, I)) \
+ /**/
+
+ #define C0
+
+ #define C1 const
+
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY), <boost/xpressive/proto/detail/fun_call_ex.hpp>))
+ #include BOOST_PP_ITERATE()
+
+ #undef C0
+ #undef C1
+ #undef M1
+ #undef M2
+ #undef M3
+ #undef M4
+ #undef M5
+ #undef M6
+
+#else
+
+ BOOST_PP_SEQ_FOR_EACH_PRODUCT(
+ M2,
+ BOOST_PP_REPEAT(BOOST_PP_ITERATION(), M1, ~)
+ )
+
+#endif

Modified: branches/proto/v3/boost/xpressive/proto/detail/make_expr_ex.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto/detail/make_expr_ex.hpp (original)
+++ branches/proto/v3/boost/xpressive/proto/detail/make_expr_ex.hpp 2007-12-18 20:50:04 EST (Tue, 18 Dec 2007)
@@ -72,6 +72,7 @@
         #undef M2
         #undef M3
         #undef M4
+ #undef M5
 
 #else
 

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-18 20:50:04 EST (Tue, 18 Dec 2007)
@@ -70,6 +70,28 @@
 
             typename Args::cons_type proto_args_;
 
+ expr &proto_base()
+ {
+ return *this;
+ }
+
+ expr const &proto_base() const
+ {
+ return *this;
+ }
+
+ typedef
+ typename
+ exprns_::detail::address_of_hack<Tag, typename Args::cons_type::car_type>
+ ::type
+ address_of_hack_type_;
+
+ operator address_of_hack_type_() const
+ {
+ return boost::addressof(this->proto_args_.car);
+ }
+
+ // TODO make this a free function
             template<typename... A>
             static expr make(A &&... a)
             {
@@ -92,26 +114,7 @@
                 return that;
             }
 
- expr &proto_base()
- {
- return *this;
- }
-
- expr const &proto_base() const
- {
- return *this;
- }
-
- typedef
- typename
- exprns_::detail::address_of_hack<Tag, typename Args::cons_type::car_type>
- ::type
- address_of_hack_type_;
-
- operator address_of_hack_type_() const
- {
- return boost::addressof(this->proto_args_.car);
- }
+ #if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
 
             template<typename A>
             expr<tag::assign, args<expr &, typename result_of::as_arg<A>::type> >
@@ -168,6 +171,99 @@
                     {argsns_::make_cons_<typename args_type::cons_type>(*this, result_of::as_arg<A>::call(a)...)};
                 return that;
             }
+
+ #else
+
+ template<typename A>
+ expr<tag::assign, args<expr &, typename result_of::as_arg<A &>::type> >
+ operator=(A &a)
+ {
+ expr<tag::assign, args<expr &, typename result_of::as_arg<A &>::type> > that =
+ {{*this, {result_of::as_arg<A &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::assign, args<expr const &, typename result_of::as_arg<A &>::type> >
+ operator=(A &a) const
+ {
+ expr<tag::assign, args<expr const &, typename result_of::as_arg<A &>::type> > that =
+ {{*this, {result_of::as_arg<A &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::assign, args<expr &, typename result_of::as_arg<A const &>::type> >
+ operator=(A const &a)
+ {
+ expr<tag::assign, args<expr &, typename result_of::as_arg<A const &>::type> > that =
+ {{*this, {result_of::as_arg<A const &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::assign, args<expr const &, typename result_of::as_arg<A const &>::type> >
+ operator=(A const &a) const
+ {
+ expr<tag::assign, args<expr const &, typename result_of::as_arg<A const &>::type> > that =
+ {{*this, {result_of::as_arg<A const &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::subscript, args<expr &, typename result_of::as_arg<A &>::type> >
+ operator[](A &a)
+ {
+ expr<tag::subscript, args<expr &, typename result_of::as_arg<A &>::type> > that =
+ {{*this, {result_of::as_arg<A &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::subscript, args<expr const &, typename result_of::as_arg<A &>::type> >
+ operator[](A &a) const
+ {
+ expr<tag::subscript, args<expr const &, typename result_of::as_arg<A &>::type> > that =
+ {{*this, {result_of::as_arg<A &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::subscript, args<expr &, typename result_of::as_arg<A const &>::type> >
+ operator[](A const &a)
+ {
+ expr<tag::subscript, args<expr &, typename result_of::as_arg<A const &>::type> > that =
+ {{*this, {result_of::as_arg<A const &>::call(a)}}};
+ return that;
+ }
+
+ template<typename A>
+ expr<tag::subscript, args<expr const &, typename result_of::as_arg<A const &>::type> >
+ operator[](A const &a) const
+ {
+ expr<tag::subscript, args<expr const &, typename result_of::as_arg<A const &>::type> > that =
+ {{*this, {result_of::as_arg<A const &>::call(a)}}};
+ return that;
+ }
+
+ expr<tag::function, args<expr &> >
+ operator()()
+ {
+ expr<tag::function, args<expr &> > that = {{*this}};
+ return that;
+ }
+
+ expr<tag::function, args<expr const &> >
+ operator()() const
+ {
+ expr<tag::function, args<expr const &> > that = {{*this}};
+ return that;
+ }
+
+ #include <boost/xpressive/proto/detail/fun_call_ex.hpp>
+
+ #endif
+
         };
 
     }


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