Create a scope guard.
Declared in <folly/ScopeGuard.h>
template<typename F>
[[nodiscard]]
/* implementation-defined */
makeGuard(F&& f) noexcept(/* see-below */);
The returned object has methods .dismiss() and .rehire(), which will deactivate/reactivate the calling of the function upon destruction.
The return value of this function must be captured. Otherwise, since it is a temporary, it will be destroyed immediately, thus calling the function.
auto guard = makeGuard(...); // good
makeGuard(...); // bad
This function is potentially-throwing unless noexcept(detail::ScopeGuardImplDecay<F, true>(static_cast<F &&>(f))).
A scope guard that runs f when it is destroyed. refcode folly/docs/examples/folly/ScopeGuard2.cpp
The return value should not be discarded.
| Name | Description |
|---|---|
| f | The function to execute upon the guard's destruction. |