Lazy<T> class: Destroy the wrapped T object when the Lazy<T> instance gets destroyed.
This commit is contained in:
parent
f26e95d4c7
commit
562911dbff
@ -69,6 +69,14 @@ namespace MUtils
|
|||||||
return *m_value;
|
return *m_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~Lazy(void)
|
||||||
|
{
|
||||||
|
if(T *const value = m_value.fetchAndStoreOrdered(NULL))
|
||||||
|
{
|
||||||
|
delete value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QAtomicPointer<T> m_value;
|
QAtomicPointer<T> m_value;
|
||||||
const std::function<T*(void)> m_initializer;
|
const std::function<T*(void)> m_initializer;
|
||||||
|
Loading…
Reference in New Issue
Block a user