Defining multi-dimensional array using the T[][][]
syntax is easy. However, this creates a raw array type which doesn\'t fit nicely into modern C++. That\'s why
Refer to Multi-dimensional arrays in C++11
template
struct MultiDimArray
{
using Nested = typename MultiDimArray::type;
// typedef typename MultiDimArray::type Nested;
using type = std::array;
// typedef std::array type;
};
template
struct MultiDimArray
{
using type = std::array;
// typedef std::array type;
};
MultiDimArray::type floats;
MultiDimArray
is a pair of meta-functions to compute nested type for multi-dimensional std::array
. The most general MultiDimArray
is a variadic template of unsigned integers to pass an arbitrary number of dimensions. The terminating MultiDimArray
specialization defines the simplest case of single dimensional std::array
.