#pragma once #include "utils/option.hpp" namespace iter { template class Map { public: Map() = delete; template Map(IT &&iter, OP &&op) : iter(std::move(iter)), op(std::move(op)) { } auto next() { auto item = iter.next(); if (item.is_present()) { return Option(op(item.take())); } else { return Option(); } } private: I iter; MapOperator op; }; template auto make_map(I &&iter, OP &&op) { return Map(std::move(iter), std::move(op)); } }