template<
typename T>
class iox2::legacy::StaticLifetimeGuard< T >
Manages a static instance of type T in a way so that each existing StaticLifetimeGuard prevents the destruction of the instance.
- instance() creates a static guard itself and hence has static lifetime
- Any static StaticLifetimeGuard G created before that prolongs the lifetime of the instance at least until G is destroyed
- The instance is lazily constructed, i.e. only when first used. Hence there can be guards without any instance existing. These guards still protect the instance from destruction if it is ever constructed.
- If and once the instance is constructed, it will be destructed only after main exits (static destruction).
- Guards can be used in static variables to control destruction order of static (singleton) instances if a specific order of destruction is required.
- Template Parameters
-
| T | the type of the instance to be guarded |
- Note
- all public functions are thread-safe
Manages a static instance of type T in a way so that each existing StaticLifetimeGuard prevents the d...
static T & instance(Args &&... args) noexcept
Construct the instance to be guarded with constructor arguments.
constexpr bool always_false_v
Helper value to bind a static_assert to a type.
Definition at line 49 of file static_lifetime_guard.hpp.