summaryrefslogtreecommitdiff
path: root/absl/container
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container')
-rw-r--r--absl/container/inlined_vector.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h
index 42121228..08a47709 100644
--- a/absl/container/inlined_vector.h
+++ b/absl/container/inlined_vector.h
@@ -275,9 +275,10 @@ class InlinedVector {
size_type max_size() const noexcept {
// One bit of the size storage is used to indicate whether the inlined
// vector contains allocated memory. As a result, the maximum size that the
- // inlined vector can express is half of the max for
- // AllocatorTraits<A>::max_size();
- return AllocatorTraits<A>::max_size(storage_.GetAllocator()) / 2;
+ // inlined vector can express is the minimum of the limit of how many
+ // objects we can allocate and std::numeric_limits<size_type>::max() / 2.
+ return (std::min)(AllocatorTraits<A>::max_size(storage_.GetAllocator()),
+ (std::numeric_limits<size_type>::max)() / 2);
}
// `InlinedVector::capacity()`