fI have the next template of a matrix class:
template<typename T, int rows, int cols>
struct Matrix{
public:
Matrix() {
if (rows == cols)
LoadIdentity();
}
T data[rows][cols];
void LoadIdentity(){ }
/* more methods ... */
}
template<int rows, int cols>
using matrixf = Matrix<float, rows, cols>;
template<int rows, int cols>
using matrixd = Matrix<double, rows, cols>;
And i want to be able to initialize this class like:
void main(){
matrixf<2, 3> m2x3 = { { 1, 2, 3 }, {4, 5, 6} };
}
If I try this, the compiler says:
E0289 no instance of constructor "vian::Matrix [with T=float, rows=2, cols=3]" matches the argument list
If I remove my default constructor, I get the behaviour that I want, but I lose the posibility of having any constructor.
Matrix() { ... } // If I remove this, I have the behaviour I want
A solution I found was to create a constructor that takes an std::initializer_list, but if I do that, the compiler wont check if the initialier list has the right amount of arguments for a matrix of NxM size.
Edit: Added the LoadIdentity method so it compiles.