On Thu, Dec 18, 2025 at 09:42:53AM +0000, Jonathan Wakely wrote:
> Make use of __detail::_Select_uint_least_t<d>::type for
> std::generate_canonical, so that we choose an appropriately sized
> integer based on the number of bits needed, and so we have a 128-bit
> integer type even on 32-bit targets (via the new __rand_uint128 class).
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/random.tcc (__generate_canonical_pow2): Adjust
> comments. Remove _UInt template parameter and define it in the
> body using _Select_uint_least_t<__d>. Remove popcount call for
> getting the width of the _UInt type. Cast floating-point
> literal to _RealT.
> (__generate_canonical_any): Remove _UInt template parameter and
> define it in the body using _Select_uint_least_t<__d * 2>. Use
> direct-initialization for _UInt variables. Cast floating-point
> literal to _RealT.
> (generate_canonical): Remove unused typedef. Remove constexpr-if
> branches and remove unsigned type from template argument lists.
LGTM.
Jakub