1.2 KiB
[diff.cpp20.strings]
Annex C (informative) Compatibility [diff]
C.2 C++ and ISO C++ 2020 [diff.cpp20]
C.2.11 [strings]: strings library [diff.cpp20.strings]
Affected subclause: [string.classes]
Change: Additional rvalue overload for the substr member function and the corresponding constructor.
Rationale: Improve efficiency of operations on rvalues.
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++.
[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]