#pragma once #include #include #include #include #define FWD(x) std::forward(x) namespace stream::ranges { template class filter_view { private: using Pred = std::function)>; using iterator = ::iterator::filter_iterator, true>; private: S stream_; Pred predicate_; public: template filter_view(S && stream, F predicate) : stream_(FWD(stream)), predicate_(predicate) {} auto begin() const { return iterator(predicate_, stream_); } auto end() const { return sentinal; } }; template filter_view(S &&, F) -> filter_view; } namespace stream::ranges::views { template class filter { public: filter(Pred const & predicate) : predicate_(predicate) {} filter(Pred & predicate) : predicate_(std::move(predicate)) {} template friend auto operator|(Stream && stream, filter filt) { // TODO: if constexpr filter_view return filter_view(FWD(stream), std::move(filt.predicate_)); } private: Pred predicate_; }; } #undef FWD