35 lines
1.2 KiB
Markdown
35 lines
1.2 KiB
Markdown
[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 "27 Strings 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*]
|