From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E0FE93857030; Fri, 21 Aug 2020 06:19:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E0FE93857030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597990762; bh=gyX1JXVntDHp0W/7FnmWo0xkpHRdi3ifCVDcP2VJNuk=; h=From:To:Subject:Date:From; b=VeYt2ZfpLOlzYp08hcDFVTItl2r5FutbNuZ0piUR/KjP9oYWiAF0ily3sdWu97qp1 fOyS+/v/BQFSUOL1pe4oe2evcLATzFAJkO3iJ/xWOO3w3Kk3FDylgabv5jal+gnEDl d2vu2l/gyhdo1axsRA0ZrC9u7zm5k8CJGl1q1960= From: "TonyELewis at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/96731] New: uniform_int_distribution requirement that its type is_integral is too strict Date: Fri, 21 Aug 2020 06:19:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: TonyELewis at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Aug 2020 06:19:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96731 Bug ID: 96731 Summary: uniform_int_distribution requirement that its type is_integral is too strict Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: TonyELewis at hotmail dot com Target Milestone: --- Following on from https://github.com/ericniebler/range-v3/issues/1532 ... I think the static_assert requirement in libstdc++'s uniform_int_distributi= on code that its template argument type is_integral may be too strict. I can't see any obvious mention of constraints on uniform_=C2=ADint_=C2=ADd= istribution's IntType in http://eel.is/c++draft/rand.dist.uni.int The motivating case is attempting to sample from a range-v3 view::indices. = The range-v3 clever tricks lead to uniform_int_distribution being invoked with a range-v3 type. This all works OK under libc++ because it doesn't impose any requirements on the type. But the aforementioned static_assert in libstdc++ won't allow it. The problem can be seen with the first error under GCC or Clang with -std= =3Dc++17 on this code: #include #include #include #include #include void fill_vec_with_random_sample_of_first_n_ints( const size_t=20=20=20=20= =20=20=20=20=20 &prm_num_possible_vals, std::vector &prm_result, std::mt19937 &prm_= rng ) { auto some_indices =3D ranges::views::indices( prm_num_possible_vals= ); std::sample( std::begin( some_indices ), std::end ( some_indices ), std::begin( prm_result ), static_cast( prm_result.size() ), prm_rng ); } Compiler Explorer : https://godbolt.org/z/MxrazP One option is that libstdc++ could use std::numeric_limits::is_integer instead of std::is_integral, so that range-v3 could then specialise accordi= ngly for its type.=