/////////////////////////////////////////////////////////////////////////////// // is_pure.hpp // // Copyright 2004 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 #include #include #include #include #include #include namespace boost { namespace xpressive { namespace detail { /////////////////////////////////////////////////////////////////////////////// // use_simple_repeat // template struct use_simple_repeat; /////////////////////////////////////////////////////////////////////////////// // is_pure // template struct is_pure; template<> struct is_pure : mpl::true_ { }; template struct is_pure > : as_matcher_type::type::pure { }; template struct is_pure > : mpl::and_, is_pure > { }; template struct is_pure > : mpl::and_, is_pure > { }; template struct is_pure > : mpl::false_ { }; template struct is_pure > : mpl::true_ { }; template struct is_pure > : is_pure { }; template struct is_pure > > : is_pure { }; template struct is_pure > > : is_pure { }; template struct is_pure > : is_pure { }; template struct is_pure > : mpl::and_ >::type { }; template struct is_pure const> > : mpl::false_ { }; template struct is_pure const> > > : mpl::false_ { }; //template //struct is_pure > // : mpl::false_ //{ //}; template struct is_pure, proto::noop_tag> > : mpl::false_ { }; template struct is_pure const>, proto::noop_tag> > : mpl::false_ { }; // when complementing a set or an assertion, the purity is that of the set (true) or the assertion template struct is_pure > : is_pure { }; // The comma is used in list-initialized sets, which are pure template struct is_pure > : 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 is_pure > : is_same { // If Left is "set" then make sure that Right is pure BOOST_MPL_ASSERT (( mpl::or_ < mpl::not_ > , is_pure > )); }; // Quantified expressions are pure IFF they use the simple_repeat_matcher template struct is_pure > : use_simple_repeat { }; template struct is_pure > : use_simple_repeat { }; template struct is_pure > : use_simple_repeat { }; template struct is_pure > > : use_simple_repeat { }; template struct is_pure > : is_pure { }; template struct is_pure > : mpl::fold < mpl::transform_view > , mpl::true_ , mpl::and_ >::type { }; /////////////////////////////////////////////////////////////////////////////// // use_simple_repeat // BUGBUG this doesn't handle +(_ >> s1) correctly, right? template struct use_simple_repeat : mpl::and_, unknown_width>, is_pure > { // should never try to quantify something of 0-width BOOST_MPL_ASSERT((mpl::not_equal_to, mpl::size_t<0> >)); }; template struct use_simple_repeat > : mpl::and_ < mpl::equal_to < quant_type::type> , mpl::int_ > , typename as_matcher_type::type::pure > { BOOST_MPL_ASSERT_RELATION(0, !=, as_matcher_type::type::width::value); }; template struct is_pure > : is_pure { }; }}} // namespace boost::xpressive::detail #endif