Runs shared initialization before namespace-scope users and shared cleanup after them.
More...
template<auto Init, auto Exit = []() noexcept {}>
requires requires { { Init() } noexcept; { Exit() } noexcept; }
class uni20::nifty_counter< Init, Exit >
Runs shared initialization before namespace-scope users and shared cleanup after them.
Place one guard with internal linkage in every header that exposes state requiring ordered initialization. Named callback functions with external linkage ensure that all translation units instantiate the same counter. Header-local lambdas must not be used for that purpose because they can produce distinct counter specializations.
- Template Parameters
-
| Init | No-throw callable invoked when the first guard is constructed. |
| Exit | No-throw callable invoked when the last guard is destroyed. |