Re: casting from variant

2012-08-05 Thread cal
On Sunday, 5 August 2012 at 18:04:41 UTC, Philippe Sigaud wrote: On Sun, Aug 5, 2012 at 6:34 PM, cal wrote: Variant j; j = 1.0; // make it a double auto x = cast(float)(j.get!(double)()); // fine auto y = cast(float)x; // fine Ah thanks!, I didn't even think of that. Btw, std.variant.Va

Re: casting from variant

2012-08-05 Thread Philippe Sigaud
On Sun, Aug 5, 2012 at 6:34 PM, cal wrote: >> Variant j; >> j = 1.0; // make it a double >> auto x = cast(float)(j.get!(double)()); // fine >> >> auto y = cast(float)x; // fine > > > Ah thanks!, I didn't even think of that. Btw, std.variant.Variant also offers a `.coerce` method: auto x = j.coe

Re: casting from variant

2012-08-05 Thread cal
On Sunday, 5 August 2012 at 06:31:37 UTC, Philippe Sigaud wrote: On Sun, Aug 5, 2012 at 5:40 AM, cal 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

Re: casting from variant

2012-08-04 Thread Philippe Sigaud
On Sun, Aug 5, 2012 at 5:40 AM, cal 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