sort using delegate as predicate

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 16 10:02:08 PDT 2014


On Tue, 16 Sep 2014 16:38:04 +0000, Simon Bürger wrote:
> 
>> sort!((a,b) => f.cmp(a, b))(data);
> 
> does in fact compile, so i guess problem is solved. Thanks guys.

Yes, this compiles because the lambda forms a closure over f.  In some 
respects this might even be better than the C++ as there is the 
possibility for inlining because the lambda literal is passed by alias.


More information about the Digitalmars-d-learn mailing list