mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Fix moving a final_act twice
This commit is contained in:
parent
df88352c1d
commit
b8ec73a179
@ -80,7 +80,7 @@ class final_act
|
|||||||
public:
|
public:
|
||||||
explicit final_act(F f) noexcept : f_(std::move(f)), invoke_(true) {}
|
explicit final_act(F f) noexcept : f_(std::move(f)), invoke_(true) {}
|
||||||
|
|
||||||
final_act(final_act&& other) noexcept : f_(std::move(other.f_)), invoke_(true) { other.invoke_ = false; }
|
final_act(final_act&& other) noexcept : f_(std::move(other.f_)), invoke_(other.invoke_) { other.invoke_ = false; }
|
||||||
final_act(const final_act&) = delete;
|
final_act(const final_act&) = delete;
|
||||||
final_act& operator=(const final_act&) = delete;
|
final_act& operator=(const final_act&) = delete;
|
||||||
|
|
||||||
|
@ -44,9 +44,14 @@ SUITE(utils_tests)
|
|||||||
auto _1 = finally([&]() {f(i);});
|
auto _1 = finally([&]() {f(i);});
|
||||||
{
|
{
|
||||||
auto _2 = std::move(_1);
|
auto _2 = std::move(_1);
|
||||||
CHECK(i == 0);
|
CHECK(i == 0);
|
||||||
}
|
}
|
||||||
CHECK(i == 1);
|
CHECK(i == 1);
|
||||||
|
{
|
||||||
|
auto _2 = std::move(_1);
|
||||||
|
CHECK(i == 1);
|
||||||
|
}
|
||||||
|
CHECK(i == 1);
|
||||||
}
|
}
|
||||||
CHECK(i == 1);
|
CHECK(i == 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user