need to write shared memory allocator for c++ std::vector
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 开发者_JS百科using shared memory on windows (using CreateFileMapping and MapViewOfFile)
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).
You would use:
std::vector< nicon *, MyAllocator >
For how you would write MyAllocator
精彩评论