Variadic function not recognizing static array length
Zach the Mystic
reachzach at gggggmail.com
Tue Mar 12 14:47:00 PDT 2013
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?
More information about the Digitalmars-d-learn
mailing list