Thank you Timon, I very much appreciate your (and others) help. I will look all this up in the online docs and the book.
There is still some very odd things in how these fit together. For example, if I comment out the last 3 function templates, I get all "simpleparms", which is expected. But if I add in the fourth, I get a compilation error saying the call to abc(arr2) is ambiguous. So even though the first one specifies "U = void" and "size_t N = 0", and the fourth specifies something very different, there is ambiguity between them. Adding in the third resolves the ambiguity between the first and fourth. John On Sat, Oct 29, 2011 at 4:02 PM, Timon Gehr <[email protected]> wrote: > > This works: > > void abc(T, U=void, size_t N=0) (T parm1) { > writeln("simpleparm: ", parm1); > } > > void abc(T: string) (T parm1) { > writeln("string : ", parm1); > } > > void abc(T:U[], U) (T parm1) if (isDynamicArray!T) { > writeln("dynamic array : ", parm1); > } > > void abc(T:U[N], U, size_t N) (T parm1) { > writeln("static array : ", parm1); > > } > > void main(string[] args) { > abc(1); > abc("str"); > int[] arr = [1, 2]; > abc(arr); > int[2] arr2 =[3, 4]; > abc(arr2); > } >
