From 43d3c7a4e290ee96684735daf7b1d528c30a7943 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 31 Aug 2022 13:44:00 -0700 Subject: InlinedVector: Correct the computation of max_size() Corrects the computation of max_size(), so that it accounts for the size of the objects. PiperOrigin-RevId: 471343778 Change-Id: I68e222cefaa0295b8d8c38d00308a29df4165e81 --- absl/container/inlined_vector.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'absl/container/inlined_vector.h') diff --git a/absl/container/inlined_vector.h b/absl/container/inlined_vector.h index bc1c4a77..42121228 100644 --- a/absl/container/inlined_vector.h +++ b/absl/container/inlined_vector.h @@ -275,8 +275,9 @@ 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 `size_type`. - return (std::numeric_limits::max)() / 2; + // inlined vector can express is half of the max for + // AllocatorTraits::max_size(); + return AllocatorTraits::max_size(storage_.GetAllocator()) / 2; } // `InlinedVector::capacity()` -- cgit v1.2.3