|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #pragma once
-
- #include "detail/scope_guard_base.h"
- #include <exception>
-
- namespace sr
- {
- namespace detail
- {
-
- struct scope_fail_strategy
- {
- bool should_execute() const noexcept
- {
- return std::uncaught_exceptions() > uncaught_on_creation;
- }
-
-
- int uncaught_on_creation = std::uncaught_exceptions();
- };
-
- }
-
-
- template<class EF>
- class scope_fail : public detail::scope_guard_base<EF, detail::scope_fail_strategy>
- {
- using ScopeGuardBase = std::enable_if_t<!std::is_same_v<detail::remove_cvref_t<EF>, scope_fail<EF>>,
- detail::scope_guard_base<EF, detail::scope_fail_strategy>
- >;
-
- public:
-
- using ScopeGuardBase::ScopeGuardBase;
-
- };
-
-
- template<class EF>
- scope_fail(EF) -> scope_fail<EF>;
-
- }
|