123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- #ifndef BOOST_YAP_ALGORITHM_FWD_HPP_INCLUDED
- #define BOOST_YAP_ALGORITHM_FWD_HPP_INCLUDED
- #include <boost/yap/config.hpp>
- #include <boost/hana/integral_constant.hpp>
- #include <boost/hana/tuple.hpp>
- #include <boost/hana/core/is_a.hpp>
- namespace boost { namespace yap {
-
- enum class expr_kind {
- expr_ref =
- 0,
- terminal = 1,
-
- unary_plus = 2,
- negate = 3,
- dereference = 4,
- complement = 5,
- address_of = 6,
- logical_not = 7,
- pre_inc = 8,
- pre_dec = 9,
- post_inc = 10,
- post_dec = 11,
-
- shift_left = 12,
- shift_right = 13,
- multiplies = 14,
- divides = 15,
- modulus = 16,
- plus = 17,
- minus = 18,
- less = 19,
- greater = 20,
- less_equal = 21,
- greater_equal = 22,
- equal_to = 23,
- not_equal_to = 24,
- logical_or = 25,
- logical_and = 26,
- bitwise_and = 27,
- bitwise_or = 28,
- bitwise_xor = 29,
- comma = 30,
- mem_ptr = 31,
- assign = 32,
- shift_left_assign = 33,
- shift_right_assign = 34,
- multiplies_assign = 35,
- divides_assign = 36,
- modulus_assign = 37,
- plus_assign = 38,
- minus_assign = 39,
- bitwise_and_assign = 40,
- bitwise_or_assign = 41,
- bitwise_xor_assign = 42,
- subscript = 43,
-
- if_else = 44,
-
- call = 45
- };
-
- template<long long I>
- struct placeholder : hana::llong<I>
- {
- };
- #ifdef BOOST_YAP_DOXYGEN
-
- template<typename Expr>
- struct is_expr;
- #else
- template<expr_kind Kind, typename Tuple>
- struct expression;
- namespace detail {
-
- template<class...>
- using void_t = void;
-
- template<typename T>
- struct remove_cv_ref : std::remove_cv<std::remove_reference_t<T>>
- {
- };
- template<typename T>
- using remove_cv_ref_t = typename remove_cv_ref<T>::type;
- }
- template<
- typename Expr,
- typename = detail::void_t<>,
- typename = detail::void_t<>>
- struct is_expr : std::false_type
- {
- };
- template<typename Expr>
- struct is_expr<
- Expr,
- detail::void_t<decltype(detail::remove_cv_ref_t<Expr>::kind)>,
- detail::void_t<decltype(std::declval<Expr>().elements)>>
- : std::integral_constant<
- bool,
- std::is_same<
- std::remove_cv_t<decltype(
- detail::remove_cv_ref_t<Expr>::kind)>,
- expr_kind>::value &&
- hana::is_a<
- hana::tuple_tag,
- decltype(std::declval<Expr>().elements)>>
- {
- };
- #endif
-
- template<template<expr_kind, class> class expr_template, typename T>
- using terminal = expr_template<expr_kind::terminal, hana::tuple<T>>;
-
- template<template<expr_kind, class> class expr_template, typename T>
- using expression_ref = expr_template<
- expr_kind::expr_ref,
- hana::tuple<std::remove_reference_t<T> *>>;
- #ifndef BOOST_YAP_DOXYGEN
- template<typename Expr, typename... T>
- constexpr decltype(auto) evaluate(Expr && expr, T &&... t);
- template<typename Expr, typename Transform, typename... Transforms>
- constexpr decltype(auto) transform(
- Expr && expr, Transform && transform, Transforms &&... transforms);
- template<typename Expr, typename Transform, typename... Transforms>
- constexpr decltype(auto) transform_strict(
- Expr && expr, Transform && transform, Transforms &&... transforms);
- template<typename T>
- constexpr decltype(auto) deref(T && x);
- template<typename Expr>
- constexpr decltype(auto) value(Expr && expr);
- #endif
- namespace literals {
-
- template<char... c>
- constexpr auto operator"" _p()
- {
- using i = hana::llong<hana::ic_detail::parse<sizeof...(c)>({c...})>;
- static_assert(1 <= i::value, "Placeholders must be >= 1.");
- return expression<
- expr_kind::terminal,
- hana::tuple<placeholder<i::value>>>{};
- }
- }
-
- template<expr_kind Kind>
- struct expr_tag
- {
- static const expr_kind kind = Kind;
- };
-
- template<expr_kind Kind, typename Tuple>
- struct minimal_expr
- {
- static expr_kind const kind = Kind;
- Tuple elements;
- };
- }}
- #endif
|