Earlier quoted context omitted.
I worked with a guy who implemented map and reduce in C++ as a subtask of some other task. It was, of course, a header-only templated monstrosity. He called it "fun.hpp". "Fun" times, indeed, working with him.
You'll like the `std::ranges` library that's been somewhat implemented as of C++20 and is getting some more stuff in C++23. It's very Fun! #include #include #include #include int main() { std::vector vec = {1, 2, 3}; // map, using `std::views::transform`. Implemented in C++20 for(int elem : std::views::transform(vec, [](int x) { return x + 1; })) { std::cout iterator version, which was // implemented in C++20. std::c…
#include
#include
#include
#include
#include
#include
int main()
{
std::vector vec{1, 2, 3, 4, 5};
auto plus_one{[](const auto x) { return x + 1; }};
std::ranges::for_each(vec | std::views::transform(plus_one), [](const auto x) {
std::cout ())
https://godbolt.org/z/84ePjfPhf