Is there a way to pass default value to array which is passed by reference to a function so that passing it is not necessary?
I have a function like this:
void foo(int (&arr) [3])
{
//some code...
}
Then i tried this:
void foo(int (&arr) [3] = nullptr)
{
//some code...
}
but it obvoiusly didn't work because reference cannot be nullptr and it is not even an array.
EDIT:
I would like not to use std::array if possible, and I also need to know the size of passed array without passing its size which is why I didn't do this: int (*arr)[3].
foothat doesn't take an argument.int (*arr)[3] = nullptr?void foo() { int dummy[3]; foo(dummy); }void foo(const int (&arr)[3] = { 1, 2, 3 })if you don't need to modify the array