Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49780 - in branches/release: . boost/proto boost/proto/detail boost/proto/transform libs/proto/doc libs/proto/doc/reference libs/proto/example
From: eric_at_[hidden]
Date: 2008-11-16 02:47:50


Author: eric_niebler
Date: 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
New Revision: 49780
URL: http://svn.boost.org/trac/boost/changeset/49780

Log:
latest proto from trunk
Added:
   branches/release/libs/proto/doc/reference/proto_typeof.xml
      - copied unchanged from r49779, /trunk/libs/proto/doc/reference/proto_typeof.xml
Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/boost/proto/args.hpp | 196 ++++++------
   branches/release/boost/proto/debug.hpp | 1
   branches/release/boost/proto/deep_copy.hpp | 4
   branches/release/boost/proto/detail/decltype.hpp | 4
   branches/release/boost/proto/detail/poly_function.hpp | 1
   branches/release/boost/proto/domain.hpp | 2
   branches/release/boost/proto/expr.hpp | 8
   branches/release/boost/proto/extends.hpp | 11
   branches/release/boost/proto/generate.hpp | 17
   branches/release/boost/proto/literal.hpp | 10
   branches/release/boost/proto/matches.hpp | 65 ++--
   branches/release/boost/proto/proto_typeof.hpp | 1
   branches/release/boost/proto/traits.hpp | 59 ++-
   branches/release/boost/proto/transform/arg.hpp | 42 +-
   branches/release/boost/proto/transform/call.hpp | 130 ++++----
   branches/release/boost/proto/transform/default.hpp | 160 +++++-----
   branches/release/boost/proto/transform/fold.hpp | 60 +-
   branches/release/boost/proto/transform/fold_tree.hpp | 8
   branches/release/boost/proto/transform/impl.hpp | 20
   branches/release/boost/proto/transform/make.hpp | 32 +-
   branches/release/boost/proto/transform/pass_through.hpp | 16
   branches/release/boost/proto/transform/when.hpp | 16
   branches/release/libs/proto/doc/Jamfile.v2 | 24 +
   branches/release/libs/proto/doc/front_end.qbk | 113 +++++-
   branches/release/libs/proto/doc/intermediate_form.qbk | 609 ++++++++++++++++++++-------------------
   branches/release/libs/proto/doc/proto.qbk | 34 ++
   branches/release/libs/proto/doc/reference.xml | 1
   branches/release/libs/proto/doc/reference/extends.xml | 4
   branches/release/libs/proto/doc/reference/traits.xml | 8
   branches/release/libs/proto/example/mixed.cpp | 8
   30 files changed, 890 insertions(+), 774 deletions(-)

Modified: branches/release/boost/proto/args.hpp
==============================================================================
--- branches/release/boost/proto/args.hpp (original)
+++ branches/release/boost/proto/args.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -1,7 +1,8 @@
 #ifndef BOOST_PP_IS_ITERATING
     ///////////////////////////////////////////////////////////////////////////////
     /// \file args.hpp
- /// Contains definition of args\<\> class template.
+ /// Contains definition of \c term\<\>, \c list1\<\>, \c list2\<\>, ...
+ /// class templates.
     //
     // Copyright 2008 Eric Niebler. Distributed under the Boost
     // Software License, Version 1.0. (See accompanying file
@@ -27,110 +28,110 @@
 
     namespace boost { namespace proto
     {
+ namespace detail
+ {
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits
+ {
+ typedef Expr value_type;
+ typedef Expr &reference;
+ typedef Expr const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits<Expr &>
+ {
+ typedef Expr value_type;
+ typedef Expr &reference;
+ typedef Expr &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename Expr>
+ struct expr_traits<Expr const &>
+ {
+ typedef Expr value_type;
+ typedef Expr const &reference;
+ typedef Expr const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T>
+ struct term_traits
+ {
+ typedef T value_type;
+ typedef T &reference;
+ typedef T const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T>
+ struct term_traits<T &>
+ {
+ 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_traits<T const &>
+ {
+ typedef T value_type;
+ typedef T const &reference;
+ typedef T const &const_reference;
+ };
+
+ /// INTERNAL ONLY
+ template<typename T, std::size_t N>
+ struct term_traits<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_traits<T const (&)[N]>
+ {
+ typedef T 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_traits<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_traits<T const[N]>
+ {
+ typedef T value_type[N];
+ typedef T const (&reference)[N];
+ typedef T const (&const_reference)[N];
+ };
+
+ }
+
         ////////////////////////////////////////////////////////////////////////////////////////////
         BOOST_PROTO_BEGIN_ADL_NAMESPACE(argsns_)
 
         #define BOOST_PROTO_DEFINE_CHILD_N(Z, N, DATA) \
             typedef BOOST_PP_CAT(Arg, N) BOOST_PP_CAT(child, N); \
- typedef expr_ref<BOOST_PP_CAT(Arg, N)> BOOST_PP_CAT(child_ref, N); \
+ /**< INTERNAL ONLY */
 
         #define BOOST_PROTO_DEFINE_VOID_N(z, n, data) \
             typedef mpl::void_ BOOST_PP_CAT(child, n); \
- typedef mpl::void_ BOOST_PP_CAT(child_ref, n); \
- /**/
-
- /// INTERNAL ONLY
- template<typename Expr>
- struct expr_ref
- {
- typedef typename Expr::proto_base_expr proto_base_expr;
- typedef typename Expr::proto_derived_expr proto_derived_expr;
- typedef typename Expr::proto_tag proto_tag;
- 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
- template<typename Expr>
- struct expr_ref<Expr &>
- {
- typedef typename Expr::proto_base_expr proto_base_expr;
- typedef typename Expr::proto_derived_expr proto_derived_expr;
- typedef typename Expr::proto_tag proto_tag;
- 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 value_type;
- typedef T &reference;
- typedef T const &const_reference;
- };
-
- /// INTERNAL ONLY
- template<typename T>
- struct term_ref<T &>
- {
- 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 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];
- };
+ /**< INTERNAL ONLY */
 
         /// \brief A type sequence, for use as the 2nd parameter to the \c expr\<\> class template.
         ///
@@ -141,7 +142,6 @@
         {
             BOOST_STATIC_CONSTANT(long, arity = 0);
             typedef Arg0 child0;
- typedef term_ref<Arg0> child_ref0;
 
             #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1500))
             BOOST_PP_REPEAT_FROM_TO(1, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_DEFINE_VOID_N, ~)

Modified: branches/release/boost/proto/debug.hpp
==============================================================================
--- branches/release/boost/proto/debug.hpp (original)
+++ branches/release/boost/proto/debug.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -107,6 +107,7 @@
         BOOST_PROTO_DEFINE_TAG_NAME(bitwise_or_assign)
         BOOST_PROTO_DEFINE_TAG_NAME(bitwise_xor_assign)
         BOOST_PROTO_DEFINE_TAG_NAME(subscript)
+ BOOST_PROTO_DEFINE_TAG_NAME(member)
         BOOST_PROTO_DEFINE_TAG_NAME(if_else_)
         BOOST_PROTO_DEFINE_TAG_NAME(function)
 

Modified: branches/release/boost/proto/deep_copy.hpp
==============================================================================
--- branches/release/boost/proto/deep_copy.hpp (original)
+++ branches/release/boost/proto/deep_copy.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -136,7 +136,9 @@
         {
         #define BOOST_PROTO_DEFINE_DEEP_COPY_TYPE(Z, N, DATA) \
             typename deep_copy_impl< \
- typename Expr::BOOST_PP_CAT(proto_child_ref, N)::proto_derived_expr \
+ typename remove_reference< \
+ typename Expr::BOOST_PP_CAT(proto_child, N) \
+ >::type::proto_derived_expr \
>::type \
             /**/
 

Modified: branches/release/boost/proto/detail/decltype.hpp
==============================================================================
--- branches/release/boost/proto/detail/decltype.hpp (original)
+++ branches/release/boost/proto/detail/decltype.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -420,9 +420,9 @@
             typedef typename remove_const<typename remove_reference<PMF>::type>::type pmf_type;
             typedef typename boost::result_of<pmf_type(T)>::type result_type;
 
- memfun(T t, PMF pmf)
+ memfun(T t, PMF p)
               : obj(t)
- , pmf(pmf)
+ , pmf(p)
             {}
 
             result_type operator()() const

Modified: branches/release/boost/proto/detail/poly_function.hpp
==============================================================================
--- branches/release/boost/proto/detail/poly_function.hpp (original)
+++ branches/release/boost/proto/detail/poly_function.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -144,6 +144,7 @@
         ////////////////////////////////////////////////////////////////////////////////////////////////
         struct poly_function_base
         {
+ /// INTERNAL ONLY
             BOOST_PROTO_POLY_FUNCTION()
         };
 

Modified: branches/release/boost/proto/domain.hpp
==============================================================================
--- branches/release/boost/proto/domain.hpp (original)
+++ branches/release/boost/proto/domain.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -83,6 +83,8 @@
       : Generator
     {
         typedef Grammar proto_grammar;
+
+ /// INTERNAL ONLY
         typedef void proto_is_domain_;
     };
 

Modified: branches/release/boost/proto/expr.hpp
==============================================================================
--- branches/release/boost/proto/expr.hpp (original)
+++ branches/release/boost/proto/expr.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -44,16 +44,14 @@
         ///
         #define BOOST_PROTO_CHILD(Z, N, DATA) \
             typedef typename Args::BOOST_PP_CAT(child, N) BOOST_PP_CAT(proto_child, N); \
- typedef typename Args::BOOST_PP_CAT(child_ref, N) BOOST_PP_CAT(proto_child_ref, N); \
             BOOST_PP_CAT(proto_child, N) BOOST_PP_CAT(child, N); \
- /**/
+ /**< INTERNAL ONLY */
 
         /// INTERNAL ONLY
         ///
         #define BOOST_PROTO_VOID(Z, N, DATA) \
             typedef void BOOST_PP_CAT(proto_child, N); \
- typedef void BOOST_PP_CAT(proto_child_ref, N); \
- /**/
+ /**< INTERNAL ONLY */
 
             struct not_a_valid_type
             {
@@ -187,8 +185,8 @@
             typedef Args proto_args;
             typedef default_domain proto_domain;
             BOOST_PROTO_FUSION_DEFINE_TAG(proto::tag::proto_expr)
- typedef void proto_is_expr_;
             typedef expr proto_derived_expr;
+ typedef void proto_is_expr_; /**< INTERNAL ONLY */
 
             BOOST_PP_REPEAT(ARG_COUNT, BOOST_PROTO_CHILD, ~)
             BOOST_PP_REPEAT_FROM_TO(ARG_COUNT, BOOST_PROTO_MAX_ARITY, BOOST_PROTO_VOID, ~)

Modified: branches/release/boost/proto/extends.hpp
==============================================================================
--- branches/release/boost/proto/extends.hpp (original)
+++ branches/release/boost/proto/extends.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -144,9 +144,6 @@
         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) \
@@ -159,7 +156,7 @@
         typedef typename proto_base_expr::proto_args proto_args; \
         typedef typename proto_base_expr::proto_arity proto_arity; \
         typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_; \
- typedef void proto_is_expr_; \
+ typedef void proto_is_expr_; /**< INTERNAL ONLY */ \
         BOOST_PROTO_FUSION_DEFINE_TAG(boost::proto::tag::proto_expr) \
         BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_EXTENDS_CHILD, ~) \
                                                                                                     \
@@ -188,7 +185,7 @@
     #define BOOST_PROTO_BASIC_EXTENDS(Expr, Derived, Domain) \
         BOOST_PROTO_BASIC_EXTENDS_(Expr, Derived, Domain) \
         typedef void proto_is_aggregate_; \
- /**/
+ /**< INTERNAL ONLY */
 
         /// INTERNAL ONLY
         ///
@@ -544,10 +541,10 @@
         typedef typename proto_base_expr::proto_args proto_args;
         typedef typename proto_base_expr::proto_arity proto_arity;
         typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_;
- typedef void proto_is_expr_;
+ typedef void proto_is_expr_; /**< INTERNAL ONLY */
         BOOST_PROTO_FUSION_DEFINE_TAG(boost::proto::tag::proto_expr)
         BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_EXTENDS_CHILD, ~)
- typedef void proto_is_aggregate_;
+ typedef void proto_is_aggregate_; /**< INTERNAL ONLY */
 
         BOOST_PROTO_EXTENDS_ASSIGN()
         BOOST_PROTO_EXTENDS_SUBSCRIPT()

Modified: branches/release/boost/proto/generate.hpp
==============================================================================
--- branches/release/boost/proto/generate.hpp (original)
+++ branches/release/boost/proto/generate.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -17,6 +17,7 @@
     #include <boost/preprocessor/repetition/enum.hpp>
     #include <boost/utility/enable_if.hpp>
     #include <boost/proto/proto_fwd.hpp>
+ #include <boost/proto/args.hpp>
     #include <boost/proto/matches.hpp>
     #include <boost/proto/detail/suffix.hpp>
 
@@ -41,21 +42,21 @@
             };
 
             template<typename Expr>
- struct expr_traits;
+ struct expr_params;
 
             template<typename Tag, typename Args, long N>
- struct expr_traits<proto::expr<Tag, Args, N> >
+ struct expr_params<proto::expr<Tag, Args, N> >
             {
                 typedef Tag tag;
                 typedef Args args;
                 BOOST_STATIC_CONSTANT(long, arity = N);
             };
 
- template<typename Expr, long Arity = expr_traits<Expr>::arity>
+ template<typename Expr, long Arity = expr_params<Expr>::arity>
             struct by_value_generator_;
 
         #define BOOST_PROTO_DEFINE_BY_VALUE_TYPE(Z, N, Expr) \
- typename uncvref<typename expr_traits<Expr>::args::BOOST_PP_CAT(child, N)>::type \
+ typename uncvref<typename expr_params<Expr>::args::BOOST_PP_CAT(child, N)>::type \
             /**/
 
         #define BOOST_PROTO_DEFINE_BY_VALUE(Z, N, expr) \
@@ -67,8 +68,8 @@
             {
                 typedef
                     proto::expr<
- typename expr_traits<Expr>::tag
- , term<typename expr_traits<Expr>::args::child_ref0::value_type>
+ typename expr_params<Expr>::tag
+ , term<typename detail::term_traits<typename expr_params<Expr>::args::child0>::value_type>
>
                 type;
 
@@ -362,9 +363,9 @@
             {
                 typedef
                     proto::expr<
- typename expr_traits<Expr>::tag
+ typename expr_params<Expr>::tag
                       , BOOST_PP_CAT(list, N)<
- // typename expr_traits<Expr>::args::child_ref0::proto_derived_expr, ...
+ // typename uncvref<typename expr_params<Expr>::args::child0>::type, ...
                             BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_BY_VALUE_TYPE, Expr)
>
>

Modified: branches/release/boost/proto/literal.hpp
==============================================================================
--- branches/release/boost/proto/literal.hpp (original)
+++ branches/release/boost/proto/literal.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -36,16 +36,16 @@
           , typename Domain BOOST_PROTO_WHEN_BUILDING_DOCS(= default_domain)
>
         struct literal
- : extends<typename terminal<T>::type, literal<T, Domain>, Domain>
+ : extends<expr<tag::terminal, term<T> >, literal<T, Domain>, Domain>
         {
         private:
- typedef typename terminal<T>::type terminal_type;
+ typedef expr<tag::terminal, term<T> > terminal_type;
             typedef extends<terminal_type, literal<T, Domain>, Domain> base_type;
 
         public:
- 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;
+ typedef typename detail::term_traits<T>::value_type value_type;
+ typedef typename detail::term_traits<T>::reference reference;
+ typedef typename detail::term_traits<T>::const_reference const_reference;
 
             template<typename U>
             literal(U &u)

Modified: branches/release/boost/proto/matches.hpp
==============================================================================
--- branches/release/boost/proto/matches.hpp (original)
+++ branches/release/boost/proto/matches.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -325,12 +325,12 @@
 
             template<typename Tag, typename Args1, typename Args2>
             struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<Tag, Args2, 1> >
- : matches_<typename Args1::child_ref0::proto_base_expr, typename Args2::child0::proto_base_expr>
+ : matches_<typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr, typename Args2::child0::proto_base_expr>
             {};
 
             template<typename Tag, typename Args1, typename Args2>
             struct matches_< proto::expr<Tag, Args1, 1>, proto::expr<proto::_, Args2, 1> >
- : matches_<typename Args1::child_ref0::proto_base_expr, typename Args2::child0::proto_base_expr>
+ : matches_<typename detail::expr_traits<typename Args1::child0>::value_type::proto_base_expr, typename Args2::child0::proto_base_expr>
             {};
 
             template<typename Args1, typename Args2>
@@ -340,7 +340,7 @@
 
         #define BOOST_PROTO_MATCHES_N_FUN(Z, N, DATA) \
             matches_< \
- typename Args1::BOOST_PP_CAT(child_ref, N)::proto_base_expr \
+ typename detail::expr_traits<typename Args1::BOOST_PP_CAT(child, N)>::value_type::proto_base_expr\
               , typename Args2::BOOST_PP_CAT(child, N)::proto_base_expr \
>
 
@@ -537,14 +537,14 @@
                     typedef Expr result_type;
 
                     /// \param expr An expression
- /// \return \c expr
+ /// \return \c e
                     typename impl::expr_param operator()(
- typename impl::expr_param expr
+ typename impl::expr_param e
                       , typename impl::state_param
                       , typename impl::data_param
                     ) const
                     {
- return expr;
+ return e;
                     }
                 };
             };
@@ -570,16 +570,16 @@
                 {
                     typedef Expr result_type;
 
- /// \param expr An expression
+ /// \param e An expression
                     /// \pre <tt>matches\<Expr,not_\>::::value</tt> is \c true.
- /// \return \c expr
+ /// \return \c e
                     typename impl::expr_param operator()(
- typename impl::expr_param expr
+ typename impl::expr_param e
                       , typename impl::state_param
                       , typename impl::data_param
                     ) const
                     {
- return expr;
+ return e;
                     }
                 };
             };
@@ -660,17 +660,17 @@
 
                     typedef typename which::template impl<Expr, State, Data>::result_type result_type;
 
- /// \param expr An expression
- /// \param state The current state
- /// \param data A data of arbitrary type
- /// \return <tt>which::impl<Expr, State, Data>()(expr, state, data)</tt>
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
+ /// \return <tt>which::impl<Expr, State, Data>()(e, s, d)</tt>
                     result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                     ) const
                     {
- return typename which::template impl<Expr, State, Data>()(expr, state, data);
+ return typename which::template impl<Expr, State, Data>()(e, s, d);
                     }
                 };
             };
@@ -692,11 +692,11 @@
             {
                 typedef or_ proto_base_expr;
 
- /// \param expr An expression
- /// \param state The current state
- /// \param data A data of arbitrary type
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
                 /// \pre <tt>matches\<Expr,or_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(expr, state, data)</tt>
+ /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
 
                 template<typename Expr, typename State, typename Data>
                 struct impl
@@ -730,11 +730,11 @@
                 struct impl
                   : detail::last<and_>::type::template impl<Expr, State, Data>
                 {
- /// \param expr An expression
- /// \param state The current state
- /// \param data A data of arbitrary type
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
                     /// \pre <tt>matches\<Expr,and_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(expr, state, data)</tt>
+ /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
                 };
             };
 
@@ -759,11 +759,11 @@
             {
                 typedef switch_ proto_base_expr;
 
- /// \param expr An expression
- /// \param state The current state
- /// \param data A data of arbitrary type
+ /// \param e An expression
+ /// \param s The current state
+ /// \param d A data of arbitrary type
                 /// \pre <tt>matches\<Expr,switch_\>::::value</tt> is \c true.
- /// \return <tt>result\<void(Expr, State, Data)\>::::which()(expr, state, data)</tt>
+ /// \return <tt>result\<void(Expr, State, Data)\>::::which()(e, s, d)</tt>
 
                 template<typename Expr, typename State, typename Data>
                 struct impl
@@ -829,6 +829,7 @@
             struct vararg
               : Grammar
             {
+ /// INTERNAL ONLY
                 typedef void proto_is_vararg_;
             };
         }
@@ -943,14 +944,14 @@
             template<typename Args, typename Back, long To>
             struct vararg_matches_impl<Args, Back, N, To>
               : and2<
- matches_<typename Args::BOOST_PP_CAT(child_ref, BOOST_PP_DEC(N))::proto_base_expr, Back>::value
+ matches_<typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr, Back>::value
                   , vararg_matches_impl<Args, Back, N + 1, To>
>
             {};
 
             template<typename Args, typename Back>
             struct vararg_matches_impl<Args, Back, N, N>
- : matches_<typename Args::BOOST_PP_CAT(child_ref, BOOST_PP_DEC(N))::proto_base_expr, Back>
+ : matches_<typename detail::expr_traits<typename Args::BOOST_PP_CAT(child, BOOST_PP_DEC(N))>::value_type::proto_base_expr, Back>
             {};
 
             template<

Modified: branches/release/boost/proto/proto_typeof.hpp
==============================================================================
--- branches/release/boost/proto/proto_typeof.hpp (original)
+++ branches/release/boost/proto/proto_typeof.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -61,6 +61,7 @@
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::bitwise_or_assign)
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::bitwise_xor_assign)
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::subscript)
+BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::member)
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::if_else_)
 BOOST_TYPEOF_REGISTER_TYPE(boost::proto::tag::function)
 

Modified: branches/release/boost/proto/traits.hpp
==============================================================================
--- branches/release/boost/proto/traits.hpp (original)
+++ branches/release/boost/proto/traits.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -378,7 +378,14 @@
>
             {
                 // BUGBUG should be able to hold this guy by reference, no?
+ #if BOOST_WORKAROUND(BOOST_MSVC, == 1310) || \
+ BOOST_WORKAROUND(BOOST_INTEL, BOOST_TESTED_AT(1010))
+ // These compilers don't strip top-level cv qualifiers
+ // on arguments in function types
+ typedef typename Domain::template result<void(typename T::proto_derived_expr)>::type type;
+ #else
                 typedef typename Domain::template result<void(T)>::type type;
+ #endif
 
                 /// INTERNAL ONLY
                 ///
@@ -440,16 +447,16 @@
                 /// \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,
+ /// The "value" type of the child, suitable for storage 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>T const(&)[N]</tt> becomes <tt>T[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;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::value_type type;
             };
 
             template<typename Expr>
@@ -459,7 +466,7 @@
                 /// \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
+ /// The "reference" type of the child, suitable for storage 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>
@@ -468,7 +475,7 @@
                 /// \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;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::reference type;
             };
 
             template<typename Expr>
@@ -478,7 +485,7 @@
                 /// \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
+ /// The "const reference" type of the child, suitable for storage 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>
@@ -487,7 +494,7 @@
                 /// \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;
+ typedef typename detail::term_traits<typename Expr::proto_child0>::const_reference type;
             };
 
             // TODO left<> and right<> force the instantiation of Expr.
@@ -532,17 +539,17 @@
                 {
                     typedef Expr result_type;
 
- /// \param expr The current expression
+ /// \param e The current expression
                     /// \pre <tt>matches\<Expr, terminal\<T\> \>::::value</tt> is \c true.
- /// \return \c expr
+ /// \return \c e
                     /// \throw nothrow
                     typename impl::expr_param operator ()(
- typename impl::expr_param expr
+ typename impl::expr_param e
                       , typename impl::state_param
                       , typename impl::data_param
                     ) const
                     {
- return expr;
+ return e;
                     }
                 };
 
@@ -1720,7 +1727,7 @@
                 /// \brief Return the Nth child of the given expression.
                 /// \param expr The expression node.
                 /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
- /// \pre <tt>N == 0 || N \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N \< Expr::proto_arity::value</tt>
                 /// \return <tt>proto::child_c\<N\>(expr)</tt>
                 /// \throw nothrow
                 template<typename Expr>
@@ -1763,7 +1770,7 @@
                 /// \brief Return the Nth child of the given expression.
                 /// \param expr The expression node.
                 /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true
- /// \pre <tt>N::value == 0 || N::value \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N::value \< Expr::proto_arity::value</tt>
                 /// \return <tt>proto::child\<N\>(expr)</tt>
                 /// \throw nothrow
                 template<typename Expr>
@@ -2011,13 +2018,12 @@
         /// Return the Nth child of the specified Proto expression. If
         /// \c N is not specified, as in \c child(expr), then \c N is assumed
         /// to be <tt>mpl::long_\<0\></tt>. The child is returned by
- /// reference. If the expression is holding the child in a
- /// <tt>ref_\<\></tt> wrapper, it is unwrapped before it is returned.
+ /// reference.
         ///
         /// \param expr The Proto expression.
         /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
         /// \pre \c N is an MPL Integral Constant.
- /// \pre <tt>N::value == 0 || N::value \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N::value \< Expr::proto_arity::value</tt>
         /// \throw nothrow
         /// \return A reference to the Nth child
         template<typename N, typename Expr>
@@ -2039,7 +2045,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename Expr2::proto_base_expr::proto_child_ref0::reference
+ typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::reference
         child(Expr2 &expr2 BOOST_PROTO_DISABLE_IF_IS_CONST(Expr2))
         {
             return expr2.proto_base().child0;
@@ -2048,7 +2054,7 @@
         /// \overload
         ///
         template<typename Expr2>
- typename Expr2::proto_base_expr::proto_child_ref0::const_reference
+ typename detail::expr_traits<typename Expr2::proto_base_expr::proto_child0>::const_reference
         child(Expr2 const &expr2)
         {
             return expr2.proto_base().child0;
@@ -2057,12 +2063,11 @@
         /// \brief Return the Nth child of the specified Proto expression.
         ///
         /// Return the Nth child of the specified Proto expression. The child
- /// is returned by reference. If the expression is holding the child in
- /// a <tt>ref_\<\></tt> wrapper, it is unwrapped before it is returned.
+ /// is returned by reference.
         ///
         /// \param expr The Proto expression.
         /// \pre <tt>is_expr\<Expr\>::::value</tt> is \c true.
- /// \pre <tt>N == 0 || N \< Expr::proto_arity::value</tt>
+ /// \pre <tt>N \< Expr::proto_arity::value</tt>
         /// \throw nothrow
         /// \return A reference to the Nth child
         template<long N, typename Expr>
@@ -2304,7 +2309,7 @@
             /// of a Proto expression.
             ///
             /// A metafunction that returns the type of the Nth child
- /// of a Proto expression. \c N must be 0 or less than
+ /// of a Proto expression. \c N must be less than
             /// \c Expr::proto_arity::value.
             template<typename Expr>
             struct child_c<Expr, N>
@@ -2318,7 +2323,7 @@
                 /// \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::BOOST_PP_CAT(proto_child_ref, N)::value_type type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::value_type type;
             };
 
             template<typename Expr>
@@ -2333,7 +2338,7 @@
                 /// \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::BOOST_PP_CAT(proto_child_ref, N)::reference type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::reference type;
 
                 /// INTERNAL ONLY
                 ///
@@ -2355,7 +2360,7 @@
                 /// \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::BOOST_PP_CAT(proto_child_ref, N)::const_reference type;
+ typedef typename detail::expr_traits<typename Expr::BOOST_PP_CAT(proto_child, N)>::const_reference type;
 
                 /// INTERNAL ONLY
                 ///

Modified: branches/release/boost/proto/transform/arg.hpp
==============================================================================
--- branches/release/boost/proto/transform/arg.hpp (original)
+++ branches/release/boost/proto/transform/arg.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -36,16 +36,16 @@
             typedef Expr result_type;
 
             /// Returns the current expression.
- /// \param expr The current expression.
- /// \return \c expr
+ /// \param e The current expression.
+ /// \return \c e
             /// \throw nothrow
             typename impl::expr_param operator()(
- typename impl::expr_param expr
+ typename impl::expr_param e
               , typename impl::state_param
               , typename impl::data_param
             ) const
             {
- return expr;
+ return e;
             }
         };
     };
@@ -68,16 +68,16 @@
             typedef State result_type;
 
             /// Returns the current state.
- /// \param state The current state.
- /// \return \c state
+ /// \param s The current state.
+ /// \return \c s
             /// \throw nothrow
             typename impl::state_param operator ()(
                 typename impl::expr_param
- , typename impl::state_param state
+ , typename impl::state_param s
               , typename impl::data_param
             ) const
             {
- return state;
+ return s;
             }
         };
     };
@@ -101,16 +101,16 @@
             typedef Data result_type;
 
             /// Returns the current data.
- /// \param data The current data.
- /// \return \c data
+ /// \param d The current data.
+ /// \return \c d
             /// \throw nothrow
             typename impl::data_param operator ()(
                 typename impl::expr_param
               , typename impl::state_param
- , typename impl::data_param data
+ , typename impl::data_param d
             ) const
             {
- return data;
+ return d;
             }
         };
     };
@@ -135,19 +135,19 @@
                 typename result_of::child_c<Expr, N>::type
             result_type;
 
- /// Returns the N-th child of \c expr
+ /// Returns the N-th child of \c e
             /// \pre <tt>arity_of\<Expr\>::::value \> N</tt>
- /// \param expr The current expression.
- /// \return <tt>proto::child_c\<N\>(expr)</tt>
+ /// \param e The current expression.
+ /// \return <tt>proto::child_c\<N\>(e)</tt>
             /// \throw nothrow
             typename result_of::child_c<typename impl::expr_param, N>::type
             operator ()(
- typename impl::expr_param expr
+ typename impl::expr_param e
               , typename impl::state_param
               , typename impl::data_param
             ) const
             {
- return proto::child_c<N>(expr);
+ return proto::child_c<N>(e);
             }
         };
     };
@@ -173,17 +173,17 @@
 
             /// Returns the value of the specified terminal expression.
             /// \pre <tt>arity_of\<Expr\>::::value == 0</tt>.
- /// \param expr The current expression.
- /// \return <tt>proto::value(expr)</tt>
+ /// \param e The current expression.
+ /// \return <tt>proto::value(e)</tt>
             /// \throw nothrow
             typename result_of::value<typename impl::expr_param>::type
             operator ()(
- typename impl::expr_param expr
+ typename impl::expr_param e
               , typename impl::state_param
               , typename impl::data_param
             ) const
             {
- return proto::value(expr);
+ return proto::value(e);
             }
         };
     };

Modified: branches/release/boost/proto/transform/call.hpp
==============================================================================
--- branches/release/boost/proto/transform/call.hpp (original)
+++ branches/release/boost/proto/transform/call.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -117,11 +117,11 @@
             /// expression, state, and data.
             ///
             /// If \c Fun is a nullary PolymorphicFunctionObject, return <tt>Fun()()</tt>.
- /// Otherwise, return <tt>Fun()(expr, state, data)</tt>.
+ /// Otherwise, return <tt>Fun()(e, s, d)</tt>.
             ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
 
             /// If \c Fun is a nullary PolymorphicFunctionObject, \c type is a typedef
             /// for <tt>boost::result_of\<Fun()\>::::type</tt>. Otherwise, it is
@@ -146,13 +146,13 @@
                 typedef typename detail::as_mono_function<Fun(a0)>::type mono_fun;
                 typedef typename boost::result_of<mono_fun(a0)>::type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return mono_fun()(
- detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data))
+ detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d))
                     );
                 }
             };
@@ -164,19 +164,19 @@
                 typedef typename when<_, A0>::template impl<Expr, State, Data>::result_type a0;
                 typedef typename Fun::template impl<a0, State, Data>::result_type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return typename Fun::template impl<a0, State, Data>()(
- typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data)
- , state
- , data
+ typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d)
+ , s
+ , d
                     );
                 }
             };
- /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt> and \c X
+ /// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt> and \c X
             /// be the type of \c x.
             /// If \c Fun is a unary PolymorphicFunctionObject that accepts \c x,
             /// then \c type is a typedef for <tt>boost::result_of\<Fun(X)\>::::type</tt>.
@@ -188,14 +188,14 @@
             /// result of applying the \c A0 transform, the state, and the
             /// data.
             ///
- /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt>.
+ /// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt>.
             /// If \c Fun is a unary PolymorphicFunctionObject that accepts \c x,
             /// then return <tt>Fun()(x)</tt>. Otherwise, return
- /// <tt>Fun()(x, state, data)</tt>.
+ /// <tt>Fun()(x, s, d)</tt>.
             ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
             template<typename Expr, typename State, typename Data>
             struct impl
               : impl2<Expr, State, Data, is_transform<Fun>::value>
@@ -217,14 +217,14 @@
                 typedef typename detail::as_mono_function<Fun(a0, a1)>::type mono_fun;
                 typedef typename boost::result_of<mono_fun(a0, a1)>::type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return mono_fun()(
- detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data))
- , detail::as_lvalue(typename when<_, A1>::template impl<Expr, State, Data>()(expr, state, data))
+ detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d))
+ , detail::as_lvalue(typename when<_, A1>::template impl<Expr, State, Data>()(e, s, d))
                     );
                 }
             };
@@ -237,22 +237,22 @@
                 typedef typename when<_, A1>::template impl<Expr, State, Data>::result_type a1;
                 typedef typename Fun::template impl<a0, a1, Data>::result_type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return typename Fun::template impl<a0, a1, Data>()(
- typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data)
- , typename when<_, A1>::template impl<Expr, State, Data>()(expr, state, data)
- , data
+ typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d)
+ , typename when<_, A1>::template impl<Expr, State, Data>()(e, s, d)
+ , d
                     );
                 }
             };
 
- /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt> and \c X
+ /// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt> and \c X
                 /// be the type of \c x.
- /// Let \c y be <tt>when\<_, A1\>()(expr, state, data)</tt> and \c Y
+ /// Let \c y be <tt>when\<_, A1\>()(e, s, d)</tt> and \c Y
                 /// be the type of \c y.
                 /// If \c Fun is a binary PolymorphicFunction object that accepts \c x
                 /// and \c y, then \c type is a typedef for
@@ -266,15 +266,15 @@
             /// the \c A0 transform, the result of applying the \c A1
             /// transform, and the data.
             ///
- /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt>.
- /// Let \c y be <tt>when\<_, A1\>()(expr, state, data)</tt>.
+ /// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt>.
+ /// Let \c y be <tt>when\<_, A1\>()(e, s, d)</tt>.
             /// If \c Fun is a binary PolymorphicFunction object that accepts \c x
             /// and \c y, return <tt>Fun()(x, y)</tt>. Otherwise, return
- /// <tt>Fun()(x, y, data)</tt>.
+ /// <tt>Fun()(x, y, d)</tt>.
             ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
             template<typename Expr, typename State, typename Data>
             struct impl
               : impl2<Expr, State, Data, is_transform<Fun>::value>
@@ -298,15 +298,15 @@
                 typedef typename detail::as_mono_function<Fun(a0, a1, a2)>::type mono_fun;
                 typedef typename boost::result_of<mono_fun(a0, a1, a2)>::type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return mono_fun()(
- detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data))
- , detail::as_lvalue(typename when<_, A1>::template impl<Expr, State, Data>()(expr, state, data))
- , detail::as_lvalue(typename when<_, A2>::template impl<Expr, State, Data>()(expr, state, data))
+ detail::as_lvalue(typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d))
+ , detail::as_lvalue(typename when<_, A1>::template impl<Expr, State, Data>()(e, s, d))
+ , detail::as_lvalue(typename when<_, A2>::template impl<Expr, State, Data>()(e, s, d))
                     );
                 }
             };
@@ -320,27 +320,27 @@
                 typedef typename when<_, A2>::template impl<Expr, State, Data>::result_type a2;
                 typedef typename Fun::template impl<a0, a1, a2>::result_type result_type;
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return typename Fun::template impl<a0, a1, a2>()(
- typename when<_, A0>::template impl<Expr, State, Data>()(expr, state, data)
- , typename when<_, A1>::template impl<Expr, State, Data>()(expr, state, data)
- , typename when<_, A2>::template impl<Expr, State, Data>()(expr, state, data)
+ typename when<_, A0>::template impl<Expr, State, Data>()(e, s, d)
+ , typename when<_, A1>::template impl<Expr, State, Data>()(e, s, d)
+ , typename when<_, A2>::template impl<Expr, State, Data>()(e, s, d)
                     );
                 }
             };
 
- /// Let \c x be <tt>when\<_, A0\>()(expr, state, data)</tt>.
- /// Let \c y be <tt>when\<_, A1\>()(expr, state, data)</tt>.
- /// Let \c z be <tt>when\<_, A2\>()(expr, state, data)</tt>.
+ /// Let \c x be <tt>when\<_, A0\>()(e, s, d)</tt>.
+ /// Let \c y be <tt>when\<_, A1\>()(e, s, d)</tt>.
+ /// Let \c z be <tt>when\<_, A2\>()(e, s, d)</tt>.
             /// Return <tt>Fun()(x, y, z)</tt>.
             ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
 
             template<typename Expr, typename State, typename Data>
             struct impl
@@ -395,23 +395,23 @@
                     typename boost::result_of<mono_fun(BOOST_PP_ENUM_PARAMS(N, a))>::type
                 result_type;
 
- /// Let \c ax be <tt>when\<_, Ax\>()(expr, state, data)</tt>
+ /// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
                 /// for each \c x in <tt>[0,N]</tt>.
                 /// Return <tt>Fun()(a0, a1,... aN)</tt>.
                 ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
                 result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                 ) const
                 {
                     #define M0(Z, M, DATA) \
                         detail::as_lvalue( \
                             typename when<_, BOOST_PP_CAT(A, M)> \
- ::template impl<Expr, State, Data>()(expr, state, data)) \
+ ::template impl<Expr, State, Data>()(e, s, d)) \
                     return mono_fun()(BOOST_PP_ENUM(N, M0, ~));
                     #undef M0
                 }

Modified: branches/release/boost/proto/transform/default.hpp
==============================================================================
--- branches/release/boost/proto/transform/default.hpp (original)
+++ branches/release/boost/proto/transform/default.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -54,13 +54,13 @@
             public: \
                 BOOST_PROTO_DECLTYPE_(OP proto::detail::MAKE<r0>(), result_type) \
                 result_type operator ()( \
- typename impl2::expr_param expr \
- , typename impl2::state_param state \
- , typename impl2::data_param data \
+ typename impl2::expr_param e \
+ , typename impl2::state_param s \
+ , typename impl2::data_param d \
                 ) const \
                 { \
                     typename Grammar::template impl<e0, State, Data> t0; \
- return OP t0(proto::child_c<0>(expr), state, data); \
+ return OP t0(proto::child_c<0>(e), s, d); \
                 } \
             }; \
             /**/
@@ -81,15 +81,15 @@
                   , result_type \
                 ) \
                 result_type operator ()( \
- typename impl2::expr_param expr \
- , typename impl2::state_param state \
- , typename impl2::data_param data \
+ typename impl2::expr_param e \
+ , typename impl2::state_param s \
+ , typename impl2::data_param d \
                 ) 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) \
- OP t1(proto::child_c<1>(expr), state, data); \
+ return t0(proto::child_c<0>(e), s, d) \
+ OP t1(proto::child_c<1>(e), s, d); \
                 } \
             }; \
             /**/
@@ -161,16 +161,16 @@
             public:
                 typedef typename detail::mem_ptr_fun<r0, r1>::result_type result_type;
                 result_type operator ()(
- typename memfun_impl::expr_param expr
- , typename memfun_impl::state_param state
- , typename memfun_impl::data_param data
+ typename memfun_impl::expr_param e
+ , typename memfun_impl::state_param s
+ , typename memfun_impl::data_param d
                 ) const
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
                     typename Grammar::template impl<e1, State, Data> t1;
                     return detail::mem_ptr_fun<r0, r1>()(
- t0(proto::child_c<0>(expr), state, data)
- , t1(proto::child_c<1>(expr), state, data)
+ t0(proto::child_c<0>(e), s, d)
+ , t1(proto::child_c<1>(e), s, d)
                     );
                 }
             };
@@ -188,16 +188,16 @@
             public:
                 typedef detail::memfun<r0, r1> result_type;
                 result_type const operator ()(
- typename memfun_impl::expr_param expr
- , typename memfun_impl::state_param state
- , typename memfun_impl::data_param data
+ typename memfun_impl::expr_param e
+ , typename memfun_impl::state_param s
+ , typename memfun_impl::data_param d
                 ) const
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
                     typename Grammar::template impl<e1, State, Data> t1;
                     return detail::memfun<r0, r1>(
- t0(proto::child_c<0>(expr), state, data)
- , t1(proto::child_c<1>(expr), state, data)
+ t0(proto::child_c<0>(e), s, d)
+ , t1(proto::child_c<1>(e), s, d)
                     );
                 }
             };
@@ -217,13 +217,13 @@
             public:
                 BOOST_PROTO_DECLTYPE_(proto::detail::make_mutable<r0>() ++, result_type)
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
- return t0(proto::child_c<0>(expr), state, data) ++;
+ return t0(proto::child_c<0>(e), s, d) ++;
                 }
             };
 
@@ -237,13 +237,13 @@
             public:
                 BOOST_PROTO_DECLTYPE_(proto::detail::make_mutable<r0>() --, result_type)
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
- return t0(proto::child_c<0>(expr), state, data) --;
+ return t0(proto::child_c<0>(e), s, d) --;
                 }
             };
 
@@ -262,15 +262,15 @@
                   , result_type
                 )
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) 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) ];
+ return t0(proto::child_c<0>(e), s, d) [
+ t1(proto::child_c<1>(e), s, d) ];
                 }
             };
 
@@ -293,17 +293,17 @@
                   , result_type
                 )
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     typename Grammar::template impl<e0, State, Data> t0;
                     typename Grammar::template impl<e1, State, Data> t1;
                     typename Grammar::template impl<e2, State, Data> t2;
- return t0(proto::child_c<0>(expr), state, data)
- ? t1(proto::child_c<1>(expr), state, data)
- : t2(proto::child_c<2>(expr), state, data);
+ return t0(proto::child_c<0>(e), s, d)
+ ? t1(proto::child_c<1>(e), s, d)
+ : t2(proto::child_c<2>(e), s, d);
                 }
             };
 
@@ -319,15 +319,15 @@
             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
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) 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);
+ return t0(proto::child_c<0>(e), s, d)
+ , t1(proto::child_c<1>(e), s, d);
                 }
             };
 
@@ -342,7 +342,7 @@
 
             #define EVAL(Z, N, DATA) \
                 typename Grammar::template impl<BOOST_PP_CAT(e, N), State, Data>()( \
- proto::child_c<N>(DATA), state, data \
+ proto::child_c<N>(DATA), s, d \
                 ) \
                 /**/
 
@@ -361,12 +361,12 @@
                 result_type;
 
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
- return EVAL(~, 0, expr)();
+ return EVAL(~, 0, e)();
                 }
             };
 
@@ -386,15 +386,15 @@
                 result_type;
 
                 result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                 ) const
                 {
                     return this->invoke(
- expr
- , state
- , data
+ e
+ , s
+ , d
                       , is_member_function_pointer<function_type>()
                       , is_member_object_pointer<function_type>()
                     );
@@ -402,38 +402,38 @@
 
             private:
                 result_type invoke(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                   , mpl::false_
                   , mpl::false_
                 ) const
                 {
- return EVAL(~, 0, expr)(EVAL(~, 1, expr));
+ return EVAL(~, 0, e)(EVAL(~, 1, e));
                 }
 
                 result_type invoke(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                   , mpl::true_
                   , mpl::false_
                 ) const
                 {
                     using namespace detail::get_pointer_;
- return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))();
+ return (get_pointer(EVAL(~, 1, e)) ->* EVAL(~, 0, e))();
                 }
 
                 result_type invoke(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
                   , mpl::false_
                   , mpl::true_
                 ) const
                 {
                     using namespace detail::get_pointer_;
- return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr));
+ return (get_pointer(EVAL(~, 1, e)) ->* EVAL(~, 0, e));
                 }
             };
 
@@ -485,36 +485,36 @@
             result_type;
 
             result_type operator ()(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
             ) const
             {
- return this->invoke(expr, state, data, is_member_function_pointer<function_type>());
+ return this->invoke(e, s, d, is_member_function_pointer<function_type>());
             }
 
         private:
             result_type invoke(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
               , mpl::false_
             ) const
             {
- return EVAL(~, 0, expr)(BOOST_PP_ENUM_SHIFTED(N, EVAL, expr));
+ return EVAL(~, 0, e)(BOOST_PP_ENUM_SHIFTED(N, EVAL, e));
             }
 
             result_type invoke(
- typename impl2::expr_param expr
- , typename impl2::state_param state
- , typename impl2::data_param data
+ typename impl2::expr_param e
+ , typename impl2::state_param s
+ , typename impl2::data_param d
               , mpl::true_
             ) const
             {
- #define M0(Z, M, expr) BOOST_PP_COMMA_IF(BOOST_PP_SUB(M, 2)) EVAL(Z, M, expr)
+ #define M0(Z, M, e) BOOST_PP_COMMA_IF(BOOST_PP_SUB(M, 2)) EVAL(Z, M, e)
                 using namespace detail::get_pointer_;
- return (get_pointer(EVAL(~, 1, expr)) ->* EVAL(~, 0, expr))(
- BOOST_PP_REPEAT_FROM_TO(2, N, M0, expr)
+ return (get_pointer(EVAL(~, 1, e)) ->* EVAL(~, 0, e))(
+ BOOST_PP_REPEAT_FROM_TO(2, N, M0, e)
                 );
                 #undef M0
             }

Modified: branches/release/boost/proto/transform/fold.hpp
==============================================================================
--- branches/release/boost/proto/transform/fold.hpp (original)
+++ branches/release/boost/proto/transform/fold.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -60,9 +60,9 @@
 
                 template<typename Expr, typename State>
                 typename when<_, Transform>::template impl<Expr &, State const &, Data>::result_type
- operator ()(Expr &expr, State const &state) const
+ operator ()(Expr &e, State const &s) const
                 {
- return typename when<_, Transform>::template impl<Expr &, State const &, Data>()(expr, state, this->v_);
+ return typename when<_, Transform>::template impl<Expr &, State const &, Data>()(e, s, this->v_);
                 }
 
             private:
@@ -145,9 +145,9 @@
                       , BOOST_PP_CAT(state, N) \
                       , Data \
>()( \
- proto::child_c<N>(expr) \
+ proto::child_c<N>(e) \
                       , BOOST_PP_CAT(s, N) \
- , data \
+ , d \
                     ); \
                 /**/
 
@@ -175,9 +175,9 @@
                       , BOOST_PP_CAT(state, BOOST_PP_SUB(DATA, N)) \
                       , Data \
>()( \
- proto::child_c<BOOST_PP_SUB(DATA, BOOST_PP_INC(N))>(expr) \
+ proto::child_c<BOOST_PP_SUB(DATA, BOOST_PP_INC(N))>(e) \
                       , BOOST_PP_CAT(s, BOOST_PP_SUB(DATA, N)) \
- , data \
+ , d \
                     ); \
                 /**/
 
@@ -227,27 +227,27 @@
>::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>
- /// is equivalent to <tt>when\<_, Fun\>()(expr, state, data)</tt>. Then, this
- /// function returns <tt>fusion::fold(seq, state0, fun(data))</tt>.
+ /// Let \c seq be <tt>when\<_, Sequence\>()(e, s, d)</tt>, let
+ /// \c state0 be <tt>when\<_, State0\>()(e, s, d)</tt>, and
+ /// let \c fun(d) be an object such that <tt>fun(d)(e, s)</tt>
+ /// is equivalent to <tt>when\<_, Fun\>()(e, s, d)</tt>. Then, this
+ /// function returns <tt>fusion::fold(seq, state0, fun(d))</tt>.
                 ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
                 result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                 ) const
                 {
- typename when<_, Sequence>::template impl<Expr, State, Data> sequence;
- detail::as_callable<Fun, Data> fun(data);
+ typename when<_, Sequence>::template impl<Expr, State, Data> seq;
+ detail::as_callable<Fun, Data> f(d);
                     return fusion::fold(
- BOOST_PROTO_AS_FUSION_SEQUENCE(sequence(expr, state, data))
- , typename when<_, State0>::template impl<Expr, State, Data>()(expr, state, data)
- , fun
+ BOOST_PROTO_AS_FUSION_SEQUENCE(seq(e, s, d))
+ , typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d)
+ , f
                     );
                 }
             };
@@ -323,13 +323,13 @@
                 typedef BOOST_PP_CAT(state, N) result_type;
 
                 result_type operator ()(
- typename fold_impl::expr_param expr
- , typename fold_impl::state_param state
- , typename fold_impl::data_param data
+ typename fold_impl::expr_param e
+ , typename fold_impl::state_param s
+ , typename fold_impl::data_param d
                 ) const
                 {
                     state0 s0 =
- typename when<_, State0>::template impl<Expr, State, Data>()(expr, state, data);
+ typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
                     BOOST_PP_REPEAT(N, BOOST_PROTO_FOLD_STATE, N)
                     return BOOST_PP_CAT(s, N);
                 }
@@ -344,13 +344,13 @@
                 typedef state0 result_type;
 
                 result_type operator ()(
- typename reverse_fold_impl::expr_param expr
- , typename reverse_fold_impl::state_param state
- , typename reverse_fold_impl::data_param data
+ typename reverse_fold_impl::expr_param e
+ , typename reverse_fold_impl::state_param s
+ , typename reverse_fold_impl::data_param d
                 ) const
                 {
                     BOOST_PP_CAT(state, N) BOOST_PP_CAT(s, N) =
- typename when<_, State0>::template impl<Expr, State, Data>()(expr, state, data);
+ typename when<_, State0>::template impl<Expr, State, Data>()(e, s, d);
                     BOOST_PP_REPEAT(N, BOOST_PROTO_REVERSE_FOLD_STATE, N)
                     return s0;
                 }

Modified: branches/release/boost/proto/transform/fold_tree.hpp
==============================================================================
--- branches/release/boost/proto/transform/fold_tree.hpp (original)
+++ branches/release/boost/proto/transform/fold_tree.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -85,9 +85,9 @@
     /// \endcode
     ///
     /// With <tt>recurse_if_\<\></tt> as defined above,
- /// <tt>fold_tree\<Sequence, State0, Fun\>()(expr, state, data)</tt> is
+ /// <tt>fold_tree\<Sequence, State0, Fun\>()(e, s, d)</tt> is
     /// equivalent to
- /// <tt>fold<Sequence, State0, recurse_if_<Expr::proto_tag, Fun> >()(expr, state, data).</tt>
+ /// <tt>fold<Sequence, State0, recurse_if_<Expr::proto_tag, Fun> >()(e, s, d).</tt>
     /// It has the effect of folding a tree front-to-back, recursing into
     /// child nodes that share a tag type with the parent node.
     template<typename Sequence, typename State0, typename Fun>
@@ -134,9 +134,9 @@
     /// \endcode
     ///
     /// With <tt>recurse_if_\<\></tt> as defined above,
- /// <tt>reverse_fold_tree\<Sequence, State0, Fun\>()(expr, state, data)</tt> is
+ /// <tt>reverse_fold_tree\<Sequence, State0, Fun\>()(e, s, d)</tt> is
     /// equivalent to
- /// <tt>reverse_fold<Sequence, State0, recurse_if_<Expr::proto_tag, Fun> >()(expr, state, data).</tt>
+ /// <tt>reverse_fold<Sequence, State0, recurse_if_<Expr::proto_tag, Fun> >()(e, s, d).</tt>
     /// It has the effect of folding a tree back-to-front, recursing into
     /// child nodes that share a tag type with the parent node.
     template<typename Sequence, typename State0, typename Fun>

Modified: branches/release/boost/proto/transform/impl.hpp
==============================================================================
--- branches/release/boost/proto/transform/impl.hpp (original)
+++ branches/release/boost/proto/transform/impl.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -60,40 +60,40 @@
 
         template<typename Expr>
         typename apply_transform<PrimitiveTransform, Expr &>::result_type
- operator ()(Expr &expr) const
+ operator ()(Expr &e) const
         {
             int i = 0;
- return apply_transform<PrimitiveTransform, Expr &>()(expr, i, i);
+ return apply_transform<PrimitiveTransform, Expr &>()(e, i, i);
         }
 
         template<typename Expr, typename State>
         typename apply_transform<PrimitiveTransform, Expr &, State &>::result_type
- operator ()(Expr &expr, State &state) const
+ operator ()(Expr &e, State &s) const
         {
             int i = 0;
- return apply_transform<PrimitiveTransform, Expr &, State &>()(expr, state, i);
+ return apply_transform<PrimitiveTransform, Expr &, State &>()(e, s, i);
         }
 
         template<typename Expr, typename State>
         typename apply_transform<PrimitiveTransform, Expr &, State const &>::result_type
- operator ()(Expr &expr, State const &state) const
+ operator ()(Expr &e, State const &s) const
         {
             int i = 0;
- return apply_transform<PrimitiveTransform, Expr &, State const &>()(expr, state, i);
+ return apply_transform<PrimitiveTransform, Expr &, State const &>()(e, s, i);
         }
 
         template<typename Expr, typename State, typename Data>
         typename apply_transform<PrimitiveTransform, Expr &, State &, Data &>::result_type
- operator ()(Expr &expr, State &state, Data &data) const
+ operator ()(Expr &e, State &s, Data &d) const
         {
- return apply_transform<PrimitiveTransform, Expr &, State &, Data &>()(expr, state, data);
+ return apply_transform<PrimitiveTransform, Expr &, State &, Data &>()(e, s, d);
         }
 
         template<typename Expr, typename State, typename Data>
         typename apply_transform<PrimitiveTransform, Expr &, State const &, Data &>::result_type
- operator ()(Expr &expr, State const &state, Data &data) const
+ operator ()(Expr &e, State const &s, Data &d) const
         {
- return apply_transform<PrimitiveTransform, Expr &, State const &, Data &>()(expr, state, data);
+ return apply_transform<PrimitiveTransform, Expr &, State const &, Data &>()(e, s, d);
         }
     };
 

Modified: branches/release/boost/proto/transform/make.hpp
==============================================================================
--- branches/release/boost/proto/transform/make.hpp (original)
+++ branches/release/boost/proto/transform/make.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -189,7 +189,7 @@
         /// \code
         /// // OK: replace anything with Bar<_>()
         /// struct Foo
- /// : proto::when<_, Bar<_>() >
+ /// : proto::when<_, Bar<protect<_> >() >
         /// {};
         /// \endcode
         template<typename PrimitiveTransform>
@@ -373,28 +373,28 @@
                 typedef typename detail::make_if_<Object, Expr, State, Data>::type result_type;
                 //typedef typename detail::make_<Object, Expr, State, Data>::type result_type;
 
- /// Let \c ax be <tt>when\<_, Ax\>()(expr, state, data)</tt>
+ /// Let \c ax be <tt>when\<_, Ax\>()(e, s, d)</tt>
                 /// for each \c x in <tt>[0,N]</tt>.
                 /// Let \c T be <tt>result\<void(Expr, State, Data)\>::::type</tt>.
                 /// Return <tt>T(a0, a1,... aN)</tt>.
                 ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
                 result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                 ) const
                 {
- proto::detail::ignore_unused(expr);
- proto::detail::ignore_unused(state);
- proto::detail::ignore_unused(data);
+ proto::detail::ignore_unused(e);
+ proto::detail::ignore_unused(s);
+ proto::detail::ignore_unused(d);
                     return detail::construct<result_type>(
                         #define TMP(Z, M, DATA) \
                             detail::as_lvalue( \
                                 typename when<_, BOOST_PP_CAT(A, M)> \
- ::template impl<Expr, State, Data>()(expr, state, data) \
+ ::template impl<Expr, State, Data>()(e, s, d) \
                             )
                         BOOST_PP_ENUM(N, TMP, DATA)
                         #undef TMP
@@ -415,16 +415,16 @@
                 typedef proto::expr<Tag, Args, Arity> result_type;
 
                 result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                 ) const
                 {
                     return proto::expr<Tag, Args, Arity>::make(
                         #define TMP(Z, M, DATA) \
                             detail::as_lvalue( \
                                 typename when<_, BOOST_PP_CAT(A, M)> \
- ::template impl<Expr, State, Data>()(expr, state, data) \
+ ::template impl<Expr, State, Data>()(e, s, d) \
                             )
                         BOOST_PP_ENUM(N, TMP, DATA)
                         #undef TMP

Modified: branches/release/boost/proto/transform/pass_through.hpp
==============================================================================
--- branches/release/boost/proto/transform/pass_through.hpp (original)
+++ branches/release/boost/proto/transform/pass_through.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -51,7 +51,7 @@
                   , State \
                   , Data \
>()( \
- expr.proto_base().BOOST_PP_CAT(child, N), state, data \
+ e.proto_base().BOOST_PP_CAT(child, N), s, d \
                 )
 
             #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/pass_through.hpp>))
@@ -66,16 +66,16 @@
             {
                 typedef Expr result_type;
 
- /// \param expr An expression
- /// \return \c expr
+ /// \param e An expression
+ /// \return \c e
                 /// \throw nothrow
                 typename pass_through_impl::expr_param operator()(
- typename pass_through_impl::expr_param expr
+ typename pass_through_impl::expr_param e
                   , typename pass_through_impl::state_param
                   , typename pass_through_impl::data_param
                 ) const
                 {
- return expr;
+ return e;
                 }
             };
 
@@ -168,9 +168,9 @@
> result_type;
 
                 result_type operator ()(
- typename pass_through_impl::expr_param expr
- , typename pass_through_impl::state_param state
- , typename pass_through_impl::data_param data
+ typename pass_through_impl::expr_param e
+ , typename pass_through_impl::state_param s
+ , typename pass_through_impl::data_param d
                 ) const
                 {
                     result_type that = {

Modified: branches/release/boost/proto/transform/when.hpp
==============================================================================
--- branches/release/boost/proto/transform/when.hpp (original)
+++ branches/release/boost/proto/transform/when.hpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -168,18 +168,18 @@
                 /// whether <tt>is_callable\<R\>::::value</tt> is \c true or
                 /// \c false.
                 ///
- /// \param expr The current expression
- /// \param state The current state
- /// \param data An arbitrary data
+ /// \param e The current expression
+ /// \param s The current state
+ /// \param d An arbitrary data
                 /// \pre <tt>matches\<Expr, Grammar\>::::value</tt> is \c true
- /// \return <tt>result\<void(Expr, State, Data)\>::::impl()(expr, state, data)</tt>
+ /// \return <tt>result\<void(Expr, State, Data)\>::::impl()(e, s, d)</tt>
                 result_type operator ()(
- typename impl::expr_param expr
- , typename impl::state_param state
- , typename impl::data_param data
+ typename impl::expr_param e
+ , typename impl::state_param s
+ , typename impl::data_param d
                 ) const
                 {
- return typename which::template impl<Expr, State, Data>()(expr, state, data);
+ return typename which::template impl<Expr, State, Data>()(e, s, d);
                 }
             };
         };

Modified: branches/release/libs/proto/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/proto/doc/Jamfile.v2 (original)
+++ branches/release/libs/proto/doc/Jamfile.v2 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -2,8 +2,25 @@
 # subject to 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)
 
+import os ;
 import path ;
 import quickbook ;
+import boostbook ;
+
+local admon-graphics-path = [ path.join [ boostbook.docbook-xsl-dir ] images ] ;
+local callout-graphics-path = [ path.join $(admon-graphics-path) callouts ] ;
+
+admon-graphics-path = [ path.native $(admon-graphics-path)/ ] ;
+callout-graphics-path = [ path.native $(callout-graphics-path)/ ] ;
+
+if [ os.name ] = CYGWIN
+{
+ admon-graphics-path = $(admon-graphics-path:W) ;
+ callout-graphics-path = $(callout-graphics-path:W) ;
+
+ admon-graphics-path = $(admon-graphics-path:T) ;
+ callout-graphics-path = $(callout-graphics-path:T) ;
+}
 
 xml proto
     :
@@ -50,8 +67,7 @@
         # Set this one for PDF generation *only*:
         # default png graphics are awful in PDF form,
         # better use SVG's instead:
- #<format>pdf:<xsl:param>admon.graphics.extension=".svg"
- #<format>pdf:<xsl:param>img.src.path="C:/Program Files/docbook-xsl-1.73.2/images/"
- #<format>pdf:<xsl:param>admon.graphics.path="C:/Program Files/docbook-xsl-1.73.2/images/"
- #<format>pdf:<xsl:param>callout.graphics.path="C:/Program Files/docbook-xsl-1.73.2/images/callouts/"
+ <format>pdf:<xsl:param>admon.graphics.extension=".svg"
+ <format>pdf:<xsl:param>admon.graphics.path="$(admon-graphics-path)"
+ <format>pdf:<xsl:param>callout.graphics.path="$(callout-graphics-path)"
     ;

Modified: branches/release/libs/proto/doc/front_end.qbk
==============================================================================
--- branches/release/libs/proto/doc/front_end.qbk (original)
+++ branches/release/libs/proto/doc/front_end.qbk 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -70,12 +70,7 @@
     _1(8,9); // OK, builds a ternary function tree node
     // ... etc.
 
-For the first two lines, assignment and subscript, it should be fairly unsurprising
-that the resulting expression node should be binary. After all, there are
-two operands in each expression. It may be surprising at first that what appears
-to be a function call with no arguments, `_1()`, actually creates an expression
-node with one child. The child is `_1` itself. Likewise, the expression `_1(7)`
-has two children: `_1` and `7`.
+For the first two lines, assignment and subscript, it should be fairly unsurprising that the resulting expression node should be binary. After all, there are two operands in each expression. It may be surprising at first that what appears to be a function call with no arguments, `_1()`, actually creates an expression node with one child. The child is `_1` itself. Likewise, the expression `_1(7)` has two children: `_1` and `7`.
 
 Because these operators can only be defined as member functions, the following expressions are invalid:
 
@@ -87,22 +82,17 @@
 
     std::sin(_1); // ERROR: cannot call std::sin() with _1
 
-Also, C++ has special rules for overloads of `operator->` that make it useless
-for building expression templates, so Proto does not overload it.
+Also, C++ has special rules for overloads of `operator->` that make it useless for building expression templates, so Proto does not overload it.
 
 [/==============================]
 [heading The Address-Of Operator]
 [/==============================]
 
-Proto overloads the address-of operator for expression types, so that the
-following code creates a new unary address-of tree node:
+Proto overloads the address-of operator for expression types, so that the following code creates a new unary address-of tree node:
 
     &_1; // OK, creates a unary address-of tree node
 
-It does /not/ return the address of the `_1` object. However, there is
-special code in Proto such that a unary address-of node is implicitly
-convertible to a pointer to its child. In other words, the following
-code works and does what you might expect, but not in the obvious way:
+It does /not/ return the address of the `_1` object. However, there is special code in Proto such that a unary address-of node is implicitly convertible to a pointer to its child. In other words, the following code works and does what you might expect, but not in the obvious way:
 
     typedef
         proto::terminal< placeholder<0> >::type
@@ -373,7 +363,7 @@
 To use _extends_, your extension type must derive from _extends_. Unfortunately, that means that your extension type is no longer POD and its instances cannot be /statically initialized/. (See the [link boost_proto.appendices.rationale.static_initialization Static
 Initialization] section in the [link boost_proto.appendices.rationale Rationale] appendix for why this matters.) In particular, as defined above, the global placeholder objects `_1` and `_2` will need to be initialized at runtime, which could lead to subtle order of initialization bugs.
 
-There is another way to make an expression extension that doesn't sacrifice POD-ness : the `BOOST_PROTO_EXTENDS()` macro. You can use it much like you use _extends_. We can use `BOOST_PROTO_EXTENDS()` to keep `calculator<>` a POD and our placeholders statically initialized.
+There is another way to make an expression extension that doesn't sacrifice POD-ness : the _EXTENDS_ macro. You can use it much like you use _extends_. We can use _EXTENDS_ to keep `calculator<>` a POD and our placeholders statically initialized.
 
     // The calculator<> expression wrapper makes expressions
     // function objects.
@@ -399,7 +389,7 @@
 
 We need to make one additional small change to accommodate the POD-ness of our expression extension, which we'll describe below in the section on expression generators.
 
-What does `BOOST_PROTO_EXTENDS()` do? It defines a data member of expression type being extended; some nested typedefs that Proto requires; `operator=`, `operator[]` and `operator()` overloads for building expression templates; and a nested `result<>` template for calculating the return type of `operator()`. In this case, however, the `operator()` overloads and the `result<>` template are not needed because we are defining our own `operator()` in the `calculator<>` type. Proto provides additional macros for finer control over which member functions are defined. We could improve our `calculator<>` type as follows:
+What does _EXTENDS_ do? It defines a data member of expression type being extended; some nested typedefs that Proto requires; `operator=`, `operator[]` and `operator()` overloads for building expression templates; and a nested `result<>` template for calculating the return type of `operator()`. In this case, however, the `operator()` overloads and the `result<>` template are not needed because we are defining our own `operator()` in the `calculator<>` type. Proto provides additional macros for finer control over which member functions are defined. We could improve our `calculator<>` type as follows:
 
     // The calculator<> expression wrapper makes expressions
     // function objects.
@@ -424,39 +414,41 @@
         }
     };
 
-Notice that we are now using `BOOST_PROTO_BASIC_EXTENDS()` instead of `BOOST_PROTO_EXTENDS()`. This just adds the data member and the nested typedefs but not any of the overloaded operators. Those are added separately with `BOOST_PROTO_EXTENDS_ASSIGN()` and `BOOST_PROTO_EXTENDS_SUBSCRIPT()`. We are leaving out the function call operator and the nested `result<>` template that could have been defined with Proto's `BOOST_PROTO_EXTENDS_FUNCTION()` macro.
+Notice that we are now using _BASIC_EXTENDS_ instead of _EXTENDS_. This just adds the data member and the nested typedefs but not any of the overloaded operators. Those are added separately with _EXTENDS_ASSIGN_ and _EXTENDS_SUBSCRIPT_. We are leaving out the function call operator and the nested `result<>` template that could have been defined with Proto's _EXTENDS_FUNCTION_ macro.
 
 In summary, here are the macros you can use to define expression extensions, and a brief description of each.
 
 [def __expression__ [~expression]]
 [def __extension__ [~extension]]
 [def __domain__ [~domain]]
+[def __extends__ [macroref BOOST_PROTO_EXTENDS]]
+[def __basic_extends__ [macroref BOOST_PROTO_BASIC_EXTENDS]]
 
 [table Expression Extension Macros
  [[Macro]
   [Purpose]]
- [[``BOOST_PROTO_BASIC_EXTENDS(
+ [[``__basic_extends__(
     __expression__
   , __extension__
   , __domain__
 )``]
   [Defines a data member of type `__expression__` and some nested typedefs that Proto requires.]]
- [[`BOOST_PROTO_EXTENDS_ASSIGN()`]
- [Defines `operator=`. Only valid when preceded by `BOOST_PROTO_BASIC_EXTENDS()`.]]
- [[`BOOST_PROTO_EXTENDS_SUBSCRIPT()`]
- [Defines `operator[]`. Only valid when preceded by `BOOST_PROTO_BASIC_EXTENDS()`.]]
- [[`BOOST_PROTO_EXTENDS_FUNCTION()`]
- [Defines `operator()` and a nested `result<>` template for return type calculation. Only valid when preceded by `BOOST_PROTO_BASIC_EXTENDS()`.]]
- [[``BOOST_PROTO_EXTENDS(
+ [[_EXTENDS_ASSIGN_]
+ [Defines `operator=`. Only valid when preceded by _BASIC_EXTENDS_.]]
+ [[_EXTENDS_SUBSCRIPT_]
+ [Defines `operator[]`. Only valid when preceded by _BASIC_EXTENDS_.]]
+ [[_EXTENDS_FUNCTION_]
+ [Defines `operator()` and a nested `result<>` template for return type calculation. Only valid when preceded by _BASIC_EXTENDS_.]]
+ [[``__extends__(
     __expression__
   , __extension__
   , __domain__
 )``]
   [Equivalent to:``
- BOOST_PROTO_BASIC_EXTENDS(__expression__, __extension__, __domain__)
- BOOST_PROTO_EXTENDS_ASSIGN()
- BOOST_PROTO_EXTENDS_SUBSCRIPT()
- BOOST_PROTO_EXTENDS_FUNCTION()``]]
+__basic_extends__(__expression__, __extension__, __domain__)
+_EXTENDS_ASSIGN_
+_EXTENDS_SUBSCRIPT_
+_EXTENDS_FUNCTION_``]]
 ]
 
 [endsect]
@@ -476,7 +468,7 @@
 
 The first template parameter to `proto::domain<>` is the generator. "Generator" is just a fancy name for a function object that accepts an expression and does something to it. `proto::generator<>` is a very simple one --- it wraps an expression in the wrapper you specify. `proto::domain<>` inherits from its generator parameter, so all domains are themselves function objects.
 
-If we used `BOOST_PROTO_EXTENDS()` to keep our expression extension type POD, then we need to use `proto::pod_generator<>` instead of `proto::generator<>`, as follows:
+If we used _EXTENDS_ to keep our expression extension type POD, then we need to use `proto::pod_generator<>` instead of `proto::generator<>`, as follows:
 
     // If calculator<> uses BOOST_PROTO_EXTENDS() instead of
     // use proto::extends<>, use proto::pod_generator<> instead
@@ -550,4 +542,65 @@
 
 [endsect]
 
+[section:define_operators Adapting Existing Types to Proto]
+
+The preceding discussions of defining Proto front ends have all made a big assumption: that you have the luxury of defining everything from scratch. What happens if you have existing types, say a matrix type and a vector type, that you would like to treat as if they were Proto terminals? Proto usually trades only in its own expression types, but with _DEFINE_OPERATORS_, it can accomodate your custom terminal types, too.
+
+Let's say, for instance, that you have the following types and that you can't modify then to make them ["native] Proto terminal types.
+
+ namespace math
+ {
+ // A matrix type ...
+ struct matrix { /*...*/ };
+
+ // A vector type ...
+ struct vector { /*...*/ };
+ }
+
+You can non-intrusively make objects of these types Proto terminals by defining the proper operator overloads using _DEFINE_OPERATORS_. The basic procedure is as follows:
+
+# Define a trait that returns true for your types and false for all others.
+# Reopen the namespace of your types and use _DEFINE_OPERATORS_ to define a set of
+ operator overloads, passing the name of the trait as the first macro parameter,
+ and the name of a Proto domain (e.g., _default_domain_) as the second.
+
+The following code demonstrates how it works.
+
+ namespace math
+ {
+ template<typename T>
+ struct is_terminal
+ : mpl::false_
+ {};
+
+ // OK, "matrix" is a custom terminal type
+ template<>
+ struct is_terminal<matrix>
+ : mpl::true_
+ {};
+
+ // OK, "vector" is a custom terminal type
+ template<>
+ struct is_terminal<vector>
+ : mpl::true_
+ {};
+
+ // Define all the operator overloads to construct Proto
+ // expression templates, treating "matrix" and "vector"
+ // objects as if they were Proto terminals.
+ BOOST_PROTO_DEFINE_OPERATORS(is_terminal, proto::default_domain)
+ }
+
+The invocation of the _DEFINE_OPERATORS_ macro defines a complete set of operator overloads that treat `matrix` and `vector` objects as if they were Proto terminals. And since the operators are defined in the same namespace as the `matrix` and `vector` types, the operators will be found by argument-dependent lookup. With the code above, we can now construct expression templates with matrices and vectors, as shown below.
+
+ math::matrix m1;
+ math::vector v1;
+ proto::literal<int> i(0);
+
+ m1 * 1; // custom terminal and literals are OK
+ m1 * i; // custom terminal and Proto expressions are OK
+ m1 * v1; // two custom terminals are OK, too.
+
+[endsect]
+
 [endsect]

Modified: branches/release/libs/proto/doc/intermediate_form.qbk
==============================================================================
--- branches/release/libs/proto/doc/intermediate_form.qbk (original)
+++ branches/release/libs/proto/doc/intermediate_form.qbk 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -29,7 +29,7 @@
 [heading The [^expr<>] Type]
 [/=========================]
 
-All Proto expressions are an instantiation of a template called `expr<>` (or a wrapper around such an instantiation). When we define a terminal as below, we are really initializing an instance of the _expr_ template.
+All Proto expressions are an instantiation of a template called _expr_ (or a wrapper around such an instantiation). When we define a terminal as below, we are really initializing an instance of the _expr_ template.
 
     // Define a placeholder type
     template<int I>
@@ -129,12 +129,12 @@
 
 There are a few things to note about these types:
 
-# Terminals have arity 0, unary expressions have arity 1 and binary expressions
- have arity 2.
-# When one Proto expression is made a child node of another Proto expression,
+* Terminals have arity zero, unary expressions have arity one and binary
+ expressions have arity two.
+* When one Proto expression is made a child node of another Proto expression,
   it is held by reference, ['even if it is a temporary object]. This last
   point becomes important later.
-# Non-Proto expressions, such as the integer literal, are turned into Proto
+* Non-Proto expressions, such as the integer literal, are turned into Proto
   expressions by wrapping them in new `expr<>` terminal objects. These new
   wrappers are not themselves held by reference, but the object wrapped /is/.
   Notice that the type of the Protofied `42` literal is `int const &` -- held
@@ -153,43 +153,79 @@
 trees so they can be passed around as value types without concern for dangling
 references.]
 
-[/=============================================]
-[section:left_right_child Accessing Child Nodes]
-[/=============================================]
+[/========================================================]
+[section:left_right_child Accessing Parts of an Expression]
+[/========================================================]
 
 After assembling an expression into a tree, you'll naturally want to be
 able to do the reverse, and access a node's children. You may even want
 to be able to iterate over the children with algorithms from the
 Boost.Fusion library. This section shows how.
 
-[heading [^tag_of<>]]
+[/==========================================]
+[heading Getting Expression Tags and Arities]
+[/==========================================]
 
-A node in an expression tree is nothing more than a collection of child
-nodes and a tag type. You can access the tag type of any Proto expression type
-`Expr` directly as `typename Expr::proto_tag`, or you can use the _tag_of_
-metafunction, as shown below:
+Every node in an expression tree has both a /tag/ type that describes the node, and an /arity/ corresponding to the number of child nodes it has. You can use the _tag_of_ and _arity_of_ metafunctions to fetch them. Consider the following:
 
     template<typename Expr>
- typename proto::result_of::tag_of<Expr>::type
- get_tag_of(Expr const &)
+ void check_plus_node(Expr const &)
     {
- // Tag types are required to be default-constructible
- return typename proto::result_of::tag_of<Expr>::type();
+ // Assert that the tag type is proto::tag::plus
+ BOOST_STATIC_ASSERT((
+ boost::is_same<
+ typename proto::tag_of<Expr>::type
+ , proto::tag::plus
+ >::value
+ ));
+
+ // Assert that the arity is 2
+ BOOST_STATIC_ASSERT( proto::arity_of<Expr>::value == 2 );
     }
 
- proto::terminal<int>::type const i = {42};
+ // Create a binary plus node and use check_plus_node()
+ // to verify its tag type and arity:
+ check_plus_node( proto::lit(1) + 2 );
+
+For a given type `Expr`, you could access the tag and arity directly as `Expr::proto_tag` and `Expr::proto_arity`, where `Expr::proto_arity` is an MPL Integral Constant.
+
+[/==============================]
+[heading Getting Terminal Values]
+[/==============================]
+
+There is no simpler expression than a terminal, and no more basic operation than extracting its value. As we've already seen, that is what _value_ is for.
+
+ proto::terminal< std::ostream & >::type cout_ = {std::cout};
 
- // Addition nodes have the "plus" tag type:
- proto::tag::plus plus_tag = get_tag_of( i + 2 );
+ // Get the value of the cout_ terminal:
+ std::ostream & sout = proto::value( cout_ );
 
-[/===================]
-[heading [^child_c()]]
-[/===================]
-
-Each node in an expression tree corresponds to an operator in an expression,
-and the children correspond to the operands, or arguments of the operator.
-To access them, you can use the _child_c_ function template, as demonstrated
-below:
+ // Assert that we got back what we put in:
+ assert( &sout == &std::cout );
+
+To compute the return type of the _value_ function, you can use _result_of_value_. When the parameter to _result_of_value_ is a non-reference type, the result type of the metafunction is the type of the value as suitable for storage by value; that is, top-level reference and qualifiers are stripped from it. But when instantiated with a reference type, the result type has a reference /added/ to it, yielding a type suitable for storage by reference. If you want to know the actual type of the terminal's value including whether it is stored by value or reference, you can use `fusion::result_of::value_at<Expr, 0>::type`.
+
+The following table summarizes the above paragraph.
+
+[def _unless_ [footnote If `T` is a reference-to-function type, then the result type is simply `T`.]]
+
+[table Accessing Value Types
+ [[Metafunction Invocation][When the Value Type Is ...][The Result Is ...]]
+ [[`proto::result_of::value<Expr>::type`][`T`][``typename boost::remove_const<
+ typename boost::remove_reference<T>::type
+>::type _unless_``]]
+ [[`proto::result_of::value<Expr &>::type`][`T`][``typename boost::add_reference<T>::type``]]
+ [[`proto::result_of::value<Expr const &>::type`][`T`][``typename boost::add_reference<
+ typename boost::add_const<T>::type
+>::type``]]
+ [[`fusion::result_of::value_at<Expr, 0>::type`][`T`][`T`]]
+]
+
+[/================================]
+[heading Getting Child Expressions]
+[/================================]
+
+Each non-terminal node in an expression tree corresponds to an operator in an expression, and the children correspond to the operands, or arguments of the operator. To access them, you can use the _child_c_ function template, as demonstrated below:
 
     proto::terminal<int>::type i = {42};
 
@@ -199,23 +235,23 @@
     // Assert that we got back what we put in:
     assert( &i == &ri );
 
-You can use the `result_of::child_c<>` metafunction to get the type of the Nth
-child of an expression node. Usually you don't care to know whether a child
-is stored by value or by reference, so when you ask for the type of the Nth
-child of an expression `Expr`, you get the child's type after references and
-cv-qualifiers have been stripped from it.
+You can use the _result_of_child_c_ metafunction to get the type of the Nth child of an expression node. Usually you don't care to know whether a child is stored by value or by reference, so when you ask for the type of the Nth child of an expression `Expr` (where `Expr` is not a reference type), you get the child's type after references and cv-qualifiers have been stripped from it.
 
     template<typename Expr>
     void test_result_of_child_c(Expr const &expr)
     {
         typedef typename proto::result_of::child_c<Expr, 0>::type type;
 
- // ::type is a non-cv qualified, non-reference
- BOOST_MPL_ASSERT((is_same< type, terminal<int>::type>));
+ // Since Expr is not a reference type,
+ // result_of::child_c<Expr, 0>::type is a
+ // non-cv qualified, non-reference type:
+ BOOST_MPL_ASSERT((
+ boost::is_same< type, proto::terminal<int>::type >
+ ));
     }
 
     // ...
- terminal<int>::type i = {42};
+ proto::terminal<int>::type i = {42};
     test_result_of_child_c( i + 2 );
 
 However, if you ask for the type of the Nth child of `Expr &` or `Expr const &`
@@ -223,136 +259,120 @@
 the child is actually stored by reference or not. If you need to know exactly
 how the child is stored in the node, whether by reference or by value, you can
 use `fusion::result_of::value_at<Expr, N>::type`. The following table summarizes
-the behavior of the `child_c<>` metafunction.
+the behavior of the _result_of_child_c_ metafunction.
 
 [table Accessing Child Types
     [[Metafunction Invocation][When the Child Is ...][The Result Is ...]]
- [[`proto::result_of::child_c<Expr, N>::type`][T][T]]
- [[][T &][T]]
- [[][T const &][T]]
- [[`proto::result_of::child_c<Expr &, N>::type`][T][T &]]
- [[][T &][T &]]
- [[][T const &][T const &]]
- [[`proto::result_of::child_c<Expr const &, N>::type`][T][T const &]]
- [[][T &][T &]]
- [[][T const &][T const &]]
- [[`fusion::result_of::value_at<Expr, N>::type`][T][T]]
- [[][T &][T &]]
- [[][T const &][T const &]]
+ [[`proto::result_of::child_c<Expr, N>::type`][`T`][``typename boost::remove_const<
+ typename boost::remove_reference<T>::type
+>::type``]]
+ [[`proto::result_of::child_c<Expr &, N>::type`][`T`][``typename boost::add_reference<T>::type``]]
+ [[`proto::result_of::child_c<Expr const &, N>::type`][`T`][``typename boost::add_reference<
+ typename boost::add_const<T>::type
+>::type``]]
+ [[`fusion::result_of::value_at<Expr, N>::type`][`T`][`T`]]
 ]
 
-[/========================================================]
-[heading [^value()], [^child()], [^left()], and [^right()]]
-[/========================================================]
+[/=======================]
+[heading Common Shortcuts]
+[/=======================]
 
-Most operators in C++ are unary or binary. For that reason, accessing the
-only operand, or the left and right operands, are very common operations. For
-this reason, Proto provides the _child_, _left_, and _right_ functions. _child_
-and _left_ are synonymous with `child_c<0>()`, and _right_ is synonymous with
-`child_c<1>()`.
-
-Another very common operation is accessing the value stored within a Proto
-terminal. You can use the _value_ function for that.
-
-There are also `result_of::child<>`, `result_of::left<>`, and `result_of::right<>`
-metafunctions that merely forward to their `result_of::child_c<>` counterparts.
-Likewise, there is a `result_of::value<>` metafunction that returns the type of the
-value stored in a terminal node.
+Most operators in C++ are unary or binary, so accessing the only operand, or the left and right operands, are very common operations. For this reason, Proto provides the _child_, _left_, and _right_ functions. _child_ and _left_ are synonymous with `proto::child_c<0>()`, and _right_ is synonymous with `proto::child_c<1>()`.
 
-[/===========================================]
-[heading Expression Nodes as Fusion Sequences]
-[/===========================================]
+There are also _result_of_child_, _result_of_left_, and _result_of_right_ metafunctions that merely forward to their _result_of_child_c_ counterparts.
 
-Proto expression nodes are valid Fusion random-access sequences of their
-child nodes. That means you can apply Fusion algorithms to them,
-transform them, apply Fusion filters and views to them, and access their
-elements using `fusion::at()`. The things Fusion can do to heterogeneous
-sequences are beyond the scope of this users' guide, but below is a simple
-example. It takes a lazy function invocation like `fun(1,2,3,4)` and uses
-Fusion to print the function arguments in order.
+[endsect]
 
- struct display
- {
- template<typename T>
- void operator()(T const &t) const
- {
- std::cout << t << std::endl;
- }
- };
+[/===============================]
+[section Deep-copying Expressions]
+[/===============================]
 
- struct fun_t {};
- proto::terminal<fun_t>::type const fun = {{}};
+When you build an expression template with Proto, all the intermediate child nodes are held /by reference/. The avoids needless copies, which is crucial if you want your DSEL to perform well at runtime. Naturally, there is a danger if the temporary objects go out of scope before you try to evaluate your expression template. This is especially a problem in C++0x with the new `decltype` and `auto` keywords. Consider:
 
- // ...
- fusion::for_each(
- fusion::transform(
- // pop_front() removes the "fun" child
- fusion::pop_front(fun(1,2,3,4))
- // Extract the ints from the terminal nodes
- , proto::functional::value()
- )
- , display()
- );
+ // OOPS: "ex" is left holding dangling references
+ auto ex = proto::lit(1) + 2;
 
-Recall from the Introduction that types in the `proto::functional` namespace
-define function objects that correspond to Proto's free functions. So
-`proto::functional::value()` creates a function object that is equivalent to
-the `proto::value()` function. The above invocation of `fusion::for_each()`
-displays the following:
+The problem can happen in today's C++ also if you use `BOOST_TYPEOF()` or `BOOST_AUTO()`, or if you try to pass an expression template outside the scope of its constituents.
 
-[pre
-1
-2
-3
-4
-]
+In these cases, you want to deep-copy your expression template so that all intermediate nodes and the terminals are held /by value/. That way, you can safely assign the expression template to a local variable or return it from a function without worrying about dangling references. You can do this with _deep_copy_ as fo
+llows:
 
-[/========================================]
-[heading Flattening Proto Expression Tress]
-[/========================================]
+ // OK, "ex" has no dangling references
+ auto ex = proto::deep_copy( proto::lit(1) + 2 );
 
-Imagine a slight variation of the above example where, instead of iterating
-over the arguments of a lazy function invocation, we would like to iterate
-over the terminals in an addition expression:
+If you are using _typeof_, it would look like this:
 
- proto::terminal<int>::type const _1 = {1};
+ // OK, use BOOST_AUTO() and proto::deep_copy() to
+ // store an expression template in a local variable
+ BOOST_AUTO( ex, proto::deep_copy( proto::lit(1) + 2 ) );
 
- // ERROR: this doesn't work! Why?
- fusion::for_each(
- fusion::transform(
- _1 + 2 + 3 + 4
- , proto::functional::value()
- )
- , display()
- );
+For the above code to work, you must include the [headerref boost/proto/proto_typeof.hpp] header, which also defines the _AUTO_ macro which automatically deep-copies its argument. With _AUTO_, the above code can be writen as:
 
-The reason this doesn't work is because the expression `_1 + 2 + 3 + 4` does
-not describe a flat sequence of terminals --- it describes a binary tree. We
-can treat it as a flat sequence of terminals, however, using Proto's _flatten_
-function. _flatten_ returns a view which makes a tree appear as a flat Fusion
-sequence. If the top-most node has a tag type `T`, then the elements of the
-flattened sequence are the child nodes that do /not/ have tag type `T`. This
-process is evaluated recursively. So the above can correctly be written as:
+ // OK, BOOST_PROTO_AUTO() automatically deep-copies
+ // its argument:
+ BOOST_PROTO_AUTO( ex, proto::lit(1) + 2 );
 
- proto::terminal<int>::type const _1 = {1};
+When deep-copying an expression tree, all intermediate nodes and all terminals are stored by value. The only exception is terminals that are function references, which are left alone.
 
- // OK, iterate over a flattened view
- fusion::for_each(
- fusion::transform(
- proto::flatten(_1 + 2 + 3 + 4)
- , proto::functional::value()
- )
- , display()
+[note _deep_copy_ makes no exception for arrays, which it stores by value. That can potentially cause a large amount of data to be copied.]
+
+[endsect]
+
+[/============================]
+[section Debugging Expressions]
+[/============================]
+
+Proto provides a utility for pretty-printing expression trees that comes in very handy when you're trying to debug your DSEL. It's called _display_expr_, and you pass it the expression to print and optionally, an `std::ostream` to which to send the output. Consider:
+
+ // Use display_expr() to pretty-print an expression tree
+ proto::display_expr(
+ proto::lit("hello") + 42
     );
 
-The above invocation of `fusion::for_each()` displays the following:
+The above code writes this to `std::cout`:
 
-[pre
-1
-2
-3
-4
-]
+[pre plus(
+ terminal(hello)
+ , terminal(42)
+)]
+
+In order to call _display_expr_, all the terminals in the expression must be Streamable (that is, they can be written to a `std::ostream`). In addition, the tag types must all be Streamable as well. Here is an example that includes a custom terminal type and a custom tag:
+
+ // A custom tag type that is Streamable
+ struct MyTag
+ {
+ friend std::ostream &operator<<(std::ostream &s, MyTag)
+ {
+ return s << "MyTag";
+ }
+ };
+
+ // Some other Streamable type
+ struct MyTerminal
+ {
+ friend std::ostream &operator<<(std::ostream &s, MyTerminal)
+ {
+ return s << "MyTerminal";
+ }
+ };
+
+ int main()
+ {
+ // Display an expression tree that contains a custom
+ // tag and a user-defined type in a terminal
+ proto::display_expr(
+ proto::make_expr<MyTag>(MyTerminal()) + 42
+ );
+ }
+
+The above code prints the following:
+
+[pre plus(
+ MyTag(
+ terminal(MyTerminal)
+ )
+ , terminal(42)
+)]
 
 [endsect]
 
@@ -360,10 +380,7 @@
 [section:tags_and_metafunctions Operator Tags and Metafunctions]
 [/=============================================================]
 
-The following table lists the overloadable C++ operators, the Proto tag types for
-each, and the name of the metafunctions for generating the corresponding Proto
-expression types. And as we'll see later, the metafunctions are also usable as
-grammars for matching such nodes, as well as pass-through transforms.
+The following table lists the overloadable C++ operators, the Proto tag types for each, and the name of the metafunctions for generating the corresponding Proto expression types. And as we'll see later, the metafunctions are also usable as grammars for matching such nodes, as well as pass-through transforms.
 
 [table Operators, Tags and Metafunctions
     [[Operator]
@@ -549,39 +566,111 @@
 
 [endsect]
 
+[/======================================]
+[section Expressions as Fusion Sequences]
+[/======================================]
+
+Boost.Fusion is a library of iterators, algorithms, containers and adaptors for manipulating heterogeneous sequences. In essence, a Proto expression is just a heterogeneous sequence of its child expressions, and so Proto expressions are valid Fusion random-access sequences. That means you can apply Fusion algorithms to them, transform them, apply Fusion filters and views to them, and access their elements using `fusion::at()`. The things Fusion can do to heterogeneous sequences are beyond the scope of this users' guide, but below is a simple example. It takes a lazy function invocation like `fun(1,2,3,4)` and uses Fusion to print the function arguments in order.
+
+ struct display
+ {
+ template<typename T>
+ void operator()(T const &t) const
+ {
+ std::cout << t << std::endl;
+ }
+ };
+
+ struct fun_t {};
+ proto::terminal<fun_t>::type const fun = {{}};
+
+ // ...
+ fusion::for_each(
+ fusion::transform(
+ // pop_front() removes the "fun" child
+ fusion::pop_front(fun(1,2,3,4))
+ // Extract the ints from the terminal nodes
+ , proto::functional::value()
+ )
+ , display()
+ );
+
+Recall from the Introduction that types in the `proto::functional` namespace
+define function objects that correspond to Proto's free functions. So
+`proto::functional::value()` creates a function object that is equivalent to
+the `proto::value()` function. The above invocation of `fusion::for_each()`
+displays the following:
+
+[pre
+1
+2
+3
+4
+]
+
+Terminals are also valid Fusion sequences. They contain exactly one element: their value.
+
+[/========================================]
+[heading Flattening Proto Expression Tress]
+[/========================================]
+
+Imagine a slight variation of the above example where, instead of iterating over the arguments of a lazy function invocation, we would like to iterate over the terminals in an addition expression:
+
+ proto::terminal<int>::type const _1 = {1};
+
+ // ERROR: this doesn't work! Why?
+ fusion::for_each(
+ fusion::transform(
+ _1 + 2 + 3 + 4
+ , proto::functional::value()
+ )
+ , display()
+ );
+
+The reason this doesn't work is because the expression `_1 + 2 + 3 + 4` does not describe a flat sequence of terminals --- it describes a binary tree. We can treat it as a flat sequence of terminals, however, using Proto's _flatten_ function. _flatten_ returns a view which makes a tree appear as a flat Fusion sequence. If the top-most node has a tag type `T`, then the elements of the flattened sequence are the child nodes that do /not/ have tag type `T`. This process is evaluated recursively. So the above can correctly be written as:
+
+ proto::terminal<int>::type const _1 = {1};
+
+ // OK, iterate over a flattened view
+ fusion::for_each(
+ fusion::transform(
+ proto::flatten(_1 + 2 + 3 + 4)
+ , proto::functional::value()
+ )
+ , display()
+ );
+
+The above invocation of `fusion::for_each()` displays the following:
+
+[pre
+1
+2
+3
+4
+]
+
+[endsect]
+
 [/============================================================================]
 [section:expression_introspection Expression Introspection: Defining a Grammar]
 [/============================================================================]
 
-Expression trees can have a very rich and complicated structure. Often, you
-need to know some things about an expression's structure before you can process
-it. This section describes the tools Proto provides for peering inside an
-expression tree and discovering its structure. And as you'll see in later
-sections, all the really interesting things you can do with Proto begin right
-here.
+Expression trees can have a very rich and complicated structure. Often, you need to know some things about an expression's structure before you can process it. This section describes the tools Proto provides for peering inside an expression tree and discovering its structure. And as you'll see in later sections, all the really interesting things you can do with Proto begin right here.
 
 [/===============================================]
 [section:patterns Finding Patterns in Expressions]
 [/===============================================]
 
-Imagine your DSEL is a miniature I/O facility, with iostream operations
-that execute lazily. You might want expressions representing input operations
-to be processed by one function, and output operations to be processed by a
-different function. How would you do that?
-
-The answer is to write patterns (a.k.a, /grammars/) that match the structure
-of input and output expressions. Proto provides utilities for defining the
-grammars, and the _matches_ template for checking whether a given expression
-type matches the grammar.
+Imagine your DSEL is a miniature I/O facility, with iostream operations that execute lazily. You might want expressions representing input operations to be processed by one function, and output operations to be processed by a different function. How would you do that?
+
+The answer is to write patterns (a.k.a, /grammars/) that match the structure of input and output expressions. Proto provides utilities for defining the grammars, and the _matches_ template for checking whether a given expression type matches the grammar.
 
 First, let's define some terminals we can use in our lazy I/O expressions:
 
     proto::terminal< std::istream & >::type cin_ = { std::cin };
     proto::terminal< std::ostream & >::type cout_ = { std::cout };
 
-Now, we can use `cout_` instead of `std::cout`, and get I/O expression trees
-that we can execute later. To define grammars that match input and output
-expressions of the form `cin_ >> i` and `cout_ << 1` we do this:
+Now, we can use `cout_` instead of `std::cout`, and get I/O expression trees that we can execute later. To define grammars that match input and output expressions of the form `cin_ >> i` and `cout_ << 1` we do this:
 
     struct Input
       : proto::shift_right< proto::terminal< std::istream & >, proto::_ >
@@ -632,9 +721,7 @@
 Input!
 ]
 
-If we wanted to break the `input_output()` function into two functions, one
-that handles input expressions and one for output expressions, we can use
-`boost::enable_if<>`, as follows:
+If we wanted to break the `input_output()` function into two functions, one that handles input expressions and one for output expressions, we can use `boost::enable_if<>`, as follows:
 
     template< typename Expr >
     typename boost::enable_if< proto::matches< Expr, Input > >::type
@@ -650,21 +737,13 @@
         std::cout << "Output!\n";
     }
 
-This works as the previous version did. However, the following does not compile
-at all:
+This works as the previous version did. However, the following does not compile at all:
 
     input_output( cout_ << 1 << 2 ); // oops!
 
-What's wrong? The problem is that this expression does not match our grammar.
-The expression groups as if it were written like `(cout_ << 1) << 2`. It will
-not match the `Output` grammar, which expects the left operand to be a
-terminal, not another left-shift operation. We need to fix the grammar.
-
-We notice that in order to verify an expression as input or output, we'll need
-to recurse down to the bottom-left-most leaf and check that it is a
-`std::istream` or `std::ostream`. When we get to the terminal, we must stop
-recursing. We can express this in our grammar using _or_. Here are the correct
-`Input` and `Output` grammars:
+What's wrong? The problem is that this expression does not match our grammar. The expression groups as if it were written like `(cout_ << 1) << 2`. It will not match the `Output` grammar, which expects the left operand to be a terminal, not another left-shift operation. We need to fix the grammar.
+
+We notice that in order to verify an expression as input or output, we'll need to recurse down to the bottom-left-most leaf and check that it is a `std::istream` or `std::ostream`. When we get to the terminal, we must stop recursing. We can express this in our grammar using _or_. Here are the correct `Input` and `Output` grammars:
 
     struct Input
       : proto::or_<
@@ -680,23 +759,22 @@
>
     {};
 
-This may look a little odd at first. We seem to be defining the `Input` and
-`Output` types in terms of themselves. This is perfectly OK, actually. At
-the point in the grammar that the `Input` and `Output` types are being used,
-they are /incomplete/, but by the time we actually evaluate the grammar with
-_matches_, the types will be complete. These are recursive grammars, and
-rightly so because they must match a recursive data structure!
-
-When the `Output` grammar is evaluated against an expression like
-`cout_ << 1 << 2`, the first alternate of the _or_ is tried first. It will fail,
-because the expression `cout_ << 1 << 2` does not match the grammar
-`proto::shift_left< proto::terminal< std::ostream & >, proto::_ >`. Then the second
-alternate is tried. We match the expression against
-`proto::shift_left< Output, proto::_ >`. The expression is a left-shift, so we try
-the operands. The right operand `2` matches `proto::_` trivially. To see if the
-left operand `cout_ << 1` matches `Output`, we must recursively evaluate the
-`Output` grammar. This time we succeed, because `cout_ << 1` will match the first
-alternate of the _or_. We're done -- the grammar matches successfully.
+This may look a little odd at first. We seem to be defining the `Input` and `Output` types in terms of themselves. This is perfectly OK, actually. At the point in the grammar that the `Input` and `Output` types are being used, they are /incomplete/, but by the time we actually evaluate the grammar with _matches_, the types will be complete. These are recursive grammars, and rightly so because they must match a recursive data structure!
+
+Matching an expression such as `cout_ << 1 << 2` against the `Output` grammar procedes as follows:
+
+# The first alternate of the _or_ is tried first. It will fail, because the
+ expression `cout_ << 1 << 2` does not match the grammar `proto::shift_left<
+ proto::terminal< std::ostream & >, proto::_ >`.
+# Then the second alternate is tried next. We match the expression against
+ `proto::shift_left< Output, proto::_ >`. The expression is a left-shift, so we
+ next try to match the operands.
+# The right operand `2` matches `proto::_` trivially.
+# To see if the left operand `cout_ << 1` matches `Output`, we must recursively
+ evaluate the `Output` grammar. This time we succeed, because `cout_ << 1` will
+ match the first alternate of the _or_.
+
+We're done -- the grammar matches successfully.
 
 [endsect]
 
@@ -704,20 +782,11 @@
 [section Fuzzy and Exact Matches of Terminals]
 [/===========================================]
 
-The terminals in an expression tree could be const or non-const references, or
-they might not be references at all. When writing grammars, you usually don't
-have to worry about it because _matches_ gives you a little wiggle room when
-matching terminals. A grammar such as `proto::terminal<int>` will match a
-terminal of type `int`, `int &`, or `int const &`.
-
-You can explicitly specify that you want to match a reference type. If you do,
-the type must match exactly. For instance, a grammar such as
-`proto::terminal<int &>` will only match an `int &`. It will not match an `int`
-or an `int const &`.
-
-The table below shows how Proto matches terminals. The simple rule is: if you
-want to match only reference types, you must specify the reference in your
-grammar. Otherwise, leave it off and Proto will ignore const and references.
+The terminals in an expression tree could be const or non-const references, or they might not be references at all. When writing grammars, you usually don't have to worry about it because _matches_ gives you a little wiggle room when matching terminals. A grammar such as `proto::terminal<int>` will match a terminal of type `int`, `int &`, or `int const &`.
+
+You can explicitly specify that you want to match a reference type. If you do, the type must match exactly. For instance, a grammar such as `proto::terminal<int &>` will only match an `int &`. It will not match an `int` or an `int const &`.
+
+The table below shows how Proto matches terminals. The simple rule is: if you want to match only reference types, you must specify the reference in your grammar. Otherwise, leave it off and Proto will ignore const and references.
 
 [table proto::matches<> and Reference / CV-Qualification of Terminals
     [[Terminal] [Grammar] [Matches?]]
@@ -732,19 +801,9 @@
     [[T const &] [T const &] [yes]]
 ]
 
-This begs the question: What if you want to match an `int`, but not an `int &`
-or an `int const &`? For forcing exact matches, Proto provides the _exact_
-template. For instance, `proto::terminal< proto::exact<int> >` would only match an
-`int` held by value.
-
-Proto gives you extra wiggle room when matching array types. Array types match
-themselves or the pointer types they decay to. This is especially useful with
-character arrays. The type returned by `proto::as_expr("hello")` is
-`proto::terminal<char const[6]>::type`. That's a terminal containing a
-6-element character array. Naturally, you can match this terminal
-with the grammar `proto::terminal<char const[6]>`, but the grammar
-`proto::terminal<char const *>` will match it as well, as the following
-code fragment illustrates.
+This begs the question: What if you want to match an `int`, but not an `int &` or an `int const &`? For forcing exact matches, Proto provides the _exact_ template. For instance, `proto::terminal< proto::exact<int> >` would only match an `int` held by value.
+
+Proto gives you extra wiggle room when matching array types. Array types match themselves or the pointer types they decay to. This is especially useful with character arrays. The type returned by `proto::as_expr("hello")` is `proto::terminal<char const[6]>::type`. That's a terminal containing a 6-element character array. Naturally, you can match this terminal with the grammar `proto::terminal<char const[6]>`, but the grammar `proto::terminal<char const *>` will match it as well, as the following code fragment illustrates.
 
     struct CharString
       : proto::terminal< char const * >
@@ -754,9 +813,7 @@
 
     BOOST_MPL_ASSERT(( proto::matches< char_array, CharString > ));
 
-What if we only wanted `CharString` to match terminals of exactly the type
-`char const *`? You can use _exact_ here to turn off the fuzzy matching of
-terminals, as follows:
+What if we only wanted `CharString` to match terminals of exactly the type `char const *`? You can use _exact_ here to turn off the fuzzy matching of terminals, as follows:
 
     struct CharString
       : proto::terminal< proto::exact< char const * > >
@@ -770,33 +827,17 @@
 
 Now, `CharString` does not match array types, only character string pointers.
 
-The inverse problem is a little trickier: what if you wanted to match all
-character arrays, but not character pointers? As mentioned above, the
-expression `as_expr("hello")` has the type
-`proto::terminal< char const[ 6 ] >::type`. If you wanted to match character
-arrays of arbitrary size, you could use `proto::N`, which is an array-size
-wildcard. The following grammar would match any string literal:
-`proto::terminal< char const[ proto::N ] >`.
-
-Sometimes you need even more wiggle room when matching terminals. For
-example, maybe you're building a calculator DSEL and you want to allow any
-terminals that are convertible to `double`. For that, Proto provides the
-_convertible_to_ template. You can use it as:
-`proto::terminal< proto::convertible_to< double > >`.
-
-There is one more way you can perform a fuzzy match on terminals. Consider the
-problem of trying to match a `std::complex<>` terminal. You can easily match
-a `std::complex<float>` or a `std::complex<double>`, but how would you match
-any instantiation of `std::complex<>`? You can use `proto::_` here to solve
-this problem. Here is the grammar to match any `std::complex<>` instantiation:
+The inverse problem is a little trickier: what if you wanted to match all character arrays, but not character pointers? As mentioned above, the expression `as_expr("hello")` has the type `proto::terminal< char const[ 6 ] >::type`. If you wanted to match character arrays of arbitrary size, you could use `proto::N`, which is an array-size wildcard. The following grammar would match any string literal: `proto::terminal< char const[ proto::N ] >`.
+
+Sometimes you need even more wiggle room when matching terminals. For example, maybe you're building a calculator DSEL and you want to allow any terminals that are convertible to `double`. For that, Proto provides the _convertible_to_ template. You can use it as: `proto::terminal< proto::convertible_to< double > >`.
+
+There is one more way you can perform a fuzzy match on terminals. Consider the problem of trying to match a `std::complex<>` terminal. You can easily match a `std::complex<float>` or a `std::complex<double>`, but how would you match any instantiation of `std::complex<>`? You can use `proto::_` here to solve this problem. Here is the grammar to match any `std::complex<>` instantiation:
 
     struct StdComplex
       : proto::terminal< std::complex< proto::_ > >
     {};
 
-When given a grammar like this, Proto will deconstruct the grammar and the
-terminal it is being matched against and see if it can match all the
-constituents.
+When given a grammar like this, Proto will deconstruct the grammar and the terminal it is being matched against and see if it can match all the constituents.
 
 [endsect]
 
@@ -804,23 +845,13 @@
 [section:if_and_not [^if_<>], [^and_<>], and [^not_<>]]
 [/====================================================]
 
-We've already seen how to use expression generators like `proto::terminal<>` and
-`proto::shift_right<>` as grammars. We've also seen _or_, which we can use to
-express a set of alternate grammars. There are a few others of interest; in
-particular, _if_, _and_ and _not_.
-
-The _not_ template is the simplest. It takes a grammar as a template parameter
-and logically negates it; `not_<Grammar>` will match any expression that
-`Grammar` does /not/ match.
-
-The _if_ template is used together with a Proto transform that is evaluated
-against expression types to find matches. (Proto transforms will be described
-later.)
-
-The _and_ template is like _or_, except that each argument of the _and_ must
-match in order for the _and_ to match. As an example, consider the definition
-of `CharString` above that uses _exact_. It could have been written without
-_exact_ as follows:
+We've already seen how to use expression generators like `proto::terminal<>` and `proto::shift_right<>` as grammars. We've also seen _or_, which we can use to express a set of alternate grammars. There are a few others of interest; in particular, _if_, _and_ and _not_.
+
+The _not_ template is the simplest. It takes a grammar as a template parameter and logically negates it; `not_<Grammar>` will match any expression that `Grammar` does /not/ match.
+
+The _if_ template is used together with a Proto transform that is evaluated against expression types to find matches. (Proto transforms will be described later.)
+
+The _and_ template is like _or_, except that each argument of the _and_ must match in order for the _and_ to match. As an example, consider the definition of `CharString` above that uses _exact_. It could have been written without _exact_ as follows:
 
     struct CharString
       : proto::and_<
@@ -829,15 +860,9 @@
>
     {};
 
-This says that a `CharString` must be a terminal, /and/ its value type must be
-the same as `char const *`. Notice the template argument of _if_:
-`boost::is_same< proto::_value, char const * >()`. This is Proto transform that
-compares the value type of a terminal to `char const *`.
-
-The _if_ template has a couple of variants. In addition to `if_<Condition>` you
-can also say `if_<Condition, ThenGrammar>` and
-`if_<Condition, ThenGrammar, ElseGrammar>`. These let you select one sub-grammar
-or another based on the `Condition`.
+This says that a `CharString` must be a terminal, /and/ its value type must be the same as `char const *`. Notice the template argument of _if_: `boost::is_same< proto::_value, char const * >()`. This is Proto transform that compares the value type of a terminal to `char const *`.
+
+The _if_ template has a couple of variants. In addition to `if_<Condition>` you can also say `if_<Condition, ThenGrammar>` and `if_<Condition, ThenGrammar, ElseGrammar>`. These let you select one sub-grammar or another based on the `Condition`.
 
 [endsect]
 
@@ -995,18 +1020,9 @@
 [section Matching Vararg Expressions]
 [/==================================]
 
-Not all of C++'s overloadable operators are unary or binary. There is the
-oddball `operator()` -- the function call operator -- which can have any number
-of arguments. Likewise, with Proto you may define your own "operators" that
-could also take more that two arguments. As a result, there may be nodes in
-your Proto expression tree that have an arbitrary number of children (up to
-`BOOST_PROTO_MAX_ARITY`, which is configurable). How do you write a grammar to
-match such a node?
-
-For such cases, Proto provides the _vararg_ class template. Its template
-argument is a grammar, and the _vararg_ will match the grammar zero or more
-times. Consider a Proto lazy function called `fun()` that can take zero or
-more characters as arguments, as follows:
+Not all of C++'s overloadable operators are unary or binary. There is the oddball `operator()` -- the function call operator -- which can have any number of arguments. Likewise, with Proto you may define your own "operators" that could also take more that two arguments. As a result, there may be nodes in your Proto expression tree that have an arbitrary number of children (up to _MAX_ARITY_, which is configurable). How do you write a grammar to match such a node?
+
+For such cases, Proto provides the _vararg_ class template. Its template argument is a grammar, and the _vararg_ will match the grammar zero or more times. Consider a Proto lazy function called `fun()` that can take zero or more characters as arguments, as follows:
 
     struct fun_tag {};
     struct FunTag : proto::terminal< fun_tag > {};
@@ -1024,8 +1040,7 @@
       : proto::function< FunTag, proto::vararg< proto::terminal< char > > >
     {};
 
-The `FunCall` grammar uses _vararg_ to match zero or more character literals
-as arguments of the `fun()` function.
+The `FunCall` grammar uses _vararg_ to match zero or more character literals as arguments of the `fun()` function.
 
 As another example, can you guess what the following grammar matches?
 
@@ -1036,10 +1051,7 @@
>
     {};
 
-Here's a hint: the first template parameter to `proto::nary_expr<>` represents the
-node type, and any additional template parameters represent child nodes. The answer
-is that this is a degenerate grammar that matches every possible expression tree,
-from root to leaves.
+Here's a hint: the first template parameter to `proto::nary_expr<>` represents the node type, and any additional template parameters represent child nodes. The answer is that this is a degenerate grammar that matches every possible expression tree, from root to leaves.
 
 [endsect]
 
@@ -1047,9 +1059,7 @@
 [section Defining DSEL Grammars]
 [/=============================]
 
-In this section we'll see how to use Proto to define a grammar for your DSEL and
-use it to validate expression templates, giving short, readable compile-time errors
-for invalid expressions.
+In this section we'll see how to use Proto to define a grammar for your DSEL and use it to validate expression templates, giving short, readable compile-time errors for invalid expressions.
 
 [tip You might think that this is a backwards way of doing things. ["If Proto let
 me select which operators to overload, my users wouldn't be able to create invalid
@@ -1074,12 +1084,7 @@
 operators are overloaded within your domain. And to do it, you need to define a
 grammar!]
 
-In a previous section, we used Proto to define a DSEL for a lazily evaluated
-calculator that allowed any combination of placeholders, floating-point
-literals, addition, subtraction, multiplication, division and grouping. If
-we were to write the grammar for this DSEL in
-[@http://en.wikipedia.org/wiki/Extended_Backus_Naur_Form EBNF], it might look
-like this:
+In a previous section, we used Proto to define a DSEL for a lazily evaluated calculator that allowed any combination of placeholders, floating-point literals, addition, subtraction, multiplication, division and grouping. If we were to write the grammar for this DSEL in [@http://en.wikipedia.org/wiki/Extended_Backus_Naur_Form EBNF], it might look like this:
 
 [pre
 group ::= '(' expression ')'

Modified: branches/release/libs/proto/doc/proto.qbk
==============================================================================
--- branches/release/libs/proto/doc/proto.qbk (original)
+++ branches/release/libs/proto/doc/proto.qbk 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -61,6 +61,8 @@
   [funcref boost::proto::make_expr `proto::make_expr()`]]
 [def _unpack_expr_
   [funcref boost::proto::unpack_expr `proto::unpack_expr()`]]
+[def _display_expr_
+ [funcref boost::proto::display_expr `proto::display_expr()`]]
 [def _matches_
   [classref boost::proto::matches `proto::matches<>`]]
 [def _or_
@@ -81,6 +83,8 @@
   [classref boost::proto::is_expr `proto::is_expr<>`]]
 [def _tag_of_
   [classref boost::proto::tag_of `proto::tag_of<>`]]
+[def _arity_of_
+ [classref boost::proto::arity_of `proto::arity_of<>`]]
 [def _child_
   [funcref boost::proto::child `proto::child()`]]
 [def _child_c_
@@ -161,6 +165,36 @@
   [classref boost::proto::lazy `proto::lazy<>`]]
 [def _SYB_
   [link boost_proto.users_guide.resources.SYB ["Scrap Your Boilerplate]]]
+[def _result_of_value_
+ [classref boost::proto::result_of::value `proto::result_of::value<>`]]
+[def _result_of_child_c_
+ [classref boost::proto::result_of::child_c `proto::result_of::child_c<>`]]
+[def _result_of_child_
+ [classref boost::proto::result_of::child `proto::result_of::child<>`]]
+[def _result_of_left_
+ [classref boost::proto::result_of::left `proto::result_of::left<>`]]
+[def _result_of_right_
+ [classref boost::proto::result_of::right `proto::result_of::right<>`]]
+[def _MAX_ARITY_
+ [^[macroref BOOST_PROTO_MAX_ARITY]]]
+[def _MAX_LOGICAL_ARITY_
+ [^[macroref BOOST_PROTO_MAX_LOGICAL_ARITY]]]
+[def _MAX_FUNCTION_CALL_ARITY_
+ [^[macroref BOOST_PROTO_MAX_FUNCTION_CALL_ARITY]]]
+[def _BASIC_EXTENDS_
+ [^[macroref BOOST_PROTO_BASIC_EXTENDS]()]]
+[def _EXTENDS_
+ [^[macroref BOOST_PROTO_EXTENDS]()]]
+[def _EXTENDS_ASSIGN_
+ [^[macroref BOOST_PROTO_EXTENDS_ASSIGN]()]]
+[def _EXTENDS_SUBSCRIPT_
+ [^[macroref BOOST_PROTO_EXTENDS_SUBSCRIPT]()]]
+[def _EXTENDS_FUNCTION_
+ [^[macroref BOOST_PROTO_EXTENDS_FUNCTION]()]]
+[def _DEFINE_OPERATORS_
+ [^[macroref BOOST_PROTO_DEFINE_OPERATORS]()]]
+[def _AUTO_
+ [^[macroref BOOST_PROTO_AUTO]()]]
 
 [include preface.qbk]
 

Modified: branches/release/libs/proto/doc/reference.xml
==============================================================================
--- branches/release/libs/proto/doc/reference.xml (original)
+++ branches/release/libs/proto/doc/reference.xml 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -1011,6 +1011,7 @@
   <xi:include href="reference/operators.xml"/>
   <xi:include href="reference/proto.xml"/>
   <xi:include href="reference/proto_fwd.xml"/>
+ <xi:include href="reference/proto_typeof.xml"/>
   <xi:include href="reference/tags.xml"/>
   <xi:include href="reference/traits.xml"/>
   <xi:include href="reference/transform/arg.xml"/>

Modified: branches/release/libs/proto/doc/reference/extends.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/extends.xml (original)
+++ branches/release/libs/proto/doc/reference/extends.xml 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -284,9 +284,7 @@
   </namespace>
 
   <macro name="BOOST_PROTO_BASIC_EXTENDS" kind="functionlike">
- <macro-parameter name="Expr">
- <purpose>Expr purpose</purpose>
- </macro-parameter>
+ <macro-parameter name="Expr"/>
     <macro-parameter name="Derived"/>
     <macro-parameter name="Domain"/>
     <purpose>For creating expression wrappers that add members to a Proto expression template, like

Modified: branches/release/libs/proto/doc/reference/traits.xml
==============================================================================
--- branches/release/libs/proto/doc/reference/traits.xml (original)
+++ branches/release/libs/proto/doc/reference/traits.xml 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -2104,7 +2104,7 @@
           <typedef name="value_type">
             <description>
               <para>
- The raw type of the <replaceable>N</replaceable><superscript>th</superscript> child as it is
+ The raw type of the value as it is
                 stored within <computeroutput>Expr</computeroutput>. This may be a value or a reference.
               </para>
             </description>
@@ -2118,17 +2118,17 @@
                 <itemizedlist>
                   <listitem>
                     <para>
- <computeroutput>T const(&amp;)[N]</computeroutput> becomes <computeroutput>T const(&amp;)[N]</computeroutput>
+ <computeroutput>T const(&amp;)[N]</computeroutput> becomes <computeroutput>T[N]</computeroutput>
                     </para>
                   </listitem>
                   <listitem>
                     <para>
- <computeroutput>T[N]</computeroutput> becomes <computeroutput>T(&amp;)[N]</computeroutput>
+ <computeroutput>T[N]</computeroutput> becomes <computeroutput>T[N]</computeroutput>
                     </para>
                   </listitem>
                   <listitem>
                     <para>
- <computeroutput>T(&amp;)[N]</computeroutput> becomes <computeroutput>T(&amp;)[N]</computeroutput>
+ <computeroutput>T(&amp;)[N]</computeroutput> becomes <computeroutput>T[N]</computeroutput>
                     </para>
                   </listitem>
                   <listitem>

Modified: branches/release/libs/proto/example/mixed.cpp
==============================================================================
--- branches/release/libs/proto/example/mixed.cpp (original)
+++ branches/release/libs/proto/example/mixed.cpp 2008-11-16 02:47:47 EST (Sun, 16 Nov 2008)
@@ -158,8 +158,8 @@
     template<int D> struct case_< proto::tag::bitwise_xor_assign, D > : _ {};
 };
 
-// A vector grammar is a terminal or some op that is not an
-// assignment op. (Assignment will be handled specially.)
+// An expression conforms to the MixedGrammar if it is a terminal or some
+// op that is not an assignment op. (Assignment will be handled specially.)
 struct MixedGrammar
   : proto::or_<
         proto::terminal<_>
@@ -170,8 +170,8 @@
>
 {};
 
-// Expressions in the vector domain will be wrapped in VectorExpr<>
-// and must conform to the VectorGrammar
+// Expressions in the MixedDomain will be wrapped in MixedExpr<>
+// and must conform to the MixedGrammar
 struct MixedDomain
   : proto::domain<proto::generator<MixedExpr>, MixedGrammar>
 {};


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