4 ms·
This is amazing, thanks! It's a bit different though - it executes a cleanup function when the variable goes out of scope, rather than a statement at the end of
by Asooka 6y ago
This is amazing, thanks! It's a bit different though - it executes a cleanup function when the variable goes out of scope, rather than a statement at the end of the enclosing guard block. It might be better though - it avoids some footguns that would be possible with a defer implementation.
- hsaliak 6y agoClang has this too. Libraries like Glib and software like Systemd use this mechanism. Standardizing it would be nice.