Perhaps I missed somewhere, but it seems that you can pass only classes or interfaces to alias argument of a template. Trying to pass another type (such as int, int[]) yields an error.

Example of issue:
------------------------
void test(alias T)(int o) {
    import std.stdio;
    writeln("coo");
}

void main() {
    int i;
    test!(Object[])(0);
}
------------------------

Try pass Object or IFoo and everything compiles perfectly.
Link to example: https://run.dlang.io/is/jqr9Zi

According to https://dlang.org/spec/template.html#TemplateAliasParameter, simple types and arrays are excluded from the list of supported "alias X" arguments. I'm wondering why do we have such limitation? Is there any reasoning at limiting primitive types and arrays?

Thank you,
Alexandru.

Reply via email to