On 10/8/2018 at 8:45 PM, mychii said:Yes, that is what the object handle I have in the picture does, a simple wrapper that handles relocatable objects in memory, which I'm trying to inject to STL container through custom STL allocator rather than making custom container using that object handle.
The handles can go directly into any standard library container without the need for a custom allocator:
extern IObject* createObject();
std::vector<ObjectHandle> handles {
ObjectHandle(createObject()),
ObjectHandle(createObject()),
ObjectHandle(createObject())
};
The behavior of your "defragmenting" heap is different from how the language and standard library expects storage to behave, so while I'm sure that you could find a way to wrap object allocation in an allocator, it wouldn't do you much good if it can't be used anywhere. At least with this approach, you retain full control over your heap while still being able to use standard containers for the handles.