Landing: 0a2b9dc9655f
Project / Subsystem
gcc / libstdc++
Date
2026-04-30
Author
Jonathan Wakely
Commit
0a2b9dc9655f12e43a0e67f26ea21ff4f4e038fe
Source
github
Perf win
No
Breaking
No
All attributes
- project
- gcc
- subsystem
- libstdc++
- patch_id
- —
- commit_hash
- 0a2b9dc9655f12e43a0e67f26ea21ff4f4e038fe
- source_type
- github
- headline
- Do Not Assume URBG::result_type Exists
- tldr
- The `ranges::sample` and `ranges::shuffle` algorithms now work with random number generators that don't define `result_type`, improving compatibility.
- author
- Jonathan Wakely
- outcome
- committed
- performance_win
- false
- breaking_change
- false
- series_id
- —
- series_parts
- []
- tags
-
- • libstdc++
- • random number generators
- • ranges
- discussion_id_link
- —
- bugzilla_pr
- —
- date
- 2026-04-30T00:00:00.000Z
This commit fixes an issue in the ranges::sample and ranges::shuffle algorithms in libstdc++. These algorithms are designed to work with types that model std::uniform_random_bit_generator. The original implementation incorrectly assumed that all such generators would have a nested result_type member. This commit changes the algorithms to use decltype(__g()) instead of result_type to determine the return type of the generator, making them compatible with a wider range of random number generators. It also updates std::uniform_int_distribution to use decltype.