News for hackers. Stuff that matters.
Re:You’re better off using Exceptions by earenndil on Monday February 03, 2020 @02:53PM (#22228232)
Hence 'when errors are rare'.
Re:You’re better off using Exceptions by iainmerrick on Monday February 03, 2020 @02:59PM (#22228303)
I guess we’re violently agreeing? Exceptions are an order of magnitude (or several orders) slower than function calls and returns; but that can still be efficient overall, if only a tiny fraction of calls fail.

I’d simply add that most people greatly underestimate how expensive exceptions are, even in C++.

Re:You’re better off using Exceptions by AstralStorm on Tuesday February 04, 2020 @12:00PM (#22237930)
Calling the destructors is identical to ending any scope in C++, including function calls. Where is that extra expense?
Re:You’re better off using Exceptions by iainmerrick on Tuesday February 04, 2020 @12:33PM (#22238370)
You likely have to parse exception blocks and maybe chase pointers to find the objects to destroy. In the happy path, you can just call the destructors directly.