| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- //
- // iota_iterator.h
- // stream
- //
- // Created by Sam Jaffe on 4/6/23.
- //
- #pragma once
- #include <iterator/facade.h>
- #include <stream/forward.h>
- namespace stream::ranges {
- template <typename T, typename Bound>
- class iota_iterator
- : public facade<iota_iterator<T, Bound>, iterator::category::forward> {
- public:
- using sentinal_type = Bound;
- iota_iterator() = default;
- iota_iterator(T value, Bound bound) : value_(value), bound_(bound) {}
- T dereference() const { return value_; }
- void increment() { ++value_; }
- bool at_end() const { return value_ == bound_; }
- // Some weird bug in dependent template instantiation???
- bool equal_to(iota_iterator const & other) const {
- return value_ == other.value_;
- }
- std::ptrdiff_t distance_to(iota_iterator const & other) const {
- return other.value_ - value_;
- }
- private:
- T value_;
- Bound bound_;
- };
- }
|