This patch implements the + and - binary operators for values of
MatrixType. It adds support for matrix +/- matrix, scalar +/- matrix and
matrix +/- scalar.
For the matrix, matrix case, the types must initially be structurally
equivalent. For the scalar,matrix variants, the element type of the
matrix must match the scalar type.
I would suggest checking some preconditions and then just calling PrepareScalarCast.
You should allow implicit conversions from class types, which somewhat surprisingly I'm not sure we have a convenient method for, but which you can find workable code for in ConvertForConditional in SemaExprCXX.cpp. Test case is struct DoubleWrapper { operator double(); };, and you should test using that even when the element type isn't a double.
In SemaOverload, you should add builtin candidates for these operators if one operand or the other is a matrix type. Basically: