I've made a Matrix
class with a constructor of this type:
Matrix<T>(const vector<vector<T>> &m)
If I do this I can instance a Matrix
object:
vector<vector<double>> a_v {
{ 17, 24, 1},
{ 23, 5, 7 },
{ 4, 6, 13 }
};
Matrix<double> a=a_v;
It works correctly, but I think that che constructor should be act as type converter and I think that also this code should work:
Matrix<double> a= {
{ 17, 24, 1},
{ 23, 5, 7 },
{ 4, 6, 13 }
};
However with this second code I get this error:
could not convert ‘{{17, 24, 1}, {23, 5, 7}, {4, 6, 13}}’ from 'brace-enclosed initializer list' to ‘Matrix’
Why C++11
does not convert the brace-enclosed initializer
to vector<vector<double>>
automatically?
What should I do if I want to initialize matrices in this way?