]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/multi_array/copy_array.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / multi_array / copy_array.hpp
1 // Copyright 2002 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
9 // Jeremy Siek
10 // Andrew Lumsdaine
11 // See http://www.boost.org/libs/multi_array for documentation.
12
13 #ifndef COPY_ARRAY_RG092101_HPP
14 #define COPY_ARRAY_RG092101_HPP
15
16 //
17 // copy_array.hpp - generic code for copying the contents of one
18 // Basic_MultiArray to another. We assume that they are of the same
19 // shape
20 //
21 #include "boost/type.hpp"
22 #include "boost/assert.hpp"
23
24 namespace boost {
25 namespace detail {
26 namespace multi_array {
27
28 template <typename Element>
29 class copy_dispatch {
30 public:
31 template <typename SourceIterator, typename DestIterator>
32 static void copy_array (SourceIterator first, SourceIterator last,
33 DestIterator result) {
34 while (first != last) {
35 copy_array(*first++,*result++);
36 }
37 }
38 private:
39 // Array2 has to be passed by VALUE here because subarray
40 // pseudo-references are temporaries created by iterator::operator*()
41 template <typename Array1, typename Array2>
42 static void copy_array (const Array1& source, Array2 dest) {
43 copy_array(source.begin(),source.end(),dest.begin());
44 }
45
46 static void copy_array (const Element& source, Element& dest) {
47 dest = source;
48 }
49
50 };
51
52
53 template <typename Array1, typename Array2>
54 void copy_array (Array1& source, Array2& dest) {
55 BOOST_ASSERT(std::equal(source.shape(),source.shape()+source.num_dimensions(),
56 dest.shape()));
57 // Dispatch to the proper function
58 typedef typename Array1::element element_type;
59 copy_dispatch<element_type>::
60 copy_array(source.begin(),source.end(),dest.begin());
61 }
62
63
64 } // namespace multi_array
65 } // namespace detail
66 } // namespace boost
67
68 #endif // COPY_ARRAY_RG092101_HPP