My try so far: import std.traits: isCallable, ReturnType, arity, ParameterTypeTuple; enum arityMin0(alias fun) = __traits(compiles, fun()); // new syntax in 2.064 auto repeat(alias fun)(size_t n) if (isCallable!fun && arityMin0!fun && !is(ReturnType!fun == void)) { import std.range: iota, map; return n.iota.map!(n => fun); }