halcheck 1.0
Loading...
Searching...
No Matches

◆ finally()

template<typename F >
lib::finally_t< F > finally ( F func)
related
Template Parameters
Fthe type of function to execute.
Parameters
funcThe function to execute.
Returns
An object that executes the function upon destruction.

This function will be run regardless of whether any exceptions occur, but not if the program terminates before the value goes out of scope (e.g. via std::terminate.)

Example
using namespace halcheck;
auto ptr = new int;
auto _ = lib::finally([&] { delete ptr; });
do_work(ptr);
lib::finally_t< F > finally(F func)
Definition scope.hpp:157