OGLplus  (0.59.0) a C++ wrapper for rendering APIs

eagine::on_scope_exit< OnException > Class Template Reference

Class executing a specified action on scope exit. More...

#include <eagine/scope_exit.hpp>

Public Types

using action_type = callable_ref< void()>
 The callable action type.
 

Public Member Functions

 on_scope_exit (action_type action) noexcept
 Construction intializing with the specified action.
 
template<typename Func >
 on_scope_exit (Func &action) noexcept
 Construction intializing with the specified action.
 
 on_scope_exit (on_scope_exit &&temp) noexcept
 Move constructor.
 
 on_scope_exit (const on_scope_exit &)=delete
 Not copy constructible.
 
auto operator= (on_scope_exit &&)=delete
 Not move constructible.
 
auto operator= (const on_scope_exit &)=delete
 Not copy constructible.
 
 ~on_scope_exit () noexcept(false)
 Invokes the stored action, unless it was released or cancelled. More...
 
auto is_active () const noexcept -> bool
 Indicates if there is any on-scope-exit action. More...
 
auto release () noexcept -> action_type
 Moves out and returns the stored action. More...
 
void cancel () noexcept
 Resets the stored action to empty default. More...
 

Detailed Description

template<typename OnException = nothing_t>
class eagine::on_scope_exit< OnException >

Class executing a specified action on scope exit.

See also
func_on_scope_exit
finally

Constructor & Destructor Documentation

◆ ~on_scope_exit()

template<typename OnException = nothing_t>
eagine::on_scope_exit< OnException >::~on_scope_exit ( )
inlinenoexcept

Invokes the stored action, unless it was released or cancelled.

See also
release
cancel

Member Function Documentation

◆ cancel()

template<typename OnException = nothing_t>
void eagine::on_scope_exit< OnException >::cancel ( )
inlinenoexcept

Resets the stored action to empty default.

Postcondition
!is_active()
See also
release
is_active

Referenced by eagine::func_on_scope_exit< Func, OnException >::cancel().

◆ is_active()

template<typename OnException = nothing_t>
auto eagine::on_scope_exit< OnException >::is_active ( ) const -> bool
inlinenoexcept

Indicates if there is any on-scope-exit action.

See also
release
cancel

◆ release()

template<typename OnException = nothing_t>
auto eagine::on_scope_exit< OnException >::release ( ) -> action_type
inlinenoexcept

Moves out and returns the stored action.

Postcondition
!is_active()
See also
cancel
is_active

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).