aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2018-06-14 14:32:53 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2018-06-14 14:32:53 +0100
commit977ac63eab69884aa8d4bd317d7c1b80627d75ef (patch)
tree6ea0e682286cdb690b257cdb36d87684b415527a /libstdc++-v3/include
parent8513bec38c903ccef49286b1dc741303f7df4761 (diff)
downloadgcc-977ac63eab69884aa8d4bd317d7c1b80627d75ef.zip
gcc-977ac63eab69884aa8d4bd317d7c1b80627d75ef.tar.gz
gcc-977ac63eab69884aa8d4bd317d7c1b80627d75ef.tar.bz2
P0935R0 Eradicating unnecessarily explicit default constructors
The param_type constructors of each random number distribution should mirror the constructors of the distribution itself, so make the same changes w.r.t explicit on default constructors. * include/bits/random.h (uniform_real_distribution::param_type) (normal_distribution::param_type, lognormal_distribution::param_type) (gamma_distribution::param_type, chi_squared_distribution::param_type) (cauchy_distribution::param_type, fisher_f_distribution::param_type) (student_t_distribution::param_type) (bernoulli_distribution::param_type) (binomial_distribution::param_type) (geometric_distribution::param_type) (negative_binomial_distribution::param_type) (poisson_distribution::param_type) (exponential_distribution::param_type) (weibull_distribution::param_type) (extreme_value_distribution::param_type): Add non-explicit default constructors. Remove default argument for first parameter of explicit constructors. * include/bits/uniform_int_dist.h (uniform_int_distribution::param_type): Likewise. * include/ext/random (beta_distribution::param_type, rice_distribution::param_type) (nakagami_distribution::param_type, pareto_distribution::param_type) (k_distribution::param_type, arcsine_distribution::param_type) (hoyt_distribution::param_type, triangular_distribution::param_type) (von_mises_distribution::param_type) (hypergeometric_distribution::param_type) (logistic_distribution::param_type) (uniform_inside_sphere_distribution::param_type): Likewise. (uniform_on_sphere_distribution::param_type): Make default constructor non-explicit. * testsuite/26_numerics/random/bernoulli_distribution/cons/default.cc: Test param_type for non-explicit default constructor. * testsuite/26_numerics/random/binomial_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/cauchy_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/chi_squared_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/discrete_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/exponential_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/extreme_value_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/fisher_f_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/gamma_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/geometric_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/lognormal_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/negative_binomial_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/normal_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/piecewise_constant_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/piecewise_linear_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/poisson_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/student_t_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/uniform_real_distribution/cons/default.cc: Likewise. * testsuite/26_numerics/random/weibull_distribution/cons/default.cc: Likewise. * testsuite/ext/random/arcsine_distribution/cons/default.cc: Likewise. * testsuite/ext/random/beta_distribution/cons/default.cc: Likewise. * testsuite/ext/random/hoyt_distribution/cons/default.cc: Likewise. * testsuite/ext/random/hypergeometric_distribution/cons/default.cc: Likewise. * testsuite/ext/random/k_distribution/cons/default.cc: Likewise. * testsuite/ext/random/logistic_distribution/cons/default.cc: Likewise. * testsuite/ext/random/nakagami_distribution/cons/default.cc: Likewise. * testsuite/ext/random/normal_mv_distribution/cons/default.cc: Likewise. * testsuite/ext/random/pareto_distribution/cons/default.cc: Likewise. * testsuite/ext/random/rice_distribution/cons/default.cc: Likewise. * testsuite/ext/random/triangular_distribution/cons/default.cc: Likewise. * testsuite/ext/random/uniform_inside_sphere_distribution/cons/default.cc: Likewise. * testsuite/ext/random/uniform_on_sphere_distribution/cons/default.cc: Likewise. * testsuite/ext/random/von_mises_distribution/cons/default.cc: Likewise. From-SVN: r261592
Diffstat (limited to 'libstdc++-v3/include')
-rw-r--r--libstdc++-v3/include/bits/random.h72
-rw-r--r--libstdc++-v3/include/bits/uniform_int_dist.h8
-rw-r--r--libstdc++-v3/include/ext/random58
3 files changed, 91 insertions, 47 deletions
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index 252b14d..738c62f 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -1745,9 +1745,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef uniform_real_distribution<_RealType> distribution_type;
+ param_type() : param_type(0) { }
+
explicit
- param_type(_RealType __a = _RealType(0),
- _RealType __b = _RealType(1))
+ param_type(_RealType __a, _RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_a <= _M_b);
@@ -1974,9 +1975,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef normal_distribution<_RealType> distribution_type;
+ param_type() : param_type(0.0) { }
+
explicit
- param_type(_RealType __mean = _RealType(0),
- _RealType __stddev = _RealType(1))
+ param_type(_RealType __mean, _RealType __stddev = _RealType(1))
: _M_mean(__mean), _M_stddev(__stddev)
{
__glibcxx_assert(_M_stddev > _RealType(0));
@@ -2194,9 +2196,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef lognormal_distribution<_RealType> distribution_type;
+ param_type() : param_type(0.0) { }
+
explicit
- param_type(_RealType __m = _RealType(0),
- _RealType __s = _RealType(1))
+ param_type(_RealType __m, _RealType __s = _RealType(1))
: _M_m(__m), _M_s(__s)
{ }
@@ -2405,9 +2408,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef gamma_distribution<_RealType> distribution_type;
friend class gamma_distribution<_RealType>;
+ param_type() : param_type(1.0) { }
+
explicit
- param_type(_RealType __alpha_val = _RealType(1),
- _RealType __beta_val = _RealType(1))
+ param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
__glibcxx_assert(_M_alpha > _RealType(0));
@@ -2631,8 +2635,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef chi_squared_distribution<_RealType> distribution_type;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_RealType __n = _RealType(1))
+ param_type(_RealType __n)
: _M_n(__n)
{ }
@@ -2853,9 +2859,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef cauchy_distribution<_RealType> distribution_type;
+ param_type() : param_type(0) { }
+
explicit
- param_type(_RealType __a = _RealType(0),
- _RealType __b = _RealType(1))
+ param_type(_RealType __a, _RealType __b = _RealType(1))
: _M_a(__a), _M_b(__b)
{ }
@@ -3060,9 +3067,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef fisher_f_distribution<_RealType> distribution_type;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_RealType __m = _RealType(1),
- _RealType __n = _RealType(1))
+ param_type(_RealType __m, _RealType __n = _RealType(1))
: _M_m(__m), _M_n(__n)
{ }
@@ -3291,8 +3299,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef student_t_distribution<_RealType> distribution_type;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_RealType __n = _RealType(1))
+ param_type(_RealType __n)
: _M_n(__n)
{ }
@@ -3513,8 +3523,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef bernoulli_distribution distribution_type;
+ param_type() : param_type(0.5) { }
+
explicit
- param_type(double __p = 0.5)
+ param_type(double __p)
: _M_p(__p)
{
__glibcxx_assert((_M_p >= 0.0) && (_M_p <= 1.0));
@@ -3732,8 +3744,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef binomial_distribution<_IntType> distribution_type;
friend class binomial_distribution<_IntType>;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_IntType __t = _IntType(1), double __p = 0.5)
+ param_type(_IntType __t, double __p = 0.5)
: _M_t(__t), _M_p(__p)
{
__glibcxx_assert((_M_t >= _IntType(0))
@@ -3970,8 +3984,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef geometric_distribution<_IntType> distribution_type;
friend class geometric_distribution<_IntType>;
+ param_type() : param_type(0.5) { }
+
explicit
- param_type(double __p = 0.5)
+ param_type(double __p)
: _M_p(__p)
{
__glibcxx_assert((_M_p > 0.0) && (_M_p < 1.0));
@@ -4177,8 +4193,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef negative_binomial_distribution<_IntType> distribution_type;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_IntType __k = 1, double __p = 0.5)
+ param_type(_IntType __k, double __p = 0.5)
: _M_k(__k), _M_p(__p)
{
__glibcxx_assert((_M_k > 0) && (_M_p > 0.0) && (_M_p <= 1.0));
@@ -4407,8 +4425,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef poisson_distribution<_IntType> distribution_type;
friend class poisson_distribution<_IntType>;
+ param_type() : param_type(1.0) { }
+
explicit
- param_type(double __mean = 1.0)
+ param_type(double __mean)
: _M_mean(__mean)
{
__glibcxx_assert(_M_mean > 0.0);
@@ -4630,8 +4650,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef exponential_distribution<_RealType> distribution_type;
+ param_type() : param_type(1.0) { }
+
explicit
- param_type(_RealType __lambda = _RealType(1))
+ param_type(_RealType __lambda)
: _M_lambda(__lambda)
{
__glibcxx_assert(_M_lambda > _RealType(0));
@@ -4843,9 +4865,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef weibull_distribution<_RealType> distribution_type;
+ param_type() : param_type(1.0) { }
+
explicit
- param_type(_RealType __a = _RealType(1),
- _RealType __b = _RealType(1))
+ param_type(_RealType __a, _RealType __b = _RealType(1.0))
: _M_a(__a), _M_b(__b)
{ }
@@ -5052,9 +5075,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef extreme_value_distribution<_RealType> distribution_type;
+ param_type() : param_type(0.0) { }
+
explicit
- param_type(_RealType __a = _RealType(0),
- _RealType __b = _RealType(1))
+ param_type(_RealType __a, _RealType __b = _RealType(1.0))
: _M_a(__a), _M_b(__b)
{ }
diff --git a/libstdc++-v3/include/bits/uniform_int_dist.h b/libstdc++-v3/include/bits/uniform_int_dist.h
index 3b6d504..f339f62 100644
--- a/libstdc++-v3/include/bits/uniform_int_dist.h
+++ b/libstdc++-v3/include/bits/uniform_int_dist.h
@@ -68,9 +68,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef uniform_int_distribution<_IntType> distribution_type;
+ param_type() : param_type(0) { }
+
explicit
- param_type(_IntType __a = 0,
- _IntType __b = std::numeric_limits<_IntType>::max())
+ param_type(_IntType __a,
+ _IntType __b = numeric_limits<_IntType>::max())
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_a <= _M_b);
@@ -108,7 +110,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
explicit
uniform_int_distribution(_IntType __a,
- _IntType __b = std::numeric_limits<_IntType>::max())
+ _IntType __b = numeric_limits<_IntType>::max())
: _M_param(__a, __b)
{ }
diff --git a/libstdc++-v3/include/ext/random b/libstdc++-v3/include/ext/random
index 3c714f5..7b2d1ea 100644
--- a/libstdc++-v3/include/ext/random
+++ b/libstdc++-v3/include/ext/random
@@ -424,9 +424,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef beta_distribution<_RealType> distribution_type;
friend class beta_distribution<_RealType>;
+ param_type() : param_type(1) { }
+
explicit
- param_type(_RealType __alpha_val = _RealType(1),
- _RealType __beta_val = _RealType(1))
+ param_type(_RealType __alpha_val, _RealType __beta_val = _RealType(1))
: _M_alpha(__alpha_val), _M_beta(__beta_val)
{
__glibcxx_assert(_M_alpha > _RealType(0));
@@ -972,7 +973,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef rice_distribution<result_type> distribution_type;
- param_type(result_type __nu_val = result_type(0),
+ param_type() : param_type(0) { }
+
+ param_type(result_type __nu_val,
result_type __sigma_val = result_type(1))
: _M_nu(__nu_val), _M_sigma(__sigma_val)
{
@@ -1224,7 +1227,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef nakagami_distribution<result_type> distribution_type;
- param_type(result_type __mu_val = result_type(1),
+ param_type() : param_type(1) { }
+
+ param_type(result_type __mu_val,
result_type __omega_val = result_type(1))
: _M_mu(__mu_val), _M_omega(__omega_val)
{
@@ -1467,7 +1472,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef pareto_distribution<result_type> distribution_type;
- param_type(result_type __alpha_val = result_type(1),
+ param_type() : param_type(1) { }
+
+ param_type(result_type __alpha_val,
result_type __mu_val = result_type(1))
: _M_alpha(__alpha_val), _M_mu(__mu_val)
{
@@ -1712,7 +1719,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef k_distribution<result_type> distribution_type;
- param_type(result_type __lambda_val = result_type(1),
+ param_type() : param_type(1) { }
+
+ param_type(result_type __lambda_val,
result_type __mu_val = result_type(1),
result_type __nu_val = result_type(1))
: _M_lambda(__lambda_val), _M_mu(__mu_val), _M_nu(__nu_val)
@@ -1964,8 +1973,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef arcsine_distribution<result_type> distribution_type;
- param_type(result_type __a = result_type(0),
- result_type __b = result_type(1))
+ param_type() : param_type(0) { }
+
+ param_type(result_type __a, result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_a <= _M_b);
@@ -2210,8 +2220,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef hoyt_distribution<result_type> distribution_type;
- param_type(result_type __q = result_type(0.5L),
- result_type __omega = result_type(1))
+ param_type() : param_type(0.5) { }
+
+ param_type(result_type __q, result_type __omega = result_type(1))
: _M_q(__q), _M_omega(__omega)
{
__glibcxx_assert(_M_q > result_type(0));
@@ -2450,8 +2461,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
friend class triangular_distribution<_RealType>;
+ param_type() : param_type(0) { }
+
explicit
- param_type(_RealType __a = _RealType(0),
+ param_type(_RealType __a,
_RealType __b = _RealType(0.5),
_RealType __c = _RealType(1))
: _M_a(__a), _M_b(__b), _M_c(__c)
@@ -2715,9 +2728,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
friend class von_mises_distribution<_RealType>;
+ param_type() : param_type(0) { }
+
explicit
- param_type(_RealType __mu = _RealType(0),
- _RealType __kappa = _RealType(1))
+ param_type(_RealType __mu, _RealType __kappa = _RealType(1))
: _M_mu(__mu), _M_kappa(__kappa)
{
const _RealType __pi = __gnu_cxx::__math_constants<_RealType>::__pi;
@@ -2958,8 +2972,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef hypergeometric_distribution<_UIntType> distribution_type;
friend class hypergeometric_distribution<_UIntType>;
+ param_type() : param_type(10) { }
+
explicit
- param_type(result_type __N = 10, result_type __K = 5,
+ param_type(result_type __N, result_type __K = 5,
result_type __n = 1)
: _M_N{__N}, _M_K{__K}, _M_n{__n}
{
@@ -3224,8 +3240,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
typedef logistic_distribution<result_type> distribution_type;
- param_type(result_type __a = result_type(0),
- result_type __b = result_type(1))
+ param_type() : param_type(0) { }
+
+ explicit
+ param_type(result_type __a, result_type __b = result_type(1))
: _M_a(__a), _M_b(__b)
{
__glibcxx_assert(_M_b > result_type(0));
@@ -3436,9 +3454,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/** Parameter type. */
struct param_type
{
- explicit
- param_type()
- { }
+ param_type() { }
friend bool
operator==(const param_type&, const param_type&)
@@ -3634,8 +3650,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
= uniform_inside_sphere_distribution<_Dimen, _RealType>;
friend class uniform_inside_sphere_distribution<_Dimen, _RealType>;
+ param_type() : param_type(1.0) { }
+
explicit
- param_type(_RealType __radius = _RealType(1))
+ param_type(_RealType __radius)
: _M_radius(__radius)
{
__glibcxx_assert(_M_radius > _RealType(0));