Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-04-18 20:16:07


Author: eric_niebler
Date: 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
New Revision: 44563
URL: http://svn.boost.org/trac/boost/changeset/44563

Log:
eliminate need for child_traits, handle function references as terminals correctly
Removed:
   branches/proto/v4/boost/proto/detail/child_traits.hpp
Text files modified:
   branches/proto/v4/boost/proto/args.hpp | 58 +++++++++++++++++++++++++-
   branches/proto/v4/boost/proto/context/callable.hpp | 69 +++++++++++++++++++++++++++-----
   branches/proto/v4/boost/proto/expr.hpp | 15 -------
   branches/proto/v4/boost/proto/extends.hpp | 3 +
   branches/proto/v4/boost/proto/fusion.hpp | 73 ++++++++++++++++++++++++++++-----
   branches/proto/v4/boost/proto/generate.hpp | 8 +--
   branches/proto/v4/boost/proto/literal.hpp | 6 +-
   branches/proto/v4/boost/proto/proto_fwd.hpp | 3
   branches/proto/v4/boost/proto/traits.hpp | 85 +++++++++++++++++++++++++++++----------
   branches/proto/v4/boost/proto/transform/arg.hpp | 33 +++++++++++++++
   branches/proto/v4/boost/xpressive/detail/static/transforms/as_action.hpp | 7 ++
   branches/proto/v4/boost/xpressive/detail/static/transforms/as_independent.hpp | 5 +
   branches/proto/v4/boost/xpressive/regex_actions.hpp | 3
   branches/proto/v4/boost/xpressive/regex_primitives.hpp | 3
   branches/proto/v4/libs/proto/test/toy_spirit2.cpp | 2
   15 files changed, 294 insertions(+), 79 deletions(-)

Modified: branches/proto/v4/boost/proto/args.hpp
==============================================================================
--- branches/proto/v4/boost/proto/args.hpp (original)
+++ branches/proto/v4/boost/proto/args.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -19,6 +19,8 @@
     #include <boost/preprocessor/repetition/enum_params.hpp>
     #include <boost/preprocessor/repetition/repeat.hpp>
     #include <boost/preprocessor/repetition/repeat_from_to.hpp>
+ #include <boost/type_traits/is_function.hpp>
+ #include <boost/mpl/if.hpp>
     #include <boost/mpl/void.hpp>
     #include <boost/proto/proto_fwd.hpp>
     #include <boost/proto/detail/suffix.hpp>
@@ -47,6 +49,9 @@
             typedef typename Expr::proto_args proto_args;
             typedef typename Expr::proto_arity proto_arity;
             typedef typename Expr::proto_domain proto_domain;
+ typedef proto_derived_expr value_type;
+ typedef Expr &reference;
+ typedef Expr const &const_reference;
         };
 
         /// INTERNAL ONLY
@@ -59,27 +64,72 @@
             typedef typename Expr::proto_args proto_args;
             typedef typename Expr::proto_arity proto_arity;
             typedef typename Expr::proto_domain proto_domain;
+ typedef proto_derived_expr value_type;
+ typedef Expr &reference;
+ typedef Expr &const_reference;
         };
-
+
         /// INTERNAL ONLY
         template<typename T>
         struct term_ref
         {
- typedef T type;
+ typedef T value_type;
+ typedef T &reference;
+ typedef T const &const_reference;
         };
 
         /// INTERNAL ONLY
         template<typename T>
         struct term_ref<T &>
         {
- typedef T type;
+ typedef typename mpl::if_c<is_function<T>::value, T &, T>::type value_type;
+ typedef T &reference;
+ typedef T &const_reference;
         };
 
         /// INTERNAL ONLY
         template<typename T>
         struct term_ref<T const &>
         {
- typedef T type;
+ typedef T value_type;
+ typedef T const &reference;
+ typedef T const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_ref<T (&)[N]>
+ {
+ typedef T (&value_type)[N];
+ typedef T (&reference)[N];
+ typedef T (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_ref<T const (&)[N]>
+ {
+ typedef T const (&value_type)[N];
+ typedef T const (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_ref<T[N]>
+ {
+ typedef T (&value_type)[N];
+ typedef T (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_ref<T const[N]>
+ {
+ typedef T const (&value_type)[N];
+ typedef T const (&reference)[N];
+ typedef T const (&const_reference)[N];
         };
 
         /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.

Modified: branches/proto/v4/boost/proto/context/callable.hpp
==============================================================================
--- branches/proto/v4/boost/proto/context/callable.hpp (original)
+++ branches/proto/v4/boost/proto/context/callable.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -48,6 +48,25 @@
 
             template<typename Expr, typename Context, long Arity = Expr::proto_arity::value>
             struct is_expr_handled;
+
+ template<typename Expr, typename Context>
+ struct is_expr_handled<Expr, Context, 0>
+ {
+ static callable_context_wrapper<Context, 1> &sctx_;
+ static Expr &sexpr_;
+ static typename Expr::proto_tag &stag_;
+
+ BOOST_STATIC_CONSTANT(bool, value =
+ (
+ sizeof(yes_type) ==
+ sizeof(
+ detail::check_is_expr_handled(
+ (sctx_(stag_, proto::value(sexpr_)), 0)
+ )
+ )));
+
+ typedef mpl::bool_<value> type;
+ };
         }
 
         namespace context
@@ -72,6 +91,38 @@
             struct callable_eval
             {};
 
+ /// \brief A BinaryFunction that accepts a Proto expression and a
+ /// callable context and calls the context with the expression tag
+ /// and children as arguments, effectively fanning the expression
+ /// out.
+ ///
+ /// <tt>callable_eval\<\></tt> requires that \c Context is a
+ /// PolymorphicFunctionObject that can be invoked with \c Expr's
+ /// tag and children as expressions, as follows:
+ ///
+ /// \code
+ /// context(Expr::proto_tag(), value(expr))
+ /// \endcode
+ template<typename Expr, typename Context>
+ struct callable_eval<Expr, Context, 0>
+ {
+ typedef typename proto::result_of::value<Expr const &>::type value_type;
+
+ typedef
+ typename boost::result_of<
+ Context(typename Expr::proto_tag, value_type)
+ >::type
+ result_type;
+
+ /// \param expr The current expression
+ /// \param context The callable evaluation context
+ /// \return <tt>context(Expr::proto_tag(), value(expr))</tt>
+ result_type operator ()(Expr &expr, Context &context) const
+ {
+ return context(typename Expr::proto_tag(), proto::value(expr));
+ }
+ };
+
             /// \brief An evaluation context adaptor that makes authoring a
             /// context a simple matter of writing function overloads, rather
             /// then writing template specializations.
@@ -176,7 +227,7 @@
         /**/
 
     #define BOOST_PP_ITERATION_PARAMS_1 \
- (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/context/callable.hpp>)) \
+ (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/context/callable.hpp>)) \
         /**/
 
     #include BOOST_PP_ITERATE()
@@ -191,11 +242,9 @@
 #else
 
     #define N BOOST_PP_ITERATION()
- #define ARG_COUNT BOOST_PP_MAX(1, N)
 
         namespace detail
         {
- #if N > 0
             template<typename Context>
             struct callable_context_wrapper<Context, N>
               : remove_cv<Context>::type
@@ -204,18 +253,17 @@
                 typedef
                     private_type_ const &fun_type(
                         BOOST_PP_ENUM_PARAMS(
- BOOST_PP_INC(ARG_COUNT)
+ BOOST_PP_INC(N)
                           , detail::dont_care BOOST_PP_INTERCEPT
                         )
                     );
                 operator fun_type *() const;
             };
- #endif
 
             template<typename Expr, typename Context>
             struct is_expr_handled<Expr, Context, N>
             {
- static callable_context_wrapper<Context, ARG_COUNT> &sctx_;
+ static callable_context_wrapper<Context, N> &sctx_;
                 static Expr &sexpr_;
                 static typename Expr::proto_tag &stag_;
 
@@ -226,7 +274,7 @@
                         detail::check_is_expr_handled(
                             (sctx_(
                                 stag_
- BOOST_PP_ENUM_TRAILING(ARG_COUNT, BOOST_PROTO_CHILD_N, sexpr_)
+ BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, sexpr_)
                             ), 0)
                         )
                 )));
@@ -252,13 +300,13 @@
             template<typename Expr, typename Context>
             struct callable_eval<Expr, Context, N>
             {
- BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD_N_TYPE, Expr)
+ BOOST_PP_REPEAT(N, BOOST_PROTO_CHILD_N_TYPE, Expr)
 
                 typedef
                     typename boost::result_of<
                         Context(
                             typename Expr::proto_tag
- BOOST_PP_ENUM_TRAILING_PARAMS(ARG_COUNT, child)
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, child)
                         )
>::type
                 result_type;
@@ -270,13 +318,12 @@
                 {
                     return context(
                         typename Expr::proto_tag()
- BOOST_PP_ENUM_TRAILING(ARG_COUNT, BOOST_PROTO_CHILD_N, expr)
+ BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_CHILD_N, expr)
                     );
                 }
             };
         }
 
     #undef N
- #undef ARG_COUNT
 
 #endif

Deleted: branches/proto/v4/boost/proto/detail/child_traits.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/child_traits.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
+++ (empty file)
@@ -1,89 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file child_traits.hpp
-/// Traits class for calculating properties of expression node children.
-//
-// Copyright 2008 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_DETAIL_CHILD_TRAITS_HPP_EAN_04_06_2008
-#define BOOST_PROTO_DETAIL_CHILD_TRAITS_HPP_EAN_04_06_2008
-
-namespace boost { namespace proto
-{
- namespace detail
- {
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T>
- struct child_traits
- {
- typedef T value_type; ///< Suitable for return by value
- typedef T &reference; ///< Suitable for return by reference
- typedef T const &const_reference; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T>
- struct child_traits<T &>
- {
- typedef T value_type; ///< Suitable for return by value
- typedef T &reference; ///< Suitable for return by reference
- typedef T &const_reference; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T>
- struct child_traits<T const &>
- {
- typedef T value_type; ///< Suitable for return by value
- typedef T const &reference; ///< Suitable for return by reference
- typedef T const &const_reference; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T, std::size_t N>
- struct child_traits<T (&)[N]>
- {
- typedef T (&value_type)[N]; ///< Suitable for return by value
- typedef T (&reference)[N]; ///< Suitable for return by reference
- typedef T (&const_reference)[N]; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T, std::size_t N>
- struct child_traits<T const (&)[N]>
- {
- typedef T const (&value_type)[N]; ///< Suitable for return by value
- typedef T const (&reference)[N]; ///< Suitable for return by reference
- typedef T const (&const_reference)[N]; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T, std::size_t N>
- struct child_traits<T[N]>
- {
- typedef T (&value_type)[N]; ///< Suitable for return by value
- typedef T (&reference)[N]; ///< Suitable for return by reference
- typedef T const (&const_reference)[N]; ///< Suitable for return by const reference
- };
-
- /// \brief Trait for stripping top-level references
- /// and reference wrappers.
- template<typename T, std::size_t N>
- struct child_traits<T const[N]>
- {
- typedef T const (&value_type)[N]; ///< Suitable for return by value
- typedef T const (&reference)[N]; ///< Suitable for return by reference
- typedef T const (&const_reference)[N]; ///< Suitable for return by const reference
- };
- }
-
-}}
-
-#endif

Modified: branches/proto/v4/boost/proto/expr.hpp
==============================================================================
--- branches/proto/v4/boost/proto/expr.hpp (original)
+++ branches/proto/v4/boost/proto/expr.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -26,7 +26,6 @@
     #include <boost/proto/proto_fwd.hpp>
     #include <boost/proto/args.hpp>
     #include <boost/proto/traits.hpp>
- #include <boost/proto/detail/child_traits.hpp>
     #include <boost/proto/detail/suffix.hpp>
 
     #if defined(_MSC_VER) && (_MSC_VER >= 1020)
@@ -56,18 +55,6 @@
             typedef void BOOST_PP_CAT(proto_child_ref, N); \
             /**/
 
- /// INTERNAL ONLY
- ///
- #define BOOST_PROTO_UNREF_CHILD_TYPE(Z, N, DATA) \
- typename detail::child_traits<typename Args::BOOST_PP_CAT(child, N)>::const_reference \
- /**/
-
- /// INTERNAL ONLY
- ///
- #define BOOST_PROTO_UNREF_CHILD(Z, N, DATA) \
- this->BOOST_PP_CAT(child, N) \
- /**/
-
             template<typename Tag, typename Arg>
             struct address_of_hack
             {
@@ -119,8 +106,6 @@
 
         #undef BOOST_PROTO_CHILD
         #undef BOOST_PROTO_VOID
- #undef BOOST_PROTO_UNREF_CHILD_TYPE
- #undef BOOST_PROTO_UNREF_CHILD
     }}
 
     #if defined(_MSC_VER) && (_MSC_VER >= 1020)

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-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -99,6 +99,9 @@
         typedef \
             typename proto_base_expr::BOOST_PP_CAT(proto_child, N) \
         BOOST_PP_CAT(proto_child, N); \
+ typedef \
+ typename proto_base_expr::BOOST_PP_CAT(proto_child_ref, N) \
+ BOOST_PP_CAT(proto_child_ref, N); \
         /**/
 
     #define 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-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -67,6 +67,7 @@
           : fusion::iterator_base<expr_iterator<Expr, Pos> >
         {
             typedef Expr expr_type;
+ typedef typename Expr::proto_tag proto_tag;
             BOOST_STATIC_CONSTANT(long, index = Pos);
             BOOST_PROTO_FUSION_DEFINE_CATEGORY(fusion::random_access_traversal_tag)
             BOOST_PROTO_FUSION_DEFINE_TAG(tag::proto_expr_iterator)
@@ -338,7 +339,10 @@
         template<>
         struct value_of_impl<proto::tag::proto_expr_iterator>
         {
- template<typename Iterator>
+ template<
+ typename Iterator
+ , long Arity = proto::arity_of<typename Iterator::expr_type>::value
+ >
             struct apply
             {
                 typedef
@@ -348,6 +352,16 @@
>::value_type
                 type;
             };
+
+ template<typename Iterator>
+ struct apply<Iterator, 0>
+ {
+ typedef
+ typename proto::result_of::value<
+ typename Iterator::expr_type
+ >::value_type
+ type;
+ };
         };
 
         #if BOOST_VERSION < 103500
@@ -366,14 +380,17 @@
         template<>
         struct deref_impl<proto::tag::proto_expr_iterator>
         {
- template<typename Iterator>
+ template<
+ typename Iterator
+ , long Arity = proto::arity_of<typename Iterator::expr_type>::value
+ >
             struct apply
             {
                 typedef
                     typename proto::result_of::child_c<
- typename Iterator::expr_type const
+ typename Iterator::expr_type const &
                       , Iterator::index
- >::type const &
+ >::type
                 type;
 
                 static type call(Iterator const &iter)
@@ -381,6 +398,21 @@
                     return proto::child_c<Iterator::index>(iter.expr);
                 }
             };
+
+ template<typename Iterator>
+ struct apply<Iterator, 0>
+ {
+ typedef
+ typename proto::result_of::value<
+ typename Iterator::expr_type const &
+ >::type
+ type;
+
+ static type call(Iterator const &iter)
+ {
+ return proto::value(iter.expr);
+ }
+ };
         };
 
         template<typename Tag>
@@ -516,7 +548,11 @@
         template<>
         struct value_at_impl<proto::tag::proto_expr>
         {
- template<typename Sequence, typename Index>
+ template<
+ typename Sequence
+ , typename Index
+ , long Arity = proto::arity_of<Sequence>::value
+ >
             struct apply
             {
                 typedef
@@ -526,6 +562,16 @@
>::value_type
                 type;
             };
+
+ template<typename Sequence, typename Index>
+ struct apply<Sequence, Index, 0>
+ {
+ typedef
+ typename proto::result_of::value<
+ Sequence
+ >::value_type
+ type;
+ };
         };
 
         template<typename Tag>
@@ -534,7 +580,11 @@
         template<>
         struct at_impl<proto::tag::proto_expr>
         {
- template<typename Sequence, typename Index>
+ template<
+ typename Sequence
+ , typename Index
+ , long Arity = proto::arity_of<Sequence>::value
+ >
             struct apply
             {
                 typedef
@@ -551,18 +601,17 @@
             };
 
             template<typename Sequence, typename Index>
- struct apply<Sequence const, Index>
+ struct apply<Sequence, Index, 0>
             {
                 typedef
- typename proto::result_of::child_c<
- Sequence const &
- , Index::value
+ typename proto::result_of::value<
+ Sequence &
>::type
                 type;
 
- static type call(Sequence const &seq)
+ static type call(Sequence &seq)
                 {
- return proto::child_c<Index::value>(seq);
+ return proto::value(seq);
                 }
             };
         };

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-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -55,9 +55,7 @@
             struct by_value_generator_;
 
         #define BOOST_PROTO_DEFINE_BY_VALUE_TYPE(Z, N, Expr) \
- typename detail::child_traits< \
- typename expr_traits<Expr>::args::BOOST_PP_CAT(child, N) \
- >::value_type \
+ typename expr_traits<Expr>::args::BOOST_PP_CAT(child_ref, N)::proto_derived_expr \
             /**/
 
         #define BOOST_PROTO_DEFINE_BY_VALUE(Z, N, expr) \
@@ -69,7 +67,7 @@
             {
                 typedef proto::expr<
                     tag::terminal
- , term<BOOST_PROTO_DEFINE_BY_VALUE_TYPE(~, 0, Expr) >
+ , term<typename expr_traits<Expr>::args::child_ref0::value_type>
> type;
 
                 static type const make(Expr const &expr)
@@ -263,7 +261,7 @@
                 typedef proto::expr<
                     typename expr_traits<Expr>::tag
                   , BOOST_PP_CAT(list, N)<
- // typename detail::child_traits<typename expr_traits<Expr>::args::child0>::value_type, ...
+ // typename expr_traits<Expr>::args::child_ref0::proto_derived_expr, ...
                         BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_BY_VALUE_TYPE, Expr)
>
> type;

Modified: branches/proto/v4/boost/proto/literal.hpp
==============================================================================
--- branches/proto/v4/boost/proto/literal.hpp (original)
+++ branches/proto/v4/boost/proto/literal.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -43,9 +43,9 @@
             typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
 
         public:
- typedef typename proto::detail::child_traits<T>::value_type value_type;
- typedef typename proto::detail::child_traits<T>::reference reference;
- typedef typename proto::detail::child_traits<T>::const_reference const_reference;
+ typedef typename terminal_type::proto_child_ref0::value_type value_type;
+ typedef typename terminal_type::proto_child_ref0::reference reference;
+ typedef typename terminal_type::proto_child_ref0::const_reference const_reference;
 
             template<typename U>
             literal(U &u)

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-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -745,13 +745,14 @@
     struct _state;
     struct _data;
 
+ struct _value;
+
     template<int I>
     struct _child_c;
 
     typedef _child_c<0> _child0;
     typedef _child_c<1> _child1;
     typedef _child0 _child;
- typedef _child0 _value;
     typedef _child0 _left;
     typedef _child1 _right;
 

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-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -43,7 +43,6 @@
     #include <boost/proto/proto_fwd.hpp>
     #include <boost/proto/args.hpp>
     #include <boost/proto/tags.hpp>
- #include <boost/proto/detail/child_traits.hpp>
     #include <boost/proto/transform/pass_through.hpp>
     #include <boost/proto/detail/suffix.hpp>
 
@@ -425,8 +424,60 @@
             ///
             template<typename Expr>
             struct value
- : child_c<Expr, 0>
- {};
+ {
+ /// 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>
+ /// \li <tt>T[N]</tt> becomes <tt>T(&)[N]</tt>
+ /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
+ /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
+ /// \li <tt>T const &</tt> becomes <tt>T</tt>
+ /// \li <tt>T &</tt> becomes <tt>T</tt>
+ /// \li <tt>T</tt> becomes <tt>T</tt>
+ typedef typename Expr::proto_child_ref0::value_type type;
+ };
+
+ template<typename Expr>
+ struct value<Expr &>
+ {
+ /// 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 "reference" type of the child, suitable for return by
+ /// reference, computed as follows:
+ /// \li <tt>T const(&)[N]</tt> becomes <tt>T const(&)[N]</tt>
+ /// \li <tt>T[N]</tt> becomes <tt>T(&)[N]</tt>
+ /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
+ /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
+ /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
+ /// \li <tt>T &</tt> becomes <tt>T &</tt>
+ /// \li <tt>T</tt> becomes <tt>T &</tt>
+ typedef typename Expr::proto_child_ref0::reference type;
+ };
+
+ template<typename Expr>
+ struct value<Expr const &>
+ {
+ /// 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>
+ /// \li <tt>T[N]</tt> becomes <tt>T const(&)[N]</tt>
+ /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
+ /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
+ /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
+ /// \li <tt>T &</tt> becomes <tt>T &</tt>
+ /// \li <tt>T</tt> becomes <tt>T const &</tt>
+ typedef typename Expr::proto_child_ref0::const_reference type;
+ };
 
             // TODO left<> and right<> force the instantiation of Expr.
             // Couldn't we partially specialize them on proto::expr< T, A >
@@ -1953,7 +2004,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename detail::child_traits<typename Expr2::proto_base_expr::proto_child0>::reference
+ typename Expr2::proto_base_expr::proto_child_ref0::reference
         child(Expr2 &expr2 BOOST_PROTO_DISABLE_IF_IS_CONST(Expr2))
         {
             return expr2.proto_base().child0;
@@ -1962,7 +2013,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename detail::child_traits<typename Expr2::proto_base_expr::proto_child0>::const_reference
+ typename Expr2::proto_base_expr::proto_child_ref0::const_reference
         child(Expr2 const &expr2)
         {
             return expr2.proto_base().child0;
@@ -2224,16 +2275,12 @@
 
                 /// 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>
- /// \li <tt>T[N]</tt> becomes <tt>T(&)[N]</tt>
- /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
- /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
                 /// \li <tt>T const &</tt> becomes <tt>T</tt>
                 /// \li <tt>T &</tt> becomes <tt>T</tt>
                 /// \li <tt>T</tt> becomes <tt>T</tt>
- typedef typename detail::child_traits<value_type>::value_type type;
+ typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::value_type type;
             };
-
+
             template<typename Expr>
             struct child_c<Expr &, N>
             {
@@ -2243,15 +2290,11 @@
 
                 /// The "reference" type of the child, suitable for return by
                 /// reference, computed as follows:
- /// \li <tt>T const(&)[N]</tt> becomes <tt>T const(&)[N]</tt>
- /// \li <tt>T[N]</tt> becomes <tt>T(&)[N]</tt>
- /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
- /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T &</tt>
- typedef typename detail::child_traits<value_type>::reference type;
-
+ typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::reference type;
+
                 /// INTERNAL ONLY
                 ///
                 static type call(Expr &expr)
@@ -2259,7 +2302,7 @@
                     return expr.proto_base().BOOST_PP_CAT(child, N);
                 }
             };
-
+
             template<typename Expr>
             struct child_c<Expr const &, N>
             {
@@ -2269,14 +2312,10 @@
                 
                 /// 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>
- /// \li <tt>T[N]</tt> becomes <tt>T const(&)[N]</tt>
- /// \li <tt>T(&)[N]</tt> becomes <tt>T(&)[N]</tt>
- /// \li <tt>R(&)(A0,...)</tt> becomes <tt>R(&)(A0,...)</tt>
                 /// \li <tt>T const &</tt> becomes <tt>T const &</tt>
                 /// \li <tt>T &</tt> becomes <tt>T &</tt>
                 /// \li <tt>T</tt> becomes <tt>T const &</tt>
- typedef typename detail::child_traits<value_type>::const_reference type;
+ typedef typename Expr::BOOST_PP_CAT(proto_child_ref, N)::const_reference type;
 
                 /// INTERNAL ONLY
                 ///

Modified: branches/proto/v4/boost/proto/transform/arg.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/arg.hpp (original)
+++ branches/proto/v4/boost/proto/transform/arg.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -114,6 +114,32 @@
         };
     };
 
+ /// \brief A PrimitiveTransform that returns the value of the
+ /// current terminal expression.
+ struct _value : transform<_value>
+ {
+ template<typename Expr, typename State, typename Data>
+ struct impl : transform_impl<Expr, State, Data>
+ {
+ typedef
+ typename result_of::value<Expr>::type
+ result_type;
+
+ /// \param expr The current expression.
+ /// \return <tt>proto::value(expr)</tt>
+ /// \throw nothrow
+ typename result_of::value<typename impl::expr_param>::type
+ operator ()(
+ typename impl::expr_param expr
+ , typename impl::state_param
+ , typename impl::data_param
+ ) const
+ {
+ return proto::value(expr);
+ }
+ };
+ };
+
     /// \brief A unary CallableTransform that wraps its argument
     /// in a \c boost::reference_wrapper\<\>.
     struct _byref : callable
@@ -223,6 +249,13 @@
     /// INTERNAL ONLY
     ///
     template<>
+ struct is_callable<_value>
+ : mpl::true_
+ {};
+
+ /// INTERNAL ONLY
+ ///
+ template<>
     struct is_callable<_byref>
       : mpl::true_
     {};

Modified: branches/proto/v4/boost/xpressive/detail/static/transforms/as_action.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/detail/static/transforms/as_action.hpp (original)
+++ branches/proto/v4/boost/xpressive/detail/static/transforms/as_action.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -24,7 +24,12 @@
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/xpressive/detail/static/transforms/as_quantifier.hpp>
 #include <boost/proto/core.hpp>
-#include <boost/proto/transform.hpp>
+#include <boost/proto/transform/arg.hpp>
+#include <boost/proto/transform/call.hpp>
+#include <boost/proto/transform/make.hpp>
+#include <boost/proto/transform/when.hpp>
+#include <boost/proto/transform/fold.hpp>
+#include <boost/proto/transform/fold_tree.hpp>
 
 namespace boost { namespace xpressive { namespace detail
 {

Modified: branches/proto/v4/boost/xpressive/detail/static/transforms/as_independent.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/detail/static/transforms/as_independent.hpp (original)
+++ branches/proto/v4/boost/xpressive/detail/static/transforms/as_independent.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -17,7 +17,10 @@
 #include <boost/xpressive/detail/detail_fwd.hpp>
 #include <boost/xpressive/detail/static/static.hpp>
 #include <boost/proto/core.hpp>
-#include <boost/proto/transform.hpp>
+#include <boost/proto/transform/arg.hpp>
+#include <boost/proto/transform/when.hpp>
+#include <boost/proto/transform/fold.hpp>
+#include <boost/proto/transform/fold_tree.hpp>
 
 namespace boost { namespace xpressive { namespace detail
 {

Modified: branches/proto/v4/boost/xpressive/regex_actions.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/regex_actions.hpp (original)
+++ branches/proto/v4/boost/xpressive/regex_actions.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -40,7 +40,8 @@
 
 // Doxygen can't handle proto :-(
 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
-# include <boost/proto/transform.hpp>
+# include <boost/proto/transform/arg.hpp>
+# include <boost/proto/transform/when.hpp>
 # include <boost/xpressive/detail/core/matcher/action_matcher.hpp>
 #endif
 

Modified: branches/proto/v4/boost/xpressive/regex_primitives.hpp
==============================================================================
--- branches/proto/v4/boost/xpressive/regex_primitives.hpp (original)
+++ branches/proto/v4/boost/xpressive/regex_primitives.hpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -24,7 +24,8 @@
 // Doxygen can't handle proto :-(
 #ifndef BOOST_XPRESSIVE_DOXYGEN_INVOKED
 # include <boost/proto/core.hpp>
-# include <boost/proto/transform.hpp>
+# include <boost/proto/transform/arg.hpp>
+# include <boost/proto/transform/when.hpp>
 # include <boost/xpressive/detail/core/icase.hpp>
 # include <boost/xpressive/detail/static/compile.hpp>
 # include <boost/xpressive/detail/static/modifier.hpp>

Modified: branches/proto/v4/libs/proto/test/toy_spirit2.cpp
==============================================================================
--- branches/proto/v4/libs/proto/test/toy_spirit2.cpp (original)
+++ branches/proto/v4/libs/proto/test/toy_spirit2.cpp 2008-04-18 20:16:05 EDT (Fri, 18 Apr 2008)
@@ -206,7 +206,7 @@
         // Extract the child from terminals
         struct SpiritTerminal
           : or_<
- when< AnyChar, _child >
+ when< AnyChar, _value >
               , when< CharLiteral, if_<_icase, ichar(_value), _value> >
               , when< CharParser, if_<_icase, ichar(_value(_child1)), _value(_child1)> > // char_('a')
               , when< NTBSLiteral, if_<_icase, istr(_value), char const*(_value)> >


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