Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2005-03-13 20:22:56


Jason Hise wrote:
> I use the following as an implementation detail, and it was mentioned
> by Pavel that a similar facility called state_saver is used in the
> implementation of the serialization library. Does it make sense for
> this to be refactored into boost/detail?
>
> template < typename T >
> struct auto_set
> {
> T & var; T val;
> auto_set ( T & var, T val ) :

auto_set(T & var,T val = T()):

// allows one to just specify a variable to be auto-set back to its default
value also

> var ( var ), val ( val ) { }
> ~ auto_set ( ) { var = val; }
> };


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