diff --git a/include/rigtorp/HashMap.h b/include/rigtorp/HashMap.h index c336032..fec29f5 100644 --- a/include/rigtorp/HashMap.h +++ b/include/rigtorp/HashMap.h @@ -25,6 +25,7 @@ probing. #pragma once #include +#include #include #include #include @@ -136,10 +137,7 @@ class HashMap { HashMap(size_type bucket_count, key_type empty_key, const allocator_type &alloc = allocator_type()) : empty_key_(empty_key), buckets_(alloc) { - size_t pow2 = 2; - while (pow2 < bucket_count) { - pow2 <<= 1; - } + size_t pow2 = std::bit_ceil(std::max(bucket_count, 2)); buckets_.resize(pow2, std::make_pair(empty_key_, T())); }