variadic overload of std.algorithm.searching.countUntil should return which needle was found · Issue #10257 · dlang/phobos (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Description
greensunny12 reported this on 2017-07-11T16:07:21Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=17634
CC List
- razvan.nitu1305
Description
Find does this already:
https://dlang.org/phobos/std_algorithm_searching.html#.find.4
A tuple containing haystack positioned to match one of the needles and also the 1-based index of the matching element in needles (0 if none of needles matched, 1 if needles[0] matched, 2 if needles[1] matched...). The first needle to be found will be the one that matches. If multiple needles are found at the same spot in the range, then the shortest one is the one which matches (if multiple needles of the same length are found at the same spot (e.g "a" and 'a'), then the left-most of them in the argument list matches).
It would be convenient if countUntil would behave the same, but it's probably too late to change the return type, so the only way left is adding an optional out
parameter.