Variant opArithmetic

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Sep 18 12:03:15 PDT 2012


On 9/18/12 1:36 PM, cal wrote:
> Variant tries to mimic D's built-in rules for arithmetic conversions but:
>
> import std.variant, std.stdio;
> void main()
> {
> auto v1 = Variant(4.5f);
> auto v2 = Variant(3.5f);
> writeln((v1+v2).type()); // double
> }
>
> The reason is Variant doesn't try to convert to float in opArithmetic
> (it's is easily fixed). But is it intentional?

I wrote this:

     writeln(typeof(4.5f + 3.5f).stringof);

To my surprise, the reported type was float, not double. Well that means 
it's a bug in Variant, could you please make a bug report (and hopefully 
a pull request fixing it)?


Thanks,

Andrei


More information about the Digitalmars-d-learn mailing list