www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to read from an input stream generically?

What can I use instead of the din.readf line below to be able to read 
any type in that generic function?

import std.cstream;

struct MyType

void generic(T)()
     T var;
     dout.writef("Please enter a value of type %s: ", T.stringof);

     din.readf(&var);  // <-- Runtime ERROR for MyType

void main()

I am looking for a substitute for C++'s operator>> overloads for user 
types. I could of course implement a static read(Stream) function for my 
types, but not for the fundamental types.

Thank you,
Feb 24 2010