Update of /cvsroot/boost/boost/boost/xpressive/proto/transform
In directory 
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5021/boost/xpressive/proto/transform

Modified Files:
        arg.hpp 
Added Files:
        apply.hpp 
Log Message:
move applyN and always transforms into the apply.hpp header

--- NEW FILE: apply.hpp ---
///////////////////////////////////////////////////////////////////////////////
/// \file apply.hpp
/// Proto transforms for applying MPL placeholder expressions.
//
//  Copyright 2004 Eric Niebler. Distributed under the Boost
//  Software License, Version 1.0. (See accompanying file
//  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef BOOST_PROTO_TRANSFORM_APPLY_HPP_EAN_06_23_2007
#define BOOST_PROTO_TRANSFORM_APPLY_HPP_EAN_06_23_2007

#include <boost/xpressive/proto/detail/prefix.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/xpressive/proto/detail/suffix.hpp>

namespace boost { namespace proto { namespace transform
{
    namespace detail
    {
        struct any
        {
            template<typename T>
            any(T const &)
            {}
        };

        struct default_factory
        {
            default_factory()
            {}

            default_factory const &operator()() const
            {
                return *this;
            }

            default_factory const &operator()(any) const
            {
                return *this;
            }

            default_factory const &operator()(any, any) const
            {
                return *this;
            }

            default_factory const &operator()(any, any, any) const
            {
                return *this;
            }

            template<typename T>
            operator T() const
            {
                return T();
            }
        };
    }
    
    // Always return the specified type/object
    template<typename Grammar, typename Always, typename Factory>
    struct always
      : Grammar
    {
        always() {}

        template<typename, typename, typename>
        struct apply
        {
            typedef Always type;
        };

        template<typename Expr, typename State, typename Visitor>
        static Always
        call(Expr const &, State const &, Visitor &)
        {
            return Factory()();
        }
    };

    // Apply an MPL lambda, passing just Expr
    template<typename Grammar, typename Lambda, typename Factory>
    struct apply1
      : Grammar
    {
        apply1() {}

        template<typename Expr, typename State, typename Visitor>
        struct apply
          : mpl::apply1<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type>
        {};

        template<typename Expr, typename State, typename Visitor>
        static typename apply<Expr, State, Visitor>::type
        call(Expr const &expr, State const &state, Visitor &visitor)
        {
            return Factory()(Grammar::call(expr, state, visitor));
        }
    };

    // Apply an MPL lambda, passing Expr and State
    template<typename Grammar, typename Lambda, typename Factory>
    struct apply2
      : Grammar
    {
        apply2() {}

        template<typename Expr, typename State, typename Visitor>
        struct apply
          : mpl::apply2<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type, State>
        {};

        template<typename Expr, typename State, typename Visitor>
        static typename apply<Expr, State, Visitor>::type
        call(Expr const &expr, State const &state, Visitor &visitor)
        {
            return Factory()(Grammar::call(expr, state, visitor), state);
        }
    };

    // Apply an MPL lambda, passing Expr, State and Visitor
    template<typename Grammar, typename Lambda, typename Factory>
    struct apply3
      : Grammar
    {
        apply3() {}

        template<typename Expr, typename State, typename Visitor>
        struct apply
          : mpl::apply3<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type, State, Visitor>
        {};

        template<typename Expr, typename State, typename Visitor>
        static typename apply<Expr, State, Visitor>::type
        call(Expr const &expr, State const &state, Visitor &visitor)
        {
            return Factory()(Grammar::call(expr, state, visitor), state, 
visitor);
        }
    };

}}}

#endif

Index: arg.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/transform/arg.hpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- arg.hpp     14 Jun 2007 06:03:30 -0000      1.16
+++ arg.hpp     23 Jun 2007 17:12:49 -0000      1.17
@@ -10,55 +10,12 @@
 #define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_12_16_2006
 
 #include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/mpl/apply.hpp>
 #include <boost/xpressive/proto/proto_fwd.hpp>
 #include <boost/xpressive/proto/traits.hpp>
 #include <boost/xpressive/proto/detail/suffix.hpp>
 
 namespace boost { namespace proto { namespace transform
 {
-    namespace detail
-    {
-        struct any
-        {
-            template<typename T>
-            any(T const &)
-            {}
-        };
-
-        struct default_factory
-        {
-            default_factory()
-            {}
-
-            default_factory const &operator()() const
-            {
-                return *this;
-            }
-
-            default_factory const &operator()(any) const
-            {
-                return *this;
-            }
-
-            default_factory const &operator()(any, any) const
-            {
-                return *this;
-            }
-
-            default_factory const &operator()(any, any, any) const
-            {
-                return *this;
-            }
-
-            template<typename T>
-            operator T() const
-            {
-                return T();
-            }
-        };
-    }
-    
     // A transform that simply extracts the arg from an expression
     template<typename Grammar, typename N>
     struct arg
@@ -75,7 +32,7 @@
         static typename apply<Expr, State, Visitor>::type //reference
         call(Expr const &expr, State const &state, Visitor &visitor)
         {
-            // BUGBUG Grammar::call could return a temporary!
+            // NOTE Grammar::call could return a temporary!
             // Don't return a dangling reference
             return proto::arg<N>(Grammar::call(expr, state, visitor));
         }
@@ -141,6 +98,15 @@
         }
     };
 
+    // Just return the passed in Expr
+    template<typename Grammar>
+    struct identity
+      : Grammar
+    {
+        identity() {}
+        BOOST_PROTO_IDENTITY_TRANSFORM();
+    };
+
     // Just return the state
     template<typename Grammar>
     struct state
@@ -183,96 +149,6 @@
         }
     };
 
-    // Always return the specified type/object
-    template<typename Grammar, typename Always, typename Factory>
-    struct always
-      : Grammar
-    {
-        always() {}
-
-        template<typename, typename, typename>
-        struct apply
-        {
-            typedef Always type;
-        };
-
-        template<typename Expr, typename State, typename Visitor>
-        static Always
-        call(Expr const &, State const &, Visitor &)
-        {
-            return Factory()();
-        }
-    };
-
-    // Just return the passed in Expr
-    template<typename Grammar>
-    struct identity
-      : Grammar
-    {
-        identity() {}
-        BOOST_PROTO_IDENTITY_TRANSFORM();
-    };
-
-    // Apply an MPL lambda, passing just Expr
-    template<typename Grammar, typename Lambda, typename Factory>
-    struct apply1
-      : Grammar
-    {
-        apply1() {}
-
-        template<typename Expr, typename State, typename Visitor>
-        struct apply
-          : mpl::apply1<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type>
-        {};
-
-        template<typename Expr, typename State, typename Visitor>
-        static typename apply<Expr, State, Visitor>::type
-        call(Expr const &expr, State const &state, Visitor &visitor)
-        {
-            return Factory()(Grammar::call(expr, state, visitor));
-        }
-    };
-
-    // Apply an MPL lambda, passing Expr and State
-    template<typename Grammar, typename Lambda, typename Factory>
-    struct apply2
-      : Grammar
-    {
-        apply2() {}
-
-        template<typename Expr, typename State, typename Visitor>
-        struct apply
-          : mpl::apply2<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type, State>
-        {};
-
-        template<typename Expr, typename State, typename Visitor>
-        static typename apply<Expr, State, Visitor>::type
-        call(Expr const &expr, State const &state, Visitor &visitor)
-        {
-            return Factory()(Grammar::call(expr, state, visitor), state);
-        }
-    };
-
-    // Apply an MPL lambda, passing Expr, State and Visitor
-    template<typename Grammar, typename Lambda, typename Factory>
-    struct apply3
-      : Grammar
-    {
-        apply3() {}
-
-        template<typename Expr, typename State, typename Visitor>
-        struct apply
-          : mpl::apply3<Lambda, typename Grammar::template apply<Expr, State, 
Visitor>::type, State, Visitor>
-        {};
-
-        template<typename Expr, typename State, typename Visitor>
-        static typename apply<Expr, State, Visitor>::type
-        call(Expr const &expr, State const &state, Visitor &visitor)
-        {
-            return Factory()(Grammar::call(expr, state, visitor), state, 
visitor);
-        }
-    };
-
 }}}
 
 #endif


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to