3 ms·
Hence 'when errors are rare'.
by earenndil 7y ago
Hence 'when errors are rare'.
- iainmerrick 7y agoI 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++.
- AstralStorm 7y agoCalling the destructors is identical to ending any scope in C++, including function calls. Where is that extra expense?
- iainmerrick 7y agoYou 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.