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

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

Macros

#define ML_UTILITIES_CONCATENATE_IMPL(s1, s2)   s1##s2
 Helper class for performing actions when the current scope is left.
 
#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(); };.
 
#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.
 

Enumerations

enum class  ml::ScopeGuardDetail::ScopeGuardOnExit
 

Functions

template<class Functor >
ScopeGuard< Functorml::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:
= ::ML_NAMESPACE::ScopeGuardDetail::ScopeGuardOnExit() + [&]()
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#define ML_UTILITIES_ANONYMOUS_VARIABLE(str)

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.