Reputation: 11
I would assume the below code would work to initialize the Matrix class, but for Matrix C I get the following:
error C2440: 'initializing': cannot convert from 'initializer list' to 'Math::Linear::Matrix<int,2,2>'
template<class T, unsigned int Rows, unsigned int Cols>
class Matrix
{
public:
Matrix(std::array<std::array<T,Cols>,Rows> ArrayArray)
{
}
}
std::array<std::array<int, 2>, 2> A = {{ {{1,1}} , {{1,1}} }};
Matrix<int, 2, 2> B = A;
Matrix<int, 2, 2> C = {{ {{1,1}} , {{1,1}} }};
Upvotes: 0
Views: 183
Reputation: 141000
To use initializer list initialization, you need one more {
}
.
std::array<std::array<int, 2>, 2> A = {{ {{1,1}} , {{1,1}} }} ;
Matrix<int, 2, 2> C = { {{ {{1,1}} , {{1,1}} }} };
Upvotes: 3