From ae24c0fe06f92a2a77fb4dbd0098335519a54390 Mon Sep 17 00:00:00 2001 From: john-lynch Date: Tue, 29 Sep 2015 00:03:15 -0500 Subject: [PATCH] Added test that Final_act object can be moved properly. While this is not a common case, it may happen if the user calls finally and the compiler fails to perform RVO. --- tests/utils_tests.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 0dc4809..66b6d14 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -37,6 +37,20 @@ SUITE(utils_tests) CHECK(i == 1); } + TEST(finally_lambda_move) + { + int i = 0; + { + auto _1 = finally([&]() {f(i);}); + { + auto _2 = std::move(_1); + CHECK(i == 0); + } + CHECK(i == 1); + } + CHECK(i == 1); + } + TEST(finally_function_with_bind) { int i = 0;