MeVisLab Toolbox Reference
mlScopeGuard.h File Reference
#include "mlTypeDefs.h"
#include <utility>

Go to the source code of this file.

Classes

class  ml::ScopeGuardDetail::ScopeGuard< Functor >
 

Namespaces

 ml
 Main documentation file for ML users and developers.
 
 ml::ScopeGuardDetail
 

Macros

#define ML_UTILITIES_CONCATENATE_IMPL(s1, s2)   s1##s2
 Helper class for performing actions when the current scope is left. More...
 
#define ML_UTILITIES_CONCATENATE(s1, s2)   ML_UTILITIES_CONCATENATE_IMPL(s1,s2)
 
#define ML_UTILITIES_ANONYMOUS_VARIABLE(str)    ML_UTILITIES_CONCATENATE(str,__LINE__)
 
#define SCOPE_EXIT
 Use this macro in case of an anonymous scope guard like SCOPE_EXIT { foo.needsToBeDoneOnLeavingTheScope(); };. More...
 
#define EXPLICIT_SCOPE_EXIT    ::ML_NAMESPACE::ScopeGuardDetail::ScopeGuardOnExit() + [&]()
 Use this macro in case you like an explicit ScopeGuard This is handy if there is a case where you want to dismiss the action to be taken on leaving the scope. More...
 

Enumerations

enum class  ml::ScopeGuardDetail::ScopeGuardOnExit
 

Functions

template<class Functor >
ScopeGuard< Functor > ml::ScopeGuardDetail::operator+ (ScopeGuardOnExit, Functor &&fn)
 

Macro Definition Documentation

◆ EXPLICIT_SCOPE_EXIT

#define EXPLICIT_SCOPE_EXIT    ::ML_NAMESPACE::ScopeGuardDetail::ScopeGuardOnExit() + [&]()

Use this macro in case you like an explicit ScopeGuard This is handy if there is a case where you want to dismiss the action to be taken on leaving the scope.

auto localGuard = EXPLICIT_SCOPE_EXIT { foo.needsToBeDoneOnLeavingTheScope(); }; ... if (specialCase) { localGuard.dismiss(); }

Note: Don't forget the semicolon after the closing brace!

Definition at line 116 of file mlScopeGuard.h.

◆ ML_UTILITIES_ANONYMOUS_VARIABLE

#define ML_UTILITIES_ANONYMOUS_VARIABLE (   str)     ML_UTILITIES_CONCATENATE(str,__LINE__)

Definition at line 33 of file mlScopeGuard.h.

◆ ML_UTILITIES_CONCATENATE

#define ML_UTILITIES_CONCATENATE (   s1,
  s2 
)    ML_UTILITIES_CONCATENATE_IMPL(s1,s2)

Definition at line 25 of file mlScopeGuard.h.

◆ ML_UTILITIES_CONCATENATE_IMPL

#define ML_UTILITIES_CONCATENATE_IMPL (   s1,
  s2 
)    s1##s2

Helper class for performing actions when the current scope is left.

Original implemention by Andrei Alexandrescu

Definition at line 24 of file mlScopeGuard.h.

◆ SCOPE_EXIT

#define SCOPE_EXIT
Value:
auto ML_UTILITIES_ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE) \
#define ML_UTILITIES_ANONYMOUS_VARIABLE(str)
Definition: mlScopeGuard.h:33

Use this macro in case of an anonymous scope guard like SCOPE_EXIT { foo.needsToBeDoneOnLeavingTheScope(); };.

Note: Don't forget the semicolon after the closing brace!

Definition at line 96 of file mlScopeGuard.h.