Basic question here, with (hopefully) a simple answer: I'm trying to write a function whose first argument is a std::array, but with an arbitrary size.
void f(array<int> x) {
//do stuff
}
isn't valid, because I need a size for array<int, #>
. Is there a way to get around this?
The only way is to make f
a function template :
template <size_t N>
void f(array<int, N> x) {
//do stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With