]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Replace use of std::min in ranges::uninitialized_xxx algos [PR101587]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 26 Mar 2025 11:47:05 +0000 (11:47 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 27 Mar 2025 15:26:32 +0000 (15:26 +0000)
commitf4b6acfc36fb1f72fdd5bf4da208515e6495a062
tree444e269f1ac25354746f1b42fa52f08418f5fcd9
parent16766d5a0c4a946d3ba9255a99621975b9773e18
libstdc++: Replace use of std::min in ranges::uninitialized_xxx algos [PR101587]

Because ranges can have any signed integer-like type as difference_type,
it's not valid to use std::min(diff1, diff2). Instead of calling
std::min with an explicit template argument, this adds a new __mindist
helper that determines the common type and uses that with std::min.

libstdc++-v3/ChangeLog:

PR libstdc++/101587
* include/bits/ranges_uninitialized.h (__detail::__mindist):
New function object.
(ranges::uninitialized_copy, ranges::uninitialized_copy_n)
(ranges::uninitialized_move, ranges::uninitialized_move_n): Use
__mindist instead of std::min.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
Check ranges with difference difference types.
* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
Likewise.
libstdc++-v3/include/bits/ranges_uninitialized.h
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc