Running a lambda on scope exit seems like such a basic thing, I would expect it to be standardized. Things like unique_ptr
are better, when they apply, but I find there is an endless supply of "one-off" destructors are needed, especially when leveraging C-style libraries. Does anyone know if this is coming?
A set of macros for invoking code when a C++ scope exits, like the finally construct in other languages. The scope_exit library provides a mechanism for invoking code when a C++ scope exits, either via an exception or after the last line of the block is executed.
Scope guard is an object which allows executing an action on scope exit. The objects of this class must be constructed using wxMakeGuard() function. Library: None; this class implementation is entirely header-based.
n4189 is a proposal to add make_scope_exit
wrappers, and other similar resource handlers, to the language. It is based off of the relatively famous scope_guard
talk.
The most recent "current paper status" from LWG is in 2013, prior to the above date.
The contents of C++1z (hopefully C++17) are yet to be determined.
C++1z status for clang does not mention it. C++1z TS for clang does not mention it.
The paper itself contains an example implementation. I do not know what licensing terms it is under.
It would appear that the current version of the scope exit paper, P0052, will be going into the Library Fundamentals v3, for likely adoption in the Post-C++17 standard.
In short, not gonna happen for C++17. Sorry.
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