[libcxx-commits] [libcxx] [libc++] Add the allocator parameter in basic_string::substr (PR #110207)
Alexandre Arsenault via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 26 22:40:17 PDT 2024
https://github.com/alxarsenault created https://github.com/llvm/llvm-project/pull/110207
When using a non-default constructible allocator in `std::basic_string`, the `substr` method should pass it's allocator to construct the substring.
>From 26e70d9beae0e6220fc377f9aa2755535acdb23f Mon Sep 17 00:00:00 2001
From: Alexandre Arsenault <alx.arsenault at gmail.com>
Date: Fri, 27 Sep 2024 01:35:53 -0400
Subject: [PATCH] [libc++] Add the allocator parameter in basic_string::substr
---
libcxx/include/string | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libcxx/include/string b/libcxx/include/string
index fdb189016bfbac..b49b61567cdc2b 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -1683,15 +1683,15 @@ public:
#if _LIBCPP_STD_VER <= 20
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string
substr(size_type __pos = 0, size_type __n = npos) const {
- return basic_string(*this, __pos, __n);
+ return basic_string(*this, __pos, __n, __alloc());
}
#else
_LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) const& {
- return basic_string(*this, __pos, __n);
+ return basic_string(*this, __pos, __n, __alloc());
}
_LIBCPP_HIDE_FROM_ABI constexpr basic_string substr(size_type __pos = 0, size_type __n = npos) && {
- return basic_string(std::move(*this), __pos, __n);
+ return basic_string(std::move(*this), __pos, __n, __alloc());
}
#endif
More information about the libcxx-commits
mailing list