3 ms·
Yeah. But when people start writing wrappers like SCOPE_EXIT that call user code inside destructors, suddenly the users of those wrappers don't have any way to
by mehrdadn 9y ago
Yeah. But when people start writing wrappers like SCOPE_EXIT that call user code inside destructors, suddenly the users of those wrappers don't have any way to know they can't throw exceptions.
- beached_whale 9y agoscope_exit is just not very idiomatic C++. If used, It's for quick'n'dirty I'm too rushed to wrap it in a class times. It's use in C++ implies that you are worrying about something at the wrong abstraction level too. With that though, I would think that the default > c++11 implicit noexcept is proper. Crash hard when an exception is thrown and maybe even static assert on the result of noexcept( on_exit_cb ) so that it gives a compile error, lambda's can be noexcept and c functions cannot throw(thinking fclose and friends)
- maxlybbert 9y agoThe people who use SCOPE_EXIT are responsible for making sure no exceptions are thrown (well, that any exceptions that get thrown are swallowed before they trigger std::terminate). If that’s not possible, they have to use a different approach.