mirror of
https://github.com/changkun/modern-cpp-tutorial.git
synced 2025-12-17 04:34:40 +03:00
book: typo fixes (#204)
This commit is contained in:
@@ -345,7 +345,7 @@ int main()
|
|||||||
|
|
||||||
const std::string& lv2 = lv1 + lv1; // legal, const lvalue reference can extend temp variable's lifecycle
|
const std::string& lv2 = lv1 + lv1; // legal, const lvalue reference can extend temp variable's lifecycle
|
||||||
// lv2 += "Test"; // illegal, const ref can't be modified
|
// lv2 += "Test"; // illegal, const ref can't be modified
|
||||||
std::cout << lv2 << std::endl; // string,string
|
std::cout << lv2 << std::endl; // string,string,
|
||||||
|
|
||||||
std::string&& rv2 = lv1 + lv2; // legal, rvalue ref extend lifecycle
|
std::string&& rv2 = lv1 + lv2; // legal, rvalue ref extend lifecycle
|
||||||
rv2 += "string"; // legal, non-const reference can be modified
|
rv2 += "string"; // legal, non-const reference can be modified
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ int main()
|
|||||||
|
|
||||||
const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期
|
const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期
|
||||||
// lv2 += "Test"; // 非法, 常量引用无法被修改
|
// lv2 += "Test"; // 非法, 常量引用无法被修改
|
||||||
std::cout << lv2 << std::endl; // string,string
|
std::cout << lv2 << std::endl; // string,string,
|
||||||
|
|
||||||
std::string&& rv2 = lv1 + lv2; // 合法, 右值引用延长临时对象生命周期
|
std::string&& rv2 = lv1 + lv2; // 合法, 右值引用延长临时对象生命周期
|
||||||
rv2 += "Test"; // 合法, 非常量引用能够修改临时变量
|
rv2 += "Test"; // 合法, 非常量引用能够修改临时变量
|
||||||
|
|||||||
Reference in New Issue
Block a user