opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
osc::ScopeExit< EF > Class Template Referencefinal

#include <scope_exit.h>

Public Member Functions

template<typename Fn >
requires ( std::destructible<EF> and std::is_constructible_v<EF, Fn> and not std::same_as<std::remove_cvref_t<Fn>, ScopeExit> )
 ScopeExit (Fn &&fn)
 Constructs a ScopeExit from a function or function object.
 
 ScopeExit (const ScopeExit &)=delete
 
 ScopeExit (ScopeExit &&tmp) noexcept
 
 ScopeExit (ScopeExit &&tmp) noexcept(std::is_nothrow_copy_constructible_v< EF >)
 
ScopeExitoperator= (const ScopeExit &)=delete
 
ScopeExitoperator= (ScopeExit &&) noexcept=delete
 
 ~ScopeExit () noexcept
 
void release () noexcept
 

Detailed Description

template<std::invocable EF>
class osc::ScopeExit< EF >

A general-purpose scope guard intended to call its exit function when a scope is exited - either normally, or via an exception.

This utility class is effectively a rewrite of std::experimental::scope_exit, which is documented here: https://en.cppreference.com/w/cpp/experimental/scope_exit.html

Constructor & Destructor Documentation

◆ ScopeExit() [1/4]

template<std::invocable EF>
template<typename Fn >
requires ( std::destructible<EF> and std::is_constructible_v<EF, Fn> and not std::same_as<std::remove_cvref_t<Fn>, ScopeExit> )
osc::ScopeExit< EF >::ScopeExit ( Fn &&  fn)
inlineexplicit

Constructs a ScopeExit from a function or function object.

◆ ScopeExit() [2/4]

template<std::invocable EF>
osc::ScopeExit< EF >::ScopeExit ( const ScopeExit< EF > &  )
delete

◆ ScopeExit() [3/4]

template<std::invocable EF>
osc::ScopeExit< EF >::ScopeExit ( ScopeExit< EF > &&  tmp)
inlinenoexcept

Move constructor. Initializes the stored function with the one in tmp. The constructed ScopeExit is active if and only if tmp is active. After successful move construction, tmp becomes inactive.

◆ ScopeExit() [4/4]

template<std::invocable EF>
osc::ScopeExit< EF >::ScopeExit ( ScopeExit< EF > &&  tmp)
inlinenoexcept

Move constructor. Initializes the stored function with the one in tmp. The constructed ScopeExit is active if and only if tmp is active. After successful move construction, tmp becomes inactive.

◆ ~ScopeExit()

template<std::invocable EF>
osc::ScopeExit< EF >::~ScopeExit ( )
inlinenoexcept

Member Function Documentation

◆ operator=() [1/2]

template<std::invocable EF>
ScopeExit & osc::ScopeExit< EF >::operator= ( const ScopeExit< EF > &  )
delete

◆ operator=() [2/2]

template<std::invocable EF>
ScopeExit & osc::ScopeExit< EF >::operator= ( ScopeExit< EF > &&  )
deletenoexcept

◆ release()

template<std::invocable EF>
void osc::ScopeExit< EF >::release ( )
inlinenoexcept

Makes the ScopeExit inactive, meaning it will not call its exit function on destruction.

Once a ScopeExit is inactive, it cannot become active again.


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