Boost logo

Boost :

From: Stephen C. Gilardi (squeegee_at_[hidden])
Date: 2000-02-06 23:26:56


> > We are treating this like a temporary push to the top of a "stack" of
> > values for the given variable.
> >
> > How does this sound for readability:
> >
> > {
> > block_push_value push(mDisableUpdates, true);
> > block_push_value push2(mEnableLogging, true);
> > }
> >
> > --Steve
> >
> Both of these suggest to me that we are setting the value of the
>variable to true for the CURRENT scope or block, and that the original value
>will be restored once the block is exited. This is the exact opposite of
>what the class actually does. This is why I prefer set_value_on_exit. It
>makes it clear exactly when the variable takes on the value.

The impression you got from the names is exactly the impression I was
trying to convey. I believe we're talking about two different
classes which are probably both useful. The one I'm talking about
sets the value on construction and restores the previous value on
destruction. It's StValueChanger<T> in PowerPlant.

"scoped_value" seems good to me too.

--Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk