Suggestion: Operator `in` for slices
Era Scarecrow
rtcvb32 at yahoo.com
Wed Jan 5 23:16:48 UTC 2022
On Tuesday, 4 January 2022 at 18:23:33 UTC, Nick Treleaven wrote:
> It would make sense to implement `in` for SortedRange, but
> there is no use case for returning a pointer. You already have
> the value on the left hand side, the only reason for a pointer
> would be to mutate the element in the range.
Sorry, i was somehow thinking there was a key/value pair in this
and not just a normal sorted block.
But yes there may still be use cases. Consider i do opCmp on a
struct, and it only does comparisons on say a name portion (*Or
UPC or some other immutable property ID*), but no other part of
the stored data. The name/ID would be how it's sorted; But any
attached data which is non-sorted would be inaccessible
otherwise. This could be phone number, address, grades, just
about anything (*and those items could be changed without
changing the sorting order*)
Though you can probably do 2 steps it seems like a bit of extra
pointless work to me. Or maybe AA's are a better choice in that
case. I'm not sure.
More information about the Digitalmars-d
mailing list