|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r76330 - in trunk: boost/unordered libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2012-01-06 03:35:53
Author: danieljames
Date: 2012-01-06 03:35:51 EST (Fri, 06 Jan 2012)
New Revision: 76330
URL: http://svn.boost.org/trac/boost/changeset/76330
Log:
Unordered: Make using Boost.Move optional.
Text files modified:
trunk/boost/unordered/unordered_map.hpp | 51 +++++++++++++++++++++++++++++++++++++++
trunk/boost/unordered/unordered_set.hpp | 50 +++++++++++++++++++++++++++++++++++++++
trunk/libs/unordered/test/unordered/move_tests.cpp | 39 ++++++++++++++++++++++++------
3 files changed, 131 insertions(+), 9 deletions(-)
Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2012-01-06 03:35:51 EST (Fri, 06 Jan 2012)
@@ -41,7 +41,9 @@
template <class K, class T, class H, class P, class A>
class unordered_map
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_map)
+#endif
public:
@@ -115,10 +117,17 @@
unordered_map(unordered_map const&, allocator_type const&);
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map(BOOST_RV_REF(unordered_map) other)
: 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)
unordered_map(unordered_map&&, allocator_type const&);
@@ -139,6 +148,7 @@
// Assign
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x)
{
table_.assign(x.table_);
@@ -150,6 +160,21 @@
table_.move_assign(x.table_);
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)
unordered_map& operator=(std::initializer_list<value_type>);
@@ -501,8 +526,9 @@
template <class K, class T, class H, class P, class A>
class unordered_multimap
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_multimap)
-
+#endif
public:
typedef K key_type;
@@ -575,10 +601,17 @@
unordered_multimap(unordered_multimap const&, allocator_type const&);
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap(BOOST_RV_REF(unordered_multimap) other)
: 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)
unordered_multimap(unordered_multimap&&, allocator_type const&);
@@ -599,6 +632,7 @@
// Assign
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multimap& operator=(
BOOST_COPY_ASSIGN_REF(unordered_multimap) x)
{
@@ -611,6 +645,21 @@
table_.move_assign(x.table_);
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)
unordered_multimap& operator=(std::initializer_list<value_type>);
Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2012-01-06 03:35:51 EST (Fri, 06 Jan 2012)
@@ -41,7 +41,9 @@
template <class T, class H, class P, class A>
class unordered_set
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_set)
+#endif
public:
typedef T key_type;
@@ -113,10 +115,17 @@
unordered_set(unordered_set const&, allocator_type const&);
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set(BOOST_RV_REF(unordered_set) other)
: 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)
unordered_set(unordered_set&&, allocator_type const&);
@@ -137,6 +146,7 @@
// Assign
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x)
{
table_.assign(x.table_);
@@ -148,6 +158,21 @@
table_.move_assign(x.table_);
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)
unordered_set& operator=(std::initializer_list<value_type>);
@@ -486,7 +511,9 @@
template <class T, class H, class P, class A>
class unordered_multiset
{
+#if defined(BOOST_UNORDERED_USE_MOVE)
BOOST_COPYABLE_AND_MOVABLE(unordered_multiset)
+#endif
public:
typedef T key_type;
@@ -558,10 +585,17 @@
unordered_multiset(unordered_multiset const&, allocator_type const&);
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset(BOOST_RV_REF(unordered_multiset) other)
: 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)
unordered_multiset(unordered_multiset&&, allocator_type const&);
@@ -582,6 +616,7 @@
// Assign
+#if defined(BOOST_UNORDERED_USE_MOVE)
unordered_multiset& operator=(
BOOST_COPY_ASSIGN_REF(unordered_multiset) x)
{
@@ -594,6 +629,21 @@
table_.move_assign(x.table_);
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)
unordered_multiset& operator=(std::initializer_list<value_type>);
Modified: trunk/libs/unordered/test/unordered/move_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/move_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/move_tests.cpp 2012-01-06 03:35:51 EST (Fri, 06 Jan 2012)
@@ -22,6 +22,11 @@
namespace move_tests
{
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>
T empty(T*) {
@@ -95,7 +100,7 @@
test::object_count count;
T y;
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);
#endif
test::check_container(y, v);
@@ -195,7 +200,10 @@
BOOST_TEST(y.max_load_factor() == 2.0);
#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));
}
else {
@@ -210,7 +218,9 @@
T y(0, hf, eq, al1);
y = create(v, count, hf, eq, al2, 0.5);
#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);
}
#endif
@@ -219,7 +229,10 @@
BOOST_TEST(y.max_load_factor() == 0.5);
#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));
}
else {
@@ -240,14 +253,19 @@
test::object_count count = test::global_object_count;
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);
}
test::check_container(y, v);
test::check_equivalent_keys(y);
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));
}
else {
@@ -272,7 +290,9 @@
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 ==
test::global_object_count.instances);
BOOST_TEST(count2.constructions ==
@@ -283,7 +303,10 @@
test::check_equivalent_keys(y);
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));
}
else {
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk