Resource acquisition is initialization: Difference between revisions

Content deleted Content added
No edit summary
WikiCleanerBot (talk | contribs)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
Line 63:
</syntaxhighlight>
 
This code is exception-safe because C++ guarantees that all objects with automatic storage duration (local variables) are destroyed at the end of the enclosing scope in the reverse order of their construction.<ref>{{cite web
| url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf
| title=Working Draft, Standard for Programming Language C++
Line 70:
| page=151, section §9.6
| access-date=2023-09-07
}}</ref>.
The destructors of both the ''lock'' and ''file'' objects are therefore guaranteed to be called when returning from the function, whether an exception has been thrown or not.<ref>{{cite web
| url=https://isocpp.org/wiki/faq/exceptions#dtors-shouldnt-throw