$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
From: eric_at_[hidden]
Date: 2007-11-15 21:06:49
Author: eric_niebler
Date: 2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
New Revision: 41133
URL: http://svn.boost.org/trac/boost/changeset/41133
Log:
flatten, pop_front and reverse transforms
Text files modified: 
   branches/proto/v3/boost/xpressive/proto3/fusion.hpp       |    83 ++++++++++++++++++++++++++++++++++++++- 
   branches/proto/v3/boost/xpressive/proto3/proto_fwd.hpp    |     8 +++                                     
   branches/proto/v3/libs/xpressive/proto3/example/mixed.cpp |    27 -------------                           
   branches/proto/v3/libs/xpressive/proto3/test/examples.cpp |    19 --------                                
   branches/proto/v3/libs/xpressive/proto3/test/main.cpp     |    34 ----------------                        
   5 files changed, 88 insertions(+), 83 deletions(-)
Modified: branches/proto/v3/boost/xpressive/proto3/fusion.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto3/fusion.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto3/fusion.hpp	2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
@@ -17,6 +17,8 @@
 #include <boost/fusion/include/iterator_base.hpp>
 //#include <boost/fusion/include/mpl.hpp>
 #include <boost/fusion/include/intrinsic.hpp>
+#include <boost/fusion/include/pop_front.hpp>
+#include <boost/fusion/include/reverse.hpp>
 #include <boost/fusion/include/single_view.hpp>
 #include <boost/fusion/include/transform_view.hpp>
 #include <boost/fusion/support/ext_/is_segmented.hpp>
@@ -73,12 +75,85 @@
 
         Expr &expr_;
     };
-
-    template<typename Expr>
-    flat_view<Expr const> flatten(Expr const &expr)
+    
+    namespace functional
     {
-        return flat_view<Expr const>(expr);
+        struct flatten
+        {
+            template<typename Sig>
+            struct result;
+
+            template<typename This, typename Expr>
+            struct result<This(Expr)>
+            {
+                typedef flat_view<UNREF(Expr) const> type;
+            };
+
+            template<typename Expr>
+            flat_view<Expr const> operator()(Expr const &expr) const
+            {
+                return flat_view<Expr const>(expr);
+            }
+        };
+
+        struct pop_front
+        {
+            template<typename Sig>
+            struct result;
+
+            template<typename This, typename Expr>
+            struct result<This(Expr)>
+              : fusion::result_of::pop_front<UNREF(Expr) const>
+            {};
+
+            template<typename Expr>
+            typename fusion::result_of::pop_front<Expr const>::type
+            operator()(Expr const &expr) const
+            {
+                return fusion::pop_front(expr);
+            }
+        };
+
+        struct reverse
+        {
+            template<typename Sig>
+            struct result;
+
+            template<typename This, typename Expr>
+            struct result<This(Expr)>
+              : fusion::result_of::reverse<Expr const>
+            {};
+
+            template<typename Expr>
+            typename fusion::result_of::reverse<Expr const>::type
+            operator()(Expr const &expr) const
+            {
+                return fusion::reverse(expr);
+            }
+        };
+
     }
+
+    template<>
+    struct transform_category<functional::flatten>
+    {
+        typedef function_transform type;
+    };
+
+    template<>
+    struct transform_category<functional::pop_front>
+    {
+        typedef function_transform type;
+    };
+
+    template<>
+    struct transform_category<functional::reverse>
+    {
+        typedef function_transform type;
+    };
+
+    functional::flatten const flatten = {};
+
 }}
 
 namespace boost { namespace fusion
Modified: branches/proto/v3/boost/xpressive/proto3/proto_fwd.hpp
==============================================================================
--- branches/proto/v3/boost/xpressive/proto3/proto_fwd.hpp	(original)
+++ branches/proto/v3/boost/xpressive/proto3/proto_fwd.hpp	2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
@@ -444,8 +444,16 @@
 
         template<typename Tag, typename Domain = deduce_domain>
         struct unfused_expr;
+
+        struct flatten;
+        struct pop_front;
+        struct reverse;
     }
 
+    typedef functional::flatten _flatten;
+    typedef functional::pop_front _pop_front;
+    typedef functional::pop_front _reverse;
+
     template<typename T>
     struct is_extension;
 
Modified: branches/proto/v3/libs/xpressive/proto3/example/mixed.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto3/example/mixed.cpp	(original)
+++ branches/proto/v3/libs/xpressive/proto3/example/mixed.cpp	2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
@@ -39,33 +39,6 @@
     Iter it;
 };
 
-//template<typename Cont>
-//iterator_wrapper<typename Cont::const_iterator> cbegin(Cont const &cont)
-//{
-//    return iterator_wrapper<typename Cont::const_iterator>(cont.begin());
-//}
-//
-//template<typename Grammar>
-//struct begin
-//  : Grammar
-//{
-//    template<typename Expr, typename State, typename Visitor>
-//    struct apply
-//      : proto::terminal<
-//            iterator_wrapper<
-//                typename proto::result_of::arg<Expr>::type::const_iterator
-//            >
-//        >
-//    {};
-//
-//    template<typename Expr, typename State, typename Visitor>
-//    static typename apply<Expr, State, Visitor>::type
-//    call(Expr const &expr, State const &state, Visitor &visitor)
-//    {
-//        return proto::as_expr(cbegin(proto::arg(expr)));
-//    }
-//};
-
 struct begin : proto::function_transform
 {
     template<class Sig> struct result;
Modified: branches/proto/v3/libs/xpressive/proto3/test/examples.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto3/test/examples.cpp	(original)
+++ branches/proto/v3/libs/xpressive/proto3/test/examples.cpp	2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
@@ -159,23 +159,6 @@
 {};
 //]
 
-struct pop_front : function_transform
-{
-    template<typename Sig> struct result;
-
-    template<typename This, typename T>
-    struct result<This(T)>
-      : fusion::result_of::pop_front<T const>
-    {};
-
-    template<typename T>
-    typename fusion::result_of::pop_front<T const>::type
-    operator()(T const &t) const
-    {
-        return fusion::pop_front(t);
-    }
-};
-
 //[ AsArgList
 // This transform matches function invocations such as foo(1,'a',"b")
 // and transforms them into Fusion cons lists of their arguments. In this
@@ -190,7 +173,7 @@
             /*<< The first child expression of a `function<>` node is the
             function being invoked. We don't want that in our list, so use
             the `pop_front()` to remove it. >>*/
-            pop_front(_)    // make (_) optional
+            _pop_front(_)    // make (_) optional
           /*<< `nil` is the initial state used by the `reverse_fold<>`
           transform. >>*/
           , fusion::nil()
Modified: branches/proto/v3/libs/xpressive/proto3/test/main.cpp
==============================================================================
--- branches/proto/v3/libs/xpressive/proto3/test/main.cpp	(original)
+++ branches/proto/v3/libs/xpressive/proto3/test/main.cpp	2007-11-15 21:06:48 EST (Thu, 15 Nov 2007)
@@ -65,40 +65,6 @@
     }
 };
 
-struct pop_front : function_transform
-{
-    template<typename Sig> struct result;
-
-    template<typename This, typename T>
-    struct result<This(T)>
-      : fusion::result_of::pop_front<T const>
-    {};
-
-    template<typename T>
-    typename fusion::result_of::pop_front<T const>::type
-    operator()(T const &t) const
-    {
-        return fusion::pop_front(t);
-    }
-};
-
-//struct reverse : function_transform
-//{
-//    template<typename Sig> struct result;
-//
-//    template<typename This, typename T>
-//    struct result<This(T)>
-//      : fusion::result_of::reverse<T const>
-//    {};
-//
-//    template<typename T>
-//    typename fusion::result_of::reverse<T const>::type
-//    operator()(T const &t) const
-//    {
-//        return fusion::reverse(t);
-//    }
-//};
-
 //struct make_cons : function_transform
 //{
 //    template<typename Sig> struct result;