Is there anyway to restrict the size of an array when passed as an argument to a function?
I mean is something like this possible?
/*following will lead to compile time error */
template<typename T, size_t n>=20> // or template<typename T,size_t n<=20>
void func(T (&a)[n])
{
// do something with a
}
I want the size of my array to be at least(or at most) n
(n can have any value).
For example:
When n=20
I must pass an array with at least(or at most) 20 elements. Is there any way in C++ for this?