在尝试使用boost托管共享内存时,我收到了'bad_alloc'.我已经从他们的快速指南中复制了这个不耐烦的提升示例,并将我自己的更改纳入其中.我的代码在下面,我已经注释掉了示例内容并在其下面编写了我自己的代码.我还提供了一些调试和测试的东西.
有没有人有任何想法?任何帮助是极大的赞赏!
-M
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/containers/map.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/exceptions.hpp>
#include <functional>
#include <utility>
#include <iostream>
#include <string>
#define space_name "MySharedMemorydfgdfhgd"
namespace std{
}
int main ()
{
using namespace boost::interprocess;
//Remove shared memory on construction and destruction
struct shm_remove
{
shm_remove() { shared_memory_object::remove(space_name); }
~shm_remove(){ shared_memory_object::remove(space_name); }
} remover;
typedef int KeyType;
typedef boost::interprocess::managed_shared_memory::allocator<char>::type char_allocator;
//typedef boost::interprocess::allocator<char, boost::interprocess::managed_shared_memory::segment_manager> char_allocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>, char_allocator> shm_string;
struct certificateStorage{
int certificate_id;
certificateStorage( int _certificate_id, const char* _certificate, const char* …Run Code Online (Sandbox Code Playgroud)