Commit 56e5f6fe authored by Joshua's avatar Joshua

Add documentation for static LifetimeList

parent a9e87fcc
......@@ -210,6 +210,7 @@ A list has to be emptied before it is destroyed.
- LifetimeList is std::iterable<...>.
- the factory functions use perfect forwarding. That means, if T of LifetimeList<T> is constructable, you can pass any arguments that the constructor of T accepts.
- Do not use stack allocated Nodes, they will be swithed out of scope.
- When using statically allocated lists, use lazy loading. This way the constructor is guarenteed to be called before list is used the first time
### Example
......@@ -223,11 +224,27 @@ The first example shows how to use LifetimeList to make a list of all objects of
class MyClass
MyClass() : node(instances.appendStatic(*this))
MyClass() : node(getInstances().appendStatic(*this))
static Collections::LifetimeList<MyClass&> instances; /** hold a reference to every instance of this */
* lazy loading getter function needs to be used.
* A static list inside this class would not be able to guarantee,
* that the list is constructed before it is used the first time.
static Collections::LifetimeList<MyClass&>& getInstance()
static Collections::LifetimeList<MyClass&> instances{};
return instances;
* It does not guarantee order of construction!
// static Collections::LifetimeList<MyClass&> instances;
Collections::LifetimeList<MyClass&>::Node node; /**< the node belongs to the object */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment