Как объявить, что boost :: round_buffer будет инициализирован позже?

Я пытаюсь использовать циклический буфер на диске, но чтобы упростить мой вопрос, я пытаюсь использовать циклический буфер в различных функциях, не передавая циклический буфер в качестве аргумента. Так что это может выглядеть так:

#include <boost/circular_buffer.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/managed_mapped_file.hpp>

struct debugStruct {
int test1;
char test2;
};

// declare the memory mapped file
boost::interprocess::managed_mapped_file mmf;

// declare the allocator
typedef boost::interprocess::allocator< debugStruct, boost::interprocess::managed_mapped_file::segment_manager > mmf_allocator;

// declare the circular buffer (this doesn't work)
boost::circular_buffer< debugStruct, mmf_allocator > mmf_buffer;

void initializeCB() {
mmf = boost::interprocess::managed_mapped_file( boost::interprocess::open_or_create, "./testfile", 4ul << 20 );
mmf_buffer = boost::circular_buffer< debugStruct, mmf_allocator >( 100, mmf.get_segment_manager() );
}

void doOperation() {
struct debugStruct testStruct;
mmf_buffer.push_back( testStruct );
}

Спасибо!

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …