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

Fix issues with pair #87

Closed
wants to merge 3 commits into from
Closed

Fix issues with pair #87

wants to merge 3 commits into from

Conversation

jrhemstad
Copy link
Collaborator

return pair_type<F, S>{std::forward<F>(f), std::forward<S>(s)};
using decayed_F = std::decay_t<F>;
using decayed_S = std::decay_t<S>;
return pair_type<decayed_F, decayed_S>{std::forward<decayed_F>(f), std::forward<decayed_S>(s)};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use move here instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::forward will have the same semantics as std::move if F or S are r-value references.

You can think of std::forward as a more generic form of std::move.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will there be a return type mismatch with the function signature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point! Used auto return type instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrhemstad yeah, I guess my point is that since decayed_F is not a reference type, then forward<decayed_F> will always return an r-value, so it's identical to just using move in this case - is my understanding correct here? and so I was thinking that move is just shorter to use here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you could use std::forward with the original type as well

@PointKernel
Copy link
Member

Superseded by #319

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

Successfully merging this pull request may close these issues.

4 participants