diff options
author | Derek Mauro <dmauro@google.com> | 2022-08-31 13:44:00 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-08-31 13:44:42 -0700 |
commit | 43d3c7a4e290ee96684735daf7b1d528c30a7943 (patch) | |
tree | ba10e3e2dcb71ff4a5bd6cc3e51c39efac377fe2 /absl/container/inlined_vector.h | |
parent | 6a262fdaddb6cd7df7ddc8472a1cc61cc64a01db (diff) |
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
Diffstat (limited to 'absl/container/inlined_vector.h')
-rw-r--r-- | absl/container/inlined_vector.h | 5 |
1 files changed, 3 insertions, 2 deletions
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<size_type>::max)() / 2; + // inlined vector can express is half of the max for + // AllocatorTraits<A>::max_size(); + return AllocatorTraits<A>::max_size(storage_.GetAllocator()) / 2; } // `InlinedVector::capacity()` |