[libcxx-commits] [libcxx] [libc++][vector] Fixes shrink_to_fit. (PR #97895)

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Wed Jul 10 07:57:27 PDT 2024


================
@@ -1443,7 +1443,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE
 #endif // _LIBCPP_HAS_NO_EXCEPTIONS
       allocator_type& __a = this->__alloc();
       __split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
----------------
mordante wrote:

Indeed and `allocate` basically "wastes" space by making the possible trailing part of the allocated space inaccessible.

https://github.com/llvm/llvm-project/pull/97895


More information about the libcxx-commits mailing list