| 1234567891011121314151617181920212223242526272829303132333435363738 |
- #pragma once
- #include <iterator>
- #include <stream/forward.h>
- #include <stream/detail/traits.h>
- #include <stream/view/interface.h>
- #include <stream/detail/macro.h>
- namespace stream::ranges {
- template <typename It, typename S = It>
- class subrange : public view_interface<subrange<It, S>, It, S> {
- private:
- It begin_;
- S end_;
- public:
- subrange(It begin, S end) : begin_(begin), end_(end) {}
- template <typename C, REQUIRES(detail::is_container_v<C>)>
- subrange(C && container)
- : subrange(std::begin(container), std::end(container)) {
- // TODO: permissible dangling
- static_assert(std::is_reference_v<C>,
- "Cannot access iterator of a temporary");
- }
- auto begin() const { return begin_; }
- auto end() const { return end_; }
- };
- template <typename It, typename S> subrange(It, S) -> subrange<It, S>;
- template <typename C>
- subrange(C &&) -> subrange<detail::begin_t<C>, detail::end_t<C>>;
- }
- #include <stream/detail/undef.h>
|