[Bug libstdc++/96731] uniform_int_distribution requirement that its type is_integral is too strict
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731 --- Comment #5 from Tony E Lewis --- Thanks very much for your work on this. That's a shame but I appreciate the problems you've highlighted. > I don't plan to work on this any further for now. Yes, fair enough.
[Bug libstdc++/96731] uniform_int_distribution requirement that its type is_integral is too strict
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731 --- Comment #4 from Jonathan Wakely --- Created attachment 49135 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49135&action=edit Patch to relax std::uniform_int_distribution requirements This patch allows a custom integer-like type to be used with std::uniform_int_distribution, but it's harder than it seems. We need to use std::make_unsigned, which is undefined for non-integral types. The patch will use _IntType is numeric_limits<_IntType>::is_signed is false, otherwise it will use make_unsigned_t<_IntType> if possible, and unsigned long long otherwise. But the example still fails, because std::sample also requires an integral type, and also wants to use make_unsigned. And the standard is clear that it's not just undefined, but ill-formed and requires a diagnostic: > Mandates: For the overload in namespace std, Distance is an integer type I don't plan to work on this any further for now.
[Bug libstdc++/96731] uniform_int_distribution requirement that its type is_integral is too strict
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731 --- Comment #3 from Tony E Lewis --- Thanks for correcting my failure to find the relevant part of the standard and for confirming this as an enhancement request. Yes please. If libstdc++'s sample() could play nicely with range-v3's view::indices, that'd be much appreciated.
[Bug libstdc++/96731] uniform_int_distribution requirement that its type is_integral is too strict
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731 Jonathan Wakely changed: What|Removed |Added Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Severity|normal |enhancement Last reconfirmed||2020-08-21 --- Comment #2 from Jonathan Wakely --- Since it's undefined, we can do whatever we want, including causing compilation to fail with a static_assert, or ignoring it (as libc++ seems to do), or using another condition to check for sufficiently integer-like types (possibly only in non-strict modes). Confirming as an enhancement request.
[Bug libstdc++/96731] uniform_int_distribution requirement that its type is_integral is too strict
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731 --- Comment #1 from Jonathan Wakely --- (In reply to Tony E Lewis from comment #0) > I can't see any obvious mention of constraints on > uniform_int_distribution's IntType in > http://eel.is/c++draft/rand.dist.uni.int See http://eel.is/c++draft/rand#req.genl-1.5