diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-11-06 18:48:07 +0000 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-11-13 20:21:40 +0000 |
commit | 55dbf154efdeb34e840ad134aab883ce86251a45 (patch) | |
tree | 9839638c166b6d7db31cfb99bf9dd2ac413ae649 | |
parent | 247e82c72f14dfaa4c496b80ad641a15658a5e4f (diff) | |
download | gcc-55dbf154efdeb34e840ad134aab883ce86251a45.zip gcc-55dbf154efdeb34e840ad134aab883ce86251a45.tar.gz gcc-55dbf154efdeb34e840ad134aab883ce86251a45.tar.bz2 |
libstdc++: Remove _Hashtable_base::_S_equals
This removes the overloaded _S_equals and _S_node_equals functions,
replacing them with 'if constexpr' in the handful of places they're
used.
libstdc++-v3/ChangeLog:
* include/bits/hashtable_policy.h (_Hashtable_base::_S_equals):
Remove.
(_Hashtable_base::_S_node_equals): Remove.
(_Hashtable_base::_M_key_equals_tr): Fix inaccurate
static_assert string.
(_Hashtable_base::_M_equals, _Hashtable_base::_M_equals_tr): Use
'if constexpr' instead of _S_equals.
(_Hashtable_base::_M_node_equals): Use 'if constexpr' instead of
_S_node_equals.
-rw-r--r-- | libstdc++-v3/include/bits/hashtable_policy.h | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index c3d89a1..ad0dfd5 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1487,24 +1487,6 @@ namespace __detail private: using _EqualEBO = _Hashtable_ebo_helper<0, _Equal>; - static bool - _S_equals(__hash_code, const _Hash_node_code_cache<false>&) - { return true; } - - static bool - _S_node_equals(const _Hash_node_code_cache<false>&, - const _Hash_node_code_cache<false>&) - { return true; } - - static bool - _S_equals(__hash_code __c, const _Hash_node_code_cache<true>& __n) - { return __c == __n._M_hash_code; } - - static bool - _S_node_equals(const _Hash_node_code_cache<true>& __lhn, - const _Hash_node_code_cache<true>& __rhn) - { return __lhn._M_hash_code == __rhn._M_hash_code; } - protected: _Hashtable_base() = default; @@ -1531,31 +1513,49 @@ namespace __detail { static_assert( __is_invocable<const _Equal&, const _Kt&, const _Key&>{}, - "key equality predicate must be invocable with two arguments of " - "key type"); + "key equality predicate must be invocable with the argument type " + "and the key type"); return _M_eq()(__k, _ExtractKey{}(__n._M_v())); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr bool _M_equals(const _Key& __k, __hash_code __c, const _Hash_node_value<_Value, __hash_cached::value>& __n) const - { return _S_equals(__c, __n) && _M_key_equals(__k, __n); } + { + if constexpr (__hash_cached::value) + if (__c != __n._M_hash_code) + return false; + + return _M_key_equals(__k, __n); + } template<typename _Kt> bool _M_equals_tr(const _Kt& __k, __hash_code __c, const _Hash_node_value<_Value, __hash_cached::value>& __n) const - { return _S_equals(__c, __n) && _M_key_equals_tr(__k, __n); } + { + if constexpr (__hash_cached::value) + if (__c != __n._M_hash_code) + return false; + + return _M_key_equals_tr(__k, __n); + } bool _M_node_equals( const _Hash_node_value<_Value, __hash_cached::value>& __lhn, const _Hash_node_value<_Value, __hash_cached::value>& __rhn) const { - return _S_node_equals(__lhn, __rhn) - && _M_key_equals(_ExtractKey{}(__lhn._M_v()), __rhn); + if constexpr (__hash_cached::value) + if (__lhn._M_hash_code != __rhn._M_hash_code) + return false; + + return _M_key_equals(_ExtractKey{}(__lhn._M_v()), __rhn); } +#pragma GCC diagnostic pop void _M_swap(_Hashtable_base& __x) |