avcpp  2.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Public Member Functions | List of all members
av::ScopeOutAction Class Reference

The ScopeOutAction class - guard-type class that allows points callback that will be called at the scope out. More...

#include <avutils.h>

Public Member Functions

template<typename Proc >
 ScopeOutAction (const Proc &proc)
 
template<typename Proc >
 ScopeOutAction (Proc &&proc)
 
 ~ScopeOutAction ()
 

Detailed Description

The ScopeOutAction class - guard-type class that allows points callback that will be called at the scope out.

Example:

void foo()
{
int fd = open(...some args...);
ScopeOutAction action([fd](){
close(fd);
});
try
{
// some actions that can throw exception
}
catch(...)
{
throw; // Not best-practice, only for example
}
}

In example above dtor of the action will be called before fd and we correctly close descriptor.

Constructor & Destructor Documentation

◆ ScopeOutAction() [1/2]

template<typename Proc >
av::ScopeOutAction::ScopeOutAction ( const Proc &  proc)
inline

◆ ScopeOutAction() [2/2]

template<typename Proc >
av::ScopeOutAction::ScopeOutAction ( Proc &&  proc)
inline

◆ ~ScopeOutAction()

av::ScopeOutAction::~ScopeOutAction ( )
inline

The documentation for this class was generated from the following file:
av::ScopeOutAction::ScopeOutAction
ScopeOutAction(const Proc &proc)
Definition: avutils.h:280