From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Modernize <bits/random.h> helpers
Date: Fri, 16 Jul 2021 15:36:41 +0100 [thread overview]
Message-ID: <YPGZeVDi2Ks308oN@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/random.h (_Shift::__value): Use constexpr.
(_Select_uint_least_t::type): Use using-declaration.
(_Mod): Likewise.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 3476 bytes --]
commit 95891ca020591196cde50c4cde4cab14783a3c00
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Jul 16 13:39:25 2021
libstdc++: Modernize <bits/random.h> helpers
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/bits/random.h (_Shift::__value): Use constexpr.
(_Select_uint_least_t::type): Use using-declaration.
(_Mod): Likewise.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error
line number.
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 6d0e1544c90..c5cae87b636 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -68,11 +68,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool = __w < static_cast<size_t>
(std::numeric_limits<_UIntType>::digits)>
struct _Shift
- { static const _UIntType __value = 0; };
+ { static constexpr _UIntType __value = 0; };
template<typename _UIntType, size_t __w>
struct _Shift<_UIntType, __w, true>
- { static const _UIntType __value = _UIntType(1) << __w; };
+ { static constexpr _UIntType __value = _UIntType(1) << __w; };
template<int __s,
int __which = ((__s <= __CHAR_BIT__ * sizeof (int))
@@ -88,20 +88,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<int __s>
struct _Select_uint_least_t<__s, 4>
- { typedef unsigned int type; };
+ { using type = unsigned int; };
template<int __s>
struct _Select_uint_least_t<__s, 3>
- { typedef unsigned long type; };
+ { using type = unsigned long; };
template<int __s>
struct _Select_uint_least_t<__s, 2>
- { typedef unsigned long long type; };
+ { using type = unsigned long long; };
#if __SIZEOF_INT128__ > __SIZEOF_LONG_LONG__
template<int __s>
struct _Select_uint_least_t<__s, 1>
- { __extension__ typedef unsigned __int128 type; };
+ { __extension__ using type = unsigned __int128; };
#endif
// Assume a != 0, a < m, c < m, x < m.
@@ -111,11 +111,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool __schrage_ok = __m % __a < __m / __a>
struct _Mod
{
- typedef typename _Select_uint_least_t<std::__lg(__a)
- + std::__lg(__m) + 2>::type _Tp2;
static _Tp
__calc(_Tp __x)
- { return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m); }
+ {
+ using _Tp2
+ = typename _Select_uint_least_t<std::__lg(__a)
+ + std::__lg(__m) + 2>::type;
+ return static_cast<_Tp>((_Tp2(__a) * __x + __c) % __m);
+ }
};
// Schrage.
diff --git a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
index 3ded306bd5f..d6e6399bd79 100644
--- a/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
@@ -10,6 +10,6 @@ std::__detail::_Adaptor<std::mt19937, unsigned long> aurng(urng);
auto x = std::generate_canonical<std::size_t,
std::numeric_limits<std::size_t>::digits>(urng);
-// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 166 }
+// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 169 }
// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3350 }
reply other threads:[~2021-07-16 14:37 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=YPGZeVDi2Ks308oN@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@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: link
Be 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).