|
Boost : |
From: Rob Stewart (stewart_at_[hidden])
Date: 2005-03-16 17:21:37
From: Jason Hise <chaos_at_[hidden]>
>
> 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 ) :
> var ( var ), val ( val ) { }
> ~ auto_set ( ) { var = val; }
> };
I could see calling that auto_reset, but not auto_set.
You do realize that this would have to be documented as requiring
that T's copy assignment operator be nonthrowing, right?
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk