]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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/call_traits.hpp> | |
12 | #include <boost/fusion/sequence/intrinsic/at.hpp> | |
13 | #include <boost/phoenix/core/as_actor.hpp> | |
14 | #include <boost/phoenix/core/detail/expression.hpp> | |
15 | #include <boost/phoenix/core/domain.hpp> | |
16 | #include <boost/proto/domain.hpp> | |
17 | #include <boost/proto/make_expr.hpp> | |
18 | #include <boost/proto/transform/pass_through.hpp> | |
19 | ||
20 | namespace boost { namespace phoenix | |
21 | { | |
22 | template <typename Expr> struct actor; | |
23 | ||
24 | #ifdef BOOST_PHOENIX_NO_VARIADIC_EXPRESSION | |
25 | #include <boost/phoenix/core/detail/cpp03/expression.hpp> | |
26 | #else | |
27 | template <template <typename> class Actor, typename Tag, typename... A> | |
28 | struct expr_ext; | |
29 | ||
30 | // This void filter is necessary to avoid forming reference to void | |
31 | // because most of other expressions are not based on variadics. | |
32 | template <typename Tag, typename F, typename... T> | |
33 | struct expr_impl; | |
34 | ||
35 | template <typename Tag, typename... A> | |
36 | struct expr_impl<Tag, void(A...)> : expr_ext<actor, Tag, A...> {}; | |
37 | ||
38 | template <typename Tag, typename... A, typename... T> | |
39 | struct expr_impl<Tag, void(A...), void, T...> : expr_impl<Tag, void(A...)> {}; | |
40 | ||
41 | template <typename Tag, typename... A, typename H, typename... T> | |
42 | struct expr_impl<Tag, void(A...), H, T...> : expr_impl<Tag, void(A..., H), T...> {}; | |
43 | ||
44 | template <typename Tag, typename... A> | |
45 | struct expr : expr_impl<Tag, void(), A...> {}; | |
46 | ||
47 | template <template <typename> class Actor, typename Tag, typename... A> | |
48 | struct expr_ext | |
49 | : proto::transform<expr_ext<Actor, Tag, A...>, int> | |
50 | { | |
51 | typedef | |
52 | typename proto::result_of::make_expr< | |
53 | Tag | |
54 | , phoenix_default_domain //proto::basic_default_domain | |
55 | , typename proto::detail::uncvref<typename call_traits<A>::value_type>::type... | |
56 | >::type | |
57 | base_type; | |
58 | ||
59 | typedef Actor<base_type> type; | |
60 | ||
61 | typedef typename proto::nary_expr<Tag, A...>::proto_grammar proto_grammar; | |
62 | ||
63 | static type make(typename call_traits<A>::param_type... a) | |
64 | { //?? actor or Actor?? | |
65 | //Actor<base_type> const e = | |
66 | actor<base_type> const e = | |
67 | { | |
68 | proto::make_expr<Tag, phoenix_default_domain>(a...) | |
69 | }; | |
70 | return e; | |
71 | } | |
72 | ||
73 | template<typename Expr, typename State, typename Data> | |
74 | struct impl | |
75 | : proto::pass_through<expr_ext>::template impl<Expr, State, Data> | |
76 | {}; | |
77 | ||
78 | typedef Tag proto_tag; | |
79 | }; | |
80 | #endif | |
81 | }} | |
82 | ||
83 | #endif |