Loading...
Searching...
No Matches
meshkit::detail::ScopeExit< F > Class Template Reference

Scope guard that calls a callable when it is destroyed. More...

#include <meshkit/detail/storage.hpp>

Collaboration diagram for meshkit::detail::ScopeExit< F >:

Public Member Functions

 ScopeExit (F f)
 Store the callable.
 
 ~ScopeExit ()
 Invoke the stored callable.
 
 ScopeExit (const ScopeExit &)=delete
 Not copyable (and therefore not movable).
 

Detailed Description

template<class F>
class meshkit::detail::ScopeExit< F >

Scope guard that calls a callable when it is destroyed.

Create it with scopeExit(). The guard is neither copyable nor movable (the deleted copy constructor also suppresses the move constructor) and cannot be dismissed, so the callable runs exactly once, when the guard leaves scope, on normal exit or during stack unwinding. The destructor is implicitly noexcept: an exception escaping the callable calls std::terminate.

Template Parameters
FCallable taking no arguments; its result is discarded.

Constructor & Destructor Documentation

◆ ScopeExit() [1/2]

template<class F>
meshkit::detail::ScopeExit< F >::ScopeExit ( F f)
inlineexplicit

Store the callable.

Parameters
[in]fCallable, moved into the guard; anything it captures by reference must outlive the guard.
Here is the caller graph for this function:

◆ ~ScopeExit()

template<class F>
meshkit::detail::ScopeExit< F >::~ScopeExit ( )
inline

Invoke the stored callable.

◆ ScopeExit() [2/2]

template<class F>
meshkit::detail::ScopeExit< F >::ScopeExit ( const ScopeExit< F > & )
delete

Not copyable (and therefore not movable).

Here is the call graph for this function:

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