Figured out test failures, removed move test

We shouldn't be moving these `final_action`s around, that wasn't part of the C++CG design requirements.
Went back to the simple version of `final_action`.
This commit is contained in:
Herb Sutter 2021-02-24 16:42:58 -08:00
parent e9c575300e
commit f59cb795a0
2 changed files with 5 additions and 24 deletions

View File

@ -52,14 +52,14 @@ template <class F>
class final_action
{
public:
explicit final_action(F f) : f_(std::move(f)) { }
~final_action() { f_(); }
explicit final_action(F f_) : f(f_) { }
~final_action() { f(); }
final_action(const final_action&) = default;
final_action& operator=(const final_action&) = default;
final_action(const final_action& rhs) = delete;
final_action& operator=(const final_action&) = delete;
private:
F f_;
F f;
};
// finally() - convenience function to generate a final_action

View File

@ -51,25 +51,6 @@ TEST(utils_tests, finally_lambda)
EXPECT_TRUE(i == 1);
}
TEST(utils_tests, finally_lambda_move)
{
int i = 0;
{
auto _1 = finally([&]() { f(i); });
{
auto _2 = std::move(_1);
EXPECT_TRUE(i == 0);
}
EXPECT_TRUE(i == 1);
{
auto _2 = std::move(_1);
EXPECT_TRUE(i == 1);
}
EXPECT_TRUE(i == 1);
}
EXPECT_TRUE(i == 1);
}
TEST(utils_tests, finally_const_lvalue_lambda)
{
int i = 0;