aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/ext/random
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/ext/random
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/ext/random')
-rw-r--r--libstdc++-v3/include/ext/random58
1 files changed, 38 insertions, 20 deletions
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));