Skip to content

Commit 757d827

Browse files
authored
Fix shrink_to_fit
1 parent 4651e1c commit 757d827

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libcxx/include/string

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
32533253

32543254
template <class _CharT, class _Traits, class _Allocator>
32553255
inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::shrink_to_fit() _NOEXCEPT {
3256-
size_type __target_capacity = __recommend(size());
3256+
size_type __target_capacity = size();
3257+
__target_capacity = __target_capacity < __min_cap ? static_cast<size_type>(__min_cap) - 1 : __recommend(__target_capacity);
32573258
if (__target_capacity == capacity())
32583259
return;
32593260

0 commit comments

Comments
 (0)