Boost logo

Boost :

Subject: Re: [boost] Small contribution to algorithm library: clamp function
From: Marshall Clow (mclow.lists_at_[hidden])
Date: 2011-02-23 09:35:06


On Feb 22, 2011, at 11:54 PM, Тимофей Игнатьич wrote:

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

I have one in my (soon to be proposed) Boost.Algorithm library.
Interesting that you were successful at uploading to the vault. I have been stymied by that :-( ]

Here's my version - it appears to be basically the same as yours. ;-)

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