diff options
author | Patrick Palka <ppalka@redhat.com> | 2025-09-13 10:44:12 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2025-09-13 10:44:12 -0400 |
commit | 349affa42c9fa47a12eb7f5f97f5650a77bbf014 (patch) | |
tree | 9b87146b71a448d8b29c750095826b0ce9b3c764 /libjava | |
parent | f8b6f1d83ba8fd4186100e1e357ba7eb8124bdb7 (diff) | |
download | gcc-349affa42c9fa47a12eb7f5f97f5650a77bbf014.zip gcc-349affa42c9fa47a12eb7f5f97f5650a77bbf014.tar.gz gcc-349affa42c9fa47a12eb7f5f97f5650a77bbf014.tar.bz2 |
libstdc++: Fix ranges::shuffle for non-sized range [PR121917]
ranges::shuffle has a two-at-a-time PRNG optimization (copied from
std::shuffle) that considers the PRNG width vs the size of the range.
But in C++20 a random access sentinel isn't always sized so we can't
unconditionally do __last - __first to obtain the size in constant
time.
We could instead use ranges::distance, but that'd take linear time for a
non-sized sentinel which makes the optimization less clear of a win. So
this patch instead makes us only consider this optimization for sized
ranges.
PR libstdc++/121917
libstdc++-v3/ChangeLog:
* include/bits/ranges_algo.h (__shuffle_fn::operator()): Only
consider the two-at-a-time PRNG optimization if the range is
sized.
* testsuite/25_algorithms/shuffle/constrained.cc (test03): New
test.
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Diffstat (limited to 'libjava')
0 files changed, 0 insertions, 0 deletions