Chris@16
|
1 /*==============================================================================
|
Chris@16
|
2 Copyright (c) 2001-2010 Joel de Guzman
|
Chris@16
|
3 Copyright (c) 2010 Thomas Heller
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8 #ifndef BOOST_PHOENIX_OBJECT_NEW_HPP
|
Chris@16
|
9 #define BOOST_PHOENIX_OBJECT_NEW_HPP
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/phoenix/core/limits.hpp>
|
Chris@16
|
12 #include <boost/phoenix/core/expression.hpp>
|
Chris@16
|
13 #include <boost/phoenix/core/meta_grammar.hpp>
|
Chris@16
|
14 #include <boost/phoenix/core/call.hpp>
|
Chris@16
|
15 #include <boost/phoenix/object/detail/target.hpp>
|
Chris@16
|
16 #include <boost/phoenix/support/iterate.hpp>
|
Chris@16
|
17 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG(
|
Chris@16
|
20 (boost)(phoenix)(new_)
|
Chris@16
|
21 , (proto::terminal<detail::target<proto::_> >)
|
Chris@16
|
22 (meta_grammar)
|
Chris@16
|
23 , BOOST_PHOENIX_COMPOSITE_LIMIT
|
Chris@16
|
24 )
|
Chris@16
|
25
|
Chris@16
|
26 namespace boost { namespace phoenix
|
Chris@16
|
27 {
|
Chris@16
|
28 struct new_eval
|
Chris@16
|
29 {
|
Chris@16
|
30 template <typename Sig>
|
Chris@16
|
31 struct result;
|
Chris@16
|
32
|
Chris@16
|
33 template <typename This, typename A0, typename Context>
|
Chris@16
|
34 struct result<This(A0, Context)>
|
Chris@16
|
35 {
|
Chris@16
|
36 typedef typename detail::result_of::target<A0> target_type;
|
Chris@16
|
37 typedef typename target_type::type * type;
|
Chris@16
|
38 };
|
Chris@16
|
39
|
Chris@16
|
40 template <typename Target, typename Context>
|
Chris@16
|
41 typename detail::result_of::target<Target>::type *
|
Chris@16
|
42 operator()(Target, Context const &) const
|
Chris@16
|
43 {
|
Chris@16
|
44 return new typename detail::result_of::target<Target>::type;
|
Chris@16
|
45 }
|
Chris@16
|
46
|
Chris@16
|
47 // Bring in the rest
|
Chris@16
|
48 #include <boost/phoenix/object/detail/new_eval.hpp>
|
Chris@16
|
49 };
|
Chris@16
|
50
|
Chris@16
|
51 template <typename Dummy>
|
Chris@16
|
52 struct default_actions::when<rule::new_, Dummy>
|
Chris@16
|
53 : call<new_eval, Dummy>
|
Chris@16
|
54 {};
|
Chris@16
|
55
|
Chris@16
|
56 template <typename T>
|
Chris@16
|
57 inline
|
Chris@16
|
58 typename expression::new_<detail::target<T> >::type const
|
Chris@16
|
59 new_()
|
Chris@16
|
60 {
|
Chris@16
|
61 return
|
Chris@16
|
62 expression::
|
Chris@16
|
63 new_<detail::target<T> >::
|
Chris@16
|
64 make(detail::target<T>());
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 // Bring in the rest
|
Chris@16
|
68 #include <boost/phoenix/object/detail/new.hpp>
|
Chris@16
|
69 }}
|
Chris@16
|
70
|
Chris@16
|
71 #endif
|
Chris@16
|
72
|