www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18051] New: missing enum support in formattedRead/unformatValue


          Issue ID: 18051
           Summary: missing enum support in formattedRead/unformatValue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > enh.d << CODE
import std.format;
enum Op { lt, gt, eq }
void main()
    auto s = format!"%s"(Op.lt);
    Op op;
    formattedRead!"%s"(s, op);
dmd -run enh.d
phobos/std/format.d(4872): Error: template std.format.unformatValueImpl cannot
deduce function from argument types !(Op)(string, const(FormatSpec!char))
enh.d(7):        instantiated from here: formattedRead!("%s", string, Op)

Formatting and unformatting should be symmetric, but currently (2.077.1) enums
are not supported by unformatValue.

Dec 09 2017