Universel toString

grauzone none at example.net
Fri Mar 20 02:15:55 PDT 2009


Daniel Keep wrote:
> 
> Qian Xu wrote:
>> Hi All,
>>
>> I want to write an universel toString() method for debugging propose.
>> However I cannot write in one version. The compiler says error all the time.
>> Could someone tell me, how to write an universel one?
>>
>> What I want, is to convert primtive types (int, int*, bool, bool*, etc.) to
>> string using "tango.text.Convert.to()" and convert object to string by
>> calling obj.toString.
>>
>> ...
>>
>> Best regards
>> --Qian Xu
> 
> to!(char[]) should call toString.  to!(T) should support all atomic
> types, strings, structs and classes.

So to!(char[])(x) almost like format("%s", x)?

>   -- Daniel


More information about the Digitalmars-d-learn mailing list