Exception thrown when Bound values overflows or underflows.
TODO: Use boundness policy.
TODO: use this.
Check if type T can wrapped in a Bounded.
Check if expression expr is a compile-time-expression that can be used as a Bound.
Check if the value of expr is known at compile-time.
Calculate absolute value of a.
TODO: Can D do better than C++ here? Does this automatically deduce to CommonType and if so do we need to declare it? Or does it suffice to constructors?
Calculate Maximum. TODO: variadic.
Calculate Minimum. TODO: variadic.
Return x with automatic packed saturation. * * If packed optimize storage for compactness otherwise for speed.
Return x with automatic packed saturation.
Value of type V bound inside inclusive range [low, high].
Get type that can contain the inclusive bound [low, high]. If packed optimize storage for compactness otherwise for speed. If signed use a signed integer.
Instantiate \c Bound from a single expression expr.
Instantiator for \c Bound.
http://en.wikipedia.org/wiki/Interval_arithmetic
https://bitbucket.org/davidstone/bounded_integer
http://stackoverflow.com/questions/18514806/ada-like-types-in-nimrod
http://forum.dlang.org/thread/xogeuqdwdjghkklzkfhl@forum.dlang.org#post-rksboytciisyezkapxkr:40forum.dlang.org http://forum.dlang.org/thread/lxdtukwzlbmzebazusgb@forum.dlang.org#post-ymqdbvrwoupwjycpizdi:40forum.dlang.org http://dlang.org/operatoroverloading.html
TODO: Test with geometry.Vector or geometry.Point
TODO: Make stuff @safe pure @nogc and in some case nothrow
TODO: Implement overload for conditional operator p ? x1 : x2 TODO: Propagate ranges in arithmetic (opUnary, opBinary, opOpAssign): - Integer: +,-,*,^^,/ - FloatingPoint: +,-,*,/,^^,sqrt,
TODO: Should implicit conversions to un-Bounds be allowed? Not in https://bitbucket.org/davidstone/bounded_integer.
TODO: Merge with limited TODO: Is this a good idea to use?: import std.meta; mixin Proxy!_t; // Limited acts as V (almost). invariant() { enforce(_t >= low && _t <= high); wln("fdsf");
TODO: If these things take to long to evaluted at compile-time maybe we need to build it into the language for example using a new syntax either using - integer(range:low..high, step:1) - int(range:low..high, step:1) - num(range:low..high, step:1)
TODO: Use V saveOp(string op, V)(V x, V y) pure @save @nogc if(isIntegral!V && (op=="+" || op=="-" || op=="<<" || op=="*")) { mixin("x "~op~"= y"); static if(isSigned!V) { static if(op == "*") { asm naked { jnc opok; } } else { asm naked { jno opok; } } x = V.min; } else // unsigned { asm naked { jnc opok; } x = V.max; } opok: return x; }
TODO: Reuse core.checkedint
TODO: Move to Phobos std.typecons
Per Nordlöw 2022-.
Bounded arithmetic wrapper type, similar to Ada's range/interval types.