[Issue 12702] New: [FixIncluded] std.container.RedBlackTree's in operator is not const

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun May 4 19:47:57 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=12702

          Issue ID: 12702
           Summary: [FixIncluded] std.container.RedBlackTree's in operator
                    is not const
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: Phobos
          Assignee: nobody at puremagic.com
          Reporter: markisaa at umich.edu

Created attachment 1353
  --> https://issues.dlang.org/attachment.cgi?id=1353&action=edit
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.

--


More information about the Digitalmars-d-bugs mailing list