There is an issue when passing a delegate as an class alias template parameter to be used with std.functional.binaryFun. Look at this code: import std.stdio; import std.functional; class Foo(T, alias greater = "a > b") { private alias compare = binaryFun!(greater); public this() { writefln("%s", compare(2, 1)); } } void main(string[] args) { // These work: auto foo1 = new Foo!(int, "a > b"); auto foo2 = new Foo!(int, (a, b) => a > b); auto foo4 = new Foo!(int, delegate(a, b){return a > b;}); // The following works when the delegate method is called without 'this.' // otherwise they generate linker Errors: auto foo3 = new Foo!(int, (int a, int b) => a > b); auto foo5 = new Foo!(int, delegate(int a, int b){return a > b;}); } If i remove the 'this.' from the compare method call, all works fine. After that call, i can call compare *with* 'this.' and all works. But there has to be an initial call made without the 'this.' for it to work from then on. If i leave the 'this.' in place and pass a delegate as the compare function using types in the parameter list, a linker error occurs when calling the delegate.
Changing the compare call to this: writefln("%s", this.compare(2, 1)); Exhibits the linker error.
https://github.com/D-Programming-Language/dmd/pull/4267
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f3556d65281bf7383a36759e7153f5accd645b32 fix Issue 13843 - Issue when passing a delegate as an class alias template parameter https://github.com/D-Programming-Language/dmd/commit/93986fd3ff4e43fa3dc06495095c4e8eccb15eea Merge pull request #4267 from 9rnsr/fix13843 Issue 13843 - Issue when passing a delegate as an class alias template parameter
Commits pushed to 2.067 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f3556d65281bf7383a36759e7153f5accd645b32 fix Issue 13843 - Issue when passing a delegate as an class alias template parameter https://github.com/D-Programming-Language/dmd/commit/93986fd3ff4e43fa3dc06495095c4e8eccb15eea Merge pull request #4267 from 9rnsr/fix13843