
From: Jason Hise <chaos@ezequal.com>
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@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;