Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion orc-rt/include/orc-rt/ScopeExit.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ namespace detail {

template <typename Fn> class ScopeExitRunner {
public:
ScopeExitRunner(Fn &&F) : F(F) {}
template <typename FnInit>
ScopeExitRunner(FnInit &&F) : F(std::forward<FnInit>(F)) {}
ScopeExitRunner(const ScopeExitRunner &) = delete;
ScopeExitRunner &operator=(const ScopeExitRunner &) = delete;
ScopeExitRunner(ScopeExitRunner &&) = delete;
Expand Down
12 changes: 12 additions & 0 deletions orc-rt/unittests/ScopeExitTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,15 @@ TEST(ScopeExitTest, Release) {
}
EXPECT_FALSE(ScopeExitRun);
}

TEST(ScopeExitTest, MoveOnlyFunctionObject) {
struct MoveOnly {
MoveOnly() = default;
MoveOnly(MoveOnly &&) = default;
void operator()() {}
};

{
auto OnExit = make_scope_exit(MoveOnly());
}
}
Loading