diff --git a/absl/container/internal/container_memory.h b/absl/container/internal/container_memory.h index fc7633f1..16a2e25a 100644 --- a/absl/container/internal/container_memory.h +++ b/absl/container/internal/container_memory.h @@ -550,10 +550,20 @@ template size_t TypeErasedDerefAndApplyToSlotFn(const void* fn, void* slot_ptr, size_t seed) { const auto* f = static_cast(fn); - const T* slot = *static_cast(slot_ptr); + const T* slot = *static_cast(slot_ptr); return HashElement{*f, seed}(*slot); } +// Type erased function to apply `Fn` to data inside of the `slot_ptr->first`. +// The data is expected to have type `T`. +template +size_t TypeErasedDerefAndApplyToSlotFirstFn(const void* fn, void* slot_ptr, + size_t seed) { + const auto* f = static_cast(fn); + const T* slot = *static_cast(slot_ptr); + return HashElement{*f, seed}(slot->first); +} + } // namespace container_internal ABSL_NAMESPACE_END } // namespace absl diff --git a/absl/container/node_hash_map.h b/absl/container/node_hash_map.h index e9130058..a58680ab 100644 --- a/absl/container/node_hash_map.h +++ b/absl/container/node_hash_map.h @@ -681,7 +681,8 @@ class NodeHashMapPolicy template static constexpr HashSlotFn get_hash_slot_fn() { return memory_internal::IsLayoutCompatible::value - ? &TypeErasedDerefAndApplyToSlotFn + ? &TypeErasedDerefAndApplyToSlotFirstFn : nullptr; } };