1 #ifndef BOOST_INDEX_GEN_RG071801_HPP
2 #define BOOST_INDEX_GEN_RG071801_HPP
4 #include "boost/array.hpp"
5 #include "boost/multi_array/index_range.hpp"
6 #include "boost/multi_array/range_list.hpp"
7 #include "boost/multi_array/types.hpp"
13 namespace multi_array {
16 template <int NumRanges, int NumDims>
20 typedef std::size_t SizeType;
21 typedef index_range<Index,SizeType> range;
23 template <int Dims, int Ranges>
25 typedef index_gen<Ranges,Dims> type;
28 typedef typename range_list_generator<range,NumRanges>::type range_list;
34 explicit index_gen(const index_gen<NumRanges-1,ND>& rhs,
35 const index_range<Index,SizeType>& range)
37 std::copy(rhs.ranges_.begin(),rhs.ranges_.end(),ranges_.begin());
38 *ranges_.rbegin() = range;
41 index_gen<NumRanges+1,NumDims+1>
42 operator[](const index_range<Index,SizeType>& range) const
44 index_gen<NumRanges+1,NumDims+1> tmp;
45 std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
46 *tmp.ranges_.rbegin() = range;
50 index_gen<NumRanges+1,NumDims>
51 operator[](Index idx) const
53 index_gen<NumRanges+1,NumDims> tmp;
54 std::copy(ranges_.begin(),ranges_.end(),tmp.ranges_.begin());
55 *tmp.ranges_.rbegin() = index_range<Index,SizeType>(idx);
59 static index_gen<0,0> indices() {
60 return index_gen<0,0>();
64 } // namespace multi_array
69 #endif // BOOST_INDEX_GEN_RG071801_HPP