On Monday, 8 June 2020 at 07:35:12 UTC, adnan338 wrote:
Self* searchTree(this Self)(auto in ref T item) const { if (&this is null) return null; if (this.item == item) return &this; return (this.item < item) ? this.right.searchTree(item) : this.right.searchTree(item); }
This method is const, which means 'this' is const, while Self is not. What you're looking for here is inout (https://dlang.org/spec/function.html#inout-functions):
auto searchTree()(auto in ref T item) inout { if (&this is null) return null; if (this.item == item) return &this; return (this.item < item) ? this.right.searchTree(item) : this.right.searchTree(item); } -- Simen