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
the idea is to prevent conversion to float with ofMin/Max (and maybe applicable to other) for the benefit of end users that mix/match types (typically floats (as returned by many OF functions), double (as dotted-decimals are interpreted in C++ source code) and int, also as textual interpretations).
comparing different types is not evident, especially when unsigned is thrown in (I guess that's why std::min does not attempt it, but our use case is probably defined enough to tackle in a specific way).
the logic:
if the args are same time, simply pass to std::min (which accepts anything that operates on <)
if args are different, find the std::common_type, then
if one of the members is size_t or uint64_t, treat it differently (there is no common type that can hold both uint64_t and anything signed, for instance, and it's undefined behaviour (no throw)) but in our case we don't need to return as such a common type as in the context of getting the minimum, the "result" will not be in the high uint64_t range (implicit, as the other arg is not size_t, it will be smaller).
if signed vs unsigned, check if the signed is < 0 before attempting cast of the "other" to prevent overflow of negatives.
from #7918
the idea is to prevent conversion to float with ofMin/Max (and maybe applicable to other) for the benefit of end users that mix/match types (typically floats (as returned by many OF functions), double (as dotted-decimals are interpreted in C++ source code) and int, also as textual interpretations).
comparing different types is not evident, especially when unsigned is thrown in (I guess that's why std::min does not attempt it, but our use case is probably defined enough to tackle in a specific way).
the logic:
The text was updated successfully, but these errors were encountered: