I have a matrix class with a toString()
method:
template <typename T, int rowCount, int columnCount>
class Matrix
{
//...
public:
std::string toString() const
{
// ...
}
};
Now I want to specialize toString()
for the case, that T
is Matrix
so that it returns a string in a different format in the case of
Matrix<Matrix<double, 2, 2>, 3, 3> a;
std::string s = a.toString();
to say this case:
Matrix<double, 2, 2> a;
std::string s = a.toString();
I tried something like this
template <int rows, int cols>
template <typename X, int rows_inside, int cols_inside>
std::string Matrix<Matrix<X, rows_inside, cols_inside>, rows, cols>::toString() const
{
//...
}
but it does not work.
How can I achieve this effect?