I'm trying to learn C++ right now and have gotten on the topic of exception safety. I'm pretty sure I understand the meaning of the four different levels of exception safety. However what are some concrete examples of when a strong guarantee would be inappropriate but a basic guarantee would be appropriate?
The strong exception guarantee is of course nice to have, and in the absence of any other consideration should be provided.
However, there are cases where providing the strong exception guarantee is too expensive, too complicated, or even impossible. Here are some examples:
In all these cases, the basic exception guarantee is still useful, and may be more appropriate. It may allow the program to continue in a valid state, e.g. by returning an error message to the user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With