Hacker News new | ask | show | jobs
by leetNightshade 3711 days ago
It sounds to me what you're trying to do is essentially what a Scope Guard is for. Here's a wiki on them: https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Scope_Guar... And here's a nice and clean implementation of one I've used recently: http://stackoverflow.com/a/28413370