rec*_*ion 5 c++ circular-buffer boost-interprocess
我正在尝试使用 Boost 和 Interprocess 库在共享内存中创建循环缓冲区circular_buffer。我编译并运行了进程间文档中给出的示例,用于在共享内存中创建向量,没有任何问题。但是,当我修改它以使用 Boostcircular_buffer 时:
int main(int argc, char *argv[])
{
managed_shared_memory segment(create_only, "MySharedMemory", 65536);
const ShmemAllocator alloc_inst (segment.get_segment_manager());
MyCircBuffer *myCircBuf = segment.construct<MyCircBuffer>("MyCircBuffer")(alloc_inst);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我收到编译错误(由 引起segment.construct())。知道我做错了什么吗?是否是因为circular_buffer不是 中列出的容器之一/boost/interprocess/containers,即它与 Interprocess 不兼容?
谢谢,
C
我在 boost 用户论坛上问了同样的问题,建议的解决方案是使用 -DBOOST_CB_DISABLE_DEBUG 或 -DNDEBUG 标志,因为circular_buffer依赖于原始指针来进行调试支持。
还有其他建议吗?