23 class [[nodiscard]] SharedScopeGuard
25 std::shared_ptr<void> Guard_;
28 SharedScopeGuard (
const F&
f)
29 : Guard_ {
nullptr, [
f] (
void*) {
f (); } }
33 SharedScopeGuard () =
delete;
35 SharedScopeGuard (
const SharedScopeGuard&) =
default;
36 SharedScopeGuard (SharedScopeGuard&&) =
default;
38 SharedScopeGuard& operator= (
const SharedScopeGuard&) =
default;
54 ScopeGuard (
const F&
f) noexcept
59 ScopeGuard (
const ScopeGuard&) =
delete;
60 ScopeGuard& operator= (
const ScopeGuard&) =
delete;
68 Perform_ = other.Perform_;
69 other.Perform_ =
false;
75 , Perform_ { other.Perform_ }
77 other.Perform_ =
false;
86 void Dismiss () noexcept
105 throw std::logic_error {
"this scope guard has already been converted to a shared one" };