From 549545b64aab77d2a1784062451ee1c33f8324d2 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 16 Dec 2019 18:23:39 -0500 Subject: [PATCH] [libc++] Rework compressed pair constructors. This patch de-duplicates most compressed pair constructors to use the same code in C++11 and C++03. Part of doing that is deleting the "__second_tag()" and replacing it with a "__value_init_tag()" which has the same effect, but allows for the removal of the special "one-arg" first element constructor. This patch is intended to have no semantic change. --- libcxx/include/__functional_03 | 8 +- libcxx/include/__hash_table | 20 ++--- libcxx/include/__split_buffer | 4 +- libcxx/include/__tree | 10 +-- libcxx/include/deque | 2 +- libcxx/include/forward_list | 2 +- libcxx/include/future | 4 +- libcxx/include/list | 2 +- libcxx/include/memory | 95 +++++++--------------- libcxx/include/string | 26 +++--- libcxx/include/vector | 14 ++-- .../unord.set/missing_hash_specialization.fail.cpp | 2 +- 12 files changed, 76 insertions(+), 113 deletions(-) diff --git a/libcxx/include/__functional_03 b/libcxx/include/__functional_03 index a90cbb7..bf86428 100644 --- a/libcxx/include/__functional_03 +++ b/libcxx/include/__functional_03 @@ -104,7 +104,7 @@ class __func<_Fp, _Alloc, _Rp()> { __compressed_pair<_Fp, _Alloc> __f_; public: - explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} + explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} virtual __base<_Rp()>* __clone() const; virtual void __clone(__base<_Rp()>*) const; @@ -189,7 +189,7 @@ class __func<_Fp, _Alloc, _Rp(_A0)> { __compressed_pair<_Fp, _Alloc> __f_; public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} virtual __base<_Rp(_A0)>* __clone() const; @@ -275,7 +275,7 @@ class __func<_Fp, _Alloc, _Rp(_A0, _A1)> { __compressed_pair<_Fp, _Alloc> __f_; public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} virtual __base<_Rp(_A0, _A1)>* __clone() const; @@ -361,7 +361,7 @@ class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> { __compressed_pair<_Fp, _Alloc> __f_; public: - _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f)) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const; diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 7ba3ceb..13ff096 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -776,7 +776,7 @@ public: _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __data_(0) {} + : __data_(0, __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator(const allocator_type& __a, size_type __size) @@ -1418,8 +1418,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) - : __p2_(0), - __p3_(1.0f) + : __p2_(0, __default_init_tag()), + __p3_(1.0f, __default_init_tag()) { } @@ -1439,7 +1439,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), + __p1_(__default_init_tag(), __node_allocator(__a)), __p2_(0, __hf), __p3_(1.0f, __eql) { @@ -1448,9 +1448,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), - __p2_(0), - __p3_(1.0f) + __p1_(__default_init_tag(), __node_allocator(__a)), + __p2_(0, __default_init_tag()), + __p3_(1.0f, __default_init_tag()) { } @@ -1460,7 +1460,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u) __bucket_list_deleter(allocator_traits<__pointer_allocator>:: select_on_container_copy_construction( __u.__bucket_list_.get_deleter().__alloc()), 0)), - __p1_(__second_tag(), allocator_traits<__node_allocator>:: + __p1_(__default_init_tag(), allocator_traits<__node_allocator>:: select_on_container_copy_construction(__u.__node_alloc())), __p2_(0, __u.hash_function()), __p3_(__u.__p3_) @@ -1471,7 +1471,7 @@ template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), + __p1_(__default_init_tag(), __node_allocator(__a)), __p2_(0, __u.hash_function()), __p3_(__u.__p3_) { @@ -1505,7 +1505,7 @@ template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const allocator_type& __a) : __bucket_list_(nullptr, __bucket_list_deleter(__pointer_allocator(__a), 0)), - __p1_(__second_tag(), __node_allocator(__a)), + __p1_(__default_init_tag(), __node_allocator(__a)), __p2_(0, _VSTD::move(__u.hash_function())), __p3_(_VSTD::move(__u.__p3_)) { diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index d70c0a7..fce209f 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -324,7 +324,7 @@ template inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) + : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __default_init_tag()) { } @@ -368,7 +368,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c) template __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a) - : __end_cap_(__second_tag(), __a) + : __end_cap_(nullptr, __a) { if (__a == __c.__alloc()) { diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 8b6509c..cb7a102 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1577,8 +1577,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) template __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), - __pair3_(0) + __pair1_(__default_init_tag(), __node_allocator(__a)), + __pair3_(0, __default_init_tag()) { __begin_node() = __end_node(); } @@ -1587,7 +1587,7 @@ template __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_allocator(__a)), + __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, __comp) { __begin_node() = __end_node(); @@ -1700,7 +1700,7 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input template __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) : __begin_node_(__iter_pointer()), - __pair1_(__second_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), + __pair1_(__default_init_tag(), __node_traits::select_on_container_copy_construction(__t.__node_alloc())), __pair3_(0, __t.value_comp()) { __begin_node() = __end_node(); @@ -1730,7 +1730,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) template __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a) - : __pair1_(__second_tag(), __node_allocator(__a)), + : __pair1_(__default_init_tag(), __node_allocator(__a)), __pair3_(0, _VSTD::move(__t.value_comp())) { if (__a == __t.__alloc()) diff --git a/libcxx/include/deque b/libcxx/include/deque index b2582f4..115b1b6 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -1171,7 +1171,7 @@ template inline __deque_base<_Tp, _Allocator>::__deque_base() _NOEXCEPT_(is_nothrow_default_constructible::value) - : __start_(0), __size_(0) {} + : __start_(0), __size_(0, __default_init_tag()) {} template inline diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list index 781cbb3..3905745 100644 --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -490,7 +490,7 @@ protected: _LIBCPP_INLINE_VISIBILITY __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) - : __before_begin_(__begin_node()) {} + : __before_begin_(__begin_node(), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY explicit __forward_list_base(const allocator_type& __a) : __before_begin_(__begin_node(), __node_allocator(__a)) {} diff --git a/libcxx/include/future b/libcxx/include/future index deb7725..751d122 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1767,9 +1767,9 @@ class _LIBCPP_AVAILABILITY_FUTURE __packaged_task_func<_Fp, _Alloc, _Rp(_ArgType __compressed_pair<_Fp, _Alloc> __f_; public: _LIBCPP_INLINE_VISIBILITY - explicit __packaged_task_func(const _Fp& __f) : __f_(__f) {} + explicit __packaged_task_func(const _Fp& __f) : __f_(__f, __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY - explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f)) {} + explicit __packaged_task_func(_Fp&& __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} _LIBCPP_INLINE_VISIBILITY __packaged_task_func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {} diff --git a/libcxx/include/list b/libcxx/include/list index cf131a1..ae318ea 100644 --- a/libcxx/include/list +++ b/libcxx/include/list @@ -715,7 +715,7 @@ template inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) - : __size_alloc_(0) + : __size_alloc_(0, __default_init_tag()) { } diff --git a/libcxx/include/memory b/libcxx/include/memory index 45e032ae..34c3e0c 100644 --- a/libcxx/include/memory +++ b/libcxx/include/memory @@ -2180,6 +2180,7 @@ public: // Tag used to default initialize one or both of the pair's elements. struct __default_init_tag {}; +struct __value_init_tag {}; template ::type>::value >::type> _LIBCPP_INLINE_VISIBILITY - constexpr explicit + _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_(_VSTD::forward<_Up>(__u)) { } + +#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indexes...>) : __value_(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} -#else - _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_() {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(__default_init_tag) {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(_ParamT __p) : __value_(std::forward<_ParamT>(__p)) {} #endif + _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return __value_; } _LIBCPP_INLINE_VISIBILITY const_reference __get() const _NOEXCEPT { return __value_; } @@ -2232,28 +2230,27 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { typedef const _Tp& const_reference; typedef _Tp __value_type; -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY constexpr __compressed_pair_elem() = default; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair_elem() = default; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __compressed_pair_elem(__default_init_tag) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __compressed_pair_elem(__value_init_tag) : __value_type() {} template ::type>::value >::type> _LIBCPP_INLINE_VISIBILITY - constexpr explicit + _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u) : __value_type(_VSTD::forward<_Up>(__u)) {} +#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair_elem(piecewise_construct_t, tuple<_Args...> __args, __tuple_indices<_Indexes...>) : __value_type(_VSTD::forward<_Args>(_VSTD::get<_Indexes>(__args))...) {} -#else - _LIBCPP_INLINE_VISIBILITY __compressed_pair_elem() : __value_type() {} - _LIBCPP_INLINE_VISIBILITY - __compressed_pair_elem(_ParamT __p) - : __value_type(std::forward<_ParamT>(__p)) {} #endif _LIBCPP_INLINE_VISIBILITY reference __get() _NOEXCEPT { return *this; } @@ -2261,9 +2258,6 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp { const_reference __get() const _NOEXCEPT { return *this; } }; -// Tag used to construct the second element of the compressed pair. -struct __second_tag {}; - template class __compressed_pair : private __compressed_pair_elem<_T1, 0>, private __compressed_pair_elem<_T2, 1> { @@ -2280,33 +2274,21 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>, "implementation for this configuration"); public: -#ifndef _LIBCPP_CXX03_LANG - template , _Dummy>::value && __dependent_type, _Dummy>::value >::type > _LIBCPP_INLINE_VISIBILITY - constexpr __compressed_pair() {} - - template ::type, - __compressed_pair>::value, - bool>::type = true> - _LIBCPP_INLINE_VISIBILITY constexpr explicit - __compressed_pair(_Tp&& __t) - : _Base1(std::forward<_Tp>(__t)), _Base2() {} - - template - _LIBCPP_INLINE_VISIBILITY constexpr - __compressed_pair(__second_tag, _Tp&& __t) - : _Base1(), _Base2(std::forward<_Tp>(__t)) {} + _LIBCPP_CONSTEXPR __compressed_pair() : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {} template - _LIBCPP_INLINE_VISIBILITY constexpr + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __compressed_pair(_U1&& __t1, _U2&& __t2) : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {} +#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 __compressed_pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, @@ -2315,21 +2297,6 @@ public: typename __make_tuple_indices::type()), _Base2(__pc, _VSTD::move(__second_args), typename __make_tuple_indices::type()) {} - -#else - _LIBCPP_INLINE_VISIBILITY - __compressed_pair() {} - - _LIBCPP_INLINE_VISIBILITY explicit - __compressed_pair(_T1 __t1) : _Base1(_VSTD::forward<_T1>(__t1)) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(__second_tag, _T2 __t2) - : _Base1(), _Base2(_VSTD::forward<_T2>(__t2)) {} - - _LIBCPP_INLINE_VISIBILITY - __compressed_pair(_T1 __t1, _T2 __t2) - : _Base1(_VSTD::forward<_T1>(__t1)), _Base2(_VSTD::forward<_T2>(__t2)) {} #endif _LIBCPP_INLINE_VISIBILITY @@ -2510,17 +2477,17 @@ public: template > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template > _LIBCPP_INLINE_VISIBILITY - explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __default_init_tag()) {} template > > @@ -2562,7 +2529,7 @@ public: typename enable_if::value && is_same<_Dp, default_delete<_Tp> >::value, __nat>::type = __nat()) _NOEXCEPT - : __ptr_(__p.release()) {} + : __ptr_(__p.release(), __default_init_tag()) {} #endif _LIBCPP_INLINE_VISIBILITY @@ -2733,19 +2700,19 @@ public: template > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template > _LIBCPP_INLINE_VISIBILITY - _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {} + _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer(), __default_init_tag()) {} template , class = _EnableIfPointerConvertible<_Pp> > _LIBCPP_INLINE_VISIBILITY explicit unique_ptr(_Pp __p) _NOEXCEPT - : __ptr_(__p) {} + : __ptr_(__p, __default_init_tag()) {} template >, @@ -3589,24 +3556,20 @@ class __shared_ptr_emplace { __compressed_pair<_Alloc, _Tp> __data_; public: -#ifndef _LIBCPP_HAS_NO_VARIADICS _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a) - : __data_(_VSTD::move(__a)) {} + : __data_(_VSTD::move(__a), __value_init_tag()) {} + +#ifndef _LIBCPP_HAS_NO_VARIADICS template _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a, _Args&& ...__args) : __data_(piecewise_construct, _VSTD::forward_as_tuple(__a), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) {} - #else // _LIBCPP_HAS_NO_VARIADICS - _LIBCPP_INLINE_VISIBILITY - __shared_ptr_emplace(_Alloc __a) - : __data_(__a) {} - template _LIBCPP_INLINE_VISIBILITY __shared_ptr_emplace(_Alloc __a, _A0& __a0) diff --git a/libcxx/include/string b/libcxx/include/string index 4e0b211..488c07a 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -1736,7 +1736,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __ #else _NOEXCEPT #endif -: __r_(__second_tag(), __a) +: __r_(__value_init_tag(), __a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1796,7 +1796,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty template template basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); @@ -1819,7 +1819,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_ template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); @@ -1830,7 +1830,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_ template basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str) - : __r_(__second_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) + : __r_(__value_init_tag(), __alloc_traits::select_on_container_copy_construction(__str.__alloc())) { if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; @@ -1844,7 +1844,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st template basic_string<_CharT, _Traits, _Allocator>::basic_string( const basic_string& __str, const allocator_type& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { if (!__str.__is_long()) __r_.first().__r = __str.__r_.first().__r; @@ -1878,7 +1878,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { if (__str.__is_long() && __a != __str.__alloc()) // copy, not move __init(_VSTD::__to_address(__str.__get_long_pointer()), __str.__get_long_size()); @@ -1933,7 +1933,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __ template template basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, _CharT __c, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { __init(__n, __c); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1945,7 +1945,7 @@ template basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, size_type __n, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) @@ -1960,7 +1960,7 @@ template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { size_type __str_sz = __str.size(); if (__pos > __str_sz) @@ -1975,7 +1975,7 @@ template template basic_string<_CharT, _Traits, _Allocator>::basic_string( const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { __self_view __sv0 = __t; __self_view __sv = __sv0.substr(__pos, __n); @@ -1999,7 +1999,7 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t) template template basic_string<_CharT, _Traits, _Allocator>::basic_string(const _Tp & __t, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { __self_view __sv = __t; __init(__sv.data(), __sv.size()); @@ -2082,7 +2082,7 @@ template inline basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { __init(__first, __last); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -2108,7 +2108,7 @@ inline basic_string<_CharT, _Traits, _Allocator>::basic_string( initializer_list<_CharT> __il, const _Allocator& __a) - : __r_(__second_tag(), __a) + : __r_(__value_init_tag(), __a) { __init(__il.begin(), __il.end()); #if _LIBCPP_DEBUG_LEVEL >= 2 diff --git a/libcxx/include/vector b/libcxx/include/vector index a828973..8366bb5 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -433,7 +433,7 @@ __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), __end_(nullptr), - __end_cap_(nullptr) + __end_cap_(nullptr, __default_init_tag()) { } @@ -2622,7 +2622,7 @@ vector::vector() _NOEXCEPT_(is_nothrow_default_constructible::value) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { } @@ -2644,7 +2644,7 @@ template vector::vector(size_type __n) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { if (__n > 0) { @@ -2672,7 +2672,7 @@ template vector::vector(size_type __n, const value_type& __x) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { if (__n > 0) { @@ -2701,7 +2701,7 @@ vector::vector(_InputIterator __first, _InputIterator __last, !__is_cpp17_forward_iterator<_InputIterator>::value>::type*) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { #ifndef _LIBCPP_NO_EXCEPTIONS try @@ -2754,7 +2754,7 @@ vector::vector(_ForwardIterator __first, _ForwardIterator __la typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { size_type __n = static_cast(_VSTD::distance(__first, __last)); if (__n > 0) @@ -2786,7 +2786,7 @@ template vector::vector(initializer_list __il) : __begin_(nullptr), __size_(0), - __cap_alloc_(0) + __cap_alloc_(0, __default_init_tag()) { size_type __n = static_cast(__il.size()); if (__n > 0) diff --git a/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp b/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp index af94748..737be32 100644 --- a/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp +++ b/libcxx/test/libcxx/containers/unord/unord.set/missing_hash_specialization.fail.cpp @@ -52,7 +52,7 @@ int main(int, char**) { // FIXME: It would be great to suppress the below diagnostic all together. // but for now it's sufficient that it appears last. However there is // currently no way to test the order diagnostics are issued. - // expected-error@memory:* {{call to implicitly-deleted default constructor of '__compressed_pair_elem}} + // expected-error@memory:* {{call to implicitly-deleted default constructor of 'std::}} } { using Set = std::unordered_set; -- 2.7.4