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