4 ms·
Counterpoint to the C++ fragment in "Error handling" section: void foo() { Matrix *a = new Matrix(1000, 1000); Matrix *b = new Matrix(1000, 1000);
by ctz 15y ago
Counterpoint to the C++ fragment in "Error handling" section:
void foo()
{
Matrix *a = new Matrix(1000, 1000);
Matrix *b = new Matrix(1000, 1000);
delete b;
delete a;
}
Pretending exceptions solve error handling gets you a big fat zero. Look at boost: despite being written by C++ experts and held up as an excellent library (which it is!), it contains exception-unsafe portions. Why? Total exception safety is just as hard as the original error handling problem.
- simoncion 15y agoCounterpoint to your counterpoint: void foo() { typedef std::auto_ptr<Matrix> matAP; matAP a(new Matrix(1000, 1000)); matAP b(new Matrix(1000, 1000)); }
- anonymous246 15y agoI don't think it's because the Boost guys thought it "too hard". Having seen/used some of those libraries, I'm 100% sure they can handle the alleged "hardness". C++ in general values performance over safety almost everywhere (just like C). That's probably why they made certain parts exception-unsafe.