distortos  v0.5.0
object-oriented C++ RTOS for microcontrollers
estd::ScopeGuard< Function > Class Template Reference

ScopeGuard template class is a idiom introduced by Andrei Alexandrescu and proposed for C++14 in N3949. More...

#include <ScopeGuard.hpp>

Public Member Functions

constexpr ScopeGuard (Function &&function) noexcept
 ScopeGuard's constructor. More...
 
 ScopeGuard (ScopeGuard &&other) noexcept
 ScopeGuard's move constructor. More...
 
 ~ScopeGuard () noexcept
 ScopeGuard's destructor. More...
 
void release () noexcept
 Releases ScopeGuard. More...
 
 ScopeGuard (const ScopeGuard &)=delete
 
ScopeGuardoperator= (const ScopeGuard &)=delete
 
ScopeGuardoperator= (ScopeGuard &&)=delete
 

Private Attributes

Function function_
 function executed on scope exit More...
 
bool released_
 true if object is released (bound function will not be executed), false otherwise More...
 

Detailed Description

template<typename Function>
class estd::ScopeGuard< Function >

ScopeGuard template class is a idiom introduced by Andrei Alexandrescu and proposed for C++14 in N3949.

http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2014/n3949.pdf http://channel9.msdn.com/Shows/Going+Deep/C-and-Beyond-2012-Andrei-Alexandrescu-Systematic-Error-Handling-in-C

Template Parameters
Functionis the type of function executed on scope exit

Constructor & Destructor Documentation

◆ ScopeGuard() [1/2]

template<typename Function >
constexpr estd::ScopeGuard< Function >::ScopeGuard ( Function &&  function)
inlineexplicitnoexcept

ScopeGuard's constructor.

Parameters
[in]functionis a rvalue reference to function executed on scope exit
Here is the caller graph for this function:

◆ ScopeGuard() [2/2]

template<typename Function >
estd::ScopeGuard< Function >::ScopeGuard ( ScopeGuard< Function > &&  other)
inlinenoexcept

ScopeGuard's move constructor.

Parameters
[in]otheris a rvalue reference to ScopeGuard used as source of move

◆ ~ScopeGuard()

template<typename Function >
estd::ScopeGuard< Function >::~ScopeGuard ( )
inlinenoexcept

ScopeGuard's destructor.

If not already "released", executes bound function.

Member Function Documentation

◆ release()

template<typename Function >
void estd::ScopeGuard< Function >::release ( )
inlinenoexcept

Releases ScopeGuard.

After this call, the bound function will not be executed when this object goes out of scope.

Here is the call graph for this function:

Member Data Documentation

◆ function_

template<typename Function >
Function estd::ScopeGuard< Function >::function_
private

function executed on scope exit

◆ released_

template<typename Function >
bool estd::ScopeGuard< Function >::released_
private

true if object is released (bound function will not be executed), false otherwise


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