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 #ifdef BOOST_PHOENIX_NO_VARIADIC_EXPRESSION 20 # include <boost/phoenix/object/detail/cpp03/new_expr.hpp> 21 #else 22 BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG( 23 (boost)(phoenix)(new_) 24 , (proto::terminal<detail::target<proto::_> >) 25 (meta_grammar) 26 , _ 27 ) 28 #endif 29 30 namespace boost { namespace phoenix 31 { 32 struct new_eval 33 { 34 template <typename Sig> 35 struct result; 36 37 #if defined(BOOST_PHOENIX_NO_VARIADIC_OBJECT) 38 template <typename This, typename A0, typename Context> 39 struct result<This(A0, Context)> 40 { 41 typedef typename detail::result_of::target<A0> target_type; 42 typedef typename target_type::type * type; 43 }; 44 45 template <typename Target, typename Context> 46 typename detail::result_of::target<Target>::type * operator ()boost::phoenix::new_eval47 operator()(Target, Context const &) const 48 { 49 return new typename detail::result_of::target<Target>::type; 50 } 51 52 // Bring in the rest 53 #include <boost/phoenix/object/detail/cpp03/new_eval.hpp> 54 #else 55 // TODO: 56 #endif 57 }; 58 59 template <typename Dummy> 60 struct default_actions::when<rule::new_, Dummy> 61 : call<new_eval, Dummy> 62 {}; 63 64 #if defined(BOOST_PHOENIX_NO_VARIADIC_OBJECT) 65 template <typename T> 66 inline 67 typename expression::new_<detail::target<T> >::type const new_()68 new_() 69 { 70 return 71 expression:: 72 new_<detail::target<T> >:: 73 make(detail::target<T>()); 74 } 75 76 // Bring in the rest 77 #include <boost/phoenix/object/detail/cpp03/new.hpp> 78 #else 79 // TODO: 80 #endif 81 }} 82 83 #endif 84 85