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.

This commit is contained in:
john-lynch 2015-09-29 00:03:15 -05:00
parent 1d11cd1ed1
commit ae24c0fe06

View File

@ -37,6 +37,20 @@ SUITE(utils_tests)
CHECK(i == 1); 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) TEST(finally_function_with_bind)
{ {
int i = 0; int i = 0;