problem with custom predicate

2015-05-27 Thread via Digitalmars-d-learn
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

Re: problem with custom predicate

2015-05-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/27/15 9:59 AM, Meta wrote: I thought unaryFun *does* work with all callables, including structs/classes with opCall? It (binaryFun actually) declares an alias. But you need an actual instance to use in this case. You simply can't declare that in a type definition, and it won't be set

Re: problem with custom predicate

2015-05-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/27/15 9:11 AM, Simon =?UTF-8?B?QsO8cmdlciI=?= simon.buer...@rwth-aachen.de wrote: 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

Re: problem with custom predicate

2015-05-27 Thread Timon Gehr via Digitalmars-d-learn
On 05/27/2015 05:30 PM, Steven Schveighoffer wrote: On 5/27/15 9:11 AM, Simon =?UTF-8?B?QsO8cmdlciI=?= simon.buer...@rwth-aachen.de wrote: 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

Re: problem with custom predicate

2015-05-27 Thread Meta via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 15:30:28 UTC, Steven Schveighoffer wrote: On 5/27/15 9:11 AM, Simon =?UTF-8?B?QsO8cmdlciI=?= simon.buer...@rwth-aachen.de wrote: 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

Re: problem with custom predicate

2015-05-27 Thread drug via Digitalmars-d-learn
On 27.05.2015 13:50, Simon Bürger simon.buer...@rwth-aachen.de wrote: 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])

Re: problem with custom predicate

2015-05-27 Thread via Digitalmars-d-learn
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

Re: problem with custom predicate

2015-05-27 Thread Meta via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 17:56:27 UTC, Steven Schveighoffer wrote: On 5/27/15 9:59 AM, Meta wrote: I thought unaryFun *does* work with all callables, including structs/classes with opCall? It (binaryFun actually) declares an alias. But you need an actual instance to use in this case.