std.range.equal or == in isPalindrome
Stanislav Blinov
stanislav.blinov at gmail.com
Tue Feb 18 01:37:34 PST 2014
On Tuesday, 18 February 2014 at 09:31:55 UTC, Per Nordlöw wrote:
> I'm curious to why we need std.range.equal in cases such as
>
> bool isPalindrome(Range)(in Range range) if
> (isBidirectionalRange!Range)
> {
> return range.retro.equal(range);
> }
>
> Why isn't equality == operator used here instead?
>
> /Per
1) opEquals cannot be a free function
2) there's no telling what opEquals does if Range defines it
IOW, equal() has a defined by-element-comparison semantics, while
opEquals doesn't.
More information about the Digitalmars-d-learn
mailing list