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
[util.smartptr.atomic.general] Remove redundant explicit construction of return types #6077
Conversation
source/threads.tex
Outdated
@@ -4833,7 +4833,7 @@ | |||
while (p && p->t != t) | |||
p = p->next; | |||
|
|||
return shared_ptr<node>(move(p)); | |||
return shared_ptr<node>(std::move(p)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we explicitly converting a shared_ptr<node>
to shared_ptr<node>
in the first place? What's wrong with return p;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return p;
is a more reasonable approach. (I'd be happy if it could be changed to this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, let's go ahead and change it. We like to show a variety of styles in examples, but writing something long and complicated when something short and simple will do isn't style, it's obfuscation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@tkoeppe, please squash when merging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You now need to look outside that member function to see what its return type is, because it uses auto
for the return type and auto
for the declaration of p
, and now this removes the only mention of the type. While it's not hard to look at the declaration of head
, is this actually making the example clearer?
We could change the return type from auto
to shared_ptr<node>
maybe.
No description provided.