File indexing completed on 2025-01-18 09:50:32
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef BOOST_PROTO_DEEP_COPY_HPP_EAN_11_21_2006
0010 #define BOOST_PROTO_DEEP_COPY_HPP_EAN_11_21_2006
0011
0012 #include <boost/preprocessor/cat.hpp>
0013 #include <boost/preprocessor/repetition/enum.hpp>
0014 #include <boost/preprocessor/iteration/iterate.hpp>
0015 #include <boost/mpl/if.hpp>
0016 #include <boost/type_traits/remove_reference.hpp>
0017 #include <boost/proto/proto_fwd.hpp>
0018 #include <boost/proto/args.hpp>
0019 #include <boost/proto/expr.hpp>
0020
0021 namespace boost { namespace proto
0022 {
0023 namespace detail
0024 {
0025 template<typename Expr, long Arity = Expr::proto_arity_c>
0026 struct deep_copy_impl;
0027
0028 template<typename Expr>
0029 struct deep_copy_impl<Expr, 0>
0030 {
0031 typedef
0032 typename base_expr<
0033 typename Expr::proto_domain
0034 , tag::terminal
0035 , term<typename term_traits<typename Expr::proto_child0>::value_type>
0036 >::type
0037 expr_type;
0038
0039 typedef typename Expr::proto_generator proto_generator;
0040 typedef typename proto_generator::template result<proto_generator(expr_type)>::type result_type;
0041
0042 template<typename Expr2, typename S, typename D>
0043 result_type operator()(Expr2 const &e, S const &, D const &) const
0044 {
0045 return proto_generator()(expr_type::make(e.proto_base().child0));
0046 }
0047 };
0048 }
0049
0050 namespace result_of
0051 {
0052
0053
0054
0055
0056
0057
0058
0059
0060 template<typename Expr>
0061 struct deep_copy
0062 {
0063 typedef
0064 typename detail::deep_copy_impl<
0065 BOOST_PROTO_UNCVREF(Expr)
0066 >::result_type
0067 type;
0068 };
0069 }
0070
0071 namespace functional
0072 {
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 struct deep_copy
0086 {
0087 BOOST_PROTO_CALLABLE()
0088
0089 template<typename Sig>
0090 struct result;
0091
0092 template<typename This, typename Expr>
0093 struct result<This(Expr)>
0094 {
0095 typedef
0096 typename detail::deep_copy_impl<
0097 BOOST_PROTO_UNCVREF(Expr)
0098 >::result_type
0099 type;
0100 };
0101
0102
0103
0104
0105 template<typename Expr>
0106 typename result_of::deep_copy<Expr>::type
0107 operator()(Expr const &e) const
0108 {
0109 return proto::detail::deep_copy_impl<Expr>()(e, 0, 0);
0110 }
0111 };
0112 }
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126 template<typename Expr>
0127 typename proto::result_of::deep_copy<Expr>::type
0128 deep_copy(Expr const &e)
0129 {
0130 return proto::detail::deep_copy_impl<Expr>()(e, 0, 0);
0131 }
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145 struct _deep_copy
0146 : proto::transform<_deep_copy>
0147 {
0148 template<typename E, typename S, typename D>
0149 struct impl
0150 : detail::deep_copy_impl<BOOST_PROTO_UNCVREF(E)>
0151 {};
0152 };
0153
0154 namespace detail
0155 {
0156
0157 #include <boost/proto/detail/deep_copy.hpp>
0158 }
0159
0160 }}
0161
0162 #endif
0163