aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/Makefile.am2
-rw-r--r--libstdc++-v3/include/Makefile.in2
-rw-r--r--libstdc++-v3/include/bits/random.h29
-rw-r--r--libstdc++-v3/include/bits/random.tcc65
4 files changed, 39 insertions, 59 deletions
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 6e7b28303e1..6a9c4f09ed4 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -852,7 +852,7 @@ pch_output_dirs = \
${pch1_output_builddir} ${pch2_output_builddir} ${pch3_output_builddir}
pch_output_anchors = \
${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor}
-PCHFLAGS=-Winvalid-pch -x c++-header $(CXXFLAGS)
+PCHFLAGS=-x c++-header $(CXXFLAGS)
if GLIBCXX_BUILD_PCH
pch_build = ${pch_output}
else
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 9f8782c5ea8..4ac2739cb43 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1098,7 +1098,7 @@ pch_output_dirs = \
pch_output_anchors = \
${pch1_output_anchor} ${pch2_output_anchor} ${pch3_output_anchor}
-PCHFLAGS = -Winvalid-pch -x c++-header $(CXXFLAGS)
+PCHFLAGS = -x c++-header $(CXXFLAGS)
@GLIBCXX_BUILD_PCH_FALSE@pch_build =
@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_output}
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 425420607ce..b5ccf8a1680 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -68,23 +68,6 @@ namespace std
struct _Shift<_UIntType, __w, true>
{ static const _UIntType __value = _UIntType(1) << __w; };
- // XXX need constexpr
- template<typename _UIntType, size_t __w,
- bool = __w < static_cast<size_t>
- (std::numeric_limits<_UIntType>::digits)>
- struct _ShiftMin1
- {
- static const _UIntType __value =
- __gnu_cxx::__numeric_traits<_UIntType>::__max;
- };
-
- template<typename _UIntType, size_t __w>
- struct _ShiftMin1<_UIntType, __w, true>
- {
- static const _UIntType __value =
- (_UIntType(1) << __w) - _UIntType(1);
- };
-
template<typename _Tp, _Tp __a, _Tp __c, _Tp __m, bool>
struct _Mod;
@@ -395,11 +378,11 @@ namespace std
static_assert(__w <=
static_cast<size_t>(numeric_limits<_UIntType>::digits),
"mersenne_twister_engine template arguments out of bounds");
- static_assert(__a <= __detail::_ShiftMin1<_UIntType, __w>::__value,
+ static_assert(__a <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"mersenne_twister_engine template arguments out of bounds");
- static_assert(__b <= __detail::_ShiftMin1<_UIntType, __w>::__value,
+ static_assert(__b <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"mersenne_twister_engine template arguments out of bounds");
- static_assert(__c <= __detail::_ShiftMin1<_UIntType, __w>::__value,
+ static_assert(__c <= (__detail::_Shift<_UIntType, __w>::__value - 1),
"mersenne_twister_engine template arguments out of bounds");
public:
@@ -459,7 +442,7 @@ namespace std
*/
result_type
max() const
- { return __detail::_ShiftMin1<_UIntType, __w>::__value; }
+ { return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
@@ -644,7 +627,7 @@ namespace std
*/
result_type
max() const
- { return __detail::_ShiftMin1<_UIntType, __w>::__value; }
+ { return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
@@ -1040,7 +1023,7 @@ namespace std
*/
result_type
max() const
- { return __detail::_ShiftMin1<_UIntType, __w>::__value; }
+ { return __detail::_Shift<_UIntType, __w>::__value - 1; }
/**
* @brief Discard a sequence of random numbers.
diff --git a/libstdc++-v3/include/bits/random.tcc b/libstdc++-v3/include/bits/random.tcc
index 8944c116b7e..b110f99740c 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -554,8 +554,8 @@ namespace std
independent_bits_engine<_RandomNumberEngine, __w, _UIntType>::
operator()()
{
- const long double __r = static_cast<long double>(this->max())
- - static_cast<long double>(this->min()) + 1.0L;
+ const long double __r = static_cast<long double>(_M_b.max())
+ - static_cast<long double>(_M_b.min()) + 1.0L;
const result_type __m = std::log10(__r) / std::log10(2.0L);
result_type __n, __n0, __y0, __y1, __s0, __s1;
for (size_t __i = 0; __i < 2; ++__i)
@@ -564,8 +564,8 @@ namespace std
__n0 = __n - __w % __n;
const result_type __w0 = __w / __n;
const result_type __w1 = __w0 + 1;
- __s0 = 1UL << __w0;
- __s1 = 1UL << __w1;
+ __s0 = result_type(1) << __w0;
+ __s1 = result_type(1) << __w1;
__y0 = __s0 * (__r / __s0);
__y1 = __s1 * (__r / __s1);
if (__r - __y0 <= __y0 / __n)
@@ -577,19 +577,17 @@ namespace std
{
result_type __u;
do
- __u = _M_b() - this->min();
+ __u = _M_b() - _M_b.min();
while (__u >= __y0);
- __sum = __s0 * __sum
- + __u % __s0;
+ __sum = __s0 * __sum + __u % __s0;
}
for (size_t __k = __n0; __k < __n; ++__k)
{
result_type __u;
do
- __u = _M_b() - this->min();
+ __u = _M_b() - _M_b.min();
while (__u >= __y1);
- __sum = __s1 * __sum
- + __u % __s1;
+ __sum = __s1 * __sum + __u % __s1;
}
return __sum;
}
@@ -1653,12 +1651,11 @@ namespace std
__aurng(__urng);
_RealType __u;
do
- {
- __u = __aurng();
- }
+ __u = __aurng();
while (__u == 0.5);
- return __p.a() + __p.b() * std::tan(M_PI * __u);
+ const _RealType __pi = 3.1415926535897932384626433832795029L;
+ return __p.a() + __p.b() * std::tan(__pi * __u);
}
template<typename _RealType, typename _CharT, typename _Traits>
@@ -2649,12 +2646,12 @@ namespace std
_RandomAccessIterator __end)
{
typedef typename iterator_traits<_RandomAccessIterator>::value_type
- __Type;
+ _Type;
if (__begin == __end)
return;
- std::fill(__begin, __end, __Type(0x8b8b8b8bU));
+ std::fill(__begin, __end, _Type(0x8b8b8b8bU));
const size_t __n = __end - __begin;
const size_t __s = _M_v.size();
@@ -2669,21 +2666,21 @@ namespace std
for (size_t __k = 0; __k < __m; ++__k)
{
- __Type __arg = __begin[__k % __n]
- ^ __begin[(__k + __p) % __n]
- ^ __begin[(__k - 1) % __n];
- __Type __r1 = __arg ^ (__arg << 27);
- __r1 = __detail::__mod<__Type, 1664525U, 0U,
- __detail::_Shift<__Type, 32>::__value>(__r1);
- __Type __r2 = __r1;
+ _Type __arg = (__begin[__k % __n]
+ ^ __begin[(__k + __p) % __n]
+ ^ __begin[(__k - 1) % __n]);
+ _Type __r1 = __arg ^ (__arg << 27);
+ __r1 = __detail::__mod<_Type, 1664525U, 0U,
+ __detail::_Shift<_Type, 32>::__value>(__r1);
+ _Type __r2 = __r1;
if (__k == 0)
__r2 += __s;
else if (__k <= __s)
__r2 += __k % __n + _M_v[__k - 1];
else
__r2 += __k % __n;
- __r2 = __detail::__mod<__Type, 1U, 0U,
- __detail::_Shift<__Type, 32>::__value>(__r2);
+ __r2 = __detail::__mod<_Type, 1U, 0U,
+ __detail::_Shift<_Type, 32>::__value>(__r2);
__begin[(__k + __p) % __n] += __r1;
__begin[(__k + __q) % __n] += __r2;
__begin[__k % __n] = __r2;
@@ -2691,15 +2688,15 @@ namespace std
for (size_t __k = __m; __k < __m + __n; ++__k)
{
- __Type __arg = __begin[__k % __n]
- + __begin[(__k + __p) % __n]
- + __begin[(__k - 1) % __n];
- __Type __r3 = __arg ^ (__arg << 27);
- __r3 = __detail::__mod<__Type, 1566083941U, 0U,
- __detail::_Shift<__Type, 32>::__value>(__r3);
- __Type __r4 = __r3 - __k % __n;
- __r4 = __detail::__mod<__Type, 1U, 0U,
- __detail::_Shift<__Type, 32>::__value>(__r4);
+ _Type __arg = (__begin[__k % __n]
+ + __begin[(__k + __p) % __n]
+ + __begin[(__k - 1) % __n]);
+ _Type __r3 = __arg ^ (__arg << 27);
+ __r3 = __detail::__mod<_Type, 1566083941U, 0U,
+ __detail::_Shift<_Type, 32>::__value>(__r3);
+ _Type __r4 = __r3 - __k % __n;
+ __r4 = __detail::__mod<_Type, 1U, 0U,
+ __detail::_Shift<_Type, 32>::__value>(__r4);
__begin[(__k + __p) % __n] ^= __r4;
__begin[(__k + __q) % __n] ^= __r3;
__begin[__k % __n] = __r4;