Variant opArithmetic

cal callumenator at gmail.com
Tue Sep 18 10:36:05 PDT 2012


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?


More information about the Digitalmars-d-learn mailing list