diff options
author | François Dumont <fdumont@gcc.gnu.org> | 2020-01-16 08:34:21 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-01-16 14:39:05 +0000 |
commit | d916538965ea260c6bcdb1d46581f6d572017ce8 (patch) | |
tree | 59517c6575a40c8df9eb7d343fb009c7cc7de1fe /libstdc++-v3/include/bits/hashtable.h | |
parent | 8c197c851e7528baba7cb837f34c05ba2242f705 (diff) | |
download | gcc-d916538965ea260c6bcdb1d46581f6d572017ce8.zip gcc-d916538965ea260c6bcdb1d46581f6d572017ce8.tar.gz gcc-d916538965ea260c6bcdb1d46581f6d572017ce8.tar.bz2 |
libstdc++: Improve unordered containers == operator (PR 91263)
Avoid comparing elements with operator== multiple times by replacing
uses of find and equal_range with equivalent inlined code that uses
operator== instead of the container's equality comparison predicate.
This is valid because the standard requires that operator== is a
refinement of the equality predicate.
Also replace the _S_is_permutation function with std::is_permutation,
which wasn't yet implemented when this code was first written.
PR libstdc++/91263
* include/bits/hashtable.h (_Hashtable<>): Make _Equality<> friend.
* include/bits/hashtable_policy.h: Include <bits/stl_algo.h>.
(_Equality_base): Remove.
(_Equality<>::_M_equal): Review implementation. Use
std::is_permutation.
* testsuite/23_containers/unordered_multiset/operators/1.cc
(Hash, Equal, test02, test03): New.
* testsuite/23_containers/unordered_set/operators/1.cc
(Hash, Equal, test02, test03): New.
Diffstat (limited to 'libstdc++-v3/include/bits/hashtable.h')
-rw-r--r-- | libstdc++-v3/include/bits/hashtable.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index 8fac385..9e721aa 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -337,6 +337,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _Constant_iteratorsa> friend struct __detail::_Insert; + template<typename _Keya, typename _Valuea, typename _Alloca, + typename _ExtractKeya, typename _Equala, + typename _H1a, typename _H2a, typename _Hasha, + typename _RehashPolicya, typename _Traitsa, + bool _Unique_keysa> + friend struct __detail::_Equality; + public: using size_type = typename __hashtable_base::size_type; using difference_type = typename __hashtable_base::difference_type; |