On Tuesday, 4 December 2012 at 12:48:57 UTC, bearophile wrote:
Era Scarecrow:

So then in theory

Variant v;
int i = v.getValue; //calls getValue!int()

 Meant it to be long i, but the idea is the same.


I think this is not possible in D.

This seems possible:
auto i = v.getValue!int;

Indeed... it was just a thought, with that you could remove certain requirements for overriding opCast, and might handle implicit casting... actually that makes sense, allowing for a limited number of types you want it to automatically change to rather than using 'alias this' to subtype it.

It also doesn't seem like it would be difficult to add, only 'auto' would cause any real errors (as it's not a known type it can return).

Reply via email to