summaryrefslogtreecommitdiffstats
path: root/Common/interface
diff options
context:
space:
mode:
Diffstat (limited to 'Common/interface')
-rw-r--r--Common/interface/STDAllocator.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/Common/interface/STDAllocator.h b/Common/interface/STDAllocator.h
index 10f6769a..2371bdb8 100644
--- a/Common/interface/STDAllocator.h
+++ b/Common/interface/STDAllocator.h
@@ -34,6 +34,17 @@
namespace Diligent
{
+template <typename T>
+typename std::enable_if<std::is_destructible<T>::value, void>::type Destruct(T *ptr)
+{
+ ptr->~T();
+}
+
+template <typename T>
+typename std::enable_if<!std::is_destructible<T>::value, void>::type Destruct(T *ptr)
+{
+}
+
template <typename T, typename AllocatorType>
struct STDAllocator
{
@@ -183,7 +194,7 @@ struct STDDeleter
void operator()(T *ptr) noexcept
{
VERIFY(m_Allocator != nullptr, "The deleter has been moved away or never initialized, and can't be used");
- ptr->~T();
+ Destruct(ptr);
m_Allocator->Free(ptr);
}