D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1487 - toString(string) and toString(Object)
Summary: toString(string) and toString(Object)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-09 13:41 UTC by Neia Neutuladh
Modified: 2015-06-09 01:31 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Neia Neutuladh 2007-09-09 13:41:39 UTC
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 Andrei Alexandrescu 2010-09-25 15:41:40 UTC
std.conv has settled this a while ago.