On Monday, 12 June 2017 at 19:23:10 UTC, ketmar wrote:
p.s.: while i understand the technical reason for second error message, it is still random and confusing.

I think the reason for the typeof problem is that it works with expressions, not with types (so, typeof (int) is also not valid), and the alias resolves ultimately to a type.

I actually found a workaround for the original issue:

```
enum defaultChooser(T) = function size_t(T[] queue) {
        return 0;
};

struct S(T, alias chooser = defaultChooser!int) if (is(typeof(chooser) : size_t function(T[]))) {
}

void main() {
        S!(int, defaultChooser!int) s;
}
```

This works, but strangely if I try "==" instead of ":" in the template condition, then it fails again. Honestly I don't know why it makes a difference, I guess attribute inference might be at fault... but in the version with the "static assert" I was explicitly checking them, and they apparently matched...

Also, this is just a(n ugly) workaround, and there might be side effects of using an alias parameter that I'm not aware of... and more importantly, I still think the original version should work! ;-)

Reply via email to