mirror of
https://github.com/boostorg/thread.git
synced 2026-01-23 06:02:14 +00:00
Thread: #6141 - Compilation error when boost.thread and boost.move are used together
[SVN r76277]
This commit is contained in:
@@ -6,15 +6,14 @@
|
||||
#ifndef BOOST_THREAD_MOVE_HPP
|
||||
#define BOOST_THREAD_MOVE_HPP
|
||||
|
||||
#include <boost/thread/detail/config.hpp>
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
#include <boost/move/move.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/config/abi_prefix.hpp>
|
||||
|
||||
@@ -45,11 +44,6 @@ namespace boost
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef BOOST_THREAD_USES_SPECIFIC_MOVE_NS
|
||||
namespace threads {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_NO_SFINAE
|
||||
template<typename T>
|
||||
typename enable_if<boost::is_convertible<T&,boost::detail::thread_move_t<T> >, boost::detail::thread_move_t<T> >::type move(T& t)
|
||||
@@ -64,9 +58,6 @@ namespace threads {
|
||||
return t;
|
||||
}
|
||||
|
||||
#ifdef BOOST_THREAD_USES_SPECIFIC_MOVE_NS
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<thread>
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
namespace this_thread
|
||||
{
|
||||
template<typename F>
|
||||
|
||||
@@ -754,6 +754,13 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
struct has_move_emulation_enabled_aux<unique_future<T> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
template <typename R>
|
||||
class shared_future
|
||||
{
|
||||
@@ -912,6 +919,13 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
struct has_move_emulation_enabled_aux<shared_future<T> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
template <typename R>
|
||||
class promise
|
||||
{
|
||||
@@ -1178,6 +1192,13 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
struct has_move_emulation_enabled_aux<promise<T> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename R>
|
||||
@@ -1409,6 +1430,13 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename T>
|
||||
struct has_move_emulation_enabled_aux<packaged_task<T> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -518,6 +518,13 @@ namespace boost
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename Mutex>
|
||||
struct has_move_emulation_enabled_aux<unique_lock<Mutex> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
template<typename Mutex>
|
||||
class shared_lock
|
||||
{
|
||||
@@ -712,6 +719,14 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename Mutex>
|
||||
struct has_move_emulation_enabled_aux<shared_lock<Mutex> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
template<typename Mutex>
|
||||
void swap(shared_lock<Mutex>&& lhs,shared_lock<Mutex>&& rhs)
|
||||
@@ -896,6 +911,12 @@ namespace boost
|
||||
friend class unique_lock<Mutex>;
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename Mutex>
|
||||
struct has_move_emulation_enabled_aux<upgrade_lock<Mutex> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_NO_RVALUE_REFERENCES
|
||||
template<typename Mutex>
|
||||
@@ -988,6 +1009,13 @@ namespace boost
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef BOOST_NO_RVALUE_REFERENCES
|
||||
template <typename Mutex>
|
||||
struct has_move_emulation_enabled_aux<upgrade_to_unique_lock<Mutex> >
|
||||
: BOOST_MOVE_BOOST_NS::integral_constant<bool, true>
|
||||
{};
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template<typename Mutex>
|
||||
|
||||
@@ -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 ]
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
22
test/test_6170.cpp
Normal file
22
test/test_6170.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
|
||||
// Including this will cause ambiguous errors in boost::move
|
||||
#include <boost/unordered_map.hpp>
|
||||
|
||||
using namespace boost;
|
||||
|
||||
typedef upgrade_lock<shared_mutex> auto_upgrade_lock;
|
||||
typedef upgrade_to_unique_lock<shared_mutex> 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
|
||||
}
|
||||
Reference in New Issue
Block a user