11#define MR_FINALLY DETAIL_MR_FINALLY( ScopeGuard )
13#ifdef __cpp_exceptions
16#define MR_FINALLY_ON_SUCCESS DETAIL_MR_FINALLY( ExceptionScopeGuard<true>::Type )
19#define MR_FINALLY_ON_THROW DETAIL_MR_FINALLY( ExceptionScopeGuard<false>::Type )
24#define MR_FINALLY_ON_SUCCESS MR_FINALLY
26#define MR_FINALLY_ON_THROW (void)[&]()
30#define DETAIL_MR_FINALLY( type_ ) \
31 auto MR_CONCAT( _mrScopeGuard, __COUNTER__ ) = ::MR::detail::MakeScopeGuard<::MR::detail::type_>{} ->* [&]() -> void
48#ifdef __cpp_exceptions
49template <
bool Success>
50struct ExceptionScopeGuard
56 int ex = std::uncaught_exceptions();
59 Type( F&& func ) : func( std::move( func ) ) {}
60 Type(
const Type& ) =
delete;
61 Type& operator=(
const Type& ) =
delete;
62 ~Type() noexcept( !Success )
64 if ( ( ex == std::uncaught_exceptions() ) == Success )
71template <
template <
typename>
typename T>
77 return T<F>( std::move( func ) );
Definition MRFinally.h:38
~ScopeGuard()
Definition MRFinally.h:45
ScopeGuard(F &&func)
Definition MRFinally.h:42
ScopeGuard & operator=(const ScopeGuard &)=delete
ScopeGuard(const ScopeGuard &)=delete
Definition MRFinally.h:34
Definition MRFinally.h:73
T< F > operator->*(F &&func)
Definition MRFinally.h:75