/////////////////////////////////////////////////////////////////////////////// // is_pure.hpp // // Copyright 2008 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_IS_PURE_HPP_EAN_10_04_2005 #define BOOST_XPRESSIVE_DETAIL_STATIC_IS_PURE_HPP_EAN_10_04_2005 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include #include #include #include #include #include #include namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // use_simple_repeat_terminal // template::value> struct use_simple_repeat_terminal : mpl::bool_< Expr::quant == quant_fixed_width || (Expr::width != unknown_width::value && Expr::pure) > {}; template struct use_simple_repeat_terminal : mpl::true_ // char literals, string literals, etc. {}; template struct use_simple_repeat_terminal >, Char, false> : mpl::false_ // basic_regex {}; template struct use_simple_repeat_terminal >, Char, false> : mpl::false_ // basic_regex {}; template struct use_simple_repeat_terminal const>, Char, false> : mpl::false_ // basic_regex {}; /////////////////////////////////////////////////////////////////////////////// // use_simple_repeat_ // template struct use_simple_repeat_ {}; template struct use_simple_repeat_ : use_simple_repeat_terminal::type, Char> {}; template struct use_simple_repeat_ : mpl::and_< use_simple_repeat_::type::proto_base_expr, Char> , use_simple_repeat_::type::proto_base_expr, Char> > {}; template struct use_simple_repeat_ : mpl::and_< mpl::not_equal_to > , use_simple_repeat_::type::proto_base_expr, Char> , use_simple_repeat_::type::proto_base_expr, Char> > {}; template struct use_simple_repeat_assign {}; template<> struct use_simple_repeat_assign : mpl::false_ {}; template<> struct use_simple_repeat_assign : mpl::true_ {}; template struct use_simple_repeat_assign > : mpl::false_ {}; // either (s1 = ...) or (a1 = ...) or (set = ...) template struct use_simple_repeat_ : use_simple_repeat_assign< typename proto::result_of::value< typename remove_reference::type::proto_base_expr >::type > {}; template struct use_simple_repeat_ : use_simple_repeat_::type::proto_base_expr, Char> {}; template struct use_simple_repeat_ : mpl::false_ {}; template struct use_simple_repeat_ : mpl::false_ {}; template struct use_simple_repeat_ : mpl::false_ {}; // when complementing a set or an assertion, the purity is that of the set (true) or the assertion template struct use_simple_repeat_ : use_simple_repeat_::type::proto_base_expr, Char> {}; // The comma is used in list-initialized sets, which are pure template struct use_simple_repeat_ : mpl::true_ {}; // The subscript operator[] is used for sets, as in set['a' | range('b','h')] // It is also used for actions, which by definition have side-effects and thus are impure template struct use_simple_repeat_subscript : mpl::false_ {}; template struct use_simple_repeat_subscript : mpl::true_ {}; template struct use_simple_repeat_ : use_simple_repeat_subscript::type::proto_base_expr> {}; // Quantified expressions are variable-width and cannot use the simple quantifier template struct use_simple_repeat_ : mpl::false_ {}; template struct use_simple_repeat_ : mpl::false_ {}; template struct use_simple_repeat_ : mpl::false_ {}; template struct use_simple_repeat_ > : mpl::false_ {}; template struct use_simple_repeat_ > : use_simple_repeat_::type::proto_base_expr, Char> {}; template struct use_simple_repeat_ : use_simple_repeat_::type::proto_base_expr, Char> {}; /////////////////////////////////////////////////////////////////////////////// // use_simple_repeat // template struct use_simple_repeat : use_simple_repeat_ { // should never try to repeat something of 0-width BOOST_MPL_ASSERT_RELATION(0, !=, (width_of::value)); }; template struct use_simple_repeat : use_simple_repeat_ { // should never try to repeat something of 0-width BOOST_MPL_ASSERT_RELATION(0, !=, (width_of::value)); }; }}} // namespace boost::xpressive::detail #endif