File tree 2 files changed +2
-2
lines changed
2 files changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ int main()
345
345
346
346
const std::string& lv2 = lv1 + lv1; // legal, const lvalue reference can extend temp variable's lifecycle
347
347
// lv2 += "Test"; // illegal, const ref can't be modified
348
- std::cout << lv2 << std::endl; // string,string
348
+ std::cout << lv2 << std::endl; // string,string,
349
349
350
350
std::string&& rv2 = lv1 + lv2; // legal, rvalue ref extend lifecycle
351
351
rv2 += "string"; // legal, non-const reference can be modified
Original file line number Diff line number Diff line change @@ -293,7 +293,7 @@ int main()
293
293
294
294
const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期
295
295
// lv2 += "Test"; // 非法, 常量引用无法被修改
296
- std::cout << lv2 << std::endl; // string,string
296
+ std::cout << lv2 << std::endl; // string,string,
297
297
298
298
std::string&& rv2 = lv1 + lv2; // 合法, 右值引用延长临时对象生命周期
299
299
rv2 += "Test"; // 合法, 非常量引用能够修改临时变量
You can’t perform that action at this time.
0 commit comments