finally in C++
Sometimes there?s a need to invoke a special action at the end of the scope: it could be a resource releasing code, flag set, code guard, begin/end function calls, etc. - Bartek’s coding blog
Let’s meet gsl::final_act/finally
The above class takes a callable object - f_ - and then it will call it when it?s about to be destroyed. So even if your code returns early or throws an exception your cleanup code is required to be invoked.
References
Written on December 29, 2020, Last update on December 29, 2020
c++