Overriding to!string on enum types
monarch_dodra via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 2 08:47:38 PDT 2014
On Tuesday, 2 September 2014 at 15:41:17 UTC, monarch_dodra wrote:
> Unless we allow defining "enum-member functions", AFAIK, it is
> impossible to override the printing behavior for enums...
... If your enum actually represents strings, then you could:
enum CxxRefQualifier : string
{
none = "",
normalRef = "&",
rvalueRef = "&&",
}
That in itself is not enough, but you *can* cast your enum to
string, and then print that, or pass that.
See also:
https://issues.dlang.org/show_bug.cgi?id=11571
More information about the Digitalmars-d-learn
mailing list