findSplitAmong

Like findSplit but with multiple separator needles known at compile-time to prevent NarrowString decoding.

TODO Do sentinel-based search when haystack is mutable and larger than a certain value.

TODO Add to Phobos.

TODO Resort to memchr for some case if (!__ctfe).

template findSplitAmong(needles...)
@trusted
findSplitAmong
(
Haystack
)
(
const scope return Haystack haystack
)
if (
is(typeof(Haystack.init[0 .. 0])) &&
is(typeof(Haystack.init[0]) : char)
&&
allSatisfy!(isASCII, needles)
)
if (
needles.length != 0 &&
isExpressions!needles
)

See Also

Meta