new.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*==============================================================================
  2. Copyright (c) 2001-2010 Joel de Guzman
  3. Copyright (c) 2010 Thomas Heller
  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_OBJECT_NEW_HPP
  8. #define BOOST_PHOENIX_OBJECT_NEW_HPP
  9. #include <boost/phoenix/core/limits.hpp>
  10. #include <boost/phoenix/core/expression.hpp>
  11. #include <boost/phoenix/core/meta_grammar.hpp>
  12. #include <boost/phoenix/core/call.hpp>
  13. #include <boost/phoenix/object/detail/target.hpp>
  14. #include <boost/phoenix/support/iterate.hpp>
  15. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  16. #ifdef BOOST_PHOENIX_NO_VARIADIC_EXPRESSION
  17. # include <boost/phoenix/object/detail/cpp03/new_expr.hpp>
  18. #else
  19. BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG(
  20. (boost)(phoenix)(new_)
  21. , (proto::terminal<detail::target<proto::_> >)
  22. (meta_grammar)
  23. , _
  24. )
  25. #endif
  26. namespace boost { namespace phoenix
  27. {
  28. struct new_eval
  29. {
  30. template <typename Sig>
  31. struct result;
  32. #if defined(BOOST_PHOENIX_NO_VARIADIC_OBJECT)
  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. template <typename Target, typename Context>
  40. typename detail::result_of::target<Target>::type *
  41. operator()(Target, Context const &) const
  42. {
  43. return new typename detail::result_of::target<Target>::type;
  44. }
  45. // Bring in the rest
  46. #include <boost/phoenix/object/detail/cpp03/new_eval.hpp>
  47. #else
  48. // TODO:
  49. #endif
  50. };
  51. template <typename Dummy>
  52. struct default_actions::when<rule::new_, Dummy>
  53. : call<new_eval, Dummy>
  54. {};
  55. #if defined(BOOST_PHOENIX_NO_VARIADIC_OBJECT)
  56. template <typename T>
  57. inline
  58. typename expression::new_<detail::target<T> >::type const
  59. new_()
  60. {
  61. return
  62. expression::
  63. new_<detail::target<T> >::
  64. make(detail::target<T>());
  65. }
  66. // Bring in the rest
  67. #include <boost/phoenix/object/detail/cpp03/new.hpp>
  68. #else
  69. // TODO:
  70. #endif
  71. }}
  72. #endif