【问题标题】:error map shared_memory boost错误映射 shared_memory boost
【发布时间】:2011-02-02 16:41:16
【问题描述】:

我正在尝试使用进程间创建共享内存,但出现编译错误

问题所在的代码是:

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...我不知道为什么会出现错误...

谢谢您

【问题讨论】:

    标签: c++ boost shared-memory


    【解决方案1】:

    既然你在使用 boost 为什么不使用boost shared_memory_object

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-09-24
    • 2011-08-21
    • 1970-01-01
    相关资源
    最近更新 更多