Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61782 - in trunk: boost/proto/transform libs/proto/doc/reference/transform
From: eric_at_[hidden]
Date: 2010-05-04 20:19:24


Author: eric_niebler
Date: 2010-05-04 20:19:22 EDT (Tue, 04 May 2010)
New Revision: 61782
URL: http://svn.boost.org/trac/boost/changeset/61782

Log:
pass_through transform doesn't strip expression wrappers, fixes #4175
Text files modified:
   trunk/boost/proto/transform/pass_through.hpp | 25 ++++++++++++++++---------
   trunk/libs/proto/doc/reference/transform/pass_through.xml | 14 +++++++++++---
   2 files changed, 27 insertions(+), 12 deletions(-)

Modified: trunk/boost/proto/transform/pass_through.hpp
==============================================================================
--- trunk/boost/proto/transform/pass_through.hpp (original)
+++ trunk/boost/proto/transform/pass_through.hpp 2010-05-04 20:19:22 EDT (Tue, 04 May 2010)
@@ -41,7 +41,8 @@
                     typename result_of::child_c<Expr, N>::type \
                   , State \
                   , Data \
- >::result_type
+ >::result_type \
+ /**/
 
             #define BOOST_PROTO_DEFINE_TRANSFORM(Z, N, DATA) \
                 typename Grammar::BOOST_PP_CAT(proto_child, N)::template impl< \
@@ -49,8 +50,9 @@
                   , State \
                   , Data \
>()( \
- e.proto_base().BOOST_PP_CAT(child, N), s, d \
- )
+ proto::child_c<N>(e), s, d \
+ ) \
+ /**/
 
             #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/transform/pass_through.hpp>))
             #include BOOST_PP_ITERATE()
@@ -70,7 +72,7 @@
                 #ifndef BOOST_NO_DECLTYPE
                 result_type
                 #else
- typename pass_through_impl::expr_param
+ typename pass_through_impl::expr_param
                 #endif
                 operator()(
                     typename pass_through_impl::expr_param e
@@ -163,21 +165,26 @@
             struct pass_through_impl<Grammar, Expr, State, Data, N>
               : transform_impl<Expr, State, Data>
             {
+ typedef typename pass_through_impl::expr unref_expr;
+
                 typedef proto::expr<
- typename remove_reference<Expr>::type::proto_tag
+ typename unref_expr::proto_tag
                   , BOOST_PP_CAT(list, N)<
                         BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM_TYPE, ~)
>
                   , N
- > result_type;
+ > expr_type;
+
+ typedef typename unref_expr::proto_domain proto_domain;
+ typedef typename boost::result_of<proto_domain(expr_type)>::type result_type;
 
- result_type operator ()(
+ result_type const operator ()(
                     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 = {
+ expr_type const that = {
                         BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM, ~)
                     };
                     #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
@@ -186,7 +193,7 @@
                     // built with VC8.
                     &that;
                     #endif
- return that;
+ return proto_domain()(that);
                 }
             };
 

Modified: trunk/libs/proto/doc/reference/transform/pass_through.xml
==============================================================================
--- trunk/libs/proto/doc/reference/transform/pass_through.xml (original)
+++ trunk/libs/proto/doc/reference/transform/pass_through.xml 2010-05-04 20:19:22 EDT (Tue, 04 May 2010)
@@ -100,9 +100,17 @@
             <purpose>For exposition only</purpose>
             <type>typename Expr::proto_tag</type>
           </typedef>
- <typedef name="result_type">
+ <typedef name="D">
+ <purpose>For exposition only</purpose>
+ <type>typename Expr::proto_domain</type>
+ </typedef>
+ <typedef name="expr_type">
+ <purpose>For exposition only</purpose>
             <type><classname>proto::expr</classname>&lt;T, <classname>proto::listN</classname>&lt;R0,...RN&gt; &gt;</type>
           </typedef>
+ <typedef name="result_type">
+ <type>typename boost::result_of&lt;D(expr_type)&gt;::type</type>
+ </typedef>
           <method-group name="public member functions">
             <method name="operator()" cv="const">
               <type>result_type</type>
@@ -124,11 +132,11 @@
               </requires>
               <returns>
                 <para>
- <programlisting>result_type::make(
+ <programlisting>D()(expr_type::make(
   G0()(<functionname>proto::child_c</functionname>&lt;0&gt;(expr), state, data),
   ...
   GN()(<functionname>proto::child_c</functionname>&lt;N&gt;(expr), state, data)
-)</programlisting>
+))</programlisting>
                 </para>
               </returns>
             </method>


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