[Issue 9872] format should include class field values

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Apr 4 00:32:35 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9872



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2013-04-04 00:32:34 PDT ---
Workaround:

private mixin template genToString()
{
    override string toString()
    {
        import std.array;
        import std.conv;
        import std.string;

        Appender!(string[]) result;

        foreach (val; this.tupleof)
        {
            result ~= to!string(val);
        }

        return format("%s(%s)", __traits(identifier, typeof(this)), 
                                result.data.join(", "));
    }
}

class C
{
    int x, y;
    mixin genToString;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list