Here is my code:
template<class T>
void Matrix<T>::set(const int i, const int j, const T v) {
try {
m[i][j] = v;
} catch (std::exception& e) {
std::cout << "Standard exception: " << e.what() << std::endl;
}
}
But, I am on the safe side here? I mean, it is possible that i
and/or j
are out of bound, but the program receives on segmentation fault, will then an exception been thrown?
If this is not a good approach, then should I use assert()
maybe?