[Issue 21512] RedBlackTree!Tid treats any values as duplicated except for Tid.init

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 2 14:22:21 UTC 2021


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

Berni44 <bugzilla at bernis-buecher.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at bernis-buecher.de

--- Comment #1 from Berni44 <bugzilla at bernis-buecher.de> ---
What happens is: to!string calls formatValue in std.format with a const(Tid), 
but hasToString in std.format fails to detect Tid's toString, because of the
constness and thus uses its generic struct handler which always produces the
same for all Tids. (Tid.init has a null pointer which is handled special and
therefore produces a different result.)


So it boils down to the following should be compilable:

const(Tid) val = void;
val.toString((scope const(char)[] s){});


A workaround is to define lessTid a little bit different:

alias lessTid = (in Tid a, in Tid b) => (cast() a).to!string < (cast()
b).to!string;

--


More information about the Digitalmars-d-bugs mailing list