You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
scope_exit is not default constructible. But it can be released and is movable, so a default constructed scope_exit state makes sense (this is the same as a moved-from scope_exit). I find this a rather strange design choice. What is the rationale behind this?
I think it does not hurt for scope_fail and scope_exit. We have scope_final for the simple case. I'm asking because i finally added it to the scope_exit-like we use in our code base.
The text was updated successfully, but these errors were encountered:
After the following discussion, it looks like default-constructible scope guards would have a very narrow use case because a default-constructed action function must be callable (as it cannot be modified after scope guard construction) and therefore would only have access to the global state. This is rarely sufficient, you normally want to bind local variables and this in scope guards.
The original reviewer who requested this feature admitted that this would have limited usability, and another reviewer, Andzej Krzemienski, also noted that he supports the design without default constructors.
So for now I'm not going to implement this feature until there is a compelling use case and more demand from users.
From Julien Blanc:
The text was updated successfully, but these errors were encountered: