> Someone smarter than me once pointed out that exceptions are great as long as you don't have to worry about rolling back state
and the point of exceptions in C++ is that they have to be used in combination with the "rolling-back state" feature backed in the language, namely RAII. It's only a pain in language without such things such as C# / Java, but in C++ if I do
file my_file;
// .. do stuff
auto f = std::make_unique<whatever>(...);
// ...
throw some_error;
I know that my_file will be closed if it had been opened, and that my memory will be freed.
Of course if your code is littered with `new` and `fopen` left and right that won't work, but the code won't pass code review in the first place :-)
and the point of exceptions in C++ is that they have to be used in combination with the "rolling-back state" feature backed in the language, namely RAII. It's only a pain in language without such things such as C# / Java, but in C++ if I do
I know that my_file will be closed if it had been opened, and that my memory will be freed.Of course if your code is littered with `new` and `fopen` left and right that won't work, but the code won't pass code review in the first place :-)