是否可以重载运算符 +
template <typename U>
Mat <T> operator + ( const Mat <U> &A );
对于以下矩阵运算
Matrix (1,1) + scalar = scalar
scalar + Matrix (1,1) = scalar
Matrix(1,1) + Matrix(1,1) = scalar
和语法(或类似的)?
template <typename T, typename U>
T operator + ( const Mat <U> &M ) const;
更新的问题:
作为模板参数的维度:
template <typename T, typename U, const unsigned int TDim>
T operator + ( const Mat <U> &M, TDim <dim> ) const;
专业化为 dim=1
template <typename T, typename U>
T operator + ( const Mat <U> &M, TDim <1> ) const;