Unordered: Merge move changes. Fixes #6311.

[SVN r76531]
This commit is contained in:
Daniel James
2012-01-15 20:22:15 +00:00
parent 280b1971b6
commit 63d56953af
12 changed files with 209 additions and 69 deletions

View File

@ -40,20 +40,7 @@
#if !defined(BOOST_NO_RVALUE_REFERENCES) && \ #if !defined(BOOST_NO_RVALUE_REFERENCES) && \
!defined(BOOST_NO_VARIADIC_TEMPLATES) !defined(BOOST_NO_VARIADIC_TEMPLATES)
# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) #define BOOST_UNORDERED_VARIADIC_MOVE
# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
# elif defined(_LIBCPP_VERSION)
# define BOOST_UNORDERED_STD_FORWARD_MOVE
# elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20090804
# define BOOST_UNORDERED_STD_FORWARD_MOVE
# endif
# elif defined(__STL_CONFIG_H)
# elif defined(__MSL_CPP__)
# elif defined(__IBMCPP__)
# elif defined(MSIPL_COMPILE_H)
# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
# endif
#endif #endif
namespace boost { namespace unordered { namespace detail { namespace boost { namespace unordered { namespace detail {
@ -64,11 +51,11 @@ namespace boost { namespace unordered { namespace detail {
// Either forwarding variadic arguments, or storing the arguments in // Either forwarding variadic arguments, or storing the arguments in
// emplace_args##n // emplace_args##n
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
#define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args #define BOOST_UNORDERED_EMPLACE_TEMPLATE typename... Args
#define BOOST_UNORDERED_EMPLACE_ARGS Args&&... args #define BOOST_UNORDERED_EMPLACE_ARGS Args&&... args
#define BOOST_UNORDERED_EMPLACE_FORWARD std::forward<Args>(args)... #define BOOST_UNORDERED_EMPLACE_FORWARD boost::forward<Args>(args)...
#else #else
@ -302,7 +289,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
#endif #endif
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Construct from variadic parameters // Construct from variadic parameters
@ -310,7 +297,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
template <typename T, typename... Args> template <typename T, typename... Args>
inline void construct_impl(T* address, Args&&... args) inline void construct_impl(T* address, Args&&... args)
{ {
new((void*) address) T(std::forward<Args>(args)...); new((void*) address) T(boost::forward<Args>(args)...);
} }
template <typename A, typename B, typename A0, typename A1, typename A2> template <typename A, typename B, typename A0, typename A1, typename A2>
@ -329,7 +316,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
inline typename enable_if<emulation1<A, B, A0>, void>::type inline typename enable_if<emulation1<A, B, A0>, void>::type
construct_impl(std::pair<A, B>* address, A0&& a0) construct_impl(std::pair<A, B>* address, A0&& a0)
{ {
new((void*) boost::addressof(address->first)) A(std::forward<A0>(a0)); new((void*) boost::addressof(address->first)) A(boost::forward<A0>(a0));
new((void*) boost::addressof(address->second)) B(); new((void*) boost::addressof(address->second)) B();
} }
@ -337,10 +324,10 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
inline typename enable_if<emulation3<A, B, A0>, void>::type inline typename enable_if<emulation3<A, B, A0>, void>::type
construct_impl(std::pair<A, B>* address, A0&& a0, A1&& a1, A2&& a2) construct_impl(std::pair<A, B>* address, A0&& a0, A1&& a1, A2&& a2)
{ {
new((void*) boost::addressof(address->first)) A(std::forward<A0>(a0)); new((void*) boost::addressof(address->first)) A(boost::forward<A0>(a0));
new((void*) boost::addressof(address->second)) B( new((void*) boost::addressof(address->second)) B(
std::forward<A1>(a1), boost::forward<A1>(a1),
std::forward<A2>(a2)); boost::forward<A2>(a2));
} }
template <typename A, typename B, template <typename A, typename B,
@ -349,17 +336,17 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
inline void construct_impl(std::pair<A, B>* address, inline void construct_impl(std::pair<A, B>* address,
A0&& a0, A1&& a1, A2&& a2, A3&& a3, Args&&... args) A0&& a0, A1&& a1, A2&& a2, A3&& a3, Args&&... args)
{ {
new((void*) boost::addressof(address->first)) A(std::forward<A0>(a0)); new((void*) boost::addressof(address->first)) A(boost::forward<A0>(a0));
new((void*) boost::addressof(address->second)) B( new((void*) boost::addressof(address->second)) B(
std::forward<A1>(a1), boost::forward<A1>(a1),
std::forward<A2>(a2), boost::forward<A2>(a2),
std::forward<A3>(a3), boost::forward<A3>(a3),
std::forward<Args>(args)...); boost::forward<Args>(args)...);
} }
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT #endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
#else // BOOST_UNORDERED_STD_FORWARD_MOVE #else // BOOST_UNORDERED_VARIADIC_MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Construct from emplace_args // Construct from emplace_args
@ -471,7 +458,7 @@ BOOST_UNORDERED_CONSTRUCT_FROM_TUPLE(10, std)
#undef BOOST_UNORDERED_CALL_FORWARD2 #undef BOOST_UNORDERED_CALL_FORWARD2
#endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT #endif // BOOST_UNORDERED_DEPRECATED_PAIR_CONSTRUCT
#endif // BOOST_UNORDERED_STD_FORWARD_MOVE #endif // BOOST_UNORDERED_VARIADIC_MOVE
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Construct without using the emplace args mechanism. // Construct without using the emplace args mechanism.

View File

@ -63,7 +63,7 @@ namespace detail {
return no_key(); return no_key();
} }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class... Args> template <class... Args>
static no_key extract(Args const&...) static no_key extract(Args const&...)
{ {
@ -126,7 +126,7 @@ namespace detail {
return v.first; return v.first;
} }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class Arg1, class... Args> template <class Arg1, class... Args>
static key_type const& extract(key_type const& k, static key_type const& extract(key_type const& k,
Arg1 const&, Args const&...) Arg1 const&, Args const&...)
@ -165,7 +165,7 @@ namespace detail {
} }
#endif #endif
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
#define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_) \ #define BOOST_UNORDERED_KEY_FROM_TUPLE(namespace_) \
template <typename T2> \ template <typename T2> \

View File

@ -337,7 +337,7 @@ namespace boost { namespace unordered { namespace detail {
// exception (need strong safety in such a case). // exception (need strong safety in such a case).
node_constructor a(this->node_alloc()); node_constructor a(this->node_alloc());
a.construct_node(); a.construct_node();
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
a.construct_value(boost::unordered::piecewise_construct, a.construct_value(boost::unordered::piecewise_construct,
boost::make_tuple(k), boost::make_tuple()); boost::make_tuple(k), boost::make_tuple());
#else #else
@ -364,7 +364,7 @@ namespace boost { namespace unordered { namespace detail {
template <BOOST_UNORDERED_EMPLACE_TEMPLATE> template <BOOST_UNORDERED_EMPLACE_TEMPLATE>
emplace_return emplace(BOOST_UNORDERED_EMPLACE_ARGS) emplace_return emplace(BOOST_UNORDERED_EMPLACE_ARGS)
{ {
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
return emplace_impl( return emplace_impl(
extractor::extract(BOOST_UNORDERED_EMPLACE_FORWARD), extractor::extract(BOOST_UNORDERED_EMPLACE_FORWARD),
BOOST_UNORDERED_EMPLACE_FORWARD); BOOST_UNORDERED_EMPLACE_FORWARD);
@ -376,7 +376,7 @@ namespace boost { namespace unordered { namespace detail {
#endif #endif
} }
#if !defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if !defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <typename A0> template <typename A0>
emplace_return emplace( emplace_return emplace(
boost::unordered::detail::emplace_args1<A0> const& args) boost::unordered::detail::emplace_args1<A0> const& args)

View File

@ -41,7 +41,9 @@ namespace unordered
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
class unordered_map class unordered_map
{ {
#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_map) BOOST_COPYABLE_AND_MOVABLE(unordered_map)
#endif
public: public:
@ -115,10 +117,17 @@ namespace unordered
unordered_map(unordered_map const&, allocator_type const&); unordered_map(unordered_map const&, allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map(BOOST_RV_REF(unordered_map) other) unordered_map(BOOST_RV_REF(unordered_map) other)
: table_(other.table_, boost::unordered::detail::move_tag()) : table_(other.table_, boost::unordered::detail::move_tag())
{ {
} }
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_map(unordered_map&& other)
: table_(other.table_, boost::unordered::detail::move_tag())
{
}
#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES) #if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_map(unordered_map&&, allocator_type const&); unordered_map(unordered_map&&, allocator_type const&);
@ -139,6 +148,7 @@ namespace unordered
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x) unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
{ {
table_.assign(x.table_); table_.assign(x.table_);
@ -150,6 +160,21 @@ namespace unordered
table_.move_assign(x.table_); table_.move_assign(x.table_);
return *this; return *this;
} }
#else
unordered_map& operator=(unordered_map const& x)
{
table_.assign(x.table_);
return *this;
}
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_map& operator=(unordered_map&& x)
{
table_.move_assign(x.table_);
return *this;
}
#endif
#endif
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_map& operator=(std::initializer_list<value_type>); unordered_map& operator=(std::initializer_list<value_type>);
@ -208,17 +233,17 @@ namespace unordered
// emplace // emplace
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class... Args> template <class... Args>
std::pair<iterator, bool> emplace(Args&&... args) std::pair<iterator, bool> emplace(Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
template <class... Args> template <class... Args>
iterator emplace_hint(const_iterator, Args&&... args) iterator emplace_hint(const_iterator, Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...).first; return table_.emplace(boost::forward<Args>(args)...).first;
} }
#else #else
@ -501,8 +526,9 @@ namespace unordered
template <class K, class T, class H, class P, class A> template <class K, class T, class H, class P, class A>
class unordered_multimap class unordered_multimap
{ {
#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_multimap) BOOST_COPYABLE_AND_MOVABLE(unordered_multimap)
#endif
public: public:
typedef K key_type; typedef K key_type;
@ -575,10 +601,17 @@ namespace unordered
unordered_multimap(unordered_multimap const&, allocator_type const&); unordered_multimap(unordered_multimap const&, allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap(BOOST_RV_REF(unordered_multimap) other) unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
: table_(other.table_, boost::unordered::detail::move_tag()) : table_(other.table_, boost::unordered::detail::move_tag())
{ {
} }
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multimap(unordered_multimap&& other)
: table_(other.table_, boost::unordered::detail::move_tag())
{
}
#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES) #if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multimap(unordered_multimap&&, allocator_type const&); unordered_multimap(unordered_multimap&&, allocator_type const&);
@ -599,6 +632,7 @@ namespace unordered
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap& operator=( unordered_multimap& operator=(
BOOST_COPY_ASSIGN_REF(unordered_multimap) x) BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
{ {
@ -611,6 +645,21 @@ namespace unordered
table_.move_assign(x.table_); table_.move_assign(x.table_);
return *this; return *this;
} }
#else
unordered_multimap& operator=(unordered_multimap const& x)
{
table_.assign(x.table_);
return *this;
}
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multimap& operator=(unordered_multimap&& x)
{
table_.move_assign(x.table_);
return *this;
}
#endif
#endif
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_multimap& operator=(std::initializer_list<value_type>); unordered_multimap& operator=(std::initializer_list<value_type>);
@ -669,17 +718,17 @@ namespace unordered
// emplace // emplace
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class... Args> template <class... Args>
iterator emplace(Args&&... args) iterator emplace(Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
template <class... Args> template <class... Args>
iterator emplace_hint(const_iterator, Args&&... args) iterator emplace_hint(const_iterator, Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
#else #else

View File

@ -41,7 +41,9 @@ namespace unordered
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
class unordered_set class unordered_set
{ {
#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_set) BOOST_COPYABLE_AND_MOVABLE(unordered_set)
#endif
public: public:
typedef T key_type; typedef T key_type;
@ -113,10 +115,17 @@ namespace unordered
unordered_set(unordered_set const&, allocator_type const&); unordered_set(unordered_set const&, allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set(BOOST_RV_REF(unordered_set) other) unordered_set(BOOST_RV_REF(unordered_set) other)
: table_(other.table_, boost::unordered::detail::move_tag()) : table_(other.table_, boost::unordered::detail::move_tag())
{ {
} }
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_set(unordered_set&& other)
: table_(other.table_, boost::unordered::detail::move_tag())
{
}
#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES) #if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_set(unordered_set&&, allocator_type const&); unordered_set(unordered_set&&, allocator_type const&);
@ -137,6 +146,7 @@ namespace unordered
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x) unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
{ {
table_.assign(x.table_); table_.assign(x.table_);
@ -148,6 +158,21 @@ namespace unordered
table_.move_assign(x.table_); table_.move_assign(x.table_);
return *this; return *this;
} }
#else
unordered_set& operator=(unordered_set const& x)
{
table_.assign(x.table_);
return *this;
}
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_set& operator=(unordered_set&& x)
{
table_.move_assign(x.table_);
return *this;
}
#endif
#endif
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_set& operator=(std::initializer_list<value_type>); unordered_set& operator=(std::initializer_list<value_type>);
@ -206,17 +231,17 @@ namespace unordered
// emplace // emplace
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class... Args> template <class... Args>
std::pair<iterator, bool> emplace(Args&&... args) std::pair<iterator, bool> emplace(Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
template <class... Args> template <class... Args>
iterator emplace_hint(const_iterator, Args&&... args) iterator emplace_hint(const_iterator, Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...).first; return table_.emplace(boost::forward<Args>(args)...).first;
} }
#else #else
@ -486,7 +511,9 @@ namespace unordered
template <class T, class H, class P, class A> template <class T, class H, class P, class A>
class unordered_multiset class unordered_multiset
{ {
#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_multiset) BOOST_COPYABLE_AND_MOVABLE(unordered_multiset)
#endif
public: public:
typedef T key_type; typedef T key_type;
@ -558,10 +585,17 @@ namespace unordered
unordered_multiset(unordered_multiset const&, allocator_type const&); unordered_multiset(unordered_multiset const&, allocator_type const&);
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset(BOOST_RV_REF(unordered_multiset) other) unordered_multiset(BOOST_RV_REF(unordered_multiset) other)
: table_(other.table_, boost::unordered::detail::move_tag()) : table_(other.table_, boost::unordered::detail::move_tag())
{ {
} }
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multiset(unordered_multiset&& other)
: table_(other.table_, boost::unordered::detail::move_tag())
{
}
#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES) #if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multiset(unordered_multiset&&, allocator_type const&); unordered_multiset(unordered_multiset&&, allocator_type const&);
@ -582,6 +616,7 @@ namespace unordered
// Assign // Assign
#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset& operator=( unordered_multiset& operator=(
BOOST_COPY_ASSIGN_REF(unordered_multiset) x) BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
{ {
@ -594,6 +629,21 @@ namespace unordered
table_.move_assign(x.table_); table_.move_assign(x.table_);
return *this; return *this;
} }
#else
unordered_multiset& operator=(unordered_multiset const& x)
{
table_.assign(x.table_);
return *this;
}
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multiset& operator=(unordered_multiset&& x)
{
table_.move_assign(x.table_);
return *this;
}
#endif
#endif
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST) #if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
unordered_multiset& operator=(std::initializer_list<value_type>); unordered_multiset& operator=(std::initializer_list<value_type>);
@ -652,17 +702,17 @@ namespace unordered
// emplace // emplace
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template <class... Args> template <class... Args>
iterator emplace(Args&&... args) iterator emplace(Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
template <class... Args> template <class... Args>
iterator emplace_hint(const_iterator, Args&&... args) iterator emplace_hint(const_iterator, Args&&... args)
{ {
return table_.emplace(std::forward<Args>(args)...); return table_.emplace(boost::forward<Args>(args)...);
} }
#else #else

View File

@ -168,10 +168,10 @@ namespace test
new(p) T(t); new(p) T(t);
} }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template<typename... Args> void construct(T* p, Args&&... args) { template<typename... Args> void construct(T* p, Args&&... args) {
detail::tracker.track_construct((void*) p, sizeof(T), tag_); detail::tracker.track_construct((void*) p, sizeof(T), tag_);
new(p) T(std::forward<Args>(args)...); new(p) T(boost::forward<Args>(args)...);
} }
#endif #endif

View File

@ -357,11 +357,11 @@ namespace exception
detail::tracker.track_construct((void*) p, sizeof(T), tag_); detail::tracker.track_construct((void*) p, sizeof(T), tag_);
} }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template<class... Args> void construct(T* p, Args&&... args) { template<class... Args> void construct(T* p, Args&&... args) {
UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) { UNORDERED_SCOPE(allocator::construct(pointer, Args&&...)) {
UNORDERED_EPOINT("Mock allocator construct function."); UNORDERED_EPOINT("Mock allocator construct function.");
new(p) T(std::forward<Args>(args)...); new(p) T(boost::forward<Args>(args)...);
} }
detail::tracker.track_construct((void*) p, sizeof(T), tag_); detail::tracker.track_construct((void*) p, sizeof(T), tag_);
} }

View File

@ -367,9 +367,9 @@ namespace minimal
void construct(T* p, T const& t) { new((void*)p) T(t); } void construct(T* p, T const& t) { new((void*)p) T(t); }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template<class... Args> void construct(T* p, Args&&... args) { template<class... Args> void construct(T* p, Args&&... args) {
new((void*)p) T(std::forward<Args>(args)...); new((void*)p) T(boost::forward<Args>(args)...);
} }
#endif #endif
@ -439,9 +439,9 @@ namespace minimal
void construct(T* p, T const& t) { new((void*)p) T(t); } void construct(T* p, T const& t) { new((void*)p) T(t); }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template<class... Args> void construct(T* p, Args&&... args) { template<class... Args> void construct(T* p, Args&&... args) {
new((void*)p) T(std::forward<Args>(args)...); new((void*)p) T(boost::forward<Args>(args)...);
} }
#endif #endif

View File

@ -259,10 +259,10 @@ namespace test
new(p) T(t); new(p) T(t);
} }
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if defined(BOOST_UNORDERED_VARIADIC_MOVE)
template<class... Args> void construct(T* p, Args&&... args) { template<class... Args> void construct(T* p, Args&&... args) {
detail::tracker.track_construct((void*) p, sizeof(T), tag_); detail::tracker.track_construct((void*) p, sizeof(T), tag_);
new(p) T(std::forward<Args>(args)...); new(p) T(boost::forward<Args>(args)...);
} }
#endif #endif

View File

@ -50,4 +50,20 @@ test-suite unordered
[ run equality_tests.cpp ] [ run equality_tests.cpp ]
[ run equality_deprecated.cpp ] [ run equality_deprecated.cpp ]
[ run swap_tests.cpp ] [ run swap_tests.cpp ]
[ run compile_set.cpp : :
: <define>BOOST_UNORDERED_USE_MOVE
: bmove_compile_set ]
[ run compile_map.cpp : :
: <define>BOOST_UNORDERED_USE_MOVE
: bmove_compile_map ]
[ run copy_tests.cpp : :
: <define>BOOST_UNORDERED_USE_MOVE
: bmove_copy ]
[ run move_tests.cpp : :
: <define>BOOST_UNORDERED_USE_MOVE
: bmove_move ]
[ run assign_tests.cpp : :
: <define>BOOST_UNORDERED_USE_MOVE
: bmove_assign ]
; ;

View File

@ -22,6 +22,11 @@
namespace move_tests namespace move_tests
{ {
test::seed_t seed(98624); test::seed_t seed(98624);
#if defined(BOOST_UNORDERED_USE_MOVE) || !defined(BOOST_NO_RVALUE_REFERENCES)
#define BOOST_UNORDERED_TEST_MOVING 1
#else
#define BOOST_UNORDERED_TEST_MOVING 0
#endif
template<class T> template<class T>
T empty(T*) { T empty(T*) {
@ -95,7 +100,7 @@ namespace move_tests
test::object_count count; test::object_count count;
T y; T y;
y = create(v, count); y = create(v, count);
#if defined(BOOST_HAS_NRVO) #if BOOST_UNORDERED_TEST_MOVING && defined(BOOST_HAS_NRVO)
BOOST_TEST(count == test::global_object_count); BOOST_TEST(count == test::global_object_count);
#endif #endif
test::check_container(y, v); test::check_container(y, v);
@ -195,7 +200,10 @@ namespace move_tests
BOOST_TEST(y.max_load_factor() == 2.0); BOOST_TEST(y.max_load_factor() == 2.0);
#if defined(BOOST_HAS_NRVO) #if defined(BOOST_HAS_NRVO)
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING ?
(bool) allocator_type::is_propagate_on_move :
(bool) allocator_type::is_propagate_on_assign)
{
BOOST_TEST(test::equivalent(y.get_allocator(), al2)); BOOST_TEST(test::equivalent(y.get_allocator(), al2));
} }
else { else {
@ -210,7 +218,9 @@ namespace move_tests
T y(0, hf, eq, al1); T y(0, hf, eq, al1);
y = create(v, count, hf, eq, al2, 0.5); y = create(v, count, hf, eq, al2, 0.5);
#if defined(BOOST_HAS_NRVO) #if defined(BOOST_HAS_NRVO)
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING &&
allocator_type::is_propagate_on_move)
{
BOOST_TEST(count == test::global_object_count); BOOST_TEST(count == test::global_object_count);
} }
#endif #endif
@ -219,7 +229,10 @@ namespace move_tests
BOOST_TEST(y.max_load_factor() == 0.5); BOOST_TEST(y.max_load_factor() == 0.5);
#if defined(BOOST_HAS_NRVO) #if defined(BOOST_HAS_NRVO)
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING ?
(bool) allocator_type::is_propagate_on_move :
(bool) allocator_type::is_propagate_on_assign)
{
BOOST_TEST(test::equivalent(y.get_allocator(), al2)); BOOST_TEST(test::equivalent(y.get_allocator(), al2));
} }
else { else {
@ -240,14 +253,19 @@ namespace move_tests
test::object_count count = test::global_object_count; test::object_count count = test::global_object_count;
y = boost::move(x); y = boost::move(x);
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING &&
allocator_type::is_propagate_on_move)
{
BOOST_TEST(count == test::global_object_count); BOOST_TEST(count == test::global_object_count);
} }
test::check_container(y, v); test::check_container(y, v);
test::check_equivalent_keys(y); test::check_equivalent_keys(y);
BOOST_TEST(y.max_load_factor() == 0.25); BOOST_TEST(y.max_load_factor() == 0.25);
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING ?
(bool) allocator_type::is_propagate_on_move :
(bool) allocator_type::is_propagate_on_assign)
{
BOOST_TEST(test::equivalent(y.get_allocator(), al2)); BOOST_TEST(test::equivalent(y.get_allocator(), al2));
} }
else { else {
@ -272,7 +290,9 @@ namespace move_tests
test::object_count count2 = test::global_object_count; test::object_count count2 = test::global_object_count;
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING &&
allocator_type::is_propagate_on_move)
{
BOOST_TEST(count1.instances == BOOST_TEST(count1.instances ==
test::global_object_count.instances); test::global_object_count.instances);
BOOST_TEST(count2.constructions == BOOST_TEST(count2.constructions ==
@ -283,7 +303,10 @@ namespace move_tests
test::check_equivalent_keys(y); test::check_equivalent_keys(y);
BOOST_TEST(y.max_load_factor() == 0.5); BOOST_TEST(y.max_load_factor() == 0.5);
if (allocator_type::is_propagate_on_move) { if (BOOST_UNORDERED_TEST_MOVING ?
(bool) allocator_type::is_propagate_on_move :
(bool) allocator_type::is_propagate_on_assign)
{
BOOST_TEST(test::equivalent(y.get_allocator(), al2)); BOOST_TEST(test::equivalent(y.get_allocator(), al2));
} }
else { else {

View File

@ -9,6 +9,23 @@
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include "../helpers/test.hpp" #include "../helpers/test.hpp"
#if defined(BOOST_UNORDERED_VARIADIC_MOVE)
# if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
# elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER)
# elif defined(_LIBCPP_VERSION)
# define BOOST_UNORDERED_VARIADIC_MOVE
# elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
# if defined(__GLIBCXX__) && __GLIBCXX__ >= 20090804
# define BOOST_UNORDERED_VARIADIC_MOVE
# endif
# elif defined(__STL_CONFIG_H)
# elif defined(__MSL_CPP__)
# elif defined(__IBMCPP__)
# elif defined(MSIPL_COMPILE_H)
# elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
# endif
#endif
namespace unnecessary_copy_tests namespace unnecessary_copy_tests
{ {
struct count_copies struct count_copies
@ -243,9 +260,7 @@ namespace unnecessary_copy_tests
// the existing element. // the existing element.
reset(); reset();
x.emplace(); x.emplace();
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE) #if !defined(BOOST_NO_RVALUE_REFERENCES)
COPY_COUNT(1); MOVE_COUNT(0);
#elif !defined(BOOST_NO_RVALUE_REFERENCES)
// source_cost doesn't make much sense here, but it seems to fit. // source_cost doesn't make much sense here, but it seems to fit.
COPY_COUNT(1); MOVE_COUNT(source_cost); COPY_COUNT(1); MOVE_COUNT(source_cost);
#else #else