| 1 | /*============================================================================= |
| 2 | Copyright (c) 2016 Kohei Takahashi |
| 3 | |
| 4 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | ==============================================================================*/ |
| 7 | #ifndef BOOST_PHOENIX_CORE_EXPRESSION_HPP |
| 8 | #define BOOST_PHOENIX_CORE_EXPRESSION_HPP |
| 9 | |
| 10 | #include <boost/phoenix/core/limits.hpp> |
| 11 | #include <boost/fusion/sequence/intrinsic/at.hpp> |
| 12 | #include <boost/phoenix/core/as_actor.hpp> |
| 13 | #include <boost/phoenix/core/detail/expression.hpp> |
| 14 | #include <boost/phoenix/core/domain.hpp> |
| 15 | #include <boost/proto/domain.hpp> |
| 16 | #include <boost/proto/make_expr.hpp> |
| 17 | #include <boost/proto/transform/pass_through.hpp> |
| 18 | |
| 19 | namespace boost { namespace phoenix |
| 20 | { |
| 21 | template <typename Expr> struct actor; |
| 22 | |
| 23 | #ifdef BOOST_PHOENIX_NO_VARIADIC_EXPRESSION |
| 24 | #include <boost/phoenix/core/detail/cpp03/expression.hpp> |
| 25 | #else |
| 26 | template <template <typename> class Actor, typename Tag, typename... A> |
| 27 | struct expr_ext; |
| 28 | |
| 29 | // This filter cuts arguments of a template pack after a first void. |
| 30 | // It is necessary because the interface can be used in C++03 style. |
| 31 | template <typename Tag, typename... A> |
| 32 | struct expr_impl; |
| 33 | |
| 34 | // Helper template. Used to store filtered argument types. |
| 35 | template <typename... A> |
| 36 | struct expr_arg_types {}; |
| 37 | |
| 38 | template <typename Tag, typename... A> |
| 39 | struct expr_impl<Tag, expr_arg_types<A...>> : expr_ext<actor, Tag, A...> {}; |
| 40 | |
| 41 | template <typename Tag, typename... A, typename... T> |
| 42 | struct expr_impl<Tag, expr_arg_types<A...>, void, T...> : expr_ext<actor, Tag, A...> {}; |
| 43 | |
| 44 | template <typename Tag, typename... A, typename H, typename... T> |
| 45 | struct expr_impl<Tag, expr_arg_types<A...>, H, T...> : expr_impl<Tag, expr_arg_types<A..., H>, T...> {}; |
| 46 | |
| 47 | template <typename Tag, typename... A> |
| 48 | struct expr : expr_impl<Tag, expr_arg_types<>, A...> {}; |
| 49 | |
| 50 | template <template <typename> class Actor, typename Tag, typename... A> |
| 51 | struct expr_ext |
| 52 | : proto::transform<expr_ext<Actor, Tag, A...>, int> |
| 53 | { |
| 54 | typedef |
| 55 | typename proto::result_of::make_expr< |
| 56 | Tag |
| 57 | , phoenix_default_domain //proto::basic_default_domain |
| 58 | , typename proto::detail::uncvref<A>::type... |
| 59 | >::type |
| 60 | base_type; |
| 61 | |
| 62 | typedef Actor<base_type> type; |
| 63 | |
| 64 | typedef typename proto::nary_expr<Tag, A...>::proto_grammar proto_grammar; |
| 65 | |
| 66 | static type make(A const&... a) |
| 67 | { //?? actor or Actor?? |
| 68 | //Actor<base_type> const e = |
| 69 | actor<base_type> const e = |
| 70 | { |
| 71 | proto::make_expr<Tag, phoenix_default_domain>(a...) |
| 72 | }; |
| 73 | return e; |
| 74 | } |
| 75 | |
| 76 | template<typename Expr, typename State, typename Data> |
| 77 | struct impl |
| 78 | : proto::pass_through<expr_ext>::template impl<Expr, State, Data> |
| 79 | {}; |
| 80 | |
| 81 | typedef Tag proto_tag; |
| 82 | }; |
| 83 | #endif |
| 84 | }} |
| 85 | |
| 86 | #endif |
| 87 | |