
On Sep 24, 2011, at 1:58 PM, Andrew Sutton wrote:
Some quick comments about the proposed clamp() function:
template<typename V> V clamp ( V val, V lo, V hi );
Like min and max, you might consider algorithms that clamp ranges of values to a lo/hi pair. You could have clamp() that takes an initializer list and clamp_range that takes a pair of iterators. Of course, those would work in-place, so I wonder if Jefferey's suggestion for an in-place variant on a single value might also be good.
That might give some other data points for thinking about the design of the interface.
It seems to me that a clamp_range is just: std::transform ( begin, end, out, clamp ( _1, lo, hi )) is that what you meant? -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki