Skia
2DGraphicsLibrary
|
Efficient way to defer allocating/initializing a class until it is needed (if ever). More...
#include <SkTLazy.h>
Public Member Functions | |
SkTLazy (const T *src) | |
SkTLazy (const SkTLazy &src) | |
SkTLazy & | operator= (const SkTLazy &src) |
template<typename... Args> | |
T * | init (Args &&...args) |
Return a pointer to an instance of the class initialized with 'args'. More... | |
T * | set (const T &src) |
Copy src into this, and return a pointer to a copy of it. More... | |
void | reset () |
Destroy the lazy object (if it was created via init() or set()) | |
bool | isValid () const |
Returns true if a valid object has been initialized in the SkTLazy, false otherwise. | |
T * | get () const |
Returns the object. More... | |
T * | getMaybeNull () const |
Like above but doesn't assert if object isn't initialized (in which case nullptr is returned). | |
Private Attributes | |
SkAlignedSTStorage< 1, T > | fStorage |
T * | fPtr |
Efficient way to defer allocating/initializing a class until it is needed (if ever).
|
inline |
Returns the object.
This version should only be called when the caller knows that the object has been initialized.
|
inline |
Copy src into this, and return a pointer to a copy of it.
Note this will always return the same pointer, so if it is called on a lazy that has already been initialized, then this will copy over the previous contents.