annotate DEPENDENCIES/generic/include/boost/multi_array/copy_array.hpp @ 125:34e428693f5d vext

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