An OptionalStreamGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction. More...
#include <InlineStreamGuard.h>
Public Member Functions | |
InlineOptionalStreamGuard () | |
Creates an uninitialized stream guard. | |
InlineOptionalStreamGuard (optional< Stream > stream_opt) | |
Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt. More... | |
template<typename... Args> | |
InlineOptionalStreamGuard (Args &&...args) | |
All constructors of StreamGuard are valid for OptionalStreamGuard. | |
InlineOptionalStreamGuard (InlineOptionalStreamGuard< T > &&other)=delete | |
InlineOptionalStreamGuard & | operator= (InlineOptionalStreamGuard &&other)=delete |
void | reset_stream (Stream stream) |
Resets the currently set stream to the original stream and the currently set device to the original device. More... | |
optional< Stream > | original_stream () const |
Returns the stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized. More... | |
optional< Stream > | current_stream () const |
Returns the most recent stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized. More... | |
void | reset () |
Restore the original device and stream, resetting this guard to uninitialized state. | |
An OptionalStreamGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction.
See InlineOptionalDeviceGuard for more guidance on how to use this class.
Definition at line 124 of file InlineStreamGuard.h.
|
inlineexplicit |
Set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream, if the passed stream is not nullopt.
Definition at line 134 of file InlineStreamGuard.h.
|
inline |
Returns the most recent stream that was set using this stream guard, either from construction, or via reset_stream, if the guard is initialized, or nullopt if the guard is uninitialized.
Definition at line 174 of file InlineStreamGuard.h.
|
inline |
Returns the stream that was set at the time the guard was most recently initialized, or nullopt if the guard is uninitialized.
Definition at line 167 of file InlineStreamGuard.h.
|
inline |
Resets the currently set stream to the original stream and the currently set device to the original device.
Then, set the current device to the device associated with the passed stream, and set the current stream on that device to the passed stream. Initializes the OptionalStreamGuard if it was not previously initialized.
Definition at line 157 of file InlineStreamGuard.h.