summaryrefslogtreecommitdiff
path: root/source/core/slang-allocator.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/core/slang-allocator.h')
-rw-r--r--source/core/slang-allocator.h34
1 files changed, 5 insertions, 29 deletions
diff --git a/source/core/slang-allocator.h b/source/core/slang-allocator.h
index bc1b880f8..8942f993b 100644
--- a/source/core/slang-allocator.h
+++ b/source/core/slang-allocator.h
@@ -62,34 +62,6 @@ namespace Slang
}
};
- // Helper utilties for calling allocators.
- template<typename T, int isPOD>
- class Initializer;
-
- template<typename T>
- class Initializer<T, 0>
- {
- public:
- static void initialize(T* buffer, Index size)
- {
- for (Index i = 0; i < size; i++)
- new (buffer + i) T();
- }
- };
- template<typename T>
- class Initializer<T, 1>
- {
- public:
- static void initialize(T* buffer, Index size)
- {
- SLANG_UNUSED(buffer);
- SLANG_UNUSED(size);
- // It's pod so no initialization required
- //for (int i = 0; i < size; i++)
- // new (buffer + i) T;
- }
- };
-
template<typename T, typename TAllocator>
class AllocateMethod
{
@@ -98,7 +70,11 @@ namespace Slang
{
TAllocator allocator;
T* rs = (T*)allocator.allocate(count * sizeof(T));
- Initializer<T, std::is_pod<T>::value>::initialize(rs, count);
+ if (!std::is_trivially_constructible<T>::value)
+ {
+ for (Index i = 0; i < count; i++)
+ new (rs + i) T();
+ }
return rs;
}
static inline void deallocateArray(T* ptr, Index count)