Templated Binary Search Tree treats class as const, compiler complains

Mark tigchelaarm at mymacewan.ca
Sun Jan 21 20:17:43 UTC 2018


Hello,

I re wrote my old BST. This one is far more complete and clean.

However, It fails my final unittest when I try to stick a class 
in as its type.

Link: https://dpaste.dzfl.pl/95e1ae49b25b

Ive done this type of thing before, but it is giving me this 
error:

BinarySearchTree.d(30): Error: function 
BinarySearchTree.BinarySearchTree!(Empty).BinarySearchTree.New 
(Empty item) is not callable using argument types (const(Empty))
BinarySearchTree.d(40): Error: function 
BinarySearchTree.BinarySearchTree!(Empty).BinarySearchTree.New 
(Empty item) is not callable using argument types (const(Empty))
BinarySearchTree.d(574): Error: template instance 
BinarySearchTree.BinarySearchTree!(Empty) error instantiating

the New method is on line 94;

I was looking through the Programming in D book, and can't find 
what this is really telling me.

I have templated Stack and queue classes that don't give me these 
errors??

How do I make the BST accept classes like the one in my test?

I don't deal with const stuff, so I'm not too sure what to look 
for concerning these problems.

I'm still looking in the book/site for answers.

Thanks!


More information about the Digitalmars-d-learn mailing list