Index: libcxx/include/__hash_table =================================================================== --- libcxx/include/__hash_table +++ libcxx/include/__hash_table @@ -860,7 +860,11 @@ template int __diagnose_unordered_container_requirements(void*); -template +template struct __hash_table_traits { + typedef integral_constant __unique_keys; +}; + +template class __hash_table { public: @@ -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,13 @@ 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 @@ -1032,7 +1032,7 @@ __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, - __key_equal, __allocator_type> __table; + __key_equal, __allocator_type, __hash_table_traits> __table; __table __table_; @@ -1922,7 +1922,7 @@ __value_type>::type __allocator_type; typedef __hash_table<__value_type, __hasher, - __key_equal, __allocator_type> __table; + __key_equal, __allocator_type, __hash_table_traits> __table; __table __table_; Index: libcxx/include/unordered_set =================================================================== --- libcxx/include/unordered_set +++ libcxx/include/unordered_set @@ -501,7 +501,8 @@ "Invalid allocator::value_type"); private: - typedef __hash_table __table; + typedef __hash_table> __table; __table __table_; @@ -1157,7 +1158,8 @@ "Invalid allocator::value_type"); private: - typedef __hash_table __table; + typedef __hash_table> __table; __table __table_;