|
Boost : |
From: Hillel Y. Sims (hsims_at_[hidden])
Date: 2002-09-27 11:25:42
"Fredrik Blomqvist" <f_blq_at_[hidden]> wrote in message
news:20020927153922.41928.qmail_at_web13506.mail.yahoo.com...
> > {
> > vector1.push_back(e1);
> > try {
> > vector2.push_back(e2):
> > }
> > catch(...) {
> > vector1.pop_back();
> > throw;
> > }
>
> Isn't this a good example of something scopeguard +
> bind/lambda would be well suited to handle?
> IIRC Alexandrescu & Marginean's original CUJ article
> about scopeguard investigated a case very similar to
> this.
>
{
vector1.push_back(e1);
ScopeGuard guard = MakeObjScopeGuard(vector1,
{typeof(vector1)}::pop_back);
vector2.push_back(e2);
guard.Dismiss();
}
ScopeGuard rules!
hys
-- Hillel Y. Sims FactSet Research Systems hsims AT factset.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk