Change finally() to make_final_act()

This commit is contained in:
Kern Handa 2015-09-23 23:04:12 -07:00
parent 186001611a
commit 1890741079
2 changed files with 8 additions and 8 deletions

View File

@ -59,9 +59,9 @@ private:
F f_; F f_;
}; };
// finally() - convenience function to generate a Final_act // make_final_act() - convenience function to generate a Final_act
template <class F> 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 // narrow_cast(): a searchable way to do narrowing casts of values
template<class T, class U> template<class T, class U>

View File

@ -27,21 +27,21 @@ SUITE(utils_tests)
i += 1; i += 1;
} }
TEST(finally_lambda) TEST(make_final_act_lambda)
{ {
int i = 0; int i = 0;
{ {
auto _ = finally([&]() {f(i);}); auto _ = make_final_act([&]() {f(i);});
CHECK(i == 0); CHECK(i == 0);
} }
CHECK(i == 1); CHECK(i == 1);
} }
TEST(finally_function_with_bind) TEST(make_final_act_function_with_bind)
{ {
int i = 0; 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 == 0);
} }
CHECK(i == 1); CHECK(i == 1);
@ -49,11 +49,11 @@ SUITE(utils_tests)
int j = 0; int j = 0;
void g() { j += 1; }; void g() { j += 1; };
TEST(finally_function_ptr) TEST(make_final_act_function_ptr)
{ {
j = 0; j = 0;
{ {
auto _ = finally(&g); auto _ = make_final_act(&g);
CHECK(j == 0); CHECK(j == 0);
} }
CHECK(j == 1); CHECK(j == 1);