The type "array of type T " is T [dimension] , which you can pass as template parameters. For instance:.
someTemplate<int [10]> t;
Arrays must have a size that must be greater than 0. This means that, for example, U u[]; is illegal.
There are cases that may seem like exceptions, with the first parameters being:
void f(T[]);
This is a special rule for parameters, and f() actually equivalent to the following:
void f(T*);
Then there is a direct initialization of arrays:
int a[] = { 1, 2, 3, 4 };
Here, the size of the array is implicitly specified through the number of elements in the initializer, so the type of a is int[4] .
There are also incomplete types of arrays without specific boundaries, but you cannot directly instantiate these files (see Johannes answer for more):
template<class T> struct X { typedef T type; }; X<int[]>::type a = { 1, 2, 3 };
If you are looking for dynamic arrays, instead prefer standard containers like std::vector<T> .
source share