Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-04-20 16:12:13


Author: eric_niebler
Date: 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
New Revision: 44649
URL: http://svn.boost.org/trac/boost/changeset/44649

Log:
assorted bug fixes and imporovements
Text files modified:
   branches/proto/v4/boost/proto/detail/as_lvalue.hpp | 2
   branches/proto/v4/boost/proto/detail/decltype.hpp | 10 +++
   branches/proto/v4/boost/proto/extends.hpp | 18 +++---
   branches/proto/v4/boost/proto/fusion.hpp | 2
   branches/proto/v4/boost/proto/generate.hpp | 104 +++++++++++++++++++++++++++++++++++++++
   branches/proto/v4/boost/proto/make_expr.hpp | 6 +-
   branches/proto/v4/boost/proto/matches.hpp | 2
   branches/proto/v4/boost/proto/proto_fwd.hpp | 4
   branches/proto/v4/boost/proto/traits.hpp | 18 +++---
   branches/proto/v4/boost/proto/transform/call.hpp | 2
   branches/proto/v4/boost/proto/transform/default.hpp | 95 +++++++++++++++++++++++++++++++++++-
   branches/proto/v4/boost/proto/transform/fold.hpp | 2
   branches/proto/v4/boost/proto/transform/make.hpp | 2
   branches/proto/v4/boost/proto/transform/when.hpp | 2
   14 files changed, 232 insertions(+), 37 deletions(-)

Modified: branches/proto/v4/boost/proto/detail/as_lvalue.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/as_lvalue.hpp (original)
+++ branches/proto/v4/boost/proto/detail/as_lvalue.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -22,7 +22,7 @@
             int_() {}
             int_(int) {}
         };
-
+
         template<typename T>
         T &as_lvalue(T &t, int = 0)
         {

Modified: branches/proto/v4/boost/proto/detail/decltype.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/decltype.hpp (original)
+++ branches/proto/v4/boost/proto/detail/decltype.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -36,7 +36,7 @@
 # define BOOST_PROTO_DECLTYPE_(EXPR, TYPE) \
     BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL_(BOOST_PP_CAT(nested_, TYPE), (EXPR)) \
     typedef typename BOOST_PP_CAT(nested_, TYPE)::type TYPE;
-# endif
+# endif
 #else
 /// INTERNAL ONLY
 ///
@@ -82,7 +82,7 @@
 
         template<typename T, typename U = T>
         struct result_of_fixup
- : mpl::if_<is_function<T>, T *, U>
+ : mpl::if_c<is_function<T>::value, T *, U>
         {};
 
         template<typename T, typename U>
@@ -95,6 +95,12 @@
           : result_of_fixup<T, U>
         {};
 
+ template<typename R, typename T, typename U>
+ struct result_of_fixup<R T::*, U>
+ {
+ typedef R T::*type;
+ };
+
         template<typename T, typename U>
         struct result_of_fixup<T const, U>
           : result_of_fixup<T, U>

Modified: branches/proto/v4/boost/proto/extends.hpp
==============================================================================
--- branches/proto/v4/boost/proto/extends.hpp (original)
+++ branches/proto/v4/boost/proto/extends.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -105,7 +105,7 @@
         /**/
 
     #define BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain) \
- Expr expr; \
+ Expr proto_expr_; \
                                                                                                     \
         typedef typename Expr::proto_base_expr proto_base_expr; \
         typedef Domain proto_domain; \
@@ -125,12 +125,12 @@
                                                                                                     \
         proto_base_expr &proto_base() \
         { \
- return this->expr.proto_base(); \
+ return this->proto_expr_.proto_base(); \
         } \
                                                                                                     \
         proto_base_expr const &proto_base() const \
         { \
- return this->expr.proto_base(); \
+ return this->proto_expr_.proto_base(); \
         } \
         /**/
 
@@ -374,15 +374,15 @@
     struct extends
     {
         extends()
- : expr()
+ : proto_expr_()
         {}
 
         extends(extends const &that)
- : expr(that.expr)
+ : proto_expr_(that.proto_expr_)
         {}
 
         extends(Expr const &expr_)
- : expr(expr_)
+ : proto_expr_(expr_)
         {}
 
         BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain)
@@ -412,15 +412,15 @@
     struct extends<Expr, Derived, Domain, tag::terminal>
     {
         extends()
- : expr()
+ : proto_expr_()
         {}
 
         extends(extends const &that)
- : expr(that.expr)
+ : proto_expr_(that.proto_expr_)
         {}
 
         extends(Expr const &expr_)
- : expr(expr_)
+ : proto_expr_(expr_)
         {}
 
         BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain)

Modified: branches/proto/v4/boost/proto/fusion.hpp
==============================================================================
--- branches/proto/v4/boost/proto/fusion.hpp (original)
+++ branches/proto/v4/boost/proto/fusion.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -398,7 +398,7 @@
                     return proto::child_c<Iterator::index>(iter.expr);
                 }
             };
-
+
             template<typename Iterator>
             struct apply<Iterator, 0>
             {

Modified: branches/proto/v4/boost/proto/generate.hpp
==============================================================================
--- branches/proto/v4/boost/proto/generate.hpp (original)
+++ branches/proto/v4/boost/proto/generate.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -97,6 +97,8 @@
         /// passed to it.
         struct default_generator
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 
@@ -126,6 +128,8 @@
         template<template<typename> class Extends>
         struct generator
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 
@@ -135,6 +139,18 @@
                 typedef Extends<Expr> type;
             };
 
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef Extends<Expr> type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef Extends<Expr> type;
+ };
+
             /// \param expr A Proto expression
             /// \return Extends<Expr>(expr)
             template<typename Expr>
@@ -157,6 +173,8 @@
         template<template<typename> class Extends>
         struct pod_generator
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 
@@ -166,6 +184,18 @@
                 typedef Extends<Expr> type;
             };
 
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef Extends<Expr> type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef Extends<Expr> type;
+ };
+
             /// \param expr The expression to wrap
             /// \return <tt>Extends\<Expr\> that = {expr}; return that;</tt>
             template<typename Expr>
@@ -177,7 +207,7 @@
         };
 
         /// \brief A generator that replaces child nodes held by
- /// reference with ones held by value. Use with
+ /// reference with ones held by value. Use with
         /// \c compose_generators to forward that result to another
         /// generator.
         ///
@@ -190,6 +220,8 @@
         /// <tt>compose_generators\<by_value_generator, MyGenerator\></tt>.
         struct by_value_generator
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 
@@ -201,6 +233,22 @@
                 type;
             };
 
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef
+ typename detail::by_value_generator_<Expr>::type
+ type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef
+ typename detail::by_value_generator_<Expr>::type
+ type;
+ };
+
             /// \param expr The expression to modify.
             /// \return <tt>deep_copy(expr)</tt>
             template<typename Expr>
@@ -223,6 +271,8 @@
         template<typename First, typename Second>
         struct compose_generators
         {
+ BOOST_PROTO_CALLABLE()
+
             template<typename Sig>
             struct result;
 
@@ -231,7 +281,27 @@
             {
                 typedef
                     typename Second::template result<
- typename First::template result<void(Expr)>::type
+ void(typename First::template result<void(Expr)>::type)
+ >::type
+ type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr &)>
+ {
+ typedef
+ typename Second::template result<
+ void(typename First::template result<void(Expr)>::type)
+ >::type
+ type;
+ };
+
+ template<typename This, typename Expr>
+ struct result<This(Expr const &)>
+ {
+ typedef
+ typename Second::template result<
+ void(typename First::template result<void(Expr)>::type)
>::type
                 type;
             };
@@ -247,6 +317,36 @@
 
         BOOST_PROTO_END_ADL_NAMESPACE(generatorns_)
 
+ /// INTERNAL ONLY
+ template<>
+ struct is_callable<default_generator>
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ template<template<typename> class Extends>
+ struct is_callable<generator<Extends> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ template<template<typename> class Extends>
+ struct is_callable<pod_generator<Extends> >
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ template<>
+ struct is_callable<by_value_generator>
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ template<typename First, typename Second>
+ struct is_callable<compose_generators<First, Second> >
+ : mpl::true_
+ {};
+
     }}
 
     #endif // BOOST_PROTO_GENERATE_HPP_EAN_02_13_2007

Modified: branches/proto/v4/boost/proto/make_expr.hpp
==============================================================================
--- branches/proto/v4/boost/proto/make_expr.hpp (original)
+++ branches/proto/v4/boost/proto/make_expr.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -402,7 +402,7 @@
                 BOOST_MPL_ASSERT_MSG((false), PROTO_DOMAIN_MISMATCH, (select_nth));
                 typedef default_domain type;
             };
-
+
             template<typename Void = void>
             struct deduce_domain0
             {
@@ -809,7 +809,7 @@
             struct result
               : functional::make_expr<Tag, Domain>::template result<Sig>
             {};
-
+
             #define M0(Z, N, DATA) \
             template<BOOST_PP_ENUM_PARAMS_Z(Z, N, typename A)> \
             BOOST_PP_CAT(detail::implicit_expr_, N)<BOOST_PP_ENUM_PARAMS_Z(Z, N, A)> \
@@ -1013,7 +1013,7 @@
         // - If S contains only default_domain, the deduced domain is
         // default_domain.
         // - If S contains only X and default_domain, the deduced domain
- // is X.
+ // is X.
         // - If S contains different domains X and Y, neither of which is
         // default_domain, it is an error.
         template<BOOST_PP_ENUM_PARAMS(N, typename A)>

Modified: branches/proto/v4/boost/proto/matches.hpp
==============================================================================
--- branches/proto/v4/boost/proto/matches.hpp (original)
+++ branches/proto/v4/boost/proto/matches.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -641,7 +641,7 @@
             struct if_ : transform<if_<If, Then, Else> >
             {
                 typedef if_ proto_base_expr;
-
+
                 template<typename Expr, typename State, typename Data>
                 struct impl : transform_impl<Expr, State, Data>
                 {

Modified: branches/proto/v4/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v4/boost/proto/proto_fwd.hpp (original)
+++ branches/proto/v4/boost/proto/proto_fwd.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -406,7 +406,7 @@
             typename T
           , typename Domain = default_domain
           , typename Void = void
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
           , typename Void2 = void
           #endif
>
@@ -416,7 +416,7 @@
             typename T
           , typename Domain = default_domain
           , typename Void = void
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
           , typename Void2 = void
           #endif
>

Modified: branches/proto/v4/boost/proto/traits.hpp
==============================================================================
--- branches/proto/v4/boost/proto/traits.hpp (original)
+++ branches/proto/v4/boost/proto/traits.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -233,7 +233,7 @@
                 typename T
               , typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= default_domain)
               , typename Void BOOST_PROTO_WHEN_BUILDING_DOCS(= void)
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
               , typename Void2 BOOST_PROTO_WHEN_BUILDING_DOCS(= void)
               #endif
>
@@ -297,7 +297,7 @@
                 T
               , typename T::proto_domain
               , typename T::proto_is_expr_
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
               , void
               #endif
>
@@ -328,7 +328,7 @@
                 typename T
               , typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= default_domain)
               , typename Void BOOST_PROTO_WHEN_BUILDING_DOCS(= void)
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
               , typename Void2 BOOST_PROTO_WHEN_BUILDING_DOCS(= void)
               #endif
>
@@ -361,7 +361,7 @@
                 T
               , Domain
               , typename T::proto_is_expr_
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
               , typename disable_if<is_same<Domain, typename T::proto_domain> >::type
               #endif
>
@@ -393,7 +393,7 @@
                 T
               , typename T::proto_domain
               , typename T::proto_is_expr_
- #ifdef BOOST_PROTO_BROKEN_PTS
+ #ifdef BOOST_PROTO_BROKEN_PTS
               , void
               #endif
>
@@ -428,7 +428,7 @@
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::proto_child0 value_type;
-
+
                 /// The "value" type of the child, suitable for return by value,
                 /// computed as follows:
                 /// \li <tt>T const(&)[N]</tt> becomes <tt>T const(&)[N]</tt>
@@ -466,7 +466,7 @@
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::proto_child0 value_type;
-
+
                 /// The "const reference" type of the child, suitable for return by
                 /// const reference, computed as follows:
                 /// \li <tt>T const(&)[N]</tt> becomes <tt>T const(&)[N]</tt>
@@ -519,7 +519,7 @@
                 struct impl : transform_impl<Expr, State, Data>
                 {
                     typedef Expr result_type;
-
+
                     /// \param expr The current expression
                     /// \pre <tt>matches\<Expr, terminal\<T\> \>::::value</tt> is \c true.
                     /// \return \c expr
@@ -2309,7 +2309,7 @@
                 /// The raw type of the Nth child as it is stored within
                 /// \c Expr. This may be a value or a reference
                 typedef typename Expr::BOOST_PP_CAT(proto_child, N) value_type;
-
+
                 /// The "const reference" type of the child, suitable for return by
                 /// const reference, computed as follows:
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>

Modified: branches/proto/v4/boost/proto/transform/call.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/call.hpp (original)
+++ branches/proto/v4/boost/proto/transform/call.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -246,7 +246,7 @@
                     );
                 }
             };
-
+
                 /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt> and \c X
                 /// be the type of \c x.
                 /// Let \c y be <tt>when\<_, A1\>()(expr, state, data)</tt> and \c Y

Modified: branches/proto/v4/boost/proto/transform/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/default.hpp (original)
+++ branches/proto/v4/boost/proto/transform/default.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -16,6 +16,9 @@
     #include <boost/preprocessor/repetition/repeat.hpp>
     #include <boost/preprocessor/repetition/enum_shifted.hpp>
     #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
+ #include <boost/ref.hpp>
+ #include <boost/utility/enable_if.hpp>
+ #include <boost/type_traits/is_member_pointer.hpp>
     #include <boost/proto/proto_fwd.hpp>
     #include <boost/proto/traits.hpp>
     #include <boost/proto/transform/impl.hpp>
@@ -25,6 +28,33 @@
 
     namespace boost { namespace proto
     {
+ namespace detail
+ {
+ template<typename T>
+ T &deref(T &t)
+ {
+ return t;
+ }
+
+ template<typename T>
+ T const &deref(T const &t)
+ {
+ return t;
+ }
+
+ template<typename T>
+ T &deref(T *&t)
+ {
+ return *t;
+ }
+
+ template<typename T>
+ T &deref(T *const &t)
+ {
+ return *t;
+ }
+ }
+
         template<typename Grammar>
         struct _default
           : transform<_default<Grammar> >
@@ -232,6 +262,30 @@
                 }
             };
 
+ template<typename Expr, typename State, typename Data>
+ struct impl2<Expr, State, Data, tag::comma, 2>
+ : transform_impl<Expr, State, Data>
+ {
+ private:
+ typedef typename result_of::child_c<Expr, 0>::type e0;
+ typedef typename result_of::child_c<Expr, 1>::type e1;
+ typedef typename Grammar::template impl<e0, State, Data>::result_type r0;
+ typedef typename Grammar::template impl<e1, State, Data>::result_type r1;
+ public:
+ typedef typename proto::detail::comma_result<r0, r1>::type result_type;
+ result_type operator ()(
+ typename impl2::expr_param expr
+ , typename impl2::state_param state
+ , typename impl2::data_param data
+ ) const
+ {
+ typename Grammar::template impl<e0, State, Data> t0;
+ typename Grammar::template impl<e1, State, Data> t1;
+ return t0(proto::child_c<0>(expr), state, data)
+ , t1(proto::child_c<1>(expr), state, data);
+ }
+ };
+
             #define EVAL_TYPE(Z, N, DATA) \
                 typedef \
                     typename result_of::child_c<DATA, N>::type \
@@ -283,25 +337,60 @@
           : transform_impl<Expr, State, Data>
         {
             BOOST_PP_REPEAT(N, EVAL_TYPE, Expr)
-
+
             typedef
- typename proto::detail::result_of_fixup<e0>::type
+ typename proto::detail::result_of_fixup<r0>::type
             function_type;
 
             typedef
                 typename boost::result_of<
- function_type(BOOST_PP_ENUM_SHIFTED_PARAMS(N, e))
+ function_type(BOOST_PP_ENUM_SHIFTED_PARAMS(N, r))
>::type
             result_type;
 
+ #if N == 1
+ result_type operator ()(
+ typename impl2::expr_param expr
+ , typename impl2::state_param state
+ , typename impl2::data_param data
+ ) const
+ {
+ return EVAL(~, 0, expr)(BOOST_PP_ENUM_SHIFTED(N, EVAL, expr));
+ }
+ #else
             result_type operator ()(
                 typename impl2::expr_param expr
               , typename impl2::state_param state
               , typename impl2::data_param data
             ) const
             {
+ return this->invoke(expr, state, data, is_member_pointer<function_type>());
+ }
+
+ result_type invoke(
+ typename impl2::expr_param expr
+ , typename impl2::state_param state
+ , typename impl2::data_param data
+ , mpl::false_
+ ) const
+ {
                 return EVAL(~, 0, expr)(BOOST_PP_ENUM_SHIFTED(N, EVAL, expr));
             }
+
+ result_type invoke(
+ typename impl2::expr_param expr
+ , typename impl2::state_param state
+ , typename impl2::data_param data
+ , mpl::true_
+ ) const
+ {
+ #define M0(Z, M, expr) BOOST_PP_COMMA_IF(BOOST_PP_SUB(M, 2)) EVAL(Z, M, expr)
+ return (detail::deref(EVAL(~, 1, expr)) .* EVAL(~, 0, expr))(
+ BOOST_PP_REPEAT_FROM_TO(2, N, M0, expr)
+ );
+ #undef M0
+ }
+ #endif
         };
 
     #undef N

Modified: branches/proto/v4/boost/proto/transform/fold.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/fold.hpp (original)
+++ branches/proto/v4/boost/proto/transform/fold.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -226,7 +226,7 @@
                       , fun
>::type
                 result_type;
-
+
                 /// Let \c seq be <tt>when\<_, Sequence\>()(expr, state, data)</tt>, let
                 /// \c state0 be <tt>when\<_, State0\>()(expr, state, data)</tt>, and
                 /// let \c fun(data) be an object such that <tt>fun(data)(expr, state)</tt>

Modified: branches/proto/v4/boost/proto/transform/make.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/make.hpp (original)
+++ branches/proto/v4/boost/proto/transform/make.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -357,7 +357,7 @@
             struct impl : transform_impl<Expr, State, Data>
             {
                 typedef proto::expr<Tag, Args, Arity> result_type;
-
+
                 result_type operator ()(
                     typename impl::expr_param expr
                   , typename impl::state_param state

Modified: branches/proto/v4/boost/proto/transform/when.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/when.hpp (original)
+++ branches/proto/v4/boost/proto/transform/when.hpp 2008-04-20 16:12:12 EDT (Sun, 20 Apr 2008)
@@ -162,7 +162,7 @@
                 which;
 
                 typedef typename which::template impl<Expr, State, Data>::result_type result_type;
-
+
                 /// Evaluate <tt>R(A0,A1,...)</tt> as a transform either with
                 /// <tt>call\<\></tt> or with <tt>make\<\></tt> depending on
                 /// whether <tt>is_callable\<R\>::::value</tt> is \c true or


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