January 18, 2012 tdpl: partial ordering of functions: conflict error | ||||
---|---|---|---|---|
| ||||
Hello List: On my box, the following D source, inspired by the subsection 5.5.2 of tDpl, arises a `template conflict': ----------------------------------------------------------------- T[] find(T, E)(T[] haystack, E needle) if (is(typeof(haystack[0] != needle) == bool)) { while (haystack.length > 0 && haystack[0] != needle) { haystack = haystack[1 .. $]; } return haystack; } TL[] find(TL, TS)(TL[] longer, TS[] shorter) if (is(typeof(longer[0 .. 1] == shorter) : bool)) { while (longer.length >= shorter.length) { if (longer[0 .. shorter.length] == shorter) break; longer=longer[1 .. $]; } return longer; } int[] find(int[] longer, int[] shorter) { while (longer.length >= shorter.length) { if (longer[0 .. shorter.length] == shorter) break; longer=longer[1 .. $]; } return longer; } unittest { long[] a1 = [ 6, 1, 2, 3 ]; int[] a2 = [ 1 , 2 ]; assert(find(a1, a2) == a1[1 .. $]); } void main() {} ----------------------------------------------------------------- And I cannot figure why :-( Thanks in advance for any help, Jerome |
Copyright © 1999-2021 by the D Language Foundation