I am trying to use std::unique_ptr
with custom memory allocators. Basically, I have custom allocators that are subclasses of IAllocator
,
T*
doesn't contain such information, neither unique_ptr knows about the size of the array (since it uses directly a delete []
as you stated). You could let the T
be a unique_ptr
to manage the destruction automatically but this could not be possible if the whole contiguous T*
is managed by a memory allocator (and not a single T*
object). Eg:
unique_ptr[]> data;
data.reset(new unique_ptr[50]);
data[0].reset(new Foo());