Defined in <stlab/utility.hpp>
template<class F, class... Args>
void for_each_argument(F&& f, Args&&...args)
(1)
  1. Executes f individually for each of args

Parameters

f

Unary function that can take all arguments of type Args

args

Arguments to be passed one-by-one to f

Example 1

#include <iostream>
#include <mutex>
#include <thread>

#include <stlab/concurrency/future.hpp>
#include <stlab/concurrency/default_executor.hpp>
#include <stlab/concurrency/immediate_executor.hpp>
#include <stlab/concurrency/utility.hpp>

using namespace stlab;
using namespace std;

int main(int, char**) {
    auto fi = []{
        static std::size_t count_s{0};
        return make_ready_future<int>(count_s++, immediate_executor);
    };

    auto f = when_all(default_executor, [](auto... args){
        for_each_argument([](auto x) { cout << x << "\n"; }, args...);
    }, fi(), fi(), fi());

    while (!f.get_try()) this_thread::sleep_for(chrono::milliseconds(1));
}
/*
    Result:

        0
        1
        2
    or
        2
        1
        0
*/