Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19786/proto
Modified Files:
matches.hpp
Log Message:
increase performance of proto::matches<>
Index: matches.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/matches.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- matches.hpp 13 Nov 2006 15:53:45 -0000 1.12
+++ matches.hpp 18 Nov 2006 22:44:56 -0000 1.13
@@ -34,18 +34,6 @@
namespace detail
{
- template<typename T>
- struct safe_unref
- {
- typedef T type;
- };
-
- template<typename T>
- struct safe_unref<ref<T> >
- {
- typedef T type;
- };
-
// and_
template<bool B,
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PROTO_MAX_ARITY, typename P, void)>
struct and_impl
@@ -121,17 +109,39 @@
: terminal_matches<Expr0, Grammar0>
{};
+ // by default, assume parameter is an expression generator ...
+ // (this also works for extends<> types because they are also
generators)
+ template<typename Expr>
+ struct deref
+ {
+ typedef typename Expr::type type;
+ };
+
+ // ... but it could be a plain expression ...
+ template<typename Tag, typename Args, long Arity>
+ struct deref<basic_expr<Tag, Args, Arity> >
+ {
+ typedef basic_expr<Tag, Args, Arity> type;
+ };
+
+ // ... or the placeholder
+ template<>
+ struct deref<mpl::_>
+ {
+ typedef mpl::_ type;
+ };
+
// matches_impl
+ template<typename Expr, typename Grammar>
+ struct matches_impl;
+
#define BOOST_PROTO_MATCHES_N_FUN(z, n, data)\
- matches<\
- typename safe_unref<typename mpl::at_c<Args1, n>::type>::type\
- , typename safe_unref<typename mpl::at_c<Args2, n>::type>::type\
+ matches_impl<\
+ typename mpl::at_c<Args1, n>::type::expr_type\
+ , typename deref<typename mpl::at_c<Args2, n>::type>::type\
>\
/**/
- template<typename Expr, typename Grammar>
- struct matches_impl;
-
template<typename Expr>
struct matches_impl< Expr, mpl::_ >
: mpl::true_
@@ -144,17 +154,17 @@
template<typename Tag, typename Args1, typename Args2>
struct matches_impl< basic_expr<Tag, Args1, 1>, basic_expr<Tag,
Args2, 1> >
- : matches<
- typename safe_unref<typename mpl::at_c<Args1,
0>::type>::type
- , typename safe_unref<typename mpl::at_c<Args2,
0>::type>::type
+ : matches_impl<
+ typename mpl::at_c<Args1, 0>::type::expr_type
+ , typename deref<typename mpl::at_c<Args2, 0>::type>::type
>
{};
template<typename Args1, typename Args2>
struct matches_impl< basic_expr<terminal_tag, Args1, 1>,
basic_expr<terminal_tag, Args2, 1> >
: terminal_matches<
- typename safe_unref<typename mpl::at_c<Args1,
0>::type>::type
- , typename safe_unref<typename mpl::at_c<Args2,
0>::type>::type
+ typename mpl::at_c<Args1, 0>::type
+ , typename mpl::at_c<Args2, 0>::type
>
{};
@@ -175,35 +185,11 @@
: mpl::apply1<Pred, Expr>
{};
- // by default, assume parameter is an expression generator ...
- // (this also works for extends<> types because they are also
generators)
- template<typename Expr>
- struct deref
- {
- typedef typename Expr::type type;
- };
-
- // ... but it could be a plain expression ...
- template<typename Tag, typename Args, long Arity>
- struct deref<basic_expr<Tag, Args, Arity> >
- {
- typedef basic_expr<Tag, Args, Arity> type;
- };
-
- // ... or the placeholder
- template<>
- struct deref<mpl::_>
- {
- typedef mpl::_ type;
- };
}
template<typename Expr, typename Grammar>
struct matches
- : mpl::or_<
- is_same<typename Expr::expr_type, typename
detail::deref<Grammar>::type>
- , detail::matches_impl<typename Expr::expr_type, typename
detail::deref<Grammar>::type>
- >
+ : detail::matches_impl<typename Expr::expr_type, typename
detail::deref<Grammar>::type>
{};
template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename G)>
-------------------------------------------------------------------------
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