Why D is annoying =P
Ellery Newcomer
ellery-newcomer at utulsa.edu
Thu Oct 25 18:34:32 PDT 2012
On 10/24/2012 01:16 PM, Mehrdad wrote:
> On Wednesday, 24 October 2012 at 20:03:44 UTC, H. S. Teoh wrote:
>> What's wrong with RedBlackTree? You can just do something like:
>>
>> RedBlackTree!(RedBlackTree!MySet) setOfSets;
>
>
> The last time I checked two RedBlackTrees for equality, they seemed to
> have reference semantics...
>
Dang.
import std.container;
import std.stdio;
void main() {
auto a = make!(RedBlackTree!int)(1,2,3,4);
auto b = make!(RedBlackTree!int)(1,2,3,4);
writeln(a == b);
}
prints
false
Explanation: RedBlackTree doesn't override opEquals. Either file an
enhancement request or use equal(a[], b[]), depending on whether
opEquals *should* have reference semantics.
Actually, it shouldn't, since that would differ from array/string
opEquals semantics.
SList works
Array works
Oop. DList goes into infinite loop. Dibs on this bug report.
More information about the Digitalmars-d
mailing list