SL.Con.3 encourages the use bounds-checked functions such as .at() and gsl::at() over the use of operator[]. However, this becomes inconvenient when trying to access values inside multi-dimensional arrays.
For example, assume we have a 3-dimensional array named memo, which caches the values for some expensive function. To access a value, we would need to write memo.at(x).at(y).at(z), or at(at(at(memo, x), y), z) when using the GSL function. By using the new variadic template, we can simply write at(memo, x, y, z).
SL.Con.3 encourages the use bounds-checked functions such as
.at()
andgsl::at()
over the use ofoperator[]
. However, this becomes inconvenient when trying to access values inside multi-dimensional arrays.For example, assume we have a 3-dimensional array named memo, which caches the values for some expensive function. To access a value, we would need to write
memo.at(x).at(y).at(z)
, orat(at(at(memo, x), y), z)
when using the GSL function. By using the new variadic template, we can simply writeat(memo, x, y, z)
.