|
DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
|
RAII sentinel: on construction replaces ref with a new value and on destruction restores the original value.
More...
#include <ScopedValueAlternator.hpp>
Public Member Functions | |
| template<class TAssign > | |
| ScopedValueAlternator (T &ref, TAssign &&vAssign) | |
Save the current value of ref and overwrite it with vAssign. | |
| ~ScopedValueAlternator () | |
RAII sentinel: on construction replaces ref with a new value and on destruction restores the original value.
Useful for surgically changing a global / member flag for the duration of a function without adding explicit try/catch cleanup:
Move/copy are not declared; an instance must stay in the scope that owns the reference.
| T | Any assignable type. |
Definition at line 27 of file ScopedValueAlternator.hpp.
|
inline |
Save the current value of ref and overwrite it with vAssign.
Definition at line 35 of file ScopedValueAlternator.hpp.
|
inline |
Definition at line 40 of file ScopedValueAlternator.hpp.