From 49be2e68de5b063bce5d0757078c62906a2674ea Mon Sep 17 00:00:00 2001 From: Evan Brown Date: Fri, 15 Sep 2023 09:05:25 -0700 Subject: Move CountingAllocator into test_allocator.h and add some other allocators that can be shared between different container tests. PiperOrigin-RevId: 565693736 Change-Id: I59af987e30da03a805ce59ff0fb7eeae3fc08293 --- absl/container/internal/raw_hash_set_test.cc | 29 +--------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'absl/container/internal/raw_hash_set_test.cc') diff --git a/absl/container/internal/raw_hash_set_test.cc b/absl/container/internal/raw_hash_set_test.cc index 55c6f62e..7588120a 100644 --- a/absl/container/internal/raw_hash_set_test.cc +++ b/absl/container/internal/raw_hash_set_test.cc @@ -48,6 +48,7 @@ #include "absl/container/internal/hash_function_defaults.h" #include "absl/container/internal/hash_policy_testing.h" #include "absl/container/internal/hashtable_debug.h" +#include "absl/container/internal/test_allocator.h" #include "absl/log/log.h" #include "absl/strings/string_view.h" @@ -441,34 +442,6 @@ struct CustomAllocIntTable using Base::Base; }; -// Tries to allocate memory at the minimum alignment even when the default -// allocator uses a higher alignment. -template -struct MinimumAlignmentAlloc : std::allocator { - MinimumAlignmentAlloc() = default; - - template - explicit MinimumAlignmentAlloc(const MinimumAlignmentAlloc& /*other*/) {} - - template - struct rebind { - using other = MinimumAlignmentAlloc; - }; - - T* allocate(size_t n) { - T* ptr = std::allocator::allocate(n + 1); - char* cptr = reinterpret_cast(ptr); - cptr += alignof(T); - return reinterpret_cast(cptr); - } - - void deallocate(T* ptr, size_t n) { - char* cptr = reinterpret_cast(ptr); - cptr -= alignof(T); - std::allocator::deallocate(reinterpret_cast(cptr), n + 1); - } -}; - struct MinimumAlignmentUint8Table : raw_hash_set, std::equal_to, MinimumAlignmentAlloc> { -- cgit v1.2.3