This question already has an answer here:
If a std::array
is defined I need to write something like this
std::array<int,3> my_array {1,5,3};
In my option this violates the DRY
principle (Don't repeat yourself), since I need to specify the length of the array explicitly and it need to corresponds to the length of the initializer list.
Is there a way to write something like
std::array<int> my_array {1,5,3};
and the constant length of the array is deduced form the length of the initializer list?
Aucun commentaire:
Enregistrer un commentaire