std.algorithm.find and array of needles?

captaindet 2krnk at gmx.net
Mon Mar 3 11:35:53 PST 2014


std.algorithm.find has an overload that works with several needles:

// phobos doc example:
int[] a = [ 1, 4, 2, 3 ];
assert(find(a, [ 1, 3 ], 4) == tuple([ 4, 2, 3 ], 2));

the function i want to write has to deal with variadic arguments serving as needles. unfortunately, i failed trying to make find work with the needles provided in an array:

int[] a = [ 9, 8, 7, 6, 5, 4, 3, 2, 1 ];
int[][] ns = [  [ 7, 6 ], [ 4, 3 ] ];
auto res = find( a, ns );
//Error: template std.algorithm.find does not match any function template declaration. Candidates are:

any ideas how this can be achieved?

thanks
/det


More information about the Digitalmars-d-learn mailing list