[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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@287729 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-11-23 01:18:56 +00:00
parent 0373708cdc
commit ef3060ef96
20 changed files with 425 additions and 109 deletions

View File

@@ -1106,7 +1106,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type max_size() const _NOEXCEPT
{return __node_traits::max_size(__node_alloc());}
{return std::min<size_type>(
__node_traits::max_size(__node_alloc()),
numeric_limits<difference_type >::max());}
void clear() _NOEXCEPT;