Bug 21168 – std.utf.decode front/back should be able to decode using enum character types

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-16T13:44:52Z
Last change time
2024-12-01T16:37:29Z
Assigned to
No Owner
Creator
Steven Schveighoffer
Moved to GitHub: phobos#10434 →

Comments

Comment #0 by schveiguy — 2020-08-16T13:44:52Z
Came across this while working on removing autodecoding. If you have an enum that derives from char (this comes from std.algorithm.comparison): enum EditOp : char { none = 'n', substitute = 's', insert = 'i', remove = 'r' } Then isSomeChar!EditOp is true. However, EditOp[].byDchar does not work, because decodeFront cannot handle EditOp. The reason is because the decodeImpl return structure is hard coded to only accept char, wchar, or dchar EXACTLY. Instead it should accept any range that has a character element type, and check the size of the character to ensure it works (this is purely a template constraint problem, the code works fine once you fix it).
Comment #1 by robert.schadek — 2024-12-01T16:37:29Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10434 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB