Magic type return

Andrea Fontana nospam at example.com
Tue Jul 17 07:30:07 PDT 2012


Better than nothing :)
Hope in better template deduction...

Il giorno mar, 17/07/2012 alle 16.22 +0200, Tobias Pankrath ha scritto:

> On Tuesday, 17 July 2012 at 13:56:29 UTC, Andrea Fontana wrote:
> > class Known
> > {
> >          void* data; // external data by c api
> >          int type;  // 0 for int, 1 for string, etc. ..
> > }
> >
> > How can I implement a method like this?
> >
> > Known  known;  // <-- suppose known.type == 1;
> > string s  = known.value(); // <-- automatic
> >
> > I just know how to do this:
> >
> > string s = know.value!string();
> 
> You can't. You could do
> 
> string s;
> known.value(s);
> 
> where
> 
> void value(T)(ref T t);


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20120717/f84e9456/attachment.html>


More information about the Digitalmars-d-learn mailing list