diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 025758528573f..d5fbc92a3dfc4 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -18,6 +18,7 @@ #include <__functional/hash.h> #include <__functional/invoke.h> #include <__iterator/iterator_traits.h> +#include <__math/rounding_functions.h> #include <__memory/addressof.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> @@ -40,9 +41,8 @@ #include <__utility/move.h> #include <__utility/pair.h> #include <__utility/swap.h> -#include #include -#include +#include #include // __launder #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -875,10 +875,10 @@ public: _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash(__n); } _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash(__n); } _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) { - __rehash_unique(static_cast(std::ceil(__n / max_load_factor()))); + __rehash_unique(static_cast(__math::ceil(__n / max_load_factor()))); } _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) { - __rehash_multi(static_cast(std::ceil(__n / max_load_factor()))); + __rehash_multi(static_cast(__math::ceil(__n / max_load_factor()))); } _LIBCPP_HIDE_FROM_ABI size_type bucket_count() const _NOEXCEPT { return __bucket_list_.get_deleter().size(); } @@ -1348,7 +1348,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique_prepare(size_t __ } if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_unique(std::max( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); } return nullptr; } @@ -1408,7 +1408,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c size_type __bc = bucket_count(); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_multi(std::max( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = std::__constrain_hash(__cp_hash, __bc); @@ -1483,7 +1483,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(const_iterator __p size_type __bc = bucket_count(); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_multi(std::max( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); } size_t __chash = std::__constrain_hash(__cp->__hash_, __bc); @@ -1523,7 +1523,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...); if (size() + 1 > __bc * max_load_factor() || __bc == 0) { __rehash_unique(std::max( - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); __bc = bucket_count(); __chash = std::__constrain_hash(__hash, __bc); } @@ -1692,8 +1692,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D else if (__n < __bc) { __n = std::max( __n, - std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) - : std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))); + std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor()))) + : std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor())))); if (__n < __bc) __do_rehash<_UniqueKeys>(__n); } diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map index 7c31c4fce26b0..acf3485e644af 100644 --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -2532,6 +2532,7 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include # include +# include # include # include # include diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set index 3297294a893f8..d11ceacba8143 100644 --- a/libcxx/include/unordered_set +++ b/libcxx/include/unordered_set @@ -1800,6 +1800,7 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include # include # include diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 8ffb71d8b566b..591f58cd83e06 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -649,7 +649,6 @@ typeindex typeinfo typeindex version typeinfo cstddef typeinfo cstdint -unordered_map cmath unordered_map compare unordered_map cstddef unordered_map cstdint @@ -661,7 +660,6 @@ unordered_map optional unordered_map stdexcept unordered_map tuple unordered_map version -unordered_set cmath unordered_set compare unordered_set cstddef unordered_set cstdint diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 8ffb71d8b566b..591f58cd83e06 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -649,7 +649,6 @@ typeindex typeinfo typeindex version typeinfo cstddef typeinfo cstdint -unordered_map cmath unordered_map compare unordered_map cstddef unordered_map cstdint @@ -661,7 +660,6 @@ unordered_map optional unordered_map stdexcept unordered_map tuple unordered_map version -unordered_set cmath unordered_set compare unordered_set cstddef unordered_set cstdint