<p><br>
> Now what remains is to retstrict create to only take a fun with *no* input arguments and a non-void return.<br>
><br>
> How do I do that?</p>
<p>With a template contraint.<br>
Not tested:</p>
<p>import std.traits: isCallable, ParameterTypeTuple, ReturnType;</p>
<p>auto create(alias fun)(size_t n)<br>
if (isCallable!fun && ParameterTypeTuple!(fun).length == 0<br>
&& !is(ReturnType!fun == void))<br>
{<br>
import std.range: iota, map;<br>
return n.iota.map!(n => fun);<br>
}<br>
</p>