QScopedValueRollback Class
template <typename T> class QScopedValueRollback
The QScopedValueRollback class resets a variable to its previous value on destruction. More…
| Header | #include <QScopedValueRollback> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QScopedValueRollback(T &v) | |
| QScopedValueRollback(T &v, T value) | |
| ~QScopedValueRollback() | |
| void | commit() |
Detailed Description
A QScopedValueRollback saves the value of a variable when constructed and assigns it back when destroyed, unless commit() was called.
See also QScopeGuard.
Differences from Qt
None.
Member Function Documentation
QScopedValueRollback::QScopedValueRollback(T &v)
Constructs a rollback that saves the current value of v and restores it on destruction.
QScopedValueRollback::QScopedValueRollback(T &v, T value)
This is an overloaded function.
Saves the current value of v, assigns value to v, and restores the saved value on destruction.
QScopedValueRollback::~QScopedValueRollback()
Assigns the saved value back to the variable.
void QScopedValueRollback::commit()
Saves the variable's current value, so that destruction restores that value instead of the original one.