Skip to content

Commit

Permalink
small cleanup in utils.hpp.
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Oct 7, 2023
1 parent 7df85b5 commit 0f422fd
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions include/gtl/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,11 @@ class scoped_set_unset
std::forward<Set>(set)();
}

~scoped_set_unset() noexcept(noexcept(this->unset_()))
{
if (do_it_)
unset_();
}
~scoped_set_unset() { if (do_it_) unset_(); }

void dismiss() noexcept { do_it_ = false; }

scoped_set_unset(scoped_set_unset&&) = delete;
scoped_set_unset(const scoped_set_unset&) = delete;
scoped_set_unset& operator=(const scoped_set_unset&) = delete;
void* operator new(std::size_t) = delete;
Expand Down Expand Up @@ -74,14 +71,11 @@ class scoped_guard
{
}

~scoped_guard() noexcept(noexcept(this->unset_()))
{
if (do_it_)
unset_();
}
~scoped_guard() { if (do_it_) unset_(); }

void dismiss() noexcept { do_it_ = false; }

scoped_guard(scoped_guard&&) = delete;
scoped_guard(const scoped_guard&) = delete;
scoped_guard& operator=(const scoped_guard&) = delete;
void* operator new(std::size_t) = delete;
Expand Down Expand Up @@ -119,11 +113,7 @@ class scoped_set_value
}
}

~scoped_set_value() noexcept(std::is_nothrow_move_assignable_v<T>)
{
if (do_it_)
v_ = std::move(old_value_);
}
~scoped_set_value() { if (do_it_) v_ = std::move(old_value_); }

void dismiss() noexcept { do_it_ = false; }

Expand Down

0 comments on commit 0f422fd

Please sign in to comment.