I want to use call-by-reference with an array and found something on here which seemed to solve my problem. However I now changed it to this and I get the error message
"template argument deduction/substitution failed".
It works if I put
bool a[3];
but not with the variable m.
#include <assert.h>
template <typename T, int Size>
void dosth(T (&a)[Size])
{
assert(Size > 2);
a[2] = false;
}
int main()
{
int m=3;
bool a[m];
dosth(a);
}
bool a[m];is known as a variable length array and not supported in C++. However, if you were to useconst unsigned intfor the capacity or#definefor the capacity, it would be an array in local storage.