annotate DEPENDENCIES/generic/include/boost/xpressive/detail/static/is_pure.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 ///////////////////////////////////////////////////////////////////////////////
Chris@16 2 // is_pure.hpp
Chris@16 3 //
Chris@16 4 // Copyright 2008 Eric Niebler. Distributed under the Boost
Chris@16 5 // Software License, Version 1.0. (See accompanying file
Chris@16 6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7
Chris@16 8 #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_IS_PURE_HPP_EAN_10_04_2005
Chris@16 9 #define BOOST_XPRESSIVE_DETAIL_STATIC_IS_PURE_HPP_EAN_10_04_2005
Chris@16 10
Chris@16 11 // MS compatible compilers support #pragma once
Chris@101 12 #if defined(_MSC_VER)
Chris@16 13 # pragma once
Chris@16 14 #endif
Chris@16 15
Chris@16 16 #include <boost/ref.hpp>
Chris@16 17 #include <boost/mpl/and.hpp>
Chris@16 18 #include <boost/mpl/bool.hpp>
Chris@16 19 #include <boost/mpl/assert.hpp>
Chris@16 20 #include <boost/mpl/not_equal_to.hpp>
Chris@16 21 #include <boost/xpressive/detail/detail_fwd.hpp>
Chris@16 22 #include <boost/xpressive/detail/static/width_of.hpp>
Chris@16 23
Chris@16 24 namespace boost { namespace xpressive { namespace detail
Chris@16 25 {
Chris@16 26 ///////////////////////////////////////////////////////////////////////////////
Chris@16 27 // use_simple_repeat_terminal
Chris@16 28 //
Chris@16 29 template<typename Expr, typename Char, bool IsXpr = is_xpr<Expr>::value>
Chris@16 30 struct use_simple_repeat_terminal
Chris@16 31 : mpl::bool_<
Chris@16 32 Expr::quant == quant_fixed_width
Chris@16 33 || (Expr::width != unknown_width::value && Expr::pure)
Chris@16 34 >
Chris@16 35 {};
Chris@16 36
Chris@16 37 template<typename Expr, typename Char>
Chris@16 38 struct use_simple_repeat_terminal<Expr, Char, false>
Chris@16 39 : mpl::true_ // char literals, string literals, etc.
Chris@16 40 {};
Chris@16 41
Chris@16 42 template<typename BidiIter, typename Char>
Chris@16 43 struct use_simple_repeat_terminal<tracking_ptr<regex_impl<BidiIter> >, Char, false>
Chris@16 44 : mpl::false_ // basic_regex
Chris@16 45 {};
Chris@16 46
Chris@16 47 template<typename BidiIter, typename Char>
Chris@16 48 struct use_simple_repeat_terminal<reference_wrapper<basic_regex<BidiIter> >, Char, false>
Chris@16 49 : mpl::false_ // basic_regex
Chris@16 50 {};
Chris@16 51
Chris@16 52 template<typename BidiIter, typename Char>
Chris@16 53 struct use_simple_repeat_terminal<reference_wrapper<basic_regex<BidiIter> const>, Char, false>
Chris@16 54 : mpl::false_ // basic_regex
Chris@16 55 {};
Chris@16 56
Chris@16 57 ///////////////////////////////////////////////////////////////////////////////
Chris@16 58 // use_simple_repeat_
Chris@16 59 //
Chris@16 60 template<typename Expr, typename Char, typename Tag = typename Expr::proto_tag>
Chris@16 61 struct use_simple_repeat_
Chris@16 62 {};
Chris@16 63
Chris@16 64 template<typename Expr, typename Char>
Chris@16 65 struct use_simple_repeat_<Expr, Char, proto::tag::terminal>
Chris@16 66 : use_simple_repeat_terminal<typename proto::result_of::value<Expr>::type, Char>
Chris@16 67 {};
Chris@16 68
Chris@16 69 template<typename Expr, typename Char>
Chris@16 70 struct use_simple_repeat_<Expr, Char, proto::tag::shift_right>
Chris@16 71 : mpl::and_<
Chris@16 72 use_simple_repeat_<typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr, Char>
Chris@16 73 , use_simple_repeat_<typename remove_reference<typename Expr::proto_child1>::type::proto_base_expr, Char>
Chris@16 74 >
Chris@16 75 {};
Chris@16 76
Chris@16 77 template<typename Expr, typename Char>
Chris@16 78 struct use_simple_repeat_<Expr, Char, proto::tag::bitwise_or>
Chris@16 79 : mpl::and_<
Chris@16 80 mpl::not_equal_to<unknown_width, width_of<Expr, Char> >
Chris@16 81 , use_simple_repeat_<typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr, Char>
Chris@16 82 , use_simple_repeat_<typename remove_reference<typename Expr::proto_child1>::type::proto_base_expr, Char>
Chris@16 83 >
Chris@16 84 {};
Chris@16 85
Chris@16 86 template<typename Left>
Chris@16 87 struct use_simple_repeat_assign
Chris@16 88 {};
Chris@16 89
Chris@16 90 template<>
Chris@16 91 struct use_simple_repeat_assign<mark_placeholder>
Chris@16 92 : mpl::false_
Chris@16 93 {};
Chris@16 94
Chris@16 95 template<>
Chris@16 96 struct use_simple_repeat_assign<set_initializer>
Chris@16 97 : mpl::true_
Chris@16 98 {};
Chris@16 99
Chris@16 100 template<typename Nbr>
Chris@16 101 struct use_simple_repeat_assign<attribute_placeholder<Nbr> >
Chris@16 102 : mpl::false_
Chris@16 103 {};
Chris@16 104
Chris@16 105 // either (s1 = ...) or (a1 = ...) or (set = ...)
Chris@16 106 template<typename Expr, typename Char>
Chris@16 107 struct use_simple_repeat_<Expr, Char, proto::tag::assign>
Chris@16 108 : use_simple_repeat_assign<
Chris@16 109 typename proto::result_of::value<
Chris@16 110 typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr
Chris@16 111 >::type
Chris@16 112 >
Chris@16 113 {};
Chris@16 114
Chris@16 115 template<typename Expr, typename Char>
Chris@16 116 struct use_simple_repeat_<Expr, Char, modifier_tag>
Chris@16 117 : use_simple_repeat_<typename remove_reference<typename Expr::proto_child1>::type::proto_base_expr, Char>
Chris@16 118 {};
Chris@16 119
Chris@16 120 template<typename Expr, typename Char>
Chris@16 121 struct use_simple_repeat_<Expr, Char, lookahead_tag>
Chris@16 122 : mpl::false_
Chris@16 123 {};
Chris@16 124
Chris@16 125 template<typename Expr, typename Char>
Chris@16 126 struct use_simple_repeat_<Expr, Char, lookbehind_tag>
Chris@16 127 : mpl::false_
Chris@16 128 {};
Chris@16 129
Chris@16 130 template<typename Expr, typename Char>
Chris@16 131 struct use_simple_repeat_<Expr, Char, keeper_tag>
Chris@16 132 : mpl::false_
Chris@16 133 {};
Chris@16 134
Chris@16 135 // when complementing a set or an assertion, the purity is that of the set (true) or the assertion
Chris@16 136 template<typename Expr, typename Char>
Chris@16 137 struct use_simple_repeat_<Expr, Char, proto::tag::complement>
Chris@16 138 : use_simple_repeat_<typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr, Char>
Chris@16 139 {};
Chris@16 140
Chris@16 141 // The comma is used in list-initialized sets, which are pure
Chris@16 142 template<typename Expr, typename Char>
Chris@16 143 struct use_simple_repeat_<Expr, Char, proto::tag::comma>
Chris@16 144 : mpl::true_
Chris@16 145 {};
Chris@16 146
Chris@16 147 // The subscript operator[] is used for sets, as in set['a' | range('b','h')]
Chris@16 148 // It is also used for actions, which by definition have side-effects and thus are impure
Chris@16 149 template<typename Expr, typename Char, typename Left>
Chris@16 150 struct use_simple_repeat_subscript
Chris@16 151 : mpl::false_
Chris@16 152 {};
Chris@16 153
Chris@16 154 template<typename Expr, typename Char>
Chris@16 155 struct use_simple_repeat_subscript<Expr, Char, set_initializer_type>
Chris@16 156 : mpl::true_
Chris@16 157 {};
Chris@16 158
Chris@16 159 template<typename Expr, typename Char>
Chris@16 160 struct use_simple_repeat_<Expr, Char, proto::tag::subscript>
Chris@16 161 : use_simple_repeat_subscript<Expr, Char, typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr>
Chris@16 162 {};
Chris@16 163
Chris@16 164 // Quantified expressions are variable-width and cannot use the simple quantifier
Chris@16 165 template<typename Expr, typename Char>
Chris@16 166 struct use_simple_repeat_<Expr, Char, proto::tag::unary_plus>
Chris@16 167 : mpl::false_
Chris@16 168 {};
Chris@16 169
Chris@16 170 template<typename Expr, typename Char>
Chris@16 171 struct use_simple_repeat_<Expr, Char, proto::tag::dereference>
Chris@16 172 : mpl::false_
Chris@16 173 {};
Chris@16 174
Chris@16 175 template<typename Expr, typename Char>
Chris@16 176 struct use_simple_repeat_<Expr, Char, proto::tag::logical_not>
Chris@16 177 : mpl::false_
Chris@16 178 {};
Chris@16 179
Chris@16 180 template<typename Expr, typename Char, uint_t Min, uint_t Max>
Chris@16 181 struct use_simple_repeat_<Expr, Char, generic_quant_tag<Min, Max> >
Chris@16 182 : mpl::false_
Chris@16 183 {};
Chris@16 184
Chris@16 185 template<typename Expr, typename Char, uint_t Count>
Chris@16 186 struct use_simple_repeat_<Expr, Char, generic_quant_tag<Count, Count> >
Chris@16 187 : use_simple_repeat_<typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr, Char>
Chris@16 188 {};
Chris@16 189
Chris@16 190 template<typename Expr, typename Char>
Chris@16 191 struct use_simple_repeat_<Expr, Char, proto::tag::negate>
Chris@16 192 : use_simple_repeat_<typename remove_reference<typename Expr::proto_child0>::type::proto_base_expr, Char>
Chris@16 193 {};
Chris@16 194
Chris@16 195 ///////////////////////////////////////////////////////////////////////////////
Chris@16 196 // use_simple_repeat
Chris@16 197 //
Chris@16 198 template<typename Expr, typename Char>
Chris@16 199 struct use_simple_repeat
Chris@16 200 : use_simple_repeat_<Expr, Char>
Chris@16 201 {
Chris@16 202 // should never try to repeat something of 0-width
Chris@16 203 BOOST_MPL_ASSERT_RELATION(0, !=, (width_of<Expr, Char>::value));
Chris@16 204 };
Chris@16 205
Chris@16 206 template<typename Expr, typename Char>
Chris@16 207 struct use_simple_repeat<Expr &, Char>
Chris@16 208 : use_simple_repeat_<Expr, Char>
Chris@16 209 {
Chris@16 210 // should never try to repeat something of 0-width
Chris@16 211 BOOST_MPL_ASSERT_RELATION(0, !=, (width_of<Expr, Char>::value));
Chris@16 212 };
Chris@16 213
Chris@16 214 }}} // namespace boost::xpressive::detail
Chris@16 215
Chris@16 216 #endif