6 #ifndef ECHELON_HDF5_RANGE_HPP 7 #define ECHELON_HDF5_RANGE_HPP 9 #include <echelon/utility/macros.hpp> 12 #include <type_traits> 18 template <
typename Base,
typename Bound>
22 range_t(Base base_, Bound bound_, hsize_t stride_ = 1)
23 : base_(base_), bound_(bound_), stride_(stride_)
27 template <
typename OtherBase,
typename OtherBound,
28 typename Dummy =
typename std::enable_if<std::is_convertible<
29 Base, OtherBase>::value&& std::is_convertible<Bound, OtherBound>::value>::type>
30 range_t(range_t<OtherBase, OtherBound> other)
31 : base_(other.base()), bound_(other.bound()), stride_(other.stride())
45 hsize_t stride()
const 62 template <
typename Base,
typename Bound>
63 inline range_t<Base, Bound>
range(Base base, Bound bound, hsize_t stride = 1)
65 return range_t<Base, Bound>{base, bound, stride};
68 typedef range_t<hsize_t, hsize_t> totally_bound_range_t;
74 static const unbound_t _ = {};
79 template <std::size_t I,
typename... Args>
80 struct calculate_slice_boundaries;
82 template <std::
size_t I>
83 struct calculate_slice_boundaries<I>
85 static void eval(
const std::vector<hsize_t>&, std::vector<totally_bound_range_t>&)
90 template <std::size_t I,
typename Front,
typename... Tail>
91 struct calculate_slice_boundaries<I, Front, Tail...>
93 static void eval(
const std::vector<hsize_t>& current_shape,
94 std::vector<totally_bound_range_t>& boundaries, Front front, Tail... tail)
96 boundaries.push_back(get_boundaries(current_shape[I], front));
98 calculate_slice_boundaries<I + 1, Tail...>::eval(current_shape, boundaries, tail...);
102 static totally_bound_range_t get_boundaries(hsize_t extend, unbound_t)
104 return range(0, extend);
107 template <
typename Base>
108 static totally_bound_range_t get_boundaries(hsize_t extend, range_t<Base, unbound_t> r)
112 return range(r.base(), extend);
115 template <
typename Bound>
116 static totally_bound_range_t get_boundaries(hsize_t, range_t<unbound_t, Bound> r)
120 return range(0, r.bound());
123 template <
typename Base,
typename Bound>
124 static totally_bound_range_t get_boundaries(hsize_t, range_t<Base, Bound> r)
126 static_assert(std::is_integral<Base>::value && std::is_integral<Bound>::value,
127 "only integral values are allowed in slicing expressions");
134 template <
typename T>
135 static totally_bound_range_t get_boundaries(hsize_t ECHELON_UNUSED_RELEASE(extend), T value)
137 static_assert(std::is_integral<T>::value,
138 "only integral values are allowed in slicing expressions");
140 assert(value < extend);
142 return range(value, value + 1);
echelon's core namespace
Definition: attribute.cpp:10
range_t< Base, Bound > range(Base base, Bound bound, hsize_t stride=1)
Constructs an index range.
Definition: hdf5/range.hpp:63