You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(the recast I do because I need always foo-like elements because I put the pointers in a hashmap, I take care of the size of the array myself, i.e. I store the length at[0])
With that I always get an compile error in the deleteElement function. When I comment out the call to the destructor (placement new destructor?) it works.
Why is that and is it correct in my special case?
Thanks!
steffen
the compile error (gcc 4.8.1):
MemoryPool.tcc: In instantiation of ‘void MemoryPool<T, BlockSize>::deleteElement(MemoryPool<T, BlockSize>::pointer) [with T = short unsigned int [2]; long unsigned int BlockSize = 1966080ul; MemoryPool<T, BlockSize>::pointer = short unsigned int ()[2]]’:
MinHashEncoder.h:310:84: required from here
MemoryPool.tcc:228:4: error: request for member ‘~MemoryPool<short unsigned int [2], 1966080ul>::value_type’ in ‘ p’, which is of non-class type ‘short unsigned int [2]’
p->~value_type();
The text was updated successfully, but these errors were encountered:
Hi,
I want to use the pool allocator for thousands of small arrays:
typedef uint16_t elementType;
typedef elementType* arrayP;
typedef elementType array_2[2];
MemoryPool<array_2> mMemPool_2;
arrayP foo;
foo = reinterpret_cast<elementType(*)>(mMemPool_2->newElement());
...
mMemPool_2->deleteElement(reinterpret_cast<array_2(*)>(foo));
(the recast I do because I need always foo-like elements because I put the pointers in a hashmap, I take care of the size of the array myself, i.e. I store the length at[0])
With that I always get an compile error in the deleteElement function. When I comment out the call to the destructor (placement new destructor?) it works.
template <typename T, size_t BlockSize>
inline void MemoryPool<T, BlockSize>::deleteElement(pointer p) {
if (p != nullptr) {
// p->~value_type();
deallocate(p);
}
}
Why is that and is it correct in my special case?
Thanks!
steffen
the compile error (gcc 4.8.1):
MemoryPool.tcc: In instantiation of ‘void MemoryPool<T, BlockSize>::deleteElement(MemoryPool<T, BlockSize>::pointer) [with T = short unsigned int [2]; long unsigned int BlockSize = 1966080ul; MemoryPool<T, BlockSize>::pointer = short unsigned int ()[2]]’:
MinHashEncoder.h:310:84: required from here
MemoryPool.tcc:228:4: error: request for member ‘~MemoryPool<short unsigned int [2], 1966080ul>::value_type’ in ‘ p’, which is of non-class type ‘short unsigned int [2]’
p->~value_type();
The text was updated successfully, but these errors were encountered: