xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::tools::Defer< Callable > Class Template Referencefinal

A class that executes a callable at destruct time. More...

#include <tools/Defer.hpp>

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

Public Member Functions

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

Detailed Description

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

A class that executes a callable at destruct time.

This class stores a callable object like a lambda and executes it at the end of the block.

Template Parameters
CallableThe type of the object.

Constructor & Destructor Documentation

◆ Defer() [1/2]

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

Constructor.

Parameters
callableAn object that logs the exception infos

◆ Defer() [2/2]

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

Constructor.

Parameters
callableAn object that logs the exception infos

◆ ~Defer()

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

Destructor.

The destructor executes the callable