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

docs: copy-constructor vs copy-assignment #5

Open
El-even-11 opened this issue Sep 17, 2023 · 3 comments
Open

docs: copy-constructor vs copy-assignment #5

El-even-11 opened this issue Sep 17, 2023 · 3 comments

Comments

@El-even-11
Copy link

// Then, s4 is copy-assigned from s3.
std::shared_ptr<Point> s4 = s3;

Might use copy-constructor here?

@El-even-11
Copy link
Author

// copy-constructed
std::shared_ptr<Point> s4 = s3;

// copy-assigned
std::shared_ptr<Point> s4;
s4 = s3;

@cscourage
Copy link
Contributor

cscourage commented Dec 5, 2023

I totally agree with you too.
"std::shared_ptr<Point> s4 = s3; " should be copy-construction, because it is the first time s4 appears.

"std::shared_ptr<Point> s4; // default construction
s4 = s3;" // copy-assignment.
and this is the situation where copy-assignment works.

@skyzh
Copy link
Member

skyzh commented Dec 5, 2023

yep, this looks like a typo. would you please submit a pull request? thanks!

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

3 participants