header_utils
Loading...
Searching...
No Matches
ghassanpl::counted_scope_guard< EF > Struct Template Reference

A RAII class that executes a function on destruction, if its request counter is greater than zero. More...

#include <scope.h>

Public Member Functions

template<class EFP >
 counted_scope_guard (EFP &&f, int initial_count=0) noexcept(noexcept(EFP(std::forward< EFP >(f))))
 
 counted_scope_guard (counted_scope_guard &&rhs) noexcept(noexcept(EF(std::move(rhs.m_exit_function))))
 
 counted_scope_guard (const counted_scope_guard &)=delete
 
counted_scope_guardoperator= (const counted_scope_guard &)=delete
 
counted_scope_guardoperator= (counted_scope_guard &&)=delete
 
 ~counted_scope_guard () noexcept(noexcept(m_exit_function()))
 Executes the function on destruction if the request counter is greater than zero.
 
void request () noexcept
 Increments the request counter.
 
void unrequest () noexcept
 Decrements the request counter.
 
void release () noexcept
 Releases the guard, so that it will not execute the function on destruction.
 
bool will_execute_on_destruction () const noexcept
 

Detailed Description

template<class EF>
struct ghassanpl::counted_scope_guard< EF >

A RAII class that executes a function on destruction, if its request counter is greater than zero.

Definition at line 56 of file scope.h.

Constructor & Destructor Documentation

◆ counted_scope_guard() [1/2]

template<class EF >
template<class EFP >
ghassanpl::counted_scope_guard< EF >::counted_scope_guard ( EFP &&  f,
int  initial_count = 0 
)
inlineexplicitnoexcept

Definition at line 59 of file scope.h.

◆ counted_scope_guard() [2/2]

template<class EF >
ghassanpl::counted_scope_guard< EF >::counted_scope_guard ( counted_scope_guard< EF > &&  rhs)
inlinenoexcept

Definition at line 65 of file scope.h.

◆ ~counted_scope_guard()

template<class EF >
ghassanpl::counted_scope_guard< EF >::~counted_scope_guard ( )
inlinenoexcept

Executes the function on destruction if the request counter is greater than zero.

Definition at line 76 of file scope.h.

Member Function Documentation

◆ release()

template<class EF >
void ghassanpl::counted_scope_guard< EF >::release ( )
inlinenoexcept

Releases the guard, so that it will not execute the function on destruction.

Definition at line 96 of file scope.h.

◆ request()

template<class EF >
void ghassanpl::counted_scope_guard< EF >::request ( )
inlinenoexcept

Increments the request counter.

Definition at line 83 of file scope.h.

◆ unrequest()

template<class EF >
void ghassanpl::counted_scope_guard< EF >::unrequest ( )
inlinenoexcept

Decrements the request counter.

Definition at line 89 of file scope.h.

◆ will_execute_on_destruction()

template<class EF >
bool ghassanpl::counted_scope_guard< EF >::will_execute_on_destruction ( ) const
inlinenoexcept

Definition at line 101 of file scope.h.