OpenMS  2.8.0
Public Member Functions | Private Attributes | List of all members
RAIICleanup Class Reference

Exception-safe way of executing arbitrary code at the end of a scope. More...

#include <OpenMS/CONCEPT/RAIICleanup.h>

Collaboration diagram for RAIICleanup:
[legend]

Public Member Functions

 RAIICleanup ()=delete
 no default CTor; we need a lambda More...
 
 RAIICleanup (std::function< void()> l)
 pass in any lambda you like which does the cleanup at the end More...
 
 ~RAIICleanup ()
 

Private Attributes

std::function< void()> l_
 called upon destruction More...
 

Detailed Description

Exception-safe way of executing arbitrary code at the end of a scope.

Just pass in a (capturing) lambda function, which will be called upon destruction of an instance of this class.

Constructor & Destructor Documentation

◆ RAIICleanup() [1/2]

RAIICleanup ( )
delete

no default CTor; we need a lambda

◆ RAIICleanup() [2/2]

RAIICleanup ( std::function< void()>  l)
inline

pass in any lambda you like which does the cleanup at the end

◆ ~RAIICleanup()

~RAIICleanup ( )
inline

References RAIICleanup::l_.

Member Data Documentation

◆ l_

std::function<void()> l_
private

called upon destruction

Referenced by RAIICleanup::~RAIICleanup().