OSDN Git Service
(root)
/
mutilities
/
MUtilities.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f26e95d
)
Lazy<T> class: Destroy the wrapped T object when the Lazy<T> instance gets destroyed.
author
LoRd_MuldeR
<mulder2@gmx.de>
Sat, 14 Apr 2018 23:27:07 +0000
(
01:27
+0200)
committer
LoRd_MuldeR
<mulder2@gmx.de>
Sat, 14 Apr 2018 23:27:07 +0000
(
01:27
+0200)
include/MUtils/Lazy.h
patch
|
blob
|
history
diff --git
a/include/MUtils/Lazy.h
b/include/MUtils/Lazy.h
index
3f6eb10
..
e5fb12d
100644
(file)
--- a/
include/MUtils/Lazy.h
+++ b/
include/MUtils/Lazy.h
@@
-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;