gpt4 book ai didi

c++ - Boost upgrade_to_unique_lock 编译错误

转载 作者:行者123 更新时间:2023-11-28 06:48:11 27 4
gpt4 key购买 nike

我正在使用 Boost.Thread 编写应用程序。不幸的是,将新版本移至“生产”环境后,我无法编译该项目。 g++ 说:

/usr/include/boost/thread/locks.hpp: In constructor 
‘boost::upgrade_to_unique_lock<Mutex>::upgrade_to_unique_lock
(boost::upgrade_lock<Mutex>&) [with Mutex = boost::shared_mutex]’:
worker.cpp:34:69: instantiated from here
/usr/include/boost/thread/locks.hpp:926:48: error: call of overloaded ‘move(
boost::upgrade_lock<boost::shared_mutex>&)’ is ambiguous
/usr/include/boost/thread/locks.hpp:926:48: note: candidates are:
/usr/include/boost/move/move.hpp:294:86: note: typename boost::move_detail
::disable_if<boost::has_move_emulation_enabled<T>, T&>::type boost::move(T&)
[with T = boost::upgrade_lock<boost::shared_mutex>, typename boost::move_detail
::disable_if<boost::has_move_emulation_enabled<T>, T&>::type = boost
::upgrade_lock<boost::shared_mutex>&]
/usr/include/boost/thread/detail/move.hpp:44:110: note: typename boost
::enable_if<boost::is_convertible<T&, boost::detail::thread_move_t<T> >,
boost::detail::thread_move_t<T> >::type boost::move(T&) [with T = boost
::upgrade_lock<boost::shared_mutex>, typename boost::enable_if<boost
::is_convertible<T&, boost::detail::thread_move_t<T> >, boost::detail
::thread_move_t<T> >::type = boost::detail::thread_move_t<boost
::upgrade_lock<boost::shared_mutex> >]
/usr/include/boost/thread/locks.hpp: In destructor ‘boost::upgrade_to_unique_lock
<Mutex>::~upgrade_to_unique_lock() [with Mutex = boost::shared_mutex]’:
worker.cpp:34:69: instantiated from here
/usr/include/boost/thread/locks.hpp:932:17: error: call of overloaded ‘move(boost
::unique_lock<boost::shared_mutex>&)’ is ambiguous
...

等等等等。

我检查了开发环境和生产环境是否具有相同的 libboost 版本 (1.48)。

有谁知道可能是什么原因?我应该检查/升级哪些其他库/工具版本?

最佳答案

这是 Boost 1.48 中的一个已知错误,根据 their bug tracker 似乎已在 1.49 中修复.如果将模拟 C++11 移动语义的 Boost.Move 与带有自己的移动语义模拟器的 Boost.Thread 一起使用,则存在歧义。

考虑到 Boost 1.48 已发布超过 2.5 年(在 November 2011 中),您应该考虑升级到最新版本,目前是 Boost 1.55。

关于c++ - Boost upgrade_to_unique_lock 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24542574/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com