Need way to compare classes, and primitive types in bst Template

Mark via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 8 20:32:17 PDT 2017


Ok.

So I have a BST template, and it passes my tests.

However, if you look at how I insert the data into the BST, 
you'll quickly notice the problem I have.

https://dpaste.dzfl.pl/ff58876ce213

Keep in mind I just pasted that stack in there because I use it 
in my last unittest at the bottom. It has its own file.

the method that I use is called insert, on line 79.


What Id like to do is this:

auto tree = new BSTbase!int;
...
tree.insert(7);

and

auto Tree2 = new BSTbase!Aclass;
...
Tree2.insert(Aclassobject);

What I have is:
Tree.insert(7, cast(real) 7);
and
Tree2.insert(Aclassobject, cast(real) (cast(void*) Aclassobject));

I tried a few things, but I can't get them to work.

Can anyone give a way for me to avoid doing it this clumsy way? 
The only otpion I can think of is just using inheritance, one for 
Complex Data types, and the other for primitives. But that 
defeats the purpose of having be a template (a little bit).


Thanks.


More information about the Digitalmars-d-learn mailing list