Safe storage wrapper to avoid static initialization fiasco.
More...
#include </home/travis/build/forGGe/theCore/lib/utils/export/ecl/utils.hpp>
|
template<class ... Args> |
void | init (Args &&...args) |
| Initializes storage. More...
|
|
void | deinit () |
| Deinitializes storage. More...
|
|
T & | get () |
| Gets reference to the stored object. More...
|
|
const T & | get () const |
| Gets const reference to the stored object. More...
|
|
|
std::aligned_storage_t< sizeof(T), alignof(T)> | m_stor |
| Storage for the T object. More...
|
|
template<class T>
struct ecl::safe_storage< T >
Safe storage wrapper to avoid static initialization fiasco.
- Template Parameters
-
T | non-POD type to protect against implicit constructor call during static initialization |
◆ init()
template<class T>
template<class ... Args>
Initializes storage.
- Template Parameters
-
Args | Types of the constructor args. |
- Parameters
-
- Precondition
- Storage not yet initialized, i.e. ctor wasn't called yet or storage was deinitialized earlier.
- Postcondition
- Storage initialized and object is ready to work.
- Note
- Violating pre-conditions leads to undefined behaviour.
◆ deinit()
Deinitializes storage.
- Precondition
- Storage is initialized.
- Postcondition
- Storage is deinitialized and stored object is destructed.
- Note
- Violating pre-conditions leads to undefined behaviour.
◆ get() [1/2]
Gets reference to the stored object.
- Precondition
- Storage initialized, i.e. init() was called once.
◆ get() [2/2]
Gets const reference to the stored object.
- Precondition
- Storage initialized, i.e. init() was called once.
◆ m_stor
Storage for the T object.
The documentation for this struct was generated from the following file: