63 #include <type_traits> 81 , total_size_(begin < end && n_workers ? end - begin : 0)
82 , quot_(n_workers ? total_size_ / n_workers : 0)
83 , rem_(n_workers ? total_size_ % n_workers : 0) {
84 static_assert(std::is_integral<T>::value);
88 class Iterator :
public std::iterator<std::input_iterator_tag, Interval<T>> {
97 return {begin_,
T(begin_ + quot_ +
bool(rem_)),
index};
100 begin_ += quot_ + (rem_ && rem_--);
107 bool empty()
const {
return !total_size_; }
109 Iterator end()
const {
return {
static_cast<T>(begin_ + total_size_), quot_, 0}; }
110 template <
typename T1,
typename U1>
116 if constexpr (
sizeof(U) <
sizeof(std::size_t)) {
117 if (std::numeric_limits<U>::max() < n_workers) {
118 n_workers = std::numeric_limits<U>::max();
121 return {
begin,
end,
static_cast<U
>(n_workers)};
Interval< T > operator*() const
bool operator==(Iterator const &rhs) const
Intervals< T > makeIntervals(T begin, T end, std::size_t n_workers)
Intervals(T begin, T end, U n_workers)
Iterator(T begin, U quot, U rem)
bool operator!=(Iterator const &rhs) const