25 #ifndef XAPIAN_INCLUDED_CLAMP_CAST_H
26 #define XAPIAN_INCLUDED_CLAMP_CAST_H
35 template<
typename T,
typename U>
41 auto v = value + T{0};
42 auto min = std::numeric_limits<T>::min() +
U{0};
43 auto max = std::numeric_limits<T>::max() +
U{0};
44 return static_cast<T
>(std::clamp(v, min, max));
T clamp_cast(U value)
Cast a value to a type, clamping out of range values.