lundi 28 octobre 2019

How to assign variadic template arguments to std::array

I have an std::array and I have a variadic template function with the number of parameters that matches the size of the array. I need to assign the arguments to the elements of the array. In other words, in the code below I wish a to get values {1, 2, 3} and b to get values {1, 2, 3, 4, 5}

std::array<int, 3> a;
std::array<int, 5> b;

assign_values(a, 1, 2, 3);
assign_values(b, 1, 2, 3, 4, 5);

The question is how to implement the assign_values variadic template function.

I'm limited with the C++14 version.

Aucun commentaire:

Enregistrer un commentaire