<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.2.2">
</HEAD>
<BODY>
Better than nothing :)<BR>
Hope in better template deduction...<BR>
<BR>
Il giorno mar, 17/07/2012 alle 16.22 +0200, Tobias Pankrath ha scritto:
<BLOCKQUOTE TYPE=CITE>
<PRE>
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);
</PRE>
</BLOCKQUOTE>
<BR>
</BODY>
</HTML>