
On Sep 27, 2011, at 7:34 AM, Steven Watanabe wrote:
On 09/27/2011 07:23 AM, Gordon Woodhull wrote:
On Sep 26, 2011, at 2:17 PM, TONGARI <tongari95@gmail.com> wrote:
2011/9/27 Peter Dimov <pdimov@pdimov.com>
Then clamp should be
template<class T> T clamp( T const & value, typename identity<T>::type const & low, typename identity<T>::type const & high );
I second this. BTW, The return type could be T const&.
Okay, I'll bite. Why identity and not just T?
(I thought this might be a joke at first.)
Using identity means that T is deduced solely based on the first argument.
A couple of interesting results that I found playing around this morning namespace ba = boost::algorithm; short foo = 50; BOOST_CHECK_EQUAL ( 56, ba::clamp ( foo, 56.9, 129 )); BOOST_CHECK_EQUAL ( 24910, ba::clamp ( foo, 12345678, 123456999 )); -- Marshall Marshall Clow Idio Software <mailto:mclow.lists@gmail.com> A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait). -- Yu Suzuki