DASH  0.3.0
IndexRange.h
1 #ifndef DASH__VIEW__INDEX_RANGE_H__INCLUDED
2 #define DASH__VIEW__INDEX_RANGE_H__INCLUDED
3 
4 #include <dash/Types.h>
5 #include <dash/Range.h>
6 
7 #include <array>
8 
9 
10 namespace dash {
11 
12 // N-dimensional index range
13 template <
14  dim_t NDim,
15  typename IndexType >
17 {
19 
20  // One-dimensional index range in every dimension:
21  std::array< IndexRange<1, IndexType>, NDim > _ranges;
22 
23 public:
24  template <dim_t SDim>
25  constexpr self_t sub(IndexType first, IndexType last) const {
26  return self_t(*this); // _ranges[SDim].sub(first, last)
27  }
28 };
29 
30 // Specialization for one-dimensional index range
31 template <
32  typename IndexType >
33 class IndexRange<1, IndexType>
34 {
36 
37  IndexType _first;
38  IndexType _last;
39 
40 public:
41  constexpr IndexRange(IndexType first, IndexType last)
42  : _first(first)
43  , _last(last)
44  { }
45 
46  template <typename RangeT>
47  explicit constexpr IndexRange(RangeT range)
48  : IndexRange(dash::begin(range),
49  dash::end(range))
50  { }
51 };
52 
53 } // namespace dash
54 
55 #endif // DASH__VIEW__INDEX_RANGE_H__INCLUDED
constexpr auto end(RangeType &&range) -> decltype(std::forward< RangeType >(range).end())
Definition: Range.h:98
This class is a simple memory pool which holds allocates elements of size ValueType.
Definition: AllOf.h:8
constexpr auto begin(RangeType &&range) -> decltype(std::forward< RangeType >(range).begin())
Definition: Range.h:89
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
Definition: Types.h:39
Returns second operand.
Definition: Operation.h:201