Finding position of a value in an array

Ron Tarrant rontarrant at gmail.com
Mon Dec 30 14:30:12 UTC 2019


On Sunday, 29 December 2019 at 09:44:18 UTC, MoonlightSentinel 
wrote:

> int i = a.countUntil(55);


I was trying to do this with an array of pointers, but I get an 
error (which suggests to me that I don't know what data type a 
pointer is):

find_in_array_object.d(25): Error: cannot cast expression 
newObject of type find_in_array_object.MyObject to ulong
find_in_array_object.d(34): Error: template 
std.algorithm.searching.countUntil cannot deduce function from 
argument types !()(MyObject[], ulong), candidates are:
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\searching.d(768):        std.algorithm.searching.countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs needles) if (isForwardRange!R && (Rs.length > 0) && (isForwardRange!(Rs[0]) == isInputRange!(Rs[0])) && is(typeof(startsWith!pred(haystack, needles[0]))) && (Rs.length == 1 || is(typeof(countUntil!pred(haystack, needles[1..__dollar])))))
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\searching.d(856):        std.algorithm.searching.countUntil(alias pred = "a == b", R, N)(R haystack, N needle) if (isInputRange!R && is(typeof(binaryFun!pred(haystack.front, needle)) : bool))
C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\searching.d(915):        std.algorithm.searching.countUntil(alias pred, R)(R haystack) if (isInputRange!R && is(typeof(unaryFun!pred(haystack.front)) : bool))

It's not a ulong? Have I forgotten so much?


More information about the Digitalmars-d-learn mailing list