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 Issue 8341 - topN(zip()) doesn't work #6156

Merged
merged 1 commit into from Mar 12, 2018
Merged

Conversation

wilzbach
Copy link
Member

topN requires an assignable range. While fixing the constraint of topN, I found that almost the entire module had missing constraints.
This should improve the error messages slightly, i.e. now they aren't in std.algorithm anymore, but the user at least gets "no matching function found" and sees the constraints.

@dlang-bot
Copy link
Contributor

dlang-bot commented Feb 10, 2018

Thanks for your pull request, @wilzbach!

Bugzilla references

Auto-close Bugzilla Description
8341 topN(zip()) too?

@@ -3100,7 +3102,8 @@ Stable topN has not been implemented yet.
auto topN(alias less = "a < b",
SwapStrategy ss = SwapStrategy.unstable,
Range)(Range r, size_t nth)
if (isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range)
if (isRandomAccessRange!(Range) && hasLength!Range &&
hasSlicing!Range && hasAssignableElements!Range)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be hasSwappableElements?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it calls pivotPartition which calls moveAt and assigns to the element:

auto save = r.moveAt(hi);
...
r[lo] = save;

hasSwappableElements just requires that swap(a, b) works.

@dlang-bot dlang-bot merged commit 78f7209 into dlang:master Mar 12, 2018
@wilzbach wilzbach deleted the fix-8341 branch March 12, 2018 14:14
@wilzbach wilzbach mentioned this pull request Mar 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants