Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-09-26 12:22:06


On Sep 26, 2011, at 8:41 AM, Andrew Sutton wrote:

>> It seems to me that a clamp_range is just:
>>
>> std::transform ( begin, end, out, clamp ( _1, lo, hi ))
>>
>> is that what you meant?
>
> Sorry... this got lost in the thread. That looks like the right
> implementation, but it might be nice to provide an interface for it:
>
> template<typename Iter, typename T>
> void clamp_range(Iter first, Iter last, cont T& high, const T& low)
>
> template<typename T>
> void clamp_range(initialize_list<T> list, const T& high, const T& low);

I think that, like transform, they would need an output iterator to write into.
[ note that you can do in-place with that also, by passing "first" as the output iterator ]

-- 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