| std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | ||||
| && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_exit(EFP&& deleter) : m_exitFunction(std::move(deleter)), | |||||
| explicit scope_exit(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)), | |||||
| m_execute_on_destruction(true) | m_execute_on_destruction(true) | ||||
| { | { | ||||
| } | } | ||||
| std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | ||||
| std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_exit(EFP&& deleter) try : m_exitFunction(deleter), | |||||
| explicit scope_exit(EFP&& exitFunction) try : m_exitFunction(exitFunction), | |||||
| m_execute_on_destruction(true) | m_execute_on_destruction(true) | ||||
| { | { | ||||
| } | } | ||||
| catch( ... ) | catch( ... ) | ||||
| { | { | ||||
| deleter(); | |||||
| exitFunction(); | |||||
| throw; | throw; | ||||
| } | } | ||||
| template<class EF> | template<class EF> | ||||
| scope_exit<std::decay_t<EF>> make_scope_exit(EF&& deleter) | |||||
| scope_exit<std::decay_t<EF>> make_scope_exit(EF&& exitFunction) | |||||
| { | { | ||||
| return scope_exit<std::decay_t<EF>>{std::forward<EF>(deleter)}; | |||||
| return scope_exit<std::decay_t<EF>>{std::forward<EF>(exitFunction)}; | |||||
| } | } | ||||
| } | } |
| std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | ||||
| && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_fail(EFP&& deleter) : m_exitFunction(std::move(deleter)), | |||||
| explicit scope_fail(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)), | |||||
| m_execute_on_destruction(true), | m_execute_on_destruction(true), | ||||
| m_uncaught_on_creation(uncaught_exceptions()) | m_uncaught_on_creation(uncaught_exceptions()) | ||||
| { | { | ||||
| std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | ||||
| std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_fail(EFP&& deleter) try : m_exitFunction(deleter), | |||||
| explicit scope_fail(EFP&& exitFunction) try : m_exitFunction(exitFunction), | |||||
| m_execute_on_destruction(true), | m_execute_on_destruction(true), | ||||
| m_uncaught_on_creation(uncaught_exceptions()) | m_uncaught_on_creation(uncaught_exceptions()) | ||||
| { | { | ||||
| } | } | ||||
| catch( ... ) | catch( ... ) | ||||
| { | { | ||||
| deleter(); | |||||
| exitFunction(); | |||||
| throw; | throw; | ||||
| } | } | ||||
| template<class EF> | template<class EF> | ||||
| scope_fail<std::decay_t<EF>> make_scope_fail(EF&& deleter) | |||||
| scope_fail<std::decay_t<EF>> make_scope_fail(EF&& exitFunction) | |||||
| { | { | ||||
| return scope_fail<std::decay_t<EF>>{std::forward<EF>(deleter)}; | |||||
| return scope_fail<std::decay_t<EF>>{std::forward<EF>(exitFunction)}; | |||||
| } | } | ||||
| } | } |
| std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | std::enable_if_t<(!std::is_lvalue_reference<EFP>::value) | ||||
| && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | && std::is_nothrow_constructible<EF, EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_success(EFP&& deleter) : m_exitFunction(std::move(deleter)), | |||||
| explicit scope_success(EFP&& exitFunction) : m_exitFunction(std::move(exitFunction)), | |||||
| m_execute_on_destruction(true), | m_execute_on_destruction(true), | ||||
| m_uncaught_on_creation(uncaught_exceptions()) | m_uncaught_on_creation(uncaught_exceptions()) | ||||
| { | { | ||||
| std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | std::enable_if_t<std::is_constructible<EF, EFP>::value, int> = 0, | ||||
| std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | std::enable_if_t<std::is_lvalue_reference<EFP>::value, int> = 0 | ||||
| > | > | ||||
| explicit scope_success(EFP&& deleter) try : m_exitFunction(deleter), | |||||
| explicit scope_success(EFP&& exitFunction) try : m_exitFunction(exitFunction), | |||||
| m_execute_on_destruction(true), | m_execute_on_destruction(true), | ||||
| m_uncaught_on_creation(uncaught_exceptions()) | m_uncaught_on_creation(uncaught_exceptions()) | ||||
| { | { | ||||
| template<class EF> | template<class EF> | ||||
| scope_success<std::decay_t<EF>> make_scope_success(EF&& deleter) | |||||
| scope_success<std::decay_t<EF>> make_scope_success(EF&& exitFunction) | |||||
| { | { | ||||
| return scope_success<std::decay_t<EF>>{std::forward<EF>(deleter)}; | |||||
| return scope_success<std::decay_t<EF>>{std::forward<EF>(exitFunction)}; | |||||
| } | } | ||||
| } | } |