简体   繁体   English

需要为c ++ std :: vector编写共享内存分配器

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

Please help to write c++ allocator for std::vector< nIcon*> class. 请帮助为std :: vector <nIcon *>类编写C ++分配器。

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) 我需要使用Windows上的共享内存来实现分配器(使用CreateFileMapping和MapViewOfFile)

May I suggest you look at the boost interprocess library ? 我可以建议您看一下boost 进程间库吗? 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). 尽管除了实现一小部分功能之外,实际上没有任何其他功能(前提是您不需要为map实现一个功能)。

You would use: 您将使用:

std::vector< nicon *, MyAllocator >

For how you would write MyAllocator 有关如何编写MyAllocator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM