diff --git a/libcxx/docs/Cxx2aStatusPaperStatus.csv b/libcxx/docs/Cxx2aStatusPaperStatus.csv --- a/libcxx/docs/Cxx2aStatusPaperStatus.csv +++ b/libcxx/docs/Cxx2aStatusPaperStatus.csv @@ -44,7 +44,7 @@ "`P0887R1 `__","LWG","The identity metafunction","Rapperswil","|Complete|","8.0" "`P0892R2 `__","CWG","explicit(bool)","Rapperswil","","" "`P0898R3 `__","LWG","Standard Library Concepts","Rapperswil","","" -"`P0935R0 `__","LWG","Eradicating unnecessarily explicit default constructors from the standard library","Rapperswil","","" +"`P0935R0 `__","LWG","Eradicating unnecessarily explicit default constructors from the standard library","Rapperswil","|Complete|","12.0" "`P0941R2 `__","CWG","Integrating feature-test macros into the C++ WD","Rapperswil","|In Progress|","" "`P1023R0 `__","LWG","constexpr comparison operators for std::array","Rapperswil","|Complete|","8.0" "`P1025R1 `__","CWG","Update The Reference To The Unicode Standard","Rapperswil","","" diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm --- a/libcxx/include/algorithm +++ b/libcxx/include/algorithm @@ -3029,9 +3029,17 @@ public: // constructors and reset functions - explicit uniform_int_distribution(result_type __a = 0, - result_type __b = numeric_limits::max()) +#ifndef _LIBCPP_CXX03_LANG + uniform_int_distribution() : uniform_int_distribution(0) {} + explicit uniform_int_distribution( + result_type __a, result_type __b = numeric_limits::max()) + : __p_(param_type(__a, __b)) {} +#else + explicit uniform_int_distribution( + result_type __a = 0, + result_type __b = numeric_limits::max()) : __p_(param_type(__a, __b)) {} +#endif explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {} void reset() {} diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -92,7 +92,11 @@ typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 + wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14 + explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20 + wstring_convert() : wstring_convert(new Codecvt) {} // C++20 + explicit wstring_convert(Codecvt* pcvt); // C++20 + wstring_convert(Codecvt* pcvt, state_type state); explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); @@ -121,8 +125,14 @@ public: typedef typename Tr::state_type state_type; - explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, - state_type state = state_type()); // explicit in C++14 + wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // before C++14 + explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // before C++20 + wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20 + explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // C++20 + wbuffer_convert(const wbuffer_convert&) = delete; // C++14 wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 ~wbuffer_convert(); // C++14 @@ -3650,8 +3660,17 @@ wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); + wstring_convert() : wstring_convert(new _Codecvt) {} + _LIBCPP_INLINE_VISIBILITY + explicit wstring_convert(_Codecvt* __pcvt); +#else + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_EXPLICIT_AFTER_CXX11 + wstring_convert(_Codecvt* __pcvt = new _Codecvt); +#endif + _LIBCPP_INLINE_VISIBILITY wstring_convert(_Codecvt* __pcvt, state_type __state); _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, @@ -3918,9 +3937,20 @@ wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); + public: - _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = nullptr, - _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); +#ifndef _LIBCPP_CXX03_LANG + wbuffer_convert() : wbuffer_convert(nullptr) {} + explicit wbuffer_convert(streambuf* __bytebuf, + _Codecvt* __pcvt = new _Codecvt, + state_type __state = state_type()); +#else + _LIBCPP_EXPLICIT_AFTER_CXX11 + wbuffer_convert(streambuf* __bytebuf = nullptr, + _Codecvt* __pcvt = new _Codecvt, + state_type __state = state_type()); +#endif + ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/queue b/libcxx/include/queue --- a/libcxx/include/queue +++ b/libcxx/include/queue @@ -112,18 +112,11 @@ Compare comp; public: - priority_queue() = default; - ~priority_queue() = default; - - priority_queue(const priority_queue& q) = default; - priority_queue(priority_queue&& q) = default; - - priority_queue& operator=(const priority_queue& q) = default; - priority_queue& operator=(priority_queue&& q) = default; - - explicit priority_queue(const Compare& comp); - priority_queue(const Compare& comp, const container_type& c); - explicit priority_queue(const Compare& comp, container_type&& c); + priority_queue() : priority_queue(Compare()) {} // C++20 + explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} + priority_queue(const Compare& x, const Container&); + explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20 + priority_queue(const Compare& x, Container&&); // C++20 template priority_queue(InputIterator first, InputIterator last, const Compare& comp = Compare()); @@ -474,7 +467,7 @@ priority_queue(const value_compare& __comp, const container_type& __c); #ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit priority_queue(const value_compare& __comp, container_type&& __c); + priority_queue(const value_compare& __comp, container_type&& __c); #endif template _LIBCPP_INLINE_VISIBILITY diff --git a/libcxx/include/random b/libcxx/include/random --- a/libcxx/include/random +++ b/libcxx/include/random @@ -36,7 +36,9 @@ static constexpr result_type default_seed = 1u; // constructors and seeding functions - explicit linear_congruential_engine(result_type s = default_seed); + explicit linear_congruential_engine(result_type s = default_seed); // before C++20 + linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20 + explicit linear_congruential_engine(result_type s); // C++20 template explicit linear_congruential_engine(Sseq& q); void seed(result_type s = default_seed); template void seed(Sseq& q); @@ -96,7 +98,9 @@ static constexpr result_type default_seed = 5489u; // constructors and seeding functions - explicit mersenne_twister_engine(result_type value = default_seed); + explicit mersenne_twister_engine(result_type s = default_seed); // before C++20 + mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20 + explicit mersenne_twister_engine(result_type s); // C++20 template explicit mersenne_twister_engine(Sseq& q); void seed(result_type value = default_seed); template void seed(Sseq& q); @@ -154,7 +158,9 @@ static constexpr result_type default_seed = 19780503u; // constructors and seeding functions - explicit subtract_with_carry_engine(result_type value = default_seed); + explicit subtract_with_carry_engine(result_type value = default_seed); // before C++20 + subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20 + explicit subtract_with_carry_engine(result_type value); // C++20 template explicit subtract_with_carry_engine(Sseq& q); void seed(result_type value = default_seed); template void seed(Sseq& q); @@ -385,7 +391,9 @@ static constexpr result_type max() { return numeric_limits::max(); } // constructors - explicit random_device(const string& token = "/dev/urandom"); + explicit random_device(const string& token = implementation-defined); // before C++20 + random_device() : random_device(implementation-defined) {} // C++20 + explicit random_device(const string& token); // C++20 // generating functions result_type operator()(); @@ -456,7 +464,10 @@ // constructors and reset functions explicit uniform_int_distribution(IntType a = 0, - IntType b = numeric_limits::max()); + IntType b = numeric_limits::max()); // before C++20 + uniform_int_distribution() : uniform_int_distribution(0) {} // C++20 + explicit uniform_int_distribution(IntType a, + IntType b = numeric_limits::max()); // C++20 explicit uniform_int_distribution(const param_type& parm); void reset(); @@ -515,7 +526,9 @@ }; // constructors and reset functions - explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); + explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20 + uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20 + explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20 explicit uniform_real_distribution(const param_type& parm); void reset(); @@ -571,7 +584,9 @@ }; // constructors and reset functions - explicit bernoulli_distribution(double p = 0.5); + explicit bernoulli_distribution(double p = 0.5); // before C++20 + bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20 + explicit bernoulli_distribution(double p); // C++20 explicit bernoulli_distribution(const param_type& parm); void reset(); @@ -628,7 +643,9 @@ }; // constructors and reset functions - explicit binomial_distribution(IntType t = 1, double p = 0.5); + explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20 + binomial_distribution() : binomial_distribution(1) {} // C++20 + explicit binomial_distribution(IntType t, double p = 0.5); // C++20 explicit binomial_distribution(const param_type& parm); void reset(); @@ -685,7 +702,9 @@ }; // constructors and reset functions - explicit geometric_distribution(double p = 0.5); + explicit geometric_distribution(double p = 0.5); // before C++20 + geometric_distribution() : geometric_distribution(0.5) {} // C++20 + explicit geometric_distribution(double p); // C++20 explicit geometric_distribution(const param_type& parm); void reset(); @@ -742,7 +761,9 @@ }; // constructor and reset functions - explicit negative_binomial_distribution(result_type k = 1, double p = 0.5); + explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20 + negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20 + explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20 explicit negative_binomial_distribution(const param_type& parm); void reset(); @@ -799,7 +820,9 @@ }; // constructors and reset functions - explicit poisson_distribution(double mean = 1.0); + explicit poisson_distribution(double mean = 1.0); // before C++20 + poisson_distribution() : poisson_distribution(1.0) {} // C++20 + explicit poisson_distribution(double mean); // C++20 explicit poisson_distribution(const param_type& parm); void reset(); @@ -855,7 +878,9 @@ }; // constructors and reset functions - explicit exponential_distribution(result_type lambda = 1.0); + explicit exponential_distribution(RealType lambda = 1.0); // before C++20 + exponential_distribution() : exponential_distribution(1.0) {} // C++20 + explicit exponential_distribution(RealType lambda); // C++20 explicit exponential_distribution(const param_type& parm); void reset(); @@ -912,7 +937,9 @@ }; // constructors and reset functions - explicit gamma_distribution(result_type alpha = 1, result_type beta = 1); + explicit gamma_distribution(RealType alpha = 0.0, RealType beta = 1.0); // before C++20 + gamma_distribution() : gamma_distribution(0.0) {} // C++20 + explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20 explicit gamma_distribution(const param_type& parm); void reset(); @@ -970,7 +997,9 @@ }; // constructor and reset functions - explicit weibull_distribution(result_type a = 1, result_type b = 1); + explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20 + weibull_distribution() : weibull_distribution(1.0) {} // C++20 + explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20 explicit weibull_distribution(const param_type& parm); void reset(); @@ -1028,7 +1057,9 @@ }; // constructor and reset functions - explicit extreme_value_distribution(result_type a = 0, result_type b = 1); + explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20 + extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20 + explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20 explicit extreme_value_distribution(const param_type& parm); void reset(); @@ -1086,7 +1117,9 @@ }; // constructors and reset functions - explicit normal_distribution(result_type mean = 0, result_type stddev = 1); + explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20 + normal_distribution() : normal_distribution(0.0) {} // C++20 + explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20 explicit normal_distribution(const param_type& parm); void reset(); @@ -1144,7 +1177,9 @@ }; // constructor and reset functions - explicit lognormal_distribution(result_type m = 0, result_type s = 1); + explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20 + lognormal_distribution() : lognormal_distribution(0.0) {} // C++20 + explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20 explicit lognormal_distribution(const param_type& parm); void reset(); @@ -1201,7 +1236,9 @@ }; // constructor and reset functions - explicit chi_squared_distribution(result_type n = 1); + explicit chi_squared_distribution(RealType n = 1.0); // before C++20 + chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20 + explicit chi_squared_distribution(RealType n); // C++20 explicit chi_squared_distribution(const param_type& parm); void reset(); @@ -1258,7 +1295,9 @@ }; // constructor and reset functions - explicit cauchy_distribution(result_type a = 0, result_type b = 1); + explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20 + cauchy_distribution() : cauchy_distribution(0.0) {} // C++20 + explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20 explicit cauchy_distribution(const param_type& parm); void reset(); @@ -1316,7 +1355,9 @@ }; // constructor and reset functions - explicit fisher_f_distribution(result_type m = 1, result_type n = 1); + explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20 + fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20 + explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20 explicit fisher_f_distribution(const param_type& parm); void reset(); @@ -1373,7 +1414,9 @@ }; // constructor and reset functions - explicit student_t_distribution(result_type n = 1); + explicit student_t_distribution(RealType n = 1.0); // before C++20 + student_t_distribution() : student_t_distribution(1.0) {} // C++20 + explicit student_t_distribution(RealType n); // C++20 explicit student_t_distribution(const param_type& parm); void reset(); @@ -1875,9 +1918,17 @@ static _LIBCPP_CONSTEXPR const result_type default_seed = 1u; // constructors and seeding functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + linear_congruential_engine() : linear_congruential_engine(default_seed) {} + _LIBCPP_INLINE_VISIBILITY + explicit linear_congruential_engine(result_type __s) { seed(__s); } +#else _LIBCPP_INLINE_VISIBILITY - explicit linear_congruential_engine(result_type __s = default_seed) - {seed(__s);} + explicit linear_congruential_engine(result_type __s = default_seed) { + seed(__s); + } +#endif template _LIBCPP_INLINE_VISIBILITY explicit linear_congruential_engine(_Sseq& __q, @@ -2124,9 +2175,17 @@ static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u; // constructors and seeding functions +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit mersenne_twister_engine(result_type __sd = default_seed) - {seed(__sd);} + mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} + _LIBCPP_INLINE_VISIBILITY + explicit mersenne_twister_engine(result_type __sd) { seed(__sd); } +#else + _LIBCPP_INLINE_VISIBILITY + explicit mersenne_twister_engine(result_type __sd = default_seed) { + seed(__sd); + } +#endif template _LIBCPP_INLINE_VISIBILITY explicit mersenne_twister_engine(_Sseq& __q, @@ -2582,9 +2641,17 @@ static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u; // constructors and seeding functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} _LIBCPP_INLINE_VISIBILITY - explicit subtract_with_carry_engine(result_type __sd = default_seed) - {seed(__sd);} + explicit subtract_with_carry_engine(result_type __sd) { seed(__sd); } +#else + _LIBCPP_INLINE_VISIBILITY + explicit subtract_with_carry_engine(result_type __sd = default_seed) { + seed(__sd); + } +#endif template _LIBCPP_INLINE_VISIBILITY explicit subtract_with_carry_engine(_Sseq& __q, @@ -3524,7 +3591,12 @@ static _LIBCPP_CONSTEXPR result_type max() { return _Max;} // constructors +#ifndef _LIBCPP_CXX03_LANG + random_device() : random_device("/dev/urandom") {} + explicit random_device(const string& __token); +#else explicit random_device(const string& __token = "/dev/urandom"); +#endif ~random_device(); // generating functions @@ -3758,9 +3830,16 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + uniform_real_distribution() : uniform_real_distribution(0) {} + explicit uniform_real_distribution(result_type __a, result_type __b = 1) + : __p_(param_type(__a, __b)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit uniform_real_distribution(result_type __a = 0, result_type __b = 1) : __p_(param_type(__a, __b)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit uniform_real_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -3876,9 +3955,15 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + bernoulli_distribution() : bernoulli_distribution(0.5) {} _LIBCPP_INLINE_VISIBILITY - explicit bernoulli_distribution(double __p = 0.5) - : __p_(param_type(__p)) {} + explicit bernoulli_distribution(double __p) : __p_(param_type(__p)) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit bernoulli_distribution(double __p = 0.5) : __p_(param_type(__p)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit bernoulli_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -3994,9 +4079,17 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + binomial_distribution() : binomial_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit binomial_distribution(result_type __t, double __p = 0.5) + : __p_(param_type(__t, __p)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit binomial_distribution(result_type __t = 1, double __p = 0.5) : __p_(param_type(__t, __p)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit binomial_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -4176,9 +4269,17 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + exponential_distribution() : exponential_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit exponential_distribution(result_type __lambda) + : __p_(param_type(__lambda)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit exponential_distribution(result_type __lambda = 1) : __p_(param_type(__lambda)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit exponential_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -4299,9 +4400,18 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + normal_distribution() : normal_distribution(0) {} _LIBCPP_INLINE_VISIBILITY - explicit normal_distribution(result_type __mean = 0, result_type __stddev = 1) + explicit normal_distribution(result_type __mean, result_type __stddev = 1) : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit normal_distribution(result_type __mean = 0, + result_type __stddev = 1) + : __p_(param_type(__mean, __stddev)), _V_hot_(false) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit normal_distribution(const param_type& __p) : __p_(__p), _V_hot_(false) {} @@ -4479,9 +4589,18 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit lognormal_distribution(result_type __m = 0, result_type __s = 1) + lognormal_distribution() : lognormal_distribution(0) {} + _LIBCPP_INLINE_VISIBILITY + explicit lognormal_distribution(result_type __m, result_type __s = 1) : __p_(param_type(__m, __s)) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit lognormal_distribution(result_type __m = 0, + result_type __s = 1) + : __p_(param_type(__m, __s)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit lognormal_distribution(const param_type& __p) : __p_(__p) {} @@ -4599,8 +4718,17 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + poisson_distribution() : poisson_distribution(1.0) {} _LIBCPP_INLINE_VISIBILITY - explicit poisson_distribution(double __mean = 1.0) : __p_(__mean) {} + explicit poisson_distribution(double __mean) + : __p_(__mean) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit poisson_distribution(double __mean = 1.0) + : __p_(__mean) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit poisson_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -4828,9 +4956,17 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + weibull_distribution() : weibull_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit weibull_distribution(result_type __a, result_type __b = 1) + : __p_(param_type(__a, __b)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit weibull_distribution(result_type __a = 1, result_type __b = 1) : __p_(param_type(__a, __b)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit weibull_distribution(const param_type& __p) : __p_(__p) {} @@ -4944,9 +5080,18 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit extreme_value_distribution(result_type __a = 0, result_type __b = 1) + extreme_value_distribution() : extreme_value_distribution(0) {} + _LIBCPP_INLINE_VISIBILITY + explicit extreme_value_distribution(result_type __a, result_type __b = 1) : __p_(param_type(__a, __b)) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit extreme_value_distribution(result_type __a = 0, + result_type __b = 1) + : __p_(param_type(__a, __b)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit extreme_value_distribution(const param_type& __p) : __p_(__p) {} @@ -5067,9 +5212,18 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + gamma_distribution() : gamma_distribution(1) {} _LIBCPP_INLINE_VISIBILITY - explicit gamma_distribution(result_type __alpha = 1, result_type __beta = 1) + explicit gamma_distribution(result_type __alpha, result_type __beta = 1) : __p_(param_type(__alpha, __beta)) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit gamma_distribution(result_type __alpha = 1, + result_type __beta = 1) + : __p_(param_type(__alpha, __beta)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit gamma_distribution(const param_type& __p) : __p_(__p) {} @@ -5241,9 +5395,18 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit negative_binomial_distribution(result_type __k = 1, double __p = 0.5) + negative_binomial_distribution() : negative_binomial_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit negative_binomial_distribution(result_type __k, double __p = 0.5) : __p_(__k, __p) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit negative_binomial_distribution(result_type __k = 1, + double __p = 0.5) + : __p_(__k, __p) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit negative_binomial_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -5374,8 +5537,17 @@ public: // constructors and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + geometric_distribution() : geometric_distribution(0.5) {} _LIBCPP_INLINE_VISIBILITY - explicit geometric_distribution(double __p = 0.5) : __p_(__p) {} + explicit geometric_distribution(double __p) + : __p_(__p) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit geometric_distribution(double __p = 0.5) + : __p_(__p) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit geometric_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY @@ -5478,9 +5650,17 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + chi_squared_distribution() : chi_squared_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit chi_squared_distribution(result_type __n) + : __p_(param_type(__n)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit chi_squared_distribution(result_type __n = 1) : __p_(param_type(__n)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit chi_squared_distribution(const param_type& __p) : __p_(__p) {} @@ -5590,9 +5770,17 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + cauchy_distribution() : cauchy_distribution(0) {} + _LIBCPP_INLINE_VISIBILITY + explicit cauchy_distribution(result_type __a, result_type __b = 1) + : __p_(param_type(__a, __b)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit cauchy_distribution(result_type __a = 0, result_type __b = 1) : __p_(param_type(__a, __b)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit cauchy_distribution(const param_type& __p) : __p_(__p) {} @@ -5715,9 +5903,17 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + fisher_f_distribution() : fisher_f_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit fisher_f_distribution(result_type __m, result_type __n = 1) + : __p_(param_type(__m, __n)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit fisher_f_distribution(result_type __m = 1, result_type __n = 1) : __p_(param_type(__m, __n)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit fisher_f_distribution(const param_type& __p) : __p_(__p) {} @@ -5836,9 +6032,17 @@ public: // constructor and reset functions +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + student_t_distribution() : student_t_distribution(1) {} + _LIBCPP_INLINE_VISIBILITY + explicit student_t_distribution(result_type __n) + : __p_(param_type(__n)) {} +#else _LIBCPP_INLINE_VISIBILITY explicit student_t_distribution(result_type __n = 1) : __p_(param_type(__n)) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit student_t_distribution(const param_type& __p) : __p_(__p) {} diff --git a/libcxx/include/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -455,7 +455,9 @@ typedef basic_string string_type; // construct/copy/destroy: - explicit match_results(const Allocator& a = Allocator()); + explicit match_results(const Allocator& a = Allocator()); // before C++20 + match_results() : match_results(Allocator()) {} // C++20 + explicit match_results(const Allocator& a); // C++20 match_results(const match_results& m); match_results(match_results&& m) noexcept; match_results& operator=(const match_results& m); @@ -5357,7 +5359,13 @@ typedef basic_string string_type; // construct/copy/destroy: +#ifndef _LIBCPP_CXX03_LANG + match_results() : match_results(allocator_type()) {} + explicit match_results(const allocator_type& __a); +#else explicit match_results(const allocator_type& __a = allocator_type()); +#endif + // match_results(const match_results&) = default; // match_results& operator=(const match_results&) = default; // match_results(match_results&& __m) = default; diff --git a/libcxx/include/sstream b/libcxx/include/sstream --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -25,8 +25,10 @@ typedef typename traits_type::off_type off_type; typedef Allocator allocator_type; - // 27.8.1.1 Constructors: - explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); + // 27.8.1.1 [stringbuf.cons], constructors: + explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20 + basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20 + explicit basic_stringbuf(ios_base::openmode which); // C++20 explicit basic_stringbuf(const basic_string& str, ios_base::openmode which = ios_base::in | ios_base::out); basic_stringbuf(basic_stringbuf&& rhs); @@ -71,7 +73,10 @@ typedef Allocator allocator_type; // 27.8.2.1 Constructors: - explicit basic_istringstream(ios_base::openmode which = ios_base::in); + explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20 + basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20 + explicit basic_istringstream(ios_base::openmode which); // C++20 + explicit basic_istringstream(const basic_string& str, ios_base::openmode which = ios_base::in); basic_istringstream(basic_istringstream&& rhs); @@ -107,7 +112,10 @@ typedef Allocator allocator_type; // 27.8.3.1 Constructors/destructor: - explicit basic_ostringstream(ios_base::openmode which = ios_base::out); + explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20 + basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20 + explicit basic_ostringstream(ios_base::openmode which); // C++20 + explicit basic_ostringstream(const basic_string& str, ios_base::openmode which = ios_base::out); basic_ostringstream(basic_ostringstream&& rhs); @@ -143,7 +151,10 @@ typedef Allocator allocator_type; // constructors/destructor - explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); + explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20 + basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20 + explicit basic_stringstream(ios_base::openmode which); // C++20 + explicit basic_stringstream(const basic_string& str, ios_base::openmode which = ios_base::out|ios_base::in); basic_stringstream(basic_stringstream&& rhs); @@ -207,11 +218,20 @@ ios_base::openmode __mode_; public: - // 27.8.1.1 Constructors: + // 30.8.2.1 [stringbuf.cons], constructors +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out) - : __hm_(nullptr), __mode_(__wch) - { } + basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} + + _LIBCPP_INLINE_VISIBILITY + explicit basic_stringbuf(ios_base::openmode __wch) + : __hm_(nullptr), __mode_(__wch) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | + ios_base::out) + : __hm_(nullptr), __mode_(__wch) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit basic_stringbuf(const string_type& __s, @@ -622,12 +642,20 @@ basic_stringbuf __sb_; public: - // 27.8.2.1 Constructors: + // 30.8.3.1 [istringstream.cons], constructors +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + basic_istringstream() : basic_istringstream(ios_base::in) {} + + _LIBCPP_INLINE_VISIBILITY + explicit basic_istringstream(ios_base::openmode __wch) + : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {} +#else _LIBCPP_INLINE_VISIBILITY explicit basic_istringstream(ios_base::openmode __wch = ios_base::in) - : basic_istream<_CharT, _Traits>(&__sb_) - , __sb_(__wch | ios_base::in) - { } + : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) {} +#endif + _LIBCPP_INLINE_VISIBILITY explicit basic_istringstream(const string_type& __s, ios_base::openmode __wch = ios_base::in) @@ -699,12 +727,21 @@ basic_stringbuf __sb_; public: - // 27.8.2.1 Constructors: + // 30.8.4.1 [ostringstream.cons], constructors +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + basic_ostringstream() : basic_ostringstream(ios_base::out) {} + + _LIBCPP_INLINE_VISIBILITY + explicit basic_ostringstream(ios_base::openmode __wch) + : basic_ostream<_CharT, _Traits>(&__sb_), + __sb_(__wch | ios_base::out) {} +#else _LIBCPP_INLINE_VISIBILITY explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out) - : basic_ostream<_CharT, _Traits>(&__sb_) - , __sb_(__wch | ios_base::out) - { } + : basic_ostream<_CharT, _Traits>(&__sb_), + __sb_(__wch | ios_base::out) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit basic_ostringstream(const string_type& __s, @@ -778,12 +815,20 @@ basic_stringbuf __sb_; public: - // 27.8.2.1 Constructors: + // 30.8.5.1 [stringstream.cons], constructors +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY - explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out) - : basic_iostream<_CharT, _Traits>(&__sb_) - , __sb_(__wch) - { } + basic_stringstream() : basic_stringstream(ios_base::in | ios_base::out) {} + + _LIBCPP_INLINE_VISIBILITY + explicit basic_stringstream(ios_base::openmode __wch) + : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {} +#else + _LIBCPP_INLINE_VISIBILITY + explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | + ios_base::out) + : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) {} +#endif _LIBCPP_INLINE_VISIBILITY explicit basic_stringstream(const string_type& __s, diff --git a/libcxx/include/strstream b/libcxx/include/strstream --- a/libcxx/include/strstream +++ b/libcxx/include/strstream @@ -17,7 +17,10 @@ : public basic_streambuf { public: - explicit strstreambuf(streamsize alsize_arg = 0); + explicit strstreambuf(streamsize alsize_arg = 0); // before C++20 + strstreambuf() : strstreambuf(0) {} // C++20 + explicit strstreambuf(streamsize alsize_arg); // C++20 + strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr); strstreambuf(const char* gnext_arg, streamsize n); @@ -140,7 +143,12 @@ : public streambuf { public: +#ifndef _LIBCPP_CXX03_LANG + strstreambuf() : strstreambuf(0) {} + explicit strstreambuf(streamsize __alsize); +#else explicit strstreambuf(streamsize __alsize = 0); +#endif strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); strstreambuf(const char* __gnext, streamsize __n); diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp @@ -15,15 +15,25 @@ #include "test_macros.h" #include "test_allocator.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { - std::priority_queue > > q((std::less())); + typedef std::vector > Container; + typedef std::less Compare; + typedef std::priority_queue Q; + Q q((Compare())); assert(q.size() == 0); q.push(1); q.push(2); assert(q.size() == 2); assert(q.top() == 2); - return 0; +#if TEST_STD_VER >= 11 + static_assert(!test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp @@ -8,13 +8,16 @@ // -// explicit priority_queue(const Compare& comp, const container_type& c); +// priority_queue(const Compare& comp, const Container& c); #include #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template C @@ -28,10 +31,18 @@ int main(int, char**) { - std::vector v = make >(5); - std::priority_queue, std::greater > q(std::greater(), v); + typedef std::vector Container; + typedef std::greater Compare; + typedef std::priority_queue Q; + Container v = make(5); + Q q(Compare(), v); assert(q.size() == 5); assert(q.top() == 0); - return 0; +#if TEST_STD_VER >= 11 + // It should be explicit, so not convertible before C++20. + static_assert(test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp @@ -10,14 +10,15 @@ // -// explicit priority_queue(const Compare& comp, container_type&& c); +// explicit priority_queue(const Compare& comp, Container&& c); // before C++20 +// priority_queue(const Compare& comp, Container&& c); // C++20 #include #include #include "test_macros.h" #include "MoveOnly.h" - +#include "test_convertible.h" template C @@ -29,12 +30,16 @@ return c; } - int main(int, char**) { - std::priority_queue q(std::less(), make >(5)); + typedef std::vector Container; + typedef std::less Compare; + typedef std::priority_queue Q; + Q q(Compare(), make(5)); assert(q.size() == 5); assert(q.top() == MoveOnly(4)); - return 0; + static_assert(test_convertible(), ""); + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp @@ -8,22 +8,34 @@ // -// priority_queue(); +// explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 +// priority_queue() : priority_queue(Compare()) {} // C++20 +// explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} // C++20 #include #include #include "test_macros.h" #include "test_allocator.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { - std::priority_queue > > q; + typedef std::vector > Container; + typedef std::priority_queue Q; + Q q; assert(q.size() == 0); q.push(1); q.push(2); assert(q.size() == 2); assert(q.top() == 2); - return 0; +#if TEST_STD_VER >= 11 + // It should be explicit, so not convertible before C++20. + static_assert(test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp @@ -15,6 +15,9 @@ #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template C @@ -28,8 +31,10 @@ int main(int, char**) { - std::deque d = make >(5); - std::queue q(d); + typedef std::deque Container; + typedef std::queue Q; + Container d = make(5); + Q q(d); assert(q.size() == 5); for (std::size_t i = 0; i < d.size(); ++i) { @@ -37,5 +42,9 @@ q.pop(); } - return 0; +#if TEST_STD_VER >= 11 + static_assert(!test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp @@ -8,17 +8,24 @@ // -// queue(); +// explicit queue(Container&& = Container()); // before C++20 +// queue() : queue(Container()) {} // C++20 +// explicit queue(Container&&); // before C++20 #include #include #include "test_macros.h" #include "test_allocator.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { - std::queue > > q; + typedef std::vector > Container; + typedef std::queue Q; + Q q; assert(q.size() == 0); q.push(1); q.push(2); @@ -26,5 +33,10 @@ assert(q.front() == 1); assert(q.back() == 2); - return 0; +#if TEST_STD_VER >= 11 + // It should be explicit, so not convertible before C++20. + static_assert(test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp @@ -10,14 +10,18 @@ // -// explicit queue(container_type&& c); +// explicit queue(Container&& c = Container()); // before C++20 +// queue() : queue(Container()) {} // C++20 +// explicit queue(Container&& c); // C++20 #include #include #include "test_macros.h" #include "MoveOnly.h" - +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template C @@ -29,11 +33,16 @@ return c; } - int main(int, char**) { - std::queue q(make >(5)); + typedef std::deque Container; + typedef std::queue Q; + Q q(make >(5)); assert(q.size() == 5); - return 0; +#if TEST_STD_VER >= 11 + static_assert(!test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp @@ -8,13 +8,16 @@ // -// explicit stack(const container_type& c); +// explicit stack(const Container&); #include #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template C @@ -28,8 +31,10 @@ int main(int, char**) { - std::deque d = make >(5); - std::stack q(d); + typedef std::deque Container; + typedef std::stack Q; + Container d = make(5); + Q q(d); assert(q.size() == 5); for (std::size_t i = 0; i < d.size(); ++i) { @@ -37,5 +42,9 @@ q.pop(); } - return 0; +#if TEST_STD_VER >= 11 + static_assert(!test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp @@ -8,7 +8,9 @@ // -// stack(); +// explicit stack(Container&& = Container()); // before C++20 +// stack() : stack(Container()) {} // C++20 +// explicit stack(Container&&); // before C++20 #include #include @@ -16,15 +18,25 @@ #include "test_macros.h" #include "test_allocator.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { - std::stack > > q; + typedef std::vector > Container; + typedef std::stack Q; + Q q; assert(q.size() == 0); q.push(1); q.push(2); assert(q.size() == 2); assert(q.top() == 2); - return 0; +#if TEST_STD_VER >= 11 + // It should be explicit, so not convertible before C++20. + static_assert(test_convertible(), ""); +#endif + + return 0; } diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp --- a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp +++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp @@ -10,14 +10,18 @@ // -// explicit stack(container_type&& c); +// explicit stack(Container&&= Container()); // before C++20 +// stack() : stack(Container()) {} // C++20 +// explicit stack(Container&&); // C++20 #include #include #include "test_macros.h" #include "MoveOnly.h" - +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template C @@ -29,11 +33,16 @@ return c; } - int main(int, char**) { - std::stack q(make >(5)); + typedef std::deque Container; + typedef std::stack Q; + Q q(make(5)); assert(q.size() == 5); +#if TEST_STD_VER >= 11 + static_assert(!test_convertible(), ""); +#endif + return 0; } diff --git a/libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp b/libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp --- a/libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp +++ b/libcxx/test/std/depr/depr.str.strstreams/depr.strstreambuf/depr.strstreambuf.cons/default.pass.cpp @@ -10,12 +10,17 @@ // class strstreambuf -// explicit strstreambuf(streamsize alsize_arg = 0); +// explicit strstreambuf(streamsize alsize_arg = 0); // before C++20 +// strstreambuf() : strstreambuf(0) {} // C++20 +// explicit strstreambuf(streamsize alsize_arg); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { @@ -30,5 +35,13 @@ assert(s.pcount() == 0); } - return 0; +#if TEST_STD_VER >= 11 + { + typedef std::strstreambuf B; + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); + } +#endif + + return 0; } diff --git a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp --- a/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/string.streams/istringstream/istringstream.cons/default.pass.cpp @@ -11,12 +11,23 @@ // template , class Allocator = allocator > // class basic_istringstream -// explicit basic_istringstream(ios_base::openmode which = ios_base::in); +// explicit basic_istringstream(ios_base::openmode which = ios_base::in); // before C++20 +// basic_istringstream() : basic_istringstream(ios_base::in) {} // C++20 +// explicit basic_istringstream(ios_base::openmode which); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" + +template +void test() { + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); +} +#endif int main(int, char**) { @@ -45,5 +56,10 @@ assert(ss.str() == L""); } - return 0; +#if TEST_STD_VER >= 11 + test(); + test(); +#endif + + return 0; } diff --git a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp --- a/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/string.streams/ostringstream/ostringstream.cons/default.pass.cpp @@ -11,12 +11,23 @@ // template , class Allocator = allocator > // class basic_ostringstream -// explicit basic_ostringstream(ios_base::openmode which = ios_base::in); +// explicit basic_ostringstream(ios_base::openmode which = ios_base::out); // before C++20 +// basic_ostringstream() : basic_ostringstream(ios_base::out) {} // C++20 +// explicit basic_ostringstream(ios_base::openmode which); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" + +template +void test() { + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); +} +#endif int main(int, char**) { @@ -45,5 +56,10 @@ assert(ss.str() == L""); } - return 0; +#if TEST_STD_VER >= 11 + test(); + test(); +#endif + + return 0; } diff --git a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp --- a/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/string.streams/stringbuf/stringbuf.cons/default.pass.cpp @@ -11,12 +11,17 @@ // template , class Allocator = allocator > // class basic_stringbuf -// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); +// explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); // before C++20 +// basic_stringbuf() : basic_stringbuf(ios_base::in | ios_base::out) {} // C++20 +// explicit basic_stringbuf(ios_base::openmode which); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif template struct testbuf @@ -52,5 +57,13 @@ buf.check(); } - return 0; +#if TEST_STD_VER >= 11 + { + typedef std::stringbuf B; + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); + } +#endif + + return 0; } diff --git a/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp b/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp --- a/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp +++ b/libcxx/test/std/input.output/string.streams/stringstream.cons/default.pass.cpp @@ -11,12 +11,23 @@ // template , class Allocator = allocator > // class basic_stringstream -// explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); +// explicit basic_stringstream(ios_base::openmode which = ios_base::out | ios_base::in); // before C++20 +// basic_stringstream() : basic_stringstream(ios_base::out | ios_base::in) {} // C++20 +// explicit basic_stringstream(ios_base::openmode which); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" + +template +void test() { + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); +} +#endif int main(int, char**) { @@ -45,5 +56,10 @@ assert(ss.str() == L""); } - return 0; +#if TEST_STD_VER >= 11 + test(); + test(); +#endif + + return 0; } diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp --- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp +++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp @@ -10,8 +10,13 @@ // wbuffer_convert -// wbuffer_convert(streambuf *bytebuf = 0, Codecvt *pcvt = new Codecvt, -// state_type state = state_type()); +// wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, +// state_type state = state_type()); // before C++14 +// explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt, +// state_type state = state_type()); // before C++20 +// wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20 +// explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt, +// state_type state = state_type()); // C++20 #include #include @@ -20,6 +25,9 @@ #include "test_macros.h" #include "count_new.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { @@ -57,5 +65,12 @@ } assert(globalMemCounter.checkOutstandingNewEq(0)); - return 0; +#if TEST_STD_VER >= 11 + { + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); + } +#endif + + return 0; } diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp --- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp +++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp @@ -10,13 +10,19 @@ // wstring_convert -// wstring_convert(Codecvt* pcvt = new Codecvt); +// wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14 +// explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20 +// wstring_convert() : wstring_convert(new Codecvt) {} // C++20 +// explicit wstring_convert(Codecvt* pcvt); // C++20 #include #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif int main(int, char**) { @@ -37,5 +43,14 @@ #endif } - return 0; +#if TEST_STD_VER >= 11 + { + typedef std::codecvt_utf8 Codecvt; + typedef std::wstring_convert B; + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); + } +#endif + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp b/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.device/ctor.pass.cpp @@ -18,7 +18,9 @@ // class random_device; -// explicit random_device(const string& token = implementation-defined); +// explicit random_device(const string& token = implementation-defined); // before C++20 +// random_device() : random_device(implementation-defined) {} // C++20 +// explicit random_device(const string& token); // C++20 // For the following ctors, the standard states: "The semantics and default // value of the token parameter are implementation-defined". Implementations @@ -34,7 +36,9 @@ #endif #include "test_macros.h" - +#if TEST_STD_VER >= 11 +#include "test_convertible.h" +#endif bool is_valid_random_device(const std::string &token) { #if defined(_LIBCPP_USING_DEV_RANDOM) @@ -61,7 +65,6 @@ #endif } - int main(int, char**) { { std::random_device r; @@ -100,5 +103,9 @@ } #endif // !defined(_WIN32) +#if TEST_STD_VER >= 11 + static_assert(test_convertible(), ""); +#endif + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bernoulli/ctor_double.pass.cpp @@ -10,12 +10,18 @@ // class bernoulli_distribution -// explicit bernoulli_distribution(double p = 0.5); +// explicit bernoulli_distribution(double p = 0.5); // before C++20 +// bernoulli_distribution() : bernoulli_distribution(0.5) {} // C++20 +// explicit bernoulli_distribution(double p); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif int main(int, char**) { @@ -35,5 +41,14 @@ assert(d.p() == 0.75); } - return 0; +#if TEST_STD_VER >= 11 + { + typedef std::bernoulli_distribution D; + static_assert(test_convertible(), ""); + assert(D(0.5) == make_implicit()); + static_assert(!test_convertible(), ""); + } +#endif + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp @@ -11,12 +11,29 @@ // template // class binomial_distribution -// explicit binomial_distribution(IntType t = 1, double p = 0.5); +// explicit binomial_distribution(IntType t = 1, double p = 0.5); // before C++20 +// binomial_distribution() : binomial_distribution(1) {} // C++20 +// explicit binomial_distribution(IntType t, double p = 0.5); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::binomial_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.p() == 0.75); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.geo/ctor_double.pass.cpp @@ -11,12 +11,28 @@ // template // class geometric_distribution -// explicit geometric_distribution(double p = 0.5); +// explicit geometric_distribution(double p = 0.5); // before C++20 +// geometric_distribution() : geometric_distribution(0.5) {} // C++20 +// explicit geometric_distribution(double p); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::geometric_distribution D; + static_assert(test_convertible(), ""); + assert(D(0.5) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -31,5 +47,8 @@ assert(d.p() == 0.75); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.negbin/ctor_int_double.pass.cpp @@ -11,12 +11,29 @@ // template // class negative_binomial_distribution -// explicit negative_binomial_distribution(IntType t = 1, double p = 0.5); +// explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); // before C++20 +// negative_binomial_distribution() : negative_binomial_distribution(1) {} // C++20 +// explicit negative_binomial_distribution(IntType k, double p = 0.5); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::negative_binomial_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.p() == 0.75); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.cauchy/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class cauchy_distribution -// explicit cauchy_distribution(result_type a = 0, result_type b = 1); +// explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20 +// cauchy_distribution() : cauchy_distribution(0.0) {} // C++20 +// explicit cauchy_distribution(RealType a, RealType b = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::cauchy_distribution D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.b() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.chisq/ctor_double.pass.cpp @@ -11,12 +11,28 @@ // template // class chi_squared_distribution -// explicit chi_squared_distribution(result_type alpha = 0, result_type beta = 1); +// explicit chi_squared_distribution(RealType n = 1.0); // before C++20 +// chi_squared_distribution() : chi_squared_distribution(1.0) {} // C++20 +// explicit chi_squared_distribution(RealType n); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::chi_squared_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -31,5 +47,8 @@ assert(d.n() == 14.5); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class fisher_f_distribution -// explicit fisher_f_distribution(result_type alpha = 0, result_type beta = 1); +// explicit fisher_f_distribution(RealType m = 1.0, RealType n = 1.0); // before C++20 +// fisher_f_distribution() : fisher_f_distribution(1.0) {} // C++20 +// explicit fisher_f_distribution(RealType m, RealType n = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::fisher_f_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.n() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class lognormal_distribution -// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1); +// explicit lognormal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20 +// lognormal_distribution() : lognormal_distribution(0.0) {} // C++20 +// explicit lognormal_distribution(RealType mean, RealType stddev = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::lognormal_distribution D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.s() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.normal/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class normal_distribution -// explicit normal_distribution(result_type mean = 0, result_type stddev = 1); +// explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); // before C++20 +// normal_distribution() : normal_distribution(0.0) {} // C++20 +// explicit normal_distribution(RealType mean, RealType stddev = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::normal_distribution D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.stddev() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.t/ctor_double.pass.cpp @@ -11,12 +11,28 @@ // template // class student_t_distribution -// explicit student_t_distribution(result_type alpha = 0, result_type beta = 1); +// explicit student_t_distribution(RealType n = 1.0); // before C++20 +// student_t_distribution() : student_t_distribution(1.0) {} // C++20 +// explicit student_t_distribution(RealType n); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::student_t_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -31,5 +47,8 @@ assert(d.n() == 14.5); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.exp/ctor_double.pass.cpp @@ -11,12 +11,28 @@ // template // class exponential_distribution -// explicit exponential_distribution(RealType lambda = 1.0); +// explicit exponential_distribution(RealType lambda = 1.0); // before C++20 +// exponential_distribution() : exponential_distribution(1.0) {} // C++20 +// explicit exponential_distribution(RealType lambda); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::exponential_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -31,5 +47,8 @@ assert(d.lambda() == 3.5); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.extreme/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class extreme_value_distribution -// explicit extreme_value_distribution(result_type a = 0, result_type b = 1); +// explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); // before C++20 +// extreme_value_distribution() : extreme_value_distribution(0.0) {} // C++20 +// explicit extreme_value_distribution(RealType a, RealType b = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::extreme_value_distribution D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.b() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.gamma/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class gamma_distribution -// explicit gamma_distribution(result_type alpha = 0, result_type beta = 1); +// explicit gamma_distribution(RealType alpha = 1.0, RealType beta = 1.0); // before C++20 +// gamma_distribution() : gamma_distribution(1.0) {} // C++20 +// explicit gamma_distribution(RealType alpha, RealType beta = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::gamma_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.beta() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.poisson/ctor_double.pass.cpp @@ -11,12 +11,28 @@ // template // class poisson_distribution -// explicit poisson_distribution(RealType lambda = 1.0); +// explicit poisson_distribution(double mean = 1.0); // before C++20 +// poisson_distribution() : poisson_distribution(1.0) {} // C++20 +// explicit poisson_distribution(double mean); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::poisson_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -31,5 +47,8 @@ assert(d.mean() == 3.5); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.pois/rand.dist.pois.weibull/ctor_double_double.pass.cpp @@ -11,12 +11,29 @@ // template // class weibull_distribution -// explicit weibull_distribution(result_type a = 0, result_type b = 1); +// explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); // before C++20 +// weibull_distribution() : weibull_distribution(1.0) {} // C++20 +// explicit weibull_distribution(RealType a, RealType b = 1.0); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::weibull_distribution D; + static_assert(test_convertible(), ""); + assert(D(1) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -39,5 +56,8 @@ assert(d.b() == 5.25); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.int/ctor_int_int.pass.cpp @@ -12,12 +12,30 @@ // class uniform_int_distribution // explicit uniform_int_distribution(IntType a = 0, -// IntType b = numeric_limits::max()); +// IntType b = numeric_limits::max()); // before C++20 +// uniform_int_distribution() : uniform_int_distribution(0) {} // C++20 +// explicit uniform_int_distribution(IntType a, +// IntType b = numeric_limits::max()); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::uniform_int_distribution<> D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} int main(int, char**) { @@ -40,5 +58,8 @@ assert(d.b() == 106); } - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp deleted file mode 100644 --- a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_int_int.pass.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -// - -// template -// class uniform_real_distribution - -// explicit uniform_real_distribution(RealType a = 0, -// RealType b = 1); - -#include -#include - -#include "test_macros.h" - -int main(int, char**) -{ - { - typedef std::uniform_real_distribution<> D; - D d; - assert(d.a() == 0); - assert(d.b() == 1); - } - { - typedef std::uniform_real_distribution<> D; - D d(-6); - assert(d.a() == -6); - assert(d.b() == 1); - } - { - typedef std::uniform_real_distribution<> D; - D d(-6, 106); - assert(d.a() == -6); - assert(d.b() == 106); - } - - return 0; -} diff --git a/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_real_real.pass.cpp b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_real_real.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.dis/rand.dist.uni/rand.dist.uni.real/ctor_real_real.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// + +// template +// class uniform_real_distribution + +// explicit uniform_real_distribution(RealType a = 0.0, +// RealType b = 1.0); // before C++20 +// uniform_real_distribution() : uniform_real_distribution(0.0) {} // C++20 +// explicit uniform_real_distribution(RealType a, RealType b = 1.0); // C++20 + +#include +#include + +#include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::uniform_real_distribution D; + static_assert(test_convertible(), ""); + assert(D(0) == make_implicit()); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif +} + +int main(int, char**) +{ + { + typedef std::uniform_real_distribution<> D; + D d; + assert(d.a() == 0.0); + assert(d.b() == 1.0); + } + { + typedef std::uniform_real_distribution<> D; + D d(-6.5); + assert(d.a() == -6.5); + assert(d.b() == 1.0); + } + { + typedef std::uniform_real_distribution<> D; + D d(-6.9, 106.1); + assert(d.a() == -6.9); + assert(d.b() == 106.1); + } + + test_implicit(); + test_implicit(); + + return 0; +} diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/ctor_result_type.pass.cpp @@ -11,7 +11,9 @@ // template // class linear_congruential_engine; -// explicit linear_congruential_engine(result_type s = default_seed); +// explicit linear_congruential_engine(result_type s = default_seed); // before C++20 +// linear_congruential_engine() : linear_congruential_engine(default_seed) {} // C++20 +// explicit linear_congruential_engine(result_type s); // C++20 // Serializing/deserializing the state of the RNG requires iostreams // UNSUPPORTED: libcpp-has-no-localization @@ -21,6 +23,17 @@ #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +std::string to_string(T const& e) { + std::ostringstream os; + os << e; + return os.str(); +} template void @@ -30,23 +43,17 @@ { typedef std::linear_congruential_engine E; E e(5); - std::ostringstream os; - os << e; - assert(os.str() == "5"); + assert(to_string(e) == "5"); } { typedef std::linear_congruential_engine E; E e(5); - std::ostringstream os; - os << e; - assert(os.str() == "5"); + assert(to_string(e) == "5"); } { typedef std::linear_congruential_engine E; E e(5); - std::ostringstream os; - os << e; - assert(os.str() == "1"); + assert(to_string(e) == "1"); } } @@ -58,23 +65,17 @@ { typedef std::linear_congruential_engine E; E e(7); - std::ostringstream os; - os << e; - assert(os.str() == "0"); + assert(to_string(e) == "0"); } { typedef std::linear_congruential_engine E; E e(0); - std::ostringstream os; - os << e; - assert(os.str() == "0"); + assert(to_string(e) == "0"); } { typedef std::linear_congruential_engine E; E e(4); - std::ostringstream os; - os << e; - assert(os.str() == "0"); + assert(to_string(e) == "0"); } } @@ -86,23 +87,17 @@ { typedef std::linear_congruential_engine E; E e(3); - std::ostringstream os; - os << e; - assert(os.str() == "3"); + assert(to_string(e) == "3"); } { typedef std::linear_congruential_engine E; E e(5); - std::ostringstream os; - os << e; - assert(os.str() == "5"); + assert(to_string(e) == "5"); } { typedef std::linear_congruential_engine E; E e(7); - std::ostringstream os; - os << e; - assert(os.str() == "3"); + assert(to_string(e) == "3"); } } @@ -114,26 +109,30 @@ { typedef std::linear_congruential_engine E; E e(7); - std::ostringstream os; - os << e; - assert(os.str() == "1"); + assert(to_string(e) == "1"); } { typedef std::linear_congruential_engine E; E e(0); - std::ostringstream os; - os << e; - assert(os.str() == "1"); + assert(to_string(e) == "1"); } { typedef std::linear_congruential_engine E; E e(8); - std::ostringstream os; - os << e; - assert(os.str() == "1"); + assert(to_string(e) == "1"); } } +template +void test_implicit() { +#if TEST_STD_VER >= 11 + typedef std::linear_congruential_engine E; + static_assert(test_convertible(), ""); + assert(E(E::default_seed) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif +} + int main(int, char**) { test1(); @@ -156,5 +155,7 @@ test4(); test4(); - return 0; + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.mers/ctor_result_type.pass.cpp @@ -13,7 +13,9 @@ // UIntType b, size_t t, UIntType c, size_t l, UIntType f> // class mersenne_twister_engine; -// explicit mersenne_twister_engine(result_type s = default_seed); +// explicit mersenne_twister_engine(result_type s = default_seed); // before C++20 +// mersenne_twister_engine() : mersenne_twister_engine(default_seed) {} // C++20 +// explicit mersenne_twister_engine(result_type s); // C++20 // Serializing/deserializing the state of the RNG requires iostreams // UNSUPPORTED: libcpp-has-no-localization @@ -23,6 +25,19 @@ #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +std::string +to_string(T const &e) +{ + std::ostringstream os; + os << e; + return os.str(); +} void test1() @@ -124,9 +139,7 @@ "3668048733 2030009470 1910839172 1234925283 3575831445 123595418 " "2362440495 3048484911 1796872496"; std::mt19937 e1(0); - std::ostringstream os; - os << e1; - assert(os.str() == a); + assert(to_string(e1) == a); } void @@ -237,9 +250,16 @@ "15150289760867914983 4931341382074091848 12635920082410445322 " "8498109357807439006 14836776625250834986"; std::mt19937_64 e1(0); - std::ostringstream os; - os << e1; - assert(os.str() == a); + assert(to_string(e1) == a); +} + +template +void test_implicit() { +#if TEST_STD_VER >= 11 + static_assert(test_convertible(), ""); + assert(E(E::default_seed) == make_implicit()); + static_assert(!test_convertible(), ""); +#endif } int main(int, char**) @@ -247,5 +267,8 @@ test1(); test2(); - return 0; + test_implicit(); + test_implicit(); + + return 0; } diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/ctor_result_type.pass.cpp @@ -11,7 +11,9 @@ // template // class subtract_with_carry_engine; -// explicit subtract_with_carry_engine(result_type s = default_seed); +// explicit subtract_with_carry_engine(result_type s = default_seed); // before C++20 +// subtract_with_carry_engine() : subtract_with_carry_engine(default_seed) {} // C++20 +// explicit subtract_with_carry_engine(result_type s); // C++20 // Serializing/deserializing the state of the RNG requires iostreams // UNSUPPORTED: libcpp-has-no-localization @@ -21,6 +23,19 @@ #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "make_implicit.h" +#include "test_convertible.h" +#endif + +template +std::string +to_string(T const &e) +{ + std::ostringstream os; + os << e; + return os.str(); +} void test1() @@ -30,9 +45,7 @@ "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 " "5707268 2355175 0"; std::ranlux24_base e1(0); - std::ostringstream os; - os << e1; - assert(os.str() == a); + assert(to_string(e1) == a); } void @@ -43,15 +56,29 @@ "34339434557790 155299155394531 29014415493780 209265474179052 " "263777435457028 0"; std::ranlux48_base e1(0); - std::ostringstream os; - os << e1; - assert(os.str() == a); + assert(to_string(e1) == a); +} + +#if TEST_STD_VER >= 11 +template +void test_implicit_ctor() { + assert(E(E::default_seed) == make_implicit()); } +#endif int main(int, char**) { test1(); test2(); +#if TEST_STD_VER >= 11 + static_assert(test_convertible(), ""); + static_assert(test_convertible(), ""); + test_implicit_ctor(); + test_implicit_ctor(); + static_assert(!test_convertible(), ""); + static_assert(!test_convertible(), ""); +#endif + return 0; } diff --git a/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp b/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp --- a/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp +++ b/libcxx/test/std/re/re.results/re.results.const/default.pass.cpp @@ -10,20 +10,37 @@ // class match_results -// match_results(const Allocator& a = Allocator()); +// explicit match_results(const Allocator& a = Allocator()); // before C++20 +// match_results() : match_results(Allocator()) {} // C++20 +// explicit match_results(const Allocator& a); // C++20 #include #include #include "test_macros.h" +#if TEST_STD_VER >= 11 +#include "test_convertible.h" + +template +void test_implicit() { + static_assert(test_convertible(), ""); + static_assert(!test_convertible(), ""); +} +#endif template void test() { - std::match_results m; + typedef std::match_results M; + typedef std::allocator > Alloc; + M m; assert(m.size() == 0); assert(!m.ready()); - assert(m.get_allocator() == std::allocator >()); + assert(m.get_allocator() == Alloc()); + +#if TEST_STD_VER >= 11 + test_implicit(); +#endif } int main(int, char**) diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/libcxx/test/support/make_implicit.h copy from libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp copy to libcxx/test/support/make_implicit.h --- a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp +++ b/libcxx/test/support/make_implicit.h @@ -6,25 +6,17 @@ // //===----------------------------------------------------------------------===// -// +#ifndef SUPPORT_MAKE_IMPLICIT_H +#define SUPPORT_MAKE_IMPLICIT_H -// stack(); +// "make_implicit(Args&&... args)" is a function to construct 'Tp' +// from 'Args...' using implicit construction. -#include -#include -#include +#include -#include "test_macros.h" -#include "test_allocator.h" - -int main(int, char**) -{ - std::stack > > q; - assert(q.size() == 0); - q.push(1); - q.push(2); - assert(q.size() == 2); - assert(q.top() == 2); - - return 0; +template +T make_implicit(Args&&... args) { + return {std::forward(args)...}; } + +#endif // SUPPORT_MAKE_IMPLICIT_H