You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/en-us/03-runtime.md
+17-1Lines changed: 17 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -260,6 +260,22 @@ Temporary variables returned by non-references, temporary variables generated
260
260
by operation expressions, original literals, and Lambda expressions
261
261
are all pure rvalue values.
262
262
263
+
Note that a string literal became rvalue in a class, and remains an lvalue in other cases (e.g., in a function):
264
+
265
+
```cpp
266
+
class Foo {
267
+
const char*&& right = "this is a rvalue";
268
+
public:
269
+
void bar() {
270
+
right = "still rvalue"; // the string literal is a rvalue
271
+
}
272
+
};
273
+
274
+
int main() {
275
+
const char* const &left = "this is an lvalue"; // the string literal is an lvalue
276
+
}
277
+
```
278
+
263
279
**xvalue, expiring value** is the concept proposed by C++11 to introduce
264
280
rvalue references (so in traditional C++, pure rvalue and rvalue are the same concept),
265
281
a value that is destroyed but can be moved.
@@ -617,4 +633,4 @@ Lambda expression
617
633
618
634
## Licenses
619
635
620
-
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](../../LICENSE).
636
+
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png" /></a><br />This work was written by [Ou Changkun](https://changkun.de) and licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/">Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License</a>. The code of this repository is open sourced under the [MIT license](../../LICENSE).