/Src/Dependencies/Boost/boost/spirit/home/phoenix/object/new.hpp

http://hadesmem.googlecode.com/ · C++ Header · 80 lines · 61 code · 11 blank · 8 comment · 0 complexity · 8a76b50ce38febb0113f86e7040cdac7 MD5 · raw file

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