Weird const behavior
Marko
marko at gmail.com
Thu Dec 20 17:10:56 UTC 2018
On Thursday, 20 December 2018 at 15:17:31 UTC, Steven
Schveighoffer wrote:
> It's really how opEquals is marked.
>
> opEquals for structs (without a specific implementation), is
> marked as a combination of comparing all the fields, whatever
> they are marked. Any basic types are comparable whether they
> are const or not. So most likely the range struct's opEquals is
> marked const.
>
> However, popFront is likely not const. In some rare cases it
> can be (i.e. an infinite range of a single value). If the range
> cannot be operated, isInputRange returns false.
>
> -Steve
I know about promotion / implicit casting, but I always find this
is a but awkward when comparing objects or structs it's equal but
acts differently.
But I'm may be the minority. :)
Marko.
More information about the Digitalmars-d-learn
mailing list