Ada-Style Range Types with Value Range Propagation in Arithmetic

"Nordlöw" per.nordlow at gmail.com
Wed Mar 19 15:15:07 PDT 2014


> Ideas anyone?

I cracked it:


     auto opBinary(string op, U,
                   string file = __FILE__,
                   int line = __LINE__)(U rhs)
     {
         static if (is(U == Bound))
         {
             alias C = CommonType!(T, U.type);
             Bound!(C,
                    cast(C)min + cast(C)U.min,
                    cast(C)max + cast(C)U.max) tmp = void; // 
TODO: Needs fix
         }
         else
         {
             CommonType!(T, U) tmp = void;
         }
         mixin("tmp = _value " ~ op ~ "rhs;");
         mixin(check());
         return tmp;
     }


More information about the Digitalmars-d-learn mailing list