https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96731

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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.

Reply via email to