public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r10-10212] libstdc++: Implement LWG 3422 for std::seed_seq Date: Wed, 13 Oct 2021 15:29:47 +0000 (GMT) [thread overview] Message-ID: <20211013152947.69D093858425@sourceware.org> (raw) https://gcc.gnu.org/g:e7274af45795b450268d7769ddae06f774db4dc9 commit r10-10212-ge7274af45795b450268d7769ddae06f774db4dc9 Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Jun 22 18:05:11 2021 +0100 libstdc++: Implement LWG 3422 for std::seed_seq This ensures that the std::seed_seq initializer-list constructor will not be used for list-initialization unless the initializers in the list are integers. This allows list-initialization syntax to be used with a pair of pointers and for that to use the appropriate constructor. Signed-off-by: Jonathan Wakely <jwakely@redhat.com> libstdc++-v3/ChangeLog: * include/bits/random.h (seed_seq): Constrain initializer-list constructor. * include/bits/random.tcc (seed_seq): Add template parameter. * testsuite/26_numerics/random/seed_seq/cons/default.cc: Check for noexcept. * testsuite/26_numerics/random/seed_seq/cons/initlist.cc: Check constraints. (cherry picked from commit 6c63cb231e4cf99552bb7904ebe402f7adcafda4) Diff: --- libstdc++-v3/include/bits/random.h | 2 +- libstdc++-v3/include/bits/random.tcc | 2 +- libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc | 4 +++- .../testsuite/26_numerics/random/seed_seq/cons/initlist.cc | 7 +++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 2bcac1b41b1..2bd6bc1e120 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -6071,7 +6071,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_v() { } - template<typename _IntType> + template<typename _IntType, typename = _Require<is_integral<_IntType>>> seed_seq(std::initializer_list<_IntType> __il); template<typename _InputIterator> diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc index a921b9bf815..d7503ee7094 100644 --- a/libstdc++-v3/include/bits/random.tcc +++ b/libstdc++-v3/include/bits/random.tcc @@ -3197,7 +3197,7 @@ namespace __detail } - template<typename _IntType> + template<typename _IntType, typename> seed_seq::seed_seq(std::initializer_list<_IntType> __il) { for (auto __iter = __il.begin(); __iter != __il.end(); ++__iter) diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc index 73a4390da26..3c4e38a7408 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/default.cc @@ -25,6 +25,9 @@ #include <random> #include <testsuite_hooks.h> +static_assert( std::is_nothrow_default_constructible<std::seed_seq>::value, + "LWG 3422" ); + void test01() { @@ -34,7 +37,6 @@ test01() seq.generate(foo.begin(), foo.end()); VERIFY( seq.size() == 0 ); - //VERIFY(); } int diff --git a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc index 1e2a88d32ff..396141e9c4e 100644 --- a/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc +++ b/libstdc++-v3/testsuite/26_numerics/random/seed_seq/cons/initlist.cc @@ -36,6 +36,13 @@ test01() VERIFY( seq.size() == 10 ); } +void +lwg3422() +{ + int i[32] = { }; + std::seed_seq ss{i, i+32}; // LWG 3422 +} + int main() { test01();
reply other threads:[~2021-10-13 15:29 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211013152947.69D093858425@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).