I'm trying to rewrite really old D code. There was fragment like that:
template Foo(T, T[] Array) {
// ...
}
// ...
Bar[] arr;
Foo!(Bar, arr);
This gives error can't read arr in compile time
. Small changes:
template Foo(T, alias T[] Array) {
// ...
}
// ...
Bar[] arr;
Foo!(Bar, arr);
This is valid D, but it doesn't work. It gives error "Error: template instance Foo!(Bar, arr)
does not match template declaration Foo(T, alias T[] Array)
".
Of course, there is some ways to avoid this error (e.g. check Array type in if), but I don't undestand why this code doesn't compiles.