problem with custom predicate

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 08:11:48 PDT 2015


On Wednesday, 27 May 2015 at 14:58:39 UTC, drug wrote:

> Do you want to dynamically change priority?
Actually yes. In my actual code I am not using a RedBlackTree but 
my own Container (a heap with the possibility to modify elements 
inside), which is notified when prio changes so it can do a 
(local) reordering.

> Why prio is outside of your predicate?
Well, how would I get it into the lambda? In C++ I would use a 
comparision class, and the constructor of the container would 
take an instance of that class. But D's RedBlackTree-constructor 
does not take such a (run-time) argument. And I dont see a way to 
get prio into the predicate, which is a template-argument.

As I am implementing my own container anyway, I could of course 
do it the C++-way. But I was wondering if there is another way.


More information about the Digitalmars-d-learn mailing list