construct.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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_CONSTRUCT_HPP
  8. #define BOOST_PHOENIX_OBJECT_CONSTRUCT_HPP
  9. #include <boost/phoenix/core/limits.hpp>
  10. #include <boost/phoenix/core/call.hpp>
  11. #include <boost/phoenix/core/expression.hpp>
  12. #include <boost/phoenix/core/meta_grammar.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/construct_expr.hpp>
  18. #else
  19. BOOST_PHOENIX_DEFINE_EXPRESSION_VARARG(
  20. (boost)(phoenix)(construct)
  21. , (proto::terminal<detail::target<proto::_> >)
  22. (meta_grammar)
  23. , _
  24. )
  25. #endif
  26. namespace boost { namespace phoenix
  27. {
  28. struct construct_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. : detail::result_of::target<A0>
  36. {
  37. };
  38. template <typename Target, typename Context>
  39. typename detail::result_of::target<Target>::type
  40. operator()(Target, Context const &) const
  41. {
  42. return typename detail::result_of::target<Target>::type();
  43. }
  44. // Bring in the rest
  45. #include <boost/phoenix/object/detail/cpp03/construct_eval.hpp>
  46. #else
  47. // TODO:
  48. #endif
  49. };
  50. template <typename Dummy>
  51. struct default_actions::when<rule::construct, Dummy>
  52. : call<construct_eval, Dummy>
  53. {};
  54. #if defined(BOOST_PHOENIX_NO_VARIADIC_OBJECT)
  55. template <typename T>
  56. inline
  57. typename expression::construct<detail::target<T> >::type const
  58. construct()
  59. {
  60. return
  61. expression::
  62. construct<detail::target<T> >::
  63. make(detail::target<T>());
  64. }
  65. // Bring in the rest
  66. #include <boost/phoenix/object/detail/cpp03/construct.hpp>
  67. #else
  68. // TODO:
  69. #endif
  70. }}
  71. #endif