无法从'boost :: interprocess :: mapped_region'转换为'boost :: interprocess :: mapped_region&&'

时间:2010-10-21 12:35:56

标签: visual-studio-2010 visual-c++ boost

当我尝试使用

编译一个简单的boost应用程序时
#include <boost/interprocess/allocators/allocator.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>
VS 2010 中的

标题,我收到此错误消息。

c:\program files\boost\boost_1_44_0\boost\interprocess\detail\move.hpp(342): error C2440: 'return' : cannot convert from 'boost::interprocess::mapped_region' to 'boost::interprocess::mapped_region &&'
1>          You cannot bind an lvalue to an rvalue reference
1>          c:\program files\boost\boost_1_44_0\boost\interprocess\mapped_region.hpp(159) : see reference to function template instantiation 'boost::interprocess::mapped_region &&boost::interprocess::move<boost::interprocess::mapped_region&>(T)' being compiled
1>          with
1>          [
1>              T=boost::interprocess::mapped_region &
1>          ]
1>c:\program files\boost\boost_1_44_0\boost\interprocess\detail\move.hpp(342): error C2440: 'return' : cannot convert from 'boost::interprocess::shared_memory_object' to 'boost::interprocess::shared_memory_object &&'
1>          You cannot bind an lvalue to an rvalue reference
1>          c:\program files\boost\boost_1_44_0\boost\interprocess\shared_memory_object.hpp(85) : see reference to function template instantiation 'boost::interprocess::shared_memory_object &&boost::interprocess::move<boost::interprocess::shared_memory_object&>(T)' being compiled
1>          with
1>          [
1>              T=boost::interprocess::shared_memory_object &
1>          ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

我无法理解这个问题。我删除了所有的函数实现,只有c_tor和d_tor但仍然是相同的错误..

1 个答案:

答案 0 :(得分:2)

您可以按照here所示解决此问题。在处理rvalue引用时,它看起来像Boost或编译器中的限制。

  

#define BOOST_NO_RVALUE_REFERENCES   工作。感谢。