Run Callable on each Argument

This snippet shows how to run a callable given as first argument on each following argument.

template<typename F, typename ...T>
void for_each_arg(F&amp;&amp; function, T&amp;&amp;... args){
    //(function(std::forward(args)), ...); // c++17 fold expression
    int pass[]{ ((   function(std::forward(args))   ), 0)... };
    (void)pass;
}
Posted in c++

Leave a Reply

Your email address will not be published. Required fields are marked *