Skip to content

Commit

Permalink
Made scope exit class abide rule of 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Nov 23, 2024
1 parent 03f16e4 commit b7c220a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmake/dependencies/interval_tree.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
option(NUI_FETCH_INTERVAL_TREE "Fetch interval tree" ON)
set(NUI_INTERVAL_TREE_GIT_REPOSITORY "https://github.com/5cript/interval-tree.git" CACHE STRING "interval tree git repository")
set(NUI_INTERVAL_TREE_GIT_TAG "v2.2.4" CACHE STRING "interval tree git tag")
set(NUI_INTERVAL_TREE_GIT_TAG "v2.3.2" CACHE STRING "interval tree git tag")

if(NUI_FETCH_INTERVAL_TREE)
include(FetchContent)
Expand Down
21 changes: 19 additions & 2 deletions nui/include/nui/utility/scope_exit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,28 @@ namespace Nui
{}
~ScopeExit()
{
onExit_();
if (onExit_)
onExit_();
}
ScopeExit(ScopeExit&& other)
: onExit_(std::move(other.onExit_))
{
other.onExit_ = {};
}
ScopeExit& operator=(ScopeExit&& other)
{
if (this != &other)
{
onExit_ = std::move(other.onExit_);
other.onExit_ = {};
}
return *this;
}
ScopeExit(const ScopeExit&) = delete;
ScopeExit& operator=(const ScopeExit&) = delete;
void disarm()
{
onExit_ = [] {};
onExit_ = {};
}

private:
Expand Down

0 comments on commit b7c220a

Please sign in to comment.