problem with custom predicate

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 06:50:01 PDT 2015


I am trying to use a Container class with a custom predicate, but 
the following code does not compile. Any hints on how to do it?

import std.container;

class C
{
     int[] prio;
     RedBlackTree!(int, (a,b)=>prio[a]<prio[b]) tree;
}

I think I understand the reason why this does not work (the 
lambda cannot access the 'this' to get to 'prio'), but I can't 
think of a way to make it work. Any Ideas?




More information about the Digitalmars-d-learn mailing list