digitalmars.D.bugs - [Issue 7881] New: std.string.format does not support structs with no toString
- d-bugmail puremagic.com (44/44) Apr 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7881
- d-bugmail puremagic.com (12/12) Apr 09 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7881
- d-bugmail puremagic.com (11/11) Jan 24 2013 http://d.puremagic.com/issues/show_bug.cgi?id=7881
http://d.puremagic.com/issues/show_bug.cgi?id=7881 Summary: std.string.format does not support structs with no toString Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 16:02:18 PDT --- import std.string; import std.stdio; struct Foo { string name; } void main() { Foo foo; // ok writefln("%s", foo); // Can't convert test.Foo to string: "string toString()" not defined format("%s", foo); } I thought I was being clever when implementing this: void printfln(string file = __FILE__, int line = __LINE__, T...)(T t) { writefln("%s L %s - %s", file, line, format(t[0], t[1 .. $])); } It gives me a nice file+line when printing (great for debugging). Unfortunately format() fails to work in numerous cases that writef has no issues with. Anywho I can use this workaround: void printfln(string file = __FILE__, int line = __LINE__, T...)(T t) { writef("%s L %s - ", file, line); writefln(t[0], t[1 .. $]); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7881 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |DUPLICATE This issue is almost a dup of 4532. *** This issue has been marked as a duplicate of issue 4532 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 09 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7881 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|DUPLICATE |WORKSFORME 16:19:44 PST --- I'm making as WORKSFORME instead because it's fixed, the other issue is still opened. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 24 2013