The QScopedValueRollback class resets a variable to its previous value on destruction. More...
|CMake:||find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|qmake:||QT += core|
|QScopedValueRollback(T &var, T value)|
The QScopedValueRollback class can be used to revert state when an exception is thrown without needing to write try-catch blocks.
It can also be used to manage variables that are temporarily set, such as reentrancy guards. By using this class, the variable will be reset whether the function is exited normally, exited early by a return statement, or exited by an exception.
The template can only be instantiated with a type that supports assignment.
[since 5.4]QScopedValueRollback::QScopedValueRollback(T &var, T value)
Assigns value to var and stores the previous value of var internally, for revert on destruction.
This function was introduced in Qt 5.4.
Stores the previous value of var internally, for revert on destruction.
Assigns the previous value to the managed variable. This is the value at construction time, or at the last call to commit()
Updates the previous value of the managed variable to its current value.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: