This is the mail archive of the
mailing list for the GCC project.
Re: [libstdc++] Add C++17clamp
- From: NightStrike <nightstrike at gmail dot com>
- To: Ed Smith-Rowland <3dw4rd at verizon dot net>
- Cc: "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>, Jonathan Wakely <jwakely at redhat dot com>
- Date: Thu, 21 Jul 2016 19:38:00 -0400
- Subject: Re: [libstdc++] Add C++17clamp
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org>
On Thu, Jul 14, 2016 at 7:50 PM, Ed Smith-Rowland <email@example.com> wrote:
> Here is an implementation of P0025
> An algorithm to "clamp" a value between a pair of boundary values.
> Testing is almost finished - looks good so far.
> OK if testing passes?
> I didn't see a feature test in any of the SD-6 papers or P0025.
This is not an efficient implementation. See here:
Which I derived from this SO answer (which is sadly not the accepted
answer at this time):
I suggest using the very efficient method that requires a temporary.