1 ///////////////////////////////////////////////////////////////////////////////
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007
9 #define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007
11 // MS compatible compilers support #pragma once
16 #include <boost/mpl/sizeof.hpp>
17 #include <boost/mpl/not.hpp>
18 #include <boost/xpressive/detail/detail_fwd.hpp>
19 #include <boost/xpressive/detail/static/static.hpp>
20 #include <boost/proto/core.hpp>
22 #define UNCV(x) typename remove_const<x>::type
23 #define UNREF(x) typename remove_reference<x>::type
24 #define UNCVREF(x) UNCV(UNREF(x))
26 namespace boost { namespace xpressive { namespace grammar_detail
40 template<typename Traits, typename ICase, typename Not>
41 struct inverter<detail::literal_matcher<Traits, ICase, Not> >
43 typedef detail::literal_matcher<Traits, ICase, typename mpl::not_<Not>::type> type;
44 static type call(detail::literal_matcher<Traits, ICase, Not> t)
50 template<typename Traits>
51 struct inverter<detail::logical_newline_matcher<Traits> >
53 // ~_ln matches any one character that is not in the "newline" character class
54 typedef detail::posix_charset_matcher<Traits> type;
55 static type call(detail::logical_newline_matcher<Traits> t)
57 return type(t.newline(), true);
61 template<typename Traits>
62 struct inverter<detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> >
64 typedef detail::assert_word_matcher<detail::word_boundary<mpl::false_>, Traits> type;
65 static type call(detail::assert_word_matcher<detail::word_boundary<mpl::true_>, Traits> t)
67 return type(t.word());
71 struct as_inverse : proto::callable
73 template<typename Sig>
76 template<typename This, typename Matcher>
77 struct result<This(Matcher)>
78 : inverter<UNCVREF(Matcher)>
81 template<typename Matcher>
82 typename inverter<Matcher>::type operator ()(Matcher const &matcher) const
84 return inverter<Matcher>::call(matcher);