[Issue 14931] switch doesn't work with any pointers

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 19 00:45:28 PDT 2015


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

--- Comment #10 from yebblies <yebblies at gmail.com> ---
(In reply to Walter Bright from comment #9)
> The only thing you can do is have two tables. The first is a table of
> pointer values, upon which a binary search is done to convert the switch
> expression into an integer. Then use the integer to index into the second
> table of jump addresses.
> 
> Of course, you can do this manually in conventional D anyway, and get just
> as good results.

Wouldn't you need to sort the pointer list at runtime?

--


More information about the Digitalmars-d-bugs mailing list