【问题标题】:Build issue with code using boost::interprocess on VS 2010在 VS 2010 上使用 boost::interprocess 构建代码问题
【发布时间】:2012-09-15 14:16:54
【问题描述】:

我正在尝试在 VS 2010 中构建一段代码,该代码通常在网上找到,作为在共享内存中拥有地图的示例。

#include <boost\interprocess\managed_shared_memory.hpp>
#include <boost\interprocess\containers\map.hpp>

typedef boost::interprocess::map<long,long,
            std::less<long>,
            boost::interprocess::allocator<std::pair<long,long>,
                boost::interprocess::managed_shared_memory::segment_manager> >
        shmap;

boost::interprocess::managed_shared_memory segment1(
    boost::interprocess::create_only, 
    "MySharedMemory", 655360); //segment name and size in bytes

shmap *rp = segment1.construct<shmap>("SharedMap")(
    std::less<long>(), segment1.get_segment_manager());

我收到了这个让我大吃一惊的错误。有什么想法吗?

error C2338: (container_detail::is_same<std::pair<const Key, T>, typename A::value_type>::value)

【问题讨论】:

  • 这不是完整的错误信息吗?
  • 足够了:is_same+'const Key'

标签: c++ boost map shared-memory boost-interprocess


【解决方案1】:

应该是

typedef boost::interprocess::map
<long,long,std::less<long>,
boost::interprocess::allocator<std::pair<const long,long>, 
boost::interprocess::managed_shared_memory::segment_manager> > shmap;

由于内部检查是is_same&lt;std::pair&lt;const Key, T&gt;, Allocator::value_type&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多