need to write shared memory allocator for c++ std::vector

心已入冬 提交于 2020-01-24 00:22:06

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!