| 123456789101112131415161718192021222324252627282930313233343536 |
- //
- // transform_iterator.h
- // stream
- //
- // Created by Sam Jaffe on 4/2/23.
- //
- #pragma once
- #include <iterator/proxy.h>
- #include <stream/forward.h>
- namespace stream::ranges {
- template <typename It, typename Proj>
- class transform_iterator : public proxy<It, transform_iterator<It, Proj>> {
- private:
- using super_t = proxy<It, transform_iterator<It, Proj>>;
- private:
- Proj projection_;
- public:
- transform_iterator() = default;
- transform_iterator(It iter, Proj projection)
- : super_t(std::move(iter)), projection_(projection) {}
- decltype(auto) dereference() const {
- return projection_(super_t::dereference());
- }
- bool at_end() const { return super_t::impl().at_end(); }
- };
- }
- MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::transform_iterator);
|