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?
Will there be standardization of scope guard/scope exit idioms?
3.7k Views Asked by VoidStar At
2
There are 2 best solutions below
3
Nicol Bolas
On
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.
Related Questions in C++
- C++ using std::vector across boundaries
- Linked list without struct
- Connecting Signal QML to C++ (Qt5)
- how to get the reference of struct soap inherited in C++ Proxy/Service class
- Why we can't assign value to pointer
- Conversion of objects in c++
- shared_ptr: "is not a type" error
- C++ template using pointer and non pointer arguments in a QVector
- C++ SFML 2.2 vectors
- Lifetime of temporary objects
- I want to be able to use 4 different variables in a select statement in c ++
- segmentation fault: 11, extracting data in vector
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- How can I print all the values in this linked list inside a hash table?
- Configured TTL for A record(s) backing CNAME records
Related Questions in C++14
- Using std::vector<> and std::shared_ptr<> should cause error
- How does an unspecified pointer conversion behave in C++14?
- There is a way in gcc to get a warning when a constexpr can't be evaluated at compile time?
- How to pass std::bind as universal reference type?
- Constant expression initializer for static class member of type double
- Template specialization: ‘Scalar’ does not name a type
- clang 3.4 C++14 support
- Is it valid to pass non-arithmetic types as arguments to cmath functions?
- Can `auto &&` parameters be perfect forwarded?
- Are new and delete still useful in C++14?
- why declare constrexpr constructors for classes with non-trivial destructors (e.g. unique_ptr, std::variant)
- Is there a way to iterate over at most N elements using range-based for loop?
- Define virtual function to be pure in special cases of templated class
- How to detect whether some callable takes a rvalue reference?
- QtWidget Disable Margin for overlay widget
Related Questions in C++17
- why declare constrexpr constructors for classes with non-trivial destructors (e.g. unique_ptr, std::variant)
- Passing lambda as template parameter to templated by function-pointer function
- std::vector on forward declared type
- Is there a tuple for_each() that returns a tuple of all values returned from the functions invoked?
- How to use allocators in modern C++
- I made a C++17 burrito for mapping over tuples, and anything that has begin() end() iterators. Is it possible to get rid of these factory functions?
- Do overloaded logical operators && and || short-circuit since C++17?
- Why the equivalent representation of a range-for required to be updated?
- In C++17, why do associative containers have an `erase` member function that takes (non-`const`) `iterator`?
- c++ variant class member stored by reference
- How does std::apply forward parameters without explicit std::forward?
- Neither clang nor g++ compile the snippet below. Why?
- constexpr recursive function using if constexpr or not
- Why is std::shared_ptr::unique() deprecated?
- Can constexpr-if-else bodies return different types in constexpr auto function?
Related Questions in SCOPEGUARD
- How to avoid warning when using scope guard?
- C++: why this simple Scope Guard works?
- C++ : other one simple scope guard
- Will there be standardization of scope guard/scope exit idioms?
- Is a lambda-expression that only captures by reference guaranteed not to throw?
- RAII wrapper for function pairs and template specialization
- Using std::unique_ptr and lambdas to advance a state of an object
- The simplest and neatest c++11 ScopeGuard
- ScopeGuard dismiss
- Dynamically created scope guards
- Is there any way to extend the lifetime of a temporary object in C++?
- Who copies the return value of a function?
- Difference between ScopeGuard11 and Boost.ScopeExit - just backwards compatibility?
- const reference for temporary lifetime lengthening
- Why can't Alexandrescu use std::uncaught_exception() to implement SCOPE_FAIL in ScopeGuard11?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
n4189 is a proposal to add
make_scope_exitwrappers, and other similar resource handlers, to the language. It is based off of the relatively famousscope_guardtalk.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.