| 12345678910111213141516171819202122232425262728293031323334 |
- //
- // 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 std::invoke(projection_, super_t::dereference());
- }
- };
- }
- MAKE_ITERATOR_FACADE_TYPEDEFS_T(stream::ranges::transform_iterator);
|