simple syntax issue with template

Lloyd Dupont ld-REMOVE at galador.net
Mon Jun 13 05:49:29 PDT 2011


ho.. plenty of silly mistake indeed.. thanks for spotting them!
(maybe I should take a break and play the witcher 2 hey!?!? :)

however I still have a problem with removeAt now! :(
===
void removeAt(T)(ref T[] array, int index)
{
    if(index < 0 || index >= array.length)
        return;
    array.replaceInPlace(index, index + 1, []);
}
===
will produce the following errors:
===
Error: template std.array.replaceInPlace(T,Range) if (isDynamicArray!(Range) 
&& is(ElementEncodingType!(Range) : T) && !is(T == const(T)) && !is(T == 
immutable(T))) does not match any function template declaration
Error: template std.array.replaceInPlace(T,Range) if (isDynamicArray!(Range) 
&& is(ElementEncodingType!(Range) : T) && !is(T == const(T)) && !is(T == 
immutable(T))) cannot deduce template function from argument types 
!()(int[],int,int,void[])
===

mmm.. strangely enough the code below succeed!
====
void removeAt(T)(ref T[] array, int index)
{
    if(index < 0 || index >= array.length)
        return;
    T[] empty;
    array.replaceInPlace(index, index + 1, empty);
}
====
but T[].init didn't work either....?! ho well, thanks! :) 



More information about the Digitalmars-d-learn mailing list