/////////////////////////////////////////////////////////////////////////////// // as_inverse.hpp // // Copyright 2007 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_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007 #define BOOST_XPRESSIVE_DETAIL_STATIC_TRANSFORMS_AS_INVERSE_HPP_EAN_04_05_2007 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include #include #include #include namespace boost { namespace xpressive { namespace detail { template struct inverter { typedef T type; static T call(T t) { t.inverse(); return t; } }; template struct inverter > { typedef literal_matcher type; static type call(literal_matcher t) { return type(t); } }; template struct inverter > { // ~_ln matches any one character that is not in the "newline" character class typedef posix_charset_matcher type; static type call(logical_newline_matcher t) { return type(t.newline(), true); } }; template struct inverter, Traits> > { typedef assert_word_matcher, Traits> type; static type call(assert_word_matcher, Traits> t) { return type(t.word()); } }; template typename inverter::type invert(T const &t) { return inverter::call(t); } template struct as_inverse : Grammar { as_inverse(); template struct apply : inverter::type> {}; template static typename apply::type call(Expr const &expr, State const &state, Visitor &visitor) { return detail::invert(Grammar::call(expr, state, visitor)); } }; }}} #endif