
23 Feb
2011
23 Feb
'11
7:54 a.m.
I wasn't able to find a clamp function in boost so i submitted my version for discussion and refinement here: http://www.boostpro.com/vault/index.php?&direction=0&order=&directory=Algorithms (file clamp.hpp) Summary: clamp(a, x, b) Effect: if (x < a) returns a, otherwise if (b < x) returns b, otherwise returns x. clamp(a, x, b, comp) clamp<comp>(a, x, b) Effect: if comp(x, a) returns a, otherwise if comp(b, x) returns b, otherwise returns x. Let me know what you think. Maybe i was wrong and such function does already exist within boost?