Created attachment 1353
std.container with the indicated changes
The "in" operator for std.container.RedBlackTree is not const. This seems inappropriate as it is only performing a 'checking' operation. The operation is semantically const, but this is not expressed in the definition.
When I examine the code I also see no obvious reason why the current implementation cannot be happily adorned with const. I attempted an implementation myself and it seems to work properly and passes the existing unit tests.
List of changes:
1) opBinaryRight "in" is now const.
2) _find is now inout and has its return type automatically deduced.
3) Local variables in _find are now declared with auto.
4) The getter left, right, and parent properties of RBNode are now inout and return inout(RBNode)*.
I believe that was everything. A copy of std.container with my alterations (I also removed the module line at the top for testing) is attached.
Comment #1 by markisaa — 2014-05-05T03:54:57Z
It would seem that the other querying methods: equalRange, lowerBound, upperBound (and quite a few others, like front) are also missing const correctness. I attempted a fix for that as well but that seems to be a bit over my head. Perhaps I'll find time to try my hand at a more thorough solution later in the week.
Comment #2 by andrej.mitrovich — 2014-05-05T09:47:37Z
Could you create a pull request for these? It would be welcome!
Comment #3 by markisaa — 2014-05-05T20:36:10Z
(In reply to Andrej Mitrovic from comment #2)
> Could you create a pull request for these? It would be welcome!
Cool. When I saw that just about everything else in that module was not const-correct I thought it may have been an intentional decision. I will probably work on this later in the week and try and provide a more complete/better styled pull request then.