Subject: Re: [boost] [Review:Algorithms] Order of args to clamp
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2011-09-26 13:51:29
Le 26/09/11 13:36, Dave Abrahams a écrit :
> Note: you can solve that problem by asking the caller to do the
> conversion ;-)
I'm not sure this could always be the desired interface for the caller.
When I want to clip an 22 bit integer to a 16 bit integer, I expect the
result be a 16 bit integer. So in these cases the result type will be
the types of lo and hi.
short res= clamp(v, lo,hi);
And in this case I can not convert the 22 bits integer to a 16 bit
because I would lost some essential information.
short res= clamp(short(v), lo,hi); // not the expected behavior
That means that I will need to convert to the
short res= short(clamp(v, int(lo),int(hi)));
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk