On Monday, 11 August 2014 at 14:45:09 UTC, Andrei Alexandrescu
wrote:
On 8/11/14, 2:11 AM, "Nordlöw" wrote:
On Monday, 11 August 2014 at 06:56:52 UTC, Dragos Carp wrote:
bool sliceOf(T)(in T[] whole, in T[] slice)
{
return whole.ptr <= slice.ptr &&
whole.ptr + slice.length <= whole.ptr + slice.length;
}
Shouldn't the function arguments of sliceOf be reversed to
given a more
intuitive UCFS as
if (slice.sliceOf(whole) { ... }
isSliceOf -> yum
While "sameHead" and "sameTail" *could* have a "good enough"
generic implementation for ranges, there is absolutely no way to
make "isSliceOf" or "overlap" work for a generic range.
That said, sameHead and sameTail is just the iterator equivalent
of "first1 == first2" and "last1 == last2", which is used a lot
with iterators. You rarely see operator "<" used with iterators
though, so I have doubts about why those two functions (isSliceOf
and overlap) would actually be of any use.