From Jason Turner

[diff.cpp20.strings]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpivczlbnb/{from.md → to.md} +18 -0
tmp/tmpivczlbnb/{from.md → to.md} RENAMED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### [[strings]]: strings library <a id="diff.cpp20.strings">[[diff.cpp20.strings]]</a>
2
+
3
+ **Change:** Additional rvalue overload for the `substr` member function
4
+ and the corresponding constructor. **Rationale:** Improve efficiency of
5
+ operations on rvalues. **Effect on original feature:** Valid C++20 code
6
+ that created a substring by calling `substr` (or the corresponding
7
+ constructor) on an xvalue expression with type `S` that is a
8
+ specialization of `basic_string` may change meaning in this revision of
9
+ C++. For example:
10
+
11
+ ``` cpp
12
+ std::string s1 = "some long string that forces allocation", s2 = s1;
13
+ std::move(s1).substr(10, 5);
14
+ assert(s1 == s2); // unspecified, previously guaranteed to be true
15
+ std::string s3(std::move(s2), 10, 5);
16
+ assert(s1 == s2); // unspecified, previously guaranteed to be true
17
+ ```
18
+