Lazy<T> class: Destroy the wrapped T object when the Lazy<T> instance gets destroyed.

This commit is contained in:
LoRd_MuldeR 2018-04-15 01:27:07 +02:00
parent f26e95d4c7
commit 562911dbff

View File

@ -69,6 +69,14 @@ namespace MUtils
return *m_value;
}
~Lazy(void)
{
if(T *const value = m_value.fetchAndStoreOrdered(NULL))
{
delete value;
}
}
private:
QAtomicPointer<T> m_value;
const std::function<T*(void)> m_initializer;