|
|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
-#include <iterator/sentinel_iterator.h>
|
|
|
+#include <iterator/proxy.h>
|
|
|
#include <stream/detail/traits.h>
|
|
|
#include <stream/forward.h>
|
|
|
|
|
|
@@ -16,10 +16,27 @@
|
|
|
#define FWD(x) std::forward<decltype(x)>(x)
|
|
|
|
|
|
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(); }
|
|
|
+};
|
|
|
+
|
|
|
template <typename S> class common_view {
|
|
|
private:
|
|
|
- using iterator =
|
|
|
- iterator::sentinel_iterator<detail::begin_t<S>, detail::end_t<S>>;
|
|
|
+ using iterator = common_iterator<detail::begin_t<S>, detail::end_t<S>>;
|
|
|
|
|
|
private:
|
|
|
S stream_;
|
|
|
@@ -50,5 +67,7 @@ struct common {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::common_iterator);
|
|
|
+
|
|
|
#undef FWD
|
|
|
#include <iterator/detail/undef.h>
|