Let's suppose that we want to subtract some value from a given matrix. How could/should I overload that operator.
main.cpp
Matrix<double> m(10, 5);
auto r = 1.0 - m; //error: return type specified for 'operator double'
matrix.hpp
template <typename T>
class Matrix {
public:
  Matrix operator double(T val) {
    Matrix tmp(rows, cols);
    for (unsigned int i = 0; i < rows; i++)
      for (unsigned int j = 0; j < cols; j++) {
        const unsigned int idx = VecToIdx({i, j});
        tmp[idx] = val - this[idx];
      }
    return tmp;
  }
}
 
    