]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Implement std::clamp with std::min and std::max [PR 96733]
authorJonathan Wakely <jwakely@redhat.com>
Sat, 17 Apr 2021 21:34:09 +0000 (22:34 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 1 Oct 2021 19:34:46 +0000 (20:34 +0100)
commit741c7350c08b0884689466867b6c9e711c7b109e
tree1b0c1a73481bc0fb4cabbed8d3d5ad96bbe8d35d
parent2a93d18da3bd79eb0be87f029eefc8b28bb66dec
libstdc++: Implement std::clamp with std::min and std::max [PR 96733]

The compiler doesn't know about the precondition of std::clamp that
(hi < lo) is false, and so can't optimize as well as we'd like. By using
std::min and std::max we help the compiler.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/96733
* include/bits/stl_algo.h (clamp): Use std::min and std::max.
libstdc++-v3/include/bits/stl_algo.h