casting from variant

cal callumenator at gmail.com
Sun Aug 5 09:34:55 PDT 2012


On Sunday, 5 August 2012 at 06:31:37 UTC, Philippe Sigaud wrote:
> 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

Ah thanks!, I didn't even think of that.



More information about the Digitalmars-d-learn mailing list