The overlapping portion of the two arrays.
int[] a = [ 10, 11, 12, 13, 14 ]; int[] b = a[1 .. 3]; assert(overlap(a, b) == [ 11, 12 ]); b = b.dup; // overlap disappears even though the content is the same assert(overlap(a, b).empty); static test()() @nogc { auto a = "It's three o'clock"d; auto b = a[5 .. 10]; return b.overlap(a); } //works at compile-time static assert(test == "three"d);
Returns the overlapping portion, if any, of two arrays. Unlike equal, overlap only compares the pointers and lengths in the ranges, not the values referred by them. If r1 and r2 have an overlapping slice, returns that slice. Otherwise, returns the null slice.