File indexing completed on 2025-01-18 09:53:56
0001
0002
0003
0004
0005
0006 #ifndef BOOST_YAP_ALGORITHM_FWD_HPP_INCLUDED
0007 #define BOOST_YAP_ALGORITHM_FWD_HPP_INCLUDED
0008
0009 #include <boost/yap/config.hpp>
0010
0011 #include <boost/hana/integral_constant.hpp>
0012 #include <boost/hana/tuple.hpp>
0013 #include <boost/hana/core/is_a.hpp>
0014
0015
0016 namespace boost { namespace yap {
0017
0018
0019
0020
0021 enum class expr_kind {
0022 expr_ref =
0023 0,
0024
0025 terminal = 1,
0026
0027
0028 unary_plus = 2,
0029 negate = 3,
0030 dereference = 4,
0031 complement = 5,
0032 address_of = 6,
0033 logical_not = 7,
0034 pre_inc = 8,
0035 pre_dec = 9,
0036 post_inc = 10,
0037 post_dec = 11,
0038
0039
0040 shift_left = 12,
0041 shift_right = 13,
0042 multiplies = 14,
0043 divides = 15,
0044 modulus = 16,
0045 plus = 17,
0046 minus = 18,
0047 less = 19,
0048 greater = 20,
0049 less_equal = 21,
0050 greater_equal = 22,
0051 equal_to = 23,
0052 not_equal_to = 24,
0053 logical_or = 25,
0054 logical_and = 26,
0055 bitwise_and = 27,
0056 bitwise_or = 28,
0057 bitwise_xor = 29,
0058 comma = 30,
0059 mem_ptr = 31,
0060 assign = 32,
0061 shift_left_assign = 33,
0062 shift_right_assign = 34,
0063 multiplies_assign = 35,
0064 divides_assign = 36,
0065 modulus_assign = 37,
0066 plus_assign = 38,
0067 minus_assign = 39,
0068 bitwise_and_assign = 40,
0069 bitwise_or_assign = 41,
0070 bitwise_xor_assign = 42,
0071 subscript = 43,
0072
0073
0074 if_else = 44,
0075
0076
0077 call = 45
0078 };
0079
0080
0081 template<long long I>
0082 struct placeholder : hana::llong<I>
0083 {
0084 };
0085
0086 #ifdef BOOST_YAP_DOXYGEN
0087
0088
0089
0090 template<typename Expr>
0091 struct is_expr;
0092
0093 #else
0094
0095 template<expr_kind Kind, typename Tuple>
0096 struct expression;
0097
0098 namespace detail {
0099
0100
0101
0102 template<class...>
0103 using void_t = void;
0104
0105
0106
0107 template<typename T>
0108 struct remove_cv_ref : std::remove_cv<std::remove_reference_t<T>>
0109 {
0110 };
0111
0112 template<typename T>
0113 using remove_cv_ref_t = typename remove_cv_ref<T>::type;
0114 }
0115
0116 template<
0117 typename Expr,
0118 typename = detail::void_t<>,
0119 typename = detail::void_t<>>
0120 struct is_expr : std::false_type
0121 {
0122 };
0123
0124 template<typename Expr>
0125 struct is_expr<
0126 Expr,
0127 detail::void_t<decltype(detail::remove_cv_ref_t<Expr>::kind)>,
0128 detail::void_t<decltype(std::declval<Expr>().elements)>>
0129 : std::integral_constant<
0130 bool,
0131 std::is_same<
0132 std::remove_cv_t<decltype(
0133 detail::remove_cv_ref_t<Expr>::kind)>,
0134 expr_kind>::value &&
0135 hana::is_a<
0136 hana::tuple_tag,
0137 decltype(std::declval<Expr>().elements)>>
0138 {
0139 };
0140
0141 #endif
0142
0143
0144
0145 template<template<expr_kind, class> class expr_template, typename T>
0146 using terminal = expr_template<expr_kind::terminal, hana::tuple<T>>;
0147
0148
0149
0150 template<template<expr_kind, class> class expr_template, typename T>
0151 using expression_ref = expr_template<
0152 expr_kind::expr_ref,
0153 hana::tuple<std::remove_reference_t<T> *>>;
0154
0155 #ifndef BOOST_YAP_DOXYGEN
0156
0157 template<typename Expr, typename... T>
0158 constexpr decltype(auto) evaluate(Expr && expr, T &&... t);
0159
0160 template<typename Expr, typename Transform, typename... Transforms>
0161 constexpr decltype(auto) transform(
0162 Expr && expr, Transform && transform, Transforms &&... transforms);
0163
0164 template<typename Expr, typename Transform, typename... Transforms>
0165 constexpr decltype(auto) transform_strict(
0166 Expr && expr, Transform && transform, Transforms &&... transforms);
0167
0168 template<typename T>
0169 constexpr decltype(auto) deref(T && x);
0170
0171 template<typename Expr>
0172 constexpr decltype(auto) value(Expr && expr);
0173
0174 #endif
0175
0176 namespace literals {
0177
0178
0179 template<char... c>
0180 constexpr auto operator"" _p()
0181 {
0182 using i = hana::llong<hana::ic_detail::parse<sizeof...(c)>({c...})>;
0183 static_assert(1 <= i::value, "Placeholders must be >= 1.");
0184 return expression<
0185 expr_kind::terminal,
0186 hana::tuple<placeholder<i::value>>>{};
0187 }
0188 }
0189
0190
0191
0192 template<expr_kind Kind>
0193 struct expr_tag
0194 {
0195 static const expr_kind kind = Kind;
0196 };
0197
0198
0199
0200
0201
0202
0203
0204
0205 template<expr_kind Kind, typename Tuple>
0206 struct minimal_expr
0207 {
0208 static expr_kind const kind = Kind;
0209 Tuple elements;
0210 };
0211
0212 }}
0213
0214 #endif