I am implementing boost::circular_buffer
in boost::managed_shared_memory
. I used the sample code demonstrating vector in shared memory here. I made the following changes :
1) typedef boost::circular_buffer<int, ShmemAllocatorCB> MyCircularBuffer;
2) MyCircularBuffer *circbuff = segment.construct<MyCircularBuffer>("MyCB")(alloc_inst);
3) circbuff->push_back(1);
The code is giving a compile error on line #3. The error is
error C2665: 'operator new' : none of the 5 overloads could convert all the argument types c:\boost2005\boost\circular_buffer\base.hpp 1470
From the documentation, I understand the push_back function is expecting one of these 3 forms :
void push_back(param_value_type);
void push_back(rvalue_type);
void push_back();
I tried the empty parameter call, tried casting the 1 into param_value_type, rvalue_type but none of them seem to work. This might be a simple mistake but I have not been able to figure this out for quite some time now. Any help is appreciated. Thanks.
Edit:
typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocatorCB;
managed_shared_memory segment(create_only, "MySharedMemory", 65536);
const ShmemAllocatorCB alloc_inst (segment.get_segment_manager());