Should this invariant always hold? equal(range.retro.array, range.array.retro)
Dukc
ajieskola at gmail.com
Mon Oct 17 20:31:20 UTC 2022
On Monday, 17 October 2022 at 11:02:07 UTC, FeepingCreature wrote:
> Trolling a bit: Should this invariant always hold?
>
> assert(equal(range.retro.array, range.array.retro));
Posting this without having looked at other replies.
No. The range could be a reference range, in which case this does
not hold unless the range is already empty.
The invariant would have to be
`assert(equal(range.save.retro.array, range.save.array.retro));`
instead.
Also this won't hold if the range contains floating point NaNs,
or other elements that are not equal to themselves.
There may be other corner cases too I didn't think of.
More information about the Digitalmars-d
mailing list