开发者

error map shared_memory boost

I am trying to create a shared memory with interprocess and I am having a compilation error

the code where resides the problem is:

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);  

and I am having problems to create the map. The error is:

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
        ]

Do I have to declare differently? I worked when I was putting in std::pair a typename of a Template, but now I want to try to put only a int...I do not know why that error...

Thanks in adavnce


Since you are using boost why dont you use boost shared_memory_object?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜