|
|
|
|
|
by junon
400 days ago
|
|
Honestly if this isn't part of a public API this isn't very cursed in terms of C++, especially if you have a lot of one-off cleanup operations. I think the only bit I don't like personally is the syntax. I normally implement defer as a macro to keep things clean. If done correctly it can look like a keyword: `defer []{ something(); };`. |
|
Or you could even make a non-macro version (but then you need to think of variable names for each defer):