I'm trying to write a thin wrapper around redblacktree, but it
seems every object of the class shares the same copy of
redblacktree. Am I doing something wrong or is this a bug.
Minimal code example:
import std.array;
import std.container;
import std.stdio;
class A {
auto tree = new RedBlackTree!string();
}
unittest {
auto a = new A();
a.tree.insert( "a" );
auto b = new A();
writeln( "Should be empty, but is: ", b.tree.array );
writeln( "Should be empty, but has length: ", b.tree.length );
}
Which results in the following output:
$ rdmd -unittest rbt.d
Should be empty, but is: ["a"]
Should be empty, but has length: 1
I'm using dmd 2.0.65.