| 1234567891011121314151617181920212223242526272829 |
- //
- // single.h
- // stream
- //
- // Created by Sam Jaffe on 3/29/23.
- //
- #pragma once
- namespace stream::ranges {
- template <typename T> class single_view {
- private:
- T value_;
- public:
- single_view(T const & value) : value_(value) {}
- T const * begin() const { return &value_; }
- T const * end() const { return 1 + &value_; }
- static bool empty() { return false; }
- static size_t size() { return 1; }
- };
- }
- namespace stream::ranges::views {
- template <typename T> auto single(T const & value) {
- return single_view(value);
- }
- }
|