Files
2025-10-25 03:02:53 +03:00

35 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[diff.cpp20.strings]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.2 C++ and ISO C++ 2020 [[diff.cpp20]](diff.cpp20#strings)
### C.2.11 [[strings]](strings "27Strings library"): strings library [diff.cpp20.strings]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L749)
**Affected subclause:** [[string.classes]](string.classes)
**Change:** Additional rvalue overload for the substr member function and
the corresponding constructor[.](#1.sentence-1)
**Rationale:** Improve efficiency of operations on rvalues[.](#1.sentence-2)
**Effect on original feature:** Valid C++ 2020 code that created a substring
by calling substr (or the corresponding constructor)
on an xvalue expression with type S that is a specialization of basic_string may change meaning in this revision of C++[.](#1.sentence-3)
[*Example [1](#example-1)*: std::string s1 = "some long string that forces allocation", s2 = s1;
std::move(s1).substr(10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true std::string s3(std::move(s2), 10, 5);
assert(s1 == s2); // unspecified, previously guaranteed to be true — *end example*]