|
Boost : |
Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-09-24 19:44:26
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_at_[hidden]>
A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
-- Yu Suzuki
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk