estd::typed_mem<T>

Overview

typed_mem<T> is wrapper type for delayed creation of objects. If an application uses global variables with static storage duration that are spread over multiple compilation units, the initialization order is not guaranteed. If dependencies between objects of these multiple compilation units exist, this can lead to a application crash.

typed_mem<T> allows to allocate memory with static storage duration be allows the construction of the objects at runtime.

Example

// Create the memory for a CanSystem.
estd::typed_mem<CanSystem> canSystem;

void initLifecycle()
{
    // Construct CanSystem and add it to lifecycleManager at runlevel 1.
    lifecycleManager.addComponent("can", canSystem.emplace(TASK_CAN, staticBsp), 1);
}