Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2007-10-09 18:27:00


Author: eric_niebler
Date: 2007-10-09 18:26:59 EDT (Tue, 09 Oct 2007)
New Revision: 39868
URL: http://svn.boost.org/trac/boost/changeset/39868

Log:
add xpressive::function<> for defining function objects for use in semantic actions
Text files modified:
   trunk/boost/xpressive/proto/expr.hpp | 7 ++---
   trunk/boost/xpressive/regex_actions.hpp | 47 ++++++++++++++++++++++++---------------
   2 files changed, 32 insertions(+), 22 deletions(-)

Modified: trunk/boost/xpressive/proto/expr.hpp
==============================================================================
--- trunk/boost/xpressive/proto/expr.hpp (original)
+++ trunk/boost/xpressive/proto/expr.hpp 2007-10-09 18:26:59 EDT (Tue, 09 Oct 2007)
@@ -136,6 +136,9 @@
 
 #elif BOOST_PP_ITERATION_DEPTH() == 1
 
+ #define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
+ #define IS_TERMINAL 0 == BOOST_PP_ITERATION()
+
         /// \brief Representation of a node in an expression tree.
         ///
         /// \c proto::expr\<\> is a node in an expression template tree. It
@@ -157,10 +160,6 @@
         /// type is \c boost::proto::tag::terminal, in which case
         /// \c Args must be \c proto::args1\<T\>, where \c T can be any
         /// type.
-
- #define ARG_COUNT BOOST_PP_MAX(1, BOOST_PP_ITERATION())
- #define IS_TERMINAL 0 == BOOST_PP_ITERATION()
-
         template<typename Tag, typename Args>
         struct expr<Tag, Args, BOOST_PP_ITERATION() >
         {

Modified: trunk/boost/xpressive/regex_actions.hpp
==============================================================================
--- trunk/boost/xpressive/regex_actions.hpp (original)
+++ trunk/boost/xpressive/regex_actions.hpp 2007-10-09 18:26:59 EDT (Tue, 09 Oct 2007)
@@ -39,8 +39,13 @@
 # include <boost/xpressive/detail/core/matcher/action_matcher.hpp>
 #endif
 
-#define UNREF(x) typename remove_reference<x>::type
-#define UNCVREF(x) typename remove_cv<typename remove_reference<x>::type>::type
+/// INTERNAL ONLY
+///
+#define UNREF(x) typename remove_reference<x>::type
+
+/// INTERNAL ONLY
+///
+#define UNCVREF(x) typename remove_cv<typename remove_reference<x>::type>::type
 
 namespace boost { namespace xpressive
 {
@@ -523,22 +528,28 @@
         };
     }
 
- proto::terminal<op::push>::type const push = {{}};
- proto::terminal<op::push_back>::type const push_back = {{}};
- proto::terminal<op::push_front>::type const push_front = {{}};
- proto::terminal<op::pop>::type const pop = {{}};
- proto::terminal<op::pop_back>::type const pop_back = {{}};
- proto::terminal<op::pop_front>::type const pop_front = {{}};
- proto::terminal<op::top>::type const top = {{}};
- proto::terminal<op::back>::type const back = {{}};
- proto::terminal<op::front>::type const front = {{}};
- proto::terminal<op::first>::type const first = {{}};
- proto::terminal<op::second>::type const second = {{}};
- proto::terminal<op::matched>::type const matched = {{}};
- proto::terminal<op::length>::type const length = {{}};
- proto::terminal<op::str>::type const str = {{}};
- proto::terminal<op::insert>::type const insert = {{}};
- proto::terminal<op::make_pair>::type const make_pair = {{}};
+ template<typename Fun>
+ struct function
+ {
+ typedef typename proto::terminal<Fun>::type type;
+ };
+
+ function<op::push>::type const push = {{}};
+ function<op::push_back>::type const push_back = {{}};
+ function<op::push_front>::type const push_front = {{}};
+ function<op::pop>::type const pop = {{}};
+ function<op::pop_back>::type const pop_back = {{}};
+ function<op::pop_front>::type const pop_front = {{}};
+ function<op::top>::type const top = {{}};
+ function<op::back>::type const back = {{}};
+ function<op::front>::type const front = {{}};
+ function<op::first>::type const first = {{}};
+ function<op::second>::type const second = {{}};
+ function<op::matched>::type const matched = {{}};
+ function<op::length>::type const length = {{}};
+ function<op::str>::type const str = {{}};
+ function<op::insert>::type const insert = {{}};
+ function<op::make_pair>::type const make_pair = {{}};
 
     template<typename T>
     struct value


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