|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84277 - trunk/boost/unordered/detail
From: dnljms_at_[hidden]
Date: 2013-05-13 19:13:06
Author: danieljames
Date: 2013-05-13 19:13:04 EDT (Mon, 13 May 2013)
New Revision: 84277
URL: http://svn.boost.org/trac/boost/changeset/84277
Log:
Use nothrow move construction for function objects, when available.
Text files modified:
trunk/boost/unordered/detail/buckets.hpp | 34 ++++++++++++++++++++++++++++------
trunk/boost/unordered/detail/table.hpp | 6 +++---
2 files changed, 31 insertions(+), 9 deletions(-)
Modified: trunk/boost/unordered/detail/buckets.hpp
==============================================================================
--- trunk/boost/unordered/detail/buckets.hpp (original)
+++ trunk/boost/unordered/detail/buckets.hpp 2013-05-13 19:13:04 EDT (Mon, 13 May 2013)
@@ -678,10 +678,17 @@
template <class H, class P>
class functions
{
+ public:
+ static const bool nothrow_move_assignable =
+ boost::is_nothrow_move_assignable<H>::value &&
+ boost::is_nothrow_move_assignable<P>::value;
+ static const bool nothrow_move_constructible =
+ boost::is_nothrow_move_constructible<H>::value &&
+ boost::is_nothrow_move_constructible<P>::value;
+
+ private:
friend class boost::unordered::detail::set_hash_functions<H, P,
- boost::is_nothrow_move_assignable<H>::value &&
- boost::is_nothrow_move_assignable<P>::value
- >;
+ nothrow_move_assignable>;
functions& operator=(functions const&);
typedef compressed<H, P> function_pair;
@@ -713,6 +720,12 @@
new((void*) &funcs_[which]) function_pair(f);
}
+ void construct(bool which, function_pair& f,
+ boost::unordered::detail::move_tag m)
+ {
+ new((void*) &funcs_[which]) function_pair(f, m);
+ }
+
void destroy(bool which)
{
boost::unordered::detail::destroy((function_pair*)(&funcs_[which]));
@@ -721,9 +734,7 @@
public:
typedef boost::unordered::detail::set_hash_functions<H, P,
- boost::is_nothrow_move_assignable<H>::value &&
- boost::is_nothrow_move_assignable<P>::value
- > set_hash_functions;
+ nothrow_move_assignable> set_hash_functions;
functions(H const& hf, P const& eq)
: current_(false)
@@ -737,6 +748,17 @@
construct(current_, bf.current());
}
+ functions(functions& bf, boost::unordered::detail::move_tag m)
+ : current_(false)
+ {
+ if (nothrow_move_constructible) {
+ construct(current_, bf.current(), m);
+ }
+ else {
+ construct(current_, bf.current());
+ }
+ }
+
~functions() {
this->destroy(current_);
}
Modified: trunk/boost/unordered/detail/table.hpp
==============================================================================
--- trunk/boost/unordered/detail/table.hpp (original)
+++ trunk/boost/unordered/detail/table.hpp 2013-05-13 19:13:04 EDT (Mon, 13 May 2013)
@@ -364,7 +364,7 @@
{}
table(table& x, boost::unordered::detail::move_tag m) :
- functions(x),
+ functions(x, m),
allocators_(x.allocators_, m),
bucket_count_(x.bucket_count_),
size_(x.size_),
@@ -378,8 +378,8 @@
}
table(table& x, node_allocator const& a,
- boost::unordered::detail::move_tag) :
- functions(x),
+ boost::unordered::detail::move_tag m) :
+ functions(x, m),
allocators_(a, a),
bucket_count_(x.bucket_count_),
size_(0),
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