xxxxxxxxxx
struct s // maybe more specific?
{
import std.traits : CommonType;
static CommonType!Args[Args.length] opIndex(Args...)(auto ref Args args)
if (!is(CommonType!Args == void))
{
import std.functional : forward;
return [ forward!args ];
}
}
struct NoCopy
{
this(this);
int x;
}
void main()
{
auto intArray = s[1, 2, 3];
static assert(is(typeof(intArray) == int[3]));
auto noCopyArray = s[ NoCopy(1), NoCopy(2) ];
static assert(is(typeof(noCopyArray) == NoCopy[2]));
}