[llvm] [ADT] Simplify DenseMapInfo<std::tuple<...>> with constexpr if (NFC) (PR #156810)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 4 07:58:31 PDT 2025


================
@@ -179,41 +179,35 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
     return Tuple(DenseMapInfo<Ts>::getTombstoneKey()...);
   }
 
-  template <unsigned I>
-  static unsigned getHashValueImpl(const Tuple &values, std::false_type) {
-    using EltType = std::tuple_element_t<I, Tuple>;
-    std::integral_constant<bool, I + 1 == sizeof...(Ts)> atEnd;
-    return detail::combineHashValue(
-        DenseMapInfo<EltType>::getHashValue(std::get<I>(values)),
-        getHashValueImpl<I + 1>(values, atEnd));
-  }
-
-  template <unsigned I>
-  static unsigned getHashValueImpl(const Tuple &, std::true_type) {
-    return 0;
+  template <unsigned I> static unsigned getHashValueImpl(const Tuple &values) {
+    if constexpr (I == sizeof...(Ts))
+      return 0;
+    else {
----------------
kuhar wrote:

also below

https://github.com/llvm/llvm-project/pull/156810


More information about the llvm-commits mailing list