Re: [PATCH] P0935R0 Eradicating unnecessarily explicit default constructors
On 12/06/18 20:10 +0100, Jonathan Wakely wrote: Explicit default constructors are problematic, so this change removes them from and , as per P0935R0. * include/bits/random.h (linear_congruential_engine) (mersenne_twister_engine, subtract_with_carry_engine, random_device) I forgot to remove the default argument in the no-/dev/urandom version of std::random_device. Fixed like so. (Incidentally, it makes me very sad that our std::random_device is 5000 bytes even when it only needs to store a pointer, because we have a union with mt19937 in it). commit 8c359baec670ed7d0305d376ebf8ebb209e50a8a Author: Jonathan Wakely Date: Fri Jun 15 17:10:06 2018 +0100 PR libstdc++/86168 fix ambiguous default constructor PR libstdc++/86168 * include/bits/random.h (random_device(const string&)): Remove default argument. diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h index 738c62fccd1..e59c8b0221d 100644 --- a/libstdc++-v3/include/bits/random.h +++ b/libstdc++-v3/include/bits/random.h @@ -1614,7 +1614,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION random_device() { _M_init("mt19937"); } explicit -random_device(const std::string& __token = "mt19937") +random_device(const std::string& __token) { _M_init_pretr1(__token); } #endif
Re: [PATCH] P0935R0 Eradicating unnecessarily explicit default constructors
Another piece of P0935, this time for , and . The only piece left is . Tested powerpc64le-linux, committed to trunk. commit 0752b4dfd8dba7bae234f6210eea74dc337ade15 Author: Jonathan Wakely Date: Thu Jun 14 14:58:16 2018 +0100 P0935R0 Eradicating unnecessarily explicit default constructors More pieces of P0935R0, making default constructors non-explicit. * include/backward/strstream (strstreambuf): Add non-explicit default constructor. * include/bits/locale_conv.h (wbuffer_convert, wstring_convert): Likewise. * include/bits/regex.h (match_results): Likewise. * testsuite/22_locale/conversions/buffer/1.cc: Test for non-explicit default constructor. * testsuite/22_locale/conversions/string/1.cc: Likewise. * testsuite/28_regex/match_results/ctors/char/default.cc: Likewise. * testsuite/28_regex/match_results/ctors/wchar_t/default.cc: Likewise. diff --git a/libstdc++-v3/include/backward/strstream b/libstdc++-v3/include/backward/strstream index 0429c28ce35..566ad8cd130 100644 --- a/libstdc++-v3/include/backward/strstream +++ b/libstdc++-v3/include/backward/strstream @@ -68,7 +68,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: // Constructor, destructor +#if __cplusplus >= 201103L +strstreambuf() : strstreambuf(0) { } +explicit strstreambuf(streamsize __initial_capacity); +#else explicit strstreambuf(streamsize __initial_capacity = 0); +#endif strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*)); strstreambuf(char* __get, streamsize __n, char* __put = 0) throw (); diff --git a/libstdc++-v3/include/bits/locale_conv.h b/libstdc++-v3/include/bits/locale_conv.h index bc5669f2521..e9b684b4f98 100644 --- a/libstdc++-v3/include/bits/locale_conv.h +++ b/libstdc++-v3/include/bits/locale_conv.h @@ -174,14 +174,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 typedef typename _Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - /** Default constructor. + /// Default constructor. + wstring_convert() : _M_cvt(new _Codecvt()) { } + + /** Constructor. * * @param __pcvt The facet to use for conversions. * * Takes ownership of @p __pcvt and will delete it in the destructor. */ explicit - wstring_convert(_Codecvt* __pcvt = new _Codecvt()) : _M_cvt(__pcvt) + wstring_convert(_Codecvt* __pcvt) : _M_cvt(__pcvt) { if (!_M_cvt) __throw_logic_error("wstring_convert"); @@ -325,7 +328,10 @@ _GLIBCXX_END_NAMESPACE_CXX11 public: typedef typename _Codecvt::state_type state_type; - /** Default constructor. + /// Default constructor. + wbuffer_convert() : wbuffer_convert(nullptr) { } + + /** Constructor. * * @param __bytebuf The underlying byte stream buffer. * @param __pcvtThe facet to use for conversions. @@ -334,7 +340,7 @@ _GLIBCXX_END_NAMESPACE_CXX11 * Takes ownership of @p __pcvt and will delete it in the destructor. */ explicit - wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, + wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()) : _M_buf(__bytebuf), _M_cvt(__pcvt), _M_state(__state) { diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h index 674be9ac50c..6b6501e98ae 100644 --- a/libstdc++-v3/include/bits/regex.h +++ b/libstdc++-v3/include/bits/regex.h @@ -1600,12 +1600,17 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 /** * @brief Constructs a default %match_results container. * @post size() returns 0 and str() returns an empty string. + * @{ */ + match_results() : match_results(_Alloc()) { } + explicit - match_results(const _Alloc& __a = _Alloc()) noexcept + match_results(const _Alloc& __a) noexcept : _Base_type(__a) { } + // @} + /** * @brief Copy constructs a %match_results. */ diff --git a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc index 5d0c664679b..0f3f9ffb35a 100644 --- a/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc +++ b/libstdc++-v3/testsuite/22_locale/conversions/buffer/1.cc @@ -22,6 +22,7 @@ #include #include #include +#include template struct cvt : std::codecvt { }; @@ -42,6 +43,9 @@ void test01() VERIFY( buf.rdbuf() == nullptr ); VERIFY( buf.rdbuf() == ); VERIFY( buf.rdbuf(nullptr) == ); + + __gnu_test::implicitly_default_constructible test; + test.operator()>(); // P0935R0 } void test02() diff --git a/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc b/libstdc++-v3/testsuite/22_locale/conversions/string/1.cc index ff260267e87..a2a8641d520 100644 ---
Re: [PATCH] P0935R0 Eradicating unnecessarily explicit default constructors
On 14/06/18 11:46 +0100, Jonathan Wakely wrote: On 14/06/18 06:43 -0400, Tim Song wrote: Since param_type's constructors are defined by reference to the constructors of the distribution, P0935's changes to the distribution's constructors apply to their param_type as well. Back to the patch mines I go ... This repeats the same changes to the param types. Tested powerpc64le-linux, committed to trunk. (The rest of P0935 is still to be done, because it requires some new symbols to be exported from the DSO). commit 09f385bdb64741901461712c2e9be74db46ebdc7 Author: Jonathan Wakely Date: Thu Jun 14 14:15:19 2018 +0100 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:
Re: [PATCH] P0935R0 Eradicating unnecessarily explicit default constructors
On 14/06/18 06:43 -0400, Tim Song wrote: Since param_type's constructors are defined by reference to the constructors of the distribution, P0935's changes to the distribution's constructors apply to their param_type as well. Back to the patch mines I go ...
Re: [PATCH] P0935R0 Eradicating unnecessarily explicit default constructors
Since param_type's constructors are defined by reference to the constructors of the distribution, P0935's changes to the distribution's constructors apply to their param_type as well.