Update of /cvsroot/boost/boost/boost/xpressive
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv11154
Modified Files:
regex_actions.hpp
Log Message:
regex_actions.hpp gets first(), second(), length(), str() and construct()
Index: regex_actions.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/regex_actions.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- regex_actions.hpp 24 Mar 2007 10:07:29 -0000 1.5
+++ regex_actions.hpp 24 Mar 2007 18:29:06 -0000 1.6
@@ -14,7 +14,7 @@
# pragma once
#endif
-#include <boost/mpl/identity.hpp>
+#include <boost/mpl/int.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
#include <boost/xpressive/detail/core/state.hpp>
@@ -42,8 +42,11 @@
{
return const_cast<T &>(t);
}
+ }
- struct push_impl
+ namespace op
+ {
+ struct push
{
typedef void result_type;
@@ -54,7 +57,7 @@
}
};
- struct push_back_impl
+ struct push_back
{
typedef void result_type;
@@ -65,7 +68,7 @@
}
};
- struct push_front_impl
+ struct push_front
{
typedef void result_type;
@@ -76,7 +79,7 @@
}
};
- struct pop_impl
+ struct pop
{
typedef void result_type;
@@ -87,7 +90,7 @@
}
};
- struct pop_back_impl
+ struct pop_back
{
typedef void result_type;
@@ -98,7 +101,7 @@
}
};
- struct pop_front_impl
+ struct pop_front
{
typedef void result_type;
@@ -109,7 +112,7 @@
}
};
- struct front_impl
+ struct front
{
template<typename Sig>
struct result;
@@ -127,7 +130,7 @@
}
};
- struct back_impl
+ struct back
{
template<typename Sig>
struct result;
@@ -145,7 +148,7 @@
}
};
- struct top_impl
+ struct top
{
template<typename Sig>
struct result;
@@ -163,8 +166,80 @@
}
};
+ struct first
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Pair>
+ struct result<This(Pair &)>
+ {
+ typedef typename Pair::first_type type;
+ };
+
+ template<typename Pair>
+ typename Pair::first_type operator()(Pair &p) const
+ {
+ return p.first;
+ }
+ };
+
+ struct second
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Pair>
+ struct result<This(Pair &)>
+ {
+ typedef typename Pair::second_type type;
+ };
+
+ template<typename Pair>
+ typename Pair::second_type operator()(Pair &p) const
+ {
+ return p.second;
+ }
+ };
+
+ struct length
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Sub>
+ struct result<This(Sub &)>
+ {
+ typedef typename Sub::difference_type type;
+ };
+
+ template<typename Sub>
+ typename Sub::difference_type operator()(Sub &sub) const
+ {
+ return sub.length();
+ }
+ };
+
+ struct str
+ {
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename Sub>
+ struct result<This(Sub &)>
+ {
+ typedef typename Sub::string_type type;
+ };
+
+ template<typename Sub>
+ typename Sub::string_type operator()(Sub &sub) const
+ {
+ return sub.str();
+ }
+ };
+
template<typename T>
- struct as_impl
+ struct as
{
typedef T result_type;
@@ -174,28 +249,61 @@
return lexical_cast<T>(val);
}
};
+
+ template<typename T>
+ struct construct
+ {
+ typedef T result_type;
+
+ T operator()() const
+ {
+ return T();
+ }
+
+ template<typename A0>
+ T operator()(A0 &a0) const
+ {
+ return T(a0);
+ }
+
+ template<typename A0, typename A1>
+ T operator()(A0 &a0, A1 &a1) const
+ {
+ return T(a0, a1);
+ }
+
+ template<typename A0, typename A1, typename A2>
+ T operator()(A0 &a0, A1 &a1, A2 &a2) const
+ {
+ return T(a0, a1, a2);
+ }
+ };
}
- proto::terminal<detail::push_impl>::type const push = {{}};
- proto::terminal<detail::push_back_impl>::type const push_back = {{}};
- proto::terminal<detail::push_front_impl>::type const push_front = {{}};
- proto::terminal<detail::pop_impl>::type const pop = {{}};
- proto::terminal<detail::pop_back_impl>::type const pop_back = {{}};
- proto::terminal<detail::pop_front_impl>::type const pop_front = {{}};
- proto::terminal<detail::top_impl>::type const top = {{}};
- proto::terminal<detail::back_impl>::type const back = {{}};
- proto::terminal<detail::front_impl>::type const front = {{}};
+ 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::length>::type const length = {{}};
+ proto::terminal<op::str>::type const str = {{}};
template<typename T, typename D>
typename proto::function<
- typename proto::terminal<detail::as_impl<T> >::type
- , typename proto::result_of::as_arg<D const>::type
+ typename proto::terminal<op::as<T> >::type
+ , typename proto::result_of::as_expr<D const>::type
>::type as(D const &d)
{
typename proto::function<
- typename proto::terminal<detail::as_impl<T> >::type
- , typename proto::result_of::as_arg<D const>::type
- >::type that = {{{}}, proto::as_arg(d)};
+ typename proto::terminal<op::as<T> >::type
+ , typename proto::result_of::as_expr<D const>::type
+ >::type that = {{{}}, proto::as_expr(d)};
return that;
}
@@ -225,14 +333,78 @@
return proto::as_expr(p);
}
- template<typename T, typename U = void>
+ template<typename T, int I = 0>
struct arg
- : proto::extends<typename proto::terminal<detail::action_arg<T, U>
>::type, arg<T, U> >
+ : proto::extends<typename proto::terminal<detail::action_arg<T,
mpl::int_<I> > >::type, arg<T, I> >
{
- typedef proto::extends<typename proto::terminal<detail::action_arg<T,
U> >::type, arg<T, U> > base_type;
+ typedef proto::extends<typename proto::terminal<detail::action_arg<T,
mpl::int_<I> > >::type, arg<T, I> > base_type;
using base_type::operator =;
};
+ /// construct
+ ///
+ template<typename T>
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ >::type construct()
+ {
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ >::type that = {{{}}};
+ return that;
+ }
+
+ /// \overload
+ ///
+ template<typename T, typename A0>
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ >::type construct(A0 &a0)
+ {
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ >::type that = {{{}}, proto::as_expr(a0)};
+ return that;
+ }
+
+ /// \overload
+ ///
+ template<typename T, typename A0, typename A1>
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ , typename proto::result_of::as_expr<A1>::type
+ >::type construct(A0 &a0, A1 &a1)
+ {
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ , typename proto::result_of::as_expr<A1>::type
+ >::type that = {{{}}, proto::as_expr(a0), proto::as_expr(a1)};
+ return that;
+ }
+
+ /// \overload
+ ///
+ template<typename T, typename A0, typename A1, typename A2>
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ , typename proto::result_of::as_expr<A1>::type
+ , typename proto::result_of::as_expr<A2>::type
+ >::type construct(A0 &a0, A1 &a1, A2 &a2)
+ {
+ typename proto::function<
+ typename proto::terminal<op::construct<T> >::type
+ , typename proto::result_of::as_expr<A0>::type
+ , typename proto::result_of::as_expr<A1>::type
+ , typename proto::result_of::as_expr<A2>::type
+ >::type that = {{{}}, proto::as_expr(a0), proto::as_expr(a1),
proto::as_expr(a2)};
+ return that;
+ }
+
}}
#endif // BOOST_XPRESSIVE_ACTIONS_HPP_EAN_03_22_2007
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs