Equality of ForwardRanges

monarch_dodra monarchdodra at gmail.com
Sun Oct 28 13:32:18 PDT 2012


On Sunday, 28 October 2012 at 19:42:30 UTC, Tobias Pankrath wrote:
> Given:
>
> void foo(Range)(Range fwdR)
>    if(isForwardRange!Range)
> {
>     auto tmp = fwdR.save;
>     assert(tmp == fwdR);
> }
>
> May I assume that the assert holds for generic forward range 
> types?
>
> Reason: I try to write an algorithm, that is easily 
> implementable with random access ranges, but to make it work 
> with forward ranges I need a comparison similar to the one 
> above.

If you meant comparing the actual range objects using "r == 
r.save", that doesn't hold either: If a is a "reference semantic 
range", such as a class, then the saved range will be different 
from the old range.

Note that in both cases, this has nothing to do with RA vs Frwd.


More information about the Digitalmars-d mailing list