$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: eric_at_[hidden]
Date: 2008-05-27 16:01:47
Author: eric_niebler
Date: 2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
New Revision: 45831
URL: http://svn.boost.org/trac/boost/changeset/45831
Log:
add proto::protect<> to prevent a nested transform from being applied
Text files modified: 
   branches/proto/v4/boost/proto/detail/decltype.hpp   |     2                                         
   branches/proto/v4/boost/proto/fusion.hpp            |     2                                         
   branches/proto/v4/boost/proto/make_expr.hpp         |     2                                         
   branches/proto/v4/boost/proto/proto_fwd.hpp         |     3 ++                                      
   branches/proto/v4/boost/proto/transform/default.hpp |     4 +-                                      
   branches/proto/v4/boost/proto/transform/make.hpp    |    56 ++++++++++++++++++++++++++++++++++++++++
   6 files changed, 64 insertions(+), 5 deletions(-)
Modified: branches/proto/v4/boost/proto/detail/decltype.hpp
==============================================================================
--- branches/proto/v4/boost/proto/detail/decltype.hpp	(original)
+++ branches/proto/v4/boost/proto/detail/decltype.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -225,7 +225,7 @@
 
         private:
             T obj;
-            PMF pmf;            
+            PMF pmf;
         };
 
     } // namespace detail
Modified: branches/proto/v4/boost/proto/fusion.hpp
==============================================================================
--- branches/proto/v4/boost/proto/fusion.hpp	(original)
+++ branches/proto/v4/boost/proto/fusion.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -117,7 +117,7 @@
             }
         };
     }
-    
+
     namespace result_of
     {
         template<typename Expr>
Modified: branches/proto/v4/boost/proto/make_expr.hpp
==============================================================================
--- branches/proto/v4/boost/proto/make_expr.hpp	(original)
+++ branches/proto/v4/boost/proto/make_expr.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -1013,7 +1013,7 @@
     #ifdef _MSC_VER
     # pragma warning(pop)
     #endif
-    
+
     #undef BOOST_PROTO_AT
     #undef BOOST_PROTO_AT_TYPE
     #undef BOOST_PROTO_AS_CHILD_AT
Modified: branches/proto/v4/boost/proto/proto_fwd.hpp
==============================================================================
--- branches/proto/v4/boost/proto/proto_fwd.hpp	(original)
+++ branches/proto/v4/boost/proto/proto_fwd.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -729,6 +729,9 @@
     template<typename Fun>
     struct make;
 
+    template<typename PrimitiveTransform>
+    struct protect;
+
     template<typename Fun>
     struct lazy;
 
Modified: branches/proto/v4/boost/proto/transform/default.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/default.hpp	(original)
+++ branches/proto/v4/boost/proto/transform/default.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -135,7 +135,7 @@
 
             #undef BOOST_PROTO_UNARY_OP_RESULT
             #undef BOOST_PROTO_BINARY_OP_RESULT
-            
+
             /// INTERNAL ONLY
             template<typename Expr, typename State, typename Data>
             struct is_member_function_invocation
@@ -330,7 +330,7 @@
                          , t1(proto::child_c<1>(expr), state, data);
                 }
             };
-            
+
             #define EVAL_TYPE(Z, N, DATA)                                                           \
                 typedef                                                                             \
                     typename result_of::child_c<DATA, N>::type                                      \
Modified: branches/proto/v4/boost/proto/transform/make.hpp
==============================================================================
--- branches/proto/v4/boost/proto/transform/make.hpp	(original)
+++ branches/proto/v4/boost/proto/transform/make.hpp	2008-05-27 16:01:46 EDT (Tue, 27 May 2008)
@@ -152,6 +152,56 @@
             #undef TMP
         }
 
+        /// \brief A PrimitiveTransform which prevents another PrimitiveTransform
+        /// from being applied in an \c ObjectTransform.
+        ///
+        /// When building higher order transforms with <tt>make\<\></tt> or
+        /// <tt>lazy\<\></tt>, you sometimes would like to build types that
+        /// are parameterized with Proto transforms. In such lambda-style
+        /// transforms, Proto will unhelpfully find all nested transforms
+        /// and apply them, even if you don't want them to be applied. Consider
+        /// the following transform, which will replace the \c _ in
+        /// <tt>Bar<_>()</tt> with <tt>proto::terminal\<int\>::type</tt>:
+        ///
+        /// \code
+        /// template<typename T>
+        /// struct Bar
+        /// {};
+        /// 
+        /// struct Foo
+        ///   : proto::when<_, Bar<_>() >
+        /// {};
+        /// 
+        /// proto::terminal<int>::type i = {0};
+        /// 
+        /// int main()
+        /// {
+        ///     Foo()(i);
+        ///     std::cout << typeid(Foo()(i)).name() << std::endl;
+        /// }
+        /// \endcode
+        ///
+        /// If you actually wanted to default-construct an object of type
+        /// <tt>Bar\<_\></tt>, you would have to protect the \c _ to prevent
+        /// it from being applied. You can use <tt>proto::protect\<\></tt>
+        /// as follows:
+        ///
+        /// \code
+        /// // OK: replace anything with Bar<_>()
+        /// struct Foo
+        ///   : proto::when<_, Bar<_>() >
+        /// {};
+        /// \endcode
+        template<typename PrimitiveTransform>
+        struct protect : transform<protect<PrimitiveTransform> >
+        {
+            template<typename, typename, typename>
+            struct impl
+            {
+                typedef PrimitiveTransform result_type;
+            };
+        };
+
         /// \brief A PrimitiveTransform which computes a type by evaluating any
         /// nested transforms and then constructs an object of that type.
         ///
@@ -212,6 +262,12 @@
           : mpl::true_
         {};
 
+        /// INTERNAL ONLY
+        ///
+        template<typename PrimitiveTransform>
+        struct is_callable<protect<PrimitiveTransform> >
+          : mpl::true_
+        {};
     }}
 
     #endif