2 ms·
A typical C++ codebase I'm working on these days would have scope guards implemented via macros, such that you can do e.g.: FILE* f = fopen(...); SCOPE
by int_19h 10y ago
A typical C++ codebase I'm working on these days would have scope guards implemented via macros, such that you can do e.g.:
FILE* f = fopen(...);
SCOPE_GUARD({ fclose(f); });
This is mainly used for one-off calls to some native API, where writing a proper RAII wrapper for the managed resource is not worth it.