Bug 15941 – [REG v2.069] rbtree no longer supports classes
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-04-20T15:48:00Z
Last change time
2016-06-18T12:31:48Z
Keywords
pull
Assigned to
schveiguy
Creator
jbc.engelen
Comments
Comment #0 by jbc.engelen — 2016-04-20T15:48:46Z
```
class A {}
RedBlackTree!(A, "cast(void*)a < cast(void*)b") tree;
```
This used to work, but now no longer works because of the addition of rbtree.toString.
With a nice instantiation error:
/Library/D/dmd/src/phobos/std/format.d(2916): Error: template instance std.format.formatObject!(void delegate(const(char)[]), const(A), char) does not match template declaration formatObject(Writer, T, Char)(ref Writer w, ref T val, ref FormatSpec!Char f) if (hasToString!(T, Char))
/Library/D/dmd/src/phobos/std/format.d(2649): Error: template instance std.format.formatValue!(void delegate(const(char)[]), const(A), char) error instantiating
/Library/D/dmd/src/phobos/std/format.d(2435): instantiated from here: formatElement!(void delegate(const(char)[]), const(A), char)
/Library/D/dmd/src/phobos/std/format.d(3142): instantiated from here: formatRange!(void delegate(const(char)[]), RBRange!(const(RBNode!(A))*), char)
/Library/D/dmd/src/phobos/std/container/rbtree.d(1679): instantiated from here: formatValue!(void delegate(const(char)[]), RBRange!(const(RBNode!(A))*), char)
/Users/johan/ldc/johan/ddmd/root/array.d(217): instantiated from here: RedBlackTree!(A, "cast(void*)a < cast(void*)b", false)
This is really a problem with Object.toString not working by default for const objects. I will try and make code that optionally adds toString if it can toString each element, this should work once we fix the issue with Object.