Index: libcxx/include/__hash_table =================================================================== --- libcxx/include/__hash_table +++ libcxx/include/__hash_table @@ -126,8 +126,8 @@ return __n < 2 ? __n : (size_t(1) << (numeric_limits::digits - __libcpp_clz(__n-1))); } - -template class __hash_table; +template +class __hash_table; template class _LIBCPP_TEMPLATE_VIS __hash_iterator; template class _LIBCPP_TEMPLATE_VIS __hash_const_iterator; @@ -860,9 +860,13 @@ template int __diagnose_unordered_container_requirements(void*); -template -class __hash_table -{ +template +struct __hash_table_traits { + typedef integral_constant __unique_keys; +}; + +template +class __hash_table { public: typedef _Tp value_type; typedef _Hash hasher; @@ -921,6 +925,7 @@ typedef unique_ptr<__next_pointer[], __bucket_list_deleter> __bucket_list; typedef allocator_traits<__pointer_allocator> __pointer_alloc_traits; typedef typename __bucket_list_deleter::pointer __node_pointer_pointer; + typedef typename _Traits::__unique_keys __unique_keys; // --- Member data begin --- __bucket_list __bucket_list_; @@ -2274,11 +2279,12 @@ else { __next_pointer __np = __cp; - for (; __np->__next_ != nullptr && - key_eq()(__cp->__upcast()->__value_, - __np->__next_->__upcast()->__value_); - __np = __np->__next_) + if (!__unique_keys{}) { + for (; __np->__next_ != nullptr && + key_eq()(__cp->__upcast()->__value_, __np->__next_->__upcast()->__value_); + __np = __np->__next_) ; + } __pp->__next_ = __np->__next_; __np->__next_ = __bucket_list_[__chash]->__next_; __bucket_list_[__chash]->__next_ = __cp; Index: libcxx/include/unordered_map =================================================================== --- libcxx/include/unordered_map +++ libcxx/include/unordered_map @@ -1031,8 +1031,7 @@ typedef typename __rebind_alloc_helper, __value_type>::type __allocator_type; - typedef __hash_table<__value_type, __hasher, - __key_equal, __allocator_type> __table; + typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type, __hash_table_traits> __table; __table __table_; @@ -1921,8 +1920,7 @@ typedef typename __rebind_alloc_helper, __value_type>::type __allocator_type; - typedef __hash_table<__value_type, __hasher, - __key_equal, __allocator_type> __table; + typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type, __hash_table_traits> __table; __table __table_; Index: libcxx/include/unordered_set =================================================================== --- libcxx/include/unordered_set +++ libcxx/include/unordered_set @@ -501,9 +501,9 @@ "Invalid allocator::value_type"); private: - typedef __hash_table __table; + typedef __hash_table> __table; - __table __table_; + __table __table_; public: typedef typename __table::pointer pointer; @@ -1157,9 +1157,9 @@ "Invalid allocator::value_type"); private: - typedef __hash_table __table; + typedef __hash_table> __table; - __table __table_; + __table __table_; public: typedef typename __table::pointer pointer;