epoc32/include/stdapis/boost/multi_array/index_gen.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/index_gen.hpp	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,81 @@
     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 BOOST_INDEX_GEN_RG071801_HPP
    1.17 +#define BOOST_INDEX_GEN_RG071801_HPP
    1.18 +
    1.19 +#include "boost/array.hpp"
    1.20 +#include "boost/multi_array/index_range.hpp"
    1.21 +#include "boost/multi_array/range_list.hpp"
    1.22 +#include "boost/multi_array/types.hpp"
    1.23 +#include <algorithm> 
    1.24 +#include <cstddef>
    1.25 +
    1.26 +namespace boost {
    1.27 +namespace detail {
    1.28 +namespace multi_array {
    1.29 +
    1.30 +
    1.31 +template <int NumRanges, int NumDims>
    1.32 +struct index_gen {
    1.33 +private:
    1.34 +  typedef ::boost::detail::multi_array::index index;
    1.35 +  typedef ::boost::detail::multi_array::size_type size_type;
    1.36 +  typedef index_range<index,size_type> range;
    1.37 +public:
    1.38 +  template <int Dims, int Ranges>
    1.39 +  struct gen_type {
    1.40 +    typedef index_gen<Ranges,Dims> type;
    1.41 +  };
    1.42 +
    1.43 +  typedef typename range_list_generator<range,NumRanges>::type range_list;
    1.44 +  range_list ranges_;
    1.45 +
    1.46 +  index_gen() { }
    1.47 +
    1.48 +  template <int ND>
    1.49 +  explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
    1.50 +            const range& r)
    1.51 +  {
    1.52 +    std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
    1.53 +    *ranges_.rbegin() = r;
    1.54 +  }
    1.55 +
    1.56 +  index_gen<NumRanges+1,NumDims+1>
    1.57 +  operator[](const range& r) const
    1.58 +  {
    1.59 +    index_gen<NumRanges+1,NumDims+1> tmp;
    1.60 +    std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
    1.61 +    *tmp.ranges_.rbegin() = r;
    1.62 +    return tmp;
    1.63 +  }
    1.64 +
    1.65 +  index_gen<NumRanges+1,NumDims>
    1.66 +  operator[](index idx) const
    1.67 +  {
    1.68 +    index_gen<NumRanges+1,NumDims> tmp;
    1.69 +    std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
    1.70 +    *tmp.ranges_.rbegin() = range(idx);
    1.71 +    return tmp;
    1.72 +  }    
    1.73 +
    1.74 +  static index_gen<0,0> indices() {
    1.75 +    return index_gen<0,0>();
    1.76 +  }
    1.77 +};
    1.78 +
    1.79 +} // namespace multi_array
    1.80 +} // namespace detail
    1.81 +} // namespace boost
    1.82 +
    1.83 +
    1.84 +#endif // BOOST_INDEX_GEN_RG071801_HPP