// // iota.h // stream // // Created by Sam Jaffe on 3/29/23. // #pragma once #include #include #include namespace stream::ranges { template struct iota_view { public: constexpr static inline bool has_size_v = std::is_constructible_v; private: T value_; Bound bound_; public: iota_view(T value, Bound bound) : value_(value), bound_(bound) {} auto begin() const { return iota_iterator(value_, bound_); } auto end() const { if constexpr (has_size_v) { return iota_iterator(bound_, bound_); } else { return bound_; } } bool empty() const { return begin().at_end(); } SFINAE(has_size_v, size_t) size() const { return begin().distance_to(end()); } }; } namespace stream::ranges::views { template auto iota(T value, Bound bound) { return iota_view(value, bound); } } MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::iota_iterator); #include