removed some obvious error, still stumped on the templated syntax ...
so.. why is it not compiling?
(error:
Error: template std.algorithm.countUntil(alias pred = "a == b",R1,R2) if (is(typeof(startsWith!(pred)(haystack,needle)))) does not match any function template declaration
)
=====
import std.algorithm;

public:

void remove(T)(ref T[] array, T element)
{
   sizediff_t index = array.countUntil!("a == b", T[], T)(array, element);
   removeAt(array, index);
}

void removeAt(T)(ref T[] array, sizediff_t index)
{
   if(index < 0 || index >= array.length)
       return;
   array.replaceInPlace(index, index + 1, []);
}


unittest
{
   auto a = [1, 3, 4];
   a.remove(3);
   assert(a == [1, 4]);
}
=====

Reply via email to