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