From 97d0ae6527df036e01bebb17df701fab4e39ea1e Mon Sep 17 00:00:00 2001 From: "Vicente J. Botet Escriba" Date: Mon, 2 Jan 2012 17:12:01 +0000 Subject: [PATCH] Thread: #6141 - Compilation error when boost.thread and boost.move are used together [SVN r76277] --- include/boost/thread/detail/move.hpp | 11 +--------- include/boost/thread/detail/thread.hpp | 7 +++++++ include/boost/thread/future.hpp | 28 ++++++++++++++++++++++++++ include/boost/thread/locks.hpp | 28 ++++++++++++++++++++++++++ test/Jamfile.v2 | 8 ++++++++ test/test_6170.cpp | 22 ++++++++++++++++++++ 6 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 test/test_6170.cpp diff --git a/include/boost/thread/detail/move.hpp b/include/boost/thread/detail/move.hpp index 5909efba..665a0b59 100644 --- a/include/boost/thread/detail/move.hpp +++ b/include/boost/thread/detail/move.hpp @@ -6,15 +6,14 @@ #ifndef BOOST_THREAD_MOVE_HPP #define BOOST_THREAD_MOVE_HPP +#include #ifndef BOOST_NO_SFINAE #include #include #include #endif -#ifndef BOOST_NO_RVALUE_REFERENCES #include -#endif #include @@ -45,11 +44,6 @@ namespace boost }; } -#ifdef BOOST_THREAD_USES_SPECIFIC_MOVE_NS -namespace threads { -#endif - - #ifndef BOOST_NO_SFINAE template typename enable_if >, boost::detail::thread_move_t >::type move(T& t) @@ -64,9 +58,6 @@ namespace threads { return t; } -#ifdef BOOST_THREAD_USES_SPECIFIC_MOVE_NS -} -#endif } diff --git a/include/boost/thread/detail/thread.hpp b/include/boost/thread/detail/thread.hpp index 32d38407..7ac342bf 100644 --- a/include/boost/thread/detail/thread.hpp +++ b/include/boost/thread/detail/thread.hpp @@ -521,6 +521,13 @@ namespace boost void BOOST_THREAD_DECL add_thread_exit_function(thread_exit_function_base*); } +#ifdef BOOST_NO_RVALUE_REFERENCES + template <> + struct has_move_emulation_enabled_aux + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + namespace this_thread { template diff --git a/include/boost/thread/future.hpp b/include/boost/thread/future.hpp index 84464406..bd871583 100644 --- a/include/boost/thread/future.hpp +++ b/include/boost/thread/future.hpp @@ -754,6 +754,13 @@ namespace boost }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + template class shared_future { @@ -912,6 +919,13 @@ namespace boost }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + template class promise { @@ -1178,6 +1192,13 @@ namespace boost }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + namespace detail { template @@ -1409,6 +1430,13 @@ namespace boost }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + } diff --git a/include/boost/thread/locks.hpp b/include/boost/thread/locks.hpp index 41f1b44f..26012707 100644 --- a/include/boost/thread/locks.hpp +++ b/include/boost/thread/locks.hpp @@ -518,6 +518,13 @@ namespace boost } #endif +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + template class shared_lock { @@ -712,6 +719,14 @@ namespace boost }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + + #ifndef BOOST_NO_RVALUE_REFERENCES template void swap(shared_lock&& lhs,shared_lock&& rhs) @@ -896,6 +911,12 @@ namespace boost friend class unique_lock; }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif #ifndef BOOST_NO_RVALUE_REFERENCES template @@ -988,6 +1009,13 @@ namespace boost } }; +#ifdef BOOST_NO_RVALUE_REFERENCES + template + struct has_move_emulation_enabled_aux > + : BOOST_MOVE_BOOST_NS::integral_constant + {}; +#endif + namespace detail { template diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e924e9b1..97c5c445 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -62,4 +62,12 @@ rule thread-run ( sources ) [ compile-fail no_implicit_move_from_lvalue_thread.cpp ] [ compile-fail no_implicit_assign_from_lvalue_thread.cpp ] ; + + + #explicit tickets ; + test-suite tickets + : + [ compile test_6170.cpp ] + ; + } diff --git a/test/test_6170.cpp b/test/test_6170.cpp new file mode 100644 index 00000000..e79dbbbe --- /dev/null +++ b/test/test_6170.cpp @@ -0,0 +1,22 @@ +#include +#include + +// Including this will cause ambiguous errors in boost::move +#include + +using namespace boost; + +typedef upgrade_lock auto_upgrade_lock; +typedef upgrade_to_unique_lock auto_upgrade_unique_lock; + +void testUpgrade(void); + +void testUpgrade(void) +{ + shared_mutex mtx; + auto_upgrade_lock lock(mtx); + // Do some read-only stuff + + auto_upgrade_unique_lock writeLock(lock); + // Do some write-only stuff with the upgraded lock +}