How do i use std.functional.binaryFun?
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 8 17:17:46 PST 2014
On Monday, 8 December 2014 at 20:08:35 UTC, Gary Willoughby wrote:
> import std.stdio;
> import std.functional;
>
> class Foo(T, alias greater = "a > b") if
> (is(typeof(binaryFun!(greater)(T.init, T.init)) == bool))
> {
> private alias compare = binaryFun!(greater);
>
> public this()
> {
> writefln("%s", this.compare(2, 1));
> }
> }
>
> void main(string[] args)
> {
> auto foo = new Foo!(int, "a < b"); // Works
>
> auto bar = new Foo!(int, delegate(int a, int b){ return a > b;
> }); // Linker error.
> }
Looks like a compiler bug.
A call without "this." works. When you insert a call without
"this.", other calls with "this." work, too.
A delegate with an implicit parameter type works: `Foo!(int,
delegate(int a, /*!*/ b){ return a > b;})`.
More information about the Digitalmars-d-learn
mailing list