|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-09-22 16:21:44
Jason Stewart <jstewart_at_[hidden]> writes:
> However, maybe using the shared_ptr semantics would work. I.e. if you
> can create a guard that is "uninitialized" and then reset it later to
> an active guard.
>
> {
> scope_guard g;
>
> if (some condition)
> {
> g = scope_guard(my_undo_function);
> // do something here
> }
>
> if (some other condition)
> {
> // we changed our mind, dismiss it.
> g = scope_guard;
>
> // or ...
> // g.dismiss();
> // g.reset(); // like shared_ptr
reset() is wrong unless you mean the guard to immediately take it
would take upon destruction. release() would be the correct smart
pointer analogy.
> }
> }
>
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk