![]() |
LeechCraft
0.6.70-10870-g558588d6ec
Modular cross-platform feature rich live environment.
|
Provides lazy initialization on first access to an object. More...
#include "lazyinitializer.h"
Public Member Functions | |
template<typename Init > | |
LazyInitializer (const Source &source, const Init &initializer, const std::function< void(Source &)> &clear=[](Source &src) { src=Source {};}) | |
Constructs an unevaluated lazy initializer. More... | |
LazyInitializer (const Object &object) | |
Constructs an evaluated initializer from the object. More... | |
LazyInitializer & | operator= (const Object &object) |
Assigns an object to this lazy (making it evaluated) initializer and clears the source. More... | |
operator Object () | |
Conversion operator to Object, forcing object construction. More... | |
Object & | operator-> () |
Indirection operator, forcing object construction. More... | |
Provides lazy initialization on first access to an object.
If the lazy initializer is unevaluated, the initialization functor passed to the constructor will be called first time the object inside this initializer is accessed.
Source | The source object used for initialization of the object. |
Object | The type of the object which should be initialized. |
Definition at line 50 of file lazyinitializer.h.
|
inline |
Constructs an unevaluated lazy initializer.
[in] | source | The source object from which the Object should be initialized. |
[in] | initializer | The initialization function that returns an Object when called with Source. |
[in] | clear | The function for clearing the source after initialization to free up resources. Default function just assigns a default-constructed Source. |
Init | The type of the initializer. |
Definition at line 71 of file lazyinitializer.h.
|
inline |
Constructs an evaluated initializer from the object.
[in] | object | The object used to initialize the stored one. |
Definition at line 84 of file lazyinitializer.h.
|
inline |
Conversion operator to Object, forcing object construction.
Definition at line 104 of file lazyinitializer.h.
|
inline |
Indirection operator, forcing object construction.
Definition at line 112 of file lazyinitializer.h.
|
inline |
Assigns an object to this lazy (making it evaluated) initializer and clears the source.
[in] | object | The object to set this lazy initializer to. |
Definition at line 94 of file lazyinitializer.h.