summaryrefslogtreecommitdiffstats
path: root/libcxx/include/__hash_table
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-11-23 01:18:56 +0000
committerEric Fiselier <eric@efcs.ca>2016-11-23 01:18:56 +0000
commit55b31b4e6934fb2e9dda6d7f0f2792b6c3420c05 (patch)
treec5f77e59cac52f369638c0016587bf7b53a601c0 /libcxx/include/__hash_table
parent80e66ac1d3cdb67a35ca0c57f8e4a00cacd0f019 (diff)
downloadbcm5719-llvm-55b31b4e6934fb2e9dda6d7f0f2792b6c3420c05.tar.gz
bcm5719-llvm-55b31b4e6934fb2e9dda6d7f0f2792b6c3420c05.zip
[libcxx] Fix max_size() across all containers
Summary: The `max_size()` method of containers should respect both the allocator's reported `max_size` and the range of the `difference_type`. This patch makes all containers choose the smallest of those two values. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26885 llvm-svn: 287729
Diffstat (limited to 'libcxx/include/__hash_table')
-rw-r--r--libcxx/include/__hash_table9
1 files changed, 6 insertions, 3 deletions
diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table
index 3072f93e00b..0dc188b7a1f 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1004,8 +1004,11 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
{
- return allocator_traits<__pointer_allocator>::max_size(
- __bucket_list_.get_deleter().__alloc());
+ return std::min<size_type>(
+ allocator_traits<__pointer_allocator>::max_size(
+ __bucket_list_.get_deleter().__alloc()),
+ numeric_limits<difference_type >::max()
+ );
}
pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
@@ -1192,7 +1195,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_bucket_count() const _NOEXCEPT
- {return __pointer_alloc_traits::max_size(__bucket_list_.get_deleter().__alloc());}
+ {return max_size(); }
size_type bucket_size(size_type __n) const;
_LIBCPP_INLINE_VISIBILITY float load_factor() const _NOEXCEPT
{
OpenPOWER on IntegriCloud