1 // Copyright 2002 The Trustees of Indiana University.
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)
7 // Boost.MultiArray Library
8 // Authors: Ronald Garcia
11 // See http://www.boost.org/libs/multi_array for documentation.
13 #ifndef BOOST_INDEX_GEN_RG071801_HPP
14 #define BOOST_INDEX_GEN_RG071801_HPP
16 #include "boost/array.hpp"
17 #include "boost/multi_array/index_range.hpp"
18 #include "boost/multi_array/range_list.hpp"
19 #include "boost/multi_array/types.hpp"
25 namespace multi_array {
28 template <int NumRanges, int NumDims>
31 typedef ::boost::detail::multi_array::index Index;
32 typedef std::size_t SizeType;
33 typedef index_range<Index,SizeType> range;
35 template <int Dims, int Ranges>
37 typedef index_gen<Ranges,Dims> type;
40 typedef typename range_list_generator<range,NumRanges>::type range_list;
46 explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
47 const index_range<Index,SizeType>& range)
49 std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
50 *ranges_.rbegin() = range;
53 index_gen<NumRanges+1,NumDims+1>
54 operator[](const index_range<Index,SizeType>& range) const
56 index_gen<NumRanges+1,NumDims+1> tmp;
57 std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
58 *tmp.ranges_.rbegin() = range;
62 index_gen<NumRanges+1,NumDims>
63 operator[](Index idx) const
65 index_gen<NumRanges+1,NumDims> tmp;
66 std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
67 *tmp.ranges_.rbegin() = index_range<Index,SizeType>(idx);
71 static index_gen<0,0> indices() {
72 return index_gen<0,0>();
76 } // namespace multi_array
81 #endif // BOOST_INDEX_GEN_RG071801_HPP