Boost logo

Boost :

Subject: Re: [boost] [Review:Algorithms] About a static clamp function
From: Ahmed Charles (ahmedcharles_at_[hidden])
Date: 2011-09-25 13:10:07


C++11 constexpr would handle the function case while also working for
user defined types. This suggests that the template version is less
generic.

My phone doesn't allow bottom posting. :( From: Vicente J. Botet Escriba
Sent: Sunday, September 25, 2011 7:13 AM
To: boost_at_[hidden]
Subject: [boost] [Review:Algorithms] About a static clamp function
Hi,

Sometimes the bound values are know at compile time. Could we ensure
that the compiler could optimize the following code

   auto res = clamp(val, 1, 100);

If this is not the case, I was wondering if it is worth adding a static
clamp function that has its bounds defined as template parameters.

   auto res = static_clamp<1,100>(val);

Best,
Vicente

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk