// // common_iterator.h // stream // // Created by Sam Jaffe on 4/2/23. // #pragma once #include #include #include namespace stream::ranges { template class common_iterator : public proxy> { public: static_assert(!std::is_same_v, "cannot operator on common types"); using super_t = proxy>; using sentinel_type = common_iterator; public: using super_t::super_t; common_iterator(S) : super_t() {} SFINAE(super_t::category_enum == iterator::category::random_access) auto distance_to(common_iterator const & other) const { if (at_end()) { return other.at_end() ? 0 : -(S() - other); } else if (other.at_end()) { return S() - *this; } else { return super_t::distance_to(other); } } bool equal_to(common_iterator const & other) const { return (at_end() && other.at_end()) || super_t::impl() == other.impl(); } bool at_end() const { return super_t::impl() == S(); } }; } MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::common_iterator); #include