Chris@16: /////////////////////////////////////////////////////////////////////////////// Chris@16: /// \file deep_copy.hpp Chris@16: /// Replace all nodes stored by reference by nodes stored by value. Chris@16: // Chris@16: // Copyright 2008 Eric Niebler. Distributed under the Boost Chris@16: // Software License, Version 1.0. (See accompanying file Chris@16: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list1< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list2< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list3< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list4< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list5< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list6< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child5 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) , proto::deep_copy(e.proto_base().child5) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list7< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child5 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child6 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) , proto::deep_copy(e.proto_base().child5) , proto::deep_copy(e.proto_base().child6) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list8< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child5 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child6 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child7 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) , proto::deep_copy(e.proto_base().child5) , proto::deep_copy(e.proto_base().child6) , proto::deep_copy(e.proto_base().child7) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list9< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child5 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child6 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child7 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child8 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) , proto::deep_copy(e.proto_base().child5) , proto::deep_copy(e.proto_base().child6) , proto::deep_copy(e.proto_base().child7) , proto::deep_copy(e.proto_base().child8) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: }; Chris@16: template Chris@16: struct deep_copy_impl Chris@16: { Chris@16: typedef Chris@16: typename base_expr< Chris@16: typename Expr::proto_domain Chris@16: , typename Expr::proto_tag Chris@16: , list10< Chris@16: typename deep_copy_impl< typename remove_reference< typename Expr::proto_child0 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child1 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child2 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child3 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child4 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child5 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child6 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child7 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child8 >::type::proto_derived_expr >::result_type , typename deep_copy_impl< typename remove_reference< typename Expr::proto_child9 >::type::proto_derived_expr >::result_type Chris@16: > Chris@16: >::type Chris@16: expr_type; Chris@16: typedef typename Expr::proto_generator proto_generator; Chris@16: typedef typename proto_generator::template result::type result_type; Chris@16: template Chris@16: result_type operator()(Expr2 const &e, S const &, D const &) const Chris@16: { Chris@16: expr_type const that = { Chris@16: proto::deep_copy(e.proto_base().child0) , proto::deep_copy(e.proto_base().child1) , proto::deep_copy(e.proto_base().child2) , proto::deep_copy(e.proto_base().child3) , proto::deep_copy(e.proto_base().child4) , proto::deep_copy(e.proto_base().child5) , proto::deep_copy(e.proto_base().child6) , proto::deep_copy(e.proto_base().child7) , proto::deep_copy(e.proto_base().child8) , proto::deep_copy(e.proto_base().child9) Chris@16: }; Chris@16: return proto_generator()(that); Chris@16: } Chris@16: };