0
我有下面的代码,它写结构来提升共享内存。我无法添加新的float *或Vector。升压版本:1.59.0获得一堆错误作为Float *或向量在Boost共享结构
error: no matching function for call to ‘boost::interprocess::allocator<boost::container::container_detail::list_node<float, boost::interprocess::offset_ptr<void>......."
尝试:
typedef boost::interprocess::list<float, salloc::rebind<float>::other> shared_float;
任何建议如何添加浮子*或将被添加来提高共享存储器结构矢量
#include <iostream>
#include <string>
#include <cstdlib>
#include <boost/interprocess/ipc/message_queue.hpp>
#include <boost/scoped_ptr.hpp>
#include <boost/interprocess/shared_memory_object.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
#include <boost/interprocess/mapped_region.hpp>
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/containers/string.hpp>
#include <boost/interprocess/containers/vector.hpp>
#include <boost/shared_array.hpp>
#include <boost/interprocess/containers/list.hpp>
#include <boost/version.hpp>
using namespace boost::interprocess;
struct InData;
typedef boost::interprocess::allocator<InData, managed_shared_memory::segment_manager> salloc;
typedef boost::interprocess::basic_string<char, std::char_traits<char>, salloc::rebind<char>::other> shared_string;
struct InData {
int X, Y, H, W;
InData(salloc alloc) : Label(alloc) {}
shared_string Label;
};
int main() {
std::cout << "Using Boost "
<< BOOST_VERSION/100000 << "." // major version
<< BOOST_VERSION/100 % 1000 << "." // minor version
<< BOOST_VERSION % 100 // patch level
<< std::endl;
shared_memory_object::remove("MySharedMemory");
managed_shared_memory managed_shm(create_only, "MySharedMemory", 10000);
salloc alloc_inst(managed_shm.get_segment_manager());
InData tData(alloc_inst); // = managed_shm.construct<InData>("InDataStructure")();
tData.Label = "Hello World";
tData.H = 1;
tData.W = 1;
tData.Y = 1;
tData.X = 1;
typedef boost::interprocess::list<InData, salloc> MyList;
MyList *myvector = managed_shm.construct<MyList>("MyVector")(alloc_inst);
myvector->push_back(tData);
}
不能简写的错误。该错误说“错误:没有匹配的函数调用X”,你设法把比“X”有趣的一半, – sehe