Skip to main content

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

Back to lesson: Practice: Function template practice