问题
Please help to write c++ allocator for std::vector< nIcon*> class.
All examples i find shows just what methods i need to overwrite, not code examples.
I need to implement allocator using shared memory on windows (using CreateFileMapping and MapViewOfFile)
回答1:
May I suggest you look at the boost interprocess library? It allows you to create allocators using shared memory.
I've seen some examples around, I would say just look a bit more. I agree that none of them do a perfect job, thus I won't recommend any in particular. Though beyond just implementing the small set of functions there is really nothing to it (provided you don't need to implement one for map).
回答2:
You would use:
std::vector< nicon *, MyAllocator >
For how you would write MyAllocator
来源:https://stackoverflow.com/questions/5312714/need-to-write-shared-memory-allocator-for-c-stdvector