xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::tools::DeferThrowing< Callable > Class Template Referencefinal

A class that executes a callable at destruct time, catching exceptions if necessary. More...

#include <xentara/utils/tools/Defer.hpp>

+ Inheritance diagram for xentara::utils::tools::DeferThrowing< Callable >:

Public Member Functions

 DeferThrowing (Callable &&callable) noexcept(std::is_nothrow_move_constructible_v< Callable >)
 Constructor.
 
 DeferThrowing (const Callable &callable) noexcept(std::is_nothrow_copy_constructible_v< Callable >)
 Constructor.
 
 ~DeferThrowing () noexcept(std::is_nothrow_invocable_v< Callable >)
 Destructor.
 

Detailed Description

template<std::invocable<> Callable>
class xentara::utils::tools::DeferThrowing< Callable >

A class that executes a callable at destruct time, catching exceptions if necessary.

This class stores a callable object like a lambda and executes it at the end of the block. If the callable can throw exceptions, the exceptions are caugh during stack rollup only.

Template Parameters
CallableThe type of the object.

Constructor & Destructor Documentation

◆ DeferThrowing() [1/2]

template<std::invocable<> Callable>
xentara::utils::tools::DeferThrowing< Callable >::DeferThrowing ( Callable &&  callable)
noexcept

Constructor.

Parameters
callableAn object that logs the exception infos

◆ DeferThrowing() [2/2]

template<std::invocable<> Callable>
xentara::utils::tools::DeferThrowing< Callable >::DeferThrowing ( const Callable &  callable)
noexcept

Constructor.

Parameters
callableAn object that logs the exception infos

◆ ~DeferThrowing()

template<std::invocable<> Callable>
xentara::utils::tools::DeferThrowing< Callable >::~DeferThrowing ( )
noexcept

Destructor.

The destructor executes the callable