// A simplistic template providing a general save-restore pattern through a // local auto/stack object (scope). // template<typename T> class AutoSaveRestore : public StackObj { public:
AutoSaveRestore(T &loc) : _loc(loc) {
_value = loc;
}
~AutoSaveRestore() {
_loc = _value;
} private:
T &_loc;
T _value;
};
// A simplistic template providing a general modify-restore pattern through a // local auto/stack object (scope). // template<typename T> class AutoModifyRestore : private AutoSaveRestore<T> { public:
AutoModifyRestore(T &loc, T value) : AutoSaveRestore<T>(loc) {
loc = value;
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.