1 /*============================================================================= 2 Copyright (c) 2001-2011 Joel de Guzman 3 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 #if !defined(FUSION_COPY_02162011_2308) 8 #define FUSION_COPY_02162011_2308 9 10 #include <boost/fusion/support/config.hpp> 11 #include <boost/fusion/sequence/intrinsic/begin.hpp> 12 #include <boost/fusion/sequence/intrinsic/end.hpp> 13 #include <boost/fusion/sequence/intrinsic/size.hpp> 14 #include <boost/fusion/sequence/comparison/detail/equal_to.hpp> 15 #include <boost/fusion/support/is_sequence.hpp> 16 #include <boost/config.hpp> 17 #include <boost/static_assert.hpp> 18 #include <boost/utility/enable_if.hpp> 19 #include <boost/mpl/and.hpp> 20 21 #if defined (BOOST_MSVC) 22 # pragma warning(push) 23 # pragma warning (disable: 4100) // unreferenced formal parameter 24 #endif 25 26 namespace boost { namespace fusion 27 { 28 namespace detail 29 { 30 template <typename Seq1, typename Seq2> 31 struct sequence_copy 32 { 33 typedef typename result_of::end<Seq1>::type end1_type; 34 typedef typename result_of::end<Seq2>::type end2_type; 35 36 template <typename I1, typename I2> 37 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED 38 static void callboost::fusion::detail::sequence_copy39 call(I1 const&, I2 const&, mpl::true_) 40 { 41 } 42 43 template <typename I1, typename I2> 44 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED 45 static void callboost::fusion::detail::sequence_copy46 call(I1 const& src, I2 const& dest, mpl::false_) 47 { 48 *dest = *src; 49 call(fusion::next(src), fusion::next(dest)); 50 } 51 52 template <typename I1, typename I2> 53 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED 54 static void callboost::fusion::detail::sequence_copy55 call(I1 const& src, I2 const& dest) 56 { 57 typename result_of::equal_to<I1, end1_type>::type eq; 58 return call(src, dest, eq); 59 } 60 }; 61 } 62 63 namespace result_of 64 { 65 template <typename Seq1, typename Seq2> 66 struct copy 67 : enable_if<mpl::and_< 68 traits::is_sequence<Seq1>, 69 traits::is_sequence<Seq2> 70 > > {}; 71 } 72 73 template <typename Seq1, typename Seq2> 74 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED 75 inline typename result_of::copy<Seq1 const, Seq2>::type copy(Seq1 const & src,Seq2 & dest)76 copy(Seq1 const& src, Seq2& dest) 77 { 78 BOOST_STATIC_ASSERT( 79 result_of::size<Seq1>::value <= result_of::size<Seq2>::value); 80 81 detail::sequence_copy< 82 Seq1 const, Seq2>:: 83 call(fusion::begin(src), fusion::begin(dest)); 84 } 85 }} 86 87 #if defined (BOOST_MSVC) 88 # pragma warning(pop) 89 #endif 90 91 #endif 92