23 typename ExitFunctionArg,
24 typename std::enable_if_t<
26 std::remove_reference_t<std::remove_const_t<ExitFunctionArg>>,
30 : _callExitFuncOnDestruct{true},
31 _exitFunc{std::forward<ExitFunctionArg>(_exitFunc)} {}
40 : _callExitFuncOnDestruct{rhs._callExitFuncOnDestruct},
41 _exitFunc{std::move(rhs._exitFunc)} {
53 _callExitFuncOnDestruct = rhs._callExitFuncOnDestruct;
54 _exitFunc = std::move(rhs._exitFunc);
66 if (_callExitFuncOnDestruct) {
75 void release() noexcept { _callExitFuncOnDestruct =
false; }
78 bool _callExitFuncOnDestruct;
79 ExitFunction _exitFunc;
82 template <
typename ExistFunction>
83 ScopeGuard(ExistFunction) -> ScopeGuard<ExistFunction>;
A utility that will automatically call the lambda function when exiting a scope.
~ScopeGuard() noexcept
Destructor. The guard will execute the lambda function when exiting a scope if it's not released.
void release() noexcept
Upon calling ScopeGuard::release(), the guard will not execute the lambda function when exiting a sco...
ScopeGuard(ScopeGuard &&rhs) noexcept
Move constructor. The rhs will move its lambda to the lhs, and the rhs will not call its lambda upon ...
ScopeGuard & operator=(ScopeGuard &&rhs) noexcept
Move assignment operator. The rhs will move its lambda to the lhs, and the rhs will not call its lamb...
ScopeGuard(ExitFunctionArg &&_exitFunc)
Constructor.
Utility classes for Cesium.