On Tue, 12 Mar 2013 17:47:00 -0400, Zach the Mystic
<[email protected]> wrote:
void func(string[2] a) {}
void func2(T...)(T args) {
static assert(is(typeof(args[0]) == string[2]));
}
void func3(T...)(T args) {
static assert(args[0].length == 2);
}
func(["",""]); // Okay
func2(["",""]); // Error: (is(string[] == string[2LU])) is false
func3(["",""]); // Error: _param_0 cannot be read at compile time
Is this the intended design? Is there a workaround which allows me to
ensure that the parameter is exactly 2 length?
Actually an array literal's default type is a slice, not a fixed-sized
array. With IFTI, the type is decided by the call, not how you use it the
parameters.
I filed an enhancement request a while back that would help fix this.
http://d.puremagic.com/issues/show_bug.cgi?id=4998
-Steve