[libcxx-commits] [libcxx] [libc++] Add the allocator parameter in basic_string::substr (PR #110207)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 26 22:41:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Alexandre Arsenault (alxarsenault)
<details>
<summary>Changes</summary>
When using a non-default constructible allocator in `std::basic_string`, the `substr` method should pass it's allocator to construct the substring.
---
Full diff: https://github.com/llvm/llvm-project/pull/110207.diff
1 Files Affected:
- (modified) libcxx/include/string (+3-3)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/110207
More information about the libcxx-commits
mailing list