| 123456789101112131415161718192021222324252627282930313233 |
- //
- // common_iterator.h
- // stream
- //
- // Created by Sam Jaffe on 4/2/23.
- //
- #pragma once
- #include <iterator/proxy.h>
- #include <stream/forward.h>
- namespace stream::ranges {
- template <typename It, typename S>
- class common_iterator : public proxy<It, common_iterator<It, S>> {
- public:
- static_assert(!std::is_same_v<It, S>, "cannot operator on common types");
- using super_t = proxy<It, common_iterator<It, S>>;
- using sentinel_type = common_iterator;
- public:
- using super_t::super_t;
- common_iterator(S) : super_t() {}
- 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);
|