|
18 | 18 | #include <__functional/hash.h>
|
19 | 19 | #include <__functional/invoke.h>
|
20 | 20 | #include <__iterator/iterator_traits.h>
|
| 21 | +#include <__math/rounding_functions.h> |
21 | 22 | #include <__memory/addressof.h>
|
22 | 23 | #include <__memory/allocator_traits.h>
|
23 | 24 | #include <__memory/compressed_pair.h>
|
|
40 | 41 | #include <__utility/move.h>
|
41 | 42 | #include <__utility/pair.h>
|
42 | 43 | #include <__utility/swap.h>
|
43 |
| -#include <cmath> |
44 | 44 | #include <cstring>
|
45 |
| -#include <initializer_list> |
| 45 | +#include <limits> |
46 | 46 | #include <new> // __launder
|
47 | 47 |
|
48 | 48 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
@@ -875,10 +875,10 @@ public:
|
875 | 875 | _LIBCPP_HIDE_FROM_ABI void __rehash_unique(size_type __n) { __rehash<true>(__n); }
|
876 | 876 | _LIBCPP_HIDE_FROM_ABI void __rehash_multi(size_type __n) { __rehash<false>(__n); }
|
877 | 877 | _LIBCPP_HIDE_FROM_ABI void __reserve_unique(size_type __n) {
|
878 |
| - __rehash_unique(static_cast<size_type>(std::ceil(__n / max_load_factor()))); |
| 878 | + __rehash_unique(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); |
879 | 879 | }
|
880 | 880 | _LIBCPP_HIDE_FROM_ABI void __reserve_multi(size_type __n) {
|
881 |
| - __rehash_multi(static_cast<size_type>(std::ceil(__n / max_load_factor()))); |
| 881 | + __rehash_multi(static_cast<size_type>(__math::ceil(__n / max_load_factor()))); |
882 | 882 | }
|
883 | 883 |
|
884 | 884 | _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 __
|
1348 | 1348 | }
|
1349 | 1349 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
|
1350 | 1350 | __rehash_unique(std::max<size_type>(
|
1351 |
| - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); |
| 1351 | + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); |
1352 | 1352 | }
|
1353 | 1353 | return nullptr;
|
1354 | 1354 | }
|
@@ -1408,7 +1408,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi_prepare(size_t __c
|
1408 | 1408 | size_type __bc = bucket_count();
|
1409 | 1409 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
|
1410 | 1410 | __rehash_multi(std::max<size_type>(
|
1411 |
| - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); |
| 1411 | + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); |
1412 | 1412 | __bc = bucket_count();
|
1413 | 1413 | }
|
1414 | 1414 | 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
|
1483 | 1483 | size_type __bc = bucket_count();
|
1484 | 1484 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
|
1485 | 1485 | __rehash_multi(std::max<size_type>(
|
1486 |
| - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); |
| 1486 | + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); |
1487 | 1487 | __bc = bucket_count();
|
1488 | 1488 | }
|
1489 | 1489 | 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&
|
1523 | 1523 | __node_holder __h = __construct_node_hash(__hash, std::forward<_Args>(__args)...);
|
1524 | 1524 | if (size() + 1 > __bc * max_load_factor() || __bc == 0) {
|
1525 | 1525 | __rehash_unique(std::max<size_type>(
|
1526 |
| - 2 * __bc + !std::__is_hash_power2(__bc), size_type(std::ceil(float(size() + 1) / max_load_factor())))); |
| 1526 | + 2 * __bc + !std::__is_hash_power2(__bc), size_type(__math::ceil(float(size() + 1) / max_load_factor())))); |
1527 | 1527 | __bc = bucket_count();
|
1528 | 1528 | __chash = std::__constrain_hash(__hash, __bc);
|
1529 | 1529 | }
|
@@ -1692,8 +1692,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __n) _LIBCPP_D
|
1692 | 1692 | else if (__n < __bc) {
|
1693 | 1693 | __n = std::max<size_type>(
|
1694 | 1694 | __n,
|
1695 |
| - std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(std::ceil(float(size()) / max_load_factor()))) |
1696 |
| - : std::__next_prime(size_t(std::ceil(float(size()) / max_load_factor())))); |
| 1695 | + std::__is_hash_power2(__bc) ? std::__next_hash_pow2(size_t(__math::ceil(float(size()) / max_load_factor()))) |
| 1696 | + : std::__next_prime(size_t(__math::ceil(float(size()) / max_load_factor())))); |
1697 | 1697 | if (__n < __bc)
|
1698 | 1698 | __do_rehash<_UniqueKeys>(__n);
|
1699 | 1699 | }
|
|
0 commit comments