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
Conversation
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. 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> |
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.
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> |
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.
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.)
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.
(There might be arcane cases where users might want to specify explicit template argument lists.)
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> |
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.
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> |
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.
Here, we switch Pred, Proj1, Proj2 to Proj1, Proj2, Pred (i.e. the "other" order). This is seriously confusing.
Also fixes NB GB 183, US 267, US 306, and PL 312 (C++20 CD).
b4f72db
to
7bf810a
Compare
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).