| { | { | ||||
| return true; | return true; | ||||
| } | } | ||||
| }; | }; | ||||
| } | } |
| int m_uncaught_on_creation = uncaught_exceptions(); | int m_uncaught_on_creation = uncaught_exceptions(); | ||||
| }; | }; | ||||
| template<class F> | |||||
| constexpr bool is_noexcept_dtor_v<F, scope_fail_strategy> = noexcept(std::declval<F>()()); | |||||
| } | } | ||||
| using detail::scope_guard_base<EF, detail::scope_fail_strategy>::scope_guard_base; | using detail::scope_guard_base<EF, detail::scope_fail_strategy>::scope_guard_base; | ||||
| private: | private: | ||||
| }; | }; |
| namespace detail | namespace detail | ||||
| { | { | ||||
| template<class F, class S> | |||||
| constexpr bool is_noexcept_dtor_v = true; | |||||
| template<class EF, class Strategy> | template<class EF, class Strategy> | ||||
| class scope_guard_base : private Strategy | class scope_guard_base : private Strategy | ||||
| { | { | ||||
| scope_guard_base(const scope_guard_base&) = delete; | scope_guard_base(const scope_guard_base&) = delete; | ||||
| ~scope_guard_base() noexcept(true) | |||||
| ~scope_guard_base() noexcept(is_noexcept_dtor_v<EF, Strategy>) | |||||
| { | { | ||||
| if( (m_execute_on_destruction == true) && (this->should_execute() == true) ) | if( (m_execute_on_destruction == true) && (this->should_execute() == true) ) | ||||
| { | { |
| return ( std::uncaught_exception() == true ? 1 : 0 ); | return ( std::uncaught_exception() == true ? 1 : 0 ); | ||||
| } | } | ||||
| int m_uncaught_on_creation = uncaught_exceptions(); | int m_uncaught_on_creation = uncaught_exceptions(); | ||||
| }; | }; | ||||