mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
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:
parent
1d11cd1ed1
commit
ae24c0fe06
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user