Universel toString

Daniel Keep daniel.keep.lists at gmail.com
Fri Mar 20 02:04:40 PDT 2009



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.

  -- Daniel


More information about the Digitalmars-d-learn mailing list