Is it possible to invoke a method with all possible K-combinations (with repetition) of arguments passed in a tuple?
The desired behaviour can be illustrated as follows: void foo(int x, int y) { std::cout << x << " " << y << std::endl; } int main() { all_combinations<2>(foo, std::make_tuple(1, 2)); // K = 2 // to run: // foo(1, 1) // foo(1, 2) // foo(2, 1) // foo(2, 2) } The c++14 version could look as follows: #include <tuple> #include <utility> #include <iostream> #include <initializer_list> template <class Foo, class Tuple, size_t... Is, size_t... Is2> int all_combinations_impl(Foo foo, Tuple t, std::index_sequence<Is...> , std::integral_constant<size_t, 0>, std::index_sequence<Is2...>) { foo(std::get<Is>