[Issue 21168] New: std.utf.decode front/back should be able to decode using enum character types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Aug 16 13:44:52 UTC 2020


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

          Issue ID: 21168
           Summary: std.utf.decode front/back should be able to decode
                    using enum character types
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

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).

--


More information about the Digitalmars-d-bugs mailing list