| 12345678910111213141516171819202122232425262728293031323334 |
- #pragma once
- namespace stream {
- namespace detail {
- template <typename C>
- class source_stream : public stream_impl<typename C::value_type> {
- public:
- typedef typename C::value_type value_type;
- class iterator : public iterator_impl<value_type> {
- public:
- typedef iterator_impl<value_type> super;
- explicit iterator(typename C::iterator it) : impl_(it) {}
- ~iterator() {}
- value_type operator*() override { return *impl_; }
- DELEGATE_ITERATOR_IMPL(impl_)
- private:
- typename C::iterator impl_;
- };
-
- explicit source_stream(C const& cont) : source_(cont) {}
- explicit source_stream(C && cont) : source_(std::forward(cont)) {}
- ~source_stream() override {}
- ::stream::iterator<value_type> begin() override { return new iterator{source_.begin()}; }
- ::stream::iterator<value_type> end() override { return new iterator{source_.end()}; }
- private:
- C source_;
- };
- }
-
- template <typename C>
- detail::stream_base<typename C::value_type, true> make_stream(C const& cont) {
- return detail::stream_base<typename C::value_type, true>{new detail::source_stream<C>{cont}};
- }
- }
|