From 12d3022fac9bd80397166917d01848541b4e216d Mon Sep 17 00:00:00 2001 From: Daniel Kral Date: Wed, 6 May 2026 20:34:30 +0200 Subject: [PATCH] Add fix The same fix as in https://github.com/boostorg/multi_index/pull/94/changes --- include/boost/unordered/detail/implementation.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 214243b1d1..595ec2693c 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -2712,8 +2712,9 @@ namespace boost { inline void table::reserve_for_insert(std::size_t num_elements) { if (num_elements > max_load_) { - std::size_t const num_buckets = static_cast( - 1.0f + std::ceil(static_cast(num_elements) / mlf_)); + std::size_t const num_buckets = (std::max)( + static_cast(1.0f + std::ceil(static_cast(num_elements) / mlf_)), + static_cast(bucket_count() + 1)); this->rehash_impl(num_buckets); }