// // for_each.h // stream // // Created by Sam Jaffe on 3/29/23. // #pragma once #include #include #define FWD(x) std::forward(x) namespace stream::ranges { template auto for_each(It it, S end, F func, Proj proj = {}) { for (; it != end; ++it) { std::invoke(func, std::invoke(proj, FWD(*it))); } return detail::in_fun_result(it, std::move(func)); } template auto for_each(Stream && stream, F func, Proj proj = {}) { return for_each(stream.begin(), stream.end(), std::move(func), std::move(proj)); } } #undef FWD