deep_copy.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES)
  2. #include <boost/proto/detail/preprocessed/deep_copy.hpp>
  3. #elif !defined(BOOST_PP_IS_ITERATING)
  4. #define BOOST_PROTO_DEFINE_DEEP_COPY_TYPE(Z, N, DATA) \
  5. typename deep_copy_impl< \
  6. typename remove_reference< \
  7. typename Expr::BOOST_PP_CAT(proto_child, N) \
  8. >::type::proto_derived_expr \
  9. >::result_type \
  10. /**/
  11. #define BOOST_PROTO_DEFINE_DEEP_COPY_FUN(Z, N, DATA) \
  12. proto::deep_copy(e.proto_base().BOOST_PP_CAT(child, N)) \
  13. /**/
  14. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  15. #pragma wave option(preserve: 2, line: 0, output: "preprocessed/deep_copy.hpp")
  16. #endif
  17. ///////////////////////////////////////////////////////////////////////////////
  18. /// \file deep_copy.hpp
  19. /// Replace all nodes stored by reference by nodes stored by value.
  20. //
  21. // Copyright 2008 Eric Niebler. Distributed under the Boost
  22. // Software License, Version 1.0. (See accompanying file
  23. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  24. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  25. #pragma wave option(preserve: 1)
  26. #endif
  27. #define BOOST_PP_ITERATION_PARAMS_1 \
  28. (3, (1, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/deep_copy.hpp>))
  29. #include BOOST_PP_ITERATE()
  30. #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)
  31. #pragma wave option(output: null)
  32. #endif
  33. #undef BOOST_PROTO_DEFINE_DEEP_COPY_FUN
  34. #undef BOOST_PROTO_DEFINE_DEEP_COPY_TYPE
  35. #else
  36. #define N BOOST_PP_ITERATION()
  37. template<typename Expr>
  38. struct deep_copy_impl<Expr, N>
  39. {
  40. typedef
  41. typename base_expr<
  42. typename Expr::proto_domain
  43. , typename Expr::proto_tag
  44. , BOOST_PP_CAT(list, N)<
  45. BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_TYPE, ~)
  46. >
  47. >::type
  48. expr_type;
  49. typedef typename Expr::proto_generator proto_generator;
  50. typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
  51. template<typename Expr2, typename S, typename D>
  52. result_type operator()(Expr2 const &e, S const &, D const &) const
  53. {
  54. expr_type const that = {
  55. BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_DEEP_COPY_FUN, ~)
  56. };
  57. return proto_generator()(that);
  58. }
  59. };
  60. #undef N
  61. #endif