I want to do this
void DoSomething (int arr[])
{
// do something
}
but instead of arr[] it's std::array
void DoSomething (std::array <int> arr) // <--- incorrect way to declare an array
{
// do something
}
Using std::vector instead of std::array works, but I expect a workaround with std::array, since arr[] works just fine.
This works too
const int arrSize;
void DoSomething (std::array <int,arrSize> arr)
{
// do something
}
but again, I expect a way to do this without any extra declarations.
void DoSomething (int arr[])ends up passing a pointer and loses all size info so DoSomething does not know how many elements to operate on.std::arrayis an array of a fixed size that must be specified.