mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Change finally() to make_final_act()
This commit is contained in:
parent
186001611a
commit
1890741079
@ -59,9 +59,9 @@ private:
|
||||
F f_;
|
||||
};
|
||||
|
||||
// finally() - convenience function to generate a Final_act
|
||||
// make_final_act() - convenience function to generate a Final_act
|
||||
template <class F>
|
||||
Final_act<F> finally(F f) { return Final_act<F>(f); }
|
||||
Final_act<F> make_final_act(F f) { return Final_act<F>(f); }
|
||||
|
||||
// narrow_cast(): a searchable way to do narrowing casts of values
|
||||
template<class T, class U>
|
||||
|
@ -27,21 +27,21 @@ SUITE(utils_tests)
|
||||
i += 1;
|
||||
}
|
||||
|
||||
TEST(finally_lambda)
|
||||
TEST(make_final_act_lambda)
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
auto _ = finally([&]() {f(i);});
|
||||
auto _ = make_final_act([&]() {f(i);});
|
||||
CHECK(i == 0);
|
||||
}
|
||||
CHECK(i == 1);
|
||||
}
|
||||
|
||||
TEST(finally_function_with_bind)
|
||||
TEST(make_final_act_function_with_bind)
|
||||
{
|
||||
int i = 0;
|
||||
{
|
||||
auto _ = finally(std::bind(&f, std::ref(i)));
|
||||
auto _ = make_final_act(std::bind(&f, std::ref(i)));
|
||||
CHECK(i == 0);
|
||||
}
|
||||
CHECK(i == 1);
|
||||
@ -49,11 +49,11 @@ SUITE(utils_tests)
|
||||
|
||||
int j = 0;
|
||||
void g() { j += 1; };
|
||||
TEST(finally_function_ptr)
|
||||
TEST(make_final_act_function_ptr)
|
||||
{
|
||||
j = 0;
|
||||
{
|
||||
auto _ = finally(&g);
|
||||
auto _ = make_final_act(&g);
|
||||
CHECK(j == 0);
|
||||
}
|
||||
CHECK(j == 1);
|
||||
|
Loading…
Reference in New Issue
Block a user