-
Notifications
You must be signed in to change notification settings - Fork 531
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
可以借助解引用操作变通地对 std::unique_ptr 进行深拷贝 #5
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
course/02/19/main.cpp
Lines 32 to 35 in c8787cf
课件这里的写法是复杂又容易出错的,其实我们可以采取下面这样更安全的方式:
虽然
std::unique_ptr
删除了 copy constructor 和 copy assignment operator ,但其实我们可以借助解引用操作变通地对std::unique_ptr
进行拷贝。deep copy 示例如下:
其它的例证:
The text was updated successfully, but these errors were encountered: