Hello,
I created a template matrix class and some appropriate binary operators like:

template <typename ContainedType>

Matrix<ContainedType> operator+ (const Matrix<ContainedType>& lhs, const Matrix<ContainedType>& rhs)

{ ... }

The first line of each such binary operator is a check, like:

assert(lhs.rows == rhs.rows && lhs.columns == rhs.columns);

But I was wondering if one could model the mathematical behavior of matrices? By that I mean that (unless you define them) there are no valid operations with matrices of different dimensions.
I think this could be well modeled with types because usually there are no valid operations between different types. And with templates one could define a type "on demand".
So I'm thinking of a syntax like:

Matrix<float, 4, 4> matrix_4x4;

would define a 4 by 4 matrix whose elements are floats, and it would be a different type than a
Matrix<float, 3, 3> ...
So is there a way to do this with templates? Or any other way?
Thanks in advance,
Harinezumi