|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r73520 - in trunk/boost/unordered: . detail
From: dnljms_at_[hidden]
Date: 2011-08-03 19:52:38
Author: danieljames
Date: 2011-08-03 19:52:37 EDT (Wed, 03 Aug 2011)
New Revision: 73520
URL: http://svn.boost.org/trac/boost/changeset/73520
Log:
Unordered: Use Boost.Move for emplace and insert.
Text files modified:
trunk/boost/unordered/detail/util.hpp | 13 +++
trunk/boost/unordered/unordered_map.hpp | 121 ++++++++++++++++++++++++++++++---------
trunk/boost/unordered/unordered_set.hpp | 111 +++++++++++++++++++++++++++++-------
3 files changed, 191 insertions(+), 54 deletions(-)
Modified: trunk/boost/unordered/detail/util.hpp
==============================================================================
--- trunk/boost/unordered/detail/util.hpp (original)
+++ trunk/boost/unordered/detail/util.hpp 2011-08-03 19:52:37 EDT (Wed, 03 Aug 2011)
@@ -27,6 +27,7 @@
#include <boost/unordered/detail/allocator_helpers.hpp>
#include <boost/preprocessor/seq/size.hpp>
#include <boost/preprocessor/seq/enum.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
#include <boost/move/move.hpp>
// Template parameters:
@@ -58,10 +59,16 @@
#define BOOST_UNORDERED_TEMPLATE_ARGS(z, num_params) \
BOOST_PP_ENUM_PARAMS_Z(z, num_params, class Arg)
+
#define BOOST_UNORDERED_FUNCTION_PARAMS(z, num_params) \
- BOOST_PP_ENUM_BINARY_PARAMS_Z(z, num_params, Arg, const& arg)
+ BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_FUNCTION_PARAMS2, _)
+#define BOOST_UNORDERED_FUNCTION_PARAMS2(z, i, _) \
+ BOOST_FWD_REF(Arg##i) arg##i
+
#define BOOST_UNORDERED_CALL_PARAMS(z, num_params) \
- BOOST_PP_ENUM_PARAMS_Z(z, num_params, arg)
+ BOOST_PP_ENUM_##z(num_params, BOOST_UNORDERED_CALL_PARAMS2, _)
+#define BOOST_UNORDERED_CALL_PARAMS2(z, i, _) \
+ boost::forward<Arg##i>(arg##i)
#endif
@@ -71,6 +78,8 @@
static const std::size_t default_bucket_count = 11;
struct move_tag {};
+ struct empty_emplace {};
+
template <class T> class unique_table;
template <class T> class equivalent_table;
template <class Alloc, bool Unique> class node_constructor;
Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2011-08-03 19:52:37 EDT (Wed, 03 Aug 2011)
@@ -223,10 +223,18 @@
iterator emplace_hint(const_iterator, Args&&...);
#else
- #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
- std::pair<iterator, bool> emplace(value_type const& = value_type());
- iterator emplace_hint(const_iterator, value_type const& = value_type());
- #endif
+#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
+ std::pair<iterator, bool> emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+ iterator emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+#endif
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
@@ -250,8 +258,10 @@
#endif
- std::pair<iterator, bool> insert(const value_type&);
- iterator insert(const_iterator, const value_type&);
+ std::pair<iterator, bool> insert(value_type const&);
+ 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));
template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
@@ -560,10 +570,18 @@
iterator emplace_hint(const_iterator, Args&&...);
#else
- #if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
- iterator emplace(value_type const& = value_type());
- iterator emplace_hint(const_iterator, value_type const& = value_type());
- #endif
+#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
+ iterator emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+ iterator emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+#endif
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
@@ -587,10 +605,11 @@
#endif
- iterator insert(const value_type&);
- iterator insert(const_iterator, const value_type&);
- template <class InputIt>
- void insert(InputIt, InputIt);
+ iterator insert(value_type const&);
+ iterator insert(BOOST_RV_REF(value_type));
+ iterator insert(const_iterator, value_type const&);
+ iterator insert(const_iterator, BOOST_RV_REF(value_type));
+ template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
void insert(std::initializer_list<value_type>);
@@ -843,17 +862,23 @@
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
template <class K, class T, class H, class P, class A>
std::pair<BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator, bool>
- unordered_map<K,T,H,P,A>::emplace(value_type const& v)
+ unordered_map<K,T,H,P,A>::emplace(
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return BOOST_UNORDERED_PAIR_CAST(iterator, bool, table_.emplace(v));
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(boost::move(v)));
}
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator
- unordered_map<K,T,H,P,A>::emplace_hint(
- const_iterator, value_type const& v)
+ unordered_map<K,T,H,P,A>::emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v).first);
+ return iterator(table_.emplace(boost::move(v)).first);
}
#endif
@@ -897,19 +922,37 @@
template <class K, class T, class H, class P, class A>
std::pair<BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator, bool>
- unordered_map<K,T,H,P,A>::insert(const value_type& obj)
+ unordered_map<K,T,H,P,A>::insert(value_type const& obj)
{
- return BOOST_UNORDERED_PAIR_CAST(iterator, bool, table_.insert(obj));
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(obj));
+ }
+
+ template <class K, class T, class H, class P, class A>
+ std::pair<BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator, bool>
+ unordered_map<K,T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
+ {
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(boost::move(obj)));
}
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator
- unordered_map<K,T,H,P,A>::insert(const_iterator, const value_type& obj)
+ unordered_map<K,T,H,P,A>::insert(const_iterator,
+ value_type const& obj)
{
return iterator(table_.emplace(obj).first);
}
template <class K, class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_map<K,T,H,P,A>::iterator
+ unordered_map<K,T,H,P,A>::insert(const_iterator,
+ BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)).first);
+ }
+
+ template <class K, class T, class H, class P, class A>
template <class InputIt>
void unordered_map<K,T,H,P,A>::insert(InputIt first, InputIt last)
{
@@ -1260,17 +1303,22 @@
#if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
- unordered_multimap<K,T,H,P,A>::emplace(value_type const& v)
+ unordered_multimap<K,T,H,P,A>::emplace(
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v));
+ return iterator(table_.emplace(boost::move(v)));
}
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
- unordered_multimap<K,T,H,P,A>::emplace_hint(
- const_iterator, value_type const& v)
+ unordered_multimap<K,T,H,P,A>::emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v));
+ return iterator(table_.emplace(boost::move(v)));
}
#endif
@@ -1309,20 +1357,35 @@
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
- unordered_multimap<K,T,H,P,A>::insert(const value_type& obj)
+ unordered_multimap<K,T,H,P,A>::insert(value_type const& obj)
{
return iterator(table_.emplace(obj));
}
template <class K, class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
+ unordered_multimap<K,T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)));
+ }
+
+ template <class K, class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
unordered_multimap<K,T,H,P,A>::insert(
- const_iterator, const value_type& obj)
+ const_iterator, value_type const& obj)
{
return iterator(table_.emplace(obj));
}
template <class K, class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_multimap<K,T,H,P,A>::iterator
+ unordered_multimap<K,T,H,P,A>::insert(
+ const_iterator, BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)));
+ }
+
+ template <class K, class T, class H, class P, class A>
template <class InputIt>
void unordered_multimap<K,T,H,P,A>::insert(InputIt first, InputIt last)
{
Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2011-08-03 19:52:37 EDT (Wed, 03 Aug 2011)
@@ -220,8 +220,16 @@
iterator emplace_hint(const_iterator, Args&&...);
#else
- std::pair<iterator, bool> emplace(value_type const& = value_type());
- iterator emplace_hint(const_iterator, value_type const& = value_type());
+ std::pair<iterator, bool> emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+ iterator emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
@@ -245,8 +253,10 @@
#endif
- std::pair<iterator, bool> insert(const value_type&);
- iterator insert(const_iterator, const value_type&);
+ std::pair<iterator, bool> insert(value_type const&);
+ 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));
template <class InputIt> void insert(InputIt, InputIt);
#if !defined(BOOST_NO_0X_HDR_INITIALIZER_LIST)
@@ -537,8 +547,16 @@
iterator emplace_hint(const_iterator, Args&&...);
#else
- iterator emplace(value_type const& = value_type());
- iterator emplace_hint(const_iterator, value_type const& = value_type());
+ iterator emplace(
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
+ iterator emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace
+ = boost::unordered::detail::empty_emplace(),
+ value_type v = value_type()
+ );
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
template < \
@@ -562,8 +580,10 @@
#endif
- iterator insert(const value_type&);
- iterator insert(const_iterator, const value_type&);
+ iterator insert(value_type const&);
+ iterator insert(BOOST_RV_REF(value_type));
+ iterator insert(const_iterator, value_type const&);
+ iterator insert(const_iterator, BOOST_RV_REF(value_type));
template <class InputIt>
void insert(InputIt, InputIt);
@@ -806,17 +826,23 @@
template <class T, class H, class P, class A>
std::pair<BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator, bool>
- unordered_set<T,H,P,A>::emplace(value_type const& v)
+ unordered_set<T,H,P,A>::emplace(
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return BOOST_UNORDERED_PAIR_CAST(iterator, bool, table_.emplace(v));
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(boost::move(v)));
}
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator
- unordered_set<T,H,P,A>::emplace_hint(
- const_iterator, value_type const& v)
+ unordered_set<T,H,P,A>::emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v).first);
+ return iterator(table_.emplace(boost::move(v)).first);
}
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
@@ -859,19 +885,37 @@
template <class T, class H, class P, class A>
std::pair<BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator, bool>
- unordered_set<T,H,P,A>::insert(const value_type& obj)
+ unordered_set<T,H,P,A>::insert(value_type const& obj)
+ {
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(obj));
+ }
+
+ template <class T, class H, class P, class A>
+ std::pair<BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator, bool>
+ unordered_set<T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
{
- return BOOST_UNORDERED_PAIR_CAST(iterator, bool, table_.insert(obj));
+ return BOOST_UNORDERED_PAIR_CAST(iterator, bool,
+ table_.emplace(boost::move(obj)));
}
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator
- unordered_set<T,H,P,A>::insert(const_iterator, const value_type& obj)
+ unordered_set<T,H,P,A>::insert(const_iterator,
+ value_type const& obj)
{
return iterator(table_.emplace(obj).first);
}
template <class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_set<T,H,P,A>::iterator
+ unordered_set<T,H,P,A>::insert(const_iterator,
+ BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)).first);
+ }
+
+ template <class T, class H, class P, class A>
template <class InputIt>
void unordered_set<T,H,P,A>::insert(InputIt first, InputIt last)
{
@@ -1169,17 +1213,22 @@
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
- unordered_multiset<T,H,P,A>::emplace(value_type const& v)
+ unordered_multiset<T,H,P,A>::emplace(
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v));
+ return iterator(table_.emplace(boost::move(v)));
}
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
- unordered_multiset<T,H,P,A>::emplace_hint(
- const_iterator, value_type const& v)
+ unordered_multiset<T,H,P,A>::emplace_hint(const_iterator,
+ boost::unordered::detail::empty_emplace,
+ value_type v
+ )
{
- return iterator(table_.emplace(v));
+ return iterator(table_.emplace(boost::move(v)));
}
#define BOOST_UNORDERED_EMPLACE(z, n, _) \
@@ -1217,19 +1266,35 @@
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
- unordered_multiset<T,H,P,A>::insert(const value_type& obj)
+ unordered_multiset<T,H,P,A>::insert(value_type const& obj)
{
return iterator(table_.emplace(obj));
}
template <class T, class H, class P, class A>
BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
- unordered_multiset<T,H,P,A>::insert(const_iterator, const value_type& obj)
+ unordered_multiset<T,H,P,A>::insert(BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)));
+ }
+
+ template <class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
+ unordered_multiset<T,H,P,A>::insert(const_iterator,
+ value_type const& obj)
{
return iterator(table_.emplace(obj));
}
template <class T, class H, class P, class A>
+ BOOST_DEDUCED_TYPENAME unordered_multiset<T,H,P,A>::iterator
+ unordered_multiset<T,H,P,A>::insert(const_iterator,
+ BOOST_RV_REF(value_type) obj)
+ {
+ return iterator(table_.emplace(boost::move(obj)));
+ }
+
+ template <class T, class H, class P, class A>
template <class InputIt>
void unordered_multiset<T,H,P,A>::insert(InputIt first, InputIt last)
{
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