I have a function which accepts std::array by const reference and processes its elements
void foo(const std::array<int,10> &arr) {
// do some stuff
}
I would like to pass this array all filled with some custom value (say, 5), so array becomes {5, 5, 5, ...}.
In my code I can create an array, fill it with fill(5)
method and then pass to a function
std::array<int,10> arr;
arr.fill(5);
foo(arr);
Is there any way to fill array inside function arguments so the final result will be like that:
foo(std::array<int,10>(5));
?
I know, that std::vector have such a constructor, but it doesn't match my case.