diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp index 69e9bfcd1..cdc532e3a 100644 --- a/tests/src/unit-allocator.cpp +++ b/tests/src/unit-allocator.cpp @@ -297,6 +297,19 @@ struct scratch_counting_allocator : std::allocator return std::allocator::allocate(n); } +#ifdef __cpp_lib_allocate_at_least + // std::allocator::allocate_at_least would bypass the counting, and + // libc++'s containers prefer it over allocate from C++23 on + auto allocate_at_least(std::size_t n) + { + if (is_scratch_pair::value) + { + ++scratch_pair_allocations; + } + return std::allocator::allocate_at_least(n); + } +#endif + template struct rebind {