Bug 1487 – toString(string) and toString(Object)

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-09-09T13:41:00Z
Last change time
2015-06-09T01:31:13Z
Assigned to
andrei
Creator
dhasenan

Comments

Comment #0 by dhasenan — 2007-09-09T13:41:39Z
For convenience, std.string should provide toString overloads that accept char[], const(char)[], and Object. Currently, for generic template code, you have to do the following: --- import std.string; alias std.string.toString toString; string toString(Object o) { return (o ? o.toString : "null"); } string toString(string s) { return s; } template (T) { T t; // ... toString(t); } ---
Comment #1 by andrei — 2010-09-25T15:41:40Z
std.conv has settled this a while ago.