diff --git a/include/gsl/util b/include/gsl/util index db6a85e..75c78ad 100644 --- a/include/gsl/util +++ b/include/gsl/util @@ -87,7 +87,7 @@ private: template GSL_NODISCARD auto finally(F&& f) noexcept { - return final_action>>{std::forward(f)}; + return final_action>{std::forward(f)}; } // narrow_cast(): a searchable way to do narrowing casts of values diff --git a/tests/utils_tests.cpp b/tests/utils_tests.cpp index 715073f..7e1e77d 100644 --- a/tests/utils_tests.cpp +++ b/tests/utils_tests.cpp @@ -112,6 +112,16 @@ TEST(utils_tests, finally_function_ptr) EXPECT_TRUE(j == 1); } +TEST(utils_tests, finally_function) +{ + j = 0; + { + auto _ = finally(g); + EXPECT_TRUE(j == 0); + } + EXPECT_TRUE(j == 1); +} + TEST(utils_tests, narrow_cast) { int n = 120;