[Issue 4266] add support for structs in std.format.doFormat
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jun 3 14:42:24 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4266
--- Comment #1 from Trass3r <mrmocool at gmx.de> 2010-06-03 14:42:23 PDT ---
This is an (inefficient) workaround, but it does its job until this is fixed.
import std.string : format;
string myformat(T...)(T ts)
{
string res;
foreach (t; ts)
{
static if (is (typeof(t) U : U*) && !is(U == void)) // is a pointer
{
res ~= myformat(*t);
}
else static if (is (typeof(t) == struct))
{
res ~= "{";
foreach(i, el; t.tupleof)
{
res ~= t.tupleof[i].stringof[2..$] ~ ":" ~ myformat(el); // the
slice cuts off the "t." that is always prepended
static if (i < t.tupleof.length-1)
res ~= ", ";
}
res ~= "}";
}
else
res ~= format(t);
}
return res;
}
--
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