1 #ifndef COPY_ARRAY_RG092101_HPP
2 #define COPY_ARRAY_RG092101_HPP
5 // copy_array.hpp - generic code for copying the contents of one
6 // Basic_MultiArray to another. We assume that they are of the same
9 #include "boost/type.hpp"
14 namespace multi_array {
16 template <typename Element>
19 template <typename SourceIterator, typename DestIterator>
20 static void copy_array (SourceIterator first, SourceIterator last,
21 DestIterator result) {
22 while (first != last) {
23 copy_array(*first++,*result++);
27 // Array2 has to be passed by VALUE here because subarray
28 // pseudo-references are temporaries created by iterator::operator*()
29 template <typename Array1, typename Array2>
30 static void copy_array (const Array1& source, Array2 dest) {
31 copy_array(source.begin(),source.end(),dest.begin());
34 static void copy_array (const Element& source, Element& dest) {
41 template <typename Array1, typename Array2>
42 void copy_array (Array1& source, Array2& dest) {
43 assert(std::equal(source.shape(),source.shape()+source.num_dimensions(),
45 // Dispatch to the proper function
46 typedef typename Array1::element element_type;
47 copy_dispatch<element_type>::
48 copy_array(source.begin(),source.end(),dest.begin());
52 } // namespace multi_array
56 #endif // COPY_ARRAY_RG092101_HPP