Skip to content

Commit a11f8b1

Browse files
committed
[libc++] [P0935] [C++20] Eradicating unnecessarily explicit default constructors from the standard library.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D91292
1 parent 9cf511a commit a11f8b1

File tree

49 files changed

+1194
-268
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1194
-268
lines changed

libcxx/docs/Cxx2aStatusPaperStatus.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"`P0887R1 <https://wg21.link/P0887R1>`__","LWG","The identity metafunction","Rapperswil","|Complete|","8.0"
4545
"`P0892R2 <https://wg21.link/P0892R2>`__","CWG","explicit(bool)","Rapperswil","",""
4646
"`P0898R3 <https://wg21.link/P0898R3>`__","LWG","Standard Library Concepts","Rapperswil","",""
47-
"`P0935R0 <https://wg21.link/P0935R0>`__","LWG","Eradicating unnecessarily explicit default constructors from the standard library","Rapperswil","",""
47+
"`P0935R0 <https://wg21.link/P0935R0>`__","LWG","Eradicating unnecessarily explicit default constructors from the standard library","Rapperswil","|Complete|","12.0"
4848
"`P0941R2 <https://wg21.link/P0941R2>`__","CWG","Integrating feature-test macros into the C++ WD","Rapperswil","|In Progress|",""
4949
"`P1023R0 <https://wg21.link/P1023R0>`__","LWG","constexpr comparison operators for std::array","Rapperswil","|Complete|","8.0"
5050
"`P1025R1 <https://wg21.link/P1025R1>`__","CWG","Update The Reference To The Unicode Standard","Rapperswil","",""

libcxx/include/algorithm

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,9 +3029,17 @@ private:
30293029

30303030
public:
30313031
// constructors and reset functions
3032-
explicit uniform_int_distribution(result_type __a = 0,
3033-
result_type __b = numeric_limits<result_type>::max())
3032+
#ifndef _LIBCPP_CXX03_LANG
3033+
uniform_int_distribution() : uniform_int_distribution(0) {}
3034+
explicit uniform_int_distribution(
3035+
result_type __a, result_type __b = numeric_limits<result_type>::max())
3036+
: __p_(param_type(__a, __b)) {}
3037+
#else
3038+
explicit uniform_int_distribution(
3039+
result_type __a = 0,
3040+
result_type __b = numeric_limits<result_type>::max())
30343041
: __p_(param_type(__a, __b)) {}
3042+
#endif
30353043
explicit uniform_int_distribution(const param_type& __p) : __p_(__p) {}
30363044
void reset() {}
30373045

libcxx/include/locale

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ public:
9292
typedef typename Codecvt::state_type state_type;
9393
typedef typename wide_string::traits_type::int_type int_type;
9494
95-
explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14
95+
wstring_convert(Codecvt* pcvt = new Codecvt); // before C++14
96+
explicit wstring_convert(Codecvt* pcvt = new Codecvt); // before C++20
97+
wstring_convert() : wstring_convert(new Codecvt) {} // C++20
98+
explicit wstring_convert(Codecvt* pcvt); // C++20
99+
96100
wstring_convert(Codecvt* pcvt, state_type state);
97101
explicit wstring_convert(const byte_string& byte_err, // explicit in C++14
98102
const wide_string& wide_err = wide_string());
@@ -121,8 +125,14 @@ class wbuffer_convert
121125
public:
122126
typedef typename Tr::state_type state_type;
123127
124-
explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
125-
state_type state = state_type()); // explicit in C++14
128+
wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt,
129+
state_type state = state_type()); // before C++14
130+
explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt,
131+
state_type state = state_type()); // before C++20
132+
wbuffer_convert() : wbuffer_convert(nullptr) {} // C++20
133+
explicit wbuffer_convert(streambuf* bytebuf, Codecvt* pcvt = new Codecvt,
134+
state_type state = state_type()); // C++20
135+
126136
wbuffer_convert(const wbuffer_convert&) = delete; // C++14
127137
wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14
128138
~wbuffer_convert(); // C++14
@@ -3650,8 +3660,17 @@ private:
36503660
wstring_convert(const wstring_convert& __wc);
36513661
wstring_convert& operator=(const wstring_convert& __wc);
36523662
public:
3663+
#ifndef _LIBCPP_CXX03_LANG
36533664
_LIBCPP_INLINE_VISIBILITY
3654-
_LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
3665+
wstring_convert() : wstring_convert(new _Codecvt) {}
3666+
_LIBCPP_INLINE_VISIBILITY
3667+
explicit wstring_convert(_Codecvt* __pcvt);
3668+
#else
3669+
_LIBCPP_INLINE_VISIBILITY
3670+
_LIBCPP_EXPLICIT_AFTER_CXX11
3671+
wstring_convert(_Codecvt* __pcvt = new _Codecvt);
3672+
#endif
3673+
36553674
_LIBCPP_INLINE_VISIBILITY
36563675
wstring_convert(_Codecvt* __pcvt, state_type __state);
36573676
_LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err,
@@ -3918,9 +3937,20 @@ private:
39183937

39193938
wbuffer_convert(const wbuffer_convert&);
39203939
wbuffer_convert& operator=(const wbuffer_convert&);
3940+
39213941
public:
3922-
_LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = nullptr,
3923-
_Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3942+
#ifndef _LIBCPP_CXX03_LANG
3943+
wbuffer_convert() : wbuffer_convert(nullptr) {}
3944+
explicit wbuffer_convert(streambuf* __bytebuf,
3945+
_Codecvt* __pcvt = new _Codecvt,
3946+
state_type __state = state_type());
3947+
#else
3948+
_LIBCPP_EXPLICIT_AFTER_CXX11
3949+
wbuffer_convert(streambuf* __bytebuf = nullptr,
3950+
_Codecvt* __pcvt = new _Codecvt,
3951+
state_type __state = state_type());
3952+
#endif
3953+
39243954
~wbuffer_convert();
39253955

39263956
_LIBCPP_INLINE_VISIBILITY

libcxx/include/queue

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,11 @@ protected:
112112
Compare comp;
113113
114114
public:
115-
priority_queue() = default;
116-
~priority_queue() = default;
117-
118-
priority_queue(const priority_queue& q) = default;
119-
priority_queue(priority_queue&& q) = default;
120-
121-
priority_queue& operator=(const priority_queue& q) = default;
122-
priority_queue& operator=(priority_queue&& q) = default;
123-
124-
explicit priority_queue(const Compare& comp);
125-
priority_queue(const Compare& comp, const container_type& c);
126-
explicit priority_queue(const Compare& comp, container_type&& c);
115+
priority_queue() : priority_queue(Compare()) {} // C++20
116+
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
117+
priority_queue(const Compare& x, const Container&);
118+
explicit priority_queue(const Compare& x = Compare(), Container&&= Container()); // before C++20
119+
priority_queue(const Compare& x, Container&&); // C++20
127120
template <class InputIterator>
128121
priority_queue(InputIterator first, InputIterator last,
129122
const Compare& comp = Compare());
@@ -474,7 +467,7 @@ public:
474467
priority_queue(const value_compare& __comp, const container_type& __c);
475468
#ifndef _LIBCPP_CXX03_LANG
476469
_LIBCPP_INLINE_VISIBILITY
477-
explicit priority_queue(const value_compare& __comp, container_type&& __c);
470+
priority_queue(const value_compare& __comp, container_type&& __c);
478471
#endif
479472
template <class _InputIter>
480473
_LIBCPP_INLINE_VISIBILITY

0 commit comments

Comments
 (0)