Practice ยท 2 of 2
Function template: clamp_to
Implement template <typename T> T clamp_to(const T& v, const T& lo, const T& hi) returning v bounded into [lo, hi]. Contract: T supports operator<. Must work for int and double.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Function template practice