diff --git a/include/boost/unordered/detail/buckets.hpp b/include/boost/unordered/detail/buckets.hpp index 30d70fb7..65392241 100644 --- a/include/boost/unordered/detail/buckets.hpp +++ b/include/boost/unordered/detail/buckets.hpp @@ -678,10 +678,17 @@ namespace boost { namespace unordered { namespace detail { template class functions { + public: + static const bool nothrow_move_assignable = + boost::is_nothrow_move_assignable::value && + boost::is_nothrow_move_assignable

::value; + static const bool nothrow_move_constructible = + boost::is_nothrow_move_constructible::value && + boost::is_nothrow_move_constructible

::value; + + private: friend class boost::unordered::detail::set_hash_functions::value && - boost::is_nothrow_move_assignable

::value - >; + nothrow_move_assignable>; functions& operator=(functions const&); typedef compressed function_pair; @@ -713,6 +720,12 @@ namespace boost { namespace unordered { namespace detail { 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 @@ namespace boost { namespace unordered { namespace detail { public: typedef boost::unordered::detail::set_hash_functions::value && - boost::is_nothrow_move_assignable

::value - > set_hash_functions; + nothrow_move_assignable> set_hash_functions; functions(H const& hf, P const& eq) : current_(false) @@ -737,6 +748,17 @@ namespace boost { namespace unordered { namespace detail { 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_); } diff --git a/include/boost/unordered/detail/table.hpp b/include/boost/unordered/detail/table.hpp index 06be1be1..84d1183d 100644 --- a/include/boost/unordered/detail/table.hpp +++ b/include/boost/unordered/detail/table.hpp @@ -364,7 +364,7 @@ namespace boost { namespace unordered { namespace detail { {} 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 @@ namespace boost { namespace unordered { namespace detail { } 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),