Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2007 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #ifndef PHOENIX_OBJECT_CONSTRUCT_HPP
|
Chris@16
|
8 #define PHOENIX_OBJECT_CONSTRUCT_HPP
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/spirit/home/phoenix/core/compose.hpp>
|
Chris@16
|
11 #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
|
Chris@16
|
12
|
Chris@16
|
13 namespace boost { namespace phoenix
|
Chris@16
|
14 {
|
Chris@16
|
15 namespace detail
|
Chris@16
|
16 {
|
Chris@16
|
17 template <typename T>
|
Chris@16
|
18 struct construct_eval
|
Chris@16
|
19 {
|
Chris@16
|
20 template <typename Env,
|
Chris@16
|
21 BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
|
Chris@16
|
22 PHOENIX_COMPOSITE_LIMIT, typename T, fusion::void_)>
|
Chris@16
|
23 struct result
|
Chris@16
|
24 {
|
Chris@16
|
25 typedef T type;
|
Chris@16
|
26 };
|
Chris@16
|
27
|
Chris@16
|
28 template <typename RT, typename Env>
|
Chris@16
|
29 static RT
|
Chris@16
|
30 eval(Env const& /*env*/)
|
Chris@16
|
31 {
|
Chris@16
|
32 return RT();
|
Chris@16
|
33 }
|
Chris@16
|
34
|
Chris@16
|
35 template <typename RT, typename Env, typename A0>
|
Chris@16
|
36 static RT
|
Chris@16
|
37 eval(Env const& env, A0& _0)
|
Chris@16
|
38 {
|
Chris@16
|
39 return RT(_0.eval(env));
|
Chris@16
|
40 }
|
Chris@16
|
41
|
Chris@16
|
42 template <typename RT
|
Chris@16
|
43 , typename Env, typename A0, typename A1>
|
Chris@16
|
44 static RT
|
Chris@16
|
45 eval(Env const& env, A0& _0, A1& _1)
|
Chris@16
|
46 {
|
Chris@16
|
47 return RT(_0.eval(env), _1.eval(env));
|
Chris@16
|
48 }
|
Chris@16
|
49
|
Chris@16
|
50 // Bring in the rest of the evals
|
Chris@16
|
51 #include <boost/spirit/home/phoenix/object/detail/construct_eval.hpp>
|
Chris@16
|
52 };
|
Chris@16
|
53 }
|
Chris@16
|
54
|
Chris@16
|
55 template <typename T>
|
Chris@16
|
56 inline actor<typename as_composite<detail::construct_eval<T> >::type>
|
Chris@16
|
57 construct()
|
Chris@16
|
58 {
|
Chris@16
|
59 return compose<detail::construct_eval<T> >();
|
Chris@16
|
60 }
|
Chris@16
|
61
|
Chris@16
|
62 template <typename T, typename A0>
|
Chris@16
|
63 inline actor<typename as_composite<detail::construct_eval<T>, A0>::type>
|
Chris@16
|
64 construct(A0 const& _0)
|
Chris@16
|
65 {
|
Chris@16
|
66 return compose<detail::construct_eval<T> >(_0);
|
Chris@16
|
67 }
|
Chris@16
|
68
|
Chris@16
|
69 template <typename T, typename A0, typename A1>
|
Chris@16
|
70 inline actor<typename as_composite<detail::construct_eval<T>, A0, A1>::type>
|
Chris@16
|
71 construct(A0 const& _0, A1 const& _1)
|
Chris@16
|
72 {
|
Chris@16
|
73 return compose<detail::construct_eval<T> >(_0, _1);
|
Chris@16
|
74 }
|
Chris@16
|
75
|
Chris@16
|
76 // Bring in the rest of the new_ functions
|
Chris@16
|
77 #include <boost/spirit/home/phoenix/object/detail/construct.hpp>
|
Chris@16
|
78 }}
|
Chris@16
|
79
|
Chris@16
|
80 #endif
|