header_utils
|
A RAII class that changes the value of a variable and reverts it to the original value on destruction. More...
#include <scope.h>
Public Member Functions | |
template<typename U > requires (!OPTIONAL) | |
scoped_value_change (T &ref, U new_val) noexcept(std::is_nothrow_move_constructible_v< T >) | |
template<typename U > requires OPTIONAL | |
scoped_value_change (T &ref, U new_val) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_copy_constructible_v< T >) | |
scoped_value_change (const scoped_value_change &)=delete | |
scoped_value_change (scoped_value_change &&other) noexcept(std::is_nothrow_move_constructible_v< T >) | |
scoped_value_change & | operator= (const scoped_value_change &)=delete |
scoped_value_change & | operator= (scoped_value_change &&other)=delete |
Move assignment is not implemented because it's not clear and obvious what the order of reversions would be, and I don't want to force the user to read and remember the documentation. | |
bool | valid () const noexcept |
T const & | original_value () const &noexcept |
Returns the original value. | |
T | original_value () &&noexcept(std::is_nothrow_move_constructible_v< T >) |
Returns the original value. | |
T const & | current_value () |
Returns the current value. | |
void | revert () noexcept(std::is_nothrow_move_assignable_v< T >) |
Reverts the value to the original one. | |
T | revert_and_return () noexcept(std::is_nothrow_move_assignable_v< T > &&std::is_nothrow_move_constructible_v< T >) |
Reverts the value to the original one. | |
void | release () noexcept |
Causes the value to not be reverted on destruction. | |
T | release_and_return () noexcept(std::is_nothrow_move_constructible_v< T >) |
Causes the value to not be reverted on destruction. | |
A RAII class that changes the value of a variable and reverts it to the original value on destruction.
Not exception-safe (probably).
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |