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.
---
This one could be pushed independently of the rest of the series.
libstdc++-v3/include/bits/hashtable_policy.h | 48 ++++++++++----------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/libstdc++-v3/include/bits/hashtable_policy.h
b/libstdc++-v3/include/bits/hashtable_policy.h
index c3d89a1101c..ad0dfd55c3f 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)
--
2.47.0