casting from variant

Philippe Sigaud philippe.sigaud at gmail.com
Sat Aug 4 23:31:26 PDT 2012


On Sun, Aug 5, 2012 at 5:40 AM, cal <callumenator at gmail.com> wrote:
> In the following code:
>
> Variant j;
> j = 1.0; // make it a double
> auto x = cast(float)(j.get!(double)); // fail: cannot cast j.get!(double)
> auto y = cast(float)x; // fine

I think it's a property-like problem: you need () after .get!()
I had this problem a few days ago.


Variant j;
j = 1.0; // make it a double
auto x = cast(float)(j.get!(double)()); // fine
auto y = cast(float)x; // fine


More information about the Digitalmars-d-learn mailing list