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

P1716R3 ranges compare algorithm are over-constrained #3450

Merged
merged 2 commits into from Nov 21, 2019

Conversation

zygoloid
Copy link
Member

@zygoloid zygoloid commented Nov 13, 2019

Fixes #3409.
Fixes cplusplus/nbballot#181.
Fixes cplusplus/nbballot#263.
Fixes cplusplus/nbballot#302.
Fixes cplusplus/nbballot#308.

Fixes cplusplus/papers#482

Also fixes NB GB 183, US 267, US 306, and PL 312 (C++20 CD).

@zygoloid zygoloid added this to the post-2019-11 milestone Nov 13, 2019
Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

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

Looks good. Asked LWG about order of template parameters: http://lists.isocpp.org/lib/2019/11/14279.php

class Proj1 = identity, class Proj2 = identity,
indirect_relation<projected<I1, Proj1>,
projected<I2, Proj2>> Pred = ranges::equal_to>
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
Copy link
Member

Choose a reason for hiding this comment

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

This changes the relative order of Proj1, Proj2, Pred template parameters to be Pred, Proj1, Proj2 instead. I couldn't find a mention in the prose text section of the paper that this was intended. Having deducible template parameters in the same order as the function parameters seems reasonable, though.

@@ -846,11 +846,13 @@

namespace ranges {
template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
indirect_relation<projected<I, Proj>> Pred = ranges::equal_to>
indirect_binary_predicate<projected<I, Proj>,
projected<I, Proj>> Pred = ranges::equal_to>
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused. Here, "Proj" still comes first in the template parameters. This is oddly inconsistent. (There might be arcane cases where users might want to specify explicit template argument lists.)

Copy link
Contributor

Choose a reason for hiding this comment

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

(There might be arcane cases where users might want to specify explicit template argument lists.)

[algorithms.requirements]p15:

The number and order of deducible template parameters for algorithm declarations are unspecified, except where explicitly stated otherwise.
[ Note: Consequently, the algorithms may not be called with explicitly-specified template argument lists. — end note ]

indirect_relation<projected<I1, Proj1>,
projected<I2, Proj2>> Pred = ranges::equal_to>
class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
Copy link
Member

Choose a reason for hiding this comment

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

Again, the order of template parameters is changed. Note that indirectly_comparable also takes Pred, Proj1, Proj2 (but we take Proj1, Proj2, Pred). Go figure.

requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
sentinel_for<I2> S2, class Proj1 = identity, class Proj2 = identity,
indirect_equivalence_relation<projected<I1, Proj1>,
projected<I2, Proj2>> Pred = ranges::equal_to>
Copy link
Member

Choose a reason for hiding this comment

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

Here, we switch Pred, Proj1, Proj2 to Proj1, Proj2, Pred (i.e. the "other" order). This is seriously confusing.

@zygoloid zygoloid merged commit 5435b57 into master Nov 21, 2019
@jensmaurer jensmaurer deleted the motions-2019-11-lwg-6 branch February 18, 2020 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment