diff --git a/include/gsl/util b/include/gsl/util index f853777..ebaeef6 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -52,14 +52,14 @@ template 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 diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 74dc990..705f384 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -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;