Commit 160e95dc by Jonathan Wakely Committed by Jonathan Wakely

libstdc++: Fix undefined behaviour in random dist serialization (PR93205)

The deserialization functions for random number distributions fail to
check the stream state before using the extracted values. In some cases
this leads to using indeterminate values to resize a vector, and then
filling that vector with indeterminate values.

No values that affect control flow should be used without checking that a
good value was read from the stream.

Additionally, where reasonable to do so, defer modifying any state in
the distribution until all values have been successfully read, to avoid
modifying some of the distribution's parameters and leaving others
unchanged.

	PR libstdc++/93205
	* include/bits/random.h (operator>>): Check stream operation succeeds.
	* include/bits/random.tcc (operator<<): Remove redundant __ostream_type
	typedefs.
	(operator>>): Remove redundant __istream_type typedefs. Check stream
	operations succeed.
	(__extract_params): New function to fill a vector from a stream.
	* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line.

From-SVN: r280061
parent 0a09a948
2020-01-09 Jonathan Wakely <jwakely@redhat.com> 2020-01-09 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/93205
* include/bits/random.h (operator>>): Check stream operation succeeds.
* include/bits/random.tcc (operator<<): Remove redundant __ostream_type
typedefs.
(operator>>): Remove redundant __istream_type typedefs. Check stream
operations succeed.
(__extract_params): New function to fill a vector from a stream.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error line.
PR libstdc++/93208 PR libstdc++/93208
* config/abi/pre/gnu.ver: Add new exports. * config/abi/pre/gnu.ver: Add new exports.
* include/std/memory_resource (memory_resource::~memory_resource()): * include/std/memory_resource (memory_resource::~memory_resource()):
......
...@@ -3720,13 +3720,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3720,13 +3720,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @returns The input stream with @p __x extracted or in an error state. * @returns The input stream with @p __x extracted or in an error state.
*/ */
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>& inline std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
std::bernoulli_distribution& __x) std::bernoulli_distribution& __x)
{ {
double __p; double __p;
__is >> __p; if (__is >> __p)
__x.param(bernoulli_distribution::param_type(__p)); __x.param(bernoulli_distribution::param_type(__p));
return __is; return __is;
} }
......
...@@ -155,8 +155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -155,8 +155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const linear_congruential_engine<_UIntType, const linear_congruential_engine<_UIntType,
__a, __c, __m>& __lcr) __a, __c, __m>& __lcr)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -176,8 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -176,8 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr) linear_congruential_engine<_UIntType, __a, __c, __m>& __lcr)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec); __is.flags(__ios_base::dec);
...@@ -477,8 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -477,8 +475,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const mersenne_twister_engine<_UIntType, __w, __n, __m, const mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -505,8 +502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -505,8 +502,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
mersenne_twister_engine<_UIntType, __w, __n, __m, mersenne_twister_engine<_UIntType, __w, __n, __m,
__r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x) __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
...@@ -633,8 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -633,8 +629,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const subtract_with_carry_engine<_UIntType, const subtract_with_carry_engine<_UIntType,
__w, __s, __r>& __x) __w, __s, __r>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -657,8 +652,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -657,8 +652,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x) subtract_with_carry_engine<_UIntType, __w, __s, __r>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
...@@ -703,8 +697,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -703,8 +697,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const discard_block_engine<_RandomNumberEngine, const discard_block_engine<_RandomNumberEngine,
__p, __r>& __x) __p, __r>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -725,8 +718,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -725,8 +718,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
discard_block_engine<_RandomNumberEngine, __p, __r>& __x) discard_block_engine<_RandomNumberEngine, __p, __r>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
...@@ -831,8 +823,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -831,8 +823,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const shuffle_order_engine<_RandomNumberEngine, __k>& __x) const shuffle_order_engine<_RandomNumberEngine, __k>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -856,8 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -856,8 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
shuffle_order_engine<_RandomNumberEngine, __k>& __x) shuffle_order_engine<_RandomNumberEngine, __k>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
...@@ -877,8 +867,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -877,8 +867,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_int_distribution<_IntType>& __x) const uniform_int_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -898,16 +887,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -898,16 +887,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
uniform_int_distribution<_IntType>& __x) uniform_int_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename uniform_int_distribution<_IntType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_IntType __a, __b; _IntType __a, __b;
__is >> __a >> __b; if (__is >> __a >> __b)
__x.param(typename uniform_int_distribution<_IntType>:: __x.param(param_type(__a, __b));
param_type(__a, __b));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -936,8 +925,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -936,8 +925,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const uniform_real_distribution<_RealType>& __x) const uniform_real_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -960,16 +948,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -960,16 +948,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
uniform_real_distribution<_RealType>& __x) uniform_real_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename uniform_real_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws); __is.flags(__ios_base::skipws);
_RealType __a, __b; _RealType __a, __b;
__is >> __a >> __b; if (__is >> __a >> __b)
__x.param(typename uniform_real_distribution<_RealType>:: __x.param(param_type(__a, __b));
param_type(__a, __b));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -998,8 +986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -998,8 +986,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const bernoulli_distribution& __x) const bernoulli_distribution& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1080,8 +1067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1080,8 +1067,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const geometric_distribution<_IntType>& __x) const geometric_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1104,15 +1090,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1104,15 +1090,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
geometric_distribution<_IntType>& __x) geometric_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename geometric_distribution<_IntType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws); __is.flags(__ios_base::skipws);
double __p; double __p;
__is >> __p; if (__is >> __p)
__x.param(typename geometric_distribution<_IntType>::param_type(__p)); __x.param(param_type(__p));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1195,8 +1181,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1195,8 +1181,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const negative_binomial_distribution<_IntType>& __x) const negative_binomial_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1220,17 +1205,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1220,17 +1205,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
negative_binomial_distribution<_IntType>& __x) negative_binomial_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename negative_binomial_distribution<_IntType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws); __is.flags(__ios_base::skipws);
_IntType __k; _IntType __k;
double __p; double __p;
__is >> __k >> __p >> __x._M_gd; if (__is >> __k >> __p >> __x._M_gd)
__x.param(typename negative_binomial_distribution<_IntType>:: __x.param(param_type(__k, __p));
param_type(__k, __p));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1406,8 +1391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1406,8 +1391,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const poisson_distribution<_IntType>& __x) const poisson_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1431,15 +1415,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1431,15 +1415,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
poisson_distribution<_IntType>& __x) poisson_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename poisson_distribution<_IntType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::skipws); __is.flags(__ios_base::skipws);
double __mean; double __mean;
__is >> __mean >> __x._M_nd; if (__is >> __mean >> __x._M_nd)
__x.param(typename poisson_distribution<_IntType>::param_type(__mean)); __x.param(param_type(__mean));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1673,8 +1657,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1673,8 +1657,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const binomial_distribution<_IntType>& __x) const binomial_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1699,17 +1682,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1699,17 +1682,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
binomial_distribution<_IntType>& __x) binomial_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename binomial_distribution<_IntType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_IntType __t; _IntType __t;
double __p; double __p;
__is >> __t >> __p >> __x._M_nd; if (__is >> __t >> __p >> __x._M_nd)
__x.param(typename binomial_distribution<_IntType>:: __x.param(param_type(__t, __p));
param_type(__t, __p));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1737,8 +1719,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1737,8 +1719,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const exponential_distribution<_RealType>& __x) const exponential_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1760,16 +1741,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1760,16 +1741,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
exponential_distribution<_RealType>& __x) exponential_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename exponential_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __lambda; _RealType __lambda;
__is >> __lambda; if (__is >> __lambda)
__x.param(typename exponential_distribution<_RealType>:: __x.param(param_type(__lambda));
param_type(__lambda));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1904,8 +1885,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1904,8 +1885,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const normal_distribution<_RealType>& __x) const normal_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1931,19 +1911,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1931,19 +1911,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
normal_distribution<_RealType>& __x) normal_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename normal_distribution<_RealType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
double __mean, __stddev; double __mean, __stddev;
__is >> __mean >> __stddev bool __saved_avail;
>> __x._M_saved_available; if (__is >> __mean >> __stddev >> __saved_avail)
if (__x._M_saved_available) {
__is >> __x._M_saved; if (__saved_avail && (__is >> __x._M_saved))
__x.param(typename normal_distribution<_RealType>:: {
param_type(__mean, __stddev)); __x._M_saved_available = __saved_avail;
__x.param(param_type(__mean, __stddev));
}
}
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -1969,8 +1952,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1969,8 +1952,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const lognormal_distribution<_RealType>& __x) const lognormal_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -1994,16 +1976,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -1994,16 +1976,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
lognormal_distribution<_RealType>& __x) lognormal_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename lognormal_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __m, __s; _RealType __m, __s;
__is >> __m >> __s >> __x._M_nd; if (__is >> __m >> __s >> __x._M_nd)
__x.param(typename lognormal_distribution<_RealType>:: __x.param(param_type(__m, __s));
param_type(__m, __s));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2042,8 +2024,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2042,8 +2024,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const chi_squared_distribution<_RealType>& __x) const chi_squared_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2066,16 +2047,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2066,16 +2047,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
chi_squared_distribution<_RealType>& __x) chi_squared_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename chi_squared_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n; _RealType __n;
__is >> __n >> __x._M_gd; if (__is >> __n >> __x._M_gd)
__x.param(typename chi_squared_distribution<_RealType>:: __x.param(param_type(__n));
param_type(__n));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2129,8 +2110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2129,8 +2110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const cauchy_distribution<_RealType>& __x) const cauchy_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2153,16 +2133,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2153,16 +2133,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
cauchy_distribution<_RealType>& __x) cauchy_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename cauchy_distribution<_RealType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b; _RealType __a, __b;
__is >> __a >> __b; if (__is >> __a >> __b)
__x.param(typename cauchy_distribution<_RealType>:: __x.param(param_type(__a, __b));
param_type(__a, __b));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2206,8 +2185,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2206,8 +2185,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const fisher_f_distribution<_RealType>& __x) const fisher_f_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2231,16 +2209,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2231,16 +2209,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
fisher_f_distribution<_RealType>& __x) fisher_f_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename fisher_f_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __m, __n; _RealType __m, __n;
__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y; if (__is >> __m >> __n >> __x._M_gd_x >> __x._M_gd_y)
__x.param(typename fisher_f_distribution<_RealType>:: __x.param(param_type(__m, __n));
param_type(__m, __n));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2281,8 +2259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2281,8 +2259,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const student_t_distribution<_RealType>& __x) const student_t_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2305,15 +2282,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2305,15 +2282,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
student_t_distribution<_RealType>& __x) student_t_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename student_t_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __n; _RealType __n;
__is >> __n >> __x._M_nd >> __x._M_gd; if (__is >> __n >> __x._M_nd >> __x._M_gd)
__x.param(typename student_t_distribution<_RealType>::param_type(__n)); __x.param(param_type(__n));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2450,8 +2428,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2450,8 +2428,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const gamma_distribution<_RealType>& __x) const gamma_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2475,16 +2452,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2475,16 +2452,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
gamma_distribution<_RealType>& __x) gamma_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename gamma_distribution<_RealType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __alpha_val, __beta_val; _RealType __alpha_val, __beta_val;
__is >> __alpha_val >> __beta_val >> __x._M_nd; if (__is >> __alpha_val >> __beta_val >> __x._M_nd)
__x.param(typename gamma_distribution<_RealType>:: __x.param(param_type(__alpha_val, __beta_val));
param_type(__alpha_val, __beta_val));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2528,8 +2504,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2528,8 +2504,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const weibull_distribution<_RealType>& __x) const weibull_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2552,16 +2527,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2552,16 +2527,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
weibull_distribution<_RealType>& __x) weibull_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type = typename weibull_distribution<_RealType>::param_type;
typedef typename __istream_type::ios_base __ios_base; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b; _RealType __a, __b;
__is >> __a >> __b; if (__is >> __a >> __b)
__x.param(typename weibull_distribution<_RealType>:: __x.param(param_type(__a, __b));
param_type(__a, __b));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2604,8 +2578,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2604,8 +2578,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const extreme_value_distribution<_RealType>& __x) const extreme_value_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2628,16 +2601,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2628,16 +2601,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
extreme_value_distribution<_RealType>& __x) extreme_value_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using param_type
typedef typename __istream_type::ios_base __ios_base; = typename extreme_value_distribution<_RealType>::param_type;
using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
_RealType __a, __b; _RealType __a, __b;
__is >> __a >> __b; if (__is >> __a >> __b)
__x.param(typename extreme_value_distribution<_RealType>:: __x.param(param_type(__a, __b));
param_type(__a, __b));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
...@@ -2740,8 +2713,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2740,8 +2713,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const discrete_distribution<_IntType>& __x) const discrete_distribution<_IntType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2762,32 +2734,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2762,32 +2734,44 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __os; return __os;
} }
namespace __detail
{
template<typename _ValT, typename _CharT, typename _Traits>
basic_istream<_CharT, _Traits>&
__extract_params(basic_istream<_CharT, _Traits>& __is,
vector<_ValT>& __vals, size_t __n)
{
__vals.reserve(__n);
while (__n--)
{
_ValT __val;
if (__is >> __val)
__vals.push_back(__val);
else
break;
}
return __is;
}
} // namespace __detail
template<typename _IntType, typename _CharT, typename _Traits> template<typename _IntType, typename _CharT, typename _Traits>
std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>&
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
discrete_distribution<_IntType>& __x) discrete_distribution<_IntType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n; size_t __n;
__is >> __n; if (__is >> __n)
std::vector<double> __prob_vec;
__prob_vec.reserve(__n);
for (; __n != 0; --__n)
{ {
double __prob; std::vector<double> __prob_vec;
__is >> __prob; if (__detail::__extract_params(__is, __prob_vec, __n))
__prob_vec.push_back(__prob); __x.param({__prob_vec.begin(), __prob_vec.end()});
} }
__x.param(typename discrete_distribution<_IntType>::
param_type(__prob_vec.begin(), __prob_vec.end()));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
} }
...@@ -2950,8 +2934,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2950,8 +2934,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const piecewise_constant_distribution<_RealType>& __x) const piecewise_constant_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -2982,36 +2965,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -2982,36 +2965,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
piecewise_constant_distribution<_RealType>& __x) piecewise_constant_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n; size_t __n;
__is >> __n; if (__is >> __n)
std::vector<_RealType> __int_vec;
__int_vec.reserve(__n + 1);
for (size_t __i = 0; __i <= __n; ++__i)
{
_RealType __int;
__is >> __int;
__int_vec.push_back(__int);
}
std::vector<double> __den_vec;
__den_vec.reserve(__n);
for (size_t __i = 0; __i < __n; ++__i)
{ {
double __den; std::vector<_RealType> __int_vec;
__is >> __den; if (__detail::__extract_params(__is, __int_vec, __n + 1))
__den_vec.push_back(__den); {
std::vector<double> __den_vec;
if (__detail::__extract_params(__is, __den_vec, __n))
{
__x.param({ __int_vec.begin(), __int_vec.end(),
__den_vec.begin() });
}
}
} }
__x.param(typename piecewise_constant_distribution<_RealType>::
param_type(__int_vec.begin(), __int_vec.end(), __den_vec.begin()));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
} }
...@@ -3166,8 +3139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3166,8 +3139,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator<<(std::basic_ostream<_CharT, _Traits>& __os, operator<<(std::basic_ostream<_CharT, _Traits>& __os,
const piecewise_linear_distribution<_RealType>& __x) const piecewise_linear_distribution<_RealType>& __x)
{ {
typedef std::basic_ostream<_CharT, _Traits> __ostream_type; using __ios_base = typename basic_ostream<_CharT, _Traits>::ios_base;
typedef typename __ostream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __os.flags(); const typename __ios_base::fmtflags __flags = __os.flags();
const _CharT __fill = __os.fill(); const _CharT __fill = __os.fill();
...@@ -3198,36 +3170,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -3198,36 +3170,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator>>(std::basic_istream<_CharT, _Traits>& __is, operator>>(std::basic_istream<_CharT, _Traits>& __is,
piecewise_linear_distribution<_RealType>& __x) piecewise_linear_distribution<_RealType>& __x)
{ {
typedef std::basic_istream<_CharT, _Traits> __istream_type; using __ios_base = typename basic_istream<_CharT, _Traits>::ios_base;
typedef typename __istream_type::ios_base __ios_base;
const typename __ios_base::fmtflags __flags = __is.flags(); const typename __ios_base::fmtflags __flags = __is.flags();
__is.flags(__ios_base::dec | __ios_base::skipws); __is.flags(__ios_base::dec | __ios_base::skipws);
size_t __n; size_t __n;
__is >> __n; if (__is >> __n)
std::vector<_RealType> __int_vec;
__int_vec.reserve(__n + 1);
for (size_t __i = 0; __i <= __n; ++__i)
{ {
_RealType __int; vector<_RealType> __int_vec;
__is >> __int; if (__detail::__extract_params(__is, __int_vec, __n + 1))
__int_vec.push_back(__int); {
} vector<double> __den_vec;
if (__detail::__extract_params(__is, __den_vec, __n + 1))
std::vector<double> __den_vec; {
__den_vec.reserve(__n + 1); __x.param({ __int_vec.begin(), __int_vec.end(),
for (size_t __i = 0; __i <= __n; ++__i) __den_vec.begin() });
{ }
double __den; }
__is >> __den;
__den_vec.push_back(__den);
} }
__x.param(typename piecewise_linear_distribution<_RealType>::
param_type(__int_vec.begin(), __int_vec.end(), __den_vec.begin()));
__is.flags(__flags); __is.flags(__flags);
return __is; return __is;
} }
......
...@@ -12,4 +12,4 @@ auto x = std::generate_canonical<std::size_t, ...@@ -12,4 +12,4 @@ auto x = std::generate_canonical<std::size_t,
// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 171 } // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 171 }
// { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3320 } // { dg-error "static assertion failed: template argument must be a floating point type" "" { target *-*-* } 3281 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment