cesium-native 0.43.0
Loading...
Searching...
No Matches
CesiumUtility::ScopeGuard< ExitFunction > Class Template Reference

A utility that will automatically call the lambda function when exiting a scope. More...

#include <CesiumUtility/ScopeGuard.h>

Public Member Functions

template<typename ExitFunctionArg , typename std::enable_if_t< !std::is_same_v< std::remove_reference_t< std::remove_const_t< ExitFunctionArg > >, ScopeGuard< ExitFunction > >, int > = 0>
 ScopeGuard (ExitFunctionArg &&exitFunc)
 Constructor.
 
 ScopeGuard (const ScopeGuard &rhs)=delete
 
 ScopeGuard (ScopeGuard &&rhs) noexcept
 Move constructor. The rhs will move its lambda to the lhs, and the rhs will not call its lambda upon exiting a scope.
 
ScopeGuardoperator= (const ScopeGuard &rhs)=delete
 
ScopeGuardoperator= (ScopeGuard &&rhs) noexcept
 Move assignment operator. The rhs will move its lambda to the lhs, and the rhs will not call its lambda upon 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 scope.
 

Detailed Description

template<typename ExitFunction>
class CesiumUtility::ScopeGuard< ExitFunction >

A utility that will automatically call the lambda function when exiting a scope.

Template Parameters
ExitFunctionThe function type to be called when the guard is out of scope.

Definition at line 14 of file ScopeGuard.h.

Constructor & Destructor Documentation

◆ ScopeGuard() [1/2]

template<typename ExitFunction >
template<typename ExitFunctionArg , typename std::enable_if_t< !std::is_same_v< std::remove_reference_t< std::remove_const_t< ExitFunctionArg > >, ScopeGuard< ExitFunction > >, int > = 0>
CesiumUtility::ScopeGuard< ExitFunction >::ScopeGuard ( ExitFunctionArg && exitFunc)
inlineexplicit

Constructor.

Parameters
exitFuncThe function type to be called when the guard is out of scope

Definition at line 29 of file ScopeGuard.h.

◆ ScopeGuard() [2/2]

template<typename ExitFunction >
CesiumUtility::ScopeGuard< ExitFunction >::ScopeGuard ( ScopeGuard< ExitFunction > && rhs)
inlinenoexcept

Move constructor. The rhs will move its lambda to the lhs, and the rhs will not call its lambda upon exiting a scope.

Definition at line 39 of file ScopeGuard.h.

◆ ~ScopeGuard()

template<typename ExitFunction >
CesiumUtility::ScopeGuard< ExitFunction >::~ScopeGuard ( )
inlinenoexcept

Destructor. The guard will execute the lambda function when exiting a scope if it's not released.

Definition at line 65 of file ScopeGuard.h.

Member Function Documentation

◆ operator=()

template<typename ExitFunction >
ScopeGuard & CesiumUtility::ScopeGuard< ExitFunction >::operator= ( ScopeGuard< ExitFunction > && rhs)
inlinenoexcept

Move assignment operator. The rhs will move its lambda to the lhs, and the rhs will not call its lambda upon exiting a scope.

Definition at line 51 of file ScopeGuard.h.

◆ release()

template<typename ExitFunction >
void CesiumUtility::ScopeGuard< ExitFunction >::release ( )
inlinenoexcept

Upon calling ScopeGuard::release(), the guard will not execute the lambda function when exiting a scope.

Definition at line 75 of file ScopeGuard.h.


The documentation for this class was generated from the following file: