错误图shared_memory boost

时间:2011-02-02 16:41:17

标签: c++ boost shared-memory

我正在尝试使用进程间创建共享内存,并且我遇到了编译错误

解决问题的代码是:

typedef bip::basic_string< char,std::char_traits<char>,
bip::allocator<char,bip::managed_mapped_file::segment_manager> > shared_string;

typedef        shared_string  MappedType;
typedef        shared_string  MappedType;
typedef        const int  KeyType;

typedef  std::pair<const int, shared_string> ValueType;

//Alias a map of ints that uses the previous STL-like allocator.
//Note that the third parameter argument is the ordering function
//of the map, just like with std::map, used to compare the keys.
typedef bip::map<KeyType, MappedType, std::less<KeyType>, ShmemAllocator> MyMap;

mymap = 
            seg->find_or_construct<MyMap>("MyMap")      //object name
            (std::less<int>() //first  constructor parameter
            ,*alloc_inst);  

我在创建地图时遇到问题。错误是:

c:\GQSDevEnv\3rdParty\boost\boost_1_36_0\boost\interprocess\containers\map.hpp(437) : error C2535: 'std::pair<_Ty1,_Ty2> boost::interprocess::map<Key,T,Pred,Alloc>::insert(const boost::interprocess::map<Key,T,Pred,Alloc>::value_type &)' : member function already defined or declared
        with
        [
            _Ty1=boost::interprocess::detail::rbtree<const    Testing::KeyType,std::pair<const int,Testing::shared_string>,boost::interprocess::detail::select1st<std::pair<const int,Testing::shared_string>>,std::less<const Testing::KeyType>,Testing::ShmemAllocator>::iterator,
            _Ty2=bool,
            Key=const Testing::KeyType,
            T=Testing::MappedType,
            Pred=std::less<const Testing::KeyType>,
            Alloc=Testing::ShmemAllocator
        ]

我必须以不同方式声明吗?当我在std :: pair中输入一个模板的类型名称时,我工作了,但现在我想尝试只放一个int ...我不知道为什么会出现这个错误......

感谢adavnce

1 个答案:

答案 0 :(得分:0)

既然您正在使用提升,为什么不使用boost shared_memory_object

相关问题