Function Templates
A function written for any type.
Easy
template <typename T> T clamp_to(T v, T lo, T hi) { return v < lo ? lo : v > hi ? hi : v; }
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.