20 #include <type_traits> 26 template<
typename Integer>
30 static_assert(std::is_integral<Integer>::value,
"Range should only be used for integers.");
32 Range() : _begin(0), _end(0) { }
34 Range(Integer begin, Integer end) : _begin(begin), _end(end)
36 DCHECK_LE_F(begin, end);
39 struct iterator :
public std::iterator<std::input_iterator_tag, Integer>
43 explicit iterator(Integer v) : value(v) {}
45 Integer operator*()
const {
return value; }
55 return a.value != b.value;
59 Integer operator[](
size_t ix)
const {
return _begin + ix; }
64 Integer size()
const {
return _end - _begin; }
66 Integer front()
const {
return _begin; }
67 Integer back()
const {
return _end - 1; }
74 template<
typename Integer>
81 template<
typename Integer>
88 template<
typename Integer>
91 return {first, last + 1};
95 template<
typename Integer =
size_t,
typename Container>
98 return {0,
static_cast<Integer
>(container.size())};
103 template<
typename Integer,
typename Visitor>
104 void repeat(Integer count,
const Visitor& visitor)
106 CHECK_GE_F(count, static_cast<Integer>(0));
115 template<
typename It>
120 IteratorRange(It begin, It end) : _begin(begin), _end(end) { }
126 auto&& operator*()
const {
return *_it; }
127 auto&& operator->()
const {
return &*_it; }
137 return a._it != b._it;
141 iterator begin()
const {
return { _begin }; }
142 iterator end()
const {
return { _end }; }
144 bool empty()
const {
return _begin == _end; }
145 size_t size()
const {
return std::distance(_begin, _end); }
149 template<
typename It>
154 template<
typename Chr>
165 Chr operator*()
const {
return *_ptr; }
175 return *a._ptr != *b._ptr;
191 template<
typename Chr>
Definition: irange.hpp:155
Definition: irange.hpp:122
Definition: irange.hpp:161
Definition: irange.hpp:116
Definition: irange.hpp:27
Definition: irange.hpp:39
Definition: coroutine.hpp:18