Skip to content
New issue

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

basic_content/pointer_refer/copy_construct.cpp 里面有些问题 #345

Open
LiuDong137816 opened this issue Aug 2, 2024 · 1 comment
Open

Comments

@LiuDong137816
Copy link

cout << "pass by value: " << endl;
AcceptVal(ReturnRvalue()); // 应该调用两次拷贝构造函数
cout << "pass by reference: " << endl;
AcceptRef(ReturnRvalue()); // 应该只调用一次拷贝构造函数

如果允许的话,是没有Copy的,是因为C++ RVO (Return Value Optimization),详细在https://stackoverflow.com/questions/10476665/avoiding-copy-of-objects-with-the-return-statement

我是用VS跑的

@FlyDragonMan
Copy link

FlyDragonMan commented Aug 2, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants