Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-01-31 13:44:18


Author: eric_niebler
Date: 2008-01-31 13:44:17 EST (Thu, 31 Jan 2008)
New Revision: 43035
URL: http://svn.boost.org/trac/boost/changeset/43035

Log:
minor tweak to fusion value_of and value_at for expressions, for better interop with proto::unpack_expr
Text files modified:
   trunk/boost/xpressive/proto/fusion.hpp | 61 +++++++++++++++++++++++++++++++++------
   trunk/boost/xpressive/proto/make_expr.hpp | 12 -------
   trunk/boost/xpressive/proto/proto_fwd.hpp | 18 ++++++++---
   trunk/boost/xpressive/proto/traits.hpp | 14 +++++++-
   4 files changed, 75 insertions(+), 30 deletions(-)

Modified: trunk/boost/xpressive/proto/fusion.hpp
==============================================================================
--- trunk/boost/xpressive/proto/fusion.hpp (original)
+++ trunk/boost/xpressive/proto/fusion.hpp 2008-01-31 13:44:17 EST (Thu, 31 Jan 2008)
@@ -58,7 +58,7 @@
           : fusion::iterator_base<expr_iterator<Expr, Pos> >
         {
             typedef Expr expr_type;
- static long const index = Pos;
+ BOOST_STATIC_CONSTANT(long, index = Pos);
             BOOST_PROTO_DEFINE_FUSION_CATEGORY(fusion::random_access_traversal_tag)
             BOOST_PROTO_DEFINE_FUSION_TAG(tag::proto_expr_iterator)
 
@@ -310,13 +310,29 @@
         template<>
         struct value_of_impl<proto::tag::proto_expr_iterator>
         {
- template<typename Iterator>
- struct apply
- : proto::result_of::arg_c<
+ template<
+ typename Iterator
+ , typename Value = typename proto::result_of::arg_c<
                     typename Iterator::expr_type
                   , Iterator::index
- >
- {};
+ >::wrapped_type
+ >
+ struct apply
+ {
+ typedef Value type;
+ };
+
+ template<typename Iterator, typename Expr>
+ struct apply<Iterator, proto::ref_<Expr> >
+ {
+ typedef Expr &type;
+ };
+
+ template<typename Iterator, typename Expr>
+ struct apply<Iterator, Expr &>
+ {
+ typedef Expr &type;
+ };
         };
 
         #if BOOST_VERSION < 103500
@@ -485,10 +501,30 @@
         template<>
         struct value_at_impl<proto::tag::proto_expr>
         {
- template<typename Sequence, typename Index>
+ template<
+ typename Sequence
+ , typename Index
+ , typename Value = typename proto::result_of::arg_c<
+ Sequence
+ , Index::value
+ >::wrapped_type
+ >
             struct apply
- : proto::result_of::arg_c<Sequence, Index::value>
- {};
+ {
+ typedef Value type;
+ };
+
+ template<typename Sequence, typename Index, typename Expr>
+ struct apply<Sequence, Index, proto::ref_<Expr> >
+ {
+ typedef Expr &type;
+ };
+
+ template<typename Sequence, typename Index, typename Expr>
+ struct apply<Sequence, Index, Expr &>
+ {
+ typedef Expr &type;
+ };
         };
 
         template<typename Tag>
@@ -500,7 +536,12 @@
             template<typename Sequence, typename Index>
             struct apply
             {
- typedef typename proto::result_of::arg_c<Sequence, Index::value>::type const &type;
+ typedef
+ typename proto::result_of::arg_c<
+ Sequence
+ , Index::value
+ >::const_reference
+ type;
 
                 static type call(Sequence &seq)
                 {

Modified: trunk/boost/xpressive/proto/make_expr.hpp
==============================================================================
--- trunk/boost/xpressive/proto/make_expr.hpp (original)
+++ trunk/boost/xpressive/proto/make_expr.hpp 2008-01-31 13:44:17 EST (Thu, 31 Jan 2008)
@@ -660,18 +660,6 @@
                 };
 
                 template<typename Sequence>
- typename proto::result_of::unpack_expr<Tag, Domain, Sequence>::type
- operator ()(Sequence &sequence BOOST_PROTO_DISABLE_IF_IS_CONST(Sequence)) const
- {
- return proto::detail::unpack_expr_<
- Tag
- , Domain
- , Sequence
- , fusion::BOOST_PROTO_FUSION_RESULT_OF::size<Sequence>::type::value
- >::call(sequence);
- }
-
- template<typename Sequence>
                 typename proto::result_of::unpack_expr<Tag, Domain, Sequence const>::type const
                 operator ()(Sequence const &sequence) const
                 {

Modified: trunk/boost/xpressive/proto/proto_fwd.hpp
==============================================================================
--- trunk/boost/xpressive/proto/proto_fwd.hpp (original)
+++ trunk/boost/xpressive/proto/proto_fwd.hpp 2008-01-31 13:44:17 EST (Thu, 31 Jan 2008)
@@ -236,14 +236,22 @@
         template<
             typename Grammar0
           , typename Grammar1
- , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2), typename G, void)
+ , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
+ BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2)
+ , typename G
+ , void
+ )
>
         struct or_;
 
         template<
             typename Grammar0
           , typename Grammar1
- , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2), typename G, void)
+ , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
+ BOOST_PP_SUB(BOOST_PROTO_MAX_LOGICAL_ARITY,2)
+ , typename G
+ , void
+ )
>
         struct and_;
 
@@ -343,17 +351,17 @@
 
         template<
             typename Tag
+ , typename DomainOrA0
             BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
                 BOOST_PROTO_MAX_ARITY
               , typename A
               , = void BOOST_PP_INTERCEPT
             )
- , typename _1 = void
- , typename _2 = void
+ , typename EnableIf = void
>
         struct make_expr;
 
- template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename _ = void>
+ template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename EnableIf = void>
         struct unpack_expr;
 
         template<typename T, typename EnableIf = void>

Modified: trunk/boost/xpressive/proto/traits.hpp
==============================================================================
--- trunk/boost/xpressive/proto/traits.hpp (original)
+++ trunk/boost/xpressive/proto/traits.hpp 2008-01-31 13:44:17 EST (Thu, 31 Jan 2008)
@@ -785,14 +785,22 @@
         {
             template<typename Expr>
             struct arg_c<Expr, N>
- : unref<typename Expr::BOOST_PP_CAT(proto_arg, N)>
             {
- static typename arg_c<Expr, N>::reference call(Expr &expr)
+ typedef typename Expr::BOOST_PP_CAT(proto_arg, N) wrapped_type;
+ typedef typename unref<wrapped_type>::type type;
+ typedef typename unref<wrapped_type>::reference reference;
+ typedef typename unref<wrapped_type>::const_reference const_reference;
+
+ /// INTERNAL ONLY
+ ///
+ static reference call(Expr &expr)
                 {
                     return proto::unref(expr.proto_base().BOOST_PP_CAT(arg, N));
                 }
 
- static typename arg_c<Expr, N>::const_reference call(Expr const &expr)
+ /// INTERNAL ONLY
+ ///
+ static const_reference call(Expr const &expr)
                 {
                     return proto::unref(expr.proto_base().BOOST_PP_CAT(arg, N));
                 }


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