digitalmars.D - std.format and enums
- JC (14/14) Oct 23 2006 Here's a suggestion for improving std.format.doFormat.
Here's a suggestion for improving std.format.doFormat. Currently, std.format.doFormat throws FormatError when it encounters an enum constant as one of the arguments. It's easy for it to get the integer representation and format that instead. TypeInfo_Enum has a "base" field from which you can determine the underlying type. This should do it: // After case Mangle.Ttypedef case Mangle.Tenum: ti = (cast(TypeInfo_Enum)ti).base; m = cast(Mangle)ti.classinfo.name[9]; formatArg(fc); return; Should this be added to Phobos? In an ideal world, the enum constant's name would be available, but this seems a reasonable alternative, and is better than throwing an error.
Oct 23 2006