| 108 | */ |
| 109 | template <typename DataType, typename RangeType = DataType> |
| 110 | inline DataType clamp(const DataType &n, |
| 111 | const DataType &lower = std::numeric_limits<RangeType>::lowest(), |
| 112 | const DataType &upper = std::numeric_limits<RangeType>::max()) |
| 113 | { |
| 114 | return std::max(lower, std::min(n, upper)); |
| 115 | } |
| 116 | |
| 117 | /** Base case of for_each. Does nothing. */ |
| 118 | template <typename F> |
no test coverage detected