Could templates in std.algorithm be expanded to have an optional thread-count compile-time argument? Maybe they'd be used like so:
import std.stdio; import std.array; import std.range; import std.functional; enum Threads { x1 = 1, x2 = 2, x3 = 3, x4 = 4, // etc.. } void main() { int[] data = [1, 2, 3]; count!("a < 0", Threads.x4)(data); } size_t count(alias pred = "true", alias th = Threads.x1, Range)(Range r) if (isInputRange!(Range)) { static if (th == Threads.x1) { // call normal count } else { // call parallel count } return -1; }