book: fix incorrect string literal (#102) and a typo (#103)

This commit is contained in:
dragonWater
2020-06-03 14:19:41 +08:00
committed by GitHub
parent f1c1e06178
commit 3abc907bb4
2 changed files with 34 additions and 2 deletions

View File

@@ -260,6 +260,22 @@ Temporary variables returned by non-references, temporary variables generated
by operation expressions, original literals, and Lambda expressions
are all pure rvalue values.
Note that a string literal became rvalue in a class, and remains an lvalue in other cases (e.g., in a function)
```cpp
class Foo {
const char*&& right = "this is a rvalue";
public:
void bar() {
right = "still rvalue"; // the string literal is a rvalue
}
};
int main() {
const char* const &left = "this is an lvalue"; // the string literal is an lvalue
}
```
**xvalue, expiring value** is the concept proposed by C++11 to introduce
rvalue references (so in traditional C++, pure rvalue and rvalue are the same concept),
a value that is destroyed but can be moved.
@@ -617,4 +633,4 @@ Lambda expression
## Licenses
<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).
<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).