We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std::string lv1 = "string,"; // lv1 is a lvalue // std::string&& r1 = s1; // illegal, rvalue can't ref to lvalue std::string&& rv1 = std::move(lv1); // legal, std::move can convert lvalue to rvalue std::cout << rv1 << std::endl; // string, 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 std::cout << lv2 << std::endl; // string,string
std::string lv1 = "string,"; // lv1 是一个左值 // std::string&& r1 = lv1; // 非法, 右值引用不能引用左值 std::string&& rv1 = std::move(lv1); // 合法, std::move可以将左值转移为右值 std::cout << rv1 << std::endl; // string, const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期 // lv2 += "Test"; // 非法, 常量引用无法被修改 std::cout << lv2 << std::endl; // string,string
std::string lv1 = "string,"; // lv1 is a lvalue // std::string&& r1 = s1; // illegal, rvalue can't ref to lvalue std::string&& rv1 = std::move(lv1); // legal, std::move can convert lvalue to rvalue std::cout << rv1 << std::endl; // string, 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 std::cout << lv2 << std::endl; // string,string,
std::string lv1 = "string,"; // lv1 是一个左值 // std::string&& r1 = lv1; // 非法, 右值引用不能引用左值 std::string&& rv1 = std::move(lv1); // 合法, std::move可以将左值转移为右值 std::cout << rv1 << std::endl; // string, const std::string& lv2 = lv1 + lv1; // 合法, 常量左值引用能够延长临时变量的生命周期 // lv2 += "Test"; // 非法, 常量引用无法被修改 std::cout << lv2 << std::endl; // string,string,
The text was updated successfully, but these errors were encountered:
No branches or pull requests
实际描述
预期描述
The text was updated successfully, but these errors were encountered: