| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- //
- // iota.h
- // stream
- //
- // Created by Sam Jaffe on 3/29/23.
- //
- #pragma once
- #include <stream/forward.h>
- #include <stream/iterator/iota_iterator.h>
- #include <stream/view/interface.h>
- #include <stream/detail/macro.h>
- namespace stream::ranges {
- template <typename T, typename Bound>
- struct iota_view : public view_interface<iota_view<T, Bound>,
- iota_iterator<T, Bound>, Bound> {
- private:
- T value_;
- Bound bound_;
- public:
- iota_view(T value, Bound bound) : value_(value), bound_(bound) {}
- auto begin() const { return iota_iterator<T, Bound>(value_); }
- auto end() const { return bound_; }
- };
- template <typename T>
- struct iota_view<T, T>
- : public view_interface<iota_view<T, T>, iota_iterator<T, T>> {
- private:
- T value_;
- T bound_;
- public:
- iota_view(T value, T bound) : value_(value), bound_(bound) {}
- auto begin() const { return iota_iterator<T, T>(value_); }
- auto end() const { return iota_iterator<T, T>(bound_); }
- };
- }
- namespace stream::ranges::views {
- template <typename T, typename Bound> auto iota(T value, Bound bound) {
- return iota_view(value, bound);
- }
- }
- MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::iota_iterator);
- #include <stream/detail/undef.h>
|