From 95722353327803bb8aba3c380d0fcd6c79280c84 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Fri, 22 Jan 2016 18:27:26 +0000 Subject: [PATCH] unordered: Rename __construct_node_hash() to allow forwarding, NFC Rename the version of __construct_node() that takes a hash as an argument to __construct_node_hash(), and use perfect-forwarding when Rvalue references are available. The primary motivation is to allow other types through, since unordered_map's value_type is different from __hash_table's value_type -- a follow-up will take advantage of this -- but the rename is general "goodness". There should be no functionality change here (aside from enabling the follow-up). git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@258511 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/__hash_table | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/__hash_table b/include/__hash_table index c7d1ef3d0..c48e38376 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -1047,11 +1047,12 @@ private: template __node_holder __construct_node(_Args&& ...__args); #endif // _LIBCPP_HAS_NO_VARIADICS - __node_holder __construct_node(value_type&& __v, size_t __hash); + template + __node_holder __construct_node_hash(_ValueTp&& __v, size_t __hash); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES __node_holder __construct_node(const value_type& __v); #endif - __node_holder __construct_node(const value_type& __v, size_t __hash); + __node_holder __construct_node_hash(const value_type& __v, size_t __hash); _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __hash_table& __u) @@ -1730,7 +1731,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_unique_value(const value_type } } { - __node_holder __h = __construct_node(_VSTD::forward<_ValueTp>(__x), __hash); + __node_holder __h = __construct_node_hash(_VSTD::forward<_ValueTp>(__x), __hash); if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), @@ -2051,13 +2052,14 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(_Args&& ...__args) #endif // _LIBCPP_HAS_NO_VARIADICS template +template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v, - size_t __hash) +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(_ValueTp&& __v, + size_t __hash) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::move(__v)); + __node_traits::construct(__na, _VSTD::addressof(__h->__value_), _VSTD::forward<_ValueTp>(__v)); __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; @@ -2083,8 +2085,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v, - size_t __hash) +__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(const value_type& __v, + size_t __hash) { __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));