|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r74193 - in trunk: boost/unordered boost/unordered/detail libs/unordered/test/unordered
From: dnljms_at_[hidden]
Date: 2011-09-02 04:28:54
Author: danieljames
Date: 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
New Revision: 74193
URL: http://svn.boost.org/trac/boost/changeset/74193
Log:
Unordered: Try to fix issues with moving non-class types.
Text files modified:
trunk/boost/unordered/detail/equivalent.hpp | 8 ++++++++
trunk/boost/unordered/detail/unique.hpp | 8 ++++++++
trunk/boost/unordered/detail/util.hpp | 33 +++++++++++++++++++++++++++++++++
trunk/boost/unordered/unordered_map.hpp | 24 ++++++------------------
trunk/boost/unordered/unordered_set.hpp | 35 +++++++++++------------------------
trunk/libs/unordered/test/unordered/compile_set.cpp | 4 ++--
6 files changed, 68 insertions(+), 44 deletions(-)
Modified: trunk/boost/unordered/detail/equivalent.hpp
==============================================================================
--- trunk/boost/unordered/detail/equivalent.hpp (original)
+++ trunk/boost/unordered/detail/equivalent.hpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -228,6 +228,14 @@
this->find_node(bucket_index, hash, k));
}
+#if defined(BOOST_NO_RVALUE_REFERENCES)
+ node_ptr emplace(please_ignore_this_overload const&)
+ {
+ BOOST_ASSERT(false);
+ return this->begin();
+ }
+#endif
+
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
template <class... Args>
Modified: trunk/boost/unordered/detail/unique.hpp
==============================================================================
--- trunk/boost/unordered/detail/unique.hpp (original)
+++ trunk/boost/unordered/detail/unique.hpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -196,6 +196,14 @@
}
+#if defined(BOOST_NO_RVALUE_REFERENCES)
+ emplace_return emplace(please_ignore_this_overload const&)
+ {
+ BOOST_ASSERT(false);
+ return emplace_return(this->begin(), false);
+ }
+#endif
+
#if defined(BOOST_UNORDERED_STD_FORWARD_MOVE)
template<class... Args>
Modified: trunk/boost/unordered/detail/util.hpp
==============================================================================
--- trunk/boost/unordered/detail/util.hpp (original)
+++ trunk/boost/unordered/detail/util.hpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -23,6 +23,9 @@
#include <boost/type_traits/alignment_of.hpp>
#include <boost/type_traits/remove_const.hpp>
#include <boost/type_traits/is_empty.hpp>
+#if defined(BOOST_NO_RVALUE_REFERENCES)
+#include <boost/type_traits/is_class.hpp>
+#endif
#include <boost/throw_exception.hpp>
#include <boost/move/move.hpp>
#include <boost/swap.hpp>
@@ -130,6 +133,36 @@
#pragma warning(pop)
#endif
+#if !defined(BOOST_NO_RVALUE_REFERENCES)
+
+#define BOOST_UNORDERED_RV_REF(T) BOOST_RV_REF(T)
+
+#else
+
+ struct please_ignore_this_overload {
+ typedef please_ignore_this_overload type;
+ };
+
+ template <typename T>
+ struct rv_ref_impl {
+ typedef BOOST_RV_REF(T) type;
+ };
+
+ template <typename T>
+ struct rv_ref :
+ boost::detail::if_true<
+ boost::is_class<T>::value
+ >::BOOST_NESTED_TEMPLATE then <
+ rv_ref_impl<T>,
+ please_ignore_this_overload
+ >::type
+ {};
+
+#define BOOST_UNORDERED_RV_REF(T) \
+ typename ::boost::unordered::detail::rv_ref<T>::type
+
+#endif
+
////////////////////////////////////////////////////////////////////////////
// convert double to std::size_t
Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -132,9 +132,7 @@
unordered_map(unordered_map const&);
-#if BOOST_UNORDERED_USE_RV_REF
- unordered_map& operator=(
- BOOST_RV_REF(unordered_map) x)
+ unordered_map& operator=(BOOST_RV_REF(unordered_map) x)
{
table_.move_assign(x.table_);
return *this;
@@ -144,7 +142,6 @@
: table_(other.table_, ::boost::unordered::detail::move_tag())
{
}
-#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_map(unordered_map&&, allocator_type const&);
@@ -257,11 +254,10 @@
#endif
std::pair<iterator, bool> insert(value_type const&);
- iterator insert(const_iterator, value_type const&);
-#if BOOST_UNORDERED_USE_RV_REF
std::pair<iterator, bool> insert(BOOST_RV_REF(value_type));
+ iterator insert(const_iterator, value_type const&);
iterator insert(const_iterator, BOOST_RV_REF(value_type));
-#endif
+
template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
@@ -481,9 +477,7 @@
unordered_multimap(unordered_multimap const&);
-#if BOOST_UNORDERED_USE_RV_REF
- unordered_multimap& operator=(
- BOOST_RV_REF(unordered_multimap) x)
+ unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x)
{
table_.move_assign(x.table_);
return *this;
@@ -493,7 +487,6 @@
: table_(other.table_, ::boost::unordered::detail::move_tag())
{
}
-#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multimap(unordered_multimap&&, allocator_type const&);
@@ -606,11 +599,10 @@
#endif
iterator insert(value_type const&);
- iterator insert(const_iterator, value_type const&);
-#if BOOST_UNORDERED_USE_RV_REF
iterator insert(BOOST_RV_REF(value_type));
+ iterator insert(const_iterator, value_type const&);
iterator insert(const_iterator, BOOST_RV_REF(value_type));
-#endif
+
template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
@@ -930,7 +922,6 @@
return iterator(table_.emplace(obj).first);
}
-#if BOOST_UNORDERED_USE_RV_REF
template <class K, class T, class H, class P, class A>
std::pair<typename unordered_map<K,T,H,P,A>::iterator, bool>
unordered_map<K,T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
@@ -945,7 +936,6 @@
{
return iterator(table_.emplace(boost::move(obj)).first);
}
-#endif
template <class K, class T, class H, class P, class A>
template <class InputIt>
@@ -1363,7 +1353,6 @@
return iterator(table_.emplace(obj));
}
-#if BOOST_UNORDERED_USE_RV_REF
template <class K, class T, class H, class P, class A>
typename unordered_multimap<K,T,H,P,A>::iterator
unordered_multimap<K,T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
@@ -1378,7 +1367,6 @@
{
return iterator(table_.emplace(boost::move(obj)));
}
-#endif
template <class K, class T, class H, class P, class A>
template <class InputIt>
Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -131,9 +131,7 @@
unordered_set(unordered_set const&);
-#if BOOST_UNORDERED_USE_RV_REF
- unordered_set& operator=(
- BOOST_RV_REF(unordered_set) x)
+ unordered_set& operator=(BOOST_RV_REF(unordered_set) x)
{
table_.move_assign(x.table_);
return *this;
@@ -143,7 +141,6 @@
: table_(other.table_, ::boost::unordered::detail::move_tag())
{
}
-#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_set(unordered_set&&, allocator_type const&);
@@ -254,11 +251,9 @@
#endif
std::pair<iterator, bool> insert(value_type const&);
+ std::pair<iterator, bool> insert(BOOST_UNORDERED_RV_REF(value_type));
iterator insert(const_iterator, value_type const&);
-#if BOOST_UNORDERED_USE_RV_REF
- std::pair<iterator, bool> insert(BOOST_RV_REF(value_type));
- iterator insert(const_iterator, BOOST_RV_REF(value_type));
-#endif
+ iterator insert(const_iterator, BOOST_UNORDERED_RV_REF(value_type));
template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
@@ -460,9 +455,7 @@
unordered_multiset(unordered_multiset const&);
-#if BOOST_UNORDERED_USE_RV_REF
- unordered_multiset& operator=(
- BOOST_RV_REF(unordered_multiset) x)
+ unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x)
{
table_.move_assign(x.table_);
return *this;
@@ -472,7 +465,6 @@
: table_(other.table_, ::boost::unordered::detail::move_tag())
{
}
-#endif
#if !defined(BOOST_NO_RVALUE_REFERENCES)
unordered_multiset(unordered_multiset&&, allocator_type const&);
@@ -583,11 +575,10 @@
#endif
iterator insert(value_type const&);
+ iterator insert(BOOST_UNORDERED_RV_REF(value_type));
iterator insert(const_iterator, value_type const&);
-#if BOOST_UNORDERED_USE_RV_REF
- iterator insert(BOOST_RV_REF(value_type));
- iterator insert(const_iterator, BOOST_RV_REF(value_type));
-#endif
+ iterator insert(const_iterator, BOOST_UNORDERED_RV_REF(value_type));
+
template <class InputIt>
void insert(InputIt, InputIt);
@@ -895,10 +886,9 @@
return iterator(table_.emplace(obj).first);
}
-#if BOOST_UNORDERED_USE_RV_REF
template <class T, class H, class P, class A>
std::pair<typename unordered_set<T,H,P,A>::iterator, bool>
- unordered_set<T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
+ unordered_set<T,H,P,A>::insert(BOOST_UNORDERED_RV_REF(value_type) obj)
{
return table_.emplace(boost::move(obj));
}
@@ -906,11 +896,10 @@
template <class T, class H, class P, class A>
typename unordered_set<T,H,P,A>::iterator
unordered_set<T,H,P,A>::insert(const_iterator,
- BOOST_RV_REF(value_type) obj)
+ BOOST_UNORDERED_RV_REF(value_type) obj)
{
return iterator(table_.emplace(boost::move(obj)).first);
}
-#endif
template <class T, class H, class P, class A>
template <class InputIt>
@@ -1275,10 +1264,9 @@
return iterator(table_.emplace(obj));
}
-#if BOOST_UNORDERED_USE_RV_REF
template <class T, class H, class P, class A>
typename unordered_multiset<T,H,P,A>::iterator
- unordered_multiset<T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
+ unordered_multiset<T,H,P,A>::insert(BOOST_UNORDERED_RV_REF(value_type) obj)
{
return iterator(table_.emplace(boost::move(obj)));
}
@@ -1286,11 +1274,10 @@
template <class T, class H, class P, class A>
typename unordered_multiset<T,H,P,A>::iterator
unordered_multiset<T,H,P,A>::insert(const_iterator,
- BOOST_RV_REF(value_type) obj)
+ BOOST_UNORDERED_RV_REF(value_type) obj)
{
return iterator(table_.emplace(boost::move(obj)));
}
-#endif
template <class T, class H, class P, class A>
template <class InputIt>
Modified: trunk/libs/unordered/test/unordered/compile_set.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/compile_set.cpp (original)
+++ trunk/libs/unordered/test/unordered/compile_set.cpp 2011-09-02 04:28:52 EDT (Fri, 02 Sep 2011)
@@ -16,7 +16,7 @@
#include "./compile_tests.hpp"
// Explicit instantiation to catch compile-time errors
-/*
+
template class boost::unordered_set<
int,
boost::hash<int>,
@@ -27,7 +27,7 @@
boost::hash<int>,
std::equal_to<int>,
test::minimal::allocator<int> >;
-*/
+
template class boost::unordered_set<
test::minimal::assignable,
test::minimal::hash<test::minimal::assignable>,
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