How can I save a class use the RedBlackTree?

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 3 06:26:22 PDT 2016


On Tuesday, 3 May 2016 at 12:12:04 UTC, Jonathan M Davis wrote:
> On Tue, 3 May 2016 11:37:13 +0200
> Steven Schveighoffer via Digitalmars-d-learn
> <digitalmars-d-learn at puremagic.com> wrote:
>> bleh, Object.opCmp only works with mutable objects. Which 
>> means RedBlackTree cannot work with objects because it uses 
>> inout to ensure your objects are not modified (since 2.068)
>>
>> It doesn't work with const or immutable either, the only 
>> possible solution is to go back to mutable only.
>>
>> So annoying, we need to fix Object.opCmp, or using 
>> const/immutable comparisons with objects doesn't work.
>
> Hopefully someday...
>
> https://issues.dlang.org/show_bug.cgi?id=9770
>
> - Jonathan M Davis

What's stopping us right now from making opCmp a free function in 
object.d?


More information about the Digitalmars-d-learn mailing list