2011-11-24 1 views
4

약간의 클래스가있는 cpp sourceh source 개의 파일이 있습니다. shared mutexes and shared locks을 사용합니다. 1.48.0으로 오류없이 윈도우에서 컴파일됩니다. 또한 리눅스에서 컴파일되었습니다 (이전에 boost 1.47로). 그러나이 같은 지금 가지고 코드 : 이상한 오류에부스트 1.48.0 Linux의 upgrade_to_unique_lock : 1.47부터 변경되었거나 잘못 되었나요?

boost::shared_mutex mut_; 
//... 
boost::upgrade_lock<boost::shared_mutex> lock(mut_); 
boost::upgrade_to_unique_lock<boost::shared_mutex> uniqueLock(lock); 

결과 :

==== Building cf-fs (debug) ==== 
Creating bin/obj/Debug/cf-fs 
fs_concurrent_queued_map.cpp 
fs_map.cpp 
In file included from ../../src/cf-util/http_utils_inl.h:1, 
       from ../../src/cf-util/http_utils.h:104, 
       from ../../src/cf-fs/fs_map.h:13, 
       from ../../src/cf-fs/fs_map.cpp:1: 
../../src/cf-util/http_utils.h:105:8: warning: extra tokens at end of #endif directive 
In file included from ../../src/cf-fs/fs_map.h:13, 
       from ../../src/cf-fs/fs_map.cpp:1: 
../../src/cf-util/http_utils.h:105:8: warning: extra tokens at end of #endif directive 
In file included from ../../../boost_libraries/install-dir/include/boost/thread/pthread/mutex.hpp:12, 
       from ../../../boost_libraries/install-dir/include/boost/thread/mutex.hpp:16, 
       from ../../../boost_libraries/install-dir/include/boost/thread/pthread/thread_data.hpp:12, 
       from ../../../boost_libraries/install-dir/include/boost/thread/thread.hpp:17, 
       from ../../../boost_libraries/install-dir/include/boost/thread.hpp:13, 
       from ../../src/cf-fs/fs_map.h:10, 
       from ../../src/cf-fs/fs_map.cpp:1: 
../../../boost_libraries/install-dir/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]’: 
../../src/cf-fs/fs_map.cpp:33: instantiated from here 
../../../boost_libraries/install-dir/include/boost/thread/locks.hpp:926: error: call of overloaded ‘move(boost::upgrade_lock<boost::shared_mutex>&)’ is ambiguous 
../../../boost_libraries/install-dir/include/boost/thread/detail/move.hpp:44: note: candidates are: 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>] 
../../../boost_libraries/install-dir/include/boost/move/move.hpp:294: 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>] 
../../../boost_libraries/install-dir/include/boost/thread/locks.hpp: In destructor ‘boost::upgrade_to_unique_lock<Mutex>::~upgrade_to_unique_lock() [with Mutex = boost::shared_mutex]’: 
../../src/cf-fs/fs_map.cpp:33: instantiated from here 
../../../boost_libraries/install-dir/include/boost/thread/locks.hpp:932: error: call of overloaded ‘move(boost::unique_lock<boost::shared_mutex>&)’ is ambiguous 
../../../boost_libraries/install-dir/include/boost/thread/detail/move.hpp:44: note: candidates are: 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::unique_lock<boost::shared_mutex>] 
../../../boost_libraries/install-dir/include/boost/move/move.hpp:294: note:     typename boost::move_detail::disable_if<boost::has_move_emulation_enabled<T>, T&>::type boost::move(T&) [with T = boost::unique_lock<boost::shared_mutex>] 
make[1]: *** [bin/obj/Debug/cf-fs/fs_map.o] Ошибка 1 
make: *** [cf-fs] Ошибка 2 

내가 컴파일하지 않는다 어떻게 문제를 해결하거나 해결하기 위해 내 코드에 뭔가 문제가 있습니까?

+3

는 나는이 문제를 생각 : https://svn.boost.org/trac/boost/ticket/6141 – interjay

+0

예. 있는 것처럼 보입니다. 어떤 사람이 그걸 피하기위한 방법을 제공 할 수 있습니까? – myWallJSON

+0

Boost 소스로 가서 Boost.Move를 비활성화하거나 해당 티켓에 설명 된 버그를 수정해야합니다. –

답변

2
--- a/locks.hpp 2011-12-05 12:26:11.650309054 +0400 
+++ b/locks.hpp 2011-12-05 12:27:25.905311415 +0400 
@@ -923,13 +923,13 @@ 
     upgrade_to_unique_lock& operator=(upgrade_to_unique_lock&); 
    public: 
     explicit upgrade_to_unique_lock(upgrade_lock<Mutex>& m_): 
-   source(&m_),exclusive(move(*source)) 
+   source(&m_),exclusive(move(detail::thread_move_t<upgrade_lock<Mutex> >(*source))) 
     {} 
     ~upgrade_to_unique_lock() 
     { 
      if(source) 
      { 
-    *source=move(exclusive); 
+    *source=move(detail::thread_move_t<unique_lock<Mutex> >(exclusive)); 
      } 
     }