Closed eroller closed 1 year ago
This is undefined behavior. unique
requires an equivalence relation, and less{}
is not one. range-v3 uses sortable
as the constraint here, which isn't right:
The standard library has indirect_equivalence_relation
for this case. PRs welcome to fix.
Is there a fundamental reason it could not?
Fundamental? No. But it's easy to project a binary function with a function adapter on(f, proj)
, which seems better than changing every algorithm that takes a binary function to figure out how to add a projection to it.
This makes sense. Thanks for the quick reply!
The following test fails.
Also, I noticed that ranges::views::unique doesn't support projections: https://github.com/ericniebler/range-v3/blob/master/include/range/v3/view/unique.hpp#L56 Is there a fundamental reason it could not?