epoc32/include/stdapis/boost/multi_array/copy_array.hpp
branchSymbian2
changeset 2 2fe1408b6811
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/boost/multi_array/copy_array.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,68 @@
     1.4 +// Copyright 2002 The Trustees of Indiana University.
     1.5 +
     1.6 +// Use, modification and distribution is subject to the Boost Software 
     1.7 +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
     1.8 +// http://www.boost.org/LICENSE_1_0.txt)
     1.9 +
    1.10 +//  Boost.MultiArray Library
    1.11 +//  Authors: Ronald Garcia
    1.12 +//           Jeremy Siek
    1.13 +//           Andrew Lumsdaine
    1.14 +//  See http://www.boost.org/libs/multi_array for documentation.
    1.15 +
    1.16 +#ifndef COPY_ARRAY_RG092101_HPP
    1.17 +#define COPY_ARRAY_RG092101_HPP
    1.18 +
    1.19 +//
    1.20 +// copy_array.hpp - generic code for copying the contents of one
    1.21 +// Basic_MultiArray to another.  We assume that they are of the same
    1.22 +// shape
    1.23 +//
    1.24 +#include "boost/type.hpp"
    1.25 +#include <cassert>
    1.26 +
    1.27 +namespace boost {
    1.28 +namespace detail {
    1.29 +namespace multi_array {
    1.30 +
    1.31 +template <typename Element>
    1.32 +class copy_dispatch {
    1.33 +public:
    1.34 +  template <typename SourceIterator, typename DestIterator>
    1.35 +  static void copy_array (SourceIterator first, SourceIterator last,
    1.36 +                   DestIterator result) {
    1.37 +    while (first != last) {
    1.38 +      copy_array(*first++,*result++);
    1.39 +    }
    1.40 +  }
    1.41 +private:
    1.42 +  // Array2 has to be passed by VALUE here because subarray
    1.43 +  // pseudo-references are temporaries created by iterator::operator*()
    1.44 +  template <typename Array1, typename Array2>
    1.45 +  static void copy_array (const Array1& source, Array2 dest) {
    1.46 +    copy_array(source.begin(),source.end(),dest.begin());
    1.47 +  }
    1.48 +
    1.49 +  static void copy_array (const Element& source, Element& dest) {
    1.50 +    dest = source;
    1.51 +  }
    1.52 +
    1.53 +};
    1.54 +
    1.55 +
    1.56 +template <typename Array1, typename Array2>
    1.57 +void copy_array (Array1& source, Array2& dest) {
    1.58 +  assert(std::equal(source.shape(),source.shape()+source.num_dimensions(),
    1.59 +                    dest.shape()));
    1.60 +  // Dispatch to the proper function
    1.61 +  typedef typename Array1::element element_type;
    1.62 +  copy_dispatch<element_type>::
    1.63 +    copy_array(source.begin(),source.end(),dest.begin());
    1.64 +}
    1.65 +
    1.66 +
    1.67 +} // namespace multi_array
    1.68 +} // namespace detail
    1.69 +} // namespace boost
    1.70 +
    1.71 +#endif // COPY_ARRAY_RG092101_HPP