4 ms·
How does this compare to using RAII in C++ in terms of generated code?
by waynecochran 7y ago
How does this compare to using RAII in C++ in terms of generated code?
- MaxBarraclough 7y agoAs I mentioned in another comment, it seems almost identical to Boost.ScopeExit, [0] but with the special restriction that it causes statements to run at the point a function returns. From the article: it does not care about lexical scopes. edit Looking at the implementation, it seems to use setjmp/longjmp on some platforms. Nasty. I believe Boost.ScopeExit does some macro trickery to leverage C++'s RAII, which isn't so bad. [0] https://www.boost.org/doc/libs/1_72_0/libs/scope_exit/doc/html/index.html https://www.boost.org/doc/libs/1_72_0/libs/scope_exit/doc/ht...
- cryptonector 7y agoIt's almost certainly strictly more code, as this code maintains an array at run-time. You can use godbolt to see it if you like.