ValueRestorer

This commit is contained in:
Yevgen Muntyan 2009-11-23 22:52:01 -08:00
parent 95cabcdea2
commit c78714b469

View File

@ -37,6 +37,28 @@ private:
int m_count;
};
template<typename T>
class ValueRestorer
{
public:
ValueRestorer(T &val)
: m_ref(val)
, m_val(val)
{
}
~ValueRestorer()
{
m_ref = m_val;
}
MOO_DISABLE_COPY_AND_ASSIGN(ValueRestorer)
private:
T &m_ref;
T m_val;
};
} // namespace moo
#endif /* MOO_CPP_TYPES_H */