bool empty() const for ranges
Stanislav Blinov
stanislav.blinov at gmail.com
Fri Nov 26 11:26:20 UTC 2021
On Friday, 26 November 2021 at 10:44:10 UTC, Salih Dincer wrote:
> * Is the const essential for ranges?
> * Is it possible to rewind the pointer (```Node * head;```)
> when my head is empty by the const?
`empty` is not required to be `const`, but it is required to
yield the same result if called multiple times without mutating
the range (see
https://dlang.org/phobos/std_range_primitives.html#.isInputRange). In other words, you really ought not to mutate the range in implementation of `empty`, or at least not to the extent you seem to want to.
More information about the Digitalmars-d-learn
mailing list