The overlapping portion of the two arrays.
1 int[] a = [ 10, 11, 12, 13, 14 ]; 2 int[] b = a[1 .. 3]; 3 assert(overlap(a, b) == [ 11, 12 ]); 4 b = b.dup; 5 // overlap disappears even though the content is the same 6 assert(overlap(a, b).empty); 7 8 static test()() @nogc 9 { 10 auto a = "It's three o'clock"d; 11 auto b = a[5 .. 10]; 12 return b.overlap(a); 13 } 14 15 //works at compile-time 16 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.