File indexing completed on 2025-01-18 09:42:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_MULTI_ARRAY_COPY_ARRAY_HPP
0014 #define BOOST_MULTI_ARRAY_COPY_ARRAY_HPP
0015
0016
0017
0018
0019
0020
0021 #include "boost/type.hpp"
0022 #include "boost/assert.hpp"
0023
0024 namespace boost {
0025 namespace detail {
0026 namespace multi_array {
0027
0028 template <typename Element>
0029 class copy_dispatch {
0030 public:
0031 template <typename SourceIterator, typename DestIterator>
0032 static void copy_array (SourceIterator first, SourceIterator last,
0033 DestIterator result) {
0034 while (first != last) {
0035 copy_array(*first++,*result++);
0036 }
0037 }
0038 private:
0039
0040
0041 template <typename Array1, typename Array2>
0042 static void copy_array (const Array1& source, Array2 dest) {
0043 copy_array(source.begin(),source.end(),dest.begin());
0044 }
0045
0046 static void copy_array (const Element& source, Element& dest) {
0047 dest = source;
0048 }
0049
0050 };
0051
0052
0053 template <typename Array1, typename Array2>
0054 void copy_array (Array1& source, Array2& dest) {
0055 BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
0056 dest.shape()));
0057
0058 typedef typename Array1::element element_type;
0059 copy_dispatch<element_type>::
0060 copy_array(source.begin(),source.end(),dest.begin());
0061 }
0062
0063
0064 }
0065 }
0066 }
0067
0068 #endif