diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-01-22 18:27:26 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-01-22 18:27:26 +0000 |
commit | a584f0008a896e78bd418993443f4c08749003bc (patch) | |
tree | 57bb41bb6d285a906a398cf530a903c3148c5529 /libcxx/include | |
parent | 3865fdc4cc69d630de7ea3de6b22bdf73677b31b (diff) | |
download | bcm5719-llvm-a584f0008a896e78bd418993443f4c08749003bc.tar.gz bcm5719-llvm-a584f0008a896e78bd418993443f4c08749003bc.zip |
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).
llvm-svn: 258511
Diffstat (limited to 'libcxx/include')
-rw-r--r-- | libcxx/include/__hash_table | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index c7d1ef3d082..c48e38376a9 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -1047,11 +1047,12 @@ private: template <class ..._Args> __node_holder __construct_node(_Args&& ...__args); #endif // _LIBCPP_HAS_NO_VARIADICS - __node_holder __construct_node(value_type&& __v, size_t __hash); + template <class _ValueTp> + __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<size_type>(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 <class _Tp, class _Hash, class _Equal, class _Alloc> +template <class _ValueTp> 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 <class _Tp, class _Hash, class _Equal, class _Alloc> 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)); |