// // common_view.h // stream // // Created by Sam Jaffe on 3/30/23. // #pragma once #include #include #include #define FWD(x) std::forward(x) namespace stream::ranges { template class common_view { private: S stream_; public: common_view(S && stream) : stream_(FWD(stream)) {} auto begin() const { return iterator::sentinel_iterator(stream_.begin()); } auto end() const { return decltype(begin())(); } auto empty() const { if constexpr (traits::has_empty_v) { return stream_.empty(); } } auto size() { if constexpr (traits::has_size_v) { return stream_.size(); } } }; template common_view(S &&) -> common_view; } namespace stream::ranges::views { struct common { template friend auto operator|(Stream && stream, common) { return common_view(FWD(stream)); } }; } #undef FWD