I am so confused and fed up with C++: As I have been taught "passing by reference or pointer" overcomes getting copies of parameters passed in a function.
So in an exception-handling scenario according to the law of thumb: throw by value, catch by reference.
Why Stroustrup in his "A Tour of C++" catches by value? eg:
void test()
{
try {
std::vector v(−27);
}
catch (std::length_error) {
// handle negative size
}
catch (std::bad_alloc) {
// handle memory exhaustion
}
}
This example is copied from the book. Page 59. (Invariants).