Scope exit in C++11 (2012)
What everybody seems to miss (including in the other comments here) is the fact that no kind of hackery with destructors will ever make them equivalent to scope(exit) or finally{}, because of the simple reason that destructors invoked via exceptions can&#x27;t throw their own exceptions. And this makes sense, because destructors are meant to <i>release resources</i>, whereas finally&#x2F;scope(exit) are meant to <i>execute after prior operations in a LIFO manner</i>. Not all operations that need to occur in a LIFO manner are inherently tied to resource acquisition. More fundamentally, one is inherently about data, and the other is inherently about control-flow... simply put, they&#x27;re different tools with different use cases, even though people don&#x27;t bother to make the distinction. Nevertheless, if people insist on using the same hammer for both nails, the language needs to address this fundamental issue before people can claim it&#x27;s possible to do scope(exit) or the equivalent in C++.