1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <array>
template<typename T, uint32_t X, uint32_t Y>
class MatrixImpl
{
static_assert(std::is_integral<T>::value || std::is_floating_point<T>::value, "The type for a Matrix must be numeric");
public:
std::array<std::array<T, Y>, X> values;
};
typedef MatrixImpl<int, 2, 2> Matrix2x2i;
int main()
{
// No good, you've lost the one-glance dimensionality of the data.
// Matrix2x2i test {0, 0, 0, 0};
// Great, alas it does not compile!
/*
Matrix2x2i test
{
{0, 0},
{0, 0}
};
*/
// Any end-user would be beyond confused on the seemingly random # of braces required...
// but it does compile!
Matrix2x2i test
{{{
{0, 0},
{0, 0}
}}};
}
|