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);