Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2011-09-26 06:59:31
Christian Holmquist wrote:
> Since std::min/max takes one type (for good reasons), I don't see why clamp
> all of a sudden should be different.
Because it's faster.
> I would go for something like this...
> template<class T>
> T const & clamp(T const& x, T const& lo, T const &hi)
> return std::min(std::max(x, lo), hi);
That does an extra unnecessary comparison in the case when x < lo.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk