Merge branch 'dev' into wifi_int8_prio

This commit is contained in:
J. Nick Koston
2025-11-11 08:33:57 -06:00
committed by GitHub

View File

@@ -1174,12 +1174,18 @@ template<class T> using ExternalRAMAllocator = RAMAllocator<T>;
* Functions to constrain the range of arithmetic values.
*/
template<std::totally_ordered T> T clamp_at_least(T value, T min) {
template<typename T, typename U>
concept comparable_with = requires(T a, U b) {
{ a > b } -> std::convertible_to<bool>;
{ a < b } -> std::convertible_to<bool>;
};
template<std::totally_ordered T, comparable_with<T> U> T clamp_at_least(T value, U min) {
if (value < min)
return min;
return value;
}
template<std::totally_ordered T> T clamp_at_most(T value, T max) {
template<std::totally_ordered T, comparable_with<T> U> T clamp_at_most(T value, U max) {
if (value > max)
return max;
return value;