From 4c7e7c7d94eaaa3bff3142c257d880a468a35934 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Wed, 31 Jan 2024 13:45:52 -0800 Subject: Type erased hash_slot_fn that depends only on key types (and hash function). PiperOrigin-RevId: 603148301 Change-Id: Ie2e5702995c9e1ef4d5aaab23bc89a1eb5007a86 --- absl/container/internal/container_memory_test.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'absl/container/internal/container_memory_test.cc') diff --git a/absl/container/internal/container_memory_test.cc b/absl/container/internal/container_memory_test.cc index c973ac25..7e4357d5 100644 --- a/absl/container/internal/container_memory_test.cc +++ b/absl/container/internal/container_memory_test.cc @@ -298,6 +298,20 @@ TEST(MapSlotPolicy, DestroyReturnsTrue) { } } +TEST(ApplyTest, TypeErasedApplyToSlotFn) { + size_t x = 7; + auto fn = [](size_t v) { return v * 2; }; + EXPECT_EQ((TypeErasedApplyToSlotFn(&fn, &x)), 14); +} + +TEST(ApplyTest, TypeErasedDerefAndApplyToSlotFn) { + size_t x = 7; + auto fn = [](size_t v) { return v * 2; }; + size_t* x_ptr = &x; + EXPECT_EQ( + (TypeErasedDerefAndApplyToSlotFn(&fn, &x_ptr)), 14); +} + } // namespace } // namespace container_internal ABSL_NAMESPACE_END -- cgit v1.2.3