sun::support::SaveAndRestore
class · Source (opens in a new tab)
template <typename T>
class sun::support::SaveAndRestoreSaves a copy of a value and restores it when the guard leaves scope.
The referenced value must outlive the guard and support nonthrowing move assignment so restoration is safe during exception unwinding.
Public Functions
SaveAndRestore
SaveAndRestore(T &value, T replacement)
public · function · Source (opens in a new tab)
sun::support::SaveAndRestore< T >::SaveAndRestore(T &value, T replacement)Saves the current value and installs a temporary replacement.
SaveAndRestore(const SaveAndRestore &)=delete
public · function · Source (opens in a new tab)
sun::support::SaveAndRestore< T >::SaveAndRestore(const SaveAndRestore &)=deletePrevents two guards from owning the same saved state.
SaveAndRestore(T &value)
public · function · Source (opens in a new tab)
sun::support::SaveAndRestore< T >::SaveAndRestore(T &value)Saves the current value before the caller changes it.
operator=
public · function · Source (opens in a new tab)
SaveAndRestore & sun::support::SaveAndRestore< T >::operator=(const SaveAndRestore &)=deletePrevents replacing ownership of saved state.
Related: SaveAndRestore
~SaveAndRestore
public · function · Source (opens in a new tab)
sun::support::SaveAndRestore< T >::~SaveAndRestore()Restores the saved value, including when an exception leaves the scope.
Private Fields
saved_
private · variable · Source (opens in a new tab)
T sun::support::SaveAndRestore< T >::saved_No documentation comment.
value_
private · variable · Source (opens in a new tab)
T& sun::support::SaveAndRestore< T >::value_No documentation comment.