diff --git a/include/tsl/robin_hash.h b/include/tsl/robin_hash.h index e34eac3..98643e6 100644 --- a/include/tsl/robin_hash.h +++ b/include/tsl/robin_hash.h @@ -410,9 +410,9 @@ class robin_hash : private Hash, private KeyEqual, private GrowthPolicy { TSL_RH_UNUSED(bucket_count); return true; } else if (STORE_HASH && is_power_of_two_policy::value) { - tsl_rh_assert(bucket_count > 0); - return (bucket_count - 1) <= - std::numeric_limits::max(); + return bucket_count == 0 || + (bucket_count - 1) <= + std::numeric_limits::max(); } else { TSL_RH_UNUSED(bucket_count); return false; diff --git a/tests/robin_map_tests.cpp b/tests/robin_map_tests.cpp index 34cbd26..cfa620e 100644 --- a/tests/robin_map_tests.cpp +++ b/tests/robin_map_tests.cpp @@ -140,6 +140,14 @@ BOOST_AUTO_TEST_CASE(test_range_insert) { } } +BOOST_AUTO_TEST_CASE(test_rehash_0) { + tsl::robin_map, + std::equal_to, + std::allocator>, + true> map; + map.rehash(0); +} + BOOST_AUTO_TEST_CASE(test_insert_with_hint) { tsl::robin_map map{{1, 0}, {2, 1}, {3, 2}};