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