Bug 18634 – std.container.rbtree does not work with delegate comparators
Status
RESOLVED
Resolution
FIXED
Severity
trivial
Priority
P5
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-03-19T22:21:31Z
Last change time
2018-03-21T22:54:10Z
Assigned to
No Owner
Creator
viktor.ivanov
Comments
Comment #0 by viktor.ivanov — 2018-03-19T22:21:31Z
The RedBlackTree does not work with delegate comparators due to RedBlackTree.opEquals() forcing a function when doing the equality comparison.
The following test shows the issue:
import std.algorithm.comparison : equal;
auto t = new RedBlackTree!(int, delegate (a, b) => a > b);
t.insert([1, 3, 5, 4, 2]);
assert(t[].equal([5, 4, 3, 2, 1]));