the easiest is to define a separate array type and then use it everywhere, then the compiler will help checking the index ranges.
e.g.:
const int SIZE = 5;
typedef int[0,SIZE-1] range_t; // one can customize the offset of range, but let's stick to C way of counting
typedef int row_t[range_t]; // when range_t counts from 0 then it's equivalent to row_t[SIZE], but having range_t has benefits later.
then template arguments could be:
Template(row_t& Row, range_t blank) // passing by reference, i.e. array is shared
int find_index_of(int value) {
for (i : range_t) // ranged loop over bounded integer type
if (Row[i] == value)
return i;
return blank;
}
Then system declaration could be:
row_t myrow;
Process = Template(myrow, 0);
Alternatively, pass by value:
Template(row_t Row, range_t blank)
const row_t myrow = { 1, 2, 3, 4, 5 };
Process = Template(myrow, 0);
Marius