You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I agree that ++ and -- do not have much sense for floating-point representations but those operations are defined for a floating-point number. So if the following works:
double length = 3;
++length;
I think it should work as well for a safe type:
quantity<metre, double> length(3);
++length; // should also work
Also it has benefits from a generic point of view:
Quantity foo(Quantity auto q)
{
return ++q;
}
The user should not be forced to check what is the Rep there.
Basically, if we do not provide those operators users will have to use += 1 in a generic code which basically is the same wrong for a floating-point number and we probably do not want to ban it too ;-)
I think generic programming is a fine argument for why these operator should be left.
Maybe we should add this to the paper in a section titled: Supported Operations and Representations?
Should
operator++
andoperator--
be disabled for floating point representations? Also, as foroperator%
, how should these operations be disabled?The text was updated successfully, but these errors were encountered: