dimanche 25 septembre 2016

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)
}

Aucun commentaire:

Enregistrer un commentaire