authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-07-16 10:46:24+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-08-30 06:36:40+02:00
logd9f0fbf9838060b1e8c2ec0df21b43e75430350f
tree1ad5976b5e0233a964a7c7381b3ccac8bbc9697e
parente84e9d3a01e4332ad6b7a239c74d823f283d7f8f
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxx: update to LLVM 21


563 files changed, 16838 insertions(+), 12945 deletions(-)

lib/libcxx/include/__algorithm/copy.h+133-1
...@@ -13,8 +13,10 @@...@@ -13,8 +13,10 @@
13#include <__algorithm/for_each_segment.h>13#include <__algorithm/for_each_segment.h>
14#include <__algorithm/min.h>14#include <__algorithm/min.h>
15#include <__config>15#include <__config>
16#include <__fwd/bit_reference.h>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
17#include <__iterator/segmented_iterator.h>18#include <__iterator/segmented_iterator.h>
19#include <__memory/pointer_traits.h>
18#include <__type_traits/common_type.h>20#include <__type_traits/common_type.h>
19#include <__type_traits/enable_if.h>21#include <__type_traits/enable_if.h>
20#include <__utility/move.h>22#include <__utility/move.h>
...@@ -29,9 +31,129 @@ _LIBCPP_PUSH_MACROS...@@ -29,9 +31,129 @@ _LIBCPP_PUSH_MACROS
2931
30_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3133
34template <class _InputIterator, class _OutputIterator>
35inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
36copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result);
37
32template <class _InIter, class _Sent, class _OutIter>38template <class _InIter, class _Sent, class _OutIter>
33inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);39inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
3440
41template <class _Cp, bool _IsConst>
42_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_aligned(
43 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
44 using _In = __bit_iterator<_Cp, _IsConst>;
45 using difference_type = typename _In::difference_type;
46 using __storage_type = typename _In::__storage_type;
47
48 const int __bits_per_word = _In::__bits_per_word;
49 difference_type __n = __last - __first;
50 if (__n > 0) {
51 // do first word
52 if (__first.__ctz_ != 0) {
53 unsigned __clz = __bits_per_word - __first.__ctz_;
54 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
55 __n -= __dn;
56 __storage_type __m = std::__middle_mask<__storage_type>(__clz - __dn, __first.__ctz_);
57 __storage_type __b = *__first.__seg_ & __m;
58 *__result.__seg_ &= ~__m;
59 *__result.__seg_ |= __b;
60 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
61 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
62 ++__first.__seg_;
63 // __first.__ctz_ = 0;
64 }
65 // __first.__ctz_ == 0;
66 // do middle words
67 __storage_type __nw = __n / __bits_per_word;
68 std::copy(std::__to_address(__first.__seg_),
69 std::__to_address(__first.__seg_ + __nw),
70 std::__to_address(__result.__seg_));
71 __n -= __nw * __bits_per_word;
72 __result.__seg_ += __nw;
73 // do last word
74 if (__n > 0) {
75 __first.__seg_ += __nw;
76 __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
77 __storage_type __b = *__first.__seg_ & __m;
78 *__result.__seg_ &= ~__m;
79 *__result.__seg_ |= __b;
80 __result.__ctz_ = static_cast<unsigned>(__n);
81 }
82 }
83 return __result;
84}
85
86template <class _Cp, bool _IsConst>
87_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_unaligned(
88 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
89 using _In = __bit_iterator<_Cp, _IsConst>;
90 using difference_type = typename _In::difference_type;
91 using __storage_type = typename _In::__storage_type;
92
93 const int __bits_per_word = _In::__bits_per_word;
94 difference_type __n = __last - __first;
95 if (__n > 0) {
96 // do first word
97 if (__first.__ctz_ != 0) {
98 unsigned __clz_f = __bits_per_word - __first.__ctz_;
99 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
100 __n -= __dn;
101 __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_);
102 __storage_type __b = *__first.__seg_ & __m;
103 unsigned __clz_r = __bits_per_word - __result.__ctz_;
104 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
105 __m = std::__middle_mask<__storage_type>(__clz_r - __ddn, __result.__ctz_);
106 *__result.__seg_ &= ~__m;
107 if (__result.__ctz_ > __first.__ctz_)
108 *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_);
109 else
110 *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_);
111 __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
112 __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
113 __dn -= __ddn;
114 if (__dn > 0) {
115 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __dn);
116 *__result.__seg_ &= ~__m;
117 *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn);
118 __result.__ctz_ = static_cast<unsigned>(__dn);
119 }
120 ++__first.__seg_;
121 // __first.__ctz_ = 0;
122 }
123 // __first.__ctz_ == 0;
124 // do middle words
125 unsigned __clz_r = __bits_per_word - __result.__ctz_;
126 __storage_type __m = std::__leading_mask<__storage_type>(__result.__ctz_);
127 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) {
128 __storage_type __b = *__first.__seg_;
129 *__result.__seg_ &= ~__m;
130 *__result.__seg_ |= __b << __result.__ctz_;
131 ++__result.__seg_;
132 *__result.__seg_ &= __m;
133 *__result.__seg_ |= __b >> __clz_r;
134 }
135 // do last word
136 if (__n > 0) {
137 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
138 __storage_type __b = *__first.__seg_ & __m;
139 __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r));
140 __m = std::__middle_mask<__storage_type>(__clz_r - __dn, __result.__ctz_);
141 *__result.__seg_ &= ~__m;
142 *__result.__seg_ |= __b << __result.__ctz_;
143 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
144 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
145 __n -= __dn;
146 if (__n > 0) {
147 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
148 *__result.__seg_ &= ~__m;
149 *__result.__seg_ |= __b >> __dn;
150 __result.__ctz_ = static_cast<unsigned>(__n);
151 }
152 }
153 }
154 return __result;
155}
156
35struct __copy_impl {157struct __copy_impl {
36 template <class _InIter, class _Sent, class _OutIter>158 template <class _InIter, class _Sent, class _OutIter>
37 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
...@@ -95,6 +217,16 @@ struct __copy_impl {...@@ -95,6 +217,16 @@ struct __copy_impl {
95 }217 }
96 }218 }
97219
220 template <class _Cp, bool _IsConst>
221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
222 operator()(__bit_iterator<_Cp, _IsConst> __first,
223 __bit_iterator<_Cp, _IsConst> __last,
224 __bit_iterator<_Cp, false> __result) const {
225 if (__first.__ctz_ == __result.__ctz_)
226 return std::make_pair(__last, std::__copy_aligned(__first, __last, __result));
227 return std::make_pair(__last, std::__copy_unaligned(__first, __last, __result));
228 }
229
98 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.230 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
99 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>231 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
...@@ -110,7 +242,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) {...@@ -110,7 +242,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) {
110}242}
111243
112template <class _InputIterator, class _OutputIterator>244template <class _InputIterator, class _OutputIterator>
113inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator245_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
114copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {246copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
115 return std::__copy(__first, __last, __result).second;247 return std::__copy(__first, __last, __result).second;
116}248}
lib/libcxx/include/__algorithm/copy_backward.h+131
...@@ -10,11 +10,14 @@...@@ -10,11 +10,14 @@
10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H10#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H
1111
12#include <__algorithm/copy_move_common.h>12#include <__algorithm/copy_move_common.h>
13#include <__algorithm/copy_n.h>
13#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>15#include <__algorithm/min.h>
15#include <__config>16#include <__config>
17#include <__fwd/bit_reference.h>
16#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
17#include <__iterator/segmented_iterator.h>19#include <__iterator/segmented_iterator.h>
20#include <__memory/pointer_traits.h>
18#include <__type_traits/common_type.h>21#include <__type_traits/common_type.h>
19#include <__type_traits/enable_if.h>22#include <__type_traits/enable_if.h>
20#include <__type_traits/is_constructible.h>23#include <__type_traits/is_constructible.h>
...@@ -34,6 +37,124 @@ template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>...@@ -34,6 +37,124 @@ template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
35__copy_backward(_InIter __first, _Sent __last, _OutIter __result);38__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
3639
40template <class _Cp, bool _IsConst>
41_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_aligned(
42 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
43 using _In = __bit_iterator<_Cp, _IsConst>;
44 using difference_type = typename _In::difference_type;
45 using __storage_type = typename _In::__storage_type;
46
47 const int __bits_per_word = _In::__bits_per_word;
48 difference_type __n = __last - __first;
49 if (__n > 0) {
50 // do first word
51 if (__last.__ctz_ != 0) {
52 difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n);
53 __n -= __dn;
54 unsigned __clz = __bits_per_word - __last.__ctz_;
55 __storage_type __m = std::__middle_mask<__storage_type>(__clz, __last.__ctz_ - __dn);
56 __storage_type __b = *__last.__seg_ & __m;
57 *__result.__seg_ &= ~__m;
58 *__result.__seg_ |= __b;
59 __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
60 // __last.__ctz_ = 0
61 }
62 // __last.__ctz_ == 0 || __n == 0
63 // __result.__ctz_ == 0 || __n == 0
64 // do middle words
65 __storage_type __nw = __n / __bits_per_word;
66 __result.__seg_ -= __nw;
67 __last.__seg_ -= __nw;
68 std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
69 __n -= __nw * __bits_per_word;
70 // do last word
71 if (__n > 0) {
72 __storage_type __m = std::__leading_mask<__storage_type>(__bits_per_word - __n);
73 __storage_type __b = *--__last.__seg_ & __m;
74 *--__result.__seg_ &= ~__m;
75 *__result.__seg_ |= __b;
76 __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
77 }
78 }
79 return __result;
80}
81
82template <class _Cp, bool _IsConst>
83_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_unaligned(
84 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
85 using _In = __bit_iterator<_Cp, _IsConst>;
86 using difference_type = typename _In::difference_type;
87 using __storage_type = typename _In::__storage_type;
88
89 const int __bits_per_word = _In::__bits_per_word;
90 difference_type __n = __last - __first;
91 if (__n > 0) {
92 // do first word
93 if (__last.__ctz_ != 0) {
94 difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n);
95 __n -= __dn;
96 unsigned __clz_l = __bits_per_word - __last.__ctz_;
97 __storage_type __m = std::__middle_mask<__storage_type>(__clz_l, __last.__ctz_ - __dn);
98 __storage_type __b = *__last.__seg_ & __m;
99 unsigned __clz_r = __bits_per_word - __result.__ctz_;
100 __storage_type __ddn = std::min(__dn, static_cast<difference_type>(__result.__ctz_));
101 if (__ddn > 0) {
102 __m = std::__middle_mask<__storage_type>(__clz_r, __result.__ctz_ - __ddn);
103 *__result.__seg_ &= ~__m;
104 if (__result.__ctz_ > __last.__ctz_)
105 *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
106 else
107 *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_);
108 __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
109 __dn -= __ddn;
110 }
111 if (__dn > 0) {
112 // __result.__ctz_ == 0
113 --__result.__seg_;
114 __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1));
115 __m = std::__leading_mask<__storage_type>(__result.__ctz_);
116 *__result.__seg_ &= ~__m;
117 __last.__ctz_ -= __dn + __ddn;
118 *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
119 }
120 // __last.__ctz_ = 0
121 }
122 // __last.__ctz_ == 0 || __n == 0
123 // __result.__ctz_ != 0 || __n == 0
124 // do middle words
125 unsigned __clz_r = __bits_per_word - __result.__ctz_;
126 __storage_type __m = std::__trailing_mask<__storage_type>(__clz_r);
127 for (; __n >= __bits_per_word; __n -= __bits_per_word) {
128 __storage_type __b = *--__last.__seg_;
129 *__result.__seg_ &= ~__m;
130 *__result.__seg_ |= __b >> __clz_r;
131 *--__result.__seg_ &= __m;
132 *__result.__seg_ |= __b << __result.__ctz_;
133 }
134 // do last word
135 if (__n > 0) {
136 __m = std::__leading_mask<__storage_type>(__bits_per_word - __n);
137 __storage_type __b = *--__last.__seg_ & __m;
138 __clz_r = __bits_per_word - __result.__ctz_;
139 __storage_type __dn = std::min(__n, static_cast<difference_type>(__result.__ctz_));
140 __m = std::__middle_mask<__storage_type>(__clz_r, __result.__ctz_ - __dn);
141 *__result.__seg_ &= ~__m;
142 *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_);
143 __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
144 __n -= __dn;
145 if (__n > 0) {
146 // __result.__ctz_ == 0
147 --__result.__seg_;
148 __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
149 __m = std::__leading_mask<__storage_type>(__result.__ctz_);
150 *__result.__seg_ &= ~__m;
151 *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn));
152 }
153 }
154 }
155 return __result;
156}
157
37template <class _AlgPolicy>158template <class _AlgPolicy>
38struct __copy_backward_impl {159struct __copy_backward_impl {
39 template <class _InIter, class _Sent, class _OutIter>160 template <class _InIter, class _Sent, class _OutIter>
...@@ -107,6 +228,16 @@ struct __copy_backward_impl {...@@ -107,6 +228,16 @@ struct __copy_backward_impl {
107 }228 }
108 }229 }
109230
231 template <class _Cp, bool _IsConst>
232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
233 operator()(__bit_iterator<_Cp, _IsConst> __first,
234 __bit_iterator<_Cp, _IsConst> __last,
235 __bit_iterator<_Cp, false> __result) {
236 if (__last.__ctz_ == __result.__ctz_)
237 return std::make_pair(__last, std::__copy_backward_aligned(__first, __last, __result));
238 return std::make_pair(__last, std::__copy_backward_unaligned(__first, __last, __result));
239 }
240
110 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.241 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>242 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
lib/libcxx/include/__algorithm/count.h+5-5
...@@ -55,18 +55,18 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t...@@ -55,18 +55,18 @@ __count_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_t
55 if (__first.__ctz_ != 0) {55 if (__first.__ctz_ != 0) {
56 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);56 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
57 __storage_type __dn = std::min(__clz_f, __n);57 __storage_type __dn = std::min(__clz_f, __n);
58 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));58 __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_);
59 __r = std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m);59 __r = std::__popcount(__storage_type(std::__invert_if<!_ToCount>(*__first.__seg_) & __m));
60 __n -= __dn;60 __n -= __dn;
61 ++__first.__seg_;61 ++__first.__seg_;
62 }62 }
63 // do middle whole words63 // do middle whole words
64 for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)64 for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
65 __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_));65 __r += std::__popcount(std::__invert_if<!_ToCount>(*__first.__seg_));
66 // do last partial word66 // do last partial word
67 if (__n > 0) {67 if (__n > 0) {
68 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);68 __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
69 __r += std::__libcpp_popcount(std::__invert_if<!_ToCount>(*__first.__seg_) & __m);69 __r += std::__popcount(__storage_type(std::__invert_if<!_ToCount>(*__first.__seg_) & __m));
70 }70 }
71 return __r;71 return __r;
72}72}
lib/libcxx/include/__algorithm/equal.h+160
...@@ -11,16 +11,20 @@...@@ -11,16 +11,20 @@
11#define _LIBCPP___ALGORITHM_EQUAL_H11#define _LIBCPP___ALGORITHM_EQUAL_H
1212
13#include <__algorithm/comp.h>13#include <__algorithm/comp.h>
14#include <__algorithm/min.h>
14#include <__algorithm/unwrap_iter.h>15#include <__algorithm/unwrap_iter.h>
15#include <__config>16#include <__config>
16#include <__functional/identity.h>17#include <__functional/identity.h>
18#include <__fwd/bit_reference.h>
17#include <__iterator/distance.h>19#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
21#include <__memory/pointer_traits.h>
19#include <__string/constexpr_c_functions.h>22#include <__string/constexpr_c_functions.h>
20#include <__type_traits/desugars_to.h>23#include <__type_traits/desugars_to.h>
21#include <__type_traits/enable_if.h>24#include <__type_traits/enable_if.h>
22#include <__type_traits/invoke.h>25#include <__type_traits/invoke.h>
23#include <__type_traits/is_equality_comparable.h>26#include <__type_traits/is_equality_comparable.h>
27#include <__type_traits/is_same.h>
24#include <__type_traits/is_volatile.h>28#include <__type_traits/is_volatile.h>
25#include <__utility/move.h>29#include <__utility/move.h>
2630
...@@ -33,6 +37,140 @@ _LIBCPP_PUSH_MACROS...@@ -33,6 +37,140 @@ _LIBCPP_PUSH_MACROS
3337
34_LIBCPP_BEGIN_NAMESPACE_STD38_LIBCPP_BEGIN_NAMESPACE_STD
3539
40template <class _Cp, bool _IsConst1, bool _IsConst2>
41[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
42__equal_unaligned(__bit_iterator<_Cp, _IsConst1> __first1,
43 __bit_iterator<_Cp, _IsConst1> __last1,
44 __bit_iterator<_Cp, _IsConst2> __first2) {
45 using _It = __bit_iterator<_Cp, _IsConst1>;
46 using difference_type = typename _It::difference_type;
47 using __storage_type = typename _It::__storage_type;
48
49 const int __bits_per_word = _It::__bits_per_word;
50 difference_type __n = __last1 - __first1;
51 if (__n > 0) {
52 // do first word
53 if (__first1.__ctz_ != 0) {
54 unsigned __clz_f = __bits_per_word - __first1.__ctz_;
55 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
56 __n -= __dn;
57 __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first1.__ctz_);
58 __storage_type __b = *__first1.__seg_ & __m;
59 unsigned __clz_r = __bits_per_word - __first2.__ctz_;
60 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
61 __m = std::__middle_mask<__storage_type>(__clz_r - __ddn, __first2.__ctz_);
62 if (__first2.__ctz_ > __first1.__ctz_) {
63 if (static_cast<__storage_type>(*__first2.__seg_ & __m) !=
64 static_cast<__storage_type>(__b << (__first2.__ctz_ - __first1.__ctz_)))
65 return false;
66 } else {
67 if (static_cast<__storage_type>(*__first2.__seg_ & __m) !=
68 static_cast<__storage_type>(__b >> (__first1.__ctz_ - __first2.__ctz_)))
69 return false;
70 }
71 __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word;
72 __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word);
73 __dn -= __ddn;
74 if (__dn > 0) {
75 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
76 if (static_cast<__storage_type>(*__first2.__seg_ & __m) !=
77 static_cast<__storage_type>(__b >> (__first1.__ctz_ + __ddn)))
78 return false;
79 __first2.__ctz_ = static_cast<unsigned>(__dn);
80 }
81 ++__first1.__seg_;
82 // __first1.__ctz_ = 0;
83 }
84 // __first1.__ctz_ == 0;
85 // do middle words
86 unsigned __clz_r = __bits_per_word - __first2.__ctz_;
87 __storage_type __m = std::__leading_mask<__storage_type>(__first2.__ctz_);
88 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) {
89 __storage_type __b = *__first1.__seg_;
90 if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b << __first2.__ctz_))
91 return false;
92 ++__first2.__seg_;
93 if (static_cast<__storage_type>(*__first2.__seg_ & static_cast<__storage_type>(~__m)) !=
94 static_cast<__storage_type>(__b >> __clz_r))
95 return false;
96 }
97 // do last word
98 if (__n > 0) {
99 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
100 __storage_type __b = *__first1.__seg_ & __m;
101 __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r));
102 __m = std::__middle_mask<__storage_type>(__clz_r - __dn, __first2.__ctz_);
103 if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b << __first2.__ctz_))
104 return false;
105 __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word;
106 __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word);
107 __n -= __dn;
108 if (__n > 0) {
109 __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
110 if (static_cast<__storage_type>(*__first2.__seg_ & __m) != static_cast<__storage_type>(__b >> __dn))
111 return false;
112 }
113 }
114 }
115 return true;
116}
117
118template <class _Cp, bool _IsConst1, bool _IsConst2>
119[[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
120__equal_aligned(__bit_iterator<_Cp, _IsConst1> __first1,
121 __bit_iterator<_Cp, _IsConst1> __last1,
122 __bit_iterator<_Cp, _IsConst2> __first2) {
123 using _It = __bit_iterator<_Cp, _IsConst1>;
124 using difference_type = typename _It::difference_type;
125 using __storage_type = typename _It::__storage_type;
126
127 const int __bits_per_word = _It::__bits_per_word;
128 difference_type __n = __last1 - __first1;
129 if (__n > 0) {
130 // do first word
131 if (__first1.__ctz_ != 0) {
132 unsigned __clz = __bits_per_word - __first1.__ctz_;
133 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
134 __n -= __dn;
135 __storage_type __m = std::__middle_mask<__storage_type>(__clz - __dn, __first1.__ctz_);
136 if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
137 return false;
138 ++__first2.__seg_;
139 ++__first1.__seg_;
140 // __first1.__ctz_ = 0;
141 // __first2.__ctz_ = 0;
142 }
143 // __first1.__ctz_ == 0;
144 // __first2.__ctz_ == 0;
145 // do middle words
146 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_)
147 if (*__first2.__seg_ != *__first1.__seg_)
148 return false;
149 // do last word
150 if (__n > 0) {
151 __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
152 if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
153 return false;
154 }
155 }
156 return true;
157}
158
159template <class _Cp,
160 bool _IsConst1,
161 bool _IsConst2,
162 class _BinaryPredicate,
163 __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> = 0>
164[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(
165 __bit_iterator<_Cp, _IsConst1> __first1,
166 __bit_iterator<_Cp, _IsConst1> __last1,
167 __bit_iterator<_Cp, _IsConst2> __first2,
168 _BinaryPredicate) {
169 if (__first1.__ctz_ == __first2.__ctz_)
170 return std::__equal_aligned(__first1, __last1, __first2);
171 return std::__equal_unaligned(__first1, __last1, __first2);
172}
173
36template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>174template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(175[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(
38 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) {176 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate& __pred) {
...@@ -94,6 +232,28 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,...@@ -94,6 +232,28 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,
94 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));232 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
95}233}
96234
235template <class _Cp,
236 bool _IsConst1,
237 bool _IsConst2,
238 class _Pred,
239 class _Proj1,
240 class _Proj2,
241 __enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value &&
242 __is_identity<_Proj2>::value,
243 int> = 0>
244[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
245 __bit_iterator<_Cp, _IsConst1> __first1,
246 __bit_iterator<_Cp, _IsConst1> __last1,
247 __bit_iterator<_Cp, _IsConst2> __first2,
248 __bit_iterator<_Cp, _IsConst2>,
249 _Pred&,
250 _Proj1&,
251 _Proj2&) {
252 if (__first1.__ctz_ == __first2.__ctz_)
253 return std::__equal_aligned(__first1, __last1, __first2);
254 return std::__equal_unaligned(__first1, __last1, __first2);
255}
256
97template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>257template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
98[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool258[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
99equal(_InputIterator1 __first1,259equal(_InputIterator1 __first1,
lib/libcxx/include/__algorithm/fill_n.h+2-10
...@@ -41,11 +41,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ...@@ -41,11 +41,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ
41 if (__first.__ctz_ != 0) {41 if (__first.__ctz_ != 0) {
42 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);42 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
43 __storage_type __dn = std::min(__clz_f, __n);43 __storage_type __dn = std::min(__clz_f, __n);
44 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));44 std::__fill_masked_range(std::__to_address(__first.__seg_), __clz_f - __dn, __first.__ctz_, _FillVal);
45 if (_FillVal)
46 *__first.__seg_ |= __m;
47 else
48 *__first.__seg_ &= ~__m;
49 __n -= __dn;45 __n -= __dn;
50 ++__first.__seg_;46 ++__first.__seg_;
51 }47 }
...@@ -56,11 +52,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ...@@ -56,11 +52,7 @@ __fill_n_bool(__bit_iterator<_Cp, false> __first, typename __size_difference_typ
56 // do last partial word52 // do last partial word
57 if (__n > 0) {53 if (__n > 0) {
58 __first.__seg_ += __nw;54 __first.__seg_ += __nw;
59 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);55 std::__fill_masked_range(std::__to_address(__first.__seg_), __bits_per_word - __n, 0u, _FillVal);
60 if (_FillVal)
61 *__first.__seg_ |= __m;
62 else
63 *__first.__seg_ &= ~__m;
64 }56 }
65}57}
6658
lib/libcxx/include/__algorithm/find.h+5-5
...@@ -106,10 +106,10 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty...@@ -106,10 +106,10 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty
106 if (__first.__ctz_ != 0) {106 if (__first.__ctz_ != 0) {
107 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);107 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
108 __storage_type __dn = std::min(__clz_f, __n);108 __storage_type __dn = std::min(__clz_f, __n);
109 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));109 __storage_type __m = std::__middle_mask<__storage_type>(__clz_f - __dn, __first.__ctz_);
110 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;110 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;
111 if (__b)111 if (__b)
112 return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));112 return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b)));
113 if (__n == __dn)113 if (__n == __dn)
114 return __first + __n;114 return __first + __n;
115 __n -= __dn;115 __n -= __dn;
...@@ -119,14 +119,14 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty...@@ -119,14 +119,14 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename __size_difference_ty
119 for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) {119 for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word) {
120 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_);120 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_);
121 if (__b)121 if (__b)
122 return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));122 return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b)));
123 }123 }
124 // do last partial word124 // do last partial word
125 if (__n > 0) {125 if (__n > 0) {
126 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);126 __storage_type __m = std::__trailing_mask<__storage_type>(__bits_per_word - __n);
127 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;127 __storage_type __b = std::__invert_if<!_ToFind>(*__first.__seg_) & __m;
128 if (__b)128 if (__b)
129 return _It(__first.__seg_, static_cast<unsigned>(std::__libcpp_ctz(__b)));129 return _It(__first.__seg_, static_cast<unsigned>(std::__countr_zero(__b)));
130 }130 }
131 return _It(__first.__seg_, static_cast<unsigned>(__n));131 return _It(__first.__seg_, static_cast<unsigned>(__n));
132}132}
lib/libcxx/include/__algorithm/for_each.h+28-19
...@@ -12,9 +12,10 @@...@@ -12,9 +12,10 @@
1212
13#include <__algorithm/for_each_segment.h>13#include <__algorithm/for_each_segment.h>
14#include <__config>14#include <__config>
15#include <__functional/identity.h>
15#include <__iterator/segmented_iterator.h>16#include <__iterator/segmented_iterator.h>
16#include <__ranges/movable_box.h>17#include <__type_traits/enable_if.h>
17#include <__utility/in_place.h>18#include <__type_traits/invoke.h>
18#include <__utility/move.h>19#include <__utility/move.h>
1920
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -26,28 +27,36 @@ _LIBCPP_PUSH_MACROS...@@ -26,28 +27,36 @@ _LIBCPP_PUSH_MACROS
2627
27_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2829
29template <class _InputIterator, class _Function>30template <class _InputIterator, class _Sent, class _Func, class _Proj>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
31for_each(_InputIterator __first, _InputIterator __last, _Function __f) {32__for_each(_InputIterator __first, _Sent __last, _Func& __f, _Proj& __proj) {
32 for (; __first != __last; ++__first)33 for (; __first != __last; ++__first)
33 __f(*__first);34 std::__invoke(__f, std::__invoke(__proj, *__first));
34 return __f;35 return __first;
35}36}
3637
37// __movable_box is available in C++20, but is actually a copyable-box, so optimization is only correct in C++2338#ifndef _LIBCPP_CXX03_LANG
38#if _LIBCPP_STD_VER >= 2339template <class _SegmentedIterator,
39template <class _SegmentedIterator, class _Function>40 class _Func,
40 requires __is_segmented_iterator<_SegmentedIterator>::value41 class _Proj,
41_LIBCPP_HIDE_FROM_ABI constexpr _Function42 __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0>
42for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Function __func) {43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator
43 ranges::__movable_box<_Function> __wrapped_func(in_place, std::move(__func));44__for_each(_SegmentedIterator __first, _SegmentedIterator __last, _Func& __func, _Proj& __proj) {
44 std::__for_each_segment(__first, __last, [&](auto __lfirst, auto __llast) {45 using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator;
45 __wrapped_func =46 std::__for_each_segment(__first, __last, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) {
46 ranges::__movable_box<_Function>(in_place, std::for_each(__lfirst, __llast, std::move(*__wrapped_func)));47 std::__for_each(__lfirst, __llast, __func, __proj);
47 });48 });
48 return std::move(*__wrapped_func);49 return __last;
50}
51#endif // !_LIBCPP_CXX03_LANG
52
53template <class _InputIterator, class _Func>
54_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Func
55for_each(_InputIterator __first, _InputIterator __last, _Func __f) {
56 __identity __proj;
57 std::__for_each(__first, __last, __f, __proj);
58 return __f;
49}59}
50#endif // _LIBCPP_STD_VER >= 23
5160
52_LIBCPP_END_NAMESPACE_STD61_LIBCPP_END_NAMESPACE_STD
5362
lib/libcxx/include/__algorithm/for_each_n.h+69-8
...@@ -10,32 +10,93 @@...@@ -10,32 +10,93 @@
10#ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H10#ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H
11#define _LIBCPP___ALGORITHM_FOR_EACH_N_H11#define _LIBCPP___ALGORITHM_FOR_EACH_N_H
1212
13#include <__algorithm/for_each.h>
14#include <__algorithm/for_each_n_segment.h>
13#include <__config>15#include <__config>
16#include <__functional/identity.h>
17#include <__iterator/iterator_traits.h>
18#include <__iterator/segmented_iterator.h>
19#include <__type_traits/disjunction.h>
20#include <__type_traits/enable_if.h>
21#include <__type_traits/invoke.h>
22#include <__type_traits/negation.h>
14#include <__utility/convert_to_integral.h>23#include <__utility/convert_to_integral.h>
24#include <__utility/move.h>
1525
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header27# pragma GCC system_header
18#endif28#endif
1929
20_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
2132
22#if _LIBCPP_STD_VER >= 1733_LIBCPP_BEGIN_NAMESPACE_STD
2334
24template <class _InputIterator, class _Size, class _Function>35template <class _InputIterator,
25inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator36 class _Size,
26for_each_n(_InputIterator __first, _Size __orig_n, _Function __f) {37 class _Func,
38 class _Proj,
39 __enable_if_t<!__has_random_access_iterator_category<_InputIterator>::value &&
40 _Or< _Not<__is_segmented_iterator<_InputIterator> >,
41 _Not<__has_random_access_local_iterator<_InputIterator> > >::value,
42 int> = 0>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
44__for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) {
27 typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;45 typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
28 _IntegralSize __n = __orig_n;46 _IntegralSize __n = __orig_n;
29 while (__n > 0) {47 while (__n > 0) {
30 __f(*__first);48 std::__invoke(__f, std::__invoke(__proj, *__first));
31 ++__first;49 ++__first;
32 --__n;50 --__n;
33 }51 }
34 return __first;52 return std::move(__first);
35}53}
3654
37#endif55template <class _RandIter,
56 class _Size,
57 class _Func,
58 class _Proj,
59 __enable_if_t<__has_random_access_iterator_category<_RandIter>::value, int> = 0>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandIter
61__for_each_n(_RandIter __first, _Size __orig_n, _Func& __f, _Proj& __proj) {
62 typename std::iterator_traits<_RandIter>::difference_type __n = __orig_n;
63 auto __last = __first + __n;
64 std::__for_each(__first, __last, __f, __proj);
65 return __last;
66}
67
68#ifndef _LIBCPP_CXX03_LANG
69template <class _SegmentedIterator,
70 class _Size,
71 class _Func,
72 class _Proj,
73 __enable_if_t<!__has_random_access_iterator_category<_SegmentedIterator>::value &&
74 __is_segmented_iterator<_SegmentedIterator>::value &&
75 __has_random_access_iterator_category<
76 typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value,
77 int> = 0>
78_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _SegmentedIterator
79__for_each_n(_SegmentedIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) {
80 using __local_iterator_t = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator;
81 return std::__for_each_n_segment(__first, __orig_n, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) {
82 std::__for_each(__lfirst, __llast, __f, __proj);
83 });
84}
85#endif // !_LIBCPP_CXX03_LANG
86
87#if _LIBCPP_STD_VER >= 17
88
89template <class _InputIterator, class _Size, class _Func>
90inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
91for_each_n(_InputIterator __first, _Size __orig_n, _Func __f) {
92 __identity __proj;
93 return std::__for_each_n(__first, __orig_n, __f, __proj);
94}
95
96#endif // _LIBCPP_STD_VER >= 17
3897
39_LIBCPP_END_NAMESPACE_STD98_LIBCPP_END_NAMESPACE_STD
4099
100_LIBCPP_POP_MACROS
101
41#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H102#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H
lib/libcxx/include/__algorithm/for_each_n_segment.h created+63
...@@ -0,0 +1,63 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H
10#define _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H
11
12#include <__config>
13#include <__iterator/iterator_traits.h>
14#include <__iterator/segmented_iterator.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22// __for_each_n_segment optimizes linear iteration over segmented iterators. It processes a segmented
23// input range [__first, __first + __n) by applying the functor __func to each element within the segment.
24// The return value of __func is ignored, and the function returns an iterator pointing to one past the
25// last processed element in the input range.
26
27template <class _SegmentedIterator, class _Size, class _Functor>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
29__for_each_n_segment(_SegmentedIterator __first, _Size __orig_n, _Functor __func) {
30 static_assert(__is_segmented_iterator<_SegmentedIterator>::value &&
31 __has_random_access_iterator_category<
32 typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator>::value,
33 "__for_each_n_segment only works with segmented iterators with random-access local iterators");
34 if (__orig_n <= 0)
35 return __first;
36
37 using _Traits = __segmented_iterator_traits<_SegmentedIterator>;
38 using __local_iter_t = typename _Traits::__local_iterator;
39 using __difference_t = typename std::iterator_traits<__local_iter_t>::difference_type;
40 __difference_t __n = __orig_n;
41 auto __seg = _Traits::__segment(__first);
42 auto __local_first = _Traits::__local(__first);
43 __local_iter_t __local_last;
44
45 while (__n > 0) {
46 __local_last = _Traits::__end(__seg);
47 auto __seg_size = __local_last - __local_first;
48 if (__n <= __seg_size) {
49 __local_last = __local_first + __n;
50 __func(__local_first, __local_last);
51 break;
52 }
53 __func(__local_first, __local_last);
54 __n -= __seg_size;
55 __local_first = _Traits::__begin(++__seg);
56 }
57
58 return _Traits::__compose(__seg, __local_last);
59}
60
61_LIBCPP_END_NAMESPACE_STD
62
63#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_SEGMENT_H
lib/libcxx/include/__algorithm/inplace_merge.h+6-5
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__functional/identity.h>22#include <__functional/identity.h>
23#include <__iterator/iterator_traits.h>23#include <__iterator/iterator_traits.h>
24#include <__iterator/reverse_iterator.h>24#include <__iterator/reverse_iterator.h>
25#include <__memory/construct_at.h>
25#include <__memory/destruct_n.h>26#include <__memory/destruct_n.h>
26#include <__memory/unique_ptr.h>27#include <__memory/unique_ptr.h>
27#include <__memory/unique_temporary_buffer.h>28#include <__memory/unique_temporary_buffer.h>
...@@ -106,13 +107,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merg...@@ -106,13 +107,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __buffered_inplace_merg
106 value_type* __p = __buff;107 value_type* __p = __buff;
107 for (_BidirectionalIterator __i = __first; __i != __middle;108 for (_BidirectionalIterator __i = __first; __i != __middle;
108 __d.template __incr<value_type>(), (void)++__i, (void)++__p)109 __d.template __incr<value_type>(), (void)++__i, (void)++__p)
109 ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));110 std::__construct_at(__p, _IterOps<_AlgPolicy>::__iter_move(__i));
110 std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);111 std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp);
111 } else {112 } else {
112 value_type* __p = __buff;113 value_type* __p = __buff;
113 for (_BidirectionalIterator __i = __middle; __i != __last;114 for (_BidirectionalIterator __i = __middle; __i != __last;
114 __d.template __incr<value_type>(), (void)++__i, (void)++__p)115 __d.template __incr<value_type>(), (void)++__i, (void)++__p)
115 ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));116 std::__construct_at(__p, _IterOps<_AlgPolicy>::__iter_move(__i));
116 typedef reverse_iterator<_BidirectionalIterator> _RBi;117 typedef reverse_iterator<_BidirectionalIterator> _RBi;
117 typedef reverse_iterator<value_type*> _Rv;118 typedef reverse_iterator<value_type*> _Rv;
118 typedef __invert<_Compare> _Inverted;119 typedef __invert<_Compare> _Inverted;
...@@ -203,7 +204,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge(...@@ -203,7 +204,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge(
203}204}
204205
205template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>206template <class _AlgPolicy, class _BidirectionalIterator, class _Compare>
206_LIBCPP_HIDE_FROM_ABI void __inplace_merge(207_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __inplace_merge(
207 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) {208 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare&& __comp) {
208 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;209 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
209 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;210 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
...@@ -223,14 +224,14 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge(...@@ -223,14 +224,14 @@ _LIBCPP_HIDE_FROM_ABI void __inplace_merge(
223}224}
224225
225template <class _BidirectionalIterator, class _Compare>226template <class _BidirectionalIterator, class _Compare>
226inline _LIBCPP_HIDE_FROM_ABI void inplace_merge(227inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void inplace_merge(
227 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {228 _BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) {
228 std::__inplace_merge<_ClassicAlgPolicy>(229 std::__inplace_merge<_ClassicAlgPolicy>(
229 std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp));230 std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp));
230}231}
231232
232template <class _BidirectionalIterator>233template <class _BidirectionalIterator>
233inline _LIBCPP_HIDE_FROM_ABI void234inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
234inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) {235inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) {
235 std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), __less<>());236 std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), __less<>());
236}237}
lib/libcxx/include/__algorithm/min_element.h+1-1
...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _Comp, class _Iter, class _Sent, class _Proj>30template <class _Comp, class _Iter, class _Sent, class _Proj>
31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
32__min_element(_Iter __first, _Sent __last, _Comp __comp, _Proj& __proj) {32__min_element(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
33 if (__first == __last)33 if (__first == __last)
34 return __first;34 return __first;
3535
lib/libcxx/include/__algorithm/move.h+10
...@@ -9,11 +9,13 @@...@@ -9,11 +9,13 @@
9#ifndef _LIBCPP___ALGORITHM_MOVE_H9#ifndef _LIBCPP___ALGORITHM_MOVE_H
10#define _LIBCPP___ALGORITHM_MOVE_H10#define _LIBCPP___ALGORITHM_MOVE_H
1111
12#include <__algorithm/copy.h>
12#include <__algorithm/copy_move_common.h>13#include <__algorithm/copy_move_common.h>
13#include <__algorithm/for_each_segment.h>14#include <__algorithm/for_each_segment.h>
14#include <__algorithm/iterator_operations.h>15#include <__algorithm/iterator_operations.h>
15#include <__algorithm/min.h>16#include <__algorithm/min.h>
16#include <__config>17#include <__config>
18#include <__fwd/bit_reference.h>
17#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
18#include <__iterator/segmented_iterator.h>20#include <__iterator/segmented_iterator.h>
19#include <__type_traits/common_type.h>21#include <__type_traits/common_type.h>
...@@ -98,6 +100,14 @@ struct __move_impl {...@@ -98,6 +100,14 @@ struct __move_impl {
98 }100 }
99 }101 }
100102
103 template <class _Cp, bool _IsConst>
104 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
105 operator()(__bit_iterator<_Cp, _IsConst> __first,
106 __bit_iterator<_Cp, _IsConst> __last,
107 __bit_iterator<_Cp, false> __result) {
108 return std::__copy(__first, __last, __result);
109 }
110
101 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.111 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
102 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>112 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
lib/libcxx/include/__algorithm/move_backward.h+10
...@@ -9,10 +9,12 @@...@@ -9,10 +9,12 @@
9#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H9#ifndef _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
10#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H10#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H
1111
12#include <__algorithm/copy_backward.h>
12#include <__algorithm/copy_move_common.h>13#include <__algorithm/copy_move_common.h>
13#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>15#include <__algorithm/min.h>
15#include <__config>16#include <__config>
17#include <__fwd/bit_reference.h>
16#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
17#include <__iterator/segmented_iterator.h>19#include <__iterator/segmented_iterator.h>
18#include <__type_traits/common_type.h>20#include <__type_traits/common_type.h>
...@@ -107,6 +109,14 @@ struct __move_backward_impl {...@@ -107,6 +109,14 @@ struct __move_backward_impl {
107 }109 }
108 }110 }
109111
112 template <class _Cp, bool _IsConst>
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
114 operator()(__bit_iterator<_Cp, _IsConst> __first,
115 __bit_iterator<_Cp, _IsConst> __last,
116 __bit_iterator<_Cp, false> __result) {
117 return std::__copy_backward<_ClassicAlgPolicy>(__first, __last, __result);
118 }
119
110 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.120 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>121 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>122 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
lib/libcxx/include/__algorithm/out_value_result.h created+56
...@@ -0,0 +1,56 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
11#define _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
12
13#include <__concepts/convertible_to.h>
14#include <__config>
15#include <__utility/move.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26#if _LIBCPP_STD_VER >= 23
27
28namespace ranges {
29
30template <class _OutIter1, class _ValType1>
31struct out_value_result {
32 _LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out;
33 _LIBCPP_NO_UNIQUE_ADDRESS _ValType1 value;
34
35 template <class _OutIter2, class _ValType2>
36 requires convertible_to<const _OutIter1&, _OutIter2> && convertible_to<const _ValType1&, _ValType2>
37 _LIBCPP_HIDE_FROM_ABI constexpr operator out_value_result<_OutIter2, _ValType2>() const& {
38 return {out, value};
39 }
40
41 template <class _OutIter2, class _ValType2>
42 requires convertible_to<_OutIter1, _OutIter2> && convertible_to<_ValType1, _ValType2>
43 _LIBCPP_HIDE_FROM_ABI constexpr operator out_value_result<_OutIter2, _ValType2>() && {
44 return {std::move(out), std::move(value)};
45 }
46};
47
48} // namespace ranges
49
50#endif // _LIBCPP_STD_VER >= 23
51
52_LIBCPP_END_NAMESPACE_STD
53
54_LIBCPP_POP_MACROS
55
56#endif // _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
lib/libcxx/include/__algorithm/radix_sort.h+111-14
...@@ -29,10 +29,12 @@...@@ -29,10 +29,12 @@
2929
30#include <__algorithm/for_each.h>30#include <__algorithm/for_each.h>
31#include <__algorithm/move.h>31#include <__algorithm/move.h>
32#include <__bit/bit_cast.h>
32#include <__bit/bit_log2.h>33#include <__bit/bit_log2.h>
33#include <__bit/countl.h>
34#include <__config>34#include <__config>
35#include <__cstddef/size_t.h>
35#include <__functional/identity.h>36#include <__functional/identity.h>
37#include <__iterator/access.h>
36#include <__iterator/distance.h>38#include <__iterator/distance.h>
37#include <__iterator/iterator_traits.h>39#include <__iterator/iterator_traits.h>
38#include <__iterator/move_iterator.h>40#include <__iterator/move_iterator.h>
...@@ -43,9 +45,12 @@...@@ -43,9 +45,12 @@
43#include <__type_traits/enable_if.h>45#include <__type_traits/enable_if.h>
44#include <__type_traits/invoke.h>46#include <__type_traits/invoke.h>
45#include <__type_traits/is_assignable.h>47#include <__type_traits/is_assignable.h>
48#include <__type_traits/is_enum.h>
46#include <__type_traits/is_integral.h>49#include <__type_traits/is_integral.h>
47#include <__type_traits/is_unsigned.h>50#include <__type_traits/is_unsigned.h>
48#include <__type_traits/make_unsigned.h>51#include <__type_traits/make_unsigned.h>
52#include <__type_traits/void_t.h>
53#include <__utility/declval.h>
49#include <__utility/forward.h>54#include <__utility/forward.h>
50#include <__utility/integer_sequence.h>55#include <__utility/integer_sequence.h>
51#include <__utility/move.h>56#include <__utility/move.h>
...@@ -67,7 +72,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -67,7 +72,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
67#if _LIBCPP_STD_VER >= 1472#if _LIBCPP_STD_VER >= 14
6873
69template <class _InputIterator, class _OutputIterator>74template <class _InputIterator, class _OutputIterator>
70_LIBCPP_HIDE_FROM_ABI pair<_OutputIterator, __iter_value_type<_InputIterator>>75_LIBCPP_HIDE_FROM_ABI constexpr pair<_OutputIterator, __iter_value_type<_InputIterator>>
71__partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {76__partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
72 if (__first == __last)77 if (__first == __last)
73 return {__result, 0};78 return {__result, 0};
...@@ -109,7 +114,7 @@ struct __counting_sort_traits {...@@ -109,7 +114,7 @@ struct __counting_sort_traits {
109};114};
110115
111template <class _Radix, class _Integer>116template <class _Radix, class _Integer>
112_LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) {117_LIBCPP_HIDE_FROM_ABI constexpr auto __nth_radix(size_t __radix_number, _Radix __radix, _Integer __n) {
113 static_assert(is_unsigned<_Integer>::value);118 static_assert(is_unsigned<_Integer>::value);
114 using __traits = __counting_sort_traits<_Integer, _Radix>;119 using __traits = __counting_sort_traits<_Integer, _Radix>;
115120
...@@ -117,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _I...@@ -117,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI auto __nth_radix(size_t __radix_number, _Radix __radix, _I
117}122}
118123
119template <class _ForwardIterator, class _Map, class _RandomAccessIterator>124template <class _ForwardIterator, class _Map, class _RandomAccessIterator>
120_LIBCPP_HIDE_FROM_ABI void125_LIBCPP_HIDE_FROM_ABI constexpr void
121__collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) {126__collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _RandomAccessIterator __counters) {
122 using __value_type = __iter_value_type<_ForwardIterator>;127 using __value_type = __iter_value_type<_ForwardIterator>;
123 using __traits = __counting_sort_traits<__value_type, _Map>;128 using __traits = __counting_sort_traits<__value_type, _Map>;
...@@ -129,7 +134,7 @@ __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _Random...@@ -129,7 +134,7 @@ __collect(_ForwardIterator __first, _ForwardIterator __last, _Map __map, _Random
129}134}
130135
131template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>136template <class _ForwardIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>
132_LIBCPP_HIDE_FROM_ABI void137_LIBCPP_HIDE_FROM_ABI constexpr void
133__dispose(_ForwardIterator __first,138__dispose(_ForwardIterator __first,
134 _ForwardIterator __last,139 _ForwardIterator __last,
135 _RandomAccessIterator1 __result,140 _RandomAccessIterator1 __result,
...@@ -147,7 +152,7 @@ template <class _ForwardIterator,...@@ -147,7 +152,7 @@ template <class _ForwardIterator,
147 class _RandomAccessIterator1,152 class _RandomAccessIterator1,
148 class _RandomAccessIterator2,153 class _RandomAccessIterator2,
149 size_t... _Radices>154 size_t... _Radices>
150_LIBCPP_HIDE_FROM_ABI bool __collect_impl(155_LIBCPP_HIDE_FROM_ABI constexpr bool __collect_impl(
151 _ForwardIterator __first,156 _ForwardIterator __first,
152 _ForwardIterator __last,157 _ForwardIterator __last,
153 _Map __map,158 _Map __map,
...@@ -177,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI bool __collect_impl(...@@ -177,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI bool __collect_impl(
177}182}
178183
179template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2>184template <class _ForwardIterator, class _Map, class _Radix, class _RandomAccessIterator1, class _RandomAccessIterator2>
180_LIBCPP_HIDE_FROM_ABI bool185_LIBCPP_HIDE_FROM_ABI constexpr bool
181__collect(_ForwardIterator __first,186__collect(_ForwardIterator __first,
182 _ForwardIterator __last,187 _ForwardIterator __last,
183 _Map __map,188 _Map __map,
...@@ -191,7 +196,7 @@ __collect(_ForwardIterator __first,...@@ -191,7 +196,7 @@ __collect(_ForwardIterator __first,
191}196}
192197
193template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>198template <class _BidirectionalIterator, class _RandomAccessIterator1, class _Map, class _RandomAccessIterator2>
194_LIBCPP_HIDE_FROM_ABI void __dispose_backward(199_LIBCPP_HIDE_FROM_ABI constexpr void __dispose_backward(
195 _BidirectionalIterator __first,200 _BidirectionalIterator __first,
196 _BidirectionalIterator __last,201 _BidirectionalIterator __last,
197 _RandomAccessIterator1 __result,202 _RandomAccessIterator1 __result,
...@@ -206,7 +211,7 @@ _LIBCPP_HIDE_FROM_ABI void __dispose_backward(...@@ -206,7 +211,7 @@ _LIBCPP_HIDE_FROM_ABI void __dispose_backward(
206}211}
207212
208template <class _ForwardIterator, class _RandomAccessIterator, class _Map>213template <class _ForwardIterator, class _RandomAccessIterator, class _Map>
209_LIBCPP_HIDE_FROM_ABI _RandomAccessIterator214_LIBCPP_HIDE_FROM_ABI constexpr _RandomAccessIterator
210__counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) {215__counting_sort_impl(_ForwardIterator __first, _ForwardIterator __last, _RandomAccessIterator __result, _Map __map) {
211 using __value_type = __iter_value_type<_ForwardIterator>;216 using __value_type = __iter_value_type<_ForwardIterator>;
212 using __traits = __counting_sort_traits<__value_type, _Map>;217 using __traits = __counting_sort_traits<__value_type, _Map>;
...@@ -225,7 +230,7 @@ template <class _RandomAccessIterator1,...@@ -225,7 +230,7 @@ template <class _RandomAccessIterator1,
225 class _Radix,230 class _Radix,
226 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1,231 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count == 1,
227 int> = 0>232 int> = 0>
228_LIBCPP_HIDE_FROM_ABI void __radix_sort_impl(233_LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl(
229 _RandomAccessIterator1 __first,234 _RandomAccessIterator1 __first,
230 _RandomAccessIterator1 __last,235 _RandomAccessIterator1 __last,
231 _RandomAccessIterator2 __buffer,236 _RandomAccessIterator2 __buffer,
...@@ -245,7 +250,7 @@ template <...@@ -245,7 +250,7 @@ template <
245 class _Radix,250 class _Radix,
246 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0,251 enable_if_t< __radix_sort_traits<__iter_value_type<_RandomAccessIterator1>, _Map, _Radix>::__radix_count % 2 == 0,
247 int> = 0 >252 int> = 0 >
248_LIBCPP_HIDE_FROM_ABI void __radix_sort_impl(253_LIBCPP_HIDE_FROM_ABI constexpr void __radix_sort_impl(
249 _RandomAccessIterator1 __first,254 _RandomAccessIterator1 __first,
250 _RandomAccessIterator1 __last,255 _RandomAccessIterator1 __last,
251 _RandomAccessIterator2 __buffer_begin,256 _RandomAccessIterator2 __buffer_begin,
...@@ -297,6 +302,96 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) {...@@ -297,6 +302,96 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __shift_to_unsigned(_Ip __n) {
297 return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value);302 return static_cast<make_unsigned_t<_Ip> >(__n ^ __min_value);
298}303}
299304
305template <size_t _Size>
306struct __unsigned_integer_of_size;
307
308template <>
309struct __unsigned_integer_of_size<1> {
310 using type _LIBCPP_NODEBUG = uint8_t;
311};
312
313template <>
314struct __unsigned_integer_of_size<2> {
315 using type _LIBCPP_NODEBUG = uint16_t;
316};
317
318template <>
319struct __unsigned_integer_of_size<4> {
320 using type _LIBCPP_NODEBUG = uint32_t;
321};
322
323template <>
324struct __unsigned_integer_of_size<8> {
325 using type _LIBCPP_NODEBUG = uint64_t;
326};
327
328# if _LIBCPP_HAS_INT128
329template <>
330struct __unsigned_integer_of_size<16> {
331 using type _LIBCPP_NODEBUG = unsigned __int128;
332};
333# endif
334
335template <size_t _Size>
336using __unsigned_integer_of_size_t _LIBCPP_NODEBUG = typename __unsigned_integer_of_size<_Size>::type;
337
338template <class _Sc>
339using __unsigned_representation_for_t _LIBCPP_NODEBUG = __unsigned_integer_of_size_t<sizeof(_Sc)>;
340
341// The function `__to_ordered_integral` is defined for integers and IEEE 754 floating-point numbers.
342// Returns an integer representation such that for any `x` and `y` such that `x < y`, the expression
343// `__to_ordered_integral(x) < __to_ordered_integral(y)` is true, where `x`, `y` are integers or IEEE 754 floats.
344template <class _Integral, enable_if_t< is_integral<_Integral>::value, int> = 0>
345_LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Integral __n) {
346 return __n;
347}
348
349// An overload for IEEE 754 floating-point numbers
350
351// For the floats conforming to IEEE 754 (IEC 559) standard, we know that:
352// 1. The bit representation of positive floats directly reflects their order:
353// When comparing floats by magnitude, the number with the larger exponent is greater, and if the exponents are
354// equal, the one with the larger mantissa is greater.
355// 2. The bit representation of negative floats reflects their reverse order (for the same reasons).
356// 3. The most significant bit (sign bit) is zero for positive floats and one for negative floats. Therefore, in the raw
357// bit representation, any negative number will be greater than any positive number.
358
359// The only exception from this rule is `NaN`, which is unordered by definition.
360
361// Based on the above, to obtain correctly ordered integral representation of floating-point numbers, we need to:
362// 1. Invert the bit representation (including the sign bit) of negative floats to switch from reverse order to direct
363// order;
364// 2. Invert the sign bit for positive floats.
365
366// Thus, in final integral representation, we have reversed the order for negative floats and made all negative floats
367// smaller than all positive numbers (by inverting the sign bit).
368template <class _Floating, enable_if_t< numeric_limits<_Floating>::is_iec559, int> = 0>
369_LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Floating __f) {
370 using __integral_type = __unsigned_representation_for_t<_Floating>;
371 constexpr auto __bit_count = std::numeric_limits<__integral_type>::digits;
372 constexpr auto __sign_bit_mask = static_cast<__integral_type>(__integral_type{1} << (__bit_count - 1));
373
374 const auto __u = std::__bit_cast<__integral_type>(__f);
375
376 return static_cast<__integral_type>(__u & __sign_bit_mask ? ~__u : __u ^ __sign_bit_mask);
377}
378
379// There may exist user-defined comparison for enum, so we cannot compare enums just like integers.
380template <class _Enum, enable_if_t< is_enum<_Enum>::value, int> = 0>
381_LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(_Enum __e) = delete;
382
383// `long double` varies significantly across platforms and compilers, making it practically
384// impossible to determine its actual bit width for conversion to an ordered integer.
385inline _LIBCPP_HIDE_FROM_ABI constexpr auto __to_ordered_integral(long double) = delete;
386
387template <class _Tp, class = void>
388inline const bool __is_ordered_integer_representable_v = false;
389
390template <class _Tp>
391inline const bool
392 __is_ordered_integer_representable_v<_Tp, __void_t<decltype(std::__to_ordered_integral(std::declval<_Tp>()))>> =
393 true;
394
300struct __low_byte_fn {395struct __low_byte_fn {
301 template <class _Ip>396 template <class _Ip>
302 _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const {397 _LIBCPP_HIDE_FROM_ABI constexpr uint8_t operator()(_Ip __integer) const {
...@@ -307,18 +402,20 @@ struct __low_byte_fn {...@@ -307,18 +402,20 @@ struct __low_byte_fn {
307};402};
308403
309template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix>404template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _Map, class _Radix>
310_LIBCPP_HIDE_FROM_ABI void405_LIBCPP_HIDE_FROM_ABI constexpr void
311__radix_sort(_RandomAccessIterator1 __first,406__radix_sort(_RandomAccessIterator1 __first,
312 _RandomAccessIterator1 __last,407 _RandomAccessIterator1 __last,
313 _RandomAccessIterator2 __buffer,408 _RandomAccessIterator2 __buffer,
314 _Map __map,409 _Map __map,
315 _Radix __radix) {410 _Radix __radix) {
316 auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) { return std::__shift_to_unsigned(__map(__x)); };411 auto __map_to_unsigned = [__map = std::move(__map)](const auto& __x) {
412 return std::__shift_to_unsigned(__map(std::__to_ordered_integral(__x)));
413 };
317 std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix);414 std::__radix_sort_impl(__first, __last, __buffer, __map_to_unsigned, __radix);
318}415}
319416
320template <class _RandomAccessIterator1, class _RandomAccessIterator2>417template <class _RandomAccessIterator1, class _RandomAccessIterator2>
321_LIBCPP_HIDE_FROM_ABI void418_LIBCPP_HIDE_FROM_ABI constexpr void
322__radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) {419__radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _RandomAccessIterator2 __buffer) {
323 std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{});420 std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{});
324}421}
lib/libcxx/include/__algorithm/ranges_for_each.h+14-4
...@@ -9,10 +9,12 @@...@@ -9,10 +9,12 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_H
1111
12#include <__algorithm/for_each.h>
13#include <__algorithm/for_each_n.h>
12#include <__algorithm/in_fun_result.h>14#include <__algorithm/in_fun_result.h>
15#include <__concepts/assignable.h>
13#include <__config>16#include <__config>
14#include <__functional/identity.h>17#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>18#include <__iterator/concepts.h>
17#include <__iterator/projected.h>19#include <__iterator/projected.h>
18#include <__ranges/access.h>20#include <__ranges/access.h>
...@@ -41,9 +43,17 @@ private:...@@ -41,9 +43,17 @@ private:
41 template <class _Iter, class _Sent, class _Proj, class _Func>43 template <class _Iter, class _Sent, class _Proj, class _Func>
42 _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func>44 _LIBCPP_HIDE_FROM_ABI constexpr static for_each_result<_Iter, _Func>
43 __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) {45 __for_each_impl(_Iter __first, _Sent __last, _Func& __func, _Proj& __proj) {
44 for (; __first != __last; ++__first)46 // In the case where we have different iterator and sentinel types, the segmented iterator optimization
45 std::invoke(__func, std::invoke(__proj, *__first));47 // in std::for_each will not kick in. Therefore, we prefer std::for_each_n in that case (whenever we can
46 return {std::move(__first), std::move(__func)};48 // obtain the `n`).
49 if constexpr (!std::assignable_from<_Iter&, _Sent> && std::sized_sentinel_for<_Sent, _Iter>) {
50 auto __n = __last - __first;
51 auto __end = std::__for_each_n(std::move(__first), __n, __func, __proj);
52 return {std::move(__end), std::move(__func)};
53 } else {
54 auto __end = std::__for_each(std::move(__first), std::move(__last), __func, __proj);
55 return {std::move(__end), std::move(__func)};
56 }
47 }57 }
4858
49public:59public:
lib/libcxx/include/__algorithm/ranges_for_each_n.h+3-6
...@@ -9,10 +9,10 @@...@@ -9,10 +9,10 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H9#ifndef _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H10#define _LIBCPP___ALGORITHM_RANGES_FOR_EACH_N_H
1111
12#include <__algorithm/for_each_n.h>
12#include <__algorithm/in_fun_result.h>13#include <__algorithm/in_fun_result.h>
13#include <__config>14#include <__config>
14#include <__functional/identity.h>15#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__iterator/concepts.h>16#include <__iterator/concepts.h>
17#include <__iterator/incrementable_traits.h>17#include <__iterator/incrementable_traits.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
...@@ -40,11 +40,8 @@ struct __for_each_n {...@@ -40,11 +40,8 @@ struct __for_each_n {
40 template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>40 template <input_iterator _Iter, class _Proj = identity, indirectly_unary_invocable<projected<_Iter, _Proj>> _Func>
41 _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func>41 _LIBCPP_HIDE_FROM_ABI constexpr for_each_n_result<_Iter, _Func>
42 operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const {42 operator()(_Iter __first, iter_difference_t<_Iter> __count, _Func __func, _Proj __proj = {}) const {
43 while (__count-- > 0) {43 auto __last = std::__for_each_n(std::move(__first), __count, __func, __proj);
44 std::invoke(__func, std::invoke(__proj, *__first));44 return {std::move(__last), std::move(__func)};
45 ++__first;
46 }
47 return {std::move(__first), std::move(__func)};
48 }45 }
49};46};
5047
lib/libcxx/include/__algorithm/ranges_inplace_merge.h+3-3
...@@ -41,7 +41,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -41,7 +41,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
41namespace ranges {41namespace ranges {
42struct __inplace_merge {42struct __inplace_merge {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI static constexpr auto44 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
45 __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {45 __inplace_merge_impl(_Iter __first, _Iter __middle, _Sent __last, _Comp&& __comp, _Proj&& __proj) {
46 auto __last_iter = ranges::next(__middle, __last);46 auto __last_iter = ranges::next(__middle, __last);
47 std::__inplace_merge<_RangeAlgPolicy>(47 std::__inplace_merge<_RangeAlgPolicy>(
...@@ -51,7 +51,7 @@ struct __inplace_merge {...@@ -51,7 +51,7 @@ struct __inplace_merge {
5151
52 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>52 template <bidirectional_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
53 requires sortable<_Iter, _Comp, _Proj>53 requires sortable<_Iter, _Comp, _Proj>
54 _LIBCPP_HIDE_FROM_ABI _Iter54 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter
55 operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {55 operator()(_Iter __first, _Iter __middle, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
56 return __inplace_merge_impl(56 return __inplace_merge_impl(
57 std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));57 std::move(__first), std::move(__middle), std::move(__last), std::move(__comp), std::move(__proj));
...@@ -59,7 +59,7 @@ struct __inplace_merge {...@@ -59,7 +59,7 @@ struct __inplace_merge {
5959
60 template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>60 template <bidirectional_range _Range, class _Comp = ranges::less, class _Proj = identity>
61 requires sortable<iterator_t<_Range>, _Comp, _Proj>61 requires sortable<iterator_t<_Range>, _Comp, _Proj>
62 _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>62 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_Range>
63 operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {63 operator()(_Range&& __range, iterator_t<_Range> __middle, _Comp __comp = {}, _Proj __proj = {}) const {
64 return __inplace_merge_impl(64 return __inplace_merge_impl(
65 ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));65 ranges::begin(__range), std::move(__middle), ranges::end(__range), std::move(__comp), std::move(__proj));
lib/libcxx/include/__algorithm/ranges_iterator_concept.h+1-1
...@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {...@@ -44,7 +44,7 @@ consteval auto __get_iterator_concept() {
44}44}
4545
46template <class _Iter>46template <class _Iter>
47using __iterator_concept _LIBCPP_NODEBUG = decltype(__get_iterator_concept<_Iter>());47using __iterator_concept _LIBCPP_NODEBUG = decltype(ranges::__get_iterator_concept<_Iter>());
4848
49} // namespace ranges49} // namespace ranges
50_LIBCPP_END_NAMESPACE_STD50_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/ranges_max.h+3-3
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_H
10#define _LIBCPP___ALGORITHM_RANGES_MAX_H10#define _LIBCPP___ALGORITHM_RANGES_MAX_H
1111
12#include <__algorithm/ranges_min_element.h>12#include <__algorithm/min_element.h>
13#include <__assert>13#include <__assert>
14#include <__concepts/copyable.h>14#include <__concepts/copyable.h>
15#include <__config>15#include <__config>
...@@ -57,7 +57,7 @@ struct __max {...@@ -57,7 +57,7 @@ struct __max {
57 __il.begin() != __il.end(), "initializer_list must contain at least one element");57 __il.begin() != __il.end(), "initializer_list must contain at least one element");
5858
59 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };59 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
60 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);60 return *std::__min_element(__il.begin(), __il.end(), __comp_lhs_rhs_swapped, __proj);
61 }61 }
6262
63 template <input_range _Rp,63 template <input_range _Rp,
...@@ -75,7 +75,7 @@ struct __max {...@@ -75,7 +75,7 @@ struct __max {
75 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {75 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool {
76 return std::invoke(__comp, __rhs, __lhs);76 return std::invoke(__comp, __rhs, __lhs);
77 };77 };
78 return *ranges::__min_element_impl(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);78 return *std::__min_element(std::move(__first), std::move(__last), __comp_lhs_rhs_swapped, __proj);
79 } else {79 } else {
80 range_value_t<_Rp> __result = *__first;80 range_value_t<_Rp> __result = *__first;
81 while (++__first != __last) {81 while (++__first != __last) {
lib/libcxx/include/__algorithm/ranges_max_element.h+3-3
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H9#ifndef _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H10#define _LIBCPP___ALGORITHM_RANGES_MAX_ELEMENT_H
1111
12#include <__algorithm/ranges_min_element.h>12#include <__algorithm/min_element.h>
13#include <__config>13#include <__config>
14#include <__functional/identity.h>14#include <__functional/identity.h>
15#include <__functional/invoke.h>15#include <__functional/invoke.h>
...@@ -40,7 +40,7 @@ struct __max_element {...@@ -40,7 +40,7 @@ struct __max_element {
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
41 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {41 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
42 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };42 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
43 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);43 return std::__min_element(__first, __last, __comp_lhs_rhs_swapped, __proj);
44 }44 }
4545
46 template <forward_range _Rp,46 template <forward_range _Rp,
...@@ -49,7 +49,7 @@ struct __max_element {...@@ -49,7 +49,7 @@ struct __max_element {
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
50 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {50 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
51 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };51 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
52 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);52 return std::__min_element(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
53 }53 }
54};54};
5555
lib/libcxx/include/__algorithm/ranges_min.h+3-3
...@@ -9,7 +9,7 @@...@@ -9,7 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H9#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_H
10#define _LIBCPP___ALGORITHM_RANGES_MIN_H10#define _LIBCPP___ALGORITHM_RANGES_MIN_H
1111
12#include <__algorithm/ranges_min_element.h>12#include <__algorithm/min_element.h>
13#include <__assert>13#include <__assert>
14#include <__concepts/copyable.h>14#include <__concepts/copyable.h>
15#include <__config>15#include <__config>
...@@ -54,7 +54,7 @@ struct __min {...@@ -54,7 +54,7 @@ struct __min {
54 operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {54 operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
55 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(55 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
56 __il.begin() != __il.end(), "initializer_list must contain at least one element");56 __il.begin() != __il.end(), "initializer_list must contain at least one element");
57 return *ranges::__min_element_impl(__il.begin(), __il.end(), __comp, __proj);57 return *std::__min_element(__il.begin(), __il.end(), __comp, __proj);
58 }58 }
5959
60 template <input_range _Rp,60 template <input_range _Rp,
...@@ -67,7 +67,7 @@ struct __min {...@@ -67,7 +67,7 @@ struct __min {
67 auto __last = ranges::end(__r);67 auto __last = ranges::end(__r);
68 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");68 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range must contain at least one element");
69 if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {69 if constexpr (forward_range<_Rp> && !__is_cheap_to_copy<range_value_t<_Rp>>) {
70 return *ranges::__min_element_impl(__first, __last, __comp, __proj);70 return *std::__min_element(__first, __last, __comp, __proj);
71 } else {71 } else {
72 range_value_t<_Rp> __result = *__first;72 range_value_t<_Rp> __result = *__first;
73 while (++__first != __last) {73 while (++__first != __last) {
lib/libcxx/include/__algorithm/ranges_min_element.h+3-16
...@@ -9,6 +9,7 @@...@@ -9,6 +9,7 @@
9#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H9#ifndef _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
10#define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H10#define _LIBCPP___ALGORITHM_RANGES_MIN_ELEMENT_H
1111
12#include <__algorithm/min_element.h>
12#include <__config>13#include <__config>
13#include <__functional/identity.h>14#include <__functional/identity.h>
14#include <__functional/invoke.h>15#include <__functional/invoke.h>
...@@ -32,20 +33,6 @@ _LIBCPP_PUSH_MACROS...@@ -32,20 +33,6 @@ _LIBCPP_PUSH_MACROS
32_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3334
34namespace ranges {35namespace ranges {
35
36// TODO(ranges): `ranges::min_element` can now simply delegate to `std::__min_element`.
37template <class _Ip, class _Sp, class _Proj, class _Comp>
38_LIBCPP_HIDE_FROM_ABI constexpr _Ip __min_element_impl(_Ip __first, _Sp __last, _Comp& __comp, _Proj& __proj) {
39 if (__first == __last)
40 return __first;
41
42 _Ip __i = __first;
43 while (++__i != __last)
44 if (std::invoke(__comp, std::invoke(__proj, *__i), std::invoke(__proj, *__first)))
45 __first = __i;
46 return __first;
47}
48
49struct __min_element {36struct __min_element {
50 template <forward_iterator _Ip,37 template <forward_iterator _Ip,
51 sentinel_for<_Ip> _Sp,38 sentinel_for<_Ip> _Sp,
...@@ -53,7 +40,7 @@ struct __min_element {...@@ -53,7 +40,7 @@ struct __min_element {
53 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>40 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
55 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {42 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
56 return ranges::__min_element_impl(__first, __last, __comp, __proj);43 return std::__min_element(__first, __last, __comp, __proj);
57 }44 }
5845
59 template <forward_range _Rp,46 template <forward_range _Rp,
...@@ -61,7 +48,7 @@ struct __min_element {...@@ -61,7 +48,7 @@ struct __min_element {
61 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>48 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
63 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {50 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
64 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);51 return std::__min_element(ranges::begin(__r), ranges::end(__r), __comp, __proj);
65 }52 }
66};53};
6754
lib/libcxx/include/__algorithm/ranges_stable_partition.h+4-3
...@@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
44namespace ranges {44namespace ranges {
45struct __stable_partition {45struct __stable_partition {
46 template <class _Iter, class _Sent, class _Proj, class _Pred>46 template <class _Iter, class _Sent, class _Proj, class _Pred>
47 _LIBCPP_HIDE_FROM_ABI static subrange<__remove_cvref_t<_Iter>>47 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 subrange<__remove_cvref_t<_Iter>>
48 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {48 __stable_partition_fn_impl(_Iter&& __first, _Sent&& __last, _Pred&& __pred, _Proj&& __proj) {
49 auto __last_iter = ranges::next(__first, __last);49 auto __last_iter = ranges::next(__first, __last);
5050
...@@ -60,7 +60,8 @@ struct __stable_partition {...@@ -60,7 +60,8 @@ struct __stable_partition {
60 class _Proj = identity,60 class _Proj = identity,
61 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>61 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
62 requires permutable<_Iter>62 requires permutable<_Iter>
63 _LIBCPP_HIDE_FROM_ABI subrange<_Iter> operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 subrange<_Iter>
64 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
64 return __stable_partition_fn_impl(__first, __last, __pred, __proj);65 return __stable_partition_fn_impl(__first, __last, __pred, __proj);
65 }66 }
6667
...@@ -68,7 +69,7 @@ struct __stable_partition {...@@ -68,7 +69,7 @@ struct __stable_partition {
68 class _Proj = identity,69 class _Proj = identity,
69 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>70 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
70 requires permutable<iterator_t<_Range>>71 requires permutable<iterator_t<_Range>>
71 _LIBCPP_HIDE_FROM_ABI borrowed_subrange_t<_Range>72 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_subrange_t<_Range>
72 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {73 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
73 return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);74 return __stable_partition_fn_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
74 }75 }
lib/libcxx/include/__algorithm/ranges_stable_sort.h+5-3
...@@ -41,7 +41,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -41,7 +41,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
41namespace ranges {41namespace ranges {
42struct __stable_sort {42struct __stable_sort {
43 template <class _Iter, class _Sent, class _Comp, class _Proj>43 template <class _Iter, class _Sent, class _Comp, class _Proj>
44 _LIBCPP_HIDE_FROM_ABI static _Iter __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {44 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter
45 __stable_sort_fn_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj) {
45 auto __last_iter = ranges::next(__first, __last);46 auto __last_iter = ranges::next(__first, __last);
4647
47 auto&& __projected_comp = std::__make_projected(__comp, __proj);48 auto&& __projected_comp = std::__make_projected(__comp, __proj);
...@@ -52,13 +53,14 @@ struct __stable_sort {...@@ -52,13 +53,14 @@ struct __stable_sort {
5253
53 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>54 template <random_access_iterator _Iter, sentinel_for<_Iter> _Sent, class _Comp = ranges::less, class _Proj = identity>
54 requires sortable<_Iter, _Comp, _Proj>55 requires sortable<_Iter, _Comp, _Proj>
55 _LIBCPP_HIDE_FROM_ABI _Iter operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Iter
57 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
56 return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);58 return __stable_sort_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
57 }59 }
5860
59 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>61 template <random_access_range _Range, class _Comp = ranges::less, class _Proj = identity>
60 requires sortable<iterator_t<_Range>, _Comp, _Proj>62 requires sortable<iterator_t<_Range>, _Comp, _Proj>
61 _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_Range>63 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_Range>
62 operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {64 operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
63 return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);65 return __stable_sort_fn_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
64 }66 }
lib/libcxx/include/__algorithm/rotate.h+45
...@@ -9,12 +9,19 @@...@@ -9,12 +9,19 @@
9#ifndef _LIBCPP___ALGORITHM_ROTATE_H9#ifndef _LIBCPP___ALGORITHM_ROTATE_H
10#define _LIBCPP___ALGORITHM_ROTATE_H10#define _LIBCPP___ALGORITHM_ROTATE_H
1111
12#include <__algorithm/copy.h>
13#include <__algorithm/copy_backward.h>
12#include <__algorithm/iterator_operations.h>14#include <__algorithm/iterator_operations.h>
13#include <__algorithm/move.h>15#include <__algorithm/move.h>
14#include <__algorithm/move_backward.h>16#include <__algorithm/move_backward.h>
15#include <__algorithm/swap_ranges.h>17#include <__algorithm/swap_ranges.h>
16#include <__config>18#include <__config>
19#include <__cstddef/size_t.h>
20#include <__fwd/bit_reference.h>
17#include <__iterator/iterator_traits.h>21#include <__iterator/iterator_traits.h>
22#include <__memory/construct_at.h>
23#include <__memory/pointer_traits.h>
24#include <__type_traits/is_constant_evaluated.h>
18#include <__type_traits/is_trivially_assignable.h>25#include <__type_traits/is_trivially_assignable.h>
19#include <__utility/move.h>26#include <__utility/move.h>
20#include <__utility/pair.h>27#include <__utility/pair.h>
...@@ -185,6 +192,44 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {...@@ -185,6 +192,44 @@ __rotate(_Iterator __first, _Iterator __middle, _Sentinel __last) {
185 return _Ret(std::move(__result), std::move(__last_iter));192 return _Ret(std::move(__result), std::move(__last_iter));
186}193}
187194
195template <class, class _Cp>
196_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, false>, __bit_iterator<_Cp, false> >
197__rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) {
198 using _I1 = __bit_iterator<_Cp, false>;
199 using difference_type = typename _I1::difference_type;
200 difference_type __d1 = __middle - __first;
201 difference_type __d2 = __last - __middle;
202 _I1 __r = __first + __d2;
203 while (__d1 != 0 && __d2 != 0) {
204 if (__d1 <= __d2) {
205 if (__d1 <= __bit_array<_Cp>::capacity()) {
206 __bit_array<_Cp> __b(__d1);
207 std::copy(__first, __middle, __b.begin());
208 std::copy(__b.begin(), __b.end(), std::copy(__middle, __last, __first));
209 break;
210 } else {
211 __bit_iterator<_Cp, false> __mp = std::swap_ranges(__first, __middle, __middle);
212 __first = __middle;
213 __middle = __mp;
214 __d2 -= __d1;
215 }
216 } else {
217 if (__d2 <= __bit_array<_Cp>::capacity()) {
218 __bit_array<_Cp> __b(__d2);
219 std::copy(__middle, __last, __b.begin());
220 std::copy_backward(__b.begin(), __b.end(), std::copy_backward(__first, __middle, __last));
221 break;
222 } else {
223 __bit_iterator<_Cp, false> __mp = __first + __d2;
224 std::swap_ranges(__first, __mp, __middle);
225 __first = __mp;
226 __d1 -= __d2;
227 }
228 }
229 }
230 return std::make_pair(__r, __last);
231}
232
188template <class _ForwardIterator>233template <class _ForwardIterator>
189inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator234inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
190rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) {235rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) {
lib/libcxx/include/__algorithm/simd_utils.h+8-8
...@@ -15,8 +15,6 @@...@@ -15,8 +15,6 @@
15#include <__bit/countr.h>15#include <__bit/countr.h>
16#include <__config>16#include <__config>
17#include <__cstddef/size_t.h>17#include <__cstddef/size_t.h>
18#include <__type_traits/is_arithmetic.h>
19#include <__type_traits/is_same.h>
20#include <__utility/integer_sequence.h>18#include <__utility/integer_sequence.h>
21#include <cstdint>19#include <cstdint>
2220
...@@ -28,7 +26,9 @@ _LIBCPP_PUSH_MACROS...@@ -28,7 +26,9 @@ _LIBCPP_PUSH_MACROS
28#include <__undef_macros>26#include <__undef_macros>
2927
30// TODO: Find out how altivec changes things and allow vectorizations there too.28// TODO: Find out how altivec changes things and allow vectorizations there too.
31#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__)29// TODO: Simplify this condition once we stop building with AppleClang 15 in the CI.
30#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(__ALTIVEC__) && \
31 !(defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1600)
32# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 132# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
33#else33#else
34# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 034# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
...@@ -53,20 +53,20 @@ struct __get_as_integer_type_impl;...@@ -53,20 +53,20 @@ struct __get_as_integer_type_impl;
5353
54template <>54template <>
55struct __get_as_integer_type_impl<1> {55struct __get_as_integer_type_impl<1> {
56 using type = uint8_t;56 using type _LIBCPP_NODEBUG = uint8_t;
57};57};
5858
59template <>59template <>
60struct __get_as_integer_type_impl<2> {60struct __get_as_integer_type_impl<2> {
61 using type = uint16_t;61 using type _LIBCPP_NODEBUG = uint16_t;
62};62};
63template <>63template <>
64struct __get_as_integer_type_impl<4> {64struct __get_as_integer_type_impl<4> {
65 using type = uint32_t;65 using type _LIBCPP_NODEBUG = uint32_t;
66};66};
67template <>67template <>
68struct __get_as_integer_type_impl<8> {68struct __get_as_integer_type_impl<8> {
69 using type = uint64_t;69 using type _LIBCPP_NODEBUG = uint64_t;
70};70};
7171
72template <class _Tp>72template <class _Tp>
...@@ -78,7 +78,7 @@ using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_i...@@ -78,7 +78,7 @@ using __get_as_integer_type_t _LIBCPP_NODEBUG = typename __get_as_integer_type_i
78# if defined(__AVX__) || defined(__MVS__)78# if defined(__AVX__) || defined(__MVS__)
79template <class _Tp>79template <class _Tp>
80inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp);80inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp);
81# elif defined(__SSE__) || defined(__ARM_NEON__)81# elif defined(__SSE__) || defined(__ARM_NEON)
82template <class _Tp>82template <class _Tp>
83inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp);83inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp);
84# elif defined(__MMX__)84# elif defined(__MMX__)
lib/libcxx/include/__algorithm/sort.h+10-29
...@@ -17,6 +17,7 @@...@@ -17,6 +17,7 @@
17#include <__algorithm/partial_sort.h>17#include <__algorithm/partial_sort.h>
18#include <__algorithm/unwrap_iter.h>18#include <__algorithm/unwrap_iter.h>
19#include <__assert>19#include <__assert>
20#include <__bit/bit_log2.h>
20#include <__bit/blsr.h>21#include <__bit/blsr.h>
21#include <__bit/countl.h>22#include <__bit/countl.h>
22#include <__bit/countr.h>23#include <__bit/countr.h>
...@@ -34,7 +35,7 @@...@@ -34,7 +35,7 @@
34#include <__type_traits/is_constant_evaluated.h>35#include <__type_traits/is_constant_evaluated.h>
35#include <__type_traits/is_same.h>36#include <__type_traits/is_same.h>
36#include <__type_traits/is_trivially_copyable.h>37#include <__type_traits/is_trivially_copyable.h>
37#include <__type_traits/remove_cvref.h>38#include <__type_traits/make_unsigned.h>
38#include <__utility/move.h>39#include <__utility/move.h>
39#include <__utility/pair.h>40#include <__utility/pair.h>
40#include <climits>41#include <climits>
...@@ -52,8 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -52,8 +53,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
52template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>53template <class _Compare, class _Iter, class _Tp = typename iterator_traits<_Iter>::value_type>
53inline const bool __use_branchless_sort =54inline const bool __use_branchless_sort =
54 __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value &&55 __libcpp_is_contiguous_iterator<_Iter>::value && __is_cheap_to_copy<_Tp> && is_arithmetic<_Tp>::value &&
55 (__desugars_to_v<__less_tag, __remove_cvref_t<_Compare>, _Tp, _Tp> ||56 (__desugars_to_v<__less_tag, _Compare, _Tp, _Tp> || __desugars_to_v<__greater_tag, _Compare, _Tp, _Tp>);
56 __desugars_to_v<__greater_tag, __remove_cvref_t<_Compare>, _Tp, _Tp>);
5757
58namespace __detail {58namespace __detail {
5959
...@@ -359,10 +359,10 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(...@@ -359,10 +359,10 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos(
359 // Swap one pair on each iteration as long as both bitsets have at least one359 // Swap one pair on each iteration as long as both bitsets have at least one
360 // element for swapping.360 // element for swapping.
361 while (__left_bitset != 0 && __right_bitset != 0) {361 while (__left_bitset != 0 && __right_bitset != 0) {
362 difference_type __tz_left = __libcpp_ctz(__left_bitset);362 difference_type __tz_left = std::__countr_zero(__left_bitset);
363 __left_bitset = __libcpp_blsr(__left_bitset);363 __left_bitset = std::__libcpp_blsr(__left_bitset);
364 difference_type __tz_right = __libcpp_ctz(__right_bitset);364 difference_type __tz_right = std::__countr_zero(__right_bitset);
365 __right_bitset = __libcpp_blsr(__right_bitset);365 __right_bitset = std::__libcpp_blsr(__right_bitset);
366 _Ops::iter_swap(__first + __tz_left, __last - __tz_right);366 _Ops::iter_swap(__first + __tz_left, __last - __tz_right);
367 }367 }
368}368}
...@@ -458,7 +458,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(...@@ -458,7 +458,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(
458 // Swap within the left side. Need to find set positions in the reverse458 // Swap within the left side. Need to find set positions in the reverse
459 // order.459 // order.
460 while (__left_bitset != 0) {460 while (__left_bitset != 0) {
461 difference_type __tz_left = __detail::__block_size - 1 - __libcpp_clz(__left_bitset);461 difference_type __tz_left = __detail::__block_size - 1 - std::__countl_zero(__left_bitset);
462 __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1;462 __left_bitset &= (static_cast<uint64_t>(1) << __tz_left) - 1;
463 _RandomAccessIterator __it = __first + __tz_left;463 _RandomAccessIterator __it = __first + __tz_left;
464 if (__it != __lm1) {464 if (__it != __lm1) {
...@@ -471,7 +471,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(...@@ -471,7 +471,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __swap_bitmap_pos_within(
471 // Swap within the right side. Need to find set positions in the reverse471 // Swap within the right side. Need to find set positions in the reverse
472 // order.472 // order.
473 while (__right_bitset != 0) {473 while (__right_bitset != 0) {
474 difference_type __tz_right = __detail::__block_size - 1 - __libcpp_clz(__right_bitset);474 difference_type __tz_right = __detail::__block_size - 1 - std::__countl_zero(__right_bitset);
475 __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1;475 __right_bitset &= (static_cast<uint64_t>(1) << __tz_right) - 1;
476 _RandomAccessIterator __it = __lm1 - __tz_right;476 _RandomAccessIterator __it = __lm1 - __tz_right;
477 if (__it != __first) {477 if (__it != __first) {
...@@ -828,25 +828,6 @@ void __introsort(_RandomAccessIterator __first,...@@ -828,25 +828,6 @@ void __introsort(_RandomAccessIterator __first,
828 }828 }
829}829}
830830
831template <typename _Number>
832inline _LIBCPP_HIDE_FROM_ABI _Number __log2i(_Number __n) {
833 if (__n == 0)
834 return 0;
835 if (sizeof(__n) <= sizeof(unsigned))
836 return sizeof(unsigned) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned>(__n));
837 if (sizeof(__n) <= sizeof(unsigned long))
838 return sizeof(unsigned long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long>(__n));
839 if (sizeof(__n) <= sizeof(unsigned long long))
840 return sizeof(unsigned long long) * CHAR_BIT - 1 - __libcpp_clz(static_cast<unsigned long long>(__n));
841
842 _Number __log2 = 0;
843 while (__n > 1) {
844 __log2++;
845 __n >>= 1;
846 }
847 return __log2;
848}
849
850template <class _Comp, class _RandomAccessIterator>831template <class _Comp, class _RandomAccessIterator>
851void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);832void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
852833
...@@ -880,7 +861,7 @@ template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>...@@ -880,7 +861,7 @@ template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
880_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void861_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
881__sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {862__sort_dispatch(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp& __comp) {
882 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;863 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
883 difference_type __depth_limit = 2 * std::__log2i(__last - __first);864 difference_type __depth_limit = 2 * std::__bit_log2(std::__to_unsigned_like(__last - __first));
884865
885 // Only use bitset partitioning for arithmetic types. We should also check866 // Only use bitset partitioning for arithmetic types. We should also check
886 // that the default comparator is in use so that we are sure that there are no867 // that the default comparator is in use so that we are sure that there are no
lib/libcxx/include/__algorithm/stable_partition.h+11-10
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include <__iterator/advance.h>16#include <__iterator/advance.h>
17#include <__iterator/distance.h>17#include <__iterator/distance.h>
18#include <__iterator/iterator_traits.h>18#include <__iterator/iterator_traits.h>
19#include <__memory/construct_at.h>
19#include <__memory/destruct_n.h>20#include <__memory/destruct_n.h>
20#include <__memory/unique_ptr.h>21#include <__memory/unique_ptr.h>
21#include <__memory/unique_temporary_buffer.h>22#include <__memory/unique_temporary_buffer.h>
...@@ -33,7 +34,7 @@ _LIBCPP_PUSH_MACROS...@@ -33,7 +34,7 @@ _LIBCPP_PUSH_MACROS
33_LIBCPP_BEGIN_NAMESPACE_STD34_LIBCPP_BEGIN_NAMESPACE_STD
3435
35template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>36template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _Distance, class _Pair>
36_LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl(37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator __stable_partition_impl(
37 _ForwardIterator __first,38 _ForwardIterator __first,
38 _ForwardIterator __last,39 _ForwardIterator __last,
39 _Predicate __pred,40 _Predicate __pred,
...@@ -61,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl(...@@ -61,7 +62,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl(
61 // Move the falses into the temporary buffer, and the trues to the front of the line62 // Move the falses into the temporary buffer, and the trues to the front of the line
62 // Update __first to always point to the end of the trues63 // Update __first to always point to the end of the trues
63 value_type* __t = __p.first;64 value_type* __t = __p.first;
64 ::new ((void*)__t) value_type(_Ops::__iter_move(__first));65 std::__construct_at(__t, _Ops::__iter_move(__first));
65 __d.template __incr<value_type>();66 __d.template __incr<value_type>();
66 ++__t;67 ++__t;
67 _ForwardIterator __i = __first;68 _ForwardIterator __i = __first;
...@@ -70,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl(...@@ -70,7 +71,7 @@ _LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition_impl(
70 *__first = _Ops::__iter_move(__i);71 *__first = _Ops::__iter_move(__i);
71 ++__first;72 ++__first;
72 } else {73 } else {
73 ::new ((void*)__t) value_type(_Ops::__iter_move(__i));74 std::__construct_at(__t, _Ops::__iter_move(__i));
74 __d.template __incr<value_type>();75 __d.template __incr<value_type>();
75 ++__t;76 ++__t;
76 }77 }
...@@ -116,7 +117,7 @@ __second_half_done:...@@ -116,7 +117,7 @@ __second_half_done:
116}117}
117118
118template <class _AlgPolicy, class _Predicate, class _ForwardIterator>119template <class _AlgPolicy, class _Predicate, class _ForwardIterator>
119_LIBCPP_HIDE_FROM_ABI _ForwardIterator120_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
120__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) {121__stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) {
121 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;122 typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type;
122 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;123 typedef typename iterator_traits<_ForwardIterator>::value_type value_type;
...@@ -145,7 +146,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred...@@ -145,7 +146,7 @@ __stable_partition_impl(_ForwardIterator __first, _ForwardIterator __last, _Pred
145}146}
146147
147template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>148template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator, class _Distance, class _Pair>
148_BidirectionalIterator __stable_partition_impl(149_LIBCPP_CONSTEXPR_SINCE_CXX26 _BidirectionalIterator __stable_partition_impl(
149 _BidirectionalIterator __first,150 _BidirectionalIterator __first,
150 _BidirectionalIterator __last,151 _BidirectionalIterator __last,
151 _Predicate __pred,152 _Predicate __pred,
...@@ -179,7 +180,7 @@ _BidirectionalIterator __stable_partition_impl(...@@ -179,7 +180,7 @@ _BidirectionalIterator __stable_partition_impl(
179 // Move the falses into the temporary buffer, and the trues to the front of the line180 // Move the falses into the temporary buffer, and the trues to the front of the line
180 // Update __first to always point to the end of the trues181 // Update __first to always point to the end of the trues
181 value_type* __t = __p.first;182 value_type* __t = __p.first;
182 ::new ((void*)__t) value_type(_Ops::__iter_move(__first));183 std::__construct_at(__t, _Ops::__iter_move(__first));
183 __d.template __incr<value_type>();184 __d.template __incr<value_type>();
184 ++__t;185 ++__t;
185 _BidirectionalIterator __i = __first;186 _BidirectionalIterator __i = __first;
...@@ -188,7 +189,7 @@ _BidirectionalIterator __stable_partition_impl(...@@ -188,7 +189,7 @@ _BidirectionalIterator __stable_partition_impl(
188 *__first = _Ops::__iter_move(__i);189 *__first = _Ops::__iter_move(__i);
189 ++__first;190 ++__first;
190 } else {191 } else {
191 ::new ((void*)__t) value_type(_Ops::__iter_move(__i));192 std::__construct_at(__t, _Ops::__iter_move(__i));
192 __d.template __incr<value_type>();193 __d.template __incr<value_type>();
193 ++__t;194 ++__t;
194 }195 }
...@@ -247,7 +248,7 @@ __second_half_done:...@@ -247,7 +248,7 @@ __second_half_done:
247}248}
248249
249template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>250template <class _AlgPolicy, class _Predicate, class _BidirectionalIterator>
250_LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(251_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _BidirectionalIterator __stable_partition_impl(
251 _BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) {252 _BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, bidirectional_iterator_tag) {
252 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;253 typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
253 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;254 typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
...@@ -283,14 +284,14 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(...@@ -283,14 +284,14 @@ _LIBCPP_HIDE_FROM_ABI _BidirectionalIterator __stable_partition_impl(
283}284}
284285
285template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory>286template <class _AlgPolicy, class _Predicate, class _ForwardIterator, class _IterCategory>
286_LIBCPP_HIDE_FROM_ABI _ForwardIterator __stable_partition(287_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator __stable_partition(
287 _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {288 _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred, _IterCategory __iter_category) {
288 return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>(289 return std::__stable_partition_impl<_AlgPolicy, __remove_cvref_t<_Predicate>&>(
289 std::move(__first), std::move(__last), __pred, __iter_category);290 std::move(__first), std::move(__last), __pred, __iter_category);
290}291}
291292
292template <class _ForwardIterator, class _Predicate>293template <class _ForwardIterator, class _Predicate>
293inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator294_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
294stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {295stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
295 using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;296 using _IterCategory = typename iterator_traits<_ForwardIterator>::iterator_category;
296 return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>(297 return std::__stable_partition<_ClassicAlgPolicy, _Predicate&>(
lib/libcxx/include/__algorithm/stable_sort.h+16-12
...@@ -25,10 +25,9 @@...@@ -25,10 +25,9 @@
25#include <__memory/unique_temporary_buffer.h>25#include <__memory/unique_temporary_buffer.h>
26#include <__type_traits/desugars_to.h>26#include <__type_traits/desugars_to.h>
27#include <__type_traits/enable_if.h>27#include <__type_traits/enable_if.h>
28#include <__type_traits/is_integral.h>28#include <__type_traits/is_constant_evaluated.h>
29#include <__type_traits/is_same.h>29#include <__type_traits/is_same.h>
30#include <__type_traits/is_trivially_assignable.h>30#include <__type_traits/is_trivially_assignable.h>
31#include <__type_traits/remove_cvref.h>
32#include <__utility/move.h>31#include <__utility/move.h>
33#include <__utility/pair.h>32#include <__utility/pair.h>
3433
...@@ -201,7 +200,7 @@ struct __stable_sort_switch {...@@ -201,7 +200,7 @@ struct __stable_sort_switch {
201#if _LIBCPP_STD_VER >= 17200#if _LIBCPP_STD_VER >= 17
202template <class _Tp>201template <class _Tp>
203_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {202_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {
204 static_assert(is_integral<_Tp>::value);203 static_assert(__is_ordered_integer_representable_v<_Tp>);
205 if constexpr (sizeof(_Tp) == 1) {204 if constexpr (sizeof(_Tp) == 1) {
206 return 1 << 8;205 return 1 << 8;
207 }206 }
...@@ -211,7 +210,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {...@@ -211,7 +210,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_min_bound() {
211210
212template <class _Tp>211template <class _Tp>
213_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() {212_LIBCPP_HIDE_FROM_ABI constexpr unsigned __radix_sort_max_bound() {
214 static_assert(is_integral<_Tp>::value);213 static_assert(__is_ordered_integer_representable_v<_Tp>);
215 if constexpr (sizeof(_Tp) >= 8) {214 if constexpr (sizeof(_Tp) >= 8) {
216 return 1 << 15;215 return 1 << 15;
217 }216 }
...@@ -245,14 +244,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(...@@ -245,14 +244,19 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __stable_sort(
245 }244 }
246245
247#if _LIBCPP_STD_VER >= 17246#if _LIBCPP_STD_VER >= 17
248 constexpr auto __default_comp =247 constexpr auto __default_comp = __desugars_to_v<__less_tag, _Compare, value_type, value_type >;
249 __desugars_to_v<__totally_ordered_less_tag, __remove_cvref_t<_Compare>, value_type, value_type >;248 constexpr auto __radix_sortable =
250 constexpr auto __integral_value =249 __is_ordered_integer_representable_v<value_type> &&
251 is_integral_v<value_type > && is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;250 is_same_v< value_type&, __iter_reference<_RandomAccessIterator>>;
252 constexpr auto __allowed_radix_sort = __default_comp && __integral_value;251 if constexpr (__default_comp && __radix_sortable) {
253 if constexpr (__allowed_radix_sort) {252 if (__len <= __buff_size && __len >= static_cast<difference_type>(std::__radix_sort_min_bound<value_type>()) &&
254 if (__len <= __buff_size && __len >= static_cast<difference_type>(__radix_sort_min_bound<value_type>()) &&253 __len <= static_cast<difference_type>(std::__radix_sort_max_bound<value_type>())) {
255 __len <= static_cast<difference_type>(__radix_sort_max_bound<value_type>())) {254 if (__libcpp_is_constant_evaluated()) {
255 for (auto* __p = __buff; __p < __buff + __buff_size; ++__p) {
256 std::__construct_at(__p);
257 }
258 }
259
256 std::__radix_sort(__first, __last, __buff);260 std::__radix_sort(__first, __last, __buff);
257 return;261 return;
258 }262 }
lib/libcxx/include/__algorithm/swap_ranges.h+162
...@@ -10,9 +10,12 @@...@@ -10,9 +10,12 @@
10#define _LIBCPP___ALGORITHM_SWAP_RANGES_H10#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
1111
12#include <__algorithm/iterator_operations.h>12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/min.h>
13#include <__config>14#include <__config>
15#include <__fwd/bit_reference.h>
14#include <__utility/move.h>16#include <__utility/move.h>
15#include <__utility/pair.h>17#include <__utility/pair.h>
18#include <__utility/swap.h>
1619
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header21# pragma GCC system_header
...@@ -23,6 +26,165 @@ _LIBCPP_PUSH_MACROS...@@ -23,6 +26,165 @@ _LIBCPP_PUSH_MACROS
2326
24_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2528
29template <class _Cl, class _Cr>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __swap_ranges_aligned(
31 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
32 using _I1 = __bit_iterator<_Cl, false>;
33 using difference_type = typename _I1::difference_type;
34 using __storage_type = typename _I1::__storage_type;
35
36 const int __bits_per_word = _I1::__bits_per_word;
37 difference_type __n = __last - __first;
38 if (__n > 0) {
39 // do first word
40 if (__first.__ctz_ != 0) {
41 unsigned __clz = __bits_per_word - __first.__ctz_;
42 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
43 __n -= __dn;
44 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
45 __storage_type __b1 = *__first.__seg_ & __m;
46 *__first.__seg_ &= ~__m;
47 __storage_type __b2 = *__result.__seg_ & __m;
48 *__result.__seg_ &= ~__m;
49 *__result.__seg_ |= __b1;
50 *__first.__seg_ |= __b2;
51 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
52 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
53 ++__first.__seg_;
54 // __first.__ctz_ = 0;
55 }
56 // __first.__ctz_ == 0;
57 // do middle words
58 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_)
59 swap(*__first.__seg_, *__result.__seg_);
60 // do last word
61 if (__n > 0) {
62 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
63 __storage_type __b1 = *__first.__seg_ & __m;
64 *__first.__seg_ &= ~__m;
65 __storage_type __b2 = *__result.__seg_ & __m;
66 *__result.__seg_ &= ~__m;
67 *__result.__seg_ |= __b1;
68 *__first.__seg_ |= __b2;
69 __result.__ctz_ = static_cast<unsigned>(__n);
70 }
71 }
72 return __result;
73}
74
75template <class _Cl, class _Cr>
76_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __swap_ranges_unaligned(
77 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
78 using _I1 = __bit_iterator<_Cl, false>;
79 using difference_type = typename _I1::difference_type;
80 using __storage_type = typename _I1::__storage_type;
81
82 const int __bits_per_word = _I1::__bits_per_word;
83 difference_type __n = __last - __first;
84 if (__n > 0) {
85 // do first word
86 if (__first.__ctz_ != 0) {
87 unsigned __clz_f = __bits_per_word - __first.__ctz_;
88 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
89 __n -= __dn;
90 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
91 __storage_type __b1 = *__first.__seg_ & __m;
92 *__first.__seg_ &= ~__m;
93 unsigned __clz_r = __bits_per_word - __result.__ctz_;
94 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
95 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
96 __storage_type __b2 = *__result.__seg_ & __m;
97 *__result.__seg_ &= ~__m;
98 if (__result.__ctz_ > __first.__ctz_) {
99 unsigned __s = __result.__ctz_ - __first.__ctz_;
100 *__result.__seg_ |= __b1 << __s;
101 *__first.__seg_ |= __b2 >> __s;
102 } else {
103 unsigned __s = __first.__ctz_ - __result.__ctz_;
104 *__result.__seg_ |= __b1 >> __s;
105 *__first.__seg_ |= __b2 << __s;
106 }
107 __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
108 __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
109 __dn -= __ddn;
110 if (__dn > 0) {
111 __m = ~__storage_type(0) >> (__bits_per_word - __dn);
112 __b2 = *__result.__seg_ & __m;
113 *__result.__seg_ &= ~__m;
114 unsigned __s = __first.__ctz_ + __ddn;
115 *__result.__seg_ |= __b1 >> __s;
116 *__first.__seg_ |= __b2 << __s;
117 __result.__ctz_ = static_cast<unsigned>(__dn);
118 }
119 ++__first.__seg_;
120 // __first.__ctz_ = 0;
121 }
122 // __first.__ctz_ == 0;
123 // do middle words
124 __storage_type __m = ~__storage_type(0) << __result.__ctz_;
125 unsigned __clz_r = __bits_per_word - __result.__ctz_;
126 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) {
127 __storage_type __b1 = *__first.__seg_;
128 __storage_type __b2 = *__result.__seg_ & __m;
129 *__result.__seg_ &= ~__m;
130 *__result.__seg_ |= __b1 << __result.__ctz_;
131 *__first.__seg_ = __b2 >> __result.__ctz_;
132 ++__result.__seg_;
133 __b2 = *__result.__seg_ & ~__m;
134 *__result.__seg_ &= __m;
135 *__result.__seg_ |= __b1 >> __clz_r;
136 *__first.__seg_ |= __b2 << __clz_r;
137 }
138 // do last word
139 if (__n > 0) {
140 __m = ~__storage_type(0) >> (__bits_per_word - __n);
141 __storage_type __b1 = *__first.__seg_ & __m;
142 *__first.__seg_ &= ~__m;
143 __storage_type __dn = std::min<__storage_type>(__n, __clz_r);
144 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
145 __storage_type __b2 = *__result.__seg_ & __m;
146 *__result.__seg_ &= ~__m;
147 *__result.__seg_ |= __b1 << __result.__ctz_;
148 *__first.__seg_ |= __b2 >> __result.__ctz_;
149 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
150 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
151 __n -= __dn;
152 if (__n > 0) {
153 __m = ~__storage_type(0) >> (__bits_per_word - __n);
154 __b2 = *__result.__seg_ & __m;
155 *__result.__seg_ &= ~__m;
156 *__result.__seg_ |= __b1 >> __dn;
157 *__first.__seg_ |= __b2 << __dn;
158 __result.__ctz_ = static_cast<unsigned>(__n);
159 }
160 }
161 }
162 return __result;
163}
164
165// 2+1 iterators: size2 >= size1; used by std::swap_ranges.
166template <class, class _Cl, class _Cr>
167_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> >
168__swap_ranges(__bit_iterator<_Cl, false> __first1,
169 __bit_iterator<_Cl, false> __last1,
170 __bit_iterator<_Cr, false> __first2) {
171 if (__first1.__ctz_ == __first2.__ctz_)
172 return std::make_pair(__last1, std::__swap_ranges_aligned(__first1, __last1, __first2));
173 return std::make_pair(__last1, std::__swap_ranges_unaligned(__first1, __last1, __first2));
174}
175
176// 2+2 iterators: used by std::ranges::swap_ranges.
177template <class _AlgPolicy, class _Cl, class _Cr>
178_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> >
179__swap_ranges(__bit_iterator<_Cl, false> __first1,
180 __bit_iterator<_Cl, false> __last1,
181 __bit_iterator<_Cr, false> __first2,
182 __bit_iterator<_Cr, false> __last2) {
183 if (__last1 - __first1 < __last2 - __first2)
184 return std::make_pair(__last1, std::__swap_ranges<_AlgPolicy>(__first1, __last1, __first2).second);
185 return std::make_pair(std::__swap_ranges<_AlgPolicy>(__first2, __last2, __first1).second, __last2);
186}
187
26// 2+2 iterators: the shorter size will be used.188// 2+2 iterators: the shorter size will be used.
27template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>189template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>190_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>
lib/libcxx/include/__assert+2-2
...@@ -20,8 +20,8 @@...@@ -20,8 +20,8 @@
20#define _LIBCPP_ASSERT(expression, message) \20#define _LIBCPP_ASSERT(expression, message) \
21 (__builtin_expect(static_cast<bool>(expression), 1) \21 (__builtin_expect(static_cast<bool>(expression), 1) \
22 ? (void)0 \22 ? (void)0 \
23 : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING(__LINE__) ": assertion " _LIBCPP_TOSTRING( \23 : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING( \
24 expression) " failed: " message "\n"))24 __LINE__) ": libc++ Hardening assertion " _LIBCPP_TOSTRING(expression) " failed: " message "\n"))
2525
26// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear26// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear
27// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a27// optimization intent. See https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609 for a
lib/libcxx/include/__assertion_handler+3-12
...@@ -13,9 +13,11 @@...@@ -13,9 +13,11 @@
13#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)13#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
14# include <__cxx03/__config>14# include <__cxx03/__config>
15# include <__cxx03/__verbose_abort>15# include <__cxx03/__verbose_abort>
16# include <__cxx03/__verbose_trap>
16#else17#else
17# include <__config>18# include <__config>
18# include <__verbose_abort>19# include <__verbose_abort>
20# include <__verbose_trap>
19#endif21#endif
2022
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -28,18 +30,7 @@...@@ -28,18 +30,7 @@
2830
29#else31#else
3032
31# if __has_builtin(__builtin_verbose_trap)33# define _LIBCPP_ASSERTION_HANDLER(message) _LIBCPP_VERBOSE_TRAP(message)
32// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
33// version before upstream Clang actually got the builtin.
34// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
35# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
36# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
37# else
38# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
39# endif
40# else
41# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
42# endif
4334
44#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG35#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
4536
lib/libcxx/include/__atomic/atomic.h+15-6
...@@ -23,6 +23,7 @@...@@ -23,6 +23,7 @@
23#include <__type_traits/is_integral.h>23#include <__type_traits/is_integral.h>
24#include <__type_traits/is_nothrow_constructible.h>24#include <__type_traits/is_nothrow_constructible.h>
25#include <__type_traits/is_same.h>25#include <__type_traits/is_same.h>
26#include <__type_traits/is_trivially_copyable.h>
26#include <__type_traits/remove_const.h>27#include <__type_traits/remove_const.h>
27#include <__type_traits/remove_pointer.h>28#include <__type_traits/remove_pointer.h>
28#include <__type_traits/remove_volatile.h>29#include <__type_traits/remove_volatile.h>
...@@ -40,6 +41,8 @@ struct __atomic_base // false...@@ -40,6 +41,8 @@ struct __atomic_base // false
40{41{
41 mutable __cxx_atomic_impl<_Tp> __a_;42 mutable __cxx_atomic_impl<_Tp> __a_;
4243
44 using value_type = _Tp;
45
43#if _LIBCPP_STD_VER >= 1746#if _LIBCPP_STD_VER >= 17
44 static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;47 static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
45#endif48#endif
...@@ -145,6 +148,8 @@ template <class _Tp>...@@ -145,6 +148,8 @@ template <class _Tp>
145struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {148struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
146 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>;149 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp, false>;
147150
151 using difference_type = typename __base::value_type;
152
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default;153 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __atomic_base() _NOEXCEPT = default;
149154
150 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}155 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __base(__d) {}
...@@ -226,11 +231,15 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {...@@ -226,11 +231,15 @@ struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {
226 }231 }
227};232};
228233
234template <typename _Tp>
235struct __check_atomic_mandates {
236 using type _LIBCPP_NODEBUG = _Tp;
237 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
238};
239
229template <class _Tp>240template <class _Tp>
230struct atomic : public __atomic_base<_Tp> {241struct atomic : public __atomic_base<typename __check_atomic_mandates<_Tp>::type> {
231 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;242 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp>;
232 using value_type = _Tp;
233 using difference_type = value_type;
234243
235#if _LIBCPP_STD_VER >= 20244#if _LIBCPP_STD_VER >= 20
236 _LIBCPP_HIDE_FROM_ABI atomic() = default;245 _LIBCPP_HIDE_FROM_ABI atomic() = default;
...@@ -258,8 +267,8 @@ struct atomic : public __atomic_base<_Tp> {...@@ -258,8 +267,8 @@ struct atomic : public __atomic_base<_Tp> {
258template <class _Tp>267template <class _Tp>
259struct atomic<_Tp*> : public __atomic_base<_Tp*> {268struct atomic<_Tp*> : public __atomic_base<_Tp*> {
260 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>;269 using __base _LIBCPP_NODEBUG = __atomic_base<_Tp*>;
261 using value_type = _Tp*;270
262 using difference_type = ptrdiff_t;271 using difference_type = ptrdiff_t;
263272
264 _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;273 _LIBCPP_HIDE_FROM_ABI atomic() _NOEXCEPT = default;
265274
...@@ -361,7 +370,7 @@ private:...@@ -361,7 +370,7 @@ private:
361 // https://github.com/llvm/llvm-project/issues/47978370 // https://github.com/llvm/llvm-project/issues/47978
362 // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak371 // clang bug: __old is not updated on failure for atomic<long double>::compare_exchange_weak
363 // Note __old = __self.load(memory_order_relaxed) will not work372 // Note __old = __self.load(memory_order_relaxed) will not work
364 std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), &__old, memory_order_relaxed);373 std::__cxx_atomic_load_inplace(std::addressof(__self.__a_), std::addressof(__old), memory_order_relaxed);
365 }374 }
366# endif375# endif
367 __new = __operation(__old, __operand);376 __new = __operation(__old, __operand);
lib/libcxx/include/__atomic/atomic_ref.h+1-1
...@@ -119,7 +119,7 @@ public:...@@ -119,7 +119,7 @@ public:
119 // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition119 // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition
120 // of atomic_ref's constructor.120 // of atomic_ref's constructor.
121 static constexpr bool is_always_lock_free =121 static constexpr bool is_always_lock_free =
122 __atomic_always_lock_free(sizeof(_Tp), &__get_aligner_instance<required_alignment>::__instance);122 __atomic_always_lock_free(sizeof(_Tp), std::addressof(__get_aligner_instance<required_alignment>::__instance));
123123
124 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); }124 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); }
125125
lib/libcxx/include/__atomic/memory_order.h+2-2
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24// to pin the underlying type in C++20.24// to pin the underlying type in C++20.
25enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst };25enum __legacy_memory_order { __mo_relaxed, __mo_consume, __mo_acquire, __mo_release, __mo_acq_rel, __mo_seq_cst };
2626
27using __memory_order_underlying_t _LIBCPP_NODEBUG = underlying_type<__legacy_memory_order>::type;27using __memory_order_underlying_t _LIBCPP_NODEBUG = __underlying_type_t<__legacy_memory_order>;
2828
29#if _LIBCPP_STD_VER >= 2029#if _LIBCPP_STD_VER >= 20
3030
...@@ -37,7 +37,7 @@ enum class memory_order : __memory_order_underlying_t {...@@ -37,7 +37,7 @@ enum class memory_order : __memory_order_underlying_t {
37 seq_cst = __mo_seq_cst37 seq_cst = __mo_seq_cst
38};38};
3939
40static_assert(is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value,40static_assert(is_same<__underlying_type_t<memory_order>, __memory_order_underlying_t>::value,
41 "unexpected underlying type for std::memory_order");41 "unexpected underlying type for std::memory_order");
4242
43inline constexpr auto memory_order_relaxed = memory_order::relaxed;43inline constexpr auto memory_order_relaxed = memory_order::relaxed;
lib/libcxx/include/__atomic/support.h-3
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___ATOMIC_SUPPORT_H10#define _LIBCPP___ATOMIC_SUPPORT_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_trivially_copyable.h>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -113,8 +112,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -113,8 +112,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
113112
114template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >113template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >
115struct __cxx_atomic_impl : public _Base {114struct __cxx_atomic_impl : public _Base {
116 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
117
118 _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;115 _LIBCPP_HIDE_FROM_ABI __cxx_atomic_impl() _NOEXCEPT = default;
119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}116 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp __value) _NOEXCEPT : _Base(__value) {}
120};117};
lib/libcxx/include/__atomic/support/c11.h+1-1
...@@ -35,7 +35,7 @@ struct __cxx_atomic_base_impl {...@@ -35,7 +35,7 @@ struct __cxx_atomic_base_impl {
35 }35 }
36#endif // _LIBCPP_CXX03_LANG36#endif // _LIBCPP_CXX03_LANG
37 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}37 _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp __value) _NOEXCEPT : __a_value(__value) {}
38 _LIBCPP_DISABLE_EXTENSION_WARNING _Atomic(_Tp) __a_value;38 _Atomic(_Tp) __a_value;
39};39};
4040
41#define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)41#define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)
lib/libcxx/include/__bit/bit_ceil.h+2-2
...@@ -11,8 +11,8 @@...@@ -11,8 +11,8 @@
1111
12#include <__assert>12#include <__assert>
13#include <__bit/countl.h>13#include <__bit/countl.h>
14#include <__concepts/arithmetic.h>
15#include <__config>14#include <__config>
15#include <__type_traits/integer_traits.h>
16#include <limits>16#include <limits>
1717
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -41,7 +41,7 @@ template <class _Tp>...@@ -41,7 +41,7 @@ template <class _Tp>
4141
42# if _LIBCPP_STD_VER >= 2042# if _LIBCPP_STD_VER >= 20
4343
44template <__libcpp_unsigned_integer _Tp>44template <__unsigned_integer _Tp>
45[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {45[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
46 return std::__bit_ceil(__t);46 return std::__bit_ceil(__t);
47}47}
lib/libcxx/include/__bit/bit_floor.h+2-3
...@@ -10,9 +10,8 @@...@@ -10,9 +10,8 @@
10#define _LIBCPP___BIT_BIT_FLOOR_H10#define _LIBCPP___BIT_BIT_FLOOR_H
1111
12#include <__bit/bit_log2.h>12#include <__bit/bit_log2.h>
13#include <__concepts/arithmetic.h>
14#include <__config>13#include <__config>
15#include <limits>14#include <__type_traits/integer_traits.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
...@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2221
23#if _LIBCPP_STD_VER >= 2022#if _LIBCPP_STD_VER >= 20
2423
25template <__libcpp_unsigned_integer _Tp>24template <__unsigned_integer _Tp>
26[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
27 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);26 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
28}27}
lib/libcxx/include/__bit/bit_log2.h+3-7
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
1111
12#include <__bit/countl.h>12#include <__bit/countl.h>
13#include <__config>13#include <__config>
14#include <__type_traits/is_unsigned_integer.h>14#include <__type_traits/integer_traits.h>
15#include <limits>15#include <limits>
1616
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -20,16 +20,12 @@...@@ -20,16 +20,12 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER >= 14
24
25template <class _Tp>23template <class _Tp>
26_LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_log2(_Tp __t) noexcept {24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __bit_log2(_Tp __t) _NOEXCEPT {
27 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__bit_log2 requires an unsigned integer type");25 static_assert(__is_unsigned_integer_v<_Tp>, "__bit_log2 requires an unsigned integer type");
28 return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t);26 return numeric_limits<_Tp>::digits - 1 - std::__countl_zero(__t);
29}27}
3028
31#endif // _LIBCPP_STD_VER >= 14
32
33_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3430
35#endif // _LIBCPP___BIT_BIT_LOG2_H31#endif // _LIBCPP___BIT_BIT_LOG2_H
lib/libcxx/include/__bit/bit_width.h+2-2
...@@ -10,8 +10,8 @@...@@ -10,8 +10,8 @@
10#define _LIBCPP___BIT_BIT_WIDTH_H10#define _LIBCPP___BIT_BIT_WIDTH_H
1111
12#include <__bit/bit_log2.h>12#include <__bit/bit_log2.h>
13#include <__concepts/arithmetic.h>
14#include <__config>13#include <__config>
14#include <__type_traits/integer_traits.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header17# pragma GCC system_header
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24template <__libcpp_unsigned_integer _Tp>24template <__unsigned_integer _Tp>
25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
26 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;26 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
27}27}
lib/libcxx/include/__bit/countl.h+4-68
...@@ -6,16 +6,11 @@...@@ -6,16 +6,11 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_clzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_clzg.
11
12#ifndef _LIBCPP___BIT_COUNTL_H9#ifndef _LIBCPP___BIT_COUNTL_H
13#define _LIBCPP___BIT_COUNTL_H10#define _LIBCPP___BIT_COUNTL_H
1411
15#include <__bit/rotate.h>
16#include <__concepts/arithmetic.h>
17#include <__config>12#include <__config>
18#include <__type_traits/is_unsigned_integer.h>13#include <__type_traits/integer_traits.h>
19#include <limits>14#include <limits>
2015
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -27,79 +22,20 @@ _LIBCPP_PUSH_MACROS...@@ -27,79 +22,20 @@ _LIBCPP_PUSH_MACROS
2722
28_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2924
30[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned __x) _NOEXCEPT {
31 return __builtin_clz(__x);
32}
33
34[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long __x) _NOEXCEPT {
35 return __builtin_clzl(__x);
36}
37
38[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(unsigned long long __x) _NOEXCEPT {
39 return __builtin_clzll(__x);
40}
41
42#if _LIBCPP_HAS_INT128
43inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
44# if __has_builtin(__builtin_clzg)
45 return __builtin_clzg(__x);
46# else
47 // The function is written in this form due to C++ constexpr limitations.
48 // The algorithm:
49 // - Test whether any bit in the high 64-bits is set
50 // - No bits set:
51 // - The high 64-bits contain 64 leading zeros,
52 // - Add the result of the low 64-bits.
53 // - Any bits set:
54 // - The number of leading zeros of the input is the number of leading
55 // zeros in the high 64-bits.
56 return ((__x >> 64) == 0) ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
57 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
58# endif
59}
60#endif // _LIBCPP_HAS_INT128
61
62template <class _Tp>25template <class _Tp>
63_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
64 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");27 static_assert(__is_unsigned_integer_v<_Tp>, "__countl_zero requires an unsigned integer type");
65#if __has_builtin(__builtin_clzg)
66 return __builtin_clzg(__t, numeric_limits<_Tp>::digits);28 return __builtin_clzg(__t, numeric_limits<_Tp>::digits);
67#else // __has_builtin(__builtin_clzg)
68 if (__t == 0)
69 return numeric_limits<_Tp>::digits;
70
71 if (sizeof(_Tp) <= sizeof(unsigned int))
72 return std::__libcpp_clz(static_cast<unsigned int>(__t)) -
73 (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
74 else if (sizeof(_Tp) <= sizeof(unsigned long))
75 return std::__libcpp_clz(static_cast<unsigned long>(__t)) -
76 (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
77 else if (sizeof(_Tp) <= sizeof(unsigned long long))
78 return std::__libcpp_clz(static_cast<unsigned long long>(__t)) -
79 (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
80 else {
81 int __ret = 0;
82 int __iter = 0;
83 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
84 while (true) {
85 __t = std::__rotl(__t, __ulldigits);
86 if ((__iter = std::__countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
87 break;
88 __ret += __iter;
89 }
90 return __ret + __iter;
91 }
92#endif // __has_builtin(__builtin_clzg)
93}29}
9430
95#if _LIBCPP_STD_VER >= 2031#if _LIBCPP_STD_VER >= 20
9632
97template <__libcpp_unsigned_integer _Tp>33template <__unsigned_integer _Tp>
98[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {34[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
99 return std::__countl_zero(__t);35 return std::__countl_zero(__t);
100}36}
10137
102template <__libcpp_unsigned_integer _Tp>38template <__unsigned_integer _Tp>
103[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {39[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
104 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;40 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
105}41}
lib/libcxx/include/__bit/countr.h+5-40
...@@ -6,15 +6,11 @@...@@ -6,15 +6,11 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_ctzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_ctzg.
11
12#ifndef _LIBCPP___BIT_COUNTR_H9#ifndef _LIBCPP___BIT_COUNTR_H
13#define _LIBCPP___BIT_COUNTR_H10#define _LIBCPP___BIT_COUNTR_H
1411
15#include <__bit/rotate.h>
16#include <__concepts/arithmetic.h>
17#include <__config>12#include <__config>
13#include <__type_traits/integer_traits.h>
18#include <limits>14#include <limits>
1915
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -26,51 +22,20 @@ _LIBCPP_PUSH_MACROS...@@ -26,51 +22,20 @@ _LIBCPP_PUSH_MACROS
2622
27_LIBCPP_BEGIN_NAMESPACE_STD23_LIBCPP_BEGIN_NAMESPACE_STD
2824
29[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned __x) _NOEXCEPT {
30 return __builtin_ctz(__x);
31}
32
33[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long __x) _NOEXCEPT {
34 return __builtin_ctzl(__x);
35}
36
37[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ctz(unsigned long long __x) _NOEXCEPT {
38 return __builtin_ctzll(__x);
39}
40
41template <class _Tp>25template <class _Tp>
42[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __countr_zero(_Tp __t) _NOEXCEPT {
43#if __has_builtin(__builtin_ctzg)27 static_assert(__is_unsigned_integer_v<_Tp>, "__countr_zero only works with unsigned types");
44 return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);28 return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
45#else // __has_builtin(__builtin_ctzg)
46 if (__t == 0)
47 return numeric_limits<_Tp>::digits;
48 if (sizeof(_Tp) <= sizeof(unsigned int))
49 return std::__libcpp_ctz(static_cast<unsigned int>(__t));
50 else if (sizeof(_Tp) <= sizeof(unsigned long))
51 return std::__libcpp_ctz(static_cast<unsigned long>(__t));
52 else if (sizeof(_Tp) <= sizeof(unsigned long long))
53 return std::__libcpp_ctz(static_cast<unsigned long long>(__t));
54 else {
55 int __ret = 0;
56 const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
57 while (static_cast<unsigned long long>(__t) == 0uLL) {
58 __ret += __ulldigits;
59 __t >>= __ulldigits;
60 }
61 return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
62 }
63#endif // __has_builtin(__builtin_ctzg)
64}29}
6530
66#if _LIBCPP_STD_VER >= 2031#if _LIBCPP_STD_VER >= 20
6732
68template <__libcpp_unsigned_integer _Tp>33template <__unsigned_integer _Tp>
69[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {34[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
70 return std::__countr_zero(__t);35 return std::__countr_zero(__t);
71}36}
7237
73template <__libcpp_unsigned_integer _Tp>38template <__unsigned_integer _Tp>
74[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {39[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
75 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;40 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
76}41}
lib/libcxx/include/__bit/has_single_bit.h+2-2
...@@ -9,8 +9,8 @@...@@ -9,8 +9,8 @@
9#ifndef _LIBCPP___BIT_HAS_SINGLE_BIT_H9#ifndef _LIBCPP___BIT_HAS_SINGLE_BIT_H
10#define _LIBCPP___BIT_HAS_SINGLE_BIT_H10#define _LIBCPP___BIT_HAS_SINGLE_BIT_H
1111
12#include <__concepts/arithmetic.h>
13#include <__config>12#include <__config>
13#include <__type_traits/integer_traits.h>
1414
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header16# pragma GCC system_header
...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS...@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26template <__libcpp_unsigned_integer _Tp>26template <__unsigned_integer _Tp>
27[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {27[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
28 return __t != 0 && (((__t & (__t - 1)) == 0));28 return __t != 0 && (((__t & (__t - 1)) == 0));
29}29}
lib/libcxx/include/__bit/popcount.h+8-36
...@@ -6,16 +6,11 @@...@@ -6,16 +6,11 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_popcountg.
11
12#ifndef _LIBCPP___BIT_POPCOUNT_H9#ifndef _LIBCPP___BIT_POPCOUNT_H
13#define _LIBCPP___BIT_POPCOUNT_H10#define _LIBCPP___BIT_POPCOUNT_H
1411
15#include <__bit/rotate.h>
16#include <__concepts/arithmetic.h>
17#include <__config>12#include <__config>
18#include <limits>13#include <__type_traits/integer_traits.h>
1914
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header16# pragma GCC system_header
...@@ -26,43 +21,20 @@ _LIBCPP_PUSH_MACROS...@@ -26,43 +21,20 @@ _LIBCPP_PUSH_MACROS
2621
27_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2823
29inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned __x) _NOEXCEPT {24template <class _Tp>
30 return __builtin_popcount(__x);25[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __popcount(_Tp __t) _NOEXCEPT {
31}26 static_assert(__is_unsigned_integer_v<_Tp>, "__popcount only works with unsigned types");
3227 return __builtin_popcountg(__t);
33inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long __x) _NOEXCEPT {
34 return __builtin_popcountl(__x);
35}
36
37inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long long __x) _NOEXCEPT {
38 return __builtin_popcountll(__x);
39}28}
4029
41#if _LIBCPP_STD_VER >= 2030#if _LIBCPP_STD_VER >= 20
4231
43template <__libcpp_unsigned_integer _Tp>32template <__unsigned_integer _Tp>
44[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {33[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
45# if __has_builtin(__builtin_popcountg)34 return std::__popcount(__t);
46 return __builtin_popcountg(__t);
47# else // __has_builtin(__builtin_popcountg)
48 if (sizeof(_Tp) <= sizeof(unsigned int))
49 return std::__libcpp_popcount(static_cast<unsigned int>(__t));
50 else if (sizeof(_Tp) <= sizeof(unsigned long))
51 return std::__libcpp_popcount(static_cast<unsigned long>(__t));
52 else if (sizeof(_Tp) <= sizeof(unsigned long long))
53 return std::__libcpp_popcount(static_cast<unsigned long long>(__t));
54 else {
55 int __ret = 0;
56 while (__t != 0) {
57 __ret += std::__libcpp_popcount(static_cast<unsigned long long>(__t));
58 __t >>= numeric_limits<unsigned long long>::digits;
59 }
60 return __ret;
61 }
62# endif // __has_builtin(__builtin_popcountg)
63}35}
6436
65#endif // _LIBCPP_STD_VER >= 2037#endif
6638
67_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
6840
lib/libcxx/include/__bit/rotate.h+5-6
...@@ -9,9 +9,8 @@...@@ -9,9 +9,8 @@
9#ifndef _LIBCPP___BIT_ROTATE_H9#ifndef _LIBCPP___BIT_ROTATE_H
10#define _LIBCPP___BIT_ROTATE_H10#define _LIBCPP___BIT_ROTATE_H
1111
12#include <__concepts/arithmetic.h>
13#include <__config>12#include <__config>
14#include <__type_traits/is_unsigned_integer.h>13#include <__type_traits/integer_traits.h>
15#include <limits>14#include <limits>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -25,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
25// the rotr function becomes the ROR instruction.24// the rotr function becomes the ROR instruction.
26template <class _Tp>25template <class _Tp>
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {
28 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");27 static_assert(__is_unsigned_integer_v<_Tp>, "__rotl requires an unsigned integer type");
29 const int __n = numeric_limits<_Tp>::digits;28 const int __n = numeric_limits<_Tp>::digits;
30 int __r = __s % __n;29 int __r = __s % __n;
3130
...@@ -40,7 +39,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s)...@@ -40,7 +39,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s)
4039
41template <class _Tp>40template <class _Tp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {41_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {
43 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");42 static_assert(__is_unsigned_integer_v<_Tp>, "__rotr requires an unsigned integer type");
44 const int __n = numeric_limits<_Tp>::digits;43 const int __n = numeric_limits<_Tp>::digits;
45 int __r = __s % __n;44 int __r = __s % __n;
4645
...@@ -55,12 +54,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s)...@@ -55,12 +54,12 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s)
5554
56#if _LIBCPP_STD_VER >= 2055#if _LIBCPP_STD_VER >= 20
5756
58template <__libcpp_unsigned_integer _Tp>57template <__unsigned_integer _Tp>
59[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept {58[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotl(_Tp __t, int __cnt) noexcept {
60 return std::__rotl(__t, __cnt);59 return std::__rotl(__t, __cnt);
61}60}
6261
63template <__libcpp_unsigned_integer _Tp>62template <__unsigned_integer _Tp>
64[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept {63[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp rotr(_Tp __t, int __cnt) noexcept {
65 return std::__rotr(__t, __cnt);64 return std::__rotr(__t, __cnt);
66}65}
lib/libcxx/include/__bit_reference+109-599
...@@ -10,21 +10,35 @@...@@ -10,21 +10,35 @@
10#ifndef _LIBCPP___BIT_REFERENCE10#ifndef _LIBCPP___BIT_REFERENCE
11#define _LIBCPP___BIT_REFERENCE11#define _LIBCPP___BIT_REFERENCE
1212
13#include <__algorithm/comp.h>
14#include <__algorithm/copy.h>
15#include <__algorithm/copy_backward.h>
13#include <__algorithm/copy_n.h>16#include <__algorithm/copy_n.h>
17#include <__algorithm/equal.h>
14#include <__algorithm/min.h>18#include <__algorithm/min.h>
19#include <__algorithm/rotate.h>
20#include <__algorithm/swap_ranges.h>
21#include <__assert>
15#include <__bit/countr.h>22#include <__bit/countr.h>
16#include <__compare/ordering.h>23#include <__compare/ordering.h>
17#include <__config>24#include <__config>
18#include <__cstddef/ptrdiff_t.h>25#include <__cstddef/ptrdiff_t.h>
19#include <__cstddef/size_t.h>26#include <__cstddef/size_t.h>
27#include <__functional/identity.h>
20#include <__fwd/bit_reference.h>28#include <__fwd/bit_reference.h>
21#include <__iterator/iterator_traits.h>29#include <__iterator/iterator_traits.h>
22#include <__memory/construct_at.h>30#include <__memory/construct_at.h>
23#include <__memory/pointer_traits.h>31#include <__memory/pointer_traits.h>
24#include <__type_traits/conditional.h>32#include <__type_traits/conditional.h>
33#include <__type_traits/desugars_to.h>
34#include <__type_traits/enable_if.h>
25#include <__type_traits/is_constant_evaluated.h>35#include <__type_traits/is_constant_evaluated.h>
36#include <__type_traits/is_same.h>
37#include <__type_traits/is_unsigned.h>
26#include <__type_traits/void_t.h>38#include <__type_traits/void_t.h>
39#include <__utility/pair.h>
27#include <__utility/swap.h>40#include <__utility/swap.h>
41#include <climits>
2842
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)43#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header44# pragma GCC system_header
...@@ -55,6 +69,53 @@ struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type...@@ -55,6 +69,53 @@ struct __size_difference_type_traits<_Cp, __void_t<typename _Cp::difference_type
55 using size_type = typename _Cp::size_type;69 using size_type = typename _Cp::size_type;
56};70};
5771
72// The `__x_mask` functions are designed to work exclusively with any unsigned `_StorageType`s, including small
73// integral types such as unsigned char/short, `uint8_t`, and `uint16_t`. To prevent undefined behavior or
74// ambiguities due to integral promotions for the small integral types, all intermediate bitwise operations are
75// explicitly cast back to the unsigned `_StorageType`.
76
77// Creates a mask of type `_StorageType` with a specified number of leading zeros (__clz) and sets all remaining
78// bits to one.
79template <class _StorageType>
80_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __trailing_mask(unsigned __clz) {
81 static_assert(is_unsigned<_StorageType>::value, "__trailing_mask only works with unsigned types");
82 return static_cast<_StorageType>(~static_cast<_StorageType>(0)) >> __clz;
83}
84
85// Creates a mask of type `_StorageType` with a specified number of trailing zeros (__ctz) and sets all remaining
86// bits to one.
87template <class _StorageType>
88_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __leading_mask(unsigned __ctz) {
89 static_assert(is_unsigned<_StorageType>::value, "__leading_mask only works with unsigned types");
90 return static_cast<_StorageType>(~static_cast<_StorageType>(0)) << __ctz;
91}
92
93// Creates a mask of type `_StorageType` with a specified number of leading zeros (__clz), a specified number of
94// trailing zeros (__ctz), and sets all bits in between to one.
95template <class _StorageType>
96_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __middle_mask(unsigned __clz, unsigned __ctz) {
97 static_assert(is_unsigned<_StorageType>::value, "__middle_mask only works with unsigned types");
98 return std::__leading_mask<_StorageType>(__ctz) & std::__trailing_mask<_StorageType>(__clz);
99}
100
101// This function is designed to operate correctly even for smaller integral types like `uint8_t`, `uint16_t`,
102// or `unsigned short`.
103// See https://github.com/llvm/llvm-project/pull/122410.
104template <class _StoragePointer>
105_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
106__fill_masked_range(_StoragePointer __word, unsigned __clz, unsigned __ctz, bool __fill_val) {
107 static_assert(is_unsigned<typename pointer_traits<_StoragePointer>::element_type>::value,
108 "__fill_masked_range must be called with unsigned type");
109 using _StorageType = typename pointer_traits<_StoragePointer>::element_type;
110 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
111 __ctz + __clz < sizeof(_StorageType) * CHAR_BIT, "__fill_masked_range called with invalid range");
112 _StorageType __m = std::__middle_mask<_StorageType>(__clz, __ctz);
113 if (__fill_val)
114 *__word |= __m;
115 else
116 *__word &= ~__m;
117}
118
58template <class _Cp, bool = __has_storage_type<_Cp>::value>119template <class _Cp, bool = __has_storage_type<_Cp>::value>
59class __bit_reference {120class __bit_reference {
60 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;121 using __storage_type _LIBCPP_NODEBUG = typename _Cp::__storage_type;
...@@ -104,7 +165,7 @@ public:...@@ -104,7 +165,7 @@ public:
104165
105 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; }166 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; }
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT {167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT {
107 return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));168 return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__countr_zero(__mask_)));
108 }169 }
109170
110private:171private:
...@@ -173,7 +234,7 @@ public:...@@ -173,7 +234,7 @@ public:
173 }234 }
174235
175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT {236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT {
176 return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__libcpp_ctz(__mask_)));237 return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(std::__countr_zero(__mask_)));
177 }238 }
178239
179private:240private:
...@@ -183,422 +244,6 @@ private:...@@ -183,422 +244,6 @@ private:
183 __mask_(__m) {}244 __mask_(__m) {}
184};245};
185246
186// copy
187
188template <class _Cp, bool _IsConst>
189_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_aligned(
190 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
191 using _In = __bit_iterator<_Cp, _IsConst>;
192 using difference_type = typename _In::difference_type;
193 using __storage_type = typename _In::__storage_type;
194
195 const int __bits_per_word = _In::__bits_per_word;
196 difference_type __n = __last - __first;
197 if (__n > 0) {
198 // do first word
199 if (__first.__ctz_ != 0) {
200 unsigned __clz = __bits_per_word - __first.__ctz_;
201 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
202 __n -= __dn;
203 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
204 __storage_type __b = *__first.__seg_ & __m;
205 *__result.__seg_ &= ~__m;
206 *__result.__seg_ |= __b;
207 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
208 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
209 ++__first.__seg_;
210 // __first.__ctz_ = 0;
211 }
212 // __first.__ctz_ == 0;
213 // do middle words
214 __storage_type __nw = __n / __bits_per_word;
215 std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
216 __n -= __nw * __bits_per_word;
217 __result.__seg_ += __nw;
218 // do last word
219 if (__n > 0) {
220 __first.__seg_ += __nw;
221 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
222 __storage_type __b = *__first.__seg_ & __m;
223 *__result.__seg_ &= ~__m;
224 *__result.__seg_ |= __b;
225 __result.__ctz_ = static_cast<unsigned>(__n);
226 }
227 }
228 return __result;
229}
230
231template <class _Cp, bool _IsConst>
232_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_unaligned(
233 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
234 using _In = __bit_iterator<_Cp, _IsConst>;
235 using difference_type = typename _In::difference_type;
236 using __storage_type = typename _In::__storage_type;
237
238 const int __bits_per_word = _In::__bits_per_word;
239 difference_type __n = __last - __first;
240 if (__n > 0) {
241 // do first word
242 if (__first.__ctz_ != 0) {
243 unsigned __clz_f = __bits_per_word - __first.__ctz_;
244 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
245 __n -= __dn;
246 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
247 __storage_type __b = *__first.__seg_ & __m;
248 unsigned __clz_r = __bits_per_word - __result.__ctz_;
249 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
250 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
251 *__result.__seg_ &= ~__m;
252 if (__result.__ctz_ > __first.__ctz_)
253 *__result.__seg_ |= __b << (__result.__ctz_ - __first.__ctz_);
254 else
255 *__result.__seg_ |= __b >> (__first.__ctz_ - __result.__ctz_);
256 __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
257 __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
258 __dn -= __ddn;
259 if (__dn > 0) {
260 __m = ~__storage_type(0) >> (__bits_per_word - __dn);
261 *__result.__seg_ &= ~__m;
262 *__result.__seg_ |= __b >> (__first.__ctz_ + __ddn);
263 __result.__ctz_ = static_cast<unsigned>(__dn);
264 }
265 ++__first.__seg_;
266 // __first.__ctz_ = 0;
267 }
268 // __first.__ctz_ == 0;
269 // do middle words
270 unsigned __clz_r = __bits_per_word - __result.__ctz_;
271 __storage_type __m = ~__storage_type(0) << __result.__ctz_;
272 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) {
273 __storage_type __b = *__first.__seg_;
274 *__result.__seg_ &= ~__m;
275 *__result.__seg_ |= __b << __result.__ctz_;
276 ++__result.__seg_;
277 *__result.__seg_ &= __m;
278 *__result.__seg_ |= __b >> __clz_r;
279 }
280 // do last word
281 if (__n > 0) {
282 __m = ~__storage_type(0) >> (__bits_per_word - __n);
283 __storage_type __b = *__first.__seg_ & __m;
284 __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r));
285 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
286 *__result.__seg_ &= ~__m;
287 *__result.__seg_ |= __b << __result.__ctz_;
288 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
289 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
290 __n -= __dn;
291 if (__n > 0) {
292 __m = ~__storage_type(0) >> (__bits_per_word - __n);
293 *__result.__seg_ &= ~__m;
294 *__result.__seg_ |= __b >> __dn;
295 __result.__ctz_ = static_cast<unsigned>(__n);
296 }
297 }
298 }
299 return __result;
300}
301
302template <class _Cp, bool _IsConst>
303inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false>
304copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
305 if (__first.__ctz_ == __result.__ctz_)
306 return std::__copy_aligned(__first, __last, __result);
307 return std::__copy_unaligned(__first, __last, __result);
308}
309
310// copy_backward
311
312template <class _Cp, bool _IsConst>
313_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_aligned(
314 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
315 using _In = __bit_iterator<_Cp, _IsConst>;
316 using difference_type = typename _In::difference_type;
317 using __storage_type = typename _In::__storage_type;
318
319 const int __bits_per_word = _In::__bits_per_word;
320 difference_type __n = __last - __first;
321 if (__n > 0) {
322 // do first word
323 if (__last.__ctz_ != 0) {
324 difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n);
325 __n -= __dn;
326 unsigned __clz = __bits_per_word - __last.__ctz_;
327 __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz);
328 __storage_type __b = *__last.__seg_ & __m;
329 *__result.__seg_ &= ~__m;
330 *__result.__seg_ |= __b;
331 __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
332 // __last.__ctz_ = 0
333 }
334 // __last.__ctz_ == 0 || __n == 0
335 // __result.__ctz_ == 0 || __n == 0
336 // do middle words
337 __storage_type __nw = __n / __bits_per_word;
338 __result.__seg_ -= __nw;
339 __last.__seg_ -= __nw;
340 std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
341 __n -= __nw * __bits_per_word;
342 // do last word
343 if (__n > 0) {
344 __storage_type __m = ~__storage_type(0) << (__bits_per_word - __n);
345 __storage_type __b = *--__last.__seg_ & __m;
346 *--__result.__seg_ &= ~__m;
347 *__result.__seg_ |= __b;
348 __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
349 }
350 }
351 return __result;
352}
353
354template <class _Cp, bool _IsConst>
355_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> __copy_backward_unaligned(
356 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
357 using _In = __bit_iterator<_Cp, _IsConst>;
358 using difference_type = typename _In::difference_type;
359 using __storage_type = typename _In::__storage_type;
360
361 const int __bits_per_word = _In::__bits_per_word;
362 difference_type __n = __last - __first;
363 if (__n > 0) {
364 // do first word
365 if (__last.__ctz_ != 0) {
366 difference_type __dn = std::min(static_cast<difference_type>(__last.__ctz_), __n);
367 __n -= __dn;
368 unsigned __clz_l = __bits_per_word - __last.__ctz_;
369 __storage_type __m = (~__storage_type(0) << (__last.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_l);
370 __storage_type __b = *__last.__seg_ & __m;
371 unsigned __clz_r = __bits_per_word - __result.__ctz_;
372 __storage_type __ddn = std::min(__dn, static_cast<difference_type>(__result.__ctz_));
373 if (__ddn > 0) {
374 __m = (~__storage_type(0) << (__result.__ctz_ - __ddn)) & (~__storage_type(0) >> __clz_r);
375 *__result.__seg_ &= ~__m;
376 if (__result.__ctz_ > __last.__ctz_)
377 *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
378 else
379 *__result.__seg_ |= __b >> (__last.__ctz_ - __result.__ctz_);
380 __result.__ctz_ = static_cast<unsigned>(((-__ddn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
381 __dn -= __ddn;
382 }
383 if (__dn > 0) {
384 // __result.__ctz_ == 0
385 --__result.__seg_;
386 __result.__ctz_ = static_cast<unsigned>(-__dn & (__bits_per_word - 1));
387 __m = ~__storage_type(0) << __result.__ctz_;
388 *__result.__seg_ &= ~__m;
389 __last.__ctz_ -= __dn + __ddn;
390 *__result.__seg_ |= __b << (__result.__ctz_ - __last.__ctz_);
391 }
392 // __last.__ctz_ = 0
393 }
394 // __last.__ctz_ == 0 || __n == 0
395 // __result.__ctz_ != 0 || __n == 0
396 // do middle words
397 unsigned __clz_r = __bits_per_word - __result.__ctz_;
398 __storage_type __m = ~__storage_type(0) >> __clz_r;
399 for (; __n >= __bits_per_word; __n -= __bits_per_word) {
400 __storage_type __b = *--__last.__seg_;
401 *__result.__seg_ &= ~__m;
402 *__result.__seg_ |= __b >> __clz_r;
403 *--__result.__seg_ &= __m;
404 *__result.__seg_ |= __b << __result.__ctz_;
405 }
406 // do last word
407 if (__n > 0) {
408 __m = ~__storage_type(0) << (__bits_per_word - __n);
409 __storage_type __b = *--__last.__seg_ & __m;
410 __clz_r = __bits_per_word - __result.__ctz_;
411 __storage_type __dn = std::min(__n, static_cast<difference_type>(__result.__ctz_));
412 __m = (~__storage_type(0) << (__result.__ctz_ - __dn)) & (~__storage_type(0) >> __clz_r);
413 *__result.__seg_ &= ~__m;
414 *__result.__seg_ |= __b >> (__bits_per_word - __result.__ctz_);
415 __result.__ctz_ = static_cast<unsigned>(((-__dn & (__bits_per_word - 1)) + __result.__ctz_) % __bits_per_word);
416 __n -= __dn;
417 if (__n > 0) {
418 // __result.__ctz_ == 0
419 --__result.__seg_;
420 __result.__ctz_ = static_cast<unsigned>(-__n & (__bits_per_word - 1));
421 __m = ~__storage_type(0) << __result.__ctz_;
422 *__result.__seg_ &= ~__m;
423 *__result.__seg_ |= __b << (__result.__ctz_ - (__bits_per_word - __n - __dn));
424 }
425 }
426 }
427 return __result;
428}
429
430template <class _Cp, bool _IsConst>
431inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> copy_backward(
432 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
433 if (__last.__ctz_ == __result.__ctz_)
434 return std::__copy_backward_aligned(__first, __last, __result);
435 return std::__copy_backward_unaligned(__first, __last, __result);
436}
437
438// move
439
440template <class _Cp, bool _IsConst>
441inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
442move(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
443 return std::copy(__first, __last, __result);
444}
445
446// move_backward
447
448template <class _Cp, bool _IsConst>
449inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> move_backward(
450 __bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) {
451 return std::copy_backward(__first, __last, __result);
452}
453
454// swap_ranges
455
456template <class _Cl, class _Cr>
457_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_aligned(
458 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
459 using _I1 = __bit_iterator<_Cl, false>;
460 using difference_type = typename _I1::difference_type;
461 using __storage_type = typename _I1::__storage_type;
462
463 const int __bits_per_word = _I1::__bits_per_word;
464 difference_type __n = __last - __first;
465 if (__n > 0) {
466 // do first word
467 if (__first.__ctz_ != 0) {
468 unsigned __clz = __bits_per_word - __first.__ctz_;
469 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
470 __n -= __dn;
471 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
472 __storage_type __b1 = *__first.__seg_ & __m;
473 *__first.__seg_ &= ~__m;
474 __storage_type __b2 = *__result.__seg_ & __m;
475 *__result.__seg_ &= ~__m;
476 *__result.__seg_ |= __b1;
477 *__first.__seg_ |= __b2;
478 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
479 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
480 ++__first.__seg_;
481 // __first.__ctz_ = 0;
482 }
483 // __first.__ctz_ == 0;
484 // do middle words
485 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_)
486 swap(*__first.__seg_, *__result.__seg_);
487 // do last word
488 if (__n > 0) {
489 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
490 __storage_type __b1 = *__first.__seg_ & __m;
491 *__first.__seg_ &= ~__m;
492 __storage_type __b2 = *__result.__seg_ & __m;
493 *__result.__seg_ &= ~__m;
494 *__result.__seg_ |= __b1;
495 *__first.__seg_ |= __b2;
496 __result.__ctz_ = static_cast<unsigned>(__n);
497 }
498 }
499 return __result;
500}
501
502template <class _Cl, class _Cr>
503_LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> __swap_ranges_unaligned(
504 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
505 using _I1 = __bit_iterator<_Cl, false>;
506 using difference_type = typename _I1::difference_type;
507 using __storage_type = typename _I1::__storage_type;
508
509 const int __bits_per_word = _I1::__bits_per_word;
510 difference_type __n = __last - __first;
511 if (__n > 0) {
512 // do first word
513 if (__first.__ctz_ != 0) {
514 unsigned __clz_f = __bits_per_word - __first.__ctz_;
515 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
516 __n -= __dn;
517 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
518 __storage_type __b1 = *__first.__seg_ & __m;
519 *__first.__seg_ &= ~__m;
520 unsigned __clz_r = __bits_per_word - __result.__ctz_;
521 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
522 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
523 __storage_type __b2 = *__result.__seg_ & __m;
524 *__result.__seg_ &= ~__m;
525 if (__result.__ctz_ > __first.__ctz_) {
526 unsigned __s = __result.__ctz_ - __first.__ctz_;
527 *__result.__seg_ |= __b1 << __s;
528 *__first.__seg_ |= __b2 >> __s;
529 } else {
530 unsigned __s = __first.__ctz_ - __result.__ctz_;
531 *__result.__seg_ |= __b1 >> __s;
532 *__first.__seg_ |= __b2 << __s;
533 }
534 __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
535 __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
536 __dn -= __ddn;
537 if (__dn > 0) {
538 __m = ~__storage_type(0) >> (__bits_per_word - __dn);
539 __b2 = *__result.__seg_ & __m;
540 *__result.__seg_ &= ~__m;
541 unsigned __s = __first.__ctz_ + __ddn;
542 *__result.__seg_ |= __b1 >> __s;
543 *__first.__seg_ |= __b2 << __s;
544 __result.__ctz_ = static_cast<unsigned>(__dn);
545 }
546 ++__first.__seg_;
547 // __first.__ctz_ = 0;
548 }
549 // __first.__ctz_ == 0;
550 // do middle words
551 __storage_type __m = ~__storage_type(0) << __result.__ctz_;
552 unsigned __clz_r = __bits_per_word - __result.__ctz_;
553 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) {
554 __storage_type __b1 = *__first.__seg_;
555 __storage_type __b2 = *__result.__seg_ & __m;
556 *__result.__seg_ &= ~__m;
557 *__result.__seg_ |= __b1 << __result.__ctz_;
558 *__first.__seg_ = __b2 >> __result.__ctz_;
559 ++__result.__seg_;
560 __b2 = *__result.__seg_ & ~__m;
561 *__result.__seg_ &= __m;
562 *__result.__seg_ |= __b1 >> __clz_r;
563 *__first.__seg_ |= __b2 << __clz_r;
564 }
565 // do last word
566 if (__n > 0) {
567 __m = ~__storage_type(0) >> (__bits_per_word - __n);
568 __storage_type __b1 = *__first.__seg_ & __m;
569 *__first.__seg_ &= ~__m;
570 __storage_type __dn = std::min<__storage_type>(__n, __clz_r);
571 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
572 __storage_type __b2 = *__result.__seg_ & __m;
573 *__result.__seg_ &= ~__m;
574 *__result.__seg_ |= __b1 << __result.__ctz_;
575 *__first.__seg_ |= __b2 >> __result.__ctz_;
576 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
577 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
578 __n -= __dn;
579 if (__n > 0) {
580 __m = ~__storage_type(0) >> (__bits_per_word - __n);
581 __b2 = *__result.__seg_ & __m;
582 *__result.__seg_ &= ~__m;
583 *__result.__seg_ |= __b1 >> __dn;
584 *__first.__seg_ |= __b2 << __dn;
585 __result.__ctz_ = static_cast<unsigned>(__n);
586 }
587 }
588 }
589 return __result;
590}
591
592template <class _Cl, class _Cr>
593inline _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cr, false> swap_ranges(
594 __bit_iterator<_Cl, false> __first1, __bit_iterator<_Cl, false> __last1, __bit_iterator<_Cr, false> __first2) {
595 if (__first1.__ctz_ == __first2.__ctz_)
596 return std::__swap_ranges_aligned(__first1, __last1, __first2);
597 return std::__swap_ranges_unaligned(__first1, __last1, __first2);
598}
599
600// rotate
601
602template <class _Cp>247template <class _Cp>
603struct __bit_array {248struct __bit_array {
604 using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type;249 using difference_type _LIBCPP_NODEBUG = typename __size_difference_type_traits<_Cp>::difference_type;
...@@ -630,166 +275,6 @@ struct __bit_array {...@@ -630,166 +275,6 @@ struct __bit_array {
630 }275 }
631};276};
632277
633template <class _Cp>
634_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false>
635rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last) {
636 using _I1 = __bit_iterator<_Cp, false>;
637 using difference_type = typename _I1::difference_type;
638
639 difference_type __d1 = __middle - __first;
640 difference_type __d2 = __last - __middle;
641 _I1 __r = __first + __d2;
642 while (__d1 != 0 && __d2 != 0) {
643 if (__d1 <= __d2) {
644 if (__d1 <= __bit_array<_Cp>::capacity()) {
645 __bit_array<_Cp> __b(__d1);
646 std::copy(__first, __middle, __b.begin());
647 std::copy(__b.begin(), __b.end(), std::copy(__middle, __last, __first));
648 break;
649 } else {
650 __bit_iterator<_Cp, false> __mp = std::swap_ranges(__first, __middle, __middle);
651 __first = __middle;
652 __middle = __mp;
653 __d2 -= __d1;
654 }
655 } else {
656 if (__d2 <= __bit_array<_Cp>::capacity()) {
657 __bit_array<_Cp> __b(__d2);
658 std::copy(__middle, __last, __b.begin());
659 std::copy_backward(__b.begin(), __b.end(), std::copy_backward(__first, __middle, __last));
660 break;
661 } else {
662 __bit_iterator<_Cp, false> __mp = __first + __d2;
663 std::swap_ranges(__first, __mp, __middle);
664 __first = __mp;
665 __d1 -= __d2;
666 }
667 }
668 }
669 return __r;
670}
671
672// equal
673
674template <class _Cp, bool _IC1, bool _IC2>
675_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_unaligned(
676 __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) {
677 using _It = __bit_iterator<_Cp, _IC1>;
678 using difference_type = typename _It::difference_type;
679 using __storage_type = typename _It::__storage_type;
680
681 const int __bits_per_word = _It::__bits_per_word;
682 difference_type __n = __last1 - __first1;
683 if (__n > 0) {
684 // do first word
685 if (__first1.__ctz_ != 0) {
686 unsigned __clz_f = __bits_per_word - __first1.__ctz_;
687 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
688 __n -= __dn;
689 __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
690 __storage_type __b = *__first1.__seg_ & __m;
691 unsigned __clz_r = __bits_per_word - __first2.__ctz_;
692 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
693 __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
694 if (__first2.__ctz_ > __first1.__ctz_) {
695 if ((*__first2.__seg_ & __m) != (__b << (__first2.__ctz_ - __first1.__ctz_)))
696 return false;
697 } else {
698 if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ - __first2.__ctz_)))
699 return false;
700 }
701 __first2.__seg_ += (__ddn + __first2.__ctz_) / __bits_per_word;
702 __first2.__ctz_ = static_cast<unsigned>((__ddn + __first2.__ctz_) % __bits_per_word);
703 __dn -= __ddn;
704 if (__dn > 0) {
705 __m = ~__storage_type(0) >> (__bits_per_word - __dn);
706 if ((*__first2.__seg_ & __m) != (__b >> (__first1.__ctz_ + __ddn)))
707 return false;
708 __first2.__ctz_ = static_cast<unsigned>(__dn);
709 }
710 ++__first1.__seg_;
711 // __first1.__ctz_ = 0;
712 }
713 // __first1.__ctz_ == 0;
714 // do middle words
715 unsigned __clz_r = __bits_per_word - __first2.__ctz_;
716 __storage_type __m = ~__storage_type(0) << __first2.__ctz_;
717 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_) {
718 __storage_type __b = *__first1.__seg_;
719 if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
720 return false;
721 ++__first2.__seg_;
722 if ((*__first2.__seg_ & ~__m) != (__b >> __clz_r))
723 return false;
724 }
725 // do last word
726 if (__n > 0) {
727 __m = ~__storage_type(0) >> (__bits_per_word - __n);
728 __storage_type __b = *__first1.__seg_ & __m;
729 __storage_type __dn = std::min(__n, static_cast<difference_type>(__clz_r));
730 __m = (~__storage_type(0) << __first2.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
731 if ((*__first2.__seg_ & __m) != (__b << __first2.__ctz_))
732 return false;
733 __first2.__seg_ += (__dn + __first2.__ctz_) / __bits_per_word;
734 __first2.__ctz_ = static_cast<unsigned>((__dn + __first2.__ctz_) % __bits_per_word);
735 __n -= __dn;
736 if (__n > 0) {
737 __m = ~__storage_type(0) >> (__bits_per_word - __n);
738 if ((*__first2.__seg_ & __m) != (__b >> __dn))
739 return false;
740 }
741 }
742 }
743 return true;
744}
745
746template <class _Cp, bool _IC1, bool _IC2>
747_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __equal_aligned(
748 __bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) {
749 using _It = __bit_iterator<_Cp, _IC1>;
750 using difference_type = typename _It::difference_type;
751 using __storage_type = typename _It::__storage_type;
752
753 const int __bits_per_word = _It::__bits_per_word;
754 difference_type __n = __last1 - __first1;
755 if (__n > 0) {
756 // do first word
757 if (__first1.__ctz_ != 0) {
758 unsigned __clz = __bits_per_word - __first1.__ctz_;
759 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
760 __n -= __dn;
761 __storage_type __m = (~__storage_type(0) << __first1.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
762 if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
763 return false;
764 ++__first2.__seg_;
765 ++__first1.__seg_;
766 // __first1.__ctz_ = 0;
767 // __first2.__ctz_ = 0;
768 }
769 // __first1.__ctz_ == 0;
770 // __first2.__ctz_ == 0;
771 // do middle words
772 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first1.__seg_, ++__first2.__seg_)
773 if (*__first2.__seg_ != *__first1.__seg_)
774 return false;
775 // do last word
776 if (__n > 0) {
777 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
778 if ((*__first2.__seg_ & __m) != (*__first1.__seg_ & __m))
779 return false;
780 }
781 }
782 return true;
783}
784
785template <class _Cp, bool _IC1, bool _IC2>
786inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
787equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) {
788 if (__first1.__ctz_ == __first2.__ctz_)
789 return std::__equal_aligned(__first1, __last1, __first2);
790 return std::__equal_unaligned(__first1, __last1, __first2);
791}
792
793template <class _Cp, bool _IsConst, typename _Cp::__storage_type>278template <class _Cp, bool _IsConst, typename _Cp::__storage_type>
794class __bit_iterator {279class __bit_iterator {
795public:280public:
...@@ -844,6 +329,7 @@ public:...@@ -844,6 +329,7 @@ public:
844 }329 }
845330
846 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {331 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
332 _LIBCPP_ASSERT_INTERNAL(__ctz_ < __bits_per_word, "Dereferencing an invalid __bit_iterator.");
847 return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(333 return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(
848 __seg_, __storage_type(1) << __ctz_);334 __seg_, __storage_type(1) << __ctz_);
849 }335 }
...@@ -968,7 +454,10 @@ private:...@@ -968,7 +454,10 @@ private:
968 _LIBCPP_HIDE_FROM_ABI454 _LIBCPP_HIDE_FROM_ABI
969 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT455 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
970 : __seg_(__s),456 : __seg_(__s),
971 __ctz_(__ctz) {}457 __ctz_(__ctz) {
458 _LIBCPP_ASSERT_INTERNAL(
459 __ctz_ < __bits_per_word, "__bit_iterator initialized with an invalid number of trailing zeros.");
460 }
972461
973 friend typename _Cp::__self;462 friend typename _Cp::__self;
974463
...@@ -989,38 +478,59 @@ private:...@@ -989,38 +478,59 @@ private:
989 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned(478 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_unaligned(
990 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);479 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);
991 template <class _Dp, bool _IC>480 template <class _Dp, bool _IC>
992 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false>481 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, _IC>, __bit_iterator<_Dp, false> >
993 copy(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);482 __copy_impl::operator()(
483 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result) const;
994 template <class _Dp, bool _IC>484 template <class _Dp, bool _IC>
995 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned(485 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_aligned(
996 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);486 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);
997 template <class _Dp, bool _IC>487 template <class _Dp, bool _IC>
998 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(488 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_backward_unaligned(
999 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);489 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);
1000 template <class _Dp, bool _IC>490 template <class _AlgPolicy>
1001 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false>491 friend struct __copy_backward_impl;
1002 copy_backward(__bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);
1003 template <class _Cl, class _Cr>492 template <class _Cl, class _Cr>
1004 friend __bit_iterator<_Cr, false>493 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false>
1005 __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);494 __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
1006 template <class _Cl, class _Cr>495 template <class _Cl, class _Cr>
1007 friend __bit_iterator<_Cr, false>496 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false>
1008 __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);497 __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
1009 template <class _Cl, class _Cr>498 template <class, class _Cl, class _Cr>
1010 friend __bit_iterator<_Cr, false>499 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> >
1011 swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);500 __swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
1012 template <class _Dp>501 template <class, class _Dp>
1013 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false>502 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false> >
1014 rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>);503 __rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>);
1015 template <class _Dp, bool _IC1, bool _IC2>504 template <class _Dp, bool _IsConst1, bool _IsConst2>
1016 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
1017 __equal_aligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>);
1018 template <class _Dp, bool _IC1, bool _IC2>
1019 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool505 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
1020 __equal_unaligned(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>);506 __equal_aligned(__bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>);
1021 template <class _Dp, bool _IC1, bool _IC2>507 template <class _Dp, bool _IsConst1, bool _IsConst2>
1022 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool508 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
1023 equal(__bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC1>, __bit_iterator<_Dp, _IC2>);509 __equal_unaligned(__bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>);
510 template <class _Dp,
511 bool _IsConst1,
512 bool _IsConst2,
513 class _BinaryPredicate,
514 __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, bool, bool>, int> >
515 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_iter_impl(
516 __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst1>, __bit_iterator<_Dp, _IsConst2>, _BinaryPredicate);
517 template <class _Dp,
518 bool _IsConst1,
519 bool _IsConst2,
520 class _Pred,
521 class _Proj1,
522 class _Proj2,
523 __enable_if_t<__desugars_to_v<__equal_tag, _Pred, bool, bool> && __is_identity<_Proj1>::value &&
524 __is_identity<_Proj2>::value,
525 int> >
526 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool __equal_impl(
527 __bit_iterator<_Dp, _IsConst1> __first1,
528 __bit_iterator<_Dp, _IsConst1> __last1,
529 __bit_iterator<_Dp, _IsConst2> __first2,
530 __bit_iterator<_Dp, _IsConst2>,
531 _Pred&,
532 _Proj1&,
533 _Proj2&);
1024 template <bool _ToFind, class _Dp, bool _IC>534 template <bool _ToFind, class _Dp, bool _IC>
1025 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC>535 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC>
1026 __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type);536 __find_bool(__bit_iterator<_Dp, _IC>, typename __size_difference_type_traits<_Dp>::size_type);
lib/libcxx/include/__charconv/tables.h+8-12
...@@ -19,16 +19,14 @@...@@ -19,16 +19,14 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if _LIBCPP_STD_VER >= 17
23
24namespace __itoa {22namespace __itoa {
2523
26inline constexpr char __base_2_lut[64] = {24inline _LIBCPP_CONSTEXPR const char __base_2_lut[64] = {
27 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',25 '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',
28 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',26 '0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',
29 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};27 '1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};
3028
31inline constexpr char __base_8_lut[128] = {29inline _LIBCPP_CONSTEXPR const char __base_8_lut[128] = {
32 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',30 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',
33 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',31 '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',
34 '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',32 '2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',
...@@ -36,7 +34,7 @@ inline constexpr char __base_8_lut[128] = {...@@ -36,7 +34,7 @@ inline constexpr char __base_8_lut[128] = {
36 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',34 '5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',
37 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};35 '6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};
3836
39inline constexpr char __base_16_lut[512] = {37inline _LIBCPP_CONSTEXPR const char __base_16_lut[512] = {
40 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',38 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',
41 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',39 'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',
42 '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',40 '1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',
...@@ -61,7 +59,7 @@ inline constexpr char __base_16_lut[512] = {...@@ -61,7 +59,7 @@ inline constexpr char __base_16_lut[512] = {
61 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',59 '1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',
62 'f', 'd', 'f', 'e', 'f', 'f'};60 'f', 'd', 'f', 'e', 'f', 'f'};
6361
64inline constexpr uint32_t __pow10_32[10] = {62inline _LIBCPP_CONSTEXPR const uint32_t __pow10_32[10] = {
65 UINT32_C(0),63 UINT32_C(0),
66 UINT32_C(10),64 UINT32_C(10),
67 UINT32_C(100),65 UINT32_C(100),
...@@ -73,7 +71,7 @@ inline constexpr uint32_t __pow10_32[10] = {...@@ -73,7 +71,7 @@ inline constexpr uint32_t __pow10_32[10] = {
73 UINT32_C(100000000),71 UINT32_C(100000000),
74 UINT32_C(1000000000)};72 UINT32_C(1000000000)};
7573
76inline constexpr uint64_t __pow10_64[20] = {74inline _LIBCPP_CONSTEXPR const uint64_t __pow10_64[20] = {
77 UINT64_C(0),75 UINT64_C(0),
78 UINT64_C(10),76 UINT64_C(10),
79 UINT64_C(100),77 UINT64_C(100),
...@@ -96,8 +94,8 @@ inline constexpr uint64_t __pow10_64[20] = {...@@ -96,8 +94,8 @@ inline constexpr uint64_t __pow10_64[20] = {
96 UINT64_C(10000000000000000000)};94 UINT64_C(10000000000000000000)};
9795
98# if _LIBCPP_HAS_INT12896# if _LIBCPP_HAS_INT128
99inline constexpr int __pow10_128_offset = 0;97inline _LIBCPP_CONSTEXPR const int __pow10_128_offset = 0;
100inline constexpr __uint128_t __pow10_128[40] = {98inline _LIBCPP_CONSTEXPR const __uint128_t __pow10_128[40] = {
101 UINT64_C(0),99 UINT64_C(0),
102 UINT64_C(10),100 UINT64_C(10),
103 UINT64_C(100),101 UINT64_C(100),
...@@ -140,7 +138,7 @@ inline constexpr __uint128_t __pow10_128[40] = {...@@ -140,7 +138,7 @@ inline constexpr __uint128_t __pow10_128[40] = {
140 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};138 (__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};
141# endif139# endif
142140
143inline constexpr char __digits_base_10[200] = {141inline _LIBCPP_CONSTEXPR const char __digits_base_10[200] = {
144 // clang-format off142 // clang-format off
145 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',143 '0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',
146 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',144 '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',
...@@ -156,8 +154,6 @@ inline constexpr char __digits_base_10[200] = {...@@ -156,8 +154,6 @@ inline constexpr char __digits_base_10[200] = {
156154
157} // namespace __itoa155} // namespace __itoa
158156
159#endif // _LIBCPP_STD_VER >= 17
160
161_LIBCPP_END_NAMESPACE_STD157_LIBCPP_END_NAMESPACE_STD
162158
163#endif // _LIBCPP___CHARCONV_TABLES159#endif // _LIBCPP___CHARCONV_TABLES
lib/libcxx/include/__charconv/to_chars_base_10.h+14-18
...@@ -26,55 +26,53 @@ _LIBCPP_PUSH_MACROS...@@ -26,55 +26,53 @@ _LIBCPP_PUSH_MACROS
2626
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29#if _LIBCPP_STD_VER >= 17
30
31namespace __itoa {29namespace __itoa {
3230
33_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) noexcept {31_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append1(char* __first, uint32_t __value) _NOEXCEPT {
34 *__first = '0' + static_cast<char>(__value);32 *__first = '0' + static_cast<char>(__value);
35 return __first + 1;33 return __first + 1;
36}34}
3735
38_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) noexcept {36_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append2(char* __first, uint32_t __value) _NOEXCEPT {
39 return std::copy_n(&__digits_base_10[__value * 2], 2, __first);37 return std::copy_n(&__digits_base_10[__value * 2], 2, __first);
40}38}
4139
42_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) noexcept {40_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append3(char* __first, uint32_t __value) _NOEXCEPT {
43 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);41 return __itoa::__append2(__itoa::__append1(__first, __value / 100), __value % 100);
44}42}
4543
46_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) noexcept {44_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append4(char* __first, uint32_t __value) _NOEXCEPT {
47 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);45 return __itoa::__append2(__itoa::__append2(__first, __value / 100), __value % 100);
48}46}
4947
50_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) noexcept {48_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append5(char* __first, uint32_t __value) _NOEXCEPT {
51 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);49 return __itoa::__append4(__itoa::__append1(__first, __value / 10000), __value % 10000);
52}50}
5351
54_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) noexcept {52_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append6(char* __first, uint32_t __value) _NOEXCEPT {
55 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);53 return __itoa::__append4(__itoa::__append2(__first, __value / 10000), __value % 10000);
56}54}
5755
58_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) noexcept {56_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append7(char* __first, uint32_t __value) _NOEXCEPT {
59 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);57 return __itoa::__append6(__itoa::__append1(__first, __value / 1000000), __value % 1000000);
60}58}
6159
62_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) noexcept {60_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append8(char* __first, uint32_t __value) _NOEXCEPT {
63 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);61 return __itoa::__append6(__itoa::__append2(__first, __value / 1000000), __value % 1000000);
64}62}
6563
66_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) noexcept {64_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char* __append9(char* __first, uint32_t __value) _NOEXCEPT {
67 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);65 return __itoa::__append8(__itoa::__append1(__first, __value / 100000000), __value % 100000000);
68}66}
6967
70template <class _Tp>68template <class _Tp>
71_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) noexcept {69_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI char* __append10(char* __first, _Tp __value) _NOEXCEPT {
72 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),70 return __itoa::__append8(__itoa::__append2(__first, static_cast<uint32_t>(__value / 100000000)),
73 static_cast<uint32_t>(__value % 100000000));71 static_cast<uint32_t>(__value % 100000000));
74}72}
7573
76_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*74_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
77__base_10_u32(char* __first, uint32_t __value) noexcept {75__base_10_u32(char* __first, uint32_t __value) _NOEXCEPT {
78 if (__value < 1000000) {76 if (__value < 1000000) {
79 if (__value < 10000) {77 if (__value < 10000) {
80 if (__value < 100) {78 if (__value < 100) {
...@@ -110,7 +108,7 @@ __base_10_u32(char* __first, uint32_t __value) noexcept {...@@ -110,7 +108,7 @@ __base_10_u32(char* __first, uint32_t __value) noexcept {
110}108}
111109
112_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*110_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
113__base_10_u64(char* __buffer, uint64_t __value) noexcept {111__base_10_u64(char* __buffer, uint64_t __value) _NOEXCEPT {
114 if (__value <= UINT32_MAX)112 if (__value <= UINT32_MAX)
115 return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));113 return __itoa::__base_10_u32(__buffer, static_cast<uint32_t>(__value));
116114
...@@ -132,13 +130,13 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {...@@ -132,13 +130,13 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept {
132/// \note The lookup table contains a partial set of exponents limiting the130/// \note The lookup table contains a partial set of exponents limiting the
133/// range that can be used. However the range is sufficient for131/// range that can be used. However the range is sufficient for
134/// \ref __base_10_u128.132/// \ref __base_10_u128.
135_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) noexcept {133_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline __uint128_t __pow_10(int __exp) _NOEXCEPT {
136 _LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds");134 _LIBCPP_ASSERT_INTERNAL(__exp >= __pow10_128_offset, "Index out of bounds");
137 return __pow10_128[__exp - __pow10_128_offset];135 return __pow10_128[__exp - __pow10_128_offset];
138}136}
139137
140_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*138_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI inline char*
141__base_10_u128(char* __buffer, __uint128_t __value) noexcept {139__base_10_u128(char* __buffer, __uint128_t __value) _NOEXCEPT {
142 _LIBCPP_ASSERT_INTERNAL(140 _LIBCPP_ASSERT_INTERNAL(
143 __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true.");141 __value > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fails when this isn't true.");
144142
...@@ -179,8 +177,6 @@ __base_10_u128(char* __buffer, __uint128_t __value) noexcept {...@@ -179,8 +177,6 @@ __base_10_u128(char* __buffer, __uint128_t __value) noexcept {
179# endif177# endif
180} // namespace __itoa178} // namespace __itoa
181179
182#endif // _LIBCPP_STD_VER >= 17
183
184_LIBCPP_END_NAMESPACE_STD180_LIBCPP_END_NAMESPACE_STD
185181
186_LIBCPP_POP_MACROS182_LIBCPP_POP_MACROS
lib/libcxx/include/__charconv/to_chars_integral.h+51-36
...@@ -39,16 +39,12 @@ _LIBCPP_PUSH_MACROS...@@ -39,16 +39,12 @@ _LIBCPP_PUSH_MACROS
3939
40_LIBCPP_BEGIN_NAMESPACE_STD40_LIBCPP_BEGIN_NAMESPACE_STD
4141
42#if _LIBCPP_STD_VER >= 17
43
44to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
45
46template <typename _Tp>42template <typename _Tp>
47inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result43inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
48__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type);44__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type);
4945
50template <typename _Tp>46template <typename _Tp>
51inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result47inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
52__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {48__to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {
53 auto __x = std::__to_unsigned_like(__value);49 auto __x = std::__to_unsigned_like(__value);
54 if (__value < 0 && __first != __last) {50 if (__value < 0 && __first != __last) {
...@@ -60,7 +56,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {...@@ -60,7 +56,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, true_type) {
60}56}
6157
62template <typename _Tp>58template <typename _Tp>
63inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result59inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
64__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {60__to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
65 using __tx = __itoa::__traits<_Tp>;61 using __tx = __itoa::__traits<_Tp>;
66 auto __diff = __last - __first;62 auto __diff = __last - __first;
...@@ -73,7 +69,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {...@@ -73,7 +69,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) {
7369
74# if _LIBCPP_HAS_INT12870# if _LIBCPP_HAS_INT128
75template <>71template <>
76inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result72inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
77__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {73__to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
78 // When the value fits in 64-bits use the 64-bit code path. This reduces74 // When the value fits in 64-bits use the 64-bit code path. This reduces
79 // the number of expensive calculations on 128-bit values.75 // the number of expensive calculations on 128-bit values.
...@@ -92,20 +88,20 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {...@@ -92,20 +88,20 @@ __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) {
92}88}
93# endif89# endif
9490
95template <class _Tp>91template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> = 0>
96inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result92inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
97__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type);93__to_chars_integral(char* __first, char* __last, _Tp __value, int __base);
9894
99template <typename _Tp>95template <class _Tp, __enable_if_t<is_signed<_Tp>::value, int> = 0>
100inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result96inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
101__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, true_type) {97__to_chars_integral(char* __first, char* __last, _Tp __value, int __base) {
102 auto __x = std::__to_unsigned_like(__value);98 auto __x = std::__to_unsigned_like(__value);
103 if (__value < 0 && __first != __last) {99 if (__value < 0 && __first != __last) {
104 *__first++ = '-';100 *__first++ = '-';
105 __x = std::__complement(__x);101 __x = std::__complement(__x);
106 }102 }
107103
108 return std::__to_chars_integral(__first, __last, __x, __base, false_type());104 return std::__to_chars_integral(__first, __last, __x, __base);
109}105}
110106
111namespace __itoa {107namespace __itoa {
...@@ -116,15 +112,14 @@ struct _LIBCPP_HIDDEN __integral;...@@ -116,15 +112,14 @@ struct _LIBCPP_HIDDEN __integral;
116template <>112template <>
117struct _LIBCPP_HIDDEN __integral<2> {113struct _LIBCPP_HIDDEN __integral<2> {
118 template <typename _Tp>114 template <typename _Tp>
119 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {115 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
120 // If value == 0 still need one digit. If the value != this has no116 // If value == 0 still need one digit. If the value != this has no
121 // effect since the code scans for the most significant bit set. (Note117 // effect since the code scans for the most significant bit set.
122 // that __libcpp_clz doesn't work for 0.)118 return numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1);
123 return numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1);
124 }119 }
125120
126 template <typename _Tp>121 template <typename _Tp>
127 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result122 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
128 __to_chars(char* __first, char* __last, _Tp __value) {123 __to_chars(char* __first, char* __last, _Tp __value) {
129 ptrdiff_t __cap = __last - __first;124 ptrdiff_t __cap = __last - __first;
130 int __n = __width(__value);125 int __n = __width(__value);
...@@ -152,15 +147,14 @@ struct _LIBCPP_HIDDEN __integral<2> {...@@ -152,15 +147,14 @@ struct _LIBCPP_HIDDEN __integral<2> {
152template <>147template <>
153struct _LIBCPP_HIDDEN __integral<8> {148struct _LIBCPP_HIDDEN __integral<8> {
154 template <typename _Tp>149 template <typename _Tp>
155 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {150 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
156 // If value == 0 still need one digit. If the value != this has no151 // If value == 0 still need one digit. If the value != this has no
157 // effect since the code scans for the most significat bit set. (Note152 // effect since the code scans for the most significat bit set.
158 // that __libcpp_clz doesn't work for 0.)153 return ((numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1)) + 2) / 3;
159 return ((numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1)) + 2) / 3;
160 }154 }
161155
162 template <typename _Tp>156 template <typename _Tp>
163 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result157 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
164 __to_chars(char* __first, char* __last, _Tp __value) {158 __to_chars(char* __first, char* __last, _Tp __value) {
165 ptrdiff_t __cap = __last - __first;159 ptrdiff_t __cap = __last - __first;
166 int __n = __width(__value);160 int __n = __width(__value);
...@@ -188,15 +182,14 @@ struct _LIBCPP_HIDDEN __integral<8> {...@@ -188,15 +182,14 @@ struct _LIBCPP_HIDDEN __integral<8> {
188template <>182template <>
189struct _LIBCPP_HIDDEN __integral<16> {183struct _LIBCPP_HIDDEN __integral<16> {
190 template <typename _Tp>184 template <typename _Tp>
191 _LIBCPP_HIDE_FROM_ABI static constexpr int __width(_Tp __value) noexcept {185 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int __width(_Tp __value) _NOEXCEPT {
192 // If value == 0 still need one digit. If the value != this has no186 // If value == 0 still need one digit. If the value != this has no
193 // effect since the code scans for the most significat bit set. (Note187 // effect since the code scans for the most significat bit set.
194 // that __libcpp_clz doesn't work for 0.)188 return (numeric_limits<_Tp>::digits - std::__countl_zero(__value | 1) + 3) / 4;
195 return (numeric_limits<_Tp>::digits - std::__libcpp_clz(__value | 1) + 3) / 4;
196 }189 }
197190
198 template <typename _Tp>191 template <typename _Tp>
199 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static to_chars_result192 _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI static __to_chars_result
200 __to_chars(char* __first, char* __last, _Tp __value) {193 __to_chars(char* __first, char* __last, _Tp __value) {
201 ptrdiff_t __cap = __last - __first;194 ptrdiff_t __cap = __last - __first;
202 int __n = __width(__value);195 int __n = __width(__value);
...@@ -235,13 +228,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt...@@ -235,13 +228,13 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt
235}228}
236229
237template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0>230template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) >= sizeof(unsigned)), int> = 0>
238_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result231_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
239__to_chars_integral(char* __first, char* __last, _Tp __value) {232__to_chars_integral(char* __first, char* __last, _Tp __value) {
240 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);233 return __itoa::__integral<_Base>::__to_chars(__first, __last, __value);
241}234}
242235
243template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0>236template <unsigned _Base, typename _Tp, __enable_if_t<(sizeof(_Tp) < sizeof(unsigned)), int> = 0>
244_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result237_LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
245__to_chars_integral(char* __first, char* __last, _Tp __value) {238__to_chars_integral(char* __first, char* __last, _Tp __value) {
246 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));239 return std::__to_chars_integral<_Base>(__first, __last, static_cast<unsigned>(__value));
247}240}
...@@ -272,9 +265,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt...@@ -272,9 +265,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt
272 __libcpp_unreachable();265 __libcpp_unreachable();
273}266}
274267
275template <typename _Tp>268template <class _Tp, __enable_if_t<!is_signed<_Tp>::value, int> >
276inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result269inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI __to_chars_result
277__to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) {270__to_chars_integral(char* __first, char* __last, _Tp __value, int __base) {
278 if (__base == 10) [[likely]]271 if (__base == 10) [[likely]]
279 return std::__to_chars_itoa(__first, __last, __value, false_type());272 return std::__to_chars_itoa(__first, __last, __value, false_type());
280273
...@@ -302,6 +295,28 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_...@@ -302,6 +295,28 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_
302 return {__last, errc(0)};295 return {__last, errc(0)};
303}296}
304297
298_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 char __hex_to_upper(char __c) {
299 switch (__c) {
300 case 'a':
301 return 'A';
302 case 'b':
303 return 'B';
304 case 'c':
305 return 'C';
306 case 'd':
307 return 'D';
308 case 'e':
309 return 'E';
310 case 'f':
311 return 'F';
312 }
313 return __c;
314}
315
316#if _LIBCPP_STD_VER >= 17
317
318to_chars_result to_chars(char*, char*, bool, int = 10) = delete;
319
305template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>320template <typename _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
306inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result321inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
307to_chars(char* __first, char* __last, _Tp __value) {322to_chars(char* __first, char* __last, _Tp __value) {
...@@ -316,7 +331,7 @@ to_chars(char* __first, char* __last, _Tp __value, int __base) {...@@ -316,7 +331,7 @@ to_chars(char* __first, char* __last, _Tp __value, int __base) {
316 _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]");331 _LIBCPP_ASSERT_UNCATEGORIZED(2 <= __base && __base <= 36, "base not in [2, 36]");
317332
318 using _Type = __make_32_64_or_128_bit_t<_Tp>;333 using _Type = __make_32_64_or_128_bit_t<_Tp>;
319 return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base, is_signed<_Tp>());334 return std::__to_chars_integral(__first, __last, static_cast<_Type>(__value), __base);
320}335}
321336
322#endif // _LIBCPP_STD_VER >= 17337#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__charconv/to_chars_result.h+9
...@@ -34,6 +34,15 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {...@@ -34,6 +34,15 @@ struct _LIBCPP_EXPORTED_FROM_ABI to_chars_result {
3434
35#endif // _LIBCPP_STD_VER >= 1735#endif // _LIBCPP_STD_VER >= 17
3636
37struct __to_chars_result {
38 char* __ptr;
39 errc __ec;
40
41#if _LIBCPP_STD_VER >= 17
42 _LIBCPP_HIDE_FROM_ABI constexpr operator to_chars_result() { return {__ptr, __ec}; }
43#endif
44};
45
37_LIBCPP_END_NAMESPACE_STD46_LIBCPP_END_NAMESPACE_STD
3847
39#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H48#endif // _LIBCPP___CHARCONV_TO_CHARS_RESULT_H
lib/libcxx/include/__charconv/traits.h+11-23
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__charconv/tables.h>15#include <__charconv/tables.h>
16#include <__charconv/to_chars_base_10.h>16#include <__charconv/to_chars_base_10.h>
17#include <__config>17#include <__config>
18#include <__memory/addressof.h>
18#include <__type_traits/enable_if.h>19#include <__type_traits/enable_if.h>
19#include <__type_traits/is_unsigned.h>20#include <__type_traits/is_unsigned.h>
20#include <cstdint>21#include <cstdint>
...@@ -29,27 +30,22 @@ _LIBCPP_PUSH_MACROS...@@ -29,27 +30,22 @@ _LIBCPP_PUSH_MACROS
2930
30_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3132
32#if _LIBCPP_STD_VER >= 17
33
34namespace __itoa {33namespace __itoa {
3534
36template <typename _Tp, typename = void>35template <typename _Tp, typename = void>
37struct _LIBCPP_HIDDEN __traits_base;36struct _LIBCPP_HIDDEN __traits_base;
3837
39template <typename _Tp>38template <typename _Tp>
40struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)>> {39struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uint32_t)> > {
41 using type = uint32_t;40 using type = uint32_t;
4241
43 /// The width estimation using a log10 algorithm.42 /// The width estimation using a log10 algorithm.
44 ///43 ///
45 /// The algorithm is based on44 /// The algorithm is based on
46 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog1045 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
47 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that46 /// Instead of using IntegerLogBase2 it uses __countl_zero.
48 /// function requires its input to have at least one bit set the value of
49 /// zero is set to one. This means the first element of the lookup table is
50 /// zero.
51 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {47 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
52 auto __t = (32 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;48 auto __t = (32 - std::__countl_zero(static_cast<type>(__v | 1))) * 1233 >> 12;
53 return __t - (__v < __itoa::__pow10_32[__t]) + 1;49 return __t - (__v < __itoa::__pow10_32[__t]) + 1;
54 }50 }
5551
...@@ -63,19 +59,16 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin...@@ -63,19 +59,16 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) <= sizeof(uin
63};59};
6460
65template <typename _Tp>61template <typename _Tp>
66struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)>> {62struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(uint64_t)> > {
67 using type = uint64_t;63 using type = uint64_t;
6864
69 /// The width estimation using a log10 algorithm.65 /// The width estimation using a log10 algorithm.
70 ///66 ///
71 /// The algorithm is based on67 /// The algorithm is based on
72 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog1068 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
73 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that69 /// Instead of using IntegerLogBase2 it uses __countl_zero.
74 /// function requires its input to have at least one bit set the value of
75 /// zero is set to one. This means the first element of the lookup table is
76 /// zero.
77 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {70 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
78 auto __t = (64 - std::__libcpp_clz(static_cast<type>(__v | 1))) * 1233 >> 12;71 auto __t = (64 - std::__countl_zero(static_cast<type>(__v | 1))) * 1233 >> 12;
79 return __t - (__v < __itoa::__pow10_64[__t]) + 1;72 return __t - (__v < __itoa::__pow10_64[__t]) + 1;
80 }73 }
8174
...@@ -97,15 +90,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u...@@ -97,15 +90,12 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__u
97 ///90 ///
98 /// The algorithm is based on91 /// The algorithm is based on
99 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog1092 /// http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10
100 /// Instead of using IntegerLogBase2 it uses __libcpp_clz. Since that93 /// Instead of using IntegerLogBase2 it uses __countl_zero.
101 /// function requires its input to have at least one bit set the value of
102 /// zero is set to one. This means the first element of the lookup table is
103 /// zero.
104 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {94 static _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __width(_Tp __v) {
105 _LIBCPP_ASSERT_INTERNAL(95 _LIBCPP_ASSERT_INTERNAL(
106 __v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");96 __v > numeric_limits<uint64_t>::max(), "The optimizations for this algorithm fail when this isn't true.");
107 // There's always a bit set in the upper 64-bits.97 // There's always a bit set in the upper 64-bits.
108 auto __t = (128 - std::__libcpp_clz(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;98 auto __t = (128 - std::__countl_zero(static_cast<uint64_t>(__v >> 64))) * 1233 >> 12;
109 _LIBCPP_ASSERT_INTERNAL(__t >= __itoa::__pow10_128_offset, "Index out of bounds");99 _LIBCPP_ASSERT_INTERNAL(__t >= __itoa::__pow10_128_offset, "Index out of bounds");
110 // __t is adjusted since the lookup table misses the lower entries.100 // __t is adjusted since the lookup table misses the lower entries.
111 return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1;101 return __t - (__v < __itoa::__pow10_128[__t - __itoa::__pow10_128_offset]) + 1;
...@@ -142,7 +132,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) {...@@ -142,7 +132,7 @@ __mul_overflowed(unsigned short __a, _Tp __b, unsigned short& __r) {
142template <typename _Tp>132template <typename _Tp>
143inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) {133inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r) {
144 static_assert(is_unsigned<_Tp>::value, "");134 static_assert(is_unsigned<_Tp>::value, "");
145 return __builtin_mul_overflow(__a, __b, &__r);135 return __builtin_mul_overflow(__a, __b, std::addressof(__r));
146}136}
147137
148template <typename _Tp, typename _Up>138template <typename _Tp, typename _Up>
...@@ -152,7 +142,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed...@@ -152,7 +142,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX23 __mul_overflowed
152142
153template <typename _Tp>143template <typename _Tp>
154struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> {144struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp> {
155 static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;145 static _LIBCPP_CONSTEXPR const int digits = numeric_limits<_Tp>::digits10 + 1;
156 using __traits_base<_Tp>::__pow;146 using __traits_base<_Tp>::__pow;
157 using typename __traits_base<_Tp>::type;147 using typename __traits_base<_Tp>::type;
158148
...@@ -191,8 +181,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp __complement(_Tp...@@ -191,8 +181,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _Tp __complement(_Tp
191 return _Tp(~__x + 1);181 return _Tp(~__x + 1);
192}182}
193183
194#endif // _LIBCPP_STD_VER >= 17
195
196_LIBCPP_END_NAMESPACE_STD184_LIBCPP_END_NAMESPACE_STD
197185
198_LIBCPP_POP_MACROS186_LIBCPP_POP_MACROS
lib/libcxx/include/__chrono/convert_to_tm.h+24-10
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__chrono/day.h>15#include <__chrono/day.h>
16#include <__chrono/duration.h>16#include <__chrono/duration.h>
17#include <__chrono/file_clock.h>17#include <__chrono/file_clock.h>
18#include <__chrono/gps_clock.h>
18#include <__chrono/hh_mm_ss.h>19#include <__chrono/hh_mm_ss.h>
19#include <__chrono/local_info.h>20#include <__chrono/local_info.h>
20#include <__chrono/month.h>21#include <__chrono/month.h>
...@@ -23,6 +24,7 @@...@@ -23,6 +24,7 @@
23#include <__chrono/statically_widen.h>24#include <__chrono/statically_widen.h>
24#include <__chrono/sys_info.h>25#include <__chrono/sys_info.h>
25#include <__chrono/system_clock.h>26#include <__chrono/system_clock.h>
27#include <__chrono/tai_clock.h>
26#include <__chrono/time_point.h>28#include <__chrono/time_point.h>
27#include <__chrono/utc_clock.h>29#include <__chrono/utc_clock.h>
28#include <__chrono/weekday.h>30#include <__chrono/weekday.h>
...@@ -35,6 +37,7 @@...@@ -35,6 +37,7 @@
35#include <__config>37#include <__config>
36#include <__format/format_error.h>38#include <__format/format_error.h>
37#include <__memory/addressof.h>39#include <__memory/addressof.h>
40#include <__type_traits/common_type.h>
38#include <__type_traits/is_convertible.h>41#include <__type_traits/is_convertible.h>
39#include <__type_traits/is_specialization.h>42#include <__type_traits/is_specialization.h>
40#include <cstdint>43#include <cstdint>
...@@ -112,6 +115,21 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) {...@@ -112,6 +115,21 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::utc_time<_Duration> __tp) {
112 return __result;115 return __result;
113}116}
114117
118template <class _Tm, class _Duration>
119_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::tai_time<_Duration> __tp) {
120 using _Rp = common_type_t<_Duration, chrono::seconds>;
121 // The time between the TAI epoch (1958-01-01) and UNIX epoch (1970-01-01).
122 // This avoids leap second conversion when going from TAI to UTC.
123 // (It also avoids issues when the date is before the UTC epoch.)
124 constexpr chrono::seconds __offset{4383 * 24 * 60 * 60};
125 return std::__convert_to_tm<_Tm>(chrono::sys_time<_Rp>{__tp.time_since_epoch() - __offset});
126}
127
128template <class _Tm, class _Duration>
129_LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::gps_time<_Duration> __tp) {
130 return std::__convert_to_tm<_Tm>(chrono::utc_clock::to_sys(chrono::gps_clock::to_utc(__tp)));
131}
132
115# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB133# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
116# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION134# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
117135
...@@ -125,20 +143,16 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {...@@ -125,20 +143,16 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
125# endif143# endif
126144
127 if constexpr (__is_time_point<_ChronoT>) {145 if constexpr (__is_time_point<_ChronoT>) {
128 if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)146 if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
129 return std::__convert_to_tm<_Tm>(__value);
130# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
131# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
132 else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>)
133 return std::__convert_to_tm<_Tm>(__value);
134# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
135# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
136 else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
137 return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));147 return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));
138 else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)148 else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)
139 return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});149 return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});
140 else150 else {
151 // Note that some clocks have specializations __convert_to_tm for their
152 // time_point. These don't need to be added here. They do not trigger
153 // this assert.
141 static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");154 static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");
155 }
142 } else if constexpr (chrono::__is_duration_v<_ChronoT>) {156 } else if constexpr (chrono::__is_duration_v<_ChronoT>) {
143 // [time.format]/6157 // [time.format]/6
144 // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,158 // ... However, if a flag refers to a "time of day" (e.g. %H, %I, %p,
lib/libcxx/include/__chrono/duration.h+5-5
...@@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -32,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
32namespace chrono {32namespace chrono {
3333
34template <class _Rep, class _Period = ratio<1> >34template <class _Rep, class _Period = ratio<1> >
35class _LIBCPP_TEMPLATE_VIS duration;35class duration;
3636
37template <class _Tp>37template <class _Tp>
38inline const bool __is_duration_v = false;38inline const bool __is_duration_v = false;
...@@ -52,7 +52,7 @@ inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = tru...@@ -52,7 +52,7 @@ inline const bool __is_duration_v<const volatile duration<_Rep, _Period> > = tru
52} // namespace chrono52} // namespace chrono
5353
54template <class _Rep1, class _Period1, class _Rep2, class _Period2>54template <class _Rep1, class _Period1, class _Rep2, class _Period2>
55struct _LIBCPP_TEMPLATE_VIS common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {55struct common_type<chrono::duration<_Rep1, _Period1>, chrono::duration<_Rep2, _Period2> > {
56 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type;56 typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, __ratio_gcd<_Period1, _Period2> > type;
57};57};
5858
...@@ -107,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d...@@ -107,7 +107,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration duration_cast(const d
107}107}
108108
109template <class _Rep>109template <class _Rep>
110struct _LIBCPP_TEMPLATE_VIS treat_as_floating_point : is_floating_point<_Rep> {};110struct treat_as_floating_point : is_floating_point<_Rep> {};
111111
112#if _LIBCPP_STD_VER >= 17112#if _LIBCPP_STD_VER >= 17
113template <class _Rep>113template <class _Rep>
...@@ -115,7 +115,7 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>:...@@ -115,7 +115,7 @@ inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<_Rep>:
115#endif115#endif
116116
117template <class _Rep>117template <class _Rep>
118struct _LIBCPP_TEMPLATE_VIS duration_values {118struct duration_values {
119public:119public:
120 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); }120 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep zero() _NOEXCEPT { return _Rep(0); }
121 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); }121 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR _Rep max() _NOEXCEPT { return numeric_limits<_Rep>::max(); }
...@@ -156,7 +156,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<...@@ -156,7 +156,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ToDuration round(const duration<
156// duration156// duration
157157
158template <class _Rep, class _Period>158template <class _Rep, class _Period>
159class _LIBCPP_TEMPLATE_VIS duration {159class duration {
160 static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");160 static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");
161 static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");161 static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");
162 static_assert(_Period::num > 0, "duration period must be positive");162 static_assert(_Period::num > 0, "duration period must be positive");
lib/libcxx/include/__chrono/formatter.h+54-24
...@@ -21,6 +21,7 @@...@@ -21,6 +21,7 @@
21# include <__chrono/day.h>21# include <__chrono/day.h>
22# include <__chrono/duration.h>22# include <__chrono/duration.h>
23# include <__chrono/file_clock.h>23# include <__chrono/file_clock.h>
24# include <__chrono/gps_clock.h>
24# include <__chrono/hh_mm_ss.h>25# include <__chrono/hh_mm_ss.h>
25# include <__chrono/local_info.h>26# include <__chrono/local_info.h>
26# include <__chrono/month.h>27# include <__chrono/month.h>
...@@ -31,6 +32,7 @@...@@ -31,6 +32,7 @@
31# include <__chrono/statically_widen.h>32# include <__chrono/statically_widen.h>
32# include <__chrono/sys_info.h>33# include <__chrono/sys_info.h>
33# include <__chrono/system_clock.h>34# include <__chrono/system_clock.h>
35# include <__chrono/tai_clock.h>
34# include <__chrono/time_point.h>36# include <__chrono/time_point.h>
35# include <__chrono/utc_clock.h>37# include <__chrono/utc_clock.h>
36# include <__chrono/weekday.h>38# include <__chrono/weekday.h>
...@@ -48,12 +50,14 @@...@@ -48,12 +50,14 @@
48# include <__format/formatter.h>50# include <__format/formatter.h>
49# include <__format/parser_std_format_spec.h>51# include <__format/parser_std_format_spec.h>
50# include <__format/write_escaped.h>52# include <__format/write_escaped.h>
53# include <__iterator/istreambuf_iterator.h>
54# include <__iterator/ostreambuf_iterator.h>
55# include <__locale_dir/time.h>
51# include <__memory/addressof.h>56# include <__memory/addressof.h>
52# include <__type_traits/is_specialization.h>57# include <__type_traits/is_specialization.h>
53# include <cmath>58# include <cmath>
54# include <ctime>59# include <ctime>
55# include <limits>60# include <limits>
56# include <locale>
57# include <sstream>61# include <sstream>
58# include <string_view>62# include <string_view>
5963
...@@ -232,9 +236,13 @@ _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const...@@ -232,9 +236,13 @@ _LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const
232 if constexpr (same_as<_Tp, chrono::sys_info>)236 if constexpr (same_as<_Tp, chrono::sys_info>)
233 return {__value.abbrev, __value.offset};237 return {__value.abbrev, __value.offset};
234# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM238# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
239 else if constexpr (__is_time_point<_Tp> && requires { requires same_as<typename _Tp::clock, chrono::tai_clock>; })
240 return {"TAI", chrono::seconds{0}};
241 else if constexpr (__is_time_point<_Tp> && requires { requires same_as<typename _Tp::clock, chrono::gps_clock>; })
242 return {"GPS", chrono::seconds{0}};
235 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)243 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
236 return __formatter::__convert_to_time_zone(__value.get_info());244 return __formatter::__convert_to_time_zone(__value.get_info());
237# endif245# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
238 else246 else
239# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB247# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
240 return {"UTC", chrono::seconds{0}};248 return {"UTC", chrono::seconds{0}};
...@@ -312,7 +320,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -312,7 +320,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
312 case _CharT('T'):320 case _CharT('T'):
313 __facet.put(321 __facet.put(
314 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));322 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
315 if constexpr (__use_fraction<_Tp>())323 if constexpr (__formatter::__use_fraction<_Tp>())
316 __formatter::__format_sub_seconds(__sstr, __value);324 __formatter::__format_sub_seconds(__sstr, __value);
317 break;325 break;
318326
...@@ -375,7 +383,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(...@@ -375,7 +383,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
375 break;383 break;
376384
377 case _CharT('O'):385 case _CharT('O'):
378 if constexpr (__use_fraction<_Tp>()) {386 if constexpr (__formatter::__use_fraction<_Tp>()) {
379 // Handle OS using the normal representation for the non-fractional387 // Handle OS using the normal representation for the non-fractional
380 // part. There seems to be no locale information regarding how the388 // part. There seems to be no locale information regarding how the
381 // fractional part should be formatted.389 // fractional part should be formatted.
...@@ -692,7 +700,7 @@ __format_chrono(const _Tp& __value,...@@ -692,7 +700,7 @@ __format_chrono(const _Tp& __value,
692} // namespace __formatter700} // namespace __formatter
693701
694template <__fmt_char_type _CharT>702template <__fmt_char_type _CharT>
695struct _LIBCPP_TEMPLATE_VIS __formatter_chrono {703struct __formatter_chrono {
696public:704public:
697 template <class _ParseContext>705 template <class _ParseContext>
698 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator706 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator
...@@ -710,7 +718,7 @@ public:...@@ -710,7 +718,7 @@ public:
710};718};
711719
712template <class _Duration, __fmt_char_type _CharT>720template <class _Duration, __fmt_char_type _CharT>
713struct _LIBCPP_TEMPLATE_VIS formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {721struct formatter<chrono::sys_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
714public:722public:
715 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;723 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
716724
...@@ -724,7 +732,29 @@ public:...@@ -724,7 +732,29 @@ public:
724# if _LIBCPP_HAS_EXPERIMENTAL_TZDB732# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
725733
726template <class _Duration, __fmt_char_type _CharT>734template <class _Duration, __fmt_char_type _CharT>
727struct _LIBCPP_TEMPLATE_VIS formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {735struct formatter<chrono::utc_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
736public:
737 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
738
739 template <class _ParseContext>
740 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
741 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
742 }
743};
744
745template <class _Duration, __fmt_char_type _CharT>
746struct formatter<chrono::tai_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
747public:
748 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
749
750 template <class _ParseContext>
751 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
752 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
753 }
754};
755
756template <class _Duration, __fmt_char_type _CharT>
757struct formatter<chrono::gps_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
728public:758public:
729 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;759 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
730760
...@@ -738,7 +768,7 @@ public:...@@ -738,7 +768,7 @@ public:
738# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM768# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
739769
740template <class _Duration, __fmt_char_type _CharT>770template <class _Duration, __fmt_char_type _CharT>
741struct _LIBCPP_TEMPLATE_VIS formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {771struct formatter<chrono::file_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
742public:772public:
743 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;773 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
744774
...@@ -749,7 +779,7 @@ public:...@@ -749,7 +779,7 @@ public:
749};779};
750780
751template <class _Duration, __fmt_char_type _CharT>781template <class _Duration, __fmt_char_type _CharT>
752struct _LIBCPP_TEMPLATE_VIS formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {782struct formatter<chrono::local_time<_Duration>, _CharT> : public __formatter_chrono<_CharT> {
753public:783public:
754 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;784 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
755785
...@@ -783,7 +813,7 @@ public:...@@ -783,7 +813,7 @@ public:
783};813};
784814
785template <__fmt_char_type _CharT>815template <__fmt_char_type _CharT>
786struct _LIBCPP_TEMPLATE_VIS formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {816struct formatter<chrono::day, _CharT> : public __formatter_chrono<_CharT> {
787public:817public:
788 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;818 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
789819
...@@ -794,7 +824,7 @@ public:...@@ -794,7 +824,7 @@ public:
794};824};
795825
796template <__fmt_char_type _CharT>826template <__fmt_char_type _CharT>
797struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {827struct formatter<chrono::month, _CharT> : public __formatter_chrono<_CharT> {
798public:828public:
799 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;829 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
800830
...@@ -805,7 +835,7 @@ public:...@@ -805,7 +835,7 @@ public:
805};835};
806836
807template <__fmt_char_type _CharT>837template <__fmt_char_type _CharT>
808struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {838struct formatter<chrono::year, _CharT> : public __formatter_chrono<_CharT> {
809public:839public:
810 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;840 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
811841
...@@ -816,7 +846,7 @@ public:...@@ -816,7 +846,7 @@ public:
816};846};
817847
818template <__fmt_char_type _CharT>848template <__fmt_char_type _CharT>
819struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {849struct formatter<chrono::weekday, _CharT> : public __formatter_chrono<_CharT> {
820public:850public:
821 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;851 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
822852
...@@ -827,7 +857,7 @@ public:...@@ -827,7 +857,7 @@ public:
827};857};
828858
829template <__fmt_char_type _CharT>859template <__fmt_char_type _CharT>
830struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {860struct formatter<chrono::weekday_indexed, _CharT> : public __formatter_chrono<_CharT> {
831public:861public:
832 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;862 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
833863
...@@ -838,7 +868,7 @@ public:...@@ -838,7 +868,7 @@ public:
838};868};
839869
840template <__fmt_char_type _CharT>870template <__fmt_char_type _CharT>
841struct _LIBCPP_TEMPLATE_VIS formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {871struct formatter<chrono::weekday_last, _CharT> : public __formatter_chrono<_CharT> {
842public:872public:
843 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;873 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
844874
...@@ -849,7 +879,7 @@ public:...@@ -849,7 +879,7 @@ public:
849};879};
850880
851template <__fmt_char_type _CharT>881template <__fmt_char_type _CharT>
852struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {882struct formatter<chrono::month_day, _CharT> : public __formatter_chrono<_CharT> {
853public:883public:
854 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;884 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
855885
...@@ -860,7 +890,7 @@ public:...@@ -860,7 +890,7 @@ public:
860};890};
861891
862template <__fmt_char_type _CharT>892template <__fmt_char_type _CharT>
863struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {893struct formatter<chrono::month_day_last, _CharT> : public __formatter_chrono<_CharT> {
864public:894public:
865 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;895 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
866896
...@@ -871,7 +901,7 @@ public:...@@ -871,7 +901,7 @@ public:
871};901};
872902
873template <__fmt_char_type _CharT>903template <__fmt_char_type _CharT>
874struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {904struct formatter<chrono::month_weekday, _CharT> : public __formatter_chrono<_CharT> {
875public:905public:
876 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;906 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
877907
...@@ -882,7 +912,7 @@ public:...@@ -882,7 +912,7 @@ public:
882};912};
883913
884template <__fmt_char_type _CharT>914template <__fmt_char_type _CharT>
885struct _LIBCPP_TEMPLATE_VIS formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {915struct formatter<chrono::month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
886public:916public:
887 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;917 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
888918
...@@ -893,7 +923,7 @@ public:...@@ -893,7 +923,7 @@ public:
893};923};
894924
895template <__fmt_char_type _CharT>925template <__fmt_char_type _CharT>
896struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {926struct formatter<chrono::year_month, _CharT> : public __formatter_chrono<_CharT> {
897public:927public:
898 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;928 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
899929
...@@ -904,7 +934,7 @@ public:...@@ -904,7 +934,7 @@ public:
904};934};
905935
906template <__fmt_char_type _CharT>936template <__fmt_char_type _CharT>
907struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {937struct formatter<chrono::year_month_day, _CharT> : public __formatter_chrono<_CharT> {
908public:938public:
909 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;939 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
910940
...@@ -915,7 +945,7 @@ public:...@@ -915,7 +945,7 @@ public:
915};945};
916946
917template <__fmt_char_type _CharT>947template <__fmt_char_type _CharT>
918struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {948struct formatter<chrono::year_month_day_last, _CharT> : public __formatter_chrono<_CharT> {
919public:949public:
920 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;950 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
921951
...@@ -926,7 +956,7 @@ public:...@@ -926,7 +956,7 @@ public:
926};956};
927957
928template <__fmt_char_type _CharT>958template <__fmt_char_type _CharT>
929struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {959struct formatter<chrono::year_month_weekday, _CharT> : public __formatter_chrono<_CharT> {
930public:960public:
931 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;961 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
932962
...@@ -937,7 +967,7 @@ public:...@@ -937,7 +967,7 @@ public:
937};967};
938968
939template <__fmt_char_type _CharT>969template <__fmt_char_type _CharT>
940struct _LIBCPP_TEMPLATE_VIS formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {970struct formatter<chrono::year_month_weekday_last, _CharT> : public __formatter_chrono<_CharT> {
941public:971public:
942 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;972 using _Base _LIBCPP_NODEBUG = __formatter_chrono<_CharT>;
943973
lib/libcxx/include/__chrono/gps_clock.h created+90
...@@ -0,0 +1,90 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_GPS_CLOCK_H
11#define _LIBCPP___CHRONO_GPS_CLOCK_H
12
13#include <version>
14// Enable the contents of the header only when libc++ was built with experimental features enabled.
15#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
16
17# include <__assert>
18# include <__chrono/duration.h>
19# include <__chrono/time_point.h>
20# include <__chrono/utc_clock.h>
21# include <__config>
22# include <__type_traits/common_type.h>
23
24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26# endif
27
28_LIBCPP_PUSH_MACROS
29# include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
34
35namespace chrono {
36
37class gps_clock;
38
39template <class _Duration>
40using gps_time = time_point<gps_clock, _Duration>;
41using gps_seconds = gps_time<seconds>;
42
43class gps_clock {
44public:
45 using rep = utc_clock::rep;
46 using period = utc_clock::period;
47 using duration = chrono::duration<rep, period>;
48 using time_point = chrono::time_point<gps_clock>;
49 static constexpr bool is_steady = false; // The utc_clock is not steady.
50
51 // The static difference between UTC and GPS time as specified in the Standard.
52 static constexpr chrono::seconds __offset{315964809};
53
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_utc(utc_clock::now()); }
55
56 template <class _Duration>
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>>
58 to_utc(const gps_time<_Duration>& __time) noexcept {
59 using _Rp = common_type_t<_Duration, seconds>;
60 _Duration __time_since_epoch = __time.time_since_epoch();
61 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch >= utc_time<_Rp>::min().time_since_epoch() + __offset,
62 "the GPS to UTC conversion would underflow");
63
64 return utc_time<_Rp>{__time_since_epoch + __offset};
65 }
66
67 template <class _Duration>
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static gps_time<common_type_t<_Duration, seconds>>
69 from_utc(const utc_time<_Duration>& __time) noexcept {
70 using _Rp = common_type_t<_Duration, seconds>;
71 _Duration __time_since_epoch = __time.time_since_epoch();
72 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch <= utc_time<_Rp>::max().time_since_epoch() - __offset,
73 "the UTC to GPS conversion would overflow");
74
75 return gps_time<_Rp>{__time_since_epoch - __offset};
76 }
77};
78
79} // namespace chrono
80
81# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
82 // _LIBCPP_HAS_LOCALIZATION
83
84_LIBCPP_END_NAMESPACE_STD
85
86_LIBCPP_POP_MACROS
87
88#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
89
90#endif // _LIBCPP___CHRONO_GPS_CLOCK_H
lib/libcxx/include/__chrono/ostream.h+14
...@@ -18,6 +18,7 @@...@@ -18,6 +18,7 @@
18# include <__chrono/day.h>18# include <__chrono/day.h>
19# include <__chrono/duration.h>19# include <__chrono/duration.h>
20# include <__chrono/file_clock.h>20# include <__chrono/file_clock.h>
21# include <__chrono/gps_clock.h>
21# include <__chrono/hh_mm_ss.h>22# include <__chrono/hh_mm_ss.h>
22# include <__chrono/local_info.h>23# include <__chrono/local_info.h>
23# include <__chrono/month.h>24# include <__chrono/month.h>
...@@ -26,6 +27,7 @@...@@ -26,6 +27,7 @@
26# include <__chrono/statically_widen.h>27# include <__chrono/statically_widen.h>
27# include <__chrono/sys_info.h>28# include <__chrono/sys_info.h>
28# include <__chrono/system_clock.h>29# include <__chrono/system_clock.h>
30# include <__chrono/tai_clock.h>
29# include <__chrono/utc_clock.h>31# include <__chrono/utc_clock.h>
30# include <__chrono/weekday.h>32# include <__chrono/weekday.h>
31# include <__chrono/year.h>33# include <__chrono/year.h>
...@@ -71,6 +73,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp...@@ -71,6 +73,18 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const utc_time<_Duration>& __tp
71 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);73 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
72}74}
7375
76template <class _CharT, class _Traits, class _Duration>
77_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
78operator<<(basic_ostream<_CharT, _Traits>& __os, const tai_time<_Duration>& __tp) {
79 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
80}
81
82template <class _CharT, class _Traits, class _Duration>
83_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
84operator<<(basic_ostream<_CharT, _Traits>& __os, const gps_time<_Duration>& __tp) {
85 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T}"), __tp);
86}
87
74# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB88# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
75# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM89# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM
7690
lib/libcxx/include/__chrono/parser_std_format_spec.h+1-1
...@@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {...@@ -139,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __validate_time_zone(__flags __flags) {
139}139}
140140
141template <class _CharT>141template <class _CharT>
142class _LIBCPP_TEMPLATE_VIS __parser_chrono {142class __parser_chrono {
143 using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator;143 using _ConstIterator _LIBCPP_NODEBUG = typename basic_format_parse_context<_CharT>::const_iterator;
144144
145public:145public:
lib/libcxx/include/__chrono/tai_clock.h created+108
...@@ -0,0 +1,108 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___CHRONO_TAI_CLOCK_H
11#define _LIBCPP___CHRONO_TAI_CLOCK_H
12
13#include <version>
14// Enable the contents of the header only when libc++ was built with experimental features enabled.
15#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
16
17# include <__assert>
18# include <__chrono/duration.h>
19# include <__chrono/time_point.h>
20# include <__chrono/utc_clock.h>
21# include <__config>
22# include <__type_traits/common_type.h>
23
24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26# endif
27
28_LIBCPP_PUSH_MACROS
29# include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
34
35namespace chrono {
36
37class tai_clock;
38
39template <class _Duration>
40using tai_time = time_point<tai_clock, _Duration>;
41using tai_seconds = tai_time<seconds>;
42
43// [time.clock.tai.overview]/1
44// The clock tai_clock measures seconds since 1958-01-01 00:00:00 and is
45// offset 10s ahead of UTC at this date. That is, 1958-01-01 00:00:00 TAI is
46// equivalent to 1957-12-31 23:59:50 UTC. Leap seconds are not inserted into
47// TAI. Therefore every time a leap second is inserted into UTC, UTC shifts
48// another second with respect to TAI. For example by 2000-01-01 there had
49// been 22 positive and 0 negative leap seconds inserted so 2000-01-01
50// 00:00:00 UTC is equivalent to 2000-01-01 00:00:32 TAI (22s plus the
51// initial 10s offset).
52//
53// Note this does not specify what the UTC offset before 1958-01-01 00:00:00
54// TAI is, nor does it follow the "real" TAI clock between 1958-01-01 and the
55// start of the UTC epoch. So while the member functions are fully specified in
56// the standard, they do not technically follow the "real-world" TAI clock with
57// 100% accuracy.
58//
59// https://koka-lang.github.io/koka/doc/std_time_utc.html contains more
60// information and references.
61class tai_clock {
62public:
63 using rep = utc_clock::rep;
64 using period = utc_clock::period;
65 using duration = chrono::duration<rep, period>;
66 using time_point = chrono::time_point<tai_clock>;
67 static constexpr bool is_steady = false; // The utc_clock is not steady.
68
69 // The static difference between UTC and TAI time.
70 static constexpr chrono::seconds __offset{378691210};
71
72 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static time_point now() { return from_utc(utc_clock::now()); }
73
74 template <class _Duration>
75 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static utc_time<common_type_t<_Duration, seconds>>
76 to_utc(const tai_time<_Duration>& __time) noexcept {
77 using _Rp = common_type_t<_Duration, seconds>;
78 _Duration __time_since_epoch = __time.time_since_epoch();
79 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch >= utc_time<_Rp>::min().time_since_epoch() + __offset,
80 "the TAI to UTC conversion would underflow");
81
82 return utc_time<_Rp>{__time_since_epoch - __offset};
83 }
84
85 template <class _Duration>
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static tai_time<common_type_t<_Duration, seconds>>
87 from_utc(const utc_time<_Duration>& __time) noexcept {
88 using _Rp = common_type_t<_Duration, seconds>;
89 _Duration __time_since_epoch = __time.time_since_epoch();
90 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__time_since_epoch <= utc_time<_Rp>::max().time_since_epoch() - __offset,
91 "the UTC to TAI conversion would overflow");
92
93 return tai_time<_Rp>{__time_since_epoch + __offset};
94 }
95};
96
97} // namespace chrono
98
99# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
100 // _LIBCPP_HAS_LOCALIZATION
101
102_LIBCPP_END_NAMESPACE_STD
103
104_LIBCPP_POP_MACROS
105
106#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
107
108#endif // _LIBCPP___CHRONO_TAI_CLOCK_H
lib/libcxx/include/__chrono/time_point.h+15-3
...@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31namespace chrono {31namespace chrono {
3232
33template <class _Clock, class _Duration = typename _Clock::duration>33template <class _Clock, class _Duration = typename _Clock::duration>
34class _LIBCPP_TEMPLATE_VIS time_point {34class time_point {
35 static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration");35 static_assert(__is_duration_v<_Duration>, "Second template parameter of time_point must be a std::chrono::duration");
3636
37public:37public:
...@@ -58,6 +58,19 @@ public:...@@ -58,6 +58,19 @@ public:
5858
59 // arithmetic59 // arithmetic
6060
61#if _LIBCPP_STD_VER >= 20
62 _LIBCPP_HIDE_FROM_ABI constexpr time_point& operator++() {
63 ++__d_;
64 return *this;
65 }
66 _LIBCPP_HIDE_FROM_ABI constexpr time_point operator++(int) { return time_point{__d_++}; }
67 _LIBCPP_HIDE_FROM_ABI constexpr time_point& operator--() {
68 --__d_;
69 return *this;
70 }
71 _LIBCPP_HIDE_FROM_ABI constexpr time_point operator--(int) { return time_point{__d_--}; }
72#endif // _LIBCPP_STD_VER >= 20
73
61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {74 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 time_point& operator+=(const duration& __d) {
62 __d_ += __d;75 __d_ += __d;
63 return *this;76 return *this;
...@@ -76,8 +89,7 @@ public:...@@ -76,8 +89,7 @@ public:
76} // namespace chrono89} // namespace chrono
7790
78template <class _Clock, class _Duration1, class _Duration2>91template <class _Clock, class _Duration1, class _Duration2>
79struct _LIBCPP_TEMPLATE_VIS92struct common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
80common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
81 typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;93 typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
82};94};
8395
lib/libcxx/include/__compare/common_comparison_category.h+3-3
...@@ -55,7 +55,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {...@@ -55,7 +55,7 @@ __compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
55template <class... _Ts, bool _False = false>55template <class... _Ts, bool _False = false>
56_LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {56_LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {
57 using _CCC = _ClassifyCompCategory;57 using _CCC = _ClassifyCompCategory;
58 constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};58 constexpr _CCC __type_kinds[] = {_StrongOrd, __comp_detail::__type_to_enum<_Ts>()...};
59 constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds);59 constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds);
60 if constexpr (__cat == _None)60 if constexpr (__cat == _None)
61 return void();61 return void();
...@@ -72,8 +72,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {...@@ -72,8 +72,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __get_comp_type() {
7272
73// [cmp.common], common comparison category type73// [cmp.common], common comparison category type
74template <class... _Ts>74template <class... _Ts>
75struct _LIBCPP_TEMPLATE_VIS common_comparison_category {75struct common_comparison_category {
76 using type = decltype(__comp_detail::__get_comp_type<_Ts...>());76 using type _LIBCPP_NODEBUG = decltype(__comp_detail::__get_comp_type<_Ts...>());
77};77};
7878
79template <class... _Ts>79template <class... _Ts>
lib/libcxx/include/__compare/compare_three_way.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if _LIBCPP_STD_VER >= 2023#if _LIBCPP_STD_VER >= 20
2424
25struct _LIBCPP_TEMPLATE_VIS compare_three_way {25struct compare_three_way {
26 template <class _T1, class _T2>26 template <class _T1, class _T2>
27 requires three_way_comparable_with<_T1, _T2>27 requires three_way_comparable_with<_T1, _T2>
28 constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const28 constexpr _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
lib/libcxx/include/__compare/compare_three_way_result.h+3-3
...@@ -29,12 +29,12 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<...@@ -29,12 +29,12 @@ struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<
29 _Tp,29 _Tp,
30 _Up,30 _Up,
31 decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void())> {31 decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void())> {
32 using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());32 using type _LIBCPP_NODEBUG =
33 decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
33};34};
3435
35template <class _Tp, class _Up = _Tp>36template <class _Tp, class _Up = _Tp>
36struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result37struct _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> {};
37 : __compare_three_way_result<_Tp, _Up, void> {};
3838
39template <class _Tp, class _Up = _Tp>39template <class _Tp, class _Up = _Tp>
40using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;40using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
lib/libcxx/include/__concepts/arithmetic.h-13
...@@ -13,8 +13,6 @@...@@ -13,8 +13,6 @@
13#include <__type_traits/is_floating_point.h>13#include <__type_traits/is_floating_point.h>
14#include <__type_traits/is_integral.h>14#include <__type_traits/is_integral.h>
15#include <__type_traits/is_signed.h>15#include <__type_traits/is_signed.h>
16#include <__type_traits/is_signed_integer.h>
17#include <__type_traits/is_unsigned_integer.h>
1816
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header18# pragma GCC system_header
...@@ -38,17 +36,6 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;...@@ -38,17 +36,6 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
38template <class _Tp>36template <class _Tp>
39concept floating_point = is_floating_point_v<_Tp>;37concept floating_point = is_floating_point_v<_Tp>;
4038
41// Concept helpers for the internal type traits for the fundamental types.
42
43template <class _Tp>
44concept __libcpp_unsigned_integer = __libcpp_is_unsigned_integer<_Tp>::value;
45
46template <class _Tp>
47concept __libcpp_signed_integer = __libcpp_is_signed_integer<_Tp>::value;
48
49template <class _Tp>
50concept __libcpp_integer = __libcpp_unsigned_integer<_Tp> || __libcpp_signed_integer<_Tp>;
51
52#endif // _LIBCPP_STD_VER >= 2039#endif // _LIBCPP_STD_VER >= 20
5340
54_LIBCPP_END_NAMESPACE_STD41_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/class_or_enum.h-1
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/is_class.h>13#include <__type_traits/is_class.h>
14#include <__type_traits/is_enum.h>14#include <__type_traits/is_enum.h>
15#include <__type_traits/is_union.h>15#include <__type_traits/is_union.h>
16#include <__type_traits/remove_cvref.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header18# pragma GCC system_header
lib/libcxx/include/__concepts/common_with.h+1-1
...@@ -12,7 +12,7 @@...@@ -12,7 +12,7 @@
12#include <__concepts/common_reference_with.h>12#include <__concepts/common_reference_with.h>
13#include <__concepts/same_as.h>13#include <__concepts/same_as.h>
14#include <__config>14#include <__config>
15#include <__type_traits/add_lvalue_reference.h>15#include <__type_traits/add_reference.h>
16#include <__type_traits/common_reference.h>16#include <__type_traits/common_reference.h>
17#include <__type_traits/common_type.h>17#include <__type_traits/common_type.h>
18#include <__utility/declval.h>18#include <__utility/declval.h>
lib/libcxx/include/__concepts/swappable.h-1
...@@ -22,7 +22,6 @@...@@ -22,7 +22,6 @@
22#include <__utility/exchange.h>22#include <__utility/exchange.h>
23#include <__utility/forward.h>23#include <__utility/forward.h>
24#include <__utility/move.h>24#include <__utility/move.h>
25#include <__utility/swap.h>
2625
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header27# pragma GCC system_header
lib/libcxx/include/__condition_variable/condition_variable.h+87-99
...@@ -39,60 +39,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -39,60 +39,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
39_LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout};39_LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout};
40_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)40_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
4141
42class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
43 __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
44
45public:
46 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
47
48# if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
49 ~condition_variable() = default;
50# else
51 ~condition_variable();
52# endif
53
54 condition_variable(const condition_variable&) = delete;
55 condition_variable& operator=(const condition_variable&) = delete;
56
57 void notify_one() _NOEXCEPT;
58 void notify_all() _NOEXCEPT;
59
60 void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
61 template <class _Predicate>
62 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS void wait(unique_lock<mutex>& __lk, _Predicate __pred);
63
64 template <class _Clock, class _Duration>
65 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status
66 wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t);
67
68 template <class _Clock, class _Duration, class _Predicate>
69 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
70 wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred);
71
72 template <class _Rep, class _Period>
73 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status
74 wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d);
75
76 template <class _Rep, class _Period, class _Predicate>
77 bool _LIBCPP_HIDE_FROM_ABI
78 wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred);
79
80 typedef __libcpp_condvar_t* native_handle_type;
81 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; }
82
83private:
84 void
85 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
86# if _LIBCPP_HAS_COND_CLOCKWAIT
87 _LIBCPP_HIDE_FROM_ABI void
88 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
89# endif
90 template <class _Clock>
91 _LIBCPP_HIDE_FROM_ABI void
92 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT;
93};
94#endif // _LIBCPP_HAS_THREADS
95
96template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0>42template <class _Rep, class _Period, __enable_if_t<is_floating_point<_Rep>::value, int> = 0>
97inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {43inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::duration<_Rep, _Period> __d) {
98 using namespace chrono;44 using namespace chrono;
...@@ -140,64 +86,106 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::...@@ -140,64 +86,106 @@ inline _LIBCPP_HIDE_FROM_ABI chrono::nanoseconds __safe_nanosecond_cast(chrono::
140 return nanoseconds(__result);86 return nanoseconds(__result);
141}87}
14288
143#if _LIBCPP_HAS_THREADS89class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
144template <class _Predicate>90 __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
145void condition_variable::wait(unique_lock<mutex>& __lk, _Predicate __pred) {
146 while (!__pred())
147 wait(__lk);
148}
14991
150template <class _Clock, class _Duration>92public:
151cv_status condition_variable::wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t) {93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
152 using namespace chrono;
153 using __clock_tp_ns = time_point<_Clock, nanoseconds>;
15494
155 typename _Clock::time_point __now = _Clock::now();95# if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
156 if (__t <= __now)96 ~condition_variable() = default;
157 return cv_status::timeout;97# else
98 ~condition_variable();
99# endif
158100
159 __clock_tp_ns __t_ns = __clock_tp_ns(std::__safe_nanosecond_cast(__t.time_since_epoch()));101 condition_variable(const condition_variable&) = delete;
102 condition_variable& operator=(const condition_variable&) = delete;
160103
161 __do_timed_wait(__lk, __t_ns);104 void notify_one() _NOEXCEPT;
162 return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;105 void notify_all() _NOEXCEPT;
163}106
107 void wait(unique_lock<mutex>& __lk) _NOEXCEPT;
164108
165template <class _Clock, class _Duration, class _Predicate>109 template <class _Predicate>
166bool condition_variable::wait_until(110 _LIBCPP_HIDE_FROM_ABI void wait(unique_lock<mutex>& __lk, _Predicate __pred) {
167 unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) {111 while (!__pred())
168 while (!__pred()) {112 wait(__lk);
169 if (wait_until(__lk, __t) == cv_status::timeout)
170 return __pred();
171 }113 }
172 return true;
173}
174114
175template <class _Rep, class _Period>115 template <class _Clock, class _Duration>
176cv_status condition_variable::wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d) {116 _LIBCPP_HIDE_FROM_ABI cv_status
177 using namespace chrono;117 wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t) {
178 if (__d <= __d.zero())118 using namespace chrono;
179 return cv_status::timeout;119 using __clock_tp_ns = time_point<_Clock, nanoseconds>;
180 using __ns_rep = nanoseconds::rep;120
181 steady_clock::time_point __c_now = steady_clock::now();121 typename _Clock::time_point __now = _Clock::now();
122 if (__t <= __now)
123 return cv_status::timeout;
124
125 __clock_tp_ns __t_ns = __clock_tp_ns(std::__safe_nanosecond_cast(__t.time_since_epoch()));
126
127 __do_timed_wait(__lk, __t_ns);
128 return _Clock::now() < __t ? cv_status::no_timeout : cv_status::timeout;
129 }
130
131 template <class _Clock, class _Duration, class _Predicate>
132 _LIBCPP_HIDE_FROM_ABI bool
133 wait_until(unique_lock<mutex>& __lk, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) {
134 while (!__pred()) {
135 if (wait_until(__lk, __t) == cv_status::timeout)
136 return __pred();
137 }
138 return true;
139 }
140
141 template <class _Rep, class _Period>
142 _LIBCPP_HIDE_FROM_ABI cv_status wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d) {
143 using namespace chrono;
144 if (__d <= __d.zero())
145 return cv_status::timeout;
146 using __ns_rep = nanoseconds::rep;
147 steady_clock::time_point __c_now = steady_clock::now();
182148
183# if _LIBCPP_HAS_COND_CLOCKWAIT149# if _LIBCPP_HAS_COND_CLOCKWAIT
184 using __clock_tp_ns = time_point<steady_clock, nanoseconds>;150 using __clock_tp_ns = time_point<steady_clock, nanoseconds>;
185 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();151 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count();
186# else152# else
187 using __clock_tp_ns = time_point<system_clock, nanoseconds>;153 using __clock_tp_ns = time_point<system_clock, nanoseconds>;
188 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count();154 __ns_rep __now_count_ns = std::__safe_nanosecond_cast(system_clock::now().time_since_epoch()).count();
189# endif155# endif
190156
191 __ns_rep __d_ns_count = std::__safe_nanosecond_cast(__d).count();157 __ns_rep __d_ns_count = std::__safe_nanosecond_cast(__d).count();
192158
193 if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) {159 if (__now_count_ns > numeric_limits<__ns_rep>::max() - __d_ns_count) {
194 __do_timed_wait(__lk, __clock_tp_ns::max());160 __do_timed_wait(__lk, __clock_tp_ns::max());
195 } else {161 } else {
196 __do_timed_wait(__lk, __clock_tp_ns(nanoseconds(__now_count_ns + __d_ns_count)));162 __do_timed_wait(__lk, __clock_tp_ns(nanoseconds(__now_count_ns + __d_ns_count)));
163 }
164
165 return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : cv_status::timeout;
197 }166 }
198167
199 return steady_clock::now() - __c_now < __d ? cv_status::no_timeout : cv_status::timeout;168 template <class _Rep, class _Period, class _Predicate>
200}169 bool _LIBCPP_HIDE_FROM_ABI
170 wait_for(unique_lock<mutex>& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred);
171
172 typedef __libcpp_condvar_t* native_handle_type;
173 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__cv_; }
174
175private:
176 void
177 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
178# if _LIBCPP_HAS_COND_CLOCKWAIT
179 _LIBCPP_HIDE_FROM_ABI void
180 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
181# endif
182 template <class _Clock>
183 _LIBCPP_HIDE_FROM_ABI void
184 __do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<_Clock, chrono::nanoseconds>) _NOEXCEPT;
185};
186#endif // _LIBCPP_HAS_THREADS
187
188#if _LIBCPP_HAS_THREADS
201189
202template <class _Rep, class _Period, class _Predicate>190template <class _Rep, class _Period, class _Predicate>
203inline bool191inline bool
...@@ -210,7 +198,7 @@ inline void condition_variable::__do_timed_wait(...@@ -210,7 +198,7 @@ inline void condition_variable::__do_timed_wait(
210 unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {198 unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {
211 using namespace chrono;199 using namespace chrono;
212 if (!__lk.owns_lock())200 if (!__lk.owns_lock())
213 __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");201 std::__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
214 nanoseconds __d = __tp.time_since_epoch();202 nanoseconds __d = __tp.time_since_epoch();
215 timespec __ts;203 timespec __ts;
216 seconds __s = duration_cast<seconds>(__d);204 seconds __s = duration_cast<seconds>(__d);
...@@ -225,7 +213,7 @@ inline void condition_variable::__do_timed_wait(...@@ -225,7 +213,7 @@ inline void condition_variable::__do_timed_wait(
225 }213 }
226 int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts);214 int __ec = pthread_cond_clockwait(&__cv_, __lk.mutex()->native_handle(), CLOCK_MONOTONIC, &__ts);
227 if (__ec != 0 && __ec != ETIMEDOUT)215 if (__ec != 0 && __ec != ETIMEDOUT)
228 __throw_system_error(__ec, "condition_variable timed_wait failed");216 std::__throw_system_error(__ec, "condition_variable timed_wait failed");
229}217}
230# endif // _LIBCPP_HAS_COND_CLOCKWAIT218# endif // _LIBCPP_HAS_COND_CLOCKWAIT
231219
lib/libcxx/include/__config+186-162
...@@ -28,7 +28,7 @@...@@ -28,7 +28,7 @@
28// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.28// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
29// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is29// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
30// defined to XXYYZZ.30// defined to XXYYZZ.
31# define _LIBCPP_VERSION 20010031# define _LIBCPP_VERSION 210100
3232
33# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y33# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
34# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)34# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
...@@ -38,11 +38,47 @@...@@ -38,11 +38,47 @@
38# define _LIBCPP_FREESTANDING38# define _LIBCPP_FREESTANDING
39# endif39# endif
4040
41// NOLINTNEXTLINE(libcpp-cpp-version-check)
42# if __cplusplus < 201103L
43# define _LIBCPP_CXX03_LANG
44# endif
45
46# if __has_feature(experimental_library)
47# ifndef _LIBCPP_ENABLE_EXPERIMENTAL
48# define _LIBCPP_ENABLE_EXPERIMENTAL
49# endif
50# endif
51
52// Incomplete features get their own specific disabling flags. This makes it
53// easier to grep for target specific flags once the feature is complete.
54# if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY)
55# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1
56# else
57# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0
58# endif
59
60# define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
61# define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
62# define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
63# define _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
64
41// HARDENING {65// HARDENING {
4266
43// TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated.67// TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated.
44# ifdef _LIBCPP_ENABLE_ASSERTIONS68// Since hardening went through several changes (many of which impacted user-facing macros),
45# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"69// we're keeping these checks around for a bit longer than usual. Failure to properly configure
70// hardening results in checks being dropped silently, which is a pretty big deal.
71# if defined(_LIBCPP_ENABLE_ASSERTIONS)
72# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
73# endif
74# if defined(_LIBCPP_ENABLE_HARDENED_MODE)
75# error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
76# endif
77# if defined(_LIBCPP_ENABLE_SAFE_MODE)
78# error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
79# endif
80# if defined(_LIBCPP_ENABLE_DEBUG_MODE)
81# error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
46# endif82# endif
4783
48// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:84// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
...@@ -147,16 +183,53 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \...@@ -147,16 +183,53 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \
147_LIBCPP_HARDENING_MODE_DEBUG183_LIBCPP_HARDENING_MODE_DEBUG
148# endif184# endif
149185
186// Hardening assertion semantics generally mirror the evaluation semantics of C++26 Contracts:
187// - `ignore` evaluates the assertion but doesn't do anything if it fails (note that it differs from the Contracts
188// `ignore` semantic which wouldn't evaluate the assertion at all);
189// - `observe` logs an error (indicating, if possible, that the error is fatal) and continues execution;
190// - `quick-enforce` terminates the program as fast as possible (via trapping);
191// - `enforce` logs an error and then terminates the program.
192//
193// Notes:
194// - Continuing execution after a hardening check fails results in undefined behavior; the `observe` semantic is meant
195// to make adopting hardening easier but should not be used outside of this scenario;
196// - C++26 wording for Library Hardening precludes a conforming Hardened implementation from using the Contracts
197// `ignore` semantic when evaluating hardened preconditions in the Library. Libc++ allows using this semantic for
198// hardened preconditions, however, be aware that using `ignore` does not produce a conforming "Hardened"
199// implementation, unlike the other semantics above.
200// clang-format off
201# define _LIBCPP_ASSERTION_SEMANTIC_IGNORE (1 << 1)
202# define _LIBCPP_ASSERTION_SEMANTIC_OBSERVE (1 << 2)
203# define _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE (1 << 3)
204# define _LIBCPP_ASSERTION_SEMANTIC_ENFORCE (1 << 4)
205// clang-format on
206
207// Allow users to define an arbitrary assertion semantic; otherwise, use the default mapping from modes to semantics.
208// The default is for production-capable modes to use `quick-enforce` (i.e., trap) and for the `debug` mode to use
209// `enforce` (i.e., log and abort).
210# ifndef _LIBCPP_ASSERTION_SEMANTIC
211
212# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
213# define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
214# else
215# define _LIBCPP_ASSERTION_SEMANTIC _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
216# endif
217
218# else
219# if !_LIBCPP_HAS_EXPERIMENTAL_LIBRARY
220# error "Assertion semantics are an experimental feature."
221# endif
222# if defined(_LIBCPP_CXX03_LANG)
223# error "Assertion semantics are not available in the C++03 mode."
224# endif
225
226# endif // _LIBCPP_ASSERTION_SEMANTIC
227
150// } HARDENING228// } HARDENING
151229
152# define _LIBCPP_TOSTRING2(x) #x230# define _LIBCPP_TOSTRING2(x) #x
153# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)231# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
154232
155// NOLINTNEXTLINE(libcpp-cpp-version-check)
156# if __cplusplus < 201103L
157# define _LIBCPP_CXX03_LANG
158# endif
159
160# ifndef __has_constexpr_builtin233# ifndef __has_constexpr_builtin
161# define __has_constexpr_builtin(x) 0234# define __has_constexpr_builtin(x) 0
162# endif235# endif
...@@ -190,24 +263,6 @@ _LIBCPP_HARDENING_MODE_DEBUG...@@ -190,24 +263,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
190# define _LIBCPP_ABI_VCRUNTIME263# define _LIBCPP_ABI_VCRUNTIME
191# endif264# endif
192265
193# if __has_feature(experimental_library)
194# ifndef _LIBCPP_ENABLE_EXPERIMENTAL
195# define _LIBCPP_ENABLE_EXPERIMENTAL
196# endif
197# endif
198
199// Incomplete features get their own specific disabling flags. This makes it
200// easier to grep for target specific flags once the feature is complete.
201# if defined(_LIBCPP_ENABLE_EXPERIMENTAL) || defined(_LIBCPP_BUILDING_LIBRARY)
202# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 1
203# else
204# define _LIBCPP_HAS_EXPERIMENTAL_LIBRARY 0
205# endif
206
207# define _LIBCPP_HAS_EXPERIMENTAL_PSTL _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
208# define _LIBCPP_HAS_EXPERIMENTAL_TZDB _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
209# define _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM _LIBCPP_HAS_EXPERIMENTAL_LIBRARY
210
211# if defined(__MVS__)266# if defined(__MVS__)
212# include <features.h> // for __NATIVE_ASCII_F267# include <features.h> // for __NATIVE_ASCII_F
213# endif268# endif
...@@ -319,41 +374,14 @@ typedef __char32_t char32_t;...@@ -319,41 +374,14 @@ typedef __char32_t char32_t;
319374
320# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)375# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
321376
322// Objective-C++ features (opt-in)377# if __has_extension(blocks) && defined(__APPLE__)
323# if __has_feature(objc_arc)
324# define _LIBCPP_HAS_OBJC_ARC 1
325# else
326# define _LIBCPP_HAS_OBJC_ARC 0
327# endif
328
329# if __has_feature(objc_arc_weak)
330# define _LIBCPP_HAS_OBJC_ARC_WEAK 1
331# else
332# define _LIBCPP_HAS_OBJC_ARC_WEAK 0
333# endif
334
335# if __has_extension(blocks)
336# define _LIBCPP_HAS_EXTENSION_BLOCKS 1
337# else
338# define _LIBCPP_HAS_EXTENSION_BLOCKS 0
339# endif
340
341# if _LIBCPP_HAS_EXTENSION_BLOCKS && defined(__APPLE__)
342# define _LIBCPP_HAS_BLOCKS_RUNTIME 1378# define _LIBCPP_HAS_BLOCKS_RUNTIME 1
343# else379# else
344# define _LIBCPP_HAS_BLOCKS_RUNTIME 0380# define _LIBCPP_HAS_BLOCKS_RUNTIME 0
345# endif381# endif
346382
347# if __has_feature(address_sanitizer)
348# define _LIBCPP_HAS_ASAN 1
349# else
350# define _LIBCPP_HAS_ASAN 0
351# endif
352
353# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))383# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
354384
355# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
356
357# if defined(_LIBCPP_OBJECT_FORMAT_COFF)385# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
358386
359# ifdef _DLL387# ifdef _DLL
...@@ -363,35 +391,30 @@ typedef __char32_t char32_t;...@@ -363,35 +391,30 @@ typedef __char32_t char32_t;
363# endif391# endif
364392
365# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))393# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
366# define _LIBCPP_DLL_VIS
367# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS394# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
368# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS395# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
369# define _LIBCPP_OVERRIDABLE_FUNC_VIS396# define _LIBCPP_OVERRIDABLE_FUNC_VIS
370# define _LIBCPP_EXPORTED_FROM_ABI397# define _LIBCPP_EXPORTED_FROM_ABI
371# elif defined(_LIBCPP_BUILDING_LIBRARY)398# elif defined(_LIBCPP_BUILDING_LIBRARY)
372# define _LIBCPP_DLL_VIS __declspec(dllexport)
373# if defined(__MINGW32__)399# if defined(__MINGW32__)
374# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS400# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
375# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS401# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
376# else402# else
377# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS403# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
378# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS404# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
379# endif405# endif
380# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS406# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
381# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)407# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
382# else408# else
383# define _LIBCPP_DLL_VIS __declspec(dllimport)409# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
384# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
385# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS410# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
386# define _LIBCPP_OVERRIDABLE_FUNC_VIS411# define _LIBCPP_OVERRIDABLE_FUNC_VIS
387# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)412# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
388# endif413# endif
389414
390# define _LIBCPP_HIDDEN415# define _LIBCPP_HIDDEN
391# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
392# define _LIBCPP_TEMPLATE_VIS
393# define _LIBCPP_TEMPLATE_DATA_VIS416# define _LIBCPP_TEMPLATE_DATA_VIS
394# define _LIBCPP_TYPE_VISIBILITY_DEFAULT417# define _LIBCPP_NAMESPACE_VISIBILITY
395418
396# else419# else
397420
...@@ -412,24 +435,12 @@ typedef __char32_t char32_t;...@@ -412,24 +435,12 @@ typedef __char32_t char32_t;
412# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")435# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
413# endif436# endif
414437
415# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
416// The inline should be removed once PR32114 is resolved
417# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS inline _LIBCPP_HIDDEN
418# else
419# define _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
420# endif
421
422// GCC doesn't support the type_visibility attribute, so we have to keep the visibility attribute on templates
423# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && !__has_attribute(__type_visibility__)
424# define _LIBCPP_TEMPLATE_VIS __attribute__((__visibility__("default")))
425# else
426# define _LIBCPP_TEMPLATE_VIS
427# endif
428
429# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)438# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
430# define _LIBCPP_TYPE_VISIBILITY_DEFAULT __attribute__((__type_visibility__("default")))439# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
440# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
441# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
431# else442# else
432# define _LIBCPP_TYPE_VISIBILITY_DEFAULT443# define _LIBCPP_NAMESPACE_VISIBILITY
433# endif444# endif
434445
435# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)446# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
...@@ -549,24 +560,17 @@ typedef __char32_t char32_t;...@@ -549,24 +560,17 @@ typedef __char32_t char32_t;
549# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI560# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
550# endif561# endif
551562
552// TODO: Remove this workaround once we drop support for Clang 16
553# if __has_warning("-Wc++23-extensions")
554# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
555# else
556# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
557# endif
558
559// Clang modules take a significant compile time hit when pushing and popping diagnostics.563// Clang modules take a significant compile time hit when pushing and popping diagnostics.
560// Since all the headers are marked as system headers in the modulemap, we can simply disable this564// Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can
561// pushing and popping when building with clang modules.565// simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined.
562# if !__has_feature(modules)566# ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
563# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \567# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
564 _LIBCPP_DIAGNOSTIC_PUSH \568 _LIBCPP_DIAGNOSTIC_PUSH \
565 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \569 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
566 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \570 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
567 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \571 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
568 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \572 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
569 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \573 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
570 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \574 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
571 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \575 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
572 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \576 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
...@@ -577,15 +581,27 @@ typedef __char32_t char32_t;...@@ -577,15 +581,27 @@ typedef __char32_t char32_t;
577# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS581# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
578# endif582# endif
579583
580// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
581// clang-format off584// clang-format off
582# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
583 namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
584 inline namespace _LIBCPP_ABI_NAMESPACE {
585# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS
586585
587#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace std { namespace experimental {586// The unversioned namespace is used when we want to be ABI compatible with other standard libraries in some way. There
588#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL }}587// are two main categories where that's the case:
588// - Historically, we have made exception types ABI compatible with libstdc++ to allow throwing them between libstdc++
589// and libc++. This is not used anymore for new exception types, since there is no use-case for it anymore.
590// - Types and functions which are used by the compiler are in the unversioned namespace, since the compiler has to know
591// their mangling without the appropriate declaration in some cases.
592// If it's not clear whether using the unversioned namespace is the correct thing to do, it's not. The versioned
593// namespace (_LIBCPP_BEGIN_NAMESPACE_STD) should almost always be used.
594# define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \
595 _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_NAMESPACE_VISIBILITY std {
596
597# define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_POP_EXTENSION_DIAGNOSTICS
598
599# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD inline namespace _LIBCPP_ABI_NAMESPACE {
600# define _LIBCPP_END_NAMESPACE_STD } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
601
602// TODO: This should really be in the versioned namespace
603#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD namespace experimental {
604#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
589605
590#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {606#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
591#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL607#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
...@@ -663,7 +679,10 @@ typedef __char32_t char32_t;...@@ -663,7 +679,10 @@ typedef __char32_t char32_t;
663# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \679# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
664 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \680 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
665 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \681 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
666 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000)682 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
683 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
684 __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) || \
685 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000)
667# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0686# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0
668# else687# else
669# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1688# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
...@@ -675,10 +694,6 @@ typedef __char32_t char32_t;...@@ -675,10 +694,6 @@ typedef __char32_t char32_t;
675# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1694# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1
676# endif695# endif
677696
678# if defined(__APPLE__) || defined(__FreeBSD__)
679# define _LIBCPP_HAS_DEFAULTRUNELOCALE
680# endif
681
682# if defined(__APPLE__) || defined(__FreeBSD__)697# if defined(__APPLE__) || defined(__FreeBSD__)
683# define _LIBCPP_WCTYPE_IS_MASK698# define _LIBCPP_WCTYPE_IS_MASK
684# endif699# endif
...@@ -741,8 +756,10 @@ typedef __char32_t char32_t;...@@ -741,8 +756,10 @@ typedef __char32_t char32_t;
741756
742# if _LIBCPP_STD_VER >= 26757# if _LIBCPP_STD_VER >= 26
743# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED758# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
759# define _LIBCPP_DEPRECATED_IN_CXX26_(m) _LIBCPP_DEPRECATED_(m)
744# else760# else
745# define _LIBCPP_DEPRECATED_IN_CXX26761# define _LIBCPP_DEPRECATED_IN_CXX26
762# define _LIBCPP_DEPRECATED_IN_CXX26_(m)
746# endif763# endif
747764
748# if _LIBCPP_HAS_CHAR8_T765# if _LIBCPP_HAS_CHAR8_T
...@@ -937,23 +954,6 @@ typedef __char32_t char32_t;...@@ -937,23 +954,6 @@ typedef __char32_t char32_t;
937# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS954# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
938# endif955# endif
939956
940// Work around the attribute handling in clang. When both __declspec and
941// __attribute__ are present, the processing goes awry preventing the definition
942// of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus
943// combining the two does work.
944# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) && \
945 __has_attribute(acquire_capability) && !defined(_MSC_VER)
946# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1
947# else
948# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 0
949# endif
950
951# if _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
952# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x))
953# else
954# define _LIBCPP_THREAD_SAFETY_ANNOTATION(x)
955# endif
956
957# if _LIBCPP_STD_VER >= 20957# if _LIBCPP_STD_VER >= 20
958# define _LIBCPP_CONSTINIT constinit958# define _LIBCPP_CONSTINIT constinit
959# elif __has_attribute(__require_constant_initialization__)959# elif __has_attribute(__require_constant_initialization__)
...@@ -1064,9 +1064,8 @@ typedef __char32_t char32_t;...@@ -1064,9 +1064,8 @@ typedef __char32_t char32_t;
1064# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")1064# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
1065# endif1065# endif
10661066
1067// TODO(varconst): currently, there are bugs in Clang's intrinsics when handling Objective-C++ `id`, so don't use1067// TODO(LLVM 22): Remove the workaround
1068// compiler intrinsics in the Objective-C++ mode.1068# if defined(__OBJC__) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER < 2001)
1069# ifdef __OBJC__
1070# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS1069# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1071# endif1070# endif
10721071
...@@ -1119,26 +1118,28 @@ typedef __char32_t char32_t;...@@ -1119,26 +1118,28 @@ typedef __char32_t char32_t;
11191118
1120// Optional attributes - these are useful for a better QoI, but not required to be available1119// Optional attributes - these are useful for a better QoI, but not required to be available
11211120
1121# define _LIBCPP_NOALIAS __attribute__((__malloc__))
1122# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
1123# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
1124# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
1125# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1126 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1127# define _LIBCPP_PACKED __attribute__((__packed__))
1128
1122# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)1129# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
1123# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))1130# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
1124# else1131# else
1125# define _LIBCPP_NO_CFI1132# define _LIBCPP_NO_CFI
1126# endif1133# endif
11271134
1128# if __has_attribute(__malloc__)
1129# define _LIBCPP_NOALIAS __attribute__((__malloc__))
1130# else
1131# define _LIBCPP_NOALIAS
1132# endif
1133
1134# if __has_attribute(__using_if_exists__)1135# if __has_attribute(__using_if_exists__)
1135# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))1136# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
1136# else1137# else
1137# define _LIBCPP_USING_IF_EXISTS1138# define _LIBCPP_USING_IF_EXISTS
1138# endif1139# endif
11391140
1140# if __has_attribute(__no_destroy__)1141# if __has_cpp_attribute(_Clang::__no_destroy__)
1141# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))1142# define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]]
1142# else1143# else
1143# define _LIBCPP_NO_DESTROY1144# define _LIBCPP_NO_DESTROY
1144# endif1145# endif
...@@ -1149,15 +1150,6 @@ typedef __char32_t char32_t;...@@ -1149,15 +1150,6 @@ typedef __char32_t char32_t;
1149# define _LIBCPP_DIAGNOSE_WARNING(...)1150# define _LIBCPP_DIAGNOSE_WARNING(...)
1150# endif1151# endif
11511152
1152// Use a function like macro to imply that it must be followed by a semicolon
1153# if __has_cpp_attribute(fallthrough)
1154# define _LIBCPP_FALLTHROUGH() [[fallthrough]]
1155# elif __has_attribute(__fallthrough__)
1156# define _LIBCPP_FALLTHROUGH() __attribute__((__fallthrough__))
1157# else
1158# define _LIBCPP_FALLTHROUGH() ((void)0)
1159# endif
1160
1161# if __has_cpp_attribute(_Clang::__lifetimebound__)1153# if __has_cpp_attribute(_Clang::__lifetimebound__)
1162# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]1154# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
1163# else1155# else
...@@ -1170,8 +1162,6 @@ typedef __char32_t char32_t;...@@ -1170,8 +1162,6 @@ typedef __char32_t char32_t;
1170# define _LIBCPP_NOESCAPE1162# define _LIBCPP_NOESCAPE
1171# endif1163# endif
11721164
1173# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
1174
1175# if __has_cpp_attribute(_Clang::__no_specializations__)1165# if __has_cpp_attribute(_Clang::__no_specializations__)
1176# define _LIBCPP_NO_SPECIALIZATIONS \1166# define _LIBCPP_NO_SPECIALIZATIONS \
1177 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]1167 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
...@@ -1179,43 +1169,70 @@ typedef __char32_t char32_t;...@@ -1179,43 +1169,70 @@ typedef __char32_t char32_t;
1179# define _LIBCPP_NO_SPECIALIZATIONS1169# define _LIBCPP_NO_SPECIALIZATIONS
1180# endif1170# endif
11811171
1182# if __has_attribute(__standalone_debug__)1172# if __has_cpp_attribute(_Clang::__standalone_debug__)
1183# define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))1173# define _LIBCPP_STANDALONE_DEBUG [[_Clang::__standalone_debug__]]
1184# else1174# else
1185# define _LIBCPP_STANDALONE_DEBUG1175# define _LIBCPP_STANDALONE_DEBUG
1186# endif1176# endif
11871177
1188# if __has_attribute(__preferred_name__)1178# if __has_cpp_attribute(_Clang::__preferred_name__)
1189# define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))1179# define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]]
1190# else1180# else
1191# define _LIBCPP_PREFERRED_NAME(x)1181# define _LIBCPP_PREFERRED_NAME(x)
1192# endif1182# endif
11931183
1194# if __has_attribute(__no_sanitize__)1184# if __has_cpp_attribute(_Clang::__scoped_lockable__)
1195# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))1185# define _LIBCPP_SCOPED_LOCKABLE [[_Clang::__scoped_lockable__]]
1186# else
1187# define _LIBCPP_SCOPED_LOCKABLE
1188# endif
1189
1190# if __has_cpp_attribute(_Clang::__capability__)
1191# define _LIBCPP_CAPABILITY(...) [[_Clang::__capability__(__VA_ARGS__)]]
1196# else1192# else
1197# define _LIBCPP_NO_SANITIZE(...)1193# define _LIBCPP_CAPABILITY(...)
1198# endif1194# endif
11991195
1200# if __has_attribute(__init_priority__)1196# if __has_attribute(__acquire_capability__)
1201# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))1197# define _LIBCPP_ACQUIRE_CAPABILITY(...) __attribute__((__acquire_capability__(__VA_ARGS__)))
1202# else1198# else
1203# define _LIBCPP_INIT_PRIORITY_MAX1199# define _LIBCPP_ACQUIRE_CAPABILITY(...)
1204# endif1200# endif
12051201
1206# if __has_attribute(__format__)1202# if __has_cpp_attribute(_Clang::__try_acquire_capability__)
1207// The attribute uses 1-based indices for ordinary and static member functions.1203# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) [[_Clang::__try_acquire_capability__(__VA_ARGS__)]]
1208// The attribute uses 2-based indices for non-static member functions.
1209# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
1210 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
1211# else1204# else
1212# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) /* nothing */1205# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...)
1213# endif1206# endif
12141207
1215# if __has_attribute(__packed__)1208# if __has_cpp_attribute(_Clang::__acquire_shared_capability__)
1216# define _LIBCPP_PACKED __attribute__((__packed__))1209# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY [[_Clang::__acquire_shared_capability__]]
1217# else1210# else
1218# define _LIBCPP_PACKED1211# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY
1212# endif
1213
1214# if __has_cpp_attribute(_Clang::__try_acquire_shared_capability__)
1215# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) [[_Clang::__try_acquire_shared_capability__(__VA_ARGS__)]]
1216# else
1217# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...)
1218# endif
1219
1220# if __has_cpp_attribute(_Clang::__release_capability__)
1221# define _LIBCPP_RELEASE_CAPABILITY [[_Clang::__release_capability__]]
1222# else
1223# define _LIBCPP_RELEASE_CAPABILITY
1224# endif
1225
1226# if __has_cpp_attribute(_Clang::__release_shared_capability__)
1227# define _LIBCPP_RELEASE_SHARED_CAPABILITY [[_Clang::__release_shared_capability__]]
1228# else
1229# define _LIBCPP_RELEASE_SHARED_CAPABILITY
1230# endif
1231
1232# if __has_attribute(__requires_capability__)
1233# define _LIBCPP_REQUIRES_CAPABILITY(...) __attribute__((__requires_capability__(__VA_ARGS__)))
1234# else
1235# define _LIBCPP_REQUIRES_CAPABILITY(...)
1219# endif1236# endif
12201237
1221# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)1238# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
...@@ -1231,6 +1248,13 @@ typedef __char32_t char32_t;...@@ -1231,6 +1248,13 @@ typedef __char32_t char32_t;
1231# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK1248# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1232# endif1249# endif
12331250
1251# if __has_feature(nullability)
1252# define _LIBCPP_DIAGNOSE_NULLPTR _Nonnull
1253# else
1254# define _LIBCPP_DIAGNOSE_NULLPTR
1255# endif
1256
1257// TODO(LLVM 22): Remove this macro once LLVM19 support ends. __cpp_explicit_this_parameter has been set in LLVM20.
1234// Clang-18 has support for deducing this, but it does not set the FTM.1258// Clang-18 has support for deducing this, but it does not set the FTM.
1235# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)1259# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)
1236# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 11260# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1
lib/libcxx/include/__configuration/abi.h+30-104
...@@ -38,92 +38,47 @@...@@ -38,92 +38,47 @@
38#endif38#endif
3939
40#if _LIBCPP_ABI_VERSION >= 240#if _LIBCPP_ABI_VERSION >= 2
41// Change short string representation so that string data starts at offset 0,41// TODO: Move the description of the remaining ABI flags to ABIGuarantees.rst or remove them.
42// improving its alignment in some cases.42
43# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
44// Fix deque iterator type in order to support incomplete types.
45# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
46// Fix undefined behavior in how std::list stores its linked nodes.
47# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
48// Fix undefined behavior in how __tree stores its end and parent nodes.
49# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
50// Fix undefined behavior in how __hash_table stores its pointer types.
51# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
52# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
53# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
54// Override the default return value of exception::what() for bad_function_call::what()43// Override the default return value of exception::what() for bad_function_call::what()
55// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).44// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).
56// This is an ABI break on platforms that sign and authenticate vtable function pointers45// This is an ABI break on platforms that sign and authenticate vtable function pointers
57// because it changes the mangling of the virtual function located in the vtable, which46// because it changes the mangling of the virtual function located in the vtable, which
58// changes how it gets signed.47// changes how it gets signed.
59# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE48# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
60// Enable optimized version of __do_get_(un)signed which avoids redundant copies.49// According to the Standard, `bitset::operator[] const` returns bool
61# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET50# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
62// Give reverse_iterator<T> one data member of type T, not two.51
63// Also, in C++17 and later, don't derive iterator types from std::iterator.52// In LLVM 20, we've changed to take these ABI breaks unconditionally. These flags only exist in case someone is running
53// into the static_asserts we added to catch the ABI break and don't care that it is one.
54// TODO(LLVM 22): Remove these flags
55# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
56# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
57# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
58# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
59
60// These flags are documented in ABIGuarantees.rst
61# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
62# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
63# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
64# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
65# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
66# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
67# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
68# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
69# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
70# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE
71# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
72# define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
64# define _LIBCPP_ABI_NO_ITERATOR_BASES73# define _LIBCPP_ABI_NO_ITERATOR_BASES
65// Use the smallest possible integer type to represent the index of the variant.74# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
66// Previously libc++ used "unsigned int" exclusively.
67# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
68// Unstable attempt to provide a more optimized std::function
69# define _LIBCPP_ABI_OPTIMIZED_FUNCTION75# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
70// All the regex constants must be distinct and nonzero.
71# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO76# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
72// Re-worked external template instantiations for std::string with a focus on
73// performance and fast-path inlining.
74# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION77# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
75// Enable clang::trivial_abi on std::unique_ptr.
76# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
77// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
78# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
79// std::random_device holds some state when it uses an implementation that gets
80// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
81// implementation to another one on a platform that has already shipped
82// std::random_device, one needs to retain the same object layout to remain ABI
83// compatible. This switch removes these workarounds for platforms that don't care
84// about ABI compatibility.
85# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
86// Don't export the legacy __basic_string_common class and its methods from the built library.
87# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
88// Don't export the legacy __vector_base_common class and its methods from the built library.
89# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
90// According to the Standard, `bitset::operator[] const` returns bool
91# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
92// Fix the implementation of CityHash used for std::hash<fundamental-type>.
93// This is an ABI break because `std::hash` will return a different result,
94// which means that hashing the same object in translation units built against
95// different versions of libc++ can return inconsistent results. This is especially
96// tricky since std::hash is used in the implementation of unordered containers.
97//
98// The incorrect implementation of CityHash has the problem that it drops some
99// bits on the floor.
100# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
101// Remove the base 10 implementation of std::to_chars from the dylib.
102// The implementation moved to the header, but we still export the symbols from
103// the dylib for backwards compatibility.
104# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
105// Define std::array/std::string_view iterators to be __wrap_iters instead of raw
106// pointers, which prevents people from relying on a non-portable implementation
107// detail. This is especially useful because enabling bounded iterators hardening
108// requires code not to make these assumptions.
109# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY78# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
110# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW79# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
111// Dont' add an inline namespace for `std::filesystem`80# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
112# define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE81
113// std::basic_ios uses WEOF to indicate that the fill value is
114// uninitialized. However, on platforms where the size of char_type is
115// equal to or greater than the size of int_type and char_type is unsigned,
116// std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF
117// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill
118// value has been initialized using a separate boolean, which changes the ABI.
119# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE
120// Historically, libc++ used a type called `__compressed_pair` to reduce storage needs in cases of empty types (e.g. an
121// empty allocator in std::vector). We switched to using `[[no_unique_address]]`. However, for ABI compatibility reasons
122// we had to add artificial padding in a few places.
123//
124// This setting disables the addition of such artificial padding, leading to a more optimal
125// representation for several types.
126# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
127#elif _LIBCPP_ABI_VERSION == 182#elif _LIBCPP_ABI_VERSION == 1
128# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))83# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
129// Enable compiling copies of now inline methods into the dylib to support84// Enable compiling copies of now inline methods into the dylib to support
...@@ -138,7 +93,7 @@...@@ -138,7 +93,7 @@
138# endif93# endif
139// Feature macros for disabling pre ABI v1 features. All of these options94// Feature macros for disabling pre ABI v1 features. All of these options
140// are deprecated.95// are deprecated.
141# if defined(__FreeBSD__) && __FreeBSD__ < 1496# if defined(__FreeBSD__)
142# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR97# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
143# endif98# endif
144#endif99#endif
...@@ -153,35 +108,6 @@...@@ -153,35 +108,6 @@
153// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.108// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.
154#define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))109#define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))
155110
156// Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
157// within the bounds of the original container and asserts it on every dereference.
158//
159// ABI impact: changes the iterator type of the relevant containers.
160//
161// Supported containers:
162// - `span`;
163// - `string_view`.
164// #define _LIBCPP_ABI_BOUNDED_ITERATORS
165
166// Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds
167// of the original container and asserts it on every dereference and when performing iterator arithmetics.
168//
169// ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`.
170// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
171
172// Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the
173// original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't
174// yet affect `vector<bool>`.
175//
176// ABI impact: changes the iterator type of `vector` (except `vector<bool>`).
177// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
178
179// Changes the iterator type of `array` to a bounded iterator that keeps track of whether it's within the bounds of the
180// container and asserts it on every dereference and when performing iterator arithmetic.
181//
182// ABI impact: changes the iterator type of `array`, its size and its layout.
183// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STD_ARRAY
184
185// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work.111// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work.
186#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING)112#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING)
187# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING113# define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
lib/libcxx/include/__configuration/availability.h+24-41
...@@ -69,7 +69,13 @@...@@ -69,7 +69,13 @@
6969
70// Availability markup is disabled when building the library, or when a non-Clang70// Availability markup is disabled when building the library, or when a non-Clang
71// compiler is used because only Clang supports the necessary attributes.71// compiler is used because only Clang supports the necessary attributes.
72#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)72//
73// We also allow users to force-disable availability markup via the `_LIBCPP_DISABLE_AVAILABILITY`
74// macro because that is the only way to work around a Clang bug related to availability
75// attributes: https://github.com/llvm/llvm-project/issues/134151.
76// Once that bug has been fixed, we should remove the macro.
77#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || \
78 !defined(_LIBCPP_COMPILER_CLANG_BASED) || defined(_LIBCPP_DISABLE_AVAILABILITY)
73# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS79# undef _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
74# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 080# define _LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS 0
75#endif81#endif
...@@ -78,6 +84,9 @@...@@ -78,6 +84,9 @@
78// in all versions of the library are available.84// in all versions of the library are available.
79#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS85#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
8086
87# define _LIBCPP_INTRODUCED_IN_LLVM_21 1
88# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */
89
81# define _LIBCPP_INTRODUCED_IN_LLVM_20 190# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
82# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */91# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */
8392
...@@ -107,13 +116,15 @@...@@ -107,13 +116,15 @@
107# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */116# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
108# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */117# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */
109118
110# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
111# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
112
113#elif defined(__APPLE__)119#elif defined(__APPLE__)
114120
115// clang-format off121// clang-format off
116122
123// LLVM 21
124// TODO: Fill this in
125# define _LIBCPP_INTRODUCED_IN_LLVM_21 0
126# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable))
127
117// LLVM 20128// LLVM 20
118// TODO: Fill this in129// TODO: Fill this in
119# define _LIBCPP_INTRODUCED_IN_LLVM_20 0130# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
...@@ -244,14 +255,6 @@...@@ -244,14 +255,6 @@
244 _Pragma("clang attribute pop") \255 _Pragma("clang attribute pop") \
245 _Pragma("clang attribute pop")256 _Pragma("clang attribute pop")
246257
247// LLVM 4
248# if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000
249# define _LIBCPP_INTRODUCED_IN_LLVM_4 0
250# else
251# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
252# endif
253# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0)))
254
255// clang-format on258// clang-format on
256259
257#else260#else
...@@ -263,23 +266,6 @@...@@ -263,23 +266,6 @@
263266
264#endif267#endif
265268
266// These macros control the availability of std::bad_optional_access and
267// other exception types. These were put in the shared library to prevent
268// code bloat from every user program defining the vtable for these exception
269// types.
270//
271// Note that when exceptions are disabled, the methods that normally throw
272// these exceptions can be used even on older deployment targets, but those
273// methods will abort instead of throwing.
274#define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
275#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
276
277#define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
278#define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
279
280#define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4
281#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
282
283// These macros control the availability of all parts of <filesystem> that269// These macros control the availability of all parts of <filesystem> that
284// depend on something in the dylib.270// depend on something in the dylib.
285#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9271#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9
...@@ -359,18 +345,15 @@...@@ -359,18 +345,15 @@
359#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20345#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
360#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE346#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
361347
362// Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS.348// This controls whether `std::__hash_memory` is available in the dylib, which
363// Those are defined in terms of the availability attributes above, and349// is used for some `std::hash` specializations.
364// should not be vendor-specific.350#define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21
365#if !_LIBCPP_HAS_EXCEPTIONS351// No attribute, since we've had hash in the headers before
366# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST352
367# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS353// This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`.
368# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS354// See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib.
369#else355#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
370# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST356// No attribute, since we've had bad_function_call::what() in the headers before
371# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
372# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
373#endif
374357
375// Define availability attributes that depend on both358// Define availability attributes that depend on both
376// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.359// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
lib/libcxx/include/__configuration/compiler.h+2-2
...@@ -33,8 +33,8 @@...@@ -33,8 +33,8 @@
33// Warn if a compiler version is used that is not supported anymore33// Warn if a compiler version is used that is not supported anymore
34// LLVM RELEASE Update the minimum compiler versions34// LLVM RELEASE Update the minimum compiler versions
35# if defined(_LIBCPP_CLANG_VER)35# if defined(_LIBCPP_CLANG_VER)
36# if _LIBCPP_CLANG_VER < 180036# if _LIBCPP_CLANG_VER < 1900
37# warning "Libc++ only supports Clang 18 and later"37# warning "Libc++ only supports Clang 19 and later"
38# endif38# endif
39# elif defined(_LIBCPP_APPLE_CLANG_VER)39# elif defined(_LIBCPP_APPLE_CLANG_VER)
40# if _LIBCPP_APPLE_CLANG_VER < 150040# if _LIBCPP_APPLE_CLANG_VER < 1500
lib/libcxx/include/__configuration/platform.h+7
...@@ -42,6 +42,13 @@...@@ -42,6 +42,13 @@
42# endif42# endif
43#endif43#endif
4444
45// This is required in order for _NEWLIB_VERSION to be defined in places where we use it.
46// TODO: We shouldn't be including arbitrarily-named headers from libc++ since this can break valid
47// user code. Move code paths that need _NEWLIB_VERSION to another customization mechanism.
48#if __has_include(<picolibc.h>)
49# include <picolibc.h>
50#endif
51
45#ifndef __BYTE_ORDER__52#ifndef __BYTE_ORDER__
46# error \53# error \
47 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"54 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
lib/libcxx/include/__coroutine/coroutine_handle.h+4-4
...@@ -28,10 +28,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,10 +28,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
29// [coroutine.handle]29// [coroutine.handle]
30template <class _Promise = void>30template <class _Promise = void>
31struct _LIBCPP_TEMPLATE_VIS coroutine_handle;31struct coroutine_handle;
3232
33template <>33template <>
34struct _LIBCPP_TEMPLATE_VIS coroutine_handle<void> {34struct coroutine_handle<void> {
35public:35public:
36 // [coroutine.handle.con], construct/reset36 // [coroutine.handle.con], construct/reset
37 constexpr coroutine_handle() noexcept = default;37 constexpr coroutine_handle() noexcept = default;
...@@ -93,7 +93,7 @@ operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {...@@ -93,7 +93,7 @@ operator<=>(coroutine_handle<> __x, coroutine_handle<> __y) noexcept {
93}93}
9494
95template <class _Promise>95template <class _Promise>
96struct _LIBCPP_TEMPLATE_VIS coroutine_handle {96struct coroutine_handle {
97public:97public:
98 // [coroutine.handle.con], construct/reset98 // [coroutine.handle.con], construct/reset
99 constexpr coroutine_handle() noexcept = default;99 constexpr coroutine_handle() noexcept = default;
...@@ -172,6 +172,6 @@ struct hash<coroutine_handle<_Tp>> {...@@ -172,6 +172,6 @@ struct hash<coroutine_handle<_Tp>> {
172172
173_LIBCPP_END_NAMESPACE_STD173_LIBCPP_END_NAMESPACE_STD
174174
175#endif // __LIBCPP_STD_VER >= 20175#endif // _LIBCPP_STD_VER >= 20
176176
177#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H177#endif // _LIBCPP___COROUTINE_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/coroutine_traits.h+1-1
...@@ -43,6 +43,6 @@ struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {};...@@ -43,6 +43,6 @@ struct coroutine_traits : public __coroutine_traits_sfinae<_Ret> {};
4343
44_LIBCPP_END_NAMESPACE_STD44_LIBCPP_END_NAMESPACE_STD
4545
46#endif // __LIBCPP_STD_VER >= 2046#endif // _LIBCPP_STD_VER >= 20
4747
48#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H48#endif // _LIBCPP___COROUTINE_COROUTINE_TRAITS_H
lib/libcxx/include/__coroutine/noop_coroutine_handle.h+2-2
...@@ -28,7 +28,7 @@ struct noop_coroutine_promise {};...@@ -28,7 +28,7 @@ struct noop_coroutine_promise {};
2828
29// [coroutine.handle.noop]29// [coroutine.handle.noop]
30template <>30template <>
31struct _LIBCPP_TEMPLATE_VIS coroutine_handle<noop_coroutine_promise> {31struct coroutine_handle<noop_coroutine_promise> {
32public:32public:
33 // [coroutine.handle.noop.conv], conversion33 // [coroutine.handle.noop.conv], conversion
34 _LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept {34 _LIBCPP_HIDE_FROM_ABI constexpr operator coroutine_handle<>() const noexcept {
...@@ -94,6 +94,6 @@ inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { r...@@ -94,6 +94,6 @@ inline _LIBCPP_HIDE_FROM_ABI noop_coroutine_handle noop_coroutine() noexcept { r
9494
95_LIBCPP_END_NAMESPACE_STD95_LIBCPP_END_NAMESPACE_STD
9696
97#endif // __LIBCPP_STD_VER >= 2097#endif // _LIBCPP_STD_VER >= 20
9898
99#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H99#endif // _LIBCPP___COROUTINE_NOOP_COROUTINE_HANDLE_H
lib/libcxx/include/__coroutine/trivial_awaitables.h+1-1
...@@ -35,6 +35,6 @@ struct suspend_always {...@@ -35,6 +35,6 @@ struct suspend_always {
3535
36_LIBCPP_END_NAMESPACE_STD36_LIBCPP_END_NAMESPACE_STD
3737
38#endif // __LIBCPP_STD_VER >= 2038#endif // _LIBCPP_STD_VER >= 20
3939
40#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H40#endif // __LIBCPP___COROUTINE_TRIVIAL_AWAITABLES_H
lib/libcxx/include/__cstddef/byte.h+2-2
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19#endif19#endif
2020
21#if _LIBCPP_STD_VER >= 1721#if _LIBCPP_STD_VER >= 17
22namespace std { // purposefully not versioned22_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
2323
24enum class byte : unsigned char {};24enum class byte : unsigned char {};
2525
...@@ -79,7 +79,7 @@ template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>...@@ -79,7 +79,7 @@ template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
79 return static_cast<_Integer>(__b);79 return static_cast<_Integer>(__b);
80}80}
8181
82} // namespace std82_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
83#endif // _LIBCPP_STD_VER >= 1783#endif // _LIBCPP_STD_VER >= 17
8484
85#endif // _LIBCPP___CSTDDEF_BYTE_H85#endif // _LIBCPP___CSTDDEF_BYTE_H
lib/libcxx/include/__debug_utils/sanitizers.h+5-5
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20#if _LIBCPP_HAS_ASAN20#if __has_feature(address_sanitizer)
2121
22extern "C" {22extern "C" {
23_LIBCPP_EXPORTED_FROM_ABI void23_LIBCPP_EXPORTED_FROM_ABI void
...@@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int...@@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int
28__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);28__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
29}29}
3030
31#endif // _LIBCPP_HAS_ASAN31#endif // __has_feature(address_sanitizer)
3232
33_LIBCPP_BEGIN_NAMESPACE_STD33_LIBCPP_BEGIN_NAMESPACE_STD
3434
35// ASan choices35// ASan choices
36#if _LIBCPP_HAS_ASAN36#if __has_feature(address_sanitizer)
37# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 137# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1
38#endif38#endif
3939
...@@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(...@@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
57 const void* __last_old_contained,57 const void* __last_old_contained,
58 const void* __first_new_contained,58 const void* __first_new_contained,
59 const void* __last_new_contained) {59 const void* __last_new_contained) {
60#if !_LIBCPP_HAS_ASAN60#if !__has_feature(address_sanitizer)
61 (void)__first_storage;61 (void)__first_storage;
62 (void)__last_storage;62 (void)__last_storage;
63 (void)__first_old_contained;63 (void)__first_old_contained;
...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c...@@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c
86 const void* __last_storage,86 const void* __last_storage,
87 const void* __old_last_contained,87 const void* __old_last_contained,
88 const void* __new_last_contained) {88 const void* __new_last_contained) {
89#if !_LIBCPP_HAS_ASAN89#if !__has_feature(address_sanitizer)
90 (void)__first_storage;90 (void)__first_storage;
91 (void)__last_storage;91 (void)__last_storage;
92 (void)__old_last_contained;92 (void)__old_last_contained;
lib/libcxx/include/__exception/exception.h+2-2
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
21# pragma GCC system_header21# pragma GCC system_header
22#endif22#endif
2323
24namespace std { // purposefully not using versioning namespace24_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
2525
26#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)26#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
27// The std::exception class was already included above, but we're explicit about this condition here for clarity.27// The std::exception class was already included above, but we're explicit about this condition here for clarity.
...@@ -89,6 +89,6 @@ public:...@@ -89,6 +89,6 @@ public:
89};89};
90#endif // !_LIBCPP_ABI_VCRUNTIME90#endif // !_LIBCPP_ABI_VCRUNTIME
9191
92} // namespace std92_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
9393
94#endif // _LIBCPP___EXCEPTION_EXCEPTION_H94#endif // _LIBCPP___EXCEPTION_EXCEPTION_H
lib/libcxx/include/__exception/exception_ptr.h+49-21
...@@ -15,6 +15,7 @@...@@ -15,6 +15,7 @@
15#include <__memory/addressof.h>15#include <__memory/addressof.h>
16#include <__memory/construct_at.h>16#include <__memory/construct_at.h>
17#include <__type_traits/decay.h>17#include <__type_traits/decay.h>
18#include <__type_traits/is_pointer.h>
18#include <cstdlib>19#include <cstdlib>
19#include <typeinfo>20#include <typeinfo>
2021
...@@ -52,7 +53,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(...@@ -52,7 +53,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
5253
53#endif54#endif
5455
55namespace std { // purposefully not using versioning namespace56_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
5657
57#ifndef _LIBCPP_ABI_MICROSOFT58#ifndef _LIBCPP_ABI_MICROSOFT
5859
...@@ -62,11 +63,13 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {...@@ -62,11 +63,13 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
62 static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;63 static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
6364
64 template <class _Ep>65 template <class _Ep>
65 friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;66 friend _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep&) _NOEXCEPT;
6667
67public:68public:
68 // exception_ptr is basically a COW string.69 // exception_ptr is basically a COW string so it is trivially relocatable.
70 // It is also replaceable because assignment has normal value semantics.
69 using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr;71 using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr;
72 using __replaceable _LIBCPP_NODEBUG = exception_ptr;
7073
71 _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}74 _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
72 _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}75 _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
...@@ -89,25 +92,21 @@ public:...@@ -89,25 +92,21 @@ public:
89 friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);92 friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
90};93};
9194
92template <class _Ep>
93_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
94# if _LIBCPP_HAS_EXCEPTIONS95# if _LIBCPP_HAS_EXCEPTIONS
95# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L96# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
97template <class _Ep>
98_LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep& __e) _NOEXCEPT {
96 using _Ep2 = __decay_t<_Ep>;99 using _Ep2 = __decay_t<_Ep>;
97
98 void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));100 void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
99# ifdef __wasm__101# ifdef __wasm__
100 // In Wasm, a destructor returns its argument102 auto __cleanup = [](void* __p) -> void* {
101 (void)__cxxabiv1::__cxa_init_primary_exception(103 std::__destroy_at(static_cast<_Ep2*>(__p));
102 __ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* {104 return __p;
105 };
103# else106# else
104 (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {107 auto __cleanup = [](void* __p) { std::__destroy_at(static_cast<_Ep2*>(__p)); };
105# endif
106 std::__destroy_at(static_cast<_Ep2*>(__p));
107# ifdef __wasm__
108 return __p;
109# endif108# endif
110 });109 (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), __cleanup);
111110
112 try {111 try {
113 ::new (__ex) _Ep2(__e);112 ::new (__ex) _Ep2(__e);
...@@ -116,18 +115,47 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {...@@ -116,18 +115,47 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
116 __cxxabiv1::__cxa_free_exception(__ex);115 __cxxabiv1::__cxa_free_exception(__ex);
117 return current_exception();116 return current_exception();
118 }117 }
119# else118}
119# endif
120
121template <class _Ep>
122_LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_via_throw(_Ep& __e) _NOEXCEPT {
120 try {123 try {
121 throw __e;124 throw __e;
122 } catch (...) {125 } catch (...) {
123 return current_exception();126 return current_exception();
124 }127 }
128}
129
130template <class _Ep>
131_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
132 // Objective-C exceptions are thrown via pointer. When throwing an Objective-C exception,
133 // Clang generates a call to `objc_exception_throw` instead of the usual `__cxa_throw`.
134 // That function creates an exception with a special Objective-C typeinfo instead of
135 // the usual C++ typeinfo, since that is needed to implement the behavior documented
136 // at [1]).
137 //
138 // Because of this special behavior, we can't create an exception via `__cxa_init_primary_exception`
139 // for Objective-C exceptions, otherwise we'd bypass `objc_exception_throw`. See https://llvm.org/PR135089.
140 //
141 // [1]:
142 // https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Exceptions/Articles/Exceptions64Bit.html
143 if _LIBCPP_CONSTEXPR (is_pointer<_Ep>::value) {
144 return std::__make_exception_ptr_via_throw(__e);
145 }
146
147# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && !defined(_LIBCPP_CXX03_LANG)
148 return std::__make_exception_ptr_explicit(__e);
149# else
150 return std::__make_exception_ptr_via_throw(__e);
125# endif151# endif
126# else152}
127 ((void)__e);153# else // !_LIBCPP_HAS_EXCEPTIONS
154template <class _Ep>
155_LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT {
128 std::abort();156 std::abort();
129# endif
130}157}
158# endif // _LIBCPP_HAS_EXCEPTIONS
131159
132#else // _LIBCPP_ABI_MICROSOFT160#else // _LIBCPP_ABI_MICROSOFT
133161
...@@ -171,6 +199,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {...@@ -171,6 +199,6 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
171}199}
172200
173#endif // _LIBCPP_ABI_MICROSOFT201#endif // _LIBCPP_ABI_MICROSOFT
174} // namespace std202_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
175203
176#endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H204#endif // _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
lib/libcxx/include/__exception/nested_exception.h+2-2
...@@ -27,7 +27,7 @@...@@ -27,7 +27,7 @@
27# pragma GCC system_header27# pragma GCC system_header
28#endif28#endif
2929
30namespace std { // purposefully not using versioning namespace30_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
3131
32class _LIBCPP_EXPORTED_FROM_ABI nested_exception {32class _LIBCPP_EXPORTED_FROM_ABI nested_exception {
33 exception_ptr __ptr_;33 exception_ptr __ptr_;
...@@ -95,6 +95,6 @@ inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) {...@@ -95,6 +95,6 @@ inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) {
95template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>95template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>
96inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {}96inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {}
9797
98} // namespace std98_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
9999
100#endif // _LIBCPP___EXCEPTION_NESTED_EXCEPTION_H100#endif // _LIBCPP___EXCEPTION_NESTED_EXCEPTION_H
lib/libcxx/include/__exception/operations.h+2-2
...@@ -15,7 +15,7 @@...@@ -15,7 +15,7 @@
15# pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18namespace std { // purposefully not using versioning namespace18_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
19#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \19#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \
20 defined(_LIBCPP_BUILDING_LIBRARY)20 defined(_LIBCPP_BUILDING_LIBRARY)
21using unexpected_handler = void (*)();21using unexpected_handler = void (*)();
...@@ -37,6 +37,6 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;...@@ -37,6 +37,6 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
3737
38_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;38_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
39[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);39[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
40} // namespace std40_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
4141
42#endif // _LIBCPP___EXCEPTION_OPERATIONS_H42#endif // _LIBCPP___EXCEPTION_OPERATIONS_H
lib/libcxx/include/__exception/terminate.h+2-2
...@@ -15,8 +15,8 @@...@@ -15,8 +15,8 @@
15# pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18namespace std { // purposefully not using versioning namespace18_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
19[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;19[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;
20} // namespace std20_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
2121
22#endif // _LIBCPP___EXCEPTION_TERMINATE_H22#endif // _LIBCPP___EXCEPTION_TERMINATE_H
lib/libcxx/include/__expected/expected.h+40-5
...@@ -25,10 +25,12 @@...@@ -25,10 +25,12 @@
25#include <__type_traits/is_assignable.h>25#include <__type_traits/is_assignable.h>
26#include <__type_traits/is_constructible.h>26#include <__type_traits/is_constructible.h>
27#include <__type_traits/is_convertible.h>27#include <__type_traits/is_convertible.h>
28#include <__type_traits/is_core_convertible.h>
28#include <__type_traits/is_function.h>29#include <__type_traits/is_function.h>
29#include <__type_traits/is_nothrow_assignable.h>30#include <__type_traits/is_nothrow_assignable.h>
30#include <__type_traits/is_nothrow_constructible.h>31#include <__type_traits/is_nothrow_constructible.h>
31#include <__type_traits/is_reference.h>32#include <__type_traits/is_reference.h>
33#include <__type_traits/is_replaceable.h>
32#include <__type_traits/is_same.h>34#include <__type_traits/is_same.h>
33#include <__type_traits/is_swappable.h>35#include <__type_traits/is_swappable.h>
34#include <__type_traits/is_trivially_constructible.h>36#include <__type_traits/is_trivially_constructible.h>
...@@ -470,6 +472,8 @@ public:...@@ -470,6 +472,8 @@ public:
470 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,472 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,
471 expected,473 expected,
472 void>;474 void>;
475 using __replaceable _LIBCPP_NODEBUG =
476 __conditional_t<__is_replaceable_v<_Tp> && __is_replaceable_v<_Err>, expected, void>;
473477
474 template <class _Up>478 template <class _Up>
475 using rebind = expected<_Up, error_type>;479 using rebind = expected<_Up, error_type>;
...@@ -1139,8 +1143,15 @@ public:...@@ -1139,8 +1143,15 @@ public:
11391143
1140 // [expected.object.eq], equality operators1144 // [expected.object.eq], equality operators
1141 template <class _T2, class _E2>1145 template <class _T2, class _E2>
1146 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y)
1142 requires(!is_void_v<_T2>)1147 requires(!is_void_v<_T2>)
1143 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {1148# if _LIBCPP_STD_VER >= 26
1149 && requires {
1150 { *__x == *__y } -> __core_convertible_to<bool>;
1151 { __x.error() == __y.error() } -> __core_convertible_to<bool>;
1152 }
1153# endif
1154 {
1144 if (__x.__has_val() != __y.__has_val()) {1155 if (__x.__has_val() != __y.__has_val()) {
1145 return false;1156 return false;
1146 } else {1157 } else {
...@@ -1153,12 +1164,24 @@ public:...@@ -1153,12 +1164,24 @@ public:
1153 }1164 }
11541165
1155 template <class _T2>1166 template <class _T2>
1156 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v) {1167 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v)
1168# if _LIBCPP_STD_VER >= 26
1169 requires(!__is_std_expected<_T2>::value) && requires {
1170 { *__x == __v } -> __core_convertible_to<bool>;
1171 }
1172# endif
1173 {
1157 return __x.__has_val() && static_cast<bool>(__x.__val() == __v);1174 return __x.__has_val() && static_cast<bool>(__x.__val() == __v);
1158 }1175 }
11591176
1160 template <class _E2>1177 template <class _E2>
1161 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e) {1178 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __e)
1179# if _LIBCPP_STD_VER >= 26
1180 requires requires {
1181 { __x.error() == __e.error() } -> __core_convertible_to<bool>;
1182 }
1183# endif
1184 {
1162 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __e.error());1185 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __e.error());
1163 }1186 }
1164};1187};
...@@ -1851,7 +1874,13 @@ public:...@@ -1851,7 +1874,13 @@ public:
1851 // [expected.void.eq], equality operators1874 // [expected.void.eq], equality operators
1852 template <class _T2, class _E2>1875 template <class _T2, class _E2>
1853 requires is_void_v<_T2>1876 requires is_void_v<_T2>
1854 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y) {1877 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const expected<_T2, _E2>& __y)
1878# if _LIBCPP_STD_VER >= 26
1879 requires requires {
1880 { __x.error() == __y.error() } -> __core_convertible_to<bool>;
1881 }
1882# endif
1883 {
1855 if (__x.__has_val() != __y.__has_val()) {1884 if (__x.__has_val() != __y.__has_val()) {
1856 return false;1885 return false;
1857 } else {1886 } else {
...@@ -1860,7 +1889,13 @@ public:...@@ -1860,7 +1889,13 @@ public:
1860 }1889 }
18611890
1862 template <class _E2>1891 template <class _E2>
1863 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y) {1892 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const unexpected<_E2>& __y)
1893# if _LIBCPP_STD_VER >= 26
1894 requires requires {
1895 { __x.error() == __y.error() } -> __core_convertible_to<bool>;
1896 }
1897# endif
1898 {
1864 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __y.error());1899 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __y.error());
1865 }1900 }
1866};1901};
lib/libcxx/include/__filesystem/directory_entry.h+1-1
...@@ -286,7 +286,7 @@ private:...@@ -286,7 +286,7 @@ private:
286 return;286 return;
287 }287 }
288 if (__ec && (!__allow_dne || !__is_dne_error(__ec)))288 if (__ec && (!__allow_dne || !__is_dne_error(__ec)))
289 __throw_filesystem_error(__msg, __p_, __ec);289 filesystem::__throw_filesystem_error(__msg, __p_, __ec);
290 }290 }
291291
292 _LIBCPP_HIDE_FROM_ABI void __refresh(error_code* __ec = nullptr) {292 _LIBCPP_HIDE_FROM_ABI void __refresh(error_code* __ec = nullptr) {
lib/libcxx/include/__filesystem/operations.h+3-3
...@@ -66,6 +66,9 @@ _LIBCPP_EXPORTED_FROM_ABI bool __remove(const path&, error_code* __ec = nullptr)...@@ -66,6 +66,9 @@ _LIBCPP_EXPORTED_FROM_ABI bool __remove(const path&, error_code* __ec = nullptr)
66_LIBCPP_EXPORTED_FROM_ABI void __rename(const path& __from, const path& __to, error_code* __ec = nullptr);66_LIBCPP_EXPORTED_FROM_ABI void __rename(const path& __from, const path& __to, error_code* __ec = nullptr);
67_LIBCPP_EXPORTED_FROM_ABI void __resize_file(const path&, uintmax_t __size, error_code* = nullptr);67_LIBCPP_EXPORTED_FROM_ABI void __resize_file(const path&, uintmax_t __size, error_code* = nullptr);
68_LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr);68_LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr);
69_LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
70_LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr);
71_LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr);
6972
70inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }73inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
71inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }74inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) { return __absolute(__p, &__ec); }
...@@ -182,7 +185,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_dire...@@ -182,7 +185,6 @@ inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p) { return is_dire
182inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept {185inline _LIBCPP_HIDE_FROM_ABI bool is_directory(const path& __p, error_code& __ec) noexcept {
183 return is_directory(__status(__p, &__ec));186 return is_directory(__status(__p, &__ec));
184}187}
185_LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
186inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }188inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p) { return __fs_is_empty(__p); }
187inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }189inline _LIBCPP_HIDE_FROM_ABI bool is_empty(const path& __p, error_code& __ec) { return __fs_is_empty(__p, &__ec); }
188inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }190inline _LIBCPP_HIDE_FROM_ABI bool is_fifo(file_status __s) noexcept { return __s.type() == file_type::fifo; }
...@@ -220,7 +222,6 @@ inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_typ...@@ -220,7 +222,6 @@ inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_typ
220inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept {222inline _LIBCPP_HIDE_FROM_ABI void last_write_time(const path& __p, file_time_type __t, error_code& __ec) noexcept {
221 __last_write_time(__p, __t, &__ec);223 __last_write_time(__p, __t, &__ec);
222}224}
223_LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr);
224inline _LIBCPP_HIDE_FROM_ABI void225inline _LIBCPP_HIDE_FROM_ABI void
225permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) {226permissions(const path& __p, perms __prms, perm_options __opts = perm_options::replace) {
226 __permissions(__p, __prms, __opts);227 __permissions(__p, __prms, __opts);
...@@ -281,7 +282,6 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) {...@@ -281,7 +282,6 @@ inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns) {
281inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept {282inline _LIBCPP_HIDE_FROM_ABI void resize_file(const path& __p, uintmax_t __ns, error_code& __ec) noexcept {
282 return __resize_file(__p, __ns, &__ec);283 return __resize_file(__p, __ns, &__ec);
283}284}
284_LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr);
285inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }285inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p) { return __space(__p); }
286inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept {286inline _LIBCPP_HIDE_FROM_ABI space_info space(const path& __p, error_code& __ec) noexcept {
287 return __space(__p, &__ec);287 return __space(__p, &__ec);
lib/libcxx/include/__filesystem/path.h+3-2
...@@ -17,7 +17,9 @@...@@ -17,7 +17,9 @@
17#include <__fwd/functional.h>17#include <__fwd/functional.h>
18#include <__iterator/back_insert_iterator.h>18#include <__iterator/back_insert_iterator.h>
19#include <__iterator/iterator_traits.h>19#include <__iterator/iterator_traits.h>
20#include <__memory/addressof.h>
20#include <__type_traits/decay.h>21#include <__type_traits/decay.h>
22#include <__type_traits/enable_if.h>
21#include <__type_traits/is_pointer.h>23#include <__type_traits/is_pointer.h>
22#include <__type_traits/remove_const.h>24#include <__type_traits/remove_const.h>
23#include <__type_traits/remove_pointer.h>25#include <__type_traits/remove_pointer.h>
...@@ -27,7 +29,6 @@...@@ -27,7 +29,6 @@
2729
28#if _LIBCPP_HAS_LOCALIZATION30#if _LIBCPP_HAS_LOCALIZATION
29# include <iomanip> // for quoted31# include <iomanip> // for quoted
30# include <locale>
31#endif32#endif
3233
33#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -583,7 +584,7 @@ public:...@@ -583,7 +584,7 @@ public:
583584
584 template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>585 template <class _ECharT, __enable_if_t<__can_convert_char<_ECharT>::value, int> = 0>
585 _LIBCPP_HIDE_FROM_ABI path& operator+=(_ECharT __x) {586 _LIBCPP_HIDE_FROM_ABI path& operator+=(_ECharT __x) {
586 _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(&__x, 1));587 _PathCVT<_ECharT>::__append_source(__pn_, basic_string_view<_ECharT>(std::addressof(__x), 1));
587 return *this;588 return *this;
588 }589 }
589590
lib/libcxx/include/__filesystem/u8path.h+1-6
...@@ -13,14 +13,9 @@...@@ -13,14 +13,9 @@
13#include <__algorithm/unwrap_iter.h>13#include <__algorithm/unwrap_iter.h>
14#include <__config>14#include <__config>
15#include <__filesystem/path.h>15#include <__filesystem/path.h>
16#include <__locale>
16#include <string>17#include <string>
1718
18// Only required on Windows for __widen_from_utf8, and included conservatively
19// because it requires support for localization.
20#if defined(_LIBCPP_WIN32API)
21# include <locale>
22#endif
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header20# pragma GCC system_header
26#endif21#endif
lib/libcxx/include/__flat_map/flat_map.h+258-185
...@@ -11,16 +11,15 @@...@@ -11,16 +11,15 @@
11#define _LIBCPP___FLAT_MAP_FLAT_MAP_H11#define _LIBCPP___FLAT_MAP_FLAT_MAP_H
1212
13#include <__algorithm/lexicographical_compare_three_way.h>13#include <__algorithm/lexicographical_compare_three_way.h>
14#include <__algorithm/lower_bound.h>
14#include <__algorithm/min.h>15#include <__algorithm/min.h>
15#include <__algorithm/ranges_adjacent_find.h>16#include <__algorithm/ranges_adjacent_find.h>
16#include <__algorithm/ranges_equal.h>17#include <__algorithm/ranges_equal.h>
17#include <__algorithm/ranges_inplace_merge.h>18#include <__algorithm/ranges_inplace_merge.h>
18#include <__algorithm/ranges_lower_bound.h>
19#include <__algorithm/ranges_partition_point.h>
20#include <__algorithm/ranges_sort.h>19#include <__algorithm/ranges_sort.h>
21#include <__algorithm/ranges_unique.h>20#include <__algorithm/ranges_unique.h>
22#include <__algorithm/ranges_upper_bound.h>
23#include <__algorithm/remove_if.h>21#include <__algorithm/remove_if.h>
22#include <__algorithm/upper_bound.h>
24#include <__assert>23#include <__assert>
25#include <__compare/synth_three_way.h>24#include <__compare/synth_three_way.h>
26#include <__concepts/swappable.h>25#include <__concepts/swappable.h>
...@@ -33,6 +32,7 @@...@@ -33,6 +32,7 @@
33#include <__functional/invoke.h>32#include <__functional/invoke.h>
34#include <__functional/is_transparent.h>33#include <__functional/is_transparent.h>
35#include <__functional/operations.h>34#include <__functional/operations.h>
35#include <__fwd/memory.h>
36#include <__fwd/vector.h>36#include <__fwd/vector.h>
37#include <__iterator/concepts.h>37#include <__iterator/concepts.h>
38#include <__iterator/distance.h>38#include <__iterator/distance.h>
...@@ -114,11 +114,12 @@ public:...@@ -114,11 +114,12 @@ public:
114 class value_compare {114 class value_compare {
115 private:115 private:
116 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;116 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __comp_;
117 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : __comp_(__c) {}
118 friend flat_map;118 friend flat_map;
119119
120 public:120 public:
121 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
122 operator()(const_reference __x, const_reference __y) const {
122 return __comp_(__x.first, __y.first);123 return __comp_(__x.first, __y.first);
123 }124 }
124 };125 };
...@@ -137,14 +138,14 @@ private:...@@ -137,14 +138,14 @@ private:
137138
138public:139public:
139 // [flat.map.cons], construct/copy/destroy140 // [flat.map.cons], construct/copy/destroy
140 _LIBCPP_HIDE_FROM_ABI flat_map() noexcept(141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map() noexcept(
141 is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> &&142 is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_MappedContainer> &&
142 is_nothrow_default_constructible_v<_Compare>)143 is_nothrow_default_constructible_v<_Compare>)
143 : __containers_(), __compare_() {}144 : __containers_(), __compare_() {}
144145
145 _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default;146 _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default;
146147
147 _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept(148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(flat_map&& __other) noexcept(
148 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&149 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&
149 is_nothrow_move_constructible_v<_Compare>)150 is_nothrow_move_constructible_v<_Compare>)
150# if _LIBCPP_HAS_EXCEPTIONS151# if _LIBCPP_HAS_EXCEPTIONS
...@@ -165,7 +166,7 @@ public:...@@ -165,7 +166,7 @@ public:
165166
166 template <class _Allocator>167 template <class _Allocator>
167 requires __allocator_ctor_constraint<_Allocator>168 requires __allocator_ctor_constraint<_Allocator>
168 _LIBCPP_HIDE_FROM_ABI flat_map(const flat_map& __other, const _Allocator& __alloc)169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(const flat_map& __other, const _Allocator& __alloc)
169 : flat_map(__ctor_uses_allocator_tag{},170 : flat_map(__ctor_uses_allocator_tag{},
170 __alloc,171 __alloc,
171 __other.__containers_.keys,172 __other.__containers_.keys,
...@@ -174,7 +175,7 @@ public:...@@ -174,7 +175,7 @@ public:
174175
175 template <class _Allocator>176 template <class _Allocator>
176 requires __allocator_ctor_constraint<_Allocator>177 requires __allocator_ctor_constraint<_Allocator>
177 _LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other, const _Allocator& __alloc)178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(flat_map&& __other, const _Allocator& __alloc)
178# if _LIBCPP_HAS_EXCEPTIONS179# if _LIBCPP_HAS_EXCEPTIONS
179 try180 try
180# endif // _LIBCPP_HAS_EXCEPTIONS181# endif // _LIBCPP_HAS_EXCEPTIONS
...@@ -191,7 +192,7 @@ public:...@@ -191,7 +192,7 @@ public:
191# endif // _LIBCPP_HAS_EXCEPTIONS192# endif // _LIBCPP_HAS_EXCEPTIONS
192 }193 }
193194
194 _LIBCPP_HIDE_FROM_ABI flat_map(195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(
195 key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare())196 key_container_type __key_cont, mapped_container_type __mapped_cont, const key_compare& __comp = key_compare())
196 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {197 : __containers_{.keys = std::move(__key_cont), .values = std::move(__mapped_cont)}, __compare_(__comp) {
197 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),198 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
...@@ -201,7 +202,7 @@ public:...@@ -201,7 +202,7 @@ public:
201202
202 template <class _Allocator>203 template <class _Allocator>
203 requires __allocator_ctor_constraint<_Allocator>204 requires __allocator_ctor_constraint<_Allocator>
204 _LIBCPP_HIDE_FROM_ABI205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
205 flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc)206 flat_map(const key_container_type& __key_cont, const mapped_container_type& __mapped_cont, const _Allocator& __alloc)
206 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {207 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont) {
207 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),208 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
...@@ -211,7 +212,7 @@ public:...@@ -211,7 +212,7 @@ public:
211212
212 template <class _Allocator>213 template <class _Allocator>
213 requires __allocator_ctor_constraint<_Allocator>214 requires __allocator_ctor_constraint<_Allocator>
214 _LIBCPP_HIDE_FROM_ABI215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
215 flat_map(const key_container_type& __key_cont,216 flat_map(const key_container_type& __key_cont,
216 const mapped_container_type& __mapped_cont,217 const mapped_container_type& __mapped_cont,
217 const key_compare& __comp,218 const key_compare& __comp,
...@@ -222,7 +223,7 @@ public:...@@ -222,7 +223,7 @@ public:
222 __sort_and_unique();223 __sort_and_unique();
223 }224 }
224225
225 _LIBCPP_HIDE_FROM_ABI226 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
226 flat_map(sorted_unique_t,227 flat_map(sorted_unique_t,
227 key_container_type __key_cont,228 key_container_type __key_cont,
228 mapped_container_type __mapped_cont,229 mapped_container_type __mapped_cont,
...@@ -236,7 +237,7 @@ public:...@@ -236,7 +237,7 @@ public:
236237
237 template <class _Allocator>238 template <class _Allocator>
238 requires __allocator_ctor_constraint<_Allocator>239 requires __allocator_ctor_constraint<_Allocator>
239 _LIBCPP_HIDE_FROM_ABI240 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
240 flat_map(sorted_unique_t,241 flat_map(sorted_unique_t,
241 const key_container_type& __key_cont,242 const key_container_type& __key_cont,
242 const mapped_container_type& __mapped_cont,243 const mapped_container_type& __mapped_cont,
...@@ -250,12 +251,12 @@ public:...@@ -250,12 +251,12 @@ public:
250251
251 template <class _Allocator>252 template <class _Allocator>
252 requires __allocator_ctor_constraint<_Allocator>253 requires __allocator_ctor_constraint<_Allocator>
253 _LIBCPP_HIDE_FROM_ABI254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(
254 flat_map(sorted_unique_t,255 sorted_unique_t,
255 const key_container_type& __key_cont,256 const key_container_type& __key_cont,
256 const mapped_container_type& __mapped_cont,257 const mapped_container_type& __mapped_cont,
257 const key_compare& __comp,258 const key_compare& __comp,
258 const _Allocator& __alloc)259 const _Allocator& __alloc)
259 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {260 : flat_map(__ctor_uses_allocator_tag{}, __alloc, __key_cont, __mapped_cont, __comp) {
260 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),261 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__containers_.keys.size() == __containers_.values.size(),
261 "flat_map keys and mapped containers have different size");262 "flat_map keys and mapped containers have different size");
...@@ -263,21 +264,22 @@ public:...@@ -263,21 +264,22 @@ public:
263 __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates");264 __is_sorted_and_unique(__containers_.keys), "Either the key container is not sorted or it contains duplicates");
264 }265 }
265266
266 _LIBCPP_HIDE_FROM_ABI explicit flat_map(const key_compare& __comp) : __containers_(), __compare_(__comp) {}267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_map(const key_compare& __comp)
268 : __containers_(), __compare_(__comp) {}
267269
268 template <class _Allocator>270 template <class _Allocator>
269 requires __allocator_ctor_constraint<_Allocator>271 requires __allocator_ctor_constraint<_Allocator>
270 _LIBCPP_HIDE_FROM_ABI flat_map(const key_compare& __comp, const _Allocator& __alloc)272 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(const key_compare& __comp, const _Allocator& __alloc)
271 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {}273 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {}
272274
273 template <class _Allocator>275 template <class _Allocator>
274 requires __allocator_ctor_constraint<_Allocator>276 requires __allocator_ctor_constraint<_Allocator>
275 _LIBCPP_HIDE_FROM_ABI explicit flat_map(const _Allocator& __alloc)277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_map(const _Allocator& __alloc)
276 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {}278 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {}
277279
278 template <class _InputIterator>280 template <class _InputIterator>
279 requires __has_input_iterator_category<_InputIterator>::value281 requires __has_input_iterator_category<_InputIterator>::value
280 _LIBCPP_HIDE_FROM_ABI282 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
281 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())283 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
282 : __containers_(), __compare_(__comp) {284 : __containers_(), __compare_(__comp) {
283 insert(__first, __last);285 insert(__first, __last);
...@@ -285,7 +287,7 @@ public:...@@ -285,7 +287,7 @@ public:
285287
286 template <class _InputIterator, class _Allocator>288 template <class _InputIterator, class _Allocator>
287 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)289 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
288 _LIBCPP_HIDE_FROM_ABI290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
289 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)291 flat_map(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
290 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {292 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
291 insert(__first, __last);293 insert(__first, __last);
...@@ -293,99 +295,105 @@ public:...@@ -293,99 +295,105 @@ public:
293295
294 template <class _InputIterator, class _Allocator>296 template <class _InputIterator, class _Allocator>
295 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)297 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
296 _LIBCPP_HIDE_FROM_ABI flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)298 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
299 flat_map(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
297 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {300 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
298 insert(__first, __last);301 insert(__first, __last);
299 }302 }
300303
301 template <_ContainerCompatibleRange<value_type> _Range>304 template <_ContainerCompatibleRange<value_type> _Range>
302 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t __fr, _Range&& __rg)305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t __fr, _Range&& __rg)
303 : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {}306 : flat_map(__fr, std::forward<_Range>(__rg), key_compare()) {}
304307
305 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>308 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
306 requires __allocator_ctor_constraint<_Allocator>309 requires __allocator_ctor_constraint<_Allocator>
307 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc)310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t, _Range&& __rg, const _Allocator& __alloc)
308 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {311 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
309 insert_range(std::forward<_Range>(__rg));312 insert_range(std::forward<_Range>(__rg));
310 }313 }
311314
312 template <_ContainerCompatibleRange<value_type> _Range>315 template <_ContainerCompatibleRange<value_type> _Range>
313 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_map(__comp) {316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(from_range_t, _Range&& __rg, const key_compare& __comp)
317 : flat_map(__comp) {
314 insert_range(std::forward<_Range>(__rg));318 insert_range(std::forward<_Range>(__rg));
315 }319 }
316320
317 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>321 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
318 requires __allocator_ctor_constraint<_Allocator>322 requires __allocator_ctor_constraint<_Allocator>
319 _LIBCPP_HIDE_FROM_ABI flat_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)323 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
324 flat_map(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
320 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {325 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
321 insert_range(std::forward<_Range>(__rg));326 insert_range(std::forward<_Range>(__rg));
322 }327 }
323328
324 template <class _InputIterator>329 template <class _InputIterator>
325 requires __has_input_iterator_category<_InputIterator>::value330 requires __has_input_iterator_category<_InputIterator>::value
326 _LIBCPP_HIDE_FROM_ABI331 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
327 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())332 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
328 : __containers_(), __compare_(__comp) {333 : __containers_(), __compare_(__comp) {
329 insert(sorted_unique, __first, __last);334 insert(sorted_unique, __first, __last);
330 }335 }
331 template <class _InputIterator, class _Allocator>336 template <class _InputIterator, class _Allocator>
332 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)337 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
333 _LIBCPP_HIDE_FROM_ABI338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(
334 flat_map(sorted_unique_t,339 sorted_unique_t,
335 _InputIterator __first,340 _InputIterator __first,
336 _InputIterator __last,341 _InputIterator __last,
337 const key_compare& __comp,342 const key_compare& __comp,
338 const _Allocator& __alloc)343 const _Allocator& __alloc)
339 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {344 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc, __comp) {
340 insert(sorted_unique, __first, __last);345 insert(sorted_unique, __first, __last);
341 }346 }
342347
343 template <class _InputIterator, class _Allocator>348 template <class _InputIterator, class _Allocator>
344 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)349 requires(__has_input_iterator_category<_InputIterator>::value && __allocator_ctor_constraint<_Allocator>)
345 _LIBCPP_HIDE_FROM_ABI350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
346 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)351 flat_map(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
347 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {352 : flat_map(__ctor_uses_allocator_empty_tag{}, __alloc) {
348 insert(sorted_unique, __first, __last);353 insert(sorted_unique, __first, __last);
349 }354 }
350355
351 _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
357 flat_map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
352 : flat_map(__il.begin(), __il.end(), __comp) {}358 : flat_map(__il.begin(), __il.end(), __comp) {}
353359
354 template <class _Allocator>360 template <class _Allocator>
355 requires __allocator_ctor_constraint<_Allocator>361 requires __allocator_ctor_constraint<_Allocator>
356 _LIBCPP_HIDE_FROM_ABI362 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
357 flat_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)363 flat_map(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
358 : flat_map(__il.begin(), __il.end(), __comp, __alloc) {}364 : flat_map(__il.begin(), __il.end(), __comp, __alloc) {}
359365
360 template <class _Allocator>366 template <class _Allocator>
361 requires __allocator_ctor_constraint<_Allocator>367 requires __allocator_ctor_constraint<_Allocator>
362 _LIBCPP_HIDE_FROM_ABI flat_map(initializer_list<value_type> __il, const _Allocator& __alloc)368 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
369 flat_map(initializer_list<value_type> __il, const _Allocator& __alloc)
363 : flat_map(__il.begin(), __il.end(), __alloc) {}370 : flat_map(__il.begin(), __il.end(), __alloc) {}
364371
365 _LIBCPP_HIDE_FROM_ABI372 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
366 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())373 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
367 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {}374 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp) {}
368375
369 template <class _Allocator>376 template <class _Allocator>
370 requires __allocator_ctor_constraint<_Allocator>377 requires __allocator_ctor_constraint<_Allocator>
371 _LIBCPP_HIDE_FROM_ABI378 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
372 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)379 flat_map(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
373 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {}380 : flat_map(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {}
374381
375 template <class _Allocator>382 template <class _Allocator>
376 requires __allocator_ctor_constraint<_Allocator>383 requires __allocator_ctor_constraint<_Allocator>
377 _LIBCPP_HIDE_FROM_ABI flat_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
385 flat_map(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)
378 : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {}386 : flat_map(sorted_unique, __il.begin(), __il.end(), __alloc) {}
379387
380 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(initializer_list<value_type> __il) {388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(initializer_list<value_type> __il) {
381 clear();389 clear();
382 insert(__il);390 insert(__il);
383 return *this;391 return *this;
384 }392 }
385393
386 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(const flat_map&) = default;394 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(const flat_map&) = default;
387395
388 _LIBCPP_HIDE_FROM_ABI flat_map& operator=(flat_map&& __other) noexcept(396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map& operator=(flat_map&& __other) noexcept(
389 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> &&397 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_MappedContainer> &&
390 is_nothrow_move_assignable_v<_Compare>) {398 is_nothrow_move_assignable_v<_Compare>) {
391 // No matter what happens, we always want to clear the other container before returning399 // No matter what happens, we always want to clear the other container before returning
...@@ -402,49 +410,65 @@ public:...@@ -402,49 +410,65 @@ public:
402 }410 }
403411
404 // iterators412 // iterators
405 _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept {413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept {
406 return iterator(__containers_.keys.begin(), __containers_.values.begin());414 return iterator(__containers_.keys.begin(), __containers_.values.begin());
407 }415 }
408416
409 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept {417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept {
410 return const_iterator(__containers_.keys.begin(), __containers_.values.begin());418 return const_iterator(__containers_.keys.begin(), __containers_.values.begin());
411 }419 }
412420
413 _LIBCPP_HIDE_FROM_ABI iterator end() noexcept {421 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept {
414 return iterator(__containers_.keys.end(), __containers_.values.end());422 return iterator(__containers_.keys.end(), __containers_.values.end());
415 }423 }
416424
417 _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept {425 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept {
418 return const_iterator(__containers_.keys.end(), __containers_.values.end());426 return const_iterator(__containers_.keys.end(), __containers_.values.end());
419 }427 }
420428
421 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }429 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept {
422 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }430 return reverse_iterator(end());
423 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }431 }
424 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }432 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept {
433 return const_reverse_iterator(end());
434 }
435 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept {
436 return reverse_iterator(begin());
437 }
438 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept {
439 return const_reverse_iterator(begin());
440 }
425441
426 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }442 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); }
427 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }443 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); }
428 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }444 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept {
429 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }445 return const_reverse_iterator(end());
446 }
447 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept {
448 return const_reverse_iterator(begin());
449 }
430450
431 // [flat.map.capacity], capacity451 // [flat.map.capacity], capacity
432 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __containers_.keys.empty(); }452 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept {
453 return __containers_.keys.empty();
454 }
433455
434 _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __containers_.keys.size(); }456 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept {
457 return __containers_.keys.size();
458 }
435459
436 _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept {460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept {
437 return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size());461 return std::min<size_type>(__containers_.keys.max_size(), __containers_.values.max_size());
438 }462 }
439463
440 // [flat.map.access], element access464 // [flat.map.access], element access
441 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __x)465 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __x)
442 requires is_constructible_v<mapped_type>466 requires is_constructible_v<mapped_type>
443 {467 {
444 return try_emplace(__x).first->second;468 return try_emplace(__x).first->second;
445 }469 }
446470
447 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __x)471 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](key_type&& __x)
448 requires is_constructible_v<mapped_type>472 requires is_constructible_v<mapped_type>
449 {473 {
450 return try_emplace(std::move(__x)).first->second;474 return try_emplace(std::move(__x)).first->second;
...@@ -453,11 +477,11 @@ public:...@@ -453,11 +477,11 @@ public:
453 template <class _Kp>477 template <class _Kp>
454 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> &&478 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type> &&
455 !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>)479 !is_convertible_v<_Kp &&, const_iterator> && !is_convertible_v<_Kp &&, iterator>)
456 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](_Kp&& __x) {480 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](_Kp&& __x) {
457 return try_emplace(std::forward<_Kp>(__x)).first->second;481 return try_emplace(std::forward<_Kp>(__x)).first->second;
458 }482 }
459483
460 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __x) {484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __x) {
461 auto __it = find(__x);485 auto __it = find(__x);
462 if (__it == end()) {486 if (__it == end()) {
463 std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist");487 std::__throw_out_of_range("flat_map::at(const key_type&): Key does not exist");
...@@ -465,7 +489,7 @@ public:...@@ -465,7 +489,7 @@ public:
465 return __it->second;489 return __it->second;
466 }490 }
467491
468 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __x) const {492 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const key_type& __x) const {
469 auto __it = find(__x);493 auto __it = find(__x);
470 if (__it == end()) {494 if (__it == end()) {
471 std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist");495 std::__throw_out_of_range("flat_map::at(const key_type&) const: Key does not exist");
...@@ -475,7 +499,7 @@ public:...@@ -475,7 +499,7 @@ public:
475499
476 template <class _Kp>500 template <class _Kp>
477 requires __is_compare_transparent501 requires __is_compare_transparent
478 _LIBCPP_HIDE_FROM_ABI mapped_type& at(const _Kp& __x) {502 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const _Kp& __x) {
479 auto __it = find(__x);503 auto __it = find(__x);
480 if (__it == end()) {504 if (__it == end()) {
481 std::__throw_out_of_range("flat_map::at(const K&): Key does not exist");505 std::__throw_out_of_range("flat_map::at(const K&): Key does not exist");
...@@ -485,7 +509,7 @@ public:...@@ -485,7 +509,7 @@ public:
485509
486 template <class _Kp>510 template <class _Kp>
487 requires __is_compare_transparent511 requires __is_compare_transparent
488 _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const _Kp& __x) const {512 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const _Kp& __x) const {
489 auto __it = find(__x);513 auto __it = find(__x);
490 if (__it == end()) {514 if (__it == end()) {
491 std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist");515 std::__throw_out_of_range("flat_map::at(const K&) const: Key does not exist");
...@@ -496,45 +520,49 @@ public:...@@ -496,45 +520,49 @@ public:
496 // [flat.map.modifiers], modifiers520 // [flat.map.modifiers], modifiers
497 template <class... _Args>521 template <class... _Args>
498 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>522 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
499 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {523 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
500 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);524 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
501 return __try_emplace(std::move(__pair.first), std::move(__pair.second));525 return __try_emplace(std::move(__pair.first), std::move(__pair.second));
502 }526 }
503527
504 template <class... _Args>528 template <class... _Args>
505 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>529 requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
506 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {530 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
507 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);531 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
508 return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first;532 return __try_emplace_hint(__hint, std::move(__pair.first), std::move(__pair.second)).first;
509 }533 }
510534
511 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return emplace(__x); }535 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __x) {
536 return emplace(__x);
537 }
512538
513 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) { return emplace(std::move(__x)); }539 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __x) {
540 return emplace(std::move(__x));
541 }
514542
515 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {543 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) {
516 return emplace_hint(__hint, __x);544 return emplace_hint(__hint, __x);
517 }545 }
518546
519 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {547 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) {
520 return emplace_hint(__hint, std::move(__x));548 return emplace_hint(__hint, std::move(__x));
521 }549 }
522550
523 template <class _PairLike>551 template <class _PairLike>
524 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>552 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
525 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_PairLike&& __x) {553 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_PairLike&& __x) {
526 return emplace(std::forward<_PairLike>(__x));554 return emplace(std::forward<_PairLike>(__x));
527 }555 }
528556
529 template <class _PairLike>557 template <class _PairLike>
530 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>558 requires is_constructible_v<pair<key_type, mapped_type>, _PairLike>
531 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, _PairLike&& __x) {559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _PairLike&& __x) {
532 return emplace_hint(__hint, std::forward<_PairLike>(__x));560 return emplace_hint(__hint, std::forward<_PairLike>(__x));
533 }561 }
534562
535 template <class _InputIterator>563 template <class _InputIterator>
536 requires __has_input_iterator_category<_InputIterator>::value564 requires __has_input_iterator_category<_InputIterator>::value
537 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {565 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
538 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {566 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
539 __reserve(__last - __first);567 __reserve(__last - __first);
540 }568 }
...@@ -543,7 +571,8 @@ public:...@@ -543,7 +571,8 @@ public:
543571
544 template <class _InputIterator>572 template <class _InputIterator>
545 requires __has_input_iterator_category<_InputIterator>::value573 requires __has_input_iterator_category<_InputIterator>::value
546 _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {574 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
575 insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
547 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {576 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
548 __reserve(__last - __first);577 __reserve(__last - __first);
549 }578 }
...@@ -552,7 +581,7 @@ public:...@@ -552,7 +581,7 @@ public:
552 }581 }
553582
554 template <_ContainerCompatibleRange<value_type> _Range>583 template <_ContainerCompatibleRange<value_type> _Range>
555 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {584 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
556 if constexpr (ranges::sized_range<_Range>) {585 if constexpr (ranges::sized_range<_Range>) {
557 __reserve(ranges::size(__range));586 __reserve(ranges::size(__range));
558 }587 }
...@@ -560,19 +589,22 @@ public:...@@ -560,19 +589,22 @@ public:
560 __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range));589 __append_sort_merge_unique</*WasSorted = */ false>(ranges::begin(__range), ranges::end(__range));
561 }590 }
562591
563 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }592 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
593 insert(__il.begin(), __il.end());
594 }
564595
565 _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, initializer_list<value_type> __il) {596 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(sorted_unique_t, initializer_list<value_type> __il) {
566 insert(sorted_unique, __il.begin(), __il.end());597 insert(sorted_unique, __il.begin(), __il.end());
567 }598 }
568599
569 _LIBCPP_HIDE_FROM_ABI containers extract() && {600 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 containers extract() && {
570 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });601 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
571 auto __ret = std::move(__containers_);602 auto __ret = std::move(__containers_);
572 return __ret;603 return __ret;
573 }604 }
574605
575 _LIBCPP_HIDE_FROM_ABI void replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) {606 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
607 replace(key_container_type&& __key_cont, mapped_container_type&& __mapped_cont) {
576 _LIBCPP_ASSERT_VALID_INPUT_RANGE(608 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
577 __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size");609 __key_cont.size() == __mapped_cont.size(), "flat_map keys and mapped containers have different size");
578610
...@@ -586,13 +618,15 @@ public:...@@ -586,13 +618,15 @@ public:
586618
587 template <class... _Args>619 template <class... _Args>
588 requires is_constructible_v<mapped_type, _Args...>620 requires is_constructible_v<mapped_type, _Args...>
589 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __key, _Args&&... __args) {621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
622 try_emplace(const key_type& __key, _Args&&... __args) {
590 return __try_emplace(__key, std::forward<_Args>(__args)...);623 return __try_emplace(__key, std::forward<_Args>(__args)...);
591 }624 }
592625
593 template <class... _Args>626 template <class... _Args>
594 requires is_constructible_v<mapped_type, _Args...>627 requires is_constructible_v<mapped_type, _Args...>
595 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __key, _Args&&... __args) {628 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
629 try_emplace(key_type&& __key, _Args&&... __args) {
596 return __try_emplace(std::move(__key), std::forward<_Args>(__args)...);630 return __try_emplace(std::move(__key), std::forward<_Args>(__args)...);
597 }631 }
598632
...@@ -600,75 +634,84 @@ public:...@@ -600,75 +634,84 @@ public:
600 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> &&634 requires(__is_compare_transparent && is_constructible_v<key_type, _Kp> &&
601 is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> &&635 is_constructible_v<mapped_type, _Args...> && !is_convertible_v<_Kp &&, const_iterator> &&
602 !is_convertible_v<_Kp &&, iterator>)636 !is_convertible_v<_Kp &&, iterator>)
603 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) {637 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> try_emplace(_Kp&& __key, _Args&&... __args) {
604 return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...);638 return __try_emplace(std::forward<_Kp>(__key), std::forward<_Args>(__args)...);
605 }639 }
606640
607 template <class... _Args>641 template <class... _Args>
608 requires is_constructible_v<mapped_type, _Args...>642 requires is_constructible_v<mapped_type, _Args...>
609 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) {643 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
644 try_emplace(const_iterator __hint, const key_type& __key, _Args&&... __args) {
610 return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first;645 return __try_emplace_hint(__hint, __key, std::forward<_Args>(__args)...).first;
611 }646 }
612647
613 template <class... _Args>648 template <class... _Args>
614 requires is_constructible_v<mapped_type, _Args...>649 requires is_constructible_v<mapped_type, _Args...>
615 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) {650 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
651 try_emplace(const_iterator __hint, key_type&& __key, _Args&&... __args) {
616 return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first;652 return __try_emplace_hint(__hint, std::move(__key), std::forward<_Args>(__args)...).first;
617 }653 }
618654
619 template <class _Kp, class... _Args>655 template <class _Kp, class... _Args>
620 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...>656 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_constructible_v<mapped_type, _Args...>
621 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) {657 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
658 try_emplace(const_iterator __hint, _Kp&& __key, _Args&&... __args) {
622 return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first;659 return __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Args>(__args)...).first;
623 }660 }
624661
625 template <class _Mapped>662 template <class _Mapped>
626 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>663 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
627 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __key, _Mapped&& __obj) {664 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
665 insert_or_assign(const key_type& __key, _Mapped&& __obj) {
628 return __insert_or_assign(__key, std::forward<_Mapped>(__obj));666 return __insert_or_assign(__key, std::forward<_Mapped>(__obj));
629 }667 }
630668
631 template <class _Mapped>669 template <class _Mapped>
632 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>670 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
633 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __key, _Mapped&& __obj) {671 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
672 insert_or_assign(key_type&& __key, _Mapped&& __obj) {
634 return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj));673 return __insert_or_assign(std::move(__key), std::forward<_Mapped>(__obj));
635 }674 }
636675
637 template <class _Kp, class _Mapped>676 template <class _Kp, class _Mapped>
638 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&677 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&
639 is_constructible_v<mapped_type, _Mapped>678 is_constructible_v<mapped_type, _Mapped>
640 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(_Kp&& __key, _Mapped&& __obj) {679 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
680 insert_or_assign(_Kp&& __key, _Mapped&& __obj) {
641 return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));681 return __insert_or_assign(std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));
642 }682 }
643683
644 template <class _Mapped>684 template <class _Mapped>
645 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>685 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
646 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) {686 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
687 insert_or_assign(const_iterator __hint, const key_type& __key, _Mapped&& __obj) {
647 return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj));688 return __insert_or_assign(__hint, __key, std::forward<_Mapped>(__obj));
648 }689 }
649690
650 template <class _Mapped>691 template <class _Mapped>
651 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>692 requires is_assignable_v<mapped_type&, _Mapped> && is_constructible_v<mapped_type, _Mapped>
652 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) {693 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
694 insert_or_assign(const_iterator __hint, key_type&& __key, _Mapped&& __obj) {
653 return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj));695 return __insert_or_assign(__hint, std::move(__key), std::forward<_Mapped>(__obj));
654 }696 }
655697
656 template <class _Kp, class _Mapped>698 template <class _Kp, class _Mapped>
657 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&699 requires __is_compare_transparent && is_constructible_v<key_type, _Kp> && is_assignable_v<mapped_type&, _Mapped> &&
658 is_constructible_v<mapped_type, _Mapped>700 is_constructible_v<mapped_type, _Mapped>
659 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) {701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
702 insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __obj) {
660 return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));703 return __insert_or_assign(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__obj));
661 }704 }
662705
663 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) {
664 return __erase(__position.__key_iter_, __position.__mapped_iter_);707 return __erase(__position.__key_iter_, __position.__mapped_iter_);
665 }708 }
666709
667 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __position) {710 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __position) {
668 return __erase(__position.__key_iter_, __position.__mapped_iter_);711 return __erase(__position.__key_iter_, __position.__mapped_iter_);
669 }712 }
670713
671 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) {
672 auto __iter = find(__x);715 auto __iter = find(__x);
673 if (__iter != end()) {716 if (__iter != end()) {
674 erase(__iter);717 erase(__iter);
...@@ -680,14 +723,14 @@ public:...@@ -680,14 +723,14 @@ public:
680 template <class _Kp>723 template <class _Kp>
681 requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> &&724 requires(__is_compare_transparent && !is_convertible_v<_Kp &&, iterator> &&
682 !is_convertible_v<_Kp &&, const_iterator>)725 !is_convertible_v<_Kp &&, const_iterator>)
683 _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {726 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) {
684 auto [__first, __last] = equal_range(__x);727 auto [__first, __last] = equal_range(__x);
685 auto __res = __last - __first;728 auto __res = __last - __first;
686 erase(__first, __last);729 erase(__first, __last);
687 return __res;730 return __res;
688 }731 }
689732
690 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) {
691 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });734 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
692 auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_);735 auto __key_it = __containers_.keys.erase(__first.__key_iter_, __last.__key_iter_);
693 auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_);736 auto __mapped_it = __containers_.values.erase(__first.__mapped_iter_, __last.__mapped_iter_);
...@@ -695,7 +738,7 @@ public:...@@ -695,7 +738,7 @@ public:
695 return iterator(std::move(__key_it), std::move(__mapped_it));738 return iterator(std::move(__key_it), std::move(__mapped_it));
696 }739 }
697740
698 _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __y) noexcept {741 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __y) noexcept {
699 // warning: The spec has unconditional noexcept, which means that742 // warning: The spec has unconditional noexcept, which means that
700 // if any of the following functions throw an exception,743 // if any of the following functions throw an exception,
701 // std::terminate will be called.744 // std::terminate will be called.
...@@ -705,133 +748,156 @@ public:...@@ -705,133 +748,156 @@ public:
705 ranges::swap(__containers_.values, __y.__containers_.values);748 ranges::swap(__containers_.values, __y.__containers_.values);
706 }749 }
707750
708 _LIBCPP_HIDE_FROM_ABI void clear() noexcept {751 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept {
709 __containers_.keys.clear();752 __containers_.keys.clear();
710 __containers_.values.clear();753 __containers_.values.clear();
711 }754 }
712755
713 // observers756 // observers
714 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }757 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; }
715 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); }758 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const {
759 return value_compare(__compare_);
760 }
716761
717 _LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; }762 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const key_container_type& keys() const noexcept {
718 _LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; }763 return __containers_.keys;
764 }
765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_container_type& values() const noexcept {
766 return __containers_.values;
767 }
719768
720 // map operations769 // map operations
721 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }770 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) {
771 return __find_impl(*this, __x);
772 }
722773
723 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }774 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const {
775 return __find_impl(*this, __x);
776 }
724777
725 template <class _Kp>778 template <class _Kp>
726 requires __is_compare_transparent779 requires __is_compare_transparent
727 _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {780 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) {
728 return __find_impl(*this, __x);781 return __find_impl(*this, __x);
729 }782 }
730783
731 template <class _Kp>784 template <class _Kp>
732 requires __is_compare_transparent785 requires __is_compare_transparent
733 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {786 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const {
734 return __find_impl(*this, __x);787 return __find_impl(*this, __x);
735 }788 }
736789
737 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const { return contains(__x) ? 1 : 0; }790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const {
791 return contains(__x) ? 1 : 0;
792 }
738793
739 template <class _Kp>794 template <class _Kp>
740 requires __is_compare_transparent795 requires __is_compare_transparent
741 _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {796 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const {
742 return contains(__x) ? 1 : 0;797 return contains(__x) ? 1 : 0;
743 }798 }
744799
745 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }800 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const {
801 return find(__x) != end();
802 }
746803
747 template <class _Kp>804 template <class _Kp>
748 requires __is_compare_transparent805 requires __is_compare_transparent
749 _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {806 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const {
750 return find(__x) != end();807 return find(__x) != end();
751 }808 }
752809
753 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) { return __lower_bound<iterator>(*this, __x); }810 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) {
811 return __lower_bound<iterator>(*this, __x);
812 }
754813
755 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {814 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const {
756 return __lower_bound<const_iterator>(*this, __x);815 return __lower_bound<const_iterator>(*this, __x);
757 }816 }
758817
759 template <class _Kp>818 template <class _Kp>
760 requires __is_compare_transparent819 requires __is_compare_transparent
761 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {820 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) {
762 return __lower_bound<iterator>(*this, __x);821 return __lower_bound<iterator>(*this, __x);
763 }822 }
764823
765 template <class _Kp>824 template <class _Kp>
766 requires __is_compare_transparent825 requires __is_compare_transparent
767 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {826 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const {
768 return __lower_bound<const_iterator>(*this, __x);827 return __lower_bound<const_iterator>(*this, __x);
769 }828 }
770829
771 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) { return __upper_bound<iterator>(*this, __x); }830 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) {
831 return __upper_bound<iterator>(*this, __x);
832 }
772833
773 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {834 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const {
774 return __upper_bound<const_iterator>(*this, __x);835 return __upper_bound<const_iterator>(*this, __x);
775 }836 }
776837
777 template <class _Kp>838 template <class _Kp>
778 requires __is_compare_transparent839 requires __is_compare_transparent
779 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {840 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) {
780 return __upper_bound<iterator>(*this, __x);841 return __upper_bound<iterator>(*this, __x);
781 }842 }
782843
783 template <class _Kp>844 template <class _Kp>
784 requires __is_compare_transparent845 requires __is_compare_transparent
785 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {846 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const {
786 return __upper_bound<const_iterator>(*this, __x);847 return __upper_bound<const_iterator>(*this, __x);
787 }848 }
788849
789 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {850 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) {
790 return __equal_range_impl(*this, __x);851 return __equal_range_impl(*this, __x);
791 }852 }
792853
793 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {854 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
855 equal_range(const key_type& __x) const {
794 return __equal_range_impl(*this, __x);856 return __equal_range_impl(*this, __x);
795 }857 }
796858
797 template <class _Kp>859 template <class _Kp>
798 requires __is_compare_transparent860 requires __is_compare_transparent
799 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {861 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) {
800 return __equal_range_impl(*this, __x);862 return __equal_range_impl(*this, __x);
801 }863 }
802 template <class _Kp>864 template <class _Kp>
803 requires __is_compare_transparent865 requires __is_compare_transparent
804 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {866 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
867 equal_range(const _Kp& __x) const {
805 return __equal_range_impl(*this, __x);868 return __equal_range_impl(*this, __x);
806 }869 }
807870
808 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_map& __x, const flat_map& __y) {871 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const flat_map& __x, const flat_map& __y) {
809 return ranges::equal(__x, __y);872 return ranges::equal(__x, __y);
810 }873 }
811874
812 friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_map& __x, const flat_map& __y) {875 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
876 operator<=>(const flat_map& __x, const flat_map& __y) {
813 return std::lexicographical_compare_three_way(877 return std::lexicographical_compare_three_way(
814 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);878 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
815 }879 }
816880
817 friend _LIBCPP_HIDE_FROM_ABI void swap(flat_map& __x, flat_map& __y) noexcept { __x.swap(__y); }881 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_map& __x, flat_map& __y) noexcept {
882 __x.swap(__y);
883 }
818884
819private:885private:
820 struct __ctor_uses_allocator_tag {886 struct __ctor_uses_allocator_tag {
821 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_tag() = default;887 explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_tag() = default;
822 };888 };
823 struct __ctor_uses_allocator_empty_tag {889 struct __ctor_uses_allocator_empty_tag {
824 explicit _LIBCPP_HIDE_FROM_ABI __ctor_uses_allocator_empty_tag() = default;890 explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __ctor_uses_allocator_empty_tag() = default;
825 };891 };
826892
827 template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg>893 template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg>
828 requires __allocator_ctor_constraint<_Allocator>894 requires __allocator_ctor_constraint<_Allocator>
829 _LIBCPP_HIDE_FROM_ABI895 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_map(
830 flat_map(__ctor_uses_allocator_tag,896 __ctor_uses_allocator_tag,
831 const _Allocator& __alloc,897 const _Allocator& __alloc,
832 _KeyCont&& __key_cont,898 _KeyCont&& __key_cont,
833 _MappedCont&& __mapped_cont,899 _MappedCont&& __mapped_cont,
834 _CompArg&&... __comp)900 _CompArg&&... __comp)
835 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(901 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(
836 __alloc, std::forward<_KeyCont>(__key_cont)),902 __alloc, std::forward<_KeyCont>(__key_cont)),
837 .values = std::make_obj_using_allocator<mapped_container_type>(903 .values = std::make_obj_using_allocator<mapped_container_type>(
...@@ -840,12 +906,13 @@ private:...@@ -840,12 +906,13 @@ private:
840906
841 template <class _Allocator, class... _CompArg>907 template <class _Allocator, class... _CompArg>
842 requires __allocator_ctor_constraint<_Allocator>908 requires __allocator_ctor_constraint<_Allocator>
843 _LIBCPP_HIDE_FROM_ABI flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp)909 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
910 flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp)
844 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc),911 : __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc),
845 .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)},912 .values = std::make_obj_using_allocator<mapped_container_type>(__alloc)},
846 __compare_(std::forward<_CompArg>(__comp)...) {}913 __compare_(std::forward<_CompArg>(__comp)...) {}
847914
848 _LIBCPP_HIDE_FROM_ABI bool __is_sorted_and_unique(auto&& __key_container) const {915 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const {
849 auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };916 auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };
850 return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);917 return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);
851 }918 }
...@@ -853,7 +920,7 @@ private:...@@ -853,7 +920,7 @@ private:
853 // This function is only used in constructors. So there is not exception handling in this function.920 // This function is only used in constructors. So there is not exception handling in this function.
854 // If the function exits via an exception, there will be no flat_map object constructed, thus, there921 // If the function exits via an exception, there will be no flat_map object constructed, thus, there
855 // is no invariant state to preserve922 // is no invariant state to preserve
856 _LIBCPP_HIDE_FROM_ABI void __sort_and_unique() {923 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort_and_unique() {
857 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);924 auto __zv = ranges::views::zip(__containers_.keys, __containers_.values);
858 ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });925 ranges::sort(__zv, __compare_, [](const auto& __p) -> decltype(auto) { return std::get<0>(__p); });
859 auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin();926 auto __dup_start = ranges::unique(__zv, __key_equiv(__compare_)).begin();
...@@ -862,8 +929,17 @@ private:...@@ -862,8 +929,17 @@ private:
862 __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end());929 __containers_.values.erase(__containers_.values.begin() + __dist, __containers_.values.end());
863 }930 }
864931
932 template <class _Self, class _KeyIter>
933 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto
934 __corresponding_mapped_it(_Self&& __self, _KeyIter&& __key_iter) {
935 return __self.__containers_.values.begin() +
936 static_cast<ranges::range_difference_t<mapped_container_type>>(
937 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
938 }
939
865 template <bool _WasSorted, class _InputIterator, class _Sentinel>940 template <bool _WasSorted, class _InputIterator, class _Sentinel>
866 _LIBCPP_HIDE_FROM_ABI void __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) {941 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
942 __append_sort_merge_unique(_InputIterator __first, _Sentinel __last) {
867 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });943 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
868 size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last));944 size_t __num_of_appended = __flat_map_utils::__append(*this, std::move(__first), std::move(__last));
869 if (__num_of_appended != 0) {945 if (__num_of_appended != 0) {
...@@ -891,7 +967,7 @@ private:...@@ -891,7 +967,7 @@ private:
891 }967 }
892968
893 template <class _Self, class _Kp>969 template <class _Self, class _Kp>
894 _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {970 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) {
895 auto __it = __self.lower_bound(__key);971 auto __it = __self.lower_bound(__key);
896 auto __last = __self.end();972 auto __last = __self.end();
897 if (__it == __last || __self.__compare_(__key, __it->first)) {973 if (__it == __last || __self.__compare_(__key, __it->first)) {
...@@ -901,8 +977,9 @@ private:...@@ -901,8 +977,9 @@ private:
901 }977 }
902978
903 template <class _Self, class _Kp>979 template <class _Self, class _Kp>
904 _LIBCPP_HIDE_FROM_ABI static auto __key_equal_range(_Self&& __self, const _Kp& __key) {980 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __key_equal_range(_Self&& __self, const _Kp& __key) {
905 auto __it = ranges::lower_bound(__self.__containers_.keys, __key, __self.__compare_);981 auto __it =
982 std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_);
906 auto __last = __self.__containers_.keys.end();983 auto __last = __self.__containers_.keys.end();
907 if (__it == __last || __self.__compare_(__key, *__it)) {984 if (__it == __last || __self.__compare_(__key, *__it)) {
908 return std::make_pair(__it, __it);985 return std::make_pair(__it, __it);
...@@ -911,44 +988,33 @@ private:...@@ -911,44 +988,33 @@ private:
911 }988 }
912989
913 template <class _Self, class _Kp>990 template <class _Self, class _Kp>
914 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {991 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
915 auto [__key_first, __key_last] = __key_equal_range(__self, __key);992 auto [__key_first, __key_last] = __key_equal_range(__self, __key);
916993 using __iterator_type = ranges::iterator_t<decltype(__self)>;
917 const auto __make_mapped_iter = [&](const auto& __key_iter) {994 return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)),
918 return __self.__containers_.values.begin() +995 __iterator_type(__key_last, __corresponding_mapped_it(__self, __key_last)));
919 static_cast<ranges::range_difference_t<mapped_container_type>>(
920 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
921 };
922
923 using __iterator_type = ranges::iterator_t<decltype(__self)>;
924 return std::make_pair(__iterator_type(__key_first, __make_mapped_iter(__key_first)),
925 __iterator_type(__key_last, __make_mapped_iter(__key_last)));
926 }996 }
927997
928 template <class _Res, class _Self, class _Kp>998 template <class _Res, class _Self, class _Kp>
929 _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) {999 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __lower_bound(_Self&& __self, _Kp& __x) {
930 return __binary_search<_Res>(__self, ranges::lower_bound, __x);1000 auto __key_iter =
1001 std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_);
1002 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
1003 return _Res(std::move(__key_iter), std::move(__mapped_iter));
931 }1004 }
9321005
933 template <class _Res, class _Self, class _Kp>1006 template <class _Res, class _Self, class _Kp>
934 _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) {1007 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static _Res __upper_bound(_Self&& __self, _Kp& __x) {
935 return __binary_search<_Res>(__self, ranges::upper_bound, __x);1008 auto __key_iter =
936 }1009 std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_);
9371010 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
938 template <class _Res, class _Self, class _Fn, class _Kp>
939 _LIBCPP_HIDE_FROM_ABI static _Res __binary_search(_Self&& __self, _Fn __search_fn, _Kp& __x) {
940 auto __key_iter = __search_fn(__self.__containers_.keys, __x, __self.__compare_);
941 auto __mapped_iter =
942 __self.__containers_.values.begin() +
943 static_cast<ranges::range_difference_t<mapped_container_type>>(
944 ranges::distance(__self.__containers_.keys.begin(), __key_iter));
945
946 return _Res(std::move(__key_iter), std::move(__mapped_iter));1011 return _Res(std::move(__key_iter), std::move(__mapped_iter));
947 }1012 }
9481013
949 template <class _KeyArg, class... _MArgs>1014 template <class _KeyArg, class... _MArgs>
950 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) {1015 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
951 auto __key_it = ranges::lower_bound(__containers_.keys, __key, __compare_);1016 __try_emplace(_KeyArg&& __key, _MArgs&&... __mapped_args) {
1017 auto __key_it = std::lower_bound(__containers_.keys.begin(), __containers_.keys.end(), __key, __compare_);
952 auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it);1018 auto __mapped_it = __containers_.values.begin() + ranges::distance(__containers_.keys.begin(), __key_it);
9531019
954 if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) {1020 if (__key_it == __containers_.keys.end() || __compare_(__key, *__key_it)) {
...@@ -966,7 +1032,7 @@ private:...@@ -966,7 +1032,7 @@ private:
966 }1032 }
9671033
968 template <class _Kp>1034 template <class _Kp>
969 _LIBCPP_HIDE_FROM_ABI bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {1035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {
970 if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) {1036 if (__hint != cbegin() && !__compare_((__hint - 1)->first, __key)) {
971 return false;1037 return false;
972 }1038 }
...@@ -977,7 +1043,8 @@ private:...@@ -977,7 +1043,8 @@ private:
977 }1043 }
9781044
979 template <class _Kp, class... _Args>1045 template <class _Kp, class... _Args>
980 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) {1046 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1047 __try_emplace_hint(const_iterator __hint, _Kp&& __key, _Args&&... __args) {
981 if (__is_hint_correct(__hint, __key)) {1048 if (__is_hint_correct(__hint, __key)) {
982 if (__hint == cend() || __compare_(__key, __hint->first)) {1049 if (__hint == cend() || __compare_(__key, __hint->first)) {
983 return {__flat_map_utils::__emplace_exact_pos(1050 return {__flat_map_utils::__emplace_exact_pos(
...@@ -998,7 +1065,8 @@ private:...@@ -998,7 +1065,8 @@ private:
998 }1065 }
9991066
1000 template <class _Kp, class _Mapped>1067 template <class _Kp, class _Mapped>
1001 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) {1068 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1069 __insert_or_assign(_Kp&& __key, _Mapped&& __mapped) {
1002 auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));1070 auto __r = try_emplace(std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));
1003 if (!__r.second) {1071 if (!__r.second) {
1004 __r.first->second = std::forward<_Mapped>(__mapped);1072 __r.first->second = std::forward<_Mapped>(__mapped);
...@@ -1007,7 +1075,8 @@ private:...@@ -1007,7 +1075,8 @@ private:
1007 }1075 }
10081076
1009 template <class _Kp, class _Mapped>1077 template <class _Kp, class _Mapped>
1010 _LIBCPP_HIDE_FROM_ABI iterator __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) {1078 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1079 __insert_or_assign(const_iterator __hint, _Kp&& __key, _Mapped&& __mapped) {
1011 auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));1080 auto __r = __try_emplace_hint(__hint, std::forward<_Kp>(__key), std::forward<_Mapped>(__mapped));
1012 if (!__r.second) {1081 if (!__r.second) {
1013 __r.first->second = std::forward<_Mapped>(__mapped);1082 __r.first->second = std::forward<_Mapped>(__mapped);
...@@ -1015,18 +1084,19 @@ private:...@@ -1015,18 +1084,19 @@ private:
1015 return __r.first;1084 return __r.first;
1016 }1085 }
10171086
1018 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {1087 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) {
1019 if constexpr (requires { __containers_.keys.reserve(__size); }) {1088 if constexpr (__container_traits<_KeyContainer>::__reservable) {
1020 __containers_.keys.reserve(__size);1089 __containers_.keys.reserve(__size);
1021 }1090 }
10221091
1023 if constexpr (requires { __containers_.values.reserve(__size); }) {1092 if constexpr (__container_traits<_MappedContainer>::__reservable) {
1024 __containers_.values.reserve(__size);1093 __containers_.values.reserve(__size);
1025 }1094 }
1026 }1095 }
10271096
1028 template <class _KIter, class _MIter>1097 template <class _KIter, class _MIter>
1029 _LIBCPP_HIDE_FROM_ABI iterator __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) {1098 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1099 __erase(_KIter __key_iter_to_remove, _MIter __mapped_iter_to_remove) {
1030 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });1100 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
1031 auto __key_iter = __containers_.keys.erase(__key_iter_to_remove);1101 auto __key_iter = __containers_.keys.erase(__key_iter_to_remove);
1032 auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove);1102 auto __mapped_iter = __containers_.values.erase(__mapped_iter_to_remove);
...@@ -1036,7 +1106,8 @@ private:...@@ -1036,7 +1106,8 @@ private:
10361106
1037 template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate>1107 template <class _Key2, class _Tp2, class _Compare2, class _KeyContainer2, class _MappedContainer2, class _Predicate>
1038 friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type1108 friend typename flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>::size_type
1039 erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate);1109 _LIBCPP_CONSTEXPR_SINCE_CXX26
1110 erase_if(flat_map<_Key2, _Tp2, _Compare2, _KeyContainer2, _MappedContainer2>&, _Predicate);
10401111
1041 friend __flat_map_utils;1112 friend __flat_map_utils;
10421113
...@@ -1044,8 +1115,9 @@ private:...@@ -1044,8 +1115,9 @@ private:
1044 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;1115 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
10451116
1046 struct __key_equiv {1117 struct __key_equiv {
1047 _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}1118 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {}
1048 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {1119 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
1120 operator()(const_reference __x, const_reference __y) const {
1049 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));1121 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
1050 }1122 }
1051 key_compare __comp_;1123 key_compare __comp_;
...@@ -1168,8 +1240,9 @@ struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContai...@@ -1168,8 +1240,9 @@ struct uses_allocator<flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContai
1168 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {};1240 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> && uses_allocator_v<_MappedContainer, _Allocator>> {};
11691241
1170template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate>1242template <class _Key, class _Tp, class _Compare, class _KeyContainer, class _MappedContainer, class _Predicate>
1171_LIBCPP_HIDE_FROM_ABI typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type1243_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1172erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) {1244 typename flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>::size_type
1245 erase_if(flat_map<_Key, _Tp, _Compare, _KeyContainer, _MappedContainer>& __flat_map, _Predicate __pred) {
1173 auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values);1246 auto __zv = ranges::views::zip(__flat_map.__containers_.keys, __flat_map.__containers_.values);
1174 auto __first = __zv.begin();1247 auto __first = __zv.begin();
1175 auto __last = __zv.end();1248 auto __last = __zv.end();
lib/libcxx/include/__flat_map/flat_multimap.h+14-13
...@@ -10,18 +10,16 @@...@@ -10,18 +10,16 @@
10#ifndef _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H10#ifndef _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H
11#define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H11#define _LIBCPP___FLAT_MAP_FLAT_MULTIMAP_H
1212
13#include <__algorithm/equal_range.h>
13#include <__algorithm/lexicographical_compare_three_way.h>14#include <__algorithm/lexicographical_compare_three_way.h>
15#include <__algorithm/lower_bound.h>
14#include <__algorithm/min.h>16#include <__algorithm/min.h>
15#include <__algorithm/ranges_equal.h>17#include <__algorithm/ranges_equal.h>
16#include <__algorithm/ranges_equal_range.h>
17#include <__algorithm/ranges_inplace_merge.h>18#include <__algorithm/ranges_inplace_merge.h>
18#include <__algorithm/ranges_is_sorted.h>19#include <__algorithm/ranges_is_sorted.h>
19#include <__algorithm/ranges_lower_bound.h>
20#include <__algorithm/ranges_partition_point.h>
21#include <__algorithm/ranges_sort.h>20#include <__algorithm/ranges_sort.h>
22#include <__algorithm/ranges_unique.h>
23#include <__algorithm/ranges_upper_bound.h>
24#include <__algorithm/remove_if.h>21#include <__algorithm/remove_if.h>
22#include <__algorithm/upper_bound.h>
25#include <__assert>23#include <__assert>
26#include <__compare/synth_three_way.h>24#include <__compare/synth_three_way.h>
27#include <__concepts/convertible_to.h>25#include <__concepts/convertible_to.h>
...@@ -443,7 +441,7 @@ public:...@@ -443,7 +441,7 @@ public:
443 is_move_constructible_v<mapped_type>441 is_move_constructible_v<mapped_type>
444 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {442 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
445 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);443 std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
446 auto __key_it = ranges::upper_bound(__containers_.keys, __pair.first, __compare_);444 auto __key_it = std::upper_bound(__containers_.keys.begin(), __containers_.keys.end(), __pair.first, __compare_);
447 auto __mapped_it = __corresponding_mapped_it(*this, __key_it);445 auto __mapped_it = __corresponding_mapped_it(*this, __key_it);
448446
449 return __flat_map_utils::__emplace_exact_pos(447 return __flat_map_utils::__emplace_exact_pos(
...@@ -473,7 +471,7 @@ public:...@@ -473,7 +471,7 @@ public:
473 // |471 // |
474 // hint472 // hint
475 // We want to insert "2" after the last existing "2"473 // We want to insert "2" after the last existing "2"
476 __key_iter = ranges::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_);474 __key_iter = std::upper_bound(__containers_.keys.begin(), __key_iter, __pair.first, __compare_);
477 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);475 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);
478 } else {476 } else {
479 _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted");477 _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multimap is not sorted");
...@@ -485,7 +483,7 @@ public:...@@ -485,7 +483,7 @@ public:
485 // |483 // |
486 // hint484 // hint
487 // We want to insert "2" before the first existing "2"485 // We want to insert "2" before the first existing "2"
488 __key_iter = ranges::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_);486 __key_iter = std::lower_bound(__key_iter, __containers_.keys.end(), __pair.first, __compare_);
489 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);487 __mapped_iter = __corresponding_mapped_it(*this, __key_iter);
490 }488 }
491 return __flat_map_utils::__emplace_exact_pos(489 return __flat_map_utils::__emplace_exact_pos(
...@@ -804,7 +802,8 @@ private:...@@ -804,7 +802,8 @@ private:
804802
805 template <class _Self, class _Kp>803 template <class _Self, class _Kp>
806 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {804 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
807 auto [__key_first, __key_last] = ranges::equal_range(__self.__containers_.keys, __key, __self.__compare_);805 auto [__key_first, __key_last] =
806 std::equal_range(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __key, __self.__compare_);
808807
809 using __iterator_type = ranges::iterator_t<decltype(__self)>;808 using __iterator_type = ranges::iterator_t<decltype(__self)>;
810 return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)),809 return std::make_pair(__iterator_type(__key_first, __corresponding_mapped_it(__self, __key_first)),
...@@ -813,24 +812,26 @@ private:...@@ -813,24 +812,26 @@ private:
813812
814 template <class _Res, class _Self, class _Kp>813 template <class _Res, class _Self, class _Kp>
815 _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) {814 _LIBCPP_HIDE_FROM_ABI static _Res __lower_bound(_Self&& __self, _Kp& __x) {
816 auto __key_iter = ranges::lower_bound(__self.__containers_.keys, __x, __self.__compare_);815 auto __key_iter =
816 std::lower_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_);
817 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);817 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
818 return _Res(std::move(__key_iter), std::move(__mapped_iter));818 return _Res(std::move(__key_iter), std::move(__mapped_iter));
819 }819 }
820820
821 template <class _Res, class _Self, class _Kp>821 template <class _Res, class _Self, class _Kp>
822 _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) {822 _LIBCPP_HIDE_FROM_ABI static _Res __upper_bound(_Self&& __self, _Kp& __x) {
823 auto __key_iter = ranges::upper_bound(__self.__containers_.keys, __x, __self.__compare_);823 auto __key_iter =
824 std::upper_bound(__self.__containers_.keys.begin(), __self.__containers_.keys.end(), __x, __self.__compare_);
824 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);825 auto __mapped_iter = __corresponding_mapped_it(__self, __key_iter);
825 return _Res(std::move(__key_iter), std::move(__mapped_iter));826 return _Res(std::move(__key_iter), std::move(__mapped_iter));
826 }827 }
827828
828 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {829 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
829 if constexpr (requires { __containers_.keys.reserve(__size); }) {830 if constexpr (__container_traits<_KeyContainer>::__reservable) {
830 __containers_.keys.reserve(__size);831 __containers_.keys.reserve(__size);
831 }832 }
832833
833 if constexpr (requires { __containers_.values.reserve(__size); }) {834 if constexpr (__container_traits<_MappedContainer>::__reservable) {
834 __containers_.values.reserve(__size);835 __containers_.values.reserve(__size);
835 }836 }
836 }837 }
lib/libcxx/include/__flat_map/key_value_iterator.h+64-22
...@@ -13,9 +13,12 @@...@@ -13,9 +13,12 @@
13#include <__compare/three_way_comparable.h>13#include <__compare/three_way_comparable.h>
14#include <__concepts/convertible_to.h>14#include <__concepts/convertible_to.h>
15#include <__config>15#include <__config>
16#include <__cstddef/size_t.h>
16#include <__iterator/iterator_traits.h>17#include <__iterator/iterator_traits.h>
18#include <__iterator/product_iterator.h>
17#include <__memory/addressof.h>19#include <__memory/addressof.h>
18#include <__type_traits/conditional.h>20#include <__type_traits/conditional.h>
21#include <__utility/forward.h>
19#include <__utility/move.h>22#include <__utility/move.h>
20#include <__utility/pair.h>23#include <__utility/pair.h>
2124
...@@ -46,7 +49,7 @@ private:...@@ -46,7 +49,7 @@ private:
4649
47 struct __arrow_proxy {50 struct __arrow_proxy {
48 __reference __ref_;51 __reference __ref_;
49 _LIBCPP_HIDE_FROM_ABI __reference* operator->() { return std::addressof(__ref_); }52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference* operator->() { return std::addressof(__ref_); }
50 };53 };
5154
52 __key_iterator __key_iter_;55 __key_iterator __key_iter_;
...@@ -57,6 +60,8 @@ private:...@@ -57,6 +60,8 @@ private:
57 template <class, class, class, bool>60 template <class, class, class, bool>
58 friend struct __key_value_iterator;61 friend struct __key_value_iterator;
5962
63 friend struct __product_iterator_traits<__key_value_iterator>;
64
60public:65public:
61 using iterator_concept = random_access_iterator_tag;66 using iterator_concept = random_access_iterator_tag;
62 // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because67 // `__key_value_iterator` only satisfy "Cpp17InputIterator" named requirements, because
...@@ -69,104 +74,141 @@ public:...@@ -69,104 +74,141 @@ public:
6974
70 _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default;75 _LIBCPP_HIDE_FROM_ABI __key_value_iterator() = default;
7176
72 _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i)77 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
78 __key_value_iterator(__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, !_Const> __i)
73 requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> &&79 requires _Const && convertible_to<typename _KeyContainer::iterator, __key_iterator> &&
74 convertible_to<typename _MappedContainer::iterator, __mapped_iterator>80 convertible_to<typename _MappedContainer::iterator, __mapped_iterator>
75 : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {}81 : __key_iter_(std::move(__i.__key_iter_)), __mapped_iter_(std::move(__i.__mapped_iter_)) {}
7682
77 _LIBCPP_HIDE_FROM_ABI __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter)83 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
84 __key_value_iterator(__key_iterator __key_iter, __mapped_iterator __mapped_iter)
78 : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {}85 : __key_iter_(std::move(__key_iter)), __mapped_iter_(std::move(__mapped_iter)) {}
7986
80 _LIBCPP_HIDE_FROM_ABI __reference operator*() const { return __reference(*__key_iter_, *__mapped_iter_); }87 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference operator*() const {
81 _LIBCPP_HIDE_FROM_ABI __arrow_proxy operator->() const { return __arrow_proxy{**this}; }88 return __reference(*__key_iter_, *__mapped_iter_);
89 }
90 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __arrow_proxy operator->() const { return __arrow_proxy{**this}; }
8291
83 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator++() {92 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator++() {
84 ++__key_iter_;93 ++__key_iter_;
85 ++__mapped_iter_;94 ++__mapped_iter_;
86 return *this;95 return *this;
87 }96 }
8897
89 _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator++(int) {98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator operator++(int) {
90 __key_value_iterator __tmp(*this);99 __key_value_iterator __tmp(*this);
91 ++*this;100 ++*this;
92 return __tmp;101 return __tmp;
93 }102 }
94103
95 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator--() {104 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator--() {
96 --__key_iter_;105 --__key_iter_;
97 --__mapped_iter_;106 --__mapped_iter_;
98 return *this;107 return *this;
99 }108 }
100109
101 _LIBCPP_HIDE_FROM_ABI __key_value_iterator operator--(int) {110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator operator--(int) {
102 __key_value_iterator __tmp(*this);111 __key_value_iterator __tmp(*this);
103 --*this;112 --*this;
104 return __tmp;113 return __tmp;
105 }114 }
106115
107 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator+=(difference_type __x) {116 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator+=(difference_type __x) {
108 __key_iter_ += __x;117 __key_iter_ += __x;
109 __mapped_iter_ += __x;118 __mapped_iter_ += __x;
110 return *this;119 return *this;
111 }120 }
112121
113 _LIBCPP_HIDE_FROM_ABI __key_value_iterator& operator-=(difference_type __x) {122 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_value_iterator& operator-=(difference_type __x) {
114 __key_iter_ -= __x;123 __key_iter_ -= __x;
115 __mapped_iter_ -= __x;124 __mapped_iter_ -= __x;
116 return *this;125 return *this;
117 }126 }
118127
119 _LIBCPP_HIDE_FROM_ABI __reference operator[](difference_type __n) const { return *(*this + __n); }128 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __reference operator[](difference_type __n) const {
129 return *(*this + __n);
130 }
120131
121 _LIBCPP_HIDE_FROM_ABI friend constexpr bool132 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool
122 operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) {133 operator==(const __key_value_iterator& __x, const __key_value_iterator& __y) {
123 return __x.__key_iter_ == __y.__key_iter_;134 return __x.__key_iter_ == __y.__key_iter_;
124 }135 }
125136
126 _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) {137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool
138 operator<(const __key_value_iterator& __x, const __key_value_iterator& __y) {
127 return __x.__key_iter_ < __y.__key_iter_;139 return __x.__key_iter_ < __y.__key_iter_;
128 }140 }
129141
130 _LIBCPP_HIDE_FROM_ABI friend bool operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) {142 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool
143 operator>(const __key_value_iterator& __x, const __key_value_iterator& __y) {
131 return __y < __x;144 return __y < __x;
132 }145 }
133146
134 _LIBCPP_HIDE_FROM_ABI friend bool operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) {147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool
148 operator<=(const __key_value_iterator& __x, const __key_value_iterator& __y) {
135 return !(__y < __x);149 return !(__y < __x);
136 }150 }
137151
138 _LIBCPP_HIDE_FROM_ABI friend bool operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) {152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend bool
153 operator>=(const __key_value_iterator& __x, const __key_value_iterator& __y) {
139 return !(__x < __y);154 return !(__x < __y);
140 }155 }
141156
142 _LIBCPP_HIDE_FROM_ABI friend auto operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y)157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend auto
158 operator<=>(const __key_value_iterator& __x, const __key_value_iterator& __y)
143 requires three_way_comparable<__key_iterator>159 requires three_way_comparable<__key_iterator>
144 {160 {
145 return __x.__key_iter_ <=> __y.__key_iter_;161 return __x.__key_iter_ <=> __y.__key_iter_;
146 }162 }
147163
148 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(const __key_value_iterator& __i, difference_type __n) {164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator
165 operator+(const __key_value_iterator& __i, difference_type __n) {
149 auto __tmp = __i;166 auto __tmp = __i;
150 __tmp += __n;167 __tmp += __n;
151 return __tmp;168 return __tmp;
152 }169 }
153170
154 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator+(difference_type __n, const __key_value_iterator& __i) {171 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator
172 operator+(difference_type __n, const __key_value_iterator& __i) {
155 return __i + __n;173 return __i + __n;
156 }174 }
157175
158 _LIBCPP_HIDE_FROM_ABI friend __key_value_iterator operator-(const __key_value_iterator& __i, difference_type __n) {176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend __key_value_iterator
177 operator-(const __key_value_iterator& __i, difference_type __n) {
159 auto __tmp = __i;178 auto __tmp = __i;
160 __tmp -= __n;179 __tmp -= __n;
161 return __tmp;180 return __tmp;
162 }181 }
163182
164 _LIBCPP_HIDE_FROM_ABI friend difference_type183 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend difference_type
165 operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) {184 operator-(const __key_value_iterator& __x, const __key_value_iterator& __y) {
166 return difference_type(__x.__key_iter_ - __y.__key_iter_);185 return difference_type(__x.__key_iter_ - __y.__key_iter_);
167 }186 }
168};187};
169188
189template <class _Owner, class _KeyContainer, class _MappedContainer, bool _Const>
190struct __product_iterator_traits<__key_value_iterator<_Owner, _KeyContainer, _MappedContainer, _Const>> {
191 static constexpr size_t __size = 2;
192
193 template <size_t _Nth, class _Iter>
194 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static decltype(auto) __get_iterator_element(_Iter&& __it)
195 requires(_Nth <= 1)
196 {
197 if constexpr (_Nth == 0) {
198 return std::forward<_Iter>(__it).__key_iter_;
199 } else {
200 return std::forward<_Iter>(__it).__mapped_iter_;
201 }
202 }
203
204 template <class _KeyIter, class _MappedIter>
205 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto
206 __make_product_iterator(_KeyIter&& __key_iter, _MappedIter&& __mapped_iter) {
207 return __key_value_iterator<_Owner, _KeyContainer, _MappedContainer, _Const>(
208 std::forward<_KeyIter>(__key_iter), std::forward<_MappedIter>(__mapped_iter));
209 }
210};
211
170_LIBCPP_END_NAMESPACE_STD212_LIBCPP_END_NAMESPACE_STD
171213
172#endif // _LIBCPP_STD_VER >= 23214#endif // _LIBCPP_STD_VER >= 23
lib/libcxx/include/__flat_map/utils.h+22-4
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
11#define _LIBCPP___FLAT_MAP_UTILS_H11#define _LIBCPP___FLAT_MAP_UTILS_H
1212
13#include <__config>13#include <__config>
14#include <__iterator/product_iterator.h>
14#include <__type_traits/container_traits.h>15#include <__type_traits/container_traits.h>
15#include <__utility/exception_guard.h>16#include <__utility/exception_guard.h>
16#include <__utility/forward.h>17#include <__utility/forward.h>
...@@ -35,7 +36,7 @@ struct __flat_map_utils {...@@ -35,7 +36,7 @@ struct __flat_map_utils {
35 // roll back the changes it made to the map. If it cannot roll back the changes, it will36 // roll back the changes it made to the map. If it cannot roll back the changes, it will
36 // clear the map.37 // clear the map.
37 template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs>38 template <class _Map, class _IterK, class _IterM, class _KeyArg, class... _MArgs>
38 _LIBCPP_HIDE_FROM_ABI static typename _Map::iterator __emplace_exact_pos(39 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::iterator __emplace_exact_pos(
39 _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) {40 _Map& __map, _IterK&& __it_key, _IterM&& __it_mapped, _KeyArg&& __key, _MArgs&&... __mapped_args) {
40 auto __on_key_failed = std::__make_exception_guard([&]() noexcept {41 auto __on_key_failed = std::__make_exception_guard([&]() noexcept {
41 using _KeyContainer = typename _Map::key_container_type;42 using _KeyContainer = typename _Map::key_container_type;
...@@ -79,10 +80,8 @@ struct __flat_map_utils {...@@ -79,10 +80,8 @@ struct __flat_map_utils {
79 return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it));80 return typename _Map::iterator(std::move(__key_it), std::move(__mapped_it));
80 }81 }
8182
82 // TODO: We could optimize this, see
83 // https://github.com/llvm/llvm-project/issues/108624
84 template <class _Map, class _InputIterator, class _Sentinel>83 template <class _Map, class _InputIterator, class _Sentinel>
85 _LIBCPP_HIDE_FROM_ABI static typename _Map::size_type84 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::size_type
86 __append(_Map& __map, _InputIterator __first, _Sentinel __last) {85 __append(_Map& __map, _InputIterator __first, _Sentinel __last) {
87 typename _Map::size_type __num_appended = 0;86 typename _Map::size_type __num_appended = 0;
88 for (; __first != __last; ++__first) {87 for (; __first != __last; ++__first) {
...@@ -93,6 +92,25 @@ struct __flat_map_utils {...@@ -93,6 +92,25 @@ struct __flat_map_utils {
93 }92 }
94 return __num_appended;93 return __num_appended;
95 }94 }
95
96 template <class _Map, class _InputIterator>
97 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static typename _Map::size_type
98 __append(_Map& __map, _InputIterator __first, _InputIterator __last)
99 requires __is_product_iterator_of_size<_InputIterator, 2>::value
100 {
101 auto __s1 = __map.__containers_.keys.size();
102 __map.__containers_.keys.insert(
103 __map.__containers_.keys.end(),
104 __product_iterator_traits<_InputIterator>::template __get_iterator_element<0>(__first),
105 __product_iterator_traits<_InputIterator>::template __get_iterator_element<0>(__last));
106
107 __map.__containers_.values.insert(
108 __map.__containers_.values.end(),
109 __product_iterator_traits<_InputIterator>::template __get_iterator_element<1>(__first),
110 __product_iterator_traits<_InputIterator>::template __get_iterator_element<1>(__last));
111
112 return __map.__containers_.keys.size() - __s1;
113 }
96};114};
97_LIBCPP_END_NAMESPACE_STD115_LIBCPP_END_NAMESPACE_STD
98116
lib/libcxx/include/__flat_set/flat_multiset.h created+792
...@@ -0,0 +1,792 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FLAT_MAP_FLAT_MULTISET_H
11#define _LIBCPP___FLAT_MAP_FLAT_MULTISET_H
12
13#include <__algorithm/equal_range.h>
14#include <__algorithm/lexicographical_compare_three_way.h>
15#include <__algorithm/lower_bound.h>
16#include <__algorithm/min.h>
17#include <__algorithm/ranges_equal.h>
18#include <__algorithm/ranges_inplace_merge.h>
19#include <__algorithm/ranges_is_sorted.h>
20#include <__algorithm/ranges_sort.h>
21#include <__algorithm/ranges_unique.h>
22#include <__algorithm/remove_if.h>
23#include <__algorithm/upper_bound.h>
24#include <__assert>
25#include <__compare/synth_three_way.h>
26#include <__concepts/convertible_to.h>
27#include <__concepts/swappable.h>
28#include <__config>
29#include <__cstddef/byte.h>
30#include <__cstddef/ptrdiff_t.h>
31#include <__flat_map/key_value_iterator.h>
32#include <__flat_map/sorted_equivalent.h>
33#include <__flat_set/ra_iterator.h>
34#include <__flat_set/utils.h>
35#include <__functional/invoke.h>
36#include <__functional/is_transparent.h>
37#include <__functional/operations.h>
38#include <__fwd/vector.h>
39#include <__iterator/concepts.h>
40#include <__iterator/distance.h>
41#include <__iterator/iterator_traits.h>
42#include <__iterator/prev.h>
43#include <__iterator/ranges_iterator_traits.h>
44#include <__iterator/reverse_iterator.h>
45#include <__memory/allocator_traits.h>
46#include <__memory/uses_allocator.h>
47#include <__memory/uses_allocator_construction.h>
48#include <__ranges/access.h>
49#include <__ranges/concepts.h>
50#include <__ranges/container_compatible_range.h>
51#include <__ranges/drop_view.h>
52#include <__ranges/from_range.h>
53#include <__ranges/ref_view.h>
54#include <__ranges/size.h>
55#include <__ranges/subrange.h>
56#include <__ranges/zip_view.h>
57#include <__type_traits/conjunction.h>
58#include <__type_traits/container_traits.h>
59#include <__type_traits/invoke.h>
60#include <__type_traits/is_allocator.h>
61#include <__type_traits/is_nothrow_constructible.h>
62#include <__type_traits/is_same.h>
63#include <__type_traits/maybe_const.h>
64#include <__utility/as_const.h>
65#include <__utility/exception_guard.h>
66#include <__utility/move.h>
67#include <__utility/pair.h>
68#include <__utility/scope_guard.h>
69#include <__vector/vector.h>
70#include <initializer_list>
71
72#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
73# pragma GCC system_header
74#endif
75
76_LIBCPP_PUSH_MACROS
77#include <__undef_macros>
78
79#if _LIBCPP_STD_VER >= 23
80
81_LIBCPP_BEGIN_NAMESPACE_STD
82
83template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>>
84class flat_multiset {
85 template <class, class, class>
86 friend class flat_multiset;
87
88 friend __flat_set_utils;
89
90 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
91 static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
92
93public:
94 // types
95 using key_type = _Key;
96 using value_type = _Key;
97 using key_compare = __type_identity_t<_Compare>;
98 using value_compare = _Compare;
99 using reference = value_type&;
100 using const_reference = const value_type&;
101 using size_type = typename _KeyContainer::size_type;
102 using difference_type = typename _KeyContainer::difference_type;
103 using iterator = __ra_iterator<flat_multiset, typename _KeyContainer::const_iterator>;
104 using const_iterator = iterator;
105 using reverse_iterator = std::reverse_iterator<iterator>;
106 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
107 using container_type = _KeyContainer;
108
109public:
110 // [flat.multiset.cons], constructors
111 _LIBCPP_HIDE_FROM_ABI flat_multiset() noexcept(is_nothrow_default_constructible_v<_KeyContainer> &&
112 is_nothrow_default_constructible_v<_Compare>)
113 : __keys_(), __compare_() {}
114
115 _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset&) = default;
116
117 // The copy/move constructors are not specified in the spec, which means they should be defaulted.
118 // However, the move constructor can potentially leave a moved-from object in an inconsistent
119 // state if an exception is thrown.
120 _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other) noexcept(
121 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)
122# if _LIBCPP_HAS_EXCEPTIONS
123 try
124# endif // _LIBCPP_HAS_EXCEPTIONS
125 : __keys_(std::move(__other.__keys_)), __compare_(std::move(__other.__compare_)) {
126 __other.clear();
127# if _LIBCPP_HAS_EXCEPTIONS
128 } catch (...) {
129 __other.clear();
130 // gcc does not like the `throw` keyword in a conditionally noexcept function
131 if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)) {
132 throw;
133 }
134# endif // _LIBCPP_HAS_EXCEPTIONS
135 }
136
137 _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const key_compare& __comp) : __keys_(), __compare_(__comp) {}
138
139 _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(container_type __keys, const key_compare& __comp = key_compare())
140 : __keys_(std::move(__keys)), __compare_(__comp) {
141 ranges::sort(__keys_, __compare_);
142 }
143
144 _LIBCPP_HIDE_FROM_ABI
145 flat_multiset(sorted_equivalent_t, container_type __keys, const key_compare& __comp = key_compare())
146 : __keys_(std::move(__keys)), __compare_(__comp) {
147 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
148 }
149
150 template <class _InputIterator>
151 requires __has_input_iterator_category<_InputIterator>::value
152 _LIBCPP_HIDE_FROM_ABI
153 flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
154 : __keys_(), __compare_(__comp) {
155 insert(__first, __last);
156 }
157
158 template <class _InputIterator>
159 requires __has_input_iterator_category<_InputIterator>::value
160 _LIBCPP_HIDE_FROM_ABI flat_multiset(
161 sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
162 : __keys_(__first, __last), __compare_(__comp) {
163 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
164 }
165
166 template <_ContainerCompatibleRange<value_type> _Range>
167 _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t __fr, _Range&& __rg)
168 : flat_multiset(__fr, std::forward<_Range>(__rg), key_compare()) {}
169
170 template <_ContainerCompatibleRange<value_type> _Range>
171 _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp) : flat_multiset(__comp) {
172 insert_range(std::forward<_Range>(__rg));
173 }
174
175 _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
176 : flat_multiset(__il.begin(), __il.end(), __comp) {}
177
178 _LIBCPP_HIDE_FROM_ABI
179 flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
180 : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp) {}
181
182 template <class _Allocator>
183 requires uses_allocator<container_type, _Allocator>::value
184 _LIBCPP_HIDE_FROM_ABI explicit flat_multiset(const _Allocator& __alloc)
185 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {}
186
187 template <class _Allocator>
188 requires uses_allocator<container_type, _Allocator>::value
189 _LIBCPP_HIDE_FROM_ABI flat_multiset(const key_compare& __comp, const _Allocator& __alloc)
190 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {}
191
192 template <class _Allocator>
193 requires uses_allocator<container_type, _Allocator>::value
194 _LIBCPP_HIDE_FROM_ABI flat_multiset(const container_type& __keys, const _Allocator& __alloc)
195 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
196 ranges::sort(__keys_, __compare_);
197 }
198
199 template <class _Allocator>
200 requires uses_allocator<container_type, _Allocator>::value
201 _LIBCPP_HIDE_FROM_ABI
202 flat_multiset(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
203 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
204 ranges::sort(__keys_, __compare_);
205 }
206
207 template <class _Allocator>
208 requires uses_allocator<container_type, _Allocator>::value
209 _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, const container_type& __keys, const _Allocator& __alloc)
210 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
211 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
212 }
213
214 template <class _Allocator>
215 requires uses_allocator<container_type, _Allocator>::value
216 _LIBCPP_HIDE_FROM_ABI
217 flat_multiset(sorted_equivalent_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
218 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
219 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
220 }
221
222 template <class _Allocator>
223 requires uses_allocator<container_type, _Allocator>::value
224 _LIBCPP_HIDE_FROM_ABI flat_multiset(const flat_multiset& __other, const _Allocator& __alloc)
225 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)),
226 __compare_(__other.__compare_) {}
227
228 template <class _Allocator>
229 requires uses_allocator<container_type, _Allocator>::value
230 _LIBCPP_HIDE_FROM_ABI flat_multiset(flat_multiset&& __other, const _Allocator& __alloc)
231# if _LIBCPP_HAS_EXCEPTIONS
232 try
233# endif // _LIBCPP_HAS_EXCEPTIONS
234 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, std::move(__other.__keys_))),
235 __compare_(std::move(__other.__compare_)) {
236 __other.clear();
237# if _LIBCPP_HAS_EXCEPTIONS
238 } catch (...) {
239 __other.clear();
240 throw;
241# endif // _LIBCPP_HAS_EXCEPTIONS
242 }
243
244 template <class _InputIterator, class _Allocator>
245 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
246 _LIBCPP_HIDE_FROM_ABI flat_multiset(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
247 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
248 insert(__first, __last);
249 }
250
251 template <class _InputIterator, class _Allocator>
252 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
253 _LIBCPP_HIDE_FROM_ABI
254 flat_multiset(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
255 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
256 insert(__first, __last);
257 }
258
259 template <class _InputIterator, class _Allocator>
260 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
261 _LIBCPP_HIDE_FROM_ABI
262 flat_multiset(sorted_equivalent_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
263 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() {
264 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
265 }
266
267 template <class _InputIterator, class _Allocator>
268 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
269 _LIBCPP_HIDE_FROM_ABI
270 flat_multiset(sorted_equivalent_t,
271 _InputIterator __first,
272 _InputIterator __last,
273 const key_compare& __comp,
274 const _Allocator& __alloc)
275 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) {
276 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys_, __compare_), "Key container is not sorted");
277 }
278
279 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
280 requires uses_allocator<container_type, _Allocator>::value
281 _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const _Allocator& __alloc)
282 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
283 insert_range(std::forward<_Range>(__rg));
284 }
285
286 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
287 requires uses_allocator<container_type, _Allocator>::value
288 _LIBCPP_HIDE_FROM_ABI flat_multiset(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
289 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
290 insert_range(std::forward<_Range>(__rg));
291 }
292
293 template <class _Allocator>
294 requires uses_allocator<container_type, _Allocator>::value
295 _LIBCPP_HIDE_FROM_ABI flat_multiset(initializer_list<value_type> __il, const _Allocator& __alloc)
296 : flat_multiset(__il.begin(), __il.end(), __alloc) {}
297
298 template <class _Allocator>
299 requires uses_allocator<container_type, _Allocator>::value
300 _LIBCPP_HIDE_FROM_ABI
301 flat_multiset(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
302 : flat_multiset(__il.begin(), __il.end(), __comp, __alloc) {}
303
304 template <class _Allocator>
305 requires uses_allocator<container_type, _Allocator>::value
306 _LIBCPP_HIDE_FROM_ABI flat_multiset(sorted_equivalent_t, initializer_list<value_type> __il, const _Allocator& __alloc)
307 : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __alloc) {}
308
309 template <class _Allocator>
310 requires uses_allocator<container_type, _Allocator>::value
311 _LIBCPP_HIDE_FROM_ABI flat_multiset(
312 sorted_equivalent_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
313 : flat_multiset(sorted_equivalent, __il.begin(), __il.end(), __comp, __alloc) {}
314
315 _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(initializer_list<value_type> __il) {
316 clear();
317 insert(__il);
318 return *this;
319 }
320
321 // copy/move assignment are not specified in the spec (defaulted)
322 // but move assignment can potentially leave moved from object in an inconsistent
323 // state if an exception is thrown
324 _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(const flat_multiset&) = default;
325
326 _LIBCPP_HIDE_FROM_ABI flat_multiset& operator=(flat_multiset&& __other) noexcept(
327 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) {
328 auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
329 auto __clear_self_guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
330 __keys_ = std::move(__other.__keys_);
331 __compare_ = std::move(__other.__compare_);
332 __clear_self_guard.__complete();
333 return *this;
334 }
335
336 // iterators
337 _LIBCPP_HIDE_FROM_ABI iterator begin() noexcept { return iterator(std::as_const(__keys_).begin()); }
338 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return const_iterator(__keys_.begin()); }
339 _LIBCPP_HIDE_FROM_ABI iterator end() noexcept { return iterator(std::as_const(__keys_).end()); }
340 _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return const_iterator(__keys_.end()); }
341
342 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() noexcept { return reverse_iterator(end()); }
343 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); }
344 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() noexcept { return reverse_iterator(begin()); }
345 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); }
346
347 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return begin(); }
348 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return end(); }
349 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); }
350 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); }
351
352 // capacity
353 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __keys_.empty(); }
354 _LIBCPP_HIDE_FROM_ABI size_type size() const noexcept { return __keys_.size(); }
355 _LIBCPP_HIDE_FROM_ABI size_type max_size() const noexcept { return __keys_.max_size(); }
356
357 // [flat.multiset.modifiers], modifiers
358 template <class... _Args>
359 requires is_constructible_v<value_type, _Args...>
360 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
361 if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
362 return __emplace(std::forward<_Args>(__args)...);
363 } else {
364 return __emplace(_Key(std::forward<_Args>(__args)...));
365 }
366 }
367
368 template <class... _Args>
369 requires is_constructible_v<value_type, _Args...>
370 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
371 if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
372 return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...);
373 } else {
374 return __emplace_hint(std::move(__hint), _Key(std::forward<_Args>(__args)...));
375 }
376 }
377
378 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return emplace(__x); }
379
380 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return emplace(std::move(__x)); }
381
382 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, const value_type& __x) {
383 return emplace_hint(__hint, __x);
384 }
385
386 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, value_type&& __x) {
387 return emplace_hint(__hint, std::move(__x));
388 }
389
390 template <class _InputIterator>
391 requires __has_input_iterator_category<_InputIterator>::value
392 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
393 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
394 __reserve(__last - __first);
395 }
396 __append_sort_merge</*WasSorted = */ false>(std::move(__first), std::move(__last));
397 }
398
399 template <class _InputIterator>
400 requires __has_input_iterator_category<_InputIterator>::value
401 _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, _InputIterator __first, _InputIterator __last) {
402 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
403 __reserve(__last - __first);
404 }
405
406 __append_sort_merge</*WasSorted = */ true>(std::move(__first), std::move(__last));
407 }
408
409 template <_ContainerCompatibleRange<value_type> _Range>
410 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
411 if constexpr (ranges::sized_range<_Range>) {
412 __reserve(ranges::size(__range));
413 }
414
415 __append_sort_merge</*WasSorted = */ false>(std::forward<_Range>(__range));
416 }
417
418 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
419
420 _LIBCPP_HIDE_FROM_ABI void insert(sorted_equivalent_t, initializer_list<value_type> __il) {
421 insert(sorted_equivalent, __il.begin(), __il.end());
422 }
423
424 _LIBCPP_HIDE_FROM_ABI container_type extract() && {
425 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
426 auto __ret = std::move(__keys_);
427 return __ret;
428 }
429
430 _LIBCPP_HIDE_FROM_ABI void replace(container_type&& __keys) {
431 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(ranges::is_sorted(__keys, __compare_), "Key container is not sorted");
432 auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
433 __keys_ = std::move(__keys);
434 __guard.__complete();
435 }
436
437 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __position) {
438 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
439 auto __key_iter = __keys_.erase(__position.__base());
440 __on_failure.__complete();
441 return iterator(__key_iter);
442 }
443
444 // The following overload is the same as the iterator overload
445 // iterator erase(const_iterator __position);
446
447 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __x) {
448 auto [__first, __last] = equal_range(__x);
449 auto __res = __last - __first;
450 erase(__first, __last);
451 return __res;
452 }
453
454 template <class _Kp>
455 requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> &&
456 !is_convertible_v<_Kp &&, const_iterator>)
457 _LIBCPP_HIDE_FROM_ABI size_type erase(_Kp&& __x) {
458 auto [__first, __last] = equal_range(__x);
459 auto __res = __last - __first;
460 erase(__first, __last);
461 return __res;
462 }
463
464 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __first, const_iterator __last) {
465 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
466 auto __key_it = __keys_.erase(__first.__base(), __last.__base());
467 __on_failure.__complete();
468 return iterator(std::move(__key_it));
469 }
470
471 _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __y) noexcept {
472 // warning: The spec has unconditional noexcept, which means that
473 // if any of the following functions throw an exception,
474 // std::terminate will be called
475 // This is discussed in P3567, which hasn't been voted on yet.
476 ranges::swap(__compare_, __y.__compare_);
477 ranges::swap(__keys_, __y.__keys_);
478 }
479
480 _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __keys_.clear(); }
481
482 // observers
483 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
484 _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __compare_; }
485
486 // map operations
487 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __x) { return __find_impl(*this, __x); }
488
489 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __x) const { return __find_impl(*this, __x); }
490
491 template <class _Kp>
492 requires __is_transparent_v<_Compare>
493 _LIBCPP_HIDE_FROM_ABI iterator find(const _Kp& __x) {
494 return __find_impl(*this, __x);
495 }
496
497 template <class _Kp>
498 requires __is_transparent_v<_Compare>
499 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Kp& __x) const {
500 return __find_impl(*this, __x);
501 }
502
503 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __x) const {
504 auto [__first, __last] = equal_range(__x);
505 return __last - __first;
506 }
507
508 template <class _Kp>
509 requires __is_transparent_v<_Compare>
510 _LIBCPP_HIDE_FROM_ABI size_type count(const _Kp& __x) const {
511 auto [__first, __last] = equal_range(__x);
512 return __last - __first;
513 }
514
515 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
516
517 template <class _Kp>
518 requires __is_transparent_v<_Compare>
519 _LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
520 return find(__x) != end();
521 }
522
523 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __x) {
524 const auto& __keys = __keys_;
525 return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
526 }
527
528 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __x) const {
529 return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
530 }
531
532 template <class _Kp>
533 requires __is_transparent_v<_Compare>
534 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _Kp& __x) {
535 const auto& __keys = __keys_;
536 return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
537 }
538
539 template <class _Kp>
540 requires __is_transparent_v<_Compare>
541 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Kp& __x) const {
542 return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
543 }
544
545 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __x) {
546 const auto& __keys = __keys_;
547 return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
548 }
549
550 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __x) const {
551 return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
552 }
553
554 template <class _Kp>
555 requires __is_transparent_v<_Compare>
556 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Kp& __x) {
557 const auto& __keys = __keys_;
558 return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
559 }
560
561 template <class _Kp>
562 requires __is_transparent_v<_Compare>
563 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Kp& __x) const {
564 return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
565 }
566
567 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __x) {
568 return __equal_range_impl(*this, __x);
569 }
570
571 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __x) const {
572 return __equal_range_impl(*this, __x);
573 }
574
575 template <class _Kp>
576 requires __is_transparent_v<_Compare>
577 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _Kp& __x) {
578 return __equal_range_impl(*this, __x);
579 }
580 template <class _Kp>
581 requires __is_transparent_v<_Compare>
582 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _Kp& __x) const {
583 return __equal_range_impl(*this, __x);
584 }
585
586 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const flat_multiset& __x, const flat_multiset& __y) {
587 return ranges::equal(__x, __y);
588 }
589
590 friend _LIBCPP_HIDE_FROM_ABI auto operator<=>(const flat_multiset& __x, const flat_multiset& __y) {
591 return std::lexicographical_compare_three_way(
592 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
593 }
594
595 friend _LIBCPP_HIDE_FROM_ABI void swap(flat_multiset& __x, flat_multiset& __y) noexcept { __x.swap(__y); }
596
597private:
598 template <bool _WasSorted, class... _Args>
599 _LIBCPP_HIDE_FROM_ABI void __append_sort_merge(_Args&&... __args) {
600 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
601 size_type __old_size = size();
602 __flat_set_utils::__append(*this, std::forward<_Args>(__args)...);
603 if constexpr (!_WasSorted) {
604 ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_);
605 } else {
606 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
607 ranges::is_sorted(__keys_ | ranges::views::drop(__old_size)), "Key container is not sorted");
608 }
609 ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_);
610 __on_failure.__complete();
611 }
612
613 template <class _Kp>
614 _LIBCPP_HIDE_FROM_ABI iterator __emplace(_Kp&& __key) {
615 auto __it = upper_bound(__key);
616 return __flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key));
617 }
618
619 template <class _Kp>
620 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
621 auto __prev_larger = __hint != cbegin() && __compare_(__key, *std::prev(__hint));
622 auto __next_smaller = __hint != cend() && __compare_(*__hint, __key);
623
624 if (!__prev_larger && !__next_smaller) [[likely]] {
625 // hint correct, just use exact hint iterator
626 } else if (__prev_larger && !__next_smaller) {
627 // the hint position is more to the right than the key should have been.
628 // we want to emplace the element to a position as right as possible
629 // e.g. Insert new element "2" in the following range
630 // 1, 1, 2, 2, 2, 3, 4, 6
631 // ^
632 // |
633 // hint
634 // We want to insert "2" after the last existing "2"
635 __hint = std::upper_bound(begin(), __hint, __key, __compare_);
636 } else {
637 _LIBCPP_ASSERT_INTERNAL(!__prev_larger && __next_smaller, "this means that the multiset is not sorted");
638
639 // the hint position is more to the left than the key should have been.
640 // we want to emplace the element to a position as left as possible
641 // 1, 1, 2, 2, 2, 3, 4, 6
642 // ^
643 // |
644 // hint
645 // We want to insert "2" before the first existing "2"
646 __hint = std::lower_bound(__hint, end(), __key, __compare_);
647 }
648 return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key));
649 }
650
651 template <class _Self, class _Kp>
652 _LIBCPP_HIDE_FROM_ABI static auto __find_impl(_Self&& __self, const _Kp& __key) {
653 auto __it = __self.lower_bound(__key);
654 auto __last = __self.end();
655 if (__it == __last || __self.__compare_(__key, *__it)) {
656 return __last;
657 }
658 return __it;
659 }
660
661 template <class _Self, class _Kp>
662 _LIBCPP_HIDE_FROM_ABI static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
663 using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>;
664 auto [__key_first, __key_last] =
665 std::equal_range(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_);
666 return std::make_pair(__iter(__key_first), __iter(__key_last));
667 }
668
669 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __size) {
670 if constexpr (__container_traits<_KeyContainer>::__reservable) {
671 __keys_.reserve(__size);
672 }
673 }
674
675 template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate>
676 friend typename flat_multiset<_Key2, _Compare2, _KeyContainer2>::size_type
677 erase_if(flat_multiset<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
678
679 _KeyContainer __keys_;
680 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
681
682 struct __key_equiv {
683 _LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
684 _LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
685 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
686 }
687 key_compare __comp_;
688 };
689};
690
691template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
692 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
693 is_invocable_v<const _Compare&,
694 const typename _KeyContainer::value_type&,
695 const typename _KeyContainer::value_type&>)
696flat_multiset(_KeyContainer, _Compare = _Compare())
697 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
698
699template <class _KeyContainer, class _Allocator>
700 requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
701flat_multiset(_KeyContainer, _Allocator)
702 -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
703
704template <class _KeyContainer, class _Compare, class _Allocator>
705 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
706 uses_allocator_v<_KeyContainer, _Allocator> &&
707 is_invocable_v<const _Compare&,
708 const typename _KeyContainer::value_type&,
709 const typename _KeyContainer::value_type&>)
710flat_multiset(_KeyContainer, _Compare, _Allocator)
711 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
712
713template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
714 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
715 is_invocable_v<const _Compare&,
716 const typename _KeyContainer::value_type&,
717 const typename _KeyContainer::value_type&>)
718flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare = _Compare())
719 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
720
721template <class _KeyContainer, class _Allocator>
722 requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
723flat_multiset(sorted_equivalent_t, _KeyContainer, _Allocator)
724 -> flat_multiset<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
725
726template <class _KeyContainer, class _Compare, class _Allocator>
727 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
728 uses_allocator_v<_KeyContainer, _Allocator> &&
729 is_invocable_v<const _Compare&,
730 const typename _KeyContainer::value_type&,
731 const typename _KeyContainer::value_type&>)
732flat_multiset(sorted_equivalent_t, _KeyContainer, _Compare, _Allocator)
733 -> flat_multiset<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
734
735template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
736 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
737flat_multiset(_InputIterator, _InputIterator, _Compare = _Compare())
738 -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
739
740template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
741 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
742flat_multiset(sorted_equivalent_t, _InputIterator, _InputIterator, _Compare = _Compare())
743 -> flat_multiset<__iter_value_type<_InputIterator>, _Compare>;
744
745template <ranges::input_range _Range,
746 class _Compare = less<ranges::range_value_t<_Range>>,
747 class _Allocator = allocator<ranges::range_value_t<_Range>>,
748 class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
749flat_multiset(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_multiset<
750 ranges::range_value_t<_Range>,
751 _Compare,
752 vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
753
754template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
755flat_multiset(from_range_t, _Range&&, _Allocator) -> flat_multiset<
756 ranges::range_value_t<_Range>,
757 less<ranges::range_value_t<_Range>>,
758 vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
759
760template <class _Key, class _Compare = less<_Key>>
761 requires(!__is_allocator<_Compare>::value)
762flat_multiset(initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>;
763
764template <class _Key, class _Compare = less<_Key>>
765 requires(!__is_allocator<_Compare>::value)
766flat_multiset(sorted_equivalent_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_multiset<_Key, _Compare>;
767
768template <class _Key, class _Compare, class _KeyContainer, class _Allocator>
769struct uses_allocator<flat_multiset<_Key, _Compare, _KeyContainer>, _Allocator>
770 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator> > {};
771
772template <class _Key, class _Compare, class _KeyContainer, class _Predicate>
773_LIBCPP_HIDE_FROM_ABI typename flat_multiset<_Key, _Compare, _KeyContainer>::size_type
774erase_if(flat_multiset<_Key, _Compare, _KeyContainer>& __flat_multiset, _Predicate __pred) {
775 auto __guard = std::__make_exception_guard([&] { __flat_multiset.clear(); });
776 auto __it =
777 std::remove_if(__flat_multiset.__keys_.begin(), __flat_multiset.__keys_.end(), [&](const auto& __e) -> bool {
778 return static_cast<bool>(__pred(__e));
779 });
780 auto __res = __flat_multiset.__keys_.end() - __it;
781 __flat_multiset.__keys_.erase(__it, __flat_multiset.__keys_.end());
782 __guard.__complete();
783 return __res;
784}
785
786_LIBCPP_END_NAMESPACE_STD
787
788#endif // _LIBCPP_STD_VER >= 23
789
790_LIBCPP_POP_MACROS
791
792#endif // _LIBCPP___FLAT_MAP_FLAT_MULTISET_H
lib/libcxx/include/__flat_set/flat_set.h created+874
...@@ -0,0 +1,874 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FLAT_SET_FLAT_SET_H
11#define _LIBCPP___FLAT_SET_FLAT_SET_H
12
13#include <__algorithm/lexicographical_compare_three_way.h>
14#include <__algorithm/lower_bound.h>
15#include <__algorithm/min.h>
16#include <__algorithm/ranges_adjacent_find.h>
17#include <__algorithm/ranges_equal.h>
18#include <__algorithm/ranges_inplace_merge.h>
19#include <__algorithm/ranges_sort.h>
20#include <__algorithm/ranges_unique.h>
21#include <__algorithm/remove_if.h>
22#include <__algorithm/upper_bound.h>
23#include <__assert>
24#include <__compare/synth_three_way.h>
25#include <__concepts/swappable.h>
26#include <__config>
27#include <__cstddef/ptrdiff_t.h>
28#include <__flat_map/sorted_unique.h>
29#include <__flat_set/ra_iterator.h>
30#include <__flat_set/utils.h>
31#include <__functional/invoke.h>
32#include <__functional/is_transparent.h>
33#include <__functional/operations.h>
34#include <__fwd/vector.h>
35#include <__iterator/concepts.h>
36#include <__iterator/distance.h>
37#include <__iterator/iterator_traits.h>
38#include <__iterator/next.h>
39#include <__iterator/prev.h>
40#include <__iterator/ranges_iterator_traits.h>
41#include <__iterator/reverse_iterator.h>
42#include <__memory/allocator_traits.h>
43#include <__memory/uses_allocator.h>
44#include <__memory/uses_allocator_construction.h>
45#include <__ranges/access.h>
46#include <__ranges/concepts.h>
47#include <__ranges/container_compatible_range.h>
48#include <__ranges/drop_view.h>
49#include <__ranges/from_range.h>
50#include <__ranges/ref_view.h>
51#include <__ranges/size.h>
52#include <__ranges/subrange.h>
53#include <__type_traits/conjunction.h>
54#include <__type_traits/container_traits.h>
55#include <__type_traits/invoke.h>
56#include <__type_traits/is_allocator.h>
57#include <__type_traits/is_const.h>
58#include <__type_traits/is_nothrow_constructible.h>
59#include <__type_traits/is_same.h>
60#include <__type_traits/remove_reference.h>
61#include <__utility/as_const.h>
62#include <__utility/exception_guard.h>
63#include <__utility/move.h>
64#include <__utility/pair.h>
65#include <__utility/scope_guard.h>
66#include <__vector/vector.h>
67#include <initializer_list>
68
69#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
70# pragma GCC system_header
71#endif
72
73_LIBCPP_PUSH_MACROS
74#include <__undef_macros>
75
76#if _LIBCPP_STD_VER >= 23
77
78_LIBCPP_BEGIN_NAMESPACE_STD
79
80template <class _Key, class _Compare = less<_Key>, class _KeyContainer = vector<_Key>>
81class flat_set {
82 template <class, class, class>
83 friend class flat_set;
84
85 friend __flat_set_utils;
86
87 static_assert(is_same_v<_Key, typename _KeyContainer::value_type>);
88 static_assert(!is_same_v<_KeyContainer, std::vector<bool>>, "vector<bool> is not a sequence container");
89
90 using __key_iterator _LIBCPP_NODEBUG = typename _KeyContainer::const_iterator;
91
92public:
93 // types
94 using key_type = _Key;
95 using value_type = _Key;
96 using key_compare = __type_identity_t<_Compare>;
97 using value_compare = _Compare;
98 using reference = value_type&;
99 using const_reference = const value_type&;
100 using size_type = typename _KeyContainer::size_type;
101 using difference_type = typename _KeyContainer::difference_type;
102 using iterator = __ra_iterator<flat_set, typename _KeyContainer::const_iterator>;
103 using const_iterator = iterator;
104 using reverse_iterator = std::reverse_iterator<iterator>;
105 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
106 using container_type = _KeyContainer;
107
108public:
109 // [flat.set.cons], construct/copy/destroy
110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
111 flat_set() noexcept(is_nothrow_default_constructible_v<_KeyContainer> && is_nothrow_default_constructible_v<_Compare>)
112 : __keys_(), __compare_() {}
113
114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set&) = default;
115
116 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other) noexcept(
117 is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)
118# if _LIBCPP_HAS_EXCEPTIONS
119 try
120# endif // _LIBCPP_HAS_EXCEPTIONS
121 : __keys_(std::move(__other.__keys_)), __compare_(std::move(__other.__compare_)) {
122 __other.clear();
123# if _LIBCPP_HAS_EXCEPTIONS
124 } catch (...) {
125 __other.clear();
126 // gcc does not like the `throw` keyword in a conditionally noexcept function
127 if constexpr (!(is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_Compare>)) {
128 throw;
129 }
130# endif // _LIBCPP_HAS_EXCEPTIONS
131 }
132
133 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const key_compare& __comp)
134 : __keys_(), __compare_(__comp) {}
135
136 _LIBCPP_HIDE_FROM_ABI
137 _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(container_type __keys, const key_compare& __comp = key_compare())
138 : __keys_(std::move(__keys)), __compare_(__comp) {
139 __sort_and_unique();
140 }
141
142 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
143 flat_set(sorted_unique_t, container_type __keys, const key_compare& __comp = key_compare())
144 : __keys_(std::move(__keys)), __compare_(__comp) {
145 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
146 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
147 }
148
149 template <class _InputIterator>
150 requires __has_input_iterator_category<_InputIterator>::value
151 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
152 flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
153 : __keys_(), __compare_(__comp) {
154 insert(__first, __last);
155 }
156
157 template <class _InputIterator>
158 requires __has_input_iterator_category<_InputIterator>::value
159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
160 flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const key_compare& __comp = key_compare())
161 : __keys_(__first, __last), __compare_(__comp) {
162 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
163 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
164 }
165
166 template <_ContainerCompatibleRange<value_type> _Range>
167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg)
168 : flat_set(from_range, std::forward<_Range>(__rg), key_compare()) {}
169
170 template <_ContainerCompatibleRange<value_type> _Range>
171 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const key_compare& __comp)
172 : flat_set(__comp) {
173 insert_range(std::forward<_Range>(__rg));
174 }
175
176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
177 flat_set(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
178 : flat_set(__il.begin(), __il.end(), __comp) {}
179
180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
181 flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp = key_compare())
182 : flat_set(sorted_unique, __il.begin(), __il.end(), __comp) {}
183
184 template <class _Allocator>
185 requires uses_allocator<container_type, _Allocator>::value
186 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit flat_set(const _Allocator& __alloc)
187 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {}
188
189 template <class _Allocator>
190 requires uses_allocator<container_type, _Allocator>::value
191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const key_compare& __comp, const _Allocator& __alloc)
192 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {}
193
194 template <class _Allocator>
195 requires uses_allocator<container_type, _Allocator>::value
196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const container_type& __keys, const _Allocator& __alloc)
197 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
198 __sort_and_unique();
199 }
200
201 template <class _Allocator>
202 requires uses_allocator<container_type, _Allocator>::value
203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
204 flat_set(const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
205 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
206 __sort_and_unique();
207 }
208
209 template <class _Allocator>
210 requires uses_allocator<container_type, _Allocator>::value
211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
212 flat_set(sorted_unique_t, const container_type& __keys, const _Allocator& __alloc)
213 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_() {
214 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
215 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
216 }
217
218 template <class _Allocator>
219 requires uses_allocator<container_type, _Allocator>::value
220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
221 flat_set(sorted_unique_t, const container_type& __keys, const key_compare& __comp, const _Allocator& __alloc)
222 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __keys)), __compare_(__comp) {
223 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
224 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
225 }
226
227 template <class _Allocator>
228 requires uses_allocator<container_type, _Allocator>::value
229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(const flat_set& __other, const _Allocator& __alloc)
230 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __other.__keys_)),
231 __compare_(__other.__compare_) {}
232
233 template <class _Allocator>
234 requires uses_allocator<container_type, _Allocator>::value
235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(flat_set&& __other, const _Allocator& __alloc)
236# if _LIBCPP_HAS_EXCEPTIONS
237 try
238# endif // _LIBCPP_HAS_EXCEPTIONS
239 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, std::move(__other.__keys_))),
240 __compare_(std::move(__other.__compare_)) {
241 __other.clear();
242# if _LIBCPP_HAS_EXCEPTIONS
243 } catch (...) {
244 __other.clear();
245 throw;
246# endif // _LIBCPP_HAS_EXCEPTIONS
247 }
248
249 template <class _InputIterator, class _Allocator>
250 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
252 flat_set(_InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
253 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
254 insert(__first, __last);
255 }
256
257 template <class _InputIterator, class _Allocator>
258 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
260 flat_set(_InputIterator __first, _InputIterator __last, const key_compare& __comp, const _Allocator& __alloc)
261 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
262 insert(__first, __last);
263 }
264
265 template <class _InputIterator, class _Allocator>
266 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
268 flat_set(sorted_unique_t, _InputIterator __first, _InputIterator __last, const _Allocator& __alloc)
269 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_() {
270 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
271 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
272 }
273
274 template <class _InputIterator, class _Allocator>
275 requires(__has_input_iterator_category<_InputIterator>::value && uses_allocator<container_type, _Allocator>::value)
276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(
277 sorted_unique_t,
278 _InputIterator __first,
279 _InputIterator __last,
280 const key_compare& __comp,
281 const _Allocator& __alloc)
282 : __keys_(std::make_obj_using_allocator<container_type>(__alloc, __first, __last)), __compare_(__comp) {
283 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
284 __is_sorted_and_unique(__keys_), "Either the key container is not sorted or it contains duplicates");
285 }
286
287 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
288 requires uses_allocator<container_type, _Allocator>::value
289 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set(from_range_t, _Range&& __rg, const _Allocator& __alloc)
290 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_() {
291 insert_range(std::forward<_Range>(__rg));
292 }
293
294 template <_ContainerCompatibleRange<value_type> _Range, class _Allocator>
295 requires uses_allocator<container_type, _Allocator>::value
296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
297 flat_set(from_range_t, _Range&& __rg, const key_compare& __comp, const _Allocator& __alloc)
298 : __keys_(std::make_obj_using_allocator<container_type>(__alloc)), __compare_(__comp) {
299 insert_range(std::forward<_Range>(__rg));
300 }
301
302 template <class _Allocator>
303 requires uses_allocator<container_type, _Allocator>::value
304 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
305 flat_set(initializer_list<value_type> __il, const _Allocator& __alloc)
306 : flat_set(__il.begin(), __il.end(), __alloc) {}
307
308 template <class _Allocator>
309 requires uses_allocator<container_type, _Allocator>::value
310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
311 flat_set(initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
312 : flat_set(__il.begin(), __il.end(), __comp, __alloc) {}
313
314 template <class _Allocator>
315 requires uses_allocator<container_type, _Allocator>::value
316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
317 flat_set(sorted_unique_t, initializer_list<value_type> __il, const _Allocator& __alloc)
318 : flat_set(sorted_unique, __il.begin(), __il.end(), __alloc) {}
319
320 template <class _Allocator>
321 requires uses_allocator<container_type, _Allocator>::value
322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
323 flat_set(sorted_unique_t, initializer_list<value_type> __il, const key_compare& __comp, const _Allocator& __alloc)
324 : flat_set(sorted_unique, __il.begin(), __il.end(), __comp, __alloc) {}
325
326 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(initializer_list<value_type> __il) {
327 clear();
328 insert(__il);
329 return *this;
330 }
331
332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(const flat_set&) = default;
333
334 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 flat_set& operator=(flat_set&& __other) noexcept(
335 is_nothrow_move_assignable_v<_KeyContainer> && is_nothrow_move_assignable_v<_Compare>) {
336 // No matter what happens, we always want to clear the other container before returning
337 // since we moved from it
338 auto __clear_other_guard = std::__make_scope_guard([&]() noexcept { __other.clear() /* noexcept */; });
339 {
340 // If an exception is thrown, we have no choice but to clear *this to preserve invariants
341 auto __on_exception = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
342 __keys_ = std::move(__other.__keys_);
343 __compare_ = std::move(__other.__compare_);
344 __on_exception.__complete();
345 }
346 return *this;
347 }
348
349 // iterators
350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() noexcept {
351 return iterator(std::as_const(__keys_).begin());
352 }
353 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const noexcept {
354 return const_iterator(__keys_.begin());
355 }
356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() noexcept {
357 return iterator(std::as_const(__keys_).end());
358 }
359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const noexcept {
360 return const_iterator(__keys_.end());
361 }
362
363 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() noexcept {
364 return reverse_iterator(end());
365 }
366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const noexcept {
367 return const_reverse_iterator(end());
368 }
369 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() noexcept {
370 return reverse_iterator(begin());
371 }
372 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const noexcept {
373 return const_reverse_iterator(begin());
374 }
375
376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const noexcept { return begin(); }
377 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const noexcept { return end(); }
378 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const noexcept {
379 return const_reverse_iterator(end());
380 }
381 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const noexcept {
382 return const_reverse_iterator(begin());
383 }
384
385 // [flat.set.capacity], capacity
386 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const noexcept {
387 return __keys_.empty();
388 }
389
390 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const noexcept { return __keys_.size(); }
391
392 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const noexcept { return __keys_.max_size(); }
393
394 // [flat.set.modifiers], modifiers
395 template <class... _Args>
396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
397 if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
398 return __emplace(std::forward<_Args>(__args)...);
399 } else {
400 return __emplace(_Key(std::forward<_Args>(__args)...));
401 }
402 }
403
404 template <class... _Args>
405 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __hint, _Args&&... __args) {
406 if constexpr (sizeof...(__args) == 1 && (is_same_v<remove_cvref_t<_Args>, _Key> && ...)) {
407 return __emplace_hint(std::move(__hint), std::forward<_Args>(__args)...);
408 } else {
409 return __emplace_hint(std::move(__hint), _Key(std::forward<_Args>(__args)...));
410 }
411 }
412
413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __x) {
414 return emplace(__x);
415 }
416
417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __x) {
418 return emplace(std::move(__x));
419 }
420
421 template <class _Kp>
422 requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>)
423 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_Kp&& __x) {
424 return __emplace(std::forward<_Kp>(__x));
425 }
426 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, const value_type& __x) {
427 return emplace_hint(__hint, __x);
428 }
429
430 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, value_type&& __x) {
431 return emplace_hint(__hint, std::move(__x));
432 }
433
434 template <class _Kp>
435 requires(__is_transparent_v<_Compare> && is_constructible_v<value_type, _Kp>)
436 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, _Kp&& __x) {
437 return __emplace_hint(__hint, std::forward<_Kp>(__x));
438 }
439
440 template <class _InputIterator>
441 requires __has_input_iterator_category<_InputIterator>::value
442 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
443 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
444 __reserve(__last - __first);
445 }
446 __append_sort_merge_unique</*WasSorted = */ false>(std::move(__first), std::move(__last));
447 }
448
449 template <class _InputIterator>
450 requires __has_input_iterator_category<_InputIterator>::value
451 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
452 insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
453 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
454 __reserve(__last - __first);
455 }
456
457 __append_sort_merge_unique</*WasSorted = */ true>(std::move(__first), std::move(__last));
458 }
459
460 template <_ContainerCompatibleRange<value_type> _Range>
461 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
462 if constexpr (ranges::sized_range<_Range>) {
463 __reserve(ranges::size(__range));
464 }
465
466 __append_sort_merge_unique</*WasSorted = */ false>(std::forward<_Range>(__range));
467 }
468
469 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
470 insert(__il.begin(), __il.end());
471 }
472
473 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(sorted_unique_t, initializer_list<value_type> __il) {
474 insert(sorted_unique, __il.begin(), __il.end());
475 }
476
477 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 container_type extract() && {
478 auto __guard = std::__make_scope_guard([&]() noexcept { clear() /* noexcept */; });
479 auto __ret = std::move(__keys_);
480 return __ret;
481 }
482
483 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void replace(container_type&& __keys) {
484 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(
485 __is_sorted_and_unique(__keys), "Either the key container is not sorted or it contains duplicates");
486 auto __guard = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
487 __keys_ = std::move(__keys);
488 __guard.__complete();
489 }
490
491 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __position) {
492 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
493 auto __key_iter = __keys_.erase(__position.__base());
494 __on_failure.__complete();
495 return iterator(__key_iter);
496 }
497
498 // The following overload is the same as the iterator overload
499 // iterator erase(const_iterator __position);
500
501 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __x) {
502 auto __iter = find(__x);
503 if (__iter != end()) {
504 erase(__iter);
505 return 1;
506 }
507 return 0;
508 }
509
510 template <class _Kp>
511 requires(__is_transparent_v<_Compare> && !is_convertible_v<_Kp &&, iterator> &&
512 !is_convertible_v<_Kp &&, const_iterator>)
513 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(_Kp&& __x) {
514 auto [__first, __last] = equal_range(__x);
515 auto __res = __last - __first;
516 erase(__first, __last);
517 return __res;
518 }
519
520 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __first, const_iterator __last) {
521 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
522 auto __key_it = __keys_.erase(__first.__base(), __last.__base());
523 __on_failure.__complete();
524 return iterator(std::move(__key_it));
525 }
526
527 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __y) noexcept {
528 // warning: The spec has unconditional noexcept, which means that
529 // if any of the following functions throw an exception,
530 // std::terminate will be called.
531 // This is discussed in P2767, which hasn't been voted on yet.
532 ranges::swap(__compare_, __y.__compare_);
533 ranges::swap(__keys_, __y.__keys_);
534 }
535
536 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() noexcept { __keys_.clear(); }
537
538 // observers
539 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __compare_; }
540 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { return __compare_; }
541
542 // set operations
543 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __x) {
544 return __find_impl(*this, __x);
545 }
546
547 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __x) const {
548 return __find_impl(*this, __x);
549 }
550
551 template <class _Kp>
552 requires __is_transparent_v<_Compare>
553 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Kp& __x) {
554 return __find_impl(*this, __x);
555 }
556
557 template <class _Kp>
558 requires __is_transparent_v<_Compare>
559 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Kp& __x) const {
560 return __find_impl(*this, __x);
561 }
562
563 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __x) const {
564 return contains(__x) ? 1 : 0;
565 }
566
567 template <class _Kp>
568 requires __is_transparent_v<_Compare>
569 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _Kp& __x) const {
570 return contains(__x) ? 1 : 0;
571 }
572
573 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __x) const {
574 return find(__x) != end();
575 }
576
577 template <class _Kp>
578 requires __is_transparent_v<_Compare>
579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _Kp& __x) const {
580 return find(__x) != end();
581 }
582
583 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __x) {
584 const auto& __keys = __keys_;
585 return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
586 }
587
588 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __x) const {
589 return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
590 }
591
592 template <class _Kp>
593 requires __is_transparent_v<_Compare>
594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _Kp& __x) {
595 const auto& __keys = __keys_;
596 return iterator(std::lower_bound(__keys.begin(), __keys.end(), __x, __compare_));
597 }
598
599 template <class _Kp>
600 requires __is_transparent_v<_Compare>
601 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _Kp& __x) const {
602 return const_iterator(std::lower_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
603 }
604
605 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __x) {
606 const auto& __keys = __keys_;
607 return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
608 }
609
610 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __x) const {
611 return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
612 }
613
614 template <class _Kp>
615 requires __is_transparent_v<_Compare>
616 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _Kp& __x) {
617 const auto& __keys = __keys_;
618 return iterator(std::upper_bound(__keys.begin(), __keys.end(), __x, __compare_));
619 }
620
621 template <class _Kp>
622 requires __is_transparent_v<_Compare>
623 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _Kp& __x) const {
624 return const_iterator(std::upper_bound(__keys_.begin(), __keys_.end(), __x, __compare_));
625 }
626
627 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __x) {
628 return __equal_range_impl(*this, __x);
629 }
630
631 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
632 equal_range(const key_type& __x) const {
633 return __equal_range_impl(*this, __x);
634 }
635
636 template <class _Kp>
637 requires __is_transparent_v<_Compare>
638 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _Kp& __x) {
639 return __equal_range_impl(*this, __x);
640 }
641 template <class _Kp>
642 requires __is_transparent_v<_Compare>
643 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
644 equal_range(const _Kp& __x) const {
645 return __equal_range_impl(*this, __x);
646 }
647
648 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const flat_set& __x, const flat_set& __y) {
649 return ranges::equal(__x, __y);
650 }
651
652 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
653 operator<=>(const flat_set& __x, const flat_set& __y) {
654 return std::lexicographical_compare_three_way(
655 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
656 }
657
658 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(flat_set& __x, flat_set& __y) noexcept {
659 __x.swap(__y);
660 }
661
662private:
663 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_sorted_and_unique(auto&& __key_container) const {
664 auto __greater_or_equal_to = [this](const auto& __x, const auto& __y) { return !__compare_(__x, __y); };
665 return ranges::adjacent_find(__key_container, __greater_or_equal_to) == ranges::end(__key_container);
666 }
667
668 // This function is only used in constructors. So there is not exception handling in this function.
669 // If the function exits via an exception, there will be no flat_set object constructed, thus, there
670 // is no invariant state to preserve
671 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __sort_and_unique() {
672 ranges::sort(__keys_, __compare_);
673 auto __dup_start = ranges::unique(__keys_, __key_equiv(__compare_)).begin();
674 __keys_.erase(__dup_start, __keys_.end());
675 }
676
677 template <bool _WasSorted, class... _Args>
678 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __append_sort_merge_unique(_Args&&... __args) {
679 auto __on_failure = std::__make_exception_guard([&]() noexcept { clear() /* noexcept */; });
680 size_type __old_size = size();
681 __flat_set_utils::__append(*this, std::forward<_Args>(__args)...);
682 if (size() != __old_size) {
683 if constexpr (!_WasSorted) {
684 ranges::sort(__keys_.begin() + __old_size, __keys_.end(), __compare_);
685 } else {
686 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__is_sorted_and_unique(__keys_ | ranges::views::drop(__old_size)),
687 "Either the key container is not sorted or it contains duplicates");
688 }
689 ranges::inplace_merge(__keys_.begin(), __keys_.begin() + __old_size, __keys_.end(), __compare_);
690
691 auto __dup_start = ranges::unique(__keys_, __key_equiv(__compare_)).begin();
692 __keys_.erase(__dup_start, __keys_.end());
693 }
694 __on_failure.__complete();
695 }
696
697 template <class _Self, class _Kp>
698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __find_impl(_Self&& __self, const _Kp& __key) {
699 auto __it = __self.lower_bound(__key);
700 auto __last = __self.end();
701 if (__it == __last || __self.__compare_(__key, *__it)) {
702 return __last;
703 }
704 return __it;
705 }
706
707 template <class _Self, class _Kp>
708 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto __equal_range_impl(_Self&& __self, const _Kp& __key) {
709 using __iter = _If<is_const_v<__libcpp_remove_reference_t<_Self>>, const_iterator, iterator>;
710 auto __it = std::lower_bound(__self.__keys_.begin(), __self.__keys_.end(), __key, __self.__compare_);
711 auto __last = __self.__keys_.end();
712 if (__it == __last || __self.__compare_(__key, *__it)) {
713 return std::make_pair(__iter(__it), __iter(__it));
714 }
715 return std::make_pair(__iter(__it), __iter(std::next(__it)));
716 }
717
718 template <class _Kp>
719 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace(_Kp&& __key) {
720 auto __it = lower_bound(__key);
721 if (__it == end() || __compare_(__key, *__it)) {
722 return pair<iterator, bool>(__flat_set_utils::__emplace_exact_pos(*this, __it, std::forward<_Kp>(__key)), true);
723 } else {
724 return pair<iterator, bool>(std::move(__it), false);
725 }
726 }
727
728 template <class _Kp>
729 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __is_hint_correct(const_iterator __hint, _Kp&& __key) {
730 if (__hint != cbegin() && !__compare_(*std::prev(__hint), __key)) {
731 return false;
732 }
733 if (__hint != cend() && __compare_(*__hint, __key)) {
734 return false;
735 }
736 return true;
737 }
738
739 template <class _Kp>
740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint(const_iterator __hint, _Kp&& __key) {
741 if (__is_hint_correct(__hint, __key)) {
742 if (__hint == cend() || __compare_(__key, *__hint)) {
743 return __flat_set_utils::__emplace_exact_pos(*this, __hint, std::forward<_Kp>(__key));
744 } else {
745 // we already have an equal key
746 return __hint;
747 }
748 } else {
749 return __emplace(std::forward<_Kp>(__key)).first;
750 }
751 }
752
753 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __reserve(size_t __size) {
754 if constexpr (__container_traits<_KeyContainer>::__reservable) {
755 __keys_.reserve(__size);
756 }
757 }
758
759 template <class _Key2, class _Compare2, class _KeyContainer2, class _Predicate>
760 friend typename flat_set<_Key2, _Compare2, _KeyContainer2>::size_type _LIBCPP_CONSTEXPR_SINCE_CXX26
761 erase_if(flat_set<_Key2, _Compare2, _KeyContainer2>&, _Predicate);
762
763 _KeyContainer __keys_;
764 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
765
766 struct __key_equiv {
767 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {}
768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
769 operator()(const_reference __x, const_reference __y) const {
770 return !__comp_(__x, __y) && !__comp_(__y, __x);
771 }
772 key_compare __comp_;
773 };
774};
775
776template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
777 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
778 is_invocable_v<const _Compare&,
779 const typename _KeyContainer::value_type&,
780 const typename _KeyContainer::value_type&>)
781flat_set(_KeyContainer, _Compare = _Compare()) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
782
783template <class _KeyContainer, class _Allocator>
784 requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
785flat_set(_KeyContainer, _Allocator)
786 -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
787
788template <class _KeyContainer, class _Compare, class _Allocator>
789 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
790 uses_allocator_v<_KeyContainer, _Allocator> &&
791 is_invocable_v<const _Compare&,
792 const typename _KeyContainer::value_type&,
793 const typename _KeyContainer::value_type&>)
794flat_set(_KeyContainer, _Compare, _Allocator) -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
795
796template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
797 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
798 is_invocable_v<const _Compare&,
799 const typename _KeyContainer::value_type&,
800 const typename _KeyContainer::value_type&>)
801flat_set(sorted_unique_t, _KeyContainer, _Compare = _Compare())
802 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
803
804template <class _KeyContainer, class _Allocator>
805 requires(uses_allocator_v<_KeyContainer, _Allocator> && !__is_allocator<_KeyContainer>::value)
806flat_set(sorted_unique_t, _KeyContainer, _Allocator)
807 -> flat_set<typename _KeyContainer::value_type, less<typename _KeyContainer::value_type>, _KeyContainer>;
808
809template <class _KeyContainer, class _Compare, class _Allocator>
810 requires(!__is_allocator<_Compare>::value && !__is_allocator<_KeyContainer>::value &&
811 uses_allocator_v<_KeyContainer, _Allocator> &&
812 is_invocable_v<const _Compare&,
813 const typename _KeyContainer::value_type&,
814 const typename _KeyContainer::value_type&>)
815flat_set(sorted_unique_t, _KeyContainer, _Compare, _Allocator)
816 -> flat_set<typename _KeyContainer::value_type, _Compare, _KeyContainer>;
817
818template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
819 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
820flat_set(_InputIterator, _InputIterator, _Compare = _Compare())
821 -> flat_set<__iter_value_type<_InputIterator>, _Compare>;
822
823template <class _InputIterator, class _Compare = less<__iter_value_type<_InputIterator>>>
824 requires(__has_input_iterator_category<_InputIterator>::value && !__is_allocator<_Compare>::value)
825flat_set(sorted_unique_t, _InputIterator, _InputIterator, _Compare = _Compare())
826 -> flat_set<__iter_value_type<_InputIterator>, _Compare>;
827
828template <ranges::input_range _Range,
829 class _Compare = less<ranges::range_value_t<_Range>>,
830 class _Allocator = allocator<ranges::range_value_t<_Range>>,
831 class = __enable_if_t<!__is_allocator<_Compare>::value && __is_allocator<_Allocator>::value>>
832flat_set(from_range_t, _Range&&, _Compare = _Compare(), _Allocator = _Allocator()) -> flat_set<
833 ranges::range_value_t<_Range>,
834 _Compare,
835 vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
836
837template <ranges::input_range _Range, class _Allocator, class = __enable_if_t<__is_allocator<_Allocator>::value>>
838flat_set(from_range_t, _Range&&, _Allocator) -> flat_set<
839 ranges::range_value_t<_Range>,
840 less<ranges::range_value_t<_Range>>,
841 vector<ranges::range_value_t<_Range>, __allocator_traits_rebind_t<_Allocator, ranges::range_value_t<_Range>>>>;
842
843template <class _Key, class _Compare = less<_Key>>
844 requires(!__is_allocator<_Compare>::value)
845flat_set(initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>;
846
847template <class _Key, class _Compare = less<_Key>>
848 requires(!__is_allocator<_Compare>::value)
849flat_set(sorted_unique_t, initializer_list<_Key>, _Compare = _Compare()) -> flat_set<_Key, _Compare>;
850
851template <class _Key, class _Compare, class _KeyContainer, class _Allocator>
852struct uses_allocator<flat_set<_Key, _Compare, _KeyContainer>, _Allocator>
853 : bool_constant<uses_allocator_v<_KeyContainer, _Allocator>> {};
854
855template <class _Key, class _Compare, class _KeyContainer, class _Predicate>
856_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename flat_set<_Key, _Compare, _KeyContainer>::size_type
857erase_if(flat_set<_Key, _Compare, _KeyContainer>& __flat_set, _Predicate __pred) {
858 auto __guard = std::__make_exception_guard([&] { __flat_set.clear(); });
859 auto __it = std::remove_if(__flat_set.__keys_.begin(), __flat_set.__keys_.end(), [&](const auto& __e) -> bool {
860 return static_cast<bool>(__pred(__e));
861 });
862 auto __res = __flat_set.__keys_.end() - __it;
863 __flat_set.__keys_.erase(__it, __flat_set.__keys_.end());
864 __guard.__complete();
865 return __res;
866}
867
868_LIBCPP_END_NAMESPACE_STD
869
870#endif // _LIBCPP_STD_VER >= 23
871
872_LIBCPP_POP_MACROS
873
874#endif // _LIBCPP___FLAT_SET_FLAT_SET_H
lib/libcxx/include/__flat_set/ra_iterator.h created+157
...@@ -0,0 +1,157 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FLAT_SET_RA_ITERATOR_H
11#define _LIBCPP___FLAT_SET_RA_ITERATOR_H
12
13#include "__type_traits/is_same.h"
14#include <__compare/three_way_comparable.h>
15#include <__config>
16#include <__iterator/incrementable_traits.h>
17#include <__iterator/iterator_traits.h>
18#include <__type_traits/is_constructible.h>
19#include <__utility/move.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28#if _LIBCPP_STD_VER >= 23
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32/**
33 * __ra_iterator is a random access iterator that wraps an underlying iterator.
34 * It also stores the underlying container type in its type so that algorithms
35 * can optimize based on the underlying container type, and to avoid inadvertently
36 * mixing iterators coming from different containers..
37 */
38template <class _Container, class _Iterator>
39struct __ra_iterator {
40private:
41 _Iterator __iter_;
42
43 friend _Container;
44
45 // note: checking the concept random_access_iterator does not work for incomplete types
46 static_assert(_IsSame<typename iterator_traits<_Iterator>::iterator_category, random_access_iterator_tag>::value,
47 "Underlying iterator must be a random access iterator");
48
49public:
50 using iterator_concept = random_access_iterator_tag; // deliberately lower contiguous_iterator
51 using iterator_category = random_access_iterator_tag;
52 using value_type = iter_value_t<_Iterator>;
53 using difference_type = iter_difference_t<_Iterator>;
54
55 _LIBCPP_HIDE_FROM_ABI __ra_iterator()
56 requires is_default_constructible_v<_Iterator>
57 = default;
58
59 _LIBCPP_HIDE_FROM_ABI explicit constexpr __ra_iterator(_Iterator __iter) : __iter_(std::move(__iter)) {}
60
61 _LIBCPP_HIDE_FROM_ABI constexpr _Iterator __base() const noexcept(noexcept(_Iterator(__iter_))) { return __iter_; }
62
63 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__iter_; }
64 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator->() const
65 requires requires { __iter_.operator->(); }
66 {
67 return __iter_.operator->();
68 }
69
70 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator++() {
71 ++__iter_;
72 return *this;
73 }
74
75 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator operator++(int) {
76 __ra_iterator __tmp(*this);
77 ++*this;
78 return __tmp;
79 }
80
81 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator--() {
82 --__iter_;
83 return *this;
84 }
85
86 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator operator--(int) {
87 __ra_iterator __tmp(*this);
88 --*this;
89 return __tmp;
90 }
91
92 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator+=(difference_type __x) {
93 __iter_ += __x;
94 return *this;
95 }
96
97 _LIBCPP_HIDE_FROM_ABI constexpr __ra_iterator& operator-=(difference_type __x) {
98 __iter_ -= __x;
99 return *this;
100 }
101
102 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const { return *(*this + __n); }
103
104 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __ra_iterator& __x, const __ra_iterator& __y) {
105 return __x.__iter_ == __y.__iter_;
106 }
107
108 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __ra_iterator& __x, const __ra_iterator& __y) {
109 return __x.__iter_ < __y.__iter_;
110 }
111
112 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __ra_iterator& __x, const __ra_iterator& __y) {
113 return __y < __x;
114 }
115
116 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __ra_iterator& __x, const __ra_iterator& __y) {
117 return !(__y < __x);
118 }
119
120 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __ra_iterator& __x, const __ra_iterator& __y) {
121 return !(__x < __y);
122 }
123
124 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __ra_iterator& __x, const __ra_iterator& __y)
125 requires three_way_comparable<_Iterator>
126 {
127 return __x.__iter_ <=> __y.__iter_;
128 }
129
130 _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator+(const __ra_iterator& __i, difference_type __n) {
131 auto __tmp = __i;
132 __tmp += __n;
133 return __tmp;
134 }
135
136 _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator+(difference_type __n, const __ra_iterator& __i) {
137 return __i + __n;
138 }
139
140 _LIBCPP_HIDE_FROM_ABI friend constexpr __ra_iterator operator-(const __ra_iterator& __i, difference_type __n) {
141 auto __tmp = __i;
142 __tmp -= __n;
143 return __tmp;
144 }
145
146 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __ra_iterator& __x, const __ra_iterator& __y) {
147 return __x.__iter_ - __y.__iter_;
148 }
149};
150
151_LIBCPP_END_NAMESPACE_STD
152
153#endif // _LIBCPP_STD_VER >= 23
154
155_LIBCPP_POP_MACROS
156
157#endif // _LIBCPP___FLAT_SET_RA_ITERATOR_H
lib/libcxx/include/__flat_set/utils.h created+82
...@@ -0,0 +1,82 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___FLAT_SET_UTILS_H
11#define _LIBCPP___FLAT_SET_UTILS_H
12
13#include <__config>
14#include <__iterator/iterator_traits.h>
15#include <__ranges/access.h>
16#include <__ranges/concepts.h>
17#include <__type_traits/container_traits.h>
18#include <__type_traits/decay.h>
19#include <__utility/exception_guard.h>
20#include <__utility/forward.h>
21#include <__utility/move.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>
29
30#if _LIBCPP_STD_VER >= 23
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34// These utilities are defined in a class instead of a namespace so that this class can be befriended more easily.
35struct __flat_set_utils {
36 // Emplace a key into a flat_{multi}set, at the exact position that
37 // __it point to, assuming that the key is not already present in the set.
38 // When an exception is thrown during the emplacement, the function will clear the set if the container does not
39 // have strong exception safety guarantee on emplacement.
40 template <class _Set, class _Iter, class _KeyArg>
41 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto
42 __emplace_exact_pos(_Set& __set, _Iter&& __iter, _KeyArg&& __key) {
43 using _KeyContainer = typename decay_t<_Set>::container_type;
44 auto __on_failure = std::__make_exception_guard([&]() noexcept {
45 if constexpr (!__container_traits<_KeyContainer>::__emplacement_has_strong_exception_safety_guarantee) {
46 __set.clear() /* noexcept */;
47 }
48 });
49 auto __key_it = __set.__keys_.emplace(__iter.__base(), std::forward<_KeyArg>(__key));
50 __on_failure.__complete();
51 return typename decay_t<_Set>::iterator(std::move(__key_it));
52 }
53
54 template <class _Set, class _InputIterator>
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
56 __append(_Set& __set, _InputIterator __first, _InputIterator __last) {
57 __set.__keys_.insert(__set.__keys_.end(), std::move(__first), std::move(__last));
58 }
59
60 template <class _Set, class _Range>
61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void __append(_Set& __set, _Range&& __rng) {
62 if constexpr (requires { __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng)); }) {
63 // C++23 Sequence Container should have insert_range member function
64 // Note that not all Sequence Containers provide append_range.
65 __set.__keys_.insert_range(__set.__keys_.end(), std::forward<_Range>(__rng));
66 } else if constexpr (ranges::common_range<_Range> &&
67 __has_input_iterator_category<ranges::iterator_t<_Range>>::value) {
68 __set.__keys_.insert(__set.__keys_.end(), ranges::begin(__rng), ranges::end(__rng));
69 } else {
70 for (auto&& __x : __rng) {
71 __set.__keys_.insert(__set.__keys_.end(), std::forward<decltype(__x)>(__x));
72 }
73 }
74 }
75};
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_STD_VER >= 23
79
80_LIBCPP_POP_MACROS
81
82#endif // #define _LIBCPP___FLAT_SET_UTILS_H
lib/libcxx/include/__format/buffer.h+14-15
...@@ -15,7 +15,6 @@...@@ -15,7 +15,6 @@
15#include <__algorithm/max.h>15#include <__algorithm/max.h>
16#include <__algorithm/min.h>16#include <__algorithm/min.h>
17#include <__algorithm/ranges_copy.h>17#include <__algorithm/ranges_copy.h>
18#include <__algorithm/ranges_copy_n.h>
19#include <__algorithm/transform.h>18#include <__algorithm/transform.h>
20#include <__algorithm/unwrap_iter.h>19#include <__algorithm/unwrap_iter.h>
21#include <__concepts/same_as.h>20#include <__concepts/same_as.h>
...@@ -33,7 +32,7 @@...@@ -33,7 +32,7 @@
33#include <__memory/allocator.h>32#include <__memory/allocator.h>
34#include <__memory/allocator_traits.h>33#include <__memory/allocator_traits.h>
35#include <__memory/construct_at.h>34#include <__memory/construct_at.h>
36#include <__memory/ranges_construct_at.h>35#include <__memory/destroy.h>
37#include <__memory/uninitialized_algorithms.h>36#include <__memory/uninitialized_algorithms.h>
38#include <__type_traits/add_pointer.h>37#include <__type_traits/add_pointer.h>
39#include <__type_traits/conditional.h>38#include <__type_traits/conditional.h>
...@@ -180,7 +179,7 @@ private:...@@ -180,7 +179,7 @@ private:
180/// The latter option allows formatted_size to use the output buffer without179/// The latter option allows formatted_size to use the output buffer without
181/// ever writing anything to the buffer.180/// ever writing anything to the buffer.
182template <__fmt_char_type _CharT>181template <__fmt_char_type _CharT>
183class _LIBCPP_TEMPLATE_VIS __output_buffer {182class __output_buffer {
184public:183public:
185 using value_type _LIBCPP_NODEBUG = _CharT;184 using value_type _LIBCPP_NODEBUG = _CharT;
186 using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t);185 using __prepare_write_type _LIBCPP_NODEBUG = void (*)(__output_buffer<_CharT>&, size_t);
...@@ -340,18 +339,18 @@ concept __insertable =...@@ -340,18 +339,18 @@ concept __insertable =
340339
341/// Extract the container type of a \ref back_insert_iterator.340/// Extract the container type of a \ref back_insert_iterator.
342template <class _It>341template <class _It>
343struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {342struct __back_insert_iterator_container {
344 using type _LIBCPP_NODEBUG = void;343 using type _LIBCPP_NODEBUG = void;
345};344};
346345
347template <__insertable _Container>346template <__insertable _Container>
348struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {347struct __back_insert_iterator_container<back_insert_iterator<_Container>> {
349 using type _LIBCPP_NODEBUG = _Container;348 using type _LIBCPP_NODEBUG = _Container;
350};349};
351350
352// A dynamically growing buffer.351// A dynamically growing buffer.
353template <__fmt_char_type _CharT>352template <__fmt_char_type _CharT>
354class _LIBCPP_TEMPLATE_VIS __allocating_buffer : public __output_buffer<_CharT> {353class __allocating_buffer : public __output_buffer<_CharT> {
355public:354public:
356 __allocating_buffer(const __allocating_buffer&) = delete;355 __allocating_buffer(const __allocating_buffer&) = delete;
357 __allocating_buffer& operator=(const __allocating_buffer&) = delete;356 __allocating_buffer& operator=(const __allocating_buffer&) = delete;
...@@ -408,7 +407,7 @@ private:...@@ -408,7 +407,7 @@ private:
408407
409// A buffer that directly writes to the underlying buffer.408// A buffer that directly writes to the underlying buffer.
410template <class _OutIt, __fmt_char_type _CharT>409template <class _OutIt, __fmt_char_type _CharT>
411class _LIBCPP_TEMPLATE_VIS __direct_iterator_buffer : public __output_buffer<_CharT> {410class __direct_iterator_buffer : public __output_buffer<_CharT> {
412public:411public:
413 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it)412 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __direct_iterator_buffer(_OutIt __out_it)
414 : __direct_iterator_buffer{__out_it, nullptr} {}413 : __direct_iterator_buffer{__out_it, nullptr} {}
...@@ -437,7 +436,7 @@ private:...@@ -437,7 +436,7 @@ private:
437436
438// A buffer that writes its output to the end of a container.437// A buffer that writes its output to the end of a container.
439template <class _OutIt, __fmt_char_type _CharT>438template <class _OutIt, __fmt_char_type _CharT>
440class _LIBCPP_TEMPLATE_VIS __container_inserter_buffer : public __output_buffer<_CharT> {439class __container_inserter_buffer : public __output_buffer<_CharT> {
441public:440public:
442 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it)441 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __container_inserter_buffer(_OutIt __out_it)
443 : __container_inserter_buffer{__out_it, nullptr} {}442 : __container_inserter_buffer{__out_it, nullptr} {}
...@@ -478,7 +477,7 @@ private:...@@ -478,7 +477,7 @@ private:
478// Unlike the __container_inserter_buffer this class' performance does benefit477// Unlike the __container_inserter_buffer this class' performance does benefit
479// from allocating and then inserting.478// from allocating and then inserting.
480template <class _OutIt, __fmt_char_type _CharT>479template <class _OutIt, __fmt_char_type _CharT>
481class _LIBCPP_TEMPLATE_VIS __iterator_buffer : public __allocating_buffer<_CharT> {480class __iterator_buffer : public __allocating_buffer<_CharT> {
482public:481public:
483 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it)482 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit __iterator_buffer(_OutIt __out_it)
484 : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {}483 : __allocating_buffer<_CharT>{}, __out_it_{std::move(__out_it)} {}
...@@ -496,7 +495,7 @@ private:...@@ -496,7 +495,7 @@ private:
496495
497// Selects the type of the buffer used for the output iterator.496// Selects the type of the buffer used for the output iterator.
498template <class _OutIt, __fmt_char_type _CharT>497template <class _OutIt, __fmt_char_type _CharT>
499class _LIBCPP_TEMPLATE_VIS __buffer_selector {498class __buffer_selector {
500 using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type;499 using _Container _LIBCPP_NODEBUG = __back_insert_iterator_container<_OutIt>::type;
501500
502public:501public:
...@@ -510,7 +509,7 @@ public:...@@ -510,7 +509,7 @@ public:
510509
511// A buffer that counts and limits the number of insertions.510// A buffer that counts and limits the number of insertions.
512template <class _OutIt, __fmt_char_type _CharT>511template <class _OutIt, __fmt_char_type _CharT>
513class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type {512class __format_to_n_buffer : private __buffer_selector<_OutIt, _CharT>::type {
514public:513public:
515 using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type;514 using _Base _LIBCPP_NODEBUG = __buffer_selector<_OutIt, _CharT>::type;
516515
...@@ -534,7 +533,7 @@ private:...@@ -534,7 +533,7 @@ private:
534// Since formatted_size only needs to know the size, the output itself is533// Since formatted_size only needs to know the size, the output itself is
535// discarded.534// discarded.
536template <__fmt_char_type _CharT>535template <__fmt_char_type _CharT>
537class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer : private __output_buffer<_CharT> {536class __formatted_size_buffer : private __output_buffer<_CharT> {
538public:537public:
539 using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>;538 using _Base _LIBCPP_NODEBUG = __output_buffer<_CharT>;
540539
...@@ -577,7 +576,7 @@ private:...@@ -577,7 +576,7 @@ private:
577// This class uses its own buffer management, since using vector576// This class uses its own buffer management, since using vector
578// would lead to a circular include with formatter for vector<bool>.577// would lead to a circular include with formatter for vector<bool>.
579template <__fmt_char_type _CharT>578template <__fmt_char_type _CharT>
580class _LIBCPP_TEMPLATE_VIS __retarget_buffer {579class __retarget_buffer {
581 using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>;580 using _Alloc _LIBCPP_NODEBUG = allocator<_CharT>;
582581
583public:582public:
...@@ -621,7 +620,7 @@ public:...@@ -621,7 +620,7 @@ public:
621 }620 }
622621
623 _LIBCPP_HIDE_FROM_ABI ~__retarget_buffer() {622 _LIBCPP_HIDE_FROM_ABI ~__retarget_buffer() {
624 ranges::destroy_n(__ptr_, __size_);623 std::destroy_n(__ptr_, __size_);
625 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_);624 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_);
626 }625 }
627626
...@@ -686,7 +685,7 @@ private:...@@ -686,7 +685,7 @@ private:
686 // guard is optimized away so there is no runtime overhead.685 // guard is optimized away so there is no runtime overhead.
687 std::uninitialized_move_n(__ptr_, __size_, __result.ptr);686 std::uninitialized_move_n(__ptr_, __size_, __result.ptr);
688 __guard.__complete();687 __guard.__complete();
689 ranges::destroy_n(__ptr_, __size_);688 std::destroy_n(__ptr_, __size_);
690 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_);689 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __capacity_);
691690
692 __ptr_ = __result.ptr;691 __ptr_ = __result.ptr;
lib/libcxx/include/__format/container_adaptor.h+4-4
...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
35// adaptor headers. To use the format functions users already include <format>.35// adaptor headers. To use the format functions users already include <format>.
3636
37template <class _Adaptor, class _CharT>37template <class _Adaptor, class _CharT>
38struct _LIBCPP_TEMPLATE_VIS __formatter_container_adaptor {38struct __formatter_container_adaptor {
39private:39private:
40 using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>;40 using __maybe_const_container _LIBCPP_NODEBUG = __fmt_maybe_const<typename _Adaptor::container_type, _CharT>;
41 using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>;41 using __maybe_const_adaptor _LIBCPP_NODEBUG = __maybe_const<is_const_v<__maybe_const_container>, _Adaptor>;
...@@ -55,15 +55,15 @@ public:...@@ -55,15 +55,15 @@ public:
55};55};
5656
57template <class _CharT, class _Tp, formattable<_CharT> _Container>57template <class _CharT, class _Tp, formattable<_CharT> _Container>
58struct _LIBCPP_TEMPLATE_VIS formatter<queue<_Tp, _Container>, _CharT>58struct formatter<queue<_Tp, _Container>, _CharT>
59 : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {};59 : public __formatter_container_adaptor<queue<_Tp, _Container>, _CharT> {};
6060
61template <class _CharT, class _Tp, class _Container, class _Compare>61template <class _CharT, class _Tp, class _Container, class _Compare>
62struct _LIBCPP_TEMPLATE_VIS formatter<priority_queue<_Tp, _Container, _Compare>, _CharT>62struct formatter<priority_queue<_Tp, _Container, _Compare>, _CharT>
63 : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {};63 : public __formatter_container_adaptor<priority_queue<_Tp, _Container, _Compare>, _CharT> {};
6464
65template <class _CharT, class _Tp, formattable<_CharT> _Container>65template <class _CharT, class _Tp, formattable<_CharT> _Container>
66struct _LIBCPP_TEMPLATE_VIS formatter<stack<_Tp, _Container>, _CharT>66struct formatter<stack<_Tp, _Container>, _CharT>
67 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};67 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};
6868
69#endif // _LIBCPP_STD_VER >= 2369#endif // _LIBCPP_STD_VER >= 23
lib/libcxx/include/__format/escaped_output_table.h+53-29
...@@ -109,7 +109,7 @@ namespace __escaped_output_table {...@@ -109,7 +109,7 @@ namespace __escaped_output_table {
109/// - bits [14, 31] The lower bound code point of the range. The upper bound of109/// - bits [14, 31] The lower bound code point of the range. The upper bound of
110/// the range is lower bound + size. Note the code expects code units the fit110/// the range is lower bound + size. Note the code expects code units the fit
111/// into 18 bits, instead of the 21 bits needed for the full Unicode range.111/// into 18 bits, instead of the 21 bits needed for the full Unicode range.
112_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {112_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[735] = {
113 0x00000020 /* 00000000 - 00000020 [ 33] */,113 0x00000020 /* 00000000 - 00000020 [ 33] */,
114 0x001fc021 /* 0000007f - 000000a0 [ 34] */,114 0x001fc021 /* 0000007f - 000000a0 [ 34] */,
115 0x002b4000 /* 000000ad - 000000ad [ 1] */,115 0x002b4000 /* 000000ad - 000000ad [ 1] */,
...@@ -136,7 +136,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -136,7 +136,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
136 0x02170001 /* 0000085c - 0000085d [ 2] */,136 0x02170001 /* 0000085c - 0000085d [ 2] */,
137 0x0217c000 /* 0000085f - 0000085f [ 1] */,137 0x0217c000 /* 0000085f - 0000085f [ 1] */,
138 0x021ac004 /* 0000086b - 0000086f [ 5] */,138 0x021ac004 /* 0000086b - 0000086f [ 5] */,
139 0x0223c008 /* 0000088f - 00000897 [ 9] */,139 0x0223c007 /* 0000088f - 00000896 [ 8] */,
140 0x02388000 /* 000008e2 - 000008e2 [ 1] */,140 0x02388000 /* 000008e2 - 000008e2 [ 1] */,
141 0x02610000 /* 00000984 - 00000984 [ 1] */,141 0x02610000 /* 00000984 - 00000984 [ 1] */,
142 0x02634001 /* 0000098d - 0000098e [ 2] */,142 0x02634001 /* 0000098d - 0000098e [ 2] */,
...@@ -331,12 +331,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -331,12 +331,11 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
331 0x06a68005 /* 00001a9a - 00001a9f [ 6] */,331 0x06a68005 /* 00001a9a - 00001a9f [ 6] */,
332 0x06ab8001 /* 00001aae - 00001aaf [ 2] */,332 0x06ab8001 /* 00001aae - 00001aaf [ 2] */,
333 0x06b3c030 /* 00001acf - 00001aff [ 49] */,333 0x06b3c030 /* 00001acf - 00001aff [ 49] */,
334 0x06d34002 /* 00001b4d - 00001b4f [ 3] */,334 0x06d34000 /* 00001b4d - 00001b4d [ 1] */,
335 0x06dfc000 /* 00001b7f - 00001b7f [ 1] */,
336 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */,335 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */,
337 0x070e0002 /* 00001c38 - 00001c3a [ 3] */,336 0x070e0002 /* 00001c38 - 00001c3a [ 3] */,
338 0x07128002 /* 00001c4a - 00001c4c [ 3] */,337 0x07128002 /* 00001c4a - 00001c4c [ 3] */,
339 0x07224006 /* 00001c89 - 00001c8f [ 7] */,338 0x0722c004 /* 00001c8b - 00001c8f [ 5] */,
340 0x072ec001 /* 00001cbb - 00001cbc [ 2] */,339 0x072ec001 /* 00001cbb - 00001cbc [ 2] */,
341 0x07320007 /* 00001cc8 - 00001ccf [ 8] */,340 0x07320007 /* 00001cc8 - 00001ccf [ 8] */,
342 0x073ec004 /* 00001cfb - 00001cff [ 5] */,341 0x073ec004 /* 00001cfb - 00001cff [ 5] */,
...@@ -364,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -364,7 +363,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
364 0x0830400e /* 000020c1 - 000020cf [ 15] */,363 0x0830400e /* 000020c1 - 000020cf [ 15] */,
365 0x083c400e /* 000020f1 - 000020ff [ 15] */,364 0x083c400e /* 000020f1 - 000020ff [ 15] */,
366 0x08630003 /* 0000218c - 0000218f [ 4] */,365 0x08630003 /* 0000218c - 0000218f [ 4] */,
367 0x0909c018 /* 00002427 - 0000243f [ 25] */,366 0x090a8015 /* 0000242a - 0000243f [ 22] */,
368 0x0912c014 /* 0000244b - 0000245f [ 21] */,367 0x0912c014 /* 0000244b - 0000245f [ 21] */,
369 0x0add0001 /* 00002b74 - 00002b75 [ 2] */,368 0x0add0001 /* 00002b74 - 00002b75 [ 2] */,
370 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */,369 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */,
...@@ -393,16 +392,16 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -393,16 +392,16 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
393 0x0c400004 /* 00003100 - 00003104 [ 5] */,392 0x0c400004 /* 00003100 - 00003104 [ 5] */,
394 0x0c4c0000 /* 00003130 - 00003130 [ 1] */,393 0x0c4c0000 /* 00003130 - 00003130 [ 1] */,
395 0x0c63c000 /* 0000318f - 0000318f [ 1] */,394 0x0c63c000 /* 0000318f - 0000318f [ 1] */,
396 0x0c79000a /* 000031e4 - 000031ee [ 11] */,395 0x0c798008 /* 000031e6 - 000031ee [ 9] */,
397 0x0c87c000 /* 0000321f - 0000321f [ 1] */,396 0x0c87c000 /* 0000321f - 0000321f [ 1] */,
398 0x29234002 /* 0000a48d - 0000a48f [ 3] */,397 0x29234002 /* 0000a48d - 0000a48f [ 3] */,
399 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */,398 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */,
400 0x298b0013 /* 0000a62c - 0000a63f [ 20] */,399 0x298b0013 /* 0000a62c - 0000a63f [ 20] */,
401 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */,400 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */,
402 0x29f2c004 /* 0000a7cb - 0000a7cf [ 5] */,401 0x29f38001 /* 0000a7ce - 0000a7cf [ 2] */,
403 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */,402 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */,
404 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */,403 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */,
405 0x29f68017 /* 0000a7da - 0000a7f1 [ 24] */,404 0x29f74014 /* 0000a7dd - 0000a7f1 [ 21] */,
406 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */,405 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */,
407 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */,406 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */,
408 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */,407 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */,
...@@ -491,7 +490,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -491,7 +490,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
491 0x41688000 /* 000105a2 - 000105a2 [ 1] */,490 0x41688000 /* 000105a2 - 000105a2 [ 1] */,
492 0x416c8000 /* 000105b2 - 000105b2 [ 1] */,491 0x416c8000 /* 000105b2 - 000105b2 [ 1] */,
493 0x416e8000 /* 000105ba - 000105ba [ 1] */,492 0x416e8000 /* 000105ba - 000105ba [ 1] */,
494 0x416f4042 /* 000105bd - 000105ff [ 67] */,493 0x416f4002 /* 000105bd - 000105bf [ 3] */,
494 0x417d000b /* 000105f4 - 000105ff [ 12] */,
495 0x41cdc008 /* 00010737 - 0001073f [ 9] */,495 0x41cdc008 /* 00010737 - 0001073f [ 9] */,
496 0x41d58009 /* 00010756 - 0001075f [ 10] */,496 0x41d58009 /* 00010756 - 0001075f [ 10] */,
497 0x41da0017 /* 00010768 - 0001077f [ 24] */,497 0x41da0017 /* 00010768 - 0001077f [ 24] */,
...@@ -534,11 +534,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -534,11 +534,15 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
534 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */,534 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */,
535 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */,535 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */,
536 0x434a0007 /* 00010d28 - 00010d2f [ 8] */,536 0x434a0007 /* 00010d28 - 00010d2f [ 8] */,
537 0x434e8125 /* 00010d3a - 00010e5f [ 294] */,537 0x434e8005 /* 00010d3a - 00010d3f [ 6] */,
538 0x43598002 /* 00010d66 - 00010d68 [ 3] */,
539 0x43618007 /* 00010d86 - 00010d8d [ 8] */,
540 0x436400cf /* 00010d90 - 00010e5f [ 208] */,
538 0x439fc000 /* 00010e7f - 00010e7f [ 1] */,541 0x439fc000 /* 00010e7f - 00010e7f [ 1] */,
539 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */,542 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */,
540 0x43ab8001 /* 00010eae - 00010eaf [ 2] */,543 0x43ab8001 /* 00010eae - 00010eaf [ 2] */,
541 0x43ac804a /* 00010eb2 - 00010efc [ 75] */,544 0x43ac800f /* 00010eb2 - 00010ec1 [ 16] */,
545 0x43b14036 /* 00010ec5 - 00010efb [ 55] */,
542 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */,546 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */,
543 0x43d68015 /* 00010f5a - 00010f6f [ 22] */,547 0x43d68015 /* 00010f5a - 00010f6f [ 22] */,
544 0x43e28025 /* 00010f8a - 00010faf [ 38] */,548 0x43e28025 /* 00010f8a - 00010faf [ 38] */,
...@@ -578,7 +582,18 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -578,7 +582,18 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
578 0x44d60004 /* 00011358 - 0001135c [ 5] */,582 0x44d60004 /* 00011358 - 0001135c [ 5] */,
579 0x44d90001 /* 00011364 - 00011365 [ 2] */,583 0x44d90001 /* 00011364 - 00011365 [ 2] */,
580 0x44db4002 /* 0001136d - 0001136f [ 3] */,584 0x44db4002 /* 0001136d - 0001136f [ 3] */,
581 0x44dd408a /* 00011375 - 000113ff [ 139] */,585 0x44dd400a /* 00011375 - 0001137f [ 11] */,
586 0x44e28000 /* 0001138a - 0001138a [ 1] */,
587 0x44e30001 /* 0001138c - 0001138d [ 2] */,
588 0x44e3c000 /* 0001138f - 0001138f [ 1] */,
589 0x44ed8000 /* 000113b6 - 000113b6 [ 1] */,
590 0x44f04000 /* 000113c1 - 000113c1 [ 1] */,
591 0x44f0c001 /* 000113c3 - 000113c4 [ 2] */,
592 0x44f18000 /* 000113c6 - 000113c6 [ 1] */,
593 0x44f2c000 /* 000113cb - 000113cb [ 1] */,
594 0x44f58000 /* 000113d6 - 000113d6 [ 1] */,
595 0x44f64007 /* 000113d9 - 000113e0 [ 8] */,
596 0x44f8c01c /* 000113e3 - 000113ff [ 29] */,
582 0x45170000 /* 0001145c - 0001145c [ 1] */,597 0x45170000 /* 0001145c - 0001145c [ 1] */,
583 0x4518801d /* 00011462 - 0001147f [ 30] */,598 0x4518801d /* 00011462 - 0001147f [ 30] */,
584 0x45320007 /* 000114c8 - 000114cf [ 8] */,599 0x45320007 /* 000114c8 - 000114cf [ 8] */,
...@@ -589,7 +604,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -589,7 +604,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
589 0x45968005 /* 0001165a - 0001165f [ 6] */,604 0x45968005 /* 0001165a - 0001165f [ 6] */,
590 0x459b4012 /* 0001166d - 0001167f [ 19] */,605 0x459b4012 /* 0001166d - 0001167f [ 19] */,
591 0x45ae8005 /* 000116ba - 000116bf [ 6] */,606 0x45ae8005 /* 000116ba - 000116bf [ 6] */,
592 0x45b28035 /* 000116ca - 000116ff [ 54] */,607 0x45b28005 /* 000116ca - 000116cf [ 6] */,
608 0x45b9001b /* 000116e4 - 000116ff [ 28] */,
593 0x45c6c001 /* 0001171b - 0001171c [ 2] */,609 0x45c6c001 /* 0001171b - 0001171c [ 2] */,
594 0x45cb0003 /* 0001172c - 0001172f [ 4] */,610 0x45cb0003 /* 0001172c - 0001172f [ 4] */,
595 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */,611 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */,
...@@ -609,7 +625,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -609,7 +625,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
609 0x46920007 /* 00011a48 - 00011a4f [ 8] */,625 0x46920007 /* 00011a48 - 00011a4f [ 8] */,
610 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */,626 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */,
611 0x46be4006 /* 00011af9 - 00011aff [ 7] */,627 0x46be4006 /* 00011af9 - 00011aff [ 7] */,
612 0x46c280f5 /* 00011b0a - 00011bff [ 246] */,628 0x46c280b5 /* 00011b0a - 00011bbf [ 182] */,
629 0x46f8800d /* 00011be2 - 00011bef [ 14] */,
630 0x46fe8005 /* 00011bfa - 00011bff [ 6] */,
613 0x47024000 /* 00011c09 - 00011c09 [ 1] */,631 0x47024000 /* 00011c09 - 00011c09 [ 1] */,
614 0x470dc000 /* 00011c37 - 00011c37 [ 1] */,632 0x470dc000 /* 00011c37 - 00011c37 [ 1] */,
615 0x47118009 /* 00011c46 - 00011c4f [ 10] */,633 0x47118009 /* 00011c46 - 00011c4f [ 10] */,
...@@ -633,7 +651,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -633,7 +651,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
633 0x47be4006 /* 00011ef9 - 00011eff [ 7] */,651 0x47be4006 /* 00011ef9 - 00011eff [ 7] */,
634 0x47c44000 /* 00011f11 - 00011f11 [ 1] */,652 0x47c44000 /* 00011f11 - 00011f11 [ 1] */,
635 0x47cec002 /* 00011f3b - 00011f3d [ 3] */,653 0x47cec002 /* 00011f3b - 00011f3d [ 3] */,
636 0x47d68055 /* 00011f5a - 00011faf [ 86] */,654 0x47d6c054 /* 00011f5b - 00011faf [ 85] */,
637 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */,655 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */,
638 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */,656 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */,
639 0x48e68065 /* 0001239a - 000123ff [ 102] */,657 0x48e68065 /* 0001239a - 000123ff [ 102] */,
...@@ -642,8 +660,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -642,8 +660,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
642 0x49510a4b /* 00012544 - 00012f8f [ 2636] */,660 0x49510a4b /* 00012544 - 00012f8f [ 2636] */,
643 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */,661 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */,
644 0x4d0c000f /* 00013430 - 0001343f [ 16] */,662 0x4d0c000f /* 00013430 - 0001343f [ 16] */,
645 0x4d158fa9 /* 00013456 - 000143ff [ 4010] */,663 0x4d158009 /* 00013456 - 0001345f [ 10] */,
646 0x5191e1b8 /* 00014647 - 000167ff [ 8633] */,664 0x50fec004 /* 000143fb - 000143ff [ 5] */,
665 0x5191dab8 /* 00014647 - 000160ff [ 6841] */,
666 0x584e86c5 /* 0001613a - 000167ff [ 1734] */,
647 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */,667 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */,
648 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */,668 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */,
649 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */,669 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */,
...@@ -655,7 +675,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -655,7 +675,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
655 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */,675 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */,
656 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */,676 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */,
657 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */,677 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */,
658 0x5ae402af /* 00016b90 - 00016e3f [ 688] */,678 0x5ae401af /* 00016b90 - 00016d3f [ 432] */,
679 0x5b5e80c5 /* 00016d7a - 00016e3f [ 198] */,
659 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */,680 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */,
660 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */,681 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */,
661 0x5be20006 /* 00016f88 - 00016f8e [ 7] */,682 0x5be20006 /* 00016f88 - 00016f8e [ 7] */,
...@@ -663,7 +684,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -663,7 +684,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
663 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */,684 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */,
664 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */,685 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */,
665 0x61fe0007 /* 000187f8 - 000187ff [ 8] */,686 0x61fe0007 /* 000187f8 - 000187ff [ 8] */,
666 0x63358029 /* 00018cd6 - 00018cff [ 42] */,687 0x63358028 /* 00018cd6 - 00018cfe [ 41] */,
667 0x634262e6 /* 00018d09 - 0001afef [ 8935] */,688 0x634262e6 /* 00018d09 - 0001afef [ 8935] */,
668 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */,689 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */,
669 0x6bff0000 /* 0001affc - 0001affc [ 1] */,690 0x6bff0000 /* 0001affc - 0001affc [ 1] */,
...@@ -678,7 +699,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -678,7 +699,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
678 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */,699 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */,
679 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */,700 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */,
680 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */,701 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */,
681 0x6f28125f /* 0001bca0 - 0001ceff [ 4704] */,702 0x6f280f5f /* 0001bca0 - 0001cbff [ 3936] */,
703 0x733e8005 /* 0001ccfa - 0001ccff [ 6] */,
704 0x73ad004b /* 0001ceb4 - 0001ceff [ 76] */,
682 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */,705 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */,
683 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */,706 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */,
684 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */,707 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */,
...@@ -730,7 +753,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -730,7 +753,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
730 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */,753 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */,
731 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */,754 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */,
732 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */,755 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */,
733 0x793e82e5 /* 0001e4fa - 0001e7df [ 742] */,756 0x793e80d5 /* 0001e4fa - 0001e5cf [ 214] */,
757 0x797ec003 /* 0001e5fb - 0001e5fe [ 4] */,
758 0x798001df /* 0001e600 - 0001e7df [ 480] */,
734 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */,759 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */,
735 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */,760 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */,
736 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */,761 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */,
...@@ -800,18 +825,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {...@@ -800,18 +825,17 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
800 0x7e168005 /* 0001f85a - 0001f85f [ 6] */,825 0x7e168005 /* 0001f85a - 0001f85f [ 6] */,
801 0x7e220007 /* 0001f888 - 0001f88f [ 8] */,826 0x7e220007 /* 0001f888 - 0001f88f [ 8] */,
802 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */,827 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */,
803 0x7e2c804d /* 0001f8b2 - 0001f8ff [ 78] */,828 0x7e2f0003 /* 0001f8bc - 0001f8bf [ 4] */,
829 0x7e30803d /* 0001f8c2 - 0001f8ff [ 62] */,
804 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */,830 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */,
805 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */,831 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */,
806 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */,832 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */,
807 0x7ea24006 /* 0001fa89 - 0001fa8f [ 7] */,833 0x7ea28004 /* 0001fa8a - 0001fa8e [ 5] */,
808 0x7eaf8000 /* 0001fabe - 0001fabe [ 1] */,834 0x7eb1c006 /* 0001fac7 - 0001facd [ 7] */,
809 0x7eb18007 /* 0001fac6 - 0001facd [ 8] */,835 0x7eb74001 /* 0001fadd - 0001fade [ 2] */,
810 0x7eb70003 /* 0001fadc - 0001fadf [ 4] */,836 0x7eba8005 /* 0001faea - 0001faef [ 6] */,
811 0x7eba4006 /* 0001fae9 - 0001faef [ 7] */,
812 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */,837 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */,
813 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */,838 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */,
814 0x7ef2c024 /* 0001fbcb - 0001fbef [ 37] */,
815 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */,839 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */,
816 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */,840 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */,
817 0xadce8005 /* 0002b73a - 0002b73f [ 6] */,841 0xadce8005 /* 0002b73a - 0002b73f [ 6] */,
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+52-47
...@@ -125,7 +125,7 @@ enum class __property : uint8_t {...@@ -125,7 +125,7 @@ enum class __property : uint8_t {
125/// following benchmark.125/// following benchmark.
126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
127// clang-format off127// clang-format off
128_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {128_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1501] = {
129 0x00000091,129 0x00000091,
130 0x00005005,130 0x00005005,
131 0x00005811,131 0x00005811,
...@@ -164,7 +164,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -164,7 +164,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
164 0x00414842,164 0x00414842,
165 0x0042c822,165 0x0042c822,
166 0x00448018,166 0x00448018,
167 0x0044c072,167 0x0044b882,
168 0x00465172,168 0x00465172,
169 0x00471008,169 0x00471008,
170 0x004719f2,170 0x004719f2,
...@@ -246,14 +246,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -246,14 +246,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
246 0x0064101a,246 0x0064101a,
247 0x0065e002,247 0x0065e002,
248 0x0065f00a,248 0x0065f00a,
249 0x0065f802,249 0x0065f812,
250 0x0066001a,250 0x0066080a,
251 0x00661002,251 0x00661002,
252 0x0066181a,252 0x0066181a,
253 0x00663002,253 0x00663022,
254 0x0066381a,254 0x00665032,
255 0x0066501a,
256 0x00666012,
257 0x0066a812,255 0x0066a812,
258 0x00671012,256 0x00671012,
259 0x0067980a,257 0x0067980a,
...@@ -318,10 +316,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -318,10 +316,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
318 0x008b047c,316 0x008b047c,
319 0x008d457b,317 0x008d457b,
320 0x009ae822,318 0x009ae822,
321 0x00b89022,319 0x00b89032,
322 0x00b8a80a,320 0x00b99022,
323 0x00b99012,
324 0x00b9a00a,
325 0x00ba9012,321 0x00ba9012,
326 0x00bb9012,322 0x00bb9012,
327 0x00bda012,323 0x00bda012,
...@@ -361,29 +357,23 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -361,29 +357,23 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
361 0x00d581e2,357 0x00d581e2,
362 0x00d80032,358 0x00d80032,
363 0x00d8200a,359 0x00d8200a,
364 0x00d9a062,360 0x00d9a092,
365 0x00d9d80a,361 0x00d9f03a,
366 0x00d9e002,362 0x00da1022,
367 0x00d9e84a,
368 0x00da1002,
369 0x00da181a,
370 0x00db5882,363 0x00db5882,
371 0x00dc0012,364 0x00dc0012,
372 0x00dc100a,365 0x00dc100a,
373 0x00dd080a,366 0x00dd080a,
374 0x00dd1032,367 0x00dd1032,
375 0x00dd301a,368 0x00dd301a,
376 0x00dd4012,369 0x00dd4052,
377 0x00dd500a,
378 0x00dd5822,
379 0x00df3002,370 0x00df3002,
380 0x00df380a,371 0x00df380a,
381 0x00df4012,372 0x00df4012,
382 0x00df502a,373 0x00df502a,
383 0x00df6802,374 0x00df6802,
384 0x00df700a,375 0x00df700a,
385 0x00df7822,376 0x00df7842,
386 0x00df901a,
387 0x00e1207a,377 0x00e1207a,
388 0x00e16072,378 0x00e16072,
389 0x00e1a01a,379 0x00e1a01a,
...@@ -475,7 +465,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -475,7 +465,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
475 0x0547f802,465 0x0547f802,
476 0x05493072,466 0x05493072,
477 0x054a38a2,467 0x054a38a2,
478 0x054a901a,468 0x054a900a,
469 0x054a9802,
479 0x054b01c4,470 0x054b01c4,
480 0x054c0022,471 0x054c0022,
481 0x054c180a,472 0x054c180a,
...@@ -484,7 +475,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -484,7 +475,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
484 0x054db032,475 0x054db032,
485 0x054dd01a,476 0x054dd01a,
486 0x054de012,477 0x054de012,
487 0x054df02a,478 0x054df01a,
479 0x054e0002,
488 0x054f2802,480 0x054f2802,
489 0x05514852,481 0x05514852,
490 0x0551781a,482 0x0551781a,
...@@ -1328,8 +1320,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1328,8 +1320,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1328 0x0851f802,1320 0x0851f802,
1329 0x08572812,1321 0x08572812,
1330 0x08692032,1322 0x08692032,
1323 0x086b4842,
1331 0x08755812,1324 0x08755812,
1332 0x0877e822,1325 0x0877e032,
1333 0x087a30a2,1326 0x087a30a2,
1334 0x087c1032,1327 0x087c1032,
1335 0x0880000a,1328 0x0880000a,
...@@ -1357,7 +1350,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1357,7 +1350,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1357 0x088c100a,1350 0x088c100a,
1358 0x088d982a,1351 0x088d982a,
1359 0x088db082,1352 0x088db082,
1360 0x088df81a,1353 0x088df80a,
1354 0x088e0002,
1361 0x088e1018,1355 0x088e1018,
1362 0x088e4832,1356 0x088e4832,
1363 0x088e700a,1357 0x088e700a,
...@@ -1365,9 +1359,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1365,9 +1359,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1365 0x0891602a,1359 0x0891602a,
1366 0x08917822,1360 0x08917822,
1367 0x0891901a,1361 0x0891901a,
1368 0x0891a002,1362 0x0891a032,
1369 0x0891a80a,
1370 0x0891b012,
1371 0x0891f002,1363 0x0891f002,
1372 0x08920802,1364 0x08920802,
1373 0x0896f802,1365 0x0896f802,
...@@ -1381,11 +1373,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1381,11 +1373,24 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1381 0x089a0002,1373 0x089a0002,
1382 0x089a083a,1374 0x089a083a,
1383 0x089a381a,1375 0x089a381a,
1384 0x089a582a,1376 0x089a581a,
1377 0x089a6802,
1385 0x089ab802,1378 0x089ab802,
1386 0x089b101a,1379 0x089b101a,
1387 0x089b3062,1380 0x089b3062,
1388 0x089b8042,1381 0x089b8042,
1382 0x089dc002,
1383 0x089dc81a,
1384 0x089dd852,
1385 0x089e1002,
1386 0x089e2802,
1387 0x089e3822,
1388 0x089e500a,
1389 0x089e601a,
1390 0x089e7022,
1391 0x089e8808,
1392 0x089e9002,
1393 0x089f0812,
1389 0x08a1a82a,1394 0x08a1a82a,
1390 0x08a1c072,1395 0x08a1c072,
1391 0x08a2001a,1396 0x08a2001a,
...@@ -1422,10 +1427,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1422,10 +1427,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1422 0x08b5600a,1427 0x08b5600a,
1423 0x08b56802,1428 0x08b56802,
1424 0x08b5701a,1429 0x08b5701a,
1425 0x08b58052,1430 0x08b58072,
1426 0x08b5b00a,1431 0x08b8e802,
1427 0x08b5b802,1432 0x08b8f00a,
1428 0x08b8e822,1433 0x08b8f802,
1429 0x08b91032,1434 0x08b91032,
1430 0x08b9300a,1435 0x08b9300a,
1431 0x08b93842,1436 0x08b93842,
...@@ -1436,9 +1441,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1436,9 +1441,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1436 0x08c98002,1441 0x08c98002,
1437 0x08c9884a,1442 0x08c9884a,
1438 0x08c9b81a,1443 0x08c9b81a,
1439 0x08c9d812,1444 0x08c9d832,
1440 0x08c9e80a,
1441 0x08c9f002,
1442 0x08c9f808,1445 0x08c9f808,
1443 0x08ca000a,1446 0x08ca000a,
1444 0x08ca0808,1447 0x08ca0808,
...@@ -1495,28 +1498,29 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1495,28 +1498,29 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1495 0x08f9a01a,1498 0x08f9a01a,
1496 0x08f9b042,1499 0x08f9b042,
1497 0x08f9f01a,1500 0x08f9f01a,
1498 0x08fa0002,1501 0x08fa0022,
1499 0x08fa080a,1502 0x08fad002,
1500 0x08fa1002,
1501 0x09a180f1,1503 0x09a180f1,
1502 0x09a20002,1504 0x09a20002,
1503 0x09a238e2,1505 0x09a238e2,
1506 0x0b08f0b2,
1507 0x0b09502a,
1508 0x0b096822,
1504 0x0b578042,1509 0x0b578042,
1505 0x0b598062,1510 0x0b598062,
1511 0x0b6b180c,
1512 0x0b6b383c,
1506 0x0b7a7802,1513 0x0b7a7802,
1507 0x0b7a8b6a,1514 0x0b7a8b6a,
1508 0x0b7c7832,1515 0x0b7c7832,
1509 0x0b7f2002,1516 0x0b7f2002,
1510 0x0b7f801a,1517 0x0b7f8012,
1511 0x0de4e812,1518 0x0de4e812,
1512 0x0de50031,1519 0x0de50031,
1513 0x0e7802d2,1520 0x0e7802d2,
1514 0x0e798162,1521 0x0e798162,
1515 0x0e8b2802,1522 0x0e8b2842,
1516 0x0e8b300a,1523 0x0e8b6852,
1517 0x0e8b3822,
1518 0x0e8b680a,
1519 0x0e8b7042,
1520 0x0e8b9871,1524 0x0e8b9871,
1521 0x0e8bd872,1525 0x0e8bd872,
1522 0x0e8c2862,1526 0x0e8c2862,
...@@ -1538,6 +1542,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {...@@ -1538,6 +1542,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
1538 0x0f157002,1542 0x0f157002,
1539 0x0f176032,1543 0x0f176032,
1540 0x0f276032,1544 0x0f276032,
1545 0x0f2f7012,
1541 0x0f468062,1546 0x0f468062,
1542 0x0f4a2062,1547 0x0f4a2062,
1543 0x0f8007f3,1548 0x0f8007f3,
lib/libcxx/include/__format/format_arg.h+3-3
...@@ -277,9 +277,9 @@ public:...@@ -277,9 +277,9 @@ public:
277};277};
278278
279template <class _Context>279template <class _Context>
280class _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {280class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
281public:281public:
282 class _LIBCPP_TEMPLATE_VIS handle;282 class handle;
283283
284 _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {}284 _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept : __type_{__format::__arg_t::__none} {}
285285
...@@ -355,7 +355,7 @@ public:...@@ -355,7 +355,7 @@ public:
355};355};
356356
357template <class _Context>357template <class _Context>
358class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {358class basic_format_arg<_Context>::handle {
359public:359public:
360 _LIBCPP_HIDE_FROM_ABI void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {360 _LIBCPP_HIDE_FROM_ABI void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {
361 __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_);361 __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_);
lib/libcxx/include/__format/format_arg_store.h+24-14
...@@ -14,13 +14,14 @@...@@ -14,13 +14,14 @@
14# pragma GCC system_header14# pragma GCC system_header
15#endif15#endif
1616
17#include <__concepts/arithmetic.h>
18#include <__concepts/same_as.h>17#include <__concepts/same_as.h>
19#include <__config>18#include <__config>
19#include <__cstddef/size_t.h>
20#include <__format/concepts.h>20#include <__format/concepts.h>
21#include <__format/format_arg.h>21#include <__format/format_arg.h>
22#include <__type_traits/conditional.h>22#include <__type_traits/conditional.h>
23#include <__type_traits/extent.h>23#include <__type_traits/extent.h>
24#include <__type_traits/integer_traits.h>
24#include <__type_traits/remove_const.h>25#include <__type_traits/remove_const.h>
25#include <cstdint>26#include <cstdint>
26#include <string>27#include <string>
...@@ -32,6 +33,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -32,6 +33,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3233
33namespace __format {34namespace __format {
3435
36template <class _Arr, class _Elem>
37inline constexpr bool __is_bounded_array_of = false;
38
39template <class _Elem, size_t _Len>
40inline constexpr bool __is_bounded_array_of<_Elem[_Len], _Elem> = true;
41
35/// \returns The @c __arg_t based on the type of the formatting argument.42/// \returns The @c __arg_t based on the type of the formatting argument.
36///43///
37/// \pre \c __formattable<_Tp, typename _Context::char_type>44/// \pre \c __formattable<_Tp, typename _Context::char_type>
...@@ -58,7 +65,7 @@ consteval __arg_t __determine_arg_t() {...@@ -58,7 +65,7 @@ consteval __arg_t __determine_arg_t() {
58# endif65# endif
5966
60// Signed integers67// Signed integers
61template <class, __libcpp_signed_integer _Tp>68template <class, __signed_integer _Tp>
62consteval __arg_t __determine_arg_t() {69consteval __arg_t __determine_arg_t() {
63 if constexpr (sizeof(_Tp) <= sizeof(int))70 if constexpr (sizeof(_Tp) <= sizeof(int))
64 return __arg_t::__int;71 return __arg_t::__int;
...@@ -73,7 +80,7 @@ consteval __arg_t __determine_arg_t() {...@@ -73,7 +80,7 @@ consteval __arg_t __determine_arg_t() {
73}80}
7481
75// Unsigned integers82// Unsigned integers
76template <class, __libcpp_unsigned_integer _Tp>83template <class, __unsigned_integer _Tp>
77consteval __arg_t __determine_arg_t() {84consteval __arg_t __determine_arg_t() {
78 if constexpr (sizeof(_Tp) <= sizeof(unsigned))85 if constexpr (sizeof(_Tp) <= sizeof(unsigned))
79 return __arg_t::__unsigned;86 return __arg_t::__unsigned;
...@@ -110,7 +117,7 @@ consteval __arg_t __determine_arg_t() {...@@ -110,7 +117,7 @@ consteval __arg_t __determine_arg_t() {
110117
111// Char array118// Char array
112template <class _Context, class _Tp>119template <class _Context, class _Tp>
113 requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>)120 requires __is_bounded_array_of<_Tp, typename _Context::char_type>
114consteval __arg_t __determine_arg_t() {121consteval __arg_t __determine_arg_t() {
115 return __arg_t::__string_view;122 return __arg_t::__string_view;
116}123}
...@@ -164,17 +171,18 @@ consteval __arg_t __determine_arg_t() {...@@ -164,17 +171,18 @@ consteval __arg_t __determine_arg_t() {
164template <class _Context, class _Tp>171template <class _Context, class _Tp>
165_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __value) noexcept {172_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __value) noexcept {
166 using _Dp = remove_const_t<_Tp>;173 using _Dp = remove_const_t<_Tp>;
167 constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>();174 constexpr __arg_t __arg = __format::__determine_arg_t<_Context, _Dp>();
168 static_assert(__arg != __arg_t::__none, "the supplied type is not formattable");175 static_assert(__arg != __arg_t::__none, "the supplied type is not formattable");
169 static_assert(__formattable_with<_Tp, _Context>);176 static_assert(__formattable_with<_Tp, _Context>);
170177
178 using __context_char_type = _Context::char_type;
171 // Not all types can be used to directly initialize the179 // Not all types can be used to directly initialize the
172 // __basic_format_arg_value. First handle all types needing adjustment, the180 // __basic_format_arg_value. First handle all types needing adjustment, the
173 // final else requires no adjustment.181 // final else requires no adjustment.
174 if constexpr (__arg == __arg_t::__char_type)182 if constexpr (__arg == __arg_t::__char_type)
175183
176# if _LIBCPP_HAS_WIDE_CHARACTERS184# if _LIBCPP_HAS_WIDE_CHARACTERS
177 if constexpr (same_as<typename _Context::char_type, wchar_t> && same_as<_Dp, char>)185 if constexpr (same_as<__context_char_type, wchar_t> && same_as<_Dp, char>)
178 return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))};186 return basic_format_arg<_Context>{__arg, static_cast<wchar_t>(static_cast<unsigned char>(__value))};
179 else187 else
180# endif188# endif
...@@ -189,14 +197,16 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu...@@ -189,14 +197,16 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu
189 return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};197 return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};
190 else if constexpr (__arg == __arg_t::__string_view)198 else if constexpr (__arg == __arg_t::__string_view)
191 // Using std::size on a character array will add the NUL-terminator to the size.199 // Using std::size on a character array will add the NUL-terminator to the size.
192 if constexpr (is_array_v<_Dp>)200 if constexpr (__is_bounded_array_of<_Dp, __context_char_type>) {
193 return basic_format_arg<_Context>{201 const __context_char_type* const __pbegin = std::begin(__value);
194 __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<_Dp> - 1}};202 const __context_char_type* const __pzero =
195 else203 char_traits<__context_char_type>::find(__pbegin, extent_v<_Dp>, __context_char_type{});
196 // When the _Traits or _Allocator are different an implicit conversion will204 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__pzero != nullptr, "formatting a non-null-terminated array");
197 // fail.
198 return basic_format_arg<_Context>{205 return basic_format_arg<_Context>{
199 __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}};206 __arg, basic_string_view<__context_char_type>{__pbegin, static_cast<size_t>(__pzero - __pbegin)}};
207 } else
208 // When the _Traits or _Allocator are different an implicit conversion will fail.
209 return basic_format_arg<_Context>{__arg, basic_string_view<__context_char_type>{__value.data(), __value.size()}};
200 else if constexpr (__arg == __arg_t::__ptr)210 else if constexpr (__arg == __arg_t::__ptr)
201 return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)};211 return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)};
202 else if constexpr (__arg == __arg_t::__handle)212 else if constexpr (__arg == __arg_t::__handle)
...@@ -247,7 +257,7 @@ struct __unpacked_format_arg_store {...@@ -247,7 +257,7 @@ struct __unpacked_format_arg_store {
247} // namespace __format257} // namespace __format
248258
249template <class _Context, class... _Args>259template <class _Context, class... _Args>
250struct _LIBCPP_TEMPLATE_VIS __format_arg_store {260struct __format_arg_store {
251 _LIBCPP_HIDE_FROM_ABI __format_arg_store(_Args&... __args) noexcept {261 _LIBCPP_HIDE_FROM_ABI __format_arg_store(_Args&... __args) noexcept {
252 if constexpr (sizeof...(_Args) != 0) {262 if constexpr (sizeof...(_Args) != 0) {
253 if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args)))263 if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args)))
lib/libcxx/include/__format/format_args.h+1-1
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26#if _LIBCPP_STD_VER >= 2026#if _LIBCPP_STD_VER >= 20
2727
28template <class _Context>28template <class _Context>
29class _LIBCPP_TEMPLATE_VIS basic_format_args {29class basic_format_args {
30public:30public:
31 template <class... _Args>31 template <class... _Args>
32 _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept32 _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
lib/libcxx/include/__format/format_context.h+4-9
...@@ -42,7 +42,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -42,7 +42,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4242
43template <class _OutIt, class _CharT>43template <class _OutIt, class _CharT>
44 requires output_iterator<_OutIt, const _CharT&>44 requires output_iterator<_OutIt, const _CharT&>
45class _LIBCPP_TEMPLATE_VIS basic_format_context;45class basic_format_context;
4646
47# if _LIBCPP_HAS_LOCALIZATION47# if _LIBCPP_HAS_LOCALIZATION
48/**48/**
...@@ -72,13 +72,8 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o...@@ -72,13 +72,8 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o
7272
73template <class _OutIt, class _CharT>73template <class _OutIt, class _CharT>
74 requires output_iterator<_OutIt, const _CharT&>74 requires output_iterator<_OutIt, const _CharT&>
75class75class _LIBCPP_PREFERRED_NAME(format_context)
76 // clang-format off76 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) basic_format_context {
77 _LIBCPP_TEMPLATE_VIS
78 _LIBCPP_PREFERRED_NAME(format_context)
79 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
80 // clang-format on
81 basic_format_context {
82public:77public:
83 using iterator = _OutIt;78 using iterator = _OutIt;
84 using char_type = _CharT;79 using char_type = _CharT;
...@@ -153,7 +148,7 @@ public:...@@ -153,7 +148,7 @@ public:
153// Here the width of an element in input is determined dynamically.148// Here the width of an element in input is determined dynamically.
154// Note when the top-level element has no width the retargeting is not needed.149// Note when the top-level element has no width the retargeting is not needed.
155template <class _CharT>150template <class _CharT>
156class _LIBCPP_TEMPLATE_VIS basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> {151class basic_format_context<typename __format::__retarget_buffer<_CharT>::__iterator, _CharT> {
157public:152public:
158 using iterator = typename __format::__retarget_buffer<_CharT>::__iterator;153 using iterator = typename __format::__retarget_buffer<_CharT>::__iterator;
159 using char_type = _CharT;154 using char_type = _CharT;
lib/libcxx/include/__format/format_functions.h+48-5
...@@ -11,6 +11,8 @@...@@ -11,6 +11,8 @@
11#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS11#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS
1212
13#include <__algorithm/clamp.h>13#include <__algorithm/clamp.h>
14#include <__algorithm/ranges_find_first_of.h>
15#include <__chrono/statically_widen.h>
14#include <__concepts/convertible_to.h>16#include <__concepts/convertible_to.h>
15#include <__concepts/same_as.h>17#include <__concepts/same_as.h>
16#include <__config>18#include <__config>
...@@ -36,6 +38,7 @@...@@ -36,6 +38,7 @@
36#include <__iterator/iterator_traits.h> // iter_value_t38#include <__iterator/iterator_traits.h> // iter_value_t
37#include <__variant/monostate.h>39#include <__variant/monostate.h>
38#include <array>40#include <array>
41#include <optional>
39#include <string>42#include <string>
40#include <string_view>43#include <string_view>
4144
...@@ -83,7 +86,7 @@ namespace __format {...@@ -83,7 +86,7 @@ namespace __format {
83/// When parsing a handle which is not enabled the code is ill-formed.86/// When parsing a handle which is not enabled the code is ill-formed.
84/// This helper uses the parser of the appropriate formatter for the stored type.87/// This helper uses the parser of the appropriate formatter for the stored type.
85template <class _CharT>88template <class _CharT>
86class _LIBCPP_TEMPLATE_VIS __compile_time_handle {89class __compile_time_handle {
87public:90public:
88 template <class _ParseContext>91 template <class _ParseContext>
89 _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const {92 _LIBCPP_HIDE_FROM_ABI constexpr void __parse(_ParseContext& __ctx) const {
...@@ -110,7 +113,7 @@ private:...@@ -110,7 +113,7 @@ private:
110// Dummy format_context only providing the parts used during constant113// Dummy format_context only providing the parts used during constant
111// validation of the basic_format_string.114// validation of the basic_format_string.
112template <class _CharT>115template <class _CharT>
113struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {116struct __compile_time_basic_format_context {
114public:117public:
115 using char_type = _CharT;118 using char_type = _CharT;
116119
...@@ -339,12 +342,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator __vformat_to(_ParseCtx&&...@@ -339,12 +342,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator __vformat_to(_ParseCtx&&
339342
340# if _LIBCPP_STD_VER >= 26343# if _LIBCPP_STD_VER >= 26
341template <class _CharT>344template <class _CharT>
342struct _LIBCPP_TEMPLATE_VIS __runtime_format_string {345struct __runtime_format_string {
343private:346private:
344 basic_string_view<_CharT> __str_;347 basic_string_view<_CharT> __str_;
345348
346 template <class _Cp, class... _Args>349 template <class _Cp, class... _Args>
347 friend struct _LIBCPP_TEMPLATE_VIS basic_format_string;350 friend struct basic_format_string;
348351
349public:352public:
350 _LIBCPP_HIDE_FROM_ABI __runtime_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {}353 _LIBCPP_HIDE_FROM_ABI __runtime_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {}
...@@ -362,7 +365,7 @@ _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wst...@@ -362,7 +365,7 @@ _LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wst
362# endif // _LIBCPP_STD_VER >= 26365# endif // _LIBCPP_STD_VER >= 26
363366
364template <class _CharT, class... _Args>367template <class _CharT, class... _Args>
365struct _LIBCPP_TEMPLATE_VIS basic_format_string {368struct basic_format_string {
366 template <class _Tp>369 template <class _Tp>
367 requires convertible_to<const _Tp&, basic_string_view<_CharT>>370 requires convertible_to<const _Tp&, basic_string_view<_CharT>>
368 consteval basic_format_string(const _Tp& __str) : __str_{__str} {371 consteval basic_format_string(const _Tp& __str) : __str_{__str} {
...@@ -447,10 +450,47 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {...@@ -447,10 +450,47 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
447}450}
448# endif451# endif
449452
453// Try constant folding the format string instead of going through the whole formatting machinery. If there is no
454// constant folding no extra code should be emitted (with optimizations enabled) and the function returns nullopt. When
455// constant folding is successful, the formatting is performed and the resulting string is returned.
456namespace __format {
457template <class _CharT>
458[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<basic_string<_CharT>> __try_constant_folding(
459 basic_string_view<_CharT> __fmt,
460 basic_format_args<basic_format_context<back_insert_iterator<__format::__output_buffer<_CharT>>, _CharT>> __args) {
461 // Fold strings not containing '{' or '}' to just return the string
462 if (bool __is_identity = [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
463 { return std::ranges::find_first_of(__fmt, array{'{', '}'}) == __fmt.end(); }();
464 __builtin_constant_p(__is_identity) && __is_identity)
465 return basic_string<_CharT>{__fmt};
466
467 // Fold '{}' to the appropriate conversion function
468 if (auto __only_first_arg = __fmt == _LIBCPP_STATICALLY_WIDEN(_CharT, "{}");
469 __builtin_constant_p(__only_first_arg) && __only_first_arg) {
470 if (auto __arg = __args.get(0); __builtin_constant_p(__arg.__type_)) {
471 return std::__visit_format_arg(
472 []<class _Tp>(_Tp&& __argument) -> optional<basic_string<_CharT>> {
473 if constexpr (is_same_v<remove_cvref_t<_Tp>, basic_string_view<_CharT>>) {
474 return basic_string<_CharT>{__argument};
475 } else {
476 return nullopt;
477 }
478 },
479 __arg);
480 }
481 }
482
483 return nullopt;
484}
485} // namespace __format
486
450// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup487// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
451// fires too eagerly, see http://llvm.org/PR61563.488// fires too eagerly, see http://llvm.org/PR61563.
452template <class = void>489template <class = void>
453[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {490[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {
491 auto __result = __format::__try_constant_folding(__fmt, __args);
492 if (__result.has_value())
493 return *std::move(__result);
454 __format::__allocating_buffer<char> __buffer;494 __format::__allocating_buffer<char> __buffer;
455 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);495 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);
456 return string{__buffer.__view()};496 return string{__buffer.__view()};
...@@ -462,6 +502,9 @@ template <class = void>...@@ -462,6 +502,9 @@ template <class = void>
462template <class = void>502template <class = void>
463[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring503[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
464vformat(wstring_view __fmt, wformat_args __args) {504vformat(wstring_view __fmt, wformat_args __args) {
505 auto __result = __format::__try_constant_folding(__fmt, __args);
506 if (__result.has_value())
507 return *std::move(__result);
465 __format::__allocating_buffer<wchar_t> __buffer;508 __format::__allocating_buffer<wchar_t> __buffer;
466 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);509 std::vformat_to(__buffer.__make_output_iterator(), __fmt, __args);
467 return wstring{__buffer.__view()};510 return wstring{__buffer.__view()};
lib/libcxx/include/__format/format_parse_context.h+1-1
...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if _LIBCPP_STD_VER >= 2024#if _LIBCPP_STD_VER >= 20
2525
26template <class _CharT>26template <class _CharT>
27class _LIBCPP_TEMPLATE_VIS basic_format_parse_context {27class basic_format_parse_context {
28public:28public:
29 using char_type = _CharT;29 using char_type = _CharT;
30 using const_iterator = typename basic_string_view<_CharT>::const_iterator;30 using const_iterator = typename basic_string_view<_CharT>::const_iterator;
lib/libcxx/include/__format/format_string.h+1-1
...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29namespace __format {29namespace __format {
3030
31template <contiguous_iterator _Iterator>31template <contiguous_iterator _Iterator>
32struct _LIBCPP_TEMPLATE_VIS __parse_number_result {32struct __parse_number_result {
33 _Iterator __last;33 _Iterator __last;
34 uint32_t __value;34 uint32_t __value;
35};35};
lib/libcxx/include/__format/format_to_n_result.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER >= 2022#if _LIBCPP_STD_VER >= 20
2323
24template <class _OutIt>24template <class _OutIt>
25struct _LIBCPP_TEMPLATE_VIS format_to_n_result {25struct format_to_n_result {
26 _OutIt out;26 _OutIt out;
27 iter_difference_t<_OutIt> size;27 iter_difference_t<_OutIt> size;
28};28};
lib/libcxx/include/__format/formatter.h+9-7
...@@ -21,6 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,6 +21,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if _LIBCPP_STD_VER >= 2022#if _LIBCPP_STD_VER >= 20
2323
24struct __disabled_formatter {
25 __disabled_formatter() = delete;
26 __disabled_formatter(const __disabled_formatter&) = delete;
27 __disabled_formatter& operator=(const __disabled_formatter&) = delete;
28};
29
24/// The default formatter template.30/// The default formatter template.
25///31///
26/// [format.formatter.spec]/532/// [format.formatter.spec]/5
...@@ -28,14 +34,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,14 +34,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28/// - is_default_constructible_v<F>,34/// - is_default_constructible_v<F>,
29/// - is_copy_constructible_v<F>,35/// - is_copy_constructible_v<F>,
30/// - is_move_constructible_v<F>,36/// - is_move_constructible_v<F>,
31/// - is_copy_assignable<F>, and37/// - is_copy_assignable_v<F>, and
32/// - is_move_assignable<F>.38/// - is_move_assignable_v<F>.
33template <class _Tp, class _CharT>39template <class _Tp, class _CharT>
34struct _LIBCPP_TEMPLATE_VIS formatter {40struct formatter : __disabled_formatter {};
35 formatter() = delete;
36 formatter(const formatter&) = delete;
37 formatter& operator=(const formatter&) = delete;
38};
3941
40# if _LIBCPP_STD_VER >= 2342# if _LIBCPP_STD_VER >= 23
4143
lib/libcxx/include/__format/formatter_bool.h+1-1
...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -33,7 +33,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
33#if _LIBCPP_STD_VER >= 2033#if _LIBCPP_STD_VER >= 20
3434
35template <__fmt_char_type _CharT>35template <__fmt_char_type _CharT>
36struct _LIBCPP_TEMPLATE_VIS formatter<bool, _CharT> {36struct formatter<bool, _CharT> {
37public:37public:
38 template <class _ParseContext>38 template <class _ParseContext>
39 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {39 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
lib/libcxx/include/__format/formatter_char.h+4-4
...@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31#if _LIBCPP_STD_VER >= 2031#if _LIBCPP_STD_VER >= 20
3232
33template <__fmt_char_type _CharT>33template <__fmt_char_type _CharT>
34struct _LIBCPP_TEMPLATE_VIS __formatter_char {34struct __formatter_char {
35public:35public:
36 template <class _ParseContext>36 template <class _ParseContext>
37 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {37 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -75,14 +75,14 @@ public:...@@ -75,14 +75,14 @@ public:
75};75};
7676
77template <>77template <>
78struct _LIBCPP_TEMPLATE_VIS formatter<char, char> : public __formatter_char<char> {};78struct formatter<char, char> : public __formatter_char<char> {};
7979
80# if _LIBCPP_HAS_WIDE_CHARACTERS80# if _LIBCPP_HAS_WIDE_CHARACTERS
81template <>81template <>
82struct _LIBCPP_TEMPLATE_VIS formatter<char, wchar_t> : public __formatter_char<wchar_t> {};82struct formatter<char, wchar_t> : public __formatter_char<wchar_t> {};
8383
84template <>84template <>
85struct _LIBCPP_TEMPLATE_VIS formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {};85struct formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {};
86# endif // _LIBCPP_HAS_WIDE_CHARACTERS86# endif // _LIBCPP_HAS_WIDE_CHARACTERS
8787
88# if _LIBCPP_STD_VER >= 2388# if _LIBCPP_STD_VER >= 23
lib/libcxx/include/__format/formatter_floating_point.h+6-5
...@@ -19,6 +19,7 @@...@@ -19,6 +19,7 @@
19#include <__assert>19#include <__assert>
20#include <__charconv/chars_format.h>20#include <__charconv/chars_format.h>
21#include <__charconv/to_chars_floating_point.h>21#include <__charconv/to_chars_floating_point.h>
22#include <__charconv/to_chars_integral.h>
22#include <__charconv/to_chars_result.h>23#include <__charconv/to_chars_result.h>
23#include <__concepts/arithmetic.h>24#include <__concepts/arithmetic.h>
24#include <__concepts/same_as.h>25#include <__concepts/same_as.h>
...@@ -140,7 +141,7 @@ struct __traits<double> {...@@ -140,7 +141,7 @@ struct __traits<double> {
140/// Depending on the maximum size required for a value, the buffer is allocated141/// Depending on the maximum size required for a value, the buffer is allocated
141/// on the stack or the heap.142/// on the stack or the heap.
142template <floating_point _Fp>143template <floating_point _Fp>
143class _LIBCPP_TEMPLATE_VIS __float_buffer {144class __float_buffer {
144 using _Traits _LIBCPP_NODEBUG = __traits<_Fp>;145 using _Traits _LIBCPP_NODEBUG = __traits<_Fp>;
145146
146public:147public:
...@@ -750,7 +751,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par...@@ -750,7 +751,7 @@ __format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__par
750} // namespace __formatter751} // namespace __formatter
751752
752template <__fmt_char_type _CharT>753template <__fmt_char_type _CharT>
753struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {754struct __formatter_floating_point {
754public:755public:
755 template <class _ParseContext>756 template <class _ParseContext>
756 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {757 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -768,11 +769,11 @@ public:...@@ -768,11 +769,11 @@ public:
768};769};
769770
770template <__fmt_char_type _CharT>771template <__fmt_char_type _CharT>
771struct _LIBCPP_TEMPLATE_VIS formatter<float, _CharT> : public __formatter_floating_point<_CharT> {};772struct formatter<float, _CharT> : public __formatter_floating_point<_CharT> {};
772template <__fmt_char_type _CharT>773template <__fmt_char_type _CharT>
773struct _LIBCPP_TEMPLATE_VIS formatter<double, _CharT> : public __formatter_floating_point<_CharT> {};774struct formatter<double, _CharT> : public __formatter_floating_point<_CharT> {};
774template <__fmt_char_type _CharT>775template <__fmt_char_type _CharT>
775struct _LIBCPP_TEMPLATE_VIS formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {};776struct formatter<long double, _CharT> : public __formatter_floating_point<_CharT> {};
776777
777# if _LIBCPP_STD_VER >= 23778# if _LIBCPP_STD_VER >= 23
778template <>779template <>
lib/libcxx/include/__format/formatter_integer.h+13-13
...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
30#if _LIBCPP_STD_VER >= 2030#if _LIBCPP_STD_VER >= 20
3131
32template <__fmt_char_type _CharT>32template <__fmt_char_type _CharT>
33struct _LIBCPP_TEMPLATE_VIS __formatter_integer {33struct __formatter_integer {
34public:34public:
35 template <class _ParseContext>35 template <class _ParseContext>
36 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {36 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -58,34 +58,34 @@ public:...@@ -58,34 +58,34 @@ public:
5858
59// Signed integral types.59// Signed integral types.
60template <__fmt_char_type _CharT>60template <__fmt_char_type _CharT>
61struct _LIBCPP_TEMPLATE_VIS formatter<signed char, _CharT> : public __formatter_integer<_CharT> {};61struct formatter<signed char, _CharT> : public __formatter_integer<_CharT> {};
62template <__fmt_char_type _CharT>62template <__fmt_char_type _CharT>
63struct _LIBCPP_TEMPLATE_VIS formatter<short, _CharT> : public __formatter_integer<_CharT> {};63struct formatter<short, _CharT> : public __formatter_integer<_CharT> {};
64template <__fmt_char_type _CharT>64template <__fmt_char_type _CharT>
65struct _LIBCPP_TEMPLATE_VIS formatter<int, _CharT> : public __formatter_integer<_CharT> {};65struct formatter<int, _CharT> : public __formatter_integer<_CharT> {};
66template <__fmt_char_type _CharT>66template <__fmt_char_type _CharT>
67struct _LIBCPP_TEMPLATE_VIS formatter<long, _CharT> : public __formatter_integer<_CharT> {};67struct formatter<long, _CharT> : public __formatter_integer<_CharT> {};
68template <__fmt_char_type _CharT>68template <__fmt_char_type _CharT>
69struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : public __formatter_integer<_CharT> {};69struct formatter<long long, _CharT> : public __formatter_integer<_CharT> {};
70# if _LIBCPP_HAS_INT12870# if _LIBCPP_HAS_INT128
71template <__fmt_char_type _CharT>71template <__fmt_char_type _CharT>
72struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {};72struct formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {};
73# endif73# endif
7474
75// Unsigned integral types.75// Unsigned integral types.
76template <__fmt_char_type _CharT>76template <__fmt_char_type _CharT>
77struct _LIBCPP_TEMPLATE_VIS formatter<unsigned char, _CharT> : public __formatter_integer<_CharT> {};77struct formatter<unsigned char, _CharT> : public __formatter_integer<_CharT> {};
78template <__fmt_char_type _CharT>78template <__fmt_char_type _CharT>
79struct _LIBCPP_TEMPLATE_VIS formatter<unsigned short, _CharT> : public __formatter_integer<_CharT> {};79struct formatter<unsigned short, _CharT> : public __formatter_integer<_CharT> {};
80template <__fmt_char_type _CharT>80template <__fmt_char_type _CharT>
81struct _LIBCPP_TEMPLATE_VIS formatter<unsigned, _CharT> : public __formatter_integer<_CharT> {};81struct formatter<unsigned, _CharT> : public __formatter_integer<_CharT> {};
82template <__fmt_char_type _CharT>82template <__fmt_char_type _CharT>
83struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {};83struct formatter<unsigned long, _CharT> : public __formatter_integer<_CharT> {};
84template <__fmt_char_type _CharT>84template <__fmt_char_type _CharT>
85struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {};85struct formatter<unsigned long long, _CharT> : public __formatter_integer<_CharT> {};
86# if _LIBCPP_HAS_INT12886# if _LIBCPP_HAS_INT128
87template <__fmt_char_type _CharT>87template <__fmt_char_type _CharT>
88struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {};88struct formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {};
89# endif89# endif
9090
91# if _LIBCPP_STD_VER >= 2391# if _LIBCPP_STD_VER >= 23
lib/libcxx/include/__format/formatter_integral.h+4-4
...@@ -338,7 +338,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer(...@@ -338,7 +338,7 @@ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_integer(
338 if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]]338 if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]]
339 return __formatter::__write(__first, __last, __ctx.out(), __specs);339 return __formatter::__write(__first, __last, __ctx.out(), __specs);
340340
341 return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper);341 return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, std::__hex_to_upper);
342}342}
343343
344template <unsigned_integral _Tp, class _CharT, class _FormatContext>344template <unsigned_integral _Tp, class _CharT, class _FormatContext>
...@@ -404,17 +404,17 @@ __format_integer(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_spe...@@ -404,17 +404,17 @@ __format_integer(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_spe
404//404//
405405
406template <class _CharT>406template <class _CharT>
407struct _LIBCPP_TEMPLATE_VIS __bool_strings;407struct __bool_strings;
408408
409template <>409template <>
410struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {410struct __bool_strings<char> {
411 static constexpr string_view __true{"true"};411 static constexpr string_view __true{"true"};
412 static constexpr string_view __false{"false"};412 static constexpr string_view __false{"false"};
413};413};
414414
415# if _LIBCPP_HAS_WIDE_CHARACTERS415# if _LIBCPP_HAS_WIDE_CHARACTERS
416template <>416template <>
417struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {417struct __bool_strings<wchar_t> {
418 static constexpr wstring_view __true{L"true"};418 static constexpr wstring_view __true{L"true"};
419 static constexpr wstring_view __false{L"false"};419 static constexpr wstring_view __false{L"false"};
420};420};
lib/libcxx/include/__format/formatter_output.h-18
...@@ -45,24 +45,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -45,24 +45,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4545
46namespace __formatter {46namespace __formatter {
4747
48_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) {
49 switch (__c) {
50 case 'a':
51 return 'A';
52 case 'b':
53 return 'B';
54 case 'c':
55 return 'C';
56 case 'd':
57 return 'D';
58 case 'e':
59 return 'E';
60 case 'f':
61 return 'F';
62 }
63 return __c;
64}
65
66struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result {48struct _LIBCPP_EXPORTED_FROM_ABI __padding_size_result {
67 size_t __before_;49 size_t __before_;
68 size_t __after_;50 size_t __after_;
lib/libcxx/include/__format/formatter_pointer.h+4-4
...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29#if _LIBCPP_STD_VER >= 2029#if _LIBCPP_STD_VER >= 20
3030
31template <__fmt_char_type _CharT>31template <__fmt_char_type _CharT>
32struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {32struct __formatter_pointer {
33public:33public:
34 template <class _ParseContext>34 template <class _ParseContext>
35 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {35 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -59,11 +59,11 @@ public:...@@ -59,11 +59,11 @@ public:
59// - template<> struct formatter<void*, charT>;59// - template<> struct formatter<void*, charT>;
60// - template<> struct formatter<const void*, charT>;60// - template<> struct formatter<const void*, charT>;
61template <__fmt_char_type _CharT>61template <__fmt_char_type _CharT>
62struct _LIBCPP_TEMPLATE_VIS formatter<nullptr_t, _CharT> : public __formatter_pointer<_CharT> {};62struct formatter<nullptr_t, _CharT> : public __formatter_pointer<_CharT> {};
63template <__fmt_char_type _CharT>63template <__fmt_char_type _CharT>
64struct _LIBCPP_TEMPLATE_VIS formatter<void*, _CharT> : public __formatter_pointer<_CharT> {};64struct formatter<void*, _CharT> : public __formatter_pointer<_CharT> {};
65template <__fmt_char_type _CharT>65template <__fmt_char_type _CharT>
66struct _LIBCPP_TEMPLATE_VIS formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {};66struct formatter<const void*, _CharT> : public __formatter_pointer<_CharT> {};
6767
68# if _LIBCPP_STD_VER >= 2368# if _LIBCPP_STD_VER >= 23
69template <>69template <>
lib/libcxx/include/__format/formatter_string.h+24-8
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H10#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
11#define _LIBCPP___FORMAT_FORMATTER_STRING_H11#define _LIBCPP___FORMAT_FORMATTER_STRING_H
1212
13#include <__assert>
13#include <__config>14#include <__config>
14#include <__format/concepts.h>15#include <__format/concepts.h>
15#include <__format/format_parse_context.h>16#include <__format/format_parse_context.h>
...@@ -17,6 +18,7 @@...@@ -17,6 +18,7 @@
17#include <__format/formatter_output.h>18#include <__format/formatter_output.h>
18#include <__format/parser_std_format_spec.h>19#include <__format/parser_std_format_spec.h>
19#include <__format/write_escaped.h>20#include <__format/write_escaped.h>
21#include <cstddef>
20#include <string>22#include <string>
21#include <string_view>23#include <string_view>
2224
...@@ -29,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -29,7 +31,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
29#if _LIBCPP_STD_VER >= 2031#if _LIBCPP_STD_VER >= 20
3032
31template <__fmt_char_type _CharT>33template <__fmt_char_type _CharT>
32struct _LIBCPP_TEMPLATE_VIS __formatter_string {34struct __formatter_string {
33public:35public:
34 template <class _ParseContext>36 template <class _ParseContext>
35 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {37 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
...@@ -58,7 +60,7 @@ public:...@@ -58,7 +60,7 @@ public:
5860
59// Formatter const char*.61// Formatter const char*.
60template <__fmt_char_type _CharT>62template <__fmt_char_type _CharT>
61struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> {63struct formatter<const _CharT*, _CharT> : public __formatter_string<_CharT> {
62 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;64 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
6365
64 template <class _FormatContext>66 template <class _FormatContext>
...@@ -77,7 +79,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatte...@@ -77,7 +79,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<const _CharT*, _CharT> : public __formatte
7779
78// Formatter char*.80// Formatter char*.
79template <__fmt_char_type _CharT>81template <__fmt_char_type _CharT>
80struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {82struct formatter<_CharT*, _CharT> : public formatter<const _CharT*, _CharT> {
81 using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>;83 using _Base _LIBCPP_NODEBUG = formatter<const _CharT*, _CharT>;
8284
83 template <class _FormatContext>85 template <class _FormatContext>
...@@ -88,20 +90,21 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const...@@ -88,20 +90,21 @@ struct _LIBCPP_TEMPLATE_VIS formatter<_CharT*, _CharT> : public formatter<const
8890
89// Formatter char[].91// Formatter char[].
90template <__fmt_char_type _CharT, size_t _Size>92template <__fmt_char_type _CharT, size_t _Size>
91struct _LIBCPP_TEMPLATE_VIS formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> {93struct formatter<_CharT[_Size], _CharT> : public __formatter_string<_CharT> {
92 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;94 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
9395
94 template <class _FormatContext>96 template <class _FormatContext>
95 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator97 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
96 format(const _CharT (&__str)[_Size], _FormatContext& __ctx) const {98 format(const _CharT (&__str)[_Size], _FormatContext& __ctx) const {
97 return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);99 const _CharT* const __pzero = char_traits<_CharT>::find(__str, _Size, _CharT{});
100 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__pzero != nullptr, "formatting a non-null-terminated array");
101 return _Base::format(basic_string_view<_CharT>(__str, static_cast<size_t>(__pzero - __str)), __ctx);
98 }102 }
99};103};
100104
101// Formatter std::string.105// Formatter std::string.
102template <__fmt_char_type _CharT, class _Traits, class _Allocator>106template <__fmt_char_type _CharT, class _Traits, class _Allocator>
103struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>107struct formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT> : public __formatter_string<_CharT> {
104 : public __formatter_string<_CharT> {
105 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;108 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
106109
107 template <class _FormatContext>110 template <class _FormatContext>
...@@ -114,7 +117,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>,...@@ -114,7 +117,7 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string<_CharT, _Traits, _Allocator>,
114117
115// Formatter std::string_view.118// Formatter std::string_view.
116template <__fmt_char_type _CharT, class _Traits>119template <__fmt_char_type _CharT, class _Traits>
117struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> {120struct formatter<basic_string_view<_CharT, _Traits>, _CharT> : public __formatter_string<_CharT> {
118 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;121 using _Base _LIBCPP_NODEBUG = __formatter_string<_CharT>;
119122
120 template <class _FormatContext>123 template <class _FormatContext>
...@@ -125,6 +128,19 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT...@@ -125,6 +128,19 @@ struct _LIBCPP_TEMPLATE_VIS formatter<basic_string_view<_CharT, _Traits>, _CharT
125 }128 }
126};129};
127130
131# if _LIBCPP_HAS_WIDE_CHARACTERS
132template <>
133struct formatter<char*, wchar_t> : __disabled_formatter {};
134template <>
135struct formatter<const char*, wchar_t> : __disabled_formatter {};
136template <size_t _Size>
137struct formatter<char[_Size], wchar_t> : __disabled_formatter {};
138template <class _Traits, class _Allocator>
139struct formatter<basic_string<char, _Traits, _Allocator>, wchar_t> : __disabled_formatter {};
140template <class _Traits>
141struct formatter<basic_string_view<char, _Traits>, wchar_t> : __disabled_formatter {};
142# endif // _LIBCPP_HAS_WIDE_CHARACTERS
143
128# if _LIBCPP_STD_VER >= 23144# if _LIBCPP_STD_VER >= 23
129template <>145template <>
130inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true;146inline constexpr bool enable_nonlocking_formatter_optimization<char*> = true;
lib/libcxx/include/__format/formatter_tuple.h+3-5
...@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -36,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
36#if _LIBCPP_STD_VER >= 2336#if _LIBCPP_STD_VER >= 23
3737
38template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>38template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>
39struct _LIBCPP_TEMPLATE_VIS __formatter_tuple {39struct __formatter_tuple {
40 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept {40 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept {
41 __separator_ = __separator;41 __separator_ = __separator;
42 }42 }
...@@ -136,12 +136,10 @@ private:...@@ -136,12 +136,10 @@ private:
136};136};
137137
138template <__fmt_char_type _CharT, formattable<_CharT>... _Args>138template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
139struct _LIBCPP_TEMPLATE_VIS formatter<pair<_Args...>, _CharT>139struct formatter<pair<_Args...>, _CharT> : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {};
140 : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {};
141140
142template <__fmt_char_type _CharT, formattable<_CharT>... _Args>141template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
143struct _LIBCPP_TEMPLATE_VIS formatter<tuple<_Args...>, _CharT>142struct formatter<tuple<_Args...>, _CharT> : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
144 : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
145143
146#endif // _LIBCPP_STD_VER >= 23144#endif // _LIBCPP_STD_VER >= 23
147145
lib/libcxx/include/__format/indic_conjunct_break_table.h+257-55
...@@ -107,10 +107,9 @@ enum class __property : uint8_t {...@@ -107,10 +107,9 @@ enum class __property : uint8_t {
107/// following benchmark.107/// following benchmark.
108/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp108/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
109// clang-format off109// clang-format off
110_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {110_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[403] = {
111 0x00180139,111 0x001801bd,
112 0x001a807d,112 0x00241819,
113 0x00241811,
114 0x002c88b1,113 0x002c88b1,
115 0x002df801,114 0x002df801,
116 0x002e0805,115 0x002e0805,
...@@ -125,6 +124,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {...@@ -125,6 +124,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
125 0x0037500d,124 0x0037500d,
126 0x00388801,125 0x00388801,
127 0x00398069,126 0x00398069,
127 0x003d3029,
128 0x003f5821,128 0x003f5821,
129 0x003fe801,129 0x003fe801,
130 0x0040b00d,130 0x0040b00d,
...@@ -132,87 +132,174 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {...@@ -132,87 +132,174 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
132 0x00412809,132 0x00412809,
133 0x00414811,133 0x00414811,
134 0x0042c809,134 0x0042c809,
135 0x0044c01d,135 0x0044b821,
136 0x0046505d,136 0x0046505d,
137 0x00471871,137 0x0047187d,
138 0x0048a890,138 0x0048a890,
139 0x0049d001,
139 0x0049e001,140 0x0049e001,
141 0x004a081d,
140 0x004a6802,142 0x004a6802,
141 0x004a880d,143 0x004a8819,
142 0x004ac01c,144 0x004ac01c,
145 0x004b1005,
143 0x004bc01c,146 0x004bc01c,
147 0x004c0801,
144 0x004ca84c,148 0x004ca84c,
145 0x004d5018,149 0x004d5018,
146 0x004d9000,150 0x004d9000,
147 0x004db00c,151 0x004db00c,
148 0x004de001,152 0x004de001,
153 0x004df001,
154 0x004e080d,
149 0x004e6802,155 0x004e6802,
156 0x004eb801,
150 0x004ee004,157 0x004ee004,
151 0x004ef800,158 0x004ef800,
159 0x004f1005,
152 0x004f8004,160 0x004f8004,
153 0x004ff001,161 0x004ff001,
162 0x00500805,
154 0x0051e001,163 0x0051e001,
164 0x00520805,
165 0x00523805,
166 0x00525809,
167 0x00528801,
168 0x00538005,
169 0x0053a801,
170 0x00540805,
155 0x0054a84c,171 0x0054a84c,
156 0x00555018,172 0x00555018,
157 0x00559004,173 0x00559004,
158 0x0055a810,174 0x0055a810,
159 0x0055e001,175 0x0055e001,
176 0x00560811,
177 0x00563805,
160 0x00566802,178 0x00566802,
179 0x00571005,
161 0x0057c800,180 0x0057c800,
181 0x0057d015,
182 0x00580801,
162 0x0058a84c,183 0x0058a84c,
163 0x00595018,184 0x00595018,
164 0x00599004,185 0x00599004,
165 0x0059a810,186 0x0059a810,
166 0x0059e001,187 0x0059e001,
188 0x0059f005,
189 0x005a080d,
167 0x005a6802,190 0x005a6802,
191 0x005aa809,
168 0x005ae004,192 0x005ae004,
169 0x005af800,193 0x005af800,
194 0x005b1005,
170 0x005b8800,195 0x005b8800,
196 0x005c1001,
197 0x005df001,
198 0x005e0001,
199 0x005e6801,
200 0x005eb801,
201 0x00600001,
202 0x00602001,
171 0x0060a84c,203 0x0060a84c,
172 0x0061503c,204 0x0061503c,
173 0x0061e001,205 0x0061e001,
206 0x0061f009,
207 0x00623009,
208 0x00625009,
174 0x00626802,209 0x00626802,
175 0x0062a805,210 0x0062a805,
176 0x0062c008,211 0x0062c008,
212 0x00631005,
213 0x00640801,
177 0x0065e001,214 0x0065e001,
215 0x0065f805,
216 0x00661001,
217 0x00663009,
218 0x0066500d,
219 0x0066a805,
220 0x00671005,
221 0x00680005,
178 0x0068a894,222 0x0068a894,
179 0x0069d805,223 0x0069d805,
224 0x0069f001,
225 0x006a080d,
180 0x006a6802,226 0x006a6802,
181 0x0071c009,227 0x006ab801,
182 0x0072400d,228 0x006b1005,
183 0x0075c009,229 0x006c0801,
184 0x0076400d,230 0x006e5001,
231 0x006e7801,
232 0x006e9009,
233 0x006eb001,
234 0x006ef801,
235 0x00718801,
236 0x0071a019,
237 0x0072381d,
238 0x00758801,
239 0x0075a021,
240 0x00764019,
185 0x0078c005,241 0x0078c005,
186 0x0079a801,242 0x0079a801,
187 0x0079b801,243 0x0079b801,
188 0x0079c801,244 0x0079c801,
189 0x007b8805,245 0x007b8835,
190 0x007ba001,246 0x007c0011,
191 0x007bd00d,
192 0x007c0001,
193 0x007c1009,
194 0x007c3005,247 0x007c3005,
248 0x007c6829,
249 0x007cc88d,
195 0x007e3001,250 0x007e3001,
196 0x0081b801,251 0x0081680d,
252 0x00819015,
197 0x0081c805,253 0x0081c805,
254 0x0081e805,
255 0x0082c005,
256 0x0082f009,
257 0x0083880d,
258 0x00841001,
259 0x00842805,
198 0x00846801,260 0x00846801,
261 0x0084e801,
199 0x009ae809,262 0x009ae809,
200 0x00b8a001,263 0x00b8900d,
201 0x00be9001,264 0x00b99009,
265 0x00ba9005,
266 0x00bb9005,
267 0x00bda005,
268 0x00bdb819,
269 0x00be3001,
270 0x00be4829,
202 0x00bee801,271 0x00bee801,
272 0x00c05809,
273 0x00c07801,
274 0x00c42805,
203 0x00c54801,275 0x00c54801,
276 0x00c90009,
277 0x00c93805,
278 0x00c99001,
204 0x00c9c809,279 0x00c9c809,
205 0x00d0b805,280 0x00d0b805,
281 0x00d0d801,
282 0x00d2b001,
283 0x00d2c019,
206 0x00d30001,284 0x00d30001,
207 0x00d3a81d,285 0x00d31001,
286 0x00d3281d,
287 0x00d39825,
208 0x00d3f801,288 0x00d3f801,
209 0x00d58035,289 0x00d58079,
210 0x00d5f83d,290 0x00d8000d,
211 0x00d9a001,291 0x00d9a025,
292 0x00da1009,
212 0x00db5821,293 0x00db5821,
213 0x00dd5801,294 0x00dc0005,
295 0x00dd100d,
296 0x00dd4015,
214 0x00df3001,297 0x00df3001,
215 0x00e1b801,298 0x00df4005,
299 0x00df6801,
300 0x00df7811,
301 0x00e1601d,
302 0x00e1b005,
216 0x00e68009,303 0x00e68009,
217 0x00e6a031,304 0x00e6a031,
218 0x00e71019,305 0x00e71019,
...@@ -221,82 +308,193 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {...@@ -221,82 +308,193 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
221 0x00e7c005,308 0x00e7c005,
222 0x00ee00fd,309 0x00ee00fd,
223 0x01006801,310 0x01006801,
224 0x01068031,311 0x01068081,
225 0x01070801,
226 0x0107282d,
227 0x01677809,312 0x01677809,
228 0x016bf801,313 0x016bf801,
229 0x016f007d,314 0x016f007d,
230 0x01815015,315 0x01815015,
231 0x0184c805,316 0x0184c805,
232 0x05337801,317 0x0533780d,
233 0x0533a025,318 0x0533a025,
234 0x0534f005,319 0x0534f005,
235 0x05378005,320 0x05378005,
321 0x05401001,
322 0x05403001,
323 0x05405801,
324 0x05412805,
236 0x05416001,325 0x05416001,
326 0x05462005,
237 0x05470045,327 0x05470045,
238 0x05495809,328 0x0547f801,
329 0x0549301d,
330 0x054a3829,
331 0x054a9801,
332 0x054c0009,
239 0x054d9801,333 0x054d9801,
334 0x054db00d,
335 0x054de005,
336 0x054e0001,
337 0x054f2801,
338 0x05514815,
339 0x05518805,
340 0x0551a805,
341 0x05521801,
342 0x05526001,
343 0x0553e001,
240 0x05558001,344 0x05558001,
241 0x05559009,345 0x05559009,
242 0x0555b805,346 0x0555b805,
243 0x0555f005,347 0x0555f005,
244 0x05560801,348 0x05560801,
349 0x05576005,
245 0x0557b001,350 0x0557b001,
351 0x055f2801,
352 0x055f4001,
246 0x055f6801,353 0x055f6801,
247 0x07d8f001,354 0x07d8f001,
355 0x07f0003d,
248 0x07f1003d,356 0x07f1003d,
357 0x07fcf005,
249 0x080fe801,358 0x080fe801,
250 0x08170001,359 0x08170001,
251 0x081bb011,360 0x081bb011,
252 0x08506801,361 0x08500809,
253 0x08507801,362 0x08502805,
363 0x0850600d,
254 0x0851c009,364 0x0851c009,
255 0x0851f801,365 0x0851f801,
256 0x08572805,366 0x08572805,
257 0x0869200d,367 0x0869200d,
368 0x086b4811,
258 0x08755805,369 0x08755805,
259 0x0877e809,370 0x0877e00d,
260 0x087a3029,371 0x087a3029,
261 0x087c100d,372 0x087c100d,
373 0x08800801,
374 0x0881c039,
262 0x08838001,375 0x08838001,
263 0x0883f801,376 0x08839805,
264 0x0885d001,377 0x0883f809,
378 0x0885980d,
379 0x0885c805,
380 0x08861001,
265 0x08880009,381 0x08880009,
266 0x08899805,382 0x08893811,
383 0x0889681d,
267 0x088b9801,384 0x088b9801,
268 0x088e5001,385 0x088c0005,
269 0x0891b001,386 0x088db021,
270 0x08974805,387 0x088e0001,
388 0x088e480d,
389 0x088e7801,
390 0x08917809,
391 0x0891a00d,
392 0x0891f001,
393 0x08920801,
394 0x0896f801,
395 0x0897181d,
396 0x08980005,
271 0x0899d805,397 0x0899d805,
398 0x0899f001,
399 0x089a0001,
400 0x089a6801,
401 0x089ab801,
272 0x089b3019,402 0x089b3019,
273 0x089b8011,403 0x089b8011,
404 0x089dc001,
405 0x089dd815,
406 0x089e1001,
407 0x089e2801,
408 0x089e3809,
409 0x089e7009,
410 0x089e9001,
411 0x089f0805,
412 0x08a1c01d,
413 0x08a21009,
274 0x08a23001,414 0x08a23001,
275 0x08a2f001,415 0x08a2f001,
276 0x08a61801,416 0x08a58001,
277 0x08ae0001,417 0x08a59815,
278 0x08b5b801,418 0x08a5d001,
279 0x08b95801,419 0x08a5e801,
280 0x08c1d001,420 0x08a5f805,
281 0x08c9f001,421 0x08a61005,
422 0x08ad7801,
423 0x08ad900d,
424 0x08ade005,
425 0x08adf805,
426 0x08aee005,
427 0x08b1981d,
428 0x08b1e801,
429 0x08b1f805,
430 0x08b55801,
431 0x08b56801,
432 0x08b5801d,
433 0x08b8e801,
434 0x08b8f801,
435 0x08b9100d,
436 0x08b93811,
437 0x08c17821,
438 0x08c1c805,
439 0x08c98001,
440 0x08c9d80d,
282 0x08ca1801,441 0x08ca1801,
283 0x08d1a001,442 0x08cea00d,
443 0x08ced005,
444 0x08cf0001,
445 0x08d00825,
446 0x08d19815,
447 0x08d1d80d,
284 0x08d23801,448 0x08d23801,
285 0x08d4c801,449 0x08d28815,
286 0x08ea1001,450 0x08d2c809,
287 0x08ea2005,451 0x08d45031,
452 0x08d4c005,
453 0x08e18019,
454 0x08e1c015,
455 0x08e1f801,
456 0x08e49055,
457 0x08e55019,
458 0x08e59005,
459 0x08e5a805,
460 0x08e98815,
461 0x08e9d001,
462 0x08e9e005,
463 0x08e9f819,
464 0x08ea3801,
465 0x08ec8005,
466 0x08eca801,
288 0x08ecb801,467 0x08ecb801,
289 0x08fa1001,468 0x08f79805,
469 0x08f80005,
470 0x08f9b011,
471 0x08fa0009,
472 0x08fad001,
473 0x09a20001,
474 0x09a23839,
475 0x0b08f02d,
476 0x0b096809,
290 0x0b578011,477 0x0b578011,
291 0x0b598019,478 0x0b598019,
292 0x0de4f001,479 0x0b7a7801,
293 0x0e8b2801,480 0x0b7c780d,
294 0x0e8b3809,481 0x0b7f2001,
295 0x0e8b7011,482 0x0b7f8005,
483 0x0de4e805,
484 0x0e7800b5,
485 0x0e798059,
486 0x0e8b2811,
487 0x0e8b6815,
296 0x0e8bd81d,488 0x0e8bd81d,
297 0x0e8c2819,489 0x0e8c2819,
298 0x0e8d500d,490 0x0e8d500d,
299 0x0e921009,491 0x0e921009,
492 0x0ed000d9,
493 0x0ed1d8c5,
494 0x0ed3a801,
495 0x0ed42001,
496 0x0ed4d811,
497 0x0ed50839,
300 0x0f000019,498 0x0f000019,
301 0x0f004041,499 0x0f004041,
302 0x0f00d819,500 0x0f00d819,
...@@ -307,8 +505,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {...@@ -307,8 +505,12 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
307 0x0f157001,505 0x0f157001,
308 0x0f17600d,506 0x0f17600d,
309 0x0f27600d,507 0x0f27600d,
508 0x0f2f7005,
310 0x0f468019,509 0x0f468019,
311 0x0f4a2019};510 0x0f4a2019,
511 0x0f9fd811,
512 0x7001017d,
513 0x700803bd};
312// clang-format on514// clang-format on
313515
314/// Returns the indic conjuct break property of a code point.516/// Returns the indic conjuct break property of a code point.
lib/libcxx/include/__format/parser_std_format_spec.h+1-1
...@@ -335,7 +335,7 @@ static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);...@@ -335,7 +335,7 @@ static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);
335/// set to zero. That way they can be repurposed if a future revision of the335/// set to zero. That way they can be repurposed if a future revision of the
336/// Standards adds new fields to std-format-spec.336/// Standards adds new fields to std-format-spec.
337template <class _CharT>337template <class _CharT>
338class _LIBCPP_TEMPLATE_VIS __parser {338class __parser {
339public:339public:
340 // Parses the format specification.340 // Parses the format specification.
341 //341 //
lib/libcxx/include/__format/range_default_formatter.h+7-7
...@@ -52,7 +52,7 @@ _LIBCPP_DIAGNOSTIC_POP...@@ -52,7 +52,7 @@ _LIBCPP_DIAGNOSTIC_POP
52// There is no definition of this struct, it's purely intended to be used to52// There is no definition of this struct, it's purely intended to be used to
53// generate diagnostics.53// generate diagnostics.
54template <class _Rp>54template <class _Rp>
55struct _LIBCPP_TEMPLATE_VIS __instantiated_the_primary_template_of_format_kind;55struct __instantiated_the_primary_template_of_format_kind;
5656
57template <class _Rp>57template <class _Rp>
58constexpr range_format format_kind = [] {58constexpr range_format format_kind = [] {
...@@ -88,12 +88,12 @@ inline constexpr range_format format_kind<_Rp> = [] {...@@ -88,12 +88,12 @@ inline constexpr range_format format_kind<_Rp> = [] {
88}();88}();
8989
90template <range_format _Kp, ranges::input_range _Rp, class _CharT>90template <range_format _Kp, ranges::input_range _Rp, class _CharT>
91struct _LIBCPP_TEMPLATE_VIS __range_default_formatter;91struct __range_default_formatter;
9292
93// Required specializations93// Required specializations
9494
95template <ranges::input_range _Rp, class _CharT>95template <ranges::input_range _Rp, class _CharT>
96struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::sequence, _Rp, _CharT> {96struct __range_default_formatter<range_format::sequence, _Rp, _CharT> {
97private:97private:
98 using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;98 using __maybe_const_r _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
99 range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;99 range_formatter<remove_cvref_t<ranges::range_reference_t<__maybe_const_r>>, _CharT> __underlying_;
...@@ -120,7 +120,7 @@ public:...@@ -120,7 +120,7 @@ public:
120};120};
121121
122template <ranges::input_range _Rp, class _CharT>122template <ranges::input_range _Rp, class _CharT>
123struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::map, _Rp, _CharT> {123struct __range_default_formatter<range_format::map, _Rp, _CharT> {
124private:124private:
125 using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;125 using __maybe_const_map _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
126 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;126 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_map>>;
...@@ -148,7 +148,7 @@ public:...@@ -148,7 +148,7 @@ public:
148};148};
149149
150template <ranges::input_range _Rp, class _CharT>150template <ranges::input_range _Rp, class _CharT>
151struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<range_format::set, _Rp, _CharT> {151struct __range_default_formatter<range_format::set, _Rp, _CharT> {
152private:152private:
153 using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;153 using __maybe_const_set _LIBCPP_NODEBUG = __fmt_maybe_const<_Rp, _CharT>;
154 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;154 using __element_type _LIBCPP_NODEBUG = remove_cvref_t<ranges::range_reference_t<__maybe_const_set>>;
...@@ -173,7 +173,7 @@ public:...@@ -173,7 +173,7 @@ public:
173173
174template <range_format _Kp, ranges::input_range _Rp, class _CharT>174template <range_format _Kp, ranges::input_range _Rp, class _CharT>
175 requires(_Kp == range_format::string || _Kp == range_format::debug_string)175 requires(_Kp == range_format::string || _Kp == range_format::debug_string)
176struct _LIBCPP_TEMPLATE_VIS __range_default_formatter<_Kp, _Rp, _CharT> {176struct __range_default_formatter<_Kp, _Rp, _CharT> {
177private:177private:
178 // This deviates from the Standard, there the exposition only type is178 // This deviates from the Standard, there the exposition only type is
179 // formatter<basic_string<charT>, charT> underlying_;179 // formatter<basic_string<charT>, charT> underlying_;
...@@ -205,7 +205,7 @@ public:...@@ -205,7 +205,7 @@ public:
205205
206template <ranges::input_range _Rp, class _CharT>206template <ranges::input_range _Rp, class _CharT>
207 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)207 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
208struct _LIBCPP_TEMPLATE_VIS formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};208struct formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
209209
210#endif // _LIBCPP_STD_VER >= 23210#endif // _LIBCPP_STD_VER >= 23
211211
lib/libcxx/include/__format/range_formatter.h+1-1
...@@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3939
40template <class _Tp, class _CharT = char>40template <class _Tp, class _CharT = char>
41 requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT>41 requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT>
42struct _LIBCPP_TEMPLATE_VIS range_formatter {42struct range_formatter {
43 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept {43 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept {
44 __separator_ = __separator;44 __separator_ = __separator;
45 }45 }
lib/libcxx/include/__format/width_estimation_table.h+11-8
...@@ -119,7 +119,7 @@ namespace __width_estimation_table {...@@ -119,7 +119,7 @@ namespace __width_estimation_table {
119/// - bits [0, 13] The size of the range, allowing 16384 elements.119/// - bits [0, 13] The size of the range, allowing 16384 elements.
120/// - bits [14, 31] The lower bound code point of the range. The upper bound of120/// - bits [14, 31] The lower bound code point of the range. The upper bound of
121/// the range is lower bound + size.121/// the range is lower bound + size.
122_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {122_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[110] = {
123 0x0440005f /* 00001100 - 0000115f [ 96] */, //123 0x0440005f /* 00001100 - 0000115f [ 96] */, //
124 0x08c68001 /* 0000231a - 0000231b [ 2] */, //124 0x08c68001 /* 0000231a - 0000231b [ 2] */, //
125 0x08ca4001 /* 00002329 - 0000232a [ 2] */, //125 0x08ca4001 /* 00002329 - 0000232a [ 2] */, //
...@@ -128,8 +128,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {...@@ -128,8 +128,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
128 0x08fcc000 /* 000023f3 - 000023f3 [ 1] */, //128 0x08fcc000 /* 000023f3 - 000023f3 [ 1] */, //
129 0x097f4001 /* 000025fd - 000025fe [ 2] */, //129 0x097f4001 /* 000025fd - 000025fe [ 2] */, //
130 0x09850001 /* 00002614 - 00002615 [ 2] */, //130 0x09850001 /* 00002614 - 00002615 [ 2] */, //
131 0x098c0007 /* 00002630 - 00002637 [ 8] */, //
131 0x0992000b /* 00002648 - 00002653 [ 12] */, //132 0x0992000b /* 00002648 - 00002653 [ 12] */, //
132 0x099fc000 /* 0000267f - 0000267f [ 1] */, //133 0x099fc000 /* 0000267f - 0000267f [ 1] */, //
134 0x09a28005 /* 0000268a - 0000268f [ 6] */, //
133 0x09a4c000 /* 00002693 - 00002693 [ 1] */, //135 0x09a4c000 /* 00002693 - 00002693 [ 1] */, //
134 0x09a84000 /* 000026a1 - 000026a1 [ 1] */, //136 0x09a84000 /* 000026a1 - 000026a1 [ 1] */, //
135 0x09aa8001 /* 000026aa - 000026ab [ 2] */, //137 0x09aa8001 /* 000026aa - 000026ab [ 2] */, //
...@@ -163,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {...@@ -163,7 +165,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
163 0x0c264066 /* 00003099 - 000030ff [ 103] */, //165 0x0c264066 /* 00003099 - 000030ff [ 103] */, //
164 0x0c41402a /* 00003105 - 0000312f [ 43] */, //166 0x0c41402a /* 00003105 - 0000312f [ 43] */, //
165 0x0c4c405d /* 00003131 - 0000318e [ 94] */, //167 0x0c4c405d /* 00003131 - 0000318e [ 94] */, //
166 0x0c640053 /* 00003190 - 000031e3 [ 84] */, //168 0x0c640055 /* 00003190 - 000031e5 [ 86] */, //
167 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, //169 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, //
168 0x0c880027 /* 00003220 - 00003247 [ 40] */, //170 0x0c880027 /* 00003220 - 00003247 [ 40] */, //
169 0x0c943fff /* 00003250 - 0000724f [16384] */, //171 0x0c943fff /* 00003250 - 0000724f [16384] */, //
...@@ -182,7 +184,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {...@@ -182,7 +184,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
182 0x5bfc0001 /* 00016ff0 - 00016ff1 [ 2] */, //184 0x5bfc0001 /* 00016ff0 - 00016ff1 [ 2] */, //
183 0x5c0017f7 /* 00017000 - 000187f7 [ 6136] */, //185 0x5c0017f7 /* 00017000 - 000187f7 [ 6136] */, //
184 0x620004d5 /* 00018800 - 00018cd5 [ 1238] */, //186 0x620004d5 /* 00018800 - 00018cd5 [ 1238] */, //
185 0x63400008 /* 00018d00 - 00018d08 [ 9] */, //187 0x633fc009 /* 00018cff - 00018d08 [ 10] */, //
186 0x6bfc0003 /* 0001aff0 - 0001aff3 [ 4] */, //188 0x6bfc0003 /* 0001aff0 - 0001aff3 [ 4] */, //
187 0x6bfd4006 /* 0001aff5 - 0001affb [ 7] */, //189 0x6bfd4006 /* 0001aff5 - 0001affb [ 7] */, //
188 0x6bff4001 /* 0001affd - 0001affe [ 2] */, //190 0x6bff4001 /* 0001affd - 0001affe [ 2] */, //
...@@ -192,6 +194,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {...@@ -192,6 +194,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
192 0x6c554000 /* 0001b155 - 0001b155 [ 1] */, //194 0x6c554000 /* 0001b155 - 0001b155 [ 1] */, //
193 0x6c590003 /* 0001b164 - 0001b167 [ 4] */, //195 0x6c590003 /* 0001b164 - 0001b167 [ 4] */, //
194 0x6c5c018b /* 0001b170 - 0001b2fb [ 396] */, //196 0x6c5c018b /* 0001b170 - 0001b2fb [ 396] */, //
197 0x74c00056 /* 0001d300 - 0001d356 [ 87] */, //
198 0x74d80016 /* 0001d360 - 0001d376 [ 23] */, //
195 0x7c010000 /* 0001f004 - 0001f004 [ 1] */, //199 0x7c010000 /* 0001f004 - 0001f004 [ 1] */, //
196 0x7c33c000 /* 0001f0cf - 0001f0cf [ 1] */, //200 0x7c33c000 /* 0001f0cf - 0001f0cf [ 1] */, //
197 0x7c638000 /* 0001f18e - 0001f18e [ 1] */, //201 0x7c638000 /* 0001f18e - 0001f18e [ 1] */, //
...@@ -213,11 +217,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {...@@ -213,11 +217,10 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
213 0x7dfc0000 /* 0001f7f0 - 0001f7f0 [ 1] */, //217 0x7dfc0000 /* 0001f7f0 - 0001f7f0 [ 1] */, //
214 0x7e4000ff /* 0001f900 - 0001f9ff [ 256] */, //218 0x7e4000ff /* 0001f900 - 0001f9ff [ 256] */, //
215 0x7e9c000c /* 0001fa70 - 0001fa7c [ 13] */, //219 0x7e9c000c /* 0001fa70 - 0001fa7c [ 13] */, //
216 0x7ea00008 /* 0001fa80 - 0001fa88 [ 9] */, //220 0x7ea00009 /* 0001fa80 - 0001fa89 [ 10] */, //
217 0x7ea4002d /* 0001fa90 - 0001fabd [ 46] */, //221 0x7ea3c037 /* 0001fa8f - 0001fac6 [ 56] */, //
218 0x7eafc006 /* 0001fabf - 0001fac5 [ 7] */, //222 0x7eb3800e /* 0001face - 0001fadc [ 15] */, //
219 0x7eb3800d /* 0001face - 0001fadb [ 14] */, //223 0x7eb7c00a /* 0001fadf - 0001fae9 [ 11] */, //
220 0x7eb80008 /* 0001fae0 - 0001fae8 [ 9] */, //
221 0x7ebc0008 /* 0001faf0 - 0001faf8 [ 9] */, //224 0x7ebc0008 /* 0001faf0 - 0001faf8 [ 9] */, //
222 0x80003fff /* 00020000 - 00023fff [16384] */, //225 0x80003fff /* 00020000 - 00023fff [16384] */, //
223 0x90003fff /* 00024000 - 00027fff [16384] */, //226 0x90003fff /* 00024000 - 00027fff [16384] */, //
lib/libcxx/include/__functional/binary_function.h+3-4
...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)21#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
2222
23template <class _Arg1, class _Arg2, class _Result>23template <class _Arg1, class _Arg2, class _Result>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binary_function {24struct _LIBCPP_DEPRECATED_IN_CXX11 binary_function {
25 typedef _Arg1 first_argument_type;25 typedef _Arg1 first_argument_type;
26 typedef _Arg2 second_argument_type;26 typedef _Arg2 second_argument_type;
27 typedef _Result result_type;27 typedef _Result result_type;
...@@ -39,11 +39,10 @@ struct __binary_function_keep_layout_base {...@@ -39,11 +39,10 @@ struct __binary_function_keep_layout_base {
39};39};
4040
41#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)41#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
42_LIBCPP_DIAGNOSTIC_PUSH42_LIBCPP_SUPPRESS_DEPRECATED_PUSH
43_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
44template <class _Arg1, class _Arg2, class _Result>43template <class _Arg1, class _Arg2, class _Result>
45using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>;44using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>;
46_LIBCPP_DIAGNOSTIC_POP45_LIBCPP_SUPPRESS_DEPRECATED_POP
47#else46#else
48template <class _Arg1, class _Arg2, class _Result>47template <class _Arg1, class _Arg2, class _Result>
49using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;48using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
lib/libcxx/include/__functional/binary_negate.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)22#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
2323
24template <class _Predicate>24template <class _Predicate>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate25class _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
26 : public __binary_function<typename _Predicate::first_argument_type,26 : public __binary_function<typename _Predicate::first_argument_type,
27 typename _Predicate::second_argument_type,27 typename _Predicate::second_argument_type,
28 bool> {28 bool> {
lib/libcxx/include/__functional/bind.h+3-3
...@@ -130,7 +130,7 @@ struct __mu_return_invokable // false...@@ -130,7 +130,7 @@ struct __mu_return_invokable // false
130130
131template <class _Ti, class... _Uj>131template <class _Ti, class... _Uj>
132struct __mu_return_invokable<true, _Ti, _Uj...> {132struct __mu_return_invokable<true, _Ti, _Uj...> {
133 using type = __invoke_result_t<_Ti&, _Uj...>;133 using type _LIBCPP_NODEBUG = __invoke_result_t<_Ti&, _Uj...>;
134};134};
135135
136template <class _Ti, class... _Uj>136template <class _Ti, class... _Uj>
...@@ -181,12 +181,12 @@ struct __bind_return;...@@ -181,12 +181,12 @@ struct __bind_return;
181181
182template <class _Fp, class... _BoundArgs, class _TupleUj>182template <class _Fp, class... _BoundArgs, class _TupleUj>
183struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {183struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
184 using type = __invoke_result_t< _Fp&, typename __mu_return< _BoundArgs, _TupleUj >::type... >;184 using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
185};185};
186186
187template <class _Fp, class... _BoundArgs, class _TupleUj>187template <class _Fp, class... _BoundArgs, class _TupleUj>
188struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {188struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
189 using type = __invoke_result_t< _Fp&, typename __mu_return< const _BoundArgs, _TupleUj >::type... >;189 using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
190};190};
191191
192template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>192template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
lib/libcxx/include/__functional/binder1st.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
24template <class _Operation>24template <class _Operation>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st25class _LIBCPP_DEPRECATED_IN_CXX11 binder1st
26 : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {26 : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
27protected:27protected:
28 _Operation op;28 _Operation op;
lib/libcxx/include/__functional/binder2nd.h+1-1
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
24template <class _Operation>24template <class _Operation>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd25class _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
26 : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {26 : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
27protected:27protected:
28 _Operation op;28 _Operation op;
lib/libcxx/include/__functional/boyer_moore_searcher.h+7-9
...@@ -17,12 +17,10 @@...@@ -17,12 +17,10 @@
17#include <__config>17#include <__config>
18#include <__functional/hash.h>18#include <__functional/hash.h>
19#include <__functional/operations.h>19#include <__functional/operations.h>
20#include <__iterator/distance.h>
21#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
22#include <__memory/shared_ptr.h>21#include <__memory/shared_ptr.h>
23#include <__type_traits/make_unsigned.h>22#include <__type_traits/make_unsigned.h>
24#include <__utility/pair.h>23#include <__utility/pair.h>
25#include <__vector/vector.h>
26#include <array>24#include <array>
27#include <limits>25#include <limits>
28#include <unordered_map>26#include <unordered_map>
...@@ -88,7 +86,7 @@ public:...@@ -88,7 +86,7 @@ public:
88template <class _RandomAccessIterator1,86template <class _RandomAccessIterator1,
89 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,87 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
90 class _BinaryPredicate = equal_to<>>88 class _BinaryPredicate = equal_to<>>
91class _LIBCPP_TEMPLATE_VIS boyer_moore_searcher {89class boyer_moore_searcher {
92private:90private:
93 using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;91 using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
94 using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;92 using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
...@@ -125,8 +123,8 @@ public:...@@ -125,8 +123,8 @@ public:
125 template <class _RandomAccessIterator2>123 template <class _RandomAccessIterator2>
126 _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>124 _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
127 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {125 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
128 static_assert(__is_same_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,126 static_assert(is_same_v<__remove_cvref_t<typename iterator_traits<_RandomAccessIterator1>::value_type>,
129 typename iterator_traits<_RandomAccessIterator2>::value_type>::value,127 __remove_cvref_t<typename iterator_traits<_RandomAccessIterator2>::value_type>>,
130 "Corpus and Pattern iterators must point to the same type");128 "Corpus and Pattern iterators must point to the same type");
131 if (__first == __last)129 if (__first == __last)
132 return std::make_pair(__last, __last);130 return std::make_pair(__last, __last);
...@@ -196,7 +194,7 @@ private:...@@ -196,7 +194,7 @@ private:
196 if (__count == 0)194 if (__count == 0)
197 return;195 return;
198196
199 vector<difference_type> __scratch(__count);197 auto __scratch = std::make_unique<difference_type[]>(__count);
200198
201 __compute_bm_prefix(__first, __last, __pred, __scratch);199 __compute_bm_prefix(__first, __last, __pred, __scratch);
202 for (size_t __i = 0; __i <= __count; ++__i)200 for (size_t __i = 0; __i <= __count; ++__i)
...@@ -219,7 +217,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);...@@ -219,7 +217,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);
219template <class _RandomAccessIterator1,217template <class _RandomAccessIterator1,
220 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,218 class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
221 class _BinaryPredicate = equal_to<>>219 class _BinaryPredicate = equal_to<>>
222class _LIBCPP_TEMPLATE_VIS boyer_moore_horspool_searcher {220class boyer_moore_horspool_searcher {
223private:221private:
224 using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;222 using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;
225 using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;223 using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;
...@@ -256,8 +254,8 @@ public:...@@ -256,8 +254,8 @@ public:
256 template <class _RandomAccessIterator2>254 template <class _RandomAccessIterator2>
257 _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>255 _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
258 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {256 operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
259 static_assert(__is_same_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,257 static_assert(is_same_v<__remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator1>::value_type>,
260 typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,258 __remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator2>::value_type>>,
261 "Corpus and Pattern iterators must point to the same type");259 "Corpus and Pattern iterators must point to the same type");
262 if (__first == __last)260 if (__first == __last)
263 return std::make_pair(__last, __last);261 return std::make_pair(__last, __last);
lib/libcxx/include/__functional/default_searcher.h+1-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727
28// default searcher28// default searcher
29template <class _ForwardIterator, class _BinaryPredicate = equal_to<>>29template <class _ForwardIterator, class _BinaryPredicate = equal_to<>>
30class _LIBCPP_TEMPLATE_VIS default_searcher {30class default_searcher {
31public:31public:
32 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX2032 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
33 default_searcher(_ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate())33 default_searcher(_ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate())
lib/libcxx/include/__functional/function.h+78-301
...@@ -17,13 +17,7 @@...@@ -17,13 +17,7 @@
17#include <__functional/binary_function.h>17#include <__functional/binary_function.h>
18#include <__functional/invoke.h>18#include <__functional/invoke.h>
19#include <__functional/unary_function.h>19#include <__functional/unary_function.h>
20#include <__iterator/iterator_traits.h>
21#include <__memory/addressof.h>20#include <__memory/addressof.h>
22#include <__memory/allocator.h>
23#include <__memory/allocator_destructor.h>
24#include <__memory/allocator_traits.h>
25#include <__memory/compressed_pair.h>
26#include <__memory/unique_ptr.h>
27#include <__type_traits/aligned_storage.h>21#include <__type_traits/aligned_storage.h>
28#include <__type_traits/decay.h>22#include <__type_traits/decay.h>
29#include <__type_traits/is_core_convertible.h>23#include <__type_traits/is_core_convertible.h>
...@@ -34,9 +28,7 @@...@@ -34,9 +28,7 @@
34#include <__type_traits/strip_signature.h>28#include <__type_traits/strip_signature.h>
35#include <__utility/forward.h>29#include <__utility/forward.h>
36#include <__utility/move.h>30#include <__utility/move.h>
37#include <__utility/piecewise_construct.h>
38#include <__utility/swap.h>31#include <__utility/swap.h>
39#include <__verbose_abort>
40#include <tuple>32#include <tuple>
41#include <typeinfo>33#include <typeinfo>
4234
...@@ -71,7 +63,7 @@ public:...@@ -71,7 +63,7 @@ public:
71 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}63 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}
72# endif64# endif
7365
74# ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE66# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
75 const char* what() const _NOEXCEPT override;67 const char* what() const _NOEXCEPT override;
76# endif68# endif
77};69};
...@@ -86,7 +78,7 @@ _LIBCPP_DIAGNOSTIC_POP...@@ -86,7 +78,7 @@ _LIBCPP_DIAGNOSTIC_POP
86}78}
8779
88template <class _Fp>80template <class _Fp>
89class _LIBCPP_TEMPLATE_VIS function; // undefined81class function; // undefined
9082
91namespace __function {83namespace __function {
9284
...@@ -122,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) {...@@ -122,7 +114,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) {
122 return !!__f;114 return !!__f;
123}115}
124116
125# if _LIBCPP_HAS_EXTENSION_BLOCKS117# if __has_extension(blocks)
126template <class _Rp, class... _Args>118template <class _Rp, class... _Args>
127_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {119_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {
128 return __p;120 return __p;
...@@ -133,108 +125,10 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {...@@ -133,108 +125,10 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {
133125
134namespace __function {126namespace __function {
135127
136// __alloc_func holds a functor and an allocator.
137
138template <class _Fp, class _Ap, class _FB>
139class __alloc_func;
140template <class _Fp, class _FB>
141class __default_alloc_func;
142
143template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>
144class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> {
145 _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Ap, __alloc_);
146
147public:
148 using _Target _LIBCPP_NODEBUG = _Fp;
149 using _Alloc _LIBCPP_NODEBUG = _Ap;
150
151 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __func_; }
152
153 // WIN32 APIs may define __allocator, so use __get_allocator instead.
154 _LIBCPP_HIDE_FROM_ABI const _Alloc& __get_allocator() const { return __alloc_; }
155
156 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f) : __func_(std::move(__f)), __alloc_() {}
157
158 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, const _Alloc& __a) : __func_(__f), __alloc_(__a) {}
159
160 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(const _Target& __f, _Alloc&& __a)
161 : __func_(__f), __alloc_(std::move(__a)) {}
162
163 _LIBCPP_HIDE_FROM_ABI explicit __alloc_func(_Target&& __f, _Alloc&& __a)
164 : __func_(std::move(__f)), __alloc_(std::move(__a)) {}
165
166 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
167 return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);
168 }
169
170 _LIBCPP_HIDE_FROM_ABI __alloc_func* __clone() const {
171 typedef allocator_traits<_Alloc> __alloc_traits;
172 typedef __rebind_alloc<__alloc_traits, __alloc_func> _AA;
173 _AA __a(__alloc_);
174 typedef __allocator_destructor<_AA> _Dp;
175 unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
176 ::new ((void*)__hold.get()) __alloc_func(__func_, _Alloc(__a));
177 return __hold.release();
178 }
179
180 _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT {
181 __func_.~_Fp();
182 __alloc_.~_Alloc();
183 }
184
185 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__alloc_func* __f) {
186 typedef allocator_traits<_Alloc> __alloc_traits;
187 typedef __rebind_alloc<__alloc_traits, __alloc_func> _FunAlloc;
188 _FunAlloc __a(__f->__get_allocator());
189 __f->destroy();
190 __a.deallocate(__f, 1);
191 }
192};
193
194template <class _Tp>
195struct __deallocating_deleter {
196 _LIBCPP_HIDE_FROM_ABI void operator()(void* __p) const {
197 std::__libcpp_deallocate<_Tp>(static_cast<_Tp*>(__p), __element_count(1));
198 }
199};
200
201template <class _Fp, class _Rp, class... _ArgTypes>
202class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
203 _Fp __f_;
204
205public:
206 using _Target _LIBCPP_NODEBUG = _Fp;
207
208 _LIBCPP_HIDE_FROM_ABI const _Target& __target() const { return __f_; }
209
210 _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {}
211
212 _LIBCPP_HIDE_FROM_ABI explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
213
214 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __arg) {
215 return std::__invoke_r<_Rp>(__f_, std::forward<_ArgTypes>(__arg)...);
216 }
217
218 _LIBCPP_HIDE_FROM_ABI __default_alloc_func* __clone() const {
219 using _Self = __default_alloc_func;
220 unique_ptr<_Self, __deallocating_deleter<_Self>> __hold(std::__libcpp_allocate<_Self>(__element_count(1)));
221 _Self* __res = ::new ((void*)__hold.get()) _Self(__f_);
222 (void)__hold.release();
223 return __res;
224 }
225
226 _LIBCPP_HIDE_FROM_ABI void destroy() _NOEXCEPT { __f_.~_Target(); }
227
228 _LIBCPP_HIDE_FROM_ABI static void __destroy_and_delete(__default_alloc_func* __f) {
229 __f->destroy();
230 std::__libcpp_deallocate<__default_alloc_func>(__f, __element_count(1));
231 }
232};
233
234// __base provides an abstract interface for copyable functors.128// __base provides an abstract interface for copyable functors.
235129
236template <class _Fp>130template <class _Fp>
237class _LIBCPP_TEMPLATE_VIS __base;131class __base;
238132
239template <class _Rp, class... _ArgTypes>133template <class _Rp, class... _ArgTypes>
240class __base<_Rp(_ArgTypes...)> {134class __base<_Rp(_ArgTypes...)> {
...@@ -257,84 +151,38 @@ public:...@@ -257,84 +151,38 @@ public:
257151
258// __func implements __base for a given functor type.152// __func implements __base for a given functor type.
259153
260template <class _FD, class _Alloc, class _FB>154template <class _FD, class _FB>
261class __func;155class __func;
262156
263template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>157template <class _Fp, class _Rp, class... _ArgTypes>
264class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {158class __func<_Fp, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
265 __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_;159 _Fp __func_;
266160
267public:161public:
268 _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __f_(std::move(__f)) {}162 _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __func_(std::move(__f)) {}
163 _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f) : __func_(__f) {}
269164
270 _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, const _Alloc& __a) : __f_(__f, __a) {}165 _LIBCPP_HIDE_FROM_ABI_VIRTUAL __base<_Rp(_ArgTypes...)>* __clone() const override { return new __func(__func_); }
271166
272 _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f, _Alloc&& __a) : __f_(__f, std::move(__a)) {}167 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __clone(__base<_Rp(_ArgTypes...)>* __p) const override {
273168 ::new ((void*)__p) __func(__func_);
274 _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f, _Alloc&& __a) : __f_(std::move(__f), std::move(__a)) {}169 }
275170
276 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const;171 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy() _NOEXCEPT override { __func_.~_Fp(); }
277 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>*) const;172 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy_deallocate() _NOEXCEPT override { delete this; }
278 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT;173 _LIBCPP_HIDE_FROM_ABI_VIRTUAL _Rp operator()(_ArgTypes&&... __arg) override {
279 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT;174 return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);
280 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg);175 }
281# if _LIBCPP_HAS_RTTI176# if _LIBCPP_HAS_RTTI
282 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT;177 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* target(const type_info& __ti) const _NOEXCEPT override {
283 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT;178 if (__ti == typeid(_Fp))
179 return std::addressof(__func_);
180 return nullptr;
181 }
182 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const std::type_info& target_type() const _NOEXCEPT override { return typeid(_Fp); }
284# endif // _LIBCPP_HAS_RTTI183# endif // _LIBCPP_HAS_RTTI
285};184};
286185
287template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
288__base<_Rp(_ArgTypes...)>* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const {
289 typedef allocator_traits<_Alloc> __alloc_traits;
290 typedef __rebind_alloc<__alloc_traits, __func> _Ap;
291 _Ap __a(__f_.__get_allocator());
292 typedef __allocator_destructor<_Ap> _Dp;
293 unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
294 ::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));
295 return __hold.release();
296}
297
298template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
299void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const {
300 ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator());
301}
302
303template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
304void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT {
305 __f_.destroy();
306}
307
308template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
309void __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT {
310 typedef allocator_traits<_Alloc> __alloc_traits;
311 typedef __rebind_alloc<__alloc_traits, __func> _Ap;
312 _Ap __a(__f_.__get_allocator());
313 __f_.destroy();
314 __a.deallocate(this, 1);
315}
316
317template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
318_Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) {
319 return __f_(std::forward<_ArgTypes>(__arg)...);
320}
321
322# if _LIBCPP_HAS_RTTI
323
324template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
325const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT {
326 if (__ti == typeid(_Fp))
327 return std::addressof(__f_.__target());
328 return nullptr;
329}
330
331template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
332const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {
333 return typeid(_Fp);
334}
335
336# endif // _LIBCPP_HAS_RTTI
337
338// __value_func creates a value-type from a __func.186// __value_func creates a value-type from a __func.
339187
340template <class _Fp>188template <class _Fp>
...@@ -354,29 +202,19 @@ class __value_func<_Rp(_ArgTypes...)> {...@@ -354,29 +202,19 @@ class __value_func<_Rp(_ArgTypes...)> {
354public:202public:
355 _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {}203 _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {}
356204
357 template <class _Fp, class _Alloc>205 template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0>
358 _LIBCPP_HIDE_FROM_ABI __value_func(_Fp&& __f, const _Alloc& __a) : __f_(nullptr) {206 _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) {
359 typedef allocator_traits<_Alloc> __alloc_traits;207 typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun;
360 typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
361 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
362208
363 if (__function::__not_null(__f)) {209 if (__function::__not_null(__f)) {
364 _FunAlloc __af(__a);210 if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) {
365 if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value &&211 __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f));
366 is_nothrow_copy_constructible<_FunAlloc>::value) {
367 __f_ = ::new ((void*)&__buf_) _Fun(std::move(__f), _Alloc(__af));
368 } else {212 } else {
369 typedef __allocator_destructor<_FunAlloc> _Dp;213 __f_ = new _Fun(std::move(__f));
370 unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
371 ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__a));
372 __f_ = __hold.release();
373 }214 }
374 }215 }
375 }216 }
376217
377 template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0>
378 _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {}
379
380 _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) {218 _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) {
381 if (__f.__f_ == nullptr)219 if (__f.__f_ == nullptr)
382 __f_ = nullptr;220 __f_ = nullptr;
...@@ -432,12 +270,12 @@ public:...@@ -432,12 +270,12 @@ public:
432270
433 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {271 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {
434 if (__f_ == nullptr)272 if (__f_ == nullptr)
435 __throw_bad_function_call();273 std::__throw_bad_function_call();
436 return (*__f_)(std::forward<_ArgTypes>(__args)...);274 return (*__f_)(std::forward<_ArgTypes>(__args)...);
437 }275 }
438276
439 _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT {277 _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT {
440 if (&__f == this)278 if (std::addressof(__f) == this)
441 return;279 return;
442 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) {280 if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) {
443 _LIBCPP_SUPPRESS_DEPRECATED_PUSH281 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
...@@ -539,22 +377,22 @@ private:...@@ -539,22 +377,22 @@ private:
539 template <typename _Fun>377 template <typename _Fun>
540 _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) {378 _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) {
541 const _Fun* __f = static_cast<const _Fun*>(__s);379 const _Fun* __f = static_cast<const _Fun*>(__s);
542 return __f->__clone();380 return new _Fun(*__f);
543 }381 }
544382
545 template <typename _Fun>383 template <typename _Fun>
546 _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) {384 _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) {
547 _Fun::__destroy_and_delete(static_cast<_Fun*>(__s));385 delete static_cast<_Fun*>(__s);
548 }386 }
549387
550 template <typename _Fun>388 template <typename _Fun>
551 _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) {389 _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) {
552 static constexpr __policy __policy = {390 static constexpr __policy __policy = {
553 &__large_clone<_Fun>,391 std::addressof(__large_clone<_Fun>),
554 &__large_destroy<_Fun>,392 std::addressof(__large_destroy<_Fun>),
555 false,393 false,
556# if _LIBCPP_HAS_RTTI394# if _LIBCPP_HAS_RTTI
557 &typeid(typename _Fun::_Target)395 &typeid(_Fun)
558# else396# else
559 nullptr397 nullptr
560# endif398# endif
...@@ -569,7 +407,7 @@ private:...@@ -569,7 +407,7 @@ private:
569 nullptr,407 nullptr,
570 false,408 false,
571# if _LIBCPP_HAS_RTTI409# if _LIBCPP_HAS_RTTI
572 &typeid(typename _Fun::_Target)410 &typeid(_Fun)
573# else411# else
574 nullptr412 nullptr
575# endif413# endif
...@@ -583,42 +421,7 @@ private:...@@ -583,42 +421,7 @@ private:
583template <typename _Tp>421template <typename _Tp>
584using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;422using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
585423
586// __policy_invoker calls an instance of __alloc_func held in __policy_storage.424// __policy_func uses a __policy to create a type-erased, copyable functor.
587
588template <class _Fp>
589struct __policy_invoker;
590
591template <class _Rp, class... _ArgTypes>
592struct __policy_invoker<_Rp(_ArgTypes...)> {
593 typedef _Rp (*__Call)(const __policy_storage*, __fast_forward<_ArgTypes>...);
594
595 __Call __call_;
596
597 // Creates an invoker that throws bad_function_call.
598 _LIBCPP_HIDE_FROM_ABI __policy_invoker() : __call_(&__call_empty) {}
599
600 // Creates an invoker that calls the given instance of __func.
601 template <typename _Fun>
602 _LIBCPP_HIDE_FROM_ABI static __policy_invoker __create() {
603 return __policy_invoker(&__call_impl<_Fun>);
604 }
605
606private:
607 _LIBCPP_HIDE_FROM_ABI explicit __policy_invoker(__Call __c) : __call_(__c) {}
608
609 _LIBCPP_HIDE_FROM_ABI static _Rp __call_empty(const __policy_storage*, __fast_forward<_ArgTypes>...) {
610 __throw_bad_function_call();
611 }
612
613 template <typename _Fun>
614 _LIBCPP_HIDE_FROM_ABI static _Rp __call_impl(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) {
615 _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large);
616 return (*__f)(std::forward<_ArgTypes>(__args)...);
617 }
618};
619
620// __policy_func uses a __policy and __policy_invoker to create a type-erased,
621// copyable functor.
622425
623template <class _Fp>426template <class _Fp>
624class __policy_func;427class __policy_func;
...@@ -628,69 +431,52 @@ class __policy_func<_Rp(_ArgTypes...)> {...@@ -628,69 +431,52 @@ class __policy_func<_Rp(_ArgTypes...)> {
628 // Inline storage for small objects.431 // Inline storage for small objects.
629 __policy_storage __buf_;432 __policy_storage __buf_;
630433
631 // Calls the value stored in __buf_. This could technically be part of434 using _ErasedFunc _LIBCPP_NODEBUG = _Rp(const __policy_storage*, __fast_forward<_ArgTypes>...);
632 // policy, but storing it here eliminates a level of indirection inside435
633 // operator().436 _ErasedFunc* __func_;
634 typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker;
635 __invoker __invoker_;
636437
637 // The policy that describes how to move / copy / destroy __buf_. Never438 // The policy that describes how to move / copy / destroy __buf_. Never
638 // null, even if the function is empty.439 // null, even if the function is empty.
639 const __policy* __policy_;440 const __policy* __policy_;
640441
641public:442 _LIBCPP_HIDE_FROM_ABI static _Rp __empty_func(const __policy_storage*, __fast_forward<_ArgTypes>...) {
642 _LIBCPP_HIDE_FROM_ABI __policy_func() : __policy_(__policy::__create_empty()) {}443 std::__throw_bad_function_call();
643444 }
644 template <class _Fp, class _Alloc>
645 _LIBCPP_HIDE_FROM_ABI __policy_func(_Fp&& __f, const _Alloc& __a) : __policy_(__policy::__create_empty()) {
646 typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun;
647 typedef allocator_traits<_Alloc> __alloc_traits;
648 typedef __rebind_alloc<__alloc_traits, _Fun> _FunAlloc;
649445
650 if (__function::__not_null(__f)) {446 template <class _Fun>
651 __invoker_ = __invoker::template __create<_Fun>();447 _LIBCPP_HIDE_FROM_ABI static _Rp __call_func(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) {
652 __policy_ = __policy::__create<_Fun>();448 _Fun* __func = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large);
653449
654 _FunAlloc __af(__a);450 return std::__invoke_r<_Rp>(*__func, std::forward<_ArgTypes>(__args)...);
655 if (__use_small_storage<_Fun>()) {
656 ::new ((void*)&__buf_.__small) _Fun(std::move(__f), _Alloc(__af));
657 } else {
658 typedef __allocator_destructor<_FunAlloc> _Dp;
659 unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1));
660 ::new ((void*)__hold.get()) _Fun(std::move(__f), _Alloc(__af));
661 __buf_.__large = __hold.release();
662 }
663 }
664 }451 }
665452
453public:
454 _LIBCPP_HIDE_FROM_ABI __policy_func() : __func_(__empty_func), __policy_(__policy::__create_empty()) {}
455
666 template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0>456 template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0>
667 _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) {457 _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) {
668 typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun;
669
670 if (__function::__not_null(__f)) {458 if (__function::__not_null(__f)) {
671 __invoker_ = __invoker::template __create<_Fun>();459 __func_ = __call_func<_Fp>;
672 __policy_ = __policy::__create<_Fun>();460 __policy_ = __policy::__create<_Fp>();
673 if (__use_small_storage<_Fun>()) {461 if (__use_small_storage<_Fp>()) {
674 ::new ((void*)&__buf_.__small) _Fun(std::move(__f));462 ::new ((void*)&__buf_.__small) _Fp(std::move(__f));
675 } else {463 } else {
676 unique_ptr<_Fun, __deallocating_deleter<_Fun>> __hold(std::__libcpp_allocate<_Fun>(__element_count(1)));464 __buf_.__large = ::new _Fp(std::move(__f));
677 __buf_.__large = ::new ((void*)__hold.get()) _Fun(std::move(__f));
678 (void)__hold.release();
679 }465 }
680 }466 }
681 }467 }
682468
683 _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f)469 _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f)
684 : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) {470 : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) {
685 if (__policy_->__clone)471 if (__policy_->__clone)
686 __buf_.__large = __policy_->__clone(__f.__buf_.__large);472 __buf_.__large = __policy_->__clone(__f.__buf_.__large);
687 }473 }
688474
689 _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f)475 _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f)
690 : __buf_(__f.__buf_), __invoker_(__f.__invoker_), __policy_(__f.__policy_) {476 : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) {
691 if (__policy_->__destroy) {477 if (__policy_->__destroy) {
692 __f.__policy_ = __policy::__create_empty();478 __f.__policy_ = __policy::__create_empty();
693 __f.__invoker_ = __invoker();479 __f.__func_ = {};
694 }480 }
695 }481 }
696482
...@@ -700,30 +486,30 @@ public:...@@ -700,30 +486,30 @@ public:
700 }486 }
701487
702 _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) {488 _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) {
703 *this = nullptr;489 *this = nullptr;
704 __buf_ = __f.__buf_;490 __buf_ = __f.__buf_;
705 __invoker_ = __f.__invoker_;491 __func_ = __f.__func_;
706 __policy_ = __f.__policy_;492 __policy_ = __f.__policy_;
707 __f.__policy_ = __policy::__create_empty();493 __f.__policy_ = __policy::__create_empty();
708 __f.__invoker_ = __invoker();494 __f.__func_ = {};
709 return *this;495 return *this;
710 }496 }
711497
712 _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) {498 _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) {
713 const __policy* __p = __policy_;499 const __policy* __p = __policy_;
714 __policy_ = __policy::__create_empty();500 __policy_ = __policy::__create_empty();
715 __invoker_ = __invoker();501 __func_ = {};
716 if (__p->__destroy)502 if (__p->__destroy)
717 __p->__destroy(__buf_.__large);503 __p->__destroy(__buf_.__large);
718 return *this;504 return *this;
719 }505 }
720506
721 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {507 _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {
722 return __invoker_.__call_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...);508 return __func_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...);
723 }509 }
724510
725 _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) {511 _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) {
726 std::swap(__invoker_, __f.__invoker_);512 std::swap(__func_, __f.__func_);
727 std::swap(__policy_, __f.__policy_);513 std::swap(__policy_, __f.__policy_);
728 std::swap(__buf_, __f.__buf_);514 std::swap(__buf_, __f.__buf_);
729 }515 }
...@@ -750,14 +536,14 @@ public:...@@ -750,14 +536,14 @@ public:
750extern "C" void* _Block_copy(const void*);536extern "C" void* _Block_copy(const void*);
751extern "C" void _Block_release(const void*);537extern "C" void _Block_release(const void*);
752538
753template <class _Rp1, class... _ArgTypes1, class _Alloc, class _Rp, class... _ArgTypes>539template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
754class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {540class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
755 typedef _Rp1 (^__block_type)(_ArgTypes1...);541 typedef _Rp1 (^__block_type)(_ArgTypes1...);
756 __block_type __f_;542 __block_type __f_;
757543
758public:544public:
759 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)545 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)
760# if _LIBCPP_HAS_OBJC_ARC546# if __has_feature(objc_arc)
761 : __f_(__f)547 : __f_(__f)
762# else548# else
763 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))549 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
...@@ -767,15 +553,6 @@ public:...@@ -767,15 +553,6 @@ public:
767553
768 // [TODO] add && to save on a retain554 // [TODO] add && to save on a retain
769555
770 _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */)
771# if _LIBCPP_HAS_OBJC_ARC
772 : __f_(__f)
773# else
774 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
775# endif
776 {
777 }
778
779 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const {556 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const {
780 _LIBCPP_ASSERT_INTERNAL(557 _LIBCPP_ASSERT_INTERNAL(
781 false,558 false,
...@@ -790,7 +567,7 @@ public:...@@ -790,7 +567,7 @@ public:
790 }567 }
791568
792 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {569 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
793# if !_LIBCPP_HAS_OBJC_ARC570# if !__has_feature(objc_arc)
794 if (__f_)571 if (__f_)
795 _Block_release(__f_);572 _Block_release(__f_);
796# endif573# endif
...@@ -822,12 +599,12 @@ public:...@@ -822,12 +599,12 @@ public:
822# endif // _LIBCPP_HAS_RTTI599# endif // _LIBCPP_HAS_RTTI
823};600};
824601
825# endif // _LIBCPP_HAS_EXTENSION_BLOCKS602# endif // _LIBCPP_HAS_BLOCKS_RUNTIME
826603
827} // namespace __function604} // namespace __function
828605
829template <class _Rp, class... _ArgTypes>606template <class _Rp, class... _ArgTypes>
830class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>607class function<_Rp(_ArgTypes...)>
831 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,608 : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
832 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> {609 public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> {
833# ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION610# ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
...@@ -954,7 +731,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {}...@@ -954,7 +731,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {}
954# if _LIBCPP_STD_VER <= 14731# if _LIBCPP_STD_VER <= 14
955template <class _Rp, class... _ArgTypes>732template <class _Rp, class... _ArgTypes>
956template <class _Fp, class _Alloc, class>733template <class _Fp, class _Alloc, class>
957function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, _Fp __f) : __f_(std::move(__f), __a) {}734function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, _Fp __f) : __f_(std::move(__f)) {}
958# endif735# endif
959736
960template <class _Rp, class... _ArgTypes>737template <class _Rp, class... _ArgTypes>
lib/libcxx/include/__functional/hash.h+44-126
...@@ -13,11 +13,14 @@...@@ -13,11 +13,14 @@
13#include <__cstddef/nullptr_t.h>13#include <__cstddef/nullptr_t.h>
14#include <__functional/unary_function.h>14#include <__functional/unary_function.h>
15#include <__fwd/functional.h>15#include <__fwd/functional.h>
16#include <__memory/addressof.h>
16#include <__type_traits/conjunction.h>17#include <__type_traits/conjunction.h>
17#include <__type_traits/enable_if.h>18#include <__type_traits/enable_if.h>
18#include <__type_traits/invoke.h>19#include <__type_traits/invoke.h>
19#include <__type_traits/is_constructible.h>20#include <__type_traits/is_constructible.h>
20#include <__type_traits/is_enum.h>21#include <__type_traits/is_enum.h>
22#include <__type_traits/is_floating_point.h>
23#include <__type_traits/is_integral.h>
21#include <__type_traits/underlying_type.h>24#include <__type_traits/underlying_type.h>
22#include <__utility/pair.h>25#include <__utility/pair.h>
23#include <__utility/swap.h>26#include <__utility/swap.h>
...@@ -33,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -33,7 +36,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
33template <class _Size>36template <class _Size>
34inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) {37inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) {
35 _Size __r;38 _Size __r;
36 std::memcpy(&__r, __p, sizeof(__r));39 std::memcpy(std::addressof(__r), __p, sizeof(__r));
37 return __r;40 return __r;
38}41}
3942
...@@ -63,10 +66,10 @@ struct __murmur2_or_cityhash<_Size, 32> {...@@ -63,10 +66,10 @@ struct __murmur2_or_cityhash<_Size, 32> {
63 switch (__len) {66 switch (__len) {
64 case 3:67 case 3:
65 __h ^= static_cast<_Size>(__data[2] << 16);68 __h ^= static_cast<_Size>(__data[2] << 16);
66 _LIBCPP_FALLTHROUGH();69 [[__fallthrough__]];
67 case 2:70 case 2:
68 __h ^= static_cast<_Size>(__data[1] << 8);71 __h ^= static_cast<_Size>(__data[1] << 8);
69 _LIBCPP_FALLTHROUGH();72 [[__fallthrough__]];
70 case 1:73 case 1:
71 __h ^= __data[0];74 __h ^= __data[0];
72 __h *= __m;75 __h *= __m;
...@@ -237,6 +240,14 @@ private:...@@ -237,6 +240,14 @@ private:
237 }240 }
238};241};
239242
243#if _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY
244[[__gnu__::__pure__]] _LIBCPP_EXPORTED_FROM_ABI size_t __hash_memory(_LIBCPP_NOESCAPE const void*, size_t) _NOEXCEPT;
245#else
246_LIBCPP_HIDE_FROM_ABI inline size_t __hash_memory(const void* __ptr, size_t __size) _NOEXCEPT {
247 return __murmur2_or_cityhash<size_t>()(__ptr, __size);
248}
249#endif
250
240template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>251template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
241struct __scalar_hash;252struct __scalar_hash;
242253
...@@ -276,7 +287,7 @@ struct __scalar_hash<_Tp, 2> : public __unary_function<_Tp, size_t> {...@@ -276,7 +287,7 @@ struct __scalar_hash<_Tp, 2> : public __unary_function<_Tp, size_t> {
276 } __s;287 } __s;
277 } __u;288 } __u;
278 __u.__t = __v;289 __u.__t = __v;
279 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));290 return std::__hash_memory(std::addressof(__u), sizeof(__u));
280 }291 }
281};292};
282293
...@@ -292,7 +303,7 @@ struct __scalar_hash<_Tp, 3> : public __unary_function<_Tp, size_t> {...@@ -292,7 +303,7 @@ struct __scalar_hash<_Tp, 3> : public __unary_function<_Tp, size_t> {
292 } __s;303 } __s;
293 } __u;304 } __u;
294 __u.__t = __v;305 __u.__t = __v;
295 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));306 return std::__hash_memory(std::addressof(__u), sizeof(__u));
296 }307 }
297};308};
298309
...@@ -309,7 +320,7 @@ struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> {...@@ -309,7 +320,7 @@ struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> {
309 } __s;320 } __s;
310 } __u;321 } __u;
311 __u.__t = __v;322 __u.__t = __v;
312 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));323 return std::__hash_memory(std::addressof(__u), sizeof(__u));
313 }324 }
314};325};
315326
...@@ -325,133 +336,54 @@ _LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _...@@ -325,133 +336,54 @@ _LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _
325}336}
326337
327template <class _Tp>338template <class _Tp>
328struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> : public __unary_function<_Tp*, size_t> {339struct hash<_Tp*> : public __unary_function<_Tp*, size_t> {
329 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp* __v) const _NOEXCEPT {340 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp* __v) const _NOEXCEPT {
330 union {341 union {
331 _Tp* __t;342 _Tp* __t;
332 size_t __a;343 size_t __a;
333 } __u;344 } __u;
334 __u.__t = __v;345 __u.__t = __v;
335 return __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));346 return std::__hash_memory(std::addressof(__u), sizeof(__u));
336 }347 }
337};348};
338349
339template <>350template <class _Tp, class = void>
340struct _LIBCPP_TEMPLATE_VIS hash<bool> : public __unary_function<bool, size_t> {351struct __hash_impl {
341 _LIBCPP_HIDE_FROM_ABI size_t operator()(bool __v) const _NOEXCEPT { return static_cast<size_t>(__v); }352 __hash_impl() = delete;
342};353 __hash_impl(__hash_impl const&) = delete;
343354 __hash_impl& operator=(__hash_impl const&) = delete;
344template <>
345struct _LIBCPP_TEMPLATE_VIS hash<char> : public __unary_function<char, size_t> {
346 _LIBCPP_HIDE_FROM_ABI size_t operator()(char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
347};355};
348356
349template <>357template <class _Tp>
350struct _LIBCPP_TEMPLATE_VIS hash<signed char> : public __unary_function<signed char, size_t> {358struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value> > : __unary_function<_Tp, size_t> {
351 _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }359 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
352};360 using type = __underlying_type_t<_Tp>;
353361 return hash<type>()(static_cast<type>(__v));
354template <>
355struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsigned char, size_t> {
356 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
357};
358
359#if _LIBCPP_HAS_CHAR8_T
360template <>
361struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> {
362 _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
363};
364#endif // _LIBCPP_HAS_CHAR8_T
365
366template <>
367struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> {
368 _LIBCPP_HIDE_FROM_ABI size_t operator()(char16_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
369};
370
371template <>
372struct _LIBCPP_TEMPLATE_VIS hash<char32_t> : public __unary_function<char32_t, size_t> {
373 _LIBCPP_HIDE_FROM_ABI size_t operator()(char32_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
374};
375
376#if _LIBCPP_HAS_WIDE_CHARACTERS
377template <>
378struct _LIBCPP_TEMPLATE_VIS hash<wchar_t> : public __unary_function<wchar_t, size_t> {
379 _LIBCPP_HIDE_FROM_ABI size_t operator()(wchar_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
380};
381#endif // _LIBCPP_HAS_WIDE_CHARACTERS
382
383template <>
384struct _LIBCPP_TEMPLATE_VIS hash<short> : public __unary_function<short, size_t> {
385 _LIBCPP_HIDE_FROM_ABI size_t operator()(short __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
386};
387
388template <>
389struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public __unary_function<unsigned short, size_t> {
390 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
391};
392
393template <>
394struct _LIBCPP_TEMPLATE_VIS hash<int> : public __unary_function<int, size_t> {
395 _LIBCPP_HIDE_FROM_ABI size_t operator()(int __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
396};
397
398template <>
399struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public __unary_function<unsigned int, size_t> {
400 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
401};
402
403template <>
404struct _LIBCPP_TEMPLATE_VIS hash<long> : public __unary_function<long, size_t> {
405 _LIBCPP_HIDE_FROM_ABI size_t operator()(long __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
406};
407
408template <>
409struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public __unary_function<unsigned long, size_t> {
410 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __v) const _NOEXCEPT {
411 static_assert(sizeof(size_t) >= sizeof(unsigned long),
412 "This would be a terrible hash function on a platform where size_t is smaller than unsigned long");
413 return static_cast<size_t>(__v);
414 }362 }
415};363};
416364
417template <>365template <class _Tp>
418struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {};366struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) <= sizeof(size_t))> >
419367 : __unary_function<_Tp, size_t> {
420template <>368 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
421struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {};369};
422
423#if _LIBCPP_HAS_INT128
424
425template <>
426struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {};
427
428template <>
429struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> : public __scalar_hash<__uint128_t> {};
430370
431#endif371template <class _Tp>
372struct __hash_impl<_Tp, __enable_if_t<is_integral<_Tp>::value && (sizeof(_Tp) > sizeof(size_t))> >
373 : __scalar_hash<_Tp> {};
432374
433template <>375template <class _Tp>
434struct _LIBCPP_TEMPLATE_VIS hash<float> : public __scalar_hash<float> {376struct __hash_impl<_Tp, __enable_if_t<is_floating_point<_Tp>::value> > : __scalar_hash<_Tp> {
435 _LIBCPP_HIDE_FROM_ABI size_t operator()(float __v) const _NOEXCEPT {377 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
436 // -0.0 and 0.0 should return same hash378 // -0.0 and 0.0 should return same hash
437 if (__v == 0.0f)379 if (__v == 0.0f)
438 return 0;380 return 0;
439 return __scalar_hash<float>::operator()(__v);381 return __scalar_hash<_Tp>::operator()(__v);
440 }
441};
442
443template <>
444struct _LIBCPP_TEMPLATE_VIS hash<double> : public __scalar_hash<double> {
445 _LIBCPP_HIDE_FROM_ABI size_t operator()(double __v) const _NOEXCEPT {
446 // -0.0 and 0.0 should return same hash
447 if (__v == 0.0)
448 return 0;
449 return __scalar_hash<double>::operator()(__v);
450 }382 }
451};383};
452384
453template <>385template <>
454struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double> {386struct __hash_impl<long double> : __scalar_hash<long double> {
455 _LIBCPP_HIDE_FROM_ABI size_t operator()(long double __v) const _NOEXCEPT {387 _LIBCPP_HIDE_FROM_ABI size_t operator()(long double __v) const _NOEXCEPT {
456 // -0.0 and 0.0 should return same hash388 // -0.0 and 0.0 should return same hash
457 if (__v == 0.0L)389 if (__v == 0.0L)
...@@ -492,27 +424,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double...@@ -492,27 +424,13 @@ struct _LIBCPP_TEMPLATE_VIS hash<long double> : public __scalar_hash<long double
492 }424 }
493};425};
494426
495template <class _Tp, bool = is_enum<_Tp>::value>
496struct _LIBCPP_TEMPLATE_VIS __enum_hash : public __unary_function<_Tp, size_t> {
497 _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
498 typedef typename underlying_type<_Tp>::type type;
499 return hash<type>()(static_cast<type>(__v));
500 }
501};
502template <class _Tp>
503struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
504 __enum_hash() = delete;
505 __enum_hash(__enum_hash const&) = delete;
506 __enum_hash& operator=(__enum_hash const&) = delete;
507};
508
509template <class _Tp>427template <class _Tp>
510struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> {};428struct hash : public __hash_impl<_Tp> {};
511429
512#if _LIBCPP_STD_VER >= 17430#if _LIBCPP_STD_VER >= 17
513431
514template <>432template <>
515struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {433struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {
516 _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }434 _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }
517};435};
518#endif436#endif
lib/libcxx/include/__functional/mem_fun_ref.h+8-9
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)23#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2424
25template <class _Sp, class _Tp>25template <class _Sp, class _Tp>
26class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {26class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {
27 _Sp (_Tp::*__p_)();27 _Sp (_Tp::*__p_)();
2828
29public:29public:
...@@ -32,7 +32,7 @@ public:...@@ -32,7 +32,7 @@ public:
32};32};
3333
34template <class _Sp, class _Tp, class _Ap>34template <class _Sp, class _Tp, class _Ap>
35class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> {35class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> {
36 _Sp (_Tp::*__p_)(_Ap);36 _Sp (_Tp::*__p_)(_Ap);
3737
38public:38public:
...@@ -51,7 +51,7 @@ _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_t<_Sp, _Tp, _A...@@ -51,7 +51,7 @@ _LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_t<_Sp, _Tp, _A
51}51}
5252
53template <class _Sp, class _Tp>53template <class _Sp, class _Tp>
54class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> {54class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
55 _Sp (_Tp::*__p_)();55 _Sp (_Tp::*__p_)();
5656
57public:57public:
...@@ -60,7 +60,7 @@ public:...@@ -60,7 +60,7 @@ public:
60};60};
6161
62template <class _Sp, class _Tp, class _Ap>62template <class _Sp, class _Tp, class _Ap>
63class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {63class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {
64 _Sp (_Tp::*__p_)(_Ap);64 _Sp (_Tp::*__p_)(_Ap);
6565
66public:66public:
...@@ -80,7 +80,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {...@@ -80,7 +80,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {
80}80}
8181
82template <class _Sp, class _Tp>82template <class _Sp, class _Tp>
83class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> {83class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> {
84 _Sp (_Tp::*__p_)() const;84 _Sp (_Tp::*__p_)() const;
8585
86public:86public:
...@@ -89,8 +89,7 @@ public:...@@ -89,8 +89,7 @@ public:
89};89};
9090
91template <class _Sp, class _Tp, class _Ap>91template <class _Sp, class _Tp, class _Ap>
92class _LIBCPP_TEMPLATE_VIS92class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> {
93_LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> {
94 _Sp (_Tp::*__p_)(_Ap) const;93 _Sp (_Tp::*__p_)(_Ap) const;
9594
96public:95public:
...@@ -110,7 +109,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) {...@@ -110,7 +109,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) {
110}109}
111110
112template <class _Sp, class _Tp>111template <class _Sp, class _Tp>
113class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> {112class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
114 _Sp (_Tp::*__p_)() const;113 _Sp (_Tp::*__p_)() const;
115114
116public:115public:
...@@ -119,7 +118,7 @@ public:...@@ -119,7 +118,7 @@ public:
119};118};
120119
121template <class _Sp, class _Tp, class _Ap>120template <class _Sp, class _Tp, class _Ap>
122class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {121class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {
123 _Sp (_Tp::*__p_)(_Ap) const;122 _Sp (_Tp::*__p_)(_Ap) const;
124123
125public:124public:
lib/libcxx/include/__functional/operations.h+39-42
...@@ -13,6 +13,7 @@...@@ -13,6 +13,7 @@
13#include <__config>13#include <__config>
14#include <__functional/binary_function.h>14#include <__functional/binary_function.h>
15#include <__functional/unary_function.h>15#include <__functional/unary_function.h>
16#include <__fwd/functional.h>
16#include <__type_traits/desugars_to.h>17#include <__type_traits/desugars_to.h>
17#include <__type_traits/is_integral.h>18#include <__type_traits/is_integral.h>
18#include <__utility/forward.h>19#include <__utility/forward.h>
...@@ -30,7 +31,7 @@ template <class _Tp = void>...@@ -30,7 +31,7 @@ template <class _Tp = void>
30#else31#else
31template <class _Tp>32template <class _Tp>
32#endif33#endif
33struct _LIBCPP_TEMPLATE_VIS plus : __binary_function<_Tp, _Tp, _Tp> {34struct plus : __binary_function<_Tp, _Tp, _Tp> {
34 typedef _Tp __result_type; // used by valarray35 typedef _Tp __result_type; // used by valarray
35 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {36 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
36 return __x + __y;37 return __x + __y;
...@@ -48,7 +49,7 @@ inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;...@@ -48,7 +49,7 @@ inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;
4849
49#if _LIBCPP_STD_VER >= 1450#if _LIBCPP_STD_VER >= 14
50template <>51template <>
51struct _LIBCPP_TEMPLATE_VIS plus<void> {52struct plus<void> {
52 template <class _T1, class _T2>53 template <class _T1, class _T2>
53 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const54 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
54 noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //55 noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //
...@@ -64,7 +65,7 @@ template <class _Tp = void>...@@ -64,7 +65,7 @@ template <class _Tp = void>
64#else65#else
65template <class _Tp>66template <class _Tp>
66#endif67#endif
67struct _LIBCPP_TEMPLATE_VIS minus : __binary_function<_Tp, _Tp, _Tp> {68struct minus : __binary_function<_Tp, _Tp, _Tp> {
68 typedef _Tp __result_type; // used by valarray69 typedef _Tp __result_type; // used by valarray
69 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {70 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
70 return __x - __y;71 return __x - __y;
...@@ -74,7 +75,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);...@@ -74,7 +75,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
7475
75#if _LIBCPP_STD_VER >= 1476#if _LIBCPP_STD_VER >= 14
76template <>77template <>
77struct _LIBCPP_TEMPLATE_VIS minus<void> {78struct minus<void> {
78 template <class _T1, class _T2>79 template <class _T1, class _T2>
79 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const80 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
80 noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //81 noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //
...@@ -90,7 +91,7 @@ template <class _Tp = void>...@@ -90,7 +91,7 @@ template <class _Tp = void>
90#else91#else
91template <class _Tp>92template <class _Tp>
92#endif93#endif
93struct _LIBCPP_TEMPLATE_VIS multiplies : __binary_function<_Tp, _Tp, _Tp> {94struct multiplies : __binary_function<_Tp, _Tp, _Tp> {
94 typedef _Tp __result_type; // used by valarray95 typedef _Tp __result_type; // used by valarray
95 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {96 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
96 return __x * __y;97 return __x * __y;
...@@ -100,7 +101,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);...@@ -100,7 +101,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
100101
101#if _LIBCPP_STD_VER >= 14102#if _LIBCPP_STD_VER >= 14
102template <>103template <>
103struct _LIBCPP_TEMPLATE_VIS multiplies<void> {104struct multiplies<void> {
104 template <class _T1, class _T2>105 template <class _T1, class _T2>
105 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const106 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
106 noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //107 noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //
...@@ -116,7 +117,7 @@ template <class _Tp = void>...@@ -116,7 +117,7 @@ template <class _Tp = void>
116#else117#else
117template <class _Tp>118template <class _Tp>
118#endif119#endif
119struct _LIBCPP_TEMPLATE_VIS divides : __binary_function<_Tp, _Tp, _Tp> {120struct divides : __binary_function<_Tp, _Tp, _Tp> {
120 typedef _Tp __result_type; // used by valarray121 typedef _Tp __result_type; // used by valarray
121 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {122 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
122 return __x / __y;123 return __x / __y;
...@@ -126,7 +127,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);...@@ -126,7 +127,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
126127
127#if _LIBCPP_STD_VER >= 14128#if _LIBCPP_STD_VER >= 14
128template <>129template <>
129struct _LIBCPP_TEMPLATE_VIS divides<void> {130struct divides<void> {
130 template <class _T1, class _T2>131 template <class _T1, class _T2>
131 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const132 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
132 noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //133 noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //
...@@ -142,7 +143,7 @@ template <class _Tp = void>...@@ -142,7 +143,7 @@ template <class _Tp = void>
142#else143#else
143template <class _Tp>144template <class _Tp>
144#endif145#endif
145struct _LIBCPP_TEMPLATE_VIS modulus : __binary_function<_Tp, _Tp, _Tp> {146struct modulus : __binary_function<_Tp, _Tp, _Tp> {
146 typedef _Tp __result_type; // used by valarray147 typedef _Tp __result_type; // used by valarray
147 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {148 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
148 return __x % __y;149 return __x % __y;
...@@ -152,7 +153,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);...@@ -152,7 +153,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
152153
153#if _LIBCPP_STD_VER >= 14154#if _LIBCPP_STD_VER >= 14
154template <>155template <>
155struct _LIBCPP_TEMPLATE_VIS modulus<void> {156struct modulus<void> {
156 template <class _T1, class _T2>157 template <class _T1, class _T2>
157 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const158 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
158 noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //159 noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //
...@@ -168,7 +169,7 @@ template <class _Tp = void>...@@ -168,7 +169,7 @@ template <class _Tp = void>
168#else169#else
169template <class _Tp>170template <class _Tp>
170#endif171#endif
171struct _LIBCPP_TEMPLATE_VIS negate : __unary_function<_Tp, _Tp> {172struct negate : __unary_function<_Tp, _Tp> {
172 typedef _Tp __result_type; // used by valarray173 typedef _Tp __result_type; // used by valarray
173 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; }174 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; }
174};175};
...@@ -176,7 +177,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);...@@ -176,7 +177,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
176177
177#if _LIBCPP_STD_VER >= 14178#if _LIBCPP_STD_VER >= 14
178template <>179template <>
179struct _LIBCPP_TEMPLATE_VIS negate<void> {180struct negate<void> {
180 template <class _Tp>181 template <class _Tp>
181 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const182 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
182 noexcept(noexcept(-std::forward<_Tp>(__x))) //183 noexcept(noexcept(-std::forward<_Tp>(__x))) //
...@@ -194,7 +195,7 @@ template <class _Tp = void>...@@ -194,7 +195,7 @@ template <class _Tp = void>
194#else195#else
195template <class _Tp>196template <class _Tp>
196#endif197#endif
197struct _LIBCPP_TEMPLATE_VIS bit_and : __binary_function<_Tp, _Tp, _Tp> {198struct bit_and : __binary_function<_Tp, _Tp, _Tp> {
198 typedef _Tp __result_type; // used by valarray199 typedef _Tp __result_type; // used by valarray
199 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {200 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
200 return __x & __y;201 return __x & __y;
...@@ -204,7 +205,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);...@@ -204,7 +205,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
204205
205#if _LIBCPP_STD_VER >= 14206#if _LIBCPP_STD_VER >= 14
206template <>207template <>
207struct _LIBCPP_TEMPLATE_VIS bit_and<void> {208struct bit_and<void> {
208 template <class _T1, class _T2>209 template <class _T1, class _T2>
209 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const210 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
210 noexcept(noexcept(std::forward<_T1>(__t) &211 noexcept(noexcept(std::forward<_T1>(__t) &
...@@ -217,13 +218,13 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> {...@@ -217,13 +218,13 @@ struct _LIBCPP_TEMPLATE_VIS bit_and<void> {
217218
218#if _LIBCPP_STD_VER >= 14219#if _LIBCPP_STD_VER >= 14
219template <class _Tp = void>220template <class _Tp = void>
220struct _LIBCPP_TEMPLATE_VIS bit_not : __unary_function<_Tp, _Tp> {221struct bit_not : __unary_function<_Tp, _Tp> {
221 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }222 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
222};223};
223_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);224_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
224225
225template <>226template <>
226struct _LIBCPP_TEMPLATE_VIS bit_not<void> {227struct bit_not<void> {
227 template <class _Tp>228 template <class _Tp>
228 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const229 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
229 noexcept(noexcept(~std::forward<_Tp>(__x))) //230 noexcept(noexcept(~std::forward<_Tp>(__x))) //
...@@ -239,7 +240,7 @@ template <class _Tp = void>...@@ -239,7 +240,7 @@ template <class _Tp = void>
239#else240#else
240template <class _Tp>241template <class _Tp>
241#endif242#endif
242struct _LIBCPP_TEMPLATE_VIS bit_or : __binary_function<_Tp, _Tp, _Tp> {243struct bit_or : __binary_function<_Tp, _Tp, _Tp> {
243 typedef _Tp __result_type; // used by valarray244 typedef _Tp __result_type; // used by valarray
244 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {245 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
245 return __x | __y;246 return __x | __y;
...@@ -249,7 +250,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);...@@ -249,7 +250,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
249250
250#if _LIBCPP_STD_VER >= 14251#if _LIBCPP_STD_VER >= 14
251template <>252template <>
252struct _LIBCPP_TEMPLATE_VIS bit_or<void> {253struct bit_or<void> {
253 template <class _T1, class _T2>254 template <class _T1, class _T2>
254 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const255 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
255 noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //256 noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //
...@@ -265,7 +266,7 @@ template <class _Tp = void>...@@ -265,7 +266,7 @@ template <class _Tp = void>
265#else266#else
266template <class _Tp>267template <class _Tp>
267#endif268#endif
268struct _LIBCPP_TEMPLATE_VIS bit_xor : __binary_function<_Tp, _Tp, _Tp> {269struct bit_xor : __binary_function<_Tp, _Tp, _Tp> {
269 typedef _Tp __result_type; // used by valarray270 typedef _Tp __result_type; // used by valarray
270 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {271 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
271 return __x ^ __y;272 return __x ^ __y;
...@@ -275,7 +276,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);...@@ -275,7 +276,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
275276
276#if _LIBCPP_STD_VER >= 14277#if _LIBCPP_STD_VER >= 14
277template <>278template <>
278struct _LIBCPP_TEMPLATE_VIS bit_xor<void> {279struct bit_xor<void> {
279 template <class _T1, class _T2>280 template <class _T1, class _T2>
280 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const281 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
281 noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //282 noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //
...@@ -293,7 +294,7 @@ template <class _Tp = void>...@@ -293,7 +294,7 @@ template <class _Tp = void>
293#else294#else
294template <class _Tp>295template <class _Tp>
295#endif296#endif
296struct _LIBCPP_TEMPLATE_VIS equal_to : __binary_function<_Tp, _Tp, bool> {297struct equal_to : __binary_function<_Tp, _Tp, bool> {
297 typedef bool __result_type; // used by valarray298 typedef bool __result_type; // used by valarray
298 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {299 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
299 return __x == __y;300 return __x == __y;
...@@ -303,7 +304,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);...@@ -303,7 +304,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
303304
304#if _LIBCPP_STD_VER >= 14305#if _LIBCPP_STD_VER >= 14
305template <>306template <>
306struct _LIBCPP_TEMPLATE_VIS equal_to<void> {307struct equal_to<void> {
307 template <class _T1, class _T2>308 template <class _T1, class _T2>
308 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const309 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
309 noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //310 noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //
...@@ -328,7 +329,7 @@ template <class _Tp = void>...@@ -328,7 +329,7 @@ template <class _Tp = void>
328#else329#else
329template <class _Tp>330template <class _Tp>
330#endif331#endif
331struct _LIBCPP_TEMPLATE_VIS not_equal_to : __binary_function<_Tp, _Tp, bool> {332struct not_equal_to : __binary_function<_Tp, _Tp, bool> {
332 typedef bool __result_type; // used by valarray333 typedef bool __result_type; // used by valarray
333 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {334 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
334 return __x != __y;335 return __x != __y;
...@@ -338,7 +339,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);...@@ -338,7 +339,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
338339
339#if _LIBCPP_STD_VER >= 14340#if _LIBCPP_STD_VER >= 14
340template <>341template <>
341struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {342struct not_equal_to<void> {
342 template <class _T1, class _T2>343 template <class _T1, class _T2>
343 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const344 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
344 noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //345 noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //
...@@ -349,12 +350,8 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {...@@ -349,12 +350,8 @@ struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {
349};350};
350#endif351#endif
351352
352#if _LIBCPP_STD_VER >= 14
353template <class _Tp = void>
354#else
355template <class _Tp>353template <class _Tp>
356#endif354struct less : __binary_function<_Tp, _Tp, bool> {
357struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> {
358 typedef bool __result_type; // used by valarray355 typedef bool __result_type; // used by valarray
359 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {356 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
360 return __x < __y;357 return __x < __y;
...@@ -370,7 +367,7 @@ inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _T...@@ -370,7 +367,7 @@ inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _T
370367
371#if _LIBCPP_STD_VER >= 14368#if _LIBCPP_STD_VER >= 14
372template <>369template <>
373struct _LIBCPP_TEMPLATE_VIS less<void> {370struct less<void> {
374 template <class _T1, class _T2>371 template <class _T1, class _T2>
375 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const372 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
376 noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //373 noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //
...@@ -392,7 +389,7 @@ template <class _Tp = void>...@@ -392,7 +389,7 @@ template <class _Tp = void>
392#else389#else
393template <class _Tp>390template <class _Tp>
394#endif391#endif
395struct _LIBCPP_TEMPLATE_VIS less_equal : __binary_function<_Tp, _Tp, bool> {392struct less_equal : __binary_function<_Tp, _Tp, bool> {
396 typedef bool __result_type; // used by valarray393 typedef bool __result_type; // used by valarray
397 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {394 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
398 return __x <= __y;395 return __x <= __y;
...@@ -402,7 +399,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);...@@ -402,7 +399,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
402399
403#if _LIBCPP_STD_VER >= 14400#if _LIBCPP_STD_VER >= 14
404template <>401template <>
405struct _LIBCPP_TEMPLATE_VIS less_equal<void> {402struct less_equal<void> {
406 template <class _T1, class _T2>403 template <class _T1, class _T2>
407 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const404 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
408 noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //405 noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //
...@@ -418,7 +415,7 @@ template <class _Tp = void>...@@ -418,7 +415,7 @@ template <class _Tp = void>
418#else415#else
419template <class _Tp>416template <class _Tp>
420#endif417#endif
421struct _LIBCPP_TEMPLATE_VIS greater_equal : __binary_function<_Tp, _Tp, bool> {418struct greater_equal : __binary_function<_Tp, _Tp, bool> {
422 typedef bool __result_type; // used by valarray419 typedef bool __result_type; // used by valarray
423 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {420 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
424 return __x >= __y;421 return __x >= __y;
...@@ -428,7 +425,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);...@@ -428,7 +425,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
428425
429#if _LIBCPP_STD_VER >= 14426#if _LIBCPP_STD_VER >= 14
430template <>427template <>
431struct _LIBCPP_TEMPLATE_VIS greater_equal<void> {428struct greater_equal<void> {
432 template <class _T1, class _T2>429 template <class _T1, class _T2>
433 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const430 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
434 noexcept(noexcept(std::forward<_T1>(__t) >=431 noexcept(noexcept(std::forward<_T1>(__t) >=
...@@ -444,7 +441,7 @@ template <class _Tp = void>...@@ -444,7 +441,7 @@ template <class _Tp = void>
444#else441#else
445template <class _Tp>442template <class _Tp>
446#endif443#endif
447struct _LIBCPP_TEMPLATE_VIS greater : __binary_function<_Tp, _Tp, bool> {444struct greater : __binary_function<_Tp, _Tp, bool> {
448 typedef bool __result_type; // used by valarray445 typedef bool __result_type; // used by valarray
449 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {446 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
450 return __x > __y;447 return __x > __y;
...@@ -457,7 +454,7 @@ inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true;...@@ -457,7 +454,7 @@ inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true;
457454
458#if _LIBCPP_STD_VER >= 14455#if _LIBCPP_STD_VER >= 14
459template <>456template <>
460struct _LIBCPP_TEMPLATE_VIS greater<void> {457struct greater<void> {
461 template <class _T1, class _T2>458 template <class _T1, class _T2>
462 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const459 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
463 noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //460 noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //
...@@ -478,7 +475,7 @@ template <class _Tp = void>...@@ -478,7 +475,7 @@ template <class _Tp = void>
478#else475#else
479template <class _Tp>476template <class _Tp>
480#endif477#endif
481struct _LIBCPP_TEMPLATE_VIS logical_and : __binary_function<_Tp, _Tp, bool> {478struct logical_and : __binary_function<_Tp, _Tp, bool> {
482 typedef bool __result_type; // used by valarray479 typedef bool __result_type; // used by valarray
483 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {480 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
484 return __x && __y;481 return __x && __y;
...@@ -488,7 +485,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);...@@ -488,7 +485,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
488485
489#if _LIBCPP_STD_VER >= 14486#if _LIBCPP_STD_VER >= 14
490template <>487template <>
491struct _LIBCPP_TEMPLATE_VIS logical_and<void> {488struct logical_and<void> {
492 template <class _T1, class _T2>489 template <class _T1, class _T2>
493 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const490 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
494 noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //491 noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //
...@@ -504,7 +501,7 @@ template <class _Tp = void>...@@ -504,7 +501,7 @@ template <class _Tp = void>
504#else501#else
505template <class _Tp>502template <class _Tp>
506#endif503#endif
507struct _LIBCPP_TEMPLATE_VIS logical_not : __unary_function<_Tp, bool> {504struct logical_not : __unary_function<_Tp, bool> {
508 typedef bool __result_type; // used by valarray505 typedef bool __result_type; // used by valarray
509 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; }506 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; }
510};507};
...@@ -512,7 +509,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);...@@ -512,7 +509,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
512509
513#if _LIBCPP_STD_VER >= 14510#if _LIBCPP_STD_VER >= 14
514template <>511template <>
515struct _LIBCPP_TEMPLATE_VIS logical_not<void> {512struct logical_not<void> {
516 template <class _Tp>513 template <class _Tp>
517 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const514 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
518 noexcept(noexcept(!std::forward<_Tp>(__x))) //515 noexcept(noexcept(!std::forward<_Tp>(__x))) //
...@@ -528,7 +525,7 @@ template <class _Tp = void>...@@ -528,7 +525,7 @@ template <class _Tp = void>
528#else525#else
529template <class _Tp>526template <class _Tp>
530#endif527#endif
531struct _LIBCPP_TEMPLATE_VIS logical_or : __binary_function<_Tp, _Tp, bool> {528struct logical_or : __binary_function<_Tp, _Tp, bool> {
532 typedef bool __result_type; // used by valarray529 typedef bool __result_type; // used by valarray
533 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {530 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
534 return __x || __y;531 return __x || __y;
...@@ -538,7 +535,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);...@@ -538,7 +535,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
538535
539#if _LIBCPP_STD_VER >= 14536#if _LIBCPP_STD_VER >= 14
540template <>537template <>
541struct _LIBCPP_TEMPLATE_VIS logical_or<void> {538struct logical_or<void> {
542 template <class _T1, class _T2>539 template <class _T1, class _T2>
543 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const540 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
544 noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //541 noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //
lib/libcxx/include/__functional/pointer_to_binary_function.h+1-2
...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
24template <class _Arg1, class _Arg2, class _Result>24template <class _Arg1, class _Arg2, class _Result>
25class _LIBCPP_TEMPLATE_VIS25class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> {
26_LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> {
27 _Result (*__f_)(_Arg1, _Arg2);26 _Result (*__f_)(_Arg1, _Arg2);
2827
29public:28public:
lib/libcxx/include/__functional/pointer_to_unary_function.h+1-2
...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)22#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
24template <class _Arg, class _Result>24template <class _Arg, class _Result>
25class _LIBCPP_TEMPLATE_VIS25class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
26_LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
27 _Result (*__f_)(_Arg);26 _Result (*__f_)(_Arg);
2827
29public:28public:
lib/libcxx/include/__functional/reference_wrapper.h+42-6
...@@ -11,13 +11,18 @@...@@ -11,13 +11,18 @@
11#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H11#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1212
13#include <__compare/synth_three_way.h>13#include <__compare/synth_three_way.h>
14#include <__concepts/boolean_testable.h>14#include <__concepts/convertible_to.h>
15#include <__config>15#include <__config>
16#include <__functional/weak_result_type.h>16#include <__functional/weak_result_type.h>
17#include <__memory/addressof.h>17#include <__memory/addressof.h>
18#include <__type_traits/common_reference.h>
19#include <__type_traits/desugars_to.h>
18#include <__type_traits/enable_if.h>20#include <__type_traits/enable_if.h>
19#include <__type_traits/invoke.h>21#include <__type_traits/invoke.h>
20#include <__type_traits/is_const.h>22#include <__type_traits/is_const.h>
23#include <__type_traits/is_core_convertible.h>
24#include <__type_traits/is_same.h>
25#include <__type_traits/is_specialization.h>
21#include <__type_traits/remove_cvref.h>26#include <__type_traits/remove_cvref.h>
22#include <__type_traits/void_t.h>27#include <__type_traits/void_t.h>
23#include <__utility/declval.h>28#include <__utility/declval.h>
...@@ -30,7 +35,7 @@...@@ -30,7 +35,7 @@
30_LIBCPP_BEGIN_NAMESPACE_STD35_LIBCPP_BEGIN_NAMESPACE_STD
3136
32template <class _Tp>37template <class _Tp>
33class _LIBCPP_TEMPLATE_VIS reference_wrapper : public __weak_result_type<_Tp> {38class reference_wrapper : public __weak_result_type<_Tp> {
34public:39public:
35 // types40 // types
36 typedef _Tp type;41 typedef _Tp type;
...@@ -44,7 +49,7 @@ private:...@@ -44,7 +49,7 @@ private:
44public:49public:
45 template <class _Up,50 template <class _Up,
46 class = __void_t<decltype(__fun(std::declval<_Up>()))>,51 class = __void_t<decltype(__fun(std::declval<_Up>()))>,
47 __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, int> = 0>52 __enable_if_t<!is_same<__remove_cvref_t<_Up>, reference_wrapper>::value, int> = 0>
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u)53 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u)
49 _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {54 _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
50 type& __f = static_cast<_Up&&>(__u);55 type& __f = static_cast<_Up&&>(__u);
...@@ -74,7 +79,7 @@ public:...@@ -74,7 +79,7 @@ public:
7479
75 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)80 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
76 requires requires {81 requires requires {
77 { __x.get() == __y.get() } -> __boolean_testable;82 { __x.get() == __y.get() } -> __core_convertible_to<bool>;
78 }83 }
79 {84 {
80 return __x.get() == __y.get();85 return __x.get() == __y.get();
...@@ -82,7 +87,7 @@ public:...@@ -82,7 +87,7 @@ public:
8287
83 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)88 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
84 requires requires {89 requires requires {
85 { __x.get() == __y } -> __boolean_testable;90 { __x.get() == __y } -> __core_convertible_to<bool>;
86 }91 }
87 {92 {
88 return __x.get() == __y;93 return __x.get() == __y;
...@@ -90,7 +95,7 @@ public:...@@ -90,7 +95,7 @@ public:
9095
91 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)96 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
92 requires(!is_const_v<_Tp>) && requires {97 requires(!is_const_v<_Tp>) && requires {
93 { __x.get() == __y.get() } -> __boolean_testable;98 { __x.get() == __y.get() } -> __core_convertible_to<bool>;
94 }99 }
95 {100 {
96 return __x.get() == __y.get();101 return __x.get() == __y.get();
...@@ -149,6 +154,37 @@ void ref(const _Tp&&) = delete;...@@ -149,6 +154,37 @@ void ref(const _Tp&&) = delete;
149template <class _Tp>154template <class _Tp>
150void cref(const _Tp&&) = delete;155void cref(const _Tp&&) = delete;
151156
157// Let desugars-to pass through std::reference_wrapper
158template <class _CanonicalTag, class _Operation, class... _Args>
159inline const bool __desugars_to_v<_CanonicalTag, reference_wrapper<_Operation>, _Args...> =
160 __desugars_to_v<_CanonicalTag, _Operation, _Args...>;
161
162#if _LIBCPP_STD_VER >= 20
163
164template <class _Tp>
165inline constexpr bool __is_ref_wrapper = __is_specialization_v<_Tp, reference_wrapper>;
166
167template <class _Rp, class _Tp, class _RpQual, class _TpQual>
168concept __ref_wrap_common_reference_exists_with = __is_ref_wrapper<_Rp> && requires {
169 typename common_reference_t<typename _Rp::type&, _TpQual>;
170} && convertible_to<_RpQual, common_reference_t<typename _Rp::type&, _TpQual>>;
171
172template <class _Rp, class _Tp, template <class> class _RpQual, template <class> class _TpQual>
173 requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
174 !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
175struct basic_common_reference<_Rp, _Tp, _RpQual, _TpQual> {
176 using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
177};
178
179template <class _Tp, class _Rp, template <class> class _TpQual, template <class> class _RpQual>
180 requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
181 !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
182struct basic_common_reference<_Tp, _Rp, _TpQual, _RpQual> {
183 using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
184};
185
186#endif // _LIBCPP_STD_VER >= 20
187
152_LIBCPP_END_NAMESPACE_STD188_LIBCPP_END_NAMESPACE_STD
153189
154#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H190#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
lib/libcxx/include/__functional/unary_function.h+3-4
...@@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
20#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)20#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
2121
22template <class _Arg, class _Result>22template <class _Arg, class _Result>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 unary_function {23struct _LIBCPP_DEPRECATED_IN_CXX11 unary_function {
24 typedef _Arg argument_type;24 typedef _Arg argument_type;
25 typedef _Result result_type;25 typedef _Result result_type;
26};26};
...@@ -36,11 +36,10 @@ struct __unary_function_keep_layout_base {...@@ -36,11 +36,10 @@ struct __unary_function_keep_layout_base {
36};36};
3737
38#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)38#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
39_LIBCPP_DIAGNOSTIC_PUSH39_LIBCPP_SUPPRESS_DEPRECATED_PUSH
40_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
41template <class _Arg, class _Result>40template <class _Arg, class _Result>
42using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>;41using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>;
43_LIBCPP_DIAGNOSTIC_POP42_LIBCPP_SUPPRESS_DEPRECATED_POP
44#else43#else
45template <class _Arg, class _Result>44template <class _Arg, class _Result>
46using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>;45using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>;
lib/libcxx/include/__functional/unary_negate.h+1-2
...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)22#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
2323
24template <class _Predicate>24template <class _Predicate>
25class _LIBCPP_TEMPLATE_VIS25class _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
26_LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
27 _Predicate __pred_;26 _Predicate __pred_;
2827
29public:28public:
lib/libcxx/include/__functional/weak_result_type.h+2
...@@ -77,6 +77,7 @@ struct __maybe_derive_from_unary_function // bool is true...@@ -77,6 +77,7 @@ struct __maybe_derive_from_unary_function // bool is true
77template <class _Tp>77template <class _Tp>
78struct __maybe_derive_from_unary_function<_Tp, false> {};78struct __maybe_derive_from_unary_function<_Tp, false> {};
7979
80_LIBCPP_SUPPRESS_DEPRECATED_PUSH
80template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>81template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
81struct __maybe_derive_from_binary_function // bool is true82struct __maybe_derive_from_binary_function // bool is true
82 : public __derives_from_binary_function<_Tp>::type {};83 : public __derives_from_binary_function<_Tp>::type {};
...@@ -99,6 +100,7 @@ struct __weak_result_type_imp<_Tp, false>...@@ -99,6 +100,7 @@ struct __weak_result_type_imp<_Tp, false>
99100
100template <class _Tp>101template <class _Tp>
101struct __weak_result_type : public __weak_result_type_imp<_Tp> {};102struct __weak_result_type : public __weak_result_type_imp<_Tp> {};
103_LIBCPP_SUPPRESS_DEPRECATED_POP
102104
103// 0 argument case105// 0 argument case
104106
lib/libcxx/include/__fwd/array.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp, size_t _Size>22template <class _Tp, size_t _Size>
23struct _LIBCPP_TEMPLATE_VIS array;23struct array;
2424
25template <size_t _Ip, class _Tp, size_t _Size>25template <size_t _Ip, class _Tp, size_t _Size>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT;26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT;
lib/libcxx/include/__fwd/bit_reference.h+16
...@@ -20,9 +20,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,9 +20,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD
20template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>20template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
21class __bit_iterator;21class __bit_iterator;
2222
23template <class _Cp>
24struct __bit_array;
25
23template <class, class = void>26template <class, class = void>
24struct __size_difference_type_traits;27struct __size_difference_type_traits;
2528
29template <class _StoragePointer>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
31__fill_masked_range(_StoragePointer __word, unsigned __clz, unsigned __ctz, bool __fill_val);
32
33template <class _StorageType>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __trailing_mask(unsigned __clz);
35
36template <class _StorageType>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __leading_mask(unsigned __ctz);
38
39template <class _StorageType>
40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __middle_mask(unsigned __clz, unsigned __ctz);
41
26_LIBCPP_END_NAMESPACE_STD42_LIBCPP_END_NAMESPACE_STD
2743
28#endif // _LIBCPP___FWD_BIT_REFERENCE_H44#endif // _LIBCPP___FWD_BIT_REFERENCE_H
lib/libcxx/include/__fwd/byte.h+2-2
...@@ -16,11 +16,11 @@...@@ -16,11 +16,11 @@
16#endif16#endif
1717
18#if _LIBCPP_STD_VER >= 1718#if _LIBCPP_STD_VER >= 17
19namespace std { // purposefully not versioned19_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
2020
21enum class byte : unsigned char;21enum class byte : unsigned char;
2222
23} // namespace std23_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
24#endif // _LIBCPP_STD_VER >= 1724#endif // _LIBCPP_STD_VER >= 17
2525
26#endif // _LIBCPP___FWD_BYTE_H26#endif // _LIBCPP___FWD_BYTE_H
lib/libcxx/include/__fwd/complex.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22class _LIBCPP_TEMPLATE_VIS complex;22class complex;
2323
24#if _LIBCPP_STD_VER >= 2624#if _LIBCPP_STD_VER >= 26
2525
lib/libcxx/include/__fwd/deque.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, class _Allocator = allocator<_Tp> >21template <class _Tp, class _Allocator = allocator<_Tp> >
22class _LIBCPP_TEMPLATE_VIS deque;22class deque;
2323
24_LIBCPP_END_NAMESPACE_STD24_LIBCPP_END_NAMESPACE_STD
2525
lib/libcxx/include/__fwd/format.h+3-3
...@@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER >= 2022#if _LIBCPP_STD_VER >= 20
2323
24template <class _Context>24template <class _Context>
25class _LIBCPP_TEMPLATE_VIS basic_format_arg;25class basic_format_arg;
2626
27template <class _OutIt, class _CharT>27template <class _OutIt, class _CharT>
28 requires output_iterator<_OutIt, const _CharT&>28 requires output_iterator<_OutIt, const _CharT&>
29class _LIBCPP_TEMPLATE_VIS basic_format_context;29class basic_format_context;
3030
31template <class _Tp, class _CharT = char>31template <class _Tp, class _CharT = char>
32struct _LIBCPP_TEMPLATE_VIS formatter;32struct formatter;
3333
34#endif // _LIBCPP_STD_VER >= 2034#endif // _LIBCPP_STD_VER >= 20
3535
lib/libcxx/include/__fwd/fstream.h+4-4
...@@ -19,13 +19,13 @@...@@ -19,13 +19,13 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _CharT, class _Traits = char_traits<_CharT> >21template <class _CharT, class _Traits = char_traits<_CharT> >
22class _LIBCPP_TEMPLATE_VIS basic_filebuf;22class basic_filebuf;
23template <class _CharT, class _Traits = char_traits<_CharT> >23template <class _CharT, class _Traits = char_traits<_CharT> >
24class _LIBCPP_TEMPLATE_VIS basic_ifstream;24class basic_ifstream;
25template <class _CharT, class _Traits = char_traits<_CharT> >25template <class _CharT, class _Traits = char_traits<_CharT> >
26class _LIBCPP_TEMPLATE_VIS basic_ofstream;26class basic_ofstream;
27template <class _CharT, class _Traits = char_traits<_CharT> >27template <class _CharT, class _Traits = char_traits<_CharT> >
28class _LIBCPP_TEMPLATE_VIS basic_fstream;28class basic_fstream;
2929
30using filebuf = basic_filebuf<char>;30using filebuf = basic_filebuf<char>;
31using ifstream = basic_ifstream<char>;31using ifstream = basic_ifstream<char>;
lib/libcxx/include/__fwd/functional.h+9-2
...@@ -17,11 +17,18 @@...@@ -17,11 +17,18 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if _LIBCPP_STD_VER >= 14
21template <class _Tp = void>
22#else
23template <class _Tp>
24#endif
25struct less;
26
20template <class>27template <class>
21struct _LIBCPP_TEMPLATE_VIS hash;28struct hash;
2229
23template <class>30template <class>
24class _LIBCPP_TEMPLATE_VIS reference_wrapper;31class reference_wrapper;
2532
26_LIBCPP_END_NAMESPACE_STD33_LIBCPP_END_NAMESPACE_STD
2734
lib/libcxx/include/__fwd/ios.h+1-1
...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21class _LIBCPP_EXPORTED_FROM_ABI ios_base;21class _LIBCPP_EXPORTED_FROM_ABI ios_base;
2222
23template <class _CharT, class _Traits = char_traits<_CharT> >23template <class _CharT, class _Traits = char_traits<_CharT> >
24class _LIBCPP_TEMPLATE_VIS basic_ios;24class basic_ios;
2525
26using ios = basic_ios<char>;26using ios = basic_ios<char>;
27#if _LIBCPP_HAS_WIDE_CHARACTERS27#if _LIBCPP_HAS_WIDE_CHARACTERS
lib/libcxx/include/__fwd/istream.h+2-2
...@@ -19,10 +19,10 @@...@@ -19,10 +19,10 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _CharT, class _Traits = char_traits<_CharT> >21template <class _CharT, class _Traits = char_traits<_CharT> >
22class _LIBCPP_TEMPLATE_VIS basic_istream;22class basic_istream;
2323
24template <class _CharT, class _Traits = char_traits<_CharT> >24template <class _CharT, class _Traits = char_traits<_CharT> >
25class _LIBCPP_TEMPLATE_VIS basic_iostream;25class basic_iostream;
2626
27using istream = basic_istream<char>;27using istream = basic_istream<char>;
28using iostream = basic_iostream<char>;28using iostream = basic_iostream<char>;
lib/libcxx/include/__fwd/map.h created+31
...@@ -0,0 +1,31 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_MAP_H
10#define _LIBCPP___FWD_MAP_H
11
12#include <__config>
13#include <__fwd/functional.h>
14#include <__fwd/memory.h>
15#include <__fwd/pair.h>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >
24class map;
25
26template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >
27class multimap;
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___FWD_MAP_H
lib/libcxx/include/__fwd/memory.h+2-2
...@@ -18,10 +18,10 @@...@@ -18,10 +18,10 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _Tp>20template <class _Tp>
21class _LIBCPP_TEMPLATE_VIS allocator;21class allocator;
2222
23template <class _Tp>23template <class _Tp>
24class _LIBCPP_TEMPLATE_VIS shared_ptr;24class shared_ptr;
2525
26_LIBCPP_END_NAMESPACE_STD26_LIBCPP_END_NAMESPACE_STD
2727
lib/libcxx/include/__fwd/memory_resource.h+1-1
...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22namespace pmr {22namespace pmr {
23template <class _ValueType>23template <class _ValueType>
24class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator;24class _LIBCPP_AVAILABILITY_PMR polymorphic_allocator;
25} // namespace pmr25} // namespace pmr
2626
27_LIBCPP_END_NAMESPACE_STD27_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__fwd/ostream.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _CharT, class _Traits = char_traits<_CharT> >21template <class _CharT, class _Traits = char_traits<_CharT> >
22class _LIBCPP_TEMPLATE_VIS basic_ostream;22class basic_ostream;
2323
24using ostream = basic_ostream<char>;24using ostream = basic_ostream<char>;
2525
lib/libcxx/include/__fwd/pair.h+7-1
...@@ -20,7 +20,13 @@...@@ -20,7 +20,13 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class, class>22template <class, class>
23struct _LIBCPP_TEMPLATE_VIS pair;23struct pair;
24
25template <class _Type>
26inline const bool __is_pair_v = false;
27
28template <class _Type1, class _Type2>
29inline const bool __is_pair_v<pair<_Type1, _Type2> > = true;
2430
25template <size_t _Ip, class _T1, class _T2>31template <size_t _Ip, class _T1, class _T2>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
lib/libcxx/include/__fwd/queue.h+2-2
...@@ -21,10 +21,10 @@...@@ -21,10 +21,10 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp, class _Container = deque<_Tp> >23template <class _Tp, class _Container = deque<_Tp> >
24class _LIBCPP_TEMPLATE_VIS queue;24class queue;
2525
26template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> >26template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> >
27class _LIBCPP_TEMPLATE_VIS priority_queue;27class priority_queue;
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
3030
lib/libcxx/include/__fwd/set.h created+30
...@@ -0,0 +1,30 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_SET_H
10#define _LIBCPP___FWD_SET_H
11
12#include <__config>
13#include <__fwd/functional.h>
14#include <__fwd/memory.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
23class set;
24
25template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
26class multiset;
27
28_LIBCPP_END_NAMESPACE_STD
29
30#endif // _LIBCPP___FWD_SET_H
lib/libcxx/include/__fwd/sstream.h+4-4
...@@ -20,14 +20,14 @@...@@ -20,14 +20,14 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >22template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
23class _LIBCPP_TEMPLATE_VIS basic_stringbuf;23class basic_stringbuf;
2424
25template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >25template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
26class _LIBCPP_TEMPLATE_VIS basic_istringstream;26class basic_istringstream;
27template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >27template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
28class _LIBCPP_TEMPLATE_VIS basic_ostringstream;28class basic_ostringstream;
29template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >29template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
30class _LIBCPP_TEMPLATE_VIS basic_stringstream;30class basic_stringstream;
3131
32using stringbuf = basic_stringbuf<char>;32using stringbuf = basic_stringbuf<char>;
33using istringstream = basic_istringstream<char>;33using istringstream = basic_istringstream<char>;
lib/libcxx/include/__fwd/stack.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, class _Container = deque<_Tp> >21template <class _Tp, class _Container = deque<_Tp> >
22class _LIBCPP_TEMPLATE_VIS stack;22class stack;
2323
24_LIBCPP_END_NAMESPACE_STD24_LIBCPP_END_NAMESPACE_STD
2525
lib/libcxx/include/__fwd/streambuf.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _CharT, class _Traits = char_traits<_CharT> >21template <class _CharT, class _Traits = char_traits<_CharT> >
22class _LIBCPP_TEMPLATE_VIS basic_streambuf;22class basic_streambuf;
2323
24using streambuf = basic_streambuf<char>;24using streambuf = basic_streambuf<char>;
2525
lib/libcxx/include/__fwd/string.h+2-2
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _CharT>22template <class _CharT>
23struct _LIBCPP_TEMPLATE_VIS char_traits;23struct char_traits;
24template <>24template <>
25struct char_traits<char>;25struct char_traits<char>;
2626
...@@ -40,7 +40,7 @@ struct char_traits<wchar_t>;...@@ -40,7 +40,7 @@ struct char_traits<wchar_t>;
40#endif40#endif
4141
42template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >42template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
43class _LIBCPP_TEMPLATE_VIS basic_string;43class basic_string;
4444
45using string = basic_string<char>;45using string = basic_string<char>;
4646
lib/libcxx/include/__fwd/string_view.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _CharT, class _Traits = char_traits<_CharT> >22template <class _CharT, class _Traits = char_traits<_CharT> >
23class _LIBCPP_TEMPLATE_VIS basic_string_view;23class basic_string_view;
2424
25typedef basic_string_view<char> string_view;25typedef basic_string_view<char> string_view;
26#if _LIBCPP_HAS_CHAR8_T26#if _LIBCPP_HAS_CHAR8_T
lib/libcxx/include/__fwd/subrange.h+1-1
...@@ -28,7 +28,7 @@ enum class subrange_kind : bool { unsized, sized };...@@ -28,7 +28,7 @@ enum class subrange_kind : bool { unsized, sized };
2828
29template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind>29template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_kind _Kind>
30 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)30 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
31class _LIBCPP_TEMPLATE_VIS subrange;31class subrange;
3232
33template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>33template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
34 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)34 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
lib/libcxx/include/__fwd/tuple.h+3-3
...@@ -19,15 +19,15 @@...@@ -19,15 +19,15 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <size_t, class>21template <size_t, class>
22struct _LIBCPP_TEMPLATE_VIS tuple_element;22struct tuple_element;
2323
24#ifndef _LIBCPP_CXX03_LANG24#ifndef _LIBCPP_CXX03_LANG
2525
26template <class...>26template <class...>
27class _LIBCPP_TEMPLATE_VIS tuple;27class tuple;
2828
29template <class>29template <class>
30struct _LIBCPP_TEMPLATE_VIS tuple_size;30struct tuple_size;
3131
32template <size_t _Ip, class... _Tp>32template <size_t _Ip, class... _Tp>
33_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&33_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
lib/libcxx/include/__fwd/variant.h+11-20
...@@ -21,16 +21,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,16 +21,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if _LIBCPP_STD_VER >= 1721#if _LIBCPP_STD_VER >= 17
2222
23template <class... _Types>23template <class... _Types>
24class _LIBCPP_TEMPLATE_VIS variant;24class variant;
2525
26template <class _Tp>26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS variant_size;27struct variant_size;
2828
29template <class _Tp>29template <class _Tp>
30inline constexpr size_t variant_size_v = variant_size<_Tp>::value;30inline constexpr size_t variant_size_v = variant_size<_Tp>::value;
3131
32template <size_t _Ip, class _Tp>32template <size_t _Ip, class _Tp>
33struct _LIBCPP_TEMPLATE_VIS variant_alternative;33struct variant_alternative;
3434
35template <size_t _Ip, class _Tp>35template <size_t _Ip, class _Tp>
36using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;36using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
...@@ -38,37 +38,28 @@ using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;...@@ -38,37 +38,28 @@ using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
38inline constexpr size_t variant_npos = static_cast<size_t>(-1);38inline constexpr size_t variant_npos = static_cast<size_t>(-1);
3939
40template <size_t _Ip, class... _Types>40template <size_t _Ip, class... _Types>
41_LIBCPP_HIDE_FROM_ABI41_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>&);
42_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
43get(variant<_Types...>&);
4442
45template <size_t _Ip, class... _Types>43template <size_t _Ip, class... _Types>
46_LIBCPP_HIDE_FROM_ABI44_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&&);
47_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
48get(variant<_Types...>&&);
4945
50template <size_t _Ip, class... _Types>46template <size_t _Ip, class... _Types>
51_LIBCPP_HIDE_FROM_ABI47_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(const variant<_Types...>&);
52_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
53get(const variant<_Types...>&);
5448
55template <size_t _Ip, class... _Types>49template <size_t _Ip, class... _Types>
56_LIBCPP_HIDE_FROM_ABI50_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(const variant<_Types...>&&);
57_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
58get(const variant<_Types...>&&);
5951
60template <class _Tp, class... _Types>52template <class _Tp, class... _Types>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&);53_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>&);
6254
63template <class _Tp, class... _Types>55template <class _Tp, class... _Types>
64_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&);56_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&&);
6557
66template <class _Tp, class... _Types>58template <class _Tp, class... _Types>
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&);59_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>&);
6860
69template <class _Tp, class... _Types>61template <class _Tp, class... _Types>
70_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&&62_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&&);
71get(const variant<_Types...>&&);
7263
73#endif // _LIBCPP_STD_VER >= 1764#endif // _LIBCPP_STD_VER >= 17
7465
lib/libcxx/include/__fwd/vector.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, class _Alloc = allocator<_Tp> >21template <class _Tp, class _Alloc = allocator<_Tp> >
22class _LIBCPP_TEMPLATE_VIS vector;22class vector;
2323
24template <class _Allocator>24template <class _Allocator>
25class vector<bool, _Allocator>;25class vector<bool, _Allocator>;
lib/libcxx/include/__hash_table+111-72
...@@ -29,6 +29,7 @@...@@ -29,6 +29,7 @@
29#include <__memory/unique_ptr.h>29#include <__memory/unique_ptr.h>
30#include <__new/launder.h>30#include <__new/launder.h>
31#include <__type_traits/can_extract_key.h>31#include <__type_traits/can_extract_key.h>
32#include <__type_traits/copy_cvref.h>
32#include <__type_traits/enable_if.h>33#include <__type_traits/enable_if.h>
33#include <__type_traits/invoke.h>34#include <__type_traits/invoke.h>
34#include <__type_traits/is_const.h>35#include <__type_traits/is_const.h>
...@@ -108,9 +109,22 @@ struct __hash_node_base {...@@ -108,9 +109,22 @@ struct __hash_node_base {
108 _LIBCPP_HIDE_FROM_ABI explicit __hash_node_base(__next_pointer __next) _NOEXCEPT : __next_(__next) {}109 _LIBCPP_HIDE_FROM_ABI explicit __hash_node_base(__next_pointer __next) _NOEXCEPT : __next_(__next) {}
109};110};
110111
112template <class _Tp>
113struct __get_hash_node_value_type {
114 using type _LIBCPP_NODEBUG = _Tp;
115};
116
117template <class _Key, class _Tp>
118struct __get_hash_node_value_type<__hash_value_type<_Key, _Tp> > {
119 using type _LIBCPP_NODEBUG = pair<const _Key, _Tp>;
120};
121
122template <class _Tp>
123using __get_hash_node_value_type_t _LIBCPP_NODEBUG = typename __get_hash_node_value_type<_Tp>::type;
124
111template <class _Tp, class _VoidPtr>125template <class _Tp, class _VoidPtr>
112struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > {126struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > > {
113 typedef _Tp __node_value_type;127 using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>;
114 using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >;128 using _Base _LIBCPP_NODEBUG = __hash_node_base<__rebind_pointer_t<_VoidPtr, __hash_node<_Tp, _VoidPtr> > >;
115 using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer;129 using __next_pointer _LIBCPP_NODEBUG = typename _Base::__next_pointer;
116130
...@@ -122,18 +136,20 @@ struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __has...@@ -122,18 +136,20 @@ struct __hash_node : public __hash_node_base< __rebind_pointer_t<_VoidPtr, __has
122136
123private:137private:
124 union {138 union {
125 _Tp __value_;139 __node_value_type __value_;
126 };140 };
127141
128public:142public:
129 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }143 _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
130#else144#else
131145
132private:146private:
133 _ALIGNAS_TYPE(_Tp) char __buffer_[sizeof(_Tp)];147 _ALIGNAS_TYPE(__node_value_type) char __buffer_[sizeof(__node_value_type)];
134148
135public:149public:
136 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }150 _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() {
151 return *std::__launder(reinterpret_cast<__node_value_type*>(&__buffer_));
152 }
137#endif153#endif
138154
139 _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {}155 _LIBCPP_HIDE_FROM_ABI explicit __hash_node(__next_pointer __next, size_t __hash) : _Base(__next), __hash_(__hash) {}
...@@ -147,24 +163,24 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __constrain_hash(size_t __h, size_t __bc) {...@@ -147,24 +163,24 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __constrain_hash(size_t __h, size_t __bc) {
147}163}
148164
149inline _LIBCPP_HIDE_FROM_ABI size_t __next_hash_pow2(size_t __n) {165inline _LIBCPP_HIDE_FROM_ABI size_t __next_hash_pow2(size_t __n) {
150 return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - __libcpp_clz(__n - 1)));166 return __n < 2 ? __n : (size_t(1) << (numeric_limits<size_t>::digits - std::__countl_zero(__n - 1)));
151}167}
152168
153template <class _Tp, class _Hash, class _Equal, class _Alloc>169template <class _Tp, class _Hash, class _Equal, class _Alloc>
154class __hash_table;170class __hash_table;
155171
156template <class _NodePtr>172template <class _NodePtr>
157class _LIBCPP_TEMPLATE_VIS __hash_iterator;173class __hash_iterator;
158template <class _ConstNodePtr>174template <class _ConstNodePtr>
159class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;175class __hash_const_iterator;
160template <class _NodePtr>176template <class _NodePtr>
161class _LIBCPP_TEMPLATE_VIS __hash_local_iterator;177class __hash_local_iterator;
162template <class _ConstNodePtr>178template <class _ConstNodePtr>
163class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;179class __hash_const_local_iterator;
164template <class _HashIterator>180template <class _HashIterator>
165class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;181class __hash_map_iterator;
166template <class _HashIterator>182template <class _HashIterator>
167class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;183class __hash_map_const_iterator;
168184
169template <class _Tp>185template <class _Tp>
170struct __hash_key_value_types {186struct __hash_key_value_types {
...@@ -191,18 +207,18 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {...@@ -191,18 +207,18 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > {
191207
192 _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; }208 _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__container_value_type const& __v) { return __v.first; }
193209
194 template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __node_value_type>::value, int> = 0>210 template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __node_value_type>::value, int> = 0>
195 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {211 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
196 return __t.__get_value();212 return __t.__get_value();
197 }213 }
198214
199 template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>215 template <class _Up, __enable_if_t<is_same<__remove_cvref_t<_Up>, __container_value_type>::value, int> = 0>
200 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {216 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
201 return __t;217 return __t;
202 }218 }
203219
204 _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) {220 _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__container_value_type& __n) {
205 return std::addressof(__n.__get_value());221 return std::addressof(__n);
206 }222 }
207 _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); }223 _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); }
208};224};
...@@ -242,7 +258,7 @@ public:...@@ -242,7 +258,7 @@ public:
242258
243 typedef typename __node_base_type::__next_pointer __next_pointer;259 typedef typename __node_base_type::__next_pointer __next_pointer;
244260
245 typedef _Tp __node_value_type;261 using __node_value_type _LIBCPP_NODEBUG = __get_hash_node_value_type_t<_Tp>;
246 typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;262 typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;
247 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;263 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;
248264
...@@ -273,7 +289,7 @@ struct __make_hash_node_types {...@@ -273,7 +289,7 @@ struct __make_hash_node_types {
273};289};
274290
275template <class _NodePtr>291template <class _NodePtr>
276class _LIBCPP_TEMPLATE_VIS __hash_iterator {292class __hash_iterator {
277 typedef __hash_node_types<_NodePtr> _NodeTypes;293 typedef __hash_node_types<_NodePtr> _NodeTypes;
278 typedef _NodePtr __node_pointer;294 typedef _NodePtr __node_pointer;
279 typedef typename _NodeTypes::__next_pointer __next_pointer;295 typedef typename _NodeTypes::__next_pointer __next_pointer;
...@@ -327,17 +343,17 @@ private:...@@ -327,17 +343,17 @@ private:
327 template <class, class, class, class>343 template <class, class, class, class>
328 friend class __hash_table;344 friend class __hash_table;
329 template <class>345 template <class>
330 friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;346 friend class __hash_const_iterator;
331 template <class>347 template <class>
332 friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;348 friend class __hash_map_iterator;
333 template <class, class, class, class, class>349 template <class, class, class, class, class>
334 friend class _LIBCPP_TEMPLATE_VIS unordered_map;350 friend class unordered_map;
335 template <class, class, class, class, class>351 template <class, class, class, class, class>
336 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;352 friend class unordered_multimap;
337};353};
338354
339template <class _NodePtr>355template <class _NodePtr>
340class _LIBCPP_TEMPLATE_VIS __hash_const_iterator {356class __hash_const_iterator {
341 static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");357 static_assert(!is_const<typename pointer_traits<_NodePtr>::element_type>::value, "");
342 typedef __hash_node_types<_NodePtr> _NodeTypes;358 typedef __hash_node_types<_NodePtr> _NodeTypes;
343 typedef _NodePtr __node_pointer;359 typedef _NodePtr __node_pointer;
...@@ -395,15 +411,15 @@ private:...@@ -395,15 +411,15 @@ private:
395 template <class, class, class, class>411 template <class, class, class, class>
396 friend class __hash_table;412 friend class __hash_table;
397 template <class>413 template <class>
398 friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;414 friend class __hash_map_const_iterator;
399 template <class, class, class, class, class>415 template <class, class, class, class, class>
400 friend class _LIBCPP_TEMPLATE_VIS unordered_map;416 friend class unordered_map;
401 template <class, class, class, class, class>417 template <class, class, class, class, class>
402 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;418 friend class unordered_multimap;
403};419};
404420
405template <class _NodePtr>421template <class _NodePtr>
406class _LIBCPP_TEMPLATE_VIS __hash_local_iterator {422class __hash_local_iterator {
407 typedef __hash_node_types<_NodePtr> _NodeTypes;423 typedef __hash_node_types<_NodePtr> _NodeTypes;
408 typedef _NodePtr __node_pointer;424 typedef _NodePtr __node_pointer;
409 typedef typename _NodeTypes::__next_pointer __next_pointer;425 typedef typename _NodeTypes::__next_pointer __next_pointer;
...@@ -468,13 +484,13 @@ private:...@@ -468,13 +484,13 @@ private:
468 template <class, class, class, class>484 template <class, class, class, class>
469 friend class __hash_table;485 friend class __hash_table;
470 template <class>486 template <class>
471 friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;487 friend class __hash_const_local_iterator;
472 template <class>488 template <class>
473 friend class _LIBCPP_TEMPLATE_VIS __hash_map_iterator;489 friend class __hash_map_iterator;
474};490};
475491
476template <class _ConstNodePtr>492template <class _ConstNodePtr>
477class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator {493class __hash_const_local_iterator {
478 typedef __hash_node_types<_ConstNodePtr> _NodeTypes;494 typedef __hash_node_types<_ConstNodePtr> _NodeTypes;
479 typedef _ConstNodePtr __node_pointer;495 typedef _ConstNodePtr __node_pointer;
480 typedef typename _NodeTypes::__next_pointer __next_pointer;496 typedef typename _NodeTypes::__next_pointer __next_pointer;
...@@ -553,7 +569,7 @@ private:...@@ -553,7 +569,7 @@ private:
553 template <class, class, class, class>569 template <class, class, class, class>
554 friend class __hash_table;570 friend class __hash_table;
555 template <class>571 template <class>
556 friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;572 friend class __hash_map_const_iterator;
557};573};
558574
559template <class _Alloc>575template <class _Alloc>
...@@ -667,14 +683,14 @@ int __diagnose_unordered_container_requirements(void*);...@@ -667,14 +683,14 @@ int __diagnose_unordered_container_requirements(void*);
667template <class _Tp, class _Hash, class _Equal, class _Alloc>683template <class _Tp, class _Hash, class _Equal, class _Alloc>
668class __hash_table {684class __hash_table {
669public:685public:
670 typedef _Tp value_type;686 using value_type = __get_hash_node_value_type_t<_Tp>;
671 typedef _Hash hasher;687 typedef _Hash hasher;
672 typedef _Equal key_equal;688 typedef _Equal key_equal;
673 typedef _Alloc allocator_type;689 typedef _Alloc allocator_type;
674690
675private:691private:
676 typedef allocator_traits<allocator_type> __alloc_traits;692 typedef allocator_traits<allocator_type> __alloc_traits;
677 typedef typename __make_hash_node_types<value_type, typename __alloc_traits::void_pointer>::type _NodeTypes;693 typedef typename __make_hash_node_types<_Tp, typename __alloc_traits::void_pointer>::type _NodeTypes;
678694
679public:695public:
680 typedef typename _NodeTypes::__node_value_type __node_value_type;696 typedef typename _NodeTypes::__node_value_type __node_value_type;
...@@ -770,9 +786,10 @@ public:...@@ -770,9 +786,10 @@ public:
770786
771 _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(const __hash_table& __u);787 _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(const __hash_table& __u);
772 _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(__hash_table&& __u)788 _LIBCPP_HIDE_FROM_ABI __hash_table& operator=(__hash_table&& __u)
773 _NOEXCEPT_(__node_traits::propagate_on_container_move_assignment::value&&789 _NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value &&
774 is_nothrow_move_assignable<__node_allocator>::value&& is_nothrow_move_assignable<hasher>::value&&790 ((__node_traits::propagate_on_container_move_assignment::value &&
775 is_nothrow_move_assignable<key_equal>::value);791 is_nothrow_move_assignable<__node_allocator>::value) ||
792 allocator_traits<__node_allocator>::is_always_equal::value));
776 template <class _InputIterator>793 template <class _InputIterator>
777 _LIBCPP_HIDE_FROM_ABI void __assign_unique(_InputIterator __first, _InputIterator __last);794 _LIBCPP_HIDE_FROM_ABI void __assign_unique(_InputIterator __first, _InputIterator __last);
778 template <class _InputIterator>795 template <class _InputIterator>
...@@ -835,27 +852,36 @@ public:...@@ -835,27 +852,36 @@ public:
835 template <class... _Args>852 template <class... _Args>
836 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);853 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
837854
838 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(__container_value_type&& __x) {855 template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0>
839 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x));856 _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) {
840 }857 using __key_type = typename _NodeTypes::key_type;
841858
842 template <class _Pp, __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value, int> = 0>859 __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second));
843 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) {860 __node_insert_unique(__h.get());
844 return __emplace_unique(std::forward<_Pp>(__x));861 __h.release();
845 }862 }
846863
847 template <class _Pp>864 template <class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0>
848 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Pp&& __x) {865 _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(value_type&& __value) {
849 return __emplace_multi(std::forward<_Pp>(__x));866 __node_holder __h = __construct_node(std::move(__value));
867 __node_insert_unique(__h.get());
868 __h.release();
850 }869 }
851870
852 template <class _Pp>871 template <class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0>
853 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Pp&& __x) {872 _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) {
854 return __emplace_hint_multi(__p, std::forward<_Pp>(__x));873 using __key_type = typename _NodeTypes::key_type;
874
875 __node_holder __h = __construct_node(const_cast<__key_type&&>(__value.first), std::move(__value.second));
876 __node_insert_multi(__h.get());
877 __h.release();
855 }878 }
856879
857 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(const __container_value_type& __x) {880 template <class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0>
858 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x);881 _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(value_type&& __value) {
882 __node_holder __h = __construct_node(std::move(__value));
883 __node_insert_multi(__h.get());
884 __h.release();
859 }885 }
860886
861#if _LIBCPP_STD_VER >= 17887#if _LIBCPP_STD_VER >= 17
...@@ -1019,10 +1045,25 @@ private:...@@ -1019,10 +1045,25 @@ private:
1019 _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__next_pointer __np) _NOEXCEPT;1045 _LIBCPP_HIDE_FROM_ABI void __deallocate_node(__next_pointer __np) _NOEXCEPT;
1020 _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT;1046 _LIBCPP_HIDE_FROM_ABI __next_pointer __detach() _NOEXCEPT;
10211047
1048 template <class _From, class _ValueT = _Tp, __enable_if_t<__is_hash_value_type<_ValueT>::value, int> = 0>
1049 _LIBCPP_HIDE_FROM_ABI void __assign_value(__get_hash_node_value_type_t<_Tp>& __lhs, _From&& __rhs) {
1050 using __key_type = typename _NodeTypes::key_type;
1051
1052 // This is technically UB, since the object was constructed as `const`.
1053 // Clang doesn't optimize on this currently though.
1054 const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
1055 __lhs.second = std::forward<_From>(__rhs).second;
1056 }
1057
1058 template <class _From, class _ValueT = _Tp, __enable_if_t<!__is_hash_value_type<_ValueT>::value, int> = 0>
1059 _LIBCPP_HIDE_FROM_ABI void __assign_value(_Tp& __lhs, _From&& __rhs) {
1060 __lhs = std::forward<_From>(__rhs);
1061 }
1062
1022 template <class, class, class, class, class>1063 template <class, class, class, class, class>
1023 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1064 friend class unordered_map;
1024 template <class, class, class, class, class>1065 template <class, class, class, class, class>
1025 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;1066 friend class unordered_multimap;
1026};1067};
10271068
1028template <class _Tp, class _Hash, class _Equal, class _Alloc>1069template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1215,8 +1256,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,...@@ -1215,8 +1256,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
1215#endif // _LIBCPP_HAS_EXCEPTIONS1256#endif // _LIBCPP_HAS_EXCEPTIONS
1216 const_iterator __i = __u.begin();1257 const_iterator __i = __u.begin();
1217 while (__cache != nullptr && __u.size() != 0) {1258 while (__cache != nullptr && __u.size() != 0) {
1218 __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value());1259 __assign_value(__cache->__upcast()->__get_value(), std::move(__u.remove(__i++)->__get_value()));
1219 __next_pointer __next = __cache->__next_;1260 __next_pointer __next = __cache->__next_;
1220 __node_insert_multi(__cache->__upcast());1261 __node_insert_multi(__cache->__upcast());
1221 __cache = __next;1262 __cache = __next;
1222 }1263 }
...@@ -1229,19 +1270,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,...@@ -1229,19 +1270,17 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u,
1229 __deallocate_node(__cache);1270 __deallocate_node(__cache);
1230 }1271 }
1231 const_iterator __i = __u.begin();1272 const_iterator __i = __u.begin();
1232 while (__u.size() != 0) {1273 while (__u.size() != 0)
1233 __node_holder __h = __construct_node(_NodeTypes::__move(__u.remove(__i++)->__get_value()));1274 __insert_multi_from_orphaned_node(std::move(__u.remove(__i++)->__get_value()));
1234 __node_insert_multi(__h.get());
1235 __h.release();
1236 }
1237 }1275 }
1238}1276}
12391277
1240template <class _Tp, class _Hash, class _Equal, class _Alloc>1278template <class _Tp, class _Hash, class _Equal, class _Alloc>
1241inline __hash_table<_Tp, _Hash, _Equal, _Alloc>&1279inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u)
1242__hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) _NOEXCEPT_(1280 _NOEXCEPT_(is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value &&
1243 __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<__node_allocator>::value&&1281 ((__node_traits::propagate_on_container_move_assignment::value &&
1244 is_nothrow_move_assignable<hasher>::value&& is_nothrow_move_assignable<key_equal>::value) {1282 is_nothrow_move_assignable<__node_allocator>::value) ||
1283 allocator_traits<__node_allocator>::is_always_equal::value)) {
1245 __move_assign(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());1284 __move_assign(__u, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1246 return *this;1285 return *this;
1247}1286}
...@@ -1260,8 +1299,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __...@@ -1260,8 +1299,8 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __
1260 try {1299 try {
1261#endif // _LIBCPP_HAS_EXCEPTIONS1300#endif // _LIBCPP_HAS_EXCEPTIONS
1262 for (; __cache != nullptr && __first != __last; ++__first) {1301 for (; __cache != nullptr && __first != __last; ++__first) {
1263 __cache->__upcast()->__get_value() = *__first;1302 __assign_value(__cache->__upcast()->__get_value(), *__first);
1264 __next_pointer __next = __cache->__next_;1303 __next_pointer __next = __cache->__next_;
1265 __node_insert_unique(__cache->__upcast());1304 __node_insert_unique(__cache->__upcast());
1266 __cache = __next;1305 __cache = __next;
1267 }1306 }
...@@ -1274,7 +1313,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __...@@ -1274,7 +1313,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __
1274 __deallocate_node(__cache);1313 __deallocate_node(__cache);
1275 }1314 }
1276 for (; __first != __last; ++__first)1315 for (; __first != __last; ++__first)
1277 __insert_unique(*__first);1316 __emplace_unique(*__first);
1278}1317}
12791318
1280template <class _Tp, class _Hash, class _Equal, class _Alloc>1319template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1292,7 +1331,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f...@@ -1292,7 +1331,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f
1292 try {1331 try {
1293#endif // _LIBCPP_HAS_EXCEPTIONS1332#endif // _LIBCPP_HAS_EXCEPTIONS
1294 for (; __cache != nullptr && __first != __last; ++__first) {1333 for (; __cache != nullptr && __first != __last; ++__first) {
1295 __cache->__upcast()->__get_value() = *__first;1334 __assign_value(__cache->__upcast()->__get_value(), *__first);
1296 __next_pointer __next = __cache->__next_;1335 __next_pointer __next = __cache->__next_;
1297 __node_insert_multi(__cache->__upcast());1336 __node_insert_multi(__cache->__upcast());
1298 __cache = __next;1337 __cache = __next;
...@@ -1306,7 +1345,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f...@@ -1306,7 +1345,7 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f
1306 __deallocate_node(__cache);1345 __deallocate_node(__cache);
1307 }1346 }
1308 for (; __first != __last; ++__first)1347 for (; __first != __last; ++__first)
1309 __insert_multi(_NodeTypes::__get_value(*__first));1348 __emplace_multi(_NodeTypes::__get_value(*__first));
1310}1349}
13111350
1312template <class _Tp, class _Hash, class _Equal, class _Alloc>1351template <class _Tp, class _Hash, class _Equal, class _Alloc>
...@@ -1769,9 +1808,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>...@@ -1769,9 +1808,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
1769template <class _Key>1808template <class _Key>
1770typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator1809typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator
1771__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) {1810__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) {
1772 size_t __hash = hash_function()(__k);
1773 size_type __bc = bucket_count();1811 size_type __bc = bucket_count();
1774 if (__bc != 0) {1812 if (__bc != 0 && size() != 0) {
1813 size_t __hash = hash_function()(__k);
1775 size_t __chash = std::__constrain_hash(__hash, __bc);1814 size_t __chash = std::__constrain_hash(__hash, __bc);
1776 __next_pointer __nd = __bucket_list_[__chash];1815 __next_pointer __nd = __bucket_list_[__chash];
1777 if (__nd != nullptr) {1816 if (__nd != nullptr) {
...@@ -1790,9 +1829,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>...@@ -1790,9 +1829,9 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
1790template <class _Key>1829template <class _Key>
1791typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator1830typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator
1792__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const {1831__hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const {
1793 size_t __hash = hash_function()(__k);
1794 size_type __bc = bucket_count();1832 size_type __bc = bucket_count();
1795 if (__bc != 0) {1833 if (__bc != 0 && size() != 0) {
1834 size_t __hash = hash_function()(__k);
1796 size_t __chash = std::__constrain_hash(__hash, __bc);1835 size_t __chash = std::__constrain_hash(__hash, __bc);
1797 __next_pointer __nd = __bucket_list_[__chash];1836 __next_pointer __nd = __bucket_list_[__chash];
1798 if (__nd != nullptr) {1837 if (__nd != nullptr) {
lib/libcxx/include/__ios/fpos.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _StateT>22template <class _StateT>
23class _LIBCPP_TEMPLATE_VIS fpos {23class fpos {
24private:24private:
25 _StateT __st_;25 _StateT __st_;
26 streamoff __off_;26 streamoff __off_;
lib/libcxx/include/__iterator/advance.h+7-9
...@@ -65,9 +65,8 @@ template < class _InputIter,...@@ -65,9 +65,8 @@ template < class _InputIter,
65_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) {65_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) {
66 typedef typename iterator_traits<_InputIter>::difference_type _Difference;66 typedef typename iterator_traits<_InputIter>::difference_type _Difference;
67 _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n));67 _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n));
68 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.68 _LIBCPP_ASSERT_PEDANTIC(__has_bidirectional_iterator_category<_InputIter>::value || __n >= 0,
69 _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value,69 "std::advance: Can only pass a negative `n` with a bidirectional_iterator.");
70 "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
71 std::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());70 std::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
72}71}
7372
...@@ -98,9 +97,8 @@ public:...@@ -98,9 +97,8 @@ public:
98 // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative.97 // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative.
99 template <input_or_output_iterator _Ip>98 template <input_or_output_iterator _Ip>
100 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const {99 _LIBCPP_HIDE_FROM_ABI constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const {
101 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.100 _LIBCPP_ASSERT_PEDANTIC(bidirectional_iterator<_Ip> || __n >= 0,
102 _LIBCPP_ASSERT_PEDANTIC(101 "ranges::advance: Can only pass a negative `n` with a bidirectional_iterator.");
103 __n >= 0 || bidirectional_iterator<_Ip>, "If `n < 0`, then `bidirectional_iterator<I>` must be true.");
104102
105 // If `I` models `random_access_iterator`, equivalent to `i += n`.103 // If `I` models `random_access_iterator`, equivalent to `i += n`.
106 if constexpr (random_access_iterator<_Ip>) {104 if constexpr (random_access_iterator<_Ip>) {
...@@ -149,9 +147,9 @@ public:...@@ -149,9 +147,9 @@ public:
149 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>147 template <input_or_output_iterator _Ip, sentinel_for<_Ip> _Sp>
150 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip>148 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip>
151 operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {149 operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound_sentinel) const {
152 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.150 _LIBCPP_ASSERT_PEDANTIC(
153 _LIBCPP_ASSERT_PEDANTIC((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>),151 (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) || (__n >= 0),
154 "If `n < 0`, then `bidirectional_iterator<I> && same_as<I, S>` must be true.");152 "ranges::advance: Can only pass a negative `n` with a bidirectional_iterator coming from a common_range.");
155 // If `S` and `I` model `sized_sentinel_for<S, I>`:153 // If `S` and `I` model `sized_sentinel_for<S, I>`:
156 if constexpr (sized_sentinel_for<_Sp, _Ip>) {154 if constexpr (sized_sentinel_for<_Sp, _Ip>) {
157 // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.155 // If |n| >= |bound_sentinel - i|, equivalent to `ranges::advance(i, bound_sentinel)`.
lib/libcxx/include/__iterator/aliasing_iterator.h+6-3
...@@ -12,8 +12,10 @@...@@ -12,8 +12,10 @@
12#include <__config>12#include <__config>
13#include <__cstddef/ptrdiff_t.h>13#include <__cstddef/ptrdiff_t.h>
14#include <__iterator/iterator_traits.h>14#include <__iterator/iterator_traits.h>
15#include <__memory/addressof.h>
15#include <__memory/pointer_traits.h>16#include <__memory/pointer_traits.h>
16#include <__type_traits/is_trivial.h>17#include <__type_traits/is_trivially_constructible.h>
18#include <__type_traits/is_trivially_copyable.h>
1719
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header21# pragma GCC system_header
...@@ -44,7 +46,8 @@ struct __aliasing_iterator_wrapper {...@@ -44,7 +46,8 @@ struct __aliasing_iterator_wrapper {
44 using reference = value_type&;46 using reference = value_type&;
45 using pointer = value_type*;47 using pointer = value_type*;
4648
47 static_assert(is_trivial<value_type>::value);49 static_assert(is_trivially_default_constructible<value_type>::value);
50 static_assert(is_trivially_copyable<value_type>::value);
48 static_assert(sizeof(__base_value_type) == sizeof(value_type));51 static_assert(sizeof(__base_value_type) == sizeof(value_type));
4952
50 _LIBCPP_HIDE_FROM_ABI __iterator() = default;53 _LIBCPP_HIDE_FROM_ABI __iterator() = default;
...@@ -102,7 +105,7 @@ struct __aliasing_iterator_wrapper {...@@ -102,7 +105,7 @@ struct __aliasing_iterator_wrapper {
102105
103 _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT {106 _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT {
104 _Alias __val;107 _Alias __val;
105 __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type));108 __builtin_memcpy(std::addressof(__val), std::__to_address(__base_), sizeof(value_type));
106 return __val;109 return __val;
107 }110 }
108111
lib/libcxx/include/__iterator/back_insert_iterator.h+1-1
...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
29_LIBCPP_SUPPRESS_DEPRECATED_PUSH29_LIBCPP_SUPPRESS_DEPRECATED_PUSH
30template <class _Container>30template <class _Container>
31class _LIBCPP_TEMPLATE_VIS back_insert_iterator31class back_insert_iterator
32#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)32#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
33 : public iterator<output_iterator_tag, void, void, void, void>33 : public iterator<output_iterator_tag, void, void, void, void>
34#endif34#endif
lib/libcxx/include/__iterator/common_iterator.h+4-3
...@@ -28,6 +28,7 @@...@@ -28,6 +28,7 @@
28#include <__memory/addressof.h>28#include <__memory/addressof.h>
29#include <__type_traits/conditional.h>29#include <__type_traits/conditional.h>
30#include <__type_traits/is_pointer.h>30#include <__type_traits/is_pointer.h>
31#include <__type_traits/is_referenceable.h>
31#include <__utility/declval.h>32#include <__utility/declval.h>
32#include <variant>33#include <variant>
3334
...@@ -157,7 +158,7 @@ public:...@@ -157,7 +158,7 @@ public:
157 ++*this;158 ++*this;
158 return __tmp;159 return __tmp;
159 } else if constexpr (requires(_Iter& __i) {160 } else if constexpr (requires(_Iter& __i) {
160 { *__i++ } -> __can_reference;161 { *__i++ } -> __referenceable;
161 } || !__can_use_postfix_proxy<_Iter>) {162 } || !__can_use_postfix_proxy<_Iter>) {
162 return std::__unchecked_get<_Iter>(__hold_)++;163 return std::__unchecked_get<_Iter>(__hold_)++;
163 } else {164 } else {
...@@ -272,13 +273,13 @@ concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>&...@@ -272,13 +273,13 @@ concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>&
272273
273template <class, class>274template <class, class>
274struct __arrow_type_or_void {275struct __arrow_type_or_void {
275 using type = void;276 using type _LIBCPP_NODEBUG = void;
276};277};
277278
278template <class _Iter, class _Sent>279template <class _Iter, class _Sent>
279 requires __common_iter_has_ptr_op<_Iter, _Sent>280 requires __common_iter_has_ptr_op<_Iter, _Sent>
280struct __arrow_type_or_void<_Iter, _Sent> {281struct __arrow_type_or_void<_Iter, _Sent> {
281 using type = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());282 using type _LIBCPP_NODEBUG = decltype(std::declval<const common_iterator<_Iter, _Sent>&>().operator->());
282};283};
283284
284template <input_iterator _Iter, class _Sent>285template <input_iterator _Iter, class _Sent>
lib/libcxx/include/__iterator/concepts.h+46-5
...@@ -29,15 +29,19 @@...@@ -29,15 +29,19 @@
29#include <__iterator/incrementable_traits.h>29#include <__iterator/incrementable_traits.h>
30#include <__iterator/iter_move.h>30#include <__iterator/iter_move.h>
31#include <__iterator/iterator_traits.h>31#include <__iterator/iterator_traits.h>
32#include <__iterator/readable_traits.h>
33#include <__memory/pointer_traits.h>32#include <__memory/pointer_traits.h>
34#include <__type_traits/add_pointer.h>33#include <__type_traits/add_pointer.h>
35#include <__type_traits/common_reference.h>34#include <__type_traits/common_reference.h>
35#include <__type_traits/conditional.h>
36#include <__type_traits/disjunction.h>
37#include <__type_traits/enable_if.h>
36#include <__type_traits/integral_constant.h>38#include <__type_traits/integral_constant.h>
37#include <__type_traits/invoke.h>39#include <__type_traits/invoke.h>
38#include <__type_traits/is_pointer.h>40#include <__type_traits/is_pointer.h>
39#include <__type_traits/is_primary_template.h>41#include <__type_traits/is_primary_template.h>
40#include <__type_traits/is_reference.h>42#include <__type_traits/is_reference.h>
43#include <__type_traits/is_referenceable.h>
44#include <__type_traits/is_valid_expansion.h>
41#include <__type_traits/remove_cv.h>45#include <__type_traits/remove_cv.h>
42#include <__type_traits/remove_cvref.h>46#include <__type_traits/remove_cvref.h>
43#include <__utility/forward.h>47#include <__utility/forward.h>
...@@ -80,12 +84,13 @@ concept __specialization_of_projected = requires {...@@ -80,12 +84,13 @@ concept __specialization_of_projected = requires {
8084
81template <class _Tp>85template <class _Tp>
82struct __indirect_value_t_impl {86struct __indirect_value_t_impl {
83 using type = iter_value_t<_Tp>&;87 using type _LIBCPP_NODEBUG = iter_value_t<_Tp>&;
84};88};
85template <__specialization_of_projected _Tp>89template <__specialization_of_projected _Tp>
86struct __indirect_value_t_impl<_Tp> {90struct __indirect_value_t_impl<_Tp> {
87 using type = invoke_result_t<__projected_projection_t<_Tp>&,91 using type _LIBCPP_NODEBUG =
88 typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;92 invoke_result_t<__projected_projection_t<_Tp>&,
93 typename __indirect_value_t_impl<__projected_iterator_t<_Tp>>::type>;
89};94};
9095
91template <indirectly_readable _Tp>96template <indirectly_readable _Tp>
...@@ -131,7 +136,7 @@ concept incrementable = regular<_Ip> && weakly_incrementable<_Ip> && requires(_I...@@ -131,7 +136,7 @@ concept incrementable = regular<_Ip> && weakly_incrementable<_Ip> && requires(_I
131// [iterator.concept.iterator]136// [iterator.concept.iterator]
132template <class _Ip>137template <class _Ip>
133concept input_or_output_iterator = requires(_Ip __i) {138concept input_or_output_iterator = requires(_Ip __i) {
134 { *__i } -> __can_reference;139 { *__i } -> __referenceable;
135} && weakly_incrementable<_Ip>;140} && weakly_incrementable<_Ip>;
136141
137// [iterator.concept.sentinel]142// [iterator.concept.sentinel]
...@@ -149,6 +154,42 @@ concept sized_sentinel_for =...@@ -149,6 +154,42 @@ concept sized_sentinel_for =
149 { __i - __s } -> same_as<iter_difference_t<_Ip>>;154 { __i - __s } -> same_as<iter_difference_t<_Ip>>;
150 };155 };
151156
157template <class _Iter>
158struct __iter_traits_cache {
159 using type _LIBCPP_NODEBUG =
160 _If<__is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
161};
162template <class _Iter>
163using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type;
164
165struct __iter_concept_concept_test {
166 template <class _Iter>
167 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept;
168};
169struct __iter_concept_category_test {
170 template <class _Iter>
171 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category;
172};
173struct __iter_concept_random_fallback {
174 template <class _Iter>
175 using _Apply _LIBCPP_NODEBUG =
176 __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>;
177};
178
179template <class _Iter, class _Tester>
180struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>, _Tester {};
181
182template <class _Iter>
183struct __iter_concept_cache {
184 using type _LIBCPP_NODEBUG =
185 _Or<__test_iter_concept<_Iter, __iter_concept_concept_test>,
186 __test_iter_concept<_Iter, __iter_concept_category_test>,
187 __test_iter_concept<_Iter, __iter_concept_random_fallback> >;
188};
189
190template <class _Iter>
191using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
192
152// [iterator.concept.input]193// [iterator.concept.input]
153template <class _Ip>194template <class _Ip>
154concept input_iterator = input_or_output_iterator<_Ip> && indirectly_readable<_Ip> && requires {195concept input_iterator = input_or_output_iterator<_Ip> && indirectly_readable<_Ip> && requires {
lib/libcxx/include/__iterator/front_insert_iterator.h+1-1
...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
29_LIBCPP_SUPPRESS_DEPRECATED_PUSH29_LIBCPP_SUPPRESS_DEPRECATED_PUSH
30template <class _Container>30template <class _Container>
31class _LIBCPP_TEMPLATE_VIS front_insert_iterator31class front_insert_iterator
32#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)32#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
33 : public iterator<output_iterator_tag, void, void, void, void>33 : public iterator<output_iterator_tag, void, void, void, void>
34#endif34#endif
lib/libcxx/include/__iterator/insert_iterator.h+1-1
...@@ -37,7 +37,7 @@ using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator;...@@ -37,7 +37,7 @@ using __insert_iterator_iter_t _LIBCPP_NODEBUG = typename _Container::iterator;
3737
38_LIBCPP_SUPPRESS_DEPRECATED_PUSH38_LIBCPP_SUPPRESS_DEPRECATED_PUSH
39template <class _Container>39template <class _Container>
40class _LIBCPP_TEMPLATE_VIS insert_iterator40class insert_iterator
41#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)41#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
42 : public iterator<output_iterator_tag, void, void, void, void>42 : public iterator<output_iterator_tag, void, void, void, void>
43#endif43#endif
lib/libcxx/include/__iterator/istream_iterator.h+4-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727
28_LIBCPP_SUPPRESS_DEPRECATED_PUSH28_LIBCPP_SUPPRESS_DEPRECATED_PUSH
29template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>29template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t>
30class _LIBCPP_TEMPLATE_VIS istream_iterator30class istream_iterator
31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
32 : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>32 : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&>
33#endif33#endif
...@@ -58,6 +58,9 @@ public:...@@ -58,6 +58,9 @@ public:
58 __in_stream_ = nullptr;58 __in_stream_ = nullptr;
59 }59 }
6060
61 // LWG3600 Changed the wording of the copy constructor. In libc++ this constructor
62 // can still be trivial after this change.
63
61 _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; }64 _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; }
62 _LIBCPP_HIDE_FROM_ABI const _Tp* operator->() const { return std::addressof((operator*())); }65 _LIBCPP_HIDE_FROM_ABI const _Tp* operator->() const { return std::addressof((operator*())); }
63 _LIBCPP_HIDE_FROM_ABI istream_iterator& operator++() {66 _LIBCPP_HIDE_FROM_ABI istream_iterator& operator++() {
lib/libcxx/include/__iterator/istreambuf_iterator.h+1-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727
28_LIBCPP_SUPPRESS_DEPRECATED_PUSH28_LIBCPP_SUPPRESS_DEPRECATED_PUSH
29template <class _CharT, class _Traits>29template <class _CharT, class _Traits>
30class _LIBCPP_TEMPLATE_VIS istreambuf_iterator30class istreambuf_iterator
31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
32 : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT>32 : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT>
33#endif33#endif
lib/libcxx/include/__iterator/iter_move.h+2-1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__config>14#include <__config>
15#include <__iterator/iterator_traits.h>15#include <__iterator/iterator_traits.h>
16#include <__type_traits/is_reference.h>16#include <__type_traits/is_reference.h>
17#include <__type_traits/is_referenceable.h>
17#include <__type_traits/remove_cvref.h>18#include <__type_traits/remove_cvref.h>
18#include <__utility/declval.h>19#include <__utility/declval.h>
19#include <__utility/forward.h>20#include <__utility/forward.h>
...@@ -90,7 +91,7 @@ inline constexpr auto iter_move = __iter_move::__fn{};...@@ -90,7 +91,7 @@ inline constexpr auto iter_move = __iter_move::__fn{};
9091
91template <__dereferenceable _Tp>92template <__dereferenceable _Tp>
92 requires requires(_Tp& __t) {93 requires requires(_Tp& __t) {
93 { ranges::iter_move(__t) } -> __can_reference;94 { ranges::iter_move(__t) } -> __referenceable;
94 }95 }
95using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));96using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
9697
lib/libcxx/include/__iterator/iterator.h+1-1
...@@ -20,7 +20,7 @@...@@ -20,7 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&>22template <class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator {23struct _LIBCPP_DEPRECATED_IN_CXX17 iterator {
24 typedef _Tp value_type;24 typedef _Tp value_type;
25 typedef _Distance difference_type;25 typedef _Distance difference_type;
26 typedef _Pointer pointer;26 typedef _Pointer pointer;
lib/libcxx/include/__iterator/iterator_traits.h+71-126
...@@ -22,16 +22,18 @@...@@ -22,16 +22,18 @@
22#include <__fwd/pair.h>22#include <__fwd/pair.h>
23#include <__iterator/incrementable_traits.h>23#include <__iterator/incrementable_traits.h>
24#include <__iterator/readable_traits.h>24#include <__iterator/readable_traits.h>
25#include <__tuple/tuple_element.h>
25#include <__type_traits/common_reference.h>26#include <__type_traits/common_reference.h>
26#include <__type_traits/conditional.h>27#include <__type_traits/conditional.h>
28#include <__type_traits/detected_or.h>
27#include <__type_traits/disjunction.h>29#include <__type_traits/disjunction.h>
28#include <__type_traits/enable_if.h>
29#include <__type_traits/integral_constant.h>30#include <__type_traits/integral_constant.h>
30#include <__type_traits/is_convertible.h>31#include <__type_traits/is_convertible.h>
31#include <__type_traits/is_object.h>32#include <__type_traits/is_object.h>
32#include <__type_traits/is_primary_template.h>33#include <__type_traits/is_primary_template.h>
33#include <__type_traits/is_reference.h>34#include <__type_traits/is_reference.h>
34#include <__type_traits/is_valid_expansion.h>35#include <__type_traits/is_referenceable.h>
36#include <__type_traits/nat.h>
35#include <__type_traits/remove_const.h>37#include <__type_traits/remove_const.h>
36#include <__type_traits/remove_cv.h>38#include <__type_traits/remove_cv.h>
37#include <__type_traits/remove_cvref.h>39#include <__type_traits/remove_cvref.h>
...@@ -46,15 +48,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -46,15 +48,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4648
47#if _LIBCPP_STD_VER >= 2049#if _LIBCPP_STD_VER >= 20
4850
49template <class _Tp>
50using __with_reference _LIBCPP_NODEBUG = _Tp&;
51
52template <class _Tp>
53concept __can_reference = requires { typename __with_reference<_Tp>; };
54
55template <class _Tp>51template <class _Tp>
56concept __dereferenceable = requires(_Tp& __t) {52concept __dereferenceable = requires(_Tp& __t) {
57 { *__t } -> __can_reference; // not required to be equality-preserving53 { *__t } -> __referenceable; // not required to be equality-preserving
58};54};
5955
60// [iterator.traits]56// [iterator.traits]
...@@ -64,92 +60,17 @@ using iter_reference_t = decltype(*std::declval<_Tp&>());...@@ -64,92 +60,17 @@ using iter_reference_t = decltype(*std::declval<_Tp&>());
64#endif // _LIBCPP_STD_VER >= 2060#endif // _LIBCPP_STD_VER >= 20
6561
66template <class _Iter>62template <class _Iter>
67struct _LIBCPP_TEMPLATE_VIS iterator_traits;63struct iterator_traits;
6864
69struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {};65struct input_iterator_tag {};
70struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {};66struct output_iterator_tag {};
71struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {};67struct forward_iterator_tag : public input_iterator_tag {};
72struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {};68struct bidirectional_iterator_tag : public forward_iterator_tag {};
73struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {};69struct random_access_iterator_tag : public bidirectional_iterator_tag {};
74#if _LIBCPP_STD_VER >= 2070#if _LIBCPP_STD_VER >= 20
75struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {};71struct contiguous_iterator_tag : public random_access_iterator_tag {};
76#endif72#endif
7773
78template <class _Iter>
79struct __iter_traits_cache {
80 using type = _If< __is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
81};
82template <class _Iter>
83using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type;
84
85struct __iter_concept_concept_test {
86 template <class _Iter>
87 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_concept;
88};
89struct __iter_concept_category_test {
90 template <class _Iter>
91 using _Apply _LIBCPP_NODEBUG = typename _ITER_TRAITS<_Iter>::iterator_category;
92};
93struct __iter_concept_random_fallback {
94 template <class _Iter>
95 using _Apply _LIBCPP_NODEBUG =
96 __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>;
97};
98
99template <class _Iter, class _Tester>
100struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>, _Tester {};
101
102template <class _Iter>
103struct __iter_concept_cache {
104 using type = _Or< __test_iter_concept<_Iter, __iter_concept_concept_test>,
105 __test_iter_concept<_Iter, __iter_concept_category_test>,
106 __test_iter_concept<_Iter, __iter_concept_random_fallback> >;
107};
108
109template <class _Iter>
110using _ITER_CONCEPT _LIBCPP_NODEBUG = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>;
111
112template <class _Tp>
113struct __has_iterator_typedefs {
114private:
115 template <class _Up>
116 static false_type __test(...);
117 template <class _Up>
118 static true_type
119 __test(__void_t<typename _Up::iterator_category>* = nullptr,
120 __void_t<typename _Up::difference_type>* = nullptr,
121 __void_t<typename _Up::value_type>* = nullptr,
122 __void_t<typename _Up::reference>* = nullptr,
123 __void_t<typename _Up::pointer>* = nullptr);
124
125public:
126 static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value;
127};
128
129template <class _Tp>
130struct __has_iterator_category {
131private:
132 template <class _Up>
133 static false_type __test(...);
134 template <class _Up>
135 static true_type __test(typename _Up::iterator_category* = nullptr);
136
137public:
138 static const bool value = decltype(__test<_Tp>(nullptr))::value;
139};
140
141template <class _Tp>
142struct __has_iterator_concept {
143private:
144 template <class _Up>
145 static false_type __test(...);
146 template <class _Up>
147 static true_type __test(typename _Up::iterator_concept* = nullptr);
148
149public:
150 static const bool value = decltype(__test<_Tp>(nullptr))::value;
151};
152
153#if _LIBCPP_STD_VER >= 2074#if _LIBCPP_STD_VER >= 20
15475
155// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements76// The `cpp17-*-iterator` exposition-only concepts have very similar names to the `Cpp17*Iterator` named requirements
...@@ -158,9 +79,9 @@ public:...@@ -158,9 +79,9 @@ public:
158namespace __iterator_traits_detail {79namespace __iterator_traits_detail {
159template <class _Ip>80template <class _Ip>
160concept __cpp17_iterator = requires(_Ip __i) {81concept __cpp17_iterator = requires(_Ip __i) {
161 { *__i } -> __can_reference;82 { *__i } -> __referenceable;
162 { ++__i } -> same_as<_Ip&>;83 { ++__i } -> same_as<_Ip&>;
163 { *__i++ } -> __can_reference;84 { *__i++ } -> __referenceable;
164} && copyable<_Ip>;85} && copyable<_Ip>;
16586
166template <class _Ip>87template <class _Ip>
...@@ -219,16 +140,6 @@ concept __specifies_members = requires {...@@ -219,16 +140,6 @@ concept __specifies_members = requires {
219 requires __has_member_iterator_category<_Ip>;140 requires __has_member_iterator_category<_Ip>;
220};141};
221142
222template <class>
223struct __iterator_traits_member_pointer_or_void {
224 using type = void;
225};
226
227template <__has_member_pointer _Tp>
228struct __iterator_traits_member_pointer_or_void<_Tp> {
229 using type = typename _Tp::pointer;
230};
231
232template <class _Tp>143template <class _Tp>
233concept __cpp17_iterator_missing_members = !__specifies_members<_Tp> && __iterator_traits_detail::__cpp17_iterator<_Tp>;144concept __cpp17_iterator_missing_members = !__specifies_members<_Tp> && __iterator_traits_detail::__cpp17_iterator<_Tp>;
234145
...@@ -239,14 +150,14 @@ concept __cpp17_input_iterator_missing_members =...@@ -239,14 +150,14 @@ concept __cpp17_input_iterator_missing_members =
239// Otherwise, `pointer` names `void`.150// Otherwise, `pointer` names `void`.
240template <class>151template <class>
241struct __iterator_traits_member_pointer_or_arrow_or_void {152struct __iterator_traits_member_pointer_or_arrow_or_void {
242 using type = void;153 using type _LIBCPP_NODEBUG = void;
243};154};
244155
245// [iterator.traits]/3.2.1156// [iterator.traits]/3.2.1
246// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type.157// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type.
247template <__has_member_pointer _Ip>158template <__has_member_pointer _Ip>
248struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {159struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
249 using type = typename _Ip::pointer;160 using type _LIBCPP_NODEBUG = typename _Ip::pointer;
250};161};
251162
252// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that163// Otherwise, if `decltype(declval<I&>().operator->())` is well-formed, then `pointer` names that
...@@ -254,48 +165,48 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {...@@ -254,48 +165,48 @@ struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
254template <class _Ip>165template <class _Ip>
255 requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)166 requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>)
256struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {167struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> {
257 using type = decltype(std::declval<_Ip&>().operator->());168 using type _LIBCPP_NODEBUG = decltype(std::declval<_Ip&>().operator->());
258};169};
259170
260// Otherwise, `reference` names `iter-reference-t<I>`.171// Otherwise, `reference` names `iter-reference-t<I>`.
261template <class _Ip>172template <class _Ip>
262struct __iterator_traits_member_reference {173struct __iterator_traits_member_reference {
263 using type = iter_reference_t<_Ip>;174 using type _LIBCPP_NODEBUG = iter_reference_t<_Ip>;
264};175};
265176
266// [iterator.traits]/3.2.2177// [iterator.traits]/3.2.2
267// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type.178// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type.
268template <__has_member_reference _Ip>179template <__has_member_reference _Ip>
269struct __iterator_traits_member_reference<_Ip> {180struct __iterator_traits_member_reference<_Ip> {
270 using type = typename _Ip::reference;181 using type _LIBCPP_NODEBUG = typename _Ip::reference;
271};182};
272183
273// [iterator.traits]/3.2.3.4184// [iterator.traits]/3.2.3.4
274// input_iterator_tag185// input_iterator_tag
275template <class _Ip>186template <class _Ip>
276struct __deduce_iterator_category {187struct __deduce_iterator_category {
277 using type = input_iterator_tag;188 using type _LIBCPP_NODEBUG = input_iterator_tag;
278};189};
279190
280// [iterator.traits]/3.2.3.1191// [iterator.traits]/3.2.3.1
281// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise192// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise
282template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip>193template <__iterator_traits_detail::__cpp17_random_access_iterator _Ip>
283struct __deduce_iterator_category<_Ip> {194struct __deduce_iterator_category<_Ip> {
284 using type = random_access_iterator_tag;195 using type _LIBCPP_NODEBUG = random_access_iterator_tag;
285};196};
286197
287// [iterator.traits]/3.2.3.2198// [iterator.traits]/3.2.3.2
288// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise199// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise
289template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip>200template <__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip>
290struct __deduce_iterator_category<_Ip> {201struct __deduce_iterator_category<_Ip> {
291 using type = bidirectional_iterator_tag;202 using type _LIBCPP_NODEBUG = bidirectional_iterator_tag;
292};203};
293204
294// [iterator.traits]/3.2.3.3205// [iterator.traits]/3.2.3.3
295// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise206// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise
296template <__iterator_traits_detail::__cpp17_forward_iterator _Ip>207template <__iterator_traits_detail::__cpp17_forward_iterator _Ip>
297struct __deduce_iterator_category<_Ip> {208struct __deduce_iterator_category<_Ip> {
298 using type = forward_iterator_tag;209 using type _LIBCPP_NODEBUG = forward_iterator_tag;
299};210};
300211
301template <class _Ip>212template <class _Ip>
...@@ -306,13 +217,13 @@ struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {};...@@ -306,13 +217,13 @@ struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {};
306// that type.217// that type.
307template <__has_member_iterator_category _Ip>218template <__has_member_iterator_category _Ip>
308struct __iterator_traits_iterator_category<_Ip> {219struct __iterator_traits_iterator_category<_Ip> {
309 using type = typename _Ip::iterator_category;220 using type _LIBCPP_NODEBUG = typename _Ip::iterator_category;
310};221};
311222
312// otherwise, it names void.223// otherwise, it names void.
313template <class>224template <class>
314struct __iterator_traits_difference_type {225struct __iterator_traits_difference_type {
315 using type = void;226 using type _LIBCPP_NODEBUG = void;
316};227};
317228
318// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then229// If the qualified-id `incrementable_traits<I>::difference_type` is valid and denotes a type, then
...@@ -320,7 +231,7 @@ struct __iterator_traits_difference_type {...@@ -320,7 +231,7 @@ struct __iterator_traits_difference_type {
320template <class _Ip>231template <class _Ip>
321 requires requires { typename incrementable_traits<_Ip>::difference_type; }232 requires requires { typename incrementable_traits<_Ip>::difference_type; }
322struct __iterator_traits_difference_type<_Ip> {233struct __iterator_traits_difference_type<_Ip> {
323 using type = typename incrementable_traits<_Ip>::difference_type;234 using type _LIBCPP_NODEBUG = typename incrementable_traits<_Ip>::difference_type;
324};235};
325236
326// [iterator.traits]/3.4237// [iterator.traits]/3.4
...@@ -328,6 +239,9 @@ struct __iterator_traits_difference_type<_Ip> {...@@ -328,6 +239,9 @@ struct __iterator_traits_difference_type<_Ip> {
328template <class>239template <class>
329struct __iterator_traits {};240struct __iterator_traits {};
330241
242template <class _Tp>
243using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
244
331// [iterator.traits]/3.1245// [iterator.traits]/3.1
332// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and246// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and
333// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members:247// `iterator-category`, then `iterator-traits<I>` has the following publicly accessible members:
...@@ -336,7 +250,7 @@ struct __iterator_traits<_Ip> {...@@ -336,7 +250,7 @@ struct __iterator_traits<_Ip> {
336 using iterator_category = typename _Ip::iterator_category;250 using iterator_category = typename _Ip::iterator_category;
337 using value_type = typename _Ip::value_type;251 using value_type = typename _Ip::value_type;
338 using difference_type = typename _Ip::difference_type;252 using difference_type = typename _Ip::difference_type;
339 using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type;253 using pointer = __detected_or_t<void, __pointer_member, _Ip>;
340 using reference = typename _Ip::reference;254 using reference = typename _Ip::reference;
341};255};
342256
...@@ -391,13 +305,30 @@ struct __iterator_traits<_Iter, true>...@@ -391,13 +305,30 @@ struct __iterator_traits<_Iter, true>
391 is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||305 is_convertible<typename _Iter::iterator_category, input_iterator_tag>::value ||
392 is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value > {};306 is_convertible<typename _Iter::iterator_category, output_iterator_tag>::value > {};
393307
308template <class _Tp>
309struct __has_iterator_typedefs {
310private:
311 template <class _Up>
312 static false_type __test(...);
313 template <class _Up>
314 static true_type
315 __test(__void_t<typename _Up::iterator_category>* = nullptr,
316 __void_t<typename _Up::difference_type>* = nullptr,
317 __void_t<typename _Up::value_type>* = nullptr,
318 __void_t<typename _Up::reference>* = nullptr,
319 __void_t<typename _Up::pointer>* = nullptr);
320
321public:
322 static const bool value = decltype(__test<_Tp>(nullptr, nullptr, nullptr, nullptr, nullptr))::value;
323};
324
394// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category325// iterator_traits<Iterator> will only have the nested types if Iterator::iterator_category
395// exists. Else iterator_traits<Iterator> will be an empty class. This is a326// exists. Else iterator_traits<Iterator> will be an empty class. This is a
396// conforming extension which allows some programs to compile and behave as327// conforming extension which allows some programs to compile and behave as
397// the client expects instead of failing at compile time.328// the client expects instead of failing at compile time.
398329
399template <class _Iter>330template <class _Iter>
400struct _LIBCPP_TEMPLATE_VIS iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {331struct iterator_traits : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> {
401 using __primary_template _LIBCPP_NODEBUG = iterator_traits;332 using __primary_template _LIBCPP_NODEBUG = iterator_traits;
402};333};
403#endif // _LIBCPP_STD_VER >= 20334#endif // _LIBCPP_STD_VER >= 20
...@@ -406,7 +337,7 @@ template <class _Tp>...@@ -406,7 +337,7 @@ template <class _Tp>
406#if _LIBCPP_STD_VER >= 20337#if _LIBCPP_STD_VER >= 20
407 requires is_object_v<_Tp>338 requires is_object_v<_Tp>
408#endif339#endif
409struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> {340struct iterator_traits<_Tp*> {
410 typedef ptrdiff_t difference_type;341 typedef ptrdiff_t difference_type;
411 typedef __remove_cv_t<_Tp> value_type;342 typedef __remove_cv_t<_Tp> value_type;
412 typedef _Tp* pointer;343 typedef _Tp* pointer;
...@@ -417,18 +348,19 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> {...@@ -417,18 +348,19 @@ struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> {
417#endif348#endif
418};349};
419350
420template <class _Tp, class _Up, bool = __has_iterator_category<iterator_traits<_Tp> >::value>351template <class _Tp>
421struct __has_iterator_category_convertible_to : is_convertible<typename iterator_traits<_Tp>::iterator_category, _Up> {352using __iterator_category _LIBCPP_NODEBUG = typename _Tp::iterator_category;
422};
423353
424template <class _Tp, class _Up>354template <class _Tp>
425struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {};355using __iterator_concept _LIBCPP_NODEBUG = typename _Tp::iterator_concept;
426356
427template <class _Tp, class _Up, bool = __has_iterator_concept<_Tp>::value>357template <class _Tp, class _Up>
428struct __has_iterator_concept_convertible_to : is_convertible<typename _Tp::iterator_concept, _Up> {};358using __has_iterator_category_convertible_to _LIBCPP_NODEBUG =
359 is_convertible<__detected_or_t<__nat, __iterator_category, iterator_traits<_Tp> >, _Up>;
429360
430template <class _Tp, class _Up>361template <class _Tp, class _Up>
431struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {};362using __has_iterator_concept_convertible_to _LIBCPP_NODEBUG =
363 is_convertible<__detected_or_t<__nat, __iterator_concept, _Tp>, _Up>;
432364
433template <class _Tp>365template <class _Tp>
434using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;366using __has_input_iterator_category _LIBCPP_NODEBUG = __has_iterator_category_convertible_to<_Tp, input_iterator_tag>;
...@@ -490,6 +422,18 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG =...@@ -490,6 +422,18 @@ using __has_exactly_bidirectional_iterator_category _LIBCPP_NODEBUG =
490template <class _InputIterator>422template <class _InputIterator>
491using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type;423using __iter_value_type _LIBCPP_NODEBUG = typename iterator_traits<_InputIterator>::value_type;
492424
425#if _LIBCPP_STD_VER >= 23
426template <class _InputIterator>
427using __iter_key_type _LIBCPP_NODEBUG = remove_const_t<tuple_element_t<0, __iter_value_type<_InputIterator>>>;
428
429template <class _InputIterator>
430using __iter_mapped_type _LIBCPP_NODEBUG = tuple_element_t<1, __iter_value_type<_InputIterator>>;
431
432template <class _InputIterator>
433using __iter_to_alloc_type _LIBCPP_NODEBUG =
434 pair<const tuple_element_t<0, __iter_value_type<_InputIterator>>,
435 tuple_element_t<1, __iter_value_type<_InputIterator>>>;
436#else
493template <class _InputIterator>437template <class _InputIterator>
494using __iter_key_type _LIBCPP_NODEBUG =438using __iter_key_type _LIBCPP_NODEBUG =
495 __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;439 __remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
...@@ -501,6 +445,7 @@ template <class _InputIterator>...@@ -501,6 +445,7 @@ template <class _InputIterator>
501using __iter_to_alloc_type _LIBCPP_NODEBUG =445using __iter_to_alloc_type _LIBCPP_NODEBUG =
502 pair<const typename iterator_traits<_InputIterator>::value_type::first_type,446 pair<const typename iterator_traits<_InputIterator>::value_type::first_type,
503 typename iterator_traits<_InputIterator>::value_type::second_type>;447 typename iterator_traits<_InputIterator>::value_type::second_type>;
448#endif // _LIBCPP_STD_VER >= 23
504449
505template <class _Iter>450template <class _Iter>
506using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category;451using __iterator_category_type _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::iterator_category;
lib/libcxx/include/__iterator/move_iterator.h+1-1
...@@ -64,7 +64,7 @@ concept __move_iter_comparable = requires {...@@ -64,7 +64,7 @@ concept __move_iter_comparable = requires {
64#endif // _LIBCPP_STD_VER >= 2064#endif // _LIBCPP_STD_VER >= 20
6565
66template <class _Iter>66template <class _Iter>
67class _LIBCPP_TEMPLATE_VIS move_iterator67class move_iterator
68#if _LIBCPP_STD_VER >= 2068#if _LIBCPP_STD_VER >= 20
69 : public __move_iter_category_base<_Iter>69 : public __move_iter_category_base<_Iter>
70#endif70#endif
lib/libcxx/include/__iterator/move_sentinel.h+1-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
27#if _LIBCPP_STD_VER >= 2027#if _LIBCPP_STD_VER >= 20
2828
29template <semiregular _Sent>29template <semiregular _Sent>
30class _LIBCPP_TEMPLATE_VIS move_sentinel {30class move_sentinel {
31public:31public:
32 _LIBCPP_HIDE_FROM_ABI move_sentinel() = default;32 _LIBCPP_HIDE_FROM_ABI move_sentinel() = default;
3333
lib/libcxx/include/__iterator/next.h-6
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#ifndef _LIBCPP___ITERATOR_NEXT_H10#ifndef _LIBCPP___ITERATOR_NEXT_H
11#define _LIBCPP___ITERATOR_NEXT_H11#define _LIBCPP___ITERATOR_NEXT_H
1212
13#include <__assert>
14#include <__config>13#include <__config>
15#include <__iterator/advance.h>14#include <__iterator/advance.h>
16#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
...@@ -27,11 +26,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,11 +26,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
27template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>26template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
28[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter27[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter
29next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {28next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) {
30 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
31 // Note that this check duplicates the similar check in `std::advance`.
32 _LIBCPP_ASSERT_PEDANTIC(__n >= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
33 "Attempt to next(it, n) with negative n on a non-bidirectional iterator");
34
35 std::advance(__x, __n);29 std::advance(__x, __n);
36 return __x;30 return __x;
37}31}
lib/libcxx/include/__iterator/ostream_iterator.h+1-1
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
27_LIBCPP_SUPPRESS_DEPRECATED_PUSH27_LIBCPP_SUPPRESS_DEPRECATED_PUSH
28template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >28template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> >
29class _LIBCPP_TEMPLATE_VIS ostream_iterator29class ostream_iterator
30#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)30#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
31 : public iterator<output_iterator_tag, void, void, void, void>31 : public iterator<output_iterator_tag, void, void, void, void>
32#endif32#endif
lib/libcxx/include/__iterator/ostreambuf_iterator.h+1-1
...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727
28_LIBCPP_SUPPRESS_DEPRECATED_PUSH28_LIBCPP_SUPPRESS_DEPRECATED_PUSH
29template <class _CharT, class _Traits>29template <class _CharT, class _Traits>
30class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator30class ostreambuf_iterator
31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)31#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
32 : public iterator<output_iterator_tag, void, void, void, void>32 : public iterator<output_iterator_tag, void, void, void, void>
33#endif33#endif
lib/libcxx/include/__iterator/prev.h-5
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#ifndef _LIBCPP___ITERATOR_PREV_H10#ifndef _LIBCPP___ITERATOR_PREV_H
11#define _LIBCPP___ITERATOR_PREV_H11#define _LIBCPP___ITERATOR_PREV_H
1212
13#include <__assert>
14#include <__config>13#include <__config>
15#include <__iterator/advance.h>14#include <__iterator/advance.h>
16#include <__iterator/concepts.h>15#include <__iterator/concepts.h>
...@@ -31,10 +30,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,10 +30,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
31template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>30template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
32[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter31[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _InputIter
33prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) {32prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n) {
34 // Calling `advance` with a negative value on a non-bidirectional iterator is a no-op in the current implementation.
35 // Note that this check duplicates the similar check in `std::advance`.
36 _LIBCPP_ASSERT_PEDANTIC(__n <= 0 || __has_bidirectional_iterator_category<_InputIter>::value,
37 "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator");
38 std::advance(__x, -__n);33 std::advance(__x, -__n);
39 return __x;34 return __x;
40}35}
lib/libcxx/include/__iterator/product_iterator.h created+76
...@@ -0,0 +1,76 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H
10#define _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H
11
12// Product iterators are iterators that contain two or more underlying iterators.
13//
14// For example, std::flat_map stores its data into two separate containers, and its iterator
15// is a proxy over two separate underlying iterators. The concept of product iterators
16// allows algorithms to operate over these underlying iterators separately, opening the
17// door to various optimizations.
18//
19// If __product_iterator_traits can be instantiated, the following functions and associated types must be provided:
20// - static constexpr size_t Traits::__size
21// The number of underlying iterators inside the product iterator.
22//
23// - template <size_t _N>
24// static decltype(auto) Traits::__get_iterator_element(It&& __it)
25// Returns the _Nth iterator element of the given product iterator.
26//
27// - template <class... _Iters>
28// static _Iterator __make_product_iterator(_Iters&&...);
29// Creates a product iterator from the given underlying iterators.
30
31#include <__config>
32#include <__cstddef/size_t.h>
33#include <__type_traits/enable_if.h>
34#include <__type_traits/integral_constant.h>
35#include <__utility/declval.h>
36
37#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
38# pragma GCC system_header
39#endif
40
41_LIBCPP_BEGIN_NAMESPACE_STD
42
43template <class _Iterator>
44struct __product_iterator_traits;
45/* exposition-only:
46{
47 static constexpr size_t __size = ...;
48
49 template <size_t _N, class _Iter>
50 static decltype(auto) __get_iterator_element(_Iter&&);
51
52 template <class... _Iters>
53 static _Iterator __make_product_iterator(_Iters&&...);
54};
55*/
56
57template <class _Tp, size_t = 0>
58struct __is_product_iterator : false_type {};
59
60template <class _Tp>
61struct __is_product_iterator<_Tp, sizeof(__product_iterator_traits<_Tp>) * 0> : true_type {};
62
63template <class _Tp, size_t _Size, class = void>
64struct __is_product_iterator_of_size : false_type {};
65
66template <class _Tp, size_t _Size>
67struct __is_product_iterator_of_size<_Tp, _Size, __enable_if_t<__product_iterator_traits<_Tp>::__size == _Size> >
68 : true_type {};
69
70template <class _Iterator, size_t _Nth>
71using __product_iterator_element_t _LIBCPP_NODEBUG =
72 decltype(__product_iterator_traits<_Iterator>::template __get_iterator_element<_Nth>(std::declval<_Iterator>()));
73
74_LIBCPP_END_NAMESPACE_STD
75
76#endif // _LIBCPP___ITERATOR_PRODUCT_ITERATOR_H
lib/libcxx/include/__iterator/reverse_iterator.h+1-1
...@@ -48,7 +48,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -48,7 +48,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4848
49_LIBCPP_SUPPRESS_DEPRECATED_PUSH49_LIBCPP_SUPPRESS_DEPRECATED_PUSH
50template <class _Iter>50template <class _Iter>
51class _LIBCPP_TEMPLATE_VIS reverse_iterator51class reverse_iterator
52#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)52#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
53 : public iterator<typename iterator_traits<_Iter>::iterator_category,53 : public iterator<typename iterator_traits<_Iter>::iterator_category,
54 typename iterator_traits<_Iter>::value_type,54 typename iterator_traits<_Iter>::value_type,
lib/libcxx/include/__iterator/segmented_iterator.h+6
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
4242
43#include <__config>43#include <__config>
44#include <__cstddef/size_t.h>44#include <__cstddef/size_t.h>
45#include <__iterator/iterator_traits.h>
45#include <__type_traits/integral_constant.h>46#include <__type_traits/integral_constant.h>
4647
47#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)48#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -74,6 +75,11 @@ struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};...@@ -74,6 +75,11 @@ struct __has_specialization<_Tp, sizeof(_Tp) * 0> : true_type {};
74template <class _Iterator>75template <class _Iterator>
75using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >;76using __is_segmented_iterator _LIBCPP_NODEBUG = __has_specialization<__segmented_iterator_traits<_Iterator> >;
7677
78template <class _SegmentedIterator>
79struct __has_random_access_local_iterator
80 : __has_random_access_iterator_category<
81 typename __segmented_iterator_traits< _SegmentedIterator >::__local_iterator > {};
82
77_LIBCPP_END_NAMESPACE_STD83_LIBCPP_END_NAMESPACE_STD
7884
79#endif // _LIBCPP___SEGMENTED_ITERATOR_H85#endif // _LIBCPP___SEGMENTED_ITERATOR_H
lib/libcxx/include/__iterator/wrap_iter.h+3-3
...@@ -112,9 +112,9 @@ private:...@@ -112,9 +112,9 @@ private:
112 template <class _CharT, class _Traits>112 template <class _CharT, class _Traits>
113 friend class basic_string_view;113 friend class basic_string_view;
114 template <class _Tp, class _Alloc>114 template <class _Tp, class _Alloc>
115 friend class _LIBCPP_TEMPLATE_VIS vector;115 friend class vector;
116 template <class _Tp, size_t>116 template <class _Tp, size_t>
117 friend class _LIBCPP_TEMPLATE_VIS span;117 friend class span;
118 template <class _Tp, size_t _Size>118 template <class _Tp, size_t _Size>
119 friend struct array;119 friend struct array;
120};120};
...@@ -236,7 +236,7 @@ struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {};...@@ -236,7 +236,7 @@ struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {};
236#endif236#endif
237237
238template <class _It>238template <class _It>
239struct _LIBCPP_TEMPLATE_VIS pointer_traits<__wrap_iter<_It> > {239struct pointer_traits<__wrap_iter<_It> > {
240 typedef __wrap_iter<_It> pointer;240 typedef __wrap_iter<_It> pointer;
241 typedef typename pointer_traits<_It>::element_type element_type;241 typedef typename pointer_traits<_It>::element_type element_type;
242 typedef typename pointer_traits<_It>::difference_type difference_type;242 typedef typename pointer_traits<_It>::difference_type difference_type;
lib/libcxx/include/__locale+114-122
...@@ -11,36 +11,43 @@...@@ -11,36 +11,43 @@
11#define _LIBCPP___LOCALE11#define _LIBCPP___LOCALE
1212
13#include <__config>13#include <__config>
14#include <__locale_dir/locale_base_api.h>14
15#include <__memory/shared_count.h>15#if _LIBCPP_HAS_LOCALIZATION
16#include <__mutex/once_flag.h>16
17#include <__type_traits/make_unsigned.h>17# include <__locale_dir/locale_base_api.h>
18#include <__utility/no_destroy.h>18# include <__memory/addressof.h>
19#include <__utility/private_constructor_tag.h>19# include <__memory/shared_count.h>
20#include <cctype>20# include <__mutex/once_flag.h>
21#include <clocale>21# include <__type_traits/make_unsigned.h>
22#include <cstdint>22# include <__utility/no_destroy.h>
23#include <cstdlib>23# include <__utility/private_constructor_tag.h>
24#include <string>24# include <cctype>
25# include <clocale>
26# include <cstdint>
27# include <cstdlib>
28# include <string>
2529
26// Some platforms require more includes than others. Keep the includes on all plaforms for now.30// Some platforms require more includes than others. Keep the includes on all plaforms for now.
27#include <cstddef>31# include <cstddef>
28#include <cstring>32# include <cstring>
2933
30#if _LIBCPP_HAS_WIDE_CHARACTERS34# if _LIBCPP_HAS_WIDE_CHARACTERS
31# include <cwchar>35# include <cwchar>
32#else36# else
33# include <__std_mbstate_t.h>37# include <__std_mbstate_t.h>
34#endif38# endif
3539
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)40# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header41# pragma GCC system_header
38#endif42# endif
3943
40_LIBCPP_BEGIN_NAMESPACE_STD44_LIBCPP_BEGIN_NAMESPACE_STD
4145
42class _LIBCPP_EXPORTED_FROM_ABI locale;46class _LIBCPP_EXPORTED_FROM_ABI locale;
4347
48template <class _CharT>
49class collate;
50
44template <class _Facet>51template <class _Facet>
45_LIBCPP_HIDE_FROM_ABI bool has_facet(const locale&) _NOEXCEPT;52_LIBCPP_HIDE_FROM_ABI bool has_facet(const locale&) _NOEXCEPT;
4653
...@@ -49,8 +56,10 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);...@@ -49,8 +56,10 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);
4956
50class _LIBCPP_EXPORTED_FROM_ABI locale {57class _LIBCPP_EXPORTED_FROM_ABI locale {
51public:58public:
52 // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor.59 // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor,
60 // so it is trivially relocatable. Like shared_ptr, it is also replaceable.
53 using __trivially_relocatable _LIBCPP_NODEBUG = locale;61 using __trivially_relocatable _LIBCPP_NODEBUG = locale;
62 using __replaceable _LIBCPP_NODEBUG = locale;
5463
55 // types:64 // types:
56 class _LIBCPP_EXPORTED_FROM_ABI facet;65 class _LIBCPP_EXPORTED_FROM_ABI facet;
...@@ -80,17 +89,25 @@ public:...@@ -80,17 +89,25 @@ public:
80 const locale& operator=(const locale&) _NOEXCEPT;89 const locale& operator=(const locale&) _NOEXCEPT;
8190
82 template <class _Facet>91 template <class _Facet>
83 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS locale combine(const locale&) const;92 _LIBCPP_HIDE_FROM_ABI locale combine(const locale& __other) const {
93 if (!std::has_facet<_Facet>(__other))
94 __throw_runtime_error("locale::combine: locale missing facet");
95
96 return locale(*this, std::addressof(const_cast<_Facet&>(std::use_facet<_Facet>(__other))));
97 }
8498
85 // locale operations:99 // locale operations:
86 string name() const;100 string name() const;
87 bool operator==(const locale&) const;101 bool operator==(const locale&) const;
88#if _LIBCPP_STD_VER <= 17102# if _LIBCPP_STD_VER <= 17
89 _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); }103 _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); }
90#endif104# endif
91 template <class _CharT, class _Traits, class _Allocator>105 template <class _CharT, class _Traits, class _Allocator>
92 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool106 _LIBCPP_HIDE_FROM_ABI bool operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
93 operator()(const basic_string<_CharT, _Traits, _Allocator>&, const basic_string<_CharT, _Traits, _Allocator>&) const;107 const basic_string<_CharT, _Traits, _Allocator>& __y) const {
108 return std::use_facet<std::collate<_CharT> >(*this).compare(
109 __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0;
110 }
94111
95 // global locale objects:112 // global locale objects:
96 static locale global(const locale&);113 static locale global(const locale&);
...@@ -151,14 +168,6 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f)...@@ -151,14 +168,6 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f)
151 __install_ctor(__other, __f, __f ? __f->id.__get() : 0);168 __install_ctor(__other, __f, __f ? __f->id.__get() : 0);
152}169}
153170
154template <class _Facet>
155locale locale::combine(const locale& __other) const {
156 if (!std::has_facet<_Facet>(__other))
157 __throw_runtime_error("locale::combine: locale missing facet");
158
159 return locale(*this, &const_cast<_Facet&>(std::use_facet<_Facet>(__other)));
160}
161
162template <class _Facet>171template <class _Facet>
163inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT {172inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT {
164 return __l.has_facet(_Facet::id);173 return __l.has_facet(_Facet::id);
...@@ -172,7 +181,7 @@ inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) {...@@ -172,7 +181,7 @@ inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) {
172// template <class _CharT> class collate;181// template <class _CharT> class collate;
173182
174template <class _CharT>183template <class _CharT>
175class _LIBCPP_TEMPLATE_VIS collate : public locale::facet {184class collate : public locale::facet {
176public:185public:
177 typedef _CharT char_type;186 typedef _CharT char_type;
178 typedef basic_string<char_type> string_type;187 typedef basic_string<char_type> string_type;
...@@ -237,14 +246,14 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons...@@ -237,14 +246,14 @@ long collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) cons
237}246}
238247
239extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;248extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<char>;
240#if _LIBCPP_HAS_WIDE_CHARACTERS249# if _LIBCPP_HAS_WIDE_CHARACTERS
241extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;250extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS collate<wchar_t>;
242#endif251# endif
243252
244// template <class CharT> class collate_byname;253// template <class CharT> class collate_byname;
245254
246template <class _CharT>255template <class _CharT>
247class _LIBCPP_TEMPLATE_VIS collate_byname;256class collate_byname;
248257
249template <>258template <>
250class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {259class _LIBCPP_EXPORTED_FROM_ABI collate_byname<char> : public collate<char> {
...@@ -264,7 +273,7 @@ protected:...@@ -264,7 +273,7 @@ protected:
264 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;273 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
265};274};
266275
267#if _LIBCPP_HAS_WIDE_CHARACTERS276# if _LIBCPP_HAS_WIDE_CHARACTERS
268template <>277template <>
269class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {278class _LIBCPP_EXPORTED_FROM_ABI collate_byname<wchar_t> : public collate<wchar_t> {
270 __locale::__locale_t __l_;279 __locale::__locale_t __l_;
...@@ -283,20 +292,13 @@ protected:...@@ -283,20 +292,13 @@ protected:
283 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const override;292 const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const override;
284 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;293 string_type do_transform(const char_type* __lo, const char_type* __hi) const override;
285};294};
286#endif295# endif
287
288template <class _CharT, class _Traits, class _Allocator>
289bool locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
290 const basic_string<_CharT, _Traits, _Allocator>& __y) const {
291 return std::use_facet<std::collate<_CharT> >(*this).compare(
292 __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0;
293}
294296
295// template <class charT> class ctype297// template <class charT> class ctype
296298
297class _LIBCPP_EXPORTED_FROM_ABI ctype_base {299class _LIBCPP_EXPORTED_FROM_ABI ctype_base {
298public:300public:
299#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)301# if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
300 typedef unsigned long mask;302 typedef unsigned long mask;
301 static const mask space = 1 << 0;303 static const mask space = 1 << 0;
302 static const mask print = 1 << 1;304 static const mask print = 1 << 1;
...@@ -308,14 +310,14 @@ public:...@@ -308,14 +310,14 @@ public:
308 static const mask punct = 1 << 7;310 static const mask punct = 1 << 7;
309 static const mask xdigit = 1 << 8;311 static const mask xdigit = 1 << 8;
310 static const mask blank = 1 << 9;312 static const mask blank = 1 << 9;
311# if defined(__BIONIC__)313# if defined(__BIONIC__)
312 // Historically this was a part of regex_traits rather than ctype_base. The314 // Historically this was a part of regex_traits rather than ctype_base. The
313 // historical value of the constant is preserved for ABI compatibility.315 // historical value of the constant is preserved for ABI compatibility.
314 static const mask __regex_word = 0x8000;316 static const mask __regex_word = 0x8000;
315# else317# else
316 static const mask __regex_word = 1 << 10;318 static const mask __regex_word = 1 << 10;
317# endif // defined(__BIONIC__)319# endif // defined(__BIONIC__)
318#elif defined(__GLIBC__)320# elif defined(__GLIBC__)
319 typedef unsigned short mask;321 typedef unsigned short mask;
320 static const mask space = _ISspace;322 static const mask space = _ISspace;
321 static const mask print = _ISprint;323 static const mask print = _ISprint;
...@@ -327,12 +329,12 @@ public:...@@ -327,12 +329,12 @@ public:
327 static const mask punct = _ISpunct;329 static const mask punct = _ISpunct;
328 static const mask xdigit = _ISxdigit;330 static const mask xdigit = _ISxdigit;
329 static const mask blank = _ISblank;331 static const mask blank = _ISblank;
330# if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN)332# if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN)
331 static const mask __regex_word = static_cast<mask>(_ISbit(15));333 static const mask __regex_word = static_cast<mask>(_ISbit(15));
332# else334# else
333 static const mask __regex_word = 0x80;335 static const mask __regex_word = 0x80;
334# endif336# endif
335#elif defined(_LIBCPP_MSVCRT_LIKE)337# elif defined(_LIBCPP_MSVCRT_LIKE)
336 typedef unsigned short mask;338 typedef unsigned short mask;
337 static const mask space = _SPACE;339 static const mask space = _SPACE;
338 static const mask print = _BLANK | _PUNCT | _ALPHA | _DIGIT;340 static const mask print = _BLANK | _PUNCT | _ALPHA | _DIGIT;
...@@ -345,16 +347,16 @@ public:...@@ -345,16 +347,16 @@ public:
345 static const mask xdigit = _HEX;347 static const mask xdigit = _HEX;
346 static const mask blank = _BLANK;348 static const mask blank = _BLANK;
347 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used349 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
348# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT350# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
349# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA351# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
350#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)352# elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
351# ifdef __APPLE__353# ifdef __APPLE__
352 typedef uint32_t mask;354 typedef uint32_t mask;
353# elif defined(__FreeBSD__)355# elif defined(__FreeBSD__)
354 typedef unsigned long mask;356 typedef unsigned long mask;
355# elif defined(__NetBSD__)357# elif defined(__NetBSD__)
356 typedef unsigned short mask;358 typedef unsigned short mask;
357# endif359# endif
358 static const mask space = _CTYPE_S;360 static const mask space = _CTYPE_S;
359 static const mask print = _CTYPE_R;361 static const mask print = _CTYPE_R;
360 static const mask cntrl = _CTYPE_C;362 static const mask cntrl = _CTYPE_C;
...@@ -365,16 +367,16 @@ public:...@@ -365,16 +367,16 @@ public:
365 static const mask punct = _CTYPE_P;367 static const mask punct = _CTYPE_P;
366 static const mask xdigit = _CTYPE_X;368 static const mask xdigit = _CTYPE_X;
367369
368# if defined(__NetBSD__)370# if defined(__NetBSD__)
369 static const mask blank = _CTYPE_BL;371 static const mask blank = _CTYPE_BL;
370 // NetBSD defines classes up to 0x2000372 // NetBSD defines classes up to 0x2000
371 // see sys/ctype_bits.h, _CTYPE_Q373 // see sys/ctype_bits.h, _CTYPE_Q
372 static const mask __regex_word = 0x8000;374 static const mask __regex_word = 0x8000;
373# else375# else
374 static const mask blank = _CTYPE_B;376 static const mask blank = _CTYPE_B;
375 static const mask __regex_word = 0x80;377 static const mask __regex_word = 0x80;
376# endif378# endif
377#elif defined(_AIX)379# elif defined(_AIX)
378 typedef unsigned int mask;380 typedef unsigned int mask;
379 static const mask space = _ISSPACE;381 static const mask space = _ISSPACE;
380 static const mask print = _ISPRINT;382 static const mask print = _ISPRINT;
...@@ -387,7 +389,7 @@ public:...@@ -387,7 +389,7 @@ public:
387 static const mask xdigit = _ISXDIGIT;389 static const mask xdigit = _ISXDIGIT;
388 static const mask blank = _ISBLANK;390 static const mask blank = _ISBLANK;
389 static const mask __regex_word = 0x8000;391 static const mask __regex_word = 0x8000;
390#elif defined(_NEWLIB_VERSION)392# elif defined(_NEWLIB_VERSION)
391 // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.393 // Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
392 typedef char mask;394 typedef char mask;
393 // In case char is signed, static_cast is needed to avoid warning on395 // In case char is signed, static_cast is needed to avoid warning on
...@@ -404,11 +406,11 @@ public:...@@ -404,11 +406,11 @@ public:
404 static const mask blank = static_cast<mask>(_B);406 static const mask blank = static_cast<mask>(_B);
405 // mask is already fully saturated, use a different type in regex_type_traits.407 // mask is already fully saturated, use a different type in regex_type_traits.
406 static const unsigned short __regex_word = 0x100;408 static const unsigned short __regex_word = 0x100;
407# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT409# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
408# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA410# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
409# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT411# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
410#elif defined(__MVS__)412# elif defined(__MVS__)
411# if defined(__NATIVE_ASCII_F)413# if defined(__NATIVE_ASCII_F)
412 typedef unsigned int mask;414 typedef unsigned int mask;
413 static const mask space = _ISSPACE_A;415 static const mask space = _ISSPACE_A;
414 static const mask print = _ISPRINT_A;416 static const mask print = _ISPRINT_A;
...@@ -420,7 +422,7 @@ public:...@@ -420,7 +422,7 @@ public:
420 static const mask punct = _ISPUNCT_A;422 static const mask punct = _ISPUNCT_A;
421 static const mask xdigit = _ISXDIGIT_A;423 static const mask xdigit = _ISXDIGIT_A;
422 static const mask blank = _ISBLANK_A;424 static const mask blank = _ISBLANK_A;
423# else425# else
424 typedef unsigned short mask;426 typedef unsigned short mask;
425 static const mask space = __ISSPACE;427 static const mask space = __ISSPACE;
426 static const mask print = __ISPRINT;428 static const mask print = __ISPRINT;
...@@ -432,11 +434,11 @@ public:...@@ -432,11 +434,11 @@ public:
432 static const mask punct = __ISPUNCT;434 static const mask punct = __ISPUNCT;
433 static const mask xdigit = __ISXDIGIT;435 static const mask xdigit = __ISXDIGIT;
434 static const mask blank = __ISBLANK;436 static const mask blank = __ISBLANK;
435# endif437# endif
436 static const mask __regex_word = 0x8000;438 static const mask __regex_word = 0x8000;
437#else439# else
438# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?440# error unknown rune table for this platform -- do you mean to define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE?
439#endif441# endif
440 static const mask alnum = alpha | digit;442 static const mask alnum = alpha | digit;
441 static const mask graph = alnum | punct;443 static const mask graph = alnum | punct;
442444
...@@ -448,9 +450,9 @@ public:...@@ -448,9 +450,9 @@ public:
448};450};
449451
450template <class _CharT>452template <class _CharT>
451class _LIBCPP_TEMPLATE_VIS ctype;453class ctype;
452454
453#if _LIBCPP_HAS_WIDE_CHARACTERS455# if _LIBCPP_HAS_WIDE_CHARACTERS
454template <>456template <>
455class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base {457class _LIBCPP_EXPORTED_FROM_ABI ctype<wchar_t> : public locale::facet, public ctype_base {
456public:458public:
...@@ -515,7 +517,7 @@ protected:...@@ -515,7 +517,7 @@ protected:
515 virtual const char_type*517 virtual const char_type*
516 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;518 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const;
517};519};
518#endif // _LIBCPP_HAS_WIDE_CHARACTERS520# endif // _LIBCPP_HAS_WIDE_CHARACTERS
519521
520inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; }522inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_isascii(int __c) { return (__c & ~0x7F) == 0; }
521523
...@@ -580,25 +582,13 @@ public:...@@ -580,25 +582,13 @@ public:
580582
581 static locale::id id;583 static locale::id id;
582584
583#ifdef _CACHED_RUNES585# ifdef _CACHED_RUNES
584 static const size_t table_size = _CACHED_RUNES;586 static const size_t table_size = _CACHED_RUNES;
585#else587# else
586 static const size_t table_size = 256; // FIXME: Don't hardcode this.588 static const size_t table_size = 256; // FIXME: Don't hardcode this.
587#endif589# endif
588 _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; }590 _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; }
589 static const mask* classic_table() _NOEXCEPT;591 static const mask* classic_table() _NOEXCEPT;
590#if defined(__GLIBC__) || defined(__EMSCRIPTEN__)
591 static const int* __classic_upper_table() _NOEXCEPT;
592 static const int* __classic_lower_table() _NOEXCEPT;
593#endif
594#if defined(__NetBSD__)
595 static const short* __classic_upper_table() _NOEXCEPT;
596 static const short* __classic_lower_table() _NOEXCEPT;
597#endif
598#if defined(__MVS__)
599 static const unsigned short* __classic_upper_table() _NOEXCEPT;
600 static const unsigned short* __classic_lower_table() _NOEXCEPT;
601#endif
602592
603protected:593protected:
604 ~ctype() override;594 ~ctype() override;
...@@ -615,7 +605,7 @@ protected:...@@ -615,7 +605,7 @@ protected:
615// template <class CharT> class ctype_byname;605// template <class CharT> class ctype_byname;
616606
617template <class _CharT>607template <class _CharT>
618class _LIBCPP_TEMPLATE_VIS ctype_byname;608class ctype_byname;
619609
620template <>610template <>
621class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {611class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<char> : public ctype<char> {
...@@ -633,7 +623,7 @@ protected:...@@ -633,7 +623,7 @@ protected:
633 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;623 const char_type* do_tolower(char_type* __low, const char_type* __high) const override;
634};624};
635625
636#if _LIBCPP_HAS_WIDE_CHARACTERS626# if _LIBCPP_HAS_WIDE_CHARACTERS
637template <>627template <>
638class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {628class _LIBCPP_EXPORTED_FROM_ABI ctype_byname<wchar_t> : public ctype<wchar_t> {
639 __locale::__locale_t __l_;629 __locale::__locale_t __l_;
...@@ -658,7 +648,7 @@ protected:...@@ -658,7 +648,7 @@ protected:
658 const char_type*648 const char_type*
659 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;649 do_narrow(const char_type* __low, const char_type* __high, char __dfault, char* __dest) const override;
660};650};
661#endif // _LIBCPP_HAS_WIDE_CHARACTERS651# endif // _LIBCPP_HAS_WIDE_CHARACTERS
662652
663template <class _CharT>653template <class _CharT>
664inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {654inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {
...@@ -741,7 +731,7 @@ public:...@@ -741,7 +731,7 @@ public:
741// template <class internT, class externT, class stateT> class codecvt;731// template <class internT, class externT, class stateT> class codecvt;
742732
743template <class _InternT, class _ExternT, class _StateT>733template <class _InternT, class _ExternT, class _StateT>
744class _LIBCPP_TEMPLATE_VIS codecvt;734class codecvt;
745735
746// template <> class codecvt<char, char, mbstate_t>736// template <> class codecvt<char, char, mbstate_t>
747737
...@@ -824,7 +814,7 @@ protected:...@@ -824,7 +814,7 @@ protected:
824814
825// template <> class codecvt<wchar_t, char, mbstate_t>815// template <> class codecvt<wchar_t, char, mbstate_t>
826816
827#if _LIBCPP_HAS_WIDE_CHARACTERS817# if _LIBCPP_HAS_WIDE_CHARACTERS
828template <>818template <>
829class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {819class _LIBCPP_EXPORTED_FROM_ABI codecvt<wchar_t, char, mbstate_t> : public locale::facet, public codecvt_base {
830 __locale::__locale_t __l_;820 __locale::__locale_t __l_;
...@@ -903,7 +893,7 @@ protected:...@@ -903,7 +893,7 @@ protected:
903 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;893 virtual int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const;
904 virtual int do_max_length() const _NOEXCEPT;894 virtual int do_max_length() const _NOEXCEPT;
905};895};
906#endif // _LIBCPP_HAS_WIDE_CHARACTERS896# endif // _LIBCPP_HAS_WIDE_CHARACTERS
907897
908// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20898// template <> class codecvt<char16_t, char, mbstate_t> // deprecated in C++20
909899
...@@ -985,7 +975,7 @@ protected:...@@ -985,7 +975,7 @@ protected:
985 virtual int do_max_length() const _NOEXCEPT;975 virtual int do_max_length() const _NOEXCEPT;
986};976};
987977
988#if _LIBCPP_HAS_CHAR8_T978# if _LIBCPP_HAS_CHAR8_T
989979
990// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20980// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
991981
...@@ -1066,7 +1056,7 @@ protected:...@@ -1066,7 +1056,7 @@ protected:
1066 virtual int do_max_length() const _NOEXCEPT;1056 virtual int do_max_length() const _NOEXCEPT;
1067};1057};
10681058
1069#endif1059# endif
10701060
1071// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++201061// template <> class codecvt<char32_t, char, mbstate_t> // deprecated in C++20
10721062
...@@ -1148,7 +1138,7 @@ protected:...@@ -1148,7 +1138,7 @@ protected:
1148 virtual int do_max_length() const _NOEXCEPT;1138 virtual int do_max_length() const _NOEXCEPT;
1149};1139};
11501140
1151#if _LIBCPP_HAS_CHAR8_T1141# if _LIBCPP_HAS_CHAR8_T
11521142
1153// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++201143// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
11541144
...@@ -1229,12 +1219,12 @@ protected:...@@ -1229,12 +1219,12 @@ protected:
1229 virtual int do_max_length() const _NOEXCEPT;1219 virtual int do_max_length() const _NOEXCEPT;
1230};1220};
12311221
1232#endif1222# endif
12331223
1234// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname1224// template <class _InternT, class _ExternT, class _StateT> class codecvt_byname
12351225
1236template <class _InternT, class _ExternT, class _StateT>1226template <class _InternT, class _ExternT, class _StateT>
1237class _LIBCPP_TEMPLATE_VIS codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {1227class codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> {
1238public:1228public:
1239 _LIBCPP_HIDE_FROM_ABI explicit codecvt_byname(const char* __nm, size_t __refs = 0)1229 _LIBCPP_HIDE_FROM_ABI explicit codecvt_byname(const char* __nm, size_t __refs = 0)
1240 : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}1230 : codecvt<_InternT, _ExternT, _StateT>(__nm, __refs) {}
...@@ -1251,17 +1241,17 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {}...@@ -1251,17 +1241,17 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() {}
1251_LIBCPP_SUPPRESS_DEPRECATED_POP1241_LIBCPP_SUPPRESS_DEPRECATED_POP
12521242
1253extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;1243extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char, mbstate_t>;
1254#if _LIBCPP_HAS_WIDE_CHARACTERS1244# if _LIBCPP_HAS_WIDE_CHARACTERS
1255extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;1245extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
1256#endif1246# endif
1257extern template class _LIBCPP_DEPRECATED_IN_CXX201247extern template class _LIBCPP_DEPRECATED_IN_CXX20
1258_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++201248_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1259extern template class _LIBCPP_DEPRECATED_IN_CXX201249extern template class _LIBCPP_DEPRECATED_IN_CXX20
1260_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++201250_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
1261#if _LIBCPP_HAS_CHAR8_T1251# if _LIBCPP_HAS_CHAR8_T
1262extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++201252extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
1263extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++201253extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
1264#endif1254# endif
12651255
1266template <size_t _Np>1256template <size_t _Np>
1267struct __narrow_to_utf8 {1257struct __narrow_to_utf8 {
...@@ -1298,7 +1288,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t,...@@ -1298,7 +1288,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<16> : public codecvt<char16_t,
1298 const char16_t* __wn = (const char16_t*)__wb;1288 const char16_t* __wn = (const char16_t*)__wb;
1299 __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf + __sz, __bn);1289 __r = do_out(__mb, (const char16_t*)__wb, (const char16_t*)__we, __wn, __buf, __buf + __sz, __bn);
1300 if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)1290 if (__r == codecvt_base::error || __wn == (const char16_t*)__wb)
1301 __throw_runtime_error("locale not supported");1291 std::__throw_runtime_error("locale not supported");
1302 for (const char* __p = __buf; __p < __bn; ++__p, ++__s)1292 for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1303 *__s = *__p;1293 *__s = *__p;
1304 __wb = (const _CharT*)__wn;1294 __wb = (const _CharT*)__wn;
...@@ -1326,7 +1316,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t,...@@ -1326,7 +1316,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __narrow_to_utf8<32> : public codecvt<char32_t,
1326 const char32_t* __wn = (const char32_t*)__wb;1316 const char32_t* __wn = (const char32_t*)__wb;
1327 __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf + __sz, __bn);1317 __r = do_out(__mb, (const char32_t*)__wb, (const char32_t*)__we, __wn, __buf, __buf + __sz, __bn);
1328 if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)1318 if (__r == codecvt_base::error || __wn == (const char32_t*)__wb)
1329 __throw_runtime_error("locale not supported");1319 std::__throw_runtime_error("locale not supported");
1330 for (const char* __p = __buf; __p < __bn; ++__p, ++__s)1320 for (const char* __p = __buf; __p < __bn; ++__p, ++__s)
1331 *__s = *__p;1321 *__s = *__p;
1332 __wb = (const _CharT*)__wn;1322 __wb = (const _CharT*)__wn;
...@@ -1370,7 +1360,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t...@@ -1370,7 +1360,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<16> : public codecvt<char16_t
1370 const char* __nn = __nb;1360 const char* __nn = __nb;
1371 __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);1361 __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);
1372 if (__r == codecvt_base::error || __nn == __nb)1362 if (__r == codecvt_base::error || __nn == __nb)
1373 __throw_runtime_error("locale not supported");1363 std::__throw_runtime_error("locale not supported");
1374 for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)1364 for (const char16_t* __p = __buf; __p < __bn; ++__p, ++__s)
1375 *__s = *__p;1365 *__s = *__p;
1376 __nb = __nn;1366 __nb = __nn;
...@@ -1398,7 +1388,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t...@@ -1398,7 +1388,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t
1398 const char* __nn = __nb;1388 const char* __nn = __nb;
1399 __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);1389 __r = do_in(__mb, __nb, __ne - __nb > __sz ? __nb + __sz : __ne, __nn, __buf, __buf + __sz, __bn);
1400 if (__r == codecvt_base::error || __nn == __nb)1390 if (__r == codecvt_base::error || __nn == __nb)
1401 __throw_runtime_error("locale not supported");1391 std::__throw_runtime_error("locale not supported");
1402 for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)1392 for (const char32_t* __p = __buf; __p < __bn; ++__p, ++__s)
1403 *__s = *__p;1393 *__s = *__p;
1404 __nb = __nn;1394 __nb = __nn;
...@@ -1410,7 +1400,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t...@@ -1410,7 +1400,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __widen_from_utf8<32> : public codecvt<char32_t
1410// template <class charT> class numpunct1400// template <class charT> class numpunct
14111401
1412template <class _CharT>1402template <class _CharT>
1413class _LIBCPP_TEMPLATE_VIS numpunct;1403class numpunct;
14141404
1415template <>1405template <>
1416class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet {1406class _LIBCPP_EXPORTED_FROM_ABI numpunct<char> : public locale::facet {
...@@ -1441,7 +1431,7 @@ protected:...@@ -1441,7 +1431,7 @@ protected:
1441 string __grouping_;1431 string __grouping_;
1442};1432};
14431433
1444#if _LIBCPP_HAS_WIDE_CHARACTERS1434# if _LIBCPP_HAS_WIDE_CHARACTERS
1445template <>1435template <>
1446class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {1436class _LIBCPP_EXPORTED_FROM_ABI numpunct<wchar_t> : public locale::facet {
1447public:1437public:
...@@ -1470,12 +1460,12 @@ protected:...@@ -1470,12 +1460,12 @@ protected:
1470 char_type __thousands_sep_;1460 char_type __thousands_sep_;
1471 string __grouping_;1461 string __grouping_;
1472};1462};
1473#endif // _LIBCPP_HAS_WIDE_CHARACTERS1463# endif // _LIBCPP_HAS_WIDE_CHARACTERS
14741464
1475// template <class charT> class numpunct_byname1465// template <class charT> class numpunct_byname
14761466
1477template <class _CharT>1467template <class _CharT>
1478class _LIBCPP_TEMPLATE_VIS numpunct_byname;1468class numpunct_byname;
14791469
1480template <>1470template <>
1481class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> {1471class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<char> : public numpunct<char> {
...@@ -1493,7 +1483,7 @@ private:...@@ -1493,7 +1483,7 @@ private:
1493 void __init(const char*);1483 void __init(const char*);
1494};1484};
14951485
1496#if _LIBCPP_HAS_WIDE_CHARACTERS1486# if _LIBCPP_HAS_WIDE_CHARACTERS
1497template <>1487template <>
1498class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {1488class _LIBCPP_EXPORTED_FROM_ABI numpunct_byname<wchar_t> : public numpunct<wchar_t> {
1499public:1489public:
...@@ -1509,8 +1499,10 @@ protected:...@@ -1509,8 +1499,10 @@ protected:
1509private:1499private:
1510 void __init(const char*);1500 void __init(const char*);
1511};1501};
1512#endif // _LIBCPP_HAS_WIDE_CHARACTERS1502# endif // _LIBCPP_HAS_WIDE_CHARACTERS
15131503
1514_LIBCPP_END_NAMESPACE_STD1504_LIBCPP_END_NAMESPACE_STD
15151505
1506#endif // _LIBCPP_HAS_LOCALIZATION
1507
1516#endif // _LIBCPP___LOCALE1508#endif // _LIBCPP___LOCALE
lib/libcxx/include/__locale_dir/check_grouping.h created+31
...@@ -0,0 +1,31 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H
10#define _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H
11
12#include <__config>
13#include <__fwd/string.h>
14#include <ios>
15
16#if _LIBCPP_HAS_LOCALIZATION
17
18# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20# endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24_LIBCPP_EXPORTED_FROM_ABI void
25__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err);
26
27_LIBCPP_END_NAMESPACE_STD
28
29#endif // _LIBCPP_HAS_LOCALIZATION
30
31#endif // _LIBCPP___LOCALE_DIR_CHECK_GROUPING_H
lib/libcxx/include/__locale_dir/get_c_locale.h created+40
...@@ -0,0 +1,40 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H
10#define _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H
11
12#include <__config>
13#include <__locale_dir/locale_base_api.h>
14
15#if _LIBCPP_HAS_LOCALIZATION
16
17# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19# endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23// FIXME: This should really be part of the locale base API
24
25# if defined(__APPLE__) || defined(__FreeBSD__)
26# define _LIBCPP_GET_C_LOCALE 0
27# elif defined(__NetBSD__)
28# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
29# else
30# define _LIBCPP_GET_C_LOCALE __cloc()
31// Get the C locale object
32_LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc();
33# define __cloc_defined
34# endif
35
36_LIBCPP_END_NAMESPACE_STD
37
38#endif // _LIBCPP_HAS_LOCALIZATION
39
40#endif // _LIBCPP___LOCALE_DIR_GET_C_LOCALE_H
lib/libcxx/include/__locale_dir/locale_base_api.h+59-59
...@@ -64,8 +64,6 @@...@@ -64,8 +64,6 @@
64// Character manipulation functions64// Character manipulation functions
65// --------------------------------65// --------------------------------
66// namespace __locale {66// namespace __locale {
67// int __islower(int, __locale_t);
68// int __isupper(int, __locale_t);
69// int __isdigit(int, __locale_t); // required by the headers67// int __isdigit(int, __locale_t); // required by the headers
70// int __isxdigit(int, __locale_t); // required by the headers68// int __isxdigit(int, __locale_t); // required by the headers
71// int __toupper(int, __locale_t);69// int __toupper(int, __locale_t);
...@@ -111,59 +109,64 @@...@@ -111,59 +109,64 @@
111// int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers109// int __sscanf(const char*, __locale_t, const char*, ...); // required by the headers
112// }110// }
113111
114#if defined(__APPLE__)112#if _LIBCPP_HAS_LOCALIZATION
115# include <__locale_dir/support/apple.h>113
116#elif defined(__FreeBSD__)114# if defined(__APPLE__)
117# include <__locale_dir/support/freebsd.h>115# include <__locale_dir/support/apple.h>
118#elif defined(__NetBSD__)116# elif defined(__FreeBSD__)
119# include <__locale_dir/support/netbsd.h>117# include <__locale_dir/support/freebsd.h>
120#elif defined(_LIBCPP_MSVCRT_LIKE)118/* zig patch: https://github.com/llvm/llvm-project/pull/143055 */
121# include <__locale_dir/support/windows.h>119# elif defined(__NetBSD__)
122#elif defined(__Fuchsia__)120# include <__locale_dir/support/netbsd.h>
123# include <__locale_dir/support/fuchsia.h>121# elif defined(_LIBCPP_MSVCRT_LIKE)
124#else122# include <__locale_dir/support/windows.h>
123# elif defined(__Fuchsia__)
124# include <__locale_dir/support/fuchsia.h>
125# elif defined(__linux__)
126# include <__locale_dir/support/linux.h>
127# else
125128
126// TODO: This is a temporary definition to bridge between the old way we defined the locale base API129// TODO: This is a temporary definition to bridge between the old way we defined the locale base API
127// (by providing global non-reserved names) and the new API. As we move individual platforms130// (by providing global non-reserved names) and the new API. As we move individual platforms
128// towards the new way of defining the locale base API, this should disappear since each platform131// towards the new way of defining the locale base API, this should disappear since each platform
129// will define those directly.132// will define those directly.
130# if defined(_AIX) || defined(__MVS__)133# if defined(_AIX) || defined(__MVS__)
131# include <__locale_dir/locale_base_api/ibm.h>134# include <__locale_dir/locale_base_api/ibm.h>
132# elif defined(__ANDROID__)135# elif defined(__ANDROID__)
133# include <__locale_dir/locale_base_api/android.h>136# include <__locale_dir/locale_base_api/android.h>
134# elif defined(__OpenBSD__)137# elif defined(__OpenBSD__)
135# include <__locale_dir/locale_base_api/openbsd.h>138# include <__locale_dir/locale_base_api/openbsd.h>
136# elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC139# elif defined(__wasi__) || _LIBCPP_HAS_MUSL_LIBC
137# include <__locale_dir/locale_base_api/musl.h>140# include <__locale_dir/locale_base_api/musl.h>
138# endif141# endif
139142
140# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>143# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
141144
142# include <__cstddef/size_t.h>145# include <__cstddef/size_t.h>
143# include <__utility/forward.h>146# include <__utility/forward.h>
144# include <ctype.h>147# include <ctype.h>
145# include <string.h>148# include <string.h>
146# include <time.h>149# include <time.h>
147# if _LIBCPP_HAS_WIDE_CHARACTERS150# if _LIBCPP_HAS_WIDE_CHARACTERS
148# include <wctype.h>151# include <wctype.h>
149# endif152# endif
150_LIBCPP_BEGIN_NAMESPACE_STD153_LIBCPP_BEGIN_NAMESPACE_STD
151namespace __locale {154namespace __locale {
152//155//
153// Locale management156// Locale management
154//157//
155# define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK158# define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
156# define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK159# define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
157# define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK160# define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
158# define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK161# define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
159# define _LIBCPP_TIME_MASK LC_TIME_MASK162# define _LIBCPP_TIME_MASK LC_TIME_MASK
160# define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK163# define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
161# define _LIBCPP_ALL_MASK LC_ALL_MASK164# define _LIBCPP_ALL_MASK LC_ALL_MASK
162# define _LIBCPP_LC_ALL LC_ALL165# define _LIBCPP_LC_ALL LC_ALL
163166
164using __locale_t _LIBCPP_NODEBUG = locale_t;167using __locale_t _LIBCPP_NODEBUG = locale_t;
165168
166# if defined(_LIBCPP_BUILDING_LIBRARY)169# if defined(_LIBCPP_BUILDING_LIBRARY)
167using __lconv_t _LIBCPP_NODEBUG = lconv;170using __lconv_t _LIBCPP_NODEBUG = lconv;
168171
169inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {172inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {
...@@ -177,7 +180,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc...@@ -177,7 +180,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __loc
177inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); }180inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { freelocale(__loc); }
178181
179inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); }182inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) { return __libcpp_localeconv_l(__loc); }
180# endif // _LIBCPP_BUILDING_LIBRARY183# endif // _LIBCPP_BUILDING_LIBRARY
181184
182//185//
183// Strtonum functions186// Strtonum functions
...@@ -206,15 +209,10 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {...@@ -206,15 +209,10 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
206//209//
207// Character manipulation functions210// Character manipulation functions
208//211//
209# if defined(_LIBCPP_BUILDING_LIBRARY)
210inline _LIBCPP_HIDE_FROM_ABI int __islower(int __ch, __locale_t __loc) { return islower_l(__ch, __loc); }
211inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __ch, __locale_t __loc) { return isupper_l(__ch, __loc); }
212# endif
213
214inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); }212inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __ch, __locale_t __loc) { return isdigit_l(__ch, __loc); }
215inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); }213inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __ch, __locale_t __loc) { return isxdigit_l(__ch, __loc); }
216214
217# if defined(_LIBCPP_BUILDING_LIBRARY)215# if defined(_LIBCPP_BUILDING_LIBRARY)
218inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {216inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
219 return strcoll_l(__s1, __s2, __loc);217 return strcoll_l(__s1, __s2, __loc);
220}218}
...@@ -224,7 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s...@@ -224,7 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, s
224inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); }222inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __ch, __locale_t __loc) { return toupper_l(__ch, __loc); }
225inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); }223inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __ch, __locale_t __loc) { return tolower_l(__ch, __loc); }
226224
227# if _LIBCPP_HAS_WIDE_CHARACTERS225# if _LIBCPP_HAS_WIDE_CHARACTERS
228inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) {226inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __s1, const wchar_t* __s2, __locale_t __loc) {
229 return wcscoll_l(__s1, __s2, __loc);227 return wcscoll_l(__s1, __s2, __loc);
230}228}
...@@ -246,7 +244,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret...@@ -246,7 +244,7 @@ inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __ch, __locale_t __loc) { ret
246inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); }244inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __ch, __locale_t __loc) { return iswxdigit_l(__ch, __loc); }
247inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); }245inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) { return towupper_l(__ch, __loc); }
248inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); }246inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); }
249# endif247# endif
250248
251inline _LIBCPP_HIDE_FROM_ABI size_t249inline _LIBCPP_HIDE_FROM_ABI size_t
252__strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {250__strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {
...@@ -259,7 +257,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca...@@ -259,7 +257,7 @@ __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __loca
259inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) {257inline _LIBCPP_HIDE_FROM_ABI decltype(__libcpp_mb_cur_max_l(__locale_t())) __mb_len_max(__locale_t __loc) {
260 return __libcpp_mb_cur_max_l(__loc);258 return __libcpp_mb_cur_max_l(__loc);
261}259}
262# if _LIBCPP_HAS_WIDE_CHARACTERS260# if _LIBCPP_HAS_WIDE_CHARACTERS
263inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); }261inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __ch, __locale_t __loc) { return __libcpp_btowc_l(__ch, __loc); }
264inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); }262inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __ch, __locale_t __loc) { return __libcpp_wctob_l(__ch, __loc); }
265inline _LIBCPP_HIDE_FROM_ABI size_t263inline _LIBCPP_HIDE_FROM_ABI size_t
...@@ -287,17 +285,17 @@ inline _LIBCPP_HIDE_FROM_ABI size_t...@@ -287,17 +285,17 @@ inline _LIBCPP_HIDE_FROM_ABI size_t
287__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {285__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
288 return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc);286 return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
289}287}
290# endif // _LIBCPP_HAS_WIDE_CHARACTERS288# endif // _LIBCPP_HAS_WIDE_CHARACTERS
291# endif // _LIBCPP_BUILDING_LIBRARY289# endif // _LIBCPP_BUILDING_LIBRARY
292290
293_LIBCPP_DIAGNOSTIC_PUSH291_LIBCPP_DIAGNOSTIC_PUSH
294_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")292_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
295_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates293_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
296# ifdef _LIBCPP_COMPILER_CLANG_BASED294# ifdef _LIBCPP_COMPILER_CLANG_BASED
297# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)295# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
298# else296# else
299# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */297# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
300# endif298# endif
301299
302template <class... _Args>300template <class... _Args>
303_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(301_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
...@@ -315,11 +313,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __s...@@ -315,11 +313,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __s
315 return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);313 return std::__libcpp_sscanf_l(__s, __loc, __format, std::forward<_Args>(__args)...);
316}314}
317_LIBCPP_DIAGNOSTIC_POP315_LIBCPP_DIAGNOSTIC_POP
318# undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT316# undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
319317
320} // namespace __locale318} // namespace __locale
321_LIBCPP_END_NAMESPACE_STD319_LIBCPP_END_NAMESPACE_STD
322320
323#endif // Compatibility definition of locale base APIs321# endif // Compatibility definition of locale base APIs
322
323#endif // _LIBCPP_HAS_LOCALIZATION
324324
325#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H325#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
lib/libcxx/include/__locale_dir/messages.h created+143
...@@ -0,0 +1,143 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_MESSAGES_H
10#define _LIBCPP___LOCALE_DIR_MESSAGES_H
11
12#include <__config>
13#include <__iterator/back_insert_iterator.h>
14#include <__locale>
15#include <string>
16
17#if _LIBCPP_HAS_LOCALIZATION
18
19# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21# endif
22
23# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
24// Most unix variants have catopen. These are the specific ones that don't.
25# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
26# define _LIBCPP_HAS_CATOPEN 1
27# include <nl_types.h>
28# else
29# define _LIBCPP_HAS_CATOPEN 0
30# endif
31# else
32# define _LIBCPP_HAS_CATOPEN 0
33# endif
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37class _LIBCPP_EXPORTED_FROM_ABI messages_base {
38public:
39 typedef intptr_t catalog;
40
41 _LIBCPP_HIDE_FROM_ABI messages_base() {}
42};
43
44template <class _CharT>
45class messages : public locale::facet, public messages_base {
46public:
47 typedef _CharT char_type;
48 typedef basic_string<_CharT> string_type;
49
50 _LIBCPP_HIDE_FROM_ABI explicit messages(size_t __refs = 0) : locale::facet(__refs) {}
51
52 _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const {
53 return do_open(__nm, __loc);
54 }
55
56 _LIBCPP_HIDE_FROM_ABI string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
57 return do_get(__c, __set, __msgid, __dflt);
58 }
59
60 _LIBCPP_HIDE_FROM_ABI void close(catalog __c) const { do_close(__c); }
61
62 static locale::id id;
63
64protected:
65 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {}
66
67 virtual catalog do_open(const basic_string<char>&, const locale&) const;
68 virtual string_type do_get(catalog, int __set, int __msgid, const string_type& __dflt) const;
69 virtual void do_close(catalog) const;
70};
71
72template <class _CharT>
73locale::id messages<_CharT>::id;
74
75template <class _CharT>
76typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const {
77# if _LIBCPP_HAS_CATOPEN
78 return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
79# else // !_LIBCPP_HAS_CATOPEN
80 (void)__nm;
81 return -1;
82# endif // _LIBCPP_HAS_CATOPEN
83}
84
85template <class _CharT>
86typename messages<_CharT>::string_type
87messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
88# if _LIBCPP_HAS_CATOPEN
89 string __ndflt;
90 __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()(
91 std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());
92 nl_catd __cat = (nl_catd)__c;
93 static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type");
94 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
95 string_type __w;
96 __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n));
97 return __w;
98# else // !_LIBCPP_HAS_CATOPEN
99 (void)__c;
100 (void)__set;
101 (void)__msgid;
102 return __dflt;
103# endif // _LIBCPP_HAS_CATOPEN
104}
105
106template <class _CharT>
107void messages<_CharT>::do_close(catalog __c) const {
108# if _LIBCPP_HAS_CATOPEN
109 catclose((nl_catd)__c);
110# else // !_LIBCPP_HAS_CATOPEN
111 (void)__c;
112# endif // _LIBCPP_HAS_CATOPEN
113}
114
115extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
116# if _LIBCPP_HAS_WIDE_CHARACTERS
117extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
118# endif
119
120template <class _CharT>
121class messages_byname : public messages<_CharT> {
122public:
123 typedef messages_base::catalog catalog;
124 typedef basic_string<_CharT> string_type;
125
126 _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const char*, size_t __refs = 0) : messages<_CharT>(__refs) {}
127
128 _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const string&, size_t __refs = 0) : messages<_CharT>(__refs) {}
129
130protected:
131 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {}
132};
133
134extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
135# if _LIBCPP_HAS_WIDE_CHARACTERS
136extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
137# endif
138
139_LIBCPP_END_NAMESPACE_STD
140
141#endif // _LIBCPP_HAS_LOCALIZATION
142
143#endif // _LIBCPP___LOCALE_DIR_MESSAGES_H
lib/libcxx/include/__locale_dir/money.h created+873
...@@ -0,0 +1,873 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_MONEY_H
10#define _LIBCPP___LOCALE_DIR_MONEY_H
11
12#include <__algorithm/copy.h>
13#include <__algorithm/equal.h>
14#include <__algorithm/find.h>
15#include <__algorithm/reverse.h>
16#include <__config>
17#include <__locale>
18#include <__locale_dir/check_grouping.h>
19#include <__locale_dir/get_c_locale.h>
20#include <__locale_dir/pad_and_output.h>
21#include <__memory/unique_ptr.h>
22#include <ios>
23#include <string>
24
25#if _LIBCPP_HAS_LOCALIZATION
26
27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29# endif
30
31_LIBCPP_PUSH_MACROS
32# include <__undef_macros>
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36// money_base
37
38class _LIBCPP_EXPORTED_FROM_ABI money_base {
39public:
40 enum part { none, space, symbol, sign, value };
41 struct pattern {
42 char field[4];
43 };
44
45 _LIBCPP_HIDE_FROM_ABI money_base() {}
46};
47
48// moneypunct
49
50template <class _CharT, bool _International = false>
51class moneypunct : public locale::facet, public money_base {
52public:
53 typedef _CharT char_type;
54 typedef basic_string<char_type> string_type;
55
56 _LIBCPP_HIDE_FROM_ABI explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {}
57
58 _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
59 _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
60 _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
61 _LIBCPP_HIDE_FROM_ABI string_type curr_symbol() const { return do_curr_symbol(); }
62 _LIBCPP_HIDE_FROM_ABI string_type positive_sign() const { return do_positive_sign(); }
63 _LIBCPP_HIDE_FROM_ABI string_type negative_sign() const { return do_negative_sign(); }
64 _LIBCPP_HIDE_FROM_ABI int frac_digits() const { return do_frac_digits(); }
65 _LIBCPP_HIDE_FROM_ABI pattern pos_format() const { return do_pos_format(); }
66 _LIBCPP_HIDE_FROM_ABI pattern neg_format() const { return do_neg_format(); }
67
68 static locale::id id;
69 static const bool intl = _International;
70
71protected:
72 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {}
73
74 virtual char_type do_decimal_point() const { return numeric_limits<char_type>::max(); }
75 virtual char_type do_thousands_sep() const { return numeric_limits<char_type>::max(); }
76 virtual string do_grouping() const { return string(); }
77 virtual string_type do_curr_symbol() const { return string_type(); }
78 virtual string_type do_positive_sign() const { return string_type(); }
79 virtual string_type do_negative_sign() const { return string_type(1, '-'); }
80 virtual int do_frac_digits() const { return 0; }
81 virtual pattern do_pos_format() const {
82 pattern __p = {{symbol, sign, none, value}};
83 return __p;
84 }
85 virtual pattern do_neg_format() const {
86 pattern __p = {{symbol, sign, none, value}};
87 return __p;
88 }
89};
90
91template <class _CharT, bool _International>
92locale::id moneypunct<_CharT, _International>::id;
93
94template <class _CharT, bool _International>
95const bool moneypunct<_CharT, _International>::intl;
96
97extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
98extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
99# if _LIBCPP_HAS_WIDE_CHARACTERS
100extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
101extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
102# endif
103
104// moneypunct_byname
105
106template <class _CharT, bool _International = false>
107class moneypunct_byname : public moneypunct<_CharT, _International> {
108public:
109 typedef money_base::pattern pattern;
110 typedef _CharT char_type;
111 typedef basic_string<char_type> string_type;
112
113 _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const char* __nm, size_t __refs = 0)
114 : moneypunct<_CharT, _International>(__refs) {
115 init(__nm);
116 }
117
118 _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const string& __nm, size_t __refs = 0)
119 : moneypunct<_CharT, _International>(__refs) {
120 init(__nm.c_str());
121 }
122
123protected:
124 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {}
125
126 char_type do_decimal_point() const override { return __decimal_point_; }
127 char_type do_thousands_sep() const override { return __thousands_sep_; }
128 string do_grouping() const override { return __grouping_; }
129 string_type do_curr_symbol() const override { return __curr_symbol_; }
130 string_type do_positive_sign() const override { return __positive_sign_; }
131 string_type do_negative_sign() const override { return __negative_sign_; }
132 int do_frac_digits() const override { return __frac_digits_; }
133 pattern do_pos_format() const override { return __pos_format_; }
134 pattern do_neg_format() const override { return __neg_format_; }
135
136private:
137 char_type __decimal_point_;
138 char_type __thousands_sep_;
139 string __grouping_;
140 string_type __curr_symbol_;
141 string_type __positive_sign_;
142 string_type __negative_sign_;
143 int __frac_digits_;
144 pattern __pos_format_;
145 pattern __neg_format_;
146
147 void init(const char*);
148};
149
150template <>
151_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, false>::init(const char*);
152template <>
153_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*);
154extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
155extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
156
157# if _LIBCPP_HAS_WIDE_CHARACTERS
158template <>
159_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*);
160template <>
161_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*);
162extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
163extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
164# endif
165
166// money_get
167
168template <class _CharT>
169class __money_get {
170protected:
171 typedef _CharT char_type;
172 typedef basic_string<char_type> string_type;
173
174 _LIBCPP_HIDE_FROM_ABI __money_get() {}
175
176 static void __gather_info(
177 bool __intl,
178 const locale& __loc,
179 money_base::pattern& __pat,
180 char_type& __dp,
181 char_type& __ts,
182 string& __grp,
183 string_type& __sym,
184 string_type& __psn,
185 string_type& __nsn,
186 int& __fd);
187};
188
189template <class _CharT>
190void __money_get<_CharT>::__gather_info(
191 bool __intl,
192 const locale& __loc,
193 money_base::pattern& __pat,
194 char_type& __dp,
195 char_type& __ts,
196 string& __grp,
197 string_type& __sym,
198 string_type& __psn,
199 string_type& __nsn,
200 int& __fd) {
201 if (__intl) {
202 const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc);
203 __pat = __mp.neg_format();
204 __nsn = __mp.negative_sign();
205 __psn = __mp.positive_sign();
206 __dp = __mp.decimal_point();
207 __ts = __mp.thousands_sep();
208 __grp = __mp.grouping();
209 __sym = __mp.curr_symbol();
210 __fd = __mp.frac_digits();
211 } else {
212 const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc);
213 __pat = __mp.neg_format();
214 __nsn = __mp.negative_sign();
215 __psn = __mp.positive_sign();
216 __dp = __mp.decimal_point();
217 __ts = __mp.thousands_sep();
218 __grp = __mp.grouping();
219 __sym = __mp.curr_symbol();
220 __fd = __mp.frac_digits();
221 }
222}
223
224extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
225# if _LIBCPP_HAS_WIDE_CHARACTERS
226extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
227# endif
228
229template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
230class money_get : public locale::facet, private __money_get<_CharT> {
231public:
232 typedef _CharT char_type;
233 typedef _InputIterator iter_type;
234 typedef basic_string<char_type> string_type;
235
236 _LIBCPP_HIDE_FROM_ABI explicit money_get(size_t __refs = 0) : locale::facet(__refs) {}
237
238 _LIBCPP_HIDE_FROM_ABI iter_type
239 get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
240 return do_get(__b, __e, __intl, __iob, __err, __v);
241 }
242
243 _LIBCPP_HIDE_FROM_ABI iter_type
244 get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const {
245 return do_get(__b, __e, __intl, __iob, __err, __v);
246 }
247
248 static locale::id id;
249
250protected:
251 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {}
252
253 virtual iter_type
254 do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const;
255 virtual iter_type
256 do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const;
257
258private:
259 static bool __do_get(
260 iter_type& __b,
261 iter_type __e,
262 bool __intl,
263 const locale& __loc,
264 ios_base::fmtflags __flags,
265 ios_base::iostate& __err,
266 bool& __neg,
267 const ctype<char_type>& __ct,
268 unique_ptr<char_type, void (*)(void*)>& __wb,
269 char_type*& __wn,
270 char_type* __we);
271};
272
273template <class _CharT, class _InputIterator>
274locale::id money_get<_CharT, _InputIterator>::id;
275
276_LIBCPP_EXPORTED_FROM_ABI void __do_nothing(void*);
277
278template <class _Tp>
279_LIBCPP_HIDE_FROM_ABI void __double_or_nothing(unique_ptr<_Tp, void (*)(void*)>& __b, _Tp*& __n, _Tp*& __e) {
280 bool __owns = __b.get_deleter() != __do_nothing;
281 size_t __cur_cap = static_cast<size_t>(__e - __b.get()) * sizeof(_Tp);
282 size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ? 2 * __cur_cap : numeric_limits<size_t>::max();
283 if (__new_cap == 0)
284 __new_cap = sizeof(_Tp);
285 size_t __n_off = static_cast<size_t>(__n - __b.get());
286 _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);
287 if (__t == 0)
288 std::__throw_bad_alloc();
289 if (__owns)
290 __b.release();
291 else
292 std::memcpy(__t, __b.get(), __cur_cap);
293 __b = unique_ptr<_Tp, void (*)(void*)>(__t, free);
294 __new_cap /= sizeof(_Tp);
295 __n = __b.get() + __n_off;
296 __e = __b.get() + __new_cap;
297}
298
299// true == success
300template <class _CharT, class _InputIterator>
301bool money_get<_CharT, _InputIterator>::__do_get(
302 iter_type& __b,
303 iter_type __e,
304 bool __intl,
305 const locale& __loc,
306 ios_base::fmtflags __flags,
307 ios_base::iostate& __err,
308 bool& __neg,
309 const ctype<char_type>& __ct,
310 unique_ptr<char_type, void (*)(void*)>& __wb,
311 char_type*& __wn,
312 char_type* __we) {
313 if (__b == __e) {
314 __err |= ios_base::failbit;
315 return false;
316 }
317 const unsigned __bz = 100;
318 unsigned __gbuf[__bz];
319 unique_ptr<unsigned, void (*)(void*)> __gb(__gbuf, __do_nothing);
320 unsigned* __gn = __gb.get();
321 unsigned* __ge = __gn + __bz;
322 money_base::pattern __pat;
323 char_type __dp;
324 char_type __ts;
325 string __grp;
326 string_type __sym;
327 string_type __psn;
328 string_type __nsn;
329 // Capture the spaces read into money_base::{space,none} so they
330 // can be compared to initial spaces in __sym.
331 string_type __spaces;
332 int __fd;
333 __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp, __sym, __psn, __nsn, __fd);
334 const string_type* __trailing_sign = 0;
335 __wn = __wb.get();
336 for (unsigned __p = 0; __p < 4 && __b != __e; ++__p) {
337 switch (__pat.field[__p]) {
338 case money_base::space:
339 if (__p != 3) {
340 if (__ct.is(ctype_base::space, *__b))
341 __spaces.push_back(*__b++);
342 else {
343 __err |= ios_base::failbit;
344 return false;
345 }
346 }
347 [[__fallthrough__]];
348 case money_base::none:
349 if (__p != 3) {
350 while (__b != __e && __ct.is(ctype_base::space, *__b))
351 __spaces.push_back(*__b++);
352 }
353 break;
354 case money_base::sign:
355 if (__psn.size() > 0 && *__b == __psn[0]) {
356 ++__b;
357 __neg = false;
358 if (__psn.size() > 1)
359 __trailing_sign = std::addressof(__psn);
360 break;
361 }
362 if (__nsn.size() > 0 && *__b == __nsn[0]) {
363 ++__b;
364 __neg = true;
365 if (__nsn.size() > 1)
366 __trailing_sign = std::addressof(__nsn);
367 break;
368 }
369 if (__psn.size() > 0 && __nsn.size() > 0) { // sign is required
370 __err |= ios_base::failbit;
371 return false;
372 }
373 if (__psn.size() == 0 && __nsn.size() == 0)
374 // locale has no way of specifying a sign. Use the initial value of __neg as a default
375 break;
376 __neg = (__nsn.size() == 0);
377 break;
378 case money_base::symbol: {
379 bool __more_needed =
380 __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none));
381 bool __sb = (__flags & ios_base::showbase) != 0;
382 if (__sb || __more_needed) {
383 typename string_type::const_iterator __sym_space_end = __sym.begin();
384 if (__p > 0 && (__pat.field[__p - 1] == money_base::none || __pat.field[__p - 1] == money_base::space)) {
385 // Match spaces we've already read against spaces at
386 // the beginning of __sym.
387 while (__sym_space_end != __sym.end() && __ct.is(ctype_base::space, *__sym_space_end))
388 ++__sym_space_end;
389 const size_t __num_spaces = __sym_space_end - __sym.begin();
390 if (__num_spaces > __spaces.size() ||
391 !std::equal(__spaces.end() - __num_spaces, __spaces.end(), __sym.begin())) {
392 // No match. Put __sym_space_end back at the
393 // beginning of __sym, which will prevent a
394 // match in the next loop.
395 __sym_space_end = __sym.begin();
396 }
397 }
398 typename string_type::const_iterator __sym_curr_char = __sym_space_end;
399 while (__sym_curr_char != __sym.end() && __b != __e && *__b == *__sym_curr_char) {
400 ++__b;
401 ++__sym_curr_char;
402 }
403 if (__sb && __sym_curr_char != __sym.end()) {
404 __err |= ios_base::failbit;
405 return false;
406 }
407 }
408 } break;
409 case money_base::value: {
410 unsigned __ng = 0;
411 for (; __b != __e; ++__b) {
412 char_type __c = *__b;
413 if (__ct.is(ctype_base::digit, __c)) {
414 if (__wn == __we)
415 std::__double_or_nothing(__wb, __wn, __we);
416 *__wn++ = __c;
417 ++__ng;
418 } else if (__grp.size() > 0 && __ng > 0 && __c == __ts) {
419 if (__gn == __ge)
420 std::__double_or_nothing(__gb, __gn, __ge);
421 *__gn++ = __ng;
422 __ng = 0;
423 } else
424 break;
425 }
426 if (__gb.get() != __gn && __ng > 0) {
427 if (__gn == __ge)
428 std::__double_or_nothing(__gb, __gn, __ge);
429 *__gn++ = __ng;
430 }
431 if (__fd > 0) {
432 if (__b == __e || *__b != __dp) {
433 __err |= ios_base::failbit;
434 return false;
435 }
436 for (++__b; __fd > 0; --__fd, ++__b) {
437 if (__b == __e || !__ct.is(ctype_base::digit, *__b)) {
438 __err |= ios_base::failbit;
439 return false;
440 }
441 if (__wn == __we)
442 std::__double_or_nothing(__wb, __wn, __we);
443 *__wn++ = *__b;
444 }
445 }
446 if (__wn == __wb.get()) {
447 __err |= ios_base::failbit;
448 return false;
449 }
450 } break;
451 }
452 }
453 if (__trailing_sign) {
454 for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) {
455 if (__b == __e || *__b != (*__trailing_sign)[__i]) {
456 __err |= ios_base::failbit;
457 return false;
458 }
459 }
460 }
461 if (__gb.get() != __gn) {
462 ios_base::iostate __et = ios_base::goodbit;
463 __check_grouping(__grp, __gb.get(), __gn, __et);
464 if (__et) {
465 __err |= ios_base::failbit;
466 return false;
467 }
468 }
469 return true;
470}
471
472template <class _CharT, class _InputIterator>
473_InputIterator money_get<_CharT, _InputIterator>::do_get(
474 iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
475 const int __bz = 100;
476 char_type __wbuf[__bz];
477 unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing);
478 char_type* __wn;
479 char_type* __we = __wbuf + __bz;
480 locale __loc = __iob.getloc();
481 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
482 bool __neg = false;
483 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) {
484 const char __src[] = "0123456789";
485 char_type __atoms[sizeof(__src) - 1];
486 __ct.widen(__src, __src + (sizeof(__src) - 1), __atoms);
487 char __nbuf[__bz];
488 char* __nc = __nbuf;
489 const char* __nc_in = __nc;
490 unique_ptr<char, void (*)(void*)> __h(nullptr, free);
491 if (__wn - __wb.get() > __bz - 2) {
492 __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
493 if (__h.get() == nullptr)
494 std::__throw_bad_alloc();
495 __nc = __h.get();
496 __nc_in = __nc;
497 }
498 if (__neg)
499 *__nc++ = '-';
500 for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
501 *__nc = __src[std::find(__atoms, std::end(__atoms), *__w) - __atoms];
502 *__nc = char();
503 if (sscanf(__nc_in, "%Lf", &__v) != 1)
504 std::__throw_runtime_error("money_get error");
505 }
506 if (__b == __e)
507 __err |= ios_base::eofbit;
508 return __b;
509}
510
511template <class _CharT, class _InputIterator>
512_InputIterator money_get<_CharT, _InputIterator>::do_get(
513 iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const {
514 const int __bz = 100;
515 char_type __wbuf[__bz];
516 unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing);
517 char_type* __wn;
518 char_type* __we = __wbuf + __bz;
519 locale __loc = __iob.getloc();
520 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
521 bool __neg = false;
522 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) {
523 __v.clear();
524 if (__neg)
525 __v.push_back(__ct.widen('-'));
526 char_type __z = __ct.widen('0');
527 char_type* __w;
528 for (__w = __wb.get(); __w < __wn - 1; ++__w)
529 if (*__w != __z)
530 break;
531 __v.append(__w, __wn);
532 }
533 if (__b == __e)
534 __err |= ios_base::eofbit;
535 return __b;
536}
537
538extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
539# if _LIBCPP_HAS_WIDE_CHARACTERS
540extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
541# endif
542
543// money_put
544
545template <class _CharT>
546class __money_put {
547protected:
548 typedef _CharT char_type;
549 typedef basic_string<char_type> string_type;
550
551 _LIBCPP_HIDE_FROM_ABI __money_put() {}
552
553 static void __gather_info(
554 bool __intl,
555 bool __neg,
556 const locale& __loc,
557 money_base::pattern& __pat,
558 char_type& __dp,
559 char_type& __ts,
560 string& __grp,
561 string_type& __sym,
562 string_type& __sn,
563 int& __fd);
564 static void __format(
565 char_type* __mb,
566 char_type*& __mi,
567 char_type*& __me,
568 ios_base::fmtflags __flags,
569 const char_type* __db,
570 const char_type* __de,
571 const ctype<char_type>& __ct,
572 bool __neg,
573 const money_base::pattern& __pat,
574 char_type __dp,
575 char_type __ts,
576 const string& __grp,
577 const string_type& __sym,
578 const string_type& __sn,
579 int __fd);
580};
581
582template <class _CharT>
583void __money_put<_CharT>::__gather_info(
584 bool __intl,
585 bool __neg,
586 const locale& __loc,
587 money_base::pattern& __pat,
588 char_type& __dp,
589 char_type& __ts,
590 string& __grp,
591 string_type& __sym,
592 string_type& __sn,
593 int& __fd) {
594 if (__intl) {
595 const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc);
596 if (__neg) {
597 __pat = __mp.neg_format();
598 __sn = __mp.negative_sign();
599 } else {
600 __pat = __mp.pos_format();
601 __sn = __mp.positive_sign();
602 }
603 __dp = __mp.decimal_point();
604 __ts = __mp.thousands_sep();
605 __grp = __mp.grouping();
606 __sym = __mp.curr_symbol();
607 __fd = __mp.frac_digits();
608 } else {
609 const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc);
610 if (__neg) {
611 __pat = __mp.neg_format();
612 __sn = __mp.negative_sign();
613 } else {
614 __pat = __mp.pos_format();
615 __sn = __mp.positive_sign();
616 }
617 __dp = __mp.decimal_point();
618 __ts = __mp.thousands_sep();
619 __grp = __mp.grouping();
620 __sym = __mp.curr_symbol();
621 __fd = __mp.frac_digits();
622 }
623}
624
625template <class _CharT>
626void __money_put<_CharT>::__format(
627 char_type* __mb,
628 char_type*& __mi,
629 char_type*& __me,
630 ios_base::fmtflags __flags,
631 const char_type* __db,
632 const char_type* __de,
633 const ctype<char_type>& __ct,
634 bool __neg,
635 const money_base::pattern& __pat,
636 char_type __dp,
637 char_type __ts,
638 const string& __grp,
639 const string_type& __sym,
640 const string_type& __sn,
641 int __fd) {
642 __me = __mb;
643 for (char __p : __pat.field) {
644 switch (__p) {
645 case money_base::none:
646 __mi = __me;
647 break;
648 case money_base::space:
649 __mi = __me;
650 *__me++ = __ct.widen(' ');
651 break;
652 case money_base::sign:
653 if (!__sn.empty())
654 *__me++ = __sn[0];
655 break;
656 case money_base::symbol:
657 if (!__sym.empty() && (__flags & ios_base::showbase))
658 __me = std::copy(__sym.begin(), __sym.end(), __me);
659 break;
660 case money_base::value: {
661 // remember start of value so we can reverse it
662 char_type* __t = __me;
663 // find beginning of digits
664 if (__neg)
665 ++__db;
666 // find end of digits
667 const char_type* __d;
668 for (__d = __db; __d < __de; ++__d)
669 if (!__ct.is(ctype_base::digit, *__d))
670 break;
671 // print fractional part
672 if (__fd > 0) {
673 int __f;
674 for (__f = __fd; __d > __db && __f > 0; --__f)
675 *__me++ = *--__d;
676 char_type __z = __f > 0 ? __ct.widen('0') : char_type();
677 for (; __f > 0; --__f)
678 *__me++ = __z;
679 *__me++ = __dp;
680 }
681 // print units part
682 if (__d == __db) {
683 *__me++ = __ct.widen('0');
684 } else {
685 unsigned __ng = 0;
686 unsigned __ig = 0;
687 unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max() : static_cast<unsigned>(__grp[__ig]);
688 while (__d != __db) {
689 if (__ng == __gl) {
690 *__me++ = __ts;
691 __ng = 0;
692 if (++__ig < __grp.size())
693 __gl = __grp[__ig] == numeric_limits<char>::max()
694 ? numeric_limits<unsigned>::max()
695 : static_cast<unsigned>(__grp[__ig]);
696 }
697 *__me++ = *--__d;
698 ++__ng;
699 }
700 }
701 // reverse it
702 std::reverse(__t, __me);
703 } break;
704 }
705 }
706 // print rest of sign, if any
707 if (__sn.size() > 1)
708 __me = std::copy(__sn.begin() + 1, __sn.end(), __me);
709 // set alignment
710 if ((__flags & ios_base::adjustfield) == ios_base::left)
711 __mi = __me;
712 else if ((__flags & ios_base::adjustfield) != ios_base::internal)
713 __mi = __mb;
714}
715
716extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
717# if _LIBCPP_HAS_WIDE_CHARACTERS
718extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
719# endif
720
721template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
722class money_put : public locale::facet, private __money_put<_CharT> {
723public:
724 typedef _CharT char_type;
725 typedef _OutputIterator iter_type;
726 typedef basic_string<char_type> string_type;
727
728 _LIBCPP_HIDE_FROM_ABI explicit money_put(size_t __refs = 0) : locale::facet(__refs) {}
729
730 _LIBCPP_HIDE_FROM_ABI iter_type
731 put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const {
732 return do_put(__s, __intl, __iob, __fl, __units);
733 }
734
735 _LIBCPP_HIDE_FROM_ABI iter_type
736 put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const {
737 return do_put(__s, __intl, __iob, __fl, __digits);
738 }
739
740 static locale::id id;
741
742protected:
743 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {}
744
745 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const;
746 virtual iter_type
747 do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const;
748};
749
750template <class _CharT, class _OutputIterator>
751locale::id money_put<_CharT, _OutputIterator>::id;
752
753template <class _CharT, class _OutputIterator>
754_OutputIterator money_put<_CharT, _OutputIterator>::do_put(
755 iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const {
756 // convert to char
757 const size_t __bs = 100;
758 char __buf[__bs];
759 char* __bb = __buf;
760 char_type __digits[__bs];
761 char_type* __db = __digits;
762 int __n = snprintf(__bb, __bs, "%.0Lf", __units);
763 unique_ptr<char, void (*)(void*)> __hn(nullptr, free);
764 unique_ptr<char_type, void (*)(void*)> __hd(0, free);
765 // secure memory for digit storage
766 if (static_cast<size_t>(__n) > __bs - 1) {
767 __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
768 if (__n == -1)
769 std::__throw_bad_alloc();
770 __hn.reset(__bb);
771 __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type)));
772 if (__hd == nullptr)
773 std::__throw_bad_alloc();
774 __db = __hd.get();
775 }
776 // gather info
777 locale __loc = __iob.getloc();
778 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
779 __ct.widen(__bb, __bb + __n, __db);
780 bool __neg = __n > 0 && __bb[0] == '-';
781 money_base::pattern __pat;
782 char_type __dp;
783 char_type __ts;
784 string __grp;
785 string_type __sym;
786 string_type __sn;
787 int __fd;
788 this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
789 // secure memory for formatting
790 char_type __mbuf[__bs];
791 char_type* __mb = __mbuf;
792 unique_ptr<char_type, void (*)(void*)> __hw(0, free);
793 size_t __exn = __n > __fd ? (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() +
794 static_cast<size_t>(__fd) + 1
795 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
796 if (__exn > __bs) {
797 __hw.reset((char_type*)malloc(__exn * sizeof(char_type)));
798 __mb = __hw.get();
799 if (__mb == 0)
800 std::__throw_bad_alloc();
801 }
802 // format
803 char_type* __mi;
804 char_type* __me;
805 this->__format(
806 __mb, __mi, __me, __iob.flags(), __db, __db + __n, __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
807 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
808}
809
810template <class _CharT, class _OutputIterator>
811_OutputIterator money_put<_CharT, _OutputIterator>::do_put(
812 iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const {
813 // gather info
814 locale __loc = __iob.getloc();
815 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
816 bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
817 money_base::pattern __pat;
818 char_type __dp;
819 char_type __ts;
820 string __grp;
821 string_type __sym;
822 string_type __sn;
823 int __fd;
824 this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
825 // secure memory for formatting
826 char_type __mbuf[100];
827 char_type* __mb = __mbuf;
828 unique_ptr<char_type, void (*)(void*)> __h(0, free);
829 size_t __exn =
830 static_cast<int>(__digits.size()) > __fd
831 ? (__digits.size() - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + static_cast<size_t>(__fd) +
832 1
833 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
834 if (__exn > 100) {
835 __h.reset((char_type*)malloc(__exn * sizeof(char_type)));
836 __mb = __h.get();
837 if (__mb == 0)
838 std::__throw_bad_alloc();
839 }
840 // format
841 char_type* __mi;
842 char_type* __me;
843 this->__format(
844 __mb,
845 __mi,
846 __me,
847 __iob.flags(),
848 __digits.data(),
849 __digits.data() + __digits.size(),
850 __ct,
851 __neg,
852 __pat,
853 __dp,
854 __ts,
855 __grp,
856 __sym,
857 __sn,
858 __fd);
859 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
860}
861
862extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
863# if _LIBCPP_HAS_WIDE_CHARACTERS
864extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
865# endif
866
867_LIBCPP_END_NAMESPACE_STD
868
869_LIBCPP_POP_MACROS
870
871#endif // _LIBCPP_HAS_LOCALIZATION
872
873#endif // _LIBCPP___LOCALE_DIR_MONEY_H
lib/libcxx/include/__locale_dir/num.h created+1072
...@@ -0,0 +1,1072 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_NUM_H
10#define _LIBCPP___LOCALE_DIR_NUM_H
11
12#include <__algorithm/find.h>
13#include <__algorithm/reverse.h>
14#include <__charconv/to_chars_integral.h>
15#include <__charconv/traits.h>
16#include <__config>
17#include <__iterator/istreambuf_iterator.h>
18#include <__iterator/ostreambuf_iterator.h>
19#include <__locale_dir/check_grouping.h>
20#include <__locale_dir/get_c_locale.h>
21#include <__locale_dir/pad_and_output.h>
22#include <__locale_dir/scan_keyword.h>
23#include <__memory/unique_ptr.h>
24#include <__system_error/errc.h>
25#include <cerrno>
26#include <ios>
27#include <streambuf>
28
29#if _LIBCPP_HAS_LOCALIZATION
30
31# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header
33# endif
34
35// TODO: Properly qualify calls now that the locale base API defines functions instead of macros
36// NOLINTBEGIN(libcpp-robust-against-adl)
37
38_LIBCPP_PUSH_MACROS
39# include <__undef_macros>
40
41_LIBCPP_BEGIN_NAMESPACE_STD
42
43struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base {
44 static const int __num_get_buf_sz = 40;
45
46 static int __get_base(ios_base&);
47 static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN"
48 // count of leading characters in __src used for parsing integers ("012..X+-")
49 static const size_t __int_chr_cnt = 26;
50 // count of leading characters in __src used for parsing floating-point values ("012..-pP")
51 static const size_t __fp_chr_cnt = 28;
52};
53
54template <class _CharT>
55struct __num_get : protected __num_get_base {
56 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep);
57
58 static int __stage2_float_loop(
59 _CharT __ct,
60 bool& __in_units,
61 char& __exp,
62 char* __a,
63 char*& __a_end,
64 _CharT __decimal_point,
65 _CharT __thousands_sep,
66 const string& __grouping,
67 unsigned* __g,
68 unsigned*& __g_end,
69 unsigned& __dc,
70 _CharT* __atoms);
71
72 [[__deprecated__("This exists only for ABI compatibility")]] static string
73 __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
74 static int __stage2_int_loop(
75 _CharT __ct,
76 int __base,
77 char* __a,
78 char*& __a_end,
79 unsigned& __dc,
80 _CharT __thousands_sep,
81 const string& __grouping,
82 unsigned* __g,
83 unsigned*& __g_end,
84 _CharT* __atoms);
85
86 _LIBCPP_HIDE_FROM_ABI static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) {
87 locale __loc = __iob.getloc();
88 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
89 __thousands_sep = __np.thousands_sep();
90 return __np.grouping();
91 }
92
93 _LIBCPP_HIDE_FROM_ABI const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const {
94 return __do_widen_p(__iob, __atoms);
95 }
96
97private:
98 template <typename _Tp>
99 _LIBCPP_HIDE_FROM_ABI const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const {
100 locale __loc = __iob.getloc();
101 use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
102 return __atoms;
103 }
104
105 _LIBCPP_HIDE_FROM_ABI const char* __do_widen_p(ios_base& __iob, char* __atoms) const {
106 (void)__iob;
107 (void)__atoms;
108 return __src;
109 }
110};
111
112template <class _CharT>
113string __num_get<_CharT>::__stage2_float_prep(
114 ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) {
115 locale __loc = __iob.getloc();
116 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms);
117 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
118 __decimal_point = __np.decimal_point();
119 __thousands_sep = __np.thousands_sep();
120 return __np.grouping();
121}
122
123template <class _CharT>
124int __num_get<_CharT>::__stage2_int_loop(
125 _CharT __ct,
126 int __base,
127 char* __a,
128 char*& __a_end,
129 unsigned& __dc,
130 _CharT __thousands_sep,
131 const string& __grouping,
132 unsigned* __g,
133 unsigned*& __g_end,
134 _CharT* __atoms) {
135 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) {
136 *__a_end++ = __ct == __atoms[24] ? '+' : '-';
137 __dc = 0;
138 return 0;
139 }
140 if (__grouping.size() != 0 && __ct == __thousands_sep) {
141 if (__g_end - __g < __num_get_buf_sz) {
142 *__g_end++ = __dc;
143 __dc = 0;
144 }
145 return 0;
146 }
147 ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms;
148 if (__f >= 24)
149 return -1;
150 switch (__base) {
151 case 8:
152 case 10:
153 if (__f >= __base)
154 return -1;
155 break;
156 case 16:
157 if (__f < 22)
158 break;
159 if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') {
160 __dc = 0;
161 *__a_end++ = __src[__f];
162 return 0;
163 }
164 return -1;
165 }
166 *__a_end++ = __src[__f];
167 ++__dc;
168 return 0;
169}
170
171template <class _CharT>
172int __num_get<_CharT>::__stage2_float_loop(
173 _CharT __ct,
174 bool& __in_units,
175 char& __exp,
176 char* __a,
177 char*& __a_end,
178 _CharT __decimal_point,
179 _CharT __thousands_sep,
180 const string& __grouping,
181 unsigned* __g,
182 unsigned*& __g_end,
183 unsigned& __dc,
184 _CharT* __atoms) {
185 if (__ct == __decimal_point) {
186 if (!__in_units)
187 return -1;
188 __in_units = false;
189 *__a_end++ = '.';
190 if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz)
191 *__g_end++ = __dc;
192 return 0;
193 }
194 if (__ct == __thousands_sep && __grouping.size() != 0) {
195 if (!__in_units)
196 return -1;
197 if (__g_end - __g < __num_get_buf_sz) {
198 *__g_end++ = __dc;
199 __dc = 0;
200 }
201 return 0;
202 }
203 ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms;
204 if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt))
205 return -1;
206 char __x = __src[__f];
207 if (__x == '-' || __x == '+') {
208 if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp))) {
209 *__a_end++ = __x;
210 return 0;
211 }
212 return -1;
213 }
214 if (__x == 'x' || __x == 'X')
215 __exp = 'P';
216 else if (std::toupper(__x) == __exp) {
217 __exp = std::tolower(__exp);
218 if (__in_units) {
219 __in_units = false;
220 if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz)
221 *__g_end++ = __dc;
222 }
223 }
224 *__a_end++ = __x;
225 if (__f >= 22)
226 return 0;
227 ++__dc;
228 return 0;
229}
230
231extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
232# if _LIBCPP_HAS_WIDE_CHARACTERS
233extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
234# endif
235
236template <class _Tp>
237_LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
238
239template <>
240inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
241 return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE);
242}
243
244template <>
245inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
246 return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE);
247}
248
249template <>
250inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
251 return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE);
252}
253
254template <class _Tp>
255_LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) {
256 if (__a != __a_end) {
257 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
258 errno = 0;
259 char* __p2;
260 _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
261 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
262 if (__current_errno == 0)
263 errno = __save_errno;
264 if (__p2 != __a_end) {
265 __err = ios_base::failbit;
266 return 0;
267 } else if (__current_errno == ERANGE)
268 __err = ios_base::failbit;
269 return __ld;
270 }
271 __err = ios_base::failbit;
272 return 0;
273}
274
275template <class _Tp>
276_LIBCPP_HIDE_FROM_ABI _Tp
277__num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) {
278 if (__a != __a_end) {
279 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
280 errno = 0;
281 char* __p2;
282 long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
283 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
284 if (__current_errno == 0)
285 errno = __save_errno;
286 if (__p2 != __a_end) {
287 __err = ios_base::failbit;
288 return 0;
289 } else if (__current_errno == ERANGE || __ll < numeric_limits<_Tp>::min() || numeric_limits<_Tp>::max() < __ll) {
290 __err = ios_base::failbit;
291 if (__ll > 0)
292 return numeric_limits<_Tp>::max();
293 else
294 return numeric_limits<_Tp>::min();
295 }
296 return static_cast<_Tp>(__ll);
297 }
298 __err = ios_base::failbit;
299 return 0;
300}
301
302template <class _Tp>
303_LIBCPP_HIDE_FROM_ABI _Tp
304__num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) {
305 if (__a != __a_end) {
306 const bool __negate = *__a == '-';
307 if (__negate && ++__a == __a_end) {
308 __err = ios_base::failbit;
309 return 0;
310 }
311 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
312 errno = 0;
313 char* __p2;
314 unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
315 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
316 if (__current_errno == 0)
317 errno = __save_errno;
318 if (__p2 != __a_end) {
319 __err = ios_base::failbit;
320 return 0;
321 } else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll) {
322 __err = ios_base::failbit;
323 return numeric_limits<_Tp>::max();
324 }
325 _Tp __res = static_cast<_Tp>(__ll);
326 if (__negate)
327 __res = -__res;
328 return __res;
329 }
330 __err = ios_base::failbit;
331 return 0;
332}
333
334template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
335class num_get : public locale::facet, private __num_get<_CharT> {
336public:
337 typedef _CharT char_type;
338 typedef _InputIterator iter_type;
339
340 _LIBCPP_HIDE_FROM_ABI explicit num_get(size_t __refs = 0) : locale::facet(__refs) {}
341
342 _LIBCPP_HIDE_FROM_ABI iter_type
343 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const {
344 return do_get(__b, __e, __iob, __err, __v);
345 }
346
347 _LIBCPP_HIDE_FROM_ABI iter_type
348 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const {
349 return do_get(__b, __e, __iob, __err, __v);
350 }
351
352 _LIBCPP_HIDE_FROM_ABI iter_type
353 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const {
354 return do_get(__b, __e, __iob, __err, __v);
355 }
356
357 _LIBCPP_HIDE_FROM_ABI iter_type
358 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const {
359 return do_get(__b, __e, __iob, __err, __v);
360 }
361
362 _LIBCPP_HIDE_FROM_ABI iter_type
363 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const {
364 return do_get(__b, __e, __iob, __err, __v);
365 }
366
367 _LIBCPP_HIDE_FROM_ABI iter_type
368 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const {
369 return do_get(__b, __e, __iob, __err, __v);
370 }
371
372 _LIBCPP_HIDE_FROM_ABI iter_type
373 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const {
374 return do_get(__b, __e, __iob, __err, __v);
375 }
376
377 _LIBCPP_HIDE_FROM_ABI iter_type
378 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const {
379 return do_get(__b, __e, __iob, __err, __v);
380 }
381
382 _LIBCPP_HIDE_FROM_ABI iter_type
383 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const {
384 return do_get(__b, __e, __iob, __err, __v);
385 }
386
387 _LIBCPP_HIDE_FROM_ABI iter_type
388 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
389 return do_get(__b, __e, __iob, __err, __v);
390 }
391
392 _LIBCPP_HIDE_FROM_ABI iter_type
393 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const {
394 return do_get(__b, __e, __iob, __err, __v);
395 }
396
397 static locale::id id;
398
399protected:
400 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {}
401
402 template <class _Fp>
403 _LIBCPP_HIDE_FROM_ABI iter_type
404 __do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const {
405 // Stage 1, nothing to do
406 // Stage 2
407 char_type __atoms[__num_get_base::__fp_chr_cnt];
408 char_type __decimal_point;
409 char_type __thousands_sep;
410 string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep);
411 string __buf;
412 __buf.resize(__buf.capacity());
413 char* __a = &__buf[0];
414 char* __a_end = __a;
415 unsigned __g[__num_get_base::__num_get_buf_sz];
416 unsigned* __g_end = __g;
417 unsigned __dc = 0;
418 bool __in_units = true;
419 char __exp = 'E';
420 bool __is_leading_parsed = false;
421 for (; __b != __e; ++__b) {
422 if (__a_end == __a + __buf.size()) {
423 size_t __tmp = __buf.size();
424 __buf.resize(2 * __buf.size());
425 __buf.resize(__buf.capacity());
426 __a = &__buf[0];
427 __a_end = __a + __tmp;
428 }
429 if (this->__stage2_float_loop(
430 *__b,
431 __in_units,
432 __exp,
433 __a,
434 __a_end,
435 __decimal_point,
436 __thousands_sep,
437 __grouping,
438 __g,
439 __g_end,
440 __dc,
441 __atoms))
442 break;
443
444 // the leading character excluding the sign must be a decimal digit
445 if (!__is_leading_parsed) {
446 if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') {
447 if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.')
448 __is_leading_parsed = true;
449 else
450 break;
451 } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) {
452 if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.')
453 __is_leading_parsed = true;
454 else
455 break;
456 }
457 }
458 }
459 if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz)
460 *__g_end++ = __dc;
461 // Stage 3
462 __v = std::__num_get_float<_Fp>(__a, __a_end, __err);
463 // Digit grouping checked
464 __check_grouping(__grouping, __g, __g_end, __err);
465 // EOF checked
466 if (__b == __e)
467 __err |= ios_base::eofbit;
468 return __b;
469 }
470
471 template <class _Signed>
472 _LIBCPP_HIDE_FROM_ABI iter_type
473 __do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const {
474 // Stage 1
475 int __base = this->__get_base(__iob);
476 // Stage 2
477 char_type __thousands_sep;
478 const int __atoms_size = __num_get_base::__int_chr_cnt;
479 char_type __atoms1[__atoms_size];
480 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
481 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
482 string __buf;
483 __buf.resize(__buf.capacity());
484 char* __a = &__buf[0];
485 char* __a_end = __a;
486 unsigned __g[__num_get_base::__num_get_buf_sz];
487 unsigned* __g_end = __g;
488 unsigned __dc = 0;
489 for (; __b != __e; ++__b) {
490 if (__a_end == __a + __buf.size()) {
491 size_t __tmp = __buf.size();
492 __buf.resize(2 * __buf.size());
493 __buf.resize(__buf.capacity());
494 __a = &__buf[0];
495 __a_end = __a + __tmp;
496 }
497 if (this->__stage2_int_loop(
498 *__b,
499 __base,
500 __a,
501 __a_end,
502 __dc,
503 __thousands_sep,
504 __grouping,
505 __g,
506 __g_end,
507 const_cast<char_type*>(__atoms)))
508 break;
509 }
510 if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz)
511 *__g_end++ = __dc;
512 // Stage 3
513 __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
514 // Digit grouping checked
515 __check_grouping(__grouping, __g, __g_end, __err);
516 // EOF checked
517 if (__b == __e)
518 __err |= ios_base::eofbit;
519 return __b;
520 }
521
522 template <class _Unsigned>
523 _LIBCPP_HIDE_FROM_ABI iter_type
524 __do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const {
525 // Stage 1
526 int __base = this->__get_base(__iob);
527 // Stage 2
528 char_type __thousands_sep;
529 const int __atoms_size = __num_get_base::__int_chr_cnt;
530 char_type __atoms1[__atoms_size];
531 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
532 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
533 string __buf;
534 __buf.resize(__buf.capacity());
535 char* __a = &__buf[0];
536 char* __a_end = __a;
537 unsigned __g[__num_get_base::__num_get_buf_sz];
538 unsigned* __g_end = __g;
539 unsigned __dc = 0;
540 for (; __b != __e; ++__b) {
541 if (__a_end == __a + __buf.size()) {
542 size_t __tmp = __buf.size();
543 __buf.resize(2 * __buf.size());
544 __buf.resize(__buf.capacity());
545 __a = &__buf[0];
546 __a_end = __a + __tmp;
547 }
548 if (this->__stage2_int_loop(
549 *__b,
550 __base,
551 __a,
552 __a_end,
553 __dc,
554 __thousands_sep,
555 __grouping,
556 __g,
557 __g_end,
558 const_cast<char_type*>(__atoms)))
559 break;
560 }
561 if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz)
562 *__g_end++ = __dc;
563 // Stage 3
564 __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
565 // Digit grouping checked
566 __check_grouping(__grouping, __g, __g_end, __err);
567 // EOF checked
568 if (__b == __e)
569 __err |= ios_base::eofbit;
570 return __b;
571 }
572
573 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const;
574
575 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const {
576 return this->__do_get_signed(__b, __e, __iob, __err, __v);
577 }
578
579 virtual iter_type
580 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const {
581 return this->__do_get_signed(__b, __e, __iob, __err, __v);
582 }
583
584 virtual iter_type
585 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const {
586 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
587 }
588
589 virtual iter_type
590 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const {
591 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
592 }
593
594 virtual iter_type
595 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const {
596 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
597 }
598
599 virtual iter_type
600 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const {
601 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
602 }
603
604 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const {
605 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
606 }
607
608 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const {
609 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
610 }
611
612 virtual iter_type
613 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
614 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
615 }
616
617 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const;
618};
619
620template <class _CharT, class _InputIterator>
621locale::id num_get<_CharT, _InputIterator>::id;
622
623template <class _CharT, class _InputIterator>
624_InputIterator num_get<_CharT, _InputIterator>::do_get(
625 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const {
626 if ((__iob.flags() & ios_base::boolalpha) == 0) {
627 long __lv = -1;
628 __b = do_get(__b, __e, __iob, __err, __lv);
629 switch (__lv) {
630 case 0:
631 __v = false;
632 break;
633 case 1:
634 __v = true;
635 break;
636 default:
637 __v = true;
638 __err = ios_base::failbit;
639 break;
640 }
641 return __b;
642 }
643 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc());
644 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc());
645 typedef typename numpunct<_CharT>::string_type string_type;
646 const string_type __names[2] = {__np.truename(), __np.falsename()};
647 const string_type* __i = std::__scan_keyword(__b, __e, __names, __names + 2, __ct, __err);
648 __v = __i == __names;
649 return __b;
650}
651
652template <class _CharT, class _InputIterator>
653_InputIterator num_get<_CharT, _InputIterator>::do_get(
654 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const {
655 // Stage 1
656 int __base = 16;
657 // Stage 2
658 char_type __atoms[__num_get_base::__int_chr_cnt];
659 char_type __thousands_sep = char_type();
660 string __grouping;
661 std::use_facet<ctype<_CharT> >(__iob.getloc())
662 .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms);
663 string __buf;
664 __buf.resize(__buf.capacity());
665 char* __a = &__buf[0];
666 char* __a_end = __a;
667 unsigned __g[__num_get_base::__num_get_buf_sz];
668 unsigned* __g_end = __g;
669 unsigned __dc = 0;
670 for (; __b != __e; ++__b) {
671 if (__a_end == __a + __buf.size()) {
672 size_t __tmp = __buf.size();
673 __buf.resize(2 * __buf.size());
674 __buf.resize(__buf.capacity());
675 __a = &__buf[0];
676 __a_end = __a + __tmp;
677 }
678 if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms))
679 break;
680 }
681 // Stage 3
682 __buf.resize(__a_end - __a);
683 if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
684 __err = ios_base::failbit;
685 // EOF checked
686 if (__b == __e)
687 __err |= ios_base::eofbit;
688 return __b;
689}
690
691extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
692# if _LIBCPP_HAS_WIDE_CHARACTERS
693extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
694# endif
695
696struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base {
697protected:
698 static void __format_int(char* __fmt, const char* __len, bool __signd, ios_base::fmtflags __flags);
699 static bool __format_float(char* __fmt, const char* __len, ios_base::fmtflags __flags);
700 static char* __identify_padding(char* __nb, char* __ne, const ios_base& __iob);
701};
702
703template <class _CharT>
704struct __num_put : protected __num_put_base {
705 static void __widen_and_group_int(
706 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc);
707 static void __widen_and_group_float(
708 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc);
709};
710
711template <class _CharT>
712void __num_put<_CharT>::__widen_and_group_int(
713 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) {
714 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc);
715 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
716 string __grouping = __npt.grouping();
717 if (__grouping.empty()) {
718 __ct.widen(__nb, __ne, __ob);
719 __oe = __ob + (__ne - __nb);
720 } else {
721 __oe = __ob;
722 char* __nf = __nb;
723 if (*__nf == '-' || *__nf == '+')
724 *__oe++ = __ct.widen(*__nf++);
725 if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) {
726 *__oe++ = __ct.widen(*__nf++);
727 *__oe++ = __ct.widen(*__nf++);
728 }
729 std::reverse(__nf, __ne);
730 _CharT __thousands_sep = __npt.thousands_sep();
731 unsigned __dc = 0;
732 unsigned __dg = 0;
733 for (char* __p = __nf; __p < __ne; ++__p) {
734 if (static_cast<unsigned>(__grouping[__dg]) > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) {
735 *__oe++ = __thousands_sep;
736 __dc = 0;
737 if (__dg < __grouping.size() - 1)
738 ++__dg;
739 }
740 *__oe++ = __ct.widen(*__p);
741 ++__dc;
742 }
743 std::reverse(__ob + (__nf - __nb), __oe);
744 }
745 if (__np == __ne)
746 __op = __oe;
747 else
748 __op = __ob + (__np - __nb);
749}
750
751template <class _CharT>
752void __num_put<_CharT>::__widen_and_group_float(
753 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) {
754 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc);
755 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
756 string __grouping = __npt.grouping();
757 __oe = __ob;
758 char* __nf = __nb;
759 if (*__nf == '-' || *__nf == '+')
760 *__oe++ = __ct.widen(*__nf++);
761 char* __ns;
762 if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) {
763 *__oe++ = __ct.widen(*__nf++);
764 *__oe++ = __ct.widen(*__nf++);
765 for (__ns = __nf; __ns < __ne; ++__ns)
766 if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE))
767 break;
768 } else {
769 for (__ns = __nf; __ns < __ne; ++__ns)
770 if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE))
771 break;
772 }
773 if (__grouping.empty()) {
774 __ct.widen(__nf, __ns, __oe);
775 __oe += __ns - __nf;
776 } else {
777 std::reverse(__nf, __ns);
778 _CharT __thousands_sep = __npt.thousands_sep();
779 unsigned __dc = 0;
780 unsigned __dg = 0;
781 for (char* __p = __nf; __p < __ns; ++__p) {
782 if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) {
783 *__oe++ = __thousands_sep;
784 __dc = 0;
785 if (__dg < __grouping.size() - 1)
786 ++__dg;
787 }
788 *__oe++ = __ct.widen(*__p);
789 ++__dc;
790 }
791 std::reverse(__ob + (__nf - __nb), __oe);
792 }
793 for (__nf = __ns; __nf < __ne; ++__nf) {
794 if (*__nf == '.') {
795 *__oe++ = __npt.decimal_point();
796 ++__nf;
797 break;
798 } else
799 *__oe++ = __ct.widen(*__nf);
800 }
801 __ct.widen(__nf, __ne, __oe);
802 __oe += __ne - __nf;
803 if (__np == __ne)
804 __op = __oe;
805 else
806 __op = __ob + (__np - __nb);
807}
808
809extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
810# if _LIBCPP_HAS_WIDE_CHARACTERS
811extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
812# endif
813
814template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
815class num_put : public locale::facet, private __num_put<_CharT> {
816public:
817 typedef _CharT char_type;
818 typedef _OutputIterator iter_type;
819
820 _LIBCPP_HIDE_FROM_ABI explicit num_put(size_t __refs = 0) : locale::facet(__refs) {}
821
822 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {
823 return do_put(__s, __iob, __fl, __v);
824 }
825
826 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const {
827 return do_put(__s, __iob, __fl, __v);
828 }
829
830 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const {
831 return do_put(__s, __iob, __fl, __v);
832 }
833
834 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const {
835 return do_put(__s, __iob, __fl, __v);
836 }
837
838 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const {
839 return do_put(__s, __iob, __fl, __v);
840 }
841
842 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const {
843 return do_put(__s, __iob, __fl, __v);
844 }
845
846 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const {
847 return do_put(__s, __iob, __fl, __v);
848 }
849
850 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const {
851 return do_put(__s, __iob, __fl, __v);
852 }
853
854 static locale::id id;
855
856protected:
857 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {}
858
859 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const;
860 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const;
861 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const;
862 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long) const;
863 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long) const;
864 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const;
865 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const;
866 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const;
867
868 template <class _Integral>
869 _LIBCPP_HIDE_FROM_ABI inline _OutputIterator
870 __do_put_integral(iter_type __s, ios_base& __iob, char_type __fl, _Integral __v) const;
871
872 template <class _Float>
873 _LIBCPP_HIDE_FROM_ABI inline _OutputIterator
874 __do_put_floating_point(iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const;
875};
876
877template <class _CharT, class _OutputIterator>
878locale::id num_put<_CharT, _OutputIterator>::id;
879
880template <class _CharT, class _OutputIterator>
881_OutputIterator
882num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {
883 if ((__iob.flags() & ios_base::boolalpha) == 0)
884 return do_put(__s, __iob, __fl, (unsigned long)__v);
885 const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc());
886 typedef typename numpunct<char_type>::string_type string_type;
887 string_type __nm = __v ? __np.truename() : __np.falsename();
888 for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s)
889 *__s = *__i;
890 return __s;
891}
892
893template <class _CharT, class _OutputIterator>
894template <class _Integral>
895_LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_integral(
896 iter_type __s, ios_base& __iob, char_type __fl, _Integral __v) const {
897 // Stage 1 - Get number in narrow char
898
899 // Worst case is octal, with showbase enabled. Note that octal is always
900 // printed as an unsigned value.
901 using _Unsigned = typename make_unsigned<_Integral>::type;
902 _LIBCPP_CONSTEXPR const unsigned __buffer_size =
903 (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits
904 + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up
905 + 2; // base prefix + terminating null character
906
907 char __char_buffer[__buffer_size];
908 char* __buffer_ptr = __char_buffer;
909
910 auto __flags = __iob.flags();
911
912 auto __basefield = (__flags & ios_base::basefield);
913
914 // Extract base
915 int __base = 10;
916 if (__basefield == ios_base::oct)
917 __base = 8;
918 else if (__basefield == ios_base::hex)
919 __base = 16;
920
921 // Print '-' and make the argument unsigned
922 auto __uval = std::__to_unsigned_like(__v);
923 if (__basefield != ios_base::oct && __basefield != ios_base::hex && __v < 0) {
924 *__buffer_ptr++ = '-';
925 __uval = std::__complement(__uval);
926 }
927
928 // Maybe add '+' prefix
929 if (std::is_signed<_Integral>::value && (__flags & ios_base::showpos) && __basefield != ios_base::oct &&
930 __basefield != ios_base::hex && __v >= 0)
931 *__buffer_ptr++ = '+';
932
933 // Add base prefix
934 if (__v != 0 && __flags & ios_base::showbase) {
935 if (__basefield == ios_base::oct) {
936 *__buffer_ptr++ = '0';
937 } else if (__basefield == ios_base::hex) {
938 *__buffer_ptr++ = '0';
939 *__buffer_ptr++ = (__flags & ios_base::uppercase ? 'X' : 'x');
940 }
941 }
942
943 auto __res = std::__to_chars_integral(__buffer_ptr, __char_buffer + __buffer_size, __uval, __base);
944 _LIBCPP_ASSERT_INTERNAL(__res.__ec == std::errc(0), "to_chars: invalid maximum buffer size computed?");
945
946 // Make letters uppercase
947 if (__flags & ios_base::hex && __flags & ios_base::uppercase) {
948 for (; __buffer_ptr != __res.__ptr; ++__buffer_ptr)
949 *__buffer_ptr = std::__hex_to_upper(*__buffer_ptr);
950 }
951
952 char* __np = this->__identify_padding(__char_buffer, __res.__ptr, __iob);
953 // Stage 2 - Widen __nar while adding thousands separators
954 char_type __o[2 * (__buffer_size - 1) - 1];
955 char_type* __op; // pad here
956 char_type* __oe; // end of output
957 this->__widen_and_group_int(__char_buffer, __np, __res.__ptr, __o, __op, __oe, __iob.getloc());
958 // [__o, __oe) contains thousands_sep'd wide number
959 // Stage 3 & 4
960 return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
961}
962
963template <class _CharT, class _OutputIterator>
964_OutputIterator
965num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const {
966 return this->__do_put_integral(__s, __iob, __fl, __v);
967}
968
969template <class _CharT, class _OutputIterator>
970_OutputIterator
971num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const {
972 return this->__do_put_integral(__s, __iob, __fl, __v);
973}
974
975template <class _CharT, class _OutputIterator>
976_OutputIterator
977num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const {
978 return this->__do_put_integral(__s, __iob, __fl, __v);
979}
980
981template <class _CharT, class _OutputIterator>
982_OutputIterator
983num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const {
984 return this->__do_put_integral(__s, __iob, __fl, __v);
985}
986
987template <class _CharT, class _OutputIterator>
988template <class _Float>
989_LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_floating_point(
990 iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const {
991 // Stage 1 - Get number in narrow char
992 char __fmt[8] = {'%', 0};
993 bool __specify_precision = this->__format_float(__fmt + 1, __len, __iob.flags());
994 const unsigned __nbuf = 30;
995 char __nar[__nbuf];
996 char* __nb = __nar;
997 int __nc;
998 _LIBCPP_DIAGNOSTIC_PUSH
999 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1000 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1001 if (__specify_precision)
1002 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1003 else
1004 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1005 unique_ptr<char, void (*)(void*)> __nbh(nullptr, free);
1006 if (__nc > static_cast<int>(__nbuf - 1)) {
1007 if (__specify_precision)
1008 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1009 else
1010 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1011 if (__nc == -1)
1012 std::__throw_bad_alloc();
1013 __nbh.reset(__nb);
1014 }
1015 _LIBCPP_DIAGNOSTIC_POP
1016 char* __ne = __nb + __nc;
1017 char* __np = this->__identify_padding(__nb, __ne, __iob);
1018 // Stage 2 - Widen __nar while adding thousands separators
1019 char_type __o[2 * (__nbuf - 1) - 1];
1020 char_type* __ob = __o;
1021 unique_ptr<char_type, void (*)(void*)> __obh(0, free);
1022 if (__nb != __nar) {
1023 __ob = (char_type*)malloc(2 * static_cast<size_t>(__nc) * sizeof(char_type));
1024 if (__ob == 0)
1025 std::__throw_bad_alloc();
1026 __obh.reset(__ob);
1027 }
1028 char_type* __op; // pad here
1029 char_type* __oe; // end of output
1030 this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
1031 // [__o, __oe) contains thousands_sep'd wide number
1032 // Stage 3 & 4
1033 __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
1034 return __s;
1035}
1036
1037template <class _CharT, class _OutputIterator>
1038_OutputIterator
1039num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const {
1040 return this->__do_put_floating_point(__s, __iob, __fl, __v, "");
1041}
1042
1043template <class _CharT, class _OutputIterator>
1044_OutputIterator
1045num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const {
1046 return this->__do_put_floating_point(__s, __iob, __fl, __v, "L");
1047}
1048
1049template <class _CharT, class _OutputIterator>
1050_OutputIterator
1051num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const {
1052 auto __flags = __iob.flags();
1053 __iob.flags((__flags & ~ios_base::basefield & ~ios_base::uppercase) | ios_base::hex | ios_base::showbase);
1054 auto __res = __do_put_integral(__s, __iob, __fl, reinterpret_cast<uintptr_t>(__v));
1055 __iob.flags(__flags);
1056 return __res;
1057}
1058
1059extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
1060# if _LIBCPP_HAS_WIDE_CHARACTERS
1061extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1062# endif
1063
1064_LIBCPP_END_NAMESPACE_STD
1065
1066_LIBCPP_POP_MACROS
1067
1068// NOLINTEND(libcpp-robust-against-adl)
1069
1070#endif // _LIBCPP_HAS_LOCALIZATION
1071
1072#endif // _LIBCPP___LOCALE_DIR_NUM_H
lib/libcxx/include/__locale_dir/scan_keyword.h created+143
...@@ -0,0 +1,143 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H
10#define _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H
11
12#include <__config>
13#include <__memory/unique_ptr.h>
14#include <ios>
15
16#if _LIBCPP_HAS_LOCALIZATION
17
18# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20# endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24// __scan_keyword
25// Scans [__b, __e) until a match is found in the basic_strings range
26// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
27// __b will be incremented (visibly), consuming CharT until a match is found
28// or proved to not exist. A keyword may be "", in which will match anything.
29// If one keyword is a prefix of another, and the next CharT in the input
30// might match another keyword, the algorithm will attempt to find the longest
31// matching keyword. If the longer matching keyword ends up not matching, then
32// no keyword match is found. If no keyword match is found, __ke is returned
33// and failbit is set in __err.
34// Else an iterator pointing to the matching keyword is found. If more than
35// one keyword matches, an iterator to the first matching keyword is returned.
36// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
37// __ct is used to force to lower case before comparing characters.
38// Examples:
39// Keywords: "a", "abb"
40// If the input is "a", the first keyword matches and eofbit is set.
41// If the input is "abc", no match is found and "ab" are consumed.
42template <class _InputIterator, class _ForwardIterator, class _Ctype>
43_LIBCPP_HIDE_FROM_ABI _ForwardIterator __scan_keyword(
44 _InputIterator& __b,
45 _InputIterator __e,
46 _ForwardIterator __kb,
47 _ForwardIterator __ke,
48 const _Ctype& __ct,
49 ios_base::iostate& __err,
50 bool __case_sensitive = true) {
51 typedef typename iterator_traits<_InputIterator>::value_type _CharT;
52 size_t __nkw = static_cast<size_t>(std::distance(__kb, __ke));
53 const unsigned char __doesnt_match = '\0';
54 const unsigned char __might_match = '\1';
55 const unsigned char __does_match = '\2';
56 unsigned char __statbuf[100];
57 unsigned char* __status = __statbuf;
58 unique_ptr<unsigned char, void (*)(void*)> __stat_hold(nullptr, free);
59 if (__nkw > sizeof(__statbuf)) {
60 __status = (unsigned char*)malloc(__nkw);
61 if (__status == nullptr)
62 std::__throw_bad_alloc();
63 __stat_hold.reset(__status);
64 }
65 size_t __n_might_match = __nkw; // At this point, any keyword might match
66 size_t __n_does_match = 0; // but none of them definitely do
67 // Initialize all statuses to __might_match, except for "" keywords are __does_match
68 unsigned char* __st = __status;
69 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
70 if (!__ky->empty())
71 *__st = __might_match;
72 else {
73 *__st = __does_match;
74 --__n_might_match;
75 ++__n_does_match;
76 }
77 }
78 // While there might be a match, test keywords against the next CharT
79 for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx) {
80 // Peek at the next CharT but don't consume it
81 _CharT __c = *__b;
82 if (!__case_sensitive)
83 __c = __ct.toupper(__c);
84 bool __consume = false;
85 // For each keyword which might match, see if the __indx character is __c
86 // If a match if found, consume __c
87 // If a match is found, and that is the last character in the keyword,
88 // then that keyword matches.
89 // If the keyword doesn't match this character, then change the keyword
90 // to doesn't match
91 __st = __status;
92 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
93 if (*__st == __might_match) {
94 _CharT __kc = (*__ky)[__indx];
95 if (!__case_sensitive)
96 __kc = __ct.toupper(__kc);
97 if (__c == __kc) {
98 __consume = true;
99 if (__ky->size() == __indx + 1) {
100 *__st = __does_match;
101 --__n_might_match;
102 ++__n_does_match;
103 }
104 } else {
105 *__st = __doesnt_match;
106 --__n_might_match;
107 }
108 }
109 }
110 // consume if we matched a character
111 if (__consume) {
112 ++__b;
113 // If we consumed a character and there might be a matched keyword that
114 // was marked matched on a previous iteration, then such keywords
115 // which are now marked as not matching.
116 if (__n_might_match + __n_does_match > 1) {
117 __st = __status;
118 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
119 if (*__st == __does_match && __ky->size() != __indx + 1) {
120 *__st = __doesnt_match;
121 --__n_does_match;
122 }
123 }
124 }
125 }
126 }
127 // We've exited the loop because we hit eof and/or we have no more "might matches".
128 if (__b == __e)
129 __err |= ios_base::eofbit;
130 // Return the first matching result
131 for (__st = __status; __kb != __ke; ++__kb, (void)++__st)
132 if (*__st == __does_match)
133 break;
134 if (__kb == __ke)
135 __err |= ios_base::failbit;
136 return __kb;
137}
138
139_LIBCPP_END_NAMESPACE_STD
140
141#endif // _LIBCPP_HAS_LOCALIZATION
142
143#endif // _LIBCPP___LOCALE_DIR_SCAN_KEYWORD_H
lib/libcxx/include/__locale_dir/support/apple.h-2
...@@ -15,8 +15,6 @@...@@ -15,8 +15,6 @@
15# pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18#include <xlocale.h>
19
20#include <__locale_dir/support/bsd_like.h>18#include <__locale_dir/support/bsd_like.h>
2119
22#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H20#endif // _LIBCPP___LOCALE_DIR_SUPPORT_APPLE_H
lib/libcxx/include/__locale_dir/support/bsd_like.h+7-8
...@@ -24,6 +24,11 @@...@@ -24,6 +24,11 @@
24# include <wctype.h>24# include <wctype.h>
25#endif25#endif
2626
27/* zig patch: https://github.com/llvm/llvm-project/pull/143055 */
28#if __has_include(<xlocale.h>)
29# include <xlocale.h>
30#endif
31
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header33# pragma GCC system_header
29#endif34#endif
...@@ -43,9 +48,9 @@ namespace __locale {...@@ -43,9 +48,9 @@ namespace __locale {
43#define _LIBCPP_ALL_MASK LC_ALL_MASK48#define _LIBCPP_ALL_MASK LC_ALL_MASK
44#define _LIBCPP_LC_ALL LC_ALL49#define _LIBCPP_LC_ALL LC_ALL
4550
46using __locale_t = ::locale_t;51using __locale_t _LIBCPP_NODEBUG = ::locale_t;
47#if defined(_LIBCPP_BUILDING_LIBRARY)52#if defined(_LIBCPP_BUILDING_LIBRARY)
48using __lconv_t = std::lconv;53using __lconv_t _LIBCPP_NODEBUG = std::lconv;
4954
50inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {55inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {
51 return ::newlocale(__category_mask, __locale, __base);56 return ::newlocale(__category_mask, __locale, __base);
...@@ -87,12 +92,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {...@@ -87,12 +92,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
87//92//
88// Character manipulation functions93// Character manipulation functions
89//94//
90#if defined(_LIBCPP_BUILDING_LIBRARY)
91inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return ::islower_l(__c, __loc); }
92
93inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return ::isupper_l(__c, __loc); }
94#endif
95
96inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); }95inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return ::isdigit_l(__c, __loc); }
9796
98inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); }97inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return ::isxdigit_l(__c, __loc); }
lib/libcxx/include/__locale_dir/support/freebsd.h-2
...@@ -15,8 +15,6 @@...@@ -15,8 +15,6 @@
15# pragma GCC system_header15# pragma GCC system_header
16#endif16#endif
1717
18#include <xlocale.h>
19
20#include <__locale_dir/support/bsd_like.h>18#include <__locale_dir/support/bsd_like.h>
2119
22#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H20#endif // _LIBCPP___LOCALE_DIR_SUPPORT_FREEBSD_H
lib/libcxx/include/__locale_dir/support/fuchsia.h+2-2
...@@ -49,10 +49,10 @@ struct __locale_guard {...@@ -49,10 +49,10 @@ struct __locale_guard {
49#define _LIBCPP_ALL_MASK LC_ALL_MASK49#define _LIBCPP_ALL_MASK LC_ALL_MASK
50#define _LIBCPP_LC_ALL LC_ALL50#define _LIBCPP_LC_ALL LC_ALL
5151
52using __locale_t = locale_t;52using __locale_t _LIBCPP_NODEBUG = locale_t;
5353
54#if defined(_LIBCPP_BUILDING_LIBRARY)54#if defined(_LIBCPP_BUILDING_LIBRARY)
55using __lconv_t = std::lconv;55using __lconv_t _LIBCPP_NODEBUG = std::lconv;
5656
57inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {57inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __name, __locale_t __loc) {
58 return ::newlocale(__category_mask, __name, __loc);58 return ::newlocale(__category_mask, __name, __loc);
lib/libcxx/include/__locale_dir/support/linux.h created+281
...@@ -0,0 +1,281 @@
1//===-----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__std_mbstate_t.h>
15#include <__utility/forward.h>
16#include <clocale> // std::lconv
17#include <cstdio>
18#include <cstdlib>
19#include <ctype.h>
20#include <stdarg.h>
21#include <string.h>
22#include <time.h>
23#if _LIBCPP_HAS_WIDE_CHARACTERS
24# include <cwchar>
25# include <wctype.h>
26#endif
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33namespace __locale {
34
35struct __locale_guard {
36 _LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
37
38 _LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
39 if (__old_loc_)
40 ::uselocale(__old_loc_);
41 }
42
43 locale_t __old_loc_;
44
45 __locale_guard(__locale_guard const&) = delete;
46 __locale_guard& operator=(__locale_guard const&) = delete;
47};
48
49//
50// Locale management
51//
52#define _LIBCPP_COLLATE_MASK LC_COLLATE_MASK
53#define _LIBCPP_CTYPE_MASK LC_CTYPE_MASK
54#define _LIBCPP_MONETARY_MASK LC_MONETARY_MASK
55#define _LIBCPP_NUMERIC_MASK LC_NUMERIC_MASK
56#define _LIBCPP_TIME_MASK LC_TIME_MASK
57#define _LIBCPP_MESSAGES_MASK LC_MESSAGES_MASK
58#define _LIBCPP_ALL_MASK LC_ALL_MASK
59#define _LIBCPP_LC_ALL LC_ALL
60
61using __locale_t _LIBCPP_NODEBUG = ::locale_t;
62
63#if defined(_LIBCPP_BUILDING_LIBRARY)
64using __lconv_t _LIBCPP_NODEBUG = std::lconv;
65
66inline _LIBCPP_HIDE_FROM_ABI __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {
67 return ::newlocale(__category_mask, __locale, __base);
68}
69
70inline _LIBCPP_HIDE_FROM_ABI void __freelocale(__locale_t __loc) { ::freelocale(__loc); }
71
72inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, char const* __locale) {
73 return ::setlocale(__category, __locale);
74}
75
76inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
77 __locale_guard __current(__loc);
78 return std::localeconv();
79}
80#endif // _LIBCPP_BUILDING_LIBRARY
81
82//
83// Strtonum functions
84//
85inline _LIBCPP_HIDE_FROM_ABI float __strtof(const char* __nptr, char** __endptr, __locale_t __loc) {
86 return ::strtof_l(__nptr, __endptr, __loc);
87}
88
89inline _LIBCPP_HIDE_FROM_ABI double __strtod(const char* __nptr, char** __endptr, __locale_t __loc) {
90 return ::strtod_l(__nptr, __endptr, __loc);
91}
92
93inline _LIBCPP_HIDE_FROM_ABI long double __strtold(const char* __nptr, char** __endptr, __locale_t __loc) {
94 return ::strtold_l(__nptr, __endptr, __loc);
95}
96
97inline _LIBCPP_HIDE_FROM_ABI long long __strtoll(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
98#if !_LIBCPP_HAS_MUSL_LIBC
99 return ::strtoll_l(__nptr, __endptr, __base, __loc);
100#else
101 (void)__loc;
102 return ::strtoll(__nptr, __endptr, __base);
103#endif
104}
105
106inline _LIBCPP_HIDE_FROM_ABI unsigned long long
107__strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
108#if !_LIBCPP_HAS_MUSL_LIBC
109 return ::strtoull_l(__nptr, __endptr, __base, __loc);
110#else
111 (void)__loc;
112 return ::strtoull(__nptr, __endptr, __base);
113#endif
114}
115
116//
117// Character manipulation functions
118//
119inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return isdigit_l(__c, __loc); }
120
121inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return isxdigit_l(__c, __loc); }
122
123#if defined(_LIBCPP_BUILDING_LIBRARY)
124inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t __loc) { return toupper_l(__c, __loc); }
125
126inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t __loc) { return tolower_l(__c, __loc); }
127
128inline _LIBCPP_HIDE_FROM_ABI int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) {
129 return strcoll_l(__s1, __s2, __loc);
130}
131
132inline _LIBCPP_HIDE_FROM_ABI size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
133 return strxfrm_l(__dest, __src, __n, __loc);
134}
135
136# if _LIBCPP_HAS_WIDE_CHARACTERS
137inline _LIBCPP_HIDE_FROM_ABI int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) {
138 return iswctype_l(__c, __type, __loc);
139}
140
141inline _LIBCPP_HIDE_FROM_ABI int __iswspace(wint_t __c, __locale_t __loc) { return iswspace_l(__c, __loc); }
142
143inline _LIBCPP_HIDE_FROM_ABI int __iswprint(wint_t __c, __locale_t __loc) { return iswprint_l(__c, __loc); }
144
145inline _LIBCPP_HIDE_FROM_ABI int __iswcntrl(wint_t __c, __locale_t __loc) { return iswcntrl_l(__c, __loc); }
146
147inline _LIBCPP_HIDE_FROM_ABI int __iswupper(wint_t __c, __locale_t __loc) { return iswupper_l(__c, __loc); }
148
149inline _LIBCPP_HIDE_FROM_ABI int __iswlower(wint_t __c, __locale_t __loc) { return iswlower_l(__c, __loc); }
150
151inline _LIBCPP_HIDE_FROM_ABI int __iswalpha(wint_t __c, __locale_t __loc) { return iswalpha_l(__c, __loc); }
152
153inline _LIBCPP_HIDE_FROM_ABI int __iswblank(wint_t __c, __locale_t __loc) { return iswblank_l(__c, __loc); }
154
155inline _LIBCPP_HIDE_FROM_ABI int __iswdigit(wint_t __c, __locale_t __loc) { return iswdigit_l(__c, __loc); }
156
157inline _LIBCPP_HIDE_FROM_ABI int __iswpunct(wint_t __c, __locale_t __loc) { return iswpunct_l(__c, __loc); }
158
159inline _LIBCPP_HIDE_FROM_ABI int __iswxdigit(wint_t __c, __locale_t __loc) { return iswxdigit_l(__c, __loc); }
160
161inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __c, __locale_t __loc) { return towupper_l(__c, __loc); }
162
163inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __c, __locale_t __loc) { return towlower_l(__c, __loc); }
164
165inline _LIBCPP_HIDE_FROM_ABI int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) {
166 return wcscoll_l(__ws1, __ws2, __loc);
167}
168
169inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
170 return wcsxfrm_l(__dest, __src, __n, __loc);
171}
172# endif // _LIBCPP_HAS_WIDE_CHARACTERS
173
174inline _LIBCPP_HIDE_FROM_ABI size_t
175__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
176 return strftime_l(__s, __max, __format, __tm, __loc);
177}
178
179//
180// Other functions
181//
182inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) {
183 __locale_guard __current(__loc);
184 return MB_CUR_MAX;
185}
186
187# if _LIBCPP_HAS_WIDE_CHARACTERS
188inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t __loc) {
189 __locale_guard __current(__loc);
190 return std::btowc(__c);
191}
192
193inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t __loc) {
194 __locale_guard __current(__loc);
195 return std::wctob(__c);
196}
197
198inline _LIBCPP_HIDE_FROM_ABI size_t
199__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
200 __locale_guard __current(__loc);
201 return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // non-standard
202}
203
204inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) {
205 __locale_guard __current(__loc);
206 return std::wcrtomb(__s, __wc, __ps);
207}
208
209inline _LIBCPP_HIDE_FROM_ABI size_t
210__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
211 __locale_guard __current(__loc);
212 return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // non-standard
213}
214
215inline _LIBCPP_HIDE_FROM_ABI size_t
216__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
217 __locale_guard __current(__loc);
218 return std::mbrtowc(__pwc, __s, __n, __ps);
219}
220
221inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
222 __locale_guard __current(__loc);
223 return std::mbtowc(__pwc, __pmb, __max);
224}
225
226inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
227 __locale_guard __current(__loc);
228 return std::mbrlen(__s, __n, __ps);
229}
230
231inline _LIBCPP_HIDE_FROM_ABI size_t
232__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
233 __locale_guard __current(__loc);
234 return std::mbsrtowcs(__dest, __src, __len, __ps);
235}
236# endif // _LIBCPP_HAS_WIDE_CHARACTERS
237#endif // _LIBCPP_BUILDING_LIBRARY
238
239#ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs
240_LIBCPP_HIDE_FROM_ABI
241#endif
242inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
243 char* __s, size_t __n, __locale_t __loc, const char* __format, ...) {
244 va_list __va;
245 va_start(__va, __format);
246 __locale_guard __current(__loc);
247 int __res = std::vsnprintf(__s, __n, __format, __va);
248 va_end(__va);
249 return __res;
250}
251
252#ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs
253_LIBCPP_HIDE_FROM_ABI
254#endif
255inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
256 char** __s, __locale_t __loc, const char* __format, ...) {
257 va_list __va;
258 va_start(__va, __format);
259 __locale_guard __current(__loc);
260 int __res = ::vasprintf(__s, __format, __va); // non-standard
261 va_end(__va);
262 return __res;
263}
264
265#ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs
266_LIBCPP_HIDE_FROM_ABI
267#endif
268inline _LIBCPP_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int __sscanf(
269 const char* __s, __locale_t __loc, const char* __format, ...) {
270 va_list __va;
271 va_start(__va, __format);
272 __locale_guard __current(__loc);
273 int __res = std::vsscanf(__s, __format, __va);
274 va_end(__va);
275 return __res;
276}
277
278} // namespace __locale
279_LIBCPP_END_NAMESPACE_STD
280
281#endif // _LIBCPP___LOCALE_DIR_SUPPORT_LINUX_H
lib/libcxx/include/__locale_dir/support/netbsd.h+2
...@@ -6,6 +6,8 @@...@@ -6,6 +6,8 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9/* zig patch: https://github.com/llvm/llvm-project/pull/143055 */
10
9#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H11#ifndef _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H12#define _LIBCPP___LOCALE_DIR_SUPPORT_NETBSD_H
1113
lib/libcxx/include/__locale_dir/support/no_locale/characters.h-6
...@@ -29,12 +29,6 @@ namespace __locale {...@@ -29,12 +29,6 @@ namespace __locale {
29//29//
30// Character manipulation functions30// Character manipulation functions
31//31//
32#if defined(_LIBCPP_BUILDING_LIBRARY)
33inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t) { return std::islower(__c); }
34
35inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t) { return std::isupper(__c); }
36#endif
37
38inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); }32inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t) { return std::isdigit(__c); }
3933
40inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); }34inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t) { return std::isxdigit(__c); }
lib/libcxx/include/__locale_dir/support/windows.h+2-8
...@@ -29,7 +29,7 @@...@@ -29,7 +29,7 @@
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __locale {30namespace __locale {
3131
32using __lconv_t = std::lconv;32using __lconv_t _LIBCPP_NODEBUG = std::lconv;
3333
34class __lconv_storage {34class __lconv_storage {
35public:35public:
...@@ -197,12 +197,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {...@@ -197,12 +197,6 @@ __strtoull(const char* __nptr, char** __endptr, int __base, __locale_t __loc) {
197//197//
198// Character manipulation functions198// Character manipulation functions
199//199//
200#if defined(_LIBCPP_BUILDING_LIBRARY)
201inline _LIBCPP_HIDE_FROM_ABI int __islower(int __c, __locale_t __loc) { return _islower_l(__c, __loc); }
202
203inline _LIBCPP_HIDE_FROM_ABI int __isupper(int __c, __locale_t __loc) { return _isupper_l(__c, __loc); }
204#endif
205
206inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); }200inline _LIBCPP_HIDE_FROM_ABI int __isdigit(int __c, __locale_t __loc) { return _isdigit_l(__c, __loc); }
207201
208inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); }202inline _LIBCPP_HIDE_FROM_ABI int __isxdigit(int __c, __locale_t __loc) { return _isxdigit_l(__c, __loc); }
...@@ -317,7 +311,7 @@ struct __locale_guard {...@@ -317,7 +311,7 @@ struct __locale_guard {
317 if (std::strcmp(__l.__get_locale(), __lc) != 0) {311 if (std::strcmp(__l.__get_locale(), __lc) != 0) {
318 __locale_all = _strdup(__lc);312 __locale_all = _strdup(__lc);
319 if (__locale_all == nullptr)313 if (__locale_all == nullptr)
320 __throw_bad_alloc();314 std::__throw_bad_alloc();
321 __locale::__setlocale(LC_ALL, __l.__get_locale());315 __locale::__setlocale(LC_ALL, __l.__get_locale());
322 }316 }
323 }317 }
lib/libcxx/include/__locale_dir/time.h created+766
...@@ -0,0 +1,766 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_TIME_H
10#define _LIBCPP___LOCALE_DIR_TIME_H
11
12#include <__algorithm/copy.h>
13#include <__config>
14#include <__locale_dir/get_c_locale.h>
15#include <__locale_dir/scan_keyword.h>
16#include <ios>
17
18#if _LIBCPP_HAS_LOCALIZATION
19
20# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22# endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26template <class _CharT, class _InputIterator>
27_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(
28 _InputIterator& __b, _InputIterator __e, ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n) {
29 // Precondition: __n >= 1
30 if (__b == __e) {
31 __err |= ios_base::eofbit | ios_base::failbit;
32 return 0;
33 }
34 // get first digit
35 _CharT __c = *__b;
36 if (!__ct.is(ctype_base::digit, __c)) {
37 __err |= ios_base::failbit;
38 return 0;
39 }
40 int __r = __ct.narrow(__c, 0) - '0';
41 for (++__b, (void)--__n; __b != __e && __n > 0; ++__b, (void)--__n) {
42 // get next digit
43 __c = *__b;
44 if (!__ct.is(ctype_base::digit, __c))
45 return __r;
46 __r = __r * 10 + __ct.narrow(__c, 0) - '0';
47 }
48 if (__b == __e)
49 __err |= ios_base::eofbit;
50 return __r;
51}
52
53class _LIBCPP_EXPORTED_FROM_ABI time_base {
54public:
55 enum dateorder { no_order, dmy, mdy, ymd, ydm };
56};
57
58template <class _CharT>
59class __time_get_c_storage {
60protected:
61 typedef basic_string<_CharT> string_type;
62
63 virtual const string_type* __weeks() const;
64 virtual const string_type* __months() const;
65 virtual const string_type* __am_pm() const;
66 virtual const string_type& __c() const;
67 virtual const string_type& __r() const;
68 virtual const string_type& __x() const;
69 virtual const string_type& __X() const;
70
71 _LIBCPP_HIDE_FROM_ABI ~__time_get_c_storage() {}
72};
73
74template <>
75_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__weeks() const;
76template <>
77_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__months() const;
78template <>
79_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__am_pm() const;
80template <>
81_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__c() const;
82template <>
83_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__r() const;
84template <>
85_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const;
86template <>
87_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const;
88
89# if _LIBCPP_HAS_WIDE_CHARACTERS
90template <>
91_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const;
92template <>
93_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__months() const;
94template <>
95_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__am_pm() const;
96template <>
97_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__c() const;
98template <>
99_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__r() const;
100template <>
101_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const;
102template <>
103_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const;
104# endif
105
106template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
107class time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> {
108public:
109 typedef _CharT char_type;
110 typedef _InputIterator iter_type;
111 typedef time_base::dateorder dateorder;
112 typedef basic_string<char_type> string_type;
113
114 _LIBCPP_HIDE_FROM_ABI explicit time_get(size_t __refs = 0) : locale::facet(__refs) {}
115
116 _LIBCPP_HIDE_FROM_ABI dateorder date_order() const { return this->do_date_order(); }
117
118 _LIBCPP_HIDE_FROM_ABI iter_type
119 get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
120 return do_get_time(__b, __e, __iob, __err, __tm);
121 }
122
123 _LIBCPP_HIDE_FROM_ABI iter_type
124 get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
125 return do_get_date(__b, __e, __iob, __err, __tm);
126 }
127
128 _LIBCPP_HIDE_FROM_ABI iter_type
129 get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
130 return do_get_weekday(__b, __e, __iob, __err, __tm);
131 }
132
133 _LIBCPP_HIDE_FROM_ABI iter_type
134 get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
135 return do_get_monthname(__b, __e, __iob, __err, __tm);
136 }
137
138 _LIBCPP_HIDE_FROM_ABI iter_type
139 get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
140 return do_get_year(__b, __e, __iob, __err, __tm);
141 }
142
143 _LIBCPP_HIDE_FROM_ABI iter_type
144 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod = 0)
145 const {
146 return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod);
147 }
148
149 iter_type
150 get(iter_type __b,
151 iter_type __e,
152 ios_base& __iob,
153 ios_base::iostate& __err,
154 tm* __tm,
155 const char_type* __fmtb,
156 const char_type* __fmte) const;
157
158 static locale::id id;
159
160protected:
161 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {}
162
163 virtual dateorder do_date_order() const;
164 virtual iter_type
165 do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
166 virtual iter_type
167 do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
168 virtual iter_type
169 do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
170 virtual iter_type
171 do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
172 virtual iter_type
173 do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
174 virtual iter_type do_get(
175 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod) const;
176
177private:
178 void __get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
179 void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
180
181 void __get_weekdayname(
182 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
183 void __get_monthname(
184 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
185 void __get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
186 void
187 __get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
188 void
189 __get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
190 void
191 __get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
192 void
193 __get_hour(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
194 void
195 __get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
196 void
197 __get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
198 void
199 __get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
200 void
201 __get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
202 void
203 __get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
204 void __get_day_year_num(
205 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
206};
207
208template <class _CharT, class _InputIterator>
209locale::id time_get<_CharT, _InputIterator>::id;
210
211// time_get primitives
212
213template <class _CharT, class _InputIterator>
214void time_get<_CharT, _InputIterator>::__get_weekdayname(
215 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
216 // Note: ignoring case comes from the POSIX strptime spec
217 const string_type* __wk = this->__weeks();
218 ptrdiff_t __i = std::__scan_keyword(__b, __e, __wk, __wk + 14, __ct, __err, false) - __wk;
219 if (__i < 14)
220 __w = __i % 7;
221}
222
223template <class _CharT, class _InputIterator>
224void time_get<_CharT, _InputIterator>::__get_monthname(
225 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
226 // Note: ignoring case comes from the POSIX strptime spec
227 const string_type* __month = this->__months();
228 ptrdiff_t __i = std::__scan_keyword(__b, __e, __month, __month + 24, __ct, __err, false) - __month;
229 if (__i < 24)
230 __m = __i % 12;
231}
232
233template <class _CharT, class _InputIterator>
234void time_get<_CharT, _InputIterator>::__get_day(
235 int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
236 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
237 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
238 __d = __t;
239 else
240 __err |= ios_base::failbit;
241}
242
243template <class _CharT, class _InputIterator>
244void time_get<_CharT, _InputIterator>::__get_month(
245 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
246 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
247 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
248 __m = __t;
249 else
250 __err |= ios_base::failbit;
251}
252
253template <class _CharT, class _InputIterator>
254void time_get<_CharT, _InputIterator>::__get_year(
255 int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
256 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
257 if (!(__err & ios_base::failbit)) {
258 if (__t < 69)
259 __t += 2000;
260 else if (69 <= __t && __t <= 99)
261 __t += 1900;
262 __y = __t - 1900;
263 }
264}
265
266template <class _CharT, class _InputIterator>
267void time_get<_CharT, _InputIterator>::__get_year4(
268 int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
269 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
270 if (!(__err & ios_base::failbit))
271 __y = __t - 1900;
272}
273
274template <class _CharT, class _InputIterator>
275void time_get<_CharT, _InputIterator>::__get_hour(
276 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
277 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
278 if (!(__err & ios_base::failbit) && __t <= 23)
279 __h = __t;
280 else
281 __err |= ios_base::failbit;
282}
283
284template <class _CharT, class _InputIterator>
285void time_get<_CharT, _InputIterator>::__get_12_hour(
286 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
287 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
288 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
289 __h = __t;
290 else
291 __err |= ios_base::failbit;
292}
293
294template <class _CharT, class _InputIterator>
295void time_get<_CharT, _InputIterator>::__get_minute(
296 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
297 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
298 if (!(__err & ios_base::failbit) && __t <= 59)
299 __m = __t;
300 else
301 __err |= ios_base::failbit;
302}
303
304template <class _CharT, class _InputIterator>
305void time_get<_CharT, _InputIterator>::__get_second(
306 int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
307 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
308 if (!(__err & ios_base::failbit) && __t <= 60)
309 __s = __t;
310 else
311 __err |= ios_base::failbit;
312}
313
314template <class _CharT, class _InputIterator>
315void time_get<_CharT, _InputIterator>::__get_weekday(
316 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
317 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1);
318 if (!(__err & ios_base::failbit) && __t <= 6)
319 __w = __t;
320 else
321 __err |= ios_base::failbit;
322}
323
324template <class _CharT, class _InputIterator>
325void time_get<_CharT, _InputIterator>::__get_day_year_num(
326 int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
327 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3);
328 if (!(__err & ios_base::failbit) && __t <= 365)
329 __d = __t;
330 else
331 __err |= ios_base::failbit;
332}
333
334template <class _CharT, class _InputIterator>
335void time_get<_CharT, _InputIterator>::__get_white_space(
336 iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
337 for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
338 ;
339 if (__b == __e)
340 __err |= ios_base::eofbit;
341}
342
343template <class _CharT, class _InputIterator>
344void time_get<_CharT, _InputIterator>::__get_am_pm(
345 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
346 const string_type* __ap = this->__am_pm();
347 if (__ap[0].size() + __ap[1].size() == 0) {
348 __err |= ios_base::failbit;
349 return;
350 }
351 ptrdiff_t __i = std::__scan_keyword(__b, __e, __ap, __ap + 2, __ct, __err, false) - __ap;
352 if (__i == 0 && __h == 12)
353 __h = 0;
354 else if (__i == 1 && __h < 12)
355 __h += 12;
356}
357
358template <class _CharT, class _InputIterator>
359void time_get<_CharT, _InputIterator>::__get_percent(
360 iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
361 if (__b == __e) {
362 __err |= ios_base::eofbit | ios_base::failbit;
363 return;
364 }
365 if (__ct.narrow(*__b, 0) != '%')
366 __err |= ios_base::failbit;
367 else if (++__b == __e)
368 __err |= ios_base::eofbit;
369}
370
371// time_get end primitives
372
373template <class _CharT, class _InputIterator>
374_InputIterator time_get<_CharT, _InputIterator>::get(
375 iter_type __b,
376 iter_type __e,
377 ios_base& __iob,
378 ios_base::iostate& __err,
379 tm* __tm,
380 const char_type* __fmtb,
381 const char_type* __fmte) const {
382 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
383 __err = ios_base::goodbit;
384 while (__fmtb != __fmte && __err == ios_base::goodbit) {
385 if (__b == __e) {
386 __err = ios_base::failbit;
387 break;
388 }
389 if (__ct.narrow(*__fmtb, 0) == '%') {
390 if (++__fmtb == __fmte) {
391 __err = ios_base::failbit;
392 break;
393 }
394 char __cmd = __ct.narrow(*__fmtb, 0);
395 char __opt = '\0';
396 if (__cmd == 'E' || __cmd == '0') {
397 if (++__fmtb == __fmte) {
398 __err = ios_base::failbit;
399 break;
400 }
401 __opt = __cmd;
402 __cmd = __ct.narrow(*__fmtb, 0);
403 }
404 __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt);
405 ++__fmtb;
406 } else if (__ct.is(ctype_base::space, *__fmtb)) {
407 for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb)
408 ;
409 for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
410 ;
411 } else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb)) {
412 ++__b;
413 ++__fmtb;
414 } else
415 __err = ios_base::failbit;
416 }
417 if (__b == __e)
418 __err |= ios_base::eofbit;
419 return __b;
420}
421
422template <class _CharT, class _InputIterator>
423typename time_get<_CharT, _InputIterator>::dateorder time_get<_CharT, _InputIterator>::do_date_order() const {
424 return mdy;
425}
426
427template <class _CharT, class _InputIterator>
428_InputIterator time_get<_CharT, _InputIterator>::do_get_time(
429 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
430 const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
431 return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt) / sizeof(__fmt[0]));
432}
433
434template <class _CharT, class _InputIterator>
435_InputIterator time_get<_CharT, _InputIterator>::do_get_date(
436 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
437 const string_type& __fmt = this->__x();
438 return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size());
439}
440
441template <class _CharT, class _InputIterator>
442_InputIterator time_get<_CharT, _InputIterator>::do_get_weekday(
443 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
444 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
445 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
446 return __b;
447}
448
449template <class _CharT, class _InputIterator>
450_InputIterator time_get<_CharT, _InputIterator>::do_get_monthname(
451 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
452 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
453 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
454 return __b;
455}
456
457template <class _CharT, class _InputIterator>
458_InputIterator time_get<_CharT, _InputIterator>::do_get_year(
459 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
460 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
461 __get_year(__tm->tm_year, __b, __e, __err, __ct);
462 return __b;
463}
464
465template <class _CharT, class _InputIterator>
466_InputIterator time_get<_CharT, _InputIterator>::do_get(
467 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char) const {
468 __err = ios_base::goodbit;
469 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
470 switch (__fmt) {
471 case 'a':
472 case 'A':
473 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
474 break;
475 case 'b':
476 case 'B':
477 case 'h':
478 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
479 break;
480 case 'c': {
481 const string_type& __fm = this->__c();
482 __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
483 } break;
484 case 'd':
485 case 'e':
486 __get_day(__tm->tm_mday, __b, __e, __err, __ct);
487 break;
488 case 'D': {
489 const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
490 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
491 } break;
492 case 'F': {
493 const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
494 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
495 } break;
496 case 'H':
497 __get_hour(__tm->tm_hour, __b, __e, __err, __ct);
498 break;
499 case 'I':
500 __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct);
501 break;
502 case 'j':
503 __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct);
504 break;
505 case 'm':
506 __get_month(__tm->tm_mon, __b, __e, __err, __ct);
507 break;
508 case 'M':
509 __get_minute(__tm->tm_min, __b, __e, __err, __ct);
510 break;
511 case 'n':
512 case 't':
513 __get_white_space(__b, __e, __err, __ct);
514 break;
515 case 'p':
516 __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct);
517 break;
518 case 'r': {
519 const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
520 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
521 } break;
522 case 'R': {
523 const char_type __fm[] = {'%', 'H', ':', '%', 'M'};
524 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
525 } break;
526 case 'S':
527 __get_second(__tm->tm_sec, __b, __e, __err, __ct);
528 break;
529 case 'T': {
530 const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
531 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
532 } break;
533 case 'w':
534 __get_weekday(__tm->tm_wday, __b, __e, __err, __ct);
535 break;
536 case 'x':
537 return do_get_date(__b, __e, __iob, __err, __tm);
538 case 'X': {
539 const string_type& __fm = this->__X();
540 __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
541 } break;
542 case 'y':
543 __get_year(__tm->tm_year, __b, __e, __err, __ct);
544 break;
545 case 'Y':
546 __get_year4(__tm->tm_year, __b, __e, __err, __ct);
547 break;
548 case '%':
549 __get_percent(__b, __e, __err, __ct);
550 break;
551 default:
552 __err |= ios_base::failbit;
553 }
554 return __b;
555}
556
557extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
558# if _LIBCPP_HAS_WIDE_CHARACTERS
559extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
560# endif
561
562class _LIBCPP_EXPORTED_FROM_ABI __time_get {
563protected:
564 __locale::__locale_t __loc_;
565
566 __time_get(const char* __nm);
567 __time_get(const string& __nm);
568 ~__time_get();
569};
570
571template <class _CharT>
572class __time_get_storage : public __time_get {
573protected:
574 typedef basic_string<_CharT> string_type;
575
576 string_type __weeks_[14];
577 string_type __months_[24];
578 string_type __am_pm_[2];
579 string_type __c_;
580 string_type __r_;
581 string_type __x_;
582 string_type __X_;
583
584 explicit __time_get_storage(const char* __nm);
585 explicit __time_get_storage(const string& __nm);
586
587 _LIBCPP_HIDE_FROM_ABI ~__time_get_storage() {}
588
589 time_base::dateorder __do_date_order() const;
590
591private:
592 void init(const ctype<_CharT>&);
593 string_type __analyze(char __fmt, const ctype<_CharT>&);
594};
595
596# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
597 template <> \
598 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
599 template <> \
600 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
601 template <> \
602 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
603 template <> \
604 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
605 template <> \
606 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \
607 char, const ctype<_CharT>&); \
608 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \
609 const; \
610 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
611 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
612 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
613 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \
614 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&);
615
616_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
617# if _LIBCPP_HAS_WIDE_CHARACTERS
618_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
619# endif
620# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
621
622template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
623class time_get_byname : public time_get<_CharT, _InputIterator>, private __time_get_storage<_CharT> {
624public:
625 typedef time_base::dateorder dateorder;
626 typedef _InputIterator iter_type;
627 typedef _CharT char_type;
628 typedef basic_string<char_type> string_type;
629
630 _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const char* __nm, size_t __refs = 0)
631 : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {}
632 _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const string& __nm, size_t __refs = 0)
633 : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {}
634
635protected:
636 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {}
637
638 _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override { return this->__do_date_order(); }
639
640private:
641 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override { return this->__weeks_; }
642 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override { return this->__months_; }
643 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override { return this->__am_pm_; }
644 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override { return this->__c_; }
645 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override { return this->__r_; }
646 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override { return this->__x_; }
647 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override { return this->__X_; }
648};
649
650extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
651# if _LIBCPP_HAS_WIDE_CHARACTERS
652extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
653# endif
654
655class _LIBCPP_EXPORTED_FROM_ABI __time_put {
656 __locale::__locale_t __loc_;
657
658protected:
659 _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
660 __time_put(const char* __nm);
661 __time_put(const string& __nm);
662 ~__time_put();
663 void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const;
664# if _LIBCPP_HAS_WIDE_CHARACTERS
665 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const;
666# endif
667};
668
669template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
670class time_put : public locale::facet, private __time_put {
671public:
672 typedef _CharT char_type;
673 typedef _OutputIterator iter_type;
674
675 _LIBCPP_HIDE_FROM_ABI explicit time_put(size_t __refs = 0) : locale::facet(__refs) {}
676
677 iter_type
678 put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe)
679 const;
680
681 _LIBCPP_HIDE_FROM_ABI iter_type
682 put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, char __fmt, char __mod = 0) const {
683 return do_put(__s, __iob, __fl, __tm, __fmt, __mod);
684 }
685
686 static locale::id id;
687
688protected:
689 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {}
690 virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const;
691
692 _LIBCPP_HIDE_FROM_ABI explicit time_put(const char* __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {}
693 _LIBCPP_HIDE_FROM_ABI explicit time_put(const string& __nm, size_t __refs)
694 : locale::facet(__refs), __time_put(__nm) {}
695};
696
697template <class _CharT, class _OutputIterator>
698locale::id time_put<_CharT, _OutputIterator>::id;
699
700template <class _CharT, class _OutputIterator>
701_OutputIterator time_put<_CharT, _OutputIterator>::put(
702 iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe)
703 const {
704 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
705 for (; __pb != __pe; ++__pb) {
706 if (__ct.narrow(*__pb, 0) == '%') {
707 if (++__pb == __pe) {
708 *__s++ = __pb[-1];
709 break;
710 }
711 char __mod = 0;
712 char __fmt = __ct.narrow(*__pb, 0);
713 if (__fmt == 'E' || __fmt == 'O') {
714 if (++__pb == __pe) {
715 *__s++ = __pb[-2];
716 *__s++ = __pb[-1];
717 break;
718 }
719 __mod = __fmt;
720 __fmt = __ct.narrow(*__pb, 0);
721 }
722 __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod);
723 } else
724 *__s++ = *__pb;
725 }
726 return __s;
727}
728
729template <class _CharT, class _OutputIterator>
730_OutputIterator time_put<_CharT, _OutputIterator>::do_put(
731 iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const {
732 char_type __nar[100];
733 char_type* __nb = __nar;
734 char_type* __ne = __nb + 100;
735 __do_put(__nb, __ne, __tm, __fmt, __mod);
736 return std::copy(__nb, __ne, __s);
737}
738
739extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
740# if _LIBCPP_HAS_WIDE_CHARACTERS
741extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
742# endif
743
744template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
745class time_put_byname : public time_put<_CharT, _OutputIterator> {
746public:
747 _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const char* __nm, size_t __refs = 0)
748 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
749
750 _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const string& __nm, size_t __refs = 0)
751 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
752
753protected:
754 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {}
755};
756
757extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
758# if _LIBCPP_HAS_WIDE_CHARACTERS
759extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
760# endif
761
762_LIBCPP_END_NAMESPACE_STD
763
764#endif // _LIBCPP_HAS_LOCALIZATION
765
766#endif // _LIBCPP___LOCALE_DIR_TIME_H
lib/libcxx/include/__locale_dir/wbuffer_convert.h created+430
...@@ -0,0 +1,430 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H
10#define _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H
11
12#include <__algorithm/reverse.h>
13#include <__config>
14#include <__string/char_traits.h>
15#include <ios>
16#include <streambuf>
17
18#if _LIBCPP_HAS_LOCALIZATION
19
20# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22# endif
23
24# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
25
26_LIBCPP_PUSH_MACROS
27# include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
32class _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> {
33public:
34 // types:
35 typedef _Elem char_type;
36 typedef _Tr traits_type;
37 typedef typename traits_type::int_type int_type;
38 typedef typename traits_type::pos_type pos_type;
39 typedef typename traits_type::off_type off_type;
40 typedef typename _Codecvt::state_type state_type;
41
42private:
43 char* __extbuf_;
44 const char* __extbufnext_;
45 const char* __extbufend_;
46 char __extbuf_min_[8];
47 size_t __ebs_;
48 char_type* __intbuf_;
49 size_t __ibs_;
50 streambuf* __bufptr_;
51 _Codecvt* __cv_;
52 state_type __st_;
53 ios_base::openmode __cm_;
54 bool __owns_eb_;
55 bool __owns_ib_;
56 bool __always_noconv_;
57
58public:
59# ifndef _LIBCPP_CXX03_LANG
60 _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
61 explicit _LIBCPP_HIDE_FROM_ABI
62 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
63# else
64 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
65 wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
66# endif
67
68 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();
69
70 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; }
71 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf(streambuf* __bytebuf) {
72 streambuf* __r = __bufptr_;
73 __bufptr_ = __bytebuf;
74 return __r;
75 }
76
77 wbuffer_convert(const wbuffer_convert&) = delete;
78 wbuffer_convert& operator=(const wbuffer_convert&) = delete;
79
80 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
81
82protected:
83 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type underflow();
84 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type pbackfail(int_type __c = traits_type::eof());
85 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type overflow(int_type __c = traits_type::eof());
86 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
87 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type
88 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out);
89 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type
90 seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out);
91 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int sync();
92
93private:
94 _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool __read_mode();
95 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __write_mode();
96 _LIBCPP_HIDE_FROM_ABI_VIRTUAL wbuffer_convert* __close();
97};
98
99_LIBCPP_SUPPRESS_DEPRECATED_PUSH
100template <class _Codecvt, class _Elem, class _Tr>
101wbuffer_convert<_Codecvt, _Elem, _Tr>::wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
102 : __extbuf_(nullptr),
103 __extbufnext_(nullptr),
104 __extbufend_(nullptr),
105 __ebs_(0),
106 __intbuf_(0),
107 __ibs_(0),
108 __bufptr_(__bytebuf),
109 __cv_(__pcvt),
110 __st_(__state),
111 __cm_(0),
112 __owns_eb_(false),
113 __owns_ib_(false),
114 __always_noconv_(__cv_ ? __cv_->always_noconv() : false) {
115 setbuf(0, 4096);
116}
117
118template <class _Codecvt, class _Elem, class _Tr>
119wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert() {
120 __close();
121 delete __cv_;
122 if (__owns_eb_)
123 delete[] __extbuf_;
124 if (__owns_ib_)
125 delete[] __intbuf_;
126}
127
128template <class _Codecvt, class _Elem, class _Tr>
129typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() {
130 _LIBCPP_SUPPRESS_DEPRECATED_POP
131 if (__cv_ == 0 || __bufptr_ == nullptr)
132 return traits_type::eof();
133 bool __initial = __read_mode();
134 char_type __1buf;
135 if (this->gptr() == 0)
136 this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1);
137 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
138 int_type __c = traits_type::eof();
139 if (this->gptr() == this->egptr()) {
140 std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
141 if (__always_noconv_) {
142 streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
143 __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb);
144 if (__nmemb != 0) {
145 this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb);
146 __c = *this->gptr();
147 }
148 } else {
149 if (__extbufend_ != __extbufnext_) {
150 _LIBCPP_ASSERT_NON_NULL(__extbufnext_ != nullptr, "underflow moving from nullptr");
151 _LIBCPP_ASSERT_NON_NULL(__extbuf_ != nullptr, "underflow moving into nullptr");
152 std::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
153 }
154 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
155 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
156 streamsize __nmemb = std::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
157 static_cast<streamsize>(__extbufend_ - __extbufnext_));
158 codecvt_base::result __r;
159 // FIXME: Do we ever need to restore the state here?
160 // state_type __svs = __st_;
161 streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
162 if (__nr != 0) {
163 __extbufend_ = __extbufnext_ + __nr;
164 char_type* __inext;
165 __r = __cv_->in(
166 __st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, this->egptr(), __inext);
167 if (__r == codecvt_base::noconv) {
168 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)const_cast<char*>(__extbufend_));
169 __c = *this->gptr();
170 } else if (__inext != this->eback() + __unget_sz) {
171 this->setg(this->eback(), this->eback() + __unget_sz, __inext);
172 __c = *this->gptr();
173 }
174 }
175 }
176 } else
177 __c = *this->gptr();
178 if (this->eback() == std::addressof(__1buf))
179 this->setg(0, 0, 0);
180 return __c;
181}
182
183_LIBCPP_SUPPRESS_DEPRECATED_PUSH
184template <class _Codecvt, class _Elem, class _Tr>
185typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
186wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) {
187 _LIBCPP_SUPPRESS_DEPRECATED_POP
188 if (__cv_ != 0 && __bufptr_ && this->eback() < this->gptr()) {
189 if (traits_type::eq_int_type(__c, traits_type::eof())) {
190 this->gbump(-1);
191 return traits_type::not_eof(__c);
192 }
193 if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) {
194 this->gbump(-1);
195 *this->gptr() = traits_type::to_char_type(__c);
196 return __c;
197 }
198 }
199 return traits_type::eof();
200}
201
202_LIBCPP_SUPPRESS_DEPRECATED_PUSH
203template <class _Codecvt, class _Elem, class _Tr>
204typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) {
205 _LIBCPP_SUPPRESS_DEPRECATED_POP
206 if (__cv_ == 0 || !__bufptr_)
207 return traits_type::eof();
208 __write_mode();
209 char_type __1buf;
210 char_type* __pb_save = this->pbase();
211 char_type* __epb_save = this->epptr();
212 if (!traits_type::eq_int_type(__c, traits_type::eof())) {
213 if (this->pptr() == 0)
214 this->setp(std::addressof(__1buf), std::addressof(__1buf) + 1);
215 *this->pptr() = traits_type::to_char_type(__c);
216 this->pbump(1);
217 }
218 if (this->pptr() != this->pbase()) {
219 if (__always_noconv_) {
220 streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase());
221 if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
222 return traits_type::eof();
223 } else {
224 char* __extbe = __extbuf_;
225 codecvt_base::result __r;
226 do {
227 const char_type* __e;
228 __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe);
229 if (__e == this->pbase())
230 return traits_type::eof();
231 if (__r == codecvt_base::noconv) {
232 streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
233 if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
234 return traits_type::eof();
235 } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) {
236 streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_);
237 if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
238 return traits_type::eof();
239 if (__r == codecvt_base::partial) {
240 this->setp(const_cast<char_type*>(__e), this->pptr());
241 this->__pbump(this->epptr() - this->pbase());
242 }
243 } else
244 return traits_type::eof();
245 } while (__r == codecvt_base::partial);
246 }
247 this->setp(__pb_save, __epb_save);
248 }
249 return traits_type::not_eof(__c);
250}
251
252_LIBCPP_SUPPRESS_DEPRECATED_PUSH
253template <class _Codecvt, class _Elem, class _Tr>
254basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) {
255 _LIBCPP_SUPPRESS_DEPRECATED_POP
256 this->setg(0, 0, 0);
257 this->setp(0, 0);
258 if (__owns_eb_)
259 delete[] __extbuf_;
260 if (__owns_ib_)
261 delete[] __intbuf_;
262 __ebs_ = __n;
263 if (__ebs_ > sizeof(__extbuf_min_)) {
264 if (__always_noconv_ && __s) {
265 __extbuf_ = (char*)__s;
266 __owns_eb_ = false;
267 } else {
268 __extbuf_ = new char[__ebs_];
269 __owns_eb_ = true;
270 }
271 } else {
272 __extbuf_ = __extbuf_min_;
273 __ebs_ = sizeof(__extbuf_min_);
274 __owns_eb_ = false;
275 }
276 if (!__always_noconv_) {
277 __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
278 if (__s && __ibs_ >= sizeof(__extbuf_min_)) {
279 __intbuf_ = __s;
280 __owns_ib_ = false;
281 } else {
282 __intbuf_ = new char_type[__ibs_];
283 __owns_ib_ = true;
284 }
285 } else {
286 __ibs_ = 0;
287 __intbuf_ = 0;
288 __owns_ib_ = false;
289 }
290 return this;
291}
292
293_LIBCPP_SUPPRESS_DEPRECATED_PUSH
294template <class _Codecvt, class _Elem, class _Tr>
295typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
296wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __om) {
297 int __width = __cv_->encoding();
298 if (__cv_ == 0 || !__bufptr_ || (__width <= 0 && __off != 0) || sync())
299 return pos_type(off_type(-1));
300 // __width > 0 || __off == 0, now check __way
301 if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end)
302 return pos_type(off_type(-1));
303 pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
304 __r.state(__st_);
305 return __r;
306}
307
308template <class _Codecvt, class _Elem, class _Tr>
309typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
310wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch) {
311 if (__cv_ == 0 || !__bufptr_ || sync())
312 return pos_type(off_type(-1));
313 if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1)))
314 return pos_type(off_type(-1));
315 return __sp;
316}
317
318template <class _Codecvt, class _Elem, class _Tr>
319int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() {
320 _LIBCPP_SUPPRESS_DEPRECATED_POP
321 if (__cv_ == 0 || !__bufptr_)
322 return 0;
323 if (__cm_ & ios_base::out) {
324 if (this->pptr() != this->pbase())
325 if (overflow() == traits_type::eof())
326 return -1;
327 codecvt_base::result __r;
328 do {
329 char* __extbe;
330 __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
331 streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_);
332 if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
333 return -1;
334 } while (__r == codecvt_base::partial);
335 if (__r == codecvt_base::error)
336 return -1;
337 if (__bufptr_->pubsync())
338 return -1;
339 } else if (__cm_ & ios_base::in) {
340 off_type __c;
341 if (__always_noconv_)
342 __c = this->egptr() - this->gptr();
343 else {
344 int __width = __cv_->encoding();
345 __c = __extbufend_ - __extbufnext_;
346 if (__width > 0)
347 __c += __width * (this->egptr() - this->gptr());
348 else {
349 if (this->gptr() != this->egptr()) {
350 std::reverse(this->gptr(), this->egptr());
351 codecvt_base::result __r;
352 const char_type* __e = this->gptr();
353 char* __extbe;
354 do {
355 __r = __cv_->out(__st_, __e, this->egptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe);
356 switch (__r) {
357 case codecvt_base::noconv:
358 __c += this->egptr() - this->gptr();
359 break;
360 case codecvt_base::ok:
361 case codecvt_base::partial:
362 __c += __extbe - __extbuf_;
363 break;
364 default:
365 return -1;
366 }
367 } while (__r == codecvt_base::partial);
368 }
369 }
370 }
371 if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1)))
372 return -1;
373 this->setg(0, 0, 0);
374 __cm_ = 0;
375 }
376 return 0;
377}
378
379_LIBCPP_SUPPRESS_DEPRECATED_PUSH
380template <class _Codecvt, class _Elem, class _Tr>
381bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() {
382 if (!(__cm_ & ios_base::in)) {
383 this->setp(0, 0);
384 if (__always_noconv_)
385 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_);
386 else
387 this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
388 __cm_ = ios_base::in;
389 return true;
390 }
391 return false;
392}
393
394template <class _Codecvt, class _Elem, class _Tr>
395void wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode() {
396 if (!(__cm_ & ios_base::out)) {
397 this->setg(0, 0, 0);
398 if (__ebs_ > sizeof(__extbuf_min_)) {
399 if (__always_noconv_)
400 this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__ebs_ - 1));
401 else
402 this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
403 } else
404 this->setp(0, 0);
405 __cm_ = ios_base::out;
406 }
407}
408
409template <class _Codecvt, class _Elem, class _Tr>
410wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() {
411 wbuffer_convert* __rt = nullptr;
412 if (__cv_ != nullptr && __bufptr_ != nullptr) {
413 __rt = this;
414 if ((__cm_ & ios_base::out) && sync())
415 __rt = nullptr;
416 }
417 return __rt;
418}
419
420_LIBCPP_SUPPRESS_DEPRECATED_POP
421
422_LIBCPP_END_NAMESPACE_STD
423
424_LIBCPP_POP_MACROS
425
426# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
427
428#endif // _LIBCPP_HAS_LOCALIZATION
429
430#endif // _LIBCPP___LOCALE_DIR_WBUFFER_CONVERT_H
lib/libcxx/include/__locale_dir/wstring_convert.h created+254
...@@ -0,0 +1,254 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H
10#define _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H
11
12#include <__config>
13#include <__locale>
14#include <__memory/allocator.h>
15#include <string>
16
17#if _LIBCPP_HAS_LOCALIZATION
18
19# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21# endif
22
23# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
24
25_LIBCPP_PUSH_MACROS
26# include <__undef_macros>
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30template <class _Codecvt,
31 class _Elem = wchar_t,
32 class _WideAlloc = allocator<_Elem>,
33 class _ByteAlloc = allocator<char> >
34class _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert {
35public:
36 typedef basic_string<char, char_traits<char>, _ByteAlloc> byte_string;
37 typedef basic_string<_Elem, char_traits<_Elem>, _WideAlloc> wide_string;
38 typedef typename _Codecvt::state_type state_type;
39 typedef typename wide_string::traits_type::int_type int_type;
40
41private:
42 byte_string __byte_err_string_;
43 wide_string __wide_err_string_;
44 _Codecvt* __cvtptr_;
45 state_type __cvtstate_;
46 size_t __cvtcount_;
47
48public:
49# ifndef _LIBCPP_CXX03_LANG
50 _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
51 _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt);
52# else
53 _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
54# endif
55
56 _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state);
57 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
58 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string());
59# ifndef _LIBCPP_CXX03_LANG
60 _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc);
61# endif
62 _LIBCPP_HIDE_FROM_ABI ~wstring_convert();
63
64 wstring_convert(const wstring_convert& __wc) = delete;
65 wstring_convert& operator=(const wstring_convert& __wc) = delete;
66
67 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
68 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
69 return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
70 }
71 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) {
72 return from_bytes(__str.data(), __str.data() + __str.size());
73 }
74 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last);
75
76 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) {
77 return to_bytes(std::addressof(__wchar), std::addressof(__wchar) + 1);
78 }
79 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) {
80 return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));
81 }
82 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) {
83 return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());
84 }
85 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last);
86
87 _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; }
88 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; }
89};
90
91_LIBCPP_SUPPRESS_DEPRECATED_PUSH
92template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
93inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt)
94 : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) {}
95_LIBCPP_SUPPRESS_DEPRECATED_POP
96
97template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
98inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt, state_type __state)
99 : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) {}
100
101template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
102wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(
103 const byte_string& __byte_err, const wide_string& __wide_err)
104 : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) {
105 __cvtptr_ = new _Codecvt;
106}
107
108# ifndef _LIBCPP_CXX03_LANG
109
110template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
111inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc)
112 : __byte_err_string_(std::move(__wc.__byte_err_string_)),
113 __wide_err_string_(std::move(__wc.__wide_err_string_)),
114 __cvtptr_(__wc.__cvtptr_),
115 __cvtstate_(__wc.__cvtstate_),
116 __cvtcount_(__wc.__cvtcount_) {
117 __wc.__cvtptr_ = nullptr;
118}
119
120# endif // _LIBCPP_CXX03_LANG
121
122_LIBCPP_SUPPRESS_DEPRECATED_PUSH
123template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
124wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::~wstring_convert() {
125 delete __cvtptr_;
126}
127
128template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
129typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wide_string
130wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char* __frm, const char* __frm_end) {
131 _LIBCPP_SUPPRESS_DEPRECATED_POP
132 __cvtcount_ = 0;
133 if (__cvtptr_ != nullptr) {
134 wide_string __ws(2 * (__frm_end - __frm), _Elem());
135 if (__frm != __frm_end)
136 __ws.resize(__ws.capacity());
137 codecvt_base::result __r = codecvt_base::ok;
138 state_type __st = __cvtstate_;
139 if (__frm != __frm_end) {
140 _Elem* __to = std::addressof(__ws[0]);
141 _Elem* __to_end = __to + __ws.size();
142 const char* __frm_nxt;
143 do {
144 _Elem* __to_nxt;
145 __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
146 __cvtcount_ += __frm_nxt - __frm;
147 if (__frm_nxt == __frm) {
148 __r = codecvt_base::error;
149 } else if (__r == codecvt_base::noconv) {
150 __ws.resize(__to - std::addressof(__ws[0]));
151 // This only gets executed if _Elem is char
152 __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end);
153 __frm = __frm_nxt;
154 __r = codecvt_base::ok;
155 } else if (__r == codecvt_base::ok) {
156 __ws.resize(__to_nxt - std::addressof(__ws[0]));
157 __frm = __frm_nxt;
158 } else if (__r == codecvt_base::partial) {
159 ptrdiff_t __s = __to_nxt - std::addressof(__ws[0]);
160 __ws.resize(2 * __s);
161 __to = std::addressof(__ws[0]) + __s;
162 __to_end = std::addressof(__ws[0]) + __ws.size();
163 __frm = __frm_nxt;
164 }
165 } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
166 }
167 if (__r == codecvt_base::ok)
168 return __ws;
169 }
170
171 if (__wide_err_string_.empty())
172 std::__throw_range_error("wstring_convert: from_bytes error");
173
174 return __wide_err_string_;
175}
176
177template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
178typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string
179wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) {
180 __cvtcount_ = 0;
181 if (__cvtptr_ != nullptr) {
182 byte_string __bs(2 * (__frm_end - __frm), char());
183 if (__frm != __frm_end)
184 __bs.resize(__bs.capacity());
185 codecvt_base::result __r = codecvt_base::ok;
186 state_type __st = __cvtstate_;
187 if (__frm != __frm_end) {
188 char* __to = std::addressof(__bs[0]);
189 char* __to_end = __to + __bs.size();
190 const _Elem* __frm_nxt;
191 do {
192 char* __to_nxt;
193 __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
194 __cvtcount_ += __frm_nxt - __frm;
195 if (__frm_nxt == __frm) {
196 __r = codecvt_base::error;
197 } else if (__r == codecvt_base::noconv) {
198 __bs.resize(__to - std::addressof(__bs[0]));
199 // This only gets executed if _Elem is char
200 __bs.append((const char*)__frm, (const char*)__frm_end);
201 __frm = __frm_nxt;
202 __r = codecvt_base::ok;
203 } else if (__r == codecvt_base::ok) {
204 __bs.resize(__to_nxt - std::addressof(__bs[0]));
205 __frm = __frm_nxt;
206 } else if (__r == codecvt_base::partial) {
207 ptrdiff_t __s = __to_nxt - std::addressof(__bs[0]);
208 __bs.resize(2 * __s);
209 __to = std::addressof(__bs[0]) + __s;
210 __to_end = std::addressof(__bs[0]) + __bs.size();
211 __frm = __frm_nxt;
212 }
213 } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
214 }
215 if (__r == codecvt_base::ok) {
216 size_t __s = __bs.size();
217 __bs.resize(__bs.capacity());
218 char* __to = std::addressof(__bs[0]) + __s;
219 char* __to_end = __to + __bs.size();
220 do {
221 char* __to_nxt;
222 __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
223 if (__r == codecvt_base::noconv) {
224 __bs.resize(__to - std::addressof(__bs[0]));
225 __r = codecvt_base::ok;
226 } else if (__r == codecvt_base::ok) {
227 __bs.resize(__to_nxt - std::addressof(__bs[0]));
228 } else if (__r == codecvt_base::partial) {
229 ptrdiff_t __sp = __to_nxt - std::addressof(__bs[0]);
230 __bs.resize(2 * __sp);
231 __to = std::addressof(__bs[0]) + __sp;
232 __to_end = std::addressof(__bs[0]) + __bs.size();
233 }
234 } while (__r == codecvt_base::partial);
235 if (__r == codecvt_base::ok)
236 return __bs;
237 }
238 }
239
240 if (__byte_err_string_.empty())
241 std::__throw_range_error("wstring_convert: to_bytes error");
242
243 return __byte_err_string_;
244}
245
246_LIBCPP_END_NAMESPACE_STD
247
248_LIBCPP_POP_MACROS
249
250# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
251
252#endif // _LIBCPP_HAS_LOCALIZATION
253
254#endif // _LIBCPP___LOCALE_DIR_WSTRING_CONVERT_H
lib/libcxx/include/__log_hardening_failure created+42
...@@ -0,0 +1,42 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___LOG_HARDENING_FAILURE
11#define _LIBCPP___LOG_HARDENING_FAILURE
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19// Hardening logging is not available in the C++03 mode; moreover, it is currently only available in the experimental
20// library.
21#if _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC && !defined(_LIBCPP_CXX03_LANG)
22
23_LIBCPP_BEGIN_NAMESPACE_STD
24
25// This function should never be called directly from the code -- it should only be called through the
26// `_LIBCPP_LOG_HARDENING_FAILURE` macro.
27[[__gnu__::__cold__]] _LIBCPP_EXPORTED_FROM_ABI void __log_hardening_failure(const char* __message) noexcept;
28
29// _LIBCPP_LOG_HARDENING_FAILURE(message)
30//
31// This macro is used to log an error without terminating the program (as is the case for hardening failures if the
32// `observe` assertion semantic is used).
33
34# if !defined(_LIBCPP_LOG_HARDENING_FAILURE)
35# define _LIBCPP_LOG_HARDENING_FAILURE(__message) ::std::__log_hardening_failure(__message)
36# endif // !defined(_LIBCPP_LOG_HARDENING_FAILURE)
37
38_LIBCPP_END_NAMESPACE_STD
39
40#endif // _LIBCPP_HAS_EXPERIMENTAL_HARDENING_OBSERVE_SEMANTIC && !defined(_LIBCPP_CXX03_LANG)
41
42#endif // _LIBCPP___LOG_HARDENING_FAILURE
lib/libcxx/include/__math/abs.h+24
...@@ -39,6 +39,30 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>...@@ -39,6 +39,30 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
39 return __builtin_fabs((double)__x);39 return __builtin_fabs((double)__x);
40}40}
4141
42// abs
43
44[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline float abs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }
45[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline double abs(double __x) _NOEXCEPT { return __builtin_fabs(__x); }
46
47[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long double abs(long double __x) _NOEXCEPT {
48 return __builtin_fabsl(__x);
49}
50
51template <class = int>
52[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline int abs(int __x) _NOEXCEPT {
53 return __builtin_abs(__x);
54}
55
56template <class = int>
57[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long abs(long __x) _NOEXCEPT {
58 return __builtin_labs(__x);
59}
60
61template <class = int>
62[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long long abs(long long __x) _NOEXCEPT {
63 return __builtin_llabs(__x);
64}
65
42} // namespace __math66} // namespace __math
4367
44_LIBCPP_END_NAMESPACE_STD68_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__math/copysign.h+1-1
...@@ -33,7 +33,7 @@ namespace __math {...@@ -33,7 +33,7 @@ namespace __math {
33}33}
3434
35template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>35template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
36[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT {36[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> copysign(_A1 __x, _A2 __y) _NOEXCEPT {
37 return ::__builtin_copysign(__x, __y);37 return ::__builtin_copysign(__x, __y);
38}38}
3939
lib/libcxx/include/__math/exponential_functions.h+2-2
...@@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _...@@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _
158}158}
159159
160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
161inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type pow(_A1 __x, _A2 __y) _NOEXCEPT {161inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> pow(_A1 __x, _A2 __y) _NOEXCEPT {
162 using __result_type = typename __promote<_A1, _A2>::type;162 using __result_type = __promote_t<_A1, _A2>;
163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
164 return __math::pow((__result_type)__x, (__result_type)__y);164 return __math::pow((__result_type)__x, (__result_type)__y);
165}165}
lib/libcxx/include/__math/fdim.h+2-2
...@@ -35,8 +35,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y)...@@ -35,8 +35,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y)
35}35}
3636
37template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>37template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
38inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fdim(_A1 __x, _A2 __y) _NOEXCEPT {38inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fdim(_A1 __x, _A2 __y) _NOEXCEPT {
39 using __result_type = typename __promote<_A1, _A2>::type;39 using __result_type = __promote_t<_A1, _A2>;
40 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");40 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
41 return __math::fdim((__result_type)__x, (__result_type)__y);41 return __math::fdim((__result_type)__x, (__result_type)__y);
42}42}
lib/libcxx/include/__math/fma.h+2-2
...@@ -40,8 +40,8 @@ template <class _A1,...@@ -40,8 +40,8 @@ template <class _A1,
40 class _A2,40 class _A2,
41 class _A3,41 class _A3,
42 __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0>42 __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0>
43inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {43inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
44 using __result_type = typename __promote<_A1, _A2, _A3>::type;44 using __result_type = __promote_t<_A1, _A2, _A3>;
45 static_assert(45 static_assert(
46 !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value),46 !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value),
47 "");47 "");
lib/libcxx/include/__math/hypot.h+4-4
...@@ -43,8 +43,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y)...@@ -43,8 +43,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y)
43}43}
4444
45template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>45template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
46inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _A2 __y) _NOEXCEPT {46inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> hypot(_A1 __x, _A2 __y) _NOEXCEPT {
47 using __result_type = typename __promote<_A1, _A2>::type;47 using __result_type = __promote_t<_A1, _A2>;
48 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");48 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
49 return __math::hypot((__result_type)__x, (__result_type)__y);49 return __math::hypot((__result_type)__x, (__result_type)__y);
50}50}
...@@ -91,8 +91,8 @@ template <class _A1,...@@ -91,8 +91,8 @@ template <class _A1,
91 class _A2,91 class _A2,
92 class _A3,92 class _A3,
93 std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 >93 std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 >
94_LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {94_LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2, _A3> hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
95 using __result_type = typename __promote<_A1, _A2, _A3>::type;95 using __result_type = __promote_t<_A1, _A2, _A3>;
96 static_assert(!(96 static_assert(!(
97 std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>));97 std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>));
98 return __math::__hypot(98 return __math::__hypot(
lib/libcxx/include/__math/inverse_trigonometric_functions.h+2-2
...@@ -86,8 +86,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x)...@@ -86,8 +86,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x)
86}86}
8787
88template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>88template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
89inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type atan2(_A1 __y, _A2 __x) _NOEXCEPT {89inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> atan2(_A1 __y, _A2 __x) _NOEXCEPT {
90 using __result_type = typename __promote<_A1, _A2>::type;90 using __result_type = __promote_t<_A1, _A2>;
91 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");91 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
92 return __math::atan2((__result_type)__y, (__result_type)__x);92 return __math::atan2((__result_type)__y, (__result_type)__x);
93}93}
lib/libcxx/include/__math/min_max.h+4-4
...@@ -39,8 +39,8 @@ template <class = int>...@@ -39,8 +39,8 @@ template <class = int>
39}39}
4040
41template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>41template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT {42[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmax(_A1 __x, _A2 __y) _NOEXCEPT {
43 using __result_type = typename __promote<_A1, _A2>::type;43 using __result_type = __promote_t<_A1, _A2>;
44 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");44 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
45 return __math::fmax((__result_type)__x, (__result_type)__y);45 return __math::fmax((__result_type)__x, (__result_type)__y);
46}46}
...@@ -61,8 +61,8 @@ template <class = int>...@@ -61,8 +61,8 @@ template <class = int>
61}61}
6262
63template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>63template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
64[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT {64[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmin(_A1 __x, _A2 __y) _NOEXCEPT {
65 using __result_type = typename __promote<_A1, _A2>::type;65 using __result_type = __promote_t<_A1, _A2>;
66 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");66 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
67 return __math::fmin((__result_type)__x, (__result_type)__y);67 return __math::fmin((__result_type)__x, (__result_type)__y);
68}68}
lib/libcxx/include/__math/modulo.h+2-2
...@@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y)...@@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y)
37}37}
3838
39template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>39template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
40inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmod(_A1 __x, _A2 __y) _NOEXCEPT {40inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> fmod(_A1 __x, _A2 __y) _NOEXCEPT {
41 using __result_type = typename __promote<_A1, _A2>::type;41 using __result_type = __promote_t<_A1, _A2>;
42 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");42 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
43 return __math::fmod((__result_type)__x, (__result_type)__y);43 return __math::fmod((__result_type)__x, (__result_type)__y);
44}44}
lib/libcxx/include/__math/remainder.h+4-4
...@@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double...@@ -37,8 +37,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double
37}37}
3838
39template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>39template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
40inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT {40inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> remainder(_A1 __x, _A2 __y) _NOEXCEPT {
41 using __result_type = typename __promote<_A1, _A2>::type;41 using __result_type = __promote_t<_A1, _A2>;
42 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");42 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
43 return __math::remainder((__result_type)__x, (__result_type)__y);43 return __math::remainder((__result_type)__x, (__result_type)__y);
44}44}
...@@ -59,8 +59,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y...@@ -59,8 +59,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y
59}59}
6060
61template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>61template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
62inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT {62inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT {
63 using __result_type = typename __promote<_A1, _A2>::type;63 using __result_type = __promote_t<_A1, _A2>;
64 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");64 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
65 return __math::remquo((__result_type)__x, (__result_type)__y, __z);65 return __math::remquo((__result_type)__x, (__result_type)__y, __z);
66}66}
lib/libcxx/include/__math/rounding_functions.h+2-2
...@@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double...@@ -158,8 +158,8 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double
158}158}
159159
160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
161inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type nextafter(_A1 __x, _A2 __y) _NOEXCEPT {161inline _LIBCPP_HIDE_FROM_ABI __promote_t<_A1, _A2> nextafter(_A1 __x, _A2 __y) _NOEXCEPT {
162 using __result_type = typename __promote<_A1, _A2>::type;162 using __result_type = __promote_t<_A1, _A2>;
163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
164 return __math::nextafter((__result_type)__x, (__result_type)__y);164 return __math::nextafter((__result_type)__x, (__result_type)__y);
165}165}
lib/libcxx/include/__math/traits.h+7-13
...@@ -13,7 +13,6 @@...@@ -13,7 +13,6 @@
13#include <__type_traits/enable_if.h>13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_integral.h>15#include <__type_traits/is_integral.h>
16#include <__type_traits/is_signed.h>
17#include <__type_traits/promote.h>16#include <__type_traits/promote.h>
1817
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -51,16 +50,11 @@ template <class = void>...@@ -51,16 +50,11 @@ template <class = void>
51 return __builtin_signbit(__x);50 return __builtin_signbit(__x);
52}51}
5352
54template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>53template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
55[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {54[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
56 return __x < 0;55 return __x < 0;
57}56}
5857
59template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0>
60[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
61 return false;
62}
63
64// isfinite58// isfinite
6559
66template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>60template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
...@@ -151,7 +145,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>...@@ -151,7 +145,7 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
151145
152template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>146template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
153[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {147[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
154 using type = typename __promote<_A1, _A2>::type;148 using type = __promote_t<_A1, _A2>;
155 return __builtin_isgreater((type)__x, (type)__y);149 return __builtin_isgreater((type)__x, (type)__y);
156}150}
157151
...@@ -159,7 +153,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar...@@ -159,7 +153,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
159153
160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>154template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
161[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {155[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
162 using type = typename __promote<_A1, _A2>::type;156 using type = __promote_t<_A1, _A2>;
163 return __builtin_isgreaterequal((type)__x, (type)__y);157 return __builtin_isgreaterequal((type)__x, (type)__y);
164}158}
165159
...@@ -167,7 +161,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar...@@ -167,7 +161,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
167161
168template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>162template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
169[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {163[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
170 using type = typename __promote<_A1, _A2>::type;164 using type = __promote_t<_A1, _A2>;
171 return __builtin_isless((type)__x, (type)__y);165 return __builtin_isless((type)__x, (type)__y);
172}166}
173167
...@@ -175,7 +169,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar...@@ -175,7 +169,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
175169
176template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>170template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
177[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {171[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
178 using type = typename __promote<_A1, _A2>::type;172 using type = __promote_t<_A1, _A2>;
179 return __builtin_islessequal((type)__x, (type)__y);173 return __builtin_islessequal((type)__x, (type)__y);
180}174}
181175
...@@ -183,7 +177,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar...@@ -183,7 +177,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
183177
184template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>178template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
185[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {179[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
186 using type = typename __promote<_A1, _A2>::type;180 using type = __promote_t<_A1, _A2>;
187 return __builtin_islessgreater((type)__x, (type)__y);181 return __builtin_islessgreater((type)__x, (type)__y);
188}182}
189183
...@@ -191,7 +185,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar...@@ -191,7 +185,7 @@ template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_ar
191185
192template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>186template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
193[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {187[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
194 using type = typename __promote<_A1, _A2>::type;188 using type = __promote_t<_A1, _A2>;
195 return __builtin_isunordered((type)__x, (type)__y);189 return __builtin_isunordered((type)__x, (type)__y);
196}190}
197191
lib/libcxx/include/__mbstate_t.h+4-4
...@@ -43,12 +43,12 @@...@@ -43,12 +43,12 @@
43# include <bits/types/mbstate_t.h> // works on most Unixes43# include <bits/types/mbstate_t.h> // works on most Unixes
44#elif __has_include(<sys/_types/_mbstate_t.h>)44#elif __has_include(<sys/_types/_mbstate_t.h>)
45# include <sys/_types/_mbstate_t.h> // works on Darwin45# include <sys/_types/_mbstate_t.h> // works on Darwin
46#elif _LIBCPP_HAS_WIDE_CHARACTERS && __has_include_next(<wchar.h>)46#elif __has_include_next(<wchar.h>)
47# include_next <wchar.h> // fall back to the C standard provider of mbstate_t47# include_next <wchar.h> // use the C standard provider of mbstate_t if present
48#elif __has_include_next(<uchar.h>)48#elif __has_include_next(<uchar.h>)
49# include_next <uchar.h> // <uchar.h> is also required to make mbstate_t visible49# include_next <uchar.h> // Try <uchar.h> in absence of <wchar.h> for mbstate_t
50#else50#else
51# error "We don't know how to get the definition of mbstate_t without <wchar.h> on your platform."51# error "We don't know how to get the definition of mbstate_t on your platform."
52#endif52#endif
5353
54#endif // _LIBCPP___MBSTATE_T_H54#endif // _LIBCPP___MBSTATE_T_H
lib/libcxx/include/__mdspan/aligned_accessor.h created+87
...@@ -0,0 +1,87 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8// Kokkos v. 4.0
9// Copyright (2022) National Technology & Engineering
10// Solutions of Sandia, LLC (NTESS).
11//
12// Under the terms of Contract DE-NA0003525 with NTESS,
13// the U.S. Government retains certain rights in this software.
14//
15//===---------------------------------------------------------------------===//
16
17#ifndef _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H
18#define _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H
19
20#include <__config>
21#include <__cstddef/size_t.h>
22#include <__mdspan/default_accessor.h>
23#include <__memory/assume_aligned.h>
24#include <__type_traits/is_abstract.h>
25#include <__type_traits/is_array.h>
26#include <__type_traits/is_convertible.h>
27#include <__type_traits/remove_const.h>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_PUSH_MACROS
34#include <__undef_macros>
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38#if _LIBCPP_STD_VER >= 26
39
40template <class _ElementType, size_t _ByteAlignment>
41struct aligned_accessor {
42 static_assert(_ByteAlignment != 0 && (_ByteAlignment & (_ByteAlignment - 1)) == 0,
43 "aligned_accessor: byte alignment must be a power of two");
44 static_assert(_ByteAlignment >= alignof(_ElementType), "aligned_accessor: insufficient byte alignment");
45 static_assert(!is_array_v<_ElementType>, "aligned_accessor: template argument may not be an array type");
46 static_assert(!is_abstract_v<_ElementType>, "aligned_accessor: template argument may not be an abstract class");
47
48 using offset_policy = default_accessor<_ElementType>;
49 using element_type = _ElementType;
50 using reference = _ElementType&;
51 using data_handle_type = _ElementType*;
52
53 static constexpr size_t byte_alignment = _ByteAlignment;
54
55 _LIBCPP_HIDE_FROM_ABI constexpr aligned_accessor() noexcept = default;
56
57 template <class _OtherElementType, size_t _OtherByteAlignment>
58 requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]> && _OtherByteAlignment >= byte_alignment)
59 _LIBCPP_HIDE_FROM_ABI constexpr aligned_accessor(aligned_accessor<_OtherElementType, _OtherByteAlignment>) noexcept {}
60
61 template <class _OtherElementType>
62 requires(is_convertible_v<_OtherElementType (*)[], element_type (*)[]>)
63 _LIBCPP_HIDE_FROM_ABI explicit constexpr aligned_accessor(default_accessor<_OtherElementType>) noexcept {}
64
65 template <class _OtherElementType>
66 requires(is_convertible_v<element_type (*)[], _OtherElementType (*)[]>)
67 _LIBCPP_HIDE_FROM_ABI constexpr operator default_accessor<_OtherElementType>() const noexcept {
68 return {};
69 }
70
71 _LIBCPP_HIDE_FROM_ABI constexpr reference access(data_handle_type __p, size_t __i) const noexcept {
72 return std::assume_aligned<byte_alignment>(__p)[__i];
73 }
74
75 _LIBCPP_HIDE_FROM_ABI constexpr typename offset_policy::data_handle_type
76 offset(data_handle_type __p, size_t __i) const noexcept {
77 return std::assume_aligned<byte_alignment>(__p) + __i;
78 }
79};
80
81#endif // _LIBCPP_STD_VER >= 26
82
83_LIBCPP_END_NAMESPACE_STD
84
85_LIBCPP_POP_MACROS
86
87#endif // _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H
lib/libcxx/include/__mdspan/extents.h+5-5
...@@ -21,11 +21,10 @@...@@ -21,11 +21,10 @@
21#include <__config>21#include <__config>
2222
23#include <__concepts/arithmetic.h>23#include <__concepts/arithmetic.h>
24#include <__cstddef/byte.h>
25#include <__type_traits/common_type.h>24#include <__type_traits/common_type.h>
25#include <__type_traits/integer_traits.h>
26#include <__type_traits/is_convertible.h>26#include <__type_traits/is_convertible.h>
27#include <__type_traits/is_nothrow_constructible.h>27#include <__type_traits/is_nothrow_constructible.h>
28#include <__type_traits/is_same.h>
29#include <__type_traits/make_unsigned.h>28#include <__type_traits/make_unsigned.h>
30#include <__utility/integer_sequence.h>29#include <__utility/integer_sequence.h>
31#include <__utility/unreachable.h>30#include <__utility/unreachable.h>
...@@ -283,7 +282,8 @@ public:...@@ -283,7 +282,8 @@ public:
283 using size_type = make_unsigned_t<index_type>;282 using size_type = make_unsigned_t<index_type>;
284 using rank_type = size_t;283 using rank_type = size_t;
285284
286 static_assert(__libcpp_integer<index_type>, "extents::index_type must be a signed or unsigned integer type");285 static_assert(__signed_or_unsigned_integer<index_type>,
286 "extents::index_type must be a signed or unsigned integer type");
287 static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...),287 static_assert(((__mdspan_detail::__is_representable_as<index_type>(_Extents) || (_Extents == dynamic_extent)) && ...),
288 "extents ctor: arguments must be representable as index_type and nonnegative");288 "extents ctor: arguments must be representable as index_type and nonnegative");
289289
...@@ -440,13 +440,13 @@ struct __make_dextents;...@@ -440,13 +440,13 @@ struct __make_dextents;
440440
441template <class _IndexType, size_t _Rank, size_t... _ExtentsPack>441template <class _IndexType, size_t _Rank, size_t... _ExtentsPack>
442struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> {442struct __make_dextents< _IndexType, _Rank, extents<_IndexType, _ExtentsPack...>> {
443 using type =443 using type _LIBCPP_NODEBUG =
444 typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type;444 typename __make_dextents< _IndexType, _Rank - 1, extents<_IndexType, dynamic_extent, _ExtentsPack...>>::type;
445};445};
446446
447template <class _IndexType, size_t... _ExtentsPack>447template <class _IndexType, size_t... _ExtentsPack>
448struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {448struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {
449 using type = extents<_IndexType, _ExtentsPack...>;449 using type _LIBCPP_NODEBUG = extents<_IndexType, _ExtentsPack...>;
450};450};
451451
452} // namespace __mdspan_detail452} // namespace __mdspan_detail
lib/libcxx/include/__mdspan/layout_left.h+2-1
...@@ -21,6 +21,7 @@...@@ -21,6 +21,7 @@
21#include <__config>21#include <__config>
22#include <__fwd/mdspan.h>22#include <__fwd/mdspan.h>
23#include <__mdspan/extents.h>23#include <__mdspan/extents.h>
24#include <__memory/addressof.h>
24#include <__type_traits/common_type.h>25#include <__type_traits/common_type.h>
25#include <__type_traits/is_constructible.h>26#include <__type_traits/is_constructible.h>
26#include <__type_traits/is_convertible.h>27#include <__type_traits/is_convertible.h>
...@@ -58,7 +59,7 @@ private:...@@ -58,7 +59,7 @@ private:
5859
59 index_type __prod = __ext.extent(0);60 index_type __prod = __ext.extent(0);
60 for (rank_type __r = 1; __r < extents_type::rank(); __r++) {61 for (rank_type __r = 1; __r < extents_type::rank(); __r++) {
61 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod);62 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod));
62 if (__overflowed)63 if (__overflowed)
63 return false;64 return false;
64 }65 }
lib/libcxx/include/__mdspan/layout_right.h+2-1
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__cstddef/size_t.h>22#include <__cstddef/size_t.h>
23#include <__fwd/mdspan.h>23#include <__fwd/mdspan.h>
24#include <__mdspan/extents.h>24#include <__mdspan/extents.h>
25#include <__memory/addressof.h>
25#include <__type_traits/common_type.h>26#include <__type_traits/common_type.h>
26#include <__type_traits/is_constructible.h>27#include <__type_traits/is_constructible.h>
27#include <__type_traits/is_convertible.h>28#include <__type_traits/is_convertible.h>
...@@ -58,7 +59,7 @@ private:...@@ -58,7 +59,7 @@ private:
5859
59 index_type __prod = __ext.extent(0);60 index_type __prod = __ext.extent(0);
60 for (rank_type __r = 1; __r < extents_type::rank(); __r++) {61 for (rank_type __r = 1; __r < extents_type::rank(); __r++) {
61 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod);62 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod));
62 if (__overflowed)63 if (__overflowed)
63 return false;64 return false;
64 }65 }
lib/libcxx/include/__mdspan/layout_stride.h+6-4
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__config>22#include <__config>
23#include <__fwd/mdspan.h>23#include <__fwd/mdspan.h>
24#include <__mdspan/extents.h>24#include <__mdspan/extents.h>
25#include <__memory/addressof.h>
25#include <__type_traits/common_type.h>26#include <__type_traits/common_type.h>
26#include <__type_traits/is_constructible.h>27#include <__type_traits/is_constructible.h>
27#include <__type_traits/is_convertible.h>28#include <__type_traits/is_convertible.h>
...@@ -86,7 +87,7 @@ private:...@@ -86,7 +87,7 @@ private:
8687
87 index_type __prod = __ext.extent(0);88 index_type __prod = __ext.extent(0);
88 for (rank_type __r = 1; __r < __rank_; __r++) {89 for (rank_type __r = 1; __r < __rank_; __r++) {
89 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), &__prod);90 bool __overflowed = __builtin_mul_overflow(__prod, __ext.extent(__r), std::addressof(__prod));
90 if (__overflowed)91 if (__overflowed)
91 return false;92 return false;
92 }93 }
...@@ -109,11 +110,12 @@ private:...@@ -109,11 +110,12 @@ private:
109 }110 }
110 if (__ext.extent(__r) == static_cast<index_type>(0))111 if (__ext.extent(__r) == static_cast<index_type>(0))
111 return true;112 return true;
112 index_type __prod = (__ext.extent(__r) - 1);113 index_type __prod = (__ext.extent(__r) - 1);
113 bool __overflowed_mul = __builtin_mul_overflow(__prod, static_cast<index_type>(__strides[__r]), &__prod);114 bool __overflowed_mul =
115 __builtin_mul_overflow(__prod, static_cast<index_type>(__strides[__r]), std::addressof(__prod));
114 if (__overflowed_mul)116 if (__overflowed_mul)
115 return false;117 return false;
116 bool __overflowed_add = __builtin_add_overflow(__size, __prod, &__size);118 bool __overflowed_add = __builtin_add_overflow(__size, __prod, std::addressof(__size));
117 if (__overflowed_add)119 if (__overflowed_add)
118 return false;120 return false;
119 }121 }
lib/libcxx/include/__mdspan/mdspan.h+7-5
...@@ -20,8 +20,10 @@...@@ -20,8 +20,10 @@
20#include <__assert>20#include <__assert>
21#include <__config>21#include <__config>
22#include <__fwd/mdspan.h>22#include <__fwd/mdspan.h>
23#include <__mdspan/aligned_accessor.h>
23#include <__mdspan/default_accessor.h>24#include <__mdspan/default_accessor.h>
24#include <__mdspan/extents.h>25#include <__mdspan/extents.h>
26#include <__memory/addressof.h>
25#include <__type_traits/extent.h>27#include <__type_traits/extent.h>
26#include <__type_traits/is_abstract.h>28#include <__type_traits/is_abstract.h>
27#include <__type_traits/is_array.h>29#include <__type_traits/is_array.h>
...@@ -215,7 +217,7 @@ public:...@@ -215,7 +217,7 @@ public:
215 _LIBCPP_ASSERT_UNCATEGORIZED(217 _LIBCPP_ASSERT_UNCATEGORIZED(
216 false == ([&]<size_t... _Idxs>(index_sequence<_Idxs...>) {218 false == ([&]<size_t... _Idxs>(index_sequence<_Idxs...>) {
217 size_type __prod = 1;219 size_type __prod = 1;
218 return (__builtin_mul_overflow(__prod, extent(_Idxs), &__prod) || ... || false);220 return (__builtin_mul_overflow(__prod, extent(_Idxs), std::addressof(__prod)) || ... || false);
219 }(make_index_sequence<rank()>())),221 }(make_index_sequence<rank()>())),
220 "mdspan: size() is not representable as size_type");222 "mdspan: size() is not representable as size_type");
221 return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) {223 return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) {
...@@ -266,13 +268,13 @@ private:...@@ -266,13 +268,13 @@ private:
266# if _LIBCPP_STD_VER >= 26268# if _LIBCPP_STD_VER >= 26
267template <class _ElementType, class... _OtherIndexTypes>269template <class _ElementType, class... _OtherIndexTypes>
268 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))270 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
269explicit mdspan(_ElementType*,271explicit mdspan(_ElementType*, _OtherIndexTypes...)
270 _OtherIndexTypes...) -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>;272 -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>;
271# else273# else
272template <class _ElementType, class... _OtherIndexTypes>274template <class _ElementType, class... _OtherIndexTypes>
273 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))275 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
274explicit mdspan(_ElementType*,276explicit mdspan(_ElementType*, _OtherIndexTypes...)
275 _OtherIndexTypes...) -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>;277 -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>;
276# endif278# endif
277279
278template <class _Pointer>280template <class _Pointer>
lib/libcxx/include/__memory/addressof.h+2-2
...@@ -23,7 +23,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a...@@ -23,7 +23,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a
23 return __builtin_addressof(__x);23 return __builtin_addressof(__x);
24}24}
2525
26#if _LIBCPP_HAS_OBJC_ARC26#if __has_feature(objc_arc)
27// Objective-C++ Automatic Reference Counting uses qualified pointers27// Objective-C++ Automatic Reference Counting uses qualified pointers
28// that require special addressof() signatures.28// that require special addressof() signatures.
29template <class _Tp>29template <class _Tp>
...@@ -31,7 +31,7 @@ inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEP...@@ -31,7 +31,7 @@ inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEP
31 return &__x;31 return &__x;
32}32}
3333
34# if _LIBCPP_HAS_OBJC_ARC_WEAK34# if __has_feature(objc_arc_weak)
35template <class _Tp>35template <class _Tp>
36inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {36inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT {
37 return &__x;37 return &__x;
lib/libcxx/include/__memory/allocation_guard.h+11-9
...@@ -49,24 +49,26 @@ struct __allocation_guard {...@@ -49,24 +49,26 @@ struct __allocation_guard {
49 using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;49 using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;
5050
51 template <class _AllocT> // we perform the allocator conversion inside the constructor51 template <class _AllocT> // we perform the allocator conversion inside the constructor
52 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)52 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
53 : __alloc_(std::move(__alloc)),53 : __alloc_(std::move(__alloc)),
54 __n_(__n),54 __n_(__n),
55 __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important55 __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
56 {}56 {}
5757
58 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }58 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
5959
60 _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;60 __allocation_guard(const __allocation_guard&) = delete;
61 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT61 __allocation_guard& operator=(const __allocation_guard& __other) = delete;
62
63 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
62 : __alloc_(std::move(__other.__alloc_)),64 : __alloc_(std::move(__other.__alloc_)),
63 __n_(__other.__n_),65 __n_(__other.__n_),
64 __ptr_(__other.__ptr_) {66 __ptr_(__other.__ptr_) {
65 __other.__ptr_ = nullptr;67 __other.__ptr_ = nullptr;
66 }68 }
6769
68 _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete;70 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
69 _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT {71 operator=(__allocation_guard&& __other) _NOEXCEPT {
70 if (std::addressof(__other) != this) {72 if (std::addressof(__other) != this) {
71 __destroy();73 __destroy();
7274
...@@ -79,17 +81,17 @@ struct __allocation_guard {...@@ -79,17 +81,17 @@ struct __allocation_guard {
79 return *this;81 return *this;
80 }82 }
8183
82 _LIBCPP_HIDE_FROM_ABI _Pointer84 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer
83 __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++85 __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
84 _Pointer __tmp = __ptr_;86 _Pointer __tmp = __ptr_;
85 __ptr_ = nullptr;87 __ptr_ = nullptr;
86 return __tmp;88 return __tmp;
87 }89 }
8890
89 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }91 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
9092
91private:93private:
92 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {94 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
93 if (__ptr_ != nullptr) {95 if (__ptr_ != nullptr) {
94 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);96 allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
95 }97 }
lib/libcxx/include/__memory/allocator.h+3-3
...@@ -38,7 +38,7 @@ class allocator;...@@ -38,7 +38,7 @@ class allocator;
38// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.38// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
39// Specializing allocator<void> is deprecated, but not using it.39// Specializing allocator<void> is deprecated, but not using it.
40template <>40template <>
41class _LIBCPP_TEMPLATE_VIS allocator<void> {41class allocator<void> {
42public:42public:
43 _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;43 _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
44 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;44 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
...@@ -77,7 +77,7 @@ struct __non_trivial_if<true, _Unique> {...@@ -77,7 +77,7 @@ struct __non_trivial_if<true, _Unique> {
77// allocator<void> trivial in C++20.77// allocator<void> trivial in C++20.
7878
79template <class _Tp>79template <class _Tp>
80class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > {80class allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > {
81 static_assert(!is_const<_Tp>::value, "std::allocator does not support const types");81 static_assert(!is_const<_Tp>::value, "std::allocator does not support const types");
82 static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");82 static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
8383
...@@ -98,7 +98,7 @@ public:...@@ -98,7 +98,7 @@ public:
98 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {98 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {
99 static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type");99 static_assert(sizeof(_Tp) >= 0, "cannot allocate memory for an incomplete type");
100 if (__n > allocator_traits<allocator>::max_size(*this))100 if (__n > allocator_traits<allocator>::max_size(*this))
101 __throw_bad_array_new_length();101 std::__throw_bad_array_new_length();
102 if (__libcpp_is_constant_evaluated()) {102 if (__libcpp_is_constant_evaluated()) {
103 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));103 return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp)));
104 } else {104 } else {
lib/libcxx/include/__memory/allocator_arg_t.h+1-1
...@@ -23,7 +23,7 @@...@@ -23,7 +23,7 @@
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26struct _LIBCPP_TEMPLATE_VIS allocator_arg_t {26struct allocator_arg_t {
27 explicit allocator_arg_t() = default;27 explicit allocator_arg_t() = default;
28};28};
2929
lib/libcxx/include/__memory/allocator_traits.h+87-120
...@@ -36,12 +36,7 @@ _LIBCPP_PUSH_MACROS...@@ -36,12 +36,7 @@ _LIBCPP_PUSH_MACROS
3636
37_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3838
39#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \39_LIBCPP_SUPPRESS_DEPRECATED_PUSH
40 template <class _Tp, class = void> \
41 struct NAME : false_type {}; \
42 template <class _Tp> \
43 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {}
44
45// __pointer40// __pointer
46template <class _Tp>41template <class _Tp>
47using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;42using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
...@@ -49,50 +44,45 @@ using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;...@@ -49,50 +44,45 @@ using __pointer_member _LIBCPP_NODEBUG = typename _Tp::pointer;
49template <class _Tp, class _Alloc>44template <class _Tp, class _Alloc>
50using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;45using __pointer _LIBCPP_NODEBUG = __detected_or_t<_Tp*, __pointer_member, __libcpp_remove_reference_t<_Alloc> >;
5146
52// __const_pointer47// This trait returns _Alias<_Alloc> if that's well-formed, and _Ptr rebound to _Tp otherwise
53_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer);48template <class _Alloc, template <class> class _Alias, class _Ptr, class _Tp, class = void>
54template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>49struct __rebind_or_alias_pointer {
55struct __const_pointer {
56 using type _LIBCPP_NODEBUG = typename _Alloc::const_pointer;
57};
58template <class _Tp, class _Ptr, class _Alloc>
59struct __const_pointer<_Tp, _Ptr, _Alloc, false> {
60#ifdef _LIBCPP_CXX03_LANG50#ifdef _LIBCPP_CXX03_LANG
61 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>::other;51 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<_Tp>::other;
62#else52#else
63 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const _Tp>;53 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<_Tp>;
64#endif54#endif
65};55};
6656
67// __void_pointer57template <class _Ptr, class _Alloc, class _Tp, template <class> class _Alias>
68_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer);58struct __rebind_or_alias_pointer<_Alloc, _Alias, _Ptr, _Tp, __void_t<_Alias<_Alloc> > > {
69template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>59 using type _LIBCPP_NODEBUG = _Alias<_Alloc>;
70struct __void_pointer {
71 using type _LIBCPP_NODEBUG = typename _Alloc::void_pointer;
72};60};
61
62// __const_pointer
63template <class _Alloc>
64using __const_pointer_member _LIBCPP_NODEBUG = typename _Alloc::const_pointer;
65
66template <class _Tp, class _Ptr, class _Alloc>
67using __const_pointer_t _LIBCPP_NODEBUG =
68 typename __rebind_or_alias_pointer<_Alloc, __const_pointer_member, _Ptr, const _Tp>::type;
69_LIBCPP_SUPPRESS_DEPRECATED_POP
70
71// __void_pointer
72template <class _Alloc>
73using __void_pointer_member _LIBCPP_NODEBUG = typename _Alloc::void_pointer;
74
73template <class _Ptr, class _Alloc>75template <class _Ptr, class _Alloc>
74struct __void_pointer<_Ptr, _Alloc, false> {76using __void_pointer_t _LIBCPP_NODEBUG =
75#ifdef _LIBCPP_CXX03_LANG77 typename __rebind_or_alias_pointer<_Alloc, __void_pointer_member, _Ptr, void>::type;
76 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>::other;
77#else
78 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<void>;
79#endif
80};
8178
82// __const_void_pointer79// __const_void_pointer
83_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer);80template <class _Alloc>
84template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>81using __const_void_pointer_member _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer;
85struct __const_void_pointer {82
86 using type _LIBCPP_NODEBUG = typename _Alloc::const_void_pointer;
87};
88template <class _Ptr, class _Alloc>83template <class _Ptr, class _Alloc>
89struct __const_void_pointer<_Ptr, _Alloc, false> {84using __const_void_pointer_t _LIBCPP_NODEBUG =
90#ifdef _LIBCPP_CXX03_LANG85 typename __rebind_or_alias_pointer<_Alloc, __const_void_pointer_member, _Ptr, const void>::type;
91 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>::other;
92#else
93 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::template rebind<const void>;
94#endif
95};
9686
97// __size_type87// __size_type
98template <class _Tp>88template <class _Tp>
...@@ -102,13 +92,13 @@ template <class _Alloc, class _DiffType>...@@ -102,13 +92,13 @@ template <class _Alloc, class _DiffType>
102using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;92using __size_type _LIBCPP_NODEBUG = __detected_or_t<__make_unsigned_t<_DiffType>, __size_type_member, _Alloc>;
10393
104// __alloc_traits_difference_type94// __alloc_traits_difference_type
105_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type);95template <class _Alloc, class _Ptr, class = void>
106template <class _Alloc, class _Ptr, bool = __has_alloc_traits_difference_type<_Alloc>::value>
107struct __alloc_traits_difference_type {96struct __alloc_traits_difference_type {
108 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type;97 using type _LIBCPP_NODEBUG = typename pointer_traits<_Ptr>::difference_type;
109};98};
99
110template <class _Alloc, class _Ptr>100template <class _Alloc, class _Ptr>
111struct __alloc_traits_difference_type<_Alloc, _Ptr, true> {101struct __alloc_traits_difference_type<_Alloc, _Ptr, __void_t<typename _Alloc::difference_type> > {
112 using type _LIBCPP_NODEBUG = typename _Alloc::difference_type;102 using type _LIBCPP_NODEBUG = typename _Alloc::difference_type;
113};103};
114104
...@@ -138,6 +128,7 @@ template <class _Alloc>...@@ -138,6 +128,7 @@ template <class _Alloc>
138using __propagate_on_container_swap _LIBCPP_NODEBUG =128using __propagate_on_container_swap _LIBCPP_NODEBUG =
139 __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;129 __detected_or_t<false_type, __propagate_on_container_swap_member, _Alloc>;
140130
131_LIBCPP_SUPPRESS_DEPRECATED_PUSH
141// __is_always_equal132// __is_always_equal
142template <class _Tp>133template <class _Tp>
143using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;134using __is_always_equal_member _LIBCPP_NODEBUG = typename _Tp::is_always_equal;
...@@ -147,15 +138,14 @@ using __is_always_equal _LIBCPP_NODEBUG =...@@ -147,15 +138,14 @@ using __is_always_equal _LIBCPP_NODEBUG =
147 __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;138 __detected_or_t<typename is_empty<_Alloc>::type, __is_always_equal_member, _Alloc>;
148139
149// __allocator_traits_rebind140// __allocator_traits_rebind
150_LIBCPP_SUPPRESS_DEPRECATED_PUSH
151template <class _Tp, class _Up, class = void>141template <class _Tp, class _Up, class = void>
152struct __has_rebind_other : false_type {};142inline const bool __has_rebind_other_v = false;
153template <class _Tp, class _Up>143template <class _Tp, class _Up>
154struct __has_rebind_other<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > : true_type {};144inline const bool __has_rebind_other_v<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up>::other> > = true;
155145
156template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>146template <class _Tp, class _Up, bool = __has_rebind_other_v<_Tp, _Up> >
157struct __allocator_traits_rebind {147struct __allocator_traits_rebind {
158 static_assert(__has_rebind_other<_Tp, _Up>::value, "This allocator has to implement rebind");148 static_assert(__has_rebind_other_v<_Tp, _Up>, "This allocator has to implement rebind");
159 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;149 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>::other;
160};150};
161template <template <class, class...> class _Alloc, class _Tp, class... _Args, class _Up>151template <template <class, class...> class _Alloc, class _Tp, class... _Args, class _Up>
...@@ -173,53 +163,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_...@@ -173,53 +163,52 @@ using __allocator_traits_rebind_t _LIBCPP_NODEBUG = typename __allocator_traits_
173163
174_LIBCPP_SUPPRESS_DEPRECATED_PUSH164_LIBCPP_SUPPRESS_DEPRECATED_PUSH
175165
176// __has_allocate_hint166// __has_allocate_hint_v
177template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void>167template <class _Alloc, class _SizeType, class _ConstVoidPtr, class = void>
178struct __has_allocate_hint : false_type {};168inline const bool __has_allocate_hint_v = false;
179169
180template <class _Alloc, class _SizeType, class _ConstVoidPtr>170template <class _Alloc, class _SizeType, class _ConstVoidPtr>
181struct __has_allocate_hint<171inline const bool __has_allocate_hint_v<
182 _Alloc,172 _Alloc,
183 _SizeType,173 _SizeType,
184 _ConstVoidPtr,174 _ConstVoidPtr,
185 decltype((void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))>175 decltype((void)std::declval<_Alloc>().allocate(std::declval<_SizeType>(), std::declval<_ConstVoidPtr>()))> = true;
186 : true_type {};
187176
188// __has_construct177// __has_construct_v
189template <class, class _Alloc, class... _Args>178template <class, class _Alloc, class... _Args>
190struct __has_construct_impl : false_type {};179inline const bool __has_construct_impl = false;
191180
192template <class _Alloc, class... _Args>181template <class _Alloc, class... _Args>
193struct __has_construct_impl<decltype((void)std::declval<_Alloc>().construct(std::declval<_Args>()...)),182inline const bool
194 _Alloc,183 __has_construct_impl<decltype((void)std::declval<_Alloc>().construct(std::declval<_Args>()...)), _Alloc, _Args...> =
195 _Args...> : true_type {};184 true;
196185
197template <class _Alloc, class... _Args>186template <class _Alloc, class... _Args>
198struct __has_construct : __has_construct_impl<void, _Alloc, _Args...> {};187inline const bool __has_construct_v = __has_construct_impl<void, _Alloc, _Args...>;
199188
200// __has_destroy189// __has_destroy_v
201template <class _Alloc, class _Pointer, class = void>190template <class _Alloc, class _Pointer, class = void>
202struct __has_destroy : false_type {};191inline const bool __has_destroy_v = false;
203192
204template <class _Alloc, class _Pointer>193template <class _Alloc, class _Pointer>
205struct __has_destroy<_Alloc, _Pointer, decltype((void)std::declval<_Alloc>().destroy(std::declval<_Pointer>()))>194inline const bool
206 : true_type {};195 __has_destroy_v<_Alloc, _Pointer, decltype((void)std::declval<_Alloc>().destroy(std::declval<_Pointer>()))> = true;
207196
208// __has_max_size197// __has_max_size_v
209template <class _Alloc, class = void>198template <class _Alloc, class = void>
210struct __has_max_size : false_type {};199inline const bool __has_max_size_v = false;
211200
212template <class _Alloc>201template <class _Alloc>
213struct __has_max_size<_Alloc, decltype((void)std::declval<_Alloc&>().max_size())> : true_type {};202inline const bool __has_max_size_v<_Alloc, decltype((void)std::declval<_Alloc&>().max_size())> = true;
214203
215// __has_select_on_container_copy_construction204// __has_select_on_container_copy_construction_v
216template <class _Alloc, class = void>205template <class _Alloc, class = void>
217struct __has_select_on_container_copy_construction : false_type {};206inline const bool __has_select_on_container_copy_construction_v = false;
218207
219template <class _Alloc>208template <class _Alloc>
220struct __has_select_on_container_copy_construction<209inline const bool __has_select_on_container_copy_construction_v<
221 _Alloc,210 _Alloc,
222 decltype((void)std::declval<_Alloc>().select_on_container_copy_construction())> : true_type {};211 decltype((void)std::declval<_Alloc>().select_on_container_copy_construction())> = true;
223212
224_LIBCPP_SUPPRESS_DEPRECATED_POP213_LIBCPP_SUPPRESS_DEPRECATED_POP
225214
...@@ -235,13 +224,13 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);...@@ -235,13 +224,13 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
235#endif // _LIBCPP_STD_VER224#endif // _LIBCPP_STD_VER
236225
237template <class _Alloc>226template <class _Alloc>
238struct _LIBCPP_TEMPLATE_VIS allocator_traits {227struct allocator_traits {
239 using allocator_type = _Alloc;228 using allocator_type = _Alloc;
240 using value_type = typename allocator_type::value_type;229 using value_type = typename allocator_type::value_type;
241 using pointer = __pointer<value_type, allocator_type>;230 using pointer = __pointer<value_type, allocator_type>;
242 using const_pointer = typename __const_pointer<value_type, pointer, allocator_type>::type;231 using const_pointer = __const_pointer_t<value_type, pointer, allocator_type>;
243 using void_pointer = typename __void_pointer<pointer, allocator_type>::type;232 using void_pointer = __void_pointer_t<pointer, allocator_type>;
244 using const_void_pointer = typename __const_void_pointer<pointer, allocator_type>::type;233 using const_void_pointer = __const_void_pointer_t<pointer, allocator_type>;
245 using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;234 using difference_type = typename __alloc_traits_difference_type<allocator_type, pointer>::type;
246 using size_type = __size_type<allocator_type, difference_type>;235 using size_type = __size_type<allocator_type, difference_type>;
247 using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>;236 using propagate_on_container_copy_assignment = __propagate_on_container_copy_assignment<allocator_type>;
...@@ -270,16 +259,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {...@@ -270,16 +259,14 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
270 return __a.allocate(__n);259 return __a.allocate(__n);
271 }260 }
272261
273 template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>262 template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int> = 0>
274 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer263 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
275 allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {264 allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
276 _LIBCPP_SUPPRESS_DEPRECATED_PUSH265 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
277 return __a.allocate(__n, __hint);266 return __a.allocate(__n, __hint);
278 _LIBCPP_SUPPRESS_DEPRECATED_POP267 _LIBCPP_SUPPRESS_DEPRECATED_POP
279 }268 }
280 template <class _Ap = _Alloc,269 template <class _Ap = _Alloc, __enable_if_t<!__has_allocate_hint_v<_Ap, size_type, const_void_pointer>, int> = 0>
281 class = void,
282 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>
283 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer270 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
284 allocate(allocator_type& __a, size_type __n, const_void_pointer) {271 allocate(allocator_type& __a, size_type __n, const_void_pointer) {
285 return __a.allocate(__n);272 return __a.allocate(__n);
...@@ -302,52 +289,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {...@@ -302,52 +289,47 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
302 __a.deallocate(__p, __n);289 __a.deallocate(__p, __n);
303 }290 }
304291
305 template <class _Tp, class... _Args, __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0>292 template <class _Tp, class... _Args, __enable_if_t<__has_construct_v<allocator_type, _Tp*, _Args...>, int> = 0>
306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
307 construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {294 construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
308 _LIBCPP_SUPPRESS_DEPRECATED_PUSH295 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
309 __a.construct(__p, std::forward<_Args>(__args)...);296 __a.construct(__p, std::forward<_Args>(__args)...);
310 _LIBCPP_SUPPRESS_DEPRECATED_POP297 _LIBCPP_SUPPRESS_DEPRECATED_POP
311 }298 }
312 template <class _Tp,299 template <class _Tp, class... _Args, __enable_if_t<!__has_construct_v<allocator_type, _Tp*, _Args...>, int> = 0>
313 class... _Args,
314 class = void,
315 __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0>
316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void300 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
317 construct(allocator_type&, _Tp* __p, _Args&&... __args) {301 construct(allocator_type&, _Tp* __p, _Args&&... __args) {
318 std::__construct_at(__p, std::forward<_Args>(__args)...);302 std::__construct_at(__p, std::forward<_Args>(__args)...);
319 }303 }
320304
321 template <class _Tp, __enable_if_t<__has_destroy<allocator_type, _Tp*>::value, int> = 0>305 template <class _Tp, __enable_if_t<__has_destroy_v<allocator_type, _Tp*>, int> = 0>
322 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) {306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) {
323 _LIBCPP_SUPPRESS_DEPRECATED_PUSH307 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
324 __a.destroy(__p);308 __a.destroy(__p);
325 _LIBCPP_SUPPRESS_DEPRECATED_POP309 _LIBCPP_SUPPRESS_DEPRECATED_POP
326 }310 }
327 template <class _Tp, class = void, __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value, int> = 0>311 template <class _Tp, __enable_if_t<!__has_destroy_v<allocator_type, _Tp*>, int> = 0>
328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) {312 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) {
329 std::__destroy_at(__p);313 std::__destroy_at(__p);
330 }314 }
331315
332 template <class _Ap = _Alloc, __enable_if_t<__has_max_size<const _Ap>::value, int> = 0>316 template <class _Ap = _Alloc, __enable_if_t<__has_max_size_v<const _Ap>, int> = 0>
333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT {317 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT {
334 _LIBCPP_SUPPRESS_DEPRECATED_PUSH318 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
335 return __a.max_size();319 return __a.max_size();
336 _LIBCPP_SUPPRESS_DEPRECATED_POP320 _LIBCPP_SUPPRESS_DEPRECATED_POP
337 }321 }
338 template <class _Ap = _Alloc, class = void, __enable_if_t<!__has_max_size<const _Ap>::value, int> = 0>322 template <class _Ap = _Alloc, __enable_if_t<!__has_max_size_v<const _Ap>, int> = 0>
339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT {323 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT {
340 return numeric_limits<size_type>::max() / sizeof(value_type);324 return numeric_limits<size_type>::max() / sizeof(value_type);
341 }325 }
342326
343 template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value, int> = 0>327 template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction_v<const _Ap>, int> = 0>
344 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
345 select_on_container_copy_construction(const allocator_type& __a) {329 select_on_container_copy_construction(const allocator_type& __a) {
346 return __a.select_on_container_copy_construction();330 return __a.select_on_container_copy_construction();
347 }331 }
348 template <class _Ap = _Alloc,332 template <class _Ap = _Alloc, __enable_if_t<!__has_select_on_container_copy_construction_v<const _Ap>, int> = 0>
349 class = void,
350 __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value, int> = 0>
351 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
352 select_on_container_copy_construction(const allocator_type& __a) {334 select_on_container_copy_construction(const allocator_type& __a) {
353 return __a;335 return __a;
...@@ -370,42 +352,27 @@ struct __check_valid_allocator : true_type {...@@ -370,42 +352,27 @@ struct __check_valid_allocator : true_type {
370 "original allocator");352 "original allocator");
371};353};
372354
373// __is_default_allocator355// __is_default_allocator_v
374template <class _Tp>356template <class _Tp>
375struct __is_default_allocator : false_type {};357inline const bool __is_std_allocator_v = false;
376
377template <class>
378class allocator;
379358
380template <class _Tp>359template <class _Tp>
381struct __is_default_allocator<allocator<_Tp> > : true_type {};360inline const bool __is_std_allocator_v<allocator<_Tp> > = true;
382
383// __is_cpp17_move_insertable
384template <class _Alloc, class = void>
385struct __is_cpp17_move_insertable : is_move_constructible<typename _Alloc::value_type> {};
386361
362// __is_cpp17_move_insertable_v
387template <class _Alloc>363template <class _Alloc>
388struct __is_cpp17_move_insertable<364inline const bool __is_cpp17_move_insertable_v =
389 _Alloc,365 is_move_constructible<typename _Alloc::value_type>::value ||
390 __enable_if_t< !__is_default_allocator<_Alloc>::value &&366 (!__is_std_allocator_v<_Alloc> &&
391 __has_construct<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>::value > >367 __has_construct_v<_Alloc, typename _Alloc::value_type*, typename _Alloc::value_type&&>);
392 : true_type {};
393
394// __is_cpp17_copy_insertable
395template <class _Alloc, class = void>
396struct __is_cpp17_copy_insertable
397 : integral_constant<bool,
398 is_copy_constructible<typename _Alloc::value_type>::value &&
399 __is_cpp17_move_insertable<_Alloc>::value > {};
400368
369// __is_cpp17_copy_insertable_v
401template <class _Alloc>370template <class _Alloc>
402struct __is_cpp17_copy_insertable<371inline const bool __is_cpp17_copy_insertable_v =
403 _Alloc,372 __is_cpp17_move_insertable_v<_Alloc> &&
404 __enable_if_t< !__is_default_allocator<_Alloc>::value &&373 (is_copy_constructible<typename _Alloc::value_type>::value ||
405 __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > >374 (!__is_std_allocator_v<_Alloc> &&
406 : __is_cpp17_move_insertable<_Alloc> {};375 __has_construct_v<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>));
407
408#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
409376
410_LIBCPP_END_NAMESPACE_STD377_LIBCPP_END_NAMESPACE_STD
411378
lib/libcxx/include/__memory/auto_ptr.h+2-2
...@@ -26,7 +26,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref {...@@ -26,7 +26,7 @@ struct _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr_ref {
26};26};
2727
28template <class _Tp>28template <class _Tp>
29class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr {29class _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr {
30private:30private:
31 _Tp* __ptr_;31 _Tp* __ptr_;
3232
...@@ -80,7 +80,7 @@ public:...@@ -80,7 +80,7 @@ public:
80};80};
8181
82template <>82template <>
83class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> {83class _LIBCPP_DEPRECATED_IN_CXX11 auto_ptr<void> {
84public:84public:
85 typedef void element_type;85 typedef void element_type;
86};86};
lib/libcxx/include/__memory/compressed_pair.h+50-19
...@@ -15,7 +15,6 @@...@@ -15,7 +15,6 @@
15#include <__type_traits/datasizeof.h>15#include <__type_traits/datasizeof.h>
16#include <__type_traits/is_empty.h>16#include <__type_traits/is_empty.h>
17#include <__type_traits/is_final.h>17#include <__type_traits/is_final.h>
18#include <__type_traits/is_reference.h>
1918
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header20# pragma GCC system_header
...@@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);...@@ -63,9 +62,17 @@ inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
63template <class _Tp>62template <class _Tp>
64inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*);63inline const size_t __compressed_pair_alignment<_Tp&> = _LIBCPP_ALIGNOF(void*);
6564
66template <class _ToPad,65template <class _ToPad>
67 bool _Empty = ((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) ||66inline const bool __is_reference_or_unpadded_object =
68 is_reference<_ToPad>::value || sizeof(_ToPad) == __datasizeof_v<_ToPad>)>67 (is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || sizeof(_ToPad) == __datasizeof_v<_ToPad>;
68
69template <class _Tp>
70inline const bool __is_reference_or_unpadded_object<_Tp&> = true;
71
72template <class _Tp>
73inline const bool __is_reference_or_unpadded_object<_Tp&&> = true;
74
75template <class _ToPad, bool _Empty = __is_reference_or_unpadded_object<_ToPad> >
69class __compressed_pair_padding {76class __compressed_pair_padding {
70 char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};77 char __padding_[sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
71};78};
...@@ -73,21 +80,45 @@ class __compressed_pair_padding {...@@ -73,21 +80,45 @@ class __compressed_pair_padding {
73template <class _ToPad>80template <class _ToPad>
74class __compressed_pair_padding<_ToPad, true> {};81class __compressed_pair_padding<_ToPad, true> {};
7582
76# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \83// TODO: Fix the ABI for GCC as well once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121637 is fixed
77 _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \84# ifdef _LIBCPP_COMPILER_GCC
78 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \85# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
79 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \86 _LIBCPP_NO_UNIQUE_ADDRESS __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \
80 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _)87 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
8188 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
82# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \89 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _)
83 _LIBCPP_NO_UNIQUE_ADDRESS \90
84 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \91# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
85 __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \92 _LIBCPP_NO_UNIQUE_ADDRESS \
86 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \93 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \
87 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \94 __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
88 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \95 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
89 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \96 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
90 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _)97 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
98 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \
99 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _)
100# else
101# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
102 struct { \
103 _LIBCPP_NO_UNIQUE_ADDRESS \
104 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>))) T1 Initializer1; \
105 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
106 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
107 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
108 }
109
110# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
111 struct { \
112 _LIBCPP_NO_UNIQUE_ADDRESS \
113 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \
114 __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
115 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
116 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
117 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
118 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \
119 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _); \
120 }
121# endif
91122
92#else123#else
93# define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \124# define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \
lib/libcxx/include/__memory/construct_at.h+4-38
...@@ -12,14 +12,12 @@...@@ -12,14 +12,12 @@
1212
13#include <__assert>13#include <__assert>
14#include <__config>14#include <__config>
15#include <__iterator/access.h>
16#include <__memory/addressof.h>15#include <__memory/addressof.h>
17#include <__new/placement_new_delete.h>16#include <__new/placement_new_delete.h>
18#include <__type_traits/enable_if.h>17#include <__type_traits/enable_if.h>
19#include <__type_traits/is_array.h>18#include <__type_traits/is_array.h>
20#include <__utility/declval.h>19#include <__utility/declval.h>
21#include <__utility/forward.h>20#include <__utility/forward.h>
22#include <__utility/move.h>
2321
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header23# pragma GCC system_header
...@@ -57,9 +55,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l...@@ -57,9 +55,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __l
57// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`55// The internal functions are available regardless of the language version (with the exception of the `__destroy_at`
58// taking an array).56// taking an array).
5957
60template <class _ForwardIterator>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator __destroy(_ForwardIterator, _ForwardIterator);
62
63template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>58template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>
64_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {59_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {
65 _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");60 _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");
...@@ -68,30 +63,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc...@@ -68,30 +63,13 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc
6863
69#if _LIBCPP_STD_VER >= 2064#if _LIBCPP_STD_VER >= 20
70template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>65template <class _Tp, __enable_if_t<is_array<_Tp>::value, int> = 0>
71_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy_at(_Tp* __loc) {66_LIBCPP_HIDE_FROM_ABI constexpr void __destroy_at(_Tp* __loc) {
72 _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");67 _LIBCPP_ASSERT_NON_NULL(__loc != nullptr, "null pointer given to destroy_at");
73 std::__destroy(std::begin(*__loc), std::end(*__loc));68 for (auto&& __val : *__loc)
69 std::__destroy_at(std::addressof(__val));
74}70}
75#endif71#endif
7672
77template <class _ForwardIterator>
78_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
79__destroy(_ForwardIterator __first, _ForwardIterator __last) {
80 for (; __first != __last; ++__first)
81 std::__destroy_at(std::addressof(*__first));
82 return __first;
83}
84
85template <class _BidirectionalIterator>
86_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator
87__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) {
88 while (__last != __first) {
89 --__last;
90 std::__destroy_at(std::addressof(*__last));
91 }
92 return __last;
93}
94
95#if _LIBCPP_STD_VER >= 1773#if _LIBCPP_STD_VER >= 17
9674
97template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>75template <class _Tp, enable_if_t<!is_array_v<_Tp>, int> = 0>
...@@ -101,23 +79,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc)...@@ -101,23 +79,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc)
10179
102# if _LIBCPP_STD_VER >= 2080# if _LIBCPP_STD_VER >= 20
103template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>81template <class _Tp, enable_if_t<is_array_v<_Tp>, int> = 0>
104_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy_at(_Tp* __loc) {82_LIBCPP_HIDE_FROM_ABI constexpr void destroy_at(_Tp* __loc) {
105 std::__destroy_at(__loc);83 std::__destroy_at(__loc);
106}84}
107# endif85# endif
10886
109template <class _ForwardIterator>
110_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) {
111 (void)std::__destroy(std::move(__first), std::move(__last));
112}
113
114template <class _ForwardIterator, class _Size>
115_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
116 for (; __n > 0; (void)++__first, --__n)
117 std::__destroy_at(std::addressof(*__first));
118 return __first;
119}
120
121#endif // _LIBCPP_STD_VER >= 1787#endif // _LIBCPP_STD_VER >= 17
12288
123_LIBCPP_END_NAMESPACE_STD89_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/destroy.h created+71
...@@ -0,0 +1,71 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___MEMORY_DESTROY_H
10#define _LIBCPP___MEMORY_DESTROY_H
11
12#include <__config>
13#include <__memory/addressof.h>
14#include <__memory/allocator_traits.h>
15#include <__memory/construct_at.h>
16#include <__utility/move.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27template <class _ForwardIterator>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
29__destroy(_ForwardIterator __first, _ForwardIterator __last) {
30 for (; __first != __last; ++__first)
31 std::__destroy_at(std::addressof(*__first));
32 return __first;
33}
34
35template <class _BidirectionalIterator>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator
37__reverse_destroy(_BidirectionalIterator __first, _BidirectionalIterator __last) {
38 while (__last != __first) {
39 --__last;
40 std::__destroy_at(std::addressof(*__last));
41 }
42 return __last;
43}
44
45// Destroy all elements in [__first, __last) from left to right using allocator destruction.
46template <class _Alloc, class _Iter, class _Sent>
47_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
48__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
49 for (; __first != __last; ++__first)
50 allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__first));
51}
52
53#if _LIBCPP_STD_VER >= 17
54template <class _ForwardIterator>
55_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void destroy(_ForwardIterator __first, _ForwardIterator __last) {
56 (void)std::__destroy(std::move(__first), std::move(__last));
57}
58
59template <class _ForwardIterator, class _Size>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator destroy_n(_ForwardIterator __first, _Size __n) {
61 for (; __n > 0; (void)++__first, --__n)
62 std::__destroy_at(std::addressof(*__first));
63 return __first;
64}
65#endif
66
67_LIBCPP_END_NAMESPACE_STD
68
69_LIBCPP_POP_MACROS
70
71#endif // _LIBCPP___MEMORY_DESTROY_H
lib/libcxx/include/__memory/inout_ptr.h+1-1
...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
35#if _LIBCPP_STD_VER >= 2335#if _LIBCPP_STD_VER >= 23
3636
37template <class _Smart, class _Pointer, class... _Args>37template <class _Smart, class _Pointer, class... _Args>
38class _LIBCPP_TEMPLATE_VIS inout_ptr_t {38class inout_ptr_t {
39 static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr.");39 static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr.");
4040
41public:41public:
lib/libcxx/include/__memory/is_sufficiently_aligned.h created+34
...@@ -0,0 +1,34 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H
11#define _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H
12
13#include <__config>
14#include <__cstddef/size_t.h>
15#include <cstdint>
16
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23#if _LIBCPP_STD_VER >= 26
24
25template <size_t _Alignment, class _Tp>
26_LIBCPP_HIDE_FROM_ABI bool is_sufficiently_aligned(_Tp* __ptr) {
27 return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0;
28}
29
30#endif // _LIBCPP_STD_VER >= 26
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___MEMORY_IS_SUFFICIENTLY_ALIGNED_H
lib/libcxx/include/__memory/out_ptr.h+1-1
...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
34#if _LIBCPP_STD_VER >= 2334#if _LIBCPP_STD_VER >= 23
3535
36template <class _Smart, class _Pointer, class... _Args>36template <class _Smart, class _Pointer, class... _Args>
37class _LIBCPP_TEMPLATE_VIS out_ptr_t {37class out_ptr_t {
38 static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0,38 static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0,
39 "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported.");39 "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported.");
4040
lib/libcxx/include/__memory/pointer_traits.h+52-90
...@@ -16,11 +16,13 @@...@@ -16,11 +16,13 @@
16#include <__type_traits/conditional.h>16#include <__type_traits/conditional.h>
17#include <__type_traits/conjunction.h>17#include <__type_traits/conjunction.h>
18#include <__type_traits/decay.h>18#include <__type_traits/decay.h>
19#include <__type_traits/detected_or.h>
19#include <__type_traits/enable_if.h>20#include <__type_traits/enable_if.h>
20#include <__type_traits/integral_constant.h>21#include <__type_traits/integral_constant.h>
21#include <__type_traits/is_class.h>22#include <__type_traits/is_class.h>
22#include <__type_traits/is_function.h>23#include <__type_traits/is_function.h>
23#include <__type_traits/is_void.h>24#include <__type_traits/is_void.h>
25#include <__type_traits/nat.h>
24#include <__type_traits/void_t.h>26#include <__type_traits/void_t.h>
25#include <__utility/declval.h>27#include <__utility/declval.h>
26#include <__utility/forward.h>28#include <__utility/forward.h>
...@@ -34,67 +36,37 @@ _LIBCPP_PUSH_MACROS...@@ -34,67 +36,37 @@ _LIBCPP_PUSH_MACROS
3436
35_LIBCPP_BEGIN_NAMESPACE_STD37_LIBCPP_BEGIN_NAMESPACE_STD
3638
37// clang-format off
38#define _LIBCPP_CLASS_TRAITS_HAS_XXX(NAME, PROPERTY) \
39 template <class _Tp, class = void> \
40 struct NAME : false_type {}; \
41 template <class _Tp> \
42 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY> > : true_type {}
43// clang-format on
44
45_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_pointer, pointer);
46_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_element_type, element_type);
47
48template <class _Ptr, bool = __has_element_type<_Ptr>::value>
49struct __pointer_traits_element_type {};
50
51template <class _Ptr>39template <class _Ptr>
52struct __pointer_traits_element_type<_Ptr, true> {40struct __pointer_traits_element_type_impl {};
53 using type _LIBCPP_NODEBUG = typename _Ptr::element_type;
54};
5541
56template <template <class, class...> class _Sp, class _Tp, class... _Args>42template <template <class, class...> class _Sp, class _Tp, class... _Args>
57struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {43struct __pointer_traits_element_type_impl<_Sp<_Tp, _Args...> > {
58 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::element_type;
59};
60
61template <template <class, class...> class _Sp, class _Tp, class... _Args>
62struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false> {
63 using type _LIBCPP_NODEBUG = _Tp;44 using type _LIBCPP_NODEBUG = _Tp;
64};45};
6546
66template <class _Tp, class = void>47template <class _Ptr, class = void>
67struct __has_difference_type : false_type {};48struct __pointer_traits_element_type : __pointer_traits_element_type_impl<_Ptr> {};
68
69template <class _Tp>
70struct __has_difference_type<_Tp, __void_t<typename _Tp::difference_type> > : true_type {};
71
72template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
73struct __pointer_traits_difference_type {
74 using type _LIBCPP_NODEBUG = ptrdiff_t;
75};
7649
77template <class _Ptr>50template <class _Ptr>
78struct __pointer_traits_difference_type<_Ptr, true> {51struct __pointer_traits_element_type<_Ptr, __void_t<typename _Ptr::element_type> > {
79 using type _LIBCPP_NODEBUG = typename _Ptr::difference_type;52 using type _LIBCPP_NODEBUG = typename _Ptr::element_type;
80};53};
8154
82template <class _Tp, class _Up>55template <class _Tp, class _Up>
83struct __has_rebind {56struct __pointer_traits_rebind_impl {
84private:57 static_assert(false, "Cannot rebind pointer; did you forget to add a rebind member to your pointer?");
85 template <class _Xp>58};
86 static false_type __test(...);
87 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
88 template <class _Xp>
89 static true_type __test(typename _Xp::template rebind<_Up>* = 0);
90 _LIBCPP_SUPPRESS_DEPRECATED_POP
9159
92public:60template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
93 static const bool value = decltype(__test<_Tp>(0))::value;61struct __pointer_traits_rebind_impl<_Sp<_Tp, _Args...>, _Up> {
62 using type _LIBCPP_NODEBUG = _Sp<_Up, _Args...>;
94};63};
9564
96template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>65template <class _Tp, class _Up, class = void>
97struct __pointer_traits_rebind {66struct __pointer_traits_rebind : __pointer_traits_rebind_impl<_Tp, _Up> {};
67
68template <class _Tp, class _Up>
69struct __pointer_traits_rebind<_Tp, _Up, __void_t<typename _Tp::template rebind<_Up> > > {
98#ifndef _LIBCPP_CXX03_LANG70#ifndef _LIBCPP_CXX03_LANG
99 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>;71 using type _LIBCPP_NODEBUG = typename _Tp::template rebind<_Up>;
100#else72#else
...@@ -102,19 +74,8 @@ struct __pointer_traits_rebind {...@@ -102,19 +74,8 @@ struct __pointer_traits_rebind {
102#endif74#endif
103};75};
10476
105template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>77template <class _Tp>
106struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true> {78using __difference_type_member _LIBCPP_NODEBUG = typename _Tp::difference_type;
107#ifndef _LIBCPP_CXX03_LANG
108 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>;
109#else
110 using type _LIBCPP_NODEBUG = typename _Sp<_Tp, _Args...>::template rebind<_Up>::other;
111#endif
112};
113
114template <template <class, class...> class _Sp, class _Tp, class... _Args, class _Up>
115struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, false> {
116 typedef _Sp<_Up, _Args...> type;
117};
11879
119template <class _Ptr, class = void>80template <class _Ptr, class = void>
120struct __pointer_traits_impl {};81struct __pointer_traits_impl {};
...@@ -123,7 +84,7 @@ template <class _Ptr>...@@ -123,7 +84,7 @@ template <class _Ptr>
123struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_type<_Ptr>::type> > {84struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_type<_Ptr>::type> > {
124 typedef _Ptr pointer;85 typedef _Ptr pointer;
125 typedef typename __pointer_traits_element_type<pointer>::type element_type;86 typedef typename __pointer_traits_element_type<pointer>::type element_type;
126 typedef typename __pointer_traits_difference_type<pointer>::type difference_type;87 using difference_type = __detected_or_t<ptrdiff_t, __difference_type_member, pointer>;
12788
128#ifndef _LIBCPP_CXX03_LANG89#ifndef _LIBCPP_CXX03_LANG
129 template <class _Up>90 template <class _Up>
...@@ -135,9 +96,6 @@ struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_ty...@@ -135,9 +96,6 @@ struct __pointer_traits_impl<_Ptr, __void_t<typename __pointer_traits_element_ty
135 };96 };
136#endif // _LIBCPP_CXX03_LANG97#endif // _LIBCPP_CXX03_LANG
13798
138private:
139 struct __nat {};
140
141public:99public:
142 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
143 pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) {101 pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) {
...@@ -146,10 +104,10 @@ public:...@@ -146,10 +104,10 @@ public:
146};104};
147105
148template <class _Ptr>106template <class _Ptr>
149struct _LIBCPP_TEMPLATE_VIS pointer_traits : __pointer_traits_impl<_Ptr> {};107struct pointer_traits : __pointer_traits_impl<_Ptr> {};
150108
151template <class _Tp>109template <class _Tp>
152struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> {110struct pointer_traits<_Tp*> {
153 typedef _Tp* pointer;111 typedef _Tp* pointer;
154 typedef _Tp element_type;112 typedef _Tp element_type;
155 typedef ptrdiff_t difference_type;113 typedef ptrdiff_t difference_type;
...@@ -164,9 +122,6 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> {...@@ -164,9 +122,6 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits<_Tp*> {
164 };122 };
165#endif123#endif
166124
167private:
168 struct __nat {};
169
170public:125public:
171 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer126 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
172 pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT {127 pointer_to(__conditional_t<is_void<element_type>::value, __nat, element_type>& __r) _NOEXCEPT {
...@@ -245,8 +200,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept {...@@ -245,8 +200,8 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept {
245}200}
246201
247template <class _Pointer>202template <class _Pointer>
248inline _LIBCPP_HIDE_FROM_ABI constexpr auto203inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept
249to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {204 -> decltype(std::__to_address(__p)) {
250 return std::__to_address(__p);205 return std::__to_address(__p);
251}206}
252#endif207#endif
...@@ -257,40 +212,35 @@ template <class _Tp>...@@ -257,40 +212,35 @@ template <class _Tp>
257struct __pointer_of {};212struct __pointer_of {};
258213
259template <class _Tp>214template <class _Tp>
260 requires(__has_pointer<_Tp>::value)215concept __has_pointer_member = requires { typename _Tp::pointer; };
216
217template <class _Tp>
218concept __has_element_type_member = requires { typename _Tp::element_type; };
219
220template <class _Tp>
221 requires __has_pointer_member<_Tp>
261struct __pointer_of<_Tp> {222struct __pointer_of<_Tp> {
262 using type = typename _Tp::pointer;223 using type _LIBCPP_NODEBUG = typename _Tp::pointer;
263};224};
264225
265template <class _Tp>226template <class _Tp>
266 requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value)227 requires(!__has_pointer_member<_Tp> && __has_element_type_member<_Tp>)
267struct __pointer_of<_Tp> {228struct __pointer_of<_Tp> {
268 using type = typename _Tp::element_type*;229 using type _LIBCPP_NODEBUG = typename _Tp::element_type*;
269};230};
270231
271template <class _Tp>232template <class _Tp>
272 requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value &&233 requires(!__has_pointer_member<_Tp> && !__has_element_type_member<_Tp> &&
273 __has_element_type<pointer_traits<_Tp>>::value)234 __has_element_type_member<pointer_traits<_Tp>>)
274struct __pointer_of<_Tp> {235struct __pointer_of<_Tp> {
275 using type = typename pointer_traits<_Tp>::element_type*;236 using type _LIBCPP_NODEBUG = typename pointer_traits<_Tp>::element_type*;
276};237};
277238
278template <typename _Tp>239template <typename _Tp>
279using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type;240using __pointer_of_t _LIBCPP_NODEBUG = typename __pointer_of<_Tp>::type;
280241
281template <class _Tp, class _Up>
282struct __pointer_of_or {
283 using type _LIBCPP_NODEBUG = _Up;
284};
285
286template <class _Tp, class _Up>
287 requires requires { typename __pointer_of_t<_Tp>; }
288struct __pointer_of_or<_Tp, _Up> {
289 using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>;
290};
291
292template <typename _Tp, typename _Up>242template <typename _Tp, typename _Up>
293using __pointer_of_or_t _LIBCPP_NODEBUG = typename __pointer_of_or<_Tp, _Up>::type;243using __pointer_of_or_t _LIBCPP_NODEBUG = __detected_or_t<_Up, __pointer_of_t, _Tp>;
294244
295template <class _Smart>245template <class _Smart>
296concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };246concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };
...@@ -302,6 +252,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p...@@ -302,6 +252,18 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
302252
303#endif253#endif
304254
255// This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to
256// `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`,
257// then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer
258// to that object using the `std::pointer_traits<>::pinter_to` function.
259template <class _PtrTo, class _PtrFrom>
260_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
261 using __ptr_traits = pointer_traits<_PtrTo>;
262 using __element_type = typename __ptr_traits::element_type;
263 return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p)))
264 : static_cast<_PtrTo>(nullptr);
265}
266
305_LIBCPP_END_NAMESPACE_STD267_LIBCPP_END_NAMESPACE_STD
306268
307_LIBCPP_POP_MACROS269_LIBCPP_POP_MACROS
lib/libcxx/include/__memory/ranges_construct_at.h-35
...@@ -61,41 +61,6 @@ inline namespace __cpo {...@@ -61,41 +61,6 @@ inline namespace __cpo {
61inline constexpr auto destroy_at = __destroy_at{};61inline constexpr auto destroy_at = __destroy_at{};
62} // namespace __cpo62} // namespace __cpo
6363
64// destroy
65
66struct __destroy {
67 template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
68 requires destructible<iter_value_t<_InputIterator>>
69 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
70 return std::__destroy(std::move(__first), std::move(__last));
71 }
72
73 template <__nothrow_input_range _InputRange>
74 requires destructible<range_value_t<_InputRange>>
75 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {
76 return (*this)(ranges::begin(__range), ranges::end(__range));
77 }
78};
79
80inline namespace __cpo {
81inline constexpr auto destroy = __destroy{};
82} // namespace __cpo
83
84// destroy_n
85
86struct __destroy_n {
87 template <__nothrow_input_iterator _InputIterator>
88 requires destructible<iter_value_t<_InputIterator>>
89 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator
90 operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {
91 return std::destroy_n(std::move(__first), __n);
92 }
93};
94
95inline namespace __cpo {
96inline constexpr auto destroy_n = __destroy_n{};
97} // namespace __cpo
98
99} // namespace ranges64} // namespace ranges
10065
101#endif // _LIBCPP_STD_VER >= 2066#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__memory/ranges_destroy.h created+79
...@@ -0,0 +1,79 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___MEMORY_RANGES_DESTROY_H
11#define _LIBCPP___MEMORY_RANGES_DESTROY_H
12
13#include <__concepts/destructible.h>
14#include <__config>
15#include <__iterator/incrementable_traits.h>
16#include <__iterator/iterator_traits.h>
17#include <__memory/concepts.h>
18#include <__memory/destroy.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/dangling.h>
22#include <__utility/move.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28_LIBCPP_PUSH_MACROS
29#include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33#if _LIBCPP_STD_VER >= 20
34namespace ranges {
35
36// destroy
37
38struct __destroy {
39 template <__nothrow_input_iterator _InputIterator, __nothrow_sentinel_for<_InputIterator> _Sentinel>
40 requires destructible<iter_value_t<_InputIterator>>
41 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator operator()(_InputIterator __first, _Sentinel __last) const noexcept {
42 return std::__destroy(std::move(__first), std::move(__last));
43 }
44
45 template <__nothrow_input_range _InputRange>
46 requires destructible<range_value_t<_InputRange>>
47 _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_InputRange> operator()(_InputRange&& __range) const noexcept {
48 return (*this)(ranges::begin(__range), ranges::end(__range));
49 }
50};
51
52inline namespace __cpo {
53inline constexpr auto destroy = __destroy{};
54} // namespace __cpo
55
56// destroy_n
57
58struct __destroy_n {
59 template <__nothrow_input_iterator _InputIterator>
60 requires destructible<iter_value_t<_InputIterator>>
61 _LIBCPP_HIDE_FROM_ABI constexpr _InputIterator
62 operator()(_InputIterator __first, iter_difference_t<_InputIterator> __n) const noexcept {
63 return std::destroy_n(std::move(__first), __n);
64 }
65};
66
67inline namespace __cpo {
68inline constexpr auto destroy_n = __destroy_n{};
69} // namespace __cpo
70
71} // namespace ranges
72
73#endif // _LIBCPP_STD_VER >= 20
74
75_LIBCPP_END_NAMESPACE_STD
76
77_LIBCPP_POP_MACROS
78
79#endif // _LIBCPP___MEMORY_RANGES_DESTROY_H
lib/libcxx/include/__memory/raw_storage_iterator.h+1-1
...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3030
31_LIBCPP_SUPPRESS_DEPRECATED_PUSH31_LIBCPP_SUPPRESS_DEPRECATED_PUSH
32template <class _OutputIterator, class _Tp>32template <class _OutputIterator, class _Tp>
33class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator33class _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
34# if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)34# if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES)
35 : public iterator<output_iterator_tag, void, void, void, void>35 : public iterator<output_iterator_tag, void, void, void, void>
36# endif36# endif
lib/libcxx/include/__memory/shared_count.h+3-2
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___MEMORY_SHARED_COUNT_H10#define _LIBCPP___MEMORY_SHARED_COUNT_H
1111
12#include <__config>12#include <__config>
13#include <__memory/addressof.h>
13#include <typeinfo>14#include <typeinfo>
1415
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -52,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const*...@@ -52,7 +53,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const*
52template <class _Tp>53template <class _Tp>
53inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT {54inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT {
54#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS55#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS
55 return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED);56 return __atomic_add_fetch(std::addressof(__t), 1, __ATOMIC_RELAXED);
56#else57#else
57 return __t += 1;58 return __t += 1;
58#endif59#endif
...@@ -61,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N...@@ -61,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N
61template <class _Tp>62template <class _Tp>
62inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT {63inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT {
63#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS64#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && _LIBCPP_HAS_THREADS
64 return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL);65 return __atomic_add_fetch(std::addressof(__t), -1, __ATOMIC_ACQ_REL);
65#else66#else
66 return __t -= 1;67 return __t -= 1;
67#endif68#endif
lib/libcxx/include/__memory/shared_ptr.h+23-19
...@@ -29,11 +29,12 @@...@@ -29,11 +29,12 @@
29#include <__memory/auto_ptr.h>29#include <__memory/auto_ptr.h>
30#include <__memory/compressed_pair.h>30#include <__memory/compressed_pair.h>
31#include <__memory/construct_at.h>31#include <__memory/construct_at.h>
32#include <__memory/destroy.h>
32#include <__memory/pointer_traits.h>33#include <__memory/pointer_traits.h>
33#include <__memory/shared_count.h>34#include <__memory/shared_count.h>
34#include <__memory/uninitialized_algorithms.h>35#include <__memory/uninitialized_algorithms.h>
35#include <__memory/unique_ptr.h>36#include <__memory/unique_ptr.h>
36#include <__type_traits/add_lvalue_reference.h>37#include <__type_traits/add_reference.h>
37#include <__type_traits/conditional.h>38#include <__type_traits/conditional.h>
38#include <__type_traits/conjunction.h>39#include <__type_traits/conjunction.h>
39#include <__type_traits/disjunction.h>40#include <__type_traits/disjunction.h>
...@@ -89,7 +90,7 @@ public:...@@ -89,7 +90,7 @@ public:
89}90}
9091
91template <class _Tp>92template <class _Tp>
92class _LIBCPP_TEMPLATE_VIS weak_ptr;93class weak_ptr;
9394
94template <class _Tp, class _Dp, class _Alloc>95template <class _Tp, class _Dp, class _Alloc>
95class __shared_ptr_pointer : public __shared_weak_count {96class __shared_ptr_pointer : public __shared_weak_count {
...@@ -217,7 +218,7 @@ private:...@@ -217,7 +218,7 @@ private:
217218
218struct __shared_ptr_dummy_rebind_allocator_type;219struct __shared_ptr_dummy_rebind_allocator_type;
219template <>220template <>
220class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type> {221class allocator<__shared_ptr_dummy_rebind_allocator_type> {
221public:222public:
222 template <class _Other>223 template <class _Other>
223 struct rebind {224 struct rebind {
...@@ -226,7 +227,7 @@ public:...@@ -226,7 +227,7 @@ public:
226};227};
227228
228template <class _Tp>229template <class _Tp>
229class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;230class enable_shared_from_this;
230231
231// http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.general-6232// http://eel.is/c++draft/util.sharedptr#util.smartptr.shared.general-6
232// A pointer type Y* is said to be compatible with a pointer type T*233// A pointer type Y* is said to be compatible with a pointer type T*
...@@ -303,7 +304,7 @@ using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG =...@@ -303,7 +304,7 @@ using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG =
303#endif304#endif
304305
305template <class _Tp>306template <class _Tp>
306class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {307class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr {
307 struct __nullptr_sfinae_tag {};308 struct __nullptr_sfinae_tag {};
308309
309public:310public:
...@@ -315,8 +316,10 @@ public:...@@ -315,8 +316,10 @@ public:
315#endif316#endif
316317
317 // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require318 // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
318 // any bookkeeping, so it's always trivially relocatable.319 // any bookkeeping, so it's always trivially relocatable. It is also replaceable because assignment just rebinds the
320 // shared_ptr to manage a different object.
319 using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr;321 using __trivially_relocatable _LIBCPP_NODEBUG = shared_ptr;
322 using __replaceable _LIBCPP_NODEBUG = shared_ptr;
320323
321private:324private:
322 element_type* __ptr_;325 element_type* __ptr_;
...@@ -496,7 +499,7 @@ public:...@@ -496,7 +499,7 @@ public:
496 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r)499 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r)
497 : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) {500 : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) {
498 if (__cntrl_ == nullptr)501 if (__cntrl_ == nullptr)
499 __throw_bad_weak_ptr();502 std::__throw_bad_weak_ptr();
500 }503 }
501504
502#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)505#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
...@@ -710,9 +713,9 @@ private:...@@ -710,9 +713,9 @@ private:
710 struct __shared_ptr_default_delete<_Yp[], _Un> : default_delete<_Yp[]> {};713 struct __shared_ptr_default_delete<_Yp[], _Un> : default_delete<_Yp[]> {};
711714
712 template <class _Up>715 template <class _Up>
713 friend class _LIBCPP_TEMPLATE_VIS shared_ptr;716 friend class shared_ptr;
714 template <class _Up>717 template <class _Up>
715 friend class _LIBCPP_TEMPLATE_VIS weak_ptr;718 friend class weak_ptr;
716};719};
717720
718#if _LIBCPP_STD_VER >= 17721#if _LIBCPP_STD_VER >= 17
...@@ -1201,7 +1204,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC...@@ -1201,7 +1204,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC
1201#endif // _LIBCPP_HAS_RTTI1204#endif // _LIBCPP_HAS_RTTI
12021205
1203template <class _Tp>1206template <class _Tp>
1204class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr {1207class _LIBCPP_SHARED_PTR_TRIVIAL_ABI weak_ptr {
1205public:1208public:
1206#if _LIBCPP_STD_VER >= 171209#if _LIBCPP_STD_VER >= 17
1207 typedef remove_extent_t<_Tp> element_type;1210 typedef remove_extent_t<_Tp> element_type;
...@@ -1210,8 +1213,9 @@ public:...@@ -1210,8 +1213,9 @@ public:
1210#endif1213#endif
12111214
1212 // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require1215 // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
1213 // any bookkeeping, so it's always trivially relocatable.1216 // any bookkeeping, so it's always trivially relocatable. It's also replaceable for the same reason.
1214 using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr;1217 using __trivially_relocatable _LIBCPP_NODEBUG = weak_ptr;
1218 using __replaceable _LIBCPP_NODEBUG = weak_ptr;
12151219
1216private:1220private:
1217 element_type* __ptr_;1221 element_type* __ptr_;
...@@ -1262,9 +1266,9 @@ public:...@@ -1262,9 +1266,9 @@ public:
1262 }1266 }
12631267
1264 template <class _Up>1268 template <class _Up>
1265 friend class _LIBCPP_TEMPLATE_VIS weak_ptr;1269 friend class weak_ptr;
1266 template <class _Up>1270 template <class _Up>
1267 friend class _LIBCPP_TEMPLATE_VIS shared_ptr;1271 friend class shared_ptr;
1268};1272};
12691273
1270#if _LIBCPP_STD_VER >= 171274#if _LIBCPP_STD_VER >= 17
...@@ -1382,7 +1386,7 @@ struct owner_less;...@@ -1382,7 +1386,7 @@ struct owner_less;
1382#endif1386#endif
13831387
1384template <class _Tp>1388template <class _Tp>
1385struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> {1389struct owner_less<shared_ptr<_Tp> > : __binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> {
1386 _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {1390 _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Tp> const& __y) const _NOEXCEPT {
1387 return __x.owner_before(__y);1391 return __x.owner_before(__y);
1388 }1392 }
...@@ -1395,7 +1399,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<sha...@@ -1395,7 +1399,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<shared_ptr<_Tp> > : __binary_function<sha
1395};1399};
13961400
1397template <class _Tp>1401template <class _Tp>
1398struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> {1402struct owner_less<weak_ptr<_Tp> > : __binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> {
1399 _LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {1403 _LIBCPP_HIDE_FROM_ABI bool operator()(weak_ptr<_Tp> const& __x, weak_ptr<_Tp> const& __y) const _NOEXCEPT {
1400 return __x.owner_before(__y);1404 return __x.owner_before(__y);
1401 }1405 }
...@@ -1409,7 +1413,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_...@@ -1409,7 +1413,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<weak_ptr<_Tp> > : __binary_function<weak_
14091413
1410#if _LIBCPP_STD_VER >= 171414#if _LIBCPP_STD_VER >= 17
1411template <>1415template <>
1412struct _LIBCPP_TEMPLATE_VIS owner_less<void> {1416struct owner_less<void> {
1413 template <class _Tp, class _Up>1417 template <class _Tp, class _Up>
1414 _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {1418 _LIBCPP_HIDE_FROM_ABI bool operator()(shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const _NOEXCEPT {
1415 return __x.owner_before(__y);1419 return __x.owner_before(__y);
...@@ -1431,7 +1435,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<void> {...@@ -1431,7 +1435,7 @@ struct _LIBCPP_TEMPLATE_VIS owner_less<void> {
1431#endif1435#endif
14321436
1433template <class _Tp>1437template <class _Tp>
1434class _LIBCPP_TEMPLATE_VIS enable_shared_from_this {1438class enable_shared_from_this {
1435 mutable weak_ptr<_Tp> __weak_this_;1439 mutable weak_ptr<_Tp> __weak_this_;
14361440
1437protected:1441protected:
...@@ -1455,10 +1459,10 @@ public:...@@ -1455,10 +1459,10 @@ public:
1455};1459};
14561460
1457template <class _Tp>1461template <class _Tp>
1458struct _LIBCPP_TEMPLATE_VIS hash;1462struct hash;
14591463
1460template <class _Tp>1464template <class _Tp>
1461struct _LIBCPP_TEMPLATE_VIS hash<shared_ptr<_Tp> > {1465struct hash<shared_ptr<_Tp> > {
1462#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)1466#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1463 _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type;1467 _LIBCPP_DEPRECATED_IN_CXX17 typedef shared_ptr<_Tp> argument_type;
1464 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;1468 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
lib/libcxx/include/__memory/uninitialized_algorithms.h+13-20
...@@ -16,11 +16,13 @@...@@ -16,11 +16,13 @@
16#include <__algorithm/unwrap_range.h>16#include <__algorithm/unwrap_range.h>
17#include <__config>17#include <__config>
18#include <__cstddef/size_t.h>18#include <__cstddef/size_t.h>
19#include <__fwd/memory.h>
19#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
20#include <__iterator/reverse_iterator.h>21#include <__iterator/reverse_iterator.h>
21#include <__memory/addressof.h>22#include <__memory/addressof.h>
22#include <__memory/allocator_traits.h>23#include <__memory/allocator_traits.h>
23#include <__memory/construct_at.h>24#include <__memory/construct_at.h>
25#include <__memory/destroy.h>
24#include <__memory/pointer_traits.h>26#include <__memory/pointer_traits.h>
25#include <__type_traits/enable_if.h>27#include <__type_traits/enable_if.h>
26#include <__type_traits/extent.h>28#include <__type_traits/extent.h>
...@@ -31,7 +33,6 @@...@@ -31,7 +33,6 @@
31#include <__type_traits/is_trivially_constructible.h>33#include <__type_traits/is_trivially_constructible.h>
32#include <__type_traits/is_trivially_relocatable.h>34#include <__type_traits/is_trivially_relocatable.h>
33#include <__type_traits/is_unbounded_array.h>35#include <__type_traits/is_unbounded_array.h>
34#include <__type_traits/negation.h>
35#include <__type_traits/remove_const.h>36#include <__type_traits/remove_const.h>
36#include <__type_traits/remove_extent.h>37#include <__type_traits/remove_extent.h>
37#include <__utility/exception_guard.h>38#include <__utility/exception_guard.h>
...@@ -511,14 +512,6 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B...@@ -511,14 +512,6 @@ __uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _B
511512
512#endif // _LIBCPP_STD_VER >= 17513#endif // _LIBCPP_STD_VER >= 17
513514
514// Destroy all elements in [__first, __last) from left to right using allocator destruction.
515template <class _Alloc, class _Iter, class _Sent>
516_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
517__allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
518 for (; __first != __last; ++__first)
519 allocator_traits<_Alloc>::destroy(__alloc, std::__to_address(__first));
520}
521
522template <class _Alloc, class _Iter>515template <class _Alloc, class _Iter>
523class _AllocatorDestroyRangeReverse {516class _AllocatorDestroyRangeReverse {
524public:517public:
...@@ -556,17 +549,17 @@ __uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __l...@@ -556,17 +549,17 @@ __uninitialized_allocator_copy_impl(_Alloc& __alloc, _Iter1 __first1, _Sent1 __l
556}549}
557550
558template <class _Alloc, class _Type>551template <class _Alloc, class _Type>
559struct __allocator_has_trivial_copy_construct : _Not<__has_construct<_Alloc, _Type*, const _Type&> > {};552inline const bool __allocator_has_trivial_copy_construct_v = !__has_construct_v<_Alloc, _Type*, const _Type&>;
560553
561template <class _Type>554template <class _Type>
562struct __allocator_has_trivial_copy_construct<allocator<_Type>, _Type> : true_type {};555inline const bool __allocator_has_trivial_copy_construct_v<allocator<_Type>, _Type> = true;
563556
564template <class _Alloc,557template <class _Alloc,
565 class _In,558 class _In,
566 class _Out,559 class _Out,
567 __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value &&560 __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value &&
568 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&561 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
569 __allocator_has_trivial_copy_construct<_Alloc, _In>::value,562 __allocator_has_trivial_copy_construct_v<_Alloc, _In>,
570 int> = 0>563 int> = 0>
571_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*564_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*
572__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {565__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {
...@@ -592,16 +585,16 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1,...@@ -592,16 +585,16 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1,
592}585}
593586
594template <class _Alloc, class _Type>587template <class _Alloc, class _Type>
595struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {};588inline const bool __allocator_has_trivial_move_construct_v = !__has_construct_v<_Alloc, _Type*, _Type&&>;
596589
597template <class _Type>590template <class _Type>
598struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {};591inline const bool __allocator_has_trivial_move_construct_v<allocator<_Type>, _Type> = true;
599592
600template <class _Alloc, class _Tp>593template <class _Alloc, class _Tp>
601struct __allocator_has_trivial_destroy : _Not<__has_destroy<_Alloc, _Tp*> > {};594inline const bool __allocator_has_trivial_destroy_v = !__has_destroy_v<_Alloc, _Tp*>;
602595
603template <class _Tp, class _Up>596template <class _Tp, class _Up>
604struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};597inline const bool __allocator_has_trivial_destroy_v<allocator<_Tp>, _Up> = true;
605598
606// __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result.599// __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result.
607// Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy,600// Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy,
...@@ -620,11 +613,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocat...@@ -620,11 +613,11 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __uninitialized_allocat
620 _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {613 _Alloc& __alloc, _ContiguousIterator __first, _ContiguousIterator __last, _ContiguousIterator __result) {
621 static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, "");614 static_assert(__libcpp_is_contiguous_iterator<_ContiguousIterator>::value, "");
622 using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type;615 using _ValueType = typename iterator_traits<_ContiguousIterator>::value_type;
623 static_assert(__is_cpp17_move_insertable<_Alloc>::value,616 static_assert(
624 "The specified type does not meet the requirements of Cpp17MoveInsertable");617 __is_cpp17_move_insertable_v<_Alloc>, "The specified type does not meet the requirements of Cpp17MoveInsertable");
625 if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value ||618 if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_ValueType>::value ||
626 !__allocator_has_trivial_move_construct<_Alloc, _ValueType>::value ||619 !__allocator_has_trivial_move_construct_v<_Alloc, _ValueType> ||
627 !__allocator_has_trivial_destroy<_Alloc, _ValueType>::value) {620 !__allocator_has_trivial_destroy_v<_Alloc, _ValueType>) {
628 auto __destruct_first = __result;621 auto __destruct_first = __result;
629 auto __guard = std::__make_exception_guard(622 auto __guard = std::__make_exception_guard(
630 _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result));623 _AllocatorDestroyRangeReverse<_Alloc, _ContiguousIterator>(__alloc, __destruct_first, __result));
lib/libcxx/include/__memory/unique_ptr.h+28-36
...@@ -24,7 +24,7 @@...@@ -24,7 +24,7 @@
24#include <__memory/auto_ptr.h>24#include <__memory/auto_ptr.h>
25#include <__memory/compressed_pair.h>25#include <__memory/compressed_pair.h>
26#include <__memory/pointer_traits.h>26#include <__memory/pointer_traits.h>
27#include <__type_traits/add_lvalue_reference.h>27#include <__type_traits/add_reference.h>
28#include <__type_traits/common_type.h>28#include <__type_traits/common_type.h>
29#include <__type_traits/conditional.h>29#include <__type_traits/conditional.h>
30#include <__type_traits/dependent_type.h>30#include <__type_traits/dependent_type.h>
...@@ -39,6 +39,7 @@...@@ -39,6 +39,7 @@
39#include <__type_traits/is_function.h>39#include <__type_traits/is_function.h>
40#include <__type_traits/is_pointer.h>40#include <__type_traits/is_pointer.h>
41#include <__type_traits/is_reference.h>41#include <__type_traits/is_reference.h>
42#include <__type_traits/is_replaceable.h>
42#include <__type_traits/is_same.h>43#include <__type_traits/is_same.h>
43#include <__type_traits/is_swappable.h>44#include <__type_traits/is_swappable.h>
44#include <__type_traits/is_trivially_relocatable.h>45#include <__type_traits/is_trivially_relocatable.h>
...@@ -62,13 +63,11 @@ _LIBCPP_PUSH_MACROS...@@ -62,13 +63,11 @@ _LIBCPP_PUSH_MACROS
62_LIBCPP_BEGIN_NAMESPACE_STD63_LIBCPP_BEGIN_NAMESPACE_STD
6364
64template <class _Tp>65template <class _Tp>
65struct _LIBCPP_TEMPLATE_VIS default_delete {66struct default_delete {
66 static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");67 static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
67#ifndef _LIBCPP_CXX03_LANG68
68 _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;69 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
69#else70
70 _LIBCPP_HIDE_FROM_ABI default_delete() {}
71#endif
72 template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>71 template <class _Up, __enable_if_t<is_convertible<_Up*, _Tp*>::value, int> = 0>
73 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {}72 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up>&) _NOEXCEPT {}
7473
...@@ -80,35 +79,24 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {...@@ -80,35 +79,24 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
80};79};
8180
82template <class _Tp>81template <class _Tp>
83struct _LIBCPP_TEMPLATE_VIS default_delete<_Tp[]> {82struct default_delete<_Tp[]> {
84private:83 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default;
85 template <class _Up>
86 struct _EnableIfConvertible : enable_if<is_convertible<_Up (*)[], _Tp (*)[]>::value> {};
8784
88public:85 template <class _Up, __enable_if_t<is_convertible<_Up (*)[], _Tp (*)[]>::value, int> = 0>
89#ifndef _LIBCPP_CXX03_LANG86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete(const default_delete<_Up[]>&) _NOEXCEPT {}
90 _LIBCPP_HIDE_FROM_ABI constexpr default_delete() _NOEXCEPT = default;
91#else
92 _LIBCPP_HIDE_FROM_ABI default_delete() {}
93#endif
94
95 template <class _Up>
96 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
97 default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {}
9887
99 template <class _Up>88 template <class _Up, __enable_if_t<is_convertible<_Up (*)[], _Tp (*)[]>::value, int> = 0>
100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type89 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Up* __ptr) const _NOEXCEPT {
101 operator()(_Up* __ptr) const _NOEXCEPT {
102 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");90 static_assert(sizeof(_Up) >= 0, "cannot delete an incomplete type");
103 delete[] __ptr;91 delete[] __ptr;
104 }92 }
105};93};
10694
107template <class _Deleter>95template <class _Deleter>
108struct __is_default_deleter : false_type {};96inline const bool __is_default_deleter_v = false;
10997
110template <class _Tp>98template <class _Tp>
111struct __is_default_deleter<default_delete<_Tp> > : true_type {};99inline const bool __is_default_deleter_v<default_delete<_Tp> > = true;
112100
113template <class _Deleter>101template <class _Deleter>
114struct __unique_ptr_deleter_sfinae {102struct __unique_ptr_deleter_sfinae {
...@@ -139,7 +127,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {...@@ -139,7 +127,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
139#endif127#endif
140128
141template <class _Tp, class _Dp = default_delete<_Tp> >129template <class _Tp, class _Dp = default_delete<_Tp> >
142class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr {130class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
143public:131public:
144 typedef _Tp element_type;132 typedef _Tp element_type;
145 typedef _Dp deleter_type;133 typedef _Dp deleter_type;
...@@ -157,6 +145,8 @@ public:...@@ -157,6 +145,8 @@ public:
157 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,145 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
158 unique_ptr,146 unique_ptr,
159 void>;147 void>;
148 using __replaceable _LIBCPP_NODEBUG =
149 __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>;
160150
161private:151private:
162 _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);152 _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
...@@ -313,7 +303,7 @@ public:...@@ -313,7 +303,7 @@ public:
313// We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>.303// We provide some helper classes that allow bounds checking when accessing a unique_ptr<T[]>.
314// There are a few cases where bounds checking can be implemented:304// There are a few cases where bounds checking can be implemented:
315//305//
316// 1. When an array cookie (see [1]) exists at the beginning of the array allocation, we are306// 1. When an array cookie exists at the beginning of the array allocation, we are
317// able to reuse that cookie to extract the size of the array and perform bounds checking.307// able to reuse that cookie to extract the size of the array and perform bounds checking.
318// An array cookie is a size inserted at the beginning of the allocation by the compiler.308// An array cookie is a size inserted at the beginning of the allocation by the compiler.
319// That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this309// That size is inserted implicitly when doing `new T[n]` in some cases (as of writing this
...@@ -355,7 +345,7 @@ struct __unique_ptr_array_bounds_stateless {...@@ -355,7 +345,7 @@ struct __unique_ptr_array_bounds_stateless {
355345
356 template <class _Deleter,346 template <class _Deleter,
357 class _Tp,347 class _Tp,
358 __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>348 __enable_if_t<__is_default_deleter_v<_Deleter> && __has_array_cookie<_Tp>::value, int> = 0>
359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {349 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {
360 // In constant expressions, we can't check the array cookie so we just pretend that the index350 // In constant expressions, we can't check the array cookie so we just pretend that the index
361 // is in-bounds. The compiler catches invalid accesses anyway.351 // is in-bounds. The compiler catches invalid accesses anyway.
...@@ -367,7 +357,7 @@ struct __unique_ptr_array_bounds_stateless {...@@ -367,7 +357,7 @@ struct __unique_ptr_array_bounds_stateless {
367357
368 template <class _Deleter,358 template <class _Deleter,
369 class _Tp,359 class _Tp,
370 __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>360 __enable_if_t<!__is_default_deleter_v<_Deleter> || !__has_array_cookie<_Tp>::value, int> = 0>
371 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const {361 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t) const {
372 return true; // If we don't have an array cookie, we assume the access is in-bounds362 return true; // If we don't have an array cookie, we assume the access is in-bounds
373 }363 }
...@@ -385,7 +375,7 @@ struct __unique_ptr_array_bounds_stored {...@@ -385,7 +375,7 @@ struct __unique_ptr_array_bounds_stored {
385 // Use the array cookie if there's one375 // Use the array cookie if there's one
386 template <class _Deleter,376 template <class _Deleter,
387 class _Tp,377 class _Tp,
388 __enable_if_t<__is_default_deleter<_Deleter>::value && __has_array_cookie<_Tp>::value, int> = 0>378 __enable_if_t<__is_default_deleter_v<_Deleter> && __has_array_cookie<_Tp>::value, int> = 0>
389 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {379 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp* __ptr, size_t __index) const {
390 if (__libcpp_is_constant_evaluated())380 if (__libcpp_is_constant_evaluated())
391 return true;381 return true;
...@@ -396,7 +386,7 @@ struct __unique_ptr_array_bounds_stored {...@@ -396,7 +386,7 @@ struct __unique_ptr_array_bounds_stored {
396 // Otherwise, fall back on the stored size (if any)386 // Otherwise, fall back on the stored size (if any)
397 template <class _Deleter,387 template <class _Deleter,
398 class _Tp,388 class _Tp,
399 __enable_if_t<!__is_default_deleter<_Deleter>::value || !__has_array_cookie<_Tp>::value, int> = 0>389 __enable_if_t<!__is_default_deleter_v<_Deleter> || !__has_array_cookie<_Tp>::value, int> = 0>
400 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const {390 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Tp*, size_t __index) const {
401 return __index < __size_;391 return __index < __size_;
402 }392 }
...@@ -406,7 +396,7 @@ private:...@@ -406,7 +396,7 @@ private:
406};396};
407397
408template <class _Tp, class _Dp>398template <class _Tp, class _Dp>
409class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS unique_ptr<_Tp[], _Dp> {399class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
410public:400public:
411 typedef _Tp element_type;401 typedef _Tp element_type;
412 typedef _Dp deleter_type;402 typedef _Dp deleter_type;
...@@ -423,6 +413,8 @@ public:...@@ -423,6 +413,8 @@ public:
423 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,413 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
424 unique_ptr,414 unique_ptr,
425 void>;415 void>;
416 using __replaceable _LIBCPP_NODEBUG =
417 __conditional_t<__is_replaceable_v<pointer> && __is_replaceable_v<deleter_type>, unique_ptr, void>;
426418
427private:419private:
428 template <class _Up, class _OtherDeleter>420 template <class _Up, class _OtherDeleter>
...@@ -796,13 +788,13 @@ void make_unique_for_overwrite(_Args&&...) = delete;...@@ -796,13 +788,13 @@ void make_unique_for_overwrite(_Args&&...) = delete;
796#endif // _LIBCPP_STD_VER >= 20788#endif // _LIBCPP_STD_VER >= 20
797789
798template <class _Tp>790template <class _Tp>
799struct _LIBCPP_TEMPLATE_VIS hash;791struct hash;
800792
801template <class _Tp, class _Dp>793template <class _Tp, class _Dp>
802#ifdef _LIBCPP_CXX03_LANG794#ifdef _LIBCPP_CXX03_LANG
803struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >795struct hash<unique_ptr<_Tp, _Dp> >
804#else796#else
805struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >797struct hash<__enable_hash_helper< unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
806#endif798#endif
807{799{
808#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)800#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
lib/libcxx/include/__memory/uses_allocator.h+1-1
...@@ -40,7 +40,7 @@ template <class _Tp, class _Alloc>...@@ -40,7 +40,7 @@ template <class _Tp, class _Alloc>
40struct __uses_allocator<_Tp, _Alloc, false> : public false_type {};40struct __uses_allocator<_Tp, _Alloc, false> : public false_type {};
4141
42template <class _Tp, class _Alloc>42template <class _Tp, class _Alloc>
43struct _LIBCPP_TEMPLATE_VIS uses_allocator : public __uses_allocator<_Tp, _Alloc> {};43struct uses_allocator : public __uses_allocator<_Tp, _Alloc> {};
4444
45#if _LIBCPP_STD_VER >= 1745#if _LIBCPP_STD_VER >= 17
46template <class _Tp, class _Alloc>46template <class _Tp, class _Alloc>
lib/libcxx/include/__memory/uses_allocator_construction.h+1-8
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__memory/uses_allocator.h>14#include <__memory/uses_allocator.h>
15#include <__tuple/tuple_like_no_subrange.h>15#include <__tuple/tuple_like_no_subrange.h>
16#include <__type_traits/enable_if.h>16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_same.h>
18#include <__type_traits/remove_cv.h>17#include <__type_traits/remove_cv.h>
19#include <__utility/declval.h>18#include <__utility/declval.h>
20#include <__utility/pair.h>19#include <__utility/pair.h>
...@@ -31,14 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -31,14 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3130
32#if _LIBCPP_STD_VER >= 1731#if _LIBCPP_STD_VER >= 17
3332
34template <class _Type>
35inline constexpr bool __is_std_pair = false;
36
37template <class _Type1, class _Type2>
38inline constexpr bool __is_std_pair<pair<_Type1, _Type2>> = true;
39
40template <class _Tp>33template <class _Tp>
41inline constexpr bool __is_cv_std_pair = __is_std_pair<remove_cv_t<_Tp>>;34inline constexpr bool __is_cv_std_pair = __is_pair_v<remove_cv_t<_Tp>>;
4235
43template <class _Tp, class = void>36template <class _Tp, class = void>
44struct __uses_allocator_construction_args;37struct __uses_allocator_construction_args;
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+2-2
...@@ -41,7 +41,7 @@ template <class _ValueType...@@ -41,7 +41,7 @@ template <class _ValueType
41 = byte41 = byte
42# endif42# endif
43 >43 >
44class _LIBCPP_AVAILABILITY_PMR _LIBCPP_TEMPLATE_VIS polymorphic_allocator {44class _LIBCPP_AVAILABILITY_PMR polymorphic_allocator {
4545
46public:46public:
47 using value_type = _ValueType;47 using value_type = _ValueType;
...@@ -64,7 +64,7 @@ public:...@@ -64,7 +64,7 @@ public:
6464
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {
66 if (__n > __max_size()) {66 if (__n > __max_size()) {
67 __throw_bad_array_new_length();67 std::__throw_bad_array_new_length();
68 }68 }
69 return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)));69 return static_cast<_ValueType*>(__res_->allocate(__n * sizeof(_ValueType), alignof(_ValueType)));
70 }70 }
lib/libcxx/include/__mutex/lock_guard.h+4-6
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Mutex>21template <class _Mutex>
22class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) lock_guard {22class _LIBCPP_SCOPED_LOCKABLE lock_guard {
23public:23public:
24 typedef _Mutex mutex_type;24 typedef _Mutex mutex_type;
2525
...@@ -27,16 +27,14 @@ private:...@@ -27,16 +27,14 @@ private:
27 mutex_type& __m_;27 mutex_type& __m_;
2828
29public:29public:
30 [[__nodiscard__]]30 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_ACQUIRE_CAPABILITY(__m)
31 _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
32 : __m_(__m) {31 : __m_(__m) {
33 __m_.lock();32 __m_.lock();
34 }33 }
3534
36 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t)35 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_REQUIRES_CAPABILITY(__m)
37 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
38 : __m_(__m) {}36 : __m_(__m) {}
39 _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }37 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~lock_guard() { __m_.unlock(); }
4038
41 lock_guard(lock_guard const&) = delete;39 lock_guard(lock_guard const&) = delete;
42 lock_guard& operator=(lock_guard const&) = delete;40 lock_guard& operator=(lock_guard const&) = delete;
lib/libcxx/include/__mutex/mutex.h+4-4
...@@ -21,7 +21,7 @@...@@ -21,7 +21,7 @@
2121
22_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2323
24class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex {24class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("mutex") mutex {
25 __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;25 __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
2626
27public:27public:
...@@ -36,9 +36,9 @@ public:...@@ -36,9 +36,9 @@ public:
36 ~mutex() _NOEXCEPT;36 ~mutex() _NOEXCEPT;
37# endif37# endif
3838
39 void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());39 _LIBCPP_ACQUIRE_CAPABILITY() void lock();
40 bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));40 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock() _NOEXCEPT;
41 void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());41 _LIBCPP_RELEASE_CAPABILITY void unlock() _NOEXCEPT;
4242
43 typedef __libcpp_mutex_t* native_handle_type;43 typedef __libcpp_mutex_t* native_handle_type;
44 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; }44 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; }
lib/libcxx/include/__mutex/once_flag.h+6-5
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__functional/invoke.h>13#include <__functional/invoke.h>
14#include <__memory/addressof.h>
14#include <__memory/shared_count.h> // __libcpp_acquire_load15#include <__memory/shared_count.h> // __libcpp_acquire_load
15#include <__tuple/tuple_indices.h>16#include <__tuple/tuple_indices.h>
16#include <__tuple/tuple_size.h>17#include <__tuple/tuple_size.h>
...@@ -30,7 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,7 +31,7 @@ _LIBCPP_PUSH_MACROS
3031
31_LIBCPP_BEGIN_NAMESPACE_STD32_LIBCPP_BEGIN_NAMESPACE_STD
3233
33struct _LIBCPP_TEMPLATE_VIS once_flag;34struct once_flag;
3435
35#ifndef _LIBCPP_CXX03_LANG36#ifndef _LIBCPP_CXX03_LANG
3637
...@@ -47,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&);...@@ -47,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI void call_once(once_flag&, const _Callable&);
4748
48#endif // _LIBCPP_CXX03_LANG49#endif // _LIBCPP_CXX03_LANG
4950
50struct _LIBCPP_TEMPLATE_VIS once_flag {51struct once_flag {
51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {}52 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR once_flag() _NOEXCEPT : __state_(_Unset) {}
52 once_flag(const once_flag&) = delete;53 once_flag(const once_flag&) = delete;
53 once_flag& operator=(const once_flag&) = delete;54 once_flag& operator=(const once_flag&) = delete;
...@@ -128,7 +129,7 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __fun...@@ -128,7 +129,7 @@ inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable&& __fun
128 typedef tuple<_Callable&&, _Args&&...> _Gp;129 typedef tuple<_Callable&&, _Args&&...> _Gp;
129 _Gp __f(std::forward<_Callable>(__func), std::forward<_Args>(__args)...);130 _Gp __f(std::forward<_Callable>(__func), std::forward<_Args>(__args)...);
130 __call_once_param<_Gp> __p(__f);131 __call_once_param<_Gp> __p(__f);
131 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Gp>);132 std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<_Gp>));
132 }133 }
133}134}
134135
...@@ -138,7 +139,7 @@ template <class _Callable>...@@ -138,7 +139,7 @@ template <class _Callable>
138inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) {139inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, _Callable& __func) {
139 if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {140 if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
140 __call_once_param<_Callable> __p(__func);141 __call_once_param<_Callable> __p(__func);
141 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);142 std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<_Callable>));
142 }143 }
143}144}
144145
...@@ -146,7 +147,7 @@ template <class _Callable>...@@ -146,7 +147,7 @@ template <class _Callable>
146inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) {147inline _LIBCPP_HIDE_FROM_ABI void call_once(once_flag& __flag, const _Callable& __func) {
147 if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {148 if (__libcpp_acquire_load(&__flag.__state_) != once_flag::_Complete) {
148 __call_once_param<const _Callable> __p(__func);149 __call_once_param<const _Callable> __p(__func);
149 std::__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);150 std::__call_once(__flag.__state_, std::addressof(__p), std::addressof(__call_once_proxy<const _Callable>));
150 }151 }
151}152}
152153
lib/libcxx/include/__mutex/unique_lock.h+10-10
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Mutex>27template <class _Mutex>
28class _LIBCPP_TEMPLATE_VIS unique_lock {28class unique_lock {
29public:29public:
30 typedef _Mutex mutex_type;30 typedef _Mutex mutex_type;
3131
...@@ -116,9 +116,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);...@@ -116,9 +116,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
116template <class _Mutex>116template <class _Mutex>
117_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {117_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {
118 if (__m_ == nullptr)118 if (__m_ == nullptr)
119 __throw_system_error(EPERM, "unique_lock::lock: references null mutex");119 std::__throw_system_error(EPERM, "unique_lock::lock: references null mutex");
120 if (__owns_)120 if (__owns_)
121 __throw_system_error(EDEADLK, "unique_lock::lock: already locked");121 std::__throw_system_error(EDEADLK, "unique_lock::lock: already locked");
122 __m_->lock();122 __m_->lock();
123 __owns_ = true;123 __owns_ = true;
124}124}
...@@ -126,9 +126,9 @@ _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {...@@ -126,9 +126,9 @@ _LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::lock() {
126template <class _Mutex>126template <class _Mutex>
127_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() {127_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock() {
128 if (__m_ == nullptr)128 if (__m_ == nullptr)
129 __throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");129 std::__throw_system_error(EPERM, "unique_lock::try_lock: references null mutex");
130 if (__owns_)130 if (__owns_)
131 __throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");131 std::__throw_system_error(EDEADLK, "unique_lock::try_lock: already locked");
132 __owns_ = __m_->try_lock();132 __owns_ = __m_->try_lock();
133 return __owns_;133 return __owns_;
134}134}
...@@ -137,9 +137,9 @@ template <class _Mutex>...@@ -137,9 +137,9 @@ template <class _Mutex>
137template <class _Rep, class _Period>137template <class _Rep, class _Period>
138_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {138_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
139 if (__m_ == nullptr)139 if (__m_ == nullptr)
140 __throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");140 std::__throw_system_error(EPERM, "unique_lock::try_lock_for: references null mutex");
141 if (__owns_)141 if (__owns_)
142 __throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");142 std::__throw_system_error(EDEADLK, "unique_lock::try_lock_for: already locked");
143 __owns_ = __m_->try_lock_for(__d);143 __owns_ = __m_->try_lock_for(__d);
144 return __owns_;144 return __owns_;
145}145}
...@@ -148,9 +148,9 @@ template <class _Mutex>...@@ -148,9 +148,9 @@ template <class _Mutex>
148template <class _Clock, class _Duration>148template <class _Clock, class _Duration>
149_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {149_LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
150 if (__m_ == nullptr)150 if (__m_ == nullptr)
151 __throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");151 std::__throw_system_error(EPERM, "unique_lock::try_lock_until: references null mutex");
152 if (__owns_)152 if (__owns_)
153 __throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");153 std::__throw_system_error(EDEADLK, "unique_lock::try_lock_until: already locked");
154 __owns_ = __m_->try_lock_until(__t);154 __owns_ = __m_->try_lock_until(__t);
155 return __owns_;155 return __owns_;
156}156}
...@@ -158,7 +158,7 @@ _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::tim...@@ -158,7 +158,7 @@ _LIBCPP_HIDE_FROM_ABI bool unique_lock<_Mutex>::try_lock_until(const chrono::tim
158template <class _Mutex>158template <class _Mutex>
159_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() {159_LIBCPP_HIDE_FROM_ABI void unique_lock<_Mutex>::unlock() {
160 if (!__owns_)160 if (!__owns_)
161 __throw_system_error(EPERM, "unique_lock::unlock: not locked");161 std::__throw_system_error(EPERM, "unique_lock::unlock: not locked");
162 __m_->unlock();162 __m_->unlock();
163 __owns_ = false;163 __owns_ = false;
164}164}
lib/libcxx/include/__new/align_val_t.h+2-3
...@@ -16,8 +16,7 @@...@@ -16,8 +16,7 @@
16# pragma GCC system_header16# pragma GCC system_header
17#endif17#endif
1818
19// purposefully not using versioning namespace19_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
20namespace std {
21#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)20#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME)
22# ifndef _LIBCPP_CXX03_LANG21# ifndef _LIBCPP_CXX03_LANG
23enum class align_val_t : size_t {};22enum class align_val_t : size_t {};
...@@ -25,6 +24,6 @@ enum class align_val_t : size_t {};...@@ -25,6 +24,6 @@ enum class align_val_t : size_t {};
25enum align_val_t { __zero = 0, __max = (size_t)-1 };24enum align_val_t { __zero = 0, __max = (size_t)-1 };
26# endif25# endif
27#endif26#endif
28} // namespace std27_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
2928
30#endif // _LIBCPP___NEW_ALIGN_VAL_T_H29#endif // _LIBCPP___NEW_ALIGN_VAL_T_H
lib/libcxx/include/__new/allocate.h+20-51
...@@ -31,37 +31,16 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(siz...@@ -31,37 +31,16 @@ _LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI bool __is_overaligned_for_new(siz
31#endif31#endif
32}32}
3333
34template <class... _Args>
35_LIBCPP_HIDE_FROM_ABI void* __libcpp_operator_new(_Args... __args) {
36#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
37 return __builtin_operator_new(__args...);
38#else
39 return ::operator new(__args...);
40#endif
41}
42
43template <class... _Args>
44_LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) _NOEXCEPT {
45#if __has_builtin(__builtin_operator_new) && __has_builtin(__builtin_operator_delete)
46 __builtin_operator_delete(__args...);
47#else
48 ::operator delete(__args...);
49#endif
50}
51
52template <class _Tp>34template <class _Tp>
53inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*35inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Tp*
54__libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {36__libcpp_allocate(__element_count __n, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
55 size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);37 size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
56#if _LIBCPP_HAS_ALIGNED_ALLOCATION38#if _LIBCPP_HAS_ALIGNED_ALLOCATION
57 if (__is_overaligned_for_new(__align)) {39 if (__is_overaligned_for_new(__align))
58 const align_val_t __align_val = static_cast<align_val_t>(__align);40 return static_cast<_Tp*>(__builtin_operator_new(__size, static_cast<align_val_t>(__align)));
59 return static_cast<_Tp*>(std::__libcpp_operator_new(__size, __align_val));
60 }
61#endif41#endif
6242
63 (void)__align;43 return static_cast<_Tp*>(__builtin_operator_new(__size));
64 return static_cast<_Tp*>(std::__libcpp_operator_new(__size));
65}44}
6645
67#if _LIBCPP_HAS_SIZED_DEALLOCATION46#if _LIBCPP_HAS_SIZED_DEALLOCATION
...@@ -71,39 +50,29 @@ __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {...@@ -71,39 +50,29 @@ __libcpp_allocate(__element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) {
71#endif50#endif
7251
73template <class _Tp>52template <class _Tp>
74inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(53inline _LIBCPP_HIDE_FROM_ABI void
75 __type_identity_t<_Tp>* __ptr, __element_count __n, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {54__libcpp_deallocate(__type_identity_t<_Tp>* __ptr,
76 size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);55 __element_count __n,
77 (void)__size;56 [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
78#if !_LIBCPP_HAS_ALIGNED_ALLOCATION57 [[__maybe_unused__]] size_t __size = static_cast<size_t>(__n) * sizeof(_Tp);
79 (void)__align;58#if _LIBCPP_HAS_ALIGNED_ALLOCATION
80 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));59 if (__is_overaligned_for_new(__align))
81#else60 return __builtin_operator_delete(
82 if (__is_overaligned_for_new(__align)) {61 __ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), static_cast<align_val_t>(__align));
83 const align_val_t __align_val = static_cast<align_val_t>(__align);
84 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size), __align_val);
85 } else {
86 return std::__libcpp_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));
87 }
88#endif62#endif
63 return __builtin_operator_delete(__ptr _LIBCPP_ONLY_IF_SIZED_DEALLOCATION(, __size));
89}64}
9065
91#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION66#undef _LIBCPP_ONLY_IF_SIZED_DEALLOCATION
9267
93template <class _Tp>68template <class _Tp>
94inline _LIBCPP_HIDE_FROM_ABI void69inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(
95__libcpp_deallocate_unsized(__type_identity_t<_Tp>* __ptr, size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {70 __type_identity_t<_Tp>* __ptr, [[__maybe_unused__]] size_t __align = _LIBCPP_ALIGNOF(_Tp)) _NOEXCEPT {
96#if !_LIBCPP_HAS_ALIGNED_ALLOCATION71#if _LIBCPP_HAS_ALIGNED_ALLOCATION
97 (void)__align;72 if (__is_overaligned_for_new(__align))
98 return std::__libcpp_operator_delete(__ptr);73 return __builtin_operator_delete(__ptr, static_cast<align_val_t>(__align));
99#else
100 if (__is_overaligned_for_new(__align)) {
101 const align_val_t __align_val = static_cast<align_val_t>(__align);
102 return std::__libcpp_operator_delete(__ptr, __align_val);
103 } else {
104 return std::__libcpp_operator_delete(__ptr);
105 }
106#endif74#endif
75 return __builtin_operator_delete(__ptr);
107}76}
108_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
10978
lib/libcxx/include/__new/destroying_delete_t.h+2-3
...@@ -16,15 +16,14 @@...@@ -16,15 +16,14 @@
16#endif16#endif
1717
18#if _LIBCPP_STD_VER >= 2018#if _LIBCPP_STD_VER >= 20
19// purposefully not using versioning namespace19_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
20namespace std {
21// Enable the declaration even if the compiler doesn't support the language20// Enable the declaration even if the compiler doesn't support the language
22// feature.21// feature.
23struct destroying_delete_t {22struct destroying_delete_t {
24 explicit destroying_delete_t() = default;23 explicit destroying_delete_t() = default;
25};24};
26inline constexpr destroying_delete_t destroying_delete{};25inline constexpr destroying_delete_t destroying_delete{};
27} // namespace std26_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
28#endif27#endif
2928
30#endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H29#endif // _LIBCPP___NEW_DESTROYING_DELETE_T_H
lib/libcxx/include/__new/exceptions.h+2-3
...@@ -17,8 +17,7 @@...@@ -17,8 +17,7 @@
17# pragma GCC system_header17# pragma GCC system_header
18#endif18#endif
1919
20// purposefully not using versioning namespace20_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
21namespace std {
22#if !defined(_LIBCPP_ABI_VCRUNTIME)21#if !defined(_LIBCPP_ABI_VCRUNTIME)
2322
24class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {23class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
...@@ -69,6 +68,6 @@ public:...@@ -69,6 +68,6 @@ public:
69 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");68 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
70#endif69#endif
71}70}
72} // namespace std71_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
7372
74#endif // _LIBCPP___NEW_EXCEPTIONS_H73#endif // _LIBCPP___NEW_EXCEPTIONS_H
lib/libcxx/include/__new/new_handler.h+2-3
...@@ -18,12 +18,11 @@...@@ -18,12 +18,11 @@
18#if defined(_LIBCPP_ABI_VCRUNTIME)18#if defined(_LIBCPP_ABI_VCRUNTIME)
19# include <new.h>19# include <new.h>
20#else20#else
21// purposefully not using versioning namespace21_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
22namespace std {
23typedef void (*new_handler)();22typedef void (*new_handler)();
24_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;23_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;
25_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;24_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
26} // namespace std25_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
27#endif // _LIBCPP_ABI_VCRUNTIME26#endif // _LIBCPP_ABI_VCRUNTIME
2827
29#endif // _LIBCPP___NEW_NEW_HANDLER_H28#endif // _LIBCPP___NEW_NEW_HANDLER_H
lib/libcxx/include/__new/nothrow_t.h+2-3
...@@ -18,13 +18,12 @@...@@ -18,13 +18,12 @@
18#if defined(_LIBCPP_ABI_VCRUNTIME)18#if defined(_LIBCPP_ABI_VCRUNTIME)
19# include <new.h>19# include <new.h>
20#else20#else
21// purposefully not using versioning namespace21_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
22namespace std {
23struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {22struct _LIBCPP_EXPORTED_FROM_ABI nothrow_t {
24 explicit nothrow_t() = default;23 explicit nothrow_t() = default;
25};24};
26extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;25extern _LIBCPP_EXPORTED_FROM_ABI const nothrow_t nothrow;
27} // namespace std26_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
28#endif // _LIBCPP_ABI_VCRUNTIME27#endif // _LIBCPP_ABI_VCRUNTIME
2928
30#endif // _LIBCPP___NEW_NOTHROW_T_H29#endif // _LIBCPP___NEW_NOTHROW_T_H
lib/libcxx/include/__node_handle+7-6
...@@ -62,6 +62,7 @@ public:...@@ -62,6 +62,7 @@ public:
62#include <__config>62#include <__config>
63#include <__memory/allocator_traits.h>63#include <__memory/allocator_traits.h>
64#include <__memory/pointer_traits.h>64#include <__memory/pointer_traits.h>
65#include <__type_traits/is_specialization.h>
65#include <optional>66#include <optional>
6667
67#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)68#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -80,7 +81,7 @@ template <class _NodeType, class _Alloc>...@@ -80,7 +81,7 @@ template <class _NodeType, class _Alloc>
80struct __generic_container_node_destructor;81struct __generic_container_node_destructor;
8182
82template <class _NodeType, class _Alloc, template <class, class> class _MapOrSetSpecifics>83template <class _NodeType, class _Alloc, template <class, class> class _MapOrSetSpecifics>
83class _LIBCPP_TEMPLATE_VIS __basic_node_handle84class __basic_node_handle
84 : public _MapOrSetSpecifics< _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> {85 : public _MapOrSetSpecifics< _NodeType, __basic_node_handle<_NodeType, _Alloc, _MapOrSetSpecifics>> {
85 template <class _Tp, class _Compare, class _Allocator>86 template <class _Tp, class _Compare, class _Allocator>
86 friend class __tree;87 friend class __tree;
...@@ -175,15 +176,15 @@ struct __set_node_handle_specifics {...@@ -175,15 +176,15 @@ struct __set_node_handle_specifics {
175176
176template <class _NodeType, class _Derived>177template <class _NodeType, class _Derived>
177struct __map_node_handle_specifics {178struct __map_node_handle_specifics {
178 typedef typename _NodeType::__node_value_type::key_type key_type;179 using key_type = __remove_const_t<typename _NodeType::__node_value_type::first_type>;
179 typedef typename _NodeType::__node_value_type::mapped_type mapped_type;180 using mapped_type = typename _NodeType::__node_value_type::second_type;
180181
181 _LIBCPP_HIDE_FROM_ABI key_type& key() const {182 _LIBCPP_HIDE_FROM_ABI key_type& key() const {
182 return static_cast<_Derived const*>(this)->__ptr_->__get_value().__ref().first;183 return const_cast<key_type&>(static_cast<_Derived const*>(this)->__ptr_->__get_value().first);
183 }184 }
184185
185 _LIBCPP_HIDE_FROM_ABI mapped_type& mapped() const {186 _LIBCPP_HIDE_FROM_ABI mapped_type& mapped() const {
186 return static_cast<_Derived const*>(this)->__ptr_->__get_value().__ref().second;187 return static_cast<_Derived const*>(this)->__ptr_->__get_value().second;
187 }188 }
188};189};
189190
...@@ -194,7 +195,7 @@ template <class _NodeType, class _Alloc>...@@ -194,7 +195,7 @@ template <class _NodeType, class _Alloc>
194using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;195using __map_node_handle _LIBCPP_NODEBUG = __basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
195196
196template <class _Iterator, class _NodeType>197template <class _Iterator, class _NodeType>
197struct _LIBCPP_TEMPLATE_VIS __insert_return_type {198struct __insert_return_type {
198 _Iterator position;199 _Iterator position;
199 bool inserted;200 bool inserted;
200 _NodeType node;201 _NodeType node;
lib/libcxx/include/__numeric/gcd_lcm.h+3-2
...@@ -10,15 +10,16 @@...@@ -10,15 +10,16 @@
10#ifndef _LIBCPP___NUMERIC_GCD_LCM_H10#ifndef _LIBCPP___NUMERIC_GCD_LCM_H
11#define _LIBCPP___NUMERIC_GCD_LCM_H11#define _LIBCPP___NUMERIC_GCD_LCM_H
1212
13#include <__algorithm/min.h>
14#include <__assert>13#include <__assert>
15#include <__bit/countr.h>14#include <__bit/countr.h>
16#include <__config>15#include <__config>
16#include <__memory/addressof.h>
17#include <__type_traits/common_type.h>17#include <__type_traits/common_type.h>
18#include <__type_traits/is_integral.h>18#include <__type_traits/is_integral.h>
19#include <__type_traits/is_same.h>19#include <__type_traits/is_same.h>
20#include <__type_traits/is_signed.h>20#include <__type_traits/is_signed.h>
21#include <__type_traits/make_unsigned.h>21#include <__type_traits/make_unsigned.h>
22#include <__type_traits/remove_cv.h>
22#include <limits>23#include <limits>
2324
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -115,7 +116,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {...@@ -115,7 +116,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
115 _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n);116 _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n);
116 _Rp __val2 = __ct_abs<_Rp, _Up>()(__n);117 _Rp __val2 = __ct_abs<_Rp, _Up>()(__n);
117 _Rp __res;118 _Rp __res;
118 [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, &__res);119 [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, std::addressof(__res));
119 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm");120 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm");
120 return __res;121 return __res;
121}122}
lib/libcxx/include/__numeric/ranges_iota.h created+65
...@@ -0,0 +1,65 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___NUMERIC_RANGES_IOTA_H
11#define _LIBCPP___NUMERIC_RANGES_IOTA_H
12
13#include <__algorithm/out_value_result.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__ranges/access.h>
17#include <__ranges/concepts.h>
18#include <__ranges/dangling.h>
19#include <__utility/as_const.h>
20#include <__utility/move.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31#if _LIBCPP_STD_VER >= 23
32namespace ranges {
33template <typename _Out, typename _Tp>
34using iota_result = ranges::out_value_result<_Out, _Tp>;
35
36struct __iota_fn {
37public:
38 template <input_or_output_iterator _Out, sentinel_for<_Out> _Sent, weakly_incrementable _Tp>
39 requires indirectly_writable<_Out, const _Tp&>
40 _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<_Out, _Tp> operator()(_Out __first, _Sent __last, _Tp __value) {
41 while (__first != __last) {
42 *__first = std::as_const(__value);
43 ++__first;
44 ++__value;
45 }
46 return {std::move(__first), std::move(__value)};
47 }
48
49 template <weakly_incrementable _Tp, ranges::output_range<const _Tp&> _Range>
50 _LIBCPP_HIDE_FROM_ABI static constexpr iota_result<ranges::borrowed_iterator_t<_Range>, _Tp>
51 operator()(_Range&& __r, _Tp __value) {
52 return operator()(ranges::begin(__r), ranges::end(__r), std::move(__value));
53 }
54};
55
56inline constexpr auto iota = __iota_fn{};
57} // namespace ranges
58
59#endif // _LIBCPP_STD_VER >= 23
60
61_LIBCPP_END_NAMESPACE_STD
62
63_LIBCPP_POP_MACROS
64
65#endif // _LIBCPP___NUMERIC_RANGES_IOTA_H
lib/libcxx/include/__numeric/saturation_arithmetic.h+19-18
...@@ -11,8 +11,9 @@...@@ -11,8 +11,9 @@
11#define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H11#define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H
1212
13#include <__assert>13#include <__assert>
14#include <__concepts/arithmetic.h>
15#include <__config>14#include <__config>
15#include <__memory/addressof.h>
16#include <__type_traits/integer_traits.h>
16#include <__utility/cmp.h>17#include <__utility/cmp.h>
17#include <limits>18#include <limits>
1819
...@@ -27,12 +28,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -27,12 +28,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2728
28#if _LIBCPP_STD_VER >= 2029#if _LIBCPP_STD_VER >= 20
2930
30template <__libcpp_integer _Tp>31template <__signed_or_unsigned_integer _Tp>
31_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {32_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
32 if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))33 if (_Tp __sum; !__builtin_add_overflow(__x, __y, std::addressof(__sum)))
33 return __sum;34 return __sum;
34 // Handle overflow35 // Handle overflow
35 if constexpr (__libcpp_unsigned_integer<_Tp>) {36 if constexpr (__unsigned_integer<_Tp>) {
36 return std::numeric_limits<_Tp>::max();37 return std::numeric_limits<_Tp>::max();
37 } else {38 } else {
38 // Signed addition overflow39 // Signed addition overflow
...@@ -45,12 +46,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {...@@ -45,12 +46,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
45 }46 }
46}47}
4748
48template <__libcpp_integer _Tp>49template <__signed_or_unsigned_integer _Tp>
49_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {50_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
50 if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))51 if (_Tp __sub; !__builtin_sub_overflow(__x, __y, std::addressof(__sub)))
51 return __sub;52 return __sub;
52 // Handle overflow53 // Handle overflow
53 if constexpr (__libcpp_unsigned_integer<_Tp>) {54 if constexpr (__unsigned_integer<_Tp>) {
54 // Overflows if (x < y)55 // Overflows if (x < y)
55 return std::numeric_limits<_Tp>::min();56 return std::numeric_limits<_Tp>::min();
56 } else {57 } else {
...@@ -64,12 +65,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {...@@ -64,12 +65,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
64 }65 }
65}66}
6667
67template <__libcpp_integer _Tp>68template <__signed_or_unsigned_integer _Tp>
68_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {69_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
69 if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))70 if (_Tp __mul; !__builtin_mul_overflow(__x, __y, std::addressof(__mul)))
70 return __mul;71 return __mul;
71 // Handle overflow72 // Handle overflow
72 if constexpr (__libcpp_unsigned_integer<_Tp>) {73 if constexpr (__unsigned_integer<_Tp>) {
73 return std::numeric_limits<_Tp>::max();74 return std::numeric_limits<_Tp>::max();
74 } else {75 } else {
75 // Signed multiplication overflow76 // Signed multiplication overflow
...@@ -80,10 +81,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {...@@ -80,10 +81,10 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
80 }81 }
81}82}
8283
83template <__libcpp_integer _Tp>84template <__signed_or_unsigned_integer _Tp>
84_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {85_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
85 _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");86 _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
86 if constexpr (__libcpp_unsigned_integer<_Tp>) {87 if constexpr (__unsigned_integer<_Tp>) {
87 return __x / __y;88 return __x / __y;
88 } else {89 } else {
89 // Handle signed division overflow90 // Handle signed division overflow
...@@ -93,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {...@@ -93,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
93 }94 }
94}95}
9596
96template <__libcpp_integer _Rp, __libcpp_integer _Tp>97template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
97_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {98_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
98 // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be99 // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be
99 // optimized out by the compiler.100 // optimized out by the compiler.
...@@ -111,27 +112,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {...@@ -111,27 +112,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
111112
112#if _LIBCPP_STD_VER >= 26113#if _LIBCPP_STD_VER >= 26
113114
114template <__libcpp_integer _Tp>115template <__signed_or_unsigned_integer _Tp>
115_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {116_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
116 return std::__add_sat(__x, __y);117 return std::__add_sat(__x, __y);
117}118}
118119
119template <__libcpp_integer _Tp>120template <__signed_or_unsigned_integer _Tp>
120_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {121_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
121 return std::__sub_sat(__x, __y);122 return std::__sub_sat(__x, __y);
122}123}
123124
124template <__libcpp_integer _Tp>125template <__signed_or_unsigned_integer _Tp>
125_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {126_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
126 return std::__mul_sat(__x, __y);127 return std::__mul_sat(__x, __y);
127}128}
128129
129template <__libcpp_integer _Tp>130template <__signed_or_unsigned_integer _Tp>
130_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {131_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
131 return std::__div_sat(__x, __y);132 return std::__div_sat(__x, __y);
132}133}
133134
134template <__libcpp_integer _Rp, __libcpp_integer _Tp>135template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
135_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {136_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
136 return std::__saturate_cast<_Rp>(__x);137 return std::__saturate_cast<_Rp>(__x);
137}138}
lib/libcxx/include/__ostream/basic_ostream.h+12-9
...@@ -15,6 +15,10 @@...@@ -15,6 +15,10 @@
1515
16# include <__exception/operations.h>16# include <__exception/operations.h>
17# include <__fwd/memory.h>17# include <__fwd/memory.h>
18# include <__iterator/ostreambuf_iterator.h>
19# include <__locale_dir/num.h>
20# include <__locale_dir/pad_and_output.h>
21# include <__memory/addressof.h>
18# include <__memory/unique_ptr.h>22# include <__memory/unique_ptr.h>
19# include <__new/exceptions.h>23# include <__new/exceptions.h>
20# include <__ostream/put_character_sequence.h>24# include <__ostream/put_character_sequence.h>
...@@ -26,7 +30,6 @@...@@ -26,7 +30,6 @@
26# include <__utility/declval.h>30# include <__utility/declval.h>
27# include <bitset>31# include <bitset>
28# include <ios>32# include <ios>
29# include <locale>
30# include <streambuf>33# include <streambuf>
31# include <string_view>34# include <string_view>
3235
...@@ -40,7 +43,7 @@ _LIBCPP_PUSH_MACROS...@@ -40,7 +43,7 @@ _LIBCPP_PUSH_MACROS
40_LIBCPP_BEGIN_NAMESPACE_STD43_LIBCPP_BEGIN_NAMESPACE_STD
4144
42template <class _CharT, class _Traits>45template <class _CharT, class _Traits>
43class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> {46class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
44public:47public:
45 // types (inherited from basic_ios (27.5.4)):48 // types (inherited from basic_ios (27.5.4)):
46 typedef _CharT char_type;49 typedef _CharT char_type;
...@@ -70,7 +73,7 @@ protected:...@@ -70,7 +73,7 @@ protected:
7073
71public:74public:
72 // 27.7.2.4 Prefix/suffix:75 // 27.7.2.4 Prefix/suffix:
73 class _LIBCPP_TEMPLATE_VIS sentry;76 class sentry;
7477
75 // 27.7.2.6 Formatted output:78 // 27.7.2.6 Formatted output:
76 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) {79 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) {
...@@ -180,7 +183,7 @@ protected:...@@ -180,7 +183,7 @@ protected:
180};183};
181184
182template <class _CharT, class _Traits>185template <class _CharT, class _Traits>
183class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry {186class basic_ostream<_CharT, _Traits>::sentry {
184 bool __ok_;187 bool __ok_;
185 basic_ostream<_CharT, _Traits>& __os_;188 basic_ostream<_CharT, _Traits>& __os_;
186189
...@@ -339,7 +342,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const...@@ -339,7 +342,7 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const
339342
340template <class _CharT, class _Traits>343template <class _CharT, class _Traits>
341_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {344_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
342 return std::__put_character_sequence(__os, &__c, 1);345 return std::__put_character_sequence(__os, std::addressof(__c), 1);
343}346}
344347
345template <class _CharT, class _Traits>348template <class _CharT, class _Traits>
...@@ -353,9 +356,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_...@@ -353,9 +356,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
353 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;356 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
354 if (std::__pad_and_output(357 if (std::__pad_and_output(
355 _Ip(__os),358 _Ip(__os),
356 &__c,359 std::addressof(__c),
357 (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c,360 std::addressof(__c) + (((__os.flags() & ios_base::adjustfield) == ios_base::left) ? 1 : 0),
358 &__c + 1,361 std::addressof(__c) + 1,
359 __os,362 __os,
360 __os.fill())363 __os.fill())
361 .failed())364 .failed())
...@@ -407,7 +410,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {...@@ -407,7 +410,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
407 if (__len > __bs) {410 if (__len > __bs) {
408 __wb = (_CharT*)malloc(__len * sizeof(_CharT));411 __wb = (_CharT*)malloc(__len * sizeof(_CharT));
409 if (__wb == 0)412 if (__wb == 0)
410 __throw_bad_alloc();413 std::__throw_bad_alloc();
411 __h.reset(__wb);414 __h.reset(__wb);
412 }415 }
413 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)416 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
lib/libcxx/include/__ostream/print.h+3-13
...@@ -18,8 +18,8 @@...@@ -18,8 +18,8 @@
18# include <__ostream/basic_ostream.h>18# include <__ostream/basic_ostream.h>
19# include <format>19# include <format>
20# include <ios>20# include <ios>
21# include <locale>
22# include <print>21# include <print>
22# include <streambuf>
2323
24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)24# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header25# pragma GCC system_header
...@@ -49,21 +49,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _...@@ -49,21 +49,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _
49 if (__write_nl)49 if (__write_nl)
50 __o += '\n';50 __o += '\n';
5151
52 const char* __str = __o.data();
53 size_t __len = __o.size();
54
55# if _LIBCPP_HAS_EXCEPTIONS52# if _LIBCPP_HAS_EXCEPTIONS
56 try {53 try {
57# endif // _LIBCPP_HAS_EXCEPTIONS54# endif // _LIBCPP_HAS_EXCEPTIONS
58 typedef ostreambuf_iterator<char> _Ip;55 if (auto __rdbuf = __os.rdbuf();
59 if (std::__pad_and_output(56 !__rdbuf || __rdbuf->sputn(__o.data(), __o.size()) != static_cast<streamsize>(__o.size()))
60 _Ip(__os),
61 __str,
62 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
63 __str + __len,
64 __os,
65 __os.fill())
66 .failed())
67 __os.setstate(ios_base::badbit | ios_base::failbit);57 __os.setstate(ios_base::badbit | ios_base::failbit);
6858
69# if _LIBCPP_HAS_EXCEPTIONS59# if _LIBCPP_HAS_EXCEPTIONS
lib/libcxx/include/__pstl/backends/libdispatch.h+1
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__iterator/move_iterator.h>22#include <__iterator/move_iterator.h>
23#include <__memory/allocator.h>23#include <__memory/allocator.h>
24#include <__memory/construct_at.h>24#include <__memory/construct_at.h>
25#include <__memory/destroy.h>
25#include <__memory/unique_ptr.h>26#include <__memory/unique_ptr.h>
26#include <__new/exceptions.h>27#include <__new/exceptions.h>
27#include <__numeric/reduce.h>28#include <__numeric/reduce.h>
lib/libcxx/include/__random/bernoulli_distribution.h+2-2
...@@ -23,12 +23,12 @@ _LIBCPP_PUSH_MACROS...@@ -23,12 +23,12 @@ _LIBCPP_PUSH_MACROS
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26class _LIBCPP_TEMPLATE_VIS bernoulli_distribution {26class bernoulli_distribution {
27public:27public:
28 // types28 // types
29 typedef bool result_type;29 typedef bool result_type;
3030
31 class _LIBCPP_TEMPLATE_VIS param_type {31 class param_type {
32 double __p_;32 double __p_;
3333
34 public:34 public:
lib/libcxx/include/__random/binomial_distribution.h+2-2
...@@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS...@@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _IntType = int>27template <class _IntType = int>
28class _LIBCPP_TEMPLATE_VIS binomial_distribution {28class binomial_distribution {
29 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");29 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
3030
31public:31public:
32 // types32 // types
33 typedef _IntType result_type;33 typedef _IntType result_type;
3434
35 class _LIBCPP_TEMPLATE_VIS param_type {35 class param_type {
36 result_type __t_;36 result_type __t_;
37 double __p_;37 double __p_;
38 double __pr_;38 double __pr_;
lib/libcxx/include/__random/cauchy_distribution.h+2-2
...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _RealType = double>28template <class _RealType = double>
29class _LIBCPP_TEMPLATE_VIS cauchy_distribution {29class cauchy_distribution {
30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
31 "RealType must be a supported floating-point type");31 "RealType must be a supported floating-point type");
3232
...@@ -34,7 +34,7 @@ public:...@@ -34,7 +34,7 @@ public:
34 // types34 // types
35 typedef _RealType result_type;35 typedef _RealType result_type;
3636
37 class _LIBCPP_TEMPLATE_VIS param_type {37 class param_type {
38 result_type __a_;38 result_type __a_;
39 result_type __b_;39 result_type __b_;
4040
lib/libcxx/include/__random/chi_squared_distribution.h+2-2
...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _RealType = double>27template <class _RealType = double>
28class _LIBCPP_TEMPLATE_VIS chi_squared_distribution {28class chi_squared_distribution {
29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
30 "RealType must be a supported floating-point type");30 "RealType must be a supported floating-point type");
3131
...@@ -33,7 +33,7 @@ public:...@@ -33,7 +33,7 @@ public:
33 // types33 // types
34 typedef _RealType result_type;34 typedef _RealType result_type;
3535
36 class _LIBCPP_TEMPLATE_VIS param_type {36 class param_type {
37 result_type __n_;37 result_type __n_;
3838
39 public:39 public:
lib/libcxx/include/__random/clamp_to_integral.h+1-1
...@@ -43,7 +43,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float(...@@ -43,7 +43,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float(
43template <class _IntT, class _RealT>43template <class _IntT, class _RealT>
44_LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {44_LIBCPP_HIDE_FROM_ABI _IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
45 using _Lim = numeric_limits<_IntT>;45 using _Lim = numeric_limits<_IntT>;
46 const _IntT __max_val = __max_representable_int_for_float<_IntT, _RealT>();46 const _IntT __max_val = std::__max_representable_int_for_float<_IntT, _RealT>();
47 if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) {47 if (__r >= ::nextafter(static_cast<_RealT>(__max_val), INFINITY)) {
48 return _Lim::max();48 return _Lim::max();
49 } else if (__r <= _Lim::lowest()) {49 } else if (__r <= _Lim::lowest()) {
lib/libcxx/include/__random/discard_block_engine.h+1-1
...@@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS...@@ -28,7 +28,7 @@ _LIBCPP_PUSH_MACROS
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _Engine, size_t __p, size_t __r>30template <class _Engine, size_t __p, size_t __r>
31class _LIBCPP_TEMPLATE_VIS discard_block_engine {31class discard_block_engine {
32 _Engine __e_;32 _Engine __e_;
33 int __n_;33 int __n_;
3434
lib/libcxx/include/__random/discrete_distribution.h+2-2
...@@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS...@@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _IntType = int>30template <class _IntType = int>
31class _LIBCPP_TEMPLATE_VIS discrete_distribution {31class discrete_distribution {
32 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");32 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
3333
34public:34public:
35 // types35 // types
36 typedef _IntType result_type;36 typedef _IntType result_type;
3737
38 class _LIBCPP_TEMPLATE_VIS param_type {38 class param_type {
39 vector<double> __p_;39 vector<double> __p_;
4040
41 public:41 public:
lib/libcxx/include/__random/exponential_distribution.h+2-2
...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29template <class _RealType = double>29template <class _RealType = double>
30class _LIBCPP_TEMPLATE_VIS exponential_distribution {30class exponential_distribution {
31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
32 "RealType must be a supported floating-point type");32 "RealType must be a supported floating-point type");
3333
...@@ -35,7 +35,7 @@ public:...@@ -35,7 +35,7 @@ public:
35 // types35 // types
36 typedef _RealType result_type;36 typedef _RealType result_type;
3737
38 class _LIBCPP_TEMPLATE_VIS param_type {38 class param_type {
39 result_type __lambda_;39 result_type __lambda_;
4040
41 public:41 public:
lib/libcxx/include/__random/extreme_value_distribution.h+2-2
...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _RealType = double>28template <class _RealType = double>
29class _LIBCPP_TEMPLATE_VIS extreme_value_distribution {29class extreme_value_distribution {
30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
31 "RealType must be a supported floating-point type");31 "RealType must be a supported floating-point type");
3232
...@@ -34,7 +34,7 @@ public:...@@ -34,7 +34,7 @@ public:
34 // types34 // types
35 typedef _RealType result_type;35 typedef _RealType result_type;
3636
37 class _LIBCPP_TEMPLATE_VIS param_type {37 class param_type {
38 result_type __a_;38 result_type __a_;
39 result_type __b_;39 result_type __b_;
4040
lib/libcxx/include/__random/fisher_f_distribution.h+2-2
...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _RealType = double>27template <class _RealType = double>
28class _LIBCPP_TEMPLATE_VIS fisher_f_distribution {28class fisher_f_distribution {
29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
30 "RealType must be a supported floating-point type");30 "RealType must be a supported floating-point type");
3131
...@@ -33,7 +33,7 @@ public:...@@ -33,7 +33,7 @@ public:
33 // types33 // types
34 typedef _RealType result_type;34 typedef _RealType result_type;
3535
36 class _LIBCPP_TEMPLATE_VIS param_type {36 class param_type {
37 result_type __m_;37 result_type __m_;
38 result_type __n_;38 result_type __n_;
3939
lib/libcxx/include/__random/gamma_distribution.h+2-2
...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29template <class _RealType = double>29template <class _RealType = double>
30class _LIBCPP_TEMPLATE_VIS gamma_distribution {30class gamma_distribution {
31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
32 "RealType must be a supported floating-point type");32 "RealType must be a supported floating-point type");
3333
...@@ -35,7 +35,7 @@ public:...@@ -35,7 +35,7 @@ public:
35 // types35 // types
36 typedef _RealType result_type;36 typedef _RealType result_type;
3737
38 class _LIBCPP_TEMPLATE_VIS param_type {38 class param_type {
39 result_type __alpha_;39 result_type __alpha_;
40 result_type __beta_;40 result_type __beta_;
4141
lib/libcxx/include/__random/geometric_distribution.h+2-2
...@@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS...@@ -25,14 +25,14 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _IntType = int>27template <class _IntType = int>
28class _LIBCPP_TEMPLATE_VIS geometric_distribution {28class geometric_distribution {
29 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");29 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
3030
31public:31public:
32 // types32 // types
33 typedef _IntType result_type;33 typedef _IntType result_type;
3434
35 class _LIBCPP_TEMPLATE_VIS param_type {35 class param_type {
36 double __p_;36 double __p_;
3737
38 public:38 public:
lib/libcxx/include/__random/independent_bits_engine.h+1-1
...@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS...@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33template <class _Engine, size_t __w, class _UIntType>33template <class _Engine, size_t __w, class _UIntType>
34class _LIBCPP_TEMPLATE_VIS independent_bits_engine {34class independent_bits_engine {
35 template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp>35 template <class _UInt, _UInt _R0, size_t _Wp, size_t _Mp>
36 class __get_n {36 class __get_n {
37 static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits;37 static _LIBCPP_CONSTEXPR const size_t _Dt = numeric_limits<_UInt>::digits;
lib/libcxx/include/__random/linear_congruential_engine.h+2-2
...@@ -220,7 +220,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> {...@@ -220,7 +220,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> {
220};220};
221221
222template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>222template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
223class _LIBCPP_TEMPLATE_VIS linear_congruential_engine;223class linear_congruential_engine;
224224
225template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np>225template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np>
226_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&226_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
...@@ -231,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&...@@ -231,7 +231,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
231operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);231operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
232232
233template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>233template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
234class _LIBCPP_TEMPLATE_VIS linear_congruential_engine {234class linear_congruential_engine {
235public:235public:
236 // types236 // types
237 typedef _UIntType result_type;237 typedef _UIntType result_type;
lib/libcxx/include/__random/lognormal_distribution.h+2-2
...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _RealType = double>28template <class _RealType = double>
29class _LIBCPP_TEMPLATE_VIS lognormal_distribution {29class lognormal_distribution {
30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
31 "RealType must be a supported floating-point type");31 "RealType must be a supported floating-point type");
3232
...@@ -34,7 +34,7 @@ public:...@@ -34,7 +34,7 @@ public:
34 // types34 // types
35 typedef _RealType result_type;35 typedef _RealType result_type;
3636
37 class _LIBCPP_TEMPLATE_VIS param_type {37 class param_type {
38 result_type __m_;38 result_type __m_;
39 result_type __s_;39 result_type __s_;
4040
lib/libcxx/include/__random/mersenne_twister_engine.h+2-2
...@@ -42,7 +42,7 @@ template <class _UIntType,...@@ -42,7 +42,7 @@ template <class _UIntType,
42 _UIntType __c,42 _UIntType __c,
43 size_t __l,43 size_t __l,
44 _UIntType __f>44 _UIntType __f>
45class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine;45class mersenne_twister_engine;
4646
47template <class _UInt,47template <class _UInt,
48 size_t _Wp,48 size_t _Wp,
...@@ -134,7 +134,7 @@ template <class _UIntType,...@@ -134,7 +134,7 @@ template <class _UIntType,
134 _UIntType __c,134 _UIntType __c,
135 size_t __l,135 size_t __l,
136 _UIntType __f>136 _UIntType __f>
137class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {137class mersenne_twister_engine {
138public:138public:
139 // types139 // types
140 typedef _UIntType result_type;140 typedef _UIntType result_type;
lib/libcxx/include/__random/negative_binomial_distribution.h+2-2
...@@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS...@@ -28,14 +28,14 @@ _LIBCPP_PUSH_MACROS
28_LIBCPP_BEGIN_NAMESPACE_STD28_LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _IntType = int>30template <class _IntType = int>
31class _LIBCPP_TEMPLATE_VIS negative_binomial_distribution {31class negative_binomial_distribution {
32 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");32 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
3333
34public:34public:
35 // types35 // types
36 typedef _IntType result_type;36 typedef _IntType result_type;
3737
38 class _LIBCPP_TEMPLATE_VIS param_type {38 class param_type {
39 result_type __k_;39 result_type __k_;
40 double __p_;40 double __p_;
4141
lib/libcxx/include/__random/normal_distribution.h+2-2
...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _RealType = double>28template <class _RealType = double>
29class _LIBCPP_TEMPLATE_VIS normal_distribution {29class normal_distribution {
30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
31 "RealType must be a supported floating-point type");31 "RealType must be a supported floating-point type");
3232
...@@ -34,7 +34,7 @@ public:...@@ -34,7 +34,7 @@ public:
34 // types34 // types
35 typedef _RealType result_type;35 typedef _RealType result_type;
3636
37 class _LIBCPP_TEMPLATE_VIS param_type {37 class param_type {
38 result_type __mean_;38 result_type __mean_;
39 result_type __stddev_;39 result_type __stddev_;
4040
lib/libcxx/include/__random/piecewise_constant_distribution.h+2-2
...@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS...@@ -29,7 +29,7 @@ _LIBCPP_PUSH_MACROS
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _RealType = double>31template <class _RealType = double>
32class _LIBCPP_TEMPLATE_VIS piecewise_constant_distribution {32class piecewise_constant_distribution {
33 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,33 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
34 "RealType must be a supported floating-point type");34 "RealType must be a supported floating-point type");
3535
...@@ -37,7 +37,7 @@ public:...@@ -37,7 +37,7 @@ public:
37 // types37 // types
38 typedef _RealType result_type;38 typedef _RealType result_type;
3939
40 class _LIBCPP_TEMPLATE_VIS param_type {40 class param_type {
41 vector<result_type> __b_;41 vector<result_type> __b_;
42 vector<result_type> __densities_;42 vector<result_type> __densities_;
43 vector<result_type> __areas_;43 vector<result_type> __areas_;
lib/libcxx/include/__random/piecewise_linear_distribution.h+2-2
...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32template <class _RealType = double>32template <class _RealType = double>
33class _LIBCPP_TEMPLATE_VIS piecewise_linear_distribution {33class piecewise_linear_distribution {
34 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,34 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
35 "RealType must be a supported floating-point type");35 "RealType must be a supported floating-point type");
3636
...@@ -38,7 +38,7 @@ public:...@@ -38,7 +38,7 @@ public:
38 // types38 // types
39 typedef _RealType result_type;39 typedef _RealType result_type;
4040
41 class _LIBCPP_TEMPLATE_VIS param_type {41 class param_type {
42 vector<result_type> __b_;42 vector<result_type> __b_;
43 vector<result_type> __densities_;43 vector<result_type> __densities_;
44 vector<result_type> __areas_;44 vector<result_type> __areas_;
lib/libcxx/include/__random/poisson_distribution.h+2-2
...@@ -29,14 +29,14 @@ _LIBCPP_PUSH_MACROS...@@ -29,14 +29,14 @@ _LIBCPP_PUSH_MACROS
29_LIBCPP_BEGIN_NAMESPACE_STD29_LIBCPP_BEGIN_NAMESPACE_STD
3030
31template <class _IntType = int>31template <class _IntType = int>
32class _LIBCPP_TEMPLATE_VIS poisson_distribution {32class poisson_distribution {
33 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");33 static_assert(__libcpp_random_is_valid_inttype<_IntType>::value, "IntType must be a supported integer type");
3434
35public:35public:
36 // types36 // types
37 typedef _IntType result_type;37 typedef _IntType result_type;
3838
39 class _LIBCPP_TEMPLATE_VIS param_type {39 class param_type {
40 double __mean_;40 double __mean_;
41 double __s_;41 double __s_;
42 double __d_;42 double __d_;
lib/libcxx/include/__random/seed_seq.h+1-1
...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS
3030
31_LIBCPP_BEGIN_NAMESPACE_STD31_LIBCPP_BEGIN_NAMESPACE_STD
3232
33class _LIBCPP_TEMPLATE_VIS seed_seq {33class seed_seq {
34public:34public:
35 // types35 // types
36 typedef uint32_t result_type;36 typedef uint32_t result_type;
lib/libcxx/include/__random/shuffle_order_engine.h+1-1
...@@ -52,7 +52,7 @@ public:...@@ -52,7 +52,7 @@ public:
52};52};
5353
54template <class _Engine, size_t __k>54template <class _Engine, size_t __k>
55class _LIBCPP_TEMPLATE_VIS shuffle_order_engine {55class shuffle_order_engine {
56 static_assert(0 < __k, "shuffle_order_engine invalid parameters");56 static_assert(0 < __k, "shuffle_order_engine invalid parameters");
5757
58public:58public:
lib/libcxx/include/__random/student_t_distribution.h+2-2
...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS...@@ -27,7 +27,7 @@ _LIBCPP_PUSH_MACROS
27_LIBCPP_BEGIN_NAMESPACE_STD27_LIBCPP_BEGIN_NAMESPACE_STD
2828
29template <class _RealType = double>29template <class _RealType = double>
30class _LIBCPP_TEMPLATE_VIS student_t_distribution {30class student_t_distribution {
31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,31 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
32 "RealType must be a supported floating-point type");32 "RealType must be a supported floating-point type");
3333
...@@ -35,7 +35,7 @@ public:...@@ -35,7 +35,7 @@ public:
35 // types35 // types
36 typedef _RealType result_type;36 typedef _RealType result_type;
3737
38 class _LIBCPP_TEMPLATE_VIS param_type {38 class param_type {
39 result_type __n_;39 result_type __n_;
4040
41 public:41 public:
lib/libcxx/include/__random/subtract_with_carry_engine.h+2-2
...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS...@@ -30,7 +30,7 @@ _LIBCPP_PUSH_MACROS
30_LIBCPP_BEGIN_NAMESPACE_STD30_LIBCPP_BEGIN_NAMESPACE_STD
3131
32template <class _UIntType, size_t __w, size_t __s, size_t __r>32template <class _UIntType, size_t __w, size_t __s, size_t __r>
33class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine;33class subtract_with_carry_engine;
3434
35template <class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>35template <class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
36_LIBCPP_HIDE_FROM_ABI bool operator==(const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,36_LIBCPP_HIDE_FROM_ABI bool operator==(const subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x,
...@@ -49,7 +49,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&...@@ -49,7 +49,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
49operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);49operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
5050
51template <class _UIntType, size_t __w, size_t __s, size_t __r>51template <class _UIntType, size_t __w, size_t __s, size_t __r>
52class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine {52class subtract_with_carry_engine {
53public:53public:
54 // types54 // types
55 typedef _UIntType result_type;55 typedef _UIntType result_type;
lib/libcxx/include/__random/uniform_real_distribution.h+2-2
...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS...@@ -25,7 +25,7 @@ _LIBCPP_PUSH_MACROS
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _RealType = double>27template <class _RealType = double>
28class _LIBCPP_TEMPLATE_VIS uniform_real_distribution {28class uniform_real_distribution {
29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,29 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
30 "RealType must be a supported floating-point type");30 "RealType must be a supported floating-point type");
3131
...@@ -33,7 +33,7 @@ public:...@@ -33,7 +33,7 @@ public:
33 // types33 // types
34 typedef _RealType result_type;34 typedef _RealType result_type;
3535
36 class _LIBCPP_TEMPLATE_VIS param_type {36 class param_type {
37 result_type __a_;37 result_type __a_;
38 result_type __b_;38 result_type __b_;
3939
lib/libcxx/include/__random/weibull_distribution.h+2-2
...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS...@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _RealType = double>28template <class _RealType = double>
29class _LIBCPP_TEMPLATE_VIS weibull_distribution {29class weibull_distribution {
30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,30 static_assert(__libcpp_random_is_valid_realtype<_RealType>::value,
31 "RealType must be a supported floating-point type");31 "RealType must be a supported floating-point type");
3232
...@@ -34,7 +34,7 @@ public:...@@ -34,7 +34,7 @@ public:
34 // types34 // types
35 typedef _RealType result_type;35 typedef _RealType result_type;
3636
37 class _LIBCPP_TEMPLATE_VIS param_type {37 class param_type {
38 result_type __a_;38 result_type __a_;
39 result_type __b_;39 result_type __b_;
4040
lib/libcxx/include/__ranges/concepts.h+40
...@@ -10,7 +10,9 @@...@@ -10,7 +10,9 @@
10#ifndef _LIBCPP___RANGES_CONCEPTS_H10#ifndef _LIBCPP___RANGES_CONCEPTS_H
11#define _LIBCPP___RANGES_CONCEPTS_H11#define _LIBCPP___RANGES_CONCEPTS_H
1212
13#include <__concepts/common_reference_with.h>
13#include <__concepts/constructible.h>14#include <__concepts/constructible.h>
15#include <__concepts/convertible_to.h>
14#include <__concepts/movable.h>16#include <__concepts/movable.h>
15#include <__concepts/same_as.h>17#include <__concepts/same_as.h>
16#include <__config>18#include <__config>
...@@ -25,6 +27,8 @@...@@ -25,6 +27,8 @@
25#include <__ranges/enable_view.h>27#include <__ranges/enable_view.h>
26#include <__ranges/size.h>28#include <__ranges/size.h>
27#include <__type_traits/add_pointer.h>29#include <__type_traits/add_pointer.h>
30#include <__type_traits/common_reference.h>
31#include <__type_traits/common_type.h>
28#include <__type_traits/is_reference.h>32#include <__type_traits/is_reference.h>
29#include <__type_traits/remove_cvref.h>33#include <__type_traits/remove_cvref.h>
30#include <__type_traits/remove_reference.h>34#include <__type_traits/remove_reference.h>
...@@ -133,6 +137,42 @@ concept viewable_range =...@@ -133,6 +137,42 @@ concept viewable_range =
133 (is_lvalue_reference_v<_Tp> ||137 (is_lvalue_reference_v<_Tp> ||
134 (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>))));138 (movable<remove_reference_t<_Tp>> && !__is_std_initializer_list<remove_cvref_t<_Tp>>))));
135139
140# if _LIBCPP_STD_VER >= 23
141
142template <class... _Rs>
143using __concat_reference_t _LIBCPP_NODEBUG = common_reference_t<range_reference_t<_Rs>...>;
144
145template <class... _Rs>
146using __concat_value_t _LIBCPP_NODEBUG = common_type_t<range_value_t<_Rs>...>;
147
148template <class... _Rs>
149using __concat_rvalue_reference_t _LIBCPP_NODEBUG = common_reference_t<range_rvalue_reference_t<_Rs>...>;
150
151template <class _Ref, class _RRef, class _It>
152concept __concat_indirectly_readable_impl = requires(const _It __it) {
153 { *__it } -> convertible_to<_Ref>;
154 { ranges::iter_move(__it) } -> convertible_to<_RRef>;
155};
156
157template <class... _Rs>
158concept __concat_indirectly_readable =
159 common_reference_with<__concat_reference_t<_Rs...>&&, __concat_value_t<_Rs...>&> &&
160 common_reference_with<__concat_reference_t<_Rs...>&&, __concat_rvalue_reference_t<_Rs...>&&> &&
161 common_reference_with<__concat_rvalue_reference_t<_Rs...>&&, const __concat_value_t<_Rs...>&> &&
162 (__concat_indirectly_readable_impl<__concat_reference_t<_Rs...>,
163 __concat_rvalue_reference_t<_Rs...>,
164 iterator_t<_Rs>> &&
165 ...);
166
167template <class... _Rs>
168concept __concatable = requires {
169 typename __concat_reference_t<_Rs...>;
170 typename __concat_value_t<_Rs...>;
171 typename __concat_rvalue_reference_t<_Rs...>;
172} && __concat_indirectly_readable<_Rs...>;
173
174# endif // _LIBCPP_STD_VER >= 23
175
136} // namespace ranges176} // namespace ranges
137177
138#endif // _LIBCPP_STD_VER >= 20178#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__ranges/drop_view.h+4-4
...@@ -185,22 +185,22 @@ struct __passthrough_type;...@@ -185,22 +185,22 @@ struct __passthrough_type;
185185
186template <class _Tp, size_t _Extent>186template <class _Tp, size_t _Extent>
187struct __passthrough_type<span<_Tp, _Extent>> {187struct __passthrough_type<span<_Tp, _Extent>> {
188 using type = span<_Tp>;188 using type _LIBCPP_NODEBUG = span<_Tp>;
189};189};
190190
191template <class _CharT, class _Traits>191template <class _CharT, class _Traits>
192struct __passthrough_type<basic_string_view<_CharT, _Traits>> {192struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
193 using type = basic_string_view<_CharT, _Traits>;193 using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>;
194};194};
195195
196template <class _Np, class _Bound>196template <class _Np, class _Bound>
197struct __passthrough_type<iota_view<_Np, _Bound>> {197struct __passthrough_type<iota_view<_Np, _Bound>> {
198 using type = iota_view<_Np, _Bound>;198 using type _LIBCPP_NODEBUG = iota_view<_Np, _Bound>;
199};199};
200200
201template <class _Iter, class _Sent, subrange_kind _Kind>201template <class _Iter, class _Sent, subrange_kind _Kind>
202struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {202struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
203 using type = subrange<_Iter, _Sent, _Kind>;203 using type _LIBCPP_NODEBUG = subrange<_Iter, _Sent, _Kind>;
204};204};
205205
206template <class _Tp>206template <class _Tp>
lib/libcxx/include/__ranges/elements_view.h+1-1
...@@ -197,7 +197,7 @@ class elements_view<_View, _Np>::__iterator...@@ -197,7 +197,7 @@ class elements_view<_View, _Np>::__iterator
197 }197 }
198198
199public:199public:
200 using iterator_concept = decltype(__get_iterator_concept());200 using iterator_concept = decltype(__iterator::__get_iterator_concept());
201 using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>;201 using value_type = remove_cvref_t<tuple_element_t<_Np, range_value_t<_Base>>>;
202 using difference_type = range_difference_t<_Base>;202 using difference_type = range_difference_t<_Base>;
203203
lib/libcxx/include/__ranges/enable_view.h+3-4
...@@ -14,7 +14,6 @@...@@ -14,7 +14,6 @@
14#include <__concepts/same_as.h>14#include <__concepts/same_as.h>
15#include <__config>15#include <__config>
16#include <__type_traits/is_class.h>16#include <__type_traits/is_class.h>
17#include <__type_traits/is_convertible.h>
18#include <__type_traits/remove_cv.h>17#include <__type_traits/remove_cv.h>
1918
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -34,12 +33,12 @@ template <class _Derived>...@@ -34,12 +33,12 @@ template <class _Derived>
34class view_interface;33class view_interface;
3534
36template <class _Op, class _Yp>35template <class _Op, class _Yp>
37 requires is_convertible_v<_Op*, view_interface<_Yp>*>36 requires(!same_as<_Op, view_interface<_Yp>>)
38void __is_derived_from_view_interface(const _Op*, const view_interface<_Yp>*);37void __is_derived_from_view_interface(view_interface<_Yp>*);
3938
40template <class _Tp>39template <class _Tp>
41inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires {40inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires {
42 ranges::__is_derived_from_view_interface((_Tp*)nullptr, (_Tp*)nullptr);41 ranges::__is_derived_from_view_interface<remove_cv_t<_Tp>>((remove_cv_t<_Tp>*)nullptr);
43};42};
4443
45} // namespace ranges44} // namespace ranges
lib/libcxx/include/__ranges/join_with_view.h created+460
...@@ -0,0 +1,460 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___RANGES_JOIN_WITH_VIEW_H
11#define _LIBCPP___RANGES_JOIN_WITH_VIEW_H
12
13#include <__concepts/common_reference_with.h>
14#include <__concepts/common_with.h>
15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>
17#include <__concepts/derived_from.h>
18#include <__concepts/equality_comparable.h>
19#include <__config>
20#include <__functional/bind_back.h>
21#include <__iterator/concepts.h>
22#include <__iterator/incrementable_traits.h>
23#include <__iterator/iter_move.h>
24#include <__iterator/iter_swap.h>
25#include <__iterator/iterator_traits.h>
26#include <__memory/addressof.h>
27#include <__ranges/access.h>
28#include <__ranges/all.h>
29#include <__ranges/concepts.h>
30#include <__ranges/non_propagating_cache.h>
31#include <__ranges/range_adaptor.h>
32#include <__ranges/single_view.h>
33#include <__ranges/view_interface.h>
34#include <__type_traits/conditional.h>
35#include <__type_traits/decay.h>
36#include <__type_traits/is_reference.h>
37#include <__type_traits/maybe_const.h>
38#include <__utility/as_const.h>
39#include <__utility/as_lvalue.h>
40#include <__utility/empty.h>
41#include <__utility/forward.h>
42#include <__utility/move.h>
43#include <variant>
44
45#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
46# pragma GCC system_header
47#endif
48
49_LIBCPP_PUSH_MACROS
50#include <__undef_macros>
51
52_LIBCPP_BEGIN_NAMESPACE_STD
53
54#if _LIBCPP_STD_VER >= 23
55
56namespace ranges {
57template <class _Range>
58concept __bidirectional_common = bidirectional_range<_Range> && common_range<_Range>;
59
60template <input_range _View, forward_range _Pattern>
61 requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> &&
62 __concatable<range_reference_t<_View>, _Pattern>
63class join_with_view : public view_interface<join_with_view<_View, _Pattern>> {
64 using _InnerRng _LIBCPP_NODEBUG = range_reference_t<_View>;
65
66 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
67
68 static constexpr bool _UseOuterItCache = !forward_range<_View>;
69 using _OuterItCache _LIBCPP_NODEBUG =
70 _If<_UseOuterItCache, __non_propagating_cache<iterator_t<_View>>, __empty_cache>;
71 _LIBCPP_NO_UNIQUE_ADDRESS _OuterItCache __outer_it_;
72
73 static constexpr bool _UseInnerCache = !is_reference_v<_InnerRng>;
74 using _InnerCache _LIBCPP_NODEBUG =
75 _If<_UseInnerCache, __non_propagating_cache<remove_cvref_t<_InnerRng>>, __empty_cache>;
76 _LIBCPP_NO_UNIQUE_ADDRESS _InnerCache __inner_;
77
78 _LIBCPP_NO_UNIQUE_ADDRESS _Pattern __pattern_ = _Pattern();
79
80 template <bool _Const>
81 struct __iterator;
82
83 template <bool _Const>
84 struct __sentinel;
85
86public:
87 _LIBCPP_HIDE_FROM_ABI join_with_view()
88 requires default_initializable<_View> && default_initializable<_Pattern>
89 = default;
90
91 _LIBCPP_HIDE_FROM_ABI constexpr explicit join_with_view(_View __base, _Pattern __pattern)
92 : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
93
94 template <input_range _Range>
95 requires constructible_from<_View, views::all_t<_Range>> &&
96 constructible_from<_Pattern, single_view<range_value_t<_InnerRng>>>
97 _LIBCPP_HIDE_FROM_ABI constexpr explicit join_with_view(_Range&& __r, range_value_t<_InnerRng> __e)
98 : __base_(views::all(std::forward<_Range>(__r))), __pattern_(views::single(std::move(__e))) {}
99
100 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
101 requires copy_constructible<_View>
102 {
103 return __base_;
104 }
105
106 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
107
108 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
109 if constexpr (forward_range<_View>) {
110 constexpr bool __use_const = __simple_view<_View> && is_reference_v<_InnerRng> && __simple_view<_Pattern>;
111 return __iterator<__use_const>{*this, ranges::begin(__base_)};
112 } else {
113 __outer_it_.__emplace(ranges::begin(__base_));
114 return __iterator<false>{*this};
115 }
116 }
117
118 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
119 requires forward_range<const _View> && forward_range<const _Pattern> &&
120 is_reference_v<range_reference_t<const _View>> && input_range<range_reference_t<const _View>> &&
121 __concatable<range_reference_t<const _View>, const _Pattern>
122 {
123 return __iterator<true>{*this, ranges::begin(__base_)};
124 }
125
126 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
127 constexpr bool __use_const = __simple_view<_View> && __simple_view<_Pattern>;
128 if constexpr (forward_range<_View> && is_reference_v<_InnerRng> && forward_range<_InnerRng> &&
129 common_range<_View> && common_range<_InnerRng>)
130 return __iterator<__use_const>{*this, ranges::end(__base_)};
131 else
132 return __sentinel<__use_const>{*this};
133 }
134
135 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
136 requires forward_range<const _View> && forward_range<const _Pattern> &&
137 is_reference_v<range_reference_t<const _View>> && input_range<range_reference_t<const _View>> &&
138 __concatable<range_reference_t<const _View>, const _Pattern>
139 {
140 using _InnerConstRng = range_reference_t<const _View>;
141 if constexpr (forward_range<_InnerConstRng> && common_range<const _View> && common_range<_InnerConstRng>)
142 return __iterator<true>{*this, ranges::end(__base_)};
143 else
144 return __sentinel<true>{*this};
145 }
146};
147
148template <class _Range, class _Pattern>
149join_with_view(_Range&&, _Pattern&&) -> join_with_view<views::all_t<_Range>, views::all_t<_Pattern>>;
150
151template <input_range _Range>
152join_with_view(_Range&&, range_value_t<range_reference_t<_Range>>)
153 -> join_with_view<views::all_t<_Range>, single_view<range_value_t<range_reference_t<_Range>>>>;
154
155template <class _Base, class _PatternBase, class _InnerBase = range_reference_t<_Base>>
156struct __join_with_view_iterator_category {};
157
158template <class _Base, class _PatternBase, class _InnerBase>
159 requires is_reference_v<_InnerBase> && forward_range<_Base> && forward_range<_InnerBase>
160struct __join_with_view_iterator_category<_Base, _PatternBase, _InnerBase> {
161private:
162 static consteval auto __get_iterator_category() noexcept {
163 using _OuterC = iterator_traits<iterator_t<_Base>>::iterator_category;
164 using _InnerC = iterator_traits<iterator_t<_InnerBase>>::iterator_category;
165 using _PatternC = iterator_traits<iterator_t<_PatternBase>>::iterator_category;
166
167 if constexpr (!is_reference_v<common_reference_t<iter_reference_t<iterator_t<_InnerBase>>,
168 iter_reference_t<iterator_t<_PatternBase>>>>)
169 return input_iterator_tag{};
170 else if constexpr (derived_from<_OuterC, bidirectional_iterator_tag> &&
171 derived_from<_InnerC, bidirectional_iterator_tag> &&
172 derived_from<_PatternC, bidirectional_iterator_tag> && common_range<_InnerBase> &&
173 common_range<_PatternBase>)
174 return bidirectional_iterator_tag{};
175 else if constexpr (derived_from<_OuterC, forward_iterator_tag> && derived_from<_InnerC, forward_iterator_tag> &&
176 derived_from<_PatternC, forward_iterator_tag>)
177 return forward_iterator_tag{};
178 else
179 return input_iterator_tag{};
180 }
181
182public:
183 using iterator_category = decltype(__get_iterator_category());
184};
185
186template <input_range _View, forward_range _Pattern>
187 requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> &&
188 __concatable<range_reference_t<_View>, _Pattern>
189template <bool _Const>
190struct join_with_view<_View, _Pattern>::__iterator
191 : public __join_with_view_iterator_category<__maybe_const<_Const, _View>, __maybe_const<_Const, _Pattern>> {
192private:
193 friend join_with_view;
194
195 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_with_view>;
196 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
197 using _InnerBase _LIBCPP_NODEBUG = range_reference_t<_Base>;
198 using _PatternBase _LIBCPP_NODEBUG = __maybe_const<_Const, _Pattern>;
199
200 using _OuterIter _LIBCPP_NODEBUG = iterator_t<_Base>;
201 using _InnerIter _LIBCPP_NODEBUG = iterator_t<_InnerBase>;
202 using _PatternIter _LIBCPP_NODEBUG = iterator_t<_PatternBase>;
203
204 static_assert(!_Const || forward_range<_Base>, "Const can only be true when Base models forward_range.");
205
206 static constexpr bool __ref_is_glvalue = is_reference_v<_InnerBase>;
207
208 _Parent* __parent_ = nullptr;
209
210 static constexpr bool _OuterIterPresent = forward_range<_Base>;
211 using _OuterIterType _LIBCPP_NODEBUG = _If<_OuterIterPresent, _OuterIter, std::__empty>;
212 _LIBCPP_NO_UNIQUE_ADDRESS _OuterIterType __outer_it_ = _OuterIterType();
213
214 variant<_PatternIter, _InnerIter> __inner_it_;
215
216 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(_Parent& __parent, _OuterIter __outer)
217 requires forward_range<_Base>
218 : __parent_(std::addressof(__parent)), __outer_it_(std::move(__outer)) {
219 if (__get_outer() != ranges::end(__parent_->__base_)) {
220 __inner_it_.template emplace<1>(ranges::begin(__update_inner()));
221 __satisfy();
222 }
223 }
224
225 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(_Parent& __parent)
226 requires(!forward_range<_Base>)
227 : __parent_(std::addressof(__parent)) {
228 if (__get_outer() != ranges::end(__parent_->__base_)) {
229 __inner_it_.template emplace<1>(ranges::begin(__update_inner()));
230 __satisfy();
231 }
232 }
233
234 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _OuterIter& __get_outer() {
235 if constexpr (forward_range<_Base>)
236 return __outer_it_;
237 else
238 return *__parent_->__outer_it_;
239 }
240
241 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _OuterIter& __get_outer() const {
242 if constexpr (forward_range<_Base>)
243 return __outer_it_;
244 else
245 return *__parent_->__outer_it_;
246 }
247
248 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __update_inner() {
249 if constexpr (__ref_is_glvalue)
250 return std::__as_lvalue(*__get_outer());
251 else
252 return __parent_->__inner_.__emplace_from([this]() -> decltype(auto) { return *__get_outer(); });
253 }
254
255 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto& __get_inner() {
256 if constexpr (__ref_is_glvalue)
257 return std::__as_lvalue(*__get_outer());
258 else
259 return *__parent_->__inner_;
260 }
261
262 _LIBCPP_HIDE_FROM_ABI constexpr void __satisfy() {
263 while (true) {
264 if (__inner_it_.index() == 0) {
265 if (std::get<0>(__inner_it_) != ranges::end(__parent_->__pattern_))
266 break;
267
268 __inner_it_.template emplace<1>(ranges::begin(__update_inner()));
269 } else {
270 if (std::get<1>(__inner_it_) != ranges::end(__get_inner()))
271 break;
272
273 if (++__get_outer() == ranges::end(__parent_->__base_)) {
274 if constexpr (__ref_is_glvalue)
275 __inner_it_.template emplace<0>();
276
277 break;
278 }
279
280 __inner_it_.template emplace<0>(ranges::begin(__parent_->__pattern_));
281 }
282 }
283 }
284
285 [[nodiscard]] static consteval auto __get_iterator_concept() noexcept {
286 if constexpr (__ref_is_glvalue && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> &&
287 __bidirectional_common<_PatternBase>)
288 return bidirectional_iterator_tag{};
289 else if constexpr (__ref_is_glvalue && forward_range<_Base> && forward_range<_InnerBase>)
290 return forward_iterator_tag{};
291 else
292 return input_iterator_tag{};
293 }
294
295public:
296 using iterator_concept = decltype(__get_iterator_concept());
297 using value_type = common_type_t<iter_value_t<_InnerIter>, iter_value_t<_PatternIter>>;
298 using difference_type =
299 common_type_t<iter_difference_t<_OuterIter>, iter_difference_t<_InnerIter>, iter_difference_t<_PatternIter>>;
300
301 _LIBCPP_HIDE_FROM_ABI __iterator() = default;
302
303 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i)
304 requires _Const && convertible_to<iterator_t<_View>, _OuterIter> &&
305 convertible_to<iterator_t<_InnerRng>, _InnerIter> && convertible_to<iterator_t<_Pattern>, _PatternIter>
306 : __parent_(__i.__parent_), __outer_it_(std::move(__i.__outer_it_)) {
307 if (__i.__inner_it_.index() == 0) {
308 __inner_it_.template emplace<0>(std::get<0>(std::move(__i.__inner_it_)));
309 } else {
310 __inner_it_.template emplace<1>(std::get<1>(std::move(__i.__inner_it_)));
311 }
312 }
313
314 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const {
315 using __reference = common_reference_t<iter_reference_t<_InnerIter>, iter_reference_t<_PatternIter>>;
316 return std::visit([](auto& __it) -> __reference { return *__it; }, __inner_it_);
317 }
318
319 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
320 std::visit([](auto& __it) { ++__it; }, __inner_it_);
321 __satisfy();
322 return *this;
323 }
324
325 _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++*this; }
326
327 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int)
328 requires __ref_is_glvalue && forward_iterator<_OuterIter> && forward_iterator<_InnerIter>
329 {
330 __iterator __tmp = *this;
331 ++*this;
332 return __tmp;
333 }
334
335 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--()
336 requires __ref_is_glvalue
337 && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> && __bidirectional_common<_PatternBase>
338 {
339 if (__outer_it_ == ranges::end(__parent_->__base_)) {
340 auto&& __inner = *--__outer_it_;
341 __inner_it_.template emplace<1>(ranges::end(__inner));
342 }
343
344 while (true) {
345 if (__inner_it_.index() == 0) {
346 auto& __it = std::get<0>(__inner_it_);
347 if (__it == ranges::begin(__parent_->__pattern_)) {
348 auto&& __inner = *--__outer_it_;
349 __inner_it_.template emplace<1>(ranges::end(__inner));
350 } else
351 break;
352 } else {
353 auto& __it = std::get<1>(__inner_it_);
354 auto&& __inner = *__outer_it_;
355 if (__it == ranges::begin(__inner))
356 __inner_it_.template emplace<0>(ranges::end(__parent_->__pattern_));
357 else
358 break;
359 }
360 }
361
362 std::visit([](auto& __it) { --__it; }, __inner_it_);
363 return *this;
364 }
365
366 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
367 requires __ref_is_glvalue
368 && bidirectional_range<_Base> && __bidirectional_common<_InnerBase> && __bidirectional_common<_PatternBase>
369 {
370 __iterator __tmp = *this;
371 --*this;
372 return __tmp;
373 }
374
375 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
376 requires __ref_is_glvalue && forward_range<_Base> && equality_comparable<_InnerIter>
377 {
378 return __x.__outer_it_ == __y.__outer_it_ && __x.__inner_it_ == __y.__inner_it_;
379 }
380
381 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __x) {
382 using __rvalue_reference =
383 common_reference_t<iter_rvalue_reference_t<_InnerIter>, iter_rvalue_reference_t<_PatternIter>>;
384 return std::visit<__rvalue_reference>(ranges::iter_move, __x.__inner_it_);
385 }
386
387 _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y)
388 requires indirectly_swappable<_InnerIter, _PatternIter>
389 {
390 std::visit(ranges::iter_swap, __x.__inner_it_, __y.__inner_it_);
391 }
392};
393
394template <input_range _View, forward_range _Pattern>
395 requires view<_View> && input_range<range_reference_t<_View>> && view<_Pattern> &&
396 __concatable<range_reference_t<_View>, _Pattern>
397template <bool _Const>
398struct join_with_view<_View, _Pattern>::__sentinel {
399private:
400 friend join_with_view;
401
402 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, join_with_view>;
403 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
404
405 _LIBCPP_NO_UNIQUE_ADDRESS sentinel_t<_Base> __end_ = sentinel_t<_Base>();
406
407 _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(_Parent& __parent) : __end_(ranges::end(__parent.__base_)) {}
408
409 template <bool _OtherConst>
410 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto& __get_outer_of(const __iterator<_OtherConst>& __x) {
411 return __x.__get_outer();
412 }
413
414public:
415 _LIBCPP_HIDE_FROM_ABI __sentinel() = default;
416
417 _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __s)
418 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
419 : __end_(std::move(__s.__end_)) {}
420
421 template <bool _OtherConst>
422 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
423 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool
424 operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
425 return __get_outer_of(__x) == __y.__end_;
426 }
427};
428
429namespace views {
430namespace __join_with_view {
431struct __fn {
432 template <class _Range, class _Pattern>
433 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
434 noexcept(noexcept(/**/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
435 -> decltype(/*--*/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))) {
436 return /*-------------*/ join_with_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern));
437 }
438
439 template <class _Pattern>
440 requires constructible_from<decay_t<_Pattern>, _Pattern>
441 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
442 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
443 return __pipeable(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
444 }
445};
446} // namespace __join_with_view
447
448inline namespace __cpo {
449inline constexpr auto join_with = __join_with_view::__fn{};
450} // namespace __cpo
451} // namespace views
452} // namespace ranges
453
454#endif // _LIBCPP_STD_VER >= 23
455
456_LIBCPP_END_NAMESPACE_STD
457
458_LIBCPP_POP_MACROS
459
460#endif // _LIBCPP___RANGES_JOIN_WITH_VIEW_H
lib/libcxx/include/__ranges/non_propagating_cache.h+1-1
...@@ -36,7 +36,7 @@ namespace ranges {...@@ -36,7 +36,7 @@ namespace ranges {
36// may refer to internal details of the source view.36// may refer to internal details of the source view.
37template <class _Tp>37template <class _Tp>
38 requires is_object_v<_Tp>38 requires is_object_v<_Tp>
39class _LIBCPP_TEMPLATE_VIS __non_propagating_cache {39class __non_propagating_cache {
40 struct __from_tag {};40 struct __from_tag {};
41 struct __forward_tag {};41 struct __forward_tag {};
4242
lib/libcxx/include/__ranges/repeat_view.h+2-2
...@@ -52,12 +52,12 @@ concept __integer_like_with_usable_difference_type =...@@ -52,12 +52,12 @@ concept __integer_like_with_usable_difference_type =
5252
53template <class _Tp>53template <class _Tp>
54struct __repeat_view_iterator_difference {54struct __repeat_view_iterator_difference {
55 using type = _IotaDiffT<_Tp>;55 using type _LIBCPP_NODEBUG = _IotaDiffT<_Tp>;
56};56};
5757
58template <__signed_integer_like _Tp>58template <__signed_integer_like _Tp>
59struct __repeat_view_iterator_difference<_Tp> {59struct __repeat_view_iterator_difference<_Tp> {
60 using type = _Tp;60 using type _LIBCPP_NODEBUG = _Tp;
61};61};
6262
63template <class _Tp>63template <class _Tp>
lib/libcxx/include/__ranges/reverse_view.h+2-2
...@@ -144,13 +144,13 @@ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_I...@@ -144,13 +144,13 @@ inline constexpr bool __is_unsized_reverse_subrange<subrange<reverse_iterator<_I
144144
145template <class _Tp>145template <class _Tp>
146struct __unwrapped_reverse_subrange {146struct __unwrapped_reverse_subrange {
147 using type =147 using type _LIBCPP_NODEBUG =
148 void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics148 void; // avoid SFINAE-ing out the overload below -- let the concept requirements do it for better diagnostics
149};149};
150150
151template <class _Iter, subrange_kind _Kind>151template <class _Iter, subrange_kind _Kind>
152struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> {152struct __unwrapped_reverse_subrange<subrange<reverse_iterator<_Iter>, reverse_iterator<_Iter>, _Kind>> {
153 using type = subrange<_Iter, _Iter, _Kind>;153 using type _LIBCPP_NODEBUG = subrange<_Iter, _Iter, _Kind>;
154};154};
155155
156struct __fn : __range_adaptor_closure<__fn> {156struct __fn : __range_adaptor_closure<__fn> {
lib/libcxx/include/__ranges/subrange.h+5-5
...@@ -72,7 +72,7 @@ template <input_or_output_iterator _Iter,...@@ -72,7 +72,7 @@ template <input_or_output_iterator _Iter,
72 sentinel_for<_Iter> _Sent = _Iter,72 sentinel_for<_Iter> _Sent = _Iter,
73 subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter> ? subrange_kind::sized : subrange_kind::unsized>73 subrange_kind _Kind = sized_sentinel_for<_Sent, _Iter> ? subrange_kind::sized : subrange_kind::unsized>
74 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)74 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
75class _LIBCPP_TEMPLATE_VIS subrange : public view_interface<subrange<_Iter, _Sent, _Kind>> {75class subrange : public view_interface<subrange<_Iter, _Sent, _Kind>> {
76public:76public:
77 // Note: this is an internal implementation detail that is public only for internal usage.77 // Note: this is an internal implementation detail that is public only for internal usage.
78 static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);78 static constexpr bool _StoreSize = (_Kind == subrange_kind::sized && !sized_sentinel_for<_Sent, _Iter>);
...@@ -247,22 +247,22 @@ struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2...@@ -247,22 +247,22 @@ struct tuple_size<ranges::subrange<_Ip, _Sp, _Kp>> : integral_constant<size_t, 2
247247
248template <class _Ip, class _Sp, ranges::subrange_kind _Kp>248template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
249struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> {249struct tuple_element<0, ranges::subrange<_Ip, _Sp, _Kp>> {
250 using type = _Ip;250 using type _LIBCPP_NODEBUG = _Ip;
251};251};
252252
253template <class _Ip, class _Sp, ranges::subrange_kind _Kp>253template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
254struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> {254struct tuple_element<1, ranges::subrange<_Ip, _Sp, _Kp>> {
255 using type = _Sp;255 using type _LIBCPP_NODEBUG = _Sp;
256};256};
257257
258template <class _Ip, class _Sp, ranges::subrange_kind _Kp>258template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
259struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> {259struct tuple_element<0, const ranges::subrange<_Ip, _Sp, _Kp>> {
260 using type = _Ip;260 using type _LIBCPP_NODEBUG = _Ip;
261};261};
262262
263template <class _Ip, class _Sp, ranges::subrange_kind _Kp>263template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
264struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {264struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
265 using type = _Sp;265 using type _LIBCPP_NODEBUG = _Sp;
266};266};
267267
268#endif // _LIBCPP_STD_VER >= 20268#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__ranges/take_view.h+3-3
...@@ -229,18 +229,18 @@ struct __passthrough_type;...@@ -229,18 +229,18 @@ struct __passthrough_type;
229229
230template <class _Tp, size_t _Extent>230template <class _Tp, size_t _Extent>
231struct __passthrough_type<span<_Tp, _Extent>> {231struct __passthrough_type<span<_Tp, _Extent>> {
232 using type = span<_Tp>;232 using type _LIBCPP_NODEBUG = span<_Tp>;
233};233};
234234
235template <class _CharT, class _Traits>235template <class _CharT, class _Traits>
236struct __passthrough_type<basic_string_view<_CharT, _Traits>> {236struct __passthrough_type<basic_string_view<_CharT, _Traits>> {
237 using type = basic_string_view<_CharT, _Traits>;237 using type _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>;
238};238};
239239
240template <class _Iter, class _Sent, subrange_kind _Kind>240template <class _Iter, class _Sent, subrange_kind _Kind>
241 requires requires { typename subrange<_Iter>; }241 requires requires { typename subrange<_Iter>; }
242struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {242struct __passthrough_type<subrange<_Iter, _Sent, _Kind>> {
243 using type = subrange<_Iter>;243 using type _LIBCPP_NODEBUG = subrange<_Iter>;
244};244};
245245
246template <class _Tp>246template <class _Tp>
lib/libcxx/include/__ranges/to.h+4-2
...@@ -26,7 +26,9 @@...@@ -26,7 +26,9 @@
26#include <__ranges/size.h>26#include <__ranges/size.h>
27#include <__ranges/transform_view.h>27#include <__ranges/transform_view.h>
28#include <__type_traits/add_pointer.h>28#include <__type_traits/add_pointer.h>
29#include <__type_traits/is_class.h>
29#include <__type_traits/is_const.h>30#include <__type_traits/is_const.h>
31#include <__type_traits/is_union.h>
30#include <__type_traits/is_volatile.h>32#include <__type_traits/is_volatile.h>
31#include <__type_traits/type_identity.h>33#include <__type_traits/type_identity.h>
32#include <__utility/declval.h>34#include <__utility/declval.h>
...@@ -81,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args>...@@ -81,7 +83,7 @@ template <class _Container, input_range _Range, class... _Args>
81 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");83 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
82 static_assert(84 static_assert(
83 !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");85 !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
8486 static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type");
85 // First see if the non-recursive case applies -- the conversion target is either:87 // First see if the non-recursive case applies -- the conversion target is either:
86 // - a range with a convertible value type;88 // - a range with a convertible value type;
87 // - a non-range type which might support being created from the input argument(s) (e.g. an `optional`).89 // - a non-range type which might support being created from the input argument(s) (e.g. an `optional`).
...@@ -208,7 +210,7 @@ template <class _Container, class... _Args>...@@ -208,7 +210,7 @@ template <class _Container, class... _Args>
208 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");210 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
209 static_assert(211 static_assert(
210 !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");212 !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
211213 static_assert(is_class_v<_Container> || is_union_v<_Container>, "The target must be a class type or union type");
212 auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static214 auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static
213 requires requires { //215 requires requires { //
214 /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);216 /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);
lib/libcxx/include/__ranges/transform_view.h+6-5
...@@ -38,6 +38,7 @@...@@ -38,6 +38,7 @@
38#include <__type_traits/is_nothrow_constructible.h>38#include <__type_traits/is_nothrow_constructible.h>
39#include <__type_traits/is_object.h>39#include <__type_traits/is_object.h>
40#include <__type_traits/is_reference.h>40#include <__type_traits/is_reference.h>
41#include <__type_traits/is_referenceable.h>
41#include <__type_traits/maybe_const.h>42#include <__type_traits/maybe_const.h>
42#include <__type_traits/remove_cvref.h>43#include <__type_traits/remove_cvref.h>
43#include <__utility/forward.h>44#include <__utility/forward.h>
...@@ -63,7 +64,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere...@@ -63,7 +64,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere
63template <class _View, class _Fn>64template <class _View, class _Fn>
64concept __transform_view_constraints =65concept __transform_view_constraints =
65 view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> &&66 view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> &&
66 __can_reference<invoke_result_t<_Fn&, range_reference_t<_View>>>;67 __is_referenceable_v<invoke_result_t<_Fn&, range_reference_t<_View>>>;
6768
68# if _LIBCPP_STD_VER >= 2369# if _LIBCPP_STD_VER >= 23
69template <input_range _View, move_constructible _Fn>70template <input_range _View, move_constructible _Fn>
...@@ -136,22 +137,22 @@ transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>;...@@ -136,22 +137,22 @@ transform_view(_Range&&, _Fn) -> transform_view<views::all_t<_Range>, _Fn>;
136137
137template <class _View>138template <class _View>
138struct __transform_view_iterator_concept {139struct __transform_view_iterator_concept {
139 using type = input_iterator_tag;140 using type _LIBCPP_NODEBUG = input_iterator_tag;
140};141};
141142
142template <random_access_range _View>143template <random_access_range _View>
143struct __transform_view_iterator_concept<_View> {144struct __transform_view_iterator_concept<_View> {
144 using type = random_access_iterator_tag;145 using type _LIBCPP_NODEBUG = random_access_iterator_tag;
145};146};
146147
147template <bidirectional_range _View>148template <bidirectional_range _View>
148struct __transform_view_iterator_concept<_View> {149struct __transform_view_iterator_concept<_View> {
149 using type = bidirectional_iterator_tag;150 using type _LIBCPP_NODEBUG = bidirectional_iterator_tag;
150};151};
151152
152template <forward_range _View>153template <forward_range _View>
153struct __transform_view_iterator_concept<_View> {154struct __transform_view_iterator_concept<_View> {
154 using type = forward_iterator_tag;155 using type _LIBCPP_NODEBUG = forward_iterator_tag;
155};156};
156157
157template <class, class>158template <class, class>
lib/libcxx/include/__ranges/zip_view.h+23-1
...@@ -23,6 +23,7 @@...@@ -23,6 +23,7 @@
23#include <__iterator/iter_move.h>23#include <__iterator/iter_move.h>
24#include <__iterator/iter_swap.h>24#include <__iterator/iter_swap.h>
25#include <__iterator/iterator_traits.h>25#include <__iterator/iterator_traits.h>
26#include <__iterator/product_iterator.h>
26#include <__ranges/access.h>27#include <__ranges/access.h>
27#include <__ranges/all.h>28#include <__ranges/all.h>
28#include <__ranges/concepts.h>29#include <__ranges/concepts.h>
...@@ -251,8 +252,12 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base...@@ -251,8 +252,12 @@ class zip_view<_Views...>::__iterator : public __zip_view_iterator_category_base
251252
252 friend class zip_view<_Views...>;253 friend class zip_view<_Views...>;
253254
255 static constexpr bool __is_zip_view_iterator = true;
256
257 friend struct __product_iterator_traits<__iterator>;
258
254public:259public:
255 using iterator_concept = decltype(__get_zip_view_iterator_tag<_Const, _Views...>());260 using iterator_concept = decltype(ranges::__get_zip_view_iterator_tag<_Const, _Views...>());
256 using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>;261 using value_type = tuple<range_value_t<__maybe_const<_Const, _Views>>...>;
257 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;262 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
258263
...@@ -468,6 +473,23 @@ inline constexpr auto zip = __zip::__fn{};...@@ -468,6 +473,23 @@ inline constexpr auto zip = __zip::__fn{};
468} // namespace views473} // namespace views
469} // namespace ranges474} // namespace ranges
470475
476template <class _Iterator>
477 requires _Iterator::__is_zip_view_iterator
478struct __product_iterator_traits<_Iterator> {
479 static constexpr size_t __size = tuple_size<decltype(std::declval<_Iterator>().__current_)>::value;
480
481 template <size_t _Nth, class _Iter>
482 requires(_Nth < __size)
483 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto) __get_iterator_element(_Iter&& __it) {
484 return std::get<_Nth>(std::forward<_Iter>(__it).__current_);
485 }
486
487 template <class... _Iters>
488 _LIBCPP_HIDE_FROM_ABI static constexpr _Iterator __make_product_iterator(_Iters&&... __iters) {
489 return _Iterator(std::tuple(std::forward<_Iters>(__iters)...));
490 }
491};
492
471#endif // _LIBCPP_STD_VER >= 23493#endif // _LIBCPP_STD_VER >= 23
472494
473_LIBCPP_END_NAMESPACE_STD495_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__split_buffer+8-3
...@@ -28,6 +28,7 @@...@@ -28,6 +28,7 @@
28#include <__type_traits/integral_constant.h>28#include <__type_traits/integral_constant.h>
29#include <__type_traits/is_nothrow_assignable.h>29#include <__type_traits/is_nothrow_assignable.h>
30#include <__type_traits/is_nothrow_constructible.h>30#include <__type_traits/is_nothrow_constructible.h>
31#include <__type_traits/is_replaceable.h>
31#include <__type_traits/is_swappable.h>32#include <__type_traits/is_swappable.h>
32#include <__type_traits/is_trivially_destructible.h>33#include <__type_traits/is_trivially_destructible.h>
33#include <__type_traits/is_trivially_relocatable.h>34#include <__type_traits/is_trivially_relocatable.h>
...@@ -72,6 +73,10 @@ public:...@@ -72,6 +73,10 @@ public:
72 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,73 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
73 __split_buffer,74 __split_buffer,
74 void>;75 void>;
76 using __replaceable _LIBCPP_NODEBUG =
77 __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value,
78 __split_buffer,
79 void>;
7580
76 pointer __first_;81 pointer __first_;
77 pointer __begin_;82 pointer __begin_;
...@@ -233,7 +238,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants...@@ -233,7 +238,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __split_buffer<_Tp, _Allocator>::__invariants
233// Postcondition: size() == size() + __n238// Postcondition: size() == size() + __n
234template <class _Tp, class _Allocator>239template <class _Tp, class _Allocator>
235_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {240_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n) {
236 _ConstructTransaction __tx(&this->__end_, __n);241 _ConstructTransaction __tx(std::addressof(this->__end_), __n);
237 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {242 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
238 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_));243 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_));
239 }244 }
...@@ -248,7 +253,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_...@@ -248,7 +253,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::__construct_
248template <class _Tp, class _Allocator>253template <class _Tp, class _Allocator>
249_LIBCPP_CONSTEXPR_SINCE_CXX20 void254_LIBCPP_CONSTEXPR_SINCE_CXX20 void
250__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {255__split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) {
251 _ConstructTransaction __tx(&this->__end_, __n);256 _ConstructTransaction __tx(std::addressof(this->__end_), __n);
252 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {257 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_) {
253 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x);258 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), __x);
254 }259 }
...@@ -283,7 +288,7 @@ template <class _Tp, class _Allocator>...@@ -283,7 +288,7 @@ template <class _Tp, class _Allocator>
283template <class _ForwardIterator>288template <class _ForwardIterator>
284_LIBCPP_CONSTEXPR_SINCE_CXX20 void289_LIBCPP_CONSTEXPR_SINCE_CXX20 void
285__split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {290__split_buffer<_Tp, _Allocator>::__construct_at_end_with_size(_ForwardIterator __first, size_type __n) {
286 _ConstructTransaction __tx(&this->__end_, __n);291 _ConstructTransaction __tx(std::addressof(this->__end_), __n);
287 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {292 for (; __tx.__pos_ != __tx.__end_; ++__tx.__pos_, (void)++__first) {
288 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first);293 __alloc_traits::construct(__alloc_, std::__to_address(__tx.__pos_), *__first);
289 }294 }
lib/libcxx/include/__stop_token/atomic_unique_lock.h+1-1
...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,7 +28,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28// and LockedBit is the value of State when the lock bit is set, e.g 1 << 228// and LockedBit is the value of State when the lock bit is set, e.g 1 << 2
29template <class _State, _State _LockedBit>29template <class _State, _State _LockedBit>
30class _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock {30class _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock {
31 static_assert(std::__libcpp_popcount(static_cast<unsigned long long>(_LockedBit)) == 1,31 static_assert(std::__popcount(static_cast<unsigned long long>(_LockedBit)) == 1,
32 "LockedBit must be an integer where only one bit is set");32 "LockedBit must be an integer where only one bit is set");
3333
34 std::atomic<_State>& __state_;34 std::atomic<_State>& __state_;
lib/libcxx/include/__stop_token/intrusive_shared_ptr.h+2-1
...@@ -14,6 +14,7 @@...@@ -14,6 +14,7 @@
14#include <__atomic/memory_order.h>14#include <__atomic/memory_order.h>
15#include <__config>15#include <__config>
16#include <__cstddef/nullptr_t.h>16#include <__cstddef/nullptr_t.h>
17#include <__memory/addressof.h>
17#include <__type_traits/is_reference.h>18#include <__type_traits/is_reference.h>
18#include <__utility/move.h>19#include <__utility/move.h>
19#include <__utility/swap.h>20#include <__utility/swap.h>
...@@ -113,7 +114,7 @@ private:...@@ -113,7 +114,7 @@ private:
113114
114 _LIBCPP_HIDE_FROM_ABI static void __decrement_ref_count(_Tp& __obj) {115 _LIBCPP_HIDE_FROM_ABI static void __decrement_ref_count(_Tp& __obj) {
115 if (__get_atomic_ref_count(__obj).fetch_sub(1, std::memory_order_acq_rel) == 1) {116 if (__get_atomic_ref_count(__obj).fetch_sub(1, std::memory_order_acq_rel) == 1) {
116 delete &__obj;117 delete std::addressof(__obj);
117 }118 }
118 }119 }
119120
lib/libcxx/include/__string/char_traits.h+7-14
...@@ -78,7 +78,7 @@ exposition-only to document what members a char_traits specialization should pro...@@ -78,7 +78,7 @@ exposition-only to document what members a char_traits specialization should pro
78// char_traits<char>78// char_traits<char>
7979
80template <>80template <>
81struct _LIBCPP_TEMPLATE_VIS char_traits<char> {81struct char_traits<char> {
82 using char_type = char;82 using char_type = char;
83 using int_type = int;83 using int_type = int;
84 using off_type = streamoff;84 using off_type = streamoff;
...@@ -132,8 +132,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> {...@@ -132,8 +132,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> {
132132
133 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*133 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
134 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {134 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
135 if (__n == 0)
136 return nullptr;
137 return std::__constexpr_memchr(__s, __a, __n);135 return std::__constexpr_memchr(__s, __a, __n);
138 }136 }
139137
...@@ -236,7 +234,7 @@ struct __char_traits_base {...@@ -236,7 +234,7 @@ struct __char_traits_base {
236234
237#if _LIBCPP_HAS_WIDE_CHARACTERS235#if _LIBCPP_HAS_WIDE_CHARACTERS
238template <>236template <>
239struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {237struct char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {
240 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int238 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int
241 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {239 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
242 if (__n == 0)240 if (__n == 0)
...@@ -250,8 +248,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w...@@ -250,8 +248,6 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w
250248
251 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*249 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
252 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {250 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
253 if (__n == 0)
254 return nullptr;
255 return std::__constexpr_wmemchr(__s, __a, __n);251 return std::__constexpr_wmemchr(__s, __a, __n);
256 }252 }
257};253};
...@@ -260,8 +256,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w...@@ -260,8 +256,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w
260#if _LIBCPP_HAS_CHAR8_T256#if _LIBCPP_HAS_CHAR8_T
261257
262template <>258template <>
263struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>259struct char_traits<char8_t> : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> {
264 : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> {
265 static _LIBCPP_HIDE_FROM_ABI constexpr int260 static _LIBCPP_HIDE_FROM_ABI constexpr int
266 compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept {261 compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept {
267 return std::__constexpr_memcmp(__s1, __s2, __element_count(__n));262 return std::__constexpr_memcmp(__s1, __s2, __element_count(__n));
...@@ -280,8 +275,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>...@@ -280,8 +275,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
280#endif // _LIBCPP_HAS_CHAR8_T275#endif // _LIBCPP_HAS_CHAR8_T
281276
282template <>277template <>
283struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>278struct char_traits<char16_t> : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> {
284 : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> {
285 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int279 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int
286 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;280 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
287 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;281 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;
...@@ -315,8 +309,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const...@@ -315,8 +309,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const
315}309}
316310
317template <>311template <>
318struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>312struct char_traits<char32_t> : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> {
319 : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> {
320 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int313 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int
321 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;314 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
322 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;315 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;
...@@ -355,7 +348,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const...@@ -355,7 +348,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const
355template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>348template <class _CharT, class _SizeT, class _Traits, _SizeT __npos>
356inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI349inline _SizeT _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
357__str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {350__str_find(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos) _NOEXCEPT {
358 if (__pos >= __sz)351 if (__pos > __sz)
359 return __npos;352 return __npos;
360 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);353 const _CharT* __r = _Traits::find(__p + __pos, __sz - __pos, __c);
361 if (__r == nullptr)354 if (__r == nullptr)
...@@ -534,7 +527,7 @@ __str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos)...@@ -534,7 +527,7 @@ __str_find_last_not_of(const _CharT* __p, _SizeT __sz, _CharT __c, _SizeT __pos)
534template <class _Ptr>527template <class _Ptr>
535inline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) {528inline _LIBCPP_HIDE_FROM_ABI size_t __do_string_hash(_Ptr __p, _Ptr __e) {
536 typedef typename iterator_traits<_Ptr>::value_type value_type;529 typedef typename iterator_traits<_Ptr>::value_type value_type;
537 return __murmur2_or_cityhash<size_t>()(__p, (__e - __p) * sizeof(value_type));530 return std::__hash_memory(__p, (__e - __p) * sizeof(value_type));
538}531}
539532
540_LIBCPP_END_NAMESPACE_STD533_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__string/constexpr_c_functions.h+13-10
...@@ -146,7 +146,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp*...@@ -146,7 +146,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_memchr(_Tp*
146 return nullptr;146 return nullptr;
147 } else {147 } else {
148 char __value_buffer = 0;148 char __value_buffer = 0;
149 __builtin_memcpy(&__value_buffer, &__value, sizeof(char));149 __builtin_memcpy(&__value_buffer, std::addressof(__value), sizeof(char));
150 return static_cast<_Tp*>(__builtin_memchr(__str, __value_buffer, __count));150 return static_cast<_Tp*>(__builtin_memchr(__str, __value_buffer, __count));
151 }151 }
152}152}
...@@ -204,23 +204,26 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copy...@@ -204,23 +204,26 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __assign_trivially_copy
204 return __dest;204 return __dest;
205}205}
206206
207template <class _Tp, class _Up, __enable_if_t<__is_always_bitcastable<_Up, _Tp>::value, int> = 0>207template <class _Tp, class _Up>
208_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*208_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*
209__constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) {209__constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) {
210 static_assert(__is_always_bitcastable<_Up, _Tp>::value);
210 size_t __count = static_cast<size_t>(__n);211 size_t __count = static_cast<size_t>(__n);
211 if (__libcpp_is_constant_evaluated()) {212 if (__libcpp_is_constant_evaluated()) {
212#ifdef _LIBCPP_COMPILER_CLANG_BASED213#ifdef _LIBCPP_COMPILER_CLANG_BASED
213 if (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value) {214 if _LIBCPP_CONSTEXPR (is_same<__remove_cv_t<_Tp>, __remove_cv_t<_Up> >::value) {
214 ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp));215 ::__builtin_memmove(__dest, __src, __count * sizeof(_Tp));
215 return __dest;216 return __dest;
216 }217 } else
217#endif218#endif
218 if (std::__is_pointer_in_range(__src, __src + __count, __dest)) {219 {
219 for (; __count > 0; --__count)220 if (std::__is_pointer_in_range(__src, __src + __count, __dest)) {
220 std::__assign_trivially_copyable(__dest[__count - 1], __src[__count - 1]);221 for (; __count > 0; --__count)
221 } else {222 std::__assign_trivially_copyable(__dest[__count - 1], __src[__count - 1]);
222 for (size_t __i = 0; __i != __count; ++__i)223 } else {
223 std::__assign_trivially_copyable(__dest[__i], __src[__i]);224 for (size_t __i = 0; __i != __count; ++__i)
225 std::__assign_trivially_copyable(__dest[__i], __src[__i]);
226 }
224 }227 }
225 } else if (__count > 0) {228 } else if (__count > 0) {
226 ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>);229 ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>);
lib/libcxx/include/__string/extern_template_lists.h+63-102
...@@ -17,116 +17,77 @@...@@ -17,116 +17,77 @@
1717
18// clang-format off18// clang-format off
1919
20// We maintain 2 ABI lists:20// We maintain multiple ABI lists:
21// - _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST
21// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST22// - _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST
22// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST23// - _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST
23// As the name implies, the ABI lists define the V1 (Stable) and unstable ABI.24// As the name implies, the ABI lists define a common subset, the V1 (Stable) and unstable ABI.
24//25//
25// For unstable, we may explicitly remove function that are external in V1,26// For unstable, we may explicitly remove function that are external in V1.
26// and add (new) external functions to better control inlining and compiler
27// optimization opportunities.
28//27//
29// For stable, the ABI list should rarely change, except for adding new28// For stable, the ABI list should rarely change, except for adding new
30// functions supporting new c++ version / API changes. Typically entries29// functions supporting new c++ version / API changes. Typically entries
31// must never be removed from the stable list.30// must never be removed from the stable list.
32#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_Func, _CharType) \31#define _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \
33 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \32 Func(void basic_string<CharT>::__init(const value_type*, size_type)) \
34 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \33 Func(void basic_string<CharT>::__init(size_type, value_type)) \
35 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \34 Func(basic_string<CharT>::basic_string(const basic_string&, size_type, size_type, const allocator<CharT>&)) \
36 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&)) \35 Func(basic_string<CharT>::~basic_string()) \
37 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \36 Func(basic_string<CharT>& basic_string<CharT>::operator=(value_type)) \
38 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, allocator<_CharType> const&)) \37 Func(basic_string<CharT>& basic_string<CharT>::assign(size_type, value_type)) \
39 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \38 Func(basic_string<CharT>& basic_string<CharT>::assign(const basic_string&, size_type, size_type)) \
40 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::~basic_string()) \39 Func(basic_string<CharT>& basic_string<CharT>::append(size_type, value_type)) \
41 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \40 Func(basic_string<CharT>& basic_string<CharT>::append(const value_type*)) \
42 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \41 Func(basic_string<CharT>& basic_string<CharT>::append(const value_type*, size_type)) \
43 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \42 Func(basic_string<CharT>& basic_string<CharT>::append(const basic_string&, size_type, size_type)) \
44 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type)) \43 Func(void basic_string<CharT>::push_back(value_type)) \
45 _Func(_LIBCPP_EXPORTED_FROM_ABI const _CharType& basic_string<_CharType>::at(size_type) const) \44 Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const value_type*)) \
46 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \45 Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, size_type, value_type)) \
47 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \46 Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const value_type*, size_type)) \
48 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \47 Func(basic_string<CharT>& basic_string<CharT>::insert(size_type, const basic_string&, size_type, size_type)) \
49 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*, size_type)) \48 Func(basic_string<CharT>::iterator basic_string<CharT>::insert(basic_string::const_iterator, value_type)) \
50 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::reserve(size_type)) \49 Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const value_type*)) \
51 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \50 Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, size_type, value_type)) \
52 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \51 Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const value_type*, size_type)) \
53 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \52 Func(basic_string<CharT>& basic_string<CharT>::replace(size_type, size_type, const basic_string&, size_type, size_type)) \
54 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \53 Func(void basic_string<CharT>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, const value_type*)) \
55 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \54 Func(void basic_string<CharT>::resize(size_type, value_type)) \
56 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(size_type, value_type)) \55 Func(void basic_string<CharT>::reserve(size_type)) \
57 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \56 Func(basic_string<CharT>::size_type basic_string<CharT>::copy(value_type*, size_type, size_type) const) \
58 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \57 Func(basic_string<CharT>::size_type basic_string<CharT>::find(value_type, size_type) const) \
59 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \58 Func(basic_string<CharT>::size_type basic_string<CharT>::find(const value_type*, size_type, size_type) const) \
60 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \59 Func(basic_string<CharT>::size_type basic_string<CharT>::rfind(value_type, size_type) const) \
61 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::push_back(value_type)) \60 Func(basic_string<CharT>::size_type basic_string<CharT>::rfind(const value_type*, size_type, size_type) const) \
62 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \61 Func(basic_string<CharT>::size_type basic_string<CharT>::find_first_of(const value_type*, size_type, size_type) const) \
63 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \62 Func(basic_string<CharT>::size_type basic_string<CharT>::find_last_of(const value_type*, size_type, size_type) const) \
64 _Func(_LIBCPP_EXPORTED_FROM_ABI const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \63 Func(basic_string<CharT>::size_type basic_string<CharT>::find_first_not_of(const value_type*, size_type, size_type) const) \
65 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \64 Func(basic_string<CharT>::size_type basic_string<CharT>::find_last_not_of(const value_type*, size_type, size_type) const) \
66 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::erase(size_type, size_type)) \65 Func(CharT& basic_string<CharT>::at(size_type)) \
67 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \66 Func(const CharT& basic_string<CharT>::at(size_type) const) \
68 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(value_type const*) const) \67 Func(int basic_string<CharT>::compare(const value_type*) const) \
69 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \68 Func(int basic_string<CharT>::compare(size_type, size_type, const value_type*) const) \
70 _Func(_LIBCPP_EXPORTED_FROM_ABI _CharType& basic_string<_CharType>::at(size_type)) \69 Func(int basic_string<CharT>::compare(size_type, size_type, const value_type*, size_type) const) \
71 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(value_type const*)) \70 Func(int basic_string<CharT>::compare(size_type, size_type, const basic_string&, size_type, size_type) const) \
72 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \71 Func(const basic_string<CharT>::size_type basic_string<CharT>::npos) \
73 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
74 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
75 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(basic_string const&)) \
76 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
77 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
78 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
79 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::resize(size_type, value_type)) \
80 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
8172
82#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_Func, _CharType) \73#define _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(Func, CharT) \
83 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*, size_type)) \74 _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \
84 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type const*, size_type, size_type) const) \75 Func(basic_string<CharT>::basic_string(const basic_string&)) \
85 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type, size_type)) \76 Func(basic_string<CharT>::basic_string(const basic_string&, const allocator<CharT>&)) \
86 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, value_type const*)) \77 Func(basic_string<CharT>& basic_string<CharT>::assign(const value_type*)) \
87 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_not_of(value_type const*, size_type, size_type) const) \78 Func(basic_string<CharT>& basic_string<CharT>::assign(const value_type*, size_type)) \
88 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::~basic_string()) \79 Func(basic_string<CharT>& basic_string<CharT>::operator=(basic_string const&)) \
89 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_not_of(value_type const*, size_type, size_type) const) \80 Func(void basic_string<CharT>::__grow_by(size_type, size_type, size_type, size_type, size_type, size_type)) \
90 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, size_type, value_type)) \81 Func(basic_string<CharT>& basic_string<CharT>::erase(size_type, size_type)) \
91 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::operator=(value_type)) \82
92 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(value_type const*, size_type)) \83#define _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(Func, CharT) \
93 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init_copy_ctor_external(value_type const*, size_type)) \84 _LIBCPP_STRING_COMMON_EXTERN_TEMPLATE_LIST(Func, CharT) \
94 _Func(_LIBCPP_EXPORTED_FROM_ABI const _CharType& basic_string<_CharType>::at(size_type) const) \85 Func(void basic_string<CharT>::__init_copy_ctor_external(const value_type*, size_type)) \
95 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*, size_type)) \86 Func(basic_string<CharT>& basic_string<CharT>::__assign_external(const value_type*, size_type)) \
96 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_first_of(value_type const*, size_type, size_type) const) \87 Func(basic_string<CharT>& basic_string<CharT>::__assign_external(const value_type*)) \
97 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, size_type, value_type)) \88 Func(basic_string<CharT>& basic_string<CharT>::__assign_no_alias<false>(const value_type*, size_type)) \
98 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*, size_type)) \89 Func(basic_string<CharT>& basic_string<CharT>::__assign_no_alias<true>(const value_type*, size_type)) \
99 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_external(value_type const*)) \90 Func(void basic_string<CharT>::__erase_external_with_move(size_type, size_type))
100 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::reserve(size_type)) \
101 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*, size_type)) \
102 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(basic_string const&, size_type, size_type)) \
103 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::copy(value_type*, size_type, size_type) const) \
104 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::basic_string(basic_string const&, size_type, size_type, allocator<_CharType> const&)) \
105 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type, size_type) const) \
106 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__init(size_type, value_type)) \
107 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, value_type const*)) \
108 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find_last_of(value_type const*, size_type, size_type) const) \
109 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__grow_by_and_replace(size_type, size_type, size_type, size_type, size_type, size_type, value_type const*)) \
110 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<false>(value_type const*, size_type)) \
111 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::__assign_no_alias<true>(value_type const*, size_type)) \
112 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::push_back(value_type)) \
113 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(size_type, value_type)) \
114 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::rfind(value_type, size_type) const) \
115 _Func(_LIBCPP_EXPORTED_FROM_ABI const basic_string<_CharType>::size_type basic_string<_CharType>::npos) \
116 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::assign(size_type, value_type)) \
117 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::__erase_external_with_move(size_type, size_type)) \
118 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(basic_string const&, size_type, size_type)) \
119 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(value_type const*) const) \
120 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*) const) \
121 _Func(_LIBCPP_EXPORTED_FROM_ABI _CharType& basic_string<_CharType>::at(size_type)) \
122 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::size_type basic_string<_CharType>::find(value_type const*, size_type, size_type) const) \
123 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, basic_string const&, size_type, size_type) const) \
124 _Func(_LIBCPP_EXPORTED_FROM_ABI int basic_string<_CharType>::compare(size_type, size_type, value_type const*, size_type) const) \
125 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::append(value_type const*)) \
126 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::replace(size_type, size_type, basic_string const&, size_type, size_type)) \
127 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>::iterator basic_string<_CharType>::insert(basic_string::const_iterator, value_type)) \
128 _Func(_LIBCPP_EXPORTED_FROM_ABI void basic_string<_CharType>::resize(size_type, value_type)) \
129 _Func(_LIBCPP_EXPORTED_FROM_ABI basic_string<_CharType>& basic_string<_CharType>::insert(size_type, basic_string const&, size_type, size_type))
13091
131// clang-format on92// clang-format on
13293
lib/libcxx/include/__system_error/error_category.h+2-2
...@@ -67,8 +67,8 @@ public:...@@ -67,8 +67,8 @@ public:
67 string message(int __ev) const override;67 string message(int __ev) const override;
68};68};
6969
70__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;70[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
71__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;71[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
7272
73_LIBCPP_END_NAMESPACE_STD73_LIBCPP_END_NAMESPACE_STD
7474
lib/libcxx/include/__system_error/error_code.h+2-2
...@@ -26,7 +26,7 @@...@@ -26,7 +26,7 @@
26_LIBCPP_BEGIN_NAMESPACE_STD26_LIBCPP_BEGIN_NAMESPACE_STD
2727
28template <class _Tp>28template <class _Tp>
29struct _LIBCPP_TEMPLATE_VIS is_error_code_enum : public false_type {};29struct is_error_code_enum : public false_type {};
3030
31#if _LIBCPP_STD_VER >= 1731#if _LIBCPP_STD_VER >= 17
32template <class _Tp>32template <class _Tp>
...@@ -131,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const error_code& __x,...@@ -131,7 +131,7 @@ inline _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const error_code& __x,
131#endif // _LIBCPP_STD_VER <= 17131#endif // _LIBCPP_STD_VER <= 17
132132
133template <>133template <>
134struct _LIBCPP_TEMPLATE_VIS hash<error_code> : public __unary_function<error_code, size_t> {134struct hash<error_code> : public __unary_function<error_code, size_t> {
135 _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_code& __ec) const _NOEXCEPT {135 _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_code& __ec) const _NOEXCEPT {
136 return static_cast<size_t>(__ec.value());136 return static_cast<size_t>(__ec.value());
137 }137 }
lib/libcxx/include/__system_error/error_condition.h+4-4
...@@ -25,7 +25,7 @@...@@ -25,7 +25,7 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp>27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum : public false_type {};28struct is_error_condition_enum : public false_type {};
2929
30#if _LIBCPP_STD_VER >= 1730#if _LIBCPP_STD_VER >= 17
31template <class _Tp>31template <class _Tp>
...@@ -33,11 +33,11 @@ inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::...@@ -33,11 +33,11 @@ inline constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Tp>::
33#endif33#endif
3434
35template <>35template <>
36struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc> : true_type {};36struct is_error_condition_enum<errc> : true_type {};
3737
38#ifdef _LIBCPP_CXX03_LANG38#ifdef _LIBCPP_CXX03_LANG
39template <>39template <>
40struct _LIBCPP_TEMPLATE_VIS is_error_condition_enum<errc::__lx> : true_type {};40struct is_error_condition_enum<errc::__lx> : true_type {};
41#endif41#endif
4242
43namespace __adl_only {43namespace __adl_only {
...@@ -118,7 +118,7 @@ operator<=>(const error_condition& __x, const error_condition& __y) noexcept {...@@ -118,7 +118,7 @@ operator<=>(const error_condition& __x, const error_condition& __y) noexcept {
118#endif // _LIBCPP_STD_VER <= 17118#endif // _LIBCPP_STD_VER <= 17
119119
120template <>120template <>
121struct _LIBCPP_TEMPLATE_VIS hash<error_condition> : public __unary_function<error_condition, size_t> {121struct hash<error_condition> : public __unary_function<error_condition, size_t> {
122 _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_condition& __ec) const _NOEXCEPT {122 _LIBCPP_HIDE_FROM_ABI size_t operator()(const error_condition& __ec) const _NOEXCEPT {
123 return static_cast<size_t>(__ec.value());123 return static_cast<size_t>(__ec.value());
124 }124 }
lib/libcxx/include/__thread/formatter.h+1-1
...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -34,7 +34,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
34# if _LIBCPP_HAS_THREADS34# if _LIBCPP_HAS_THREADS
3535
36template <__fmt_char_type _CharT>36template <__fmt_char_type _CharT>
37struct _LIBCPP_TEMPLATE_VIS formatter<__thread_id, _CharT> {37struct formatter<__thread_id, _CharT> {
38public:38public:
39 template <class _ParseContext>39 template <class _ParseContext>
40 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {40 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
lib/libcxx/include/__thread/id.h+2-2
...@@ -34,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT;...@@ -34,7 +34,7 @@ _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT;
34template <>34template <>
35struct hash<__thread_id>;35struct hash<__thread_id>;
3636
37class _LIBCPP_TEMPLATE_VIS __thread_id {37class __thread_id {
38 // FIXME: pthread_t is a pointer on Darwin but a long on Linux.38 // FIXME: pthread_t is a pointer on Darwin but a long on Linux.
39 // NULL is the no-thread value on Darwin. Someone needs to check39 // NULL is the no-thread value on Darwin. Someone needs to check
40 // on other platforms. We assume 0 works everywhere for now.40 // on other platforms. We assume 0 works everywhere for now.
...@@ -72,7 +72,7 @@ private:...@@ -72,7 +72,7 @@ private:
7272
73 friend __thread_id this_thread::get_id() _NOEXCEPT;73 friend __thread_id this_thread::get_id() _NOEXCEPT;
74 friend class _LIBCPP_EXPORTED_FROM_ABI thread;74 friend class _LIBCPP_EXPORTED_FROM_ABI thread;
75 friend struct _LIBCPP_TEMPLATE_VIS hash<__thread_id>;75 friend struct hash<__thread_id>;
76};76};
7777
78inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT {78inline _LIBCPP_HIDE_FROM_ABI bool operator==(__thread_id __x, __thread_id __y) _NOEXCEPT {
lib/libcxx/include/__thread/support/windows.h+2-4
...@@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec;...@@ -28,12 +28,10 @@ using __libcpp_timespec_t = ::timespec;
28typedef void* __libcpp_mutex_t;28typedef void* __libcpp_mutex_t;
29#define _LIBCPP_MUTEX_INITIALIZER 029#define _LIBCPP_MUTEX_INITIALIZER 0
3030
31#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)31#if defined(_WIN64)
32typedef void* __libcpp_recursive_mutex_t[6];
33#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
34typedef void* __libcpp_recursive_mutex_t[5];32typedef void* __libcpp_recursive_mutex_t[5];
35#else33#else
36# error Unsupported architecture34typedef void* __libcpp_recursive_mutex_t[6];
37#endif35#endif
3836
39_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);37_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);
lib/libcxx/include/__thread/thread.h+65-69
...@@ -16,6 +16,8 @@...@@ -16,6 +16,8 @@
16#include <__exception/terminate.h>16#include <__exception/terminate.h>
17#include <__functional/hash.h>17#include <__functional/hash.h>
18#include <__functional/unary_function.h>18#include <__functional/unary_function.h>
19#include <__locale>
20#include <__memory/addressof.h>
19#include <__memory/unique_ptr.h>21#include <__memory/unique_ptr.h>
20#include <__mutex/mutex.h>22#include <__mutex/mutex.h>
21#include <__system_error/throw_system_error.h>23#include <__system_error/throw_system_error.h>
...@@ -29,7 +31,6 @@...@@ -29,7 +31,6 @@
29#include <tuple>31#include <tuple>
3032
31#if _LIBCPP_HAS_LOCALIZATION33#if _LIBCPP_HAS_LOCALIZATION
32# include <locale>
33# include <sstream>34# include <sstream>
34#endif35#endif
3536
...@@ -100,7 +101,7 @@ template <class _Tp>...@@ -100,7 +101,7 @@ template <class _Tp>
100__thread_specific_ptr<_Tp>::__thread_specific_ptr() {101__thread_specific_ptr<_Tp>::__thread_specific_ptr() {
101 int __ec = __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);102 int __ec = __libcpp_tls_create(&__key_, &__thread_specific_ptr::__at_thread_exit);
102 if (__ec)103 if (__ec)
103 __throw_system_error(__ec, "__thread_specific_ptr construction failed");104 std::__throw_system_error(__ec, "__thread_specific_ptr construction failed");
104}105}
105106
106template <class _Tp>107template <class _Tp>
...@@ -118,7 +119,7 @@ void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) {...@@ -118,7 +119,7 @@ void __thread_specific_ptr<_Tp>::set_pointer(pointer __p) {
118}119}
119120
120template <>121template <>
121struct _LIBCPP_TEMPLATE_VIS hash<__thread_id> : public __unary_function<__thread_id, size_t> {122struct hash<__thread_id> : public __unary_function<__thread_id, size_t> {
122 _LIBCPP_HIDE_FROM_ABI size_t operator()(__thread_id __v) const _NOEXCEPT {123 _LIBCPP_HIDE_FROM_ABI size_t operator()(__thread_id __v) const _NOEXCEPT {
123 return hash<__libcpp_thread_id>()(__v.__id_);124 return hash<__libcpp_thread_id>()(__v.__id_);
124 }125 }
...@@ -151,47 +152,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {...@@ -151,47 +152,6 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
151}152}
152# endif // _LIBCPP_HAS_LOCALIZATION153# endif // _LIBCPP_HAS_LOCALIZATION
153154
154class _LIBCPP_EXPORTED_FROM_ABI thread {
155 __libcpp_thread_t __t_;
156
157 thread(const thread&);
158 thread& operator=(const thread&);
159
160public:
161 typedef __thread_id id;
162 typedef __libcpp_thread_t native_handle_type;
163
164 _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
165# ifndef _LIBCPP_CXX03_LANG
166 template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>
167 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args);
168# else // _LIBCPP_CXX03_LANG
169 template <class _Fp>
170 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp __f);
171# endif
172 ~thread();
173
174 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }
175
176 _LIBCPP_HIDE_FROM_ABI thread& operator=(thread&& __t) _NOEXCEPT {
177 if (!__libcpp_thread_isnull(&__t_))
178 terminate();
179 __t_ = __t.__t_;
180 __t.__t_ = _LIBCPP_NULL_THREAD;
181 return *this;
182 }
183
184 _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); }
185
186 _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); }
187 void join();
188 void detach();
189 _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); }
190 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; }
191
192 static unsigned hardware_concurrency() _NOEXCEPT;
193};
194
195# ifndef _LIBCPP_CXX03_LANG155# ifndef _LIBCPP_CXX03_LANG
196156
197template <class _TSp, class _Fp, class... _Args, size_t... _Indices>157template <class _TSp, class _Fp, class... _Args, size_t... _Indices>
...@@ -209,19 +169,6 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) {...@@ -209,19 +169,6 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) {
209 return nullptr;169 return nullptr;
210}170}
211171
212template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> >
213thread::thread(_Fp&& __f, _Args&&... __args) {
214 typedef unique_ptr<__thread_struct> _TSPtr;
215 _TSPtr __tsp(new __thread_struct);
216 typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp;
217 unique_ptr<_Gp> __p(new _Gp(std::move(__tsp), std::forward<_Fp>(__f), std::forward<_Args>(__args)...));
218 int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy<_Gp>, __p.get());
219 if (__ec == 0)
220 __p.release();
221 else
222 __throw_system_error(__ec, "thread constructor failed");
223}
224
225# else // _LIBCPP_CXX03_LANG172# else // _LIBCPP_CXX03_LANG
226173
227template <class _Fp>174template <class _Fp>
...@@ -242,20 +189,69 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp) {...@@ -242,20 +189,69 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy_cxx03(void* __vp) {
242 return nullptr;189 return nullptr;
243}190}
244191
245template <class _Fp>
246thread::thread(_Fp __f) {
247 typedef __thread_invoke_pair<_Fp> _InvokePair;
248 typedef unique_ptr<_InvokePair> _PairPtr;
249 _PairPtr __pp(new _InvokePair(__f));
250 int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
251 if (__ec == 0)
252 __pp.release();
253 else
254 __throw_system_error(__ec, "thread constructor failed");
255}
256
257# endif // _LIBCPP_CXX03_LANG192# endif // _LIBCPP_CXX03_LANG
258193
194class _LIBCPP_EXPORTED_FROM_ABI thread {
195 __libcpp_thread_t __t_;
196
197 thread(const thread&);
198 thread& operator=(const thread&);
199
200public:
201 typedef __thread_id id;
202 typedef __libcpp_thread_t native_handle_type;
203
204 _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
205
206# ifndef _LIBCPP_CXX03_LANG
207 template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>
208 _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp&& __f, _Args&&... __args) {
209 typedef unique_ptr<__thread_struct> _TSPtr;
210 _TSPtr __tsp(new __thread_struct);
211 typedef tuple<_TSPtr, __decay_t<_Fp>, __decay_t<_Args>...> _Gp;
212 unique_ptr<_Gp> __p(new _Gp(std::move(__tsp), std::forward<_Fp>(__f), std::forward<_Args>(__args)...));
213 int __ec = std::__libcpp_thread_create(&__t_, std::addressof(__thread_proxy<_Gp>), __p.get());
214 if (__ec == 0)
215 __p.release();
216 else
217 __throw_system_error(__ec, "thread constructor failed");
218 }
219# else // _LIBCPP_CXX03_LANG
220 template <class _Fp>
221 _LIBCPP_HIDE_FROM_ABI explicit thread(_Fp __f) {
222 typedef __thread_invoke_pair<_Fp> _InvokePair;
223 typedef unique_ptr<_InvokePair> _PairPtr;
224 _PairPtr __pp(new _InvokePair(__f));
225 int __ec = std::__libcpp_thread_create(&__t_, &__thread_proxy_cxx03<_InvokePair>, __pp.get());
226 if (__ec == 0)
227 __pp.release();
228 else
229 __throw_system_error(__ec, "thread constructor failed");
230 }
231# endif
232 ~thread();
233
234 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }
235
236 _LIBCPP_HIDE_FROM_ABI thread& operator=(thread&& __t) _NOEXCEPT {
237 if (!__libcpp_thread_isnull(&__t_))
238 terminate();
239 __t_ = __t.__t_;
240 __t.__t_ = _LIBCPP_NULL_THREAD;
241 return *this;
242 }
243
244 _LIBCPP_HIDE_FROM_ABI void swap(thread& __t) _NOEXCEPT { std::swap(__t_, __t.__t_); }
245
246 _LIBCPP_HIDE_FROM_ABI bool joinable() const _NOEXCEPT { return !__libcpp_thread_isnull(&__t_); }
247 void join();
248 void detach();
249 _LIBCPP_HIDE_FROM_ABI id get_id() const _NOEXCEPT { return __libcpp_thread_get_id(&__t_); }
250 _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() _NOEXCEPT { return __t_; }
251
252 static unsigned hardware_concurrency() _NOEXCEPT;
253};
254
259inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); }255inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x.swap(__y); }
260256
261#endif // _LIBCPP_HAS_THREADS257#endif // _LIBCPP_HAS_THREADS
lib/libcxx/include/__tree+269-361
...@@ -13,6 +13,9 @@...@@ -13,6 +13,9 @@
13#include <__algorithm/min.h>13#include <__algorithm/min.h>
14#include <__assert>14#include <__assert>
15#include <__config>15#include <__config>
16#include <__fwd/map.h>
17#include <__fwd/pair.h>
18#include <__fwd/set.h>
16#include <__iterator/distance.h>19#include <__iterator/distance.h>
17#include <__iterator/iterator_traits.h>20#include <__iterator/iterator_traits.h>
18#include <__iterator/next.h>21#include <__iterator/next.h>
...@@ -23,6 +26,7 @@...@@ -23,6 +26,7 @@
23#include <__memory/swap_allocator.h>26#include <__memory/swap_allocator.h>
24#include <__memory/unique_ptr.h>27#include <__memory/unique_ptr.h>
25#include <__type_traits/can_extract_key.h>28#include <__type_traits/can_extract_key.h>
29#include <__type_traits/copy_cvref.h>
26#include <__type_traits/enable_if.h>30#include <__type_traits/enable_if.h>
27#include <__type_traits/invoke.h>31#include <__type_traits/invoke.h>
28#include <__type_traits/is_const.h>32#include <__type_traits/is_const.h>
...@@ -31,6 +35,7 @@...@@ -31,6 +35,7 @@
31#include <__type_traits/is_nothrow_constructible.h>35#include <__type_traits/is_nothrow_constructible.h>
32#include <__type_traits/is_same.h>36#include <__type_traits/is_same.h>
33#include <__type_traits/is_swappable.h>37#include <__type_traits/is_swappable.h>
38#include <__type_traits/remove_const.h>
34#include <__type_traits/remove_const_ref.h>39#include <__type_traits/remove_const_ref.h>
35#include <__type_traits/remove_cvref.h>40#include <__type_traits/remove_cvref.h>
36#include <__utility/forward.h>41#include <__utility/forward.h>
...@@ -48,21 +53,12 @@ _LIBCPP_PUSH_MACROS...@@ -48,21 +53,12 @@ _LIBCPP_PUSH_MACROS
4853
49_LIBCPP_BEGIN_NAMESPACE_STD54_LIBCPP_BEGIN_NAMESPACE_STD
5055
51template <class, class, class, class>
52class _LIBCPP_TEMPLATE_VIS map;
53template <class, class, class, class>
54class _LIBCPP_TEMPLATE_VIS multimap;
55template <class, class, class>
56class _LIBCPP_TEMPLATE_VIS set;
57template <class, class, class>
58class _LIBCPP_TEMPLATE_VIS multiset;
59
60template <class _Tp, class _Compare, class _Allocator>56template <class _Tp, class _Compare, class _Allocator>
61class __tree;57class __tree;
62template <class _Tp, class _NodePtr, class _DiffType>58template <class _Tp, class _NodePtr, class _DiffType>
63class _LIBCPP_TEMPLATE_VIS __tree_iterator;59class __tree_iterator;
64template <class _Tp, class _ConstNodePtr, class _DiffType>60template <class _Tp, class _ConstNodePtr, class _DiffType>
65class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;61class __tree_const_iterator;
6662
67template <class _Pointer>63template <class _Pointer>
68class __tree_end_node;64class __tree_end_node;
...@@ -77,9 +73,9 @@ struct __value_type;...@@ -77,9 +73,9 @@ struct __value_type;
77template <class _Allocator>73template <class _Allocator>
78class __map_node_destructor;74class __map_node_destructor;
79template <class _TreeIterator>75template <class _TreeIterator>
80class _LIBCPP_TEMPLATE_VIS __map_iterator;76class __map_iterator;
81template <class _TreeIterator>77template <class _TreeIterator>
82class _LIBCPP_TEMPLATE_VIS __map_const_iterator;78class __map_const_iterator;
8379
84/*80/*
8581
...@@ -142,7 +138,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) {...@@ -142,7 +138,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) {
142}138}
143139
144// Determines if the red black tree rooted at __root is a proper red black tree.140// Determines if the red black tree rooted at __root is a proper red black tree.
145// __root == nullptr is a proper tree. Returns true is __root is a proper141// __root == nullptr is a proper tree. Returns true if __root is a proper
146// red black tree, else returns false.142// red black tree, else returns false.
147template <class _NodePtr>143template <class _NodePtr>
148_LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {144_LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {
...@@ -510,119 +506,42 @@ template <class _One>...@@ -510,119 +506,42 @@ template <class _One>
510struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};506struct __is_tree_value_type<_One> : __is_tree_value_type_imp<__remove_cvref_t<_One> > {};
511507
512template <class _Tp>508template <class _Tp>
513struct __tree_key_value_types {509struct __get_tree_key_type {
514 typedef _Tp key_type;510 using type _LIBCPP_NODEBUG = _Tp;
515 typedef _Tp __node_value_type;
516 typedef _Tp __container_value_type;
517 static const bool __is_map = false;
518
519 _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Tp const& __v) { return __v; }
520 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; }
521 _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); }
522 _LIBCPP_HIDE_FROM_ABI static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); }
523};511};
524512
525template <class _Key, class _Tp>513template <class _Key, class _ValueT>
526struct __tree_key_value_types<__value_type<_Key, _Tp> > {514struct __get_tree_key_type<__value_type<_Key, _ValueT> > {
527 typedef _Key key_type;515 using type _LIBCPP_NODEBUG = _Key;
528 typedef _Tp mapped_type;
529 typedef __value_type<_Key, _Tp> __node_value_type;
530 typedef pair<const _Key, _Tp> __container_value_type;
531 typedef __container_value_type __map_value_type;
532 static const bool __is_map = true;
533
534 _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__node_value_type const& __t) {
535 return __t.__get_value().first;
536 }
537
538 template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
539 _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Up& __t) {
540 return __t.first;
541 }
542
543 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __t) {
544 return __t.__get_value();
545 }
546
547 template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
548 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
549 return __t;
550 }
551
552 _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) {
553 return std::addressof(__n.__get_value());
554 }
555
556 _LIBCPP_HIDE_FROM_ABI static pair<key_type&&, mapped_type&&> __move(__node_value_type& __v) { return __v.__move(); }
557};516};
558517
559template <class _VoidPtr>518template <class _Tp>
560struct __tree_node_base_types {519using __get_tree_key_type_t _LIBCPP_NODEBUG = typename __get_tree_key_type<_Tp>::type;
561 typedef _VoidPtr __void_pointer;
562
563 typedef __tree_node_base<__void_pointer> __node_base_type;
564 typedef __rebind_pointer_t<_VoidPtr, __node_base_type> __node_base_pointer;
565
566 typedef __tree_end_node<__node_base_pointer> __end_node_type;
567 typedef __rebind_pointer_t<_VoidPtr, __end_node_type> __end_node_pointer;
568 typedef __end_node_pointer __parent_pointer;
569
570// TODO(LLVM 22): Remove this check
571#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
572 static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
573 _LIBCPP_ALIGNOF(__end_node_pointer),
574 "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy "
575 "pointer type that thas a different representation depending on whether it points to a __tree base "
576 "pointer or a __tree node pointer (both of which are implementation details of the standard library). "
577 "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your "
578 "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this "
579 "diagnostic.");
580#endif
581520
582private:521template <class _Tp>
583 static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value,522struct __get_node_value_type {
584 "_VoidPtr does not point to unqualified void type");523 using type _LIBCPP_NODEBUG = _Tp;
585};524};
586525
587template <class _Tp, class _AllocPtr, class _KVTypes = __tree_key_value_types<_Tp>, bool = _KVTypes::__is_map>526template <class _Key, class _ValueT>
588struct __tree_map_pointer_types {};527struct __get_node_value_type<__value_type<_Key, _ValueT> > {
589528 using type _LIBCPP_NODEBUG = pair<const _Key, _ValueT>;
590template <class _Tp, class _AllocPtr, class _KVTypes>
591struct __tree_map_pointer_types<_Tp, _AllocPtr, _KVTypes, true> {
592 typedef typename _KVTypes::__map_value_type _Mv;
593 typedef __rebind_pointer_t<_AllocPtr, _Mv> __map_value_type_pointer;
594 typedef __rebind_pointer_t<_AllocPtr, const _Mv> __const_map_value_type_pointer;
595};529};
596530
531template <class _Tp>
532using __get_node_value_type_t _LIBCPP_NODEBUG = typename __get_node_value_type<_Tp>::type;
533
597template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>534template <class _NodePtr, class _NodeT = typename pointer_traits<_NodePtr>::element_type>
598struct __tree_node_types;535struct __tree_node_types;
599536
600template <class _NodePtr, class _Tp, class _VoidPtr>537template <class _NodePtr, class _Tp, class _VoidPtr>
601struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> >538struct __tree_node_types<_NodePtr, __tree_node<_Tp, _VoidPtr> > {
602 : public __tree_node_base_types<_VoidPtr>, __tree_key_value_types<_Tp>, __tree_map_pointer_types<_Tp, _VoidPtr> {539 using __node_base_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> >;
603 typedef __tree_node_base_types<_VoidPtr> __base;540 using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<__node_base_pointer> >;
604 typedef __tree_key_value_types<_Tp> __key_base;
605 typedef __tree_map_pointer_types<_Tp, _VoidPtr> __map_pointer_base;
606
607public:
608 typedef typename pointer_traits<_NodePtr>::element_type __node_type;
609 typedef _NodePtr __node_pointer;
610
611 typedef _Tp __node_value_type;
612 typedef __rebind_pointer_t<_VoidPtr, __node_value_type> __node_value_type_pointer;
613 typedef __rebind_pointer_t<_VoidPtr, const __node_value_type> __const_node_value_type_pointer;
614 typedef typename __base::__end_node_pointer __iter_pointer;
615541
616private:542private:
617 static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");543 static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value,
618 static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value,544 "_VoidPtr does not point to unqualified void type");
619 "_VoidPtr does not rebind to _NodePtr.");
620};
621
622template <class _ValueTp, class _VoidPtr>
623struct __make_tree_node_types {
624 typedef __rebind_pointer_t<_VoidPtr, __tree_node<_ValueTp, _VoidPtr> > _NodePtr;
625 typedef __tree_node_types<_NodePtr> type;
626};545};
627546
628// node547// node
...@@ -637,20 +556,19 @@ public:...@@ -637,20 +556,19 @@ public:
637};556};
638557
639template <class _VoidPtr>558template <class _VoidPtr>
640class _LIBCPP_STANDALONE_DEBUG __tree_node_base : public __tree_node_base_types<_VoidPtr>::__end_node_type {559class _LIBCPP_STANDALONE_DEBUG
641 typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;560__tree_node_base : public __tree_end_node<__rebind_pointer_t<_VoidPtr, __tree_node_base<_VoidPtr> > > {
642
643public:561public:
644 typedef typename _NodeBaseTypes::__node_base_pointer pointer;562 using pointer = __rebind_pointer_t<_VoidPtr, __tree_node_base>;
645 typedef typename _NodeBaseTypes::__parent_pointer __parent_pointer;563 using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<_VoidPtr, __tree_end_node<pointer> >;
646564
647 pointer __right_;565 pointer __right_;
648 __parent_pointer __parent_;566 __end_node_pointer __parent_;
649 bool __is_black_;567 bool __is_black_;
650568
651 _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); }569 _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); }
652570
653 _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); }571 _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); }
654572
655 ~__tree_node_base() = delete;573 ~__tree_node_base() = delete;
656 __tree_node_base(__tree_node_base const&) = delete;574 __tree_node_base(__tree_node_base const&) = delete;
...@@ -660,11 +578,11 @@ public:...@@ -660,11 +578,11 @@ public:
660template <class _Tp, class _VoidPtr>578template <class _Tp, class _VoidPtr>
661class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {579class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
662public:580public:
663 typedef _Tp __node_value_type;581 using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>;
664582
665 __node_value_type __value_;583 __node_value_type __value_;
666584
667 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }585 _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
668586
669 ~__tree_node() = delete;587 ~__tree_node() = delete;
670 __tree_node(__tree_node const&) = delete;588 __tree_node(__tree_node const&) = delete;
...@@ -680,7 +598,6 @@ public:...@@ -680,7 +598,6 @@ public:
680 typedef typename __alloc_traits::pointer pointer;598 typedef typename __alloc_traits::pointer pointer;
681599
682private:600private:
683 typedef __tree_node_types<pointer> _NodeTypes;
684 allocator_type& __na_;601 allocator_type& __na_;
685602
686public:603public:
...@@ -695,7 +612,7 @@ public:...@@ -695,7 +612,7 @@ public:
695612
696 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {613 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
697 if (__value_constructed)614 if (__value_constructed)
698 __alloc_traits::destroy(__na_, _NodeTypes::__get_ptr(__p->__value_));615 __alloc_traits::destroy(__na_, std::addressof(__p->__value_));
699 if (__p)616 if (__p)
700 __alloc_traits::deallocate(__na_, __p, 1);617 __alloc_traits::deallocate(__na_, __p, 1);
701 }618 }
...@@ -714,22 +631,20 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> :...@@ -714,22 +631,20 @@ struct __generic_container_node_destructor<__tree_node<_Tp, _VoidPtr>, _Alloc> :
714#endif631#endif
715632
716template <class _Tp, class _NodePtr, class _DiffType>633template <class _Tp, class _NodePtr, class _DiffType>
717class _LIBCPP_TEMPLATE_VIS __tree_iterator {634class __tree_iterator {
718 typedef __tree_node_types<_NodePtr> _NodeTypes;635 typedef __tree_node_types<_NodePtr> _NodeTypes;
719 typedef _NodePtr __node_pointer;636 typedef _NodePtr __node_pointer;
720 typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;637 typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
721 typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;638 typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
722 typedef typename _NodeTypes::__iter_pointer __iter_pointer;
723 typedef pointer_traits<__node_pointer> __pointer_traits;
724639
725 __iter_pointer __ptr_;640 __end_node_pointer __ptr_;
726641
727public:642public:
728 typedef bidirectional_iterator_tag iterator_category;643 using iterator_category = bidirectional_iterator_tag;
729 typedef _Tp value_type;644 using value_type = __get_node_value_type_t<_Tp>;
730 typedef _DiffType difference_type;645 using difference_type = _DiffType;
731 typedef value_type& reference;646 using reference = value_type&;
732 typedef typename _NodeTypes::__node_value_type_pointer pointer;647 using pointer = __rebind_pointer_t<_NodePtr, value_type>;
733648
734 _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT649 _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT
735#if _LIBCPP_STD_VER >= 14650#if _LIBCPP_STD_VER >= 14
...@@ -742,8 +657,7 @@ public:...@@ -742,8 +657,7 @@ public:
742 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }657 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }
743658
744 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() {659 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() {
745 __ptr_ = static_cast<__iter_pointer>(660 __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
746 std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
747 return *this;661 return *this;
748 }662 }
749 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) {663 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) {
...@@ -753,8 +667,7 @@ public:...@@ -753,8 +667,7 @@ public:
753 }667 }
754668
755 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() {669 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() {
756 __ptr_ = static_cast<__iter_pointer>(670 __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
757 std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_)));
758 return *this;671 return *this;
759 }672 }
760 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) {673 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) {
...@@ -777,36 +690,35 @@ private:...@@ -777,36 +690,35 @@ private:
777 template <class, class, class>690 template <class, class, class>
778 friend class __tree;691 friend class __tree;
779 template <class, class, class>692 template <class, class, class>
780 friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;693 friend class __tree_const_iterator;
781 template <class>694 template <class>
782 friend class _LIBCPP_TEMPLATE_VIS __map_iterator;695 friend class __map_iterator;
783 template <class, class, class, class>696 template <class, class, class, class>
784 friend class _LIBCPP_TEMPLATE_VIS map;697 friend class map;
785 template <class, class, class, class>698 template <class, class, class, class>
786 friend class _LIBCPP_TEMPLATE_VIS multimap;699 friend class multimap;
787 template <class, class, class>700 template <class, class, class>
788 friend class _LIBCPP_TEMPLATE_VIS set;701 friend class set;
789 template <class, class, class>702 template <class, class, class>
790 friend class _LIBCPP_TEMPLATE_VIS multiset;703 friend class multiset;
791};704};
792705
793template <class _Tp, class _NodePtr, class _DiffType>706template <class _Tp, class _NodePtr, class _DiffType>
794class _LIBCPP_TEMPLATE_VIS __tree_const_iterator {707class __tree_const_iterator {
795 typedef __tree_node_types<_NodePtr> _NodeTypes;708 typedef __tree_node_types<_NodePtr> _NodeTypes;
796 typedef typename _NodeTypes::__node_pointer __node_pointer;709 // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing
710 using __node_pointer = _NodePtr;
797 typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;711 typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
798 typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;712 typedef typename _NodeTypes::__end_node_pointer __end_node_pointer;
799 typedef typename _NodeTypes::__iter_pointer __iter_pointer;
800 typedef pointer_traits<__node_pointer> __pointer_traits;
801713
802 __iter_pointer __ptr_;714 __end_node_pointer __ptr_;
803715
804public:716public:
805 typedef bidirectional_iterator_tag iterator_category;717 using iterator_category = bidirectional_iterator_tag;
806 typedef _Tp value_type;718 using value_type = __get_node_value_type_t<_Tp>;
807 typedef _DiffType difference_type;719 using difference_type = _DiffType;
808 typedef const value_type& reference;720 using reference = const value_type&;
809 typedef typename _NodeTypes::__const_node_value_type_pointer pointer;721 using pointer = __rebind_pointer_t<_NodePtr, const value_type>;
810722
811 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT723 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT
812#if _LIBCPP_STD_VER >= 14724#if _LIBCPP_STD_VER >= 14
...@@ -816,7 +728,7 @@ public:...@@ -816,7 +728,7 @@ public:
816 }728 }
817729
818private:730private:
819 typedef __tree_iterator<value_type, __node_pointer, difference_type> __non_const_iterator;731 typedef __tree_iterator<_Tp, __node_pointer, difference_type> __non_const_iterator;
820732
821public:733public:
822 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}734 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
...@@ -825,8 +737,7 @@ public:...@@ -825,8 +737,7 @@ public:
825 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }737 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }
826738
827 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() {739 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() {
828 __ptr_ = static_cast<__iter_pointer>(740 __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
829 std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_)));
830 return *this;741 return *this;
831 }742 }
832743
...@@ -837,8 +748,7 @@ public:...@@ -837,8 +748,7 @@ public:
837 }748 }
838749
839 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() {750 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() {
840 __ptr_ = static_cast<__iter_pointer>(751 __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
841 std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_pointer>(__ptr_)));
842 return *this;752 return *this;
843 }753 }
844754
...@@ -863,15 +773,15 @@ private:...@@ -863,15 +773,15 @@ private:
863 template <class, class, class>773 template <class, class, class>
864 friend class __tree;774 friend class __tree;
865 template <class, class, class, class>775 template <class, class, class, class>
866 friend class _LIBCPP_TEMPLATE_VIS map;776 friend class map;
867 template <class, class, class, class>777 template <class, class, class, class>
868 friend class _LIBCPP_TEMPLATE_VIS multimap;778 friend class multimap;
869 template <class, class, class>779 template <class, class, class>
870 friend class _LIBCPP_TEMPLATE_VIS set;780 friend class set;
871 template <class, class, class>781 template <class, class, class>
872 friend class _LIBCPP_TEMPLATE_VIS multiset;782 friend class multiset;
873 template <class>783 template <class>
874 friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;784 friend class __map_const_iterator;
875};785};
876786
877template <class _Tp, class _Compare>787template <class _Tp, class _Compare>
...@@ -884,42 +794,50 @@ int __diagnose_non_const_comparator();...@@ -884,42 +794,50 @@ int __diagnose_non_const_comparator();
884template <class _Tp, class _Compare, class _Allocator>794template <class _Tp, class _Compare, class _Allocator>
885class __tree {795class __tree {
886public:796public:
887 typedef _Tp value_type;797 using value_type = __get_node_value_type_t<_Tp>;
888 typedef _Compare value_compare;798 typedef _Compare value_compare;
889 typedef _Allocator allocator_type;799 typedef _Allocator allocator_type;
890800
891private:801private:
892 typedef allocator_traits<allocator_type> __alloc_traits;802 typedef allocator_traits<allocator_type> __alloc_traits;
893 typedef typename __make_tree_node_types<value_type, typename __alloc_traits::void_pointer>::type _NodeTypes;803 using key_type = __get_tree_key_type_t<_Tp>;
894 typedef typename _NodeTypes::key_type key_type;
895804
896public:805public:
897 typedef typename _NodeTypes::__node_value_type __node_value_type;
898 typedef typename _NodeTypes::__container_value_type __container_value_type;
899
900 typedef typename __alloc_traits::pointer pointer;806 typedef typename __alloc_traits::pointer pointer;
901 typedef typename __alloc_traits::const_pointer const_pointer;807 typedef typename __alloc_traits::const_pointer const_pointer;
902 typedef typename __alloc_traits::size_type size_type;808 typedef typename __alloc_traits::size_type size_type;
903 typedef typename __alloc_traits::difference_type difference_type;809 typedef typename __alloc_traits::difference_type difference_type;
904810
905public:811public:
906 typedef typename _NodeTypes::__void_pointer __void_pointer;812 using __void_pointer _LIBCPP_NODEBUG = typename __alloc_traits::void_pointer;
907813
908 typedef typename _NodeTypes::__node_type __node;814 using __node _LIBCPP_NODEBUG = __tree_node<_Tp, __void_pointer>;
909 typedef typename _NodeTypes::__node_pointer __node_pointer;815 // NOLINTNEXTLINE(libcpp-nodebug-on-aliases) lldb relies on this alias for pretty printing
816 using __node_pointer = __rebind_pointer_t<__void_pointer, __node>;
910817
911 typedef typename _NodeTypes::__node_base_type __node_base;818 using __node_base _LIBCPP_NODEBUG = __tree_node_base<__void_pointer>;
912 typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;819 using __node_base_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __node_base>;
913820
914 typedef typename _NodeTypes::__end_node_type __end_node_t;821 using __end_node_t _LIBCPP_NODEBUG = __tree_end_node<__node_base_pointer>;
915 typedef typename _NodeTypes::__end_node_pointer __end_node_ptr;822 using __end_node_pointer _LIBCPP_NODEBUG = __rebind_pointer_t<__void_pointer, __end_node_t>;
916823
917 typedef typename _NodeTypes::__parent_pointer __parent_pointer;824 using __parent_pointer _LIBCPP_NODEBUG = __end_node_pointer; // TODO: Remove this once the uses in <map> are removed
918 typedef typename _NodeTypes::__iter_pointer __iter_pointer;
919825
920 typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;826 typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
921 typedef allocator_traits<__node_allocator> __node_traits;827 typedef allocator_traits<__node_allocator> __node_traits;
922828
829// TODO(LLVM 22): Remove this check
830#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
831 static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
832 _LIBCPP_ALIGNOF(__end_node_pointer),
833 "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy "
834 "pointer type that thas a different representation depending on whether it points to a __tree base "
835 "pointer or a __tree node pointer (both of which are implementation details of the standard library). "
836 "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your "
837 "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this "
838 "diagnostic.");
839#endif
840
923private:841private:
924 // check for sane allocator pointer rebinding semantics. Rebinding the842 // check for sane allocator pointer rebinding semantics. Rebinding the
925 // allocator for a new pointer type should be exactly the same as rebinding843 // allocator for a new pointer type should be exactly the same as rebinding
...@@ -932,24 +850,23 @@ private:...@@ -932,24 +850,23 @@ private:
932 "Allocator does not rebind pointers in a sane manner.");850 "Allocator does not rebind pointers in a sane manner.");
933851
934private:852private:
935 __iter_pointer __begin_node_;853 __end_node_pointer __begin_node_;
936 _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_);854 _LIBCPP_COMPRESSED_PAIR(__end_node_t, __end_node_, __node_allocator, __node_alloc_);
937 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);855 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);
938856
939public:857public:
940 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT {858 _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() _NOEXCEPT {
941 return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_));859 return pointer_traits<__end_node_pointer>::pointer_to(__end_node_);
942 }860 }
943 _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT {861 _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() const _NOEXCEPT {
944 return static_cast<__iter_pointer>(862 return pointer_traits<__end_node_pointer>::pointer_to(const_cast<__end_node_t&>(__end_node_));
945 pointer_traits<__end_node_ptr>::pointer_to(const_cast<__end_node_t&>(__end_node_)));
946 }863 }
947 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }864 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }
948865
949private:866private:
950 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }867 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }
951 _LIBCPP_HIDE_FROM_ABI __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; }868 _LIBCPP_HIDE_FROM_ABI __end_node_pointer& __begin_node() _NOEXCEPT { return __begin_node_; }
952 _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; }869 _LIBCPP_HIDE_FROM_ABI const __end_node_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; }
953870
954public:871public:
955 _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }872 _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }
...@@ -971,8 +888,8 @@ public:...@@ -971,8 +888,8 @@ public:
971 return std::addressof(__end_node()->__left_);888 return std::addressof(__end_node()->__left_);
972 }889 }
973890
974 typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator;891 typedef __tree_iterator<_Tp, __node_pointer, difference_type> iterator;
975 typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;892 typedef __tree_const_iterator<_Tp, __node_pointer, difference_type> const_iterator;
976893
977 _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(894 _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
978 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);895 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value);
...@@ -987,9 +904,12 @@ public:...@@ -987,9 +904,12 @@ public:
987 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(904 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(
988 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);905 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);
989 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);906 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);
990 _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) _NOEXCEPT_(907 _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t)
991 __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&&908 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
992 is_nothrow_move_assignable<__node_allocator>::value);909 ((__node_traits::propagate_on_container_move_assignment::value &&
910 is_nothrow_move_assignable<__node_allocator>::value) ||
911 allocator_traits<__node_allocator>::is_always_equal::value));
912
993 _LIBCPP_HIDE_FROM_ABI ~__tree();913 _LIBCPP_HIDE_FROM_ABI ~__tree();
994914
995 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); }915 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node()); }
...@@ -1035,7 +955,7 @@ public:...@@ -1035,7 +955,7 @@ public:
1035955
1036 template <class _First,956 template <class _First,
1037 class _Second,957 class _Second,
1038 __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>958 __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0>
1039 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) {959 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_First&& __f, _Second&& __s) {
1040 return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s));960 return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s));
1041 }961 }
...@@ -1067,7 +987,7 @@ public:...@@ -1067,7 +987,7 @@ public:
1067987
1068 template <class _First,988 template <class _First,
1069 class _Second,989 class _Second,
1070 __enable_if_t<__can_extract_map_key<_First, key_type, __container_value_type>::value, int> = 0>990 __enable_if_t<__can_extract_map_key<_First, key_type, value_type>::value, int> = 0>
1071 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {991 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) {
1072 return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first;992 return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first;
1073 }993 }
...@@ -1095,52 +1015,28 @@ public:...@@ -1095,52 +1015,28 @@ public:
1095 return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first;1015 return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first;
1096 }1016 }
10971017
1098 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(const __container_value_type& __v) {1018 template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
1099 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v);1019 _LIBCPP_HIDE_FROM_ABI void
1100 }1020 __insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
11011021 __emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
1102 _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, const __container_value_type& __v) {
1103 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first;
1104 }
1105
1106 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(__container_value_type&& __v) {
1107 return __emplace_unique_key_args(_NodeTypes::__get_key(__v), std::move(__v));
1108 }
1109
1110 _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, __container_value_type&& __v) {
1111 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first;
1112 }
1113
1114 template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>
1115 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) {
1116 return __emplace_unique(std::forward<_Vp>(__v));
1117 }
1118
1119 template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>
1120 _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) {
1121 return __emplace_hint_unique(__p, std::forward<_Vp>(__v));
1122 }
1123
1124 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(__container_value_type&& __v) {
1125 return __emplace_multi(std::move(__v));
1126 }1022 }
11271023
1128 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, __container_value_type&& __v) {1024 template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
1129 return __emplace_hint_multi(__p, std::move(__v));1025 _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) {
1026 __emplace_hint_unique(__p, std::move(__value));
1130 }1027 }
11311028
1132 template <class _Vp>1029 template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
1133 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Vp&& __v) {1030 _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) {
1134 return __emplace_multi(std::forward<_Vp>(__v));1031 __emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
1135 }1032 }
11361033
1137 template <class _Vp>1034 template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
1138 _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Vp&& __v) {1035 _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) {
1139 return __emplace_hint_multi(__p, std::forward<_Vp>(__v));1036 __emplace_hint_multi(__p, std::move(__value));
1140 }1037 }
11411038
1142 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool>1039 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __node_assign_unique(const value_type& __v, __node_pointer __dest);
1143 __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
11441040
1145 _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd);1041 _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd);
1146 _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);1042 _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);
...@@ -1176,7 +1072,7 @@ public:...@@ -1176,7 +1072,7 @@ public:
1176 _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k);1072 _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k);
11771073
1178 _LIBCPP_HIDE_FROM_ABI void1074 _LIBCPP_HIDE_FROM_ABI void
1179 __insert_node_at(__parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;1075 __insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;
11801076
1181 template <class _Key>1077 template <class _Key>
1182 _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v);1078 _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __v);
...@@ -1193,27 +1089,27 @@ public:...@@ -1193,27 +1089,27 @@ public:
1193 return __lower_bound(__v, __root(), __end_node());1089 return __lower_bound(__v, __root(), __end_node());
1194 }1090 }
1195 template <class _Key>1091 template <class _Key>
1196 _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result);1092 _LIBCPP_HIDE_FROM_ABI iterator __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
1197 template <class _Key>1093 template <class _Key>
1198 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const {1094 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _Key& __v) const {
1199 return __lower_bound(__v, __root(), __end_node());1095 return __lower_bound(__v, __root(), __end_node());
1200 }1096 }
1201 template <class _Key>1097 template <class _Key>
1202 _LIBCPP_HIDE_FROM_ABI const_iterator1098 _LIBCPP_HIDE_FROM_ABI const_iterator
1203 __lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const;1099 __lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
1204 template <class _Key>1100 template <class _Key>
1205 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) {1101 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _Key& __v) {
1206 return __upper_bound(__v, __root(), __end_node());1102 return __upper_bound(__v, __root(), __end_node());
1207 }1103 }
1208 template <class _Key>1104 template <class _Key>
1209 _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result);1105 _LIBCPP_HIDE_FROM_ABI iterator __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
1210 template <class _Key>1106 template <class _Key>
1211 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const {1107 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _Key& __v) const {
1212 return __upper_bound(__v, __root(), __end_node());1108 return __upper_bound(__v, __root(), __end_node());
1213 }1109 }
1214 template <class _Key>1110 template <class _Key>
1215 _LIBCPP_HIDE_FROM_ABI const_iterator1111 _LIBCPP_HIDE_FROM_ABI const_iterator
1216 __upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) const;1112 __upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
1217 template <class _Key>1113 template <class _Key>
1218 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k);1114 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k);
1219 template <class _Key>1115 template <class _Key>
...@@ -1229,28 +1125,17 @@ public:...@@ -1229,28 +1125,17 @@ public:
12291125
1230 _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;1126 _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;
12311127
1232private:
1233 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__parent_pointer& __parent, const key_type& __v);
1234 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__parent_pointer& __parent, const key_type& __v);
1235 _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
1236 __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v);
1237 // FIXME: Make this function const qualified. Unfortunately doing so1128 // FIXME: Make this function const qualified. Unfortunately doing so
1238 // breaks existing code which uses non-const callable comparators.1129 // breaks existing code which uses non-const callable comparators.
1239 template <class _Key>1130 template <class _Key>
1240 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v);1131 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v);
1241 template <class _Key>1132 template <class _Key>
1242 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v) const {1133 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__end_node_pointer& __parent, const _Key& __v) const {
1243 return const_cast<__tree*>(this)->__find_equal(__parent, __v);1134 return const_cast<__tree*>(this)->__find_equal(__parent, __v);
1244 }1135 }
1245 template <class _Key>1136 template <class _Key>
1246 _LIBCPP_HIDE_FROM_ABI __node_base_pointer&1137 _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
1247 __find_equal(const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v);1138 __find_equal(const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v);
1248
1249 template <class... _Args>
1250 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
1251
1252 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
1253 _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
12541139
1255 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {1140 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {
1256 __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());1141 __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());
...@@ -1263,6 +1148,20 @@ private:...@@ -1263,6 +1148,20 @@ private:
1263 }1148 }
1264 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}1149 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}
12651150
1151private:
1152 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__end_node_pointer& __parent, const value_type& __v);
1153
1154 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__end_node_pointer& __parent, const value_type& __v);
1155
1156 _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
1157 __find_leaf(const_iterator __hint, __end_node_pointer& __parent, const value_type& __v);
1158
1159 template <class... _Args>
1160 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
1161
1162 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
1163 _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
1164
1266 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);1165 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
1267 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(1166 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
1268 is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);1167 is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);
...@@ -1279,6 +1178,21 @@ private:...@@ -1279,6 +1178,21 @@ private:
1279 }1178 }
1280 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}1179 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
12811180
1181 template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type<_ValueT>::value, int> = 0>
1182 _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
1183 using __key_type = __remove_const_t<typename value_type::first_type>;
1184
1185 // This is technically UB, since the object was constructed as `const`.
1186 // Clang doesn't optimize on this currently though.
1187 const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
1188 __lhs.second = std::forward<_From>(__rhs).second;
1189 }
1190
1191 template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type<_ValueT>::value, int> = 0>
1192 _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
1193 __lhs = std::forward<_From>(__rhs);
1194 }
1195
1282 struct _DetachedTreeCache {1196 struct _DetachedTreeCache {
1283 _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT1197 _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT
1284 : __t_(__t),1198 : __t_(__t),
...@@ -1315,11 +1229,6 @@ private:...@@ -1315,11 +1229,6 @@ private:
1315 __node_pointer __cache_root_;1229 __node_pointer __cache_root_;
1316 __node_pointer __cache_elem_;1230 __node_pointer __cache_elem_;
1317 };1231 };
1318
1319 template <class, class, class, class>
1320 friend class _LIBCPP_TEMPLATE_VIS map;
1321 template <class, class, class, class>
1322 friend class _LIBCPP_TEMPLATE_VIS multimap;
1323};1232};
13241233
1325template <class _Tp, class _Compare, class _Allocator>1234template <class _Tp, class _Compare, class _Allocator>
...@@ -1331,13 +1240,13 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT...@@ -1331,13 +1240,13 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT
13311240
1332template <class _Tp, class _Compare, class _Allocator>1241template <class _Tp, class _Compare, class _Allocator>
1333__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)1242__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a)
1334 : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) {1243 : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
1335 __begin_node() = __end_node();1244 __begin_node() = __end_node();
1336}1245}
13371246
1338template <class _Tp, class _Compare, class _Allocator>1247template <class _Tp, class _Compare, class _Allocator>
1339__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)1248__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a)
1340 : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {1249 : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
1341 __begin_node() = __end_node();1250 __begin_node() = __end_node();
1342}1251}
13431252
...@@ -1397,8 +1306,8 @@ template <class _ForwardIterator>...@@ -1397,8 +1306,8 @@ template <class _ForwardIterator>
1397void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {1306void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {
1398 typedef iterator_traits<_ForwardIterator> _ITraits;1307 typedef iterator_traits<_ForwardIterator> _ITraits;
1399 typedef typename _ITraits::value_type _ItValueType;1308 typedef typename _ITraits::value_type _ItValueType;
1400 static_assert(is_same<_ItValueType, __container_value_type>::value,1309 static_assert(
1401 "__assign_unique may only be called with the containers value type");1310 is_same<_ItValueType, value_type>::value, "__assign_unique may only be called with the containers value type");
1402 static_assert(1311 static_assert(
1403 __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator");1312 __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator");
1404 if (size() != 0) {1313 if (size() != 0) {
...@@ -1409,7 +1318,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first...@@ -1409,7 +1318,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first
1409 }1318 }
1410 }1319 }
1411 for (; __first != __last; ++__first)1320 for (; __first != __last; ++__first)
1412 __insert_unique(*__first);1321 __emplace_unique(*__first);
1413}1322}
14141323
1415template <class _Tp, class _Compare, class _Allocator>1324template <class _Tp, class _Compare, class _Allocator>
...@@ -1418,24 +1327,23 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _...@@ -1418,24 +1327,23 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _
1418 typedef iterator_traits<_InputIterator> _ITraits;1327 typedef iterator_traits<_InputIterator> _ITraits;
1419 typedef typename _ITraits::value_type _ItValueType;1328 typedef typename _ITraits::value_type _ItValueType;
1420 static_assert(1329 static_assert(
1421 (is_same<_ItValueType, __container_value_type>::value || is_same<_ItValueType, __node_value_type>::value),1330 is_same<_ItValueType, value_type>::value, "__assign_multi may only be called with the containers value_type");
1422 "__assign_multi may only be called with the containers value type"
1423 " or the nodes value type");
1424 if (size() != 0) {1331 if (size() != 0) {
1425 _DetachedTreeCache __cache(this);1332 _DetachedTreeCache __cache(this);
1426 for (; __cache.__get() && __first != __last; ++__first) {1333 for (; __cache.__get() && __first != __last; ++__first) {
1427 __cache.__get()->__value_ = *__first;1334 __assign_value(__cache.__get()->__value_, *__first);
1428 __node_insert_multi(__cache.__get());1335 __node_insert_multi(__cache.__get());
1429 __cache.__advance();1336 __cache.__advance();
1430 }1337 }
1431 }1338 }
1339 const_iterator __e = end();
1432 for (; __first != __last; ++__first)1340 for (; __first != __last; ++__first)
1433 __insert_multi(_NodeTypes::__get_value(*__first));1341 __emplace_hint_multi(__e, *__first);
1434}1342}
14351343
1436template <class _Tp, class _Compare, class _Allocator>1344template <class _Tp, class _Compare, class _Allocator>
1437__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)1345__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
1438 : __begin_node_(__iter_pointer()),1346 : __begin_node_(),
1439 __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),1347 __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
1440 __size_(0),1348 __size_(0),
1441 __value_comp_(__t.value_comp()) {1349 __value_comp_(__t.value_comp()) {
...@@ -1453,7 +1361,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(...@@ -1453,7 +1361,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
1453 if (size() == 0)1361 if (size() == 0)
1454 __begin_node() = __end_node();1362 __begin_node() = __end_node();
1455 else {1363 else {
1456 __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());1364 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1457 __t.__begin_node() = __t.__end_node();1365 __t.__begin_node() = __t.__end_node();
1458 __t.__end_node()->__left_ = nullptr;1366 __t.__end_node()->__left_ = nullptr;
1459 __t.size() = 0;1367 __t.size() = 0;
...@@ -1469,7 +1377,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __...@@ -1469,7 +1377,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __
1469 else {1377 else {
1470 __begin_node() = __t.__begin_node();1378 __begin_node() = __t.__begin_node();
1471 __end_node()->__left_ = __t.__end_node()->__left_;1379 __end_node()->__left_ = __t.__end_node()->__left_;
1472 __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());1380 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1473 size() = __t.size();1381 size() = __t.size();
1474 __t.__begin_node() = __t.__end_node();1382 __t.__begin_node() = __t.__end_node();
1475 __t.__end_node()->__left_ = nullptr;1383 __t.__end_node()->__left_ = nullptr;
...@@ -1492,7 +1400,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)...@@ -1492,7 +1400,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
1492 if (size() == 0)1400 if (size() == 0)
1493 __begin_node() = __end_node();1401 __begin_node() = __end_node();
1494 else {1402 else {
1495 __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());1403 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1496 __t.__begin_node() = __t.__end_node();1404 __t.__begin_node() = __t.__end_node();
1497 __t.__end_node()->__left_ = nullptr;1405 __t.__end_node()->__left_ = nullptr;
1498 __t.size() = 0;1406 __t.size() = 0;
...@@ -1509,22 +1417,23 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {...@@ -1509,22 +1417,23 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
1509 if (size() != 0) {1417 if (size() != 0) {
1510 _DetachedTreeCache __cache(this);1418 _DetachedTreeCache __cache(this);
1511 while (__cache.__get() != nullptr && __t.size() != 0) {1419 while (__cache.__get() != nullptr && __t.size() != 0) {
1512 __cache.__get()->__value_ = std::move(__t.remove(__t.begin())->__value_);1420 __assign_value(__cache.__get()->__value_, std::move(__t.remove(__t.begin())->__value_));
1513 __node_insert_multi(__cache.__get());1421 __node_insert_multi(__cache.__get());
1514 __cache.__advance();1422 __cache.__advance();
1515 }1423 }
1516 }1424 }
1517 while (__t.size() != 0)1425 while (__t.size() != 0) {
1518 __insert_multi(__e, _NodeTypes::__move(__t.remove(__t.begin())->__value_));1426 __insert_multi_from_orphaned_node(__e, std::move(__t.remove(__t.begin())->__value_));
1427 }
1519 }1428 }
1520}1429}
15211430
1522template <class _Tp, class _Compare, class _Allocator>1431template <class _Tp, class _Compare, class _Allocator>
1523__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) _NOEXCEPT_(1432__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t)
1524 __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<value_compare>::value&&1433 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
1525 is_nothrow_move_assignable<__node_allocator>::value)1434 ((__node_traits::propagate_on_container_move_assignment::value &&
15261435 is_nothrow_move_assignable<__node_allocator>::value) ||
1527{1436 allocator_traits<__node_allocator>::is_always_equal::value)) {
1528 __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());1437 __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1529 return *this;1438 return *this;
1530}1439}
...@@ -1541,7 +1450,7 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {...@@ -1541,7 +1450,7 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
1541 destroy(static_cast<__node_pointer>(__nd->__left_));1450 destroy(static_cast<__node_pointer>(__nd->__left_));
1542 destroy(static_cast<__node_pointer>(__nd->__right_));1451 destroy(static_cast<__node_pointer>(__nd->__right_));
1543 __node_allocator& __na = __node_alloc();1452 __node_allocator& __na = __node_alloc();
1544 __node_traits::destroy(__na, _NodeTypes::__get_ptr(__nd->__value_));1453 __node_traits::destroy(__na, std::addressof(__nd->__value_));
1545 __node_traits::deallocate(__na, __nd, 1);1454 __node_traits::deallocate(__na, __nd, 1);
1546 }1455 }
1547}1456}
...@@ -1564,11 +1473,11 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)...@@ -1564,11 +1473,11 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
1564 if (size() == 0)1473 if (size() == 0)
1565 __begin_node() = __end_node();1474 __begin_node() = __end_node();
1566 else1475 else
1567 __end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__end_node());1476 __end_node()->__left_->__parent_ = __end_node();
1568 if (__t.size() == 0)1477 if (__t.size() == 0)
1569 __t.__begin_node() = __t.__end_node();1478 __t.__begin_node() = __t.__end_node();
1570 else1479 else
1571 __t.__end_node()->__left_->__parent_ = static_cast<__parent_pointer>(__t.__end_node());1480 __t.__end_node()->__left_->__parent_ = __t.__end_node();
1572}1481}
15731482
1574template <class _Tp, class _Compare, class _Allocator>1483template <class _Tp, class _Compare, class _Allocator>
...@@ -1584,7 +1493,7 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {...@@ -1584,7 +1493,7 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
1584// Return reference to null leaf1493// Return reference to null leaf
1585template <class _Tp, class _Compare, class _Allocator>1494template <class _Tp, class _Compare, class _Allocator>
1586typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&1495typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1587__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, const key_type& __v) {1496__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, const value_type& __v) {
1588 __node_pointer __nd = __root();1497 __node_pointer __nd = __root();
1589 if (__nd != nullptr) {1498 if (__nd != nullptr) {
1590 while (true) {1499 while (true) {
...@@ -1592,20 +1501,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c...@@ -1592,20 +1501,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c
1592 if (__nd->__right_ != nullptr)1501 if (__nd->__right_ != nullptr)
1593 __nd = static_cast<__node_pointer>(__nd->__right_);1502 __nd = static_cast<__node_pointer>(__nd->__right_);
1594 else {1503 else {
1595 __parent = static_cast<__parent_pointer>(__nd);1504 __parent = static_cast<__end_node_pointer>(__nd);
1596 return __nd->__right_;1505 return __nd->__right_;
1597 }1506 }
1598 } else {1507 } else {
1599 if (__nd->__left_ != nullptr)1508 if (__nd->__left_ != nullptr)
1600 __nd = static_cast<__node_pointer>(__nd->__left_);1509 __nd = static_cast<__node_pointer>(__nd->__left_);
1601 else {1510 else {
1602 __parent = static_cast<__parent_pointer>(__nd);1511 __parent = static_cast<__end_node_pointer>(__nd);
1603 return __parent->__left_;1512 return __parent->__left_;
1604 }1513 }
1605 }1514 }
1606 }1515 }
1607 }1516 }
1608 __parent = static_cast<__parent_pointer>(__end_node());1517 __parent = __end_node();
1609 return __parent->__left_;1518 return __parent->__left_;
1610}1519}
16111520
...@@ -1614,7 +1523,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c...@@ -1614,7 +1523,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__parent_pointer& __parent, c
1614// Return reference to null leaf1523// Return reference to null leaf
1615template <class _Tp, class _Compare, class _Allocator>1524template <class _Tp, class _Compare, class _Allocator>
1616typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&1525typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1617__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent, const key_type& __v) {1526__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent, const value_type& __v) {
1618 __node_pointer __nd = __root();1527 __node_pointer __nd = __root();
1619 if (__nd != nullptr) {1528 if (__nd != nullptr) {
1620 while (true) {1529 while (true) {
...@@ -1622,20 +1531,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent,...@@ -1622,20 +1531,20 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent,
1622 if (__nd->__left_ != nullptr)1531 if (__nd->__left_ != nullptr)
1623 __nd = static_cast<__node_pointer>(__nd->__left_);1532 __nd = static_cast<__node_pointer>(__nd->__left_);
1624 else {1533 else {
1625 __parent = static_cast<__parent_pointer>(__nd);1534 __parent = static_cast<__end_node_pointer>(__nd);
1626 return __parent->__left_;1535 return __parent->__left_;
1627 }1536 }
1628 } else {1537 } else {
1629 if (__nd->__right_ != nullptr)1538 if (__nd->__right_ != nullptr)
1630 __nd = static_cast<__node_pointer>(__nd->__right_);1539 __nd = static_cast<__node_pointer>(__nd->__right_);
1631 else {1540 else {
1632 __parent = static_cast<__parent_pointer>(__nd);1541 __parent = static_cast<__end_node_pointer>(__nd);
1633 return __nd->__right_;1542 return __nd->__right_;
1634 }1543 }
1635 }1544 }
1636 }1545 }
1637 }1546 }
1638 __parent = static_cast<__parent_pointer>(__end_node());1547 __parent = __end_node();
1639 return __parent->__left_;1548 return __parent->__left_;
1640}1549}
16411550
...@@ -1646,8 +1555,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent,...@@ -1646,8 +1555,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__parent_pointer& __parent,
1646// Set __parent to parent of null leaf1555// Set __parent to parent of null leaf
1647// Return reference to null leaf1556// Return reference to null leaf
1648template <class _Tp, class _Compare, class _Allocator>1557template <class _Tp, class _Compare, class _Allocator>
1649typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&1558typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf(
1650__tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v) {1559 const_iterator __hint, __end_node_pointer& __parent, const value_type& __v) {
1651 if (__hint == end() || !value_comp()(*__hint, __v)) // check before1560 if (__hint == end() || !value_comp()(*__hint, __v)) // check before
1652 {1561 {
1653 // __v <= *__hint1562 // __v <= *__hint
...@@ -1655,10 +1564,10 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p...@@ -1655,10 +1564,10 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p
1655 if (__prior == begin() || !value_comp()(__v, *--__prior)) {1564 if (__prior == begin() || !value_comp()(__v, *--__prior)) {
1656 // *prev(__hint) <= __v <= *__hint1565 // *prev(__hint) <= __v <= *__hint
1657 if (__hint.__ptr_->__left_ == nullptr) {1566 if (__hint.__ptr_->__left_ == nullptr) {
1658 __parent = static_cast<__parent_pointer>(__hint.__ptr_);1567 __parent = static_cast<__end_node_pointer>(__hint.__ptr_);
1659 return __parent->__left_;1568 return __parent->__left_;
1660 } else {1569 } else {
1661 __parent = static_cast<__parent_pointer>(__prior.__ptr_);1570 __parent = static_cast<__end_node_pointer>(__prior.__ptr_);
1662 return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;1571 return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
1663 }1572 }
1664 }1573 }
...@@ -1676,7 +1585,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p...@@ -1676,7 +1585,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p
1676template <class _Tp, class _Compare, class _Allocator>1585template <class _Tp, class _Compare, class _Allocator>
1677template <class _Key>1586template <class _Key>
1678typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&1587typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1679__tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, const _Key& __v) {1588__tree<_Tp, _Compare, _Allocator>::__find_equal(__end_node_pointer& __parent, const _Key& __v) {
1680 __node_pointer __nd = __root();1589 __node_pointer __nd = __root();
1681 __node_base_pointer* __nd_ptr = __root_ptr();1590 __node_base_pointer* __nd_ptr = __root_ptr();
1682 if (__nd != nullptr) {1591 if (__nd != nullptr) {
...@@ -1686,7 +1595,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons...@@ -1686,7 +1595,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons
1686 __nd_ptr = std::addressof(__nd->__left_);1595 __nd_ptr = std::addressof(__nd->__left_);
1687 __nd = static_cast<__node_pointer>(__nd->__left_);1596 __nd = static_cast<__node_pointer>(__nd->__left_);
1688 } else {1597 } else {
1689 __parent = static_cast<__parent_pointer>(__nd);1598 __parent = static_cast<__end_node_pointer>(__nd);
1690 return __parent->__left_;1599 return __parent->__left_;
1691 }1600 }
1692 } else if (value_comp()(__nd->__value_, __v)) {1601 } else if (value_comp()(__nd->__value_, __v)) {
...@@ -1694,16 +1603,16 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons...@@ -1694,16 +1603,16 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons
1694 __nd_ptr = std::addressof(__nd->__right_);1603 __nd_ptr = std::addressof(__nd->__right_);
1695 __nd = static_cast<__node_pointer>(__nd->__right_);1604 __nd = static_cast<__node_pointer>(__nd->__right_);
1696 } else {1605 } else {
1697 __parent = static_cast<__parent_pointer>(__nd);1606 __parent = static_cast<__end_node_pointer>(__nd);
1698 return __nd->__right_;1607 return __nd->__right_;
1699 }1608 }
1700 } else {1609 } else {
1701 __parent = static_cast<__parent_pointer>(__nd);1610 __parent = static_cast<__end_node_pointer>(__nd);
1702 return *__nd_ptr;1611 return *__nd_ptr;
1703 }1612 }
1704 }1613 }
1705 }1614 }
1706 __parent = static_cast<__parent_pointer>(__end_node());1615 __parent = __end_node();
1707 return __parent->__left_;1616 return __parent->__left_;
1708}1617}
17091618
...@@ -1717,7 +1626,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons...@@ -1717,7 +1626,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons
1717template <class _Tp, class _Compare, class _Allocator>1626template <class _Tp, class _Compare, class _Allocator>
1718template <class _Key>1627template <class _Key>
1719typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(1628typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(
1720 const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) {1629 const_iterator __hint, __end_node_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) {
1721 if (__hint == end() || value_comp()(__v, *__hint)) // check before1630 if (__hint == end() || value_comp()(__v, *__hint)) // check before
1722 {1631 {
1723 // __v < *__hint1632 // __v < *__hint
...@@ -1725,10 +1634,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co...@@ -1725,10 +1634,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
1725 if (__prior == begin() || value_comp()(*--__prior, __v)) {1634 if (__prior == begin() || value_comp()(*--__prior, __v)) {
1726 // *prev(__hint) < __v < *__hint1635 // *prev(__hint) < __v < *__hint
1727 if (__hint.__ptr_->__left_ == nullptr) {1636 if (__hint.__ptr_->__left_ == nullptr) {
1728 __parent = static_cast<__parent_pointer>(__hint.__ptr_);1637 __parent = __hint.__ptr_;
1729 return __parent->__left_;1638 return __parent->__left_;
1730 } else {1639 } else {
1731 __parent = static_cast<__parent_pointer>(__prior.__ptr_);1640 __parent = __prior.__ptr_;
1732 return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;1641 return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
1733 }1642 }
1734 }1643 }
...@@ -1741,10 +1650,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co...@@ -1741,10 +1650,10 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
1741 if (__next == end() || value_comp()(__v, *__next)) {1650 if (__next == end() || value_comp()(__v, *__next)) {
1742 // *__hint < __v < *std::next(__hint)1651 // *__hint < __v < *std::next(__hint)
1743 if (__hint.__get_np()->__right_ == nullptr) {1652 if (__hint.__get_np()->__right_ == nullptr) {
1744 __parent = static_cast<__parent_pointer>(__hint.__ptr_);1653 __parent = __hint.__ptr_;
1745 return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_;1654 return static_cast<__node_base_pointer>(__hint.__ptr_)->__right_;
1746 } else {1655 } else {
1747 __parent = static_cast<__parent_pointer>(__next.__ptr_);1656 __parent = __next.__ptr_;
1748 return __parent->__left_;1657 return __parent->__left_;
1749 }1658 }
1750 }1659 }
...@@ -1752,21 +1661,21 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co...@@ -1752,21 +1661,21 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
1752 return __find_equal(__parent, __v);1661 return __find_equal(__parent, __v);
1753 }1662 }
1754 // else __v == *__hint1663 // else __v == *__hint
1755 __parent = static_cast<__parent_pointer>(__hint.__ptr_);1664 __parent = __hint.__ptr_;
1756 __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);1665 __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);
1757 return __dummy;1666 return __dummy;
1758}1667}
17591668
1760template <class _Tp, class _Compare, class _Allocator>1669template <class _Tp, class _Compare, class _Allocator>
1761void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(1670void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
1762 __parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {1671 __end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {
1763 __new_node->__left_ = nullptr;1672 __new_node->__left_ = nullptr;
1764 __new_node->__right_ = nullptr;1673 __new_node->__right_ = nullptr;
1765 __new_node->__parent_ = __parent;1674 __new_node->__parent_ = __parent;
1766 // __new_node->__is_black_ is initialized in __tree_balance_after_insert1675 // __new_node->__is_black_ is initialized in __tree_balance_after_insert
1767 __child = __new_node;1676 __child = __new_node;
1768 if (__begin_node()->__left_ != nullptr)1677 if (__begin_node()->__left_ != nullptr)
1769 __begin_node() = static_cast<__iter_pointer>(__begin_node()->__left_);1678 __begin_node() = static_cast<__end_node_pointer>(__begin_node()->__left_);
1770 std::__tree_balance_after_insert(__end_node()->__left_, __child);1679 std::__tree_balance_after_insert(__end_node()->__left_, __child);
1771 ++size();1680 ++size();
1772}1681}
...@@ -1775,7 +1684,7 @@ template <class _Tp, class _Compare, class _Allocator>...@@ -1775,7 +1684,7 @@ template <class _Tp, class _Compare, class _Allocator>
1775template <class _Key, class... _Args>1684template <class _Key, class... _Args>
1776pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>1685pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
1777__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) {1686__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) {
1778 __parent_pointer __parent;1687 __end_node_pointer __parent;
1779 __node_base_pointer& __child = __find_equal(__parent, __k);1688 __node_base_pointer& __child = __find_equal(__parent, __k);
1780 __node_pointer __r = static_cast<__node_pointer>(__child);1689 __node_pointer __r = static_cast<__node_pointer>(__child);
1781 bool __inserted = false;1690 bool __inserted = false;
...@@ -1793,7 +1702,7 @@ template <class _Key, class... _Args>...@@ -1793,7 +1702,7 @@ template <class _Key, class... _Args>
1793pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>1702pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
1794__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(1703__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
1795 const_iterator __p, _Key const& __k, _Args&&... __args) {1704 const_iterator __p, _Key const& __k, _Args&&... __args) {
1796 __parent_pointer __parent;1705 __end_node_pointer __parent;
1797 __node_base_pointer __dummy;1706 __node_base_pointer __dummy;
1798 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);1707 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k);
1799 __node_pointer __r = static_cast<__node_pointer>(__child);1708 __node_pointer __r = static_cast<__node_pointer>(__child);
...@@ -1811,10 +1720,9 @@ template <class _Tp, class _Compare, class _Allocator>...@@ -1811,10 +1720,9 @@ template <class _Tp, class _Compare, class _Allocator>
1811template <class... _Args>1720template <class... _Args>
1812typename __tree<_Tp, _Compare, _Allocator>::__node_holder1721typename __tree<_Tp, _Compare, _Allocator>::__node_holder
1813__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {1722__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
1814 static_assert(!__is_tree_value_type<_Args...>::value, "Cannot construct from __value_type");
1815 __node_allocator& __na = __node_alloc();1723 __node_allocator& __na = __node_alloc();
1816 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));1724 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1817 __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...);1725 __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1818 __h.get_deleter().__value_constructed = true;1726 __h.get_deleter().__value_constructed = true;
1819 return __h;1727 return __h;
1820}1728}
...@@ -1824,7 +1732,7 @@ template <class... _Args>...@@ -1824,7 +1732,7 @@ template <class... _Args>
1824pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>1732pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
1825__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) {1733__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) {
1826 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);1734 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
1827 __parent_pointer __parent;1735 __end_node_pointer __parent;
1828 __node_base_pointer& __child = __find_equal(__parent, __h->__value_);1736 __node_base_pointer& __child = __find_equal(__parent, __h->__value_);
1829 __node_pointer __r = static_cast<__node_pointer>(__child);1737 __node_pointer __r = static_cast<__node_pointer>(__child);
1830 bool __inserted = false;1738 bool __inserted = false;
...@@ -1841,7 +1749,7 @@ template <class... _Args>...@@ -1841,7 +1749,7 @@ template <class... _Args>
1841typename __tree<_Tp, _Compare, _Allocator>::iterator1749typename __tree<_Tp, _Compare, _Allocator>::iterator
1842__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) {1750__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) {
1843 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);1751 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
1844 __parent_pointer __parent;1752 __end_node_pointer __parent;
1845 __node_base_pointer __dummy;1753 __node_base_pointer __dummy;
1846 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_);1754 __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __h->__value_);
1847 __node_pointer __r = static_cast<__node_pointer>(__child);1755 __node_pointer __r = static_cast<__node_pointer>(__child);
...@@ -1857,8 +1765,8 @@ template <class... _Args>...@@ -1857,8 +1765,8 @@ template <class... _Args>
1857typename __tree<_Tp, _Compare, _Allocator>::iterator1765typename __tree<_Tp, _Compare, _Allocator>::iterator
1858__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {1766__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {
1859 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);1767 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
1860 __parent_pointer __parent;1768 __end_node_pointer __parent;
1861 __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_));1769 __node_base_pointer& __child = __find_leaf_high(__parent, __h->__value_);
1862 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));1770 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1863 return iterator(static_cast<__node_pointer>(__h.release()));1771 return iterator(static_cast<__node_pointer>(__h.release()));
1864}1772}
...@@ -1868,21 +1776,21 @@ template <class... _Args>...@@ -1868,21 +1776,21 @@ template <class... _Args>
1868typename __tree<_Tp, _Compare, _Allocator>::iterator1776typename __tree<_Tp, _Compare, _Allocator>::iterator
1869__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) {1777__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) {
1870 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);1778 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
1871 __parent_pointer __parent;1779 __end_node_pointer __parent;
1872 __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_));1780 __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__value_);
1873 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));1781 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1874 return iterator(static_cast<__node_pointer>(__h.release()));1782 return iterator(static_cast<__node_pointer>(__h.release()));
1875}1783}
18761784
1877template <class _Tp, class _Compare, class _Allocator>1785template <class _Tp, class _Compare, class _Allocator>
1878pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>1786pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
1879__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd) {1787__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, __node_pointer __nd) {
1880 __parent_pointer __parent;1788 __end_node_pointer __parent;
1881 __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v));1789 __node_base_pointer& __child = __find_equal(__parent, __v);
1882 __node_pointer __r = static_cast<__node_pointer>(__child);1790 __node_pointer __r = static_cast<__node_pointer>(__child);
1883 bool __inserted = false;1791 bool __inserted = false;
1884 if (__child == nullptr) {1792 if (__child == nullptr) {
1885 __nd->__value_ = __v;1793 __assign_value(__nd->__value_, __v);
1886 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));1794 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
1887 __r = __nd;1795 __r = __nd;
1888 __inserted = true;1796 __inserted = true;
...@@ -1893,8 +1801,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_...@@ -1893,8 +1801,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_
1893template <class _Tp, class _Compare, class _Allocator>1801template <class _Tp, class _Compare, class _Allocator>
1894typename __tree<_Tp, _Compare, _Allocator>::iterator1802typename __tree<_Tp, _Compare, _Allocator>::iterator
1895__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {1803__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {
1896 __parent_pointer __parent;1804 __end_node_pointer __parent;
1897 __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_));1805 __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__value_);
1898 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));1806 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
1899 return iterator(__nd);1807 return iterator(__nd);
1900}1808}
...@@ -1902,8 +1810,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {...@@ -1902,8 +1810,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {
1902template <class _Tp, class _Compare, class _Allocator>1810template <class _Tp, class _Compare, class _Allocator>
1903typename __tree<_Tp, _Compare, _Allocator>::iterator1811typename __tree<_Tp, _Compare, _Allocator>::iterator
1904__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) {1812__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) {
1905 __parent_pointer __parent;1813 __end_node_pointer __parent;
1906 __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_));1814 __node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__value_);
1907 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));1815 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
1908 return iterator(__nd);1816 return iterator(__nd);
1909}1817}
...@@ -1929,7 +1837,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n...@@ -1929,7 +1837,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n
1929 return _InsertReturnType{end(), false, _NodeHandle()};1837 return _InsertReturnType{end(), false, _NodeHandle()};
19301838
1931 __node_pointer __ptr = __nh.__ptr_;1839 __node_pointer __ptr = __nh.__ptr_;
1932 __parent_pointer __parent;1840 __end_node_pointer __parent;
1933 __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_);1841 __node_base_pointer& __child = __find_equal(__parent, __ptr->__value_);
1934 if (__child != nullptr)1842 if (__child != nullptr)
1935 return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)};1843 return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)};
...@@ -1947,7 +1855,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __...@@ -1947,7 +1855,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
1947 return end();1855 return end();
19481856
1949 __node_pointer __ptr = __nh.__ptr_;1857 __node_pointer __ptr = __nh.__ptr_;
1950 __parent_pointer __parent;1858 __end_node_pointer __parent;
1951 __node_base_pointer __dummy;1859 __node_base_pointer __dummy;
1952 __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_);1860 __node_base_pointer& __child = __find_equal(__hint, __parent, __dummy, __ptr->__value_);
1953 __node_pointer __r = static_cast<__node_pointer>(__child);1861 __node_pointer __r = static_cast<__node_pointer>(__child);
...@@ -1983,8 +1891,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg...@@ -1983,8 +1891,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg
19831891
1984 for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {1892 for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {
1985 __node_pointer __src_ptr = __i.__get_np();1893 __node_pointer __src_ptr = __i.__get_np();
1986 __parent_pointer __parent;1894 __end_node_pointer __parent;
1987 __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__src_ptr->__value_));1895 __node_base_pointer& __child = __find_equal(__parent, __src_ptr->__value_);
1988 ++__i;1896 ++__i;
1989 if (__child != nullptr)1897 if (__child != nullptr)
1990 continue;1898 continue;
...@@ -2000,8 +1908,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh...@@ -2000,8 +1908,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh
2000 if (__nh.empty())1908 if (__nh.empty())
2001 return end();1909 return end();
2002 __node_pointer __ptr = __nh.__ptr_;1910 __node_pointer __ptr = __nh.__ptr_;
2003 __parent_pointer __parent;1911 __end_node_pointer __parent;
2004 __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__ptr->__value_));1912 __node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__value_);
2005 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));1913 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2006 __nh.__release_ptr();1914 __nh.__release_ptr();
2007 return iterator(__ptr);1915 return iterator(__ptr);
...@@ -2015,8 +1923,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h...@@ -2015,8 +1923,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h
2015 return end();1923 return end();
20161924
2017 __node_pointer __ptr = __nh.__ptr_;1925 __node_pointer __ptr = __nh.__ptr_;
2018 __parent_pointer __parent;1926 __end_node_pointer __parent;
2019 __node_base_pointer& __child = __find_leaf(__hint, __parent, _NodeTypes::__get_key(__ptr->__value_));1927 __node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__value_);
2020 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));1928 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2021 __nh.__release_ptr();1929 __nh.__release_ptr();
2022 return iterator(__ptr);1930 return iterator(__ptr);
...@@ -2029,8 +1937,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg...@@ -2029,8 +1937,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg
20291937
2030 for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {1938 for (typename _Tree::iterator __i = __source.begin(); __i != __source.end();) {
2031 __node_pointer __src_ptr = __i.__get_np();1939 __node_pointer __src_ptr = __i.__get_np();
2032 __parent_pointer __parent;1940 __end_node_pointer __parent;
2033 __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__src_ptr->__value_));1941 __node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__value_);
2034 ++__i;1942 ++__i;
2035 __source.__remove_node_pointer(__src_ptr);1943 __source.__remove_node_pointer(__src_ptr);
2036 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));1944 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));
...@@ -2044,7 +1952,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo...@@ -2044,7 +1952,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo
2044 __node_pointer __np = __p.__get_np();1952 __node_pointer __np = __p.__get_np();
2045 iterator __r = __remove_node_pointer(__np);1953 iterator __r = __remove_node_pointer(__np);
2046 __node_allocator& __na = __node_alloc();1954 __node_allocator& __na = __node_alloc();
2047 __node_traits::destroy(__na, _NodeTypes::__get_ptr(const_cast<__node_value_type&>(*__p)));1955 __node_traits::destroy(__na, std::addressof(const_cast<value_type&>(*__p)));
2048 __node_traits::deallocate(__na, __np, 1);1956 __node_traits::deallocate(__na, __np, 1);
2049 return __r;1957 return __r;
2050}1958}
...@@ -2118,17 +2026,17 @@ template <class _Tp, class _Compare, class _Allocator>...@@ -2118,17 +2026,17 @@ template <class _Tp, class _Compare, class _Allocator>
2118template <class _Key>2026template <class _Key>
2119typename __tree<_Tp, _Compare, _Allocator>::size_type2027typename __tree<_Tp, _Compare, _Allocator>::size_type
2120__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {2028__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
2121 __iter_pointer __result = __end_node();2029 __end_node_pointer __result = __end_node();
2122 __node_pointer __rt = __root();2030 __node_pointer __rt = __root();
2123 while (__rt != nullptr) {2031 while (__rt != nullptr) {
2124 if (value_comp()(__k, __rt->__value_)) {2032 if (value_comp()(__k, __rt->__value_)) {
2125 __result = static_cast<__iter_pointer>(__rt);2033 __result = static_cast<__end_node_pointer>(__rt);
2126 __rt = static_cast<__node_pointer>(__rt->__left_);2034 __rt = static_cast<__node_pointer>(__rt->__left_);
2127 } else if (value_comp()(__rt->__value_, __k))2035 } else if (value_comp()(__rt->__value_, __k))
2128 __rt = static_cast<__node_pointer>(__rt->__right_);2036 __rt = static_cast<__node_pointer>(__rt->__right_);
2129 else2037 else
2130 return std::distance(2038 return std::distance(
2131 __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),2039 __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2132 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));2040 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2133 }2041 }
2134 return 0;2042 return 0;
...@@ -2137,10 +2045,10 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {...@@ -2137,10 +2045,10 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
2137template <class _Tp, class _Compare, class _Allocator>2045template <class _Tp, class _Compare, class _Allocator>
2138template <class _Key>2046template <class _Key>
2139typename __tree<_Tp, _Compare, _Allocator>::iterator2047typename __tree<_Tp, _Compare, _Allocator>::iterator
2140__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) {2048__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
2141 while (__root != nullptr) {2049 while (__root != nullptr) {
2142 if (!value_comp()(__root->__value_, __v)) {2050 if (!value_comp()(__root->__value_, __v)) {
2143 __result = static_cast<__iter_pointer>(__root);2051 __result = static_cast<__end_node_pointer>(__root);
2144 __root = static_cast<__node_pointer>(__root->__left_);2052 __root = static_cast<__node_pointer>(__root->__left_);
2145 } else2053 } else
2146 __root = static_cast<__node_pointer>(__root->__right_);2054 __root = static_cast<__node_pointer>(__root->__right_);
...@@ -2151,10 +2059,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer...@@ -2151,10 +2059,10 @@ __tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v, __node_pointer
2151template <class _Tp, class _Compare, class _Allocator>2059template <class _Tp, class _Compare, class _Allocator>
2152template <class _Key>2060template <class _Key>
2153typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound(2061typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound(
2154 const _Key& __v, __node_pointer __root, __iter_pointer __result) const {2062 const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
2155 while (__root != nullptr) {2063 while (__root != nullptr) {
2156 if (!value_comp()(__root->__value_, __v)) {2064 if (!value_comp()(__root->__value_, __v)) {
2157 __result = static_cast<__iter_pointer>(__root);2065 __result = static_cast<__end_node_pointer>(__root);
2158 __root = static_cast<__node_pointer>(__root->__left_);2066 __root = static_cast<__node_pointer>(__root->__left_);
2159 } else2067 } else
2160 __root = static_cast<__node_pointer>(__root->__right_);2068 __root = static_cast<__node_pointer>(__root->__right_);
...@@ -2165,10 +2073,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare,...@@ -2165,10 +2073,10 @@ typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare,
2165template <class _Tp, class _Compare, class _Allocator>2073template <class _Tp, class _Compare, class _Allocator>
2166template <class _Key>2074template <class _Key>
2167typename __tree<_Tp, _Compare, _Allocator>::iterator2075typename __tree<_Tp, _Compare, _Allocator>::iterator
2168__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __iter_pointer __result) {2076__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
2169 while (__root != nullptr) {2077 while (__root != nullptr) {
2170 if (value_comp()(__v, __root->__value_)) {2078 if (value_comp()(__v, __root->__value_)) {
2171 __result = static_cast<__iter_pointer>(__root);2079 __result = static_cast<__end_node_pointer>(__root);
2172 __root = static_cast<__node_pointer>(__root->__left_);2080 __root = static_cast<__node_pointer>(__root->__left_);
2173 } else2081 } else
2174 __root = static_cast<__node_pointer>(__root->__right_);2082 __root = static_cast<__node_pointer>(__root->__right_);
...@@ -2179,10 +2087,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer...@@ -2179,10 +2087,10 @@ __tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v, __node_pointer
2179template <class _Tp, class _Compare, class _Allocator>2087template <class _Tp, class _Compare, class _Allocator>
2180template <class _Key>2088template <class _Key>
2181typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound(2089typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound(
2182 const _Key& __v, __node_pointer __root, __iter_pointer __result) const {2090 const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
2183 while (__root != nullptr) {2091 while (__root != nullptr) {
2184 if (value_comp()(__v, __root->__value_)) {2092 if (value_comp()(__v, __root->__value_)) {
2185 __result = static_cast<__iter_pointer>(__root);2093 __result = static_cast<__end_node_pointer>(__root);
2186 __root = static_cast<__node_pointer>(__root->__left_);2094 __root = static_cast<__node_pointer>(__root->__left_);
2187 } else2095 } else
2188 __root = static_cast<__node_pointer>(__root->__right_);2096 __root = static_cast<__node_pointer>(__root->__right_);
...@@ -2195,17 +2103,17 @@ template <class _Key>...@@ -2195,17 +2103,17 @@ template <class _Key>
2195pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>2103pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2196__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {2104__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
2197 typedef pair<iterator, iterator> _Pp;2105 typedef pair<iterator, iterator> _Pp;
2198 __iter_pointer __result = __end_node();2106 __end_node_pointer __result = __end_node();
2199 __node_pointer __rt = __root();2107 __node_pointer __rt = __root();
2200 while (__rt != nullptr) {2108 while (__rt != nullptr) {
2201 if (value_comp()(__k, __rt->__value_)) {2109 if (value_comp()(__k, __rt->__value_)) {
2202 __result = static_cast<__iter_pointer>(__rt);2110 __result = static_cast<__end_node_pointer>(__rt);
2203 __rt = static_cast<__node_pointer>(__rt->__left_);2111 __rt = static_cast<__node_pointer>(__rt->__left_);
2204 } else if (value_comp()(__rt->__value_, __k))2112 } else if (value_comp()(__rt->__value_, __k))
2205 __rt = static_cast<__node_pointer>(__rt->__right_);2113 __rt = static_cast<__node_pointer>(__rt->__right_);
2206 else2114 else
2207 return _Pp(iterator(__rt),2115 return _Pp(iterator(__rt),
2208 iterator(__rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_))2116 iterator(__rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
2209 : __result));2117 : __result));
2210 }2118 }
2211 return _Pp(iterator(__result), iterator(__result));2119 return _Pp(iterator(__result), iterator(__result));
...@@ -2217,11 +2125,11 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,...@@ -2217,11 +2125,11 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2217 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>2125 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
2218__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {2126__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
2219 typedef pair<const_iterator, const_iterator> _Pp;2127 typedef pair<const_iterator, const_iterator> _Pp;
2220 __iter_pointer __result = __end_node();2128 __end_node_pointer __result = __end_node();
2221 __node_pointer __rt = __root();2129 __node_pointer __rt = __root();
2222 while (__rt != nullptr) {2130 while (__rt != nullptr) {
2223 if (value_comp()(__k, __rt->__value_)) {2131 if (value_comp()(__k, __rt->__value_)) {
2224 __result = static_cast<__iter_pointer>(__rt);2132 __result = static_cast<__end_node_pointer>(__rt);
2225 __rt = static_cast<__node_pointer>(__rt->__left_);2133 __rt = static_cast<__node_pointer>(__rt->__left_);
2226 } else if (value_comp()(__rt->__value_, __k))2134 } else if (value_comp()(__rt->__value_, __k))
2227 __rt = static_cast<__node_pointer>(__rt->__right_);2135 __rt = static_cast<__node_pointer>(__rt->__right_);
...@@ -2229,7 +2137,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {...@@ -2229,7 +2137,7 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
2229 return _Pp(2137 return _Pp(
2230 const_iterator(__rt),2138 const_iterator(__rt),
2231 const_iterator(2139 const_iterator(
2232 __rt->__right_ != nullptr ? static_cast<__iter_pointer>(std::__tree_min(__rt->__right_)) : __result));2140 __rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result));
2233 }2141 }
2234 return _Pp(const_iterator(__result), const_iterator(__result));2142 return _Pp(const_iterator(__result), const_iterator(__result));
2235}2143}
...@@ -2239,16 +2147,16 @@ template <class _Key>...@@ -2239,16 +2147,16 @@ template <class _Key>
2239pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>2147pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2240__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {2148__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
2241 typedef pair<iterator, iterator> _Pp;2149 typedef pair<iterator, iterator> _Pp;
2242 __iter_pointer __result = __end_node();2150 __end_node_pointer __result = __end_node();
2243 __node_pointer __rt = __root();2151 __node_pointer __rt = __root();
2244 while (__rt != nullptr) {2152 while (__rt != nullptr) {
2245 if (value_comp()(__k, __rt->__value_)) {2153 if (value_comp()(__k, __rt->__value_)) {
2246 __result = static_cast<__iter_pointer>(__rt);2154 __result = static_cast<__end_node_pointer>(__rt);
2247 __rt = static_cast<__node_pointer>(__rt->__left_);2155 __rt = static_cast<__node_pointer>(__rt->__left_);
2248 } else if (value_comp()(__rt->__value_, __k))2156 } else if (value_comp()(__rt->__value_, __k))
2249 __rt = static_cast<__node_pointer>(__rt->__right_);2157 __rt = static_cast<__node_pointer>(__rt->__right_);
2250 else2158 else
2251 return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),2159 return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2252 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));2160 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2253 }2161 }
2254 return _Pp(iterator(__result), iterator(__result));2162 return _Pp(iterator(__result), iterator(__result));
...@@ -2260,16 +2168,16 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,...@@ -2260,16 +2168,16 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2260 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>2168 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
2261__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {2169__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
2262 typedef pair<const_iterator, const_iterator> _Pp;2170 typedef pair<const_iterator, const_iterator> _Pp;
2263 __iter_pointer __result = __end_node();2171 __end_node_pointer __result = __end_node();
2264 __node_pointer __rt = __root();2172 __node_pointer __rt = __root();
2265 while (__rt != nullptr) {2173 while (__rt != nullptr) {
2266 if (value_comp()(__k, __rt->__value_)) {2174 if (value_comp()(__k, __rt->__value_)) {
2267 __result = static_cast<__iter_pointer>(__rt);2175 __result = static_cast<__end_node_pointer>(__rt);
2268 __rt = static_cast<__node_pointer>(__rt->__left_);2176 __rt = static_cast<__node_pointer>(__rt->__left_);
2269 } else if (value_comp()(__rt->__value_, __k))2177 } else if (value_comp()(__rt->__value_, __k))
2270 __rt = static_cast<__node_pointer>(__rt->__right_);2178 __rt = static_cast<__node_pointer>(__rt->__right_);
2271 else2179 else
2272 return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__iter_pointer>(__rt)),2180 return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2273 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));2181 __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2274 }2182 }
2275 return _Pp(const_iterator(__result), const_iterator(__result));2183 return _Pp(const_iterator(__result), const_iterator(__result));
...@@ -2281,9 +2189,9 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT {...@@ -2281,9 +2189,9 @@ __tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT {
2281 __node_pointer __np = __p.__get_np();2189 __node_pointer __np = __p.__get_np();
2282 if (__begin_node() == __p.__ptr_) {2190 if (__begin_node() == __p.__ptr_) {
2283 if (__np->__right_ != nullptr)2191 if (__np->__right_ != nullptr)
2284 __begin_node() = static_cast<__iter_pointer>(__np->__right_);2192 __begin_node() = static_cast<__end_node_pointer>(__np->__right_);
2285 else2193 else
2286 __begin_node() = static_cast<__iter_pointer>(__np->__parent_);2194 __begin_node() = static_cast<__end_node_pointer>(__np->__parent_);
2287 }2195 }
2288 --size();2196 --size();
2289 std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np));2197 std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np));
lib/libcxx/include/__tuple/make_tuple_types.h+1-1
...@@ -60,7 +60,7 @@ struct __make_tuple_types {...@@ -60,7 +60,7 @@ struct __make_tuple_types {
60 static_assert(_Sp <= _Ep, "__make_tuple_types input error");60 static_assert(_Sp <= _Ep, "__make_tuple_types input error");
61 using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;61 using _RawTp _LIBCPP_NODEBUG = __remove_cvref_t<_Tp>;
62 using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;62 using _Maker _LIBCPP_NODEBUG = __make_tuple_types_flat<_RawTp, typename __make_tuple_indices<_Ep, _Sp>::type>;
63 using type = typename _Maker::template __apply_quals<_Tp>;63 using type _LIBCPP_NODEBUG = typename _Maker::template __apply_quals<_Tp>;
64};64};
6565
66template <class... _Types, size_t _Ep>66template <class... _Types, size_t _Ep>
lib/libcxx/include/__tuple/sfinae_helpers.h+1-1
...@@ -58,7 +58,7 @@ struct __tuple_constructible<_Tp, _Up, true, true>...@@ -58,7 +58,7 @@ struct __tuple_constructible<_Tp, _Up, true, true>
58 typename __make_tuple_types<_Up>::type > {};58 typename __make_tuple_types<_Up>::type > {};
5959
60template <size_t _Ip, class... _Tp>60template <size_t _Ip, class... _Tp>
61struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {61struct tuple_element<_Ip, tuple<_Tp...> > {
62 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;62 using type _LIBCPP_NODEBUG = typename tuple_element<_Ip, __tuple_types<_Tp...> >::type;
63};63};
6464
lib/libcxx/include/__tuple/tuple_element.h+5-5
...@@ -21,27 +21,27 @@...@@ -21,27 +21,27 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <size_t _Ip, class _Tp>23template <size_t _Ip, class _Tp>
24struct _LIBCPP_TEMPLATE_VIS tuple_element;24struct tuple_element;
2525
26template <size_t _Ip, class _Tp>26template <size_t _Ip, class _Tp>
27struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {27struct tuple_element<_Ip, const _Tp> {
28 using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type;28 using type _LIBCPP_NODEBUG = const typename tuple_element<_Ip, _Tp>::type;
29};29};
3030
31template <size_t _Ip, class _Tp>31template <size_t _Ip, class _Tp>
32struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {32struct tuple_element<_Ip, volatile _Tp> {
33 using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type;33 using type _LIBCPP_NODEBUG = volatile typename tuple_element<_Ip, _Tp>::type;
34};34};
3535
36template <size_t _Ip, class _Tp>36template <size_t _Ip, class _Tp>
37struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {37struct tuple_element<_Ip, const volatile _Tp> {
38 using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type;38 using type _LIBCPP_NODEBUG = const volatile typename tuple_element<_Ip, _Tp>::type;
39};39};
4040
41#ifndef _LIBCPP_CXX03_LANG41#ifndef _LIBCPP_CXX03_LANG
4242
43template <size_t _Ip, class... _Types>43template <size_t _Ip, class... _Types>
44struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {44struct tuple_element<_Ip, __tuple_types<_Types...> > {
45 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");45 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
46 using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;46 using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;
47};47};
lib/libcxx/include/__tuple/tuple_size.h+11-14
...@@ -25,45 +25,42 @@...@@ -25,45 +25,42 @@
25_LIBCPP_BEGIN_NAMESPACE_STD25_LIBCPP_BEGIN_NAMESPACE_STD
2626
27template <class _Tp>27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS tuple_size;28struct tuple_size;
2929
30#if !defined(_LIBCPP_CXX03_LANG)30#if !defined(_LIBCPP_CXX03_LANG)
31template <class _Tp, class...>31template <class _Tp, class...>
32using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp;32using __enable_if_tuple_size_imp _LIBCPP_NODEBUG = _Tp;
3333
34template <class _Tp>34template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< const _Tp,35struct tuple_size<
36 __enable_if_t<!is_volatile<_Tp>::value>,36 __enable_if_tuple_size_imp<const _Tp, __enable_if_t<!is_volatile<_Tp>::value>, decltype(tuple_size<_Tp>::value)>>
37 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
38 : public integral_constant<size_t, tuple_size<_Tp>::value> {};37 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
3938
40template <class _Tp>39template <class _Tp>
41struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp,40struct tuple_size<
42 __enable_if_t<!is_const<_Tp>::value>,41 __enable_if_tuple_size_imp<volatile _Tp, __enable_if_t<!is_const<_Tp>::value>, decltype(tuple_size<_Tp>::value)>>
43 integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
44 : public integral_constant<size_t, tuple_size<_Tp>::value> {};42 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
4543
46template <class _Tp>44template <class _Tp>
47struct _LIBCPP_TEMPLATE_VIS45struct tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, decltype(tuple_size<_Tp>::value)>>
48tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
49 : public integral_constant<size_t, tuple_size<_Tp>::value> {};46 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
5047
51#else48#else
52template <class _Tp>49template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS tuple_size<const _Tp> : public tuple_size<_Tp> {};50struct tuple_size<const _Tp> : public tuple_size<_Tp> {};
54template <class _Tp>51template <class _Tp>
55struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : public tuple_size<_Tp> {};52struct tuple_size<volatile _Tp> : public tuple_size<_Tp> {};
56template <class _Tp>53template <class _Tp>
57struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};54struct tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
58#endif55#endif
5956
60#ifndef _LIBCPP_CXX03_LANG57#ifndef _LIBCPP_CXX03_LANG
6158
62template <class... _Tp>59template <class... _Tp>
63struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};60struct tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};
6461
65template <class... _Tp>62template <class... _Tp>
66struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};63struct tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};
6764
68# if _LIBCPP_STD_VER >= 1765# if _LIBCPP_STD_VER >= 17
69template <class _Tp>66template <class _Tp>
lib/libcxx/include/__type_traits/add_cv_quals.h+3-3
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _Tp>20template <class _Tp>
21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_const {21struct _LIBCPP_NO_SPECIALIZATIONS add_const {
22 using type _LIBCPP_NODEBUG = const _Tp;22 using type _LIBCPP_NODEBUG = const _Tp;
23};23};
2424
...@@ -28,7 +28,7 @@ using add_const_t = typename add_const<_Tp>::type;...@@ -28,7 +28,7 @@ using add_const_t = typename add_const<_Tp>::type;
28#endif28#endif
2929
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_cv {31struct _LIBCPP_NO_SPECIALIZATIONS add_cv {
32 using type _LIBCPP_NODEBUG = const volatile _Tp;32 using type _LIBCPP_NODEBUG = const volatile _Tp;
33};33};
3434
...@@ -38,7 +38,7 @@ using add_cv_t = typename add_cv<_Tp>::type;...@@ -38,7 +38,7 @@ using add_cv_t = typename add_cv<_Tp>::type;
38#endif38#endif
3939
40template <class _Tp>40template <class _Tp>
41struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS add_volatile {41struct _LIBCPP_NO_SPECIALIZATIONS add_volatile {
42 using type _LIBCPP_NODEBUG = volatile _Tp;42 using type _LIBCPP_NODEBUG = volatile _Tp;
43};43};
4444
lib/libcxx/include/__type_traits/add_lvalue_reference.h deleted-54
...@@ -1,54 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
11
12#include <__config>
13#include <__type_traits/is_referenceable.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if __has_builtin(__add_lvalue_reference)
22
23template <class _Tp>
24using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
25
26#else
27
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_lvalue_reference_impl {
30 using type _LIBCPP_NODEBUG = _Tp;
31};
32template <class _Tp >
33struct __add_lvalue_reference_impl<_Tp, true> {
34 using type _LIBCPP_NODEBUG = _Tp&;
35};
36
37template <class _Tp>
38using __add_lvalue_reference_t = typename __add_lvalue_reference_impl<_Tp>::type;
39
40#endif // __has_builtin(__add_lvalue_reference)
41
42template <class _Tp>
43struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
44 using type _LIBCPP_NODEBUG = __add_lvalue_reference_t<_Tp>;
45};
46
47#if _LIBCPP_STD_VER >= 14
48template <class _Tp>
49using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
50#endif
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/add_pointer.h+14-4
...@@ -20,13 +20,23 @@...@@ -20,13 +20,23 @@
2020
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)23#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS)
2424
25template <class _Tp>
26struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
27 using type _LIBCPP_NODEBUG = __add_pointer(_Tp);
28};
29
30# ifdef _LIBCPP_COMPILER_GCC
31template <class _Tp>
32using __add_pointer_t _LIBCPP_NODEBUG = typename add_pointer<_Tp>::type;
33# else
25template <class _Tp>34template <class _Tp>
26using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);35using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
36# endif
2737
28#else38#else
29template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value || is_void<_Tp>::value>39template <class _Tp, bool = __is_referenceable_v<_Tp> || is_void<_Tp>::value>
30struct __add_pointer_impl {40struct __add_pointer_impl {
31 using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*;41 using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*;
32};42};
...@@ -38,13 +48,13 @@ struct __add_pointer_impl<_Tp, false> {...@@ -38,13 +48,13 @@ struct __add_pointer_impl<_Tp, false> {
38template <class _Tp>48template <class _Tp>
39using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;49using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
4050
41#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
42
43template <class _Tp>51template <class _Tp>
44struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {52struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
45 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;53 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
46};54};
4755
56#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS)
57
48#if _LIBCPP_STD_VER >= 1458#if _LIBCPP_STD_VER >= 14
49template <class _Tp>59template <class _Tp>
50using add_pointer_t = __add_pointer_t<_Tp>;60using add_pointer_t = __add_pointer_t<_Tp>;
lib/libcxx/include/__type_traits/add_reference.h created+58
...@@ -0,0 +1,58 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20template <class _Tp>
21struct _LIBCPP_NO_SPECIALIZATIONS add_lvalue_reference {
22 using type _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
23};
24
25#ifdef _LIBCPP_COMPILER_GCC
26template <class _Tp>
27using __add_lvalue_reference_t _LIBCPP_NODEBUG = typename add_lvalue_reference<_Tp>::type;
28#else
29template <class _Tp>
30using __add_lvalue_reference_t _LIBCPP_NODEBUG = __add_lvalue_reference(_Tp);
31#endif
32
33#if _LIBCPP_STD_VER >= 14
34template <class _Tp>
35using add_lvalue_reference_t = __add_lvalue_reference_t<_Tp>;
36#endif
37
38template <class _Tp>
39struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
40 using type _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
41};
42
43#ifdef _LIBCPP_COMPILER_GCC
44template <class _Tp>
45using __add_rvalue_reference_t _LIBCPP_NODEBUG = typename add_rvalue_reference<_Tp>::type;
46#else
47template <class _Tp>
48using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
49#endif
50
51#if _LIBCPP_STD_VER >= 14
52template <class _Tp>
53using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
54#endif
55
56_LIBCPP_END_NAMESPACE_STD
57
58#endif // _LIBCPP___TYPE_TRAITS_ADD_REFERENCE_H
lib/libcxx/include/__type_traits/add_rvalue_reference.h deleted-54
...@@ -1,54 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
10#define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
11
12#include <__config>
13#include <__type_traits/is_referenceable.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if __has_builtin(__add_rvalue_reference)
22
23template <class _Tp>
24using __add_rvalue_reference_t _LIBCPP_NODEBUG = __add_rvalue_reference(_Tp);
25
26#else
27
28template <class _Tp, bool = __libcpp_is_referenceable<_Tp>::value>
29struct __add_rvalue_reference_impl {
30 using type _LIBCPP_NODEBUG = _Tp;
31};
32template <class _Tp >
33struct __add_rvalue_reference_impl<_Tp, true> {
34 using type _LIBCPP_NODEBUG = _Tp&&;
35};
36
37template <class _Tp>
38using __add_rvalue_reference_t = typename __add_rvalue_reference_impl<_Tp>::type;
39
40#endif // __has_builtin(__add_rvalue_reference)
41
42template <class _Tp>
43struct _LIBCPP_NO_SPECIALIZATIONS add_rvalue_reference {
44 using type = __add_rvalue_reference_t<_Tp>;
45};
46
47#if _LIBCPP_STD_VER >= 14
48template <class _Tp>
49using add_rvalue_reference_t = __add_rvalue_reference_t<_Tp>;
50#endif
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H
lib/libcxx/include/__type_traits/aligned_storage.h+1-1
...@@ -68,7 +68,7 @@ struct __find_max_align<__type_list<_Head, _Tail...>, _Len>...@@ -68,7 +68,7 @@ struct __find_max_align<__type_list<_Head, _Tail...>, _Len>
68 __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {};68 __select_align<_Len, _Head::value, __find_max_align<__type_list<_Tail...>, _Len>::value>::value> {};
6969
70template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>70template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value>
71struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS aligned_storage {71struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_storage {
72 union _ALIGNAS(_Align) type {72 union _ALIGNAS(_Align) type {
73 unsigned char __data[(_Len + _Align - 1) / _Align * _Align];73 unsigned char __data[(_Len + _Align - 1) / _Align * _Align];
74 };74 };
lib/libcxx/include/__type_traits/alignment_of.h+1-2
...@@ -20,8 +20,7 @@...@@ -20,8 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS alignment_of23struct _LIBCPP_NO_SPECIALIZATIONS alignment_of : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
24 : public integral_constant<size_t, _LIBCPP_ALIGNOF(_Tp)> {};
2524
26#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
27template <class _Tp>26template <class _Tp>
lib/libcxx/include/__type_traits/common_reference.h+22-12
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H10#define _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_pointer.h>
13#include <__type_traits/common_type.h>14#include <__type_traits/common_type.h>
14#include <__type_traits/copy_cv.h>15#include <__type_traits/copy_cv.h>
15#include <__type_traits/copy_cvref.h>16#include <__type_traits/copy_cvref.h>
...@@ -109,11 +110,18 @@ struct __common_ref {};...@@ -109,11 +110,18 @@ struct __common_ref {};
109// Note C: For the common_reference trait applied to a parameter pack [...]110// Note C: For the common_reference trait applied to a parameter pack [...]
110111
111template <class...>112template <class...>
112struct common_reference;113struct _LIBCPP_NO_SPECIALIZATIONS common_reference;
113114
114template <class... _Types>115template <class... _Types>
115using common_reference_t = typename common_reference<_Types...>::type;116using common_reference_t = typename common_reference<_Types...>::type;
116117
118template <class, class, template <class> class, template <class> class>
119struct basic_common_reference {};
120
121_LIBCPP_DIAGNOSTIC_PUSH
122# if __has_warning("-Winvalid-specialization")
123_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
124# endif
117// bullet 1 - sizeof...(T) == 0125// bullet 1 - sizeof...(T) == 0
118template <>126template <>
119struct common_reference<> {};127struct common_reference<> {};
...@@ -121,7 +129,7 @@ struct common_reference<> {};...@@ -121,7 +129,7 @@ struct common_reference<> {};
121// bullet 2 - sizeof...(T) == 1129// bullet 2 - sizeof...(T) == 1
122template <class _Tp>130template <class _Tp>
123struct common_reference<_Tp> {131struct common_reference<_Tp> {
124 using type = _Tp;132 using type _LIBCPP_NODEBUG = _Tp;
125};133};
126134
127// bullet 3 - sizeof...(T) == 2135// bullet 3 - sizeof...(T) == 2
...@@ -132,22 +140,23 @@ struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up>...@@ -132,22 +140,23 @@ struct __common_reference_sub_bullet2 : __common_reference_sub_bullet3<_Tp, _Up>
132template <class _Tp, class _Up>140template <class _Tp, class _Up>
133struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};141struct __common_reference_sub_bullet1 : __common_reference_sub_bullet2<_Tp, _Up> {};
134142
135// sub-bullet 1 - If T1 and T2 are reference types and COMMON-REF(T1, T2) is well-formed, then143// sub-bullet 1 - Let R be COMMON-REF(T1, T2). If T1 and T2 are reference types, R is well-formed, and
136// the member typedef `type` denotes that type.144// is_convertible_v<add_pointer_t<T1>, add_pointer_t<R>> && is_convertible_v<add_pointer_t<T2>, add_pointer_t<R>> is
145// true, then the member typedef type denotes R.
146
137template <class _Tp, class _Up>147template <class _Tp, class _Up>
138struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};148struct common_reference<_Tp, _Up> : __common_reference_sub_bullet1<_Tp, _Up> {};
139149
140template <class _Tp, class _Up>150template <class _Tp, class _Up>
141 requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; }151 requires is_reference_v<_Tp> && is_reference_v<_Up> && requires { typename __common_ref_t<_Tp, _Up>; } &&
152 is_convertible_v<add_pointer_t<_Tp>, add_pointer_t<__common_ref_t<_Tp, _Up>>> &&
153 is_convertible_v<add_pointer_t<_Up>, add_pointer_t<__common_ref_t<_Tp, _Up>>>
142struct __common_reference_sub_bullet1<_Tp, _Up> {154struct __common_reference_sub_bullet1<_Tp, _Up> {
143 using type = __common_ref_t<_Tp, _Up>;155 using type _LIBCPP_NODEBUG = __common_ref_t<_Tp, _Up>;
144};156};
145157
146// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type158// sub-bullet 2 - Otherwise, if basic_common_reference<remove_cvref_t<T1>, remove_cvref_t<T2>, XREF(T1), XREF(T2)>::type
147// is well-formed, then the member typedef `type` denotes that type.159// is well-formed, then the member typedef `type` denotes that type.
148template <class, class, template <class> class, template <class> class>
149struct basic_common_reference {};
150
151template <class _Tp, class _Up>160template <class _Tp, class _Up>
152using __basic_common_reference_t _LIBCPP_NODEBUG =161using __basic_common_reference_t _LIBCPP_NODEBUG =
153 typename basic_common_reference<remove_cvref_t<_Tp>,162 typename basic_common_reference<remove_cvref_t<_Tp>,
...@@ -158,7 +167,7 @@ using __basic_common_reference_t _LIBCPP_NODEBUG =...@@ -158,7 +167,7 @@ using __basic_common_reference_t _LIBCPP_NODEBUG =
158template <class _Tp, class _Up>167template <class _Tp, class _Up>
159 requires requires { typename __basic_common_reference_t<_Tp, _Up>; }168 requires requires { typename __basic_common_reference_t<_Tp, _Up>; }
160struct __common_reference_sub_bullet2<_Tp, _Up> {169struct __common_reference_sub_bullet2<_Tp, _Up> {
161 using type = __basic_common_reference_t<_Tp, _Up>;170 using type _LIBCPP_NODEBUG = __basic_common_reference_t<_Tp, _Up>;
162};171};
163172
164// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,173// sub-bullet 3 - Otherwise, if COND-RES(T1, T2) is well-formed,
...@@ -166,7 +175,7 @@ struct __common_reference_sub_bullet2<_Tp, _Up> {...@@ -166,7 +175,7 @@ struct __common_reference_sub_bullet2<_Tp, _Up> {
166template <class _Tp, class _Up>175template <class _Tp, class _Up>
167 requires requires { typename __cond_res<_Tp, _Up>; }176 requires requires { typename __cond_res<_Tp, _Up>; }
168struct __common_reference_sub_bullet3<_Tp, _Up> {177struct __common_reference_sub_bullet3<_Tp, _Up> {
169 using type = __cond_res<_Tp, _Up>;178 using type _LIBCPP_NODEBUG = __cond_res<_Tp, _Up>;
170};179};
171180
172// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,181// sub-bullet 4 & 5 - Otherwise, if common_type_t<T1, T2> is well-formed,
...@@ -180,10 +189,11 @@ struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};...@@ -180,10 +189,11 @@ struct __common_reference_sub_bullet3 : common_type<_Tp, _Up> {};
180template <class _Tp, class _Up, class _Vp, class... _Rest>189template <class _Tp, class _Up, class _Vp, class... _Rest>
181 requires requires { typename common_reference_t<_Tp, _Up>; }190 requires requires { typename common_reference_t<_Tp, _Up>; }
182struct common_reference<_Tp, _Up, _Vp, _Rest...> : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> {};191struct common_reference<_Tp, _Up, _Vp, _Rest...> : common_reference<common_reference_t<_Tp, _Up>, _Vp, _Rest...> {};
192_LIBCPP_DIAGNOSTIC_POP
183193
184// bullet 5 - Otherwise, there shall be no member `type`.194// bullet 5 - Otherwise, there shall be no member `type`.
185template <class...>195template <class...>
186struct common_reference {};196struct _LIBCPP_NO_SPECIALIZATIONS common_reference {};
187197
188#endif // _LIBCPP_STD_VER >= 20198#endif // _LIBCPP_STD_VER >= 20
189199
lib/libcxx/include/__type_traits/common_type.h+6-7
...@@ -48,7 +48,7 @@ struct __common_type3 {};...@@ -48,7 +48,7 @@ struct __common_type3 {};
48// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."48// sub-bullet 4 - "if COND_RES(CREF(D1), CREF(D2)) denotes a type..."
49template <class _Tp, class _Up>49template <class _Tp, class _Up>
50struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> {50struct __common_type3<_Tp, _Up, void_t<__cond_type<const _Tp&, const _Up&>>> {
51 using type = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;51 using type _LIBCPP_NODEBUG = remove_cvref_t<__cond_type<const _Tp&, const _Up&>>;
52};52};
5353
54template <class _Tp, class _Up, class = void>54template <class _Tp, class _Up, class = void>
...@@ -70,7 +70,7 @@ struct __common_type_impl {};...@@ -70,7 +70,7 @@ struct __common_type_impl {};
70template <class... _Tp>70template <class... _Tp>
71struct __common_types;71struct __common_types;
72template <class... _Tp>72template <class... _Tp>
73struct _LIBCPP_TEMPLATE_VIS common_type;73struct common_type;
7474
75template <class _Tp, class _Up>75template <class _Tp, class _Up>
76struct __common_type_impl< __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> > {76struct __common_type_impl< __common_types<_Tp, _Up>, __void_t<typename common_type<_Tp, _Up>::type> > {
...@@ -84,18 +84,18 @@ struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, __void_t<type...@@ -84,18 +84,18 @@ struct __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...>, __void_t<type
84// bullet 1 - sizeof...(Tp) == 084// bullet 1 - sizeof...(Tp) == 0
8585
86template <>86template <>
87struct _LIBCPP_TEMPLATE_VIS common_type<> {};87struct common_type<> {};
8888
89// bullet 2 - sizeof...(Tp) == 189// bullet 2 - sizeof...(Tp) == 1
9090
91template <class _Tp>91template <class _Tp>
92struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {};92struct common_type<_Tp> : public common_type<_Tp, _Tp> {};
9393
94// bullet 3 - sizeof...(Tp) == 294// bullet 3 - sizeof...(Tp) == 2
9595
96// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."96// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
97template <class _Tp, class _Up>97template <class _Tp, class _Up>
98struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>98struct common_type<_Tp, _Up>
99 : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,99 : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,
100 __common_type2_imp<_Tp, _Up>,100 __common_type2_imp<_Tp, _Up>,
101 common_type<__decay_t<_Tp>, __decay_t<_Up> > > {};101 common_type<__decay_t<_Tp>, __decay_t<_Up> > > {};
...@@ -103,8 +103,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>...@@ -103,8 +103,7 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
103// bullet 4 - sizeof...(Tp) > 2103// bullet 4 - sizeof...(Tp) > 2
104104
105template <class _Tp, class _Up, class _Vp, class... _Rest>105template <class _Tp, class _Up, class _Vp, class... _Rest>
106struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up, _Vp, _Rest...>106struct common_type<_Tp, _Up, _Vp, _Rest...> : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {};
107 : __common_type_impl<__common_types<_Tp, _Up, _Vp, _Rest...> > {};
108107
109#endif108#endif
110109
lib/libcxx/include/__type_traits/conditional.h+2-2
...@@ -36,7 +36,7 @@ template <bool _Cond, class _IfRes, class _ElseRes>...@@ -36,7 +36,7 @@ template <bool _Cond, class _IfRes, class _ElseRes>
36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;36using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
3737
38template <bool _Bp, class _If, class _Then>38template <bool _Bp, class _If, class _Then>
39struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS conditional {39struct _LIBCPP_NO_SPECIALIZATIONS conditional {
40 using type _LIBCPP_NODEBUG = _If;40 using type _LIBCPP_NODEBUG = _If;
41};41};
4242
...@@ -45,7 +45,7 @@ _LIBCPP_DIAGNOSTIC_PUSH...@@ -45,7 +45,7 @@ _LIBCPP_DIAGNOSTIC_PUSH
45_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")45_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
46#endif46#endif
47template <class _If, class _Then>47template <class _If, class _Then>
48struct _LIBCPP_TEMPLATE_VIS conditional<false, _If, _Then> {48struct conditional<false, _If, _Then> {
49 using type _LIBCPP_NODEBUG = _Then;49 using type _LIBCPP_NODEBUG = _Then;
50};50};
51_LIBCPP_DIAGNOSTIC_POP51_LIBCPP_DIAGNOSTIC_POP
lib/libcxx/include/__type_traits/container_traits.h+3
...@@ -36,6 +36,9 @@ struct __container_traits {...@@ -36,6 +36,9 @@ struct __container_traits {
36 // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function36 // `insert(...)` or `emplace(...)` has strong exception guarantee, that is, if the function
37 // exits via an exception, the original container is unaffected37 // exits via an exception, the original container is unaffected
38 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false;38 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = false;
39
40 // A trait that tells whether a container supports `reserve(n)` member function.
41 static _LIBCPP_CONSTEXPR const bool __reservable = false;
39};42};
4043
41_LIBCPP_END_NAMESPACE_STD44_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/copy_cvref.h+1-2
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H10#define _LIBCPP___TYPE_TRAITS_COPY_CVREF_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/copy_cv.h>14#include <__type_traits/copy_cv.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__type_traits/decay.h+6-38
...@@ -10,14 +10,6 @@...@@ -10,14 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_DECAY_H10#define _LIBCPP___TYPE_TRAITS_DECAY_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_pointer.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/is_array.h>
16#include <__type_traits/is_function.h>
17#include <__type_traits/is_referenceable.h>
18#include <__type_traits/remove_cv.h>
19#include <__type_traits/remove_extent.h>
20#include <__type_traits/remove_reference.h>
2113
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header15# pragma GCC system_header
...@@ -25,42 +17,18 @@...@@ -25,42 +17,18 @@
2517
26_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
2719
28#if __has_builtin(__decay)
29template <class _Tp>
30using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
31
32template <class _Tp>20template <class _Tp>
33struct _LIBCPP_NO_SPECIALIZATIONS decay {21struct _LIBCPP_NO_SPECIALIZATIONS decay {
34 using type _LIBCPP_NODEBUG = __decay_t<_Tp>;22 using type _LIBCPP_NODEBUG = __decay(_Tp);
35};
36
37#else
38template <class _Up, bool>
39struct __decay {
40 using type _LIBCPP_NODEBUG = __remove_cv_t<_Up>;
41};
42
43template <class _Up>
44struct __decay<_Up, true> {
45public:
46 using type _LIBCPP_NODEBUG =
47 __conditional_t<is_array<_Up>::value,
48 __add_pointer_t<__remove_extent_t<_Up> >,
49 __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >;
50};23};
5124
25#ifdef _LIBCPP_COMPILER_GCC
52template <class _Tp>26template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS decay {27using __decay_t _LIBCPP_NODEBUG = typename decay<_Tp>::type;
54private:28#else
55 using _Up _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>;
56
57public:
58 using type _LIBCPP_NODEBUG = typename __decay<_Up, __libcpp_is_referenceable<_Up>::value>::type;
59};
60
61template <class _Tp>29template <class _Tp>
62using __decay_t = typename decay<_Tp>::type;30using __decay_t _LIBCPP_NODEBUG = __decay(_Tp);
63#endif // __has_builtin(__decay)31#endif
6432
65#if _LIBCPP_STD_VER >= 1433#if _LIBCPP_STD_VER >= 14
66template <class _Tp>34template <class _Tp>
lib/libcxx/include/__type_traits/dependent_type.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _Tp, bool>20template <class _Tp, bool>
21struct _LIBCPP_TEMPLATE_VIS __dependent_type : public _Tp {};21struct __dependent_type : public _Tp {};
2222
23_LIBCPP_END_NAMESPACE_STD23_LIBCPP_END_NAMESPACE_STD
2424
lib/libcxx/include/__type_traits/desugars_to.h+12
...@@ -52,6 +52,18 @@ struct __totally_ordered_less_tag {};...@@ -52,6 +52,18 @@ struct __totally_ordered_less_tag {};
52template <class _CanonicalTag, class _Operation, class... _Args>52template <class _CanonicalTag, class _Operation, class... _Args>
53inline const bool __desugars_to_v = false;53inline const bool __desugars_to_v = false;
5454
55// For the purpose of determining whether something desugars to something else,
56// we disregard const and ref qualifiers on the operation itself.
57template <class _CanonicalTag, class _Operation, class... _Args>
58inline const bool __desugars_to_v<_CanonicalTag, _Operation const, _Args...> =
59 __desugars_to_v<_CanonicalTag, _Operation, _Args...>;
60template <class _CanonicalTag, class _Operation, class... _Args>
61inline const bool __desugars_to_v<_CanonicalTag, _Operation&, _Args...> =
62 __desugars_to_v<_CanonicalTag, _Operation, _Args...>;
63template <class _CanonicalTag, class _Operation, class... _Args>
64inline const bool __desugars_to_v<_CanonicalTag, _Operation&&, _Args...> =
65 __desugars_to_v<_CanonicalTag, _Operation, _Args...>;
66
55_LIBCPP_END_NAMESPACE_STD67_LIBCPP_END_NAMESPACE_STD
5668
57#endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H69#endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H
lib/libcxx/include/__type_traits/enable_if.h+2-2
...@@ -18,14 +18,14 @@...@@ -18,14 +18,14 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <bool, class _Tp = void>20template <bool, class _Tp = void>
21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS enable_if{};21struct _LIBCPP_NO_SPECIALIZATIONS enable_if{};
2222
23_LIBCPP_DIAGNOSTIC_PUSH23_LIBCPP_DIAGNOSTIC_PUSH
24#if __has_warning("-Winvalid-specialization")24#if __has_warning("-Winvalid-specialization")
25_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")25_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
26#endif26#endif
27template <class _Tp>27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {28struct enable_if<true, _Tp> {
29 typedef _Tp type;29 typedef _Tp type;
30};30};
31_LIBCPP_DIAGNOSTIC_POP31_LIBCPP_DIAGNOSTIC_POP
lib/libcxx/include/__type_traits/extent.h+6-6
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__array_extent)22#if __has_builtin(__array_extent)
2323
24template <class _Tp, size_t _Dim = 0>24template <class _Tp, size_t _Dim = 0>
25struct _LIBCPP_NO_SPECIALIZATIONS _LIBCPP_TEMPLATE_VIS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};25struct _LIBCPP_NO_SPECIALIZATIONS extent : integral_constant<size_t, __array_extent(_Tp, _Dim)> {};
2626
27# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
28template <class _Tp, unsigned _Ip = 0>28template <class _Tp, unsigned _Ip = 0>
...@@ -32,15 +32,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp...@@ -32,15 +32,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t extent_v = __array_extent(_Tp
32#else // __has_builtin(__array_extent)32#else // __has_builtin(__array_extent)
3333
34template <class _Tp, unsigned _Ip = 0>34template <class _Tp, unsigned _Ip = 0>
35struct _LIBCPP_TEMPLATE_VIS extent : public integral_constant<size_t, 0> {};35struct extent : public integral_constant<size_t, 0> {};
36template <class _Tp>36template <class _Tp>
37struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> : public integral_constant<size_t, 0> {};37struct extent<_Tp[], 0> : public integral_constant<size_t, 0> {};
38template <class _Tp, unsigned _Ip>38template <class _Tp, unsigned _Ip>
39struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};39struct extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};
40template <class _Tp, size_t _Np>40template <class _Tp, size_t _Np>
41struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {};41struct extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {};
42template <class _Tp, size_t _Np, unsigned _Ip>42template <class _Tp, size_t _Np, unsigned _Ip>
43struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};43struct extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip - 1>::value> {};
4444
45# if _LIBCPP_STD_VER >= 1745# if _LIBCPP_STD_VER >= 17
46template <class _Tp, unsigned _Ip = 0>46template <class _Tp, unsigned _Ip = 0>
lib/libcxx/include/__type_traits/has_unique_object_representation.h+2-8
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_all_extents.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -22,13 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,13 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if _LIBCPP_STD_VER >= 1721#if _LIBCPP_STD_VER >= 17
2322
24template <class _Tp>23template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations24struct _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations
26 // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents25 : integral_constant<bool, __has_unique_object_representations(_Tp)> {};
27 // even though it should not be necessary. This was reported to the compilers:
28 // - Clang: https://github.com/llvm/llvm-project/issues/95311
29 // - GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476
30 // remove_all_extents_t can be removed once all the compilers we support have fixed this bug.
31 : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {};
3226
33template <class _Tp>27template <class _Tp>
34_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v =28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v =
lib/libcxx/include/__type_traits/has_virtual_destructor.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor22struct _LIBCPP_NO_SPECIALIZATIONS has_virtual_destructor
23 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};23 : public integral_constant<bool, __has_virtual_destructor(_Tp)> {};
2424
25#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
lib/libcxx/include/__type_traits/integer_traits.h created+73
...@@ -0,0 +1,73 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H
10#define _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20// This trait is to determine whether a type is a /signed integer type/
21// See [basic.fundamental]/p1
22template <class _Tp>
23inline const bool __is_signed_integer_v = false;
24template <>
25inline const bool __is_signed_integer_v<signed char> = true;
26template <>
27inline const bool __is_signed_integer_v<signed short> = true;
28template <>
29inline const bool __is_signed_integer_v<signed int> = true;
30template <>
31inline const bool __is_signed_integer_v<signed long> = true;
32template <>
33inline const bool __is_signed_integer_v<signed long long> = true;
34#if _LIBCPP_HAS_INT128
35template <>
36inline const bool __is_signed_integer_v<__int128_t> = true;
37#endif
38
39// This trait is to determine whether a type is an /unsigned integer type/
40// See [basic.fundamental]/p2
41template <class _Tp>
42inline const bool __is_unsigned_integer_v = false;
43template <>
44inline const bool __is_unsigned_integer_v<unsigned char> = true;
45template <>
46inline const bool __is_unsigned_integer_v<unsigned short> = true;
47template <>
48inline const bool __is_unsigned_integer_v<unsigned int> = true;
49template <>
50inline const bool __is_unsigned_integer_v<unsigned long> = true;
51template <>
52inline const bool __is_unsigned_integer_v<unsigned long long> = true;
53#if _LIBCPP_HAS_INT128
54template <>
55inline const bool __is_unsigned_integer_v<__uint128_t> = true;
56#endif
57
58#if _LIBCPP_STD_VER >= 20
59template <class _Tp>
60concept __signed_integer = __is_signed_integer_v<_Tp>;
61
62template <class _Tp>
63concept __unsigned_integer = __is_unsigned_integer_v<_Tp>;
64
65// This isn't called __integer, because an integer type according to [basic.fundamental]/p11 is the same as an integral
66// type. An integral type is _not_ the same set of types as signed and unsigned integer types combined.
67template <class _Tp>
68concept __signed_or_unsigned_integer = __signed_integer<_Tp> || __unsigned_integer<_Tp>;
69#endif
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H
lib/libcxx/include/__type_traits/integral_constant.h+1-1
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20template <class _Tp, _Tp __v>20template <class _Tp, _Tp __v>
21struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS integral_constant {21struct _LIBCPP_NO_SPECIALIZATIONS integral_constant {
22 static inline _LIBCPP_CONSTEXPR const _Tp value = __v;22 static inline _LIBCPP_CONSTEXPR const _Tp value = __v;
23 typedef _Tp value_type;23 typedef _Tp value_type;
24 typedef integral_constant type;24 typedef integral_constant type;
lib/libcxx/include/__type_traits/invoke.h+110-37
...@@ -22,6 +22,7 @@...@@ -22,6 +22,7 @@
22#include <__type_traits/is_same.h>22#include <__type_traits/is_same.h>
23#include <__type_traits/is_void.h>23#include <__type_traits/is_void.h>
24#include <__type_traits/nat.h>24#include <__type_traits/nat.h>
25#include <__type_traits/void_t.h>
25#include <__utility/declval.h>26#include <__utility/declval.h>
26#include <__utility/forward.h>27#include <__utility/forward.h>
2728
...@@ -41,19 +42,22 @@...@@ -41,19 +42,22 @@
41// return std::invoke_r(std::forward<Args>(args)...);42// return std::invoke_r(std::forward<Args>(args)...);
42// }43// }
43//44//
44// template <class Ret, class Func, class... Args>
45// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
46//
47// template <class Func, class... Args>45// template <class Func, class... Args>
48// struct __is_invocable : is_invocable<Func, Args...> {};46// struct __is_invocable : is_invocable<Func, Args...> {};
49//47//
50// template <class Func, class... Args>48// template <class Func, class... Args>
51// inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;49// inline const bool __is_invocable_v = is_invocable_v<Func, Args...>;
52//50//
51// template <class Ret, class Func, class... Args>
52// inline const bool __is_invocable_r_v = is_invocable_r_v<Ret, Func, Args...>;
53//
53// template <class Func, class... Args>54// template <class Func, class... Args>
54// inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;55// inline const bool __is_nothrow_invocable_v = is_nothrow_invocable_v<Func, Args...>;
55//56//
56// template <class Func, class... Args>57// template <class Func, class... Args>
58// inline const bool __is_nothrow_invocable_r_v = is_nothrow_invocable_r_v<Func, Args...>;
59//
60// template <class Func, class... Args>
57// struct __invoke_result : invoke_result {};61// struct __invoke_result : invoke_result {};
58//62//
59// template <class Func, class... Args>63// template <class Func, class... Args>
...@@ -61,6 +65,72 @@...@@ -61,6 +65,72 @@
6165
62_LIBCPP_BEGIN_NAMESPACE_STD66_LIBCPP_BEGIN_NAMESPACE_STD
6367
68#if __has_builtin(__builtin_invoke)
69
70template <class, class... _Args>
71struct __invoke_result_impl {};
72
73template <class... _Args>
74struct __invoke_result_impl<__void_t<decltype(__builtin_invoke(std::declval<_Args>()...))>, _Args...> {
75 using type _LIBCPP_NODEBUG = decltype(__builtin_invoke(std::declval<_Args>()...));
76};
77
78template <class... _Args>
79using __invoke_result _LIBCPP_NODEBUG = __invoke_result_impl<void, _Args...>;
80
81template <class... _Args>
82using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Args...>::type;
83
84template <class... _Args>
85_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __invoke_result_t<_Args...> __invoke(_Args&&... __args)
86 _NOEXCEPT_(noexcept(__builtin_invoke(std::forward<_Args>(__args)...))) {
87 return __builtin_invoke(std::forward<_Args>(__args)...);
88}
89
90template <class _Void, class... _Args>
91inline const bool __is_invocable_impl = false;
92
93template <class... _Args>
94inline const bool __is_invocable_impl<__void_t<__invoke_result_t<_Args...> >, _Args...> = true;
95
96template <class... _Args>
97inline const bool __is_invocable_v = __is_invocable_impl<void, _Args...>;
98
99template <class... _Args>
100struct __is_invocable : integral_constant<bool, __is_invocable_v<_Args...> > {};
101
102template <class _Ret, bool, class... _Args>
103inline const bool __is_invocable_r_impl = false;
104
105template <class _Ret, class... _Args>
106inline const bool __is_invocable_r_impl<_Ret, true, _Args...> =
107 __is_core_convertible<__invoke_result_t<_Args...>, _Ret>::value || is_void<_Ret>::value;
108
109template <class _Ret, class... _Args>
110inline const bool __is_invocable_r_v = __is_invocable_r_impl<_Ret, __is_invocable_v<_Args...>, _Args...>;
111
112template <bool __is_invocable, class... _Args>
113inline const bool __is_nothrow_invocable_impl = false;
114
115template <class... _Args>
116inline const bool __is_nothrow_invocable_impl<true, _Args...> = noexcept(__builtin_invoke(std::declval<_Args>()...));
117
118template <class... _Args>
119inline const bool __is_nothrow_invocable_v = __is_nothrow_invocable_impl<__is_invocable_v<_Args...>, _Args...>;
120
121template <bool __is_invocable, class _Ret, class... _Args>
122inline const bool __is_nothrow_invocable_r_impl = false;
123
124template <class _Ret, class... _Args>
125inline const bool __is_nothrow_invocable_r_impl<true, _Ret, _Args...> =
126 __is_nothrow_core_convertible_v<__invoke_result_t<_Args...>, _Ret> || is_void<_Ret>::value;
127
128template <class _Ret, class... _Args>
129inline const bool __is_nothrow_invocable_r_v =
130 __is_nothrow_invocable_r_impl<__is_nothrow_invocable_v<_Args...>, _Ret, _Args...>;
131
132#else // __has_builtin(__builtin_invoke)
133
64template <class _DecayedFp>134template <class _DecayedFp>
65struct __member_pointer_class_type {};135struct __member_pointer_class_type {};
66136
...@@ -211,21 +281,21 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> {...@@ -211,21 +281,21 @@ struct __nothrow_invokable_r_imp<true, false, _Ret, _Fp, _Args...> {
211 template <class _Tp>281 template <class _Tp>
212 static void __test_noexcept(_Tp) _NOEXCEPT;282 static void __test_noexcept(_Tp) _NOEXCEPT;
213283
214#ifdef _LIBCPP_CXX03_LANG284# ifdef _LIBCPP_CXX03_LANG
215 static const bool value = false;285 static const bool value = false;
216#else286# else
217 static const bool value =287 static const bool value =
218 noexcept(_ThisT::__test_noexcept<_Ret>(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)));288 noexcept(_ThisT::__test_noexcept<_Ret>(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...)));
219#endif289# endif
220};290};
221291
222template <class _Ret, class _Fp, class... _Args>292template <class _Ret, class _Fp, class... _Args>
223struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> {293struct __nothrow_invokable_r_imp<true, true, _Ret, _Fp, _Args...> {
224#ifdef _LIBCPP_CXX03_LANG294# ifdef _LIBCPP_CXX03_LANG
225 static const bool value = false;295 static const bool value = false;
226#else296# else
227 static const bool value = noexcept(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));297 static const bool value = noexcept(std::__invoke(std::declval<_Fp>(), std::declval<_Args>()...));
228#endif298# endif
229};299};
230300
231template <class _Ret, class _Fp, class... _Args>301template <class _Ret, class _Fp, class... _Args>
...@@ -236,22 +306,6 @@ template <class _Fp, class... _Args>...@@ -236,22 +306,6 @@ template <class _Fp, class... _Args>
236using __nothrow_invokable _LIBCPP_NODEBUG =306using __nothrow_invokable _LIBCPP_NODEBUG =
237 __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;307 __nothrow_invokable_r_imp<__is_invocable<_Fp, _Args...>::value, true, void, _Fp, _Args...>;
238308
239template <class _Ret, bool = is_void<_Ret>::value>
240struct __invoke_void_return_wrapper {
241 template <class... _Args>
242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call(_Args&&... __args) {
243 return std::__invoke(std::forward<_Args>(__args)...);
244 }
245};
246
247template <class _Ret>
248struct __invoke_void_return_wrapper<_Ret, true> {
249 template <class... _Args>
250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call(_Args&&... __args) {
251 std::__invoke(std::forward<_Args>(__args)...);
252 }
253};
254
255template <class _Func, class... _Args>309template <class _Func, class... _Args>
256inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value;310inline const bool __is_invocable_v = __is_invocable<_Func, _Args...>::value;
257311
...@@ -261,6 +315,9 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val...@@ -261,6 +315,9 @@ inline const bool __is_invocable_r_v = __invokable_r<_Ret, _Func, _Args...>::val
261template <class _Func, class... _Args>315template <class _Func, class... _Args>
262inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;316inline const bool __is_nothrow_invocable_v = __nothrow_invokable<_Func, _Args...>::value;
263317
318template <class _Ret, class _Func, class... _Args>
319inline const bool __is_nothrow_invocable_r_v = __nothrow_invokable_r<_Ret, _Func, _Args...>::value;
320
264template <class _Func, class... _Args>321template <class _Func, class... _Args>
265struct __invoke_result322struct __invoke_result
266 : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {};323 : enable_if<__is_invocable_v<_Func, _Args...>, typename __invokable_r<void, _Func, _Args...>::_Result> {};
...@@ -268,6 +325,24 @@ struct __invoke_result...@@ -268,6 +325,24 @@ struct __invoke_result
268template <class _Func, class... _Args>325template <class _Func, class... _Args>
269using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type;326using __invoke_result_t _LIBCPP_NODEBUG = typename __invoke_result<_Func, _Args...>::type;
270327
328#endif // __has_builtin(__builtin_invoke_r)
329
330template <class _Ret, bool = is_void<_Ret>::value>
331struct __invoke_void_return_wrapper {
332 template <class... _Args>
333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static _Ret __call(_Args&&... __args) {
334 return std::__invoke(std::forward<_Args>(__args)...);
335 }
336};
337
338template <class _Ret>
339struct __invoke_void_return_wrapper<_Ret, true> {
340 template <class... _Args>
341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void __call(_Args&&... __args) {
342 std::__invoke(std::forward<_Args>(__args)...);
343 }
344};
345
271template <class _Ret, class... _Args>346template <class _Ret, class... _Args>
272_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) {347_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... __args) {
273 return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...);348 return __invoke_void_return_wrapper<_Ret>::__call(std::forward<_Args>(__args)...);
...@@ -278,11 +353,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... _...@@ -278,11 +353,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ret __invoke_r(_Args&&... _
278// is_invocable353// is_invocable
279354
280template <class _Fn, class... _Args>355template <class _Fn, class... _Args>
281struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...>> {};356struct _LIBCPP_NO_SPECIALIZATIONS is_invocable : bool_constant<__is_invocable_v<_Fn, _Args...> > {};
282357
283template <class _Ret, class _Fn, class... _Args>358template <class _Ret, class _Fn, class... _Args>
284struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_invocable_r359struct _LIBCPP_NO_SPECIALIZATIONS is_invocable_r : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
285 : bool_constant<__is_invocable_r_v<_Ret, _Fn, _Args...>> {};
286360
287template <class _Fn, class... _Args>361template <class _Fn, class... _Args>
288_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;362_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_v = __is_invocable_v<_Fn, _Args...>;
...@@ -293,27 +367,26 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocab...@@ -293,27 +367,26 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_invocable_r_v = __is_invocab
293// is_nothrow_invocable367// is_nothrow_invocable
294368
295template <class _Fn, class... _Args>369template <class _Fn, class... _Args>
296struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable370struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable : bool_constant<__is_nothrow_invocable_v<_Fn, _Args...> > {};
297 : bool_constant<__nothrow_invokable<_Fn, _Args...>::value> {};
298371
299template <class _Ret, class _Fn, class... _Args>372template <class _Ret, class _Fn, class... _Args>
300struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r373struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_invocable_r
301 : bool_constant<__nothrow_invokable_r<_Ret, _Fn, _Args...>::value> {};374 : bool_constant<__is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>> {};
302375
303template <class _Fn, class... _Args>376template <class _Fn, class... _Args>
304_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = is_nothrow_invocable<_Fn, _Args...>::value;377_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_v = __is_nothrow_invocable_v<_Fn, _Args...>;
305378
306template <class _Ret, class _Fn, class... _Args>379template <class _Ret, class _Fn, class... _Args>
307_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =380_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_invocable_r_v =
308 is_nothrow_invocable_r<_Ret, _Fn, _Args...>::value;381 __is_nothrow_invocable_r_v<_Ret, _Fn, _Args...>;
309382
310template <class _Fn, class... _Args>383template <class _Fn, class... _Args>
311struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};384struct _LIBCPP_NO_SPECIALIZATIONS invoke_result : __invoke_result<_Fn, _Args...> {};
312385
313template <class _Fn, class... _Args>386template <class _Fn, class... _Args>
314using invoke_result_t = typename invoke_result<_Fn, _Args...>::type;387using invoke_result_t = __invoke_result_t<_Fn, _Args...>;
315388
316#endif // _LIBCPP_STD_VER >= 17389#endif
317390
318_LIBCPP_END_NAMESPACE_STD391_LIBCPP_END_NAMESPACE_STD
319392
lib/libcxx/include/__type_traits/is_abstract.h+1-2
...@@ -19,8 +19,7 @@...@@ -19,8 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_abstract22struct _LIBCPP_NO_SPECIALIZATIONS is_abstract : integral_constant<bool, __is_abstract(_Tp)> {};
23 : public integral_constant<bool, __is_abstract(_Tp)> {};
2423
25#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
26template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_aggregate.h+1-2
...@@ -21,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,8 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
21#if _LIBCPP_STD_VER >= 1721#if _LIBCPP_STD_VER >= 17
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_aggregate24struct _LIBCPP_NO_SPECIALIZATIONS is_aggregate : integral_constant<bool, __is_aggregate(_Tp)> {};
25 : public integral_constant<bool, __is_aggregate(_Tp)> {};
2625
27template <class _Tp>26template <class _Tp>
28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_aggregate_v = __is_aggregate(_Tp);
lib/libcxx/include/__type_traits/is_arithmetic.h+2-2
...@@ -21,8 +21,8 @@...@@ -21,8 +21,8 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_arithmetic24struct _LIBCPP_NO_SPECIALIZATIONS is_arithmetic
25 : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {};25 : integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {};
2626
27#if _LIBCPP_STD_VER >= 1727#if _LIBCPP_STD_VER >= 17
28template <class _Tp>28template <class _Tp>
lib/libcxx/include/__type_traits/is_array.h+3-23
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H10#define _LIBCPP___TYPE_TRAITS_IS_ARRAY_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,32 +18,13 @@...@@ -19,32 +18,13 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_array) && \
23 (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900))
24
25template <class _Tp>21template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_array : _BoolConstant<__is_array(_Tp)> {};
2723
28# if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
29template <class _Tp>25template <class _Tp>
30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_array_v = __is_array(_Tp);
31# endif27#endif
32
33#else
34
35template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_array : public false_type {};
37template <class _Tp>
38struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[]> : public true_type {};
39template <class _Tp, size_t _Np>
40struct _LIBCPP_TEMPLATE_VIS is_array<_Tp[_Np]> : public true_type {};
41
42# if _LIBCPP_STD_VER >= 17
43template <class _Tp>
44inline constexpr bool is_array_v = is_array<_Tp>::value;
45# endif
46
47#endif // __has_builtin(__is_array)
4828
49_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
5030
lib/libcxx/include/__type_traits/is_assignable.h+6-8
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,7 +20,7 @@...@@ -21,7 +20,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp, class _Up>22template <class _Tp, class _Up>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {};23struct _LIBCPP_NO_SPECIALIZATIONS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> {};
2524
26#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
27template <class _Tp, class _Arg>26template <class _Tp, class _Arg>
...@@ -29,9 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignab...@@ -29,9 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_assignable_v = __is_assignab
29#endif28#endif
3029
31template <class _Tp>30template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable31struct _LIBCPP_NO_SPECIALIZATIONS is_copy_assignable
33 : public integral_constant<bool,32 : integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
34 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3533
36#if _LIBCPP_STD_VER >= 1734#if _LIBCPP_STD_VER >= 17
37template <class _Tp>35template <class _Tp>
...@@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_...@@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_assignable_v = is_copy_
39#endif37#endif
4038
41template <class _Tp>39template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_assignable40struct _LIBCPP_NO_SPECIALIZATIONS is_move_assignable
43 : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};41 : integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
4442
45#if _LIBCPP_STD_VER >= 1743#if _LIBCPP_STD_VER >= 17
46template <class _Tp>44template <class _Tp>
lib/libcxx/include/__type_traits/is_base_of.h+2-4
...@@ -19,8 +19,7 @@...@@ -19,8 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Bp, class _Dp>21template <class _Bp, class _Dp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_base_of22struct _LIBCPP_NO_SPECIALIZATIONS is_base_of : integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
23 : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {};
2423
25#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
26template <class _Bp, class _Dp>25template <class _Bp, class _Dp>
...@@ -31,8 +30,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp...@@ -31,8 +30,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_base_of_v = __is_base_of(_Bp
31# if __has_builtin(__builtin_is_virtual_base_of)30# if __has_builtin(__builtin_is_virtual_base_of)
3231
33template <class _Base, class _Derived>32template <class _Base, class _Derived>
34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of33struct _LIBCPP_NO_SPECIALIZATIONS is_virtual_base_of : bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {};
35 : public bool_constant<__builtin_is_virtual_base_of(_Base, _Derived)> {};
3634
37template <class _Base, class _Derived>35template <class _Base, class _Derived>
38_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);36_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_virtual_base_of_v = __builtin_is_virtual_base_of(_Base, _Derived);
lib/libcxx/include/__type_traits/is_bounded_array.h+5-16
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,26 +18,16 @@...@@ -19,26 +18,16 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22template <class>21template <class _Tp>
23inline const bool __is_bounded_array_v = false;22inline const bool __is_bounded_array_v = __is_bounded_array(_Tp);
24template <class _Tp, size_t _Np>
25inline const bool __is_bounded_array_v<_Tp[_Np]> = true;
2623
27#if _LIBCPP_STD_VER >= 2024#if _LIBCPP_STD_VER >= 20
2825
29template <class>26template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : false_type {};27struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {};
31
32_LIBCPP_DIAGNOSTIC_PUSH
33# if __has_warning("-Winvalid-specialization")
34_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
35# endif
36template <class _Tp, size_t _Np>
37struct _LIBCPP_TEMPLATE_VIS is_bounded_array<_Tp[_Np]> : true_type {};
38_LIBCPP_DIAGNOSTIC_POP
3928
40template <class _Tp>29template <class _Tp>
41_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = is_bounded_array<_Tp>::value;30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
4231
43#endif32#endif
4433
lib/libcxx/include/__type_traits/is_char_like_type.h+4-2
...@@ -12,7 +12,8 @@...@@ -12,7 +12,8 @@
12#include <__config>12#include <__config>
13#include <__type_traits/conjunction.h>13#include <__type_traits/conjunction.h>
14#include <__type_traits/is_standard_layout.h>14#include <__type_traits/is_standard_layout.h>
15#include <__type_traits/is_trivial.h>15#include <__type_traits/is_trivially_constructible.h>
16#include <__type_traits/is_trivially_copyable.h>
1617
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header19# pragma GCC system_header
...@@ -21,7 +22,8 @@...@@ -21,7 +22,8 @@
21_LIBCPP_BEGIN_NAMESPACE_STD22_LIBCPP_BEGIN_NAMESPACE_STD
2223
23template <class _CharT>24template <class _CharT>
24using _IsCharLikeType _LIBCPP_NODEBUG = _And<is_standard_layout<_CharT>, is_trivial<_CharT> >;25using _IsCharLikeType _LIBCPP_NODEBUG =
26 _And<is_standard_layout<_CharT>, is_trivially_default_constructible<_CharT>, is_trivially_copyable<_CharT> >;
2527
26_LIBCPP_END_NAMESPACE_STD28_LIBCPP_END_NAMESPACE_STD
2729
lib/libcxx/include/__type_traits/is_class.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_class : public integral_constant<bool, __is_class(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_class : integral_constant<bool, __is_class(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_compound.h+2-2
...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__is_compound)22#if __has_builtin(__is_compound)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {};25struct _LIBCPP_NO_SPECIALIZATIONS is_compound : _BoolConstant<__is_compound(_Tp)> {};
2626
27# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
28template <class _Tp>28template <class _Tp>
...@@ -32,7 +32,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_...@@ -32,7 +32,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_compound_v = __is_compound(_
32#else // __has_builtin(__is_compound)32#else // __has_builtin(__is_compound)
3333
34template <class _Tp>34template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {};35struct is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {};
3636
37# if _LIBCPP_STD_VER >= 1737# if _LIBCPP_STD_VER >= 17
38template <class _Tp>38template <class _Tp>
lib/libcxx/include/__type_traits/is_const.h+3-19
...@@ -18,29 +18,13 @@...@@ -18,29 +18,13 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__is_const)
22
23template <class _Tp>21template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_const : _BoolConstant<__is_const(_Tp)> {};
2523
26# if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
27template <class _Tp>25template <class _Tp>
28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_const_v = __is_const(_Tp);
29# endif27#endif
30
31#else
32
33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS is_const : public false_type {};
35template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_const<_Tp const> : public true_type {};
37
38# if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_const_v = is_const<_Tp>::value;
41# endif
42
43#endif // __has_builtin(__is_const)
4428
45_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
4630
lib/libcxx/include/__type_traits/is_constructible.h+7-10
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H10#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,8 +20,7 @@...@@ -21,8 +20,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp, class... _Args>22template <class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_constructible23struct _LIBCPP_NO_SPECIALIZATIONS is_constructible : integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
25 : public integral_constant<bool, __is_constructible(_Tp, _Args...)> {};
2624
27#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class... _Args>26template <class _Tp, class... _Args>
...@@ -30,8 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_const...@@ -30,8 +28,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_constructible_v = __is_const
30#endif28#endif
3129
32template <class _Tp>30template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible31struct _LIBCPP_NO_SPECIALIZATIONS is_copy_constructible
34 : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};32 : integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3533
36#if _LIBCPP_STD_VER >= 1734#if _LIBCPP_STD_VER >= 17
37template <class _Tp>35template <class _Tp>
...@@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_co...@@ -39,8 +37,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_copy_constructible_v = is_co
39#endif37#endif
4038
41template <class _Tp>39template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_move_constructible40struct _LIBCPP_NO_SPECIALIZATIONS is_move_constructible
43 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};41 : integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4442
45#if _LIBCPP_STD_VER >= 1743#if _LIBCPP_STD_VER >= 17
46template <class _Tp>44template <class _Tp>
...@@ -48,8 +46,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_mo...@@ -48,8 +46,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_move_constructible_v = is_mo
48#endif46#endif
4947
50template <class _Tp>48template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_default_constructible49struct _LIBCPP_NO_SPECIALIZATIONS is_default_constructible : integral_constant<bool, __is_constructible(_Tp)> {};
52 : public integral_constant<bool, __is_constructible(_Tp)> {};
5350
54#if _LIBCPP_STD_VER >= 1751#if _LIBCPP_STD_VER >= 17
55template <class _Tp>52template <class _Tp>
lib/libcxx/include/__type_traits/is_convertible.h+11-2
...@@ -19,14 +19,23 @@...@@ -19,14 +19,23 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _T1, class _T2>21template <class _T1, class _T2>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_convertible22struct _LIBCPP_NO_SPECIALIZATIONS is_convertible : integral_constant<bool, __is_convertible(_T1, _T2)> {};
23 : public integral_constant<bool, __is_convertible(_T1, _T2)> {};
2423
25#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
26template <class _From, class _To>25template <class _From, class _To>
27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_convertible_v = __is_convertible(_From, _To);
28#endif27#endif
2928
29#if _LIBCPP_STD_VER >= 20
30
31template <class _Tp, class _Up>
32struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
33
34template <class _Tp, class _Up>
35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
36
37#endif // _LIBCPP_STD_VER >= 20
38
30_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
3140
32#endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H41#endif // _LIBCPP___TYPE_TRAITS_IS_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_core_convertible.h+22-3
...@@ -24,11 +24,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,11 +24,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.24// and __is_core_convertible<immovable-type,immovable-type> is true in C++17 and later.
2525
26template <class _Tp, class _Up, class = void>26template <class _Tp, class _Up, class = void>
27struct __is_core_convertible : public false_type {};27inline const bool __is_core_convertible_v = false;
2828
29template <class _Tp, class _Up>29template <class _Tp, class _Up>
30struct __is_core_convertible<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))>30inline const bool
31 : public true_type {};31 __is_core_convertible_v<_Tp, _Up, decltype(static_cast<void (*)(_Up)>(0)(static_cast<_Tp (*)()>(0)()))> = true;
32
33template <class _Tp, class _Up>
34using __is_core_convertible _LIBCPP_NODEBUG = integral_constant<bool, __is_core_convertible_v<_Tp, _Up> >;
35
36#if _LIBCPP_STD_VER >= 20
37
38template <class _Tp, class _Up>
39concept __core_convertible_to = __is_core_convertible_v<_Tp, _Up>;
40
41#endif // _LIBCPP_STD_VER >= 20
42
43template <class _Tp, class _Up, bool = __is_core_convertible_v<_Tp, _Up> >
44inline const bool __is_nothrow_core_convertible_v = false;
45
46#ifndef _LIBCPP_CXX03_LANG
47template <class _Tp, class _Up>
48inline const bool __is_nothrow_core_convertible_v<_Tp, _Up, true> =
49 noexcept(static_cast<void (*)(_Up) noexcept>(0)(static_cast<_Tp (*)() noexcept>(0)()));
50#endif
3251
33_LIBCPP_END_NAMESPACE_STD52_LIBCPP_END_NAMESPACE_STD
3453
lib/libcxx/include/__type_traits/is_destructible.h+8-8
...@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
25#if __has_builtin(__is_destructible)25#if __has_builtin(__is_destructible)
2626
27template <class _Tp>27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {};28struct _LIBCPP_NO_SPECIALIZATIONS is_destructible : _BoolConstant<__is_destructible(_Tp)> {};
2929
30# if _LIBCPP_STD_VER >= 1730# if _LIBCPP_STD_VER >= 17
31template <class _Tp>31template <class _Tp>
...@@ -62,28 +62,28 @@ struct __destructible_imp;...@@ -62,28 +62,28 @@ struct __destructible_imp;
6262
63template <class _Tp>63template <class _Tp>
64struct __destructible_imp<_Tp, false>64struct __destructible_imp<_Tp, false>
65 : public integral_constant<bool, __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {};65 : integral_constant<bool, __is_destructor_wellformed<__remove_all_extents_t<_Tp> >::value> {};
6666
67template <class _Tp>67template <class _Tp>
68struct __destructible_imp<_Tp, true> : public true_type {};68struct __destructible_imp<_Tp, true> : true_type {};
6969
70template <class _Tp, bool>70template <class _Tp, bool>
71struct __destructible_false;71struct __destructible_false;
7272
73template <class _Tp>73template <class _Tp>
74struct __destructible_false<_Tp, false> : public __destructible_imp<_Tp, is_reference<_Tp>::value> {};74struct __destructible_false<_Tp, false> : __destructible_imp<_Tp, is_reference<_Tp>::value> {};
7575
76template <class _Tp>76template <class _Tp>
77struct __destructible_false<_Tp, true> : public false_type {};77struct __destructible_false<_Tp, true> : false_type {};
7878
79template <class _Tp>79template <class _Tp>
80struct is_destructible : public __destructible_false<_Tp, is_function<_Tp>::value> {};80struct is_destructible : __destructible_false<_Tp, is_function<_Tp>::value> {};
8181
82template <class _Tp>82template <class _Tp>
83struct is_destructible<_Tp[]> : public false_type {};83struct is_destructible<_Tp[]> : false_type {};
8484
85template <>85template <>
86struct is_destructible<void> : public false_type {};86struct is_destructible<void> : false_type {};
8787
88# if _LIBCPP_STD_VER >= 1788# if _LIBCPP_STD_VER >= 17
89template <class _Tp>89template <class _Tp>
lib/libcxx/include/__type_traits/is_empty.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_empty : public integral_constant<bool, __is_empty(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_empty : integral_constant<bool, __is_empty(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_enum.h+2-2
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_enum : public integral_constant<bool, __is_enum(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_enum : integral_constant<bool, __is_enum(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
...@@ -29,7 +29,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp);...@@ -29,7 +29,7 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_enum_v = __is_enum(_Tp);
29#if _LIBCPP_STD_VER >= 2329#if _LIBCPP_STD_VER >= 23
3030
31template <class _Tp>31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {};32struct _LIBCPP_NO_SPECIALIZATIONS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {};
3333
34template <class _Tp>34template <class _Tp>
35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
lib/libcxx/include/__type_traits/is_final.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS __libcpp_is_final : public integral_constant<bool, __is_final(_Tp)> {};22struct __libcpp_is_final : integral_constant<bool, __is_final(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1424#if _LIBCPP_STD_VER >= 14
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_final : public integral_constant<bool, __is_final(_Tp)> {};26struct _LIBCPP_NO_SPECIALIZATIONS is_final : integral_constant<bool, __is_final(_Tp)> {};
27#endif27#endif
2828
29#if _LIBCPP_STD_VER >= 1729#if _LIBCPP_STD_VER >= 17
lib/libcxx/include/__type_traits/is_floating_point.h+5-6
...@@ -20,15 +20,14 @@...@@ -20,15 +20,14 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22// clang-format off22// clang-format off
23template <class _Tp> struct __libcpp_is_floating_point : public false_type {};23template <class _Tp> struct __libcpp_is_floating_point : false_type {};
24template <> struct __libcpp_is_floating_point<float> : public true_type {};24template <> struct __libcpp_is_floating_point<float> : true_type {};
25template <> struct __libcpp_is_floating_point<double> : public true_type {};25template <> struct __libcpp_is_floating_point<double> : true_type {};
26template <> struct __libcpp_is_floating_point<long double> : public true_type {};26template <> struct __libcpp_is_floating_point<long double> : true_type {};
27// clang-format on27// clang-format on
2828
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_floating_point30struct _LIBCPP_NO_SPECIALIZATIONS is_floating_point : __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
31 : public __libcpp_is_floating_point<__remove_cv_t<_Tp> > {};
3231
33#if _LIBCPP_STD_VER >= 1732#if _LIBCPP_STD_VER >= 17
34template <class _Tp>33template <class _Tp>
lib/libcxx/include/__type_traits/is_function.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_function : integral_constant<bool, __is_function(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_fundamental.h+3-3
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_fundamental)23#if __has_builtin(__is_fundamental)
2424
25template <class _Tp>25template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {};26struct _LIBCPP_NO_SPECIALIZATIONS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> {};
2727
28# if _LIBCPP_STD_VER >= 1728# if _LIBCPP_STD_VER >= 17
29template <class _Tp>29template <class _Tp>
...@@ -33,8 +33,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundame...@@ -33,8 +33,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_fundamental_v = __is_fundame
33#else // __has_builtin(__is_fundamental)33#else // __has_builtin(__is_fundamental)
3434
35template <class _Tp>35template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_fundamental36struct is_fundamental
37 : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {};37 : integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {};
3838
39# if _LIBCPP_STD_VER >= 1739# if _LIBCPP_STD_VER >= 17
40template <class _Tp>40template <class _Tp>
lib/libcxx/include/__type_traits/is_implicit_lifetime.h+1-2
...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,8 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22# if __has_builtin(__builtin_is_implicit_lifetime)22# if __has_builtin(__builtin_is_implicit_lifetime)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime25struct _LIBCPP_NO_SPECIALIZATIONS is_implicit_lifetime : bool_constant<__builtin_is_implicit_lifetime(_Tp)> {};
26 : public bool_constant<__builtin_is_implicit_lifetime(_Tp)> {};
2726
28template <class _Tp>27template <class _Tp>
29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);
lib/libcxx/include/__type_traits/is_integral.h+13-13
...@@ -19,6 +19,18 @@...@@ -19,6 +19,18 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if __has_builtin(__is_integral)
23
24template <class _Tp>
25struct _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {};
26
27# if _LIBCPP_STD_VER >= 17
28template <class _Tp>
29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp);
30# endif
31
32#else
33
22// clang-format off34// clang-format off
23template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };35template <class _Tp> struct __libcpp_is_integral { enum { value = 0 }; };
24template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };36template <> struct __libcpp_is_integral<bool> { enum { value = 1 }; };
...@@ -47,20 +59,8 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va...@@ -47,20 +59,8 @@ template <> struct __libcpp_is_integral<__uint128_t> { enum { va
47#endif59#endif
48// clang-format on60// clang-format on
4961
50#if __has_builtin(__is_integral)
51
52template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_integral : _BoolConstant<__is_integral(_Tp)> {};
54
55# if _LIBCPP_STD_VER >= 17
56template <class _Tp>
57_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_integral_v = __is_integral(_Tp);
58# endif
59
60#else
61
62template <class _Tp>62template <class _Tp>
63struct _LIBCPP_TEMPLATE_VIS is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};63struct is_integral : public _BoolConstant<__libcpp_is_integral<__remove_cv_t<_Tp> >::value> {};
6464
65# if _LIBCPP_STD_VER >= 1765# if _LIBCPP_STD_VER >= 17
66template <class _Tp>66template <class _Tp>
lib/libcxx/include/__type_traits/is_literal_type.h+2-2
...@@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)21#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type23struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type
24 : public integral_constant<bool, __is_literal_type(_Tp)> {};24 : integral_constant<bool, __is_literal_type(_Tp)> {};
2525
26# if _LIBCPP_STD_VER >= 1726# if _LIBCPP_STD_VER >= 17
27template <class _Tp>27template <class _Tp>
lib/libcxx/include/__type_traits/is_member_pointer.h+3-5
...@@ -19,15 +19,13 @@...@@ -19,15 +19,13 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer25struct _LIBCPP_NO_SPECIALIZATIONS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
26 : _BoolConstant<__is_member_object_pointer(_Tp)> {};
2726
28template <class _Tp>27template <class _Tp>
29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer28struct _LIBCPP_NO_SPECIALIZATIONS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
30 : _BoolConstant<__is_member_function_pointer(_Tp)> {};
3129
32#if _LIBCPP_STD_VER >= 1730#if _LIBCPP_STD_VER >= 17
33template <class _Tp>31template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+8-12
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,8 +20,8 @@...@@ -21,8 +20,8 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp, class _Arg>22template <class _Tp, class _Arg>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable23struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_assignable : integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {
25 : public integral_constant<bool, __is_nothrow_assignable(_Tp, _Arg)> {};24};
2625
27#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class _Arg>27template <class _Tp, class _Arg>
...@@ -30,10 +29,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_...@@ -30,10 +29,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_assignable_v = __is_
30#endif29#endif
3130
32template <class _Tp>31template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable32struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_assignable
34 : public integral_constant<33 : integral_constant<bool,
35 bool,34 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
36 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3735
38#if _LIBCPP_STD_VER >= 1736#if _LIBCPP_STD_VER >= 17
39template <class _Tp>37template <class _Tp>
...@@ -41,10 +39,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v =...@@ -41,10 +39,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_assignable_v =
41#endif39#endif
4240
43template <class _Tp>41template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable42struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_assignable
45 : public integral_constant<bool,43 : integral_constant<bool, __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
46 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
47};
4844
49#if _LIBCPP_STD_VER >= 1745#if _LIBCPP_STD_VER >= 17
50template <class _Tp>46template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+9-10
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,8 +20,8 @@...@@ -21,8 +20,8 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template < class _Tp, class... _Args>22template < class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible23struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_constructible
25 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};24 : integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
2625
27#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
28template <class _Tp, class... _Args>27template <class _Tp, class... _Args>
...@@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v =...@@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_constructible_v =
31#endif30#endif
3231
33template <class _Tp>32template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible33struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_copy_constructible
35 : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};34 : integral_constant<bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3635
37#if _LIBCPP_STD_VER >= 1736#if _LIBCPP_STD_VER >= 17
38template <class _Tp>37template <class _Tp>
...@@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v...@@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_copy_constructible_v
41#endif40#endif
4241
43template <class _Tp>42template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible43struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_move_constructible
45 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};44 : integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4645
47#if _LIBCPP_STD_VER >= 1746#if _LIBCPP_STD_VER >= 17
48template <class _Tp>47template <class _Tp>
...@@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v...@@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_move_constructible_v
51#endif50#endif
5251
53template <class _Tp>52template <class _Tp>
54struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible53struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_default_constructible
55 : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {};54 : integral_constant<bool, __is_nothrow_constructible(_Tp)> {};
5655
57#if _LIBCPP_STD_VER >= 1756#if _LIBCPP_STD_VER >= 17
58template <class _Tp>57template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_convertible.h deleted-62
...@@ -1,62 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
11
12#include <__config>
13#include <__type_traits/conjunction.h>
14#include <__type_traits/disjunction.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_convertible.h>
17#include <__type_traits/is_void.h>
18#include <__type_traits/lazy.h>
19#include <__utility/declval.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER >= 20
28
29# if __has_builtin(__is_nothrow_convertible)
30
31template <class _Tp, class _Up>
32struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
33
34template <class _Tp, class _Up>
35_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
36
37# else // __has_builtin(__is_nothrow_convertible)
38
39template <typename _Tp>
40void __test_noexcept(_Tp) noexcept;
41
42template <typename _Fm, typename _To>
43bool_constant<noexcept(std::__test_noexcept<_To>(std::declval<_Fm>()))> __is_nothrow_convertible_test();
44
45template <typename _Fm, typename _To>
46struct __is_nothrow_convertible_helper : decltype(__is_nothrow_convertible_test<_Fm, _To>()) {};
47
48template <typename _Fm, typename _To>
49struct is_nothrow_convertible
50 : _Or<_And<is_void<_To>, is_void<_Fm>>,
51 _Lazy<_And, is_convertible<_Fm, _To>, __is_nothrow_convertible_helper<_Fm, _To> > >::type {};
52
53template <typename _Fm, typename _To>
54inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
55
56# endif // __has_builtin(__is_nothrow_convertible)
57
58#endif // _LIBCPP_STD_VER >= 20
59
60_LIBCPP_END_NAMESPACE_STD
61
62#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONVERTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+7-10
...@@ -24,8 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -24,8 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24#if __has_builtin(__is_nothrow_destructible)24#if __has_builtin(__is_nothrow_destructible)
2525
26template <class _Tp>26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible27struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};
28 : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};
2928
30#else29#else
3130
...@@ -33,24 +32,22 @@ template <bool, class _Tp>...@@ -33,24 +32,22 @@ template <bool, class _Tp>
33struct __libcpp_is_nothrow_destructible;32struct __libcpp_is_nothrow_destructible;
3433
35template <class _Tp>34template <class _Tp>
36struct __libcpp_is_nothrow_destructible<false, _Tp> : public false_type {};35struct __libcpp_is_nothrow_destructible<false, _Tp> : false_type {};
3736
38template <class _Tp>37template <class _Tp>
39struct __libcpp_is_nothrow_destructible<true, _Tp>38struct __libcpp_is_nothrow_destructible<true, _Tp> : integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) > {};
40 : public integral_constant<bool, noexcept(std::declval<_Tp>().~_Tp()) > {};
4139
42template <class _Tp>40template <class _Tp>
43struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible41struct is_nothrow_destructible : __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> {};
44 : public __libcpp_is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> {};
4542
46template <class _Tp, size_t _Ns>43template <class _Tp, size_t _Ns>
47struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> {};44struct is_nothrow_destructible<_Tp[_Ns]> : is_nothrow_destructible<_Tp> {};
4845
49template <class _Tp>46template <class _Tp>
50struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {};47struct is_nothrow_destructible<_Tp&> : true_type {};
5148
52template <class _Tp>49template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {};50struct is_nothrow_destructible<_Tp&&> : true_type {};
5451
55#endif // __has_builtin(__is_nothrow_destructible)52#endif // __has_builtin(__is_nothrow_destructible)
5653
lib/libcxx/include/__type_traits/is_null_pointer.h+1-2
...@@ -24,8 +24,7 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);...@@ -24,8 +24,7 @@ inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);
2424
25#if _LIBCPP_STD_VER >= 1425#if _LIBCPP_STD_VER >= 14
26template <class _Tp>26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_null_pointer27struct _LIBCPP_NO_SPECIALIZATIONS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {};
28 : integral_constant<bool, __is_null_pointer_v<_Tp>> {};
2928
30# if _LIBCPP_STD_VER >= 1729# if _LIBCPP_STD_VER >= 17
31template <class _Tp>30template <class _Tp>
lib/libcxx/include/__type_traits/is_object.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_object : _BoolConstant<__is_object(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_pod.h+2-2
...@@ -19,11 +19,11 @@...@@ -19,11 +19,11 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pod : public integral_constant<bool, __is_pod(_Tp)> {};22struct _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS is_pod : integral_constant<bool, __is_pod(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);26_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pod_v = __is_pod(_Tp);
27#endif27#endif
2828
29_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_pointer.h+1-35
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -19,47 +18,14 @@...@@ -19,47 +18,14 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_pointer)
23
24template <class _Tp>21template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_pointer : _BoolConstant<__is_pointer(_Tp)> {};
2623
27# if _LIBCPP_STD_VER >= 1724# if _LIBCPP_STD_VER >= 17
28template <class _Tp>25template <class _Tp>
29_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_pointer_v = __is_pointer(_Tp);
30# endif27# endif
3128
32#else // __has_builtin(__is_pointer)
33
34template <class _Tp>
35struct __libcpp_is_pointer : public false_type {};
36template <class _Tp>
37struct __libcpp_is_pointer<_Tp*> : public true_type {};
38
39template <class _Tp>
40struct __libcpp_remove_objc_qualifiers {
41 typedef _Tp type;
42};
43# if _LIBCPP_HAS_OBJC_ARC
44// clang-format off
45template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
46template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; };
47template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing> { typedef _Tp type; };
48template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
49// clang-format on
50# endif
51
52template <class _Tp>
53struct _LIBCPP_TEMPLATE_VIS is_pointer
54 : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<__remove_cv_t<_Tp> >::type> {};
55
56# if _LIBCPP_STD_VER >= 17
57template <class _Tp>
58inline constexpr bool is_pointer_v = is_pointer<_Tp>::value;
59# endif
60
61#endif // __has_builtin(__is_pointer)
62
63_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
6430
65#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H31#endif // _LIBCPP___TYPE_TRAITS_IS_POINTER_H
lib/libcxx/include/__type_traits/is_polymorphic.h+1-2
...@@ -19,8 +19,7 @@...@@ -19,8 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_polymorphic22struct _LIBCPP_NO_SPECIALIZATIONS is_polymorphic : integral_constant<bool, __is_polymorphic(_Tp)> {};
23 : public integral_constant<bool, __is_polymorphic(_Tp)> {};
2423
25#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
26template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_reference.h+7-9
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_reference : _BoolConstant<__is_reference(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
...@@ -29,12 +29,10 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference...@@ -29,12 +29,10 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_reference_v = __is_reference
29#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)29#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)
3030
31template <class _Tp>31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {32struct _LIBCPP_NO_SPECIALIZATIONS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};
33};
3433
35template <class _Tp>34template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {35struct _LIBCPP_NO_SPECIALIZATIONS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {};
37};
3836
39# if _LIBCPP_STD_VER >= 1737# if _LIBCPP_STD_VER >= 17
40template <class _Tp>38template <class _Tp>
...@@ -46,14 +44,14 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rv...@@ -46,14 +44,14 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_rvalue_reference_v = __is_rv
46#else // __has_builtin(__is_lvalue_reference)44#else // __has_builtin(__is_lvalue_reference)
4745
48template <class _Tp>46template <class _Tp>
49struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};47struct is_lvalue_reference : false_type {};
50template <class _Tp>48template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference<_Tp&> : public true_type {};49struct is_lvalue_reference<_Tp&> : true_type {};
5250
53template <class _Tp>51template <class _Tp>
54struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};52struct is_rvalue_reference : false_type {};
55template <class _Tp>53template <class _Tp>
56struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};54struct is_rvalue_reference<_Tp&&> : true_type {};
5755
58# if _LIBCPP_STD_VER >= 1756# if _LIBCPP_STD_VER >= 17
59template <class _Tp>57template <class _Tp>
lib/libcxx/include/__type_traits/is_reference_wrapper.h+3-3
...@@ -21,11 +21,11 @@...@@ -21,11 +21,11 @@
21_LIBCPP_BEGIN_NAMESPACE_STD21_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <class _Tp>23template <class _Tp>
24struct __is_reference_wrapper_impl : public false_type {};24struct __is_reference_wrapper_impl : false_type {};
25template <class _Tp>25template <class _Tp>
26struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : public true_type {};26struct __is_reference_wrapper_impl<reference_wrapper<_Tp> > : true_type {};
27template <class _Tp>27template <class _Tp>
28struct __is_reference_wrapper : public __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {};28struct __is_reference_wrapper : __is_reference_wrapper_impl<__remove_cv_t<_Tp> > {};
2929
30_LIBCPP_END_NAMESPACE_STD30_LIBCPP_END_NAMESPACE_STD
3131
lib/libcxx/include/__type_traits/is_referenceable.h+8-15
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/void_t.h>
14#include <__type_traits/is_same.h>
1514
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header16# pragma GCC system_header
...@@ -19,22 +18,16 @@...@@ -19,22 +18,16 @@
1918
20_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_referenceable)21template <class _Tp, class = void>
22inline const bool __is_referenceable_v = false;
23
23template <class _Tp>24template <class _Tp>
24struct __libcpp_is_referenceable : integral_constant<bool, __is_referenceable(_Tp)> {};25inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&> > = true;
25#else
26struct __libcpp_is_referenceable_impl {
27 template <class _Tp>
28 static _Tp& __test(int);
29 template <class _Tp>
30 static false_type __test(...);
31};
3226
27#if _LIBCPP_STD_VER >= 20
33template <class _Tp>28template <class _Tp>
34struct __libcpp_is_referenceable29concept __referenceable = __is_referenceable_v<_Tp>;
35 : integral_constant<bool, _IsNotSame<decltype(__libcpp_is_referenceable_impl::__test<_Tp>(0)), false_type>::value> {30#endif
36};
37#endif // __has_builtin(__is_referenceable)
3831
39_LIBCPP_END_NAMESPACE_STD32_LIBCPP_END_NAMESPACE_STD
4033
lib/libcxx/include/__type_traits/is_replaceable.h created+61
...@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H
11
12#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_same.h>
16#include <__type_traits/is_trivially_copyable.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24// A type is replaceable if, with `x` and `y` being different objects, `x = std::move(y)` is equivalent to:
25//
26// std::destroy_at(&x)
27// std::construct_at(&x, std::move(y))
28//
29// This allows turning a move-assignment into a sequence of destroy + move-construct, which
30// is often more efficient. This is especially relevant when the move-construct is in fact
31// part of a trivial relocation from somewhere else, in which case there is a huge win.
32//
33// Note that this requires language support in order to be really effective, but we
34// currently emulate the base template with something very conservative.
35template <class _Tp, class = void>
36struct __is_replaceable : is_trivially_copyable<_Tp> {};
37
38template <class _Tp>
39struct __is_replaceable<_Tp, __enable_if_t<is_same<_Tp, typename _Tp::__replaceable>::value> > : true_type {};
40
41template <class _Tp>
42inline const bool __is_replaceable_v = __is_replaceable<_Tp>::value;
43
44// Determines whether an allocator member of a container is replaceable.
45//
46// First, we require the allocator type to be considered replaceable. If not, then something fishy might be
47// happening. Assuming the allocator type is replaceable, we conclude replaceability of the allocator as a
48// member of the container if the allocator always compares equal (in which case propagation doesn't matter),
49// or if the allocator always propagates on assignment, which is required in order for move construction and
50// assignment to be equivalent.
51template <class _AllocatorTraits>
52struct __container_allocator_is_replaceable
53 : integral_constant<bool,
54 __is_replaceable_v<typename _AllocatorTraits::allocator_type> &&
55 (_AllocatorTraits::is_always_equal::value ||
56 (_AllocatorTraits::propagate_on_container_move_assignment::value &&
57 _AllocatorTraits::propagate_on_container_copy_assignment::value))> {};
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP___TYPE_TRAITS_IS_REPLACEABLE_H
lib/libcxx/include/__type_traits/is_same.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, class _Up>21template <class _Tp, class _Up>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_same : _BoolConstant<__is_same(_Tp, _Up)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp, class _Up>25template <class _Tp, class _Up>
lib/libcxx/include/__type_traits/is_scalar.h+5-5
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26#if __has_builtin(__is_scalar)26#if __has_builtin(__is_scalar)
2727
28template <class _Tp>28template <class _Tp>
29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};29struct _LIBCPP_NO_SPECIALIZATIONS is_scalar : _BoolConstant<__is_scalar(_Tp)> {};
3030
31# if _LIBCPP_STD_VER >= 1731# if _LIBCPP_STD_VER >= 17
32template <class _Tp>32template <class _Tp>
...@@ -37,15 +37,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp);...@@ -37,15 +37,15 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_scalar_v = __is_scalar(_Tp);
3737
38template <class _Tp>38template <class _Tp>
39struct __is_block : false_type {};39struct __is_block : false_type {};
40# if _LIBCPP_HAS_EXTENSION_BLOCKS40# if __has_extension(blocks)
41template <class _Rp, class... _Args>41template <class _Rp, class... _Args>
42struct __is_block<_Rp (^)(_Args...)> : true_type {};42struct __is_block<_Rp (^)(_Args...)> : true_type {};
43# endif43# endif
4444
45// clang-format off45// clang-format off
46template <class _Tp>46template <class _Tp>
47struct _LIBCPP_TEMPLATE_VIS is_scalar47struct is_scalar
48 : public integral_constant<48 : integral_constant<
49 bool, is_arithmetic<_Tp>::value ||49 bool, is_arithmetic<_Tp>::value ||
50 is_member_pointer<_Tp>::value ||50 is_member_pointer<_Tp>::value ||
51 is_pointer<_Tp>::value ||51 is_pointer<_Tp>::value ||
...@@ -55,7 +55,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar...@@ -55,7 +55,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar
55// clang-format on55// clang-format on
5656
57template <>57template <>
58struct _LIBCPP_TEMPLATE_VIS is_scalar<nullptr_t> : public true_type {};58struct is_scalar<nullptr_t> : true_type {};
5959
60# if _LIBCPP_STD_VER >= 1760# if _LIBCPP_STD_VER >= 17
61template <class _Tp>61template <class _Tp>
lib/libcxx/include/__type_traits/is_signed.h+5-12
...@@ -12,7 +12,6 @@...@@ -12,7 +12,6 @@
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_integral.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18# pragma GCC system_header17# pragma GCC system_header
...@@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_signed)22#if __has_builtin(__is_signed)
2423
25template <class _Tp>24template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {};25struct _LIBCPP_NO_SPECIALIZATIONS is_signed : _BoolConstant<__is_signed(_Tp)> {};
2726
28# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
29template <class _Tp>28template <class _Tp>
...@@ -32,24 +31,18 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp);...@@ -32,24 +31,18 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_signed_v = __is_signed(_Tp);
3231
33#else // __has_builtin(__is_signed)32#else // __has_builtin(__is_signed)
3433
35template <class _Tp, bool = is_integral<_Tp>::value>
36struct __libcpp_is_signed_impl : public _BoolConstant<(_Tp(-1) < _Tp(0))> {};
37
38template <class _Tp>
39struct __libcpp_is_signed_impl<_Tp, false> : public true_type {}; // floating point
40
41template <class _Tp, bool = is_arithmetic<_Tp>::value>34template <class _Tp, bool = is_arithmetic<_Tp>::value>
42struct __libcpp_is_signed : public __libcpp_is_signed_impl<_Tp> {};35inline constexpr bool __is_signed_v = false;
4336
44template <class _Tp>37template <class _Tp>
45struct __libcpp_is_signed<_Tp, false> : public false_type {};38inline constexpr bool __is_signed_v<_Tp, true> = _Tp(-1) < _Tp(0);
4639
47template <class _Tp>40template <class _Tp>
48struct _LIBCPP_TEMPLATE_VIS is_signed : public __libcpp_is_signed<_Tp> {};41struct is_signed : integral_constant<bool, __is_signed_v<_Tp>> {};
4942
50# if _LIBCPP_STD_VER >= 1743# if _LIBCPP_STD_VER >= 17
51template <class _Tp>44template <class _Tp>
52inline constexpr bool is_signed_v = is_signed<_Tp>::value;45inline constexpr bool is_signed_v = __is_signed_v<_Tp>;
53# endif46# endif
5447
55#endif // __has_builtin(__is_signed)48#endif // __has_builtin(__is_signed)
lib/libcxx/include/__type_traits/is_signed_integer.h deleted-35
...@@ -1,35 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
10#define _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21// clang-format off
22template <class _Tp> struct __libcpp_is_signed_integer : public false_type {};
23template <> struct __libcpp_is_signed_integer<signed char> : public true_type {};
24template <> struct __libcpp_is_signed_integer<signed short> : public true_type {};
25template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
26template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
27template <> struct __libcpp_is_signed_integer<signed long long> : public true_type {};
28#if _LIBCPP_HAS_INT128
29template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {};
30#endif
31// clang-format on
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_SIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_standard_layout.h+1-2
...@@ -19,8 +19,7 @@...@@ -19,8 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_standard_layout22struct _LIBCPP_NO_SPECIALIZATIONS is_standard_layout : integral_constant<bool, __is_standard_layout(_Tp)> {};
23 : public integral_constant<bool, __is_standard_layout(_Tp)> {};
2423
25#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
26template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_swappable.h+5-8
...@@ -11,7 +11,7 @@...@@ -11,7 +11,7 @@
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>13#include <__cstddef/size_t.h>
14#include <__type_traits/add_lvalue_reference.h>14#include <__type_traits/add_reference.h>
15#include <__type_traits/enable_if.h>15#include <__type_traits/enable_if.h>
16#include <__type_traits/integral_constant.h>16#include <__type_traits/integral_constant.h>
17#include <__type_traits/is_assignable.h>17#include <__type_traits/is_assignable.h>
...@@ -77,30 +77,27 @@ template <class _Tp, class _Up>...@@ -77,30 +77,27 @@ template <class _Tp, class _Up>
77_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;77_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;
7878
79template <class _Tp, class _Up>79template <class _Tp, class _Up>
80struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable_with80struct _LIBCPP_NO_SPECIALIZATIONS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {};
81 : bool_constant<is_swappable_with_v<_Tp, _Up>> {};
8281
83template <class _Tp>82template <class _Tp>
84_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v =83_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_swappable_v =
85 is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;84 is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
8685
87template <class _Tp>86template <class _Tp>
88struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {};87struct _LIBCPP_NO_SPECIALIZATIONS is_swappable : bool_constant<is_swappable_v<_Tp>> {};
8988
90template <class _Tp, class _Up>89template <class _Tp, class _Up>
91_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;90_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;
9291
93template <class _Tp, class _Up>92template <class _Tp, class _Up>
94struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with93struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};
95 : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};
9694
97template <class _Tp>95template <class _Tp>
98_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v =96_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_nothrow_swappable_v =
99 is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;97 is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
10098
101template <class _Tp>99template <class _Tp>
102struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable100struct _LIBCPP_NO_SPECIALIZATIONS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {};
103 : bool_constant<is_nothrow_swappable_v<_Tp>> {};
104101
105#endif // _LIBCPP_STD_VER >= 17102#endif // _LIBCPP_STD_VER >= 17
106103
lib/libcxx/include/__type_traits/is_trivial.h+5-2
...@@ -19,11 +19,14 @@...@@ -19,11 +19,14 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivial : public integral_constant<bool, __is_trivial(_Tp)> {22struct _LIBCPP_DEPRECATED_IN_CXX26_(
23};23 "Consider using is_trivially_copyable<T>::value && is_trivially_default_constructible<T>::value instead.")
24 _LIBCPP_NO_SPECIALIZATIONS is_trivial : integral_constant<bool, __is_trivial(_Tp)> {};
2425
25#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
26template <class _Tp>27template <class _Tp>
28_LIBCPP_DEPRECATED_IN_CXX26_(
29 "Consider using is_trivially_copyable_v<T> && is_trivially_default_constructible_v<T> instead.")
27_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp);30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivial_v = __is_trivial(_Tp);
28#endif31#endif
2932
lib/libcxx/include/__type_traits/is_trivially_assignable.h+6-8
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -30,8 +29,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __i...@@ -30,8 +29,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_assignable_v = __i
30#endif29#endif
3130
32template <class _Tp>31template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable32struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_assignable
34 : public integral_constant<33 : integral_constant<
35 bool,34 bool,
36 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};35 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
3736
...@@ -42,10 +41,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v...@@ -42,10 +41,9 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_assignable_v
42#endif41#endif
4342
44template <class _Tp>43template <class _Tp>
45struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable44struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_assignable
46 : public integral_constant<45 : integral_constant<bool, __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
47 bool,46};
48 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
4947
50#if _LIBCPP_STD_VER >= 1748#if _LIBCPP_STD_VER >= 17
51template <class _Tp>49template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_constructible.h+8-9
...@@ -10,8 +10,7 @@...@@ -10,8 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>13#include <__type_traits/add_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.h>14#include <__type_traits/integral_constant.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -21,7 +20,7 @@...@@ -21,7 +20,7 @@
21_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2221
23template <class _Tp, class... _Args>22template <class _Tp, class... _Args>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible23struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_constructible
25 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {};24 : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> {};
2625
27#if _LIBCPP_STD_VER >= 1726#if _LIBCPP_STD_VER >= 17
...@@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v =...@@ -31,8 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_constructible_v =
31#endif30#endif
3231
33template <class _Tp>32template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible33struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copy_constructible
35 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};34 : integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
3635
37#if _LIBCPP_STD_VER >= 1736#if _LIBCPP_STD_VER >= 17
38template <class _Tp>37template <class _Tp>
...@@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible...@@ -41,8 +40,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_copy_constructible
41#endif40#endif
4241
43template <class _Tp>42template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible43struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_move_constructible
45 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};44 : integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
4645
47#if _LIBCPP_STD_VER >= 1746#if _LIBCPP_STD_VER >= 17
48template <class _Tp>47template <class _Tp>
...@@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible...@@ -51,8 +50,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_trivially_move_constructible
51#endif50#endif
5251
53template <class _Tp>52template <class _Tp>
54struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible53struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_default_constructible
55 : public integral_constant<bool, __is_trivially_constructible(_Tp)> {};54 : integral_constant<bool, __is_trivially_constructible(_Tp)> {};
5655
57#if _LIBCPP_STD_VER >= 1756#if _LIBCPP_STD_VER >= 17
58template <class _Tp>57template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_copyable.h+1-2
...@@ -20,8 +20,7 @@...@@ -20,8 +20,7 @@
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class _Tp>22template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable23struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_copyable : integral_constant<bool, __is_trivially_copyable(_Tp)> {};
24 : public integral_constant<bool, __is_trivially_copyable(_Tp)> {};
2524
26#if _LIBCPP_STD_VER >= 1725#if _LIBCPP_STD_VER >= 17
27template <class _Tp>26template <class _Tp>
lib/libcxx/include/__type_traits/is_trivially_destructible.h+4-4
...@@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -22,14 +22,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD
22#if __has_builtin(__is_trivially_destructible)22#if __has_builtin(__is_trivially_destructible)
2323
24template <class _Tp>24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible25struct _LIBCPP_NO_SPECIALIZATIONS is_trivially_destructible
26 : public integral_constant<bool, __is_trivially_destructible(_Tp)> {};26 : integral_constant<bool, __is_trivially_destructible(_Tp)> {};
2727
28#elif __has_builtin(__has_trivial_destructor)28#elif __has_builtin(__has_trivial_destructor)
2929
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible31struct is_trivially_destructible
32 : public integral_constant<bool, is_destructible<_Tp>::value&& __has_trivial_destructor(_Tp)> {};32 : integral_constant<bool, is_destructible<_Tp>::value&& __has_trivial_destructor(_Tp)> {};
3333
34#else34#else
3535
lib/libcxx/include/__type_traits/is_unbounded_array.h+2-10
...@@ -25,19 +25,11 @@ inline const bool __is_unbounded_array_v<_Tp[]> = true;...@@ -25,19 +25,11 @@ inline const bool __is_unbounded_array_v<_Tp[]> = true;
2525
26#if _LIBCPP_STD_VER >= 2026#if _LIBCPP_STD_VER >= 20
2727
28template <class>
29struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : false_type {};
30
31_LIBCPP_DIAGNOSTIC_PUSH
32# if __has_warning("-Winvalid-specialization")
33_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
34# endif
35template <class _Tp>28template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_unbounded_array<_Tp[]> : true_type {};29struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array_v<_Tp>> {};
37_LIBCPP_DIAGNOSTIC_POP
3830
39template <class _Tp>31template <class _Tp>
40_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = is_unbounded_array<_Tp>::value;32_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array_v<_Tp>;
4133
42#endif34#endif
4335
lib/libcxx/include/__type_traits/is_union.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_union : public integral_constant<bool, __is_union(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_union : integral_constant<bool, __is_union(_Tp)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_unsigned.h+5-12
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_arithmetic.h>
15#include <__type_traits/is_integral.h>14#include <__type_traits/is_integral.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
23#if __has_builtin(__is_unsigned)22#if __has_builtin(__is_unsigned)
2423
25template <class _Tp>24template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {};25struct _LIBCPP_NO_SPECIALIZATIONS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> {};
2726
28# if _LIBCPP_STD_VER >= 1727# if _LIBCPP_STD_VER >= 17
29template <class _Tp>28template <class _Tp>
...@@ -33,23 +32,17 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_...@@ -33,23 +32,17 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unsigned_v = __is_unsigned(_
33#else // __has_builtin(__is_unsigned)32#else // __has_builtin(__is_unsigned)
3433
35template <class _Tp, bool = is_integral<_Tp>::value>34template <class _Tp, bool = is_integral<_Tp>::value>
36struct __libcpp_is_unsigned_impl : public _BoolConstant<(_Tp(0) < _Tp(-1))> {};35inline constexpr bool __is_unsigned_v = false;
3736
38template <class _Tp>37template <class _Tp>
39struct __libcpp_is_unsigned_impl<_Tp, false> : public false_type {}; // floating point38inline constexpr bool __is_unsigned_v<_Tp, true> = _Tp(0) < _Tp(-1);
40
41template <class _Tp, bool = is_arithmetic<_Tp>::value>
42struct __libcpp_is_unsigned : public __libcpp_is_unsigned_impl<_Tp> {};
43
44template <class _Tp>
45struct __libcpp_is_unsigned<_Tp, false> : public false_type {};
4639
47template <class _Tp>40template <class _Tp>
48struct _LIBCPP_TEMPLATE_VIS is_unsigned : public __libcpp_is_unsigned<_Tp> {};41struct is_unsigned : integral_constant<bool, __is_unsigned_v<_Tp>> {};
4942
50# if _LIBCPP_STD_VER >= 1743# if _LIBCPP_STD_VER >= 17
51template <class _Tp>44template <class _Tp>
52inline constexpr bool is_unsigned_v = is_unsigned<_Tp>::value;45inline constexpr bool is_unsigned_v = __is_unsigned_v<_Tp>;
53# endif46# endif
5447
55#endif // __has_builtin(__is_unsigned)48#endif // __has_builtin(__is_unsigned)
lib/libcxx/include/__type_traits/is_unsigned_integer.h deleted-35
...@@ -1,35 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21// clang-format off
22template <class _Tp> struct __libcpp_is_unsigned_integer : public false_type {};
23template <> struct __libcpp_is_unsigned_integer<unsigned char> : public true_type {};
24template <> struct __libcpp_is_unsigned_integer<unsigned short> : public true_type {};
25template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
26template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
27template <> struct __libcpp_is_unsigned_integer<unsigned long long> : public true_type {};
28#if _LIBCPP_HAS_INT128
29template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {};
30#endif
31// clang-format on
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_UNSIGNED_INTEGER_H
lib/libcxx/include/__type_traits/is_void.h+1-1
...@@ -19,7 +19,7 @@...@@ -19,7 +19,7 @@
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp>21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
25template <class _Tp>25template <class _Tp>
lib/libcxx/include/__type_traits/is_volatile.h+3-19
...@@ -18,29 +18,13 @@...@@ -18,29 +18,13 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__is_volatile)
22
23template <class _Tp>21template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};22struct _LIBCPP_NO_SPECIALIZATIONS is_volatile : _BoolConstant<__is_volatile(_Tp)> {};
2523
26# if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
27template <class _Tp>25template <class _Tp>
28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp);26_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_volatile_v = __is_volatile(_Tp);
29# endif27#endif
30
31#else
32
33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS is_volatile : public false_type {};
35template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_volatile<_Tp volatile> : public true_type {};
37
38# if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_volatile_v = is_volatile<_Tp>::value;
41# endif
42
43#endif // __has_builtin(__is_volatile)
4428
45_LIBCPP_END_NAMESPACE_STD29_LIBCPP_END_NAMESPACE_STD
4630
lib/libcxx/include/__type_traits/promote.h+16-20
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10#define _LIBCPP___TYPE_TRAITS_PROMOTE_H10#define _LIBCPP___TYPE_TRAITS_PROMOTE_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/integral_constant.h>13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_arithmetic.h>14#include <__type_traits/is_arithmetic.h>
1515
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -19,28 +19,24 @@...@@ -19,28 +19,24 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <class... _Args>22float __promote_impl(float);
23class __promote {23double __promote_impl(char);
24 static_assert((is_arithmetic<_Args>::value && ...));24double __promote_impl(int);
2525double __promote_impl(unsigned);
26 static float __test(float);26double __promote_impl(long);
27 static double __test(char);27double __promote_impl(unsigned long);
28 static double __test(int);28double __promote_impl(long long);
29 static double __test(unsigned);29double __promote_impl(unsigned long long);
30 static double __test(long);
31 static double __test(unsigned long);
32 static double __test(long long);
33 static double __test(unsigned long long);
34#if _LIBCPP_HAS_INT12830#if _LIBCPP_HAS_INT128
35 static double __test(__int128_t);31double __promote_impl(__int128_t);
36 static double __test(__uint128_t);32double __promote_impl(__uint128_t);
37#endif33#endif
38 static double __test(double);34double __promote_impl(double);
39 static long double __test(long double);35long double __promote_impl(long double);
4036
41public:37template <class... _Args>
42 using type = decltype((__test(_Args()) + ...));38using __promote_t _LIBCPP_NODEBUG =
43};39 decltype((__enable_if_t<(is_arithmetic<_Args>::value && ...)>)0, (std::__promote_impl(_Args()) + ...));
4440
45_LIBCPP_END_NAMESPACE_STD41_LIBCPP_END_NAMESPACE_STD
4642
lib/libcxx/include/__type_traits/rank.h+6-6
...@@ -19,25 +19,25 @@...@@ -19,25 +19,25 @@
1919
20_LIBCPP_BEGIN_NAMESPACE_STD20_LIBCPP_BEGIN_NAMESPACE_STD
2121
22// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved22#if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) || \
23#if __has_builtin(__array_rank) && 023 (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001)
2424
25template <class _Tp>25template <class _Tp>
26struct rank : integral_constant<size_t, __array_rank(_Tp)> {};26struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {};
2727
28#else28#else
2929
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {};31struct _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {};
3232
33_LIBCPP_DIAGNOSTIC_PUSH33_LIBCPP_DIAGNOSTIC_PUSH
34# if __has_warning("-Winvalid-specialization")34# if __has_warning("-Winvalid-specialization")
35_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")35_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
36# endif36# endif
37template <class _Tp>37template <class _Tp>
38struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};38struct rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
39template <class _Tp, size_t _Np>39template <class _Tp, size_t _Np>
40struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};40struct rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
41_LIBCPP_DIAGNOSTIC_POP41_LIBCPP_DIAGNOSTIC_POP
4242
43#endif // __has_builtin(__array_rank)43#endif // __has_builtin(__array_rank)
lib/libcxx/include/__type_traits/reference_constructs_from_temporary.h created+44
...@@ -0,0 +1,44 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H
10#define _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_constructs_from_temporary)
22
23template <class _Tp, class _Up>
24struct _LIBCPP_NO_SPECIALIZATIONS reference_constructs_from_temporary
25 : public bool_constant<__reference_constructs_from_temporary(_Tp, _Up)> {};
26
27template <class _Tp, class _Up>
28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_temporary_v =
29 __reference_constructs_from_temporary(_Tp, _Up);
30
31#endif
32
33#if __has_builtin(__reference_constructs_from_temporary)
34template <class _Tp, class _Up>
35inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up);
36#else
37// TODO(LLVM 22): Remove this as all supported compilers should have __reference_constructs_from_temporary implemented.
38template <class _Tp, class _Up>
39inline const bool __reference_constructs_from_temporary_v = __reference_binds_to_temporary(_Tp, _Up);
40#endif
41
42_LIBCPP_END_NAMESPACE_STD
43
44#endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONSTRUCTS_FROM_TEMPORARY_H
lib/libcxx/include/__type_traits/reference_converts_from_temporary.h created+35
...@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H
10#define _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if _LIBCPP_STD_VER >= 23 && __has_builtin(__reference_converts_from_temporary)
22
23template <class _Tp, class _Up>
24struct _LIBCPP_NO_SPECIALIZATIONS reference_converts_from_temporary
25 : public bool_constant<__reference_converts_from_temporary(_Tp, _Up)> {};
26
27template <class _Tp, class _Up>
28_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_converts_from_temporary_v =
29 __reference_converts_from_temporary(_Tp, _Up);
30
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H
lib/libcxx/include/__type_traits/remove_all_extents.h+4-18
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_ALL_EXTENTS_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -18,31 +17,18 @@...@@ -18,31 +17,18 @@
1817
19_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
2019
21#if __has_builtin(__remove_all_extents)
22template <class _Tp>20template <class _Tp>
23struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {21struct _LIBCPP_NO_SPECIALIZATIONS remove_all_extents {
24 using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);22 using type _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
25};23};
2624
25#ifdef _LIBCPP_COMPILER_GCC
27template <class _Tp>26template <class _Tp>
28using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);27using __remove_all_extents_t _LIBCPP_NODEBUG = typename remove_all_extents<_Tp>::type;
29#else28#else
30template <class _Tp>29template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS remove_all_extents {30using __remove_all_extents_t _LIBCPP_NODEBUG = __remove_all_extents(_Tp);
32 typedef _Tp type;31#endif
33};
34template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[]> {
36 typedef typename remove_all_extents<_Tp>::type type;
37};
38template <class _Tp, size_t _Np>
39struct _LIBCPP_TEMPLATE_VIS remove_all_extents<_Tp[_Np]> {
40 typedef typename remove_all_extents<_Tp>::type type;
41};
42
43template <class _Tp>
44using __remove_all_extents_t = typename remove_all_extents<_Tp>::type;
45#endif // __has_builtin(__remove_all_extents)
4632
47#if _LIBCPP_STD_VER >= 1433#if _LIBCPP_STD_VER >= 14
48template <class _Tp>34template <class _Tp>
lib/libcxx/include/__type_traits/remove_const.h+2-2
...@@ -27,11 +27,11 @@ template <class _Tp>...@@ -27,11 +27,11 @@ template <class _Tp>
27using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp);27using __remove_const_t _LIBCPP_NODEBUG = __remove_const(_Tp);
28#else28#else
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS remove_const {30struct remove_const {
31 typedef _Tp type;31 typedef _Tp type;
32};32};
33template <class _Tp>33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS remove_const<const _Tp> {34struct remove_const<const _Tp> {
35 typedef _Tp type;35 typedef _Tp type;
36};36};
3737
lib/libcxx/include/__type_traits/remove_cvref.h-4
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_CVREF_H
1111
12#include <__config>12#include <__config>
13#include <__type_traits/is_same.h>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -31,9 +30,6 @@ template <class _Tp>...@@ -31,9 +30,6 @@ template <class _Tp>
31using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);30using __remove_cvref_t _LIBCPP_NODEBUG = __remove_cvref(_Tp);
32#endif // __has_builtin(__remove_cvref)31#endif // __has_builtin(__remove_cvref)
3332
34template <class _Tp, class _Up>
35using __is_same_uncvref _LIBCPP_NODEBUG = _IsSame<__remove_cvref_t<_Tp>, __remove_cvref_t<_Up> >;
36
37#if _LIBCPP_STD_VER >= 2033#if _LIBCPP_STD_VER >= 20
38template <class _Tp>34template <class _Tp>
39struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref {35struct _LIBCPP_NO_SPECIALIZATIONS remove_cvref {
lib/libcxx/include/__type_traits/remove_extent.h+4-18
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H10#define _LIBCPP___TYPE_TRAITS_REMOVE_EXTENT_H
1111
12#include <__config>12#include <__config>
13#include <__cstddef/size_t.h>
1413
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header15# pragma GCC system_header
...@@ -18,31 +17,18 @@...@@ -18,31 +17,18 @@
1817
19_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
2019
21#if __has_builtin(__remove_extent)
22template <class _Tp>20template <class _Tp>
23struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {21struct _LIBCPP_NO_SPECIALIZATIONS remove_extent {
24 using type _LIBCPP_NODEBUG = __remove_extent(_Tp);22 using type _LIBCPP_NODEBUG = __remove_extent(_Tp);
25};23};
2624
25#ifdef _LIBCPP_COMPILER_GCC
27template <class _Tp>26template <class _Tp>
28using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);27using __remove_extent_t _LIBCPP_NODEBUG = typename remove_extent<_Tp>::type;
29#else28#else
30template <class _Tp>29template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS remove_extent {30using __remove_extent_t _LIBCPP_NODEBUG = __remove_extent(_Tp);
32 typedef _Tp type;31#endif
33};
34template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[]> {
36 typedef _Tp type;
37};
38template <class _Tp, size_t _Np>
39struct _LIBCPP_TEMPLATE_VIS remove_extent<_Tp[_Np]> {
40 typedef _Tp type;
41};
42
43template <class _Tp>
44using __remove_extent_t = typename remove_extent<_Tp>::type;
45#endif // __has_builtin(__remove_extent)
4632
47#if _LIBCPP_STD_VER >= 1433#if _LIBCPP_STD_VER >= 14
48template <class _Tp>34template <class _Tp>
lib/libcxx/include/__type_traits/remove_pointer.h+5-5
...@@ -32,11 +32,11 @@ using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp);...@@ -32,11 +32,11 @@ using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp);
32# endif32# endif
33#else33#else
34// clang-format off34// clang-format off
35template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {using type _LIBCPP_NODEBUG = _Tp;};35template <class _Tp> struct remove_pointer {using type _LIBCPP_NODEBUG = _Tp;};
36template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;};36template <class _Tp> struct remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;};
37template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;};37template <class _Tp> struct remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;};
38template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;};38template <class _Tp> struct remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;};
39template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;};39template <class _Tp> struct remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;};
40// clang-format on40// clang-format on
4141
42template <class _Tp>42template <class _Tp>
lib/libcxx/include/__type_traits/remove_volatile.h+2-2
...@@ -27,11 +27,11 @@ template <class _Tp>...@@ -27,11 +27,11 @@ template <class _Tp>
27using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp);27using __remove_volatile_t _LIBCPP_NODEBUG = __remove_volatile(_Tp);
28#else28#else
29template <class _Tp>29template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS remove_volatile {30struct remove_volatile {
31 typedef _Tp type;31 typedef _Tp type;
32};32};
33template <class _Tp>33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS remove_volatile<volatile _Tp> {34struct remove_volatile<volatile _Tp> {
35 typedef _Tp type;35 typedef _Tp type;
36};36};
3737
lib/libcxx/include/__type_traits/result_of.h+1-1
...@@ -29,7 +29,7 @@ _LIBCPP_DIAGNOSTIC_PUSH...@@ -29,7 +29,7 @@ _LIBCPP_DIAGNOSTIC_PUSH
29_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")29_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
30#endif30#endif
31template <class _Fp, class... _Args>31template <class _Fp, class... _Args>
32struct _LIBCPP_TEMPLATE_VIS result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};32struct result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
33_LIBCPP_DIAGNOSTIC_POP33_LIBCPP_DIAGNOSTIC_POP
3434
35# if _LIBCPP_STD_VER >= 1435# if _LIBCPP_STD_VER >= 14
lib/libcxx/include/__type_traits/strip_signature.h+18-18
...@@ -26,52 +26,52 @@ struct __strip_signature;...@@ -26,52 +26,52 @@ struct __strip_signature;
2626
27template <class _Rp, class... _Args>27template <class _Rp, class... _Args>
28struct __strip_signature<_Rp (*)(_Args...)> {28struct __strip_signature<_Rp (*)(_Args...)> {
29 using type = _Rp(_Args...);29 using type _LIBCPP_NODEBUG = _Rp(_Args...);
30};30};
3131
32template <class _Rp, class... _Args>32template <class _Rp, class... _Args>
33struct __strip_signature<_Rp (*)(_Args...) noexcept> {33struct __strip_signature<_Rp (*)(_Args...) noexcept> {
34 using type = _Rp(_Args...);34 using type _LIBCPP_NODEBUG = _Rp(_Args...);
35};35};
3636
37# endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L37# endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
3838
39// clang-format off39// clang-format off
40template<class _Rp, class _Gp, class ..._Ap>40template<class _Rp, class _Gp, class ..._Ap>
41struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };41struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
42template<class _Rp, class _Gp, class ..._Ap>42template<class _Rp, class _Gp, class ..._Ap>
43struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); };43struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
44template<class _Rp, class _Gp, class ..._Ap>44template<class _Rp, class _Gp, class ..._Ap>
45struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); };45struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
46template<class _Rp, class _Gp, class ..._Ap>46template<class _Rp, class _Gp, class ..._Ap>
47struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); };47struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
4848
49template<class _Rp, class _Gp, class ..._Ap>49template<class _Rp, class _Gp, class ..._Ap>
50struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); };50struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
51template<class _Rp, class _Gp, class ..._Ap>51template<class _Rp, class _Gp, class ..._Ap>
52struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); };52struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
53template<class _Rp, class _Gp, class ..._Ap>53template<class _Rp, class _Gp, class ..._Ap>
54struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); };54struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
55template<class _Rp, class _Gp, class ..._Ap>55template<class _Rp, class _Gp, class ..._Ap>
56struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); };56struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
5757
58template<class _Rp, class _Gp, class ..._Ap>58template<class _Rp, class _Gp, class ..._Ap>
59struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); };59struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
60template<class _Rp, class _Gp, class ..._Ap>60template<class _Rp, class _Gp, class ..._Ap>
61struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); };61struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
62template<class _Rp, class _Gp, class ..._Ap>62template<class _Rp, class _Gp, class ..._Ap>
63struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); };63struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
64template<class _Rp, class _Gp, class ..._Ap>64template<class _Rp, class _Gp, class ..._Ap>
65struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); };65struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
6666
67template<class _Rp, class _Gp, class ..._Ap>67template<class _Rp, class _Gp, class ..._Ap>
68struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); };68struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
69template<class _Rp, class _Gp, class ..._Ap>69template<class _Rp, class _Gp, class ..._Ap>
70struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); };70struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
71template<class _Rp, class _Gp, class ..._Ap>71template<class _Rp, class _Gp, class ..._Ap>
72struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); };72struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
73template<class _Rp, class _Gp, class ..._Ap>73template<class _Rp, class _Gp, class ..._Ap>
74struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); };74struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
75// clang-format on75// clang-format on
7676
77_LIBCPP_END_NAMESPACE_STD77_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/underlying_type.h+11-2
...@@ -18,7 +18,7 @@...@@ -18,7 +18,7 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21template <class _Tp, bool = is_enum<_Tp>::value>21template <class _Tp, bool>
22struct __underlying_type_impl;22struct __underlying_type_impl;
2323
24template <class _Tp>24template <class _Tp>
...@@ -32,9 +32,18 @@ struct __underlying_type_impl<_Tp, true> {...@@ -32,9 +32,18 @@ struct __underlying_type_impl<_Tp, true> {
32template <class _Tp>32template <class _Tp>
33struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};33struct _LIBCPP_NO_SPECIALIZATIONS underlying_type : __underlying_type_impl<_Tp, is_enum<_Tp>::value> {};
3434
35// GCC doesn't SFINAE away when using __underlying_type directly
36#if !defined(_LIBCPP_COMPILER_GCC)
37template <class _Tp>
38using __underlying_type_t _LIBCPP_NODEBUG = __underlying_type(_Tp);
39#else
40template <class _Tp>
41using __underlying_type_t _LIBCPP_NODEBUG = typename underlying_type<_Tp>::type;
42#endif
43
35#if _LIBCPP_STD_VER >= 1444#if _LIBCPP_STD_VER >= 14
36template <class _Tp>45template <class _Tp>
37using underlying_type_t = typename underlying_type<_Tp>::type;46using underlying_type_t = __underlying_type_t<_Tp>;
38#endif47#endif
3948
40_LIBCPP_END_NAMESPACE_STD49_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/cmp.h+8-8
...@@ -9,8 +9,8 @@...@@ -9,8 +9,8 @@
9#ifndef _LIBCPP___UTILITY_CMP_H9#ifndef _LIBCPP___UTILITY_CMP_H
10#define _LIBCPP___UTILITY_CMP_H10#define _LIBCPP___UTILITY_CMP_H
1111
12#include <__concepts/arithmetic.h>
13#include <__config>12#include <__config>
13#include <__type_traits/integer_traits.h>
14#include <__type_traits/is_signed.h>14#include <__type_traits/is_signed.h>
15#include <__type_traits/make_unsigned.h>15#include <__type_traits/make_unsigned.h>
16#include <limits>16#include <limits>
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
27#if _LIBCPP_STD_VER >= 2027#if _LIBCPP_STD_VER >= 20
2828
29template <__libcpp_integer _Tp, __libcpp_integer _Up>29template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
30_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept {30_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept {
31 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)31 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
32 return __t == __u;32 return __t == __u;
...@@ -36,12 +36,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept {...@@ -36,12 +36,12 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_equal(_Tp __t, _Up __u) noexcept {
36 return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u);36 return __u < 0 ? false : __t == make_unsigned_t<_Up>(__u);
37}37}
3838
39template <__libcpp_integer _Tp, __libcpp_integer _Up>39template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
40_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept {40_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_not_equal(_Tp __t, _Up __u) noexcept {
41 return !std::cmp_equal(__t, __u);41 return !std::cmp_equal(__t, __u);
42}42}
4343
44template <__libcpp_integer _Tp, __libcpp_integer _Up>44template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
45_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept {45_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept {
46 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)46 if constexpr (is_signed_v<_Tp> == is_signed_v<_Up>)
47 return __t < __u;47 return __t < __u;
...@@ -51,22 +51,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept {...@@ -51,22 +51,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less(_Tp __t, _Up __u) noexcept {
51 return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u);51 return __u < 0 ? false : __t < make_unsigned_t<_Up>(__u);
52}52}
5353
54template <__libcpp_integer _Tp, __libcpp_integer _Up>54template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
55_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept {55_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater(_Tp __t, _Up __u) noexcept {
56 return std::cmp_less(__u, __t);56 return std::cmp_less(__u, __t);
57}57}
5858
59template <__libcpp_integer _Tp, __libcpp_integer _Up>59template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
60_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept {60_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_less_equal(_Tp __t, _Up __u) noexcept {
61 return !std::cmp_greater(__t, __u);61 return !std::cmp_greater(__t, __u);
62}62}
6363
64template <__libcpp_integer _Tp, __libcpp_integer _Up>64template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
65_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept {65_LIBCPP_HIDE_FROM_ABI constexpr bool cmp_greater_equal(_Tp __t, _Up __u) noexcept {
66 return !std::cmp_less(__t, __u);66 return !std::cmp_less(__t, __u);
67}67}
6868
69template <__libcpp_integer _Tp, __libcpp_integer _Up>69template <__signed_or_unsigned_integer _Tp, __signed_or_unsigned_integer _Up>
70_LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept {70_LIBCPP_HIDE_FROM_ABI constexpr bool in_range(_Up __u) noexcept {
71 return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&71 return std::cmp_less_equal(__u, numeric_limits<_Tp>::max()) &&
72 std::cmp_greater_equal(__u, numeric_limits<_Tp>::min());72 std::cmp_greater_equal(__u, numeric_limits<_Tp>::min());
lib/libcxx/include/__utility/convert_to_integral.h+1-1
...@@ -50,7 +50,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral...@@ -50,7 +50,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral
5050
51template <class _Tp, bool = is_enum<_Tp>::value>51template <class _Tp, bool = is_enum<_Tp>::value>
52struct __sfinae_underlying_type {52struct __sfinae_underlying_type {
53 typedef typename underlying_type<_Tp>::type type;53 using type = __underlying_type_t<_Tp>;
54 typedef decltype(((type)1) + 0) __promoted_type;54 typedef decltype(((type)1) + 0) __promoted_type;
55};55};
5656
lib/libcxx/include/__utility/exception_guard.h+3-4
...@@ -6,13 +6,12 @@...@@ -6,13 +6,12 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#ifndef _LIBCPP___UTILITY_TRANSACTION_H9#ifndef _LIBCPP___UTILITY_EXCEPTION_GUARD_H
10#define _LIBCPP___UTILITY_TRANSACTION_H10#define _LIBCPP___UTILITY_EXCEPTION_GUARD_H
1111
12#include <__assert>12#include <__assert>
13#include <__config>13#include <__config>
14#include <__type_traits/is_nothrow_constructible.h>14#include <__type_traits/is_nothrow_constructible.h>
15#include <__utility/exchange.h>
16#include <__utility/move.h>15#include <__utility/move.h>
1716
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -141,4 +140,4 @@ _LIBCPP_END_NAMESPACE_STD...@@ -141,4 +140,4 @@ _LIBCPP_END_NAMESPACE_STD
141140
142_LIBCPP_POP_MACROS141_LIBCPP_POP_MACROS
143142
144#endif // _LIBCPP___UTILITY_TRANSACTION_H143#endif // _LIBCPP___UTILITY_EXCEPTION_GUARD_H
lib/libcxx/include/__utility/in_place.h+2-2
...@@ -28,14 +28,14 @@ struct _LIBCPP_EXPORTED_FROM_ABI in_place_t {...@@ -28,14 +28,14 @@ struct _LIBCPP_EXPORTED_FROM_ABI in_place_t {
28inline constexpr in_place_t in_place{};28inline constexpr in_place_t in_place{};
2929
30template <class _Tp>30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS in_place_type_t {31struct in_place_type_t {
32 _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default;32 _LIBCPP_HIDE_FROM_ABI explicit in_place_type_t() = default;
33};33};
34template <class _Tp>34template <class _Tp>
35inline constexpr in_place_type_t<_Tp> in_place_type{};35inline constexpr in_place_type_t<_Tp> in_place_type{};
3636
37template <size_t _Idx>37template <size_t _Idx>
38struct _LIBCPP_TEMPLATE_VIS in_place_index_t {38struct in_place_index_t {
39 _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default;39 _LIBCPP_HIDE_FROM_ABI explicit in_place_index_t() = default;
40};40};
41template <size_t _Idx>41template <size_t _Idx>
lib/libcxx/include/__utility/integer_sequence.h+1-1
...@@ -46,7 +46,7 @@ using __make_indices_imp _LIBCPP_NODEBUG =...@@ -46,7 +46,7 @@ using __make_indices_imp _LIBCPP_NODEBUG =
46#if _LIBCPP_STD_VER >= 1446#if _LIBCPP_STD_VER >= 14
4747
48template <class _Tp, _Tp... _Ip>48template <class _Tp, _Tp... _Ip>
49struct _LIBCPP_TEMPLATE_VIS integer_sequence {49struct integer_sequence {
50 typedef _Tp value_type;50 typedef _Tp value_type;
51 static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type");51 static_assert(is_integral<_Tp>::value, "std::integer_sequence can only be instantiated with an integral type");
52 static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); }52 static _LIBCPP_HIDE_FROM_ABI constexpr size_t size() noexcept { return sizeof...(_Ip); }
lib/libcxx/include/__utility/no_destroy.h-1
...@@ -11,7 +11,6 @@...@@ -11,7 +11,6 @@
1111
12#include <__config>12#include <__config>
13#include <__new/placement_new_delete.h>13#include <__new/placement_new_delete.h>
14#include <__type_traits/is_constant_evaluated.h>
15#include <__utility/forward.h>14#include <__utility/forward.h>
1615
17#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__utility/pair.h+97-83
...@@ -11,6 +11,7 @@...@@ -11,6 +11,7 @@
1111
12#include <__compare/common_comparison_category.h>12#include <__compare/common_comparison_category.h>
13#include <__compare/synth_three_way.h>13#include <__compare/synth_three_way.h>
14#include <__concepts/boolean_testable.h>
14#include <__concepts/different_from.h>15#include <__concepts/different_from.h>
15#include <__config>16#include <__config>
16#include <__cstddef/size_t.h>17#include <__cstddef/size_t.h>
...@@ -23,7 +24,6 @@...@@ -23,7 +24,6 @@
23#include <__type_traits/common_reference.h>24#include <__type_traits/common_reference.h>
24#include <__type_traits/common_type.h>25#include <__type_traits/common_type.h>
25#include <__type_traits/conditional.h>26#include <__type_traits/conditional.h>
26#include <__type_traits/decay.h>
27#include <__type_traits/enable_if.h>27#include <__type_traits/enable_if.h>
28#include <__type_traits/integral_constant.h>28#include <__type_traits/integral_constant.h>
29#include <__type_traits/is_assignable.h>29#include <__type_traits/is_assignable.h>
...@@ -32,11 +32,11 @@...@@ -32,11 +32,11 @@
32#include <__type_traits/is_implicitly_default_constructible.h>32#include <__type_traits/is_implicitly_default_constructible.h>
33#include <__type_traits/is_nothrow_assignable.h>33#include <__type_traits/is_nothrow_assignable.h>
34#include <__type_traits/is_nothrow_constructible.h>34#include <__type_traits/is_nothrow_constructible.h>
35#include <__type_traits/is_replaceable.h>
35#include <__type_traits/is_same.h>36#include <__type_traits/is_same.h>
36#include <__type_traits/is_swappable.h>37#include <__type_traits/is_swappable.h>
37#include <__type_traits/is_trivially_relocatable.h>38#include <__type_traits/is_trivially_relocatable.h>
38#include <__type_traits/nat.h>39#include <__type_traits/nat.h>
39#include <__type_traits/remove_cvref.h>
40#include <__type_traits/unwrap_ref.h>40#include <__type_traits/unwrap_ref.h>
41#include <__utility/declval.h>41#include <__utility/declval.h>
42#include <__utility/forward.h>42#include <__utility/forward.h>
...@@ -52,6 +52,33 @@ _LIBCPP_PUSH_MACROS...@@ -52,6 +52,33 @@ _LIBCPP_PUSH_MACROS
5252
53_LIBCPP_BEGIN_NAMESPACE_STD53_LIBCPP_BEGIN_NAMESPACE_STD
5454
55#ifndef _LIBCPP_CXX03_LANG
56
57template <class _T1, class _T2>
58struct __check_pair_construction {
59 template <int&...>
60 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {
61 return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
62 }
63
64 template <int&...>
65 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() {
66 return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
67 }
68
69 template <class _U1, class _U2>
70 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() {
71 return is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value;
72 }
73
74 template <class _U1, class _U2>
75 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() {
76 return is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value;
77 }
78};
79
80#endif
81
55template <class, class>82template <class, class>
56struct __non_trivially_copyable_base {83struct __non_trivially_copyable_base {
57 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {}84 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {}
...@@ -60,7 +87,7 @@ struct __non_trivially_copyable_base {...@@ -60,7 +87,7 @@ struct __non_trivially_copyable_base {
60};87};
6188
62template <class _T1, class _T2>89template <class _T1, class _T2>
63struct _LIBCPP_TEMPLATE_VIS pair90struct pair
64#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)91#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
65 : private __non_trivially_copyable_base<_T1, _T2>92 : private __non_trivially_copyable_base<_T1, _T2>
66#endif93#endif
...@@ -75,6 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -75,6 +102,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
75 __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,102 __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,
76 pair,103 pair,
77 void>;104 void>;
105 using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_T1> && __is_replaceable_v<_T2>, pair, void>;
78106
79 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;107 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
80 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;108 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;
...@@ -107,40 +135,16 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -107,40 +135,16 @@ struct _LIBCPP_TEMPLATE_VIS pair
107 return *this;135 return *this;
108 }136 }
109#else137#else
110 struct _CheckArgs {138 template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>,
111 template <int&...>139 __enable_if_t<_CheckArgsDep::__enable_default(), int> = 0>
112 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {140 explicit(!_CheckArgsDep::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(
113 return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
114 }
115
116 template <int&...>
117 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() {
118 return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
119 }
120
121 template <class _U1, class _U2>
122 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() {
123 return is_constructible<first_type, _U1>::value && is_constructible<second_type, _U2>::value;
124 }
125
126 template <class _U1, class _U2>
127 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() {
128 return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value;
129 }
130 };
131
132 template <bool _MaybeEnable>
133 using _CheckArgsDep _LIBCPP_NODEBUG = __conditional_t<_MaybeEnable, _CheckArgs, void>;
134
135 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0>
136 explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(
137 is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)141 is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)
138 : first(), second() {}142 : first(), second() {}
139143
140 template <bool _Dummy = true,144 template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>,
141 __enable_if_t<_CheckArgsDep<_Dummy>::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0>145 __enable_if_t<_CheckArgsDep::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0>
142 _LIBCPP_HIDE_FROM_ABI146 _LIBCPP_HIDE_FROM_ABI
143 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>())147 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep::template __is_implicit<_T1 const&, _T2 const&>())
144 pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value &&148 pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value &&
145 is_nothrow_copy_constructible<second_type>::value)149 is_nothrow_copy_constructible<second_type>::value)
146 : first(__t1), second(__t2) {}150 : first(__t1), second(__t2) {}
...@@ -153,62 +157,64 @@ struct _LIBCPP_TEMPLATE_VIS pair...@@ -153,62 +157,64 @@ struct _LIBCPP_TEMPLATE_VIS pair
153 class _U1,157 class _U1,
154 class _U2,158 class _U2,
155# endif159# endif
156 __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0 >160 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0 >
157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())161 _LIBCPP_HIDE_FROM_ABI
162 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
158 pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value &&163 pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value &&
159 is_nothrow_constructible<second_type, _U2>::value)164 is_nothrow_constructible<second_type, _U2>::value)
160 : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {165 : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {
161 }166 }
162167
163# if _LIBCPP_STD_VER >= 23168# if _LIBCPP_STD_VER >= 23
164 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int> = 0>169 template <class _U1,
165 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>())170 class _U2,
171 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1&, _U2&>(), int> = 0>
172 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1&, _U2&>())
166 pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value &&173 pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
167 is_nothrow_constructible<second_type, _U2&>::value))174 is_nothrow_constructible<second_type, _U2&>::value))
168 : first(__p.first), second(__p.second) {}175 : first(__p.first), second(__p.second) {}
169# endif176# endif
170177
171 template <class _U1,178 template <
172 class _U2,179 class _U1,
173 __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1 const&, _U2 const&>(), int> = 0>180 class _U2,
174 _LIBCPP_HIDE_FROM_ABI181 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1 const&, _U2 const&>(),
175 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1 const&, _U2 const&>())182 int> = 0>
183 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
184 !__check_pair_construction<_T1, _T2>::template __is_implicit<_U1 const&, _U2 const&>())
176 pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value &&185 pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value &&
177 is_nothrow_constructible<second_type, _U2 const&>::value)186 is_nothrow_constructible<second_type, _U2 const&>::value)
178 : first(__p.first), second(__p.second) {}187 : first(__p.first), second(__p.second) {}
179188
180 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0>189 template <class _U1,
181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())190 class _U2,
191 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0>
192 _LIBCPP_HIDE_FROM_ABI
193 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
182 pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value &&194 pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value &&
183 is_nothrow_constructible<second_type, _U2&&>::value)195 is_nothrow_constructible<second_type, _U2&&>::value)
184 : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}196 : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}
185197
186# if _LIBCPP_STD_VER >= 23198# if _LIBCPP_STD_VER >= 23
187 template <class _U1,199 template <
188 class _U2,200 class _U1,
189 __enable_if_t<_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int> = 0>201 class _U2,
190 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())202 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<const _U1&&, const _U2&&>(),
203 int> = 0>
204 _LIBCPP_HIDE_FROM_ABI constexpr explicit(
205 !__check_pair_construction<_T1, _T2>::template __is_implicit<const _U1&&, const _U2&&>())
191 pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&206 pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&
192 is_nothrow_constructible<second_type, const _U2&&>::value)207 is_nothrow_constructible<second_type, const _U2&&>::value)
193 : first(std::move(__p.first)), second(std::move(__p.second)) {}208 : first(std::move(__p.first)), second(std::move(__p.second)) {}
194# endif209# endif
195210
196# if _LIBCPP_STD_VER >= 23211# if _LIBCPP_STD_VER >= 23
197 // TODO: Remove this workaround in LLVM 20. The bug got fixed in Clang 18.
198 // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed.
199 template <class _PairLike>
200 _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() {
201 if constexpr (__pair_like_no_subrange<_PairLike>) {
202 return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||
203 !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>;
204 }
205 return false;
206 }
207
208 template <__pair_like_no_subrange _PairLike>212 template <__pair_like_no_subrange _PairLike>
209 requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&213 requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&
210 is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>)214 is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>)
211 _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p)215 _LIBCPP_HIDE_FROM_ABI constexpr explicit(
216 !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||
217 !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>) pair(_PairLike&& __p)
212 : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {}218 : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {}
213# endif219# endif
214220
...@@ -450,7 +456,14 @@ pair(_T1, _T2) -> pair<_T1, _T2>;...@@ -450,7 +456,14 @@ pair(_T1, _T2) -> pair<_T1, _T2>;
450456
451template <class _T1, class _T2, class _U1, class _U2>457template <class _T1, class _T2, class _U1, class _U2>
452inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool458inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
453operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {459operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
460#if _LIBCPP_STD_VER >= 26
461 requires requires {
462 { __x.first == __y.first } -> __boolean_testable;
463 { __x.second == __y.second } -> __boolean_testable;
464 }
465#endif
466{
454 return __x.first == __y.first && __x.second == __y.second;467 return __x.first == __y.first && __x.second == __y.second;
455}468}
456469
...@@ -506,13 +519,14 @@ template <class _T1, class _T2, class _U1, class _U2, template <class> class _TQ...@@ -506,13 +519,14 @@ template <class _T1, class _T2, class _U1, class _U2, template <class> class _TQ
506 typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;519 typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
507 }520 }
508struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {521struct basic_common_reference<pair<_T1, _T2>, pair<_U1, _U2>, _TQual, _UQual> {
509 using type = pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;522 using type _LIBCPP_NODEBUG =
523 pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>, common_reference_t<_TQual<_T2>, _UQual<_U2>>>;
510};524};
511525
512template <class _T1, class _T2, class _U1, class _U2>526template <class _T1, class _T2, class _U1, class _U2>
513 requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }527 requires requires { typename pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>; }
514struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {528struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
515 using type = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;529 using type _LIBCPP_NODEBUG = pair<common_type_t<_T1, _U1>, common_type_t<_T2, _U2>>;
516};530};
517#endif // _LIBCPP_STD_VER >= 23531#endif // _LIBCPP_STD_VER >= 23
518532
...@@ -538,20 +552,20 @@ make_pair(_T1&& __t1, _T2&& __t2) {...@@ -538,20 +552,20 @@ make_pair(_T1&& __t1, _T2&& __t2) {
538}552}
539553
540template <class _T1, class _T2>554template <class _T1, class _T2>
541struct _LIBCPP_TEMPLATE_VIS tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {};555struct tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {};
542556
543template <size_t _Ip, class _T1, class _T2>557template <size_t _Ip, class _T1, class _T2>
544struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, pair<_T1, _T2> > {558struct tuple_element<_Ip, pair<_T1, _T2> > {
545 static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");559 static_assert(_Ip < 2, "Index out of bounds in std::tuple_element<std::pair<T1, T2>>");
546};560};
547561
548template <class _T1, class _T2>562template <class _T1, class _T2>
549struct _LIBCPP_TEMPLATE_VIS tuple_element<0, pair<_T1, _T2> > {563struct tuple_element<0, pair<_T1, _T2> > {
550 using type _LIBCPP_NODEBUG = _T1;564 using type _LIBCPP_NODEBUG = _T1;
551};565};
552566
553template <class _T1, class _T2>567template <class _T1, class _T2>
554struct _LIBCPP_TEMPLATE_VIS tuple_element<1, pair<_T1, _T2> > {568struct tuple_element<1, pair<_T1, _T2> > {
555 using type _LIBCPP_NODEBUG = _T2;569 using type _LIBCPP_NODEBUG = _T2;
556};570};
557571
...@@ -631,42 +645,42 @@ get(const pair<_T1, _T2>&& __p) _NOEXCEPT {...@@ -631,42 +645,42 @@ get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
631#if _LIBCPP_STD_VER >= 14645#if _LIBCPP_STD_VER >= 14
632template <class _T1, class _T2>646template <class _T1, class _T2>
633inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {647inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
634 return __get_pair<0>::get(__p);648 return __p.first;
635}649}
636650
637template <class _T1, class _T2>651template <class _T1, class _T2>
638inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {652inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
639 return __get_pair<0>::get(__p);653 return __p.first;
640}654}
641655
642template <class _T1, class _T2>656template <class _T1, class _T2>
643inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {657inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
644 return __get_pair<0>::get(std::move(__p));658 return std::forward<_T1&&>(__p.first);
645}659}
646660
647template <class _T1, class _T2>661template <class _T1, class _T2>
648inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {662inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
649 return __get_pair<0>::get(std::move(__p));663 return std::forward<_T1 const&&>(__p.first);
650}664}
651665
652template <class _T1, class _T2>666template <class _T2, class _T1>
653inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T2, _T1>& __p) _NOEXCEPT {667inline _LIBCPP_HIDE_FROM_ABI constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {
654 return __get_pair<1>::get(__p);668 return __p.second;
655}669}
656670
657template <class _T1, class _T2>671template <class _T2, class _T1>
658inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T2, _T1> const& __p) _NOEXCEPT {672inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
659 return __get_pair<1>::get(__p);673 return __p.second;
660}674}
661675
662template <class _T1, class _T2>676template <class _T2, class _T1>
663inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T2, _T1>&& __p) _NOEXCEPT {677inline _LIBCPP_HIDE_FROM_ABI constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
664 return __get_pair<1>::get(std::move(__p));678 return std::forward<_T2&&>(__p.second);
665}679}
666680
667template <class _T1, class _T2>681template <class _T2, class _T1>
668inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T2, _T1> const&& __p) _NOEXCEPT {682inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
669 return __get_pair<1>::get(std::move(__p));683 return std::forward<_T2 const&&>(__p.second);
670}684}
671685
672#endif // _LIBCPP_STD_VER >= 14686#endif // _LIBCPP_STD_VER >= 14
lib/libcxx/include/__utility/piecewise_construct.h+1-1
...@@ -17,7 +17,7 @@...@@ -17,7 +17,7 @@
1717
18_LIBCPP_BEGIN_NAMESPACE_STD18_LIBCPP_BEGIN_NAMESPACE_STD
1919
20struct _LIBCPP_TEMPLATE_VIS piecewise_construct_t {20struct piecewise_construct_t {
21 explicit piecewise_construct_t() = default;21 explicit piecewise_construct_t() = default;
22};22};
2323
lib/libcxx/include/__utility/scope_guard.h-1
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
10#ifndef _LIBCPP___UTILITY_SCOPE_GUARD_H10#ifndef _LIBCPP___UTILITY_SCOPE_GUARD_H
11#define _LIBCPP___UTILITY_SCOPE_GUARD_H11#define _LIBCPP___UTILITY_SCOPE_GUARD_H
1212
13#include <__assert>
14#include <__config>13#include <__config>
15#include <__utility/move.h>14#include <__utility/move.h>
1615
lib/libcxx/include/__utility/swap.h-1
...@@ -17,7 +17,6 @@...@@ -17,7 +17,6 @@
17#include <__type_traits/is_nothrow_assignable.h>17#include <__type_traits/is_nothrow_assignable.h>
18#include <__type_traits/is_nothrow_constructible.h>18#include <__type_traits/is_nothrow_constructible.h>
19#include <__type_traits/is_swappable.h>19#include <__type_traits/is_swappable.h>
20#include <__utility/declval.h>
21#include <__utility/move.h>20#include <__utility/move.h>
2221
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__utility/to_underlying.h+2-2
...@@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -21,8 +21,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG22#ifndef _LIBCPP_CXX03_LANG
23template <class _Tp>23template <class _Tp>
24_LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underlying(_Tp __val) noexcept {24[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr __underlying_type_t<_Tp> __to_underlying(_Tp __val) noexcept {
25 return static_cast<typename underlying_type<_Tp>::type>(__val);25 return static_cast<__underlying_type_t<_Tp>>(__val);
26}26}
27#endif // !_LIBCPP_CXX03_LANG27#endif // !_LIBCPP_CXX03_LANG
2828
lib/libcxx/include/__variant/monostate.h+7-5
...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323
24#if _LIBCPP_STD_VER >= 1724#if _LIBCPP_STD_VER >= 17
2525
26struct _LIBCPP_TEMPLATE_VIS monostate {};26struct monostate {};
2727
28_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }28_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }
2929
...@@ -48,11 +48,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noe...@@ -48,11 +48,13 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noe
48# endif // _LIBCPP_STD_VER >= 2048# endif // _LIBCPP_STD_VER >= 20
4949
50template <>50template <>
51struct _LIBCPP_TEMPLATE_VIS hash<monostate> {51struct hash<monostate> {
52 using argument_type = monostate;52# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
53 using result_type = size_t;53 using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = monostate;
54 using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t;
55# endif
5456
55 inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {57 inline _LIBCPP_HIDE_FROM_ABI size_t operator()(const monostate&) const noexcept {
56 return 66740831; // return a fundamentally attractive random value.58 return 66740831; // return a fundamentally attractive random value.
57 }59 }
58};60};
lib/libcxx/include/__vector/container_traits.h+3-1
...@@ -31,7 +31,9 @@ struct __container_traits<vector<_Tp, _Allocator> > {...@@ -31,7 +31,9 @@ struct __container_traits<vector<_Tp, _Allocator> > {
31 // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T,31 // there are no effects. Otherwise, if an exception is thrown by the move constructor of a non-Cpp17CopyInsertable T,
32 // the effects are unspecified.32 // the effects are unspecified.
33 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =33 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
34 _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value;34 is_nothrow_move_constructible<_Tp>::value || __is_cpp17_copy_insertable_v<_Allocator>;
35
36 static _LIBCPP_CONSTEXPR const bool __reservable = true;
35};37};
3638
37_LIBCPP_END_NAMESPACE_STD39_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__vector/vector.h+66-60
...@@ -55,9 +55,11 @@...@@ -55,9 +55,11 @@
55#include <__type_traits/is_nothrow_assignable.h>55#include <__type_traits/is_nothrow_assignable.h>
56#include <__type_traits/is_nothrow_constructible.h>56#include <__type_traits/is_nothrow_constructible.h>
57#include <__type_traits/is_pointer.h>57#include <__type_traits/is_pointer.h>
58#include <__type_traits/is_replaceable.h>
58#include <__type_traits/is_same.h>59#include <__type_traits/is_same.h>
59#include <__type_traits/is_trivially_relocatable.h>60#include <__type_traits/is_trivially_relocatable.h>
60#include <__type_traits/type_identity.h>61#include <__type_traits/type_identity.h>
62#include <__utility/declval.h>
61#include <__utility/exception_guard.h>63#include <__utility/exception_guard.h>
62#include <__utility/forward.h>64#include <__utility/forward.h>
63#include <__utility/is_pointer_in_range.h>65#include <__utility/is_pointer_in_range.h>
...@@ -83,36 +85,33 @@ _LIBCPP_PUSH_MACROS...@@ -83,36 +85,33 @@ _LIBCPP_PUSH_MACROS
83_LIBCPP_BEGIN_NAMESPACE_STD85_LIBCPP_BEGIN_NAMESPACE_STD
8486
85template <class _Tp, class _Allocator /* = allocator<_Tp> */>87template <class _Tp, class _Allocator /* = allocator<_Tp> */>
86class _LIBCPP_TEMPLATE_VIS vector {88class vector {
87private:
88 typedef allocator<_Tp> __default_allocator_type;
89
90public:89public:
91 //90 //
92 // Types91 // Types
93 //92 //
94 typedef vector __self;93 using __self _LIBCPP_NODEBUG = vector;
95 typedef _Tp value_type;94 using value_type = _Tp;
96 typedef _Allocator allocator_type;95 using allocator_type = _Allocator;
97 typedef allocator_traits<allocator_type> __alloc_traits;96 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
98 typedef value_type& reference;97 using reference = value_type&;
99 typedef const value_type& const_reference;98 using const_reference = const value_type&;
100 typedef typename __alloc_traits::size_type size_type;99 using size_type = typename __alloc_traits::size_type;
101 typedef typename __alloc_traits::difference_type difference_type;100 using difference_type = typename __alloc_traits::difference_type;
102 typedef typename __alloc_traits::pointer pointer;101 using pointer = typename __alloc_traits::pointer;
103 typedef typename __alloc_traits::const_pointer const_pointer;102 using const_pointer = typename __alloc_traits::const_pointer;
104#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR103#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
105 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's104 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
106 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is105 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
107 // considered contiguous.106 // considered contiguous.
108 typedef __bounded_iter<__wrap_iter<pointer> > iterator;107 using iterator = __bounded_iter<__wrap_iter<pointer> >;
109 typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;108 using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >;
110#else109#else
111 typedef __wrap_iter<pointer> iterator;110 using iterator = __wrap_iter<pointer>;
112 typedef __wrap_iter<const_pointer> const_iterator;111 using const_iterator = __wrap_iter<const_pointer>;
113#endif112#endif
114 typedef std::reverse_iterator<iterator> reverse_iterator;113 using reverse_iterator = std::reverse_iterator<iterator>;
115 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;114 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
116115
117 // A vector containers the following members which may be trivially relocatable:116 // A vector containers the following members which may be trivially relocatable:
118 // - pointer: may be trivially relocatable, so it's checked117 // - pointer: may be trivially relocatable, so it's checked
...@@ -122,6 +121,10 @@ public:...@@ -122,6 +121,10 @@ public:
122 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,121 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
123 vector,122 vector,
124 void>;123 void>;
124 using __replaceable _LIBCPP_NODEBUG =
125 __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value,
126 vector,
127 void>;
125128
126 static_assert(__check_valid_allocator<allocator_type>::value, "");129 static_assert(__check_valid_allocator<allocator_type>::value, "");
127 static_assert(is_same<typename allocator_type::value_type, value_type>::value,130 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
...@@ -463,6 +466,15 @@ public:...@@ -463,6 +466,15 @@ public:
463 emplace_back(_Args&&... __args);466 emplace_back(_Args&&... __args);
464#endif467#endif
465468
469 template <class... _Args>
470 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __emplace_back_assume_capacity(_Args&&... __args) {
471 _LIBCPP_ASSERT_INTERNAL(
472 size() < capacity(), "We assume that we have enough space to insert an element at the end of the vector");
473 _ConstructTransaction __tx(*this, 1);
474 __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
475 ++__tx.__pos_;
476 }
477
466#if _LIBCPP_STD_VER >= 23478#if _LIBCPP_STD_VER >= 23
467 template <_ContainerCompatibleRange<_Tp> _Range>479 template <_ContainerCompatibleRange<_Tp> _Range>
468 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {480 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
...@@ -558,7 +570,7 @@ private:...@@ -558,7 +570,7 @@ private:
558 // Postcondition: size() == 0570 // Postcondition: size() == 0
559 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {571 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
560 if (__n > max_size())572 if (__n > max_size())
561 __throw_length_error();573 this->__throw_length_error();
562 auto __allocation = std::__allocate_at_least(this->__alloc_, __n);574 auto __allocation = std::__allocate_at_least(this->__alloc_, __n);
563 __begin_ = __allocation.ptr;575 __begin_ = __allocation.ptr;
564 __end_ = __allocation.ptr;576 __end_ = __allocation.ptr;
...@@ -605,6 +617,30 @@ private:...@@ -605,6 +617,30 @@ private:
605 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void617 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
606 __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n);618 __assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n);
607619
620 template <class _Iterator,
621 __enable_if_t<!is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0>
622 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
623 __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) {
624 for (pointer __end_position = __position + __n; __position != __end_position; ++__position, (void)++__first) {
625 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, *__first);
626 *__position = std::move(__tmp.get());
627 }
628 }
629
630 template <class _Iterator,
631 __enable_if_t<is_same<decltype(*std::declval<_Iterator&>())&&, value_type&&>::value, int> = 0>
632 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
633 __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) {
634#if _LIBCPP_STD_VER >= 23
635 if constexpr (!forward_iterator<_Iterator>) { // Handles input-only sized ranges for insert_range
636 ranges::copy_n(std::move(__first), __n, __position);
637 } else
638#endif
639 {
640 std::copy_n(__first, __n, __position);
641 }
642 }
643
608 template <class _InputIterator, class _Sentinel>644 template <class _InputIterator, class _Sentinel>
609 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator645 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
610 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);646 __insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last);
...@@ -685,47 +721,32 @@ private:...@@ -685,47 +721,32 @@ private:
685 }721 }
686722
687 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {723 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
688 (void)__current_size;
689#if _LIBCPP_HAS_ASAN
690 __annotate_contiguous_container(data() + capacity(), data() + __current_size);724 __annotate_contiguous_container(data() + capacity(), data() + __current_size);
691#endif
692 }725 }
693726
694 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {727 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
695#if _LIBCPP_HAS_ASAN
696 __annotate_contiguous_container(data() + size(), data() + capacity());728 __annotate_contiguous_container(data() + size(), data() + capacity());
697#endif
698 }729 }
699730
700 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {731 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT {
701 (void)__n;
702#if _LIBCPP_HAS_ASAN
703 __annotate_contiguous_container(data() + size(), data() + size() + __n);732 __annotate_contiguous_container(data() + size(), data() + size() + __n);
704#endif
705 }733 }
706734
707 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {735 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
708 (void)__old_size;
709#if _LIBCPP_HAS_ASAN
710 __annotate_contiguous_container(data() + __old_size, data() + size());736 __annotate_contiguous_container(data() + __old_size, data() + size());
711#endif
712 }737 }
713738
714 struct _ConstructTransaction {739 struct _ConstructTransaction {
715 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)740 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
716 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {741 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
717#if _LIBCPP_HAS_ASAN
718 __v_.__annotate_increase(__n);742 __v_.__annotate_increase(__n);
719#endif
720 }743 }
721744
722 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {745 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
723 __v_.__end_ = __pos_;746 __v_.__end_ = __pos_;
724#if _LIBCPP_HAS_ASAN
725 if (__pos_ != __new_end_) {747 if (__pos_ != __new_end_) {
726 __v_.__annotate_shrink(__new_end_ - __v_.__begin_);748 __v_.__annotate_shrink(__new_end_ - __v_.__begin_);
727 }749 }
728#endif
729 }750 }
730751
731 vector& __v_;752 vector& __v_;
...@@ -736,13 +757,6 @@ private:...@@ -736,13 +757,6 @@ private:
736 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;757 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
737 };758 };
738759
739 template <class... _Args>
740 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __construct_one_at_end(_Args&&... __args) {
741 _ConstructTransaction __tx(*this, 1);
742 __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
743 ++__tx.__pos_;
744 }
745
746 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {760 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
747 pointer __soon_to_be_end = this->__end_;761 pointer __soon_to_be_end = this->__end_;
748 while (__new_last != __soon_to_be_end)762 while (__new_last != __soon_to_be_end)
...@@ -1130,7 +1144,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline...@@ -1130,7 +1144,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline
1130 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {1144 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1131 pointer __end = this->__end_;1145 pointer __end = this->__end_;
1132 if (__end < this->__cap_) {1146 if (__end < this->__cap_) {
1133 __construct_one_at_end(std::forward<_Args>(__args)...);1147 __emplace_back_assume_capacity(std::forward<_Args>(__args)...);
1134 ++__end;1148 ++__end;
1135 } else {1149 } else {
1136 __end = __emplace_back_slow_path(std::forward<_Args>(__args)...);1150 __end = __emplace_back_slow_path(std::forward<_Args>(__args)...);
...@@ -1184,7 +1198,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)...@@ -1184,7 +1198,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
1184 pointer __p = this->__begin_ + (__position - begin());1198 pointer __p = this->__begin_ + (__position - begin());
1185 if (this->__end_ < this->__cap_) {1199 if (this->__end_ < this->__cap_) {
1186 if (__p == this->__end_) {1200 if (__p == this->__end_) {
1187 __construct_one_at_end(__x);1201 __emplace_back_assume_capacity(__x);
1188 } else {1202 } else {
1189 __move_range(__p, this->__end_, __p + 1);1203 __move_range(__p, this->__end_, __p + 1);
1190 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);1204 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
...@@ -1206,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {...@@ -1206,7 +1220,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
1206 pointer __p = this->__begin_ + (__position - begin());1220 pointer __p = this->__begin_ + (__position - begin());
1207 if (this->__end_ < this->__cap_) {1221 if (this->__end_ < this->__cap_) {
1208 if (__p == this->__end_) {1222 if (__p == this->__end_) {
1209 __construct_one_at_end(std::move(__x));1223 __emplace_back_assume_capacity(std::move(__x));
1210 } else {1224 } else {
1211 __move_range(__p, this->__end_, __p + 1);1225 __move_range(__p, this->__end_, __p + 1);
1212 *__p = std::move(__x);1226 *__p = std::move(__x);
...@@ -1226,7 +1240,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {...@@ -1226,7 +1240,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
1226 pointer __p = this->__begin_ + (__position - begin());1240 pointer __p = this->__begin_ + (__position - begin());
1227 if (this->__end_ < this->__cap_) {1241 if (this->__end_ < this->__cap_) {
1228 if (__p == this->__end_) {1242 if (__p == this->__end_) {
1229 __construct_one_at_end(std::forward<_Args>(__args)...);1243 __emplace_back_assume_capacity(std::forward<_Args>(__args)...);
1230 } else {1244 } else {
1231 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);1245 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);
1232 __move_range(__p, this->__end_, __p + 1);1246 __move_range(__p, this->__end_, __p + 1);
...@@ -1245,8 +1259,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator...@@ -1245,8 +1259,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
1245vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {1259vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {
1246 pointer __p = this->__begin_ + (__position - begin());1260 pointer __p = this->__begin_ + (__position - begin());
1247 if (__n > 0) {1261 if (__n > 0) {
1248 // We can't compare unrelated pointers inside constant expressions1262 if (__n <= static_cast<size_type>(this->__cap_ - this->__end_)) {
1249 if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__cap_ - this->__end_)) {
1250 size_type __old_n = __n;1263 size_type __old_n = __n;
1251 pointer __old_last = this->__end_;1264 pointer __old_last = this->__end_;
1252 if (__n > static_cast<size_type>(this->__end_ - __p)) {1265 if (__n > static_cast<size_type>(this->__end_ - __p)) {
...@@ -1257,7 +1270,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_...@@ -1257,7 +1270,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
1257 if (__n > 0) {1270 if (__n > 0) {
1258 __move_range(__p, __old_last, __p + __old_n);1271 __move_range(__p, __old_last, __p + __old_n);
1259 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);1272 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1260 if (__p <= __xr && __xr < this->__end_)1273 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
1261 __xr += __old_n;1274 __xr += __old_n;
1262 std::fill_n(__p, __n, *__xr);1275 std::fill_n(__p, __n, *__xr);
1263 }1276 }
...@@ -1278,7 +1291,7 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu...@@ -1278,7 +1291,7 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu
1278 pointer __p = this->__begin_ + __off;1291 pointer __p = this->__begin_ + __off;
1279 pointer __old_last = this->__end_;1292 pointer __old_last = this->__end_;
1280 for (; this->__end_ != this->__cap_ && __first != __last; ++__first)1293 for (; this->__end_ != this->__cap_ && __first != __last; ++__first)
1281 __construct_one_at_end(*__first);1294 __emplace_back_assume_capacity(*__first);
12821295
1283 if (__first == __last)1296 if (__first == __last)
1284 (void)std::rotate(__p, __old_last, this->__end_);1297 (void)std::rotate(__p, __old_last, this->__end_);
...@@ -1325,19 +1338,12 @@ vector<_Tp, _Allocator>::__insert_with_size(...@@ -1325,19 +1338,12 @@ vector<_Tp, _Allocator>::__insert_with_size(
1325 __construct_at_end(__m, __last, __n - __dx);1338 __construct_at_end(__m, __last, __n - __dx);
1326 if (__dx > 0) {1339 if (__dx > 0) {
1327 __move_range(__p, __old_last, __p + __n);1340 __move_range(__p, __old_last, __p + __n);
1328 std::copy(__first, __m, __p);1341 __insert_assign_n_unchecked(__first, __dx, __p);
1329 }1342 }
1330 }1343 }
1331 } else {1344 } else {
1332 __move_range(__p, __old_last, __p + __n);1345 __move_range(__p, __old_last, __p + __n);
1333#if _LIBCPP_STD_VER >= 231346 __insert_assign_n_unchecked(std::move(__first), __n, __p);
1334 if constexpr (!forward_iterator<_Iterator>) {
1335 ranges::copy_n(std::move(__first), __n, __p);
1336 } else
1337#endif
1338 {
1339 std::copy_n(__first, __n, __p);
1340 }
1341 }1347 }
1342 } else {1348 } else {
1343 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);1349 __split_buffer<value_type, allocator_type&> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
lib/libcxx/include/__vector/vector_bool.h+42-51
...@@ -10,14 +10,16 @@...@@ -10,14 +10,16 @@
10#define _LIBCPP___VECTOR_VECTOR_BOOL_H10#define _LIBCPP___VECTOR_VECTOR_BOOL_H
1111
12#include <__algorithm/copy.h>12#include <__algorithm/copy.h>
13#include <__algorithm/copy_backward.h>
13#include <__algorithm/fill_n.h>14#include <__algorithm/fill_n.h>
14#include <__algorithm/iterator_operations.h>15#include <__algorithm/iterator_operations.h>
15#include <__algorithm/max.h>16#include <__algorithm/max.h>
17#include <__algorithm/rotate.h>
16#include <__assert>18#include <__assert>
17#include <__bit_reference>19#include <__bit_reference>
18#include <__config>20#include <__config>
19#include <__functional/unary_function.h>21#include <__functional/unary_function.h>
20#include <__fwd/bit_reference.h>22#include <__fwd/bit_reference.h> // TODO: This is a workaround for https://github.com/llvm/llvm-project/issues/131814
21#include <__fwd/functional.h>23#include <__fwd/functional.h>
22#include <__fwd/vector.h>24#include <__fwd/vector.h>
23#include <__iterator/distance.h>25#include <__iterator/distance.h>
...@@ -73,38 +75,38 @@ struct __has_storage_type<vector<bool, _Allocator> > {...@@ -73,38 +75,38 @@ struct __has_storage_type<vector<bool, _Allocator> > {
73};75};
7476
75template <class _Allocator>77template <class _Allocator>
76class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> {78class vector<bool, _Allocator> {
77public:79public:
78 typedef vector __self;80 using __self _LIBCPP_NODEBUG = vector;
79 typedef bool value_type;81 using value_type = bool;
80 typedef _Allocator allocator_type;82 using allocator_type = _Allocator;
81 typedef allocator_traits<allocator_type> __alloc_traits;83 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
82 typedef typename __alloc_traits::size_type size_type;84 using size_type = typename __alloc_traits::size_type;
83 typedef typename __alloc_traits::difference_type difference_type;85 using difference_type = typename __alloc_traits::difference_type;
84 typedef size_type __storage_type;86 using __storage_type _LIBCPP_NODEBUG = size_type;
85 typedef __bit_iterator<vector, false> pointer;87 using pointer = __bit_iterator<vector, false>;
86 typedef __bit_iterator<vector, true> const_pointer;88 using const_pointer = __bit_iterator<vector, true>;
87 typedef pointer iterator;89 using iterator = pointer;
88 typedef const_pointer const_iterator;90 using const_iterator = const_pointer;
89 typedef std::reverse_iterator<iterator> reverse_iterator;91 using reverse_iterator = std::reverse_iterator<iterator>;
90 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;92 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
9193
92private:94private:
93 typedef __rebind_alloc<__alloc_traits, __storage_type> __storage_allocator;95 using __storage_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __storage_type>;
94 typedef allocator_traits<__storage_allocator> __storage_traits;96 using __storage_traits _LIBCPP_NODEBUG = allocator_traits<__storage_allocator>;
95 typedef typename __storage_traits::pointer __storage_pointer;97 using __storage_pointer _LIBCPP_NODEBUG = typename __storage_traits::pointer;
96 typedef typename __storage_traits::const_pointer __const_storage_pointer;98 using __const_storage_pointer _LIBCPP_NODEBUG = typename __storage_traits::const_pointer;
9799
98 __storage_pointer __begin_;100 __storage_pointer __begin_;
99 size_type __size_;101 size_type __size_;
100 _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_);102 _LIBCPP_COMPRESSED_PAIR(size_type, __cap_, __storage_allocator, __alloc_);
101103
102public:104public:
103 typedef __bit_reference<vector> reference;105 using reference = __bit_reference<vector>;
104#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL106#ifdef _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
105 using const_reference = bool;107 using const_reference = bool;
106#else108#else
107 typedef __bit_const_reference<vector> const_reference;109 using const_reference = __bit_const_reference<vector>;
108#endif110#endif
109111
110private:112private:
...@@ -445,7 +447,7 @@ private:...@@ -445,7 +447,7 @@ private:
445 // Postcondition: size() == 0447 // Postcondition: size() == 0
446 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {448 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __vallocate(size_type __n) {
447 if (__n > max_size())449 if (__n > max_size())
448 __throw_length_error();450 this->__throw_length_error();
449 auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n));451 auto __allocation = std::__allocate_at_least(__alloc_, __external_cap_to_internal(__n));
450 __begin_ = __allocation.ptr;452 __begin_ = __allocation.ptr;
451 __size_ = 0;453 __size_ = 0;
...@@ -510,14 +512,14 @@ private:...@@ -510,14 +512,14 @@ private:
510512
511 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}513 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
512514
513 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t __hash_code() const _NOEXCEPT;515 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
514516
515 friend class __bit_reference<vector>;517 friend class __bit_reference<vector>;
516 friend class __bit_const_reference<vector>;518 friend class __bit_const_reference<vector>;
517 friend class __bit_iterator<vector, false>;519 friend class __bit_iterator<vector, false>;
518 friend class __bit_iterator<vector, true>;520 friend class __bit_iterator<vector, true>;
519 friend struct __bit_array<vector>;521 friend struct __bit_array<vector>;
520 friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;522 friend struct hash<vector>;
521};523};
522524
523template <class _Allocator>525template <class _Allocator>
...@@ -533,10 +535,8 @@ template <class _Allocator>...@@ -533,10 +535,8 @@ template <class _Allocator>
533_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type535_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<bool, _Allocator>::size_type
534vector<bool, _Allocator>::max_size() const _NOEXCEPT {536vector<bool, _Allocator>::max_size() const _NOEXCEPT {
535 size_type __amax = __storage_traits::max_size(__alloc_);537 size_type __amax = __storage_traits::max_size(__alloc_);
536 size_type __nmax = numeric_limits<size_type>::max() / 2; // end() >= begin(), always538 size_type __nmax = numeric_limits<difference_type>::max();
537 if (__nmax / __bits_per_word <= __amax)539 return __nmax / __bits_per_word <= __amax ? __nmax : __internal_cap_to_external(__amax);
538 return __nmax;
539 return __internal_cap_to_external(__amax);
540}540}
541541
542// Precondition: __new_size > capacity()542// Precondition: __new_size > capacity()
...@@ -549,40 +549,33 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const {...@@ -549,40 +549,33 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const {
549 const size_type __cap = capacity();549 const size_type __cap = capacity();
550 if (__cap >= __ms / 2)550 if (__cap >= __ms / 2)
551 return __ms;551 return __ms;
552 return std::max(2 * __cap, __align_it(__new_size));552 return std::max<size_type>(2 * __cap, __align_it(__new_size));
553}553}
554554
555// Default constructs __n objects starting at __end_555// Default constructs __n objects starting at __end_
556// Precondition: __n > 0
557// Precondition: size() + __n <= capacity()556// Precondition: size() + __n <= capacity()
558// Postcondition: size() == size() + __n557// Postcondition: size() == size() + __n
559template <class _Allocator>558template <class _Allocator>
560inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void559inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
561vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {560vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) {
562 size_type __old_size = this->__size_;561 _LIBCPP_ASSERT_INTERNAL(
562 capacity() >= size() + __n, "vector<bool>::__construct_at_end called with insufficient capacity");
563 std::fill_n(end(), __n, __x);
563 this->__size_ += __n;564 this->__size_ += __n;
564 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {565 if (end().__ctz_ != 0) // Ensure uninitialized leading bits in the last word are set to zero
565 if (this->__size_ <= __bits_per_word)566 std::fill_n(end(), __bits_per_word - end().__ctz_, 0);
566 this->__begin_[0] = __storage_type(0);
567 else
568 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
569 }
570 std::fill_n(__make_iter(__old_size), __n, __x);
571}567}
572568
573template <class _Allocator>569template <class _Allocator>
574template <class _InputIterator, class _Sentinel>570template <class _InputIterator, class _Sentinel>
575_LIBCPP_CONSTEXPR_SINCE_CXX20 void571_LIBCPP_CONSTEXPR_SINCE_CXX20 void
576vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {572vector<bool, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
577 size_type __old_size = this->__size_;573 _LIBCPP_ASSERT_INTERNAL(
574 capacity() >= size() + __n, "vector<bool>::__construct_at_end called with insufficient capacity");
575 std::__copy(std::move(__first), std::move(__last), end());
578 this->__size_ += __n;576 this->__size_ += __n;
579 if (__old_size == 0 || ((__old_size - 1) / __bits_per_word) != ((this->__size_ - 1) / __bits_per_word)) {577 if (end().__ctz_ != 0) // Ensure uninitialized leading bits in the last word are set to zero
580 if (this->__size_ <= __bits_per_word)578 std::fill_n(end(), __bits_per_word - end().__ctz_, 0);
581 this->__begin_[0] = __storage_type(0);
582 else
583 this->__begin_[(this->__size_ - 1) / __bits_per_word] = __storage_type(0);
584 }
585 std::__copy(std::move(__first), std::move(__last), __make_iter(__old_size));
586}579}
587580
588template <class _Allocator>581template <class _Allocator>
...@@ -1100,7 +1093,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() cons...@@ -1100,7 +1093,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<bool, _Allocator>::__invariants() cons
1100}1093}
11011094
1102template <class _Allocator>1095template <class _Allocator>
1103_LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT {1096size_t vector<bool, _Allocator>::__hash_code() const _NOEXCEPT {
1104 size_t __h = 0;1097 size_t __h = 0;
1105 // do middle whole words1098 // do middle whole words
1106 size_type __n = __size_;1099 size_type __n = __size_;
...@@ -1116,10 +1109,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() con...@@ -1116,10 +1109,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t vector<bool, _Allocator>::__hash_code() con
1116}1109}
11171110
1118template <class _Allocator>1111template <class _Allocator>
1119struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >1112struct hash<vector<bool, _Allocator> > : public __unary_function<vector<bool, _Allocator>, size_t> {
1120 : public __unary_function<vector<bool, _Allocator>, size_t> {1113 _LIBCPP_HIDE_FROM_ABI size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT {
1121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_t
1122 operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT {
1123 return __vec.__hash_code();1114 return __vec.__hash_code();
1124 }1115 }
1125};1116};
lib/libcxx/include/__vector/vector_bool_formatter.h+1-1
...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
26template <class _Tp, class _CharT>26template <class _Tp, class _CharT>
27// Since is-vector-bool-reference is only used once it's inlined here.27// Since is-vector-bool-reference is only used once it's inlined here.
28 requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>28 requires same_as<typename _Tp::__container, vector<bool, typename _Tp::__container::allocator_type>>
29struct _LIBCPP_TEMPLATE_VIS formatter<_Tp, _CharT> {29struct formatter<_Tp, _CharT> {
30private:30private:
31 formatter<bool, _CharT> __underlying_;31 formatter<bool, _CharT> __underlying_;
3232
lib/libcxx/include/__verbose_abort+1-7
...@@ -18,16 +18,10 @@...@@ -18,16 +18,10 @@
1818
19_LIBCPP_BEGIN_NAMESPACE_STD19_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if defined(_LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT)
22# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT
23#else
24# define _LIBCPP_VERBOSE_ABORT_NOEXCEPT _NOEXCEPT
25#endif
26
27// This function should never be called directly from the code -- it should only be called through21// This function should never be called directly from the code -- it should only be called through
28// the _LIBCPP_VERBOSE_ABORT macro.22// the _LIBCPP_VERBOSE_ABORT macro.
29[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(23[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
30 __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT;24 __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
3125
32// _LIBCPP_VERBOSE_ABORT(format, args...)26// _LIBCPP_VERBOSE_ABORT(format, args...)
33//27//
lib/libcxx/include/__verbose_trap created+36
...@@ -0,0 +1,36 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___VERBOSE_TRAP
11#define _LIBCPP___VERBOSE_TRAP
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if __has_builtin(__builtin_verbose_trap)
22// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
23// version before upstream Clang actually got the builtin.
24// TODO: Remove once AppleClang supports the two-arguments version of the builtin.
25# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 1700
26# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap(message)
27# else
28# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message)
29# endif
30#else
31# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___VERBOSE_TRAP
lib/libcxx/include/algorithm+153-144
...@@ -45,6 +45,9 @@ namespace ranges {...@@ -45,6 +45,9 @@ namespace ranges {
45 template <class I, class T>45 template <class I, class T>
46 struct in_value_result; // since C++2346 struct in_value_result; // since C++23
4747
48 template <class O, class T>
49 struct out_value_result; // since C++23
50
48 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,51 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
49 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++2052 indirect_strict_weak_order<projected<I, Proj>> Comp = ranges::less> // since C++20
50 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});53 constexpr I min_element(I first, S last, Comp comp = {}, Proj proj = {});
...@@ -422,11 +425,12 @@ namespace ranges {...@@ -422,11 +425,12 @@ namespace ranges {
422 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,425 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
423 class Proj = identity>426 class Proj = identity>
424 requires sortable<I, Comp, Proj>427 requires sortable<I, Comp, Proj>
425 I ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20428 constexpr I // constexpr since C++26
429 ranges::stable_sort(I first, S last, Comp comp = {}, Proj proj = {}); // since C++20
426430
427 template<random_access_range R, class Comp = ranges::less, class Proj = identity>431 template<random_access_range R, class Comp = ranges::less, class Proj = identity>
428 requires sortable<iterator_t<R>, Comp, Proj>432 requires sortable<iterator_t<R>, Comp, Proj>
429 borrowed_iterator_t<R>433 constexpr borrowed_iterator_t<R> // constexpr since C++26
430 ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20434 ranges::stable_sort(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
431435
432 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,436 template<random_access_iterator I, sentinel_for<I> S, class Comp = ranges::less,
...@@ -627,12 +631,14 @@ namespace ranges {...@@ -627,12 +631,14 @@ namespace ranges {
627 template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,631 template<bidirectional_iterator I, sentinel_for<I> S, class Proj = identity,
628 indirect_unary_predicate<projected<I, Proj>> Pred>632 indirect_unary_predicate<projected<I, Proj>> Pred>
629 requires permutable<I>633 requires permutable<I>
630 subrange<I> stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20634 constexpr subrange<I> // constexpr since C++26
635 stable_partition(I first, S last, Pred pred, Proj proj = {}); // since C++20
631636
632 template<bidirectional_range R, class Proj = identity,637 template<bidirectional_range R, class Proj = identity,
633 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>638 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
634 requires permutable<iterator_t<R>>639 requires permutable<iterator_t<R>>
635 borrowed_subrange_t<R> stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20640 constexpr borrowed_subrange_t<R> // constexpr since C++26
641 stable_partition(R&& r, Pred pred, Proj proj = {}); // since C++20
636642
637 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,643 template<input_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
638 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>644 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
...@@ -1028,13 +1034,14 @@ namespace ranges {...@@ -1028,13 +1034,14 @@ namespace ranges {
1028 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,1034 template<bidirectional_iterator I, sentinel_for<I> S, class Comp = ranges::less,
1029 class Proj = identity>1035 class Proj = identity>
1030 requires sortable<I, Comp, Proj>1036 requires sortable<I, Comp, Proj>
1031 I inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++201037 constexpr I // constexpr since C++26
1038 inplace_merge(I first, I middle, S last, Comp comp = {}, Proj proj = {}); // since C++20
10321039
1033 template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>1040 template<bidirectional_range R, class Comp = ranges::less, class Proj = identity>
1034 requires sortable<iterator_t<R>, Comp, Proj>1041 requires sortable<iterator_t<R>, Comp, Proj>
1035 borrowed_iterator_t<R>1042 constexpr borrowed_iterator_t<R> // constexpr since C++26
1036 inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},1043 inplace_merge(R&& r, iterator_t<R> middle, Comp comp = {},
1037 Proj proj = {}); // since C++201044 Proj proj = {}); // since C++20
10381045
1039 template<permutable I, sentinel_for<I> S, class Proj = identity,1046 template<permutable I, sentinel_for<I> S, class Proj = identity,
1040 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>1047 indirect_equivalence_relation<projected<I, Proj>> C = ranges::equal_to>
...@@ -1165,84 +1172,84 @@ namespace ranges {...@@ -1165,84 +1172,84 @@ namespace ranges {
1165}1172}
11661173
1167template <class InputIterator, class Predicate>1174template <class InputIterator, class Predicate>
1168 constexpr bool // constexpr in C++201175 constexpr bool // constexpr since C++20
1169 all_of(InputIterator first, InputIterator last, Predicate pred);1176 all_of(InputIterator first, InputIterator last, Predicate pred);
11701177
1171template <class InputIterator, class Predicate>1178template <class InputIterator, class Predicate>
1172 constexpr bool // constexpr in C++201179 constexpr bool // constexpr since C++20
1173 any_of(InputIterator first, InputIterator last, Predicate pred);1180 any_of(InputIterator first, InputIterator last, Predicate pred);
11741181
1175template <class InputIterator, class Predicate>1182template <class InputIterator, class Predicate>
1176 constexpr bool // constexpr in C++201183 constexpr bool // constexpr since C++20
1177 none_of(InputIterator first, InputIterator last, Predicate pred);1184 none_of(InputIterator first, InputIterator last, Predicate pred);
11781185
1179template <class InputIterator, class Function>1186template <class InputIterator, class Function>
1180 constexpr Function // constexpr in C++201187 constexpr Function // constexpr since C++20
1181 for_each(InputIterator first, InputIterator last, Function f);1188 for_each(InputIterator first, InputIterator last, Function f);
11821189
1183template<class InputIterator, class Size, class Function>1190template<class InputIterator, class Size, class Function>
1184 constexpr InputIterator // constexpr in C++201191 constexpr InputIterator // constexpr since C++20
1185 for_each_n(InputIterator first, Size n, Function f); // C++171192 for_each_n(InputIterator first, Size n, Function f); // C++17
11861193
1187template <class InputIterator, class T>1194template <class InputIterator, class T>
1188 constexpr InputIterator // constexpr in C++201195 constexpr InputIterator // constexpr since C++20
1189 find(InputIterator first, InputIterator last, const T& value);1196 find(InputIterator first, InputIterator last, const T& value);
11901197
1191template <class InputIterator, class Predicate>1198template <class InputIterator, class Predicate>
1192 constexpr InputIterator // constexpr in C++201199 constexpr InputIterator // constexpr since C++20
1193 find_if(InputIterator first, InputIterator last, Predicate pred);1200 find_if(InputIterator first, InputIterator last, Predicate pred);
11941201
1195template<class InputIterator, class Predicate>1202template<class InputIterator, class Predicate>
1196 constexpr InputIterator // constexpr in C++201203 constexpr InputIterator // constexpr since C++20
1197 find_if_not(InputIterator first, InputIterator last, Predicate pred);1204 find_if_not(InputIterator first, InputIterator last, Predicate pred);
11981205
1199template <class ForwardIterator1, class ForwardIterator2>1206template <class ForwardIterator1, class ForwardIterator2>
1200 constexpr ForwardIterator1 // constexpr in C++201207 constexpr ForwardIterator1 // constexpr since C++20
1201 find_end(ForwardIterator1 first1, ForwardIterator1 last1,1208 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
1202 ForwardIterator2 first2, ForwardIterator2 last2);1209 ForwardIterator2 first2, ForwardIterator2 last2);
12031210
1204template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1211template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1205 constexpr ForwardIterator1 // constexpr in C++201212 constexpr ForwardIterator1 // constexpr since C++20
1206 find_end(ForwardIterator1 first1, ForwardIterator1 last1,1213 find_end(ForwardIterator1 first1, ForwardIterator1 last1,
1207 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1214 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
12081215
1209template <class ForwardIterator1, class ForwardIterator2>1216template <class ForwardIterator1, class ForwardIterator2>
1210 constexpr ForwardIterator1 // constexpr in C++201217 constexpr ForwardIterator1 // constexpr since C++20
1211 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,1218 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
1212 ForwardIterator2 first2, ForwardIterator2 last2);1219 ForwardIterator2 first2, ForwardIterator2 last2);
12131220
1214template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1221template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1215 constexpr ForwardIterator1 // constexpr in C++201222 constexpr ForwardIterator1 // constexpr since C++20
1216 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,1223 find_first_of(ForwardIterator1 first1, ForwardIterator1 last1,
1217 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1224 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
12181225
1219template <class ForwardIterator>1226template <class ForwardIterator>
1220 constexpr ForwardIterator // constexpr in C++201227 constexpr ForwardIterator // constexpr since C++20
1221 adjacent_find(ForwardIterator first, ForwardIterator last);1228 adjacent_find(ForwardIterator first, ForwardIterator last);
12221229
1223template <class ForwardIterator, class BinaryPredicate>1230template <class ForwardIterator, class BinaryPredicate>
1224 constexpr ForwardIterator // constexpr in C++201231 constexpr ForwardIterator // constexpr since C++20
1225 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);1232 adjacent_find(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
12261233
1227template <class InputIterator, class T>1234template <class InputIterator, class T>
1228 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++201235 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr since C++20
1229 count(InputIterator first, InputIterator last, const T& value);1236 count(InputIterator first, InputIterator last, const T& value);
12301237
1231template <class InputIterator, class Predicate>1238template <class InputIterator, class Predicate>
1232 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr in C++201239 constexpr typename iterator_traits<InputIterator>::difference_type // constexpr since C++20
1233 count_if(InputIterator first, InputIterator last, Predicate pred);1240 count_if(InputIterator first, InputIterator last, Predicate pred);
12341241
1235template <class InputIterator1, class InputIterator2>1242template <class InputIterator1, class InputIterator2>
1236 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++201243 constexpr pair<InputIterator1, InputIterator2> // constexpr since C++20
1237 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);1244 mismatch(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
12381245
1239template <class InputIterator1, class InputIterator2>1246template <class InputIterator1, class InputIterator2>
1240 constexpr pair<InputIterator1, InputIterator2>1247 constexpr pair<InputIterator1, InputIterator2>
1241 mismatch(InputIterator1 first1, InputIterator1 last1,1248 mismatch(InputIterator1 first1, InputIterator1 last1,
1242 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++201249 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr since C++20
12431250
1244template <class InputIterator1, class InputIterator2, class BinaryPredicate>1251template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1245 constexpr pair<InputIterator1, InputIterator2> // constexpr in C++201252 constexpr pair<InputIterator1, InputIterator2> // constexpr since C++20
1246 mismatch(InputIterator1 first1, InputIterator1 last1,1253 mismatch(InputIterator1 first1, InputIterator1 last1,
1247 InputIterator2 first2, BinaryPredicate pred);1254 InputIterator2 first2, BinaryPredicate pred);
12481255
...@@ -1250,19 +1257,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>...@@ -1250,19 +1257,19 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1250 constexpr pair<InputIterator1, InputIterator2>1257 constexpr pair<InputIterator1, InputIterator2>
1251 mismatch(InputIterator1 first1, InputIterator1 last1,1258 mismatch(InputIterator1 first1, InputIterator1 last1,
1252 InputIterator2 first2, InputIterator2 last2,1259 InputIterator2 first2, InputIterator2 last2,
1253 BinaryPredicate pred); // since C++14, constexpr in C++201260 BinaryPredicate pred); // since C++14, constexpr since C++20
12541261
1255template <class InputIterator1, class InputIterator2>1262template <class InputIterator1, class InputIterator2>
1256 constexpr bool // constexpr in C++201263 constexpr bool // constexpr since C++20
1257 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);1264 equal(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2);
12581265
1259template <class InputIterator1, class InputIterator2>1266template <class InputIterator1, class InputIterator2>
1260 constexpr bool1267 constexpr bool
1261 equal(InputIterator1 first1, InputIterator1 last1,1268 equal(InputIterator1 first1, InputIterator1 last1,
1262 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr in C++201269 InputIterator2 first2, InputIterator2 last2); // since C++14, constexpr since C++20
12631270
1264template <class InputIterator1, class InputIterator2, class BinaryPredicate>1271template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1265 constexpr bool // constexpr in C++201272 constexpr bool // constexpr since C++20
1266 equal(InputIterator1 first1, InputIterator1 last1,1273 equal(InputIterator1 first1, InputIterator1 last1,
1267 InputIterator2 first2, BinaryPredicate pred);1274 InputIterator2 first2, BinaryPredicate pred);
12681275
...@@ -1270,20 +1277,20 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>...@@ -1270,20 +1277,20 @@ template <class InputIterator1, class InputIterator2, class BinaryPredicate>
1270 constexpr bool1277 constexpr bool
1271 equal(InputIterator1 first1, InputIterator1 last1,1278 equal(InputIterator1 first1, InputIterator1 last1,
1272 InputIterator2 first2, InputIterator2 last2,1279 InputIterator2 first2, InputIterator2 last2,
1273 BinaryPredicate pred); // since C++14, constexpr in C++201280 BinaryPredicate pred); // since C++14, constexpr since C++20
12741281
1275template<class ForwardIterator1, class ForwardIterator2>1282template<class ForwardIterator1, class ForwardIterator2>
1276 constexpr bool // constexpr in C++201283 constexpr bool // constexpr since C++20
1277 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1284 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1278 ForwardIterator2 first2);1285 ForwardIterator2 first2);
12791286
1280template<class ForwardIterator1, class ForwardIterator2>1287template<class ForwardIterator1, class ForwardIterator2>
1281 constexpr bool1288 constexpr bool
1282 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1289 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1283 ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr in C++201290 ForwardIterator2 first2, ForwardIterator2 last2); // since C++14, constexpr since C++20
12841291
1285template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1292template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1286 constexpr bool // constexpr in C++201293 constexpr bool // constexpr since C++20
1287 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1294 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1288 ForwardIterator2 first2, BinaryPredicate pred);1295 ForwardIterator2 first2, BinaryPredicate pred);
12891296
...@@ -1291,42 +1298,42 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>...@@ -1291,42 +1298,42 @@ template<class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1291 constexpr bool1298 constexpr bool
1292 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,1299 is_permutation(ForwardIterator1 first1, ForwardIterator1 last1,
1293 ForwardIterator2 first2, ForwardIterator2 last2,1300 ForwardIterator2 first2, ForwardIterator2 last2,
1294 BinaryPredicate pred); // since C++14, constexpr in C++201301 BinaryPredicate pred); // since C++14, constexpr since C++20
12951302
1296template <class ForwardIterator1, class ForwardIterator2>1303template <class ForwardIterator1, class ForwardIterator2>
1297 constexpr ForwardIterator1 // constexpr in C++201304 constexpr ForwardIterator1 // constexpr since C++20
1298 search(ForwardIterator1 first1, ForwardIterator1 last1,1305 search(ForwardIterator1 first1, ForwardIterator1 last1,
1299 ForwardIterator2 first2, ForwardIterator2 last2);1306 ForwardIterator2 first2, ForwardIterator2 last2);
13001307
1301template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>1308template <class ForwardIterator1, class ForwardIterator2, class BinaryPredicate>
1302 constexpr ForwardIterator1 // constexpr in C++201309 constexpr ForwardIterator1 // constexpr since C++20
1303 search(ForwardIterator1 first1, ForwardIterator1 last1,1310 search(ForwardIterator1 first1, ForwardIterator1 last1,
1304 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);1311 ForwardIterator2 first2, ForwardIterator2 last2, BinaryPredicate pred);
13051312
1306template <class ForwardIterator, class Size, class T>1313template <class ForwardIterator, class Size, class T>
1307 constexpr ForwardIterator // constexpr in C++201314 constexpr ForwardIterator // constexpr since C++20
1308 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);1315 search_n(ForwardIterator first, ForwardIterator last, Size count, const T& value);
13091316
1310template <class ForwardIterator, class Size, class T, class BinaryPredicate>1317template <class ForwardIterator, class Size, class T, class BinaryPredicate>
1311 constexpr ForwardIterator // constexpr in C++201318 constexpr ForwardIterator // constexpr since C++20
1312 search_n(ForwardIterator first, ForwardIterator last,1319 search_n(ForwardIterator first, ForwardIterator last,
1313 Size count, const T& value, BinaryPredicate pred);1320 Size count, const T& value, BinaryPredicate pred);
13141321
1315template <class InputIterator, class OutputIterator>1322template <class InputIterator, class OutputIterator>
1316 constexpr OutputIterator // constexpr in C++201323 constexpr OutputIterator // constexpr since C++20
1317 copy(InputIterator first, InputIterator last, OutputIterator result);1324 copy(InputIterator first, InputIterator last, OutputIterator result);
13181325
1319template<class InputIterator, class OutputIterator, class Predicate>1326template<class InputIterator, class OutputIterator, class Predicate>
1320 constexpr OutputIterator // constexpr in C++201327 constexpr OutputIterator // constexpr since C++20
1321 copy_if(InputIterator first, InputIterator last,1328 copy_if(InputIterator first, InputIterator last,
1322 OutputIterator result, Predicate pred);1329 OutputIterator result, Predicate pred);
13231330
1324template<class InputIterator, class Size, class OutputIterator>1331template<class InputIterator, class Size, class OutputIterator>
1325 constexpr OutputIterator // constexpr in C++201332 constexpr OutputIterator // constexpr since C++20
1326 copy_n(InputIterator first, Size n, OutputIterator result);1333 copy_n(InputIterator first, Size n, OutputIterator result);
13271334
1328template <class BidirectionalIterator1, class BidirectionalIterator2>1335template <class BidirectionalIterator1, class BidirectionalIterator2>
1329 constexpr BidirectionalIterator2 // constexpr in C++201336 constexpr BidirectionalIterator2 // constexpr since C++20
1330 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,1337 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last,
1331 BidirectionalIterator2 result);1338 BidirectionalIterator2 result);
13321339
...@@ -1341,7 +1348,7 @@ template<class BidirectionalIterator1, class BidirectionalIterator2>...@@ -1341,7 +1348,7 @@ template<class BidirectionalIterator1, class BidirectionalIterator2>
1341 BidirectionalIterator2 result);1348 BidirectionalIterator2 result);
13421349
1343template <class ForwardIterator1, class ForwardIterator2>1350template <class ForwardIterator1, class ForwardIterator2>
1344 constexpr ForwardIterator2 // constexpr in C++201351 constexpr ForwardIterator2 // constexpr since C++20
1345 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);1352 swap_ranges(ForwardIterator1 first1, ForwardIterator1 last1, ForwardIterator2 first2);
13461353
1347namespace ranges {1354namespace ranges {
...@@ -1360,97 +1367,97 @@ template<input_range R1, input_range R2>...@@ -1360,97 +1367,97 @@ template<input_range R1, input_range R2>
1360}1367}
13611368
1362template <class ForwardIterator1, class ForwardIterator2>1369template <class ForwardIterator1, class ForwardIterator2>
1363 constexpr void // constexpr in C++201370 constexpr void // constexpr since C++20
1364 iter_swap(ForwardIterator1 a, ForwardIterator2 b);1371 iter_swap(ForwardIterator1 a, ForwardIterator2 b);
13651372
1366template <class InputIterator, class OutputIterator, class UnaryOperation>1373template <class InputIterator, class OutputIterator, class UnaryOperation>
1367 constexpr OutputIterator // constexpr in C++201374 constexpr OutputIterator // constexpr since C++20
1368 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);1375 transform(InputIterator first, InputIterator last, OutputIterator result, UnaryOperation op);
13691376
1370template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>1377template <class InputIterator1, class InputIterator2, class OutputIterator, class BinaryOperation>
1371 constexpr OutputIterator // constexpr in C++201378 constexpr OutputIterator // constexpr since C++20
1372 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,1379 transform(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
1373 OutputIterator result, BinaryOperation binary_op);1380 OutputIterator result, BinaryOperation binary_op);
13741381
1375template <class ForwardIterator, class T>1382template <class ForwardIterator, class T>
1376 constexpr void // constexpr in C++201383 constexpr void // constexpr since C++20
1377 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);1384 replace(ForwardIterator first, ForwardIterator last, const T& old_value, const T& new_value);
13781385
1379template <class ForwardIterator, class Predicate, class T>1386template <class ForwardIterator, class Predicate, class T>
1380 constexpr void // constexpr in C++201387 constexpr void // constexpr since C++20
1381 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);1388 replace_if(ForwardIterator first, ForwardIterator last, Predicate pred, const T& new_value);
13821389
1383template <class InputIterator, class OutputIterator, class T>1390template <class InputIterator, class OutputIterator, class T>
1384 constexpr OutputIterator // constexpr in C++201391 constexpr OutputIterator // constexpr since C++20
1385 replace_copy(InputIterator first, InputIterator last, OutputIterator result,1392 replace_copy(InputIterator first, InputIterator last, OutputIterator result,
1386 const T& old_value, const T& new_value);1393 const T& old_value, const T& new_value);
13871394
1388template <class InputIterator, class OutputIterator, class Predicate, class T>1395template <class InputIterator, class OutputIterator, class Predicate, class T>
1389 constexpr OutputIterator // constexpr in C++201396 constexpr OutputIterator // constexpr since C++20
1390 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);1397 replace_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T& new_value);
13911398
1392template <class ForwardIterator, class T>1399template <class ForwardIterator, class T>
1393 constexpr void // constexpr in C++201400 constexpr void // constexpr since C++20
1394 fill(ForwardIterator first, ForwardIterator last, const T& value);1401 fill(ForwardIterator first, ForwardIterator last, const T& value);
13951402
1396template <class OutputIterator, class Size, class T>1403template <class OutputIterator, class Size, class T>
1397 constexpr OutputIterator // constexpr in C++201404 constexpr OutputIterator // constexpr since C++20
1398 fill_n(OutputIterator first, Size n, const T& value);1405 fill_n(OutputIterator first, Size n, const T& value);
13991406
1400template <class ForwardIterator, class Generator>1407template <class ForwardIterator, class Generator>
1401 constexpr void // constexpr in C++201408 constexpr void // constexpr since C++20
1402 generate(ForwardIterator first, ForwardIterator last, Generator gen);1409 generate(ForwardIterator first, ForwardIterator last, Generator gen);
14031410
1404template <class OutputIterator, class Size, class Generator>1411template <class OutputIterator, class Size, class Generator>
1405 constexpr OutputIterator // constexpr in C++201412 constexpr OutputIterator // constexpr since C++20
1406 generate_n(OutputIterator first, Size n, Generator gen);1413 generate_n(OutputIterator first, Size n, Generator gen);
14071414
1408template <class ForwardIterator, class T>1415template <class ForwardIterator, class T>
1409 constexpr ForwardIterator // constexpr in C++201416 constexpr ForwardIterator // constexpr since C++20
1410 remove(ForwardIterator first, ForwardIterator last, const T& value);1417 remove(ForwardIterator first, ForwardIterator last, const T& value);
14111418
1412template <class ForwardIterator, class Predicate>1419template <class ForwardIterator, class Predicate>
1413 constexpr ForwardIterator // constexpr in C++201420 constexpr ForwardIterator // constexpr since C++20
1414 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);1421 remove_if(ForwardIterator first, ForwardIterator last, Predicate pred);
14151422
1416template <class InputIterator, class OutputIterator, class T>1423template <class InputIterator, class OutputIterator, class T>
1417 constexpr OutputIterator // constexpr in C++201424 constexpr OutputIterator // constexpr since C++20
1418 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);1425 remove_copy(InputIterator first, InputIterator last, OutputIterator result, const T& value);
14191426
1420template <class InputIterator, class OutputIterator, class Predicate>1427template <class InputIterator, class OutputIterator, class Predicate>
1421 constexpr OutputIterator // constexpr in C++201428 constexpr OutputIterator // constexpr since C++20
1422 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);1429 remove_copy_if(InputIterator first, InputIterator last, OutputIterator result, Predicate pred);
14231430
1424template <class ForwardIterator>1431template <class ForwardIterator>
1425 constexpr ForwardIterator // constexpr in C++201432 constexpr ForwardIterator // constexpr since C++20
1426 unique(ForwardIterator first, ForwardIterator last);1433 unique(ForwardIterator first, ForwardIterator last);
14271434
1428template <class ForwardIterator, class BinaryPredicate>1435template <class ForwardIterator, class BinaryPredicate>
1429 constexpr ForwardIterator // constexpr in C++201436 constexpr ForwardIterator // constexpr since C++20
1430 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);1437 unique(ForwardIterator first, ForwardIterator last, BinaryPredicate pred);
14311438
1432template <class InputIterator, class OutputIterator>1439template <class InputIterator, class OutputIterator>
1433 constexpr OutputIterator // constexpr in C++201440 constexpr OutputIterator // constexpr since C++20
1434 unique_copy(InputIterator first, InputIterator last, OutputIterator result);1441 unique_copy(InputIterator first, InputIterator last, OutputIterator result);
14351442
1436template <class InputIterator, class OutputIterator, class BinaryPredicate>1443template <class InputIterator, class OutputIterator, class BinaryPredicate>
1437 constexpr OutputIterator // constexpr in C++201444 constexpr OutputIterator // constexpr since C++20
1438 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);1445 unique_copy(InputIterator first, InputIterator last, OutputIterator result, BinaryPredicate pred);
14391446
1440template <class BidirectionalIterator>1447template <class BidirectionalIterator>
1441 constexpr void // constexpr in C++201448 constexpr void // constexpr since C++20
1442 reverse(BidirectionalIterator first, BidirectionalIterator last);1449 reverse(BidirectionalIterator first, BidirectionalIterator last);
14431450
1444template <class BidirectionalIterator, class OutputIterator>1451template <class BidirectionalIterator, class OutputIterator>
1445 constexpr OutputIterator // constexpr in C++201452 constexpr OutputIterator // constexpr since C++20
1446 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);1453 reverse_copy(BidirectionalIterator first, BidirectionalIterator last, OutputIterator result);
14471454
1448template <class ForwardIterator>1455template <class ForwardIterator>
1449 constexpr ForwardIterator // constexpr in C++201456 constexpr ForwardIterator // constexpr since C++20
1450 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);1457 rotate(ForwardIterator first, ForwardIterator middle, ForwardIterator last);
14511458
1452template <class ForwardIterator, class OutputIterator>1459template <class ForwardIterator, class OutputIterator>
1453 constexpr OutputIterator // constexpr in C++201460 constexpr OutputIterator // constexpr since C++20
1454 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);1461 rotate_copy(ForwardIterator first, ForwardIterator middle, ForwardIterator last, OutputIterator result);
14551462
1456template <class RandomAccessIterator>1463template <class RandomAccessIterator>
...@@ -1483,254 +1490,254 @@ template<class ForwardIterator>...@@ -1483,254 +1490,254 @@ template<class ForwardIterator>
1483 typename iterator_traits<ForwardIterator>::difference_type n); // C++201490 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
14841491
1485template <class InputIterator, class Predicate>1492template <class InputIterator, class Predicate>
1486 constexpr bool // constexpr in C++201493 constexpr bool // constexpr since C++20
1487 is_partitioned(InputIterator first, InputIterator last, Predicate pred);1494 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
14881495
1489template <class ForwardIterator, class Predicate>1496template <class ForwardIterator, class Predicate>
1490 constexpr ForwardIterator // constexpr in C++201497 constexpr ForwardIterator // constexpr since C++20
1491 partition(ForwardIterator first, ForwardIterator last, Predicate pred);1498 partition(ForwardIterator first, ForwardIterator last, Predicate pred);
14921499
1493template <class InputIterator, class OutputIterator1,1500template <class InputIterator, class OutputIterator1,
1494 class OutputIterator2, class Predicate>1501 class OutputIterator2, class Predicate>
1495 constexpr pair<OutputIterator1, OutputIterator2> // constexpr in C++201502 constexpr pair<OutputIterator1, OutputIterator2> // constexpr since C++20
1496 partition_copy(InputIterator first, InputIterator last,1503 partition_copy(InputIterator first, InputIterator last,
1497 OutputIterator1 out_true, OutputIterator2 out_false,1504 OutputIterator1 out_true, OutputIterator2 out_false,
1498 Predicate pred);1505 Predicate pred);
14991506
1500template <class ForwardIterator, class Predicate>1507template <class ForwardIterator, class Predicate>
1501 ForwardIterator1508 constexpr ForwardIterator // constexpr since C++26
1502 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);1509 stable_partition(ForwardIterator first, ForwardIterator last, Predicate pred);
15031510
1504template<class ForwardIterator, class Predicate>1511template<class ForwardIterator, class Predicate>
1505 constexpr ForwardIterator // constexpr in C++201512 constexpr ForwardIterator // constexpr since C++20
1506 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);1513 partition_point(ForwardIterator first, ForwardIterator last, Predicate pred);
15071514
1508template <class ForwardIterator>1515template <class ForwardIterator>
1509 constexpr bool // constexpr in C++201516 constexpr bool // constexpr since C++20
1510 is_sorted(ForwardIterator first, ForwardIterator last);1517 is_sorted(ForwardIterator first, ForwardIterator last);
15111518
1512template <class ForwardIterator, class Compare>1519template <class ForwardIterator, class Compare>
1513 constexpr bool // constexpr in C++201520 constexpr bool // constexpr since C++20
1514 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);1521 is_sorted(ForwardIterator first, ForwardIterator last, Compare comp);
15151522
1516template<class ForwardIterator>1523template<class ForwardIterator>
1517 constexpr ForwardIterator // constexpr in C++201524 constexpr ForwardIterator // constexpr since C++20
1518 is_sorted_until(ForwardIterator first, ForwardIterator last);1525 is_sorted_until(ForwardIterator first, ForwardIterator last);
15191526
1520template <class ForwardIterator, class Compare>1527template <class ForwardIterator, class Compare>
1521 constexpr ForwardIterator // constexpr in C++201528 constexpr ForwardIterator // constexpr since C++20
1522 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);1529 is_sorted_until(ForwardIterator first, ForwardIterator last, Compare comp);
15231530
1524template <class RandomAccessIterator>1531template <class RandomAccessIterator>
1525 constexpr void // constexpr in C++201532 constexpr void // constexpr since C++20
1526 sort(RandomAccessIterator first, RandomAccessIterator last);1533 sort(RandomAccessIterator first, RandomAccessIterator last);
15271534
1528template <class RandomAccessIterator, class Compare>1535template <class RandomAccessIterator, class Compare>
1529 constexpr void // constexpr in C++201536 constexpr void // constexpr since C++20
1530 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1537 sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15311538
1532template <class RandomAccessIterator>1539template <class RandomAccessIterator>
1533 constexpr void // constexpr in C++261540 constexpr void // constexpr since C++26
1534 stable_sort(RandomAccessIterator first, RandomAccessIterator last);1541 stable_sort(RandomAccessIterator first, RandomAccessIterator last);
15351542
1536template <class RandomAccessIterator, class Compare>1543template <class RandomAccessIterator, class Compare>
1537 constexpr void // constexpr in C++261544 constexpr void // constexpr since C++26
1538 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1545 stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
15391546
1540template <class RandomAccessIterator>1547template <class RandomAccessIterator>
1541 constexpr void // constexpr in C++201548 constexpr void // constexpr since C++20
1542 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);1549 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
15431550
1544template <class RandomAccessIterator, class Compare>1551template <class RandomAccessIterator, class Compare>
1545 constexpr void // constexpr in C++201552 constexpr void // constexpr since C++20
1546 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);1553 partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp);
15471554
1548template <class InputIterator, class RandomAccessIterator>1555template <class InputIterator, class RandomAccessIterator>
1549 constexpr RandomAccessIterator // constexpr in C++201556 constexpr RandomAccessIterator // constexpr since C++20
1550 partial_sort_copy(InputIterator first, InputIterator last,1557 partial_sort_copy(InputIterator first, InputIterator last,
1551 RandomAccessIterator result_first, RandomAccessIterator result_last);1558 RandomAccessIterator result_first, RandomAccessIterator result_last);
15521559
1553template <class InputIterator, class RandomAccessIterator, class Compare>1560template <class InputIterator, class RandomAccessIterator, class Compare>
1554 constexpr RandomAccessIterator // constexpr in C++201561 constexpr RandomAccessIterator // constexpr since C++20
1555 partial_sort_copy(InputIterator first, InputIterator last,1562 partial_sort_copy(InputIterator first, InputIterator last,
1556 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);1563 RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp);
15571564
1558template <class RandomAccessIterator>1565template <class RandomAccessIterator>
1559 constexpr void // constexpr in C++201566 constexpr void // constexpr since C++20
1560 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);1567 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
15611568
1562template <class RandomAccessIterator, class Compare>1569template <class RandomAccessIterator, class Compare>
1563 constexpr void // constexpr in C++201570 constexpr void // constexpr since C++20
1564 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);1571 nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp);
15651572
1566template <class ForwardIterator, class T>1573template <class ForwardIterator, class T>
1567 constexpr ForwardIterator // constexpr in C++201574 constexpr ForwardIterator // constexpr since C++20
1568 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);1575 lower_bound(ForwardIterator first, ForwardIterator last, const T& value);
15691576
1570template <class ForwardIterator, class T, class Compare>1577template <class ForwardIterator, class T, class Compare>
1571 constexpr ForwardIterator // constexpr in C++201578 constexpr ForwardIterator // constexpr since C++20
1572 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);1579 lower_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
15731580
1574template <class ForwardIterator, class T>1581template <class ForwardIterator, class T>
1575 constexpr ForwardIterator // constexpr in C++201582 constexpr ForwardIterator // constexpr since C++20
1576 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);1583 upper_bound(ForwardIterator first, ForwardIterator last, const T& value);
15771584
1578template <class ForwardIterator, class T, class Compare>1585template <class ForwardIterator, class T, class Compare>
1579 constexpr ForwardIterator // constexpr in C++201586 constexpr ForwardIterator // constexpr since C++20
1580 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);1587 upper_bound(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
15811588
1582template <class ForwardIterator, class T>1589template <class ForwardIterator, class T>
1583 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++201590 constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++20
1584 equal_range(ForwardIterator first, ForwardIterator last, const T& value);1591 equal_range(ForwardIterator first, ForwardIterator last, const T& value);
15851592
1586template <class ForwardIterator, class T, class Compare>1593template <class ForwardIterator, class T, class Compare>
1587 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++201594 constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++20
1588 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);1595 equal_range(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
15891596
1590template <class ForwardIterator, class T>1597template <class ForwardIterator, class T>
1591 constexpr bool // constexpr in C++201598 constexpr bool // constexpr since C++20
1592 binary_search(ForwardIterator first, ForwardIterator last, const T& value);1599 binary_search(ForwardIterator first, ForwardIterator last, const T& value);
15931600
1594template <class ForwardIterator, class T, class Compare>1601template <class ForwardIterator, class T, class Compare>
1595 constexpr bool // constexpr in C++201602 constexpr bool // constexpr since C++20
1596 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);1603 binary_search(ForwardIterator first, ForwardIterator last, const T& value, Compare comp);
15971604
1598template <class InputIterator1, class InputIterator2, class OutputIterator>1605template <class InputIterator1, class InputIterator2, class OutputIterator>
1599 constexpr OutputIterator // constexpr in C++201606 constexpr OutputIterator // constexpr since C++20
1600 merge(InputIterator1 first1, InputIterator1 last1,1607 merge(InputIterator1 first1, InputIterator1 last1,
1601 InputIterator2 first2, InputIterator2 last2, OutputIterator result);1608 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
16021609
1603template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>1610template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1604 constexpr OutputIterator // constexpr in C++201611 constexpr OutputIterator // constexpr since C++20
1605 merge(InputIterator1 first1, InputIterator1 last1,1612 merge(InputIterator1 first1, InputIterator1 last1,
1606 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);1613 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
16071614
1608template <class BidirectionalIterator>1615template <class BidirectionalIterator>
1609 void1616 constexpr void // constexpr since C++26
1610 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);1617 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last);
16111618
1612template <class BidirectionalIterator, class Compare>1619template <class BidirectionalIterator, class Compare>
1613 void1620 constexpr void // constexpr since C++26
1614 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);1621 inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, Compare comp);
16151622
1616template <class InputIterator1, class InputIterator2>1623template <class InputIterator1, class InputIterator2>
1617 constexpr bool // constexpr in C++201624 constexpr bool // constexpr since C++20
1618 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);1625 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
16191626
1620template <class InputIterator1, class InputIterator2, class Compare>1627template <class InputIterator1, class InputIterator2, class Compare>
1621 constexpr bool // constexpr in C++201628 constexpr bool // constexpr since C++20
1622 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);1629 includes(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, Compare comp);
16231630
1624template <class InputIterator1, class InputIterator2, class OutputIterator>1631template <class InputIterator1, class InputIterator2, class OutputIterator>
1625 constexpr OutputIterator // constexpr in C++201632 constexpr OutputIterator // constexpr since C++20
1626 set_union(InputIterator1 first1, InputIterator1 last1,1633 set_union(InputIterator1 first1, InputIterator1 last1,
1627 InputIterator2 first2, InputIterator2 last2, OutputIterator result);1634 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
16281635
1629template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>1636template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1630 constexpr OutputIterator // constexpr in C++201637 constexpr OutputIterator // constexpr since C++20
1631 set_union(InputIterator1 first1, InputIterator1 last1,1638 set_union(InputIterator1 first1, InputIterator1 last1,
1632 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);1639 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
16331640
1634template <class InputIterator1, class InputIterator2, class OutputIterator>1641template <class InputIterator1, class InputIterator2, class OutputIterator>
1635 constexpr OutputIterator // constexpr in C++201642 constexpr OutputIterator // constexpr since C++20
1636 set_intersection(InputIterator1 first1, InputIterator1 last1,1643 set_intersection(InputIterator1 first1, InputIterator1 last1,
1637 InputIterator2 first2, InputIterator2 last2, OutputIterator result);1644 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
16381645
1639template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>1646template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1640 constexpr OutputIterator // constexpr in C++201647 constexpr OutputIterator // constexpr since C++20
1641 set_intersection(InputIterator1 first1, InputIterator1 last1,1648 set_intersection(InputIterator1 first1, InputIterator1 last1,
1642 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);1649 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
16431650
1644template <class InputIterator1, class InputIterator2, class OutputIterator>1651template <class InputIterator1, class InputIterator2, class OutputIterator>
1645 constexpr OutputIterator // constexpr in C++201652 constexpr OutputIterator // constexpr since C++20
1646 set_difference(InputIterator1 first1, InputIterator1 last1,1653 set_difference(InputIterator1 first1, InputIterator1 last1,
1647 InputIterator2 first2, InputIterator2 last2, OutputIterator result);1654 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
16481655
1649template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>1656template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1650 constexpr OutputIterator // constexpr in C++201657 constexpr OutputIterator // constexpr since C++20
1651 set_difference(InputIterator1 first1, InputIterator1 last1,1658 set_difference(InputIterator1 first1, InputIterator1 last1,
1652 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);1659 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
16531660
1654template <class InputIterator1, class InputIterator2, class OutputIterator>1661template <class InputIterator1, class InputIterator2, class OutputIterator>
1655 constexpr OutputIterator // constexpr in C++201662 constexpr OutputIterator // constexpr since C++20
1656 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,1663 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
1657 InputIterator2 first2, InputIterator2 last2, OutputIterator result);1664 InputIterator2 first2, InputIterator2 last2, OutputIterator result);
16581665
1659template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>1666template <class InputIterator1, class InputIterator2, class OutputIterator, class Compare>
1660 constexpr OutputIterator // constexpr in C++201667 constexpr OutputIterator // constexpr since C++20
1661 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,1668 set_symmetric_difference(InputIterator1 first1, InputIterator1 last1,
1662 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);1669 InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp);
16631670
1664template <class RandomAccessIterator>1671template <class RandomAccessIterator>
1665 constexpr void // constexpr in C++201672 constexpr void // constexpr since C++20
1666 push_heap(RandomAccessIterator first, RandomAccessIterator last);1673 push_heap(RandomAccessIterator first, RandomAccessIterator last);
16671674
1668template <class RandomAccessIterator, class Compare>1675template <class RandomAccessIterator, class Compare>
1669 constexpr void // constexpr in C++201676 constexpr void // constexpr since C++20
1670 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1677 push_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
16711678
1672template <class RandomAccessIterator>1679template <class RandomAccessIterator>
1673 constexpr void // constexpr in C++201680 constexpr void // constexpr since C++20
1674 pop_heap(RandomAccessIterator first, RandomAccessIterator last);1681 pop_heap(RandomAccessIterator first, RandomAccessIterator last);
16751682
1676template <class RandomAccessIterator, class Compare>1683template <class RandomAccessIterator, class Compare>
1677 constexpr void // constexpr in C++201684 constexpr void // constexpr since C++20
1678 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1685 pop_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
16791686
1680template <class RandomAccessIterator>1687template <class RandomAccessIterator>
1681 constexpr void // constexpr in C++201688 constexpr void // constexpr since C++20
1682 make_heap(RandomAccessIterator first, RandomAccessIterator last);1689 make_heap(RandomAccessIterator first, RandomAccessIterator last);
16831690
1684template <class RandomAccessIterator, class Compare>1691template <class RandomAccessIterator, class Compare>
1685 constexpr void // constexpr in C++201692 constexpr void // constexpr since C++20
1686 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1693 make_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
16871694
1688template <class RandomAccessIterator>1695template <class RandomAccessIterator>
1689 constexpr void // constexpr in C++201696 constexpr void // constexpr since C++20
1690 sort_heap(RandomAccessIterator first, RandomAccessIterator last);1697 sort_heap(RandomAccessIterator first, RandomAccessIterator last);
16911698
1692template <class RandomAccessIterator, class Compare>1699template <class RandomAccessIterator, class Compare>
1693 constexpr void // constexpr in C++201700 constexpr void // constexpr since C++20
1694 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);1701 sort_heap(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
16951702
1696template <class RandomAccessIterator>1703template <class RandomAccessIterator>
1697 constexpr bool // constexpr in C++201704 constexpr bool // constexpr since C++20
1698 is_heap(RandomAccessIterator first, RandomAccessiterator last);1705 is_heap(RandomAccessIterator first, RandomAccessiterator last);
16991706
1700template <class RandomAccessIterator, class Compare>1707template <class RandomAccessIterator, class Compare>
1701 constexpr bool // constexpr in C++201708 constexpr bool // constexpr since C++20
1702 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);1709 is_heap(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
17031710
1704template <class RandomAccessIterator>1711template <class RandomAccessIterator>
1705 constexpr RandomAccessIterator // constexpr in C++201712 constexpr RandomAccessIterator // constexpr since C++20
1706 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);1713 is_heap_until(RandomAccessIterator first, RandomAccessiterator last);
17071714
1708template <class RandomAccessIterator, class Compare>1715template <class RandomAccessIterator, class Compare>
1709 constexpr RandomAccessIterator // constexpr in C++201716 constexpr RandomAccessIterator // constexpr since C++20
1710 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);1717 is_heap_until(RandomAccessIterator first, RandomAccessiterator last, Compare comp);
17111718
1712template <class ForwardIterator>1719template <class ForwardIterator>
1713 constexpr ForwardIterator // constexpr in C++141720 constexpr ForwardIterator // constexpr since C++14
1714 min_element(ForwardIterator first, ForwardIterator last);1721 min_element(ForwardIterator first, ForwardIterator last);
17151722
1716template <class ForwardIterator, class Compare>1723template <class ForwardIterator, class Compare>
1717 constexpr ForwardIterator // constexpr in C++141724 constexpr ForwardIterator // constexpr since C++14
1718 min_element(ForwardIterator first, ForwardIterator last, Compare comp);1725 min_element(ForwardIterator first, ForwardIterator last, Compare comp);
17191726
1720template <class T>1727template <class T>
1721 constexpr const T& // constexpr in C++141728 constexpr const T& // constexpr since C++14
1722 min(const T& a, const T& b);1729 min(const T& a, const T& b);
17231730
1724template <class T, class Compare>1731template <class T, class Compare>
1725 constexpr const T& // constexpr in C++141732 constexpr const T& // constexpr since C++14
1726 min(const T& a, const T& b, Compare comp);1733 min(const T& a, const T& b, Compare comp);
17271734
1728template<class T>1735template<class T>
1729 constexpr T // constexpr in C++141736 constexpr T // constexpr since C++14
1730 min(initializer_list<T> t);1737 min(initializer_list<T> t);
17311738
1732template<class T, class Compare>1739template<class T, class Compare>
1733 constexpr T // constexpr in C++141740 constexpr T // constexpr since C++14
1734 min(initializer_list<T> t, Compare comp);1741 min(initializer_list<T> t, Compare comp);
17351742
1736template<class T>1743template<class T>
...@@ -1740,59 +1747,59 @@ template<class T, class Compare>...@@ -1740,59 +1747,59 @@ template<class T, class Compare>
1740 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++171747 constexpr const T& clamp(const T& v, const T& lo, const T& hi, Compare comp); // C++17
17411748
1742template <class ForwardIterator>1749template <class ForwardIterator>
1743 constexpr ForwardIterator // constexpr in C++141750 constexpr ForwardIterator // constexpr since C++14
1744 max_element(ForwardIterator first, ForwardIterator last);1751 max_element(ForwardIterator first, ForwardIterator last);
17451752
1746template <class ForwardIterator, class Compare>1753template <class ForwardIterator, class Compare>
1747 constexpr ForwardIterator // constexpr in C++141754 constexpr ForwardIterator // constexpr since C++14
1748 max_element(ForwardIterator first, ForwardIterator last, Compare comp);1755 max_element(ForwardIterator first, ForwardIterator last, Compare comp);
17491756
1750template <class T>1757template <class T>
1751 constexpr const T& // constexpr in C++141758 constexpr const T& // constexpr since C++14
1752 max(const T& a, const T& b);1759 max(const T& a, const T& b);
17531760
1754template <class T, class Compare>1761template <class T, class Compare>
1755 constexpr const T& // constexpr in C++141762 constexpr const T& // constexpr since C++14
1756 max(const T& a, const T& b, Compare comp);1763 max(const T& a, const T& b, Compare comp);
17571764
1758template<class T>1765template<class T>
1759 constexpr T // constexpr in C++141766 constexpr T // constexpr since C++14
1760 max(initializer_list<T> t);1767 max(initializer_list<T> t);
17611768
1762template<class T, class Compare>1769template<class T, class Compare>
1763 constexpr T // constexpr in C++141770 constexpr T // constexpr since C++14
1764 max(initializer_list<T> t, Compare comp);1771 max(initializer_list<T> t, Compare comp);
17651772
1766template<class ForwardIterator>1773template<class ForwardIterator>
1767 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++141774 constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++14
1768 minmax_element(ForwardIterator first, ForwardIterator last);1775 minmax_element(ForwardIterator first, ForwardIterator last);
17691776
1770template<class ForwardIterator, class Compare>1777template<class ForwardIterator, class Compare>
1771 constexpr pair<ForwardIterator, ForwardIterator> // constexpr in C++141778 constexpr pair<ForwardIterator, ForwardIterator> // constexpr since C++14
1772 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);1779 minmax_element(ForwardIterator first, ForwardIterator last, Compare comp);
17731780
1774template<class T>1781template<class T>
1775 constexpr pair<const T&, const T&> // constexpr in C++141782 constexpr pair<const T&, const T&> // constexpr since C++14
1776 minmax(const T& a, const T& b);1783 minmax(const T& a, const T& b);
17771784
1778template<class T, class Compare>1785template<class T, class Compare>
1779 constexpr pair<const T&, const T&> // constexpr in C++141786 constexpr pair<const T&, const T&> // constexpr since C++14
1780 minmax(const T& a, const T& b, Compare comp);1787 minmax(const T& a, const T& b, Compare comp);
17811788
1782template<class T>1789template<class T>
1783 constexpr pair<T, T> // constexpr in C++141790 constexpr pair<T, T> // constexpr since C++14
1784 minmax(initializer_list<T> t);1791 minmax(initializer_list<T> t);
17851792
1786template<class T, class Compare>1793template<class T, class Compare>
1787 constexpr pair<T, T> // constexpr in C++141794 constexpr pair<T, T> // constexpr since C++14
1788 minmax(initializer_list<T> t, Compare comp);1795 minmax(initializer_list<T> t, Compare comp);
17891796
1790template <class InputIterator1, class InputIterator2>1797template <class InputIterator1, class InputIterator2>
1791 constexpr bool // constexpr in C++201798 constexpr bool // constexpr since C++20
1792 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);1799 lexicographical_compare(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2);
17931800
1794template <class InputIterator1, class InputIterator2, class Compare>1801template <class InputIterator1, class InputIterator2, class Compare>
1795 constexpr bool // constexpr in C++201802 constexpr bool // constexpr since C++20
1796 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,1803 lexicographical_compare(InputIterator1 first1, InputIterator1 last1,
1797 InputIterator2 first2, InputIterator2 last2, Compare comp);1804 InputIterator2 first2, InputIterator2 last2, Compare comp);
17981805
...@@ -1809,19 +1816,19 @@ template<class InputIterator1, class InputIterator2>...@@ -1809,19 +1816,19 @@ template<class InputIterator1, class InputIterator2>
1809 InputIterator2 first2, InputIterator2 last2); // since C++201816 InputIterator2 first2, InputIterator2 last2); // since C++20
18101817
1811template <class BidirectionalIterator>1818template <class BidirectionalIterator>
1812 constexpr bool // constexpr in C++201819 constexpr bool // constexpr since C++20
1813 next_permutation(BidirectionalIterator first, BidirectionalIterator last);1820 next_permutation(BidirectionalIterator first, BidirectionalIterator last);
18141821
1815template <class BidirectionalIterator, class Compare>1822template <class BidirectionalIterator, class Compare>
1816 constexpr bool // constexpr in C++201823 constexpr bool // constexpr since C++20
1817 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);1824 next_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
18181825
1819template <class BidirectionalIterator>1826template <class BidirectionalIterator>
1820 constexpr bool // constexpr in C++201827 constexpr bool // constexpr since C++20
1821 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);1828 prev_permutation(BidirectionalIterator first, BidirectionalIterator last);
18221829
1823template <class BidirectionalIterator, class Compare>1830template <class BidirectionalIterator, class Compare>
1824 constexpr bool // constexpr in C++201831 constexpr bool // constexpr since C++20
1825 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);1832 prev_permutation(BidirectionalIterator first, BidirectionalIterator last, Compare comp);
1826} // std1833} // std
18271834
...@@ -1932,6 +1939,7 @@ template <class BidirectionalIterator, class Compare>...@@ -1932,6 +1939,7 @@ template <class BidirectionalIterator, class Compare>
1932# include <__algorithm/in_out_result.h>1939# include <__algorithm/in_out_result.h>
1933# include <__algorithm/lexicographical_compare_three_way.h>1940# include <__algorithm/lexicographical_compare_three_way.h>
1934# include <__algorithm/min_max_result.h>1941# include <__algorithm/min_max_result.h>
1942# include <__algorithm/out_value_result.h>
1935# include <__algorithm/ranges_adjacent_find.h>1943# include <__algorithm/ranges_adjacent_find.h>
1936# include <__algorithm/ranges_all_of.h>1944# include <__algorithm/ranges_all_of.h>
1937# include <__algorithm/ranges_any_of.h>1945# include <__algorithm/ranges_any_of.h>
...@@ -2053,6 +2061,7 @@ template <class BidirectionalIterator, class Compare>...@@ -2053,6 +2061,7 @@ template <class BidirectionalIterator, class Compare>
2053# include <cstring>2061# include <cstring>
2054# include <iterator>2062# include <iterator>
2055# include <memory>2063# include <memory>
2064# include <optional>
2056# include <stdexcept>2065# include <stdexcept>
2057# include <type_traits>2066# include <type_traits>
2058# include <utility>2067# include <utility>
lib/libcxx/include/any+16-16
...@@ -81,7 +81,7 @@ namespace std {...@@ -81,7 +81,7 @@ namespace std {
81*/81*/
8282
83#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)83#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
84# include <__cxx03/any>84# include <__cxx03/__config>
85#else85#else
86# include <__config>86# include <__config>
87# include <__memory/allocator.h>87# include <__memory/allocator.h>
...@@ -119,18 +119,18 @@ namespace std {...@@ -119,18 +119,18 @@ namespace std {
119_LIBCPP_PUSH_MACROS119_LIBCPP_PUSH_MACROS
120# include <__undef_macros>120# include <__undef_macros>
121121
122namespace std {122_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
123class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {123class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
124public:124public:
125 const char* what() const _NOEXCEPT override;125 const char* what() const _NOEXCEPT override;
126};126};
127} // namespace std127_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
128128
129_LIBCPP_BEGIN_NAMESPACE_STD129_LIBCPP_BEGIN_NAMESPACE_STD
130130
131# if _LIBCPP_STD_VER >= 17131# if _LIBCPP_STD_VER >= 17
132132
133[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() {133[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_any_cast() {
134# if _LIBCPP_HAS_EXCEPTIONS134# if _LIBCPP_HAS_EXCEPTIONS
135 throw bad_any_cast();135 throw bad_any_cast();
136# else136# else
...@@ -139,7 +139,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -139,7 +139,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
139}139}
140140
141// Forward declarations141// Forward declarations
142class _LIBCPP_TEMPLATE_VIS any;142class any;
143143
144template <class _ValueType>144template <class _ValueType>
145_LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) _NOEXCEPT;145_LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const*) _NOEXCEPT;
...@@ -166,7 +166,7 @@ template <class _Tp>...@@ -166,7 +166,7 @@ template <class _Tp>
166struct _LargeHandler;166struct _LargeHandler;
167167
168template <class _Tp>168template <class _Tp>
169struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo {169struct __unique_typeinfo {
170 static constexpr int __id = 0;170 static constexpr int __id = 0;
171};171};
172172
...@@ -189,7 +189,7 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma...@@ -189,7 +189,7 @@ using _Handler _LIBCPP_NODEBUG = conditional_t< _IsSmallObject<_Tp>::value, _Sma
189189
190} // namespace __any_imp190} // namespace __any_imp
191191
192class _LIBCPP_TEMPLATE_VIS any {192class any {
193public:193public:
194 // construct/destruct194 // construct/destruct
195 _LIBCPP_HIDE_FROM_ABI constexpr any() _NOEXCEPT : __h_(nullptr) {}195 _LIBCPP_HIDE_FROM_ABI constexpr any() _NOEXCEPT : __h_(nullptr) {}
...@@ -316,7 +316,7 @@ private:...@@ -316,7 +316,7 @@ private:
316316
317namespace __any_imp {317namespace __any_imp {
318template <class _Tp>318template <class _Tp>
319struct _LIBCPP_TEMPLATE_VIS _SmallHandler {319struct _SmallHandler {
320 _LIBCPP_HIDE_FROM_ABI static void*320 _LIBCPP_HIDE_FROM_ABI static void*
321 __handle(_Action __act, any const* __this, any* __other, type_info const* __info, const void* __fallback_info) {321 __handle(_Action __act, any const* __this, any* __other, type_info const* __info, const void* __fallback_info) {
322 switch (__act) {322 switch (__act) {
...@@ -383,7 +383,7 @@ private:...@@ -383,7 +383,7 @@ private:
383};383};
384384
385template <class _Tp>385template <class _Tp>
386struct _LIBCPP_TEMPLATE_VIS _LargeHandler {386struct _LargeHandler {
387 _LIBCPP_HIDE_FROM_ABI static void*387 _LIBCPP_HIDE_FROM_ABI static void*
388 __handle(_Action __act, any const* __this, any* __other, type_info const* __info, void const* __fallback_info) {388 __handle(_Action __act, any const* __this, any* __other, type_info const* __info, void const* __fallback_info) {
389 switch (__act) {389 switch (__act) {
...@@ -519,38 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&......@@ -519,38 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&...
519}519}
520520
521template <class _ValueType>521template <class _ValueType>
522inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const& __v) {522inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) {
523 using _RawValueType = __remove_cvref_t<_ValueType>;523 using _RawValueType = __remove_cvref_t<_ValueType>;
524 static_assert(is_constructible<_ValueType, _RawValueType const&>::value,524 static_assert(is_constructible<_ValueType, _RawValueType const&>::value,
525 "ValueType is required to be a const lvalue reference "525 "ValueType is required to be a const lvalue reference "
526 "or a CopyConstructible type");526 "or a CopyConstructible type");
527 auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v);527 auto __tmp = std::any_cast<add_const_t<_RawValueType>>(&__v);
528 if (__tmp == nullptr)528 if (__tmp == nullptr)
529 __throw_bad_any_cast();529 std::__throw_bad_any_cast();
530 return static_cast<_ValueType>(*__tmp);530 return static_cast<_ValueType>(*__tmp);
531}531}
532532
533template <class _ValueType>533template <class _ValueType>
534inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any& __v) {534inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) {
535 using _RawValueType = __remove_cvref_t<_ValueType>;535 using _RawValueType = __remove_cvref_t<_ValueType>;
536 static_assert(is_constructible<_ValueType, _RawValueType&>::value,536 static_assert(is_constructible<_ValueType, _RawValueType&>::value,
537 "ValueType is required to be an lvalue reference "537 "ValueType is required to be an lvalue reference "
538 "or a CopyConstructible type");538 "or a CopyConstructible type");
539 auto __tmp = std::any_cast<_RawValueType>(&__v);539 auto __tmp = std::any_cast<_RawValueType>(&__v);
540 if (__tmp == nullptr)540 if (__tmp == nullptr)
541 __throw_bad_any_cast();541 std::__throw_bad_any_cast();
542 return static_cast<_ValueType>(*__tmp);542 return static_cast<_ValueType>(*__tmp);
543}543}
544544
545template <class _ValueType>545template <class _ValueType>
546inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any&& __v) {546inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) {
547 using _RawValueType = __remove_cvref_t<_ValueType>;547 using _RawValueType = __remove_cvref_t<_ValueType>;
548 static_assert(is_constructible<_ValueType, _RawValueType>::value,548 static_assert(is_constructible<_ValueType, _RawValueType>::value,
549 "ValueType is required to be an rvalue reference "549 "ValueType is required to be an rvalue reference "
550 "or a CopyConstructible type");550 "or a CopyConstructible type");
551 auto __tmp = std::any_cast<_RawValueType>(&__v);551 auto __tmp = std::any_cast<_RawValueType>(&__v);
552 if (__tmp == nullptr)552 if (__tmp == nullptr)
553 __throw_bad_any_cast();553 std::__throw_bad_any_cast();
554 return static_cast<_ValueType>(std::move(*__tmp));554 return static_cast<_ValueType>(std::move(*__tmp));
555}555}
556556
lib/libcxx/include/array+12-9
...@@ -134,6 +134,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce...@@ -134,6 +134,7 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
134# include <__type_traits/is_const.h>134# include <__type_traits/is_const.h>
135# include <__type_traits/is_constructible.h>135# include <__type_traits/is_constructible.h>
136# include <__type_traits/is_nothrow_constructible.h>136# include <__type_traits/is_nothrow_constructible.h>
137# include <__type_traits/is_replaceable.h>
137# include <__type_traits/is_same.h>138# include <__type_traits/is_same.h>
138# include <__type_traits/is_swappable.h>139# include <__type_traits/is_swappable.h>
139# include <__type_traits/is_trivially_relocatable.h>140# include <__type_traits/is_trivially_relocatable.h>
...@@ -172,9 +173,10 @@ _LIBCPP_PUSH_MACROS...@@ -172,9 +173,10 @@ _LIBCPP_PUSH_MACROS
172_LIBCPP_BEGIN_NAMESPACE_STD173_LIBCPP_BEGIN_NAMESPACE_STD
173174
174template <class _Tp, size_t _Size>175template <class _Tp, size_t _Size>
175struct _LIBCPP_TEMPLATE_VIS array {176struct array {
176 using __trivially_relocatable _LIBCPP_NODEBUG =177 using __trivially_relocatable _LIBCPP_NODEBUG =
177 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;178 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;
179 using __replaceable _LIBCPP_NODEBUG = __conditional_t<__is_replaceable_v<_Tp>, array, void>;
178180
179 // types:181 // types:
180 using __self _LIBCPP_NODEBUG = array;182 using __self _LIBCPP_NODEBUG = array;
...@@ -276,13 +278,13 @@ struct _LIBCPP_TEMPLATE_VIS array {...@@ -276,13 +278,13 @@ struct _LIBCPP_TEMPLATE_VIS array {
276278
277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) {279 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type __n) {
278 if (__n >= _Size)280 if (__n >= _Size)
279 __throw_out_of_range("array::at");281 std::__throw_out_of_range("array::at");
280 return __elems_[__n];282 return __elems_[__n];
281 }283 }
282284
283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const {285 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type __n) const {
284 if (__n >= _Size)286 if (__n >= _Size)
285 __throw_out_of_range("array::at");287 std::__throw_out_of_range("array::at");
286 return __elems_[__n];288 return __elems_[__n];
287 }289 }
288290
...@@ -298,7 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS array {...@@ -298,7 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS array {
298};300};
299301
300template <class _Tp>302template <class _Tp>
301struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {303struct array<_Tp, 0> {
302 // types:304 // types:
303 using __self _LIBCPP_NODEBUG = array;305 using __self _LIBCPP_NODEBUG = array;
304 using value_type = _Tp;306 using value_type = _Tp;
...@@ -407,12 +409,12 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {...@@ -407,12 +409,12 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
407 }409 }
408410
409 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) {411 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference at(size_type) {
410 __throw_out_of_range("array<T, 0>::at");412 std::__throw_out_of_range("array<T, 0>::at");
411 __libcpp_unreachable();413 __libcpp_unreachable();
412 }414 }
413415
414 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const {416 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const_reference at(size_type) const {
415 __throw_out_of_range("array<T, 0>::at");417 std::__throw_out_of_range("array<T, 0>::at");
416 __libcpp_unreachable();418 __libcpp_unreachable();
417 }419 }
418420
...@@ -492,12 +494,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp,...@@ -492,12 +494,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp,
492}494}
493495
494template <class _Tp, size_t _Size>496template <class _Tp, size_t _Size>
495struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};497struct tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {};
496498
497template <size_t _Ip, class _Tp, size_t _Size>499template <size_t _Ip, class _Tp, size_t _Size>
498struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > {500struct tuple_element<_Ip, array<_Tp, _Size> > {
499 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");501 static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
500 using type = _Tp;502 using type _LIBCPP_NODEBUG = _Tp;
501};503};
502504
503template <size_t _Ip, class _Tp, size_t _Size>505template <size_t _Ip, class _Tp, size_t _Size>
...@@ -566,6 +568,7 @@ _LIBCPP_POP_MACROS...@@ -566,6 +568,7 @@ _LIBCPP_POP_MACROS
566# include <cstdlib>568# include <cstdlib>
567# include <iterator>569# include <iterator>
568# include <new>570# include <new>
571# include <optional>
569# include <type_traits>572# include <type_traits>
570# include <utility>573# include <utility>
571# endif574# endif
lib/libcxx/include/barrier+1-1
...@@ -46,7 +46,7 @@ namespace std...@@ -46,7 +46,7 @@ namespace std
46*/46*/
4747
48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
49# include <__cxx03/barrier>49# include <__cxx03/__config>
50#else50#else
51# include <__config>51# include <__config>
5252
lib/libcxx/include/bit+1-1
...@@ -62,7 +62,7 @@ namespace std {...@@ -62,7 +62,7 @@ namespace std {
62*/62*/
6363
64#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)64#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
65# include <__cxx03/bit>65# include <__cxx03/__config>
66#else66#else
67# include <__config>67# include <__config>
6868
lib/libcxx/include/bitset+183-199
...@@ -129,18 +129,29 @@ template <size_t N> struct hash<std::bitset<N>>;...@@ -129,18 +129,29 @@ template <size_t N> struct hash<std::bitset<N>>;
129#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)129#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
130# include <__cxx03/bitset>130# include <__cxx03/bitset>
131#else131#else
132# include <__algorithm/copy.h>
133# include <__algorithm/copy_backward.h>
132# include <__algorithm/count.h>134# include <__algorithm/count.h>
135# include <__algorithm/equal.h>
133# include <__algorithm/fill.h>136# include <__algorithm/fill.h>
134# include <__algorithm/fill_n.h>137# include <__algorithm/fill_n.h>
135# include <__algorithm/find.h>138# include <__algorithm/find.h>
139# include <__algorithm/min.h>
136# include <__assert>140# include <__assert>
141# include <__bit/countr.h>
142# include <__bit/invert_if.h>
137# include <__bit_reference>143# include <__bit_reference>
138# include <__config>144# include <__config>
139# include <__cstddef/ptrdiff_t.h>145# include <__cstddef/ptrdiff_t.h>
140# include <__cstddef/size_t.h>146# include <__cstddef/size_t.h>
141# include <__functional/hash.h>147# include <__functional/hash.h>
148# include <__functional/identity.h>
142# include <__functional/unary_function.h>149# include <__functional/unary_function.h>
150# include <__tuple/tuple_indices.h>
151# include <__type_traits/enable_if.h>
152# include <__type_traits/integral_constant.h>
143# include <__type_traits/is_char_like_type.h>153# include <__type_traits/is_char_like_type.h>
154# include <__utility/integer_sequence.h>
144# include <climits>155# include <climits>
145# include <stdexcept>156# include <stdexcept>
146# include <string_view>157# include <string_view>
...@@ -214,28 +225,98 @@ protected:...@@ -214,28 +225,98 @@ protected:
214 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator^=(const __bitset& __v) _NOEXCEPT;
215226
216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
228
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {
218 return to_ulong(integral_constant < bool, _Size< sizeof(unsigned long) * CHAR_BIT>());230 if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long) * CHAR_BIT) {
231 if (auto __e = __make_iter(_Size); std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true) != __e)
232 std::__throw_overflow_error("__bitset<_N_words, _Size>::to_ulong overflow error");
233 }
234
235 static_assert(sizeof(__storage_type) >= sizeof(unsigned long),
236 "libc++ only supports platforms where sizeof(size_t) >= sizeof(unsigned long), such as 32-bit and "
237 "64-bit platforms. If you're interested in supporting a platform where that is not the case, please "
238 "contact the libc++ developers.");
239 return static_cast<unsigned long>(__first_[0]);
219 }240 }
241
220 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {242 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
221 return to_ullong(integral_constant < bool, _Size< sizeof(unsigned long long) * CHAR_BIT>());243 // Check for overflow if _Size does not fit in unsigned long long
244 if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) {
245 if (auto __e = __make_iter(_Size);
246 std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true) != __e)
247 std::__throw_overflow_error("__bitset<_N_words, _Size>::to_ullong overflow error");
248 }
249
250 // At this point, the effective bitset size (excluding leading zeros) fits in unsigned long long
251
252 if _LIBCPP_CONSTEXPR (sizeof(__storage_type) >= sizeof(unsigned long long)) {
253 // If __storage_type is at least as large as unsigned long long, the result spans only one word
254 return static_cast<unsigned long long>(__first_[0]);
255 } else {
256 // Otherwise, the result spans multiple words which are concatenated
257 const size_t __ull_words = (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1;
258 const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
259 unsigned long long __r = static_cast<unsigned long long>(__first_[0]);
260 for (size_t __i = 1; __i < __n_words; ++__i)
261 __r |= static_cast<unsigned long long>(__first_[__i]) << (__bits_per_word * __i);
262 return __r;
263 }
222 }264 }
223265
224 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;266 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return !__scan_bits(__bit_not()); }
225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT {
268 return __scan_bits(std::__identity());
269 }
226 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;270 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT;
227271
272 template <bool _Sparse, class _CharT, class _Traits, class _Allocator>
273 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
274 __to_string(_CharT __zero, _CharT __one) const {
275 basic_string<_CharT, _Traits, _Allocator> __r(_Size, _Sparse ? __zero : __one);
276 for (size_t __i = 0, __bits = 0; __i < _N_words; ++__i, __bits += __bits_per_word) {
277 __storage_type __word = std::__invert_if<!_Sparse>(__first_[__i]);
278 if (__i == _N_words - 1 && _Size - __bits < __bits_per_word)
279 __word &= (__storage_type(1) << (_Size - __bits)) - 1;
280 for (; __word; __word &= (__word - 1))
281 __r[_Size - 1 - (__bits + std::__countr_zero(__word))] = _Sparse ? __one : __zero;
282 }
283
284 return __r;
285 }
286
228private:287private:
288 struct __bit_not {
289 template <class _Tp>
290 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp operator()(const _Tp& __x) const _NOEXCEPT {
291 return ~__x;
292 }
293 };
294
295 template <typename _Proj>
296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __scan_bits(_Proj __proj) const _NOEXCEPT {
297 size_t __n = _Size;
298 __const_storage_pointer __p = __first_;
299 // do middle whole words
300 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
301 if (__proj(*__p))
302 return true;
303 // do last partial word
304 if (__n > 0) {
305 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
306 if (__proj(*__p) & __m)
307 return true;
308 }
309 return false;
310 }
311
229# ifdef _LIBCPP_CXX03_LANG312# ifdef _LIBCPP_CXX03_LANG
230 void __init(unsigned long long __v, false_type) _NOEXCEPT;313 void __init(unsigned long long __v, false_type) _NOEXCEPT;
231 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;314 _LIBCPP_HIDE_FROM_ABI void __init(unsigned long long __v, true_type) _NOEXCEPT;
315# else
316 template <size_t... _Indices>
317 _LIBCPP_HIDE_FROM_ABI constexpr __bitset(unsigned long long __v, std::__tuple_indices<_Indices...>) _NOEXCEPT
318 : __first_{static_cast<__storage_type>(__v >> (_Indices * __bits_per_word))...} {}
232# endif // _LIBCPP_CXX03_LANG319# endif // _LIBCPP_CXX03_LANG
233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(false_type) const;
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong(true_type) const;
235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(false_type) const;
236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type) const;
237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, false_type) const;
238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong(true_type, true_type) const;
239};320};
240321
241template <size_t _N_words, size_t _Size>322template <size_t _N_words, size_t _Size>
...@@ -253,26 +334,16 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT...@@ -253,26 +334,16 @@ inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT
253334
254template <size_t _N_words, size_t _Size>335template <size_t _N_words, size_t _Size>
255void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {336void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {
256 __storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];337 const size_t __n_words = std::min((sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1, _N_words);
257 size_t __sz = _Size;338 for (size_t __i = 0; __i < __n_words; ++__i, __v >>= __bits_per_word)
258 for (size_t __i = 0; __i < sizeof(__t) / sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word)339 __first_[__i] = static_cast<__storage_type>(__v);
259 if (__sz < __bits_per_word)340 std::fill(__first_ + __n_words, __first_ + _N_words, __storage_type(0));
260 __t[__i] = static_cast<__storage_type>(__v) & (1ULL << __sz) - 1;
261 else
262 __t[__i] = static_cast<__storage_type>(__v);
263
264 std::copy(__t, __t + sizeof(__t) / sizeof(__t[0]), __first_);
265 std::fill(
266 __first_ + sizeof(__t) / sizeof(__t[0]), __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
267}341}
268342
269template <size_t _N_words, size_t _Size>343template <size_t _N_words, size_t _Size>
270inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT {344inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT {
271 __first_[0] = __v;345 __first_[0] = __v;
272 if (_Size < __bits_per_word)346 std::fill(__first_ + 1, __first_ + _N_words, __storage_type(0));
273 __first_[0] &= (1ULL << _Size) - 1;
274
275 std::fill(__first_ + 1, __first_ + sizeof(__first_) / sizeof(__first_[0]), __storage_type(0));
276}347}
277348
278# endif // _LIBCPP_CXX03_LANG349# endif // _LIBCPP_CXX03_LANG
...@@ -280,21 +351,15 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon...@@ -280,21 +351,15 @@ inline _LIBCPP_HIDE_FROM_ABI void __bitset<_N_words, _Size>::__init(unsigned lon
280template <size_t _N_words, size_t _Size>351template <size_t _N_words, size_t _Size>
281inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT352inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
282# ifndef _LIBCPP_CXX03_LANG353# ifndef _LIBCPP_CXX03_LANG
283# if __SIZEOF_SIZE_T__ == 8354 : __bitset(__v,
284 : __first_{__v}355 std::__make_indices_imp< (_N_words < (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1)
285# elif __SIZEOF_SIZE_T__ == 4356 ? _N_words
286 : __first_{static_cast<__storage_type>(__v),357 : (sizeof(unsigned long long) - 1) / sizeof(__storage_type) + 1,
287 _Size >= 2 * __bits_per_word358 0>{})
288 ? static_cast<__storage_type>(__v >> __bits_per_word)
289 : static_cast<__storage_type>((__v >> __bits_per_word) &
290 (__storage_type(1) << (_Size - __bits_per_word)) - 1)}
291# else
292# error This constructor has not been ported to this platform
293# endif
294# endif359# endif
295{360{
296# ifdef _LIBCPP_CXX03_LANG361# ifdef _LIBCPP_CXX03_LANG
297 __init(__v, integral_constant<bool, sizeof(unsigned long long) == sizeof(__storage_type)>());362 __init(__v, _BoolConstant<sizeof(unsigned long long) <= sizeof(__storage_type)>());
298# endif363# endif
299}364}
300365
...@@ -327,98 +392,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz...@@ -327,98 +392,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<_N_words, _Siz
327 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)392 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
328 *__p = ~*__p;393 *__p = ~*__p;
329 // do last partial word394 // do last partial word
330 if (__n > 0) {395 // Ensure trailing padding bits are zeroed as part of the ABI for consistent hashing behavior. std::hash<bitset>
331 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);396 // assumes trailing bits are zeroed; otherwise, identical bitsets could hash differently.
332 __storage_type __b = *__p & __m;397 if (__n > 0)
333 *__p &= ~__m;398 *__p ^= (__storage_type(1) << __n) - 1;
334 *__p |= ~__b & __m;
335 }
336}
337
338template <size_t _N_words, size_t _Size>
339_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
340__bitset<_N_words, _Size>::to_ulong(false_type) const {
341 __const_iterator __e = __make_iter(_Size);
342 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true);
343 if (__i != __e)
344 __throw_overflow_error("bitset to_ulong overflow error");
345
346 return __first_[0];
347}
348
349template <size_t _N_words, size_t _Size>
350inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long
351__bitset<_N_words, _Size>::to_ulong(true_type) const {
352 return __first_[0];
353}
354
355template <size_t _N_words, size_t _Size>
356_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
357__bitset<_N_words, _Size>::to_ullong(false_type) const {
358 __const_iterator __e = __make_iter(_Size);
359 __const_iterator __i = std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true);
360 if (__i != __e)
361 __throw_overflow_error("bitset to_ullong overflow error");
362
363 return to_ullong(true_type());
364}
365
366template <size_t _N_words, size_t _Size>
367inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
368__bitset<_N_words, _Size>::to_ullong(true_type) const {
369 return to_ullong(true_type(), integral_constant<bool, sizeof(__storage_type) < sizeof(unsigned long long)>());
370}
371
372template <size_t _N_words, size_t _Size>
373inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
374__bitset<_N_words, _Size>::to_ullong(true_type, false_type) const {
375 return __first_[0];
376}
377
378template <size_t _N_words, size_t _Size>
379_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
380__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
381 unsigned long long __r = __first_[0];
382 _LIBCPP_DIAGNOSTIC_PUSH
383 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
384 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
385 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
386 _LIBCPP_DIAGNOSTIC_POP
387 return __r;
388}
389
390template <size_t _N_words, size_t _Size>
391_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::all() const _NOEXCEPT {
392 // do middle whole words
393 size_t __n = _Size;
394 __const_storage_pointer __p = __first_;
395 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
396 if (~*__p)
397 return false;
398 // do last partial word
399 if (__n > 0) {
400 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
401 if (~*__p & __m)
402 return false;
403 }
404 return true;
405}
406
407template <size_t _N_words, size_t _Size>
408_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool __bitset<_N_words, _Size>::any() const _NOEXCEPT {
409 // do middle whole words
410 size_t __n = _Size;
411 __const_storage_pointer __p = __first_;
412 for (; __n >= __bits_per_word; ++__p, __n -= __bits_per_word)
413 if (*__p)
414 return true;
415 // do last partial word
416 if (__n > 0) {
417 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
418 if (*__p & __m)
419 return true;
420 }
421 return false;
422}399}
423400
424template <size_t _N_words, size_t _Size>401template <size_t _N_words, size_t _Size>
...@@ -463,10 +440,14 @@ protected:...@@ -463,10 +440,14 @@ protected:
463 return __const_reference(&__first_, __storage_type(1) << __pos);440 return __const_reference(&__first_, __storage_type(1) << __pos);
464 }441 }
465 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {442 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __iterator __make_iter(size_t __pos) _NOEXCEPT {
466 return __iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);443 // Allow the == case to accommodate the past-the-end iterator.
444 _LIBCPP_ASSERT_INTERNAL(__pos <= __bits_per_word, "Out of bounds access in the single-word bitset implementation.");
445 return __pos != __bits_per_word ? __iterator(&__first_, __pos) : __iterator(&__first_ + 1, 0);
467 }446 }
468 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {447 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __const_iterator __make_iter(size_t __pos) const _NOEXCEPT {
469 return __const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);448 // Allow the == case to accommodate the past-the-end iterator.
449 _LIBCPP_ASSERT_INTERNAL(__pos <= __bits_per_word, "Out of bounds access in the single-word bitset implementation.");
450 return __pos != __bits_per_word ? __const_iterator(&__first_, __pos) : __const_iterator(&__first_ + 1, 0);
470 }451 }
471452
472 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;453 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator&=(const __bitset& __v) _NOEXCEPT;
...@@ -475,8 +456,39 @@ protected:...@@ -475,8 +456,39 @@ protected:
475456
476 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;457 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void flip() _NOEXCEPT;
477458
478 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const {
479 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;460 if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long) * CHAR_BIT) {
461 if (auto __e = __make_iter(_Size); std::find(__make_iter(sizeof(unsigned long) * CHAR_BIT), __e, true) != __e)
462 __throw_overflow_error("__bitset<1, _Size>::to_ulong overflow error");
463 }
464 return static_cast<unsigned long>(__first_);
465 }
466
467 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
468 // If _Size exceeds the size of unsigned long long, check for overflow
469 if _LIBCPP_CONSTEXPR (_Size > sizeof(unsigned long long) * CHAR_BIT) {
470 if (auto __e = __make_iter(_Size);
471 std::find(__make_iter(sizeof(unsigned long long) * CHAR_BIT), __e, true) != __e)
472 __throw_overflow_error("__bitset<1, _Size>::to_ullong overflow error");
473 }
474
475 // If _Size fits or no overflow, directly cast to unsigned long long
476 return static_cast<unsigned long long>(__first_);
477 }
478
479 template <bool _Sparse, class _CharT, class _Traits, class _Allocator>
480 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
481 __to_string(_CharT __zero, _CharT __one) const {
482 basic_string<_CharT, _Traits, _Allocator> __r(_Size, _Sparse ? __zero : __one);
483 __storage_type __word = std::__invert_if<!_Sparse>(__first_);
484 if (_Size < __bits_per_word)
485 __word &= (__storage_type(1) << _Size) - 1;
486 for (; __word; __word &= (__word - 1)) {
487 size_t __pos = std::__countr_zero(__word);
488 __r[_Size - 1 - __pos] = _Sparse ? __one : __zero;
489 }
490 return __r;
491 }
480492
481 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;493 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;
482 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;494 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;
...@@ -489,8 +501,10 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)...@@ -489,8 +501,10 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
489501
490template <size_t _Size>502template <size_t _Size>
491inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT503inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT
492 : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v)504 // TODO: We must refer to __bits_per_word in order to work around an issue with the GDB pretty-printers.
493 : static_cast<__storage_type>(__v) & ((__storage_type(1) << _Size) - 1)) {}505 // Without it, the pretty-printers complain about a missing __bits_per_word member. This needs to
506 // be investigated further.
507 : __first_(_Size == __bits_per_word ? static_cast<__storage_type>(__v) : static_cast<__storage_type>(__v)) {}
494508
495template <size_t _Size>509template <size_t _Size>
496inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void510inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
...@@ -512,19 +526,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {...@@ -512,19 +526,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT {
512526
513template <size_t _Size>527template <size_t _Size>
514inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT {528inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void __bitset<1, _Size>::flip() _NOEXCEPT {
515 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - _Size);529 __first_ ^= ~__storage_type(0) >> (__bits_per_word - _Size);
516 __first_ = ~__first_;
517 __first_ &= __m;
518}
519
520template <size_t _Size>
521inline _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long __bitset<1, _Size>::to_ulong() const {
522 return __first_;
523}
524
525template <size_t _Size>
526inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long __bitset<1, _Size>::to_ullong() const {
527 return __first_;
528}530}
529531
530template <size_t _Size>532template <size_t _Size>
...@@ -591,6 +593,12 @@ protected:...@@ -591,6 +593,12 @@ protected:
591 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; }593 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return 0; }
592 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; }594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const { return 0; }
593595
596 template <bool _Sparse, class _CharT, class _Traits, class _Allocator>
597 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
598 __to_string(_CharT, _CharT) const {
599 return basic_string<_CharT, _Traits, _Allocator>();
600 }
601
594 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; }602 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return true; }
595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; }603 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return false; }
596604
...@@ -602,37 +610,32 @@ inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {}...@@ -602,37 +610,32 @@ inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT {}
602inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {}610inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT {}
603611
604template <size_t _Size>612template <size_t _Size>
605class _LIBCPP_TEMPLATE_VIS bitset;613class bitset;
606template <size_t _Size>614template <size_t _Size>
607struct hash<bitset<_Size> >;615struct hash<bitset<_Size> >;
608616
609template <size_t _Size>617template <size_t _Size>
610class _LIBCPP_TEMPLATE_VIS bitset618class bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
611 : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> {
612public:619public:
613 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;620 static const unsigned __n_words = _Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1;
614 typedef __bitset<__n_words, _Size> __base;621 typedef __bitset<__n_words, _Size> __base;
615
616public:
617 typedef typename __base::reference reference;622 typedef typename __base::reference reference;
618 typedef typename __base::__const_reference __const_reference;623 typedef typename __base::__const_reference __const_reference;
619624
620 // 23.3.5.1 constructors:625 // 23.3.5.1 constructors:
621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}626 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : __base(__v) {}627 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT
628 : __base(sizeof(unsigned long long) * CHAR_BIT <= _Size ? __v : __v & ((1ULL << _Size) - 1)) {}
623 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>629 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
624 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(630 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
625 const _CharT* __str,631 const _CharT* __str,
626# if _LIBCPP_STD_VER >= 26632 size_t __n = basic_string<_CharT>::npos,
627 typename basic_string_view<_CharT>::size_type __n = basic_string_view<_CharT>::npos,
628# else
629 typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
630# endif
631 _CharT __zero = _CharT('0'),633 _CharT __zero = _CharT('0'),
632 _CharT __one = _CharT('1')) {634 _CharT __one = _CharT('1')) {
633635 if (__n == basic_string<_CharT>::npos)
634 size_t __rlen = std::min(__n, char_traits<_CharT>::length(__str));636 __init_from_string_view(basic_string_view<_CharT>(__str), __zero, __one);
635 __init_from_string_view(basic_string_view<_CharT>(__str, __rlen), __zero, __one);637 else
638 __init_from_string_view(basic_string_view<_CharT>(__str, __n), __zero, __one);
636 }639 }
637# if _LIBCPP_STD_VER >= 26640# if _LIBCPP_STD_VER >= 26
638 template <class _CharT, class _Traits>641 template <class _CharT, class _Traits>
...@@ -643,7 +646,7 @@ public:...@@ -643,7 +646,7 @@ public:
643 _CharT __zero = _CharT('0'),646 _CharT __zero = _CharT('0'),
644 _CharT __one = _CharT('1')) {647 _CharT __one = _CharT('1')) {
645 if (__pos > __str.size())648 if (__pos > __str.size())
646 __throw_out_of_range("bitset string pos out of range");649 std::__throw_out_of_range("bitset string pos out of range");
647650
648 size_t __rlen = std::min(__n, __str.size() - __pos);651 size_t __rlen = std::min(__n, __str.size() - __pos);
649 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);652 __init_from_string_view(basic_string_view<_CharT, _Traits>(__str.data() + __pos, __rlen), __zero, __one);
...@@ -694,8 +697,10 @@ public:...@@ -694,8 +697,10 @@ public:
694 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");697 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p < _Size, "bitset::operator[] index out of bounds");
695 return __base::__make_ref(__p);698 return __base::__make_ref(__p);
696 }699 }
697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const;700 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long to_ulong() const { return __base::to_ulong(); }
698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const;701 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long to_ullong() const {
702 return __base::to_ullong();
703 }
699 template <class _CharT, class _Traits, class _Allocator>704 template <class _CharT, class _Traits, class _Allocator>
700 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>705 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
701 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;706 to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const;
...@@ -714,8 +719,8 @@ public:...@@ -714,8 +719,8 @@ public:
714 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;719 _LIBCPP_HIDE_FROM_ABI bool operator!=(const bitset& __rhs) const _NOEXCEPT;
715# endif720# endif
716 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;721 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool test(size_t __pos) const;
717 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT;722 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool all() const _NOEXCEPT { return __base::all(); }
718 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT;723 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool any() const _NOEXCEPT { return __base::any(); }
719 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); }724 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool none() const _NOEXCEPT { return !any(); }
720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT;725 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator<<(size_t __pos) const _NOEXCEPT;
721 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT;726 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset operator>>(size_t __pos) const _NOEXCEPT;
...@@ -734,7 +739,6 @@ private:...@@ -734,7 +739,6 @@ private:
734 _CharT __c = __str[__mp - 1 - __i];739 _CharT __c = __str[__mp - 1 - __i];
735 (*this)[__i] = _Traits::eq(__c, __one);740 (*this)[__i] = _Traits::eq(__c, __one);
736 }741 }
737 std::fill(__base::__make_iter(__i), __base::__make_iter(_Size), false);
738 }742 }
739743
740 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }744 _LIBCPP_HIDE_FROM_ABI size_t __hash_code() const _NOEXCEPT { return __base::__hash_code(); }
...@@ -788,7 +792,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset...@@ -788,7 +792,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset
788template <size_t _Size>792template <size_t _Size>
789_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) {793_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::set(size_t __pos, bool __val) {
790 if (__pos >= _Size)794 if (__pos >= _Size)
791 __throw_out_of_range("bitset set argument out of range");795 std::__throw_out_of_range("bitset set argument out of range");
792796
793 (*this)[__pos] = __val;797 (*this)[__pos] = __val;
794 return *this;798 return *this;
...@@ -803,7 +807,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset...@@ -803,7 +807,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset
803template <size_t _Size>807template <size_t _Size>
804_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) {808_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::reset(size_t __pos) {
805 if (__pos >= _Size)809 if (__pos >= _Size)
806 __throw_out_of_range("bitset reset argument out of range");810 std::__throw_out_of_range("bitset reset argument out of range");
807811
808 (*this)[__pos] = false;812 (*this)[__pos] = false;
809 return *this;813 return *this;
...@@ -825,33 +829,22 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset...@@ -825,33 +829,22 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset
825template <size_t _Size>829template <size_t _Size>
826_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) {830_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>& bitset<_Size>::flip(size_t __pos) {
827 if (__pos >= _Size)831 if (__pos >= _Size)
828 __throw_out_of_range("bitset flip argument out of range");832 std::__throw_out_of_range("bitset flip argument out of range");
829833
830 reference __r = __base::__make_ref(__pos);834 reference __r = __base::__make_ref(__pos);
831 __r = ~__r;835 __r = ~__r;
832 return *this;836 return *this;
833}837}
834838
835template <size_t _Size>
836inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long bitset<_Size>::to_ulong() const {
837 return __base::to_ulong();
838}
839
840template <size_t _Size>
841inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long bitset<_Size>::to_ullong() const {
842 return __base::to_ullong();
843}
844
845template <size_t _Size>839template <size_t _Size>
846template <class _CharT, class _Traits, class _Allocator>840template <class _CharT, class _Traits, class _Allocator>
847_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>841_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 basic_string<_CharT, _Traits, _Allocator>
848bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {842bitset<_Size>::to_string(_CharT __zero, _CharT __one) const {
849 basic_string<_CharT, _Traits, _Allocator> __r(_Size, __zero);843 bool __sparse = size_t(std::count(__base::__make_iter(0), __base::__make_iter(_Size), true)) < _Size / 2;
850 for (size_t __i = 0; __i != _Size; ++__i) {844 if (__sparse)
851 if ((*this)[__i])845 return __base::template __to_string<true, _CharT, _Traits, _Allocator>(__zero, __one);
852 __r[_Size - 1 - __i] = __one;846 else
853 }847 return __base::template __to_string<false, _CharT, _Traits, _Allocator>(__zero, __one);
854 return __r;
855}848}
856849
857template <size_t _Size>850template <size_t _Size>
...@@ -897,21 +890,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs)...@@ -897,21 +890,11 @@ inline _LIBCPP_HIDE_FROM_ABI bool bitset<_Size>::operator!=(const bitset& __rhs)
897template <size_t _Size>890template <size_t _Size>
898_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {891_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::test(size_t __pos) const {
899 if (__pos >= _Size)892 if (__pos >= _Size)
900 __throw_out_of_range("bitset test argument out of range");893 std::__throw_out_of_range("bitset test argument out of range");
901894
902 return (*this)[__pos];895 return (*this)[__pos];
903}896}
904897
905template <size_t _Size>
906inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::all() const _NOEXCEPT {
907 return __base::all();
908}
909
910template <size_t _Size>
911inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bool bitset<_Size>::any() const _NOEXCEPT {
912 return __base::any();
913}
914
915template <size_t _Size>898template <size_t _Size>
916inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>899inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 bitset<_Size>
917bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT {900bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT {
...@@ -953,7 +936,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {...@@ -953,7 +936,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
953}936}
954937
955template <size_t _Size>938template <size_t _Size>
956struct _LIBCPP_TEMPLATE_VIS hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> {939struct hash<bitset<_Size> > : public __unary_function<bitset<_Size>, size_t> {
957 _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); }940 _LIBCPP_HIDE_FROM_ABI size_t operator()(const bitset<_Size>& __bs) const _NOEXCEPT { return __bs.__hash_code(); }
958};941};
959942
...@@ -972,6 +955,7 @@ _LIBCPP_POP_MACROS...@@ -972,6 +955,7 @@ _LIBCPP_POP_MACROS
972# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20955# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
973# include <concepts>956# include <concepts>
974# include <cstdlib>957# include <cstdlib>
958# include <optional>
975# include <type_traits>959# include <type_traits>
976# endif960# endif
977#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)961#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/charconv+1-1
...@@ -76,7 +76,7 @@ namespace std {...@@ -76,7 +76,7 @@ namespace std {
76*/76*/
7777
78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
79# include <__cxx03/charconv>79# include <__cxx03/__config>
80#else80#else
81# include <__config>81# include <__config>
8282
lib/libcxx/include/chrono+88-22
...@@ -132,6 +132,11 @@ public:...@@ -132,6 +132,11 @@ public:
132132
133 // arithmetic133 // arithmetic
134134
135 constexpr time_point& operator++(); // C++20
136 constexpr time_point operator++(int); // C++20
137 constexpr time_point& operator--(); // C++20
138 constexpr time_point operator--(int); // C++20
139
135 time_point& operator+=(const duration& d); // constexpr in C++17140 time_point& operator+=(const duration& d); // constexpr in C++17
136 time_point& operator-=(const duration& d); // constexpr in C++17141 time_point& operator-=(const duration& d); // constexpr in C++17
137142
...@@ -335,6 +340,61 @@ struct leap_second_info { // C++20...@@ -335,6 +340,61 @@ struct leap_second_info { // C++20
335template<class Duration> // C++20340template<class Duration> // C++20
336 leap_second_info get_leap_second_info(const utc_time<Duration>& ut);341 leap_second_info get_leap_second_info(const utc_time<Duration>& ut);
337342
343
344// [time.clock.tai], class tai_clock
345class tai_clock { // C++20
346public:
347 using rep = a signed arithmetic type;
348 using period = ratio<unspecified, unspecified>;
349 using duration = chrono::duration<rep, period>;
350 using time_point = chrono::time_point<tai_clock>;
351 static constexpr bool is_steady = unspecified;
352
353 static time_point now();
354
355 template<class Duration>
356 static utc_time<common_type_t<Duration, seconds>>
357 to_utc(const tai_time<Duration>& t);
358 template<class Duration>
359 static tai_time<common_type_t<Duration, seconds>>
360 from_utc(const utc_time<Duration>& t);
361};
362
363template<class Duration>
364using tai_time = time_point<tai_clock, Duration>; // C++20
365using tai_seconds = tai_time<seconds>; // C++20
366
367template<class charT, class traits, class Duration> // C++20
368 basic_ostream<charT, traits>&
369 operator<<(basic_ostream<charT, traits>& os, const tai_time<Duration>& t);
370
371// [time.clock.gps], class gps_clock
372class gps_clock { // C++20
373public:
374 using rep = a signed arithmetic type;
375 using period = ratio<unspecified, unspecified>;
376 using duration = chrono::duration<rep, period>;
377 using time_point = chrono::time_point<gps_clock>;
378 static constexpr bool is_steady = unspecified;
379
380 static time_point now();
381
382 template<class Duration>
383 static utc_time<common_type_t<Duration, seconds>>
384 to_utc(const gps_time<Duration>& t);
385 template<class Duration>
386 static gps_time<common_type_t<Duration, seconds>>
387 from_utc(const utc_time<Duration>& t);
388};
389
390template<class Duration>
391using gps_time = time_point<gps_clock, Duration>; // C++20
392using gps_seconds = gps_time<seconds>; // C++20
393
394template<class charT, class traits, class Duration> // C++20
395 basic_ostream<charT, traits>&
396 operator<<(basic_ostream<charT, traits>& os, const gps_time<Duration>& t);
397
338class file_clock // C++20398class file_clock // C++20
339{399{
340public:400public:
...@@ -374,7 +434,7 @@ public:...@@ -374,7 +434,7 @@ public:
374434
375typedef steady_clock high_resolution_clock;435typedef steady_clock high_resolution_clock;
376436
377// 25.7.8, local time // C++20437// [time.clock.local] local time // C++20
378struct local_t {};438struct local_t {};
379template<class Duration>439template<class Duration>
380 using local_time = time_point<local_t, Duration>;440 using local_time = time_point<local_t, Duration>;
...@@ -385,10 +445,10 @@ template<class charT, class traits, class Duration> // C++20...@@ -385,10 +445,10 @@ template<class charT, class traits, class Duration> // C++20
385 basic_ostream<charT, traits>&445 basic_ostream<charT, traits>&
386 operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);446 operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);
387447
388// 25.8.2, class last_spec // C++20448// [time.cal.last] class last_spec // C++20
389struct last_spec;449struct last_spec;
390450
391// 25.8.3, class day // C++20451// [time.cal.day] class day // C++20
392452
393class day;453class day;
394constexpr bool operator==(const day& x, const day& y) noexcept;454constexpr bool operator==(const day& x, const day& y) noexcept;
...@@ -401,7 +461,7 @@ template<class charT, class traits>...@@ -401,7 +461,7 @@ template<class charT, class traits>
401 basic_ostream<charT, traits>&461 basic_ostream<charT, traits>&
402 operator<<(basic_ostream<charT, traits>& os, const day& d);462 operator<<(basic_ostream<charT, traits>& os, const day& d);
403463
404// 25.8.4, class month // C++20464// [time.cal.month] class month // C++20
405class month;465class month;
406constexpr bool operator==(const month& x, const month& y) noexcept;466constexpr bool operator==(const month& x, const month& y) noexcept;
407constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;467constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
...@@ -414,7 +474,7 @@ template<class charT, class traits>...@@ -414,7 +474,7 @@ template<class charT, class traits>
414 basic_ostream<charT, traits>&474 basic_ostream<charT, traits>&
415 operator<<(basic_ostream<charT, traits>& os, const month& m);475 operator<<(basic_ostream<charT, traits>& os, const month& m);
416476
417// 25.8.5, class year // C++20477// [time.cal.year] class year // C++20
418class year;478class year;
419constexpr bool operator==(const year& x, const year& y) noexcept;479constexpr bool operator==(const year& x, const year& y) noexcept;
420constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;480constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
...@@ -427,7 +487,7 @@ template<class charT, class traits>...@@ -427,7 +487,7 @@ template<class charT, class traits>
427 basic_ostream<charT, traits>&487 basic_ostream<charT, traits>&
428 operator<<(basic_ostream<charT, traits>& os, const year& y);488 operator<<(basic_ostream<charT, traits>& os, const year& y);
429489
430// 25.8.6, class weekday // C++20490// [time.cal.wd] class weekday // C++20
431class weekday;491class weekday;
432492
433constexpr bool operator==(const weekday& x, const weekday& y) noexcept;493constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
...@@ -439,7 +499,7 @@ template<class charT, class traits>...@@ -439,7 +499,7 @@ template<class charT, class traits>
439 basic_ostream<charT, traits>&499 basic_ostream<charT, traits>&
440 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);500 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
441501
442// 25.8.7, class weekday_indexed // C++20502// [time.cal.wdidx] class weekday_indexed // C++20
443503
444class weekday_indexed;504class weekday_indexed;
445constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;505constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
...@@ -448,7 +508,7 @@ template<class charT, class traits>...@@ -448,7 +508,7 @@ template<class charT, class traits>
448 basic_ostream<charT, traits>&508 basic_ostream<charT, traits>&
449 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);509 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
450510
451// 25.8.8, class weekday_last // C++20511// [time.cal.wdlast] class weekday_last // C++20
452class weekday_last;512class weekday_last;
453513
454constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;514constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
...@@ -457,7 +517,7 @@ template<class charT, class traits>...@@ -457,7 +517,7 @@ template<class charT, class traits>
457 basic_ostream<charT, traits>&517 basic_ostream<charT, traits>&
458 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);518 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
459519
460// 25.8.9, class month_day // C++20520// [time.cal.md] class month_day // C++20
461class month_day;521class month_day;
462522
463constexpr bool operator==(const month_day& x, const month_day& y) noexcept;523constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
...@@ -467,7 +527,7 @@ template<class charT, class traits>...@@ -467,7 +527,7 @@ template<class charT, class traits>
467 basic_ostream<charT, traits>&527 basic_ostream<charT, traits>&
468 operator<<(basic_ostream<charT, traits>& os, const month_day& md);528 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
469529
470// 25.8.10, class month_day_last // C++20530// [time.cal.mdlast] class month_day_last // C++20
471class month_day_last;531class month_day_last;
472532
473constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;533constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
...@@ -477,7 +537,7 @@ template<class charT, class traits>...@@ -477,7 +537,7 @@ template<class charT, class traits>
477 basic_ostream<charT, traits>&537 basic_ostream<charT, traits>&
478 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);538 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
479539
480// 25.8.11, class month_weekday // C++20540// [time.cal.mwd] class month_weekday // C++20
481class month_weekday;541class month_weekday;
482542
483constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;543constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
...@@ -486,7 +546,7 @@ template<class charT, class traits>...@@ -486,7 +546,7 @@ template<class charT, class traits>
486 basic_ostream<charT, traits>&546 basic_ostream<charT, traits>&
487 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);547 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
488548
489// 25.8.12, class month_weekday_last // C++20549// [time.cal.mwdlast] class month_weekday_last // C++20
490class month_weekday_last;550class month_weekday_last;
491551
492constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;552constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
...@@ -496,7 +556,7 @@ template<class charT, class traits>...@@ -496,7 +556,7 @@ template<class charT, class traits>
496 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);556 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
497557
498558
499// 25.8.13, class year_month // C++20559// [time.cal.ym] class year_month // C++20
500class year_month;560class year_month;
501561
502constexpr bool operator==(const year_month& x, const year_month& y) noexcept;562constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
...@@ -514,7 +574,7 @@ template<class charT, class traits>...@@ -514,7 +574,7 @@ template<class charT, class traits>
514 basic_ostream<charT, traits>&574 basic_ostream<charT, traits>&
515 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);575 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
516576
517// 25.8.14, class year_month_day class // C++20577// [time.cal.ymd] class year_month_day class // C++20
518year_month_day;578year_month_day;
519579
520constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;580constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
...@@ -531,7 +591,7 @@ template<class charT, class traits>...@@ -531,7 +591,7 @@ template<class charT, class traits>
531 basic_ostream<charT, traits>&591 basic_ostream<charT, traits>&
532 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);592 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
533593
534// 25.8.15, class year_month_day_last // C++20594// [time.cal.ymdlast] class year_month_day_last // C++20
535class year_month_day_last;595class year_month_day_last;
536596
537constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;597constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
...@@ -554,7 +614,7 @@ template<class charT, class traits>...@@ -554,7 +614,7 @@ template<class charT, class traits>
554 basic_ostream<charT, traits>&614 basic_ostream<charT, traits>&
555 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);615 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
556616
557// 25.8.16, class year_month_weekday // C++20617// [time.cal.ymwd] class year_month_weekday // C++20
558class year_month_weekday;618class year_month_weekday;
559619
560constexpr bool operator==(const year_month_weekday& x,620constexpr bool operator==(const year_month_weekday& x,
...@@ -577,7 +637,7 @@ template<class charT, class traits>...@@ -577,7 +637,7 @@ template<class charT, class traits>
577 basic_ostream<charT, traits>&637 basic_ostream<charT, traits>&
578 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);638 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
579639
580// 25.8.17, class year_month_weekday_last // C++20640// [time.cal.ymwdlast] class year_month_weekday_last // C++20
581class year_month_weekday_last;641class year_month_weekday_last;
582642
583constexpr bool operator==(const year_month_weekday_last& x,643constexpr bool operator==(const year_month_weekday_last& x,
...@@ -599,7 +659,7 @@ template<class charT, class traits>...@@ -599,7 +659,7 @@ template<class charT, class traits>
599 basic_ostream<charT, traits>&659 basic_ostream<charT, traits>&
600 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);660 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
601661
602// 25.8.18, civil calendar conventional syntax operators // C++20662// [time.cal.operators] civil calendar conventional syntax operators // C++20
603constexpr year_month663constexpr year_month
604 operator/(const year& y, const month& m) noexcept;664 operator/(const year& y, const month& m) noexcept;
605constexpr year_month665constexpr year_month
...@@ -790,7 +850,7 @@ template<class charT, class traits>...@@ -790,7 +850,7 @@ template<class charT, class traits>
790 basic_ostream<charT, traits>&850 basic_ostream<charT, traits>&
791 operator<<(basic_ostream<charT, traits>& os, const local_info& li);851 operator<<(basic_ostream<charT, traits>& os, const local_info& li);
792852
793// 25.10.5, class time_zone // C++20853// [time.zone.timezone] class time_zone // C++20
794enum class choose {earliest, latest};854enum class choose {earliest, latest};
795class time_zone {855class time_zone {
796 time_zone(time_zone&&) = default;856 time_zone(time_zone&&) = default;
...@@ -894,16 +954,20 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);...@@ -894,16 +954,20 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);
894} // chrono954} // chrono
895955
896namespace std {956namespace std {
957 template<class Rep, class Period, class charT>
958 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
897 template<class Duration, class charT>959 template<class Duration, class charT>
898 struct formatter<chrono::sys_time<Duration>, charT>; // C++20960 struct formatter<chrono::sys_time<Duration>, charT>; // C++20
899 template<class Duration, class charT>961 template<class Duration, class charT>
900 struct formatter<chrono::utc_time<Duration>, charT>; // C++20962 struct formatter<chrono::utc_time<Duration>, charT>; // C++20
901 template<class Duration, class charT>963 template<class Duration, class charT>
902 struct formatter<chrono::filetime<Duration>, charT>; // C++20964 struct formatter<chrono::tai_time<Duration>, charT>; // C++20
965 template<class Duration, class charT>
966 struct formatter<chrono::gps_time<Duration>, charT>; // C++20
967 template<class Duration, class charT>
968 struct formatter<chrono::file_time<Duration>, charT>; // C++20
903 template<class Duration, class charT>969 template<class Duration, class charT>
904 struct formatter<chrono::local_time<Duration>, charT>; // C++20970 struct formatter<chrono::local_time<Duration>, charT>; // C++20
905 template<class Rep, class Period, class charT>
906 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
907 template<class charT> struct formatter<chrono::day, charT>; // C++20971 template<class charT> struct formatter<chrono::day, charT>; // C++20
908 template<class charT> struct formatter<chrono::month, charT>; // C++20972 template<class charT> struct formatter<chrono::month, charT>; // C++20
909 template<class charT> struct formatter<chrono::year, charT>; // C++20973 template<class charT> struct formatter<chrono::year, charT>; // C++20
...@@ -1013,7 +1077,9 @@ constexpr chrono::year operator ""y(unsigned lo...@@ -1013,7 +1077,9 @@ constexpr chrono::year operator ""y(unsigned lo
1013# endif1077# endif
10141078
1015# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION1079# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
1080# include <__chrono/gps_clock.h>
1016# include <__chrono/leap_second.h>1081# include <__chrono/leap_second.h>
1082# include <__chrono/tai_clock.h>
1017# include <__chrono/time_zone.h>1083# include <__chrono/time_zone.h>
1018# include <__chrono/time_zone_link.h>1084# include <__chrono/time_zone_link.h>
1019# include <__chrono/tzdb.h>1085# include <__chrono/tzdb.h>
lib/libcxx/include/cmath+3-5
...@@ -599,11 +599,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long do...@@ -599,11 +599,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr long double lerp(long double __a, long do
599}599}
600600
601template <class _A1, class _A2, class _A3>601template <class _A1, class _A2, class _A3>
602inline _LIBCPP_HIDE_FROM_ABI constexpr602 requires(is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>)
603 typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value,603_LIBCPP_HIDE_FROM_ABI inline constexpr __promote_t<_A1, _A2, _A3> lerp(_A1 __a, _A2 __b, _A3 __t) noexcept {
604 __promote<_A1, _A2, _A3> >::type604 using __result_type = __promote_t<_A1, _A2, _A3>;
605 lerp(_A1 __a, _A2 __b, _A3 __t) noexcept {
606 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
607 static_assert(!(605 static_assert(!(
608 _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));606 _IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value));
609 return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);607 return std::__lerp((__result_type)__a, (__result_type)__b, (__result_type)__t);
lib/libcxx/include/codecvt+22-17
...@@ -58,14 +58,17 @@ class codecvt_utf8_utf16...@@ -58,14 +58,17 @@ class codecvt_utf8_utf16
58# include <__cxx03/codecvt>58# include <__cxx03/codecvt>
59#else59#else
60# include <__config>60# include <__config>
61# include <__locale>
62# include <version>
6361
64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)62# if _LIBCPP_HAS_LOCALIZATION
65# pragma GCC system_header63
66# endif64# include <__locale>
65# include <version>
6766
68# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)67# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69# endif
70
71# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
6972
70_LIBCPP_BEGIN_NAMESPACE_STD73_LIBCPP_BEGIN_NAMESPACE_STD
7174
...@@ -76,7 +79,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea...@@ -76,7 +79,7 @@ enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_hea
76template <class _Elem>79template <class _Elem>
77class __codecvt_utf8;80class __codecvt_utf8;
7881
79# if _LIBCPP_HAS_WIDE_CHARACTERS82# if _LIBCPP_HAS_WIDE_CHARACTERS
80template <>83template <>
81class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {84class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
82 unsigned long __maxcode_;85 unsigned long __maxcode_;
...@@ -115,7 +118,7 @@ protected:...@@ -115,7 +118,7 @@ protected:
115 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;118 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
116 int do_max_length() const _NOEXCEPT override;119 int do_max_length() const _NOEXCEPT override;
117};120};
118# endif // _LIBCPP_HAS_WIDE_CHARACTERS121# endif // _LIBCPP_HAS_WIDE_CHARACTERS
119122
120_LIBCPP_SUPPRESS_DEPRECATED_PUSH123_LIBCPP_SUPPRESS_DEPRECATED_PUSH
121template <>124template <>
...@@ -193,7 +196,7 @@ protected:...@@ -193,7 +196,7 @@ protected:
193196
194_LIBCPP_SUPPRESS_DEPRECATED_PUSH197_LIBCPP_SUPPRESS_DEPRECATED_PUSH
195template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>198template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
196class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> {199class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8 : public __codecvt_utf8<_Elem> {
197public:200public:
198 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}201 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8(size_t __refs = 0) : __codecvt_utf8<_Elem>(__refs, _Maxcode, _Mode) {}
199202
...@@ -206,7 +209,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -206,7 +209,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
206template <class _Elem, bool _LittleEndian>209template <class _Elem, bool _LittleEndian>
207class __codecvt_utf16;210class __codecvt_utf16;
208211
209# if _LIBCPP_HAS_WIDE_CHARACTERS212# if _LIBCPP_HAS_WIDE_CHARACTERS
210template <>213template <>
211class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> {214class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> {
212 unsigned long __maxcode_;215 unsigned long __maxcode_;
...@@ -284,7 +287,7 @@ protected:...@@ -284,7 +287,7 @@ protected:
284 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;287 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
285 int do_max_length() const _NOEXCEPT override;288 int do_max_length() const _NOEXCEPT override;
286};289};
287# endif // _LIBCPP_HAS_WIDE_CHARACTERS290# endif // _LIBCPP_HAS_WIDE_CHARACTERS
288291
289_LIBCPP_SUPPRESS_DEPRECATED_PUSH292_LIBCPP_SUPPRESS_DEPRECATED_PUSH
290template <>293template <>
...@@ -436,8 +439,7 @@ protected:...@@ -436,8 +439,7 @@ protected:
436439
437_LIBCPP_SUPPRESS_DEPRECATED_PUSH440_LIBCPP_SUPPRESS_DEPRECATED_PUSH
438template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>441template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
439class _LIBCPP_TEMPLATE_VIS442class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> {
440_LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> {
441public:443public:
442 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0)444 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0)
443 : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}445 : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
...@@ -451,7 +453,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -451,7 +453,7 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
451template <class _Elem>453template <class _Elem>
452class __codecvt_utf8_utf16;454class __codecvt_utf8_utf16;
453455
454# if _LIBCPP_HAS_WIDE_CHARACTERS456# if _LIBCPP_HAS_WIDE_CHARACTERS
455template <>457template <>
456class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {458class _LIBCPP_EXPORTED_FROM_ABI __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> {
457 unsigned long __maxcode_;459 unsigned long __maxcode_;
...@@ -490,7 +492,7 @@ protected:...@@ -490,7 +492,7 @@ protected:
490 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;492 int do_length(state_type&, const extern_type* __frm, const extern_type* __end, size_t __mx) const override;
491 int do_max_length() const _NOEXCEPT override;493 int do_max_length() const _NOEXCEPT override;
492};494};
493# endif // _LIBCPP_HAS_WIDE_CHARACTERS495# endif // _LIBCPP_HAS_WIDE_CHARACTERS
494496
495_LIBCPP_SUPPRESS_DEPRECATED_PUSH497_LIBCPP_SUPPRESS_DEPRECATED_PUSH
496template <>498template <>
...@@ -568,7 +570,7 @@ protected:...@@ -568,7 +570,7 @@ protected:
568570
569_LIBCPP_SUPPRESS_DEPRECATED_PUSH571_LIBCPP_SUPPRESS_DEPRECATED_PUSH
570template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>572template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
571class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> {573class _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> {
572public:574public:
573 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8_utf16(size_t __refs = 0)575 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf8_utf16(size_t __refs = 0)
574 : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}576 : __codecvt_utf8_utf16<_Elem>(__refs, _Maxcode, _Mode) {}
...@@ -579,7 +581,9 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP...@@ -579,7 +581,9 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
579581
580_LIBCPP_END_NAMESPACE_STD582_LIBCPP_END_NAMESPACE_STD
581583
582# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)584# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
585
586# endif // _LIBCPP_HAS_LOCALIZATION
583587
584# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20588# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
585# include <atomic>589# include <atomic>
...@@ -592,6 +596,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -592,6 +596,7 @@ _LIBCPP_END_NAMESPACE_STD
592# include <limits>596# include <limits>
593# include <mutex>597# include <mutex>
594# include <new>598# include <new>
599# include <optional>
595# include <stdexcept>600# include <stdexcept>
596# include <type_traits>601# include <type_traits>
597# include <typeinfo>602# include <typeinfo>
lib/libcxx/include/compare+1-1
...@@ -141,7 +141,7 @@ namespace std {...@@ -141,7 +141,7 @@ namespace std {
141*/141*/
142142
143#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)143#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
144# include <__cxx03/compare>144# include <__cxx03/__config>
145#else145#else
146# include <__config>146# include <__config>
147147
lib/libcxx/include/complex+15-15
...@@ -260,6 +260,7 @@ template<class T> complex<T> tanh (const complex<T>&);...@@ -260,6 +260,7 @@ template<class T> complex<T> tanh (const complex<T>&);
260# include <__cxx03/complex>260# include <__cxx03/complex>
261#else261#else
262# include <__config>262# include <__config>
263# include <__cstddef/size_t.h>
263# include <__fwd/complex.h>264# include <__fwd/complex.h>
264# include <__fwd/tuple.h>265# include <__fwd/tuple.h>
265# include <__tuple/tuple_element.h>266# include <__tuple/tuple_element.h>
...@@ -283,7 +284,7 @@ _LIBCPP_PUSH_MACROS...@@ -283,7 +284,7 @@ _LIBCPP_PUSH_MACROS
283_LIBCPP_BEGIN_NAMESPACE_STD284_LIBCPP_BEGIN_NAMESPACE_STD
284285
285template <class _Tp>286template <class _Tp>
286class _LIBCPP_TEMPLATE_VIS complex;287class complex;
287288
288template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>289template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
289_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>290_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
...@@ -302,7 +303,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>...@@ -302,7 +303,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
302operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);303operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
303304
304template <class _Tp>305template <class _Tp>
305class _LIBCPP_TEMPLATE_VIS complex {306class complex {
306public:307public:
307 typedef _Tp value_type;308 typedef _Tp value_type;
308309
...@@ -393,9 +394,9 @@ public:...@@ -393,9 +394,9 @@ public:
393};394};
394395
395template <>396template <>
396class _LIBCPP_TEMPLATE_VIS complex<double>;397class complex<double>;
397template <>398template <>
398class _LIBCPP_TEMPLATE_VIS complex<long double>;399class complex<long double>;
399400
400struct __from_builtin_tag {};401struct __from_builtin_tag {};
401402
...@@ -415,7 +416,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re...@@ -415,7 +416,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re
415}416}
416417
417template <>418template <>
418class _LIBCPP_TEMPLATE_VIS complex<float> {419class complex<float> {
419 float __re_;420 float __re_;
420 float __im_;421 float __im_;
421422
...@@ -512,7 +513,7 @@ public:...@@ -512,7 +513,7 @@ public:
512};513};
513514
514template <>515template <>
515class _LIBCPP_TEMPLATE_VIS complex<double> {516class complex<double> {
516 double __re_;517 double __re_;
517 double __im_;518 double __im_;
518519
...@@ -612,7 +613,7 @@ public:...@@ -612,7 +613,7 @@ public:
612};613};
613614
614template <>615template <>
615class _LIBCPP_TEMPLATE_VIS complex<long double> {616class complex<long double> {
616 long double __re_;617 long double __re_;
617 long double __im_;618 long double __im_;
618619
...@@ -1101,21 +1102,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com...@@ -1101,21 +1102,20 @@ inline _LIBCPP_HIDE_FROM_ABI complex<_Tp> pow(const complex<_Tp>& __x, const com
1101}1102}
11021103
1103template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0>1104template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1104inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type>1105inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const complex<_Up>& __y) {
1105pow(const complex<_Tp>& __x, const complex<_Up>& __y) {1106 typedef complex<__promote_t<_Tp, _Up> > result_type;
1106 typedef complex<typename __promote<_Tp, _Up>::type> result_type;
1107 return std::pow(result_type(__x), result_type(__y));1107 return std::pow(result_type(__x), result_type(__y));
1108}1108}
11091109
1110template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>1110template <class _Tp, class _Up, __enable_if_t<is_floating_point<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
1111inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const complex<_Tp>& __x, const _Up& __y) {1111inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const complex<_Tp>& __x, const _Up& __y) {
1112 typedef complex<typename __promote<_Tp, _Up>::type> result_type;1112 typedef complex<__promote_t<_Tp, _Up> > result_type;
1113 return std::pow(result_type(__x), result_type(__y));1113 return std::pow(result_type(__x), result_type(__y));
1114}1114}
11151115
1116template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0>1116template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_floating_point<_Up>::value, int> = 0>
1117inline _LIBCPP_HIDE_FROM_ABI complex<typename __promote<_Tp, _Up>::type> pow(const _Tp& __x, const complex<_Up>& __y) {1117inline _LIBCPP_HIDE_FROM_ABI complex<__promote_t<_Tp, _Up> > pow(const _Tp& __x, const complex<_Up>& __y) {
1118 typedef complex<typename __promote<_Tp, _Up>::type> result_type;1118 typedef complex<__promote_t<_Tp, _Up> > result_type;
1119 return std::pow(result_type(__x), result_type(__y));1119 return std::pow(result_type(__x), result_type(__y));
1120}1120}
11211121
...@@ -1394,7 +1394,7 @@ struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};...@@ -1394,7 +1394,7 @@ struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};
1394template <size_t _Ip, class _Tp>1394template <size_t _Ip, class _Tp>
1395struct tuple_element<_Ip, complex<_Tp>> {1395struct tuple_element<_Ip, complex<_Tp>> {
1396 static_assert(_Ip < 2, "Index value is out of range.");1396 static_assert(_Ip < 2, "Index value is out of range.");
1397 using type = _Tp;1397 using type _LIBCPP_NODEBUG = _Tp;
1398};1398};
13991399
1400template <size_t _Ip, class _Xp>1400template <size_t _Ip, class _Xp>
lib/libcxx/include/concepts+1-1
...@@ -130,7 +130,7 @@ namespace std {...@@ -130,7 +130,7 @@ namespace std {
130*/130*/
131131
132#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)132#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
133# include <__cxx03/concepts>133# include <__cxx03/__config>
134#else134#else
135# include <__config>135# include <__config>
136136
lib/libcxx/include/condition_variable+31-36
...@@ -147,6 +147,21 @@ _LIBCPP_PUSH_MACROS...@@ -147,6 +147,21 @@ _LIBCPP_PUSH_MACROS
147147
148_LIBCPP_BEGIN_NAMESPACE_STD148_LIBCPP_BEGIN_NAMESPACE_STD
149149
150template <class _Lock>
151struct __unlock_guard {
152 _Lock& __lock_;
153
154 _LIBCPP_HIDE_FROM_ABI __unlock_guard(_Lock& __lock) : __lock_(__lock) { __lock_.unlock(); }
155
156 _LIBCPP_HIDE_FROM_ABI ~__unlock_guard() _NOEXCEPT // turns exception to std::terminate
157 {
158 __lock_.lock();
159 }
160
161 __unlock_guard(const __unlock_guard&) = delete;
162 __unlock_guard& operator=(const __unlock_guard&) = delete;
163};
164
150class _LIBCPP_EXPORTED_FROM_ABI condition_variable_any {165class _LIBCPP_EXPORTED_FROM_ABI condition_variable_any {
151 condition_variable __cv_;166 condition_variable __cv_;
152 shared_ptr<mutex> __mut_;167 shared_ptr<mutex> __mut_;
...@@ -158,13 +173,25 @@ public:...@@ -158,13 +173,25 @@ public:
158 _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT;173 _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT;
159174
160 template <class _Lock>175 template <class _Lock>
161 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS void wait(_Lock& __lock);176 _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock) {
177 shared_ptr<mutex> __mut = __mut_;
178 unique_lock<mutex> __lk(*__mut);
179 __unlock_guard<_Lock> __unlock(__lock);
180 lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t());
181 __cv_.wait(__lk);
182 } // __mut_.unlock(), __lock.lock()
183
162 template <class _Lock, class _Predicate>184 template <class _Lock, class _Predicate>
163 _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock, _Predicate __pred);185 _LIBCPP_HIDE_FROM_ABI void wait(_Lock& __lock, _Predicate __pred);
164186
165 template <class _Lock, class _Clock, class _Duration>187 template <class _Lock, class _Clock, class _Duration>
166 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS cv_status188 _LIBCPP_HIDE_FROM_ABI cv_status wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) {
167 wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t);189 shared_ptr<mutex> __mut = __mut_;
190 unique_lock<mutex> __lk(*__mut);
191 __unlock_guard<_Lock> __unlock(__lock);
192 lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t());
193 return __cv_.wait_until(__lk, __t);
194 } // __mut_.unlock(), __lock.lock()
168195
169 template <class _Lock, class _Clock, class _Duration, class _Predicate>196 template <class _Lock, class _Clock, class _Duration, class _Predicate>
170 bool _LIBCPP_HIDE_FROM_ABI197 bool _LIBCPP_HIDE_FROM_ABI
...@@ -204,45 +231,12 @@ inline void condition_variable_any::notify_all() _NOEXCEPT {...@@ -204,45 +231,12 @@ inline void condition_variable_any::notify_all() _NOEXCEPT {
204 __cv_.notify_all();231 __cv_.notify_all();
205}232}
206233
207template <class _Lock>
208struct __unlock_guard {
209 _Lock& __lock_;
210
211 _LIBCPP_HIDE_FROM_ABI __unlock_guard(_Lock& __lock) : __lock_(__lock) { __lock_.unlock(); }
212
213 _LIBCPP_HIDE_FROM_ABI ~__unlock_guard() _NOEXCEPT // turns exception to std::terminate
214 {
215 __lock_.lock();
216 }
217
218 __unlock_guard(const __unlock_guard&) = delete;
219 __unlock_guard& operator=(const __unlock_guard&) = delete;
220};
221
222template <class _Lock>
223void condition_variable_any::wait(_Lock& __lock) {
224 shared_ptr<mutex> __mut = __mut_;
225 unique_lock<mutex> __lk(*__mut);
226 __unlock_guard<_Lock> __unlock(__lock);
227 lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t());
228 __cv_.wait(__lk);
229} // __mut_.unlock(), __lock.lock()
230
231template <class _Lock, class _Predicate>234template <class _Lock, class _Predicate>
232inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) {235inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) {
233 while (!__pred())236 while (!__pred())
234 wait(__lock);237 wait(__lock);
235}238}
236239
237template <class _Lock, class _Clock, class _Duration>
238cv_status condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t) {
239 shared_ptr<mutex> __mut = __mut_;
240 unique_lock<mutex> __lk(*__mut);
241 __unlock_guard<_Lock> __unlock(__lock);
242 lock_guard<unique_lock<mutex> > __lx(__lk, adopt_lock_t());
243 return __cv_.wait_until(__lk, __t);
244} // __mut_.unlock(), __lock.lock()
245
246template <class _Lock, class _Clock, class _Duration, class _Predicate>240template <class _Lock, class _Clock, class _Duration, class _Predicate>
247inline bool241inline bool
248condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) {242condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred) {
...@@ -363,6 +357,7 @@ _LIBCPP_POP_MACROS...@@ -363,6 +357,7 @@ _LIBCPP_POP_MACROS
363# include <initializer_list>357# include <initializer_list>
364# include <iosfwd>358# include <iosfwd>
365# include <new>359# include <new>
360# include <optional>
366# include <stdexcept>361# include <stdexcept>
367# include <system_error>362# include <system_error>
368# include <type_traits>363# include <type_traits>
lib/libcxx/include/coroutine+1-1
...@@ -39,7 +39,7 @@ struct suspend_always;...@@ -39,7 +39,7 @@ struct suspend_always;
39 */39 */
4040
41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
42# include <__cxx03/coroutine>42# include <__cxx03/__config>
43#else43#else
44# include <__config>44# include <__config>
4545
lib/libcxx/include/cwchar+2-1
...@@ -107,6 +107,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,...@@ -107,6 +107,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
107#else107#else
108# include <__config>108# include <__config>
109# include <__cstddef/size_t.h>109# include <__cstddef/size_t.h>
110# include <__memory/addressof.h>
110# include <__type_traits/copy_cv.h>111# include <__type_traits/copy_cv.h>
111# include <__type_traits/is_constant_evaluated.h>112# include <__type_traits/is_constant_evaluated.h>
112# include <__type_traits/is_equality_comparable.h>113# include <__type_traits/is_equality_comparable.h>
...@@ -237,7 +238,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp...@@ -237,7 +238,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
237# if __has_builtin(__builtin_wmemchr)238# if __has_builtin(__builtin_wmemchr)
238 if (!__libcpp_is_constant_evaluated()) {239 if (!__libcpp_is_constant_evaluated()) {
239 wchar_t __value_buffer = 0;240 wchar_t __value_buffer = 0;
240 __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));241 __builtin_memcpy(&__value_buffer, std::addressof(__value), sizeof(wchar_t));
241 return reinterpret_cast<_Tp*>(242 return reinterpret_cast<_Tp*>(
242 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));243 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
243 }244 }
lib/libcxx/include/deque+35-26
...@@ -59,9 +59,9 @@ public:...@@ -59,9 +59,9 @@ public:
5959
60 deque& operator=(const deque& c);60 deque& operator=(const deque& c);
61 deque& operator=(deque&& c)61 deque& operator=(deque&& c)
62 noexcept(62 noexcept((allocator_traits<allocator_type>::propagate_on_container_move_assignment::value &&
63 allocator_type::propagate_on_container_move_assignment::value &&63 is_nothrow_move_assignable<allocator_type>::value) ||
64 is_nothrow_move_assignable<allocator_type>::value);64 allocator_traits<allocator_type>::is_always_equal::value);
65 deque& operator=(initializer_list<value_type> il);65 deque& operator=(initializer_list<value_type> il);
6666
67 template <class InputIterator>67 template <class InputIterator>
...@@ -230,6 +230,7 @@ template <class T, class Allocator, class Predicate>...@@ -230,6 +230,7 @@ template <class T, class Allocator, class Predicate>
230# include <__type_traits/is_convertible.h>230# include <__type_traits/is_convertible.h>
231# include <__type_traits/is_nothrow_assignable.h>231# include <__type_traits/is_nothrow_assignable.h>
232# include <__type_traits/is_nothrow_constructible.h>232# include <__type_traits/is_nothrow_constructible.h>
233# include <__type_traits/is_replaceable.h>
233# include <__type_traits/is_same.h>234# include <__type_traits/is_same.h>
234# include <__type_traits/is_swappable.h>235# include <__type_traits/is_swappable.h>
235# include <__type_traits/is_trivially_relocatable.h>236# include <__type_traits/is_trivially_relocatable.h>
...@@ -283,7 +284,7 @@ template <class _ValueType,...@@ -283,7 +284,7 @@ template <class _ValueType,
283 __deque_block_size<_ValueType, _DiffType>::value284 __deque_block_size<_ValueType, _DiffType>::value
284# endif285# endif
285 >286 >
286class _LIBCPP_TEMPLATE_VIS __deque_iterator {287class __deque_iterator {
287 typedef _MapPointer __map_iterator;288 typedef _MapPointer __map_iterator;
288289
289public:290public:
...@@ -444,9 +445,9 @@ private:...@@ -444,9 +445,9 @@ private:
444 __ptr_(__p) {}445 __ptr_(__p) {}
445446
446 template <class _Tp, class _Ap>447 template <class _Tp, class _Ap>
447 friend class _LIBCPP_TEMPLATE_VIS deque;448 friend class deque;
448 template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>449 template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp>
449 friend class _LIBCPP_TEMPLATE_VIS __deque_iterator;450 friend class __deque_iterator;
450451
451 template <class>452 template <class>
452 friend struct __segmented_iterator_traits;453 friend struct __segmented_iterator_traits;
...@@ -486,7 +487,7 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,...@@ -486,7 +487,7 @@ const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer,
486 __deque_block_size<_ValueType, _DiffType>::value;487 __deque_block_size<_ValueType, _DiffType>::value;
487488
488template <class _Tp, class _Allocator /*= allocator<_Tp>*/>489template <class _Tp, class _Allocator /*= allocator<_Tp>*/>
489class _LIBCPP_TEMPLATE_VIS deque {490class deque {
490public:491public:
491 // types:492 // types:
492493
...@@ -530,6 +531,10 @@ public:...@@ -530,6 +531,10 @@ public:
530 __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,531 __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
531 deque,532 deque,
532 void>;533 void>;
534 using __replaceable _LIBCPP_NODEBUG =
535 __conditional_t<__is_replaceable_v<__map> && __container_allocator_is_replaceable<__alloc_traits>::value,
536 deque,
537 void>;
533538
534 static_assert(is_nothrow_default_constructible<allocator_type>::value ==539 static_assert(is_nothrow_default_constructible<allocator_type>::value ==
535 is_nothrow_default_constructible<__pointer_allocator>::value,540 is_nothrow_default_constructible<__pointer_allocator>::value,
...@@ -674,9 +679,10 @@ public:...@@ -674,9 +679,10 @@ public:
674679
675 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value);680 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value);
676 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a);681 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
677 _LIBCPP_HIDE_FROM_ABI deque&682 _LIBCPP_HIDE_FROM_ABI deque& operator=(deque&& __c) noexcept(
678 operator=(deque&& __c) noexcept(__alloc_traits::propagate_on_container_move_assignment::value &&683 (__alloc_traits::propagate_on_container_move_assignment::value &&
679 is_nothrow_move_assignable<allocator_type>::value);684 is_nothrow_move_assignable<allocator_type>::value) ||
685 __alloc_traits::is_always_equal::value);
680686
681 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }687 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
682# endif // _LIBCPP_CXX03_LANG688# endif // _LIBCPP_CXX03_LANG
...@@ -924,7 +930,7 @@ private:...@@ -924,7 +930,7 @@ private:
924 (void)__end;930 (void)__end;
925 (void)__annotation_type;931 (void)__annotation_type;
926 (void)__place;932 (void)__place;
927# if _LIBCPP_HAS_ASAN933# if __has_feature(address_sanitizer)
928 // __beg - index of the first item to annotate934 // __beg - index of the first item to annotate
929 // __end - index behind the last item to annotate (so last item + 1)935 // __end - index behind the last item to annotate (so last item + 1)
930 // __annotation_type - __asan_unposion or __asan_poison936 // __annotation_type - __asan_unposion or __asan_poison
...@@ -1017,23 +1023,23 @@ private:...@@ -1017,23 +1023,23 @@ private:
1017 std::__annotate_double_ended_contiguous_container<_Allocator>(1023 std::__annotate_double_ended_contiguous_container<_Allocator>(
1018 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);1024 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);
1019 }1025 }
1020# endif // _LIBCPP_HAS_ASAN1026# endif // __has_feature(address_sanitizer)
1021 }1027 }
10221028
1023 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {1029 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
1024 (void)__current_size;1030 (void)__current_size;
1025# if _LIBCPP_HAS_ASAN1031# if __has_feature(address_sanitizer)
1026 if (__current_size == 0)1032 if (__current_size == 0)
1027 __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved);1033 __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
1028 else {1034 else {
1029 __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved);1035 __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved);
1030 __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved);1036 __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
1031 }1037 }
1032# endif // _LIBCPP_HAS_ASAN1038# endif // __has_feature(address_sanitizer)
1033 }1039 }
10341040
1035 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {1041 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
1036# if _LIBCPP_HAS_ASAN1042# if __has_feature(address_sanitizer)
1037 if (empty()) {1043 if (empty()) {
1038 for (size_t __i = 0; __i < __map_.size(); ++__i) {1044 for (size_t __i = 0; __i < __map_.size(); ++__i) {
1039 __annotate_whole_block(__i, __asan_unposion);1045 __annotate_whole_block(__i, __asan_unposion);
...@@ -1042,19 +1048,19 @@ private:...@@ -1042,19 +1048,19 @@ private:
1042 __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved);1048 __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved);
1043 __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved);1049 __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved);
1044 }1050 }
1045# endif // _LIBCPP_HAS_ASAN1051# endif // __has_feature(address_sanitizer)
1046 }1052 }
10471053
1048 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT {1054 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT {
1049 (void)__n;1055 (void)__n;
1050# if _LIBCPP_HAS_ASAN1056# if __has_feature(address_sanitizer)
1051 __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved);1057 __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved);
1052# endif1058# endif
1053 }1059 }
10541060
1055 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT {1061 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT {
1056 (void)__n;1062 (void)__n;
1057# if _LIBCPP_HAS_ASAN1063# if __has_feature(address_sanitizer)
1058 __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved);1064 __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved);
1059# endif1065# endif
1060 }1066 }
...@@ -1062,7 +1068,7 @@ private:...@@ -1062,7 +1068,7 @@ private:
1062 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT {1068 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT {
1063 (void)__old_size;1069 (void)__old_size;
1064 (void)__old_start;1070 (void)__old_start;
1065# if _LIBCPP_HAS_ASAN1071# if __has_feature(address_sanitizer)
1066 __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved);1072 __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved);
1067# endif1073# endif
1068 }1074 }
...@@ -1070,7 +1076,7 @@ private:...@@ -1070,7 +1076,7 @@ private:
1070 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT {1076 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT {
1071 (void)__old_size;1077 (void)__old_size;
1072 (void)__old_start;1078 (void)__old_start;
1073# if _LIBCPP_HAS_ASAN1079# if __has_feature(address_sanitizer)
1074 __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved);1080 __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved);
1075# endif1081# endif
1076 }1082 }
...@@ -1083,7 +1089,7 @@ private:...@@ -1083,7 +1089,7 @@ private:
1083 __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT {1089 __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT {
1084 (void)__block_index;1090 (void)__block_index;
1085 (void)__annotation_type;1091 (void)__annotation_type;
1086# if _LIBCPP_HAS_ASAN1092# if __has_feature(address_sanitizer)
1087 __map_const_iterator __block_it = __map_.begin() + __block_index;1093 __map_const_iterator __block_it = __map_.begin() + __block_index;
1088 const void* __block_start = std::__to_address(*__block_it);1094 const void* __block_start = std::__to_address(*__block_it);
1089 const void* __block_end = std::__to_address(*__block_it + __block_size);1095 const void* __block_end = std::__to_address(*__block_it + __block_size);
...@@ -1096,7 +1102,7 @@ private:...@@ -1096,7 +1102,7 @@ private:
1096 }1102 }
1097# endif1103# endif
1098 }1104 }
1099# if _LIBCPP_HAS_ASAN1105# if __has_feature(address_sanitizer)
11001106
1101public:1107public:
1102 _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {1108 _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {
...@@ -1158,7 +1164,7 @@ public:...@@ -1158,7 +1164,7 @@ public:
1158 }1164 }
11591165
1160private:1166private:
1161# endif // _LIBCPP_HAS_ASAN1167# endif // __has_feature(address_sanitizer)
1162 _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) {1168 _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) {
1163 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {1169 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
1164 __annotate_whole_block(0, __asan_unposion);1170 __annotate_whole_block(0, __asan_unposion);
...@@ -1379,8 +1385,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca...@@ -1379,8 +1385,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca
13791385
1380template <class _Tp, class _Allocator>1386template <class _Tp, class _Allocator>
1381inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept(1387inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept(
1382 __alloc_traits::propagate_on_container_move_assignment::value &&1388 (__alloc_traits::propagate_on_container_move_assignment::value &&
1383 is_nothrow_move_assignable<allocator_type>::value) {1389 is_nothrow_move_assignable<allocator_type>::value) ||
1390 __alloc_traits::is_always_equal::value) {
1384 __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());1391 __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
1385 return *this;1392 return *this;
1386}1393}
...@@ -2623,7 +2630,9 @@ struct __container_traits<deque<_Tp, _Allocator> > {...@@ -2623,7 +2630,9 @@ struct __container_traits<deque<_Tp, _Allocator> > {
2623 // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a2630 // either end, there are no effects. Otherwise, if an exception is thrown by the move constructor of a
2624 // non-Cpp17CopyInsertable T, the effects are unspecified.2631 // non-Cpp17CopyInsertable T, the effects are unspecified.
2625 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =2632 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
2626 _Or<is_nothrow_move_constructible<_Tp>, __is_cpp17_copy_insertable<_Allocator> >::value;2633 is_nothrow_move_constructible<_Tp>::value || __is_cpp17_copy_insertable_v<_Allocator>;
2634
2635 static _LIBCPP_CONSTEXPR const bool __reservable = false;
2627};2636};
26282637
2629_LIBCPP_END_NAMESPACE_STD2638_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/execution+1-1
...@@ -33,7 +33,7 @@ namespace std {...@@ -33,7 +33,7 @@ namespace std {
33*/33*/
3434
35#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)35#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
36# include <__cxx03/execution>36# include <__cxx03/__config>
37#else37#else
38# include <__config>38# include <__config>
39# include <__type_traits/is_execution_policy.h>39# include <__type_traits/is_execution_policy.h>
lib/libcxx/include/expected+1-1
...@@ -39,7 +39,7 @@ namespace std {...@@ -39,7 +39,7 @@ namespace std {
39*/39*/
4040
41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)41#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
42# include <__cxx03/expected>42# include <__cxx03/__config>
43#else43#else
44# include <__config>44# include <__config>
4545
lib/libcxx/include/experimental/__simd/declaration.h+1-1
...@@ -49,7 +49,7 @@ using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;...@@ -49,7 +49,7 @@ using native = __vec_ext<_LIBCPP_NATIVE_SIMD_WIDTH_IN_BYTES / sizeof(_Tp)>;
49// TODO: make this platform dependent49// TODO: make this platform dependent
50template <class _Tp, size_t _Np, class... _Abis>50template <class _Tp, size_t _Np, class... _Abis>
51struct deduce {51struct deduce {
52 using type = fixed_size<_Np>;52 using type _LIBCPP_NODEBUG = fixed_size<_Np>;
53};53};
5454
55// TODO: make this platform dependent55// TODO: make this platform dependent
lib/libcxx/include/experimental/__simd/utility.h+1-1
...@@ -58,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() {...@@ -58,7 +58,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() {
5858
59template <class _Tp>59template <class _Tp>
60_LIBCPP_HIDE_FROM_ABI auto constexpr __set_all_bits(bool __v) {60_LIBCPP_HIDE_FROM_ABI auto constexpr __set_all_bits(bool __v) {
61 return __v ? (numeric_limits<decltype(__choose_mask_type<_Tp>())>::max()) : 0;61 return __v ? (numeric_limits<decltype(experimental::__choose_mask_type<_Tp>())>::max()) : 0;
62}62}
6363
64template <class _From, class _To, class = void>64template <class _From, class _To, class = void>
lib/libcxx/include/experimental/iterator+7-1
...@@ -53,7 +53,7 @@ namespace std {...@@ -53,7 +53,7 @@ namespace std {
53*/53*/
5454
55#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)55#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
56# include <__cxx03/experimental/iterator>56# include <__cxx03/__config>
57#else57#else
58# include <__config>58# include <__config>
59# include <__memory/addressof.h>59# include <__memory/addressof.h>
...@@ -127,8 +127,14 @@ _LIBCPP_POP_MACROS...@@ -127,8 +127,14 @@ _LIBCPP_POP_MACROS
127# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20127# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
128# include <cstddef>128# include <cstddef>
129# include <iosfwd>129# include <iosfwd>
130# include <optional>
130# include <type_traits>131# include <type_traits>
131# endif132# endif
133
134# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
135# include <locale>
136# endif
137
132#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)138#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
133139
134#endif // _LIBCPP_EXPERIMENTAL_ITERATOR140#endif // _LIBCPP_EXPERIMENTAL_ITERATOR
lib/libcxx/include/experimental/memory+2-2
...@@ -50,15 +50,15 @@ public:...@@ -50,15 +50,15 @@ public:
50*/50*/
5151
52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53# include <__cxx03/experimental/memory>53# include <__cxx03/__config>
54#else54#else
55# include <__config>55# include <__config>
56# include <__cstddef/nullptr_t.h>56# include <__cstddef/nullptr_t.h>
57# include <__cstddef/size_t.h>57# include <__cstddef/size_t.h>
58# include <__functional/hash.h>58# include <__functional/hash.h>
59# include <__functional/operations.h>59# include <__functional/operations.h>
60# include <__type_traits/add_lvalue_reference.h>
61# include <__type_traits/add_pointer.h>60# include <__type_traits/add_pointer.h>
61# include <__type_traits/add_reference.h>
62# include <__type_traits/common_type.h>62# include <__type_traits/common_type.h>
63# include <__type_traits/enable_if.h>63# include <__type_traits/enable_if.h>
64# include <__type_traits/is_convertible.h>64# include <__type_traits/is_convertible.h>
lib/libcxx/include/experimental/propagate_const+1-1
...@@ -108,7 +108,7 @@...@@ -108,7 +108,7 @@
108*/108*/
109109
110#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)110#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
111# include <__cxx03/experimental/propagate_const>111# include <__cxx03/__config>
112#else112#else
113# include <__config>113# include <__config>
114# include <__cstddef/nullptr_t.h>114# include <__cstddef/nullptr_t.h>
lib/libcxx/include/experimental/simd+1-1
...@@ -76,7 +76,7 @@ inline namespace parallelism_v2 {...@@ -76,7 +76,7 @@ inline namespace parallelism_v2 {
76#endif76#endif
7777
78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)78#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
79# include <__cxx03/experimental/simd>79# include <__cxx03/__config>
80#else80#else
81# include <__config>81# include <__config>
82# include <experimental/__simd/aligned_tag.h>82# include <experimental/__simd/aligned_tag.h>
lib/libcxx/include/experimental/type_traits+5-5
...@@ -69,7 +69,7 @@ inline namespace fundamentals_v1 {...@@ -69,7 +69,7 @@ inline namespace fundamentals_v1 {
69 */69 */
7070
71#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)71#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
72# include <__cxx03/experimental/type_traits>72# include <__cxx03/__config>
73#else73#else
74# include <__config>74# include <__config>
7575
...@@ -87,16 +87,16 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS...@@ -87,16 +87,16 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
87// 3.3.2, Other type transformations87// 3.3.2, Other type transformations
88/*88/*
89template <class>89template <class>
90class _LIBCPP_TEMPLATE_VIS raw_invocation_type;90class raw_invocation_type;
9191
92template <class _Fn, class ..._Args>92template <class _Fn, class ..._Args>
93class _LIBCPP_TEMPLATE_VIS raw_invocation_type<_Fn(_Args...)>;93class raw_invocation_type<_Fn(_Args...)>;
9494
95template <class>95template <class>
96class _LIBCPP_TEMPLATE_VIS invokation_type;96class invokation_type;
9797
98template <class _Fn, class ..._Args>98template <class _Fn, class ..._Args>
99class _LIBCPP_TEMPLATE_VIS invokation_type<_Fn(_Args...)>;99class invokation_type<_Fn(_Args...)>;
100100
101template <class _Tp>101template <class _Tp>
102using invokation_type_t = typename invokation_type<_Tp>::type;102using invokation_type_t = typename invokation_type<_Tp>::type;
lib/libcxx/include/experimental/utility+1-1
...@@ -42,7 +42,7 @@ inline namespace fundamentals_v1 {...@@ -42,7 +42,7 @@ inline namespace fundamentals_v1 {
4242
43_LIBCPP_BEGIN_NAMESPACE_LFTS43_LIBCPP_BEGIN_NAMESPACE_LFTS
4444
45struct _LIBCPP_TEMPLATE_VIS erased_type {};45struct erased_type {};
4646
47_LIBCPP_END_NAMESPACE_LFTS47_LIBCPP_END_NAMESPACE_LFTS
4848
lib/libcxx/include/ext/__hash+12-12
...@@ -20,64 +20,64 @@...@@ -20,64 +20,64 @@
20namespace __gnu_cxx {20namespace __gnu_cxx {
2121
22template <typename _Tp>22template <typename _Tp>
23struct _LIBCPP_TEMPLATE_VIS hash {};23struct hash {};
2424
25template <>25template <>
26struct _LIBCPP_TEMPLATE_VIS hash<const char*> : public std::__unary_function<const char*, size_t> {26struct hash<const char*> : public std::__unary_function<const char*, size_t> {
27 _LIBCPP_HIDE_FROM_ABI size_t operator()(const char* __c) const _NOEXCEPT {27 _LIBCPP_HIDE_FROM_ABI size_t operator()(const char* __c) const _NOEXCEPT {
28 return std::__do_string_hash(__c, __c + strlen(__c));28 return std::__do_string_hash(__c, __c + strlen(__c));
29 }29 }
30};30};
3131
32template <>32template <>
33struct _LIBCPP_TEMPLATE_VIS hash<char*> : public std::__unary_function<char*, size_t> {33struct hash<char*> : public std::__unary_function<char*, size_t> {
34 _LIBCPP_HIDE_FROM_ABI size_t operator()(char* __c) const _NOEXCEPT {34 _LIBCPP_HIDE_FROM_ABI size_t operator()(char* __c) const _NOEXCEPT {
35 return std::__do_string_hash<const char*>(__c, __c + strlen(__c));35 return std::__do_string_hash<const char*>(__c, __c + strlen(__c));
36 }36 }
37};37};
3838
39template <>39template <>
40struct _LIBCPP_TEMPLATE_VIS hash<char> : public std::__unary_function<char, size_t> {40struct hash<char> : public std::__unary_function<char, size_t> {
41 _LIBCPP_HIDE_FROM_ABI size_t operator()(char __c) const _NOEXCEPT { return __c; }41 _LIBCPP_HIDE_FROM_ABI size_t operator()(char __c) const _NOEXCEPT { return __c; }
42};42};
4343
44template <>44template <>
45struct _LIBCPP_TEMPLATE_VIS hash<signed char> : public std::__unary_function<signed char, size_t> {45struct hash<signed char> : public std::__unary_function<signed char, size_t> {
46 _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __c) const _NOEXCEPT { return __c; }46 _LIBCPP_HIDE_FROM_ABI size_t operator()(signed char __c) const _NOEXCEPT { return __c; }
47};47};
4848
49template <>49template <>
50struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public std::__unary_function<unsigned char, size_t> {50struct hash<unsigned char> : public std::__unary_function<unsigned char, size_t> {
51 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __c) const _NOEXCEPT { return __c; }51 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __c) const _NOEXCEPT { return __c; }
52};52};
5353
54template <>54template <>
55struct _LIBCPP_TEMPLATE_VIS hash<short> : public std::__unary_function<short, size_t> {55struct hash<short> : public std::__unary_function<short, size_t> {
56 _LIBCPP_HIDE_FROM_ABI size_t operator()(short __c) const _NOEXCEPT { return __c; }56 _LIBCPP_HIDE_FROM_ABI size_t operator()(short __c) const _NOEXCEPT { return __c; }
57};57};
5858
59template <>59template <>
60struct _LIBCPP_TEMPLATE_VIS hash<unsigned short> : public std::__unary_function<unsigned short, size_t> {60struct hash<unsigned short> : public std::__unary_function<unsigned short, size_t> {
61 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __c) const _NOEXCEPT { return __c; }61 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned short __c) const _NOEXCEPT { return __c; }
62};62};
6363
64template <>64template <>
65struct _LIBCPP_TEMPLATE_VIS hash<int> : public std::__unary_function<int, size_t> {65struct hash<int> : public std::__unary_function<int, size_t> {
66 _LIBCPP_HIDE_FROM_ABI size_t operator()(int __c) const _NOEXCEPT { return __c; }66 _LIBCPP_HIDE_FROM_ABI size_t operator()(int __c) const _NOEXCEPT { return __c; }
67};67};
6868
69template <>69template <>
70struct _LIBCPP_TEMPLATE_VIS hash<unsigned int> : public std::__unary_function<unsigned int, size_t> {70struct hash<unsigned int> : public std::__unary_function<unsigned int, size_t> {
71 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __c) const _NOEXCEPT { return __c; }71 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned int __c) const _NOEXCEPT { return __c; }
72};72};
7373
74template <>74template <>
75struct _LIBCPP_TEMPLATE_VIS hash<long> : public std::__unary_function<long, size_t> {75struct hash<long> : public std::__unary_function<long, size_t> {
76 _LIBCPP_HIDE_FROM_ABI size_t operator()(long __c) const _NOEXCEPT { return __c; }76 _LIBCPP_HIDE_FROM_ABI size_t operator()(long __c) const _NOEXCEPT { return __c; }
77};77};
7878
79template <>79template <>
80struct _LIBCPP_TEMPLATE_VIS hash<unsigned long> : public std::__unary_function<unsigned long, size_t> {80struct hash<unsigned long> : public std::__unary_function<unsigned long, size_t> {
81 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __c) const _NOEXCEPT { return __c; }81 _LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned long __c) const _NOEXCEPT { return __c; }
82};82};
83} // namespace __gnu_cxx83} // namespace __gnu_cxx
lib/libcxx/include/ext/hash_map+17-17
...@@ -338,7 +338,7 @@ public:...@@ -338,7 +338,7 @@ public:
338};338};
339339
340template <class _HashIterator>340template <class _HashIterator>
341class _LIBCPP_TEMPLATE_VIS __hash_map_iterator {341class __hash_map_iterator {
342 _HashIterator __i_;342 _HashIterator __i_;
343343
344 typedef const typename _HashIterator::value_type::first_type key_type;344 typedef const typename _HashIterator::value_type::first_type key_type;
...@@ -376,19 +376,19 @@ public:...@@ -376,19 +376,19 @@ public:
376 }376 }
377377
378 template <class, class, class, class, class>378 template <class, class, class, class, class>
379 friend class _LIBCPP_TEMPLATE_VIS hash_map;379 friend class hash_map;
380 template <class, class, class, class, class>380 template <class, class, class, class, class>
381 friend class _LIBCPP_TEMPLATE_VIS hash_multimap;381 friend class hash_multimap;
382 template <class>382 template <class>
383 friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;383 friend class __hash_const_iterator;
384 template <class>384 template <class>
385 friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;385 friend class __hash_const_local_iterator;
386 template <class>386 template <class>
387 friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;387 friend class __hash_map_const_iterator;
388};388};
389389
390template <class _HashIterator>390template <class _HashIterator>
391class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator {391class __hash_map_const_iterator {
392 _HashIterator __i_;392 _HashIterator __i_;
393393
394 typedef const typename _HashIterator::value_type::first_type key_type;394 typedef const typename _HashIterator::value_type::first_type key_type;
...@@ -430,13 +430,13 @@ public:...@@ -430,13 +430,13 @@ public:
430 }430 }
431431
432 template <class, class, class, class, class>432 template <class, class, class, class, class>
433 friend class _LIBCPP_TEMPLATE_VIS hash_map;433 friend class hash_map;
434 template <class, class, class, class, class>434 template <class, class, class, class, class>
435 friend class _LIBCPP_TEMPLATE_VIS hash_multimap;435 friend class hash_multimap;
436 template <class>436 template <class>
437 friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;437 friend class __hash_const_iterator;
438 template <class>438 template <class>
439 friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;439 friend class __hash_const_local_iterator;
440};440};
441441
442template <class _Key,442template <class _Key,
...@@ -444,7 +444,7 @@ template <class _Key,...@@ -444,7 +444,7 @@ template <class _Key,
444 class _Hash = hash<_Key>,444 class _Hash = hash<_Key>,
445 class _Pred = std::equal_to<_Key>,445 class _Pred = std::equal_to<_Key>,
446 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >446 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
447class _LIBCPP_TEMPLATE_VIS hash_map {447class hash_map {
448public:448public:
449 // types449 // types
450 typedef _Key key_type;450 typedef _Key key_type;
...@@ -520,7 +520,7 @@ public:...@@ -520,7 +520,7 @@ public:
520 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }520 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
521521
522 _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) {522 _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) {
523 return __table_.__insert_unique(__x);523 return __table_.__emplace_unique(__x);
524 }524 }
525 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }525 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
526 template <class _InputIterator>526 template <class _InputIterator>
...@@ -625,7 +625,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -625,7 +625,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
625template <class _InputIterator>625template <class _InputIterator>
626inline void hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {626inline void hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
627 for (; __first != __last; ++__first)627 for (; __first != __last; ++__first)
628 __table_.__insert_unique(*__first);628 __table_.__emplace_unique(*__first);
629}629}
630630
631template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>631template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -670,7 +670,7 @@ template <class _Key,...@@ -670,7 +670,7 @@ template <class _Key,
670 class _Hash = hash<_Key>,670 class _Hash = hash<_Key>,
671 class _Pred = std::equal_to<_Key>,671 class _Pred = std::equal_to<_Key>,
672 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >672 class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
673class _LIBCPP_TEMPLATE_VIS hash_multimap {673class hash_multimap {
674public:674public:
675 // types675 // types
676 typedef _Key key_type;676 typedef _Key key_type;
...@@ -744,7 +744,7 @@ public:...@@ -744,7 +744,7 @@ public:
744 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); }744 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); }
745 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }745 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
746746
747 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }747 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); }
748 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); }748 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); }
749 template <class _InputIterator>749 template <class _InputIterator>
750 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);750 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
...@@ -831,7 +831,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -831,7 +831,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
831template <class _InputIterator>831template <class _InputIterator>
832inline void hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {832inline void hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
833 for (; __first != __last; ++__first)833 for (; __first != __last; ++__first)
834 __table_.__insert_multi(*__first);834 __table_.__emplace_multi(*__first);
835}835}
836836
837template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>837template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
lib/libcxx/include/ext/hash_set+6-6
...@@ -219,7 +219,7 @@ template <class _Value,...@@ -219,7 +219,7 @@ template <class _Value,
219 class _Hash = hash<_Value>,219 class _Hash = hash<_Value>,
220 class _Pred = std::equal_to<_Value>,220 class _Pred = std::equal_to<_Value>,
221 class _Alloc = std::allocator<_Value> >221 class _Alloc = std::allocator<_Value> >
222class _LIBCPP_TEMPLATE_VIS hash_set {222class hash_set {
223public:223public:
224 // types224 // types
225 typedef _Value key_type;225 typedef _Value key_type;
...@@ -279,7 +279,7 @@ public:...@@ -279,7 +279,7 @@ public:
279 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }279 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
280280
281 _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) {281 _LIBCPP_HIDE_FROM_ABI std::pair<iterator, bool> insert(const value_type& __x) {
282 return __table_.__insert_unique(__x);282 return __table_.__emplace_unique(__x);
283 }283 }
284 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }284 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
285 template <class _InputIterator>285 template <class _InputIterator>
...@@ -365,7 +365,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -365,7 +365,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
365template <class _InputIterator>365template <class _InputIterator>
366inline void hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {366inline void hash_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
367 for (; __first != __last; ++__first)367 for (; __first != __last; ++__first)
368 __table_.__insert_unique(*__first);368 __table_.__emplace_unique(*__first);
369}369}
370370
371template <class _Value, class _Hash, class _Pred, class _Alloc>371template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -398,7 +398,7 @@ template <class _Value,...@@ -398,7 +398,7 @@ template <class _Value,
398 class _Hash = hash<_Value>,398 class _Hash = hash<_Value>,
399 class _Pred = std::equal_to<_Value>,399 class _Pred = std::equal_to<_Value>,
400 class _Alloc = std::allocator<_Value> >400 class _Alloc = std::allocator<_Value> >
401class _LIBCPP_TEMPLATE_VIS hash_multiset {401class hash_multiset {
402public:402public:
403 // types403 // types
404 typedef _Value key_type;404 typedef _Value key_type;
...@@ -458,7 +458,7 @@ public:...@@ -458,7 +458,7 @@ public:
458 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); }458 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const { return __table_.begin(); }
459 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }459 _LIBCPP_HIDE_FROM_ABI const_iterator end() const { return __table_.end(); }
460460
461 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }461 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); }
462 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); }462 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x); }
463 template <class _InputIterator>463 template <class _InputIterator>
464 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);464 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last);
...@@ -543,7 +543,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -543,7 +543,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
543template <class _InputIterator>543template <class _InputIterator>
544inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {544inline void hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
545 for (; __first != __last; ++__first)545 for (; __first != __last; ++__first)
546 __table_.__insert_multi(*__first);546 __table_.__emplace_multi(*__first);
547}547}
548548
549template <class _Value, class _Hash, class _Pred, class _Alloc>549template <class _Value, class _Hash, class _Pred, class _Alloc>
lib/libcxx/include/filesystem+1-1
...@@ -534,7 +534,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct...@@ -534,7 +534,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
534*/534*/
535535
536#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)536#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
537# include <__cxx03/filesystem>537# include <__cxx03/__config>
538#else538#else
539# include <__config>539# include <__config>
540540
lib/libcxx/include/flat_map+9
...@@ -72,6 +72,15 @@ namespace std {...@@ -72,6 +72,15 @@ namespace std {
72# include <version>72# include <version>
7373
74// standard required includes74// standard required includes
75
76// [iterator.range]
77# include <__iterator/access.h>
78# include <__iterator/data.h>
79# include <__iterator/empty.h>
80# include <__iterator/reverse_access.h>
81# include <__iterator/size.h>
82
83// [flat.map.syn]
75# include <compare>84# include <compare>
76# include <initializer_list>85# include <initializer_list>
7786
lib/libcxx/include/flat_set created+85
...@@ -0,0 +1,85 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_FLAT_SET
11#define _LIBCPP_FLAT_SET
12
13/*
14 Header <flat_set> synopsis
15
16#include <compare> // see [compare.syn]
17#include <initializer_list> // see [initializer.list.syn]
18
19namespace std {
20 // [flat.set], class template flat_set
21 template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
22 class flat_set;
23
24 struct sorted_unique_t { explicit sorted_unique_t() = default; };
25 inline constexpr sorted_unique_t sorted_unique{};
26
27 template<class Key, class Compare, class KeyContainer, class Allocator>
28 struct uses_allocator<flat_set<Key, Compare, KeyContainer>, Allocator>;
29
30 // [flat.set.erasure], erasure for flat_set
31 template<class Key, class Compare, class KeyContainer, class Predicate>
32 typename flat_set<Key, Compare, KeyContainer>::size_type
33 erase_if(flat_set<Key, Compare, KeyContainer>& c, Predicate pred);
34
35 // [flat.multiset], class template flat_multiset
36 template<class Key, class Compare = less<Key>, class KeyContainer = vector<Key>>
37 class flat_multiset;
38
39 struct sorted_equivalent_t { explicit sorted_equivalent_t() = default; };
40 inline constexpr sorted_equivalent_t sorted_equivalent{};
41
42 template<class Key, class Compare, class KeyContainer, class Allocator>
43 struct uses_allocator<flat_multiset<Key, Compare, KeyContainer>, Allocator>;
44
45 // [flat.multiset.erasure], erasure for flat_multiset
46 template<class Key, class Compare, class KeyContainer, class Predicate>
47 typename flat_multiset<Key, Compare, KeyContainer>::size_type
48 erase_if(flat_multiset<Key, Compare, KeyContainer>& c, Predicate pred);
49}
50*/
51
52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53# include <__cxx03/__config>
54#else
55# include <__config>
56
57# if _LIBCPP_STD_VER >= 23
58# include <__flat_map/sorted_equivalent.h>
59# include <__flat_map/sorted_unique.h>
60# include <__flat_set/flat_multiset.h>
61# include <__flat_set/flat_set.h>
62# endif
63
64// for feature-test macros
65# include <version>
66
67// standard required includes
68
69// [iterator.range]
70# include <__iterator/access.h>
71# include <__iterator/data.h>
72# include <__iterator/empty.h>
73# include <__iterator/reverse_access.h>
74# include <__iterator/size.h>
75
76// [flat.set.syn]
77# include <compare>
78# include <initializer_list>
79
80# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
81# pragma GCC system_header
82# endif
83#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
84
85#endif // _LIBCPP_FLAT_SET
lib/libcxx/include/format+1-1
...@@ -192,7 +192,7 @@ namespace std {...@@ -192,7 +192,7 @@ namespace std {
192*/192*/
193193
194#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)194#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
195# include <__cxx03/format>195# include <__cxx03/__config>
196#else196#else
197# include <__config>197# include <__config>
198198
lib/libcxx/include/forward_list+325-284
...@@ -58,9 +58,9 @@ public:...@@ -58,9 +58,9 @@ public:
5858
59 forward_list& operator=(const forward_list& x);59 forward_list& operator=(const forward_list& x);
60 forward_list& operator=(forward_list&& x)60 forward_list& operator=(forward_list&& x)
61 noexcept(61 noexcept((__node_traits::propagate_on_container_move_assignment::value &&
62 allocator_type::propagate_on_container_move_assignment::value &&62 is_nothrow_move_assignable<allocator_type>::value) ||
63 is_nothrow_move_assignable<allocator_type>::value);63 allocator_traits<allocator_type>::is_always_equal::value);
64 forward_list& operator=(initializer_list<value_type> il);64 forward_list& operator=(initializer_list<value_type> il);
6565
66 template <class InputIterator>66 template <class InputIterator>
...@@ -233,6 +233,7 @@ template <class T, class Allocator, class Predicate>...@@ -233,6 +233,7 @@ template <class T, class Allocator, class Predicate>
233# include <__type_traits/is_pointer.h>233# include <__type_traits/is_pointer.h>
234# include <__type_traits/is_same.h>234# include <__type_traits/is_same.h>
235# include <__type_traits/is_swappable.h>235# include <__type_traits/is_swappable.h>
236# include <__type_traits/remove_cv.h>
236# include <__type_traits/type_identity.h>237# include <__type_traits/type_identity.h>
237# include <__utility/forward.h>238# include <__utility/forward.h>
238# include <__utility/move.h>239# include <__utility/move.h>
...@@ -282,7 +283,6 @@ struct __forward_node_traits {...@@ -282,7 +283,6 @@ struct __forward_node_traits {
282 typedef _NodePtr __node_pointer;283 typedef _NodePtr __node_pointer;
283 typedef __forward_begin_node<_NodePtr> __begin_node;284 typedef __forward_begin_node<_NodePtr> __begin_node;
284 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;285 typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer;
285 typedef __rebind_pointer_t<_NodePtr, void> __void_pointer;
286286
287// TODO(LLVM 22): Remove this check287// TODO(LLVM 22): Remove this check
288# ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB288# ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
...@@ -294,11 +294,6 @@ struct __forward_node_traits {...@@ -294,11 +294,6 @@ struct __forward_node_traits {
294 "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define "294 "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define "
295 "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");295 "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
296# endif296# endif
297
298 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; }
299 _LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
300 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p));
301 }
302};297};
303298
304template <class _NodePtr>299template <class _NodePtr>
...@@ -308,12 +303,8 @@ struct __forward_begin_node {...@@ -308,12 +303,8 @@ struct __forward_begin_node {
308303
309 pointer __next_;304 pointer __next_;
310305
311 _LIBCPP_HIDE_FROM_ABI __forward_begin_node() : __next_(nullptr) {}306 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_begin_node() : __next_(nullptr) {}
312 _LIBCPP_HIDE_FROM_ABI explicit __forward_begin_node(pointer __n) : __next_(__n) {}307 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_begin_node(pointer __n) : __next_(__n) {}
313
314 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __next_as_begin() const {
315 return static_cast<__begin_node_pointer>(__next_);
316 }
317};308};
318309
319template <class _Tp, class _VoidPtr>310template <class _Tp, class _VoidPtr>
...@@ -336,7 +327,7 @@ private:...@@ -336,7 +327,7 @@ private:
336 };327 };
337328
338public:329public:
339 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }330 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
340# else331# else
341332
342private:333private:
...@@ -346,43 +337,38 @@ public:...@@ -346,43 +337,38 @@ public:
346 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }337 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return *std::__launder(reinterpret_cast<_Tp*>(&__buffer_)); }
347# endif338# endif
348339
349 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {}340 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_node(_NodePtr __next) : _Base(__next) {}
350 _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {}341 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__forward_list_node() {}
351};342};
352343
353template <class _Tp, class _Alloc = allocator<_Tp> >344template <class _Tp, class _Alloc = allocator<_Tp> >
354class _LIBCPP_TEMPLATE_VIS forward_list;345class forward_list;
355template <class _NodeConstPtr>346template <class _NodeConstPtr>
356class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;347class __forward_list_const_iterator;
357348
358template <class _NodePtr>349template <class _NodePtr>
359class _LIBCPP_TEMPLATE_VIS __forward_list_iterator {350class __forward_list_iterator {
360 typedef __forward_node_traits<_NodePtr> __traits;351 typedef __forward_node_traits<_NodePtr> __traits;
352 typedef typename __traits::__node_type __node_type;
353 typedef typename __traits::__begin_node __begin_node_type;
361 typedef typename __traits::__node_pointer __node_pointer;354 typedef typename __traits::__node_pointer __node_pointer;
362 typedef typename __traits::__begin_node_pointer __begin_node_pointer;355 typedef typename __traits::__begin_node_pointer __begin_node_pointer;
363 typedef typename __traits::__void_pointer __void_pointer;
364356
365 __begin_node_pointer __ptr_;357 __begin_node_pointer __ptr_;
366358
367 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {359 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT
368 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));360 : __ptr_(nullptr) {}
369 }
370 _LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const {
371 return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_));
372 }
373
374 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
375361
376 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT362 _LIBCPP_CONSTEXPR_SINCE_CXX26
377 : __ptr_(__traits::__as_iter_node(__p)) {}363 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
378364
379 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT365 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
380 : __ptr_(__traits::__as_iter_node(__p)) {}366 : __ptr_(std::__static_fancy_pointer_cast<__begin_node_pointer>(__p)) {}
381367
382 template <class, class>368 template <class, class>
383 friend class _LIBCPP_TEMPLATE_VIS forward_list;369 friend class forward_list;
384 template <class>370 template <class>
385 friend class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator;371 friend class __forward_list_const_iterator;
386372
387public:373public:
388 typedef forward_iterator_tag iterator_category;374 typedef forward_iterator_tag iterator_category;
...@@ -391,58 +377,57 @@ public:...@@ -391,58 +377,57 @@ public:
391 typedef typename pointer_traits<__node_pointer>::difference_type difference_type;377 typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
392 typedef __rebind_pointer_t<__node_pointer, value_type> pointer;378 typedef __rebind_pointer_t<__node_pointer, value_type> pointer;
393379
394 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}380 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
395381
396 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_unsafe_node_pointer()->__get_value(); }382 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
397 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {383 return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value();
398 return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__get_value());384 }
385 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
386 return pointer_traits<pointer>::pointer_to(std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value());
399 }387 }
400388
401 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator& operator++() {389 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator& operator++() {
402 __ptr_ = __traits::__as_iter_node(__ptr_->__next_);390 __ptr_ = std::__static_fancy_pointer_cast<__begin_node_pointer>(__ptr_->__next_);
403 return *this;391 return *this;
404 }392 }
405 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator operator++(int) {393 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_iterator operator++(int) {
406 __forward_list_iterator __t(*this);394 __forward_list_iterator __t(*this);
407 ++(*this);395 ++(*this);
408 return __t;396 return __t;
409 }397 }
410398
411 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {399 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
400 operator==(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {
412 return __x.__ptr_ == __y.__ptr_;401 return __x.__ptr_ == __y.__ptr_;
413 }402 }
414 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {403 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
404 operator!=(const __forward_list_iterator& __x, const __forward_list_iterator& __y) {
415 return !(__x == __y);405 return !(__x == __y);
416 }406 }
417};407};
418408
419template <class _NodeConstPtr>409template <class _NodeConstPtr>
420class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {410class __forward_list_const_iterator {
421 static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, "");411 static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, "");
422 typedef _NodeConstPtr _NodePtr;412 typedef _NodeConstPtr _NodePtr;
423413
424 typedef __forward_node_traits<_NodePtr> __traits;414 typedef __forward_node_traits<_NodePtr> __traits;
425 typedef typename __traits::__node_type __node_type;415 typedef typename __traits::__node_type __node_type;
416 typedef typename __traits::__begin_node __begin_node_type;
426 typedef typename __traits::__node_pointer __node_pointer;417 typedef typename __traits::__node_pointer __node_pointer;
427 typedef typename __traits::__begin_node_pointer __begin_node_pointer;418 typedef typename __traits::__begin_node_pointer __begin_node_pointer;
428 typedef typename __traits::__void_pointer __void_pointer;
429419
430 __begin_node_pointer __ptr_;420 __begin_node_pointer __ptr_;
431421
432 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __get_begin() const {422 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT
433 return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__ptr_));423 : __ptr_(nullptr) {}
434 }
435 _LIBCPP_HIDE_FROM_ABI __node_pointer __get_unsafe_node_pointer() const {
436 return static_cast<__node_pointer>(static_cast<__void_pointer>(__ptr_));
437 }
438
439 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}
440424
441 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT425 _LIBCPP_CONSTEXPR_SINCE_CXX26
442 : __ptr_(__traits::__as_iter_node(__p)) {}426 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
443427
428 _LIBCPP_CONSTEXPR_SINCE_CXX26
444 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT429 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT
445 : __ptr_(__traits::__as_iter_node(__p)) {}430 : __ptr_(std::__static_fancy_pointer_cast<__begin_node_pointer>(__p)) {}
446431
447 template <class, class>432 template <class, class>
448 friend class forward_list;433 friend class forward_list;
...@@ -454,30 +439,32 @@ public:...@@ -454,30 +439,32 @@ public:
454 typedef typename pointer_traits<__node_pointer>::difference_type difference_type;439 typedef typename pointer_traits<__node_pointer>::difference_type difference_type;
455 typedef __rebind_pointer_t<__node_pointer, const value_type> pointer;440 typedef __rebind_pointer_t<__node_pointer, const value_type> pointer;
456441
457 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}442 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
458 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT443 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
459 : __ptr_(__p.__ptr_) {}444 __forward_list_const_iterator(__forward_list_iterator<__node_pointer> __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
460445
461 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_unsafe_node_pointer()->__get_value(); }446 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
462 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {447 return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value();
463 return pointer_traits<pointer>::pointer_to(__get_unsafe_node_pointer()->__get_value());448 }
449 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
450 return pointer_traits<pointer>::pointer_to(std::__static_fancy_pointer_cast<__node_pointer>(__ptr_)->__get_value());
464 }451 }
465452
466 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator& operator++() {453 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator& operator++() {
467 __ptr_ = __traits::__as_iter_node(__ptr_->__next_);454 __ptr_ = std::__static_fancy_pointer_cast<__begin_node_pointer>(__ptr_->__next_);
468 return *this;455 return *this;
469 }456 }
470 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator operator++(int) {457 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_const_iterator operator++(int) {
471 __forward_list_const_iterator __t(*this);458 __forward_list_const_iterator __t(*this);
472 ++(*this);459 ++(*this);
473 return __t;460 return __t;
474 }461 }
475462
476 friend _LIBCPP_HIDE_FROM_ABI bool463 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
477 operator==(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {464 operator==(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {
478 return __x.__ptr_ == __y.__ptr_;465 return __x.__ptr_ == __y.__ptr_;
479 }466 }
480 friend _LIBCPP_HIDE_FROM_ABI bool467 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
481 operator!=(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {468 operator!=(const __forward_list_const_iterator& __x, const __forward_list_const_iterator& __y) {
482 return !(__x == __y);469 return !(__x == __y);
483 }470 }
...@@ -501,48 +488,53 @@ protected:...@@ -501,48 +488,53 @@ protected:
501488
502 _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_);489 _LIBCPP_COMPRESSED_PAIR(__begin_node, __before_begin_, __node_allocator, __alloc_);
503490
504 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT {491 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() _NOEXCEPT {
505 return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_);492 return pointer_traits<__begin_node_pointer>::pointer_to(__before_begin_);
506 }493 }
507 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT {494
508 return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_));495 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __begin_node_pointer __before_begin() const _NOEXCEPT {
496 return pointer_traits<__begin_node_pointer>::pointer_to(
497 *const_cast<__begin_node*>(std::addressof(__before_begin_)));
509 }498 }
510499
511 typedef __forward_list_iterator<__node_pointer> iterator;500 typedef __forward_list_iterator<__node_pointer> iterator;
512 typedef __forward_list_const_iterator<__node_pointer> const_iterator;501 typedef __forward_list_const_iterator<__node_pointer> const_iterator;
513502
514 _LIBCPP_HIDE_FROM_ABI __forward_list_base() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)503 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __forward_list_base()
504 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
515 : __before_begin_(__begin_node()) {}505 : __before_begin_(__begin_node()) {}
516 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a)506 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const allocator_type& __a)
517 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {}507 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {}
518 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)508 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)
519 : __before_begin_(__begin_node()), __alloc_(__a) {}509 : __before_begin_(__begin_node()), __alloc_(__a) {}
520510
521public:511public:
522# ifndef _LIBCPP_CXX03_LANG512# ifndef _LIBCPP_CXX03_LANG
523 _LIBCPP_HIDE_FROM_ABI513 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
524 __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value);514 __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value);
525 _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);515 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
516 __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
526# endif // _LIBCPP_CXX03_LANG517# endif // _LIBCPP_CXX03_LANG
527518
528 __forward_list_base(const __forward_list_base&) = delete;519 __forward_list_base(const __forward_list_base&) = delete;
529 __forward_list_base& operator=(const __forward_list_base&) = delete;520 __forward_list_base& operator=(const __forward_list_base&) = delete;
530521
531 _LIBCPP_HIDE_FROM_ABI ~__forward_list_base();522 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__forward_list_base();
532523
533protected:524protected:
534 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x) {525 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x) {
535 __copy_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());526 __copy_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());
536 }527 }
537528
538 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x)529 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x)
539 _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||530 _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
540 is_nothrow_move_assignable<__node_allocator>::value) {531 is_nothrow_move_assignable<__node_allocator>::value) {
541 __move_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());532 __move_assign_alloc(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
542 }533 }
543534
544 template <class... _Args>535 template <class... _Args>
545 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) {536 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer
537 __create_node(__node_pointer __next, _Args&&... __args) {
546 __allocation_guard<__node_allocator> __guard(__alloc_, 1);538 __allocation_guard<__node_allocator> __guard(__alloc_, 1);
547 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value539 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
548 // held inside the node, since we need to use the allocator's construct() method for that.540 // held inside the node, since we need to use the allocator's construct() method for that.
...@@ -557,7 +549,7 @@ protected:...@@ -557,7 +549,7 @@ protected:
557 return __guard.__release_ptr();549 return __guard.__release_ptr();
558 }550 }
559551
560 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {552 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
561 // For the same reason as above, we use the allocator's destroy() method for the value_type,553 // For the same reason as above, we use the allocator's destroy() method for the value_type,
562 // but not for the node itself.554 // but not for the node itself.
563 __node_traits::destroy(__alloc_, std::addressof(__node->__get_value()));555 __node_traits::destroy(__alloc_, std::addressof(__node->__get_value()));
...@@ -566,7 +558,7 @@ protected:...@@ -566,7 +558,7 @@ protected:
566 }558 }
567559
568public:560public:
569 _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x)561 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(__forward_list_base& __x)
570# if _LIBCPP_STD_VER >= 14562# if _LIBCPP_STD_VER >= 14
571 _NOEXCEPT;563 _NOEXCEPT;
572# else564# else
...@@ -574,18 +566,21 @@ public:...@@ -574,18 +566,21 @@ public:
574# endif566# endif
575567
576protected:568protected:
577 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;569 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
578570
579private:571private:
580 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {}572 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {
581 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) {573 }
574 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
575 __copy_assign_alloc(const __forward_list_base& __x, true_type) {
582 if (__alloc_ != __x.__alloc_)576 if (__alloc_ != __x.__alloc_)
583 clear();577 clear();
584 __alloc_ = __x.__alloc_;578 __alloc_ = __x.__alloc_;
585 }579 }
586580
587 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {}581 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
588 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type)582 __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {}
583 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type)
589 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {584 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
590 __alloc_ = std::move(__x.__alloc_);585 __alloc_ = std::move(__x.__alloc_);
591 }586 }
...@@ -594,14 +589,15 @@ private:...@@ -594,14 +589,15 @@ private:
594# ifndef _LIBCPP_CXX03_LANG589# ifndef _LIBCPP_CXX03_LANG
595590
596template <class _Tp, class _Alloc>591template <class _Tp, class _Alloc>
597inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept(592_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(
598 is_nothrow_move_constructible<__node_allocator>::value)593 __forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value)
599 : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) {594 : __before_begin_(std::move(__x.__before_begin_)), __alloc_(std::move(__x.__alloc_)) {
600 __x.__before_begin()->__next_ = nullptr;595 __x.__before_begin()->__next_ = nullptr;
601}596}
602597
603template <class _Tp, class _Alloc>598template <class _Tp, class _Alloc>
604inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a)599_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(
600 __forward_list_base&& __x, const allocator_type& __a)
605 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {601 : __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {
606 if (__alloc_ == __x.__alloc_) {602 if (__alloc_ == __x.__alloc_) {
607 __before_begin()->__next_ = __x.__before_begin()->__next_;603 __before_begin()->__next_ = __x.__before_begin()->__next_;
...@@ -612,12 +608,12 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base...@@ -612,12 +608,12 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base
612# endif // _LIBCPP_CXX03_LANG608# endif // _LIBCPP_CXX03_LANG
613609
614template <class _Tp, class _Alloc>610template <class _Tp, class _Alloc>
615__forward_list_base<_Tp, _Alloc>::~__forward_list_base() {611_LIBCPP_CONSTEXPR_SINCE_CXX26 __forward_list_base<_Tp, _Alloc>::~__forward_list_base() {
616 clear();612 clear();
617}613}
618614
619template <class _Tp, class _Alloc>615template <class _Tp, class _Alloc>
620inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)616_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
621# if _LIBCPP_STD_VER >= 14617# if _LIBCPP_STD_VER >= 14
622 _NOEXCEPT618 _NOEXCEPT
623# else619# else
...@@ -630,7 +626,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)...@@ -630,7 +626,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
630}626}
631627
632template <class _Tp, class _Alloc>628template <class _Tp, class _Alloc>
633void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {629_LIBCPP_CONSTEXPR_SINCE_CXX26 void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {
634 for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) {630 for (__node_pointer __p = __before_begin()->__next_; __p != nullptr;) {
635 __node_pointer __next = __p->__next_;631 __node_pointer __next = __p->__next_;
636 __delete_node(__p);632 __delete_node(__p);
...@@ -640,7 +636,7 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {...@@ -640,7 +636,7 @@ void __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT {
640}636}
641637
642template <class _Tp, class _Alloc /*= allocator<_Tp>*/>638template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
643class _LIBCPP_TEMPLATE_VIS forward_list : private __forward_list_base<_Tp, _Alloc> {639class forward_list : private __forward_list_base<_Tp, _Alloc> {
644 typedef __forward_list_base<_Tp, _Alloc> __base;640 typedef __forward_list_base<_Tp, _Alloc> __base;
645 typedef typename __base::__node_allocator __node_allocator;641 typedef typename __base::__node_allocator __node_allocator;
646 typedef typename __base::__node_type __node_type;642 typedef typename __base::__node_type __node_type;
...@@ -675,104 +671,123 @@ public:...@@ -675,104 +671,123 @@ public:
675 typedef void __remove_return_type;671 typedef void __remove_return_type;
676# endif672# endif
677673
678 _LIBCPP_HIDE_FROM_ABI forward_list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {674 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list()
679 } // = default;675 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} // = default;
680 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);676 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);
681 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);677 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);
682# if _LIBCPP_STD_VER >= 14678# if _LIBCPP_STD_VER >= 14
683 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);679 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);
684# endif680# endif
685 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);681 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
686682
687 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>683 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
688 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : __base(__a) {684 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
685 forward_list(size_type __n, const value_type& __v, const allocator_type& __a)
686 : __base(__a) {
689 insert_after(cbefore_begin(), __n, __v);687 insert_after(cbefore_begin(), __n, __v);
690 }688 }
691689
692 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>690 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
693 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l);691 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l);
694692
695 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>693 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
696 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a);694 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
695 forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a);
697696
698# if _LIBCPP_STD_VER >= 23697# if _LIBCPP_STD_VER >= 23
699 template <_ContainerCompatibleRange<_Tp> _Range>698 template <_ContainerCompatibleRange<_Tp> _Range>
700 _LIBCPP_HIDE_FROM_ABI forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())699 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
700 forward_list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
701 : __base(__a) {701 : __base(__a) {
702 prepend_range(std::forward<_Range>(__range));702 prepend_range(std::forward<_Range>(__range));
703 }703 }
704# endif704# endif
705705
706 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x);706 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x);
707 _LIBCPP_HIDE_FROM_ABI forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);707 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
708 forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a);
708709
709 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);710 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);
710711
711# ifndef _LIBCPP_CXX03_LANG712# ifndef _LIBCPP_CXX03_LANG
712 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value)713 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
714 forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<__base>::value)
713 : __base(std::move(__x)) {}715 : __base(std::move(__x)) {}
714 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);716 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
717 forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
715718
716 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);719 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);
717 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a);720 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
721 forward_list(initializer_list<value_type> __il, const allocator_type& __a);
718722
719 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept(723 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept(
720 __node_traits::propagate_on_container_move_assignment::value &&724 (__node_traits::propagate_on_container_move_assignment::value &&
721 is_nothrow_move_assignable<allocator_type>::value);725 is_nothrow_move_assignable<allocator_type>::value) ||
726 allocator_traits<allocator_type>::is_always_equal::value);
722727
723 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);728 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);
724729
725 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il);730 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il);
726# endif // _LIBCPP_CXX03_LANG731# endif // _LIBCPP_CXX03_LANG
727732
728 // ~forward_list() = default;733 // ~forward_list() = default;
729734
730 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>735 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
731 void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);736 _LIBCPP_CONSTEXPR_SINCE_CXX26 void _LIBCPP_HIDE_FROM_ABI assign(_InputIterator __f, _InputIterator __l);
732737
733# if _LIBCPP_STD_VER >= 23738# if _LIBCPP_STD_VER >= 23
734 template <_ContainerCompatibleRange<_Tp> _Range>739 template <_ContainerCompatibleRange<_Tp> _Range>
735 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {740 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
736 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));741 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
737 }742 }
738# endif743# endif
739744
740 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);745 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
741746
742 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(this->__alloc_); }747 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
748 return allocator_type(this->__alloc_);
749 }
743750
744 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__base::__before_begin()->__next_); }751 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
745 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {752 return iterator(__base::__before_begin()->__next_);
753 }
754 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
746 return const_iterator(__base::__before_begin()->__next_);755 return const_iterator(__base::__before_begin()->__next_);
747 }756 }
748 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); }757 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(nullptr); }
749 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(nullptr); }758 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
759 return const_iterator(nullptr);
760 }
750761
751 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {762 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
752 return const_iterator(__base::__before_begin()->__next_);763 return const_iterator(__base::__before_begin()->__next_);
753 }764 }
754 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return const_iterator(nullptr); }765 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT {
766 return const_iterator(nullptr);
767 }
755768
756 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT { return iterator(__base::__before_begin()); }769 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator before_begin() _NOEXCEPT {
757 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT {770 return iterator(__base::__before_begin());
771 }
772 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator before_begin() const _NOEXCEPT {
758 return const_iterator(__base::__before_begin());773 return const_iterator(__base::__before_begin());
759 }774 }
760 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT {775 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbefore_begin() const _NOEXCEPT {
761 return const_iterator(__base::__before_begin());776 return const_iterator(__base::__before_begin());
762 }777 }
763778
764 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {779 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
765 return __base::__before_begin()->__next_ == nullptr;780 return __base::__before_begin()->__next_ == nullptr;
766 }781 }
767 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {782 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
768 return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());783 return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());
769 }784 }
770785
771 _LIBCPP_HIDE_FROM_ABI reference front() {786 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() {
772 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");787 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");
773 return __base::__before_begin()->__next_->__get_value();788 return __base::__before_begin()->__next_->__get_value();
774 }789 }
775 _LIBCPP_HIDE_FROM_ABI const_reference front() const {790 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
776 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");791 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::front called on an empty list");
777 return __base::__before_begin()->__next_->__get_value();792 return __base::__before_begin()->__next_->__get_value();
778 }793 }
...@@ -780,52 +795,59 @@ public:...@@ -780,52 +795,59 @@ public:
780# ifndef _LIBCPP_CXX03_LANG795# ifndef _LIBCPP_CXX03_LANG
781# if _LIBCPP_STD_VER >= 17796# if _LIBCPP_STD_VER >= 17
782 template <class... _Args>797 template <class... _Args>
783 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);798 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
784# else799# else
785 template <class... _Args>800 template <class... _Args>
786 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);801 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
787# endif802# endif
788 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);803 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __v);
789# endif // _LIBCPP_CXX03_LANG804# endif // _LIBCPP_CXX03_LANG
790 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);805 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __v);
791806
792# if _LIBCPP_STD_VER >= 23807# if _LIBCPP_STD_VER >= 23
793 template <_ContainerCompatibleRange<_Tp> _Range>808 template <_ContainerCompatibleRange<_Tp> _Range>
794 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {809 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
795 insert_range_after(cbefore_begin(), std::forward<_Range>(__range));810 insert_range_after(cbefore_begin(), std::forward<_Range>(__range));
796 }811 }
797# endif812# endif
798813
799 _LIBCPP_HIDE_FROM_ABI void pop_front();814 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_front();
800815
801# ifndef _LIBCPP_CXX03_LANG816# ifndef _LIBCPP_CXX03_LANG
802 template <class... _Args>817 template <class... _Args>
803 _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args);818 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator emplace_after(const_iterator __p, _Args&&... __args);
804819
805 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, value_type&& __v);820 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, value_type&& __v);
806 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, initializer_list<value_type> __il) {821 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
822 insert_after(const_iterator __p, initializer_list<value_type> __il) {
807 return insert_after(__p, __il.begin(), __il.end());823 return insert_after(__p, __il.begin(), __il.end());
808 }824 }
809# endif // _LIBCPP_CXX03_LANG825# endif // _LIBCPP_CXX03_LANG
810 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);826 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, const value_type& __v);
811 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, size_type __n, const value_type& __v);827 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
828 insert_after(const_iterator __p, size_type __n, const value_type& __v) {
829 return __insert_after(__p, __n, __v);
830 }
812 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>831 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
813 _LIBCPP_HIDE_FROM_ABI iterator insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);832 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
833 insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l);
814834
815# if _LIBCPP_STD_VER >= 23835# if _LIBCPP_STD_VER >= 23
816 template <_ContainerCompatibleRange<_Tp> _Range>836 template <_ContainerCompatibleRange<_Tp> _Range>
817 _LIBCPP_HIDE_FROM_ABI iterator insert_range_after(const_iterator __position, _Range&& __range) {837 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
838 insert_range_after(const_iterator __position, _Range&& __range) {
818 return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));839 return __insert_after_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
819 }840 }
820# endif841# endif
821842
822 template <class _InputIterator, class _Sentinel>843 template <class _InputIterator, class _Sentinel>
823 _LIBCPP_HIDE_FROM_ABI iterator __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l);844 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
845 __insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l);
824846
825 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __p);847 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __p);
826 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l);848 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase_after(const_iterator __f, const_iterator __l);
827849
828 _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x)850 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(forward_list& __x)
829# if _LIBCPP_STD_VER >= 14851# if _LIBCPP_STD_VER >= 14
830 _NOEXCEPT852 _NOEXCEPT
831# else853# else
...@@ -835,55 +857,63 @@ public:...@@ -835,55 +857,63 @@ public:
835 __base::swap(__x);857 __base::swap(__x);
836 }858 }
837859
838 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);860 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
839 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);861 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
840 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }862 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
841863
842 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x);864 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x);
843 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);865 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
844 _LIBCPP_HIDE_FROM_ABI void866 splice_after(const_iterator __p, forward_list&& __x, const_iterator __i);
867 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
845 splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l);868 splice_after(const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l);
846 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x);869 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x);
847 _LIBCPP_HIDE_FROM_ABI void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);870 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
848 _LIBCPP_HIDE_FROM_ABI void871 splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
872 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
849 splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l);873 splice_after(const_iterator __p, forward_list& __x, const_iterator __f, const_iterator __l);
850 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __v);874 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __v);
851 template <class _Predicate>875 template <class _Predicate>
852 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Predicate __pred);876 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Predicate __pred);
853 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }877 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
854 template <class _BinaryPredicate>878 template <class _BinaryPredicate>
855 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred);879 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPredicate __binary_pred);
856# ifndef _LIBCPP_CXX03_LANG880# ifndef _LIBCPP_CXX03_LANG
857 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); }881 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x) { merge(__x, __less<>()); }
858 template <class _Compare>882 template <class _Compare>
859 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) {883 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list&& __x, _Compare __comp) {
860 merge(__x, std::move(__comp));884 merge(__x, std::move(__comp));
861 }885 }
862# endif // _LIBCPP_CXX03_LANG886# endif // _LIBCPP_CXX03_LANG
863 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); }887 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x) { merge(__x, __less<>()); }
864 template <class _Compare>888 template <class _Compare>
865 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp);889 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(forward_list& __x, _Compare __comp);
866 _LIBCPP_HIDE_FROM_ABI void sort() { sort(__less<>()); }890 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort() { sort(__less<>()); }
867 template <class _Compare>891 template <class _Compare>
868 _LIBCPP_HIDE_FROM_ABI void sort(_Compare __comp);892 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(_Compare __comp);
869 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;893 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
870894
871private:895private:
872# ifndef _LIBCPP_CXX03_LANG896# ifndef _LIBCPP_CXX03_LANG
873 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type)897 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, true_type)
874 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);898 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
875 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type);899 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(forward_list& __x, false_type);
876# endif // _LIBCPP_CXX03_LANG900# endif // _LIBCPP_CXX03_LANG
877901
878 template <class _Iter, class _Sent>902 template <class _Iter, class _Sent>
879 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l);903 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iter __f, _Sent __l);
904
905 template <class... _Args>
906 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
907 __insert_after(const_iterator __p, size_type __n, _Args&&... __args);
880908
881 template <class _Compare>909 template <class _Compare>
882 static _LIBCPP_HIDE_FROM_ABI __node_pointer __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp);910 _LIBCPP_CONSTEXPR_SINCE_CXX26 static _LIBCPP_HIDE_FROM_ABI __node_pointer
911 __merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp);
883912
884 // TODO: Make this _LIBCPP_HIDE_FROM_ABI913 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
885 template <class _Compare>914 template <class _Compare>
886 static _LIBCPP_HIDDEN __node_pointer __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);915 _LIBCPP_CONSTEXPR_SINCE_CXX26 static _LIBCPP_HIDDEN __node_pointer
916 __sort(__node_pointer __f, difference_type __sz, _Compare& __comp);
887};917};
888918
889# if _LIBCPP_STD_VER >= 17919# if _LIBCPP_STD_VER >= 17
...@@ -908,12 +938,13 @@ forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::...@@ -908,12 +938,13 @@ forward_list(from_range_t, _Range&&, _Alloc = _Alloc()) -> forward_list<ranges::
908# endif938# endif
909939
910template <class _Tp, class _Alloc>940template <class _Tp, class _Alloc>
911inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {}941_LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>::forward_list(const allocator_type& __a) : __base(__a) {}
912942
913template <class _Tp, class _Alloc>943template <class _Tp, class _Alloc>
914forward_list<_Tp, _Alloc>::forward_list(size_type __n) {944_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n) {
915 if (__n > 0) {945 if (__n > 0) {
916 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {946 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0;
947 --__n, __p = std::__static_fancy_pointer_cast<__begin_node_pointer>(__p->__next_)) {
917 __p->__next_ = this->__create_node(/* next = */ nullptr);948 __p->__next_ = this->__create_node(/* next = */ nullptr);
918 }949 }
919 }950 }
...@@ -921,9 +952,11 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) {...@@ -921,9 +952,11 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) {
921952
922# if _LIBCPP_STD_VER >= 14953# if _LIBCPP_STD_VER >= 14
923template <class _Tp, class _Alloc>954template <class _Tp, class _Alloc>
924forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc) : __base(__base_alloc) {955_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc)
956 : __base(__base_alloc) {
925 if (__n > 0) {957 if (__n > 0) {
926 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0; --__n, __p = __p->__next_as_begin()) {958 for (__begin_node_pointer __p = __base::__before_begin(); __n > 0;
959 --__n, __p = std::__static_fancy_pointer_cast<__begin_node_pointer>(__p->__next_)) {
927 __p->__next_ = this->__create_node(/* next = */ nullptr);960 __p->__next_ = this->__create_node(/* next = */ nullptr);
928 }961 }
929 }962 }
...@@ -931,37 +964,39 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __b...@@ -931,37 +964,39 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __b
931# endif964# endif
932965
933template <class _Tp, class _Alloc>966template <class _Tp, class _Alloc>
934forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {967_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {
935 insert_after(cbefore_begin(), __n, __v);968 insert_after(cbefore_begin(), __n, __v);
936}969}
937970
938template <class _Tp, class _Alloc>971template <class _Tp, class _Alloc>
939template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >972template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
940forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) {973_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) {
941 insert_after(cbefore_begin(), __f, __l);974 insert_after(cbefore_begin(), __f, __l);
942}975}
943976
944template <class _Tp, class _Alloc>977template <class _Tp, class _Alloc>
945template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >978template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
979_LIBCPP_CONSTEXPR_SINCE_CXX26
946forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a)980forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
947 : __base(__a) {981 : __base(__a) {
948 insert_after(cbefore_begin(), __f, __l);982 insert_after(cbefore_begin(), __f, __l);
949}983}
950984
951template <class _Tp, class _Alloc>985template <class _Tp, class _Alloc>
952forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)986_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
953 : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) {987 : __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) {
954 insert_after(cbefore_begin(), __x.begin(), __x.end());988 insert_after(cbefore_begin(), __x.begin(), __x.end());
955}989}
956990
957template <class _Tp, class _Alloc>991template <class _Tp, class _Alloc>
992_LIBCPP_CONSTEXPR_SINCE_CXX26
958forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a)993forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x, const __type_identity_t<allocator_type>& __a)
959 : __base(__a) {994 : __base(__a) {
960 insert_after(cbefore_begin(), __x.begin(), __x.end());995 insert_after(cbefore_begin(), __x.begin(), __x.end());
961}996}
962997
963template <class _Tp, class _Alloc>998template <class _Tp, class _Alloc>
964forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) {999_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_list& __x) {
965 if (this != std::addressof(__x)) {1000 if (this != std::addressof(__x)) {
966 __base::__copy_assign_alloc(__x);1001 __base::__copy_assign_alloc(__x);
967 assign(__x.begin(), __x.end());1002 assign(__x.begin(), __x.end());
...@@ -971,6 +1006,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li...@@ -971,6 +1006,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li
9711006
972# ifndef _LIBCPP_CXX03_LANG1007# ifndef _LIBCPP_CXX03_LANG
973template <class _Tp, class _Alloc>1008template <class _Tp, class _Alloc>
1009_LIBCPP_CONSTEXPR_SINCE_CXX26
974forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a)1010forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a)
975 : __base(std::move(__x), __a) {1011 : __base(std::move(__x), __a) {
976 if (this->__alloc_ != __x.__alloc_) {1012 if (this->__alloc_ != __x.__alloc_) {
...@@ -980,17 +1016,19 @@ forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identit...@@ -980,17 +1016,19 @@ forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identit
980}1016}
9811017
982template <class _Tp, class _Alloc>1018template <class _Tp, class _Alloc>
983forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) {1019_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il) {
984 insert_after(cbefore_begin(), __il.begin(), __il.end());1020 insert_after(cbefore_begin(), __il.begin(), __il.end());
985}1021}
9861022
987template <class _Tp, class _Alloc>1023template <class _Tp, class _Alloc>
988forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {1024_LIBCPP_CONSTEXPR_SINCE_CXX26
1025forward_list<_Tp, _Alloc>::forward_list(initializer_list<value_type> __il, const allocator_type& __a)
1026 : __base(__a) {
989 insert_after(cbefore_begin(), __il.begin(), __il.end());1027 insert_after(cbefore_begin(), __il.begin(), __il.end());
990}1028}
9911029
992template <class _Tp, class _Alloc>1030template <class _Tp, class _Alloc>
993void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)1031_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
994 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {1032 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
995 clear();1033 clear();
996 __base::__move_assign_alloc(__x);1034 __base::__move_assign_alloc(__x);
...@@ -999,7 +1037,7 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)...@@ -999,7 +1037,7 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
999}1037}
10001038
1001template <class _Tp, class _Alloc>1039template <class _Tp, class _Alloc>
1002void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {1040_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {
1003 if (this->__alloc_ == __x.__alloc_)1041 if (this->__alloc_ == __x.__alloc_)
1004 __move_assign(__x, true_type());1042 __move_assign(__x, true_type());
1005 else {1043 else {
...@@ -1009,14 +1047,18 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {...@@ -1009,14 +1047,18 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {
1009}1047}
10101048
1011template <class _Tp, class _Alloc>1049template <class _Tp, class _Alloc>
1012inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) _NOEXCEPT_(1050_LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>&
1013 __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value) {1051forward_list<_Tp, _Alloc>::operator=(forward_list&& __x) noexcept(
1052 (__node_traits::propagate_on_container_move_assignment::value &&
1053 is_nothrow_move_assignable<allocator_type>::value) ||
1054 allocator_traits<allocator_type>::is_always_equal::value) {
1014 __move_assign(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());1055 __move_assign(__x, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1015 return *this;1056 return *this;
1016}1057}
10171058
1018template <class _Tp, class _Alloc>1059template <class _Tp, class _Alloc>
1019inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) {1060_LIBCPP_CONSTEXPR_SINCE_CXX26 inline forward_list<_Tp, _Alloc>&
1061forward_list<_Tp, _Alloc>::operator=(initializer_list<value_type> __il) {
1020 assign(__il.begin(), __il.end());1062 assign(__il.begin(), __il.end());
1021 return *this;1063 return *this;
1022}1064}
...@@ -1025,13 +1067,14 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ...@@ -1025,13 +1067,14 @@ inline forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(initializ
10251067
1026template <class _Tp, class _Alloc>1068template <class _Tp, class _Alloc>
1027template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >1069template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
1028void forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) {1070_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::assign(_InputIterator __f, _InputIterator __l) {
1029 __assign_with_sentinel(__f, __l);1071 __assign_with_sentinel(__f, __l);
1030}1072}
10311073
1032template <class _Tp, class _Alloc>1074template <class _Tp, class _Alloc>
1033template <class _Iter, class _Sent>1075template <class _Iter, class _Sent>
1034_LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_Iter __f, _Sent __l) {1076_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
1077forward_list<_Tp, _Alloc>::__assign_with_sentinel(_Iter __f, _Sent __l) {
1035 iterator __i = before_begin();1078 iterator __i = before_begin();
1036 iterator __j = std::next(__i);1079 iterator __j = std::next(__i);
1037 iterator __e = end();1080 iterator __e = end();
...@@ -1044,7 +1087,7 @@ _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_It...@@ -1044,7 +1087,7 @@ _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::__assign_with_sentinel(_It
1044}1087}
10451088
1046template <class _Tp, class _Alloc>1089template <class _Tp, class _Alloc>
1047void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {1090_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {
1048 iterator __i = before_begin();1091 iterator __i = before_begin();
1049 iterator __j = std::next(__i);1092 iterator __j = std::next(__i);
1050 iterator __e = end();1093 iterator __e = end();
...@@ -1059,18 +1102,19 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {...@@ -1059,18 +1102,19 @@ void forward_list<_Tp, _Alloc>::assign(size_type __n, const value_type& __v) {
1059# ifndef _LIBCPP_CXX03_LANG1102# ifndef _LIBCPP_CXX03_LANG
10601103
1061template <class _Tp, class _Alloc>1104template <class _Tp, class _Alloc>
1062inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) {1105_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void forward_list<_Tp, _Alloc>::assign(initializer_list<value_type> __il) {
1063 assign(__il.begin(), __il.end());1106 assign(__il.begin(), __il.end());
1064}1107}
10651108
1066template <class _Tp, class _Alloc>1109template <class _Tp, class _Alloc>
1067template <class... _Args>1110template <class... _Args>
1111_LIBCPP_CONSTEXPR_SINCE_CXX26
1068# if _LIBCPP_STD_VER >= 171112# if _LIBCPP_STD_VER >= 17
1069typename forward_list<_Tp, _Alloc>::reference1113 typename forward_list<_Tp, _Alloc>::reference
1070# else1114# else
1071void1115 void
1072# endif1116# endif
1073forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {1117 forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1074 __base::__before_begin()->__next_ =1118 __base::__before_begin()->__next_ =
1075 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...);1119 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::forward<_Args>(__args)...);
1076# if _LIBCPP_STD_VER >= 171120# if _LIBCPP_STD_VER >= 17
...@@ -1079,7 +1123,7 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {...@@ -1079,7 +1123,7 @@ forward_list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1079}1123}
10801124
1081template <class _Tp, class _Alloc>1125template <class _Tp, class _Alloc>
1082void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {1126_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {
1083 __base::__before_begin()->__next_ =1127 __base::__before_begin()->__next_ =
1084 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v));1128 this->__create_node(/* next = */ __base::__before_begin()->__next_, std::move(__v));
1085}1129}
...@@ -1087,12 +1131,12 @@ void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {...@@ -1087,12 +1131,12 @@ void forward_list<_Tp, _Alloc>::push_front(value_type&& __v) {
1087# endif // _LIBCPP_CXX03_LANG1131# endif // _LIBCPP_CXX03_LANG
10881132
1089template <class _Tp, class _Alloc>1133template <class _Tp, class _Alloc>
1090void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) {1134_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::push_front(const value_type& __v) {
1091 __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v);1135 __base::__before_begin()->__next_ = this->__create_node(/* next = */ __base::__before_begin()->__next_, __v);
1092}1136}
10931137
1094template <class _Tp, class _Alloc>1138template <class _Tp, class _Alloc>
1095void forward_list<_Tp, _Alloc>::pop_front() {1139_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::pop_front() {
1096 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list");1140 _LIBCPP_ASSERT_NON_NULL(!empty(), "forward_list::pop_front called on an empty list");
1097 __node_pointer __p = __base::__before_begin()->__next_;1141 __node_pointer __p = __base::__before_begin()->__next_;
1098 __base::__before_begin()->__next_ = __p->__next_;1142 __base::__before_begin()->__next_ = __p->__next_;
...@@ -1103,17 +1147,17 @@ void forward_list<_Tp, _Alloc>::pop_front() {...@@ -1103,17 +1147,17 @@ void forward_list<_Tp, _Alloc>::pop_front() {
11031147
1104template <class _Tp, class _Alloc>1148template <class _Tp, class _Alloc>
1105template <class... _Args>1149template <class... _Args>
1106typename forward_list<_Tp, _Alloc>::iterator1150_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1107forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) {1151forward_list<_Tp, _Alloc>::emplace_after(const_iterator __p, _Args&&... __args) {
1108 __begin_node_pointer const __r = __p.__get_begin();1152 __begin_node_pointer const __r = __p.__ptr_;
1109 __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::forward<_Args>(__args)...);1153 __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::forward<_Args>(__args)...);
1110 return iterator(__r->__next_);1154 return iterator(__r->__next_);
1111}1155}
11121156
1113template <class _Tp, class _Alloc>1157template <class _Tp, class _Alloc>
1114typename forward_list<_Tp, _Alloc>::iterator1158_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1115forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {1159forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {
1116 __begin_node_pointer const __r = __p.__get_begin();1160 __begin_node_pointer const __r = __p.__ptr_;
1117 __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::move(__v));1161 __r->__next_ = this->__create_node(/* next = */ __r->__next_, std::move(__v));
1118 return iterator(__r->__next_);1162 return iterator(__r->__next_);
1119}1163}
...@@ -1121,25 +1165,26 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {...@@ -1121,25 +1165,26 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, value_type&& __v) {
1121# endif // _LIBCPP_CXX03_LANG1165# endif // _LIBCPP_CXX03_LANG
11221166
1123template <class _Tp, class _Alloc>1167template <class _Tp, class _Alloc>
1124typename forward_list<_Tp, _Alloc>::iterator1168_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1125forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) {1169forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, const value_type& __v) {
1126 __begin_node_pointer const __r = __p.__get_begin();1170 __begin_node_pointer const __r = __p.__ptr_;
1127 __r->__next_ = this->__create_node(/* next = */ __r->__next_, __v);1171 __r->__next_ = this->__create_node(/* next = */ __r->__next_, __v);
1128 return iterator(__r->__next_);1172 return iterator(__r->__next_);
1129}1173}
11301174
1131template <class _Tp, class _Alloc>1175template <class _Tp, class _Alloc>
1132typename forward_list<_Tp, _Alloc>::iterator1176template <class... _Args>
1133forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const value_type& __v) {1177_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1134 __begin_node_pointer __r = __p.__get_begin();1178forward_list<_Tp, _Alloc>::__insert_after(const_iterator __p, size_type __n, _Args&&... __args) {
1179 __begin_node_pointer __r = __p.__ptr_;
1135 if (__n > 0) {1180 if (__n > 0) {
1136 __node_pointer __first = this->__create_node(/* next = */ nullptr, __v);1181 __node_pointer __first = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...);
1137 __node_pointer __last = __first;1182 __node_pointer __last = __first;
1138# if _LIBCPP_HAS_EXCEPTIONS1183# if _LIBCPP_HAS_EXCEPTIONS
1139 try {1184 try {
1140# endif // _LIBCPP_HAS_EXCEPTIONS1185# endif // _LIBCPP_HAS_EXCEPTIONS
1141 for (--__n; __n != 0; --__n, __last = __last->__next_) {1186 for (--__n; __n != 0; --__n, __last = __last->__next_) {
1142 __last->__next_ = this->__create_node(/* next = */ nullptr, __v);1187 __last->__next_ = this->__create_node(/* next = */ nullptr, std::forward<_Args>(__args)...);
1143 }1188 }
1144# if _LIBCPP_HAS_EXCEPTIONS1189# if _LIBCPP_HAS_EXCEPTIONS
1145 } catch (...) {1190 } catch (...) {
...@@ -1153,23 +1198,23 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const...@@ -1153,23 +1198,23 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const
1153# endif // _LIBCPP_HAS_EXCEPTIONS1198# endif // _LIBCPP_HAS_EXCEPTIONS
1154 __last->__next_ = __r->__next_;1199 __last->__next_ = __r->__next_;
1155 __r->__next_ = __first;1200 __r->__next_ = __first;
1156 __r = static_cast<__begin_node_pointer>(__last);1201 __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last);
1157 }1202 }
1158 return iterator(__r);1203 return iterator(__r);
1159}1204}
11601205
1161template <class _Tp, class _Alloc>1206template <class _Tp, class _Alloc>
1162template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >1207template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
1163typename forward_list<_Tp, _Alloc>::iterator1208_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1164forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) {1209forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, _InputIterator __f, _InputIterator __l) {
1165 return __insert_after_with_sentinel(__p, std::move(__f), std::move(__l));1210 return __insert_after_with_sentinel(__p, std::move(__f), std::move(__l));
1166}1211}
11671212
1168template <class _Tp, class _Alloc>1213template <class _Tp, class _Alloc>
1169template <class _InputIterator, class _Sentinel>1214template <class _InputIterator, class _Sentinel>
1170_LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Alloc>::iterator1215_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Alloc>::iterator
1171forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l) {1216forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _InputIterator __f, _Sentinel __l) {
1172 __begin_node_pointer __r = __p.__get_begin();1217 __begin_node_pointer __r = __p.__ptr_;
11731218
1174 if (__f != __l) {1219 if (__f != __l) {
1175 __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f);1220 __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f);
...@@ -1194,15 +1239,16 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp...@@ -1194,15 +1239,16 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp
11941239
1195 __last->__next_ = __r->__next_;1240 __last->__next_ = __r->__next_;
1196 __r->__next_ = __first;1241 __r->__next_ = __first;
1197 __r = static_cast<__begin_node_pointer>(__last);1242 __r = std::__static_fancy_pointer_cast<__begin_node_pointer>(__last);
1198 }1243 }
11991244
1200 return iterator(__r);1245 return iterator(__r);
1201}1246}
12021247
1203template <class _Tp, class _Alloc>1248template <class _Tp, class _Alloc>
1204typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) {1249_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1205 __begin_node_pointer __p = __f.__get_begin();1250forward_list<_Tp, _Alloc>::erase_after(const_iterator __f) {
1251 __begin_node_pointer __p = __f.__ptr_;
1206 __node_pointer __n = __p->__next_;1252 __node_pointer __n = __p->__next_;
1207 __p->__next_ = __n->__next_;1253 __p->__next_ = __n->__next_;
1208 this->__delete_node(__n);1254 this->__delete_node(__n);
...@@ -1210,11 +1256,11 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_af...@@ -1210,11 +1256,11 @@ typename forward_list<_Tp, _Alloc>::iterator forward_list<_Tp, _Alloc>::erase_af
1210}1256}
12111257
1212template <class _Tp, class _Alloc>1258template <class _Tp, class _Alloc>
1213typename forward_list<_Tp, _Alloc>::iterator1259_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::iterator
1214forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) {1260forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) {
1215 __node_pointer __e = __l.__get_unsafe_node_pointer();1261 __node_pointer __e = std::__static_fancy_pointer_cast<__node_pointer>(__l.__ptr_);
1216 if (__f != __l) {1262 if (__f != __l) {
1217 __begin_node_pointer __bp = __f.__get_begin();1263 __begin_node_pointer __bp = __f.__ptr_;
12181264
1219 __node_pointer __n = __bp->__next_;1265 __node_pointer __n = __bp->__next_;
1220 if (__n != __e) {1266 if (__n != __e) {
...@@ -1230,7 +1276,7 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) {...@@ -1230,7 +1276,7 @@ forward_list<_Tp, _Alloc>::erase_after(const_iterator __f, const_iterator __l) {
1230}1276}
12311277
1232template <class _Tp, class _Alloc>1278template <class _Tp, class _Alloc>
1233void forward_list<_Tp, _Alloc>::resize(size_type __n) {1279_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::resize(size_type __n) {
1234 size_type __sz = 0;1280 size_type __sz = 0;
1235 iterator __p = before_begin();1281 iterator __p = before_begin();
1236 iterator __i = begin();1282 iterator __i = begin();
...@@ -1239,18 +1285,12 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n) {...@@ -1239,18 +1285,12 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n) {
1239 ;1285 ;
1240 if (__i != __e)1286 if (__i != __e)
1241 erase_after(__p, __e);1287 erase_after(__p, __e);
1242 else {1288 else
1243 __n -= __sz;1289 __insert_after(__p, __n - __sz);
1244 if (__n > 0) {
1245 for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) {
1246 __ptr->__next_ = this->__create_node(/* next = */ nullptr);
1247 }
1248 }
1249 }
1250}1290}
12511291
1252template <class _Tp, class _Alloc>1292template <class _Tp, class _Alloc>
1253void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) {1293_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) {
1254 size_type __sz = 0;1294 size_type __sz = 0;
1255 iterator __p = before_begin();1295 iterator __p = before_begin();
1256 iterator __i = begin();1296 iterator __i = begin();
...@@ -1259,79 +1299,76 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) {...@@ -1259,79 +1299,76 @@ void forward_list<_Tp, _Alloc>::resize(size_type __n, const value_type& __v) {
1259 ;1299 ;
1260 if (__i != __e)1300 if (__i != __e)
1261 erase_after(__p, __e);1301 erase_after(__p, __e);
1262 else {1302 else
1263 __n -= __sz;1303 __insert_after(__p, __n - __sz, __v);
1264 if (__n > 0) {
1265 for (__begin_node_pointer __ptr = __p.__get_begin(); __n > 0; --__n, __ptr = __ptr->__next_as_begin()) {
1266 __ptr->__next_ = this->__create_node(/* next = */ nullptr, __v);
1267 }
1268 }
1269 }
1270}1304}
12711305
1272template <class _Tp, class _Alloc>1306template <class _Tp, class _Alloc>
1273void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x) {1307_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& __x) {
1274 if (!__x.empty()) {1308 if (!__x.empty()) {
1275 if (__p.__get_begin()->__next_ != nullptr) {1309 if (__p.__ptr_->__next_ != nullptr) {
1276 const_iterator __lm1 = __x.before_begin();1310 const_iterator __lm1 = __x.before_begin();
1277 while (__lm1.__get_begin()->__next_ != nullptr)1311 while (__lm1.__ptr_->__next_ != nullptr)
1278 ++__lm1;1312 ++__lm1;
1279 __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;1313 __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
1280 }1314 }
1281 __p.__get_begin()->__next_ = __x.__before_begin()->__next_;1315 __p.__ptr_->__next_ = __x.__before_begin()->__next_;
1282 __x.__before_begin()->__next_ = nullptr;1316 __x.__before_begin()->__next_ = nullptr;
1283 }1317 }
1284}1318}
12851319
1286template <class _Tp, class _Alloc>1320template <class _Tp, class _Alloc>
1287void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& /*__other*/, const_iterator __i) {1321_LIBCPP_CONSTEXPR_SINCE_CXX26 void
1322forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list& /*__other*/, const_iterator __i) {
1288 const_iterator __lm1 = std::next(__i);1323 const_iterator __lm1 = std::next(__i);
1289 if (__p != __i && __p != __lm1) {1324 if (__p != __i && __p != __lm1) {
1290 __i.__get_begin()->__next_ = __lm1.__get_begin()->__next_;1325 __i.__ptr_->__next_ = __lm1.__ptr_->__next_;
1291 __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;1326 __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
1292 __p.__get_begin()->__next_ = __lm1.__get_unsafe_node_pointer();1327 __p.__ptr_->__next_ = std::__static_fancy_pointer_cast<__node_pointer>(__lm1.__ptr_);
1293 }1328 }
1294}1329}
12951330
1296template <class _Tp, class _Alloc>1331template <class _Tp, class _Alloc>
1297void forward_list<_Tp, _Alloc>::splice_after(1332_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::splice_after(
1298 const_iterator __p, forward_list& /*__other*/, const_iterator __f, const_iterator __l) {1333 const_iterator __p, forward_list& /*__other*/, const_iterator __f, const_iterator __l) {
1299 if (__f != __l && __p != __f) {1334 if (__f != __l && __p != __f) {
1300 const_iterator __lm1 = __f;1335 const_iterator __lm1 = __f;
1301 while (__lm1.__get_begin()->__next_ != __l.__get_begin())1336 while (__lm1.__ptr_->__next_ != __l.__ptr_)
1302 ++__lm1;1337 ++__lm1;
1303 if (__f != __lm1) {1338 if (__f != __lm1) {
1304 __lm1.__get_begin()->__next_ = __p.__get_begin()->__next_;1339 __lm1.__ptr_->__next_ = __p.__ptr_->__next_;
1305 __p.__get_begin()->__next_ = __f.__get_begin()->__next_;1340 __p.__ptr_->__next_ = __f.__ptr_->__next_;
1306 __f.__get_begin()->__next_ = __l.__get_unsafe_node_pointer();1341 __f.__ptr_->__next_ = std::__static_fancy_pointer_cast<__node_pointer>(__l.__ptr_);
1307 }1342 }
1308 }1343 }
1309}1344}
13101345
1311template <class _Tp, class _Alloc>1346template <class _Tp, class _Alloc>
1312inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x) {1347_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void
1348forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x) {
1313 splice_after(__p, __x);1349 splice_after(__p, __x);
1314}1350}
13151351
1316template <class _Tp, class _Alloc>1352template <class _Tp, class _Alloc>
1317inline _LIBCPP_HIDE_FROM_ABI void1353_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void
1318forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __i) {1354forward_list<_Tp, _Alloc>::splice_after(const_iterator __p, forward_list&& __x, const_iterator __i) {
1319 splice_after(__p, __x, __i);1355 splice_after(__p, __x, __i);
1320}1356}
13211357
1322template <class _Tp, class _Alloc>1358template <class _Tp, class _Alloc>
1323inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after(1359_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void forward_list<_Tp, _Alloc>::splice_after(
1324 const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l) {1360 const_iterator __p, forward_list&& __x, const_iterator __f, const_iterator __l) {
1325 splice_after(__p, __x, __f, __l);1361 splice_after(__p, __x, __f, __l);
1326}1362}
13271363
1328template <class _Tp, class _Alloc>1364template <class _Tp, class _Alloc>
1329typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Alloc>::remove(const value_type& __v) {1365_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type
1366forward_list<_Tp, _Alloc>::remove(const value_type& __v) {
1330 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1367 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1331 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;1368 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
1332 const iterator __e = end();1369 const iterator __e = end();
1333 for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) {1370 for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) {
1334 if (__i.__get_begin()->__next_->__get_value() == __v) {1371 if (__i.__ptr_->__next_->__get_value() == __v) {
1335 ++__count_removed;1372 ++__count_removed;
1336 iterator __j = std::next(__i, 2);1373 iterator __j = std::next(__i, 2);
1337 for (; __j != __e && *__j == __v; ++__j)1374 for (; __j != __e && *__j == __v; ++__j)
...@@ -1349,12 +1386,13 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo...@@ -1349,12 +1386,13 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo
13491386
1350template <class _Tp, class _Alloc>1387template <class _Tp, class _Alloc>
1351template <class _Predicate>1388template <class _Predicate>
1352typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) {1389_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type
1390forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred) {
1353 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1391 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1354 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;1392 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
1355 const iterator __e = end();1393 const iterator __e = end();
1356 for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;) {1394 for (iterator __i = before_begin(); __i.__ptr_->__next_ != nullptr;) {
1357 if (__pred(__i.__get_begin()->__next_->__get_value())) {1395 if (__pred(__i.__ptr_->__next_->__get_value())) {
1358 ++__count_removed;1396 ++__count_removed;
1359 iterator __j = std::next(__i, 2);1397 iterator __j = std::next(__i, 2);
1360 for (; __j != __e && __pred(*__j); ++__j)1398 for (; __j != __e && __pred(*__j); ++__j)
...@@ -1372,7 +1410,7 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo...@@ -1372,7 +1410,7 @@ typename forward_list<_Tp, _Alloc>::__remove_return_type forward_list<_Tp, _Allo
13721410
1373template <class _Tp, class _Alloc>1411template <class _Tp, class _Alloc>
1374template <class _BinaryPredicate>1412template <class _BinaryPredicate>
1375typename forward_list<_Tp, _Alloc>::__remove_return_type1413_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__remove_return_type
1376forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {1414forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {
1377 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1415 forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1378 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;1416 typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
...@@ -1380,7 +1418,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {...@@ -1380,7 +1418,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {
1380 iterator __j = std::next(__i);1418 iterator __j = std::next(__i);
1381 for (; __j != __e && __binary_pred(*__i, *__j); ++__j)1419 for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
1382 ++__count_removed;1420 ++__count_removed;
1383 if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer())1421 if (__i.__ptr_->__next_ != std::__static_fancy_pointer_cast<__node_pointer>(__j.__ptr_))
1384 __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);1422 __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
1385 __i = __j;1423 __i = __j;
1386 }1424 }
...@@ -1390,7 +1428,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {...@@ -1390,7 +1428,7 @@ forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred) {
13901428
1391template <class _Tp, class _Alloc>1429template <class _Tp, class _Alloc>
1392template <class _Compare>1430template <class _Compare>
1393void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {1431_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {
1394 if (this != std::addressof(__x)) {1432 if (this != std::addressof(__x)) {
1395 __base::__before_begin()->__next_ =1433 __base::__before_begin()->__next_ =
1396 __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp);1434 __merge(__base::__before_begin()->__next_, __x.__before_begin()->__next_, __comp);
...@@ -1400,7 +1438,7 @@ void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {...@@ -1400,7 +1438,7 @@ void forward_list<_Tp, _Alloc>::merge(forward_list& __x, _Compare __comp) {
14001438
1401template <class _Tp, class _Alloc>1439template <class _Tp, class _Alloc>
1402template <class _Compare>1440template <class _Compare>
1403typename forward_list<_Tp, _Alloc>::__node_pointer1441_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__node_pointer
1404forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp) {1442forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Compare& __comp) {
1405 if (__f1 == nullptr)1443 if (__f1 == nullptr)
1406 return __f2;1444 return __f2;
...@@ -1437,13 +1475,13 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co...@@ -1437,13 +1475,13 @@ forward_list<_Tp, _Alloc>::__merge(__node_pointer __f1, __node_pointer __f2, _Co
14371475
1438template <class _Tp, class _Alloc>1476template <class _Tp, class _Alloc>
1439template <class _Compare>1477template <class _Compare>
1440inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) {1478_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void forward_list<_Tp, _Alloc>::sort(_Compare __comp) {
1441 __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp);1479 __base::__before_begin()->__next_ = __sort(__base::__before_begin()->__next_, std::distance(begin(), end()), __comp);
1442}1480}
14431481
1444template <class _Tp, class _Alloc>1482template <class _Tp, class _Alloc>
1445template <class _Compare>1483template <class _Compare>
1446typename forward_list<_Tp, _Alloc>::__node_pointer1484_LIBCPP_CONSTEXPR_SINCE_CXX26 typename forward_list<_Tp, _Alloc>::__node_pointer
1447forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Compare& __comp) {1485forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Compare& __comp) {
1448 switch (__sz) {1486 switch (__sz) {
1449 case 0:1487 case 0:
...@@ -1460,14 +1498,14 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co...@@ -1460,14 +1498,14 @@ forward_list<_Tp, _Alloc>::__sort(__node_pointer __f1, difference_type __sz, _Co
1460 }1498 }
1461 difference_type __sz1 = __sz / 2;1499 difference_type __sz1 = __sz / 2;
1462 difference_type __sz2 = __sz - __sz1;1500 difference_type __sz2 = __sz - __sz1;
1463 __node_pointer __t = std::next(iterator(__f1), __sz1 - 1).__get_unsafe_node_pointer();1501 __node_pointer __t = std::__static_fancy_pointer_cast<__node_pointer>(std::next(iterator(__f1), __sz1 - 1).__ptr_);
1464 __node_pointer __f2 = __t->__next_;1502 __node_pointer __f2 = __t->__next_;
1465 __t->__next_ = nullptr;1503 __t->__next_ = nullptr;
1466 return __merge(__sort(__f1, __sz1, __comp), __sort(__f2, __sz2, __comp), __comp);1504 return __merge(__sort(__f1, __sz1, __comp), __sort(__f2, __sz2, __comp), __comp);
1467}1505}
14681506
1469template <class _Tp, class _Alloc>1507template <class _Tp, class _Alloc>
1470void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {1508_LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1471 __node_pointer __p = __base::__before_begin()->__next_;1509 __node_pointer __p = __base::__before_begin()->__next_;
1472 if (__p != nullptr) {1510 if (__p != nullptr) {
1473 __node_pointer __f = __p->__next_;1511 __node_pointer __f = __p->__next_;
...@@ -1483,7 +1521,8 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {...@@ -1483,7 +1521,8 @@ void forward_list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1483}1521}
14841522
1485template <class _Tp, class _Alloc>1523template <class _Tp, class _Alloc>
1486_LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1524_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
1525operator==(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1487 typedef forward_list<_Tp, _Alloc> _Cp;1526 typedef forward_list<_Tp, _Alloc> _Cp;
1488 typedef typename _Cp::const_iterator _Ip;1527 typedef typename _Cp::const_iterator _Ip;
1489 _Ip __ix = __x.begin();1528 _Ip __ix = __x.begin();
...@@ -1499,31 +1538,31 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons...@@ -1499,31 +1538,31 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const forward_list<_Tp, _Alloc>& __x, cons
1499# if _LIBCPP_STD_VER <= 171538# if _LIBCPP_STD_VER <= 17
15001539
1501template <class _Tp, class _Alloc>1540template <class _Tp, class _Alloc>
1502inline _LIBCPP_HIDE_FROM_ABI bool1541_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1503operator!=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1542operator!=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1504 return !(__x == __y);1543 return !(__x == __y);
1505}1544}
15061545
1507template <class _Tp, class _Alloc>1546template <class _Tp, class _Alloc>
1508inline _LIBCPP_HIDE_FROM_ABI bool1547_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1509operator<(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1548operator<(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1510 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());1549 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
1511}1550}
15121551
1513template <class _Tp, class _Alloc>1552template <class _Tp, class _Alloc>
1514inline _LIBCPP_HIDE_FROM_ABI bool1553_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1515operator>(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1554operator>(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1516 return __y < __x;1555 return __y < __x;
1517}1556}
15181557
1519template <class _Tp, class _Alloc>1558template <class _Tp, class _Alloc>
1520inline _LIBCPP_HIDE_FROM_ABI bool1559_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1521operator>=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1560operator>=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1522 return !(__x < __y);1561 return !(__x < __y);
1523}1562}
15241563
1525template <class _Tp, class _Alloc>1564template <class _Tp, class _Alloc>
1526inline _LIBCPP_HIDE_FROM_ABI bool1565_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1527operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {1566operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>& __y) {
1528 return !(__y < __x);1567 return !(__y < __x);
1529}1568}
...@@ -1531,7 +1570,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>...@@ -1531,7 +1570,7 @@ operator<=(const forward_list<_Tp, _Alloc>& __x, const forward_list<_Tp, _Alloc>
1531# else // #if _LIBCPP_STD_VER <= 171570# else // #if _LIBCPP_STD_VER <= 17
15321571
1533template <class _Tp, class _Allocator>1572template <class _Tp, class _Allocator>
1534_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>1573_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
1535operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {1574operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
1536 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);1575 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1537}1576}
...@@ -1539,22 +1578,22 @@ operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _A...@@ -1539,22 +1578,22 @@ operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _A
1539# endif // #if _LIBCPP_STD_VER <= 171578# endif // #if _LIBCPP_STD_VER <= 17
15401579
1541template <class _Tp, class _Alloc>1580template <class _Tp, class _Alloc>
1542inline _LIBCPP_HIDE_FROM_ABI void swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y)1581_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void
1543 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {1582swap(forward_list<_Tp, _Alloc>& __x, forward_list<_Tp, _Alloc>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1544 __x.swap(__y);1583 __x.swap(__y);
1545}1584}
15461585
1547# if _LIBCPP_STD_VER >= 201586# if _LIBCPP_STD_VER >= 20
1548template <class _Tp, class _Allocator, class _Predicate>1587template <class _Tp, class _Allocator, class _Predicate>
1549inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type1588_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type
1550erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {1589erase_if(forward_list<_Tp, _Allocator>& __c, _Predicate __pred) {
1551 return __c.remove_if(__pred);1590 return __c.remove_if(__pred);
1552}1591}
15531592
1554template <class _Tp, class _Allocator, class _Up>1593template <class _Tp, class _Allocator, class _Up>
1555inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type1594_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename forward_list<_Tp, _Allocator>::size_type
1556erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {1595erase(forward_list<_Tp, _Allocator>& __c, const _Up& __v) {
1557 return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; });1596 return std::erase_if(__c, [&](const auto& __elem) -> bool { return __elem == __v; });
1558}1597}
1559# endif1598# endif
15601599
...@@ -1567,6 +1606,8 @@ struct __container_traits<forward_list<_Tp, _Allocator> > {...@@ -1567,6 +1606,8 @@ struct __container_traits<forward_list<_Tp, _Allocator> > {
1567 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that1606 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that
1568 // function has no effects.1607 // function has no effects.
1569 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;1608 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1609
1610 static _LIBCPP_CONSTEXPR const bool __reservable = false;
1570};1611};
15711612
1572_LIBCPP_END_NAMESPACE_STD1613_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/fstream+93-73
...@@ -189,35 +189,36 @@ typedef basic_fstream<wchar_t> wfstream;...@@ -189,35 +189,36 @@ typedef basic_fstream<wchar_t> wfstream;
189#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)189#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
190# include <__cxx03/fstream>190# include <__cxx03/fstream>
191#else191#else
192# include <__algorithm/max.h>
193# include <__assert>
194# include <__config>192# include <__config>
195# include <__filesystem/path.h>
196# include <__fwd/fstream.h>
197# include <__locale>
198# include <__memory/addressof.h>
199# include <__memory/unique_ptr.h>
200# include <__ostream/basic_ostream.h>
201# include <__type_traits/enable_if.h>
202# include <__type_traits/is_same.h>
203# include <__utility/move.h>
204# include <__utility/swap.h>
205# include <__utility/unreachable.h>
206# include <cstdio>
207# include <istream>
208# include <streambuf>
209# include <typeinfo>
210# include <version>
211
212# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
213# pragma GCC system_header
214# endif
215
216_LIBCPP_PUSH_MACROS
217# include <__undef_macros>
218193
219# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION194# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
220195
196# include <__algorithm/max.h>
197# include <__assert>
198# include <__filesystem/path.h>
199# include <__fwd/fstream.h>
200# include <__locale>
201# include <__memory/addressof.h>
202# include <__memory/unique_ptr.h>
203# include <__ostream/basic_ostream.h>
204# include <__type_traits/enable_if.h>
205# include <__type_traits/is_same.h>
206# include <__utility/move.h>
207# include <__utility/swap.h>
208# include <__utility/unreachable.h>
209# include <cstdio>
210# include <istream>
211# include <streambuf>
212# include <typeinfo>
213# include <version>
214
215# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
216# pragma GCC system_header
217# endif
218
219_LIBCPP_PUSH_MACROS
220# include <__undef_macros>
221
221_LIBCPP_BEGIN_NAMESPACE_STD222_LIBCPP_BEGIN_NAMESPACE_STD
222223
223# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)224# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_WIN32API)
...@@ -225,7 +226,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no...@@ -225,7 +226,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no
225# endif226# endif
226227
227template <class _CharT, class _Traits>228template <class _CharT, class _Traits>
228class _LIBCPP_TEMPLATE_VIS basic_filebuf : public basic_streambuf<_CharT, _Traits> {229class basic_filebuf : public basic_streambuf<_CharT, _Traits> {
229public:230public:
230 typedef _CharT char_type;231 typedef _CharT char_type;
231 typedef _Traits traits_type;232 typedef _Traits traits_type;
...@@ -420,7 +421,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()...@@ -420,7 +421,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
420 __owns_ib_(false),421 __owns_ib_(false),
421 __always_noconv_(false) {422 __always_noconv_(false) {
422 if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc())) {423 if (std::has_facet<codecvt<char_type, char, state_type> >(this->getloc())) {
423 __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(this->getloc());424 __cv_ = std::addressof(std::use_facet<codecvt<char_type, char, state_type> >(this->getloc()));
424 __always_noconv_ = __cv_->always_noconv();425 __always_noconv_ = __cv_->always_noconv();
425 }426 }
426 setbuf(nullptr, 4096);427 setbuf(nullptr, 4096);
...@@ -695,7 +696,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char*...@@ -695,7 +696,7 @@ basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char*
695 if (!__mdstr)696 if (!__mdstr)
696 return nullptr;697 return nullptr;
697698
698 return __do_open(fopen(__s, __mdstr), __mode);699 return __do_open(std::fopen(__s, __mdstr), __mode);
699}700}
700701
701template <class _CharT, class _Traits>702template <class _CharT, class _Traits>
...@@ -753,14 +754,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>...@@ -753,14 +754,14 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
753 bool __initial = __read_mode();754 bool __initial = __read_mode();
754 char_type __1buf;755 char_type __1buf;
755 if (this->gptr() == nullptr)756 if (this->gptr() == nullptr)
756 this->setg(&__1buf, &__1buf + 1, &__1buf + 1);757 this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1);
757 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);758 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
758 int_type __c = traits_type::eof();759 int_type __c = traits_type::eof();
759 if (this->gptr() == this->egptr()) {760 if (this->gptr() == this->egptr()) {
760 std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));761 std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
761 if (__always_noconv_) {762 if (__always_noconv_) {
762 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);763 size_t __nmemb = static_cast<size_t>(this->egptr() - this->eback() - __unget_sz);
763 __nmemb = ::fread(this->eback() + __unget_sz, 1, __nmemb, __file_);764 __nmemb = std::fread(this->eback() + __unget_sz, 1, __nmemb, __file_);
764 if (__nmemb != 0) {765 if (__nmemb != 0) {
765 this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb);766 this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb);
766 __c = traits_type::to_int_type(*this->gptr());767 __c = traits_type::to_int_type(*this->gptr());
...@@ -777,10 +778,10 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>...@@ -777,10 +778,10 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
777 std::min(static_cast<size_t>(__ibs_ - __unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_));778 std::min(static_cast<size_t>(__ibs_ - __unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_));
778 codecvt_base::result __r;779 codecvt_base::result __r;
779 __st_last_ = __st_;780 __st_last_ = __st_;
780 size_t __nr = fread((void*)const_cast<char*>(__extbufnext_), 1, __nmemb, __file_);781 size_t __nr = std::fread((void*)const_cast<char*>(__extbufnext_), 1, __nmemb, __file_);
781 if (__nr != 0) {782 if (__nr != 0) {
782 if (!__cv_)783 if (!__cv_)
783 __throw_bad_cast();784 std::__throw_bad_cast();
784785
785 __extbufend_ = __extbufnext_ + __nr;786 __extbufend_ = __extbufnext_ + __nr;
786 char_type* __inext;787 char_type* __inext;
...@@ -797,7 +798,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>...@@ -797,7 +798,7 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
797 }798 }
798 } else799 } else
799 __c = traits_type::to_int_type(*this->gptr());800 __c = traits_type::to_int_type(*this->gptr());
800 if (this->eback() == &__1buf)801 if (this->eback() == std::addressof(__1buf))
801 this->setg(nullptr, nullptr, nullptr);802 this->setg(nullptr, nullptr, nullptr);
802 return __c;803 return __c;
803}804}
...@@ -828,44 +829,63 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>...@@ -828,44 +829,63 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
828 char_type* __epb_save = this->epptr();829 char_type* __epb_save = this->epptr();
829 if (!traits_type::eq_int_type(__c, traits_type::eof())) {830 if (!traits_type::eq_int_type(__c, traits_type::eof())) {
830 if (this->pptr() == nullptr)831 if (this->pptr() == nullptr)
831 this->setp(&__1buf, &__1buf + 1);832 this->setp(std::addressof(__1buf), std::addressof(__1buf) + 1);
832 *this->pptr() = traits_type::to_char_type(__c);833 *this->pptr() = traits_type::to_char_type(__c);
833 this->pbump(1);834 this->pbump(1);
834 }835 }
835 if (this->pptr() != this->pbase()) {836
836 if (__always_noconv_) {837 // There is nothing to write, early return
837 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());838 if (this->pptr() == this->pbase()) {
838 if (std::fwrite(this->pbase(), sizeof(char_type), __nmemb, __file_) != __nmemb)839 return traits_type::not_eof(__c);
840 }
841
842 if (__always_noconv_) {
843 size_t __n = static_cast<size_t>(this->pptr() - this->pbase());
844 if (std::fwrite(this->pbase(), sizeof(char_type), __n, __file_) != __n)
845 return traits_type::eof();
846 } else {
847 if (!__cv_)
848 std::__throw_bad_cast();
849
850 // See [filebuf.virtuals]
851 char_type* __b = this->pbase();
852 char_type* __p = this->pptr();
853 const char_type* __end;
854 char* __extbuf_end = __extbuf_;
855 do {
856 codecvt_base::result __r = __cv_->out(__st_, __b, __p, __end, __extbuf_, __extbuf_ + __ebs_, __extbuf_end);
857 if (__end == __b)
839 return traits_type::eof();858 return traits_type::eof();
840 } else {
841 char* __extbe = __extbuf_;
842 codecvt_base::result __r;
843 do {
844 if (!__cv_)
845 __throw_bad_cast();
846859
847 const char_type* __e;860 // No conversion needed: output characters directly to the file, done.
848 __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe);861 if (__r == codecvt_base::noconv) {
849 if (__e == this->pbase())862 size_t __n = static_cast<size_t>(__p - __b);
863 if (std::fwrite(__b, 1, __n, __file_) != __n)
850 return traits_type::eof();864 return traits_type::eof();
851 if (__r == codecvt_base::noconv) {865 break;
852 size_t __nmemb = static_cast<size_t>(this->pptr() - this->pbase());866
853 if (std::fwrite(this->pbase(), 1, __nmemb, __file_) != __nmemb)867 // Conversion successful: output the converted characters to the file, done.
854 return traits_type::eof();868 } else if (__r == codecvt_base::ok) {
855 } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) {869 size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_);
856 size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);870 if (std::fwrite(__extbuf_, 1, __n, __file_) != __n)
857 if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
858 return traits_type::eof();
859 if (__r == codecvt_base::partial) {
860 this->setp(const_cast<char_type*>(__e), this->pptr());
861 this->__pbump(this->epptr() - this->pbase());
862 }
863 } else
864 return traits_type::eof();871 return traits_type::eof();
865 } while (__r == codecvt_base::partial);872 break;
866 }873
867 this->setp(__pb_save, __epb_save);874 // Conversion partially successful: output converted characters to the file and repeat with the
875 // remaining characters.
876 } else if (__r == codecvt_base::partial) {
877 size_t __n = static_cast<size_t>(__extbuf_end - __extbuf_);
878 if (std::fwrite(__extbuf_, 1, __n, __file_) != __n)
879 return traits_type::eof();
880 __b = const_cast<char_type*>(__end);
881 continue;
882
883 } else {
884 return traits_type::eof();
885 }
886 } while (true);
868 }887 }
888 this->setp(__pb_save, __epb_save);
869 return traits_type::not_eof(__c);889 return traits_type::not_eof(__c);
870}890}
871891
...@@ -913,7 +933,7 @@ template <class _CharT, class _Traits>...@@ -913,7 +933,7 @@ template <class _CharT, class _Traits>
913typename basic_filebuf<_CharT, _Traits>::pos_type933typename basic_filebuf<_CharT, _Traits>::pos_type
914basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) {934basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode) {
915 if (!__cv_)935 if (!__cv_)
916 __throw_bad_cast();936 std::__throw_bad_cast();
917937
918 int __width = __cv_->encoding();938 int __width = __cv_->encoding();
919 if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())939 if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())
...@@ -978,7 +998,7 @@ int basic_filebuf<_CharT, _Traits>::sync() {...@@ -978,7 +998,7 @@ int basic_filebuf<_CharT, _Traits>::sync() {
978 if (__file_ == nullptr)998 if (__file_ == nullptr)
979 return 0;999 return 0;
980 if (!__cv_)1000 if (!__cv_)
981 __throw_bad_cast();1001 std::__throw_bad_cast();
9821002
983 if (__cm_ & ios_base::out) {1003 if (__cm_ & ios_base::out) {
984 if (this->pptr() != this->pbase())1004 if (this->pptr() != this->pbase())
...@@ -989,12 +1009,12 @@ int basic_filebuf<_CharT, _Traits>::sync() {...@@ -989,12 +1009,12 @@ int basic_filebuf<_CharT, _Traits>::sync() {
989 char* __extbe;1009 char* __extbe;
990 __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);1010 __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
991 size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);1011 size_t __nmemb = static_cast<size_t>(__extbe - __extbuf_);
992 if (fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)1012 if (std::fwrite(__extbuf_, 1, __nmemb, __file_) != __nmemb)
993 return -1;1013 return -1;
994 } while (__r == codecvt_base::partial);1014 } while (__r == codecvt_base::partial);
995 if (__r == codecvt_base::error)1015 if (__r == codecvt_base::error)
996 return -1;1016 return -1;
997 if (fflush(__file_))1017 if (std::fflush(__file_))
998 return -1;1018 return -1;
999 } else if (__cm_ & ios_base::in) {1019 } else if (__cm_ & ios_base::in) {
1000 off_type __c;1020 off_type __c;
...@@ -1029,7 +1049,7 @@ int basic_filebuf<_CharT, _Traits>::sync() {...@@ -1029,7 +1049,7 @@ int basic_filebuf<_CharT, _Traits>::sync() {
1029template <class _CharT, class _Traits>1049template <class _CharT, class _Traits>
1030void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) {1050void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) {
1031 sync();1051 sync();
1032 __cv_ = &std::use_facet<codecvt<char_type, char, state_type> >(__loc);1052 __cv_ = std::addressof(std::use_facet<codecvt<char_type, char, state_type> >(__loc));
1033 bool __old_anc = __always_noconv_;1053 bool __old_anc = __always_noconv_;
1034 __always_noconv_ = __cv_->always_noconv();1054 __always_noconv_ = __cv_->always_noconv();
1035 if (__old_anc != __always_noconv_) {1055 if (__old_anc != __always_noconv_) {
...@@ -1095,7 +1115,7 @@ void basic_filebuf<_CharT, _Traits>::__write_mode() {...@@ -1095,7 +1115,7 @@ void basic_filebuf<_CharT, _Traits>::__write_mode() {
1095// basic_ifstream1115// basic_ifstream
10961116
1097template <class _CharT, class _Traits>1117template <class _CharT, class _Traits>
1098class _LIBCPP_TEMPLATE_VIS basic_ifstream : public basic_istream<_CharT, _Traits> {1118class basic_ifstream : public basic_istream<_CharT, _Traits> {
1099public:1119public:
1100 typedef _CharT char_type;1120 typedef _CharT char_type;
1101 typedef _Traits traits_type;1121 typedef _Traits traits_type;
...@@ -1251,7 +1271,7 @@ inline void basic_ifstream<_CharT, _Traits>::close() {...@@ -1251,7 +1271,7 @@ inline void basic_ifstream<_CharT, _Traits>::close() {
1251// basic_ofstream1271// basic_ofstream
12521272
1253template <class _CharT, class _Traits>1273template <class _CharT, class _Traits>
1254class _LIBCPP_TEMPLATE_VIS basic_ofstream : public basic_ostream<_CharT, _Traits> {1274class basic_ofstream : public basic_ostream<_CharT, _Traits> {
1255public:1275public:
1256 typedef _CharT char_type;1276 typedef _CharT char_type;
1257 typedef _Traits traits_type;1277 typedef _Traits traits_type;
...@@ -1410,7 +1430,7 @@ inline void basic_ofstream<_CharT, _Traits>::close() {...@@ -1410,7 +1430,7 @@ inline void basic_ofstream<_CharT, _Traits>::close() {
1410// basic_fstream1430// basic_fstream
14111431
1412template <class _CharT, class _Traits>1432template <class _CharT, class _Traits>
1413class _LIBCPP_TEMPLATE_VIS basic_fstream : public basic_iostream<_CharT, _Traits> {1433class basic_fstream : public basic_iostream<_CharT, _Traits> {
1414public:1434public:
1415 typedef _CharT char_type;1435 typedef _CharT char_type;
1416 typedef _Traits traits_type;1436 typedef _Traits traits_type;
...@@ -1570,10 +1590,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;...@@ -1570,10 +1590,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
15701590
1571_LIBCPP_END_NAMESPACE_STD1591_LIBCPP_END_NAMESPACE_STD
15721592
1573# endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
1574
1575_LIBCPP_POP_MACROS1593_LIBCPP_POP_MACROS
15761594
1595# endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
1596
1577# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 201597# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1578# include <atomic>1598# include <atomic>
1579# include <concepts>1599# include <concepts>
lib/libcxx/include/functional+5
...@@ -565,6 +565,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -565,6 +565,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
565# include <__functional/bind_front.h>565# include <__functional/bind_front.h>
566# include <__functional/identity.h>566# include <__functional/identity.h>
567# include <__functional/ranges_operations.h>567# include <__functional/ranges_operations.h>
568# include <__type_traits/common_reference.h>
568# include <__type_traits/unwrap_ref.h>569# include <__type_traits/unwrap_ref.h>
569# endif570# endif
570571
...@@ -599,6 +600,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited...@@ -599,6 +600,10 @@ POLICY: For non-variadic implementations, the number of arguments is limited
599# include <utility>600# include <utility>
600# include <vector>601# include <vector>
601# endif602# endif
603
604# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 23
605# include <__vector/vector.h>
606# endif
602#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)607#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
603608
604#endif // _LIBCPP_FUNCTIONAL609#endif // _LIBCPP_FUNCTIONAL
lib/libcxx/include/future+80-85
...@@ -322,8 +322,6 @@ template <class R, class... ArgTypes>...@@ -322,8 +322,6 @@ template <class R, class... ArgTypes>
322class packaged_task<R(ArgTypes...)>322class packaged_task<R(ArgTypes...)>
323{323{
324public:324public:
325 typedef R result_type; // extension
326
327 // construction and destruction325 // construction and destruction
328 packaged_task() noexcept;326 packaged_task() noexcept;
329 template <class F>327 template <class F>
...@@ -393,7 +391,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;...@@ -393,7 +391,7 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
393# include <__system_error/error_code.h>391# include <__system_error/error_code.h>
394# include <__system_error/error_condition.h>392# include <__system_error/error_condition.h>
395# include <__thread/thread.h>393# include <__thread/thread.h>
396# include <__type_traits/add_lvalue_reference.h>394# include <__type_traits/add_reference.h>
397# include <__type_traits/aligned_storage.h>395# include <__type_traits/aligned_storage.h>
398# include <__type_traits/conditional.h>396# include <__type_traits/conditional.h>
399# include <__type_traits/decay.h>397# include <__type_traits/decay.h>
...@@ -427,11 +425,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc){...@@ -427,11 +425,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(future_errc){
427_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)425_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
428426
429template <>427template <>
430struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};428struct is_error_code_enum<future_errc> : public true_type {};
431429
432# ifdef _LIBCPP_CXX03_LANG430# ifdef _LIBCPP_CXX03_LANG
433template <>431template <>
434struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {};432struct is_error_code_enum<future_errc::__lx> : public true_type {};
435# endif433# endif
436434
437// enum class launch435// enum class launch
...@@ -440,7 +438,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)...@@ -440,7 +438,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
440438
441# ifndef _LIBCPP_CXX03_LANG439# ifndef _LIBCPP_CXX03_LANG
442440
443typedef underlying_type<launch>::type __launch_underlying_type;441using __launch_underlying_type _LIBCPP_NODEBUG = __underlying_type_t<launch>;
444442
445inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) {443inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) {
446 return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y));444 return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y));
...@@ -541,7 +539,7 @@ public:...@@ -541,7 +539,7 @@ public:
541 lock_guard<mutex> __lk(__mut_);539 lock_guard<mutex> __lk(__mut_);
542 bool __has_future_attached = (__state_ & __future_attached) != 0;540 bool __has_future_attached = (__state_ & __future_attached) != 0;
543 if (__has_future_attached)541 if (__has_future_attached)
544 __throw_future_error(future_errc::future_already_retrieved);542 std::__throw_future_error(future_errc::future_already_retrieved);
545 this->__add_shared();543 this->__add_shared();
546 __state_ |= __future_attached;544 __state_ |= __future_attached;
547 }545 }
...@@ -563,24 +561,20 @@ public:...@@ -563,24 +561,20 @@ public:
563 template <class _Rep, class _Period>561 template <class _Rep, class _Period>
564 future_status _LIBCPP_HIDE_FROM_ABI wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;562 future_status _LIBCPP_HIDE_FROM_ABI wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const;
565 template <class _Clock, class _Duration>563 template <class _Clock, class _Duration>
566 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS future_status564 _LIBCPP_HIDE_FROM_ABI future_status wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {
567 wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const;565 unique_lock<mutex> __lk(__mut_);
566 if (__state_ & deferred)
567 return future_status::deferred;
568 while (!(__state_ & ready) && _Clock::now() < __abs_time)
569 __cv_.wait_until(__lk, __abs_time);
570 if (__state_ & ready)
571 return future_status::ready;
572 return future_status::timeout;
573 }
568574
569 virtual void __execute();575 virtual void __execute();
570};576};
571577
572template <class _Clock, class _Duration>
573future_status __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs_time) const {
574 unique_lock<mutex> __lk(__mut_);
575 if (__state_ & deferred)
576 return future_status::deferred;
577 while (!(__state_ & ready) && _Clock::now() < __abs_time)
578 __cv_.wait_until(__lk, __abs_time);
579 if (__state_ & ready)
580 return future_status::ready;
581 return future_status::timeout;
582}
583
584template <class _Rep, class _Period>578template <class _Rep, class _Period>
585inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {579inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const {
586 return wait_until(chrono::steady_clock::now() + __rel_time);580 return wait_until(chrono::steady_clock::now() + __rel_time);
...@@ -612,7 +606,7 @@ public:...@@ -612,7 +606,7 @@ public:
612template <class _Rp>606template <class _Rp>
613void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT {607void __assoc_state<_Rp>::__on_zero_shared() _NOEXCEPT {
614 if (this->__state_ & base::__constructed)608 if (this->__state_ & base::__constructed)
615 reinterpret_cast<_Rp*>(&__value_)->~_Rp();609 reinterpret_cast<_Rp*>(std::addressof(__value_))->~_Rp();
616 delete this;610 delete this;
617}611}
618612
...@@ -621,8 +615,8 @@ template <class _Arg>...@@ -621,8 +615,8 @@ template <class _Arg>
621void __assoc_state<_Rp>::set_value(_Arg&& __arg) {615void __assoc_state<_Rp>::set_value(_Arg&& __arg) {
622 unique_lock<mutex> __lk(this->__mut_);616 unique_lock<mutex> __lk(this->__mut_);
623 if (this->__has_value())617 if (this->__has_value())
624 __throw_future_error(future_errc::promise_already_satisfied);618 std::__throw_future_error(future_errc::promise_already_satisfied);
625 ::new ((void*)&__value_) _Rp(std::forward<_Arg>(__arg));619 ::new ((void*)std::addressof(__value_)) _Rp(std::forward<_Arg>(__arg));
626 this->__state_ |= base::__constructed | base::ready;620 this->__state_ |= base::__constructed | base::ready;
627 __cv_.notify_all();621 __cv_.notify_all();
628}622}
...@@ -632,8 +626,8 @@ template <class _Arg>...@@ -632,8 +626,8 @@ template <class _Arg>
632void __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) {626void __assoc_state<_Rp>::set_value_at_thread_exit(_Arg&& __arg) {
633 unique_lock<mutex> __lk(this->__mut_);627 unique_lock<mutex> __lk(this->__mut_);
634 if (this->__has_value())628 if (this->__has_value())
635 __throw_future_error(future_errc::promise_already_satisfied);629 std::__throw_future_error(future_errc::promise_already_satisfied);
636 ::new ((void*)&__value_) _Rp(std::forward<_Arg>(__arg));630 ::new ((void*)std::addressof(__value_)) _Rp(std::forward<_Arg>(__arg));
637 this->__state_ |= base::__constructed;631 this->__state_ |= base::__constructed;
638 __thread_local_data()->__make_ready_at_thread_exit(this);632 __thread_local_data()->__make_ready_at_thread_exit(this);
639}633}
...@@ -644,7 +638,7 @@ _Rp __assoc_state<_Rp>::move() {...@@ -644,7 +638,7 @@ _Rp __assoc_state<_Rp>::move() {
644 this->__sub_wait(__lk);638 this->__sub_wait(__lk);
645 if (this->__exception_ != nullptr)639 if (this->__exception_ != nullptr)
646 std::rethrow_exception(this->__exception_);640 std::rethrow_exception(this->__exception_);
647 return std::move(*reinterpret_cast<_Rp*>(&__value_));641 return std::move(*reinterpret_cast<_Rp*>(std::addressof(__value_)));
648}642}
649643
650template <class _Rp>644template <class _Rp>
...@@ -653,7 +647,7 @@ _Rp& __assoc_state<_Rp>::copy() {...@@ -653,7 +647,7 @@ _Rp& __assoc_state<_Rp>::copy() {
653 this->__sub_wait(__lk);647 this->__sub_wait(__lk);
654 if (this->__exception_ != nullptr)648 if (this->__exception_ != nullptr)
655 std::rethrow_exception(this->__exception_);649 std::rethrow_exception(this->__exception_);
656 return *reinterpret_cast<_Rp*>(&__value_);650 return *reinterpret_cast<_Rp*>(std::addressof(__value_));
657}651}
658652
659template <class _Rp>653template <class _Rp>
...@@ -682,7 +676,7 @@ template <class _Rp>...@@ -682,7 +676,7 @@ template <class _Rp>
682void __assoc_state<_Rp&>::set_value(_Rp& __arg) {676void __assoc_state<_Rp&>::set_value(_Rp& __arg) {
683 unique_lock<mutex> __lk(this->__mut_);677 unique_lock<mutex> __lk(this->__mut_);
684 if (this->__has_value())678 if (this->__has_value())
685 __throw_future_error(future_errc::promise_already_satisfied);679 std::__throw_future_error(future_errc::promise_already_satisfied);
686 __value_ = std::addressof(__arg);680 __value_ = std::addressof(__arg);
687 this->__state_ |= base::__constructed | base::ready;681 this->__state_ |= base::__constructed | base::ready;
688 __cv_.notify_all();682 __cv_.notify_all();
...@@ -692,7 +686,7 @@ template <class _Rp>...@@ -692,7 +686,7 @@ template <class _Rp>
692void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) {686void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) {
693 unique_lock<mutex> __lk(this->__mut_);687 unique_lock<mutex> __lk(this->__mut_);
694 if (this->__has_value())688 if (this->__has_value())
695 __throw_future_error(future_errc::promise_already_satisfied);689 std::__throw_future_error(future_errc::promise_already_satisfied);
696 __value_ = std::addressof(__arg);690 __value_ = std::addressof(__arg);
697 this->__state_ |= base::__constructed;691 this->__state_ |= base::__constructed;
698 __thread_local_data()->__make_ready_at_thread_exit(this);692 __thread_local_data()->__make_ready_at_thread_exit(this);
...@@ -907,14 +901,14 @@ void __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT {...@@ -907,14 +901,14 @@ void __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT {
907}901}
908902
909template <class _Rp>903template <class _Rp>
910class _LIBCPP_TEMPLATE_VIS promise;904class promise;
911template <class _Rp>905template <class _Rp>
912class _LIBCPP_TEMPLATE_VIS shared_future;906class shared_future;
913907
914// future908// future
915909
916template <class _Rp>910template <class _Rp>
917class _LIBCPP_TEMPLATE_VIS future;911class future;
918912
919template <class _Rp, class _Fp>913template <class _Rp, class _Fp>
920_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f);914_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_deferred_assoc_state(_Fp&& __f);
...@@ -923,7 +917,7 @@ template <class _Rp, class _Fp>...@@ -923,7 +917,7 @@ template <class _Rp, class _Fp>
923_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f);917_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f);
924918
925template <class _Rp>919template <class _Rp>
926class _LIBCPP_TEMPLATE_VIS future {920class future {
927 __assoc_state<_Rp>* __state_;921 __assoc_state<_Rp>* __state_;
928922
929 explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp>* __state);923 explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp>* __state);
...@@ -994,7 +988,7 @@ _Rp future<_Rp>::get() {...@@ -994,7 +988,7 @@ _Rp future<_Rp>::get() {
994}988}
995989
996template <class _Rp>990template <class _Rp>
997class _LIBCPP_TEMPLATE_VIS future<_Rp&> {991class future<_Rp&> {
998 __assoc_state<_Rp&>* __state_;992 __assoc_state<_Rp&>* __state_;
999993
1000 explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp&>* __state);994 explicit _LIBCPP_HIDE_FROM_ABI future(__assoc_state<_Rp&>* __state);
...@@ -1119,7 +1113,7 @@ template <class _Callable>...@@ -1119,7 +1113,7 @@ template <class _Callable>
1119class packaged_task;1113class packaged_task;
11201114
1121template <class _Rp>1115template <class _Rp>
1122class _LIBCPP_TEMPLATE_VIS promise {1116class promise {
1123 __assoc_state<_Rp>* __state_;1117 __assoc_state<_Rp>* __state_;
11241118
1125 _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}1119 _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
...@@ -1185,21 +1179,21 @@ promise<_Rp>::~promise() {...@@ -1185,21 +1179,21 @@ promise<_Rp>::~promise() {
1185template <class _Rp>1179template <class _Rp>
1186future<_Rp> promise<_Rp>::get_future() {1180future<_Rp> promise<_Rp>::get_future() {
1187 if (__state_ == nullptr)1181 if (__state_ == nullptr)
1188 __throw_future_error(future_errc::no_state);1182 std::__throw_future_error(future_errc::no_state);
1189 return future<_Rp>(__state_);1183 return future<_Rp>(__state_);
1190}1184}
11911185
1192template <class _Rp>1186template <class _Rp>
1193void promise<_Rp>::set_value(const _Rp& __r) {1187void promise<_Rp>::set_value(const _Rp& __r) {
1194 if (__state_ == nullptr)1188 if (__state_ == nullptr)
1195 __throw_future_error(future_errc::no_state);1189 std::__throw_future_error(future_errc::no_state);
1196 __state_->set_value(__r);1190 __state_->set_value(__r);
1197}1191}
11981192
1199template <class _Rp>1193template <class _Rp>
1200void promise<_Rp>::set_value(_Rp&& __r) {1194void promise<_Rp>::set_value(_Rp&& __r) {
1201 if (__state_ == nullptr)1195 if (__state_ == nullptr)
1202 __throw_future_error(future_errc::no_state);1196 std::__throw_future_error(future_errc::no_state);
1203 __state_->set_value(std::move(__r));1197 __state_->set_value(std::move(__r));
1204}1198}
12051199
...@@ -1207,21 +1201,21 @@ template <class _Rp>...@@ -1207,21 +1201,21 @@ template <class _Rp>
1207void promise<_Rp>::set_exception(exception_ptr __p) {1201void promise<_Rp>::set_exception(exception_ptr __p) {
1208 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr");1202 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr");
1209 if (__state_ == nullptr)1203 if (__state_ == nullptr)
1210 __throw_future_error(future_errc::no_state);1204 std::__throw_future_error(future_errc::no_state);
1211 __state_->set_exception(__p);1205 __state_->set_exception(__p);
1212}1206}
12131207
1214template <class _Rp>1208template <class _Rp>
1215void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) {1209void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) {
1216 if (__state_ == nullptr)1210 if (__state_ == nullptr)
1217 __throw_future_error(future_errc::no_state);1211 std::__throw_future_error(future_errc::no_state);
1218 __state_->set_value_at_thread_exit(__r);1212 __state_->set_value_at_thread_exit(__r);
1219}1213}
12201214
1221template <class _Rp>1215template <class _Rp>
1222void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) {1216void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) {
1223 if (__state_ == nullptr)1217 if (__state_ == nullptr)
1224 __throw_future_error(future_errc::no_state);1218 std::__throw_future_error(future_errc::no_state);
1225 __state_->set_value_at_thread_exit(std::move(__r));1219 __state_->set_value_at_thread_exit(std::move(__r));
1226}1220}
12271221
...@@ -1229,14 +1223,14 @@ template <class _Rp>...@@ -1229,14 +1223,14 @@ template <class _Rp>
1229void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) {1223void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) {
1230 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr");1224 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr");
1231 if (__state_ == nullptr)1225 if (__state_ == nullptr)
1232 __throw_future_error(future_errc::no_state);1226 std::__throw_future_error(future_errc::no_state);
1233 __state_->set_exception_at_thread_exit(__p);1227 __state_->set_exception_at_thread_exit(__p);
1234}1228}
12351229
1236// promise<R&>1230// promise<R&>
12371231
1238template <class _Rp>1232template <class _Rp>
1239class _LIBCPP_TEMPLATE_VIS promise<_Rp&> {1233class promise<_Rp&> {
1240 __assoc_state<_Rp&>* __state_;1234 __assoc_state<_Rp&>* __state_;
12411235
1242 _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}1236 _LIBCPP_HIDE_FROM_ABI explicit promise(nullptr_t) _NOEXCEPT : __state_(nullptr) {}
...@@ -1300,14 +1294,14 @@ promise<_Rp&>::~promise() {...@@ -1300,14 +1294,14 @@ promise<_Rp&>::~promise() {
1300template <class _Rp>1294template <class _Rp>
1301future<_Rp&> promise<_Rp&>::get_future() {1295future<_Rp&> promise<_Rp&>::get_future() {
1302 if (__state_ == nullptr)1296 if (__state_ == nullptr)
1303 __throw_future_error(future_errc::no_state);1297 std::__throw_future_error(future_errc::no_state);
1304 return future<_Rp&>(__state_);1298 return future<_Rp&>(__state_);
1305}1299}
13061300
1307template <class _Rp>1301template <class _Rp>
1308void promise<_Rp&>::set_value(_Rp& __r) {1302void promise<_Rp&>::set_value(_Rp& __r) {
1309 if (__state_ == nullptr)1303 if (__state_ == nullptr)
1310 __throw_future_error(future_errc::no_state);1304 std::__throw_future_error(future_errc::no_state);
1311 __state_->set_value(__r);1305 __state_->set_value(__r);
1312}1306}
13131307
...@@ -1315,14 +1309,14 @@ template <class _Rp>...@@ -1315,14 +1309,14 @@ template <class _Rp>
1315void promise<_Rp&>::set_exception(exception_ptr __p) {1309void promise<_Rp&>::set_exception(exception_ptr __p) {
1316 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr");1310 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception: received nullptr");
1317 if (__state_ == nullptr)1311 if (__state_ == nullptr)
1318 __throw_future_error(future_errc::no_state);1312 std::__throw_future_error(future_errc::no_state);
1319 __state_->set_exception(__p);1313 __state_->set_exception(__p);
1320}1314}
13211315
1322template <class _Rp>1316template <class _Rp>
1323void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) {1317void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) {
1324 if (__state_ == nullptr)1318 if (__state_ == nullptr)
1325 __throw_future_error(future_errc::no_state);1319 std::__throw_future_error(future_errc::no_state);
1326 __state_->set_value_at_thread_exit(__r);1320 __state_->set_value_at_thread_exit(__r);
1327}1321}
13281322
...@@ -1330,7 +1324,7 @@ template <class _Rp>...@@ -1330,7 +1324,7 @@ template <class _Rp>
1330void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) {1324void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) {
1331 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr");1325 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "promise::set_exception_at_thread_exit: received nullptr");
1332 if (__state_ == nullptr)1326 if (__state_ == nullptr)
1333 __throw_future_error(future_errc::no_state);1327 std::__throw_future_error(future_errc::no_state);
1334 __state_->set_exception_at_thread_exit(__p);1328 __state_->set_exception_at_thread_exit(__p);
1335}1329}
13361330
...@@ -1347,8 +1341,17 @@ class _LIBCPP_EXPORTED_FROM_ABI promise<void> {...@@ -1347,8 +1341,17 @@ class _LIBCPP_EXPORTED_FROM_ABI promise<void> {
13471341
1348public:1342public:
1349 promise();1343 promise();
1350 template <class _Allocator>1344 template <class _Alloc>
1351 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS promise(allocator_arg_t, const _Allocator& __a);1345 _LIBCPP_HIDE_FROM_ABI promise(allocator_arg_t, const _Alloc& __a0) {
1346 typedef __assoc_sub_state_alloc<_Alloc> _State;
1347 typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
1348 typedef __allocator_destructor<_A2> _D2;
1349 _A2 __a(__a0);
1350 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
1351 ::new ((void*)std::addressof(*__hold.get())) _State(__a0);
1352 __state_ = std::addressof(*__hold.release());
1353 }
1354
1352 _LIBCPP_HIDE_FROM_ABI promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) { __rhs.__state_ = nullptr; }1355 _LIBCPP_HIDE_FROM_ABI promise(promise&& __rhs) _NOEXCEPT : __state_(__rhs.__state_) { __rhs.__state_ = nullptr; }
1353 promise(const promise& __rhs) = delete;1356 promise(const promise& __rhs) = delete;
1354 ~promise();1357 ~promise();
...@@ -1374,24 +1377,13 @@ public:...@@ -1374,24 +1377,13 @@ public:
1374 void set_exception_at_thread_exit(exception_ptr __p);1377 void set_exception_at_thread_exit(exception_ptr __p);
1375};1378};
13761379
1377template <class _Alloc>
1378promise<void>::promise(allocator_arg_t, const _Alloc& __a0) {
1379 typedef __assoc_sub_state_alloc<_Alloc> _State;
1380 typedef typename __allocator_traits_rebind<_Alloc, _State>::type _A2;
1381 typedef __allocator_destructor<_A2> _D2;
1382 _A2 __a(__a0);
1383 unique_ptr<_State, _D2> __hold(__a.allocate(1), _D2(__a, 1));
1384 ::new ((void*)std::addressof(*__hold.get())) _State(__a0);
1385 __state_ = std::addressof(*__hold.release());
1386}
1387
1388template <class _Rp>1380template <class _Rp>
1389inline _LIBCPP_HIDE_FROM_ABI void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT {1381inline _LIBCPP_HIDE_FROM_ABI void swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT {
1390 __x.swap(__y);1382 __x.swap(__y);
1391}1383}
13921384
1393template <class _Rp, class _Alloc>1385template <class _Rp, class _Alloc>
1394struct _LIBCPP_TEMPLATE_VIS uses_allocator<promise<_Rp>, _Alloc> : public true_type {};1386struct uses_allocator<promise<_Rp>, _Alloc> : public true_type {};
13951387
1396// packaged_task1388// packaged_task
13971389
...@@ -1610,10 +1602,7 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes......@@ -1610,10 +1602,7 @@ inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes...
1610}1602}
16111603
1612template <class _Rp, class... _ArgTypes>1604template <class _Rp, class... _ArgTypes>
1613class _LIBCPP_TEMPLATE_VIS packaged_task<_Rp(_ArgTypes...)> {1605class packaged_task<_Rp(_ArgTypes...)> {
1614public:
1615 using result_type _LIBCPP_DEPRECATED = _Rp; // extension
1616
1617private:1606private:
1618 __packaged_task_function<_Rp(_ArgTypes...)> __f_;1607 __packaged_task_function<_Rp(_ArgTypes...)> __f_;
1619 promise<_Rp> __p_;1608 promise<_Rp> __p_;
...@@ -1665,9 +1654,9 @@ public:...@@ -1665,9 +1654,9 @@ public:
1665template <class _Rp, class... _ArgTypes>1654template <class _Rp, class... _ArgTypes>
1666void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {1655void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1667 if (__p_.__state_ == nullptr)1656 if (__p_.__state_ == nullptr)
1668 __throw_future_error(future_errc::no_state);1657 std::__throw_future_error(future_errc::no_state);
1669 if (__p_.__state_->__has_value())1658 if (__p_.__state_->__has_value())
1670 __throw_future_error(future_errc::promise_already_satisfied);1659 std::__throw_future_error(future_errc::promise_already_satisfied);
1671# if _LIBCPP_HAS_EXCEPTIONS1660# if _LIBCPP_HAS_EXCEPTIONS
1672 try {1661 try {
1673# endif // _LIBCPP_HAS_EXCEPTIONS1662# endif // _LIBCPP_HAS_EXCEPTIONS
...@@ -1682,9 +1671,9 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {...@@ -1682,9 +1671,9 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1682template <class _Rp, class... _ArgTypes>1671template <class _Rp, class... _ArgTypes>
1683void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) {1672void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) {
1684 if (__p_.__state_ == nullptr)1673 if (__p_.__state_ == nullptr)
1685 __throw_future_error(future_errc::no_state);1674 std::__throw_future_error(future_errc::no_state);
1686 if (__p_.__state_->__has_value())1675 if (__p_.__state_->__has_value())
1687 __throw_future_error(future_errc::promise_already_satisfied);1676 std::__throw_future_error(future_errc::promise_already_satisfied);
1688# if _LIBCPP_HAS_EXCEPTIONS1677# if _LIBCPP_HAS_EXCEPTIONS
1689 try {1678 try {
1690# endif // _LIBCPP_HAS_EXCEPTIONS1679# endif // _LIBCPP_HAS_EXCEPTIONS
...@@ -1699,15 +1688,12 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __...@@ -1699,15 +1688,12 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __
1699template <class _Rp, class... _ArgTypes>1688template <class _Rp, class... _ArgTypes>
1700void packaged_task<_Rp(_ArgTypes...)>::reset() {1689void packaged_task<_Rp(_ArgTypes...)>::reset() {
1701 if (!valid())1690 if (!valid())
1702 __throw_future_error(future_errc::no_state);1691 std::__throw_future_error(future_errc::no_state);
1703 __p_ = promise<_Rp>();1692 __p_ = promise<_Rp>();
1704}1693}
17051694
1706template <class... _ArgTypes>1695template <class... _ArgTypes>
1707class _LIBCPP_TEMPLATE_VIS packaged_task<void(_ArgTypes...)> {1696class packaged_task<void(_ArgTypes...)> {
1708public:
1709 using result_type _LIBCPP_DEPRECATED = void; // extension
1710
1711private:1697private:
1712 __packaged_task_function<void(_ArgTypes...)> __f_;1698 __packaged_task_function<void(_ArgTypes...)> __f_;
1713 promise<void> __p_;1699 promise<void> __p_;
...@@ -1767,9 +1753,9 @@ packaged_task(_Fp) -> packaged_task<_Stripped>;...@@ -1767,9 +1753,9 @@ packaged_task(_Fp) -> packaged_task<_Stripped>;
1767template <class... _ArgTypes>1753template <class... _ArgTypes>
1768void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {1754void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1769 if (__p_.__state_ == nullptr)1755 if (__p_.__state_ == nullptr)
1770 __throw_future_error(future_errc::no_state);1756 std::__throw_future_error(future_errc::no_state);
1771 if (__p_.__state_->__has_value())1757 if (__p_.__state_->__has_value())
1772 __throw_future_error(future_errc::promise_already_satisfied);1758 std::__throw_future_error(future_errc::promise_already_satisfied);
1773# if _LIBCPP_HAS_EXCEPTIONS1759# if _LIBCPP_HAS_EXCEPTIONS
1774 try {1760 try {
1775# endif // _LIBCPP_HAS_EXCEPTIONS1761# endif // _LIBCPP_HAS_EXCEPTIONS
...@@ -1785,9 +1771,9 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {...@@ -1785,9 +1771,9 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
1785template <class... _ArgTypes>1771template <class... _ArgTypes>
1786void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) {1772void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) {
1787 if (__p_.__state_ == nullptr)1773 if (__p_.__state_ == nullptr)
1788 __throw_future_error(future_errc::no_state);1774 std::__throw_future_error(future_errc::no_state);
1789 if (__p_.__state_->__has_value())1775 if (__p_.__state_->__has_value())
1790 __throw_future_error(future_errc::promise_already_satisfied);1776 std::__throw_future_error(future_errc::promise_already_satisfied);
1791# if _LIBCPP_HAS_EXCEPTIONS1777# if _LIBCPP_HAS_EXCEPTIONS
1792 try {1778 try {
1793# endif // _LIBCPP_HAS_EXCEPTIONS1779# endif // _LIBCPP_HAS_EXCEPTIONS
...@@ -1803,7 +1789,7 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _...@@ -1803,7 +1789,7 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _
1803template <class... _ArgTypes>1789template <class... _ArgTypes>
1804void packaged_task<void(_ArgTypes...)>::reset() {1790void packaged_task<void(_ArgTypes...)>::reset() {
1805 if (!valid())1791 if (!valid())
1806 __throw_future_error(future_errc::no_state);1792 std::__throw_future_error(future_errc::no_state);
1807 __p_ = promise<void>();1793 __p_ = promise<void>();
1808}1794}
18091795
...@@ -1815,7 +1801,7 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __...@@ -1815,7 +1801,7 @@ swap(packaged_task<_Rp(_ArgTypes...)>& __x, packaged_task<_Rp(_ArgTypes...)>& __
18151801
1816# if _LIBCPP_STD_VER <= 141802# if _LIBCPP_STD_VER <= 14
1817template <class _Callable, class _Alloc>1803template <class _Callable, class _Alloc>
1818struct _LIBCPP_TEMPLATE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {};1804struct uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {};
1819# endif1805# endif
18201806
1821template <class _Rp, class _Fp>1807template <class _Rp, class _Fp>
...@@ -1829,7 +1815,16 @@ template <class _Rp, class _Fp>...@@ -1829,7 +1815,16 @@ template <class _Rp, class _Fp>
1829_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) {1815_LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) {
1830 unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h(1816 unique_ptr<__async_assoc_state<_Rp, _Fp>, __release_shared_count> __h(
1831 new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f)));1817 new __async_assoc_state<_Rp, _Fp>(std::forward<_Fp>(__f)));
1832 std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach();1818# if _LIBCPP_HAS_EXCEPTIONS
1819 try {
1820# endif
1821 std::thread(&__async_assoc_state<_Rp, _Fp>::__execute, __h.get()).detach();
1822# if _LIBCPP_HAS_EXCEPTIONS
1823 } catch (...) {
1824 __h->__make_ready();
1825 throw;
1826 }
1827# endif
1833 return future<_Rp>(__h.get());1828 return future<_Rp>(__h.get());
1834}1829}
18351830
...@@ -1899,7 +1894,7 @@ async(_Fp&& __f, _Args&&... __args) {...@@ -1899,7 +1894,7 @@ async(_Fp&& __f, _Args&&... __args) {
1899// shared_future1894// shared_future
19001895
1901template <class _Rp>1896template <class _Rp>
1902class _LIBCPP_TEMPLATE_VIS shared_future {1897class shared_future {
1903 __assoc_state<_Rp>* __state_;1898 __assoc_state<_Rp>* __state_;
19041899
1905public:1900public:
...@@ -1955,7 +1950,7 @@ shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _N...@@ -1955,7 +1950,7 @@ shared_future<_Rp>& shared_future<_Rp>::operator=(const shared_future& __rhs) _N
1955}1950}
19561951
1957template <class _Rp>1952template <class _Rp>
1958class _LIBCPP_TEMPLATE_VIS shared_future<_Rp&> {1953class shared_future<_Rp&> {
1959 __assoc_state<_Rp&>* __state_;1954 __assoc_state<_Rp&>* __state_;
19601955
1961public:1956public:
lib/libcxx/include/initializer_list+2-2
...@@ -43,7 +43,7 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in...@@ -43,7 +43,7 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
43*/43*/
4444
45#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)45#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
46# include <__cxx03/initializer_list>46# include <__cxx03/__config>
47#else47#else
48# include <__config>48# include <__config>
49# include <__cstddef/size_t.h>49# include <__cstddef/size_t.h>
...@@ -59,7 +59,7 @@ namespace std // purposefully not versioned...@@ -59,7 +59,7 @@ namespace std // purposefully not versioned
59# ifndef _LIBCPP_CXX03_LANG59# ifndef _LIBCPP_CXX03_LANG
6060
61template <class _Ep>61template <class _Ep>
62class _LIBCPP_TEMPLATE_VIS initializer_list {62class _LIBCPP_NO_SPECIALIZATIONS initializer_list {
63 const _Ep* __begin_;63 const _Ep* __begin_;
64 size_t __size_;64 size_t __size_;
6565
lib/libcxx/include/iomanip+8-1
...@@ -49,10 +49,12 @@ template <class charT, class traits, class Allocator>...@@ -49,10 +49,12 @@ template <class charT, class traits, class Allocator>
4949
50# if _LIBCPP_HAS_LOCALIZATION50# if _LIBCPP_HAS_LOCALIZATION
5151
52# include <__iterator/istreambuf_iterator.h>
53# include <__locale_dir/money.h>
54# include <__locale_dir/time.h>
52# include <__ostream/put_character_sequence.h>55# include <__ostream/put_character_sequence.h>
53# include <ios>56# include <ios>
54# include <iosfwd>57# include <iosfwd>
55# include <locale>
56# include <version>58# include <version>
5759
58# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)60# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -564,6 +566,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -564,6 +566,11 @@ _LIBCPP_END_NAMESPACE_STD
564# include <unordered_map>566# include <unordered_map>
565# include <vector>567# include <vector>
566# endif568# endif
569
570# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
571# include <locale>
572# endif
573
567#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)574#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
568575
569#endif // _LIBCPP_IOMANIP576#endif // _LIBCPP_IOMANIP
lib/libcxx/include/ios+9-8
...@@ -216,6 +216,11 @@ storage-class-specifier const error_category& iostream_category() noexcept;...@@ -216,6 +216,11 @@ storage-class-specifier const error_category& iostream_category() noexcept;
216#else216#else
217# include <__config>217# include <__config>
218218
219// standard-mandated includes
220
221// [ios.syn]
222# include <iosfwd>
223
219# if _LIBCPP_HAS_LOCALIZATION224# if _LIBCPP_HAS_LOCALIZATION
220225
221# include <__fwd/ios.h>226# include <__fwd/ios.h>
...@@ -230,11 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept;...@@ -230,11 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept;
230# include <__verbose_abort>235# include <__verbose_abort>
231# include <version>236# include <version>
232237
233// standard-mandated includes
234
235// [ios.syn]
236# include <iosfwd>
237
238# if _LIBCPP_HAS_ATOMIC_HEADER238# if _LIBCPP_HAS_ATOMIC_HEADER
239# include <__atomic/atomic.h> // for __xindex_239# include <__atomic/atomic.h> // for __xindex_
240# endif240# endif
...@@ -418,11 +418,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1};...@@ -418,11 +418,11 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1};
418_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)418_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
419419
420template <>420template <>
421struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};421struct is_error_code_enum<io_errc> : public true_type {};
422422
423# ifdef _LIBCPP_CXX03_LANG423# ifdef _LIBCPP_CXX03_LANG
424template <>424template <>
425struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};425struct is_error_code_enum<io_errc::__lx> : public true_type {};
426# endif426# endif
427427
428_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;428_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;
...@@ -559,7 +559,7 @@ private:...@@ -559,7 +559,7 @@ private:
559};559};
560560
561template <class _CharT, class _Traits>561template <class _CharT, class _Traits>
562class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base {562class basic_ios : public ios_base {
563public:563public:
564 // types:564 // types:
565 typedef _CharT char_type;565 typedef _CharT char_type;
...@@ -887,6 +887,7 @@ _LIBCPP_POP_MACROS...@@ -887,6 +887,7 @@ _LIBCPP_POP_MACROS
887# include <limits>887# include <limits>
888# include <mutex>888# include <mutex>
889# include <new>889# include <new>
890# include <optional>
890# include <stdexcept>891# include <stdexcept>
891# include <system_error>892# include <system_error>
892# include <type_traits>893# include <type_traits>
lib/libcxx/include/iosfwd+3-3
...@@ -127,12 +127,12 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20...@@ -127,12 +127,12 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20
127_LIBCPP_BEGIN_NAMESPACE_STD127_LIBCPP_BEGIN_NAMESPACE_STD
128128
129template <class _CharT, class _Traits = char_traits<_CharT> >129template <class _CharT, class _Traits = char_traits<_CharT> >
130class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;130class istreambuf_iterator;
131template <class _CharT, class _Traits = char_traits<_CharT> >131template <class _CharT, class _Traits = char_traits<_CharT> >
132class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator;132class ostreambuf_iterator;
133133
134template <class _State>134template <class _State>
135class _LIBCPP_TEMPLATE_VIS fpos;135class fpos;
136typedef fpos<mbstate_t> streampos;136typedef fpos<mbstate_t> streampos;
137# if _LIBCPP_HAS_WIDE_CHARACTERS137# if _LIBCPP_HAS_WIDE_CHARACTERS
138typedef fpos<mbstate_t> wstreampos;138typedef fpos<mbstate_t> wstreampos;
lib/libcxx/include/istream+65-33
...@@ -167,6 +167,7 @@ template <class Stream, class T>...@@ -167,6 +167,7 @@ template <class Stream, class T>
167167
168# include <__fwd/istream.h>168# include <__fwd/istream.h>
169# include <__iterator/istreambuf_iterator.h>169# include <__iterator/istreambuf_iterator.h>
170# include <__locale_dir/num.h>
170# include <__ostream/basic_ostream.h>171# include <__ostream/basic_ostream.h>
171# include <__type_traits/conjunction.h>172# include <__type_traits/conjunction.h>
172# include <__type_traits/enable_if.h>173# include <__type_traits/enable_if.h>
...@@ -176,7 +177,7 @@ template <class Stream, class T>...@@ -176,7 +177,7 @@ template <class Stream, class T>
176# include <__utility/forward.h>177# include <__utility/forward.h>
177# include <bitset>178# include <bitset>
178# include <ios>179# include <ios>
179# include <locale>180# include <streambuf>
180# include <version>181# include <version>
181182
182# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)183# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
...@@ -189,7 +190,7 @@ _LIBCPP_PUSH_MACROS...@@ -189,7 +190,7 @@ _LIBCPP_PUSH_MACROS
189_LIBCPP_BEGIN_NAMESPACE_STD190_LIBCPP_BEGIN_NAMESPACE_STD
190191
191template <class _CharT, class _Traits>192template <class _CharT, class _Traits>
192class _LIBCPP_TEMPLATE_VIS basic_istream : virtual public basic_ios<_CharT, _Traits> {193class basic_istream : virtual public basic_ios<_CharT, _Traits> {
193 streamsize __gc_;194 streamsize __gc_;
194195
195 _LIBCPP_HIDE_FROM_ABI void __inc_gcount() {196 _LIBCPP_HIDE_FROM_ABI void __inc_gcount() {
...@@ -228,7 +229,7 @@ public:...@@ -228,7 +229,7 @@ public:
228 basic_istream& operator=(const basic_istream& __rhs) = delete;229 basic_istream& operator=(const basic_istream& __rhs) = delete;
229230
230 // 27.7.1.1.3 Prefix/suffix:231 // 27.7.1.1.3 Prefix/suffix:
231 class _LIBCPP_TEMPLATE_VIS sentry;232 class sentry;
232233
233 // 27.7.1.2 Formatted input:234 // 27.7.1.2 Formatted input:
234 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) {235 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)) {
...@@ -305,7 +306,7 @@ public:...@@ -305,7 +306,7 @@ public:
305};306};
306307
307template <class _CharT, class _Traits>308template <class _CharT, class _Traits>
308class _LIBCPP_TEMPLATE_VIS basic_istream<_CharT, _Traits>::sentry {309class basic_istream<_CharT, _Traits>::sentry {
309 bool __ok_;310 bool __ok_;
310311
311public:312public:
...@@ -1167,9 +1168,7 @@ _LIBCPP_HIDE_FROM_ABI _Stream&& operator>>(_Stream&& __is, _Tp&& __x) {...@@ -1167,9 +1168,7 @@ _LIBCPP_HIDE_FROM_ABI _Stream&& operator>>(_Stream&& __is, _Tp&& __x) {
1167}1168}
11681169
1169template <class _CharT, class _Traits>1170template <class _CharT, class _Traits>
1170class _LIBCPP_TEMPLATE_VIS basic_iostream1171class basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> {
1171 : public basic_istream<_CharT, _Traits>,
1172 public basic_ostream<_CharT, _Traits> {
1173public:1172public:
1174 // types:1173 // types:
1175 typedef _CharT char_type;1174 typedef _CharT char_type;
...@@ -1265,41 +1264,70 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&...@@ -1265,41 +1264,70 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>&
1265getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) {1264getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) {
1266 ios_base::iostate __state = ios_base::goodbit;1265 ios_base::iostate __state = ios_base::goodbit;
1267 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);1266 typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
1268 if (__sen) {1267 if (!__sen)
1268 return __is;
1269# if _LIBCPP_HAS_EXCEPTIONS1269# if _LIBCPP_HAS_EXCEPTIONS
1270 try {1270 try {
1271# endif1271# endif
1272 __str.clear();1272 __str.clear();
1273 streamsize __extr = 0;1273
1274 while (true) {1274 auto& __buffer = *__is.rdbuf();
1275 typename _Traits::int_type __i = __is.rdbuf()->sbumpc();1275
1276 if (_Traits::eq_int_type(__i, _Traits::eof())) {1276 auto __next = __buffer.sgetc();
1277 __state |= ios_base::eofbit;1277 for (; !_Traits::eq_int_type(__next, _Traits::eof()); __next = __buffer.sgetc()) {
1278 break;1278 const auto* __first = __buffer.gptr();
1279 const auto* __last = __buffer.egptr();
1280 _CharT __1buf;
1281
1282 if (__first == __last) {
1283 __1buf = __next;
1284 __first = std::addressof(__1buf);
1285 __last = std::addressof(__1buf) + 1;
1286 }
1287
1288 auto __bump_stream = [&](ptrdiff_t __diff) {
1289 if (__first == std::addressof(__1buf)) {
1290 _LIBCPP_ASSERT_INTERNAL(__diff == 0 || __diff == 1, "trying to bump stream further than buffer size");
1291 if (__diff != 0)
1292 __buffer.sbumpc();
1293 } else {
1294 __buffer.__gbump_ptrdiff(__diff);
1279 }1295 }
1280 ++__extr;1296 };
1281 _CharT __ch = _Traits::to_char_type(__i);1297
1282 if (_Traits::eq(__ch, __dlm))1298 const auto* const __match = _Traits::find(__first, __last - __first, __dlm);
1283 break;1299 if (__match)
1284 __str.push_back(__ch);1300 __last = __match;
1285 if (__str.size() == __str.max_size()) {1301
1286 __state |= ios_base::failbit;1302 if (auto __cap = __str.max_size() - __str.size(); __cap > static_cast<size_t>(__last - __first)) {
1303 __str.append(__first, __last);
1304 __bump_stream(__last - __first);
1305
1306 if (__match) {
1307 __bump_stream(1); // Remove the matched character
1287 break;1308 break;
1288 }1309 }
1289 }1310 } else {
1290 if (__extr == 0)1311 __str.append(__first, __cap);
1312 __bump_stream(__cap);
1291 __state |= ios_base::failbit;1313 __state |= ios_base::failbit;
1292# if _LIBCPP_HAS_EXCEPTIONS1314 break;
1293 } catch (...) {
1294 __state |= ios_base::badbit;
1295 __is.__setstate_nothrow(__state);
1296 if (__is.exceptions() & ios_base::badbit) {
1297 throw;
1298 }1315 }
1299 }1316 }
1300# endif1317
1301 __is.setstate(__state);1318 if (_Traits::eq_int_type(__next, _Traits::eof()))
1319 __state |= ios_base::eofbit | (__str.empty() ? ios_base::failbit : ios_base::goodbit);
1320
1321# if _LIBCPP_HAS_EXCEPTIONS
1322 } catch (...) {
1323 __state |= ios_base::badbit;
1324 __is.__setstate_nothrow(__state);
1325 if (__is.exceptions() & ios_base::badbit) {
1326 throw;
1327 }
1302 }1328 }
1329# endif
1330 __is.setstate(__state);
1303 return __is;1331 return __is;
1304}1332}
13051333
...@@ -1384,6 +1412,10 @@ _LIBCPP_POP_MACROS...@@ -1384,6 +1412,10 @@ _LIBCPP_POP_MACROS
1384# include <type_traits>1412# include <type_traits>
1385# endif1413# endif
13861414
1415# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
1416# include <locale>
1417# endif
1418
1387#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)1419#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
13881420
1389#endif // _LIBCPP_ISTREAM1421#endif // _LIBCPP_ISTREAM
lib/libcxx/include/iterator+1-1
...@@ -530,7 +530,7 @@ public:...@@ -530,7 +530,7 @@ public:
530 istream_iterator(); // constexpr since C++11530 istream_iterator(); // constexpr since C++11
531 constexpr istream_iterator(default_sentinel_t); // since C++20531 constexpr istream_iterator(default_sentinel_t); // since C++20
532 istream_iterator(istream_type& s);532 istream_iterator(istream_type& s);
533 istream_iterator(const istream_iterator& x);533 constexpr istream_iterator(const istream_iterator& x) noexcept(see below);
534 ~istream_iterator();534 ~istream_iterator();
535535
536 const T& operator*() const;536 const T& operator*() const;
lib/libcxx/include/latch+1-1
...@@ -41,7 +41,7 @@ namespace std...@@ -41,7 +41,7 @@ namespace std
41*/41*/
4242
43#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)43#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
44# include <__cxx03/latch>44# include <__cxx03/__config>
45#else45#else
46# include <__config>46# include <__config>
4747
lib/libcxx/include/limits+7-20
...@@ -108,7 +108,6 @@ template<> class numeric_limits<cv long double>;...@@ -108,7 +108,6 @@ template<> class numeric_limits<cv long double>;
108# include <__config>108# include <__config>
109# include <__type_traits/is_arithmetic.h>109# include <__type_traits/is_arithmetic.h>
110# include <__type_traits/is_signed.h>110# include <__type_traits/is_signed.h>
111# include <__type_traits/remove_cv.h>
112111
113# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)112# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
114# pragma GCC system_header113# pragma GCC system_header
...@@ -178,16 +177,6 @@ protected:...@@ -178,16 +177,6 @@ protected:
178 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;177 static _LIBCPP_CONSTEXPR const float_round_style round_style = round_toward_zero;
179};178};
180179
181template <class _Tp, int __digits, bool _IsSigned>
182struct __libcpp_compute_min {
183 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits);
184};
185
186template <class _Tp, int __digits>
187struct __libcpp_compute_min<_Tp, __digits, false> {
188 static _LIBCPP_CONSTEXPR const _Tp value = _Tp(0);
189};
190
191template <class _Tp>180template <class _Tp>
192class __libcpp_numeric_limits<_Tp, true> {181class __libcpp_numeric_limits<_Tp, true> {
193protected:182protected:
...@@ -199,7 +188,7 @@ protected:...@@ -199,7 +188,7 @@ protected:
199 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);188 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
200 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;189 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
201 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;190 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
202 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;191 static _LIBCPP_CONSTEXPR const type __min = is_signed ? _Tp(_Tp(1) << digits) : 0;
203 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);192 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
204 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }193 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
205 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }194 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
...@@ -250,10 +239,8 @@ protected:...@@ -250,10 +239,8 @@ protected:
250 static _LIBCPP_CONSTEXPR const int digits = 1;239 static _LIBCPP_CONSTEXPR const int digits = 1;
251 static _LIBCPP_CONSTEXPR const int digits10 = 0;240 static _LIBCPP_CONSTEXPR const int digits10 = 0;
252 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;241 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
253 static _LIBCPP_CONSTEXPR const type __min = false;242 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return false; }
254 static _LIBCPP_CONSTEXPR const type __max = true;243 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return true; }
255 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
256 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
257 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }244 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
258245
259 static _LIBCPP_CONSTEXPR const bool is_integer = true;246 static _LIBCPP_CONSTEXPR const bool is_integer = true;
...@@ -462,7 +449,7 @@ protected:...@@ -462,7 +449,7 @@ protected:
462};449};
463450
464template <class _Tp>451template <class _Tp>
465class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> {452class numeric_limits : private __libcpp_numeric_limits<_Tp> {
466 typedef __libcpp_numeric_limits<_Tp> __base;453 typedef __libcpp_numeric_limits<_Tp> __base;
467 typedef typename __base::type type;454 typedef typename __base::type type;
468455
...@@ -521,13 +508,13 @@ public:...@@ -521,13 +508,13 @@ public:
521};508};
522509
523template <class _Tp>510template <class _Tp>
524class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};511class numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
525512
526template <class _Tp>513template <class _Tp>
527class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};514class numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};
528515
529template <class _Tp>516template <class _Tp>
530class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};517class numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};
531518
532_LIBCPP_END_NAMESPACE_STD519_LIBCPP_END_NAMESPACE_STD
533520
lib/libcxx/include/list+343-247
...@@ -60,9 +60,9 @@ public:...@@ -60,9 +60,9 @@ public:
6060
61 list& operator=(const list& x);61 list& operator=(const list& x);
62 list& operator=(list&& x)62 list& operator=(list&& x)
63 noexcept(63 noexcept((__node_alloc_traits::propagate_on_container_move_assignment::value &&
64 allocator_type::propagate_on_container_move_assignment::value &&64 is_nothrow_move_assignable<__node_allocator>::value) ||
65 is_nothrow_move_assignable<allocator_type>::value);65 allocator_traits<allocator_type>::is_always_equal::value);
66 list& operator=(initializer_list<value_type>);66 list& operator=(initializer_list<value_type>);
67 template <class Iter>67 template <class Iter>
68 void assign(Iter first, Iter last);68 void assign(Iter first, Iter last);
...@@ -286,12 +286,6 @@ struct __list_node_pointer_traits {...@@ -286,12 +286,6 @@ struct __list_node_pointer_traits {
286 "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the "286 "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the "
287 "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");287 "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
288# endif288# endif
289
290 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; }
291
292 static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) {
293 return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p));
294 }
295};289};
296290
297template <class _Tp, class _VoidPtr>291template <class _Tp, class _VoidPtr>
...@@ -303,14 +297,20 @@ struct __list_node_base {...@@ -303,14 +297,20 @@ struct __list_node_base {
303 __base_pointer __prev_;297 __base_pointer __prev_;
304 __base_pointer __next_;298 __base_pointer __next_;
305299
306 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}300 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
307301
302 _LIBCPP_CONSTEXPR_SINCE_CXX26
308 _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)303 _LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)
309 : __prev_(__prev), __next_(__next) {}304 : __prev_(__prev), __next_(__next) {}
310305
311 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }306 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() {
307 return pointer_traits<__base_pointer>::pointer_to(*this);
308 }
312309
313 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { return static_cast<__node_pointer>(__self()); }310 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() {
311 return pointer_traits<__node_pointer>::pointer_to(
312 *static_cast<typename pointer_traits<__node_pointer>::element_type*>(this));
313 }
314};314};
315315
316template <class _Tp, class _VoidPtr>316template <class _Tp, class _VoidPtr>
...@@ -325,7 +325,7 @@ private:...@@ -325,7 +325,7 @@ private:
325 };325 };
326326
327public:327public:
328 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }328 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
329# else329# else
330330
331private:331private:
...@@ -338,27 +338,32 @@ public:...@@ -338,27 +338,32 @@ public:
338 typedef __list_node_base<_Tp, _VoidPtr> __base;338 typedef __list_node_base<_Tp, _VoidPtr> __base;
339 typedef typename __base::__base_pointer __base_pointer;339 typedef typename __base::__base_pointer __base_pointer;
340340
341 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {}341 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next)
342 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}342 : __base(__prev, __next) {}
343 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}
343344
344 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); }345 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() {
346 return pointer_traits<__base_pointer>::pointer_to(
347 *static_cast<typename pointer_traits<__base_pointer>::element_type*>(std::addressof(*this)));
348 }
345};349};
346350
347template <class _Tp, class _Alloc = allocator<_Tp> >351template <class _Tp, class _Alloc = allocator<_Tp> >
348class _LIBCPP_TEMPLATE_VIS list;352class list;
349template <class _Tp, class _Alloc>353template <class _Tp, class _Alloc>
350class __list_imp;354class __list_imp;
351template <class _Tp, class _VoidPtr>355template <class _Tp, class _VoidPtr>
352class _LIBCPP_TEMPLATE_VIS __list_const_iterator;356class __list_const_iterator;
353357
354template <class _Tp, class _VoidPtr>358template <class _Tp, class _VoidPtr>
355class _LIBCPP_TEMPLATE_VIS __list_iterator {359class __list_iterator {
356 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;360 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
357 typedef typename _NodeTraits::__base_pointer __base_pointer;361 typedef typename _NodeTraits::__base_pointer __base_pointer;
358362
359 __base_pointer __ptr_;363 __base_pointer __ptr_;
360364
361 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}365 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT
366 : __ptr_(__p) {}
362367
363 template <class, class>368 template <class, class>
364 friend class list;369 friend class list;
...@@ -374,49 +379,54 @@ public:...@@ -374,49 +379,54 @@ public:
374 typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;379 typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;
375 typedef typename pointer_traits<pointer>::difference_type difference_type;380 typedef typename pointer_traits<pointer>::difference_type difference_type;
376381
377 _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {}382 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
378383
379 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }384 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
380 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {385 return __ptr_->__as_node()->__get_value();
386 }
387 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
381 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());388 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
382 }389 }
383390
384 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() {391 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() {
385 __ptr_ = __ptr_->__next_;392 __ptr_ = __ptr_->__next_;
386 return *this;393 return *this;
387 }394 }
388 _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) {395 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) {
389 __list_iterator __t(*this);396 __list_iterator __t(*this);
390 ++(*this);397 ++(*this);
391 return __t;398 return __t;
392 }399 }
393400
394 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() {401 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() {
395 __ptr_ = __ptr_->__prev_;402 __ptr_ = __ptr_->__prev_;
396 return *this;403 return *this;
397 }404 }
398 _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) {405 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) {
399 __list_iterator __t(*this);406 __list_iterator __t(*this);
400 --(*this);407 --(*this);
401 return __t;408 return __t;
402 }409 }
403410
404 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_iterator& __x, const __list_iterator& __y) {411 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
412 operator==(const __list_iterator& __x, const __list_iterator& __y) {
405 return __x.__ptr_ == __y.__ptr_;413 return __x.__ptr_ == __y.__ptr_;
406 }414 }
407 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_iterator& __x, const __list_iterator& __y) {415 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
416 operator!=(const __list_iterator& __x, const __list_iterator& __y) {
408 return !(__x == __y);417 return !(__x == __y);
409 }418 }
410};419};
411420
412template <class _Tp, class _VoidPtr>421template <class _Tp, class _VoidPtr>
413class _LIBCPP_TEMPLATE_VIS __list_const_iterator {422class __list_const_iterator {
414 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;423 typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits;
415 typedef typename _NodeTraits::__base_pointer __base_pointer;424 typedef typename _NodeTraits::__base_pointer __base_pointer;
416425
417 __base_pointer __ptr_;426 __base_pointer __ptr_;
418427
419 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}428 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT
429 : __ptr_(__p) {}
420430
421 template <class, class>431 template <class, class>
422 friend class list;432 friend class list;
...@@ -430,39 +440,43 @@ public:...@@ -430,39 +440,43 @@ public:
430 typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer;440 typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer;
431 typedef typename pointer_traits<pointer>::difference_type difference_type;441 typedef typename pointer_traits<pointer>::difference_type difference_type;
432442
433 _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}443 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
434 _LIBCPP_HIDE_FROM_ABI __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT444 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
435 : __ptr_(__p.__ptr_) {}445 __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
436446
437 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }447 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
438 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {448 return __ptr_->__as_node()->__get_value();
449 }
450 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
439 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());451 return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
440 }452 }
441453
442 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() {454 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() {
443 __ptr_ = __ptr_->__next_;455 __ptr_ = __ptr_->__next_;
444 return *this;456 return *this;
445 }457 }
446 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) {458 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) {
447 __list_const_iterator __t(*this);459 __list_const_iterator __t(*this);
448 ++(*this);460 ++(*this);
449 return __t;461 return __t;
450 }462 }
451463
452 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() {464 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() {
453 __ptr_ = __ptr_->__prev_;465 __ptr_ = __ptr_->__prev_;
454 return *this;466 return *this;
455 }467 }
456 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) {468 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) {
457 __list_const_iterator __t(*this);469 __list_const_iterator __t(*this);
458 --(*this);470 --(*this);
459 return __t;471 return __t;
460 }472 }
461473
462 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) {474 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
475 operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) {
463 return __x.__ptr_ == __y.__ptr_;476 return __x.__ptr_ == __y.__ptr_;
464 }477 }
465 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) {478 friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
479 operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) {
466 return !(__x == __y);480 return !(__x == __y);
467 }481 }
468};482};
...@@ -503,43 +517,49 @@ protected:...@@ -503,43 +517,49 @@ protected:
503 __node_base __end_;517 __node_base __end_;
504 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);518 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);
505519
506 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {520 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
507 return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());521 return pointer_traits<__base_pointer>::pointer_to(const_cast<__node_base&>(__end_));
508 }522 }
509523
510 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {524 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
511 return __node_alloc_traits::max_size(__node_alloc_);525 return __node_alloc_traits::max_size(__node_alloc_);
512 }526 }
513 _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;527 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void
528 __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;
514529
515 _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);530 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp()
516 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);531 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
517 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);532 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);
533 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);
518# ifndef _LIBCPP_CXX03_LANG534# ifndef _LIBCPP_CXX03_LANG
519 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;535 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;
520# endif536# endif
521 _LIBCPP_HIDE_FROM_ABI ~__list_imp();537 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_imp();
522 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;538 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
523 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }539 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }
524540
525 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }541 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }
526 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); }542 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
527 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); }543 return const_iterator(__end_.__next_);
528 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); }544 }
545 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); }
546 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
547 return const_iterator(__end_as_link());
548 }
529549
530 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)550 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)
531# if _LIBCPP_STD_VER >= 14551# if _LIBCPP_STD_VER >= 14
532 _NOEXCEPT;552 _NOEXCEPT;
533# else553# else
534 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);554 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
535# endif555# endif
536556
537 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {557 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
538 __copy_assign_alloc(558 __copy_assign_alloc(
539 __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>());559 __c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>());
540 }560 }
541561
542 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c)562 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c)
543 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value ||563 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value ||
544 is_nothrow_move_assignable<__node_allocator>::value) {564 is_nothrow_move_assignable<__node_allocator>::value) {
545 __move_assign_alloc(565 __move_assign_alloc(
...@@ -547,7 +567,8 @@ protected:...@@ -547,7 +567,8 @@ protected:
547 }567 }
548568
549 template <class... _Args>569 template <class... _Args>
550 _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {570 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer
571 __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {
551 __allocation_guard<__node_allocator> __guard(__node_alloc_, 1);572 __allocation_guard<__node_allocator> __guard(__node_alloc_, 1);
552 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value573 // Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
553 // held inside the node, since we need to use the allocator's construct() method for that.574 // held inside the node, since we need to use the allocator's construct() method for that.
...@@ -563,7 +584,7 @@ protected:...@@ -563,7 +584,7 @@ protected:
563 return __guard.__release_ptr();584 return __guard.__release_ptr();
564 }585 }
565586
566 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {587 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
567 // For the same reason as above, we use the allocator's destroy() method for the value_type,588 // For the same reason as above, we use the allocator's destroy() method for the value_type,
568 // but not for the node itself.589 // but not for the node itself.
569 __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value()));590 __node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value()));
...@@ -572,54 +593,57 @@ protected:...@@ -572,54 +593,57 @@ protected:
572 }593 }
573594
574private:595private:
575 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {596 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {
576 if (__node_alloc_ != __c.__node_alloc_)597 if (__node_alloc_ != __c.__node_alloc_)
577 clear();598 clear();
578 __node_alloc_ = __c.__node_alloc_;599 __node_alloc_ = __c.__node_alloc_;
579 }600 }
580601
581 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}602 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}
582603
583 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)604 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)
584 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {605 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
585 __node_alloc_ = std::move(__c.__node_alloc_);606 __node_alloc_ = std::move(__c.__node_alloc_);
586 }607 }
587608
588 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}609 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}
589};610};
590611
591// Unlink nodes [__f, __l]612// Unlink nodes [__f, __l]
592template <class _Tp, class _Alloc>613template <class _Tp, class _Alloc>
593inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {614_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
615__list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {
594 __f->__prev_->__next_ = __l->__next_;616 __f->__prev_->__next_ = __l->__next_;
595 __l->__next_->__prev_ = __f->__prev_;617 __l->__next_->__prev_ = __f->__prev_;
596}618}
597619
598template <class _Tp, class _Alloc>620template <class _Tp, class _Alloc>
599inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)621_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp()
622 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
600 : __size_(0) {}623 : __size_(0) {}
601624
602template <class _Tp, class _Alloc>625template <class _Tp, class _Alloc>
603inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)626_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
604 : __size_(0), __node_alloc_(__node_allocator(__a)) {}627 : __size_(0), __node_alloc_(__node_allocator(__a)) {}
605628
606template <class _Tp, class _Alloc>629template <class _Tp, class _Alloc>
607inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {}630_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
631 : __size_(0), __node_alloc_(__a) {}
608632
609# ifndef _LIBCPP_CXX03_LANG633# ifndef _LIBCPP_CXX03_LANG
610template <class _Tp, class _Alloc>634template <class _Tp, class _Alloc>
611inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT635_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
612 : __size_(0),636 : __size_(0),
613 __node_alloc_(std::move(__a)) {}637 __node_alloc_(std::move(__a)) {}
614# endif638# endif
615639
616template <class _Tp, class _Alloc>640template <class _Tp, class _Alloc>
617__list_imp<_Tp, _Alloc>::~__list_imp() {641_LIBCPP_CONSTEXPR_SINCE_CXX26 __list_imp<_Tp, _Alloc>::~__list_imp() {
618 clear();642 clear();
619}643}
620644
621template <class _Tp, class _Alloc>645template <class _Tp, class _Alloc>
622void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {646_LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
623 if (!empty()) {647 if (!empty()) {
624 __base_pointer __f = __end_.__next_;648 __base_pointer __f = __end_.__next_;
625 __base_pointer __l = __end_as_link();649 __base_pointer __l = __end_as_link();
...@@ -634,7 +658,7 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {...@@ -634,7 +658,7 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
634}658}
635659
636template <class _Tp, class _Alloc>660template <class _Tp, class _Alloc>
637void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)661_LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
638# if _LIBCPP_STD_VER >= 14662# if _LIBCPP_STD_VER >= 14
639 _NOEXCEPT663 _NOEXCEPT
640# else664# else
...@@ -660,7 +684,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)...@@ -660,7 +684,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
660}684}
661685
662template <class _Tp, class _Alloc /*= allocator<_Tp>*/>686template <class _Tp, class _Alloc /*= allocator<_Tp>*/>
663class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> {687class list : private __list_imp<_Tp, _Alloc> {
664 typedef __list_imp<_Tp, _Alloc> __base;688 typedef __list_imp<_Tp, _Alloc> __base;
665 typedef typename __base::__node_type __node_type;689 typedef typename __base::__node_type __node_type;
666 typedef typename __base::__node_allocator __node_allocator;690 typedef typename __base::__node_allocator __node_allocator;
...@@ -692,169 +716,204 @@ public:...@@ -692,169 +716,204 @@ public:
692 typedef void __remove_return_type;716 typedef void __remove_return_type;
693# endif717# endif
694718
695 _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}719 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list()
696 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}720 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
697 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);721 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
722 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
698# if _LIBCPP_STD_VER >= 14723# if _LIBCPP_STD_VER >= 14
699 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);724 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
700# endif725# endif
701 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);726 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
702 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>727 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
703 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) {728 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
729 list(size_type __n, const value_type& __x, const allocator_type& __a)
730 : __base(__a) {
704 for (; __n > 0; --__n)731 for (; __n > 0; --__n)
705 push_back(__x);732 push_back(__x);
706 }733 }
707734
708 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>735 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
709 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);736 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);
710737
711 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>738 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
712 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);739 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
713740
714# if _LIBCPP_STD_VER >= 23741# if _LIBCPP_STD_VER >= 23
715 template <_ContainerCompatibleRange<_Tp> _Range>742 template <_ContainerCompatibleRange<_Tp> _Range>
716 _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())743 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
744 list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
717 : __base(__a) {745 : __base(__a) {
718 prepend_range(std::forward<_Range>(__range));746 prepend_range(std::forward<_Range>(__range));
719 }747 }
720# endif748# endif
721749
722 _LIBCPP_HIDE_FROM_ABI list(const list& __c);750 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(const list& __c);
723 _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a);751 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
724 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);752 list(const list& __c, const __type_identity_t<allocator_type>& __a);
753 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);
725# ifndef _LIBCPP_CXX03_LANG754# ifndef _LIBCPP_CXX03_LANG
726 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);755 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);
727 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a);756 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
728757 list(initializer_list<value_type> __il, const allocator_type& __a);
729 _LIBCPP_HIDE_FROM_ABI list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);758
730 _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a);759 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c)
731 _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c)760 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
732 _NOEXCEPT_(__node_alloc_traits::propagate_on_container_move_assignment::value&&761 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a);
733 is_nothrow_move_assignable<__node_allocator>::value);762 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) noexcept(
734763 (__node_alloc_traits::propagate_on_container_move_assignment::value &&
735 _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {764 is_nothrow_move_assignable<__node_allocator>::value) ||
765 allocator_traits<allocator_type>::is_always_equal::value);
766
767 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {
736 assign(__il.begin(), __il.end());768 assign(__il.begin(), __il.end());
737 return *this;769 return *this;
738 }770 }
739771
740 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }772 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {
773 assign(__il.begin(), __il.end());
774 }
741# endif // _LIBCPP_CXX03_LANG775# endif // _LIBCPP_CXX03_LANG
742776
743 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>777 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
744 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);778 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
745779
746# if _LIBCPP_STD_VER >= 23780# if _LIBCPP_STD_VER >= 23
747 template <_ContainerCompatibleRange<_Tp> _Range>781 template <_ContainerCompatibleRange<_Tp> _Range>
748 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {782 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
749 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));783 __assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
750 }784 }
751# endif785# endif
752786
753 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);787 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);
754788
755 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;789 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
756790
757 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }791 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }
758 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); }792 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
759 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {793 return __base::empty();
794 }
795 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
760 return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max());796 return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max());
761 }797 }
762798
763 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }799 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }
764 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }800 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }
765 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }801 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }
766 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }802 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }
767 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); }803 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
768 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }804 return __base::begin();
805 }
806 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }
769807
770 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }808 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {
771 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }809 return reverse_iterator(end());
772 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }810 }
773 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }811 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
774 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }812 return const_reverse_iterator(end());
775 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(begin()); }813 }
814 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {
815 return reverse_iterator(begin());
816 }
817 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
818 return const_reverse_iterator(begin());
819 }
820 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
821 return const_reverse_iterator(end());
822 }
823 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT {
824 return const_reverse_iterator(begin());
825 }
776826
777 _LIBCPP_HIDE_FROM_ABI reference front() {827 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() {
778 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");828 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
779 return __base::__end_.__next_->__as_node()->__get_value();829 return __base::__end_.__next_->__as_node()->__get_value();
780 }830 }
781 _LIBCPP_HIDE_FROM_ABI const_reference front() const {831 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
782 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");832 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
783 return __base::__end_.__next_->__as_node()->__get_value();833 return __base::__end_.__next_->__as_node()->__get_value();
784 }834 }
785 _LIBCPP_HIDE_FROM_ABI reference back() {835 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference back() {
786 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");836 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
787 return __base::__end_.__prev_->__as_node()->__get_value();837 return __base::__end_.__prev_->__as_node()->__get_value();
788 }838 }
789 _LIBCPP_HIDE_FROM_ABI const_reference back() const {839 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference back() const {
790 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");840 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
791 return __base::__end_.__prev_->__as_node()->__get_value();841 return __base::__end_.__prev_->__as_node()->__get_value();
792 }842 }
793843
794# ifndef _LIBCPP_CXX03_LANG844# ifndef _LIBCPP_CXX03_LANG
795 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);845 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
796 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);846 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
797847
798# if _LIBCPP_STD_VER >= 23848# if _LIBCPP_STD_VER >= 23
799 template <_ContainerCompatibleRange<_Tp> _Range>849 template <_ContainerCompatibleRange<_Tp> _Range>
800 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {850 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
801 insert_range(begin(), std::forward<_Range>(__range));851 insert_range(begin(), std::forward<_Range>(__range));
802 }852 }
803853
804 template <_ContainerCompatibleRange<_Tp> _Range>854 template <_ContainerCompatibleRange<_Tp> _Range>
805 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {855 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
806 insert_range(end(), std::forward<_Range>(__range));856 insert_range(end(), std::forward<_Range>(__range));
807 }857 }
808# endif858# endif
809859
810 template <class... _Args>860 template <class... _Args>
861 _LIBCPP_CONSTEXPR_SINCE_CXX26
811# if _LIBCPP_STD_VER >= 17862# if _LIBCPP_STD_VER >= 17
812 _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);863 _LIBCPP_HIDE_FROM_ABI reference
864 emplace_front(_Args&&... __args);
813# else865# else
814 _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);866 _LIBCPP_HIDE_FROM_ABI void
867 emplace_front(_Args&&... __args);
815# endif868# endif
816 template <class... _Args>869 template <class... _Args>
870 _LIBCPP_CONSTEXPR_SINCE_CXX26
817# if _LIBCPP_STD_VER >= 17871# if _LIBCPP_STD_VER >= 17
818 _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);872 _LIBCPP_HIDE_FROM_ABI reference
873 emplace_back(_Args&&... __args);
819# else874# else
820 _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);875 _LIBCPP_HIDE_FROM_ABI void
876 emplace_back(_Args&&... __args);
821# endif877# endif
822 template <class... _Args>878 template <class... _Args>
823 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);879 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
824880
825 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x);881 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x);
826882
827 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {883 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
884 insert(const_iterator __p, initializer_list<value_type> __il) {
828 return insert(__p, __il.begin(), __il.end());885 return insert(__p, __il.begin(), __il.end());
829 }886 }
830# endif // _LIBCPP_CXX03_LANG887# endif // _LIBCPP_CXX03_LANG
831888
832 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);889 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);
833 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);890 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);
834891
835# ifndef _LIBCPP_CXX03_LANG892# ifndef _LIBCPP_CXX03_LANG
836 template <class _Arg>893 template <class _Arg>
837 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {894 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {
838 emplace_back(std::forward<_Arg>(__arg));895 emplace_back(std::forward<_Arg>(__arg));
839 }896 }
840# else897# else
841 _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }898 _LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }
842# endif899# endif
843900
844 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);901 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
845 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);902 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
903 insert(const_iterator __p, size_type __n, const value_type& __x);
846904
847 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>905 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
848 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);906 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
849907
850# if _LIBCPP_STD_VER >= 23908# if _LIBCPP_STD_VER >= 23
851 template <_ContainerCompatibleRange<_Tp> _Range>909 template <_ContainerCompatibleRange<_Tp> _Range>
852 _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {910 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
911 insert_range(const_iterator __position, _Range&& __range) {
853 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));912 return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
854 }913 }
855# endif914# endif
856915
857 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)916 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)
858# if _LIBCPP_STD_VER >= 14917# if _LIBCPP_STD_VER >= 14
859 _NOEXCEPT918 _NOEXCEPT
860# else919# else
...@@ -863,72 +922,80 @@ public:...@@ -863,72 +922,80 @@ public:
863 {922 {
864 __base::swap(__c);923 __base::swap(__c);
865 }924 }
866 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }925 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
867926
868 _LIBCPP_HIDE_FROM_ABI void pop_front();927 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_front();
869 _LIBCPP_HIDE_FROM_ABI void pop_back();928 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_back();
870929
871 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);930 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
872 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);931 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
873932
874 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);933 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
875 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);934 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);
876935
877 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);936 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);
878# ifndef _LIBCPP_CXX03_LANG937# ifndef _LIBCPP_CXX03_LANG
879 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }938 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }
880 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); }939 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) {
881 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {940 splice(__p, __c, __i);
941 }
942 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
943 splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {
882 splice(__p, __c, __f, __l);944 splice(__p, __c, __f, __l);
883 }945 }
884# endif946# endif
885 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);947 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);
886 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);948 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
949 splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
887950
888 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x);951 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x);
889 template <class _Pred>952 template <class _Pred>
890 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred);953 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred);
891 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }954 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
892 template <class _BinaryPred>955 template <class _BinaryPred>
893 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);956 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);
894 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);957 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);
895# ifndef _LIBCPP_CXX03_LANG958# ifndef _LIBCPP_CXX03_LANG
896 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }959 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }
897960
898 template <class _Comp>961 template <class _Comp>
899 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {962 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {
900 merge(__c, __comp);963 merge(__c, __comp);
901 }964 }
902# endif965# endif
903 template <class _Comp>966 template <class _Comp>
904 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);967 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);
905968
906 _LIBCPP_HIDE_FROM_ABI void sort();969 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort();
907 template <class _Comp>970 template <class _Comp>
908 _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp);971 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp);
909972
910 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;973 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
911974
912 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;975 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
913976
914private:977private:
915 template <class _Iterator, class _Sentinel>978 template <class _Iterator, class _Sentinel>
916 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l);979 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l);
917980
918 template <class _Iterator, class _Sentinel>981 template <class _Iterator, class _Sentinel>
919 _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);982 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
920983 __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);
921 _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);984
922 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l);985 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void
923 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);986 __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);
924 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);987 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
988 __link_nodes_at_front(__base_pointer __f, __base_pointer __l);
989 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);
990 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);
925 // TODO: Make this _LIBCPP_HIDE_FROM_ABI991 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
926 template <class _Comp>992 template <class _Comp>
927 _LIBCPP_HIDDEN static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);993 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDDEN static iterator
994 __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
928995
929 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type)996 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type)
930 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);997 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
931 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);998 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);
932};999};
9331000
934# if _LIBCPP_STD_VER >= 171001# if _LIBCPP_STD_VER >= 17
...@@ -954,7 +1021,8 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R...@@ -954,7 +1021,8 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R
9541021
955// Link in nodes [__f, __l] just prior to __p1022// Link in nodes [__f, __l] just prior to __p
956template <class _Tp, class _Alloc>1023template <class _Tp, class _Alloc>
957inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {1024_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
1025list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {
958 __p->__prev_->__next_ = __f;1026 __p->__prev_->__next_ = __f;
959 __f->__prev_ = __p->__prev_;1027 __f->__prev_ = __p->__prev_;
960 __p->__prev_ = __l;1028 __p->__prev_ = __l;
...@@ -963,7 +1031,8 @@ inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer _...@@ -963,7 +1031,8 @@ inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer _
9631031
964// Link in nodes [__f, __l] at the front of the list1032// Link in nodes [__f, __l] at the front of the list
965template <class _Tp, class _Alloc>1033template <class _Tp, class _Alloc>
966inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {1034_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
1035list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {
967 __f->__prev_ = __base::__end_as_link();1036 __f->__prev_ = __base::__end_as_link();
968 __l->__next_ = __base::__end_.__next_;1037 __l->__next_ = __base::__end_.__next_;
969 __l->__next_->__prev_ = __l;1038 __l->__next_->__prev_ = __l;
...@@ -972,7 +1041,8 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_...@@ -972,7 +1041,8 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_
9721041
973// Link in nodes [__f, __l] at the back of the list1042// Link in nodes [__f, __l] at the back of the list
974template <class _Tp, class _Alloc>1043template <class _Tp, class _Alloc>
975inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {1044_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
1045list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {
976 __l->__next_ = __base::__end_as_link();1046 __l->__next_ = __base::__end_as_link();
977 __f->__prev_ = __base::__end_.__prev_;1047 __f->__prev_ = __base::__end_.__prev_;
978 __f->__prev_->__next_ = __f;1048 __f->__prev_->__next_ = __f;
...@@ -980,12 +1050,12 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_p...@@ -980,12 +1050,12 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_p
980}1050}
9811051
982template <class _Tp, class _Alloc>1052template <class _Tp, class _Alloc>
983inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {1053_LIBCPP_CONSTEXPR_SINCE_CXX26 inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {
984 return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n);1054 return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n);
985}1055}
9861056
987template <class _Tp, class _Alloc>1057template <class _Tp, class _Alloc>
988list<_Tp, _Alloc>::list(size_type __n) {1058_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n) {
989 for (; __n > 0; --__n)1059 for (; __n > 0; --__n)
990# ifndef _LIBCPP_CXX03_LANG1060# ifndef _LIBCPP_CXX03_LANG
991 emplace_back();1061 emplace_back();
...@@ -996,41 +1066,43 @@ list<_Tp, _Alloc>::list(size_type __n) {...@@ -996,41 +1066,43 @@ list<_Tp, _Alloc>::list(size_type __n) {
9961066
997# if _LIBCPP_STD_VER >= 141067# if _LIBCPP_STD_VER >= 14
998template <class _Tp, class _Alloc>1068template <class _Tp, class _Alloc>
999list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {1069_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
1000 for (; __n > 0; --__n)1070 for (; __n > 0; --__n)
1001 emplace_back();1071 emplace_back();
1002}1072}
1003# endif1073# endif
10041074
1005template <class _Tp, class _Alloc>1075template <class _Tp, class _Alloc>
1006list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {1076_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
1007 for (; __n > 0; --__n)1077 for (; __n > 0; --__n)
1008 push_back(__x);1078 push_back(__x);
1009}1079}
10101080
1011template <class _Tp, class _Alloc>1081template <class _Tp, class _Alloc>
1012template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >1082template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1013list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {1083_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
1014 for (; __f != __l; ++__f)1084 for (; __f != __l; ++__f)
1015 __emplace_back(*__f);1085 __emplace_back(*__f);
1016}1086}
10171087
1018template <class _Tp, class _Alloc>1088template <class _Tp, class _Alloc>
1019template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >1089template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1020list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) {1090_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a)
1091 : __base(__a) {
1021 for (; __f != __l; ++__f)1092 for (; __f != __l; ++__f)
1022 __emplace_back(*__f);1093 __emplace_back(*__f);
1023}1094}
10241095
1025template <class _Tp, class _Alloc>1096template <class _Tp, class _Alloc>
1026list<_Tp, _Alloc>::list(const list& __c)1097_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c)
1027 : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) {1098 : __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) {
1028 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1099 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1029 push_back(*__i);1100 push_back(*__i);
1030}1101}
10311102
1032template <class _Tp, class _Alloc>1103template <class _Tp, class _Alloc>
1033list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {1104_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a)
1105 : __base(__a) {
1034 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)1106 for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
1035 push_back(*__i);1107 push_back(*__i);
1036}1108}
...@@ -1038,25 +1110,28 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>...@@ -1038,25 +1110,28 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>
1038# ifndef _LIBCPP_CXX03_LANG1110# ifndef _LIBCPP_CXX03_LANG
10391111
1040template <class _Tp, class _Alloc>1112template <class _Tp, class _Alloc>
1041list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {1113_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
1114 : __base(__a) {
1042 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)1115 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
1043 push_back(*__i);1116 push_back(*__i);
1044}1117}
10451118
1046template <class _Tp, class _Alloc>1119template <class _Tp, class _Alloc>
1047list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {1120_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
1048 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)1121 for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
1049 push_back(*__i);1122 push_back(*__i);
1050}1123}
10511124
1052template <class _Tp, class _Alloc>1125template <class _Tp, class _Alloc>
1053inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)1126_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c) noexcept(
1127 is_nothrow_move_constructible<__node_allocator>::value)
1054 : __base(std::move(__c.__node_alloc_)) {1128 : __base(std::move(__c.__node_alloc_)) {
1055 splice(end(), __c);1129 splice(end(), __c);
1056}1130}
10571131
1058template <class _Tp, class _Alloc>1132template <class _Tp, class _Alloc>
1059inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {1133_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a)
1134 : __base(__a) {
1060 if (__a == __c.get_allocator())1135 if (__a == __c.get_allocator())
1061 splice(end(), __c);1136 splice(end(), __c);
1062 else {1137 else {
...@@ -1066,15 +1141,16 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ...@@ -1066,15 +1141,16 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ
1066}1141}
10671142
1068template <class _Tp, class _Alloc>1143template <class _Tp, class _Alloc>
1069inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(1144_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
1070 __node_alloc_traits::propagate_on_container_move_assignment::value &&1145 (__node_alloc_traits::propagate_on_container_move_assignment::value &&
1071 is_nothrow_move_assignable<__node_allocator>::value) {1146 is_nothrow_move_assignable<__node_allocator>::value) ||
1147 allocator_traits<allocator_type>::is_always_equal::value) {
1072 __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());1148 __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());
1073 return *this;1149 return *this;
1074}1150}
10751151
1076template <class _Tp, class _Alloc>1152template <class _Tp, class _Alloc>
1077void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {1153_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
1078 if (this->__node_alloc_ != __c.__node_alloc_) {1154 if (this->__node_alloc_ != __c.__node_alloc_) {
1079 typedef move_iterator<iterator> _Ip;1155 typedef move_iterator<iterator> _Ip;
1080 assign(_Ip(__c.begin()), _Ip(__c.end()));1156 assign(_Ip(__c.begin()), _Ip(__c.end()));
...@@ -1083,8 +1159,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {...@@ -1083,8 +1159,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
1083}1159}
10841160
1085template <class _Tp, class _Alloc>1161template <class _Tp, class _Alloc>
1086void list<_Tp, _Alloc>::__move_assign(list& __c,1162_LIBCPP_CONSTEXPR_SINCE_CXX26 void
1087 true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {1163list<_Tp, _Alloc>::__move_assign(list& __c, true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
1088 clear();1164 clear();
1089 __base::__move_assign_alloc(__c);1165 __base::__move_assign_alloc(__c);
1090 splice(end(), __c);1166 splice(end(), __c);
...@@ -1093,7 +1169,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c,...@@ -1093,7 +1169,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c,
1093# endif // _LIBCPP_CXX03_LANG1169# endif // _LIBCPP_CXX03_LANG
10941170
1095template <class _Tp, class _Alloc>1171template <class _Tp, class _Alloc>
1096inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {1172_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
1097 if (this != std::addressof(__c)) {1173 if (this != std::addressof(__c)) {
1098 __base::__copy_assign_alloc(__c);1174 __base::__copy_assign_alloc(__c);
1099 assign(__c.begin(), __c.end());1175 assign(__c.begin(), __c.end());
...@@ -1103,13 +1179,14 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {...@@ -1103,13 +1179,14 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
11031179
1104template <class _Tp, class _Alloc>1180template <class _Tp, class _Alloc>
1105template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >1181template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1106void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {1182_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {
1107 __assign_with_sentinel(__f, __l);1183 __assign_with_sentinel(__f, __l);
1108}1184}
11091185
1110template <class _Tp, class _Alloc>1186template <class _Tp, class _Alloc>
1111template <class _Iterator, class _Sentinel>1187template <class _Iterator, class _Sentinel>
1112_LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) {1188_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
1189list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) {
1113 iterator __i = begin();1190 iterator __i = begin();
1114 iterator __e = end();1191 iterator __e = end();
1115 for (; __f != __l && __i != __e; ++__f, (void)++__i)1192 for (; __f != __l && __i != __e; ++__f, (void)++__i)
...@@ -1121,7 +1198,7 @@ _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator _...@@ -1121,7 +1198,7 @@ _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator _
1121}1198}
11221199
1123template <class _Tp, class _Alloc>1200template <class _Tp, class _Alloc>
1124void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {1201_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
1125 iterator __i = begin();1202 iterator __i = begin();
1126 iterator __e = end();1203 iterator __e = end();
1127 for (; __n > 0 && __i != __e; --__n, (void)++__i)1204 for (; __n > 0 && __i != __e; --__n, (void)++__i)
...@@ -1133,12 +1210,13 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {...@@ -1133,12 +1210,13 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
1133}1210}
11341211
1135template <class _Tp, class _Alloc>1212template <class _Tp, class _Alloc>
1136inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {1213_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {
1137 return allocator_type(this->__node_alloc_);1214 return allocator_type(this->__node_alloc_);
1138}1215}
11391216
1140template <class _Tp, class _Alloc>1217template <class _Tp, class _Alloc>
1141typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {1218_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1219list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {
1142 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1220 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1143 __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());1221 __link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());
1144 ++this->__size_;1222 ++this->__size_;
...@@ -1146,7 +1224,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __...@@ -1146,7 +1224,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __
1146}1224}
11471225
1148template <class _Tp, class _Alloc>1226template <class _Tp, class _Alloc>
1149typename list<_Tp, _Alloc>::iterator1227_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1150list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) {1228list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) {
1151 iterator __r(__p.__ptr_);1229 iterator __r(__p.__ptr_);
1152 if (__n > 0) {1230 if (__n > 0) {
...@@ -1182,13 +1260,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _...@@ -1182,13 +1260,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
11821260
1183template <class _Tp, class _Alloc>1261template <class _Tp, class _Alloc>
1184template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >1262template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1185typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {1263_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1264list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {
1186 return __insert_with_sentinel(__p, __f, __l);1265 return __insert_with_sentinel(__p, __f, __l);
1187}1266}
11881267
1189template <class _Tp, class _Alloc>1268template <class _Tp, class _Alloc>
1190template <class _Iterator, class _Sentinel>1269template <class _Iterator, class _Sentinel>
1191_LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator1270_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator
1192list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) {1271list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) {
1193 iterator __r(__p.__ptr_);1272 iterator __r(__p.__ptr_);
1194 if (__f != __l) {1273 if (__f != __l) {
...@@ -1223,7 +1302,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se...@@ -1223,7 +1302,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
1223}1302}
12241303
1225template <class _Tp, class _Alloc>1304template <class _Tp, class _Alloc>
1226void list<_Tp, _Alloc>::push_front(const value_type& __x) {1305_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(const value_type& __x) {
1227 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1306 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1228 __base_pointer __nl = __node->__as_link();1307 __base_pointer __nl = __node->__as_link();
1229 __link_nodes_at_front(__nl, __nl);1308 __link_nodes_at_front(__nl, __nl);
...@@ -1231,7 +1310,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) {...@@ -1231,7 +1310,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) {
1231}1310}
12321311
1233template <class _Tp, class _Alloc>1312template <class _Tp, class _Alloc>
1234void list<_Tp, _Alloc>::push_back(const value_type& __x) {1313_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(const value_type& __x) {
1235 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);1314 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
1236 __base_pointer __nl = __node->__as_link();1315 __base_pointer __nl = __node->__as_link();
1237 __link_nodes_at_back(__nl, __nl);1316 __link_nodes_at_back(__nl, __nl);
...@@ -1241,7 +1320,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) {...@@ -1241,7 +1320,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) {
1241# ifndef _LIBCPP_CXX03_LANG1320# ifndef _LIBCPP_CXX03_LANG
12421321
1243template <class _Tp, class _Alloc>1322template <class _Tp, class _Alloc>
1244void list<_Tp, _Alloc>::push_front(value_type&& __x) {1323_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(value_type&& __x) {
1245 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1324 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1246 __base_pointer __nl = __node->__as_link();1325 __base_pointer __nl = __node->__as_link();
1247 __link_nodes_at_front(__nl, __nl);1326 __link_nodes_at_front(__nl, __nl);
...@@ -1249,7 +1328,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) {...@@ -1249,7 +1328,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) {
1249}1328}
12501329
1251template <class _Tp, class _Alloc>1330template <class _Tp, class _Alloc>
1252void list<_Tp, _Alloc>::push_back(value_type&& __x) {1331_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(value_type&& __x) {
1253 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1332 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1254 __base_pointer __nl = __node->__as_link();1333 __base_pointer __nl = __node->__as_link();
1255 __link_nodes_at_back(__nl, __nl);1334 __link_nodes_at_back(__nl, __nl);
...@@ -1258,12 +1337,13 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) {...@@ -1258,12 +1337,13 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) {
12581337
1259template <class _Tp, class _Alloc>1338template <class _Tp, class _Alloc>
1260template <class... _Args>1339template <class... _Args>
1340_LIBCPP_CONSTEXPR_SINCE_CXX26
1261# if _LIBCPP_STD_VER >= 171341# if _LIBCPP_STD_VER >= 17
1262typename list<_Tp, _Alloc>::reference1342 typename list<_Tp, _Alloc>::reference
1263# else1343# else
1264void1344 void
1265# endif1345# endif
1266list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {1346 list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
1267 __node_pointer __node =1347 __node_pointer __node =
1268 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1348 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1269 __base_pointer __nl = __node->__as_link();1349 __base_pointer __nl = __node->__as_link();
...@@ -1276,12 +1356,13 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {...@@ -1276,12 +1356,13 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
12761356
1277template <class _Tp, class _Alloc>1357template <class _Tp, class _Alloc>
1278template <class... _Args>1358template <class... _Args>
1359_LIBCPP_CONSTEXPR_SINCE_CXX26
1279# if _LIBCPP_STD_VER >= 171360# if _LIBCPP_STD_VER >= 17
1280typename list<_Tp, _Alloc>::reference1361 typename list<_Tp, _Alloc>::reference
1281# else1362# else
1282void1363 void
1283# endif1364# endif
1284list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {1365 list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
1285 __node_pointer __node =1366 __node_pointer __node =
1286 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1367 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1287 __base_pointer __nl = __node->__as_link();1368 __base_pointer __nl = __node->__as_link();
...@@ -1294,7 +1375,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {...@@ -1294,7 +1375,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
12941375
1295template <class _Tp, class _Alloc>1376template <class _Tp, class _Alloc>
1296template <class... _Args>1377template <class... _Args>
1297typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {1378_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1379list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {
1298 __node_pointer __node =1380 __node_pointer __node =
1299 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);1381 this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
1300 __base_pointer __nl = __node->__as_link();1382 __base_pointer __nl = __node->__as_link();
...@@ -1304,7 +1386,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _...@@ -1304,7 +1386,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _
1304}1386}
13051387
1306template <class _Tp, class _Alloc>1388template <class _Tp, class _Alloc>
1307typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {1389_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1390list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {
1308 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));1391 __node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
1309 __base_pointer __nl = __node->__as_link();1392 __base_pointer __nl = __node->__as_link();
1310 __link_nodes(__p.__ptr_, __nl, __nl);1393 __link_nodes(__p.__ptr_, __nl, __nl);
...@@ -1315,7 +1398,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __...@@ -1315,7 +1398,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __
1315# endif // _LIBCPP_CXX03_LANG1398# endif // _LIBCPP_CXX03_LANG
13161399
1317template <class _Tp, class _Alloc>1400template <class _Tp, class _Alloc>
1318void list<_Tp, _Alloc>::pop_front() {1401_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_front() {
1319 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");1402 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");
1320 __base_pointer __n = __base::__end_.__next_;1403 __base_pointer __n = __base::__end_.__next_;
1321 __base::__unlink_nodes(__n, __n);1404 __base::__unlink_nodes(__n, __n);
...@@ -1324,7 +1407,7 @@ void list<_Tp, _Alloc>::pop_front() {...@@ -1324,7 +1407,7 @@ void list<_Tp, _Alloc>::pop_front() {
1324}1407}
13251408
1326template <class _Tp, class _Alloc>1409template <class _Tp, class _Alloc>
1327void list<_Tp, _Alloc>::pop_back() {1410_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_back() {
1328 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");1411 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");
1329 __base_pointer __n = __base::__end_.__prev_;1412 __base_pointer __n = __base::__end_.__prev_;
1330 __base::__unlink_nodes(__n, __n);1413 __base::__unlink_nodes(__n, __n);
...@@ -1333,7 +1416,7 @@ void list<_Tp, _Alloc>::pop_back() {...@@ -1333,7 +1416,7 @@ void list<_Tp, _Alloc>::pop_back() {
1333}1416}
13341417
1335template <class _Tp, class _Alloc>1418template <class _Tp, class _Alloc>
1336typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {1419_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {
1337 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");1420 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");
1338 __base_pointer __n = __p.__ptr_;1421 __base_pointer __n = __p.__ptr_;
1339 __base_pointer __r = __n->__next_;1422 __base_pointer __r = __n->__next_;
...@@ -1344,7 +1427,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p...@@ -1344,7 +1427,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p
1344}1427}
13451428
1346template <class _Tp, class _Alloc>1429template <class _Tp, class _Alloc>
1347typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {1430_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1431list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {
1348 if (__f != __l) {1432 if (__f != __l) {
1349 __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);1433 __base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
1350 while (__f != __l) {1434 while (__f != __l) {
...@@ -1358,7 +1442,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f...@@ -1358,7 +1442,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f
1358}1442}
13591443
1360template <class _Tp, class _Alloc>1444template <class _Tp, class _Alloc>
1361void list<_Tp, _Alloc>::resize(size_type __n) {1445_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) {
1362 if (__n < this->__size_)1446 if (__n < this->__size_)
1363 erase(__iterator(__n), end());1447 erase(__iterator(__n), end());
1364 else if (__n > this->__size_) {1448 else if (__n > this->__size_) {
...@@ -1393,7 +1477,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) {...@@ -1393,7 +1477,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) {
1393}1477}
13941478
1395template <class _Tp, class _Alloc>1479template <class _Tp, class _Alloc>
1396void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {1480_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
1397 if (__n < this->__size_)1481 if (__n < this->__size_)
1398 erase(__iterator(__n), end());1482 erase(__iterator(__n), end());
1399 else if (__n > this->__size_) {1483 else if (__n > this->__size_) {
...@@ -1429,7 +1513,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {...@@ -1429,7 +1513,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
1429}1513}
14301514
1431template <class _Tp, class _Alloc>1515template <class _Tp, class _Alloc>
1432void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {1516_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
1433 _LIBCPP_ASSERT_VALID_INPUT_RANGE(1517 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
1434 this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");1518 this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");
1435 if (!__c.empty()) {1519 if (!__c.empty()) {
...@@ -1443,7 +1527,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {...@@ -1443,7 +1527,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
1443}1527}
14441528
1445template <class _Tp, class _Alloc>1529template <class _Tp, class _Alloc>
1446void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {1530_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {
1447 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {1531 if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {
1448 __base_pointer __f = __i.__ptr_;1532 __base_pointer __f = __i.__ptr_;
1449 __base::__unlink_nodes(__f, __f);1533 __base::__unlink_nodes(__f, __f);
...@@ -1454,7 +1538,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i...@@ -1454,7 +1538,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i
1454}1538}
14551539
1456template <class _Tp, class _Alloc>1540template <class _Tp, class _Alloc>
1457void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {1541_LIBCPP_CONSTEXPR_SINCE_CXX26 void
1542list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {
1458 if (__f != __l) {1543 if (__f != __l) {
1459 __base_pointer __first = __f.__ptr_;1544 __base_pointer __first = __f.__ptr_;
1460 --__l;1545 --__l;
...@@ -1470,7 +1555,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f...@@ -1470,7 +1555,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f
1470}1555}
14711556
1472template <class _Tp, class _Alloc>1557template <class _Tp, class _Alloc>
1473typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const value_type& __x) {1558_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
1559list<_Tp, _Alloc>::remove(const value_type& __x) {
1474 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1560 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1475 for (const_iterator __i = begin(), __e = end(); __i != __e;) {1561 for (const_iterator __i = begin(), __e = end(); __i != __e;) {
1476 if (*__i == __x) {1562 if (*__i == __x) {
...@@ -1490,7 +1576,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const...@@ -1490,7 +1576,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const
14901576
1491template <class _Tp, class _Alloc>1577template <class _Tp, class _Alloc>
1492template <class _Pred>1578template <class _Pred>
1493typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_Pred __pred) {1579_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
1580list<_Tp, _Alloc>::remove_if(_Pred __pred) {
1494 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1581 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1495 for (iterator __i = begin(), __e = end(); __i != __e;) {1582 for (iterator __i = begin(), __e = end(); __i != __e;) {
1496 if (__pred(*__i)) {1583 if (__pred(*__i)) {
...@@ -1510,7 +1597,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_P...@@ -1510,7 +1597,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_P
15101597
1511template <class _Tp, class _Alloc>1598template <class _Tp, class _Alloc>
1512template <class _BinaryPred>1599template <class _BinaryPred>
1513typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) {1600_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
1601list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) {
1514 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing1602 list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
1515 for (iterator __i = begin(), __e = end(); __i != __e;) {1603 for (iterator __i = begin(), __e = end(); __i != __e;) {
1516 iterator __j = std::next(__i);1604 iterator __j = std::next(__i);
...@@ -1526,13 +1614,13 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_Bina...@@ -1526,13 +1614,13 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_Bina
1526}1614}
15271615
1528template <class _Tp, class _Alloc>1616template <class _Tp, class _Alloc>
1529inline void list<_Tp, _Alloc>::merge(list& __c) {1617_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::merge(list& __c) {
1530 merge(__c, __less<>());1618 merge(__c, __less<>());
1531}1619}
15321620
1533template <class _Tp, class _Alloc>1621template <class _Tp, class _Alloc>
1534template <class _Comp>1622template <class _Comp>
1535void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {1623_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
1536 if (this != std::addressof(__c)) {1624 if (this != std::addressof(__c)) {
1537 iterator __f1 = begin();1625 iterator __f1 = begin();
1538 iterator __e1 = end();1626 iterator __e1 = end();
...@@ -1561,19 +1649,19 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {...@@ -1561,19 +1649,19 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
1561}1649}
15621650
1563template <class _Tp, class _Alloc>1651template <class _Tp, class _Alloc>
1564inline void list<_Tp, _Alloc>::sort() {1652_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort() {
1565 sort(__less<>());1653 sort(__less<>());
1566}1654}
15671655
1568template <class _Tp, class _Alloc>1656template <class _Tp, class _Alloc>
1569template <class _Comp>1657template <class _Comp>
1570inline void list<_Tp, _Alloc>::sort(_Comp __comp) {1658_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort(_Comp __comp) {
1571 __sort(begin(), end(), this->__size_, __comp);1659 __sort(begin(), end(), this->__size_, __comp);
1572}1660}
15731661
1574template <class _Tp, class _Alloc>1662template <class _Tp, class _Alloc>
1575template <class _Comp>1663template <class _Comp>
1576typename list<_Tp, _Alloc>::iterator1664_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
1577list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) {1665list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) {
1578 switch (__n) {1666 switch (__n) {
1579 case 0:1667 case 0:
...@@ -1627,7 +1715,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __...@@ -1627,7 +1715,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
1627}1715}
16281716
1629template <class _Tp, class _Alloc>1717template <class _Tp, class _Alloc>
1630void list<_Tp, _Alloc>::reverse() _NOEXCEPT {1718_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1631 if (this->__size_ > 1) {1719 if (this->__size_ > 1) {
1632 iterator __e = end();1720 iterator __e = end();
1633 for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {1721 for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {
...@@ -1639,46 +1727,52 @@ void list<_Tp, _Alloc>::reverse() _NOEXCEPT {...@@ -1639,46 +1727,52 @@ void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
1639}1727}
16401728
1641template <class _Tp, class _Alloc>1729template <class _Tp, class _Alloc>
1642bool list<_Tp, _Alloc>::__invariants() const {1730_LIBCPP_CONSTEXPR_SINCE_CXX26 bool list<_Tp, _Alloc>::__invariants() const {
1643 return size() == std::distance(begin(), end());1731 return size() == std::distance(begin(), end());
1644}1732}
16451733
1646template <class _Tp, class _Alloc>1734template <class _Tp, class _Alloc>
1647inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1735_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1736operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1648 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());1737 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
1649}1738}
16501739
1651# if _LIBCPP_STD_VER <= 171740# if _LIBCPP_STD_VER <= 17
16521741
1653template <class _Tp, class _Alloc>1742template <class _Tp, class _Alloc>
1654inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1743_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1744operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1655 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());1745 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
1656}1746}
16571747
1658template <class _Tp, class _Alloc>1748template <class _Tp, class _Alloc>
1659inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1749_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1750operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1660 return !(__x == __y);1751 return !(__x == __y);
1661}1752}
16621753
1663template <class _Tp, class _Alloc>1754template <class _Tp, class _Alloc>
1664inline _LIBCPP_HIDE_FROM_ABI bool operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1755_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1756operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1665 return __y < __x;1757 return __y < __x;
1666}1758}
16671759
1668template <class _Tp, class _Alloc>1760template <class _Tp, class _Alloc>
1669inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1761_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1762operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1670 return !(__x < __y);1763 return !(__x < __y);
1671}1764}
16721765
1673template <class _Tp, class _Alloc>1766template <class _Tp, class _Alloc>
1674inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {1767_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
1768operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
1675 return !(__y < __x);1769 return !(__y < __x);
1676}1770}
16771771
1678# else // _LIBCPP_STD_VER <= 171772# else // _LIBCPP_STD_VER <= 17
16791773
1680template <class _Tp, class _Allocator>1774template <class _Tp, class _Allocator>
1681_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>1775_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
1682operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {1776operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
1683 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);1777 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1684}1778}
...@@ -1686,22 +1780,22 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y)...@@ -1686,22 +1780,22 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y)
1686# endif // _LIBCPP_STD_VER <= 171780# endif // _LIBCPP_STD_VER <= 17
16871781
1688template <class _Tp, class _Alloc>1782template <class _Tp, class _Alloc>
1689inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)1783_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
1690 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {1784 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1691 __x.swap(__y);1785 __x.swap(__y);
1692}1786}
16931787
1694# if _LIBCPP_STD_VER >= 201788# if _LIBCPP_STD_VER >= 20
1695template <class _Tp, class _Allocator, class _Predicate>1789template <class _Tp, class _Allocator, class _Predicate>
1696inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type1790_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
1697erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {1791erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
1698 return __c.remove_if(__pred);1792 return __c.remove_if(__pred);
1699}1793}
17001794
1701template <class _Tp, class _Allocator, class _Up>1795template <class _Tp, class _Allocator, class _Up>
1702inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type1796_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
1703erase(list<_Tp, _Allocator>& __c, const _Up& __v) {1797erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
1704 return std::erase_if(__c, [&](auto& __elem) { return __elem == __v; });1798 return std::erase_if(__c, [&](const auto& __elem) -> bool { return __elem == __v; });
1705}1799}
17061800
1707template <>1801template <>
...@@ -1722,6 +1816,8 @@ struct __container_traits<list<_Tp, _Allocator> > {...@@ -1722,6 +1816,8 @@ struct __container_traits<list<_Tp, _Allocator> > {
1722 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that1816 // - If an exception is thrown by an insert() or emplace() function while inserting a single element, that
1723 // function has no effects.1817 // function has no effects.
1724 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;1818 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1819
1820 static _LIBCPP_CONSTEXPR const bool __reservable = false;
1725};1821};
17261822
1727_LIBCPP_END_NAMESPACE_STD1823_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/locale+7-3487
...@@ -194,3501 +194,20 @@ template <class charT> class messages_byname;...@@ -194,3501 +194,20 @@ template <class charT> class messages_byname;
194194
195# if _LIBCPP_HAS_LOCALIZATION195# if _LIBCPP_HAS_LOCALIZATION
196196
197# include <__algorithm/copy.h>
198# include <__algorithm/equal.h>
199# include <__algorithm/find.h>
200# include <__algorithm/max.h>
201# include <__algorithm/reverse.h>
202# include <__algorithm/unwrap_iter.h>
203# include <__assert>
204# include <__iterator/access.h>
205# include <__iterator/back_insert_iterator.h>
206# include <__iterator/istreambuf_iterator.h>
207# include <__iterator/ostreambuf_iterator.h>
208# include <__locale>197# include <__locale>
209# include <__locale_dir/pad_and_output.h>198# include <__locale_dir/messages.h>
210# include <__memory/unique_ptr.h>199# include <__locale_dir/money.h>
211# include <__new/exceptions.h>200# include <__locale_dir/num.h>
212# include <__type_traits/make_unsigned.h>201# include <__locale_dir/time.h>
213# include <cerrno>202# include <__locale_dir/wbuffer_convert.h>
214# include <cstdio>203# include <__locale_dir/wstring_convert.h>
215# include <cstdlib>
216# include <ctime>
217# include <ios>204# include <ios>
218# include <limits>
219# include <streambuf>
220# include <version>205# include <version>
221206
222// TODO: Properly qualify calls now that the locale base API defines functions instead of macros
223// NOLINTBEGIN(libcpp-robust-against-adl)
224
225# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
226// Most unix variants have catopen. These are the specific ones that don't.
227# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
228# define _LIBCPP_HAS_CATOPEN 1
229# include <nl_types.h>
230# else
231# define _LIBCPP_HAS_CATOPEN 0
232# endif
233# else
234# define _LIBCPP_HAS_CATOPEN 0
235# endif
236
237# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)207# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
238# pragma GCC system_header208# pragma GCC system_header
239# endif209# endif
240210
241_LIBCPP_PUSH_MACROS
242# include <__undef_macros>
243
244_LIBCPP_BEGIN_NAMESPACE_STD
245
246# if defined(__APPLE__) || defined(__FreeBSD__)
247# define _LIBCPP_GET_C_LOCALE 0
248# elif defined(__NetBSD__)
249# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
250# else
251# define _LIBCPP_GET_C_LOCALE __cloc()
252// Get the C locale object
253_LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc();
254# define __cloc_defined
255# endif
256
257// __scan_keyword
258// Scans [__b, __e) until a match is found in the basic_strings range
259// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke).
260// __b will be incremented (visibly), consuming CharT until a match is found
261// or proved to not exist. A keyword may be "", in which will match anything.
262// If one keyword is a prefix of another, and the next CharT in the input
263// might match another keyword, the algorithm will attempt to find the longest
264// matching keyword. If the longer matching keyword ends up not matching, then
265// no keyword match is found. If no keyword match is found, __ke is returned
266// and failbit is set in __err.
267// Else an iterator pointing to the matching keyword is found. If more than
268// one keyword matches, an iterator to the first matching keyword is returned.
269// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false,
270// __ct is used to force to lower case before comparing characters.
271// Examples:
272// Keywords: "a", "abb"
273// If the input is "a", the first keyword matches and eofbit is set.
274// If the input is "abc", no match is found and "ab" are consumed.
275template <class _InputIterator, class _ForwardIterator, class _Ctype>
276_LIBCPP_HIDE_FROM_ABI _ForwardIterator __scan_keyword(
277 _InputIterator& __b,
278 _InputIterator __e,
279 _ForwardIterator __kb,
280 _ForwardIterator __ke,
281 const _Ctype& __ct,
282 ios_base::iostate& __err,
283 bool __case_sensitive = true) {
284 typedef typename iterator_traits<_InputIterator>::value_type _CharT;
285 size_t __nkw = static_cast<size_t>(std::distance(__kb, __ke));
286 const unsigned char __doesnt_match = '\0';
287 const unsigned char __might_match = '\1';
288 const unsigned char __does_match = '\2';
289 unsigned char __statbuf[100];
290 unsigned char* __status = __statbuf;
291 unique_ptr<unsigned char, void (*)(void*)> __stat_hold(nullptr, free);
292 if (__nkw > sizeof(__statbuf)) {
293 __status = (unsigned char*)malloc(__nkw);
294 if (__status == nullptr)
295 __throw_bad_alloc();
296 __stat_hold.reset(__status);
297 }
298 size_t __n_might_match = __nkw; // At this point, any keyword might match
299 size_t __n_does_match = 0; // but none of them definitely do
300 // Initialize all statuses to __might_match, except for "" keywords are __does_match
301 unsigned char* __st = __status;
302 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
303 if (!__ky->empty())
304 *__st = __might_match;
305 else {
306 *__st = __does_match;
307 --__n_might_match;
308 ++__n_does_match;
309 }
310 }
311 // While there might be a match, test keywords against the next CharT
312 for (size_t __indx = 0; __b != __e && __n_might_match > 0; ++__indx) {
313 // Peek at the next CharT but don't consume it
314 _CharT __c = *__b;
315 if (!__case_sensitive)
316 __c = __ct.toupper(__c);
317 bool __consume = false;
318 // For each keyword which might match, see if the __indx character is __c
319 // If a match if found, consume __c
320 // If a match is found, and that is the last character in the keyword,
321 // then that keyword matches.
322 // If the keyword doesn't match this character, then change the keyword
323 // to doesn't match
324 __st = __status;
325 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
326 if (*__st == __might_match) {
327 _CharT __kc = (*__ky)[__indx];
328 if (!__case_sensitive)
329 __kc = __ct.toupper(__kc);
330 if (__c == __kc) {
331 __consume = true;
332 if (__ky->size() == __indx + 1) {
333 *__st = __does_match;
334 --__n_might_match;
335 ++__n_does_match;
336 }
337 } else {
338 *__st = __doesnt_match;
339 --__n_might_match;
340 }
341 }
342 }
343 // consume if we matched a character
344 if (__consume) {
345 ++__b;
346 // If we consumed a character and there might be a matched keyword that
347 // was marked matched on a previous iteration, then such keywords
348 // which are now marked as not matching.
349 if (__n_might_match + __n_does_match > 1) {
350 __st = __status;
351 for (_ForwardIterator __ky = __kb; __ky != __ke; ++__ky, (void)++__st) {
352 if (*__st == __does_match && __ky->size() != __indx + 1) {
353 *__st = __doesnt_match;
354 --__n_does_match;
355 }
356 }
357 }
358 }
359 }
360 // We've exited the loop because we hit eof and/or we have no more "might matches".
361 if (__b == __e)
362 __err |= ios_base::eofbit;
363 // Return the first matching result
364 for (__st = __status; __kb != __ke; ++__kb, (void)++__st)
365 if (*__st == __does_match)
366 break;
367 if (__kb == __ke)
368 __err |= ios_base::failbit;
369 return __kb;
370}
371
372struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base {
373 static const int __num_get_buf_sz = 40;
374
375 static int __get_base(ios_base&);
376 static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN"
377 // count of leading characters in __src used for parsing integers ("012..X+-")
378 static const size_t __int_chr_cnt = 26;
379 // count of leading characters in __src used for parsing floating-point values ("012..-pP")
380 static const size_t __fp_chr_cnt = 28;
381};
382
383_LIBCPP_EXPORTED_FROM_ABI void
384__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err);
385
386template <class _CharT>
387struct __num_get : protected __num_get_base {
388 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep);
389
390 static int __stage2_float_loop(
391 _CharT __ct,
392 bool& __in_units,
393 char& __exp,
394 char* __a,
395 char*& __a_end,
396 _CharT __decimal_point,
397 _CharT __thousands_sep,
398 const string& __grouping,
399 unsigned* __g,
400 unsigned*& __g_end,
401 unsigned& __dc,
402 _CharT* __atoms);
403# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
404 static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
405 static int __stage2_int_loop(
406 _CharT __ct,
407 int __base,
408 char* __a,
409 char*& __a_end,
410 unsigned& __dc,
411 _CharT __thousands_sep,
412 const string& __grouping,
413 unsigned* __g,
414 unsigned*& __g_end,
415 _CharT* __atoms);
416
417# else
418 static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) {
419 locale __loc = __iob.getloc();
420 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
421 __thousands_sep = __np.thousands_sep();
422 return __np.grouping();
423 }
424
425 const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const { return __do_widen_p(__iob, __atoms); }
426
427 static int __stage2_int_loop(
428 _CharT __ct,
429 int __base,
430 char* __a,
431 char*& __a_end,
432 unsigned& __dc,
433 _CharT __thousands_sep,
434 const string& __grouping,
435 unsigned* __g,
436 unsigned*& __g_end,
437 const _CharT* __atoms);
438
439private:
440 template <typename _Tp>
441 const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const {
442 locale __loc = __iob.getloc();
443 use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
444 return __atoms;
445 }
446
447 const char* __do_widen_p(ios_base& __iob, char* __atoms) const {
448 (void)__iob;
449 (void)__atoms;
450 return __src;
451 }
452# endif
453};
454
455# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
456template <class _CharT>
457string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) {
458 locale __loc = __iob.getloc();
459 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
460 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
461 __thousands_sep = __np.thousands_sep();
462 return __np.grouping();
463}
464# endif
465
466template <class _CharT>
467string __num_get<_CharT>::__stage2_float_prep(
468 ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) {
469 locale __loc = __iob.getloc();
470 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms);
471 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
472 __decimal_point = __np.decimal_point();
473 __thousands_sep = __np.thousands_sep();
474 return __np.grouping();
475}
476
477template <class _CharT>
478int
479# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
480__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
481 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
482 unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
483# else
484__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
485 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
486 unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
487
488# endif
489{
490 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) {
491 *__a_end++ = __ct == __atoms[24] ? '+' : '-';
492 __dc = 0;
493 return 0;
494 }
495 if (__grouping.size() != 0 && __ct == __thousands_sep) {
496 if (__g_end - __g < __num_get_buf_sz) {
497 *__g_end++ = __dc;
498 __dc = 0;
499 }
500 return 0;
501 }
502 ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms;
503 if (__f >= 24)
504 return -1;
505 switch (__base) {
506 case 8:
507 case 10:
508 if (__f >= __base)
509 return -1;
510 break;
511 case 16:
512 if (__f < 22)
513 break;
514 if (__a_end != __a && __a_end - __a <= 2 && __a_end[-1] == '0') {
515 __dc = 0;
516 *__a_end++ = __src[__f];
517 return 0;
518 }
519 return -1;
520 }
521 *__a_end++ = __src[__f];
522 ++__dc;
523 return 0;
524}
525
526template <class _CharT>
527int __num_get<_CharT>::__stage2_float_loop(
528 _CharT __ct,
529 bool& __in_units,
530 char& __exp,
531 char* __a,
532 char*& __a_end,
533 _CharT __decimal_point,
534 _CharT __thousands_sep,
535 const string& __grouping,
536 unsigned* __g,
537 unsigned*& __g_end,
538 unsigned& __dc,
539 _CharT* __atoms) {
540 if (__ct == __decimal_point) {
541 if (!__in_units)
542 return -1;
543 __in_units = false;
544 *__a_end++ = '.';
545 if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz)
546 *__g_end++ = __dc;
547 return 0;
548 }
549 if (__ct == __thousands_sep && __grouping.size() != 0) {
550 if (!__in_units)
551 return -1;
552 if (__g_end - __g < __num_get_buf_sz) {
553 *__g_end++ = __dc;
554 __dc = 0;
555 }
556 return 0;
557 }
558 ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms;
559 if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt))
560 return -1;
561 char __x = __src[__f];
562 if (__x == '-' || __x == '+') {
563 if (__a_end == __a || (std::toupper(__a_end[-1]) == std::toupper(__exp))) {
564 *__a_end++ = __x;
565 return 0;
566 }
567 return -1;
568 }
569 if (__x == 'x' || __x == 'X')
570 __exp = 'P';
571 else if (std::toupper(__x) == __exp) {
572 __exp = std::tolower(__exp);
573 if (__in_units) {
574 __in_units = false;
575 if (__grouping.size() != 0 && __g_end - __g < __num_get_buf_sz)
576 *__g_end++ = __dc;
577 }
578 }
579 *__a_end++ = __x;
580 if (__f >= 22)
581 return 0;
582 ++__dc;
583 return 0;
584}
585
586extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
587# if _LIBCPP_HAS_WIDE_CHARACTERS
588extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
589# endif
590
591template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
592class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> {
593public:
594 typedef _CharT char_type;
595 typedef _InputIterator iter_type;
596
597 _LIBCPP_HIDE_FROM_ABI explicit num_get(size_t __refs = 0) : locale::facet(__refs) {}
598
599 _LIBCPP_HIDE_FROM_ABI iter_type
600 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const {
601 return do_get(__b, __e, __iob, __err, __v);
602 }
603
604 _LIBCPP_HIDE_FROM_ABI iter_type
605 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const {
606 return do_get(__b, __e, __iob, __err, __v);
607 }
608
609 _LIBCPP_HIDE_FROM_ABI iter_type
610 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const {
611 return do_get(__b, __e, __iob, __err, __v);
612 }
613
614 _LIBCPP_HIDE_FROM_ABI iter_type
615 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const {
616 return do_get(__b, __e, __iob, __err, __v);
617 }
618
619 _LIBCPP_HIDE_FROM_ABI iter_type
620 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const {
621 return do_get(__b, __e, __iob, __err, __v);
622 }
623
624 _LIBCPP_HIDE_FROM_ABI iter_type
625 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const {
626 return do_get(__b, __e, __iob, __err, __v);
627 }
628
629 _LIBCPP_HIDE_FROM_ABI iter_type
630 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const {
631 return do_get(__b, __e, __iob, __err, __v);
632 }
633
634 _LIBCPP_HIDE_FROM_ABI iter_type
635 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const {
636 return do_get(__b, __e, __iob, __err, __v);
637 }
638
639 _LIBCPP_HIDE_FROM_ABI iter_type
640 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const {
641 return do_get(__b, __e, __iob, __err, __v);
642 }
643
644 _LIBCPP_HIDE_FROM_ABI iter_type
645 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
646 return do_get(__b, __e, __iob, __err, __v);
647 }
648
649 _LIBCPP_HIDE_FROM_ABI iter_type
650 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const {
651 return do_get(__b, __e, __iob, __err, __v);
652 }
653
654 static locale::id id;
655
656protected:
657 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_get() override {}
658
659 template <class _Fp>
660 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type
661 __do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const;
662
663 template <class _Signed>
664 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type
665 __do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const;
666
667 template <class _Unsigned>
668 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS iter_type
669 __do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const;
670
671 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const;
672
673 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long& __v) const {
674 return this->__do_get_signed(__b, __e, __iob, __err, __v);
675 }
676
677 virtual iter_type
678 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long long& __v) const {
679 return this->__do_get_signed(__b, __e, __iob, __err, __v);
680 }
681
682 virtual iter_type
683 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned short& __v) const {
684 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
685 }
686
687 virtual iter_type
688 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned int& __v) const {
689 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
690 }
691
692 virtual iter_type
693 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long& __v) const {
694 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
695 }
696
697 virtual iter_type
698 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, unsigned long long& __v) const {
699 return this->__do_get_unsigned(__b, __e, __iob, __err, __v);
700 }
701
702 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, float& __v) const {
703 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
704 }
705
706 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, double& __v) const {
707 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
708 }
709
710 virtual iter_type
711 do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
712 return this->__do_get_floating_point(__b, __e, __iob, __err, __v);
713 }
714
715 virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const;
716};
717
718template <class _CharT, class _InputIterator>
719locale::id num_get<_CharT, _InputIterator>::id;
720
721template <class _Tp>
722_LIBCPP_HIDE_FROM_ABI _Tp
723__num_get_signed_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) {
724 if (__a != __a_end) {
725 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
726 errno = 0;
727 char* __p2;
728 long long __ll = __locale::__strtoll(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
729 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
730 if (__current_errno == 0)
731 errno = __save_errno;
732 if (__p2 != __a_end) {
733 __err = ios_base::failbit;
734 return 0;
735 } else if (__current_errno == ERANGE || __ll < numeric_limits<_Tp>::min() || numeric_limits<_Tp>::max() < __ll) {
736 __err = ios_base::failbit;
737 if (__ll > 0)
738 return numeric_limits<_Tp>::max();
739 else
740 return numeric_limits<_Tp>::min();
741 }
742 return static_cast<_Tp>(__ll);
743 }
744 __err = ios_base::failbit;
745 return 0;
746}
747
748template <class _Tp>
749_LIBCPP_HIDE_FROM_ABI _Tp
750__num_get_unsigned_integral(const char* __a, const char* __a_end, ios_base::iostate& __err, int __base) {
751 if (__a != __a_end) {
752 const bool __negate = *__a == '-';
753 if (__negate && ++__a == __a_end) {
754 __err = ios_base::failbit;
755 return 0;
756 }
757 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
758 errno = 0;
759 char* __p2;
760 unsigned long long __ll = __locale::__strtoull(__a, &__p2, __base, _LIBCPP_GET_C_LOCALE);
761 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
762 if (__current_errno == 0)
763 errno = __save_errno;
764 if (__p2 != __a_end) {
765 __err = ios_base::failbit;
766 return 0;
767 } else if (__current_errno == ERANGE || numeric_limits<_Tp>::max() < __ll) {
768 __err = ios_base::failbit;
769 return numeric_limits<_Tp>::max();
770 }
771 _Tp __res = static_cast<_Tp>(__ll);
772 if (__negate)
773 __res = -__res;
774 return __res;
775 }
776 __err = ios_base::failbit;
777 return 0;
778}
779
780template <class _Tp>
781_LIBCPP_HIDE_FROM_ABI _Tp __do_strtod(const char* __a, char** __p2);
782
783template <>
784inline _LIBCPP_HIDE_FROM_ABI float __do_strtod<float>(const char* __a, char** __p2) {
785 return __locale::__strtof(__a, __p2, _LIBCPP_GET_C_LOCALE);
786}
787
788template <>
789inline _LIBCPP_HIDE_FROM_ABI double __do_strtod<double>(const char* __a, char** __p2) {
790 return __locale::__strtod(__a, __p2, _LIBCPP_GET_C_LOCALE);
791}
792
793template <>
794inline _LIBCPP_HIDE_FROM_ABI long double __do_strtod<long double>(const char* __a, char** __p2) {
795 return __locale::__strtold(__a, __p2, _LIBCPP_GET_C_LOCALE);
796}
797
798template <class _Tp>
799_LIBCPP_HIDE_FROM_ABI _Tp __num_get_float(const char* __a, const char* __a_end, ios_base::iostate& __err) {
800 if (__a != __a_end) {
801 __libcpp_remove_reference_t<decltype(errno)> __save_errno = errno;
802 errno = 0;
803 char* __p2;
804 _Tp __ld = std::__do_strtod<_Tp>(__a, &__p2);
805 __libcpp_remove_reference_t<decltype(errno)> __current_errno = errno;
806 if (__current_errno == 0)
807 errno = __save_errno;
808 if (__p2 != __a_end) {
809 __err = ios_base::failbit;
810 return 0;
811 } else if (__current_errno == ERANGE)
812 __err = ios_base::failbit;
813 return __ld;
814 }
815 __err = ios_base::failbit;
816 return 0;
817}
818
819template <class _CharT, class _InputIterator>
820_InputIterator num_get<_CharT, _InputIterator>::do_get(
821 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const {
822 if ((__iob.flags() & ios_base::boolalpha) == 0) {
823 long __lv = -1;
824 __b = do_get(__b, __e, __iob, __err, __lv);
825 switch (__lv) {
826 case 0:
827 __v = false;
828 break;
829 case 1:
830 __v = true;
831 break;
832 default:
833 __v = true;
834 __err = ios_base::failbit;
835 break;
836 }
837 return __b;
838 }
839 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__iob.getloc());
840 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__iob.getloc());
841 typedef typename numpunct<_CharT>::string_type string_type;
842 const string_type __names[2] = {__np.truename(), __np.falsename()};
843 const string_type* __i = std::__scan_keyword(__b, __e, __names, __names + 2, __ct, __err);
844 __v = __i == __names;
845 return __b;
846}
847
848// signed
849
850template <class _CharT, class _InputIterator>
851template <class _Signed>
852_InputIterator num_get<_CharT, _InputIterator>::__do_get_signed(
853 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Signed& __v) const {
854 // Stage 1
855 int __base = this->__get_base(__iob);
856 // Stage 2
857 char_type __thousands_sep;
858 const int __atoms_size = __num_get_base::__int_chr_cnt;
859# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
860 char_type __atoms1[__atoms_size];
861 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
862 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
863# else
864 char_type __atoms[__atoms_size];
865 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
866# endif
867 string __buf;
868 __buf.resize(__buf.capacity());
869 char* __a = &__buf[0];
870 char* __a_end = __a;
871 unsigned __g[__num_get_base::__num_get_buf_sz];
872 unsigned* __g_end = __g;
873 unsigned __dc = 0;
874 for (; __b != __e; ++__b) {
875 if (__a_end == __a + __buf.size()) {
876 size_t __tmp = __buf.size();
877 __buf.resize(2 * __buf.size());
878 __buf.resize(__buf.capacity());
879 __a = &__buf[0];
880 __a_end = __a + __tmp;
881 }
882 if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms))
883 break;
884 }
885 if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz)
886 *__g_end++ = __dc;
887 // Stage 3
888 __v = std::__num_get_signed_integral<_Signed>(__a, __a_end, __err, __base);
889 // Digit grouping checked
890 __check_grouping(__grouping, __g, __g_end, __err);
891 // EOF checked
892 if (__b == __e)
893 __err |= ios_base::eofbit;
894 return __b;
895}
896
897// unsigned
898
899template <class _CharT, class _InputIterator>
900template <class _Unsigned>
901_InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned(
902 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Unsigned& __v) const {
903 // Stage 1
904 int __base = this->__get_base(__iob);
905 // Stage 2
906 char_type __thousands_sep;
907 const int __atoms_size = __num_get_base::__int_chr_cnt;
908# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
909 char_type __atoms1[__atoms_size];
910 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
911 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
912# else
913 char_type __atoms[__atoms_size];
914 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
915# endif
916 string __buf;
917 __buf.resize(__buf.capacity());
918 char* __a = &__buf[0];
919 char* __a_end = __a;
920 unsigned __g[__num_get_base::__num_get_buf_sz];
921 unsigned* __g_end = __g;
922 unsigned __dc = 0;
923 for (; __b != __e; ++__b) {
924 if (__a_end == __a + __buf.size()) {
925 size_t __tmp = __buf.size();
926 __buf.resize(2 * __buf.size());
927 __buf.resize(__buf.capacity());
928 __a = &__buf[0];
929 __a_end = __a + __tmp;
930 }
931 if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms))
932 break;
933 }
934 if (__grouping.size() != 0 && __g_end - __g < __num_get_base::__num_get_buf_sz)
935 *__g_end++ = __dc;
936 // Stage 3
937 __v = std::__num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base);
938 // Digit grouping checked
939 __check_grouping(__grouping, __g, __g_end, __err);
940 // EOF checked
941 if (__b == __e)
942 __err |= ios_base::eofbit;
943 return __b;
944}
945
946// floating point
947
948template <class _CharT, class _InputIterator>
949template <class _Fp>
950_InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point(
951 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const {
952 // Stage 1, nothing to do
953 // Stage 2
954 char_type __atoms[__num_get_base::__fp_chr_cnt];
955 char_type __decimal_point;
956 char_type __thousands_sep;
957 string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep);
958 string __buf;
959 __buf.resize(__buf.capacity());
960 char* __a = &__buf[0];
961 char* __a_end = __a;
962 unsigned __g[__num_get_base::__num_get_buf_sz];
963 unsigned* __g_end = __g;
964 unsigned __dc = 0;
965 bool __in_units = true;
966 char __exp = 'E';
967 bool __is_leading_parsed = false;
968 for (; __b != __e; ++__b) {
969 if (__a_end == __a + __buf.size()) {
970 size_t __tmp = __buf.size();
971 __buf.resize(2 * __buf.size());
972 __buf.resize(__buf.capacity());
973 __a = &__buf[0];
974 __a_end = __a + __tmp;
975 }
976 if (this->__stage2_float_loop(
977 *__b,
978 __in_units,
979 __exp,
980 __a,
981 __a_end,
982 __decimal_point,
983 __thousands_sep,
984 __grouping,
985 __g,
986 __g_end,
987 __dc,
988 __atoms))
989 break;
990
991 // the leading character excluding the sign must be a decimal digit
992 if (!__is_leading_parsed) {
993 if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') {
994 if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.')
995 __is_leading_parsed = true;
996 else
997 break;
998 } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) {
999 if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.')
1000 __is_leading_parsed = true;
1001 else
1002 break;
1003 }
1004 }
1005 }
1006 if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz)
1007 *__g_end++ = __dc;
1008 // Stage 3
1009 __v = std::__num_get_float<_Fp>(__a, __a_end, __err);
1010 // Digit grouping checked
1011 __check_grouping(__grouping, __g, __g_end, __err);
1012 // EOF checked
1013 if (__b == __e)
1014 __err |= ios_base::eofbit;
1015 return __b;
1016}
1017
1018template <class _CharT, class _InputIterator>
1019_InputIterator num_get<_CharT, _InputIterator>::do_get(
1020 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const {
1021 // Stage 1
1022 int __base = 16;
1023 // Stage 2
1024 char_type __atoms[__num_get_base::__int_chr_cnt];
1025 char_type __thousands_sep = char_type();
1026 string __grouping;
1027 std::use_facet<ctype<_CharT> >(__iob.getloc())
1028 .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms);
1029 string __buf;
1030 __buf.resize(__buf.capacity());
1031 char* __a = &__buf[0];
1032 char* __a_end = __a;
1033 unsigned __g[__num_get_base::__num_get_buf_sz];
1034 unsigned* __g_end = __g;
1035 unsigned __dc = 0;
1036 for (; __b != __e; ++__b) {
1037 if (__a_end == __a + __buf.size()) {
1038 size_t __tmp = __buf.size();
1039 __buf.resize(2 * __buf.size());
1040 __buf.resize(__buf.capacity());
1041 __a = &__buf[0];
1042 __a_end = __a + __tmp;
1043 }
1044 if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, __thousands_sep, __grouping, __g, __g_end, __atoms))
1045 break;
1046 }
1047 // Stage 3
1048 __buf.resize(__a_end - __a);
1049 if (__locale::__sscanf(__buf.c_str(), _LIBCPP_GET_C_LOCALE, "%p", &__v) != 1)
1050 __err = ios_base::failbit;
1051 // EOF checked
1052 if (__b == __e)
1053 __err |= ios_base::eofbit;
1054 return __b;
1055}
1056
1057extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
1058# if _LIBCPP_HAS_WIDE_CHARACTERS
1059extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
1060# endif
1061
1062struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base {
1063protected:
1064 static void __format_int(char* __fmt, const char* __len, bool __signd, ios_base::fmtflags __flags);
1065 static bool __format_float(char* __fmt, const char* __len, ios_base::fmtflags __flags);
1066 static char* __identify_padding(char* __nb, char* __ne, const ios_base& __iob);
1067};
1068
1069template <class _CharT>
1070struct __num_put : protected __num_put_base {
1071 static void __widen_and_group_int(
1072 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc);
1073 static void __widen_and_group_float(
1074 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc);
1075};
1076
1077template <class _CharT>
1078void __num_put<_CharT>::__widen_and_group_int(
1079 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) {
1080 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc);
1081 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
1082 string __grouping = __npt.grouping();
1083 if (__grouping.empty()) {
1084 __ct.widen(__nb, __ne, __ob);
1085 __oe = __ob + (__ne - __nb);
1086 } else {
1087 __oe = __ob;
1088 char* __nf = __nb;
1089 if (*__nf == '-' || *__nf == '+')
1090 *__oe++ = __ct.widen(*__nf++);
1091 if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) {
1092 *__oe++ = __ct.widen(*__nf++);
1093 *__oe++ = __ct.widen(*__nf++);
1094 }
1095 std::reverse(__nf, __ne);
1096 _CharT __thousands_sep = __npt.thousands_sep();
1097 unsigned __dc = 0;
1098 unsigned __dg = 0;
1099 for (char* __p = __nf; __p < __ne; ++__p) {
1100 if (static_cast<unsigned>(__grouping[__dg]) > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) {
1101 *__oe++ = __thousands_sep;
1102 __dc = 0;
1103 if (__dg < __grouping.size() - 1)
1104 ++__dg;
1105 }
1106 *__oe++ = __ct.widen(*__p);
1107 ++__dc;
1108 }
1109 std::reverse(__ob + (__nf - __nb), __oe);
1110 }
1111 if (__np == __ne)
1112 __op = __oe;
1113 else
1114 __op = __ob + (__np - __nb);
1115}
1116
1117template <class _CharT>
1118void __num_put<_CharT>::__widen_and_group_float(
1119 char* __nb, char* __np, char* __ne, _CharT* __ob, _CharT*& __op, _CharT*& __oe, const locale& __loc) {
1120 const ctype<_CharT>& __ct = std::use_facet<ctype<_CharT> >(__loc);
1121 const numpunct<_CharT>& __npt = std::use_facet<numpunct<_CharT> >(__loc);
1122 string __grouping = __npt.grouping();
1123 __oe = __ob;
1124 char* __nf = __nb;
1125 if (*__nf == '-' || *__nf == '+')
1126 *__oe++ = __ct.widen(*__nf++);
1127 char* __ns;
1128 if (__ne - __nf >= 2 && __nf[0] == '0' && (__nf[1] == 'x' || __nf[1] == 'X')) {
1129 *__oe++ = __ct.widen(*__nf++);
1130 *__oe++ = __ct.widen(*__nf++);
1131 for (__ns = __nf; __ns < __ne; ++__ns)
1132 if (!__locale::__isxdigit(*__ns, _LIBCPP_GET_C_LOCALE))
1133 break;
1134 } else {
1135 for (__ns = __nf; __ns < __ne; ++__ns)
1136 if (!__locale::__isdigit(*__ns, _LIBCPP_GET_C_LOCALE))
1137 break;
1138 }
1139 if (__grouping.empty()) {
1140 __ct.widen(__nf, __ns, __oe);
1141 __oe += __ns - __nf;
1142 } else {
1143 std::reverse(__nf, __ns);
1144 _CharT __thousands_sep = __npt.thousands_sep();
1145 unsigned __dc = 0;
1146 unsigned __dg = 0;
1147 for (char* __p = __nf; __p < __ns; ++__p) {
1148 if (__grouping[__dg] > 0 && __dc == static_cast<unsigned>(__grouping[__dg])) {
1149 *__oe++ = __thousands_sep;
1150 __dc = 0;
1151 if (__dg < __grouping.size() - 1)
1152 ++__dg;
1153 }
1154 *__oe++ = __ct.widen(*__p);
1155 ++__dc;
1156 }
1157 std::reverse(__ob + (__nf - __nb), __oe);
1158 }
1159 for (__nf = __ns; __nf < __ne; ++__nf) {
1160 if (*__nf == '.') {
1161 *__oe++ = __npt.decimal_point();
1162 ++__nf;
1163 break;
1164 } else
1165 *__oe++ = __ct.widen(*__nf);
1166 }
1167 __ct.widen(__nf, __ne, __oe);
1168 __oe += __ne - __nf;
1169 if (__np == __ne)
1170 __op = __oe;
1171 else
1172 __op = __ob + (__np - __nb);
1173}
1174
1175extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
1176# if _LIBCPP_HAS_WIDE_CHARACTERS
1177extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
1178# endif
1179
1180template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
1181class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> {
1182public:
1183 typedef _CharT char_type;
1184 typedef _OutputIterator iter_type;
1185
1186 _LIBCPP_HIDE_FROM_ABI explicit num_put(size_t __refs = 0) : locale::facet(__refs) {}
1187
1188 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {
1189 return do_put(__s, __iob, __fl, __v);
1190 }
1191
1192 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const {
1193 return do_put(__s, __iob, __fl, __v);
1194 }
1195
1196 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const {
1197 return do_put(__s, __iob, __fl, __v);
1198 }
1199
1200 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const {
1201 return do_put(__s, __iob, __fl, __v);
1202 }
1203
1204 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const {
1205 return do_put(__s, __iob, __fl, __v);
1206 }
1207
1208 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const {
1209 return do_put(__s, __iob, __fl, __v);
1210 }
1211
1212 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const {
1213 return do_put(__s, __iob, __fl, __v);
1214 }
1215
1216 _LIBCPP_HIDE_FROM_ABI iter_type put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const {
1217 return do_put(__s, __iob, __fl, __v);
1218 }
1219
1220 static locale::id id;
1221
1222protected:
1223 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~num_put() override {}
1224
1225 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const;
1226 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const;
1227 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const;
1228 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long) const;
1229 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long) const;
1230 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const;
1231 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const;
1232 virtual iter_type do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const;
1233
1234 template <class _Integral>
1235 _LIBCPP_HIDE_FROM_ABI inline _OutputIterator
1236 __do_put_integral(iter_type __s, ios_base& __iob, char_type __fl, _Integral __v, char const* __len) const;
1237
1238 template <class _Float>
1239 _LIBCPP_HIDE_FROM_ABI inline _OutputIterator
1240 __do_put_floating_point(iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const;
1241};
1242
1243template <class _CharT, class _OutputIterator>
1244locale::id num_put<_CharT, _OutputIterator>::id;
1245
1246template <class _CharT, class _OutputIterator>
1247_OutputIterator
1248num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, bool __v) const {
1249 if ((__iob.flags() & ios_base::boolalpha) == 0)
1250 return do_put(__s, __iob, __fl, (unsigned long)__v);
1251 const numpunct<char_type>& __np = std::use_facet<numpunct<char_type> >(__iob.getloc());
1252 typedef typename numpunct<char_type>::string_type string_type;
1253 string_type __nm = __v ? __np.truename() : __np.falsename();
1254 for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s)
1255 *__s = *__i;
1256 return __s;
1257}
1258
1259template <class _CharT, class _OutputIterator>
1260template <class _Integral>
1261_LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_integral(
1262 iter_type __s, ios_base& __iob, char_type __fl, _Integral __v, char const* __len) const {
1263 // Stage 1 - Get number in narrow char
1264 char __fmt[8] = {'%', 0};
1265 this->__format_int(__fmt + 1, __len, is_signed<_Integral>::value, __iob.flags());
1266 // Worst case is octal, with showbase enabled. Note that octal is always
1267 // printed as an unsigned value.
1268 using _Unsigned = typename make_unsigned<_Integral>::type;
1269 _LIBCPP_CONSTEXPR const unsigned __nbuf =
1270 (numeric_limits<_Unsigned>::digits / 3) // 1 char per 3 bits
1271 + ((numeric_limits<_Unsigned>::digits % 3) != 0) // round up
1272 + 2; // base prefix + terminating null character
1273 char __nar[__nbuf];
1274 _LIBCPP_DIAGNOSTIC_PUSH
1275 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1276 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1277 int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, __fmt, __v);
1278 _LIBCPP_DIAGNOSTIC_POP
1279 char* __ne = __nar + __nc;
1280 char* __np = this->__identify_padding(__nar, __ne, __iob);
1281 // Stage 2 - Widen __nar while adding thousands separators
1282 char_type __o[2 * (__nbuf - 1) - 1];
1283 char_type* __op; // pad here
1284 char_type* __oe; // end of output
1285 this->__widen_and_group_int(__nar, __np, __ne, __o, __op, __oe, __iob.getloc());
1286 // [__o, __oe) contains thousands_sep'd wide number
1287 // Stage 3 & 4
1288 return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1289}
1290
1291template <class _CharT, class _OutputIterator>
1292_OutputIterator
1293num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long __v) const {
1294 return this->__do_put_integral(__s, __iob, __fl, __v, "l");
1295}
1296
1297template <class _CharT, class _OutputIterator>
1298_OutputIterator
1299num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long long __v) const {
1300 return this->__do_put_integral(__s, __iob, __fl, __v, "ll");
1301}
1302
1303template <class _CharT, class _OutputIterator>
1304_OutputIterator
1305num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long __v) const {
1306 return this->__do_put_integral(__s, __iob, __fl, __v, "l");
1307}
1308
1309template <class _CharT, class _OutputIterator>
1310_OutputIterator
1311num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, unsigned long long __v) const {
1312 return this->__do_put_integral(__s, __iob, __fl, __v, "ll");
1313}
1314
1315template <class _CharT, class _OutputIterator>
1316template <class _Float>
1317_LIBCPP_HIDE_FROM_ABI inline _OutputIterator num_put<_CharT, _OutputIterator>::__do_put_floating_point(
1318 iter_type __s, ios_base& __iob, char_type __fl, _Float __v, char const* __len) const {
1319 // Stage 1 - Get number in narrow char
1320 char __fmt[8] = {'%', 0};
1321 bool __specify_precision = this->__format_float(__fmt + 1, __len, __iob.flags());
1322 const unsigned __nbuf = 30;
1323 char __nar[__nbuf];
1324 char* __nb = __nar;
1325 int __nc;
1326 _LIBCPP_DIAGNOSTIC_PUSH
1327 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1328 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
1329 if (__specify_precision)
1330 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1331 else
1332 __nc = __locale::__snprintf(__nb, __nbuf, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1333 unique_ptr<char, void (*)(void*)> __nbh(nullptr, free);
1334 if (__nc > static_cast<int>(__nbuf - 1)) {
1335 if (__specify_precision)
1336 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, (int)__iob.precision(), __v);
1337 else
1338 __nc = __locale::__asprintf(&__nb, _LIBCPP_GET_C_LOCALE, __fmt, __v);
1339 if (__nc == -1)
1340 __throw_bad_alloc();
1341 __nbh.reset(__nb);
1342 }
1343 _LIBCPP_DIAGNOSTIC_POP
1344 char* __ne = __nb + __nc;
1345 char* __np = this->__identify_padding(__nb, __ne, __iob);
1346 // Stage 2 - Widen __nar while adding thousands separators
1347 char_type __o[2 * (__nbuf - 1) - 1];
1348 char_type* __ob = __o;
1349 unique_ptr<char_type, void (*)(void*)> __obh(0, free);
1350 if (__nb != __nar) {
1351 __ob = (char_type*)malloc(2 * static_cast<size_t>(__nc) * sizeof(char_type));
1352 if (__ob == 0)
1353 __throw_bad_alloc();
1354 __obh.reset(__ob);
1355 }
1356 char_type* __op; // pad here
1357 char_type* __oe; // end of output
1358 this->__widen_and_group_float(__nb, __np, __ne, __ob, __op, __oe, __iob.getloc());
1359 // [__o, __oe) contains thousands_sep'd wide number
1360 // Stage 3 & 4
1361 __s = std::__pad_and_output(__s, __ob, __op, __oe, __iob, __fl);
1362 return __s;
1363}
1364
1365template <class _CharT, class _OutputIterator>
1366_OutputIterator
1367num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, double __v) const {
1368 return this->__do_put_floating_point(__s, __iob, __fl, __v, "");
1369}
1370
1371template <class _CharT, class _OutputIterator>
1372_OutputIterator
1373num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, long double __v) const {
1374 return this->__do_put_floating_point(__s, __iob, __fl, __v, "L");
1375}
1376
1377template <class _CharT, class _OutputIterator>
1378_OutputIterator
1379num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_type __fl, const void* __v) const {
1380 // Stage 1 - Get pointer in narrow char
1381 const unsigned __nbuf = 20;
1382 char __nar[__nbuf];
1383 int __nc = __locale::__snprintf(__nar, sizeof(__nar), _LIBCPP_GET_C_LOCALE, "%p", __v);
1384 char* __ne = __nar + __nc;
1385 char* __np = this->__identify_padding(__nar, __ne, __iob);
1386 // Stage 2 - Widen __nar
1387 char_type __o[2 * (__nbuf - 1) - 1];
1388 char_type* __op; // pad here
1389 char_type* __oe; // end of output
1390 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1391 __ct.widen(__nar, __ne, __o);
1392 __oe = __o + (__ne - __nar);
1393 if (__np == __ne)
1394 __op = __oe;
1395 else
1396 __op = __o + (__np - __nar);
1397 // [__o, __oe) contains wide number
1398 // Stage 3 & 4
1399 return std::__pad_and_output(__s, __o, __op, __oe, __iob, __fl);
1400}
1401
1402extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
1403# if _LIBCPP_HAS_WIDE_CHARACTERS
1404extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1405# endif
1406
1407template <class _CharT, class _InputIterator>
1408_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(
1409 _InputIterator& __b, _InputIterator __e, ios_base::iostate& __err, const ctype<_CharT>& __ct, int __n) {
1410 // Precondition: __n >= 1
1411 if (__b == __e) {
1412 __err |= ios_base::eofbit | ios_base::failbit;
1413 return 0;
1414 }
1415 // get first digit
1416 _CharT __c = *__b;
1417 if (!__ct.is(ctype_base::digit, __c)) {
1418 __err |= ios_base::failbit;
1419 return 0;
1420 }
1421 int __r = __ct.narrow(__c, 0) - '0';
1422 for (++__b, (void)--__n; __b != __e && __n > 0; ++__b, (void)--__n) {
1423 // get next digit
1424 __c = *__b;
1425 if (!__ct.is(ctype_base::digit, __c))
1426 return __r;
1427 __r = __r * 10 + __ct.narrow(__c, 0) - '0';
1428 }
1429 if (__b == __e)
1430 __err |= ios_base::eofbit;
1431 return __r;
1432}
1433
1434class _LIBCPP_EXPORTED_FROM_ABI time_base {
1435public:
1436 enum dateorder { no_order, dmy, mdy, ymd, ydm };
1437};
1438
1439template <class _CharT>
1440class _LIBCPP_TEMPLATE_VIS __time_get_c_storage {
1441protected:
1442 typedef basic_string<_CharT> string_type;
1443
1444 virtual const string_type* __weeks() const;
1445 virtual const string_type* __months() const;
1446 virtual const string_type* __am_pm() const;
1447 virtual const string_type& __c() const;
1448 virtual const string_type& __r() const;
1449 virtual const string_type& __x() const;
1450 virtual const string_type& __X() const;
1451
1452 _LIBCPP_HIDE_FROM_ABI ~__time_get_c_storage() {}
1453};
1454
1455template <>
1456_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__weeks() const;
1457template <>
1458_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__months() const;
1459template <>
1460_LIBCPP_EXPORTED_FROM_ABI const string* __time_get_c_storage<char>::__am_pm() const;
1461template <>
1462_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__c() const;
1463template <>
1464_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__r() const;
1465template <>
1466_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const;
1467template <>
1468_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const;
1469
1470# if _LIBCPP_HAS_WIDE_CHARACTERS
1471template <>
1472_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const;
1473template <>
1474_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__months() const;
1475template <>
1476_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__am_pm() const;
1477template <>
1478_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__c() const;
1479template <>
1480_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__r() const;
1481template <>
1482_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const;
1483template <>
1484_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const;
1485# endif
1486
1487template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
1488class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> {
1489public:
1490 typedef _CharT char_type;
1491 typedef _InputIterator iter_type;
1492 typedef time_base::dateorder dateorder;
1493 typedef basic_string<char_type> string_type;
1494
1495 _LIBCPP_HIDE_FROM_ABI explicit time_get(size_t __refs = 0) : locale::facet(__refs) {}
1496
1497 _LIBCPP_HIDE_FROM_ABI dateorder date_order() const { return this->do_date_order(); }
1498
1499 _LIBCPP_HIDE_FROM_ABI iter_type
1500 get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1501 return do_get_time(__b, __e, __iob, __err, __tm);
1502 }
1503
1504 _LIBCPP_HIDE_FROM_ABI iter_type
1505 get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1506 return do_get_date(__b, __e, __iob, __err, __tm);
1507 }
1508
1509 _LIBCPP_HIDE_FROM_ABI iter_type
1510 get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1511 return do_get_weekday(__b, __e, __iob, __err, __tm);
1512 }
1513
1514 _LIBCPP_HIDE_FROM_ABI iter_type
1515 get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1516 return do_get_monthname(__b, __e, __iob, __err, __tm);
1517 }
1518
1519 _LIBCPP_HIDE_FROM_ABI iter_type
1520 get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1521 return do_get_year(__b, __e, __iob, __err, __tm);
1522 }
1523
1524 _LIBCPP_HIDE_FROM_ABI iter_type
1525 get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod = 0)
1526 const {
1527 return do_get(__b, __e, __iob, __err, __tm, __fmt, __mod);
1528 }
1529
1530 iter_type
1531 get(iter_type __b,
1532 iter_type __e,
1533 ios_base& __iob,
1534 ios_base::iostate& __err,
1535 tm* __tm,
1536 const char_type* __fmtb,
1537 const char_type* __fmte) const;
1538
1539 static locale::id id;
1540
1541protected:
1542 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get() override {}
1543
1544 virtual dateorder do_date_order() const;
1545 virtual iter_type
1546 do_get_time(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
1547 virtual iter_type
1548 do_get_date(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
1549 virtual iter_type
1550 do_get_weekday(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
1551 virtual iter_type
1552 do_get_monthname(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
1553 virtual iter_type
1554 do_get_year(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const;
1555 virtual iter_type do_get(
1556 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char __mod) const;
1557
1558private:
1559 void __get_white_space(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1560 void __get_percent(iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1561
1562 void __get_weekdayname(
1563 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1564 void __get_monthname(
1565 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1566 void __get_day(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1567 void
1568 __get_month(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1569 void
1570 __get_year(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1571 void
1572 __get_year4(int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1573 void
1574 __get_hour(int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1575 void
1576 __get_12_hour(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1577 void
1578 __get_am_pm(int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1579 void
1580 __get_minute(int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1581 void
1582 __get_second(int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1583 void
1584 __get_weekday(int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1585 void __get_day_year_num(
1586 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const;
1587};
1588
1589template <class _CharT, class _InputIterator>
1590locale::id time_get<_CharT, _InputIterator>::id;
1591
1592// time_get primitives
1593
1594template <class _CharT, class _InputIterator>
1595void time_get<_CharT, _InputIterator>::__get_weekdayname(
1596 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1597 // Note: ignoring case comes from the POSIX strptime spec
1598 const string_type* __wk = this->__weeks();
1599 ptrdiff_t __i = std::__scan_keyword(__b, __e, __wk, __wk + 14, __ct, __err, false) - __wk;
1600 if (__i < 14)
1601 __w = __i % 7;
1602}
1603
1604template <class _CharT, class _InputIterator>
1605void time_get<_CharT, _InputIterator>::__get_monthname(
1606 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1607 // Note: ignoring case comes from the POSIX strptime spec
1608 const string_type* __month = this->__months();
1609 ptrdiff_t __i = std::__scan_keyword(__b, __e, __month, __month + 24, __ct, __err, false) - __month;
1610 if (__i < 24)
1611 __m = __i % 12;
1612}
1613
1614template <class _CharT, class _InputIterator>
1615void time_get<_CharT, _InputIterator>::__get_day(
1616 int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1617 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1618 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 31)
1619 __d = __t;
1620 else
1621 __err |= ios_base::failbit;
1622}
1623
1624template <class _CharT, class _InputIterator>
1625void time_get<_CharT, _InputIterator>::__get_month(
1626 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1627 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2) - 1;
1628 if (!(__err & ios_base::failbit) && 0 <= __t && __t <= 11)
1629 __m = __t;
1630 else
1631 __err |= ios_base::failbit;
1632}
1633
1634template <class _CharT, class _InputIterator>
1635void time_get<_CharT, _InputIterator>::__get_year(
1636 int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1637 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
1638 if (!(__err & ios_base::failbit)) {
1639 if (__t < 69)
1640 __t += 2000;
1641 else if (69 <= __t && __t <= 99)
1642 __t += 1900;
1643 __y = __t - 1900;
1644 }
1645}
1646
1647template <class _CharT, class _InputIterator>
1648void time_get<_CharT, _InputIterator>::__get_year4(
1649 int& __y, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1650 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 4);
1651 if (!(__err & ios_base::failbit))
1652 __y = __t - 1900;
1653}
1654
1655template <class _CharT, class _InputIterator>
1656void time_get<_CharT, _InputIterator>::__get_hour(
1657 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1658 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1659 if (!(__err & ios_base::failbit) && __t <= 23)
1660 __h = __t;
1661 else
1662 __err |= ios_base::failbit;
1663}
1664
1665template <class _CharT, class _InputIterator>
1666void time_get<_CharT, _InputIterator>::__get_12_hour(
1667 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1668 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1669 if (!(__err & ios_base::failbit) && 1 <= __t && __t <= 12)
1670 __h = __t;
1671 else
1672 __err |= ios_base::failbit;
1673}
1674
1675template <class _CharT, class _InputIterator>
1676void time_get<_CharT, _InputIterator>::__get_minute(
1677 int& __m, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1678 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1679 if (!(__err & ios_base::failbit) && __t <= 59)
1680 __m = __t;
1681 else
1682 __err |= ios_base::failbit;
1683}
1684
1685template <class _CharT, class _InputIterator>
1686void time_get<_CharT, _InputIterator>::__get_second(
1687 int& __s, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1688 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 2);
1689 if (!(__err & ios_base::failbit) && __t <= 60)
1690 __s = __t;
1691 else
1692 __err |= ios_base::failbit;
1693}
1694
1695template <class _CharT, class _InputIterator>
1696void time_get<_CharT, _InputIterator>::__get_weekday(
1697 int& __w, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1698 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 1);
1699 if (!(__err & ios_base::failbit) && __t <= 6)
1700 __w = __t;
1701 else
1702 __err |= ios_base::failbit;
1703}
1704
1705template <class _CharT, class _InputIterator>
1706void time_get<_CharT, _InputIterator>::__get_day_year_num(
1707 int& __d, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1708 int __t = std::__get_up_to_n_digits(__b, __e, __err, __ct, 3);
1709 if (!(__err & ios_base::failbit) && __t <= 365)
1710 __d = __t;
1711 else
1712 __err |= ios_base::failbit;
1713}
1714
1715template <class _CharT, class _InputIterator>
1716void time_get<_CharT, _InputIterator>::__get_white_space(
1717 iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1718 for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
1719 ;
1720 if (__b == __e)
1721 __err |= ios_base::eofbit;
1722}
1723
1724template <class _CharT, class _InputIterator>
1725void time_get<_CharT, _InputIterator>::__get_am_pm(
1726 int& __h, iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1727 const string_type* __ap = this->__am_pm();
1728 if (__ap[0].size() + __ap[1].size() == 0) {
1729 __err |= ios_base::failbit;
1730 return;
1731 }
1732 ptrdiff_t __i = std::__scan_keyword(__b, __e, __ap, __ap + 2, __ct, __err, false) - __ap;
1733 if (__i == 0 && __h == 12)
1734 __h = 0;
1735 else if (__i == 1 && __h < 12)
1736 __h += 12;
1737}
1738
1739template <class _CharT, class _InputIterator>
1740void time_get<_CharT, _InputIterator>::__get_percent(
1741 iter_type& __b, iter_type __e, ios_base::iostate& __err, const ctype<char_type>& __ct) const {
1742 if (__b == __e) {
1743 __err |= ios_base::eofbit | ios_base::failbit;
1744 return;
1745 }
1746 if (__ct.narrow(*__b, 0) != '%')
1747 __err |= ios_base::failbit;
1748 else if (++__b == __e)
1749 __err |= ios_base::eofbit;
1750}
1751
1752// time_get end primitives
1753
1754template <class _CharT, class _InputIterator>
1755_InputIterator time_get<_CharT, _InputIterator>::get(
1756 iter_type __b,
1757 iter_type __e,
1758 ios_base& __iob,
1759 ios_base::iostate& __err,
1760 tm* __tm,
1761 const char_type* __fmtb,
1762 const char_type* __fmte) const {
1763 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1764 __err = ios_base::goodbit;
1765 while (__fmtb != __fmte && __err == ios_base::goodbit) {
1766 if (__b == __e) {
1767 __err = ios_base::failbit;
1768 break;
1769 }
1770 if (__ct.narrow(*__fmtb, 0) == '%') {
1771 if (++__fmtb == __fmte) {
1772 __err = ios_base::failbit;
1773 break;
1774 }
1775 char __cmd = __ct.narrow(*__fmtb, 0);
1776 char __opt = '\0';
1777 if (__cmd == 'E' || __cmd == '0') {
1778 if (++__fmtb == __fmte) {
1779 __err = ios_base::failbit;
1780 break;
1781 }
1782 __opt = __cmd;
1783 __cmd = __ct.narrow(*__fmtb, 0);
1784 }
1785 __b = do_get(__b, __e, __iob, __err, __tm, __cmd, __opt);
1786 ++__fmtb;
1787 } else if (__ct.is(ctype_base::space, *__fmtb)) {
1788 for (++__fmtb; __fmtb != __fmte && __ct.is(ctype_base::space, *__fmtb); ++__fmtb)
1789 ;
1790 for (; __b != __e && __ct.is(ctype_base::space, *__b); ++__b)
1791 ;
1792 } else if (__ct.toupper(*__b) == __ct.toupper(*__fmtb)) {
1793 ++__b;
1794 ++__fmtb;
1795 } else
1796 __err = ios_base::failbit;
1797 }
1798 if (__b == __e)
1799 __err |= ios_base::eofbit;
1800 return __b;
1801}
1802
1803template <class _CharT, class _InputIterator>
1804typename time_get<_CharT, _InputIterator>::dateorder time_get<_CharT, _InputIterator>::do_date_order() const {
1805 return mdy;
1806}
1807
1808template <class _CharT, class _InputIterator>
1809_InputIterator time_get<_CharT, _InputIterator>::do_get_time(
1810 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1811 const char_type __fmt[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
1812 return get(__b, __e, __iob, __err, __tm, __fmt, __fmt + sizeof(__fmt) / sizeof(__fmt[0]));
1813}
1814
1815template <class _CharT, class _InputIterator>
1816_InputIterator time_get<_CharT, _InputIterator>::do_get_date(
1817 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1818 const string_type& __fmt = this->__x();
1819 return get(__b, __e, __iob, __err, __tm, __fmt.data(), __fmt.data() + __fmt.size());
1820}
1821
1822template <class _CharT, class _InputIterator>
1823_InputIterator time_get<_CharT, _InputIterator>::do_get_weekday(
1824 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1825 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1826 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
1827 return __b;
1828}
1829
1830template <class _CharT, class _InputIterator>
1831_InputIterator time_get<_CharT, _InputIterator>::do_get_monthname(
1832 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1833 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1834 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
1835 return __b;
1836}
1837
1838template <class _CharT, class _InputIterator>
1839_InputIterator time_get<_CharT, _InputIterator>::do_get_year(
1840 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm) const {
1841 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1842 __get_year(__tm->tm_year, __b, __e, __err, __ct);
1843 return __b;
1844}
1845
1846template <class _CharT, class _InputIterator>
1847_InputIterator time_get<_CharT, _InputIterator>::do_get(
1848 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, tm* __tm, char __fmt, char) const {
1849 __err = ios_base::goodbit;
1850 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
1851 switch (__fmt) {
1852 case 'a':
1853 case 'A':
1854 __get_weekdayname(__tm->tm_wday, __b, __e, __err, __ct);
1855 break;
1856 case 'b':
1857 case 'B':
1858 case 'h':
1859 __get_monthname(__tm->tm_mon, __b, __e, __err, __ct);
1860 break;
1861 case 'c': {
1862 const string_type& __fm = this->__c();
1863 __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
1864 } break;
1865 case 'd':
1866 case 'e':
1867 __get_day(__tm->tm_mday, __b, __e, __err, __ct);
1868 break;
1869 case 'D': {
1870 const char_type __fm[] = {'%', 'm', '/', '%', 'd', '/', '%', 'y'};
1871 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
1872 } break;
1873 case 'F': {
1874 const char_type __fm[] = {'%', 'Y', '-', '%', 'm', '-', '%', 'd'};
1875 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
1876 } break;
1877 case 'H':
1878 __get_hour(__tm->tm_hour, __b, __e, __err, __ct);
1879 break;
1880 case 'I':
1881 __get_12_hour(__tm->tm_hour, __b, __e, __err, __ct);
1882 break;
1883 case 'j':
1884 __get_day_year_num(__tm->tm_yday, __b, __e, __err, __ct);
1885 break;
1886 case 'm':
1887 __get_month(__tm->tm_mon, __b, __e, __err, __ct);
1888 break;
1889 case 'M':
1890 __get_minute(__tm->tm_min, __b, __e, __err, __ct);
1891 break;
1892 case 'n':
1893 case 't':
1894 __get_white_space(__b, __e, __err, __ct);
1895 break;
1896 case 'p':
1897 __get_am_pm(__tm->tm_hour, __b, __e, __err, __ct);
1898 break;
1899 case 'r': {
1900 const char_type __fm[] = {'%', 'I', ':', '%', 'M', ':', '%', 'S', ' ', '%', 'p'};
1901 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
1902 } break;
1903 case 'R': {
1904 const char_type __fm[] = {'%', 'H', ':', '%', 'M'};
1905 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
1906 } break;
1907 case 'S':
1908 __get_second(__tm->tm_sec, __b, __e, __err, __ct);
1909 break;
1910 case 'T': {
1911 const char_type __fm[] = {'%', 'H', ':', '%', 'M', ':', '%', 'S'};
1912 __b = get(__b, __e, __iob, __err, __tm, __fm, __fm + sizeof(__fm) / sizeof(__fm[0]));
1913 } break;
1914 case 'w':
1915 __get_weekday(__tm->tm_wday, __b, __e, __err, __ct);
1916 break;
1917 case 'x':
1918 return do_get_date(__b, __e, __iob, __err, __tm);
1919 case 'X': {
1920 const string_type& __fm = this->__X();
1921 __b = get(__b, __e, __iob, __err, __tm, __fm.data(), __fm.data() + __fm.size());
1922 } break;
1923 case 'y':
1924 __get_year(__tm->tm_year, __b, __e, __err, __ct);
1925 break;
1926 case 'Y':
1927 __get_year4(__tm->tm_year, __b, __e, __err, __ct);
1928 break;
1929 case '%':
1930 __get_percent(__b, __e, __err, __ct);
1931 break;
1932 default:
1933 __err |= ios_base::failbit;
1934 }
1935 return __b;
1936}
1937
1938extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
1939# if _LIBCPP_HAS_WIDE_CHARACTERS
1940extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
1941# endif
1942
1943class _LIBCPP_EXPORTED_FROM_ABI __time_get {
1944protected:
1945 __locale::__locale_t __loc_;
1946
1947 __time_get(const char* __nm);
1948 __time_get(const string& __nm);
1949 ~__time_get();
1950};
1951
1952template <class _CharT>
1953class _LIBCPP_TEMPLATE_VIS __time_get_storage : public __time_get {
1954protected:
1955 typedef basic_string<_CharT> string_type;
1956
1957 string_type __weeks_[14];
1958 string_type __months_[24];
1959 string_type __am_pm_[2];
1960 string_type __c_;
1961 string_type __r_;
1962 string_type __x_;
1963 string_type __X_;
1964
1965 explicit __time_get_storage(const char* __nm);
1966 explicit __time_get_storage(const string& __nm);
1967
1968 _LIBCPP_HIDE_FROM_ABI ~__time_get_storage() {}
1969
1970 time_base::dateorder __do_date_order() const;
1971
1972private:
1973 void init(const ctype<_CharT>&);
1974 string_type __analyze(char __fmt, const ctype<_CharT>&);
1975};
1976
1977# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
1978 template <> \
1979 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
1980 template <> \
1981 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
1982 template <> \
1983 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
1984 template <> \
1985 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
1986 template <> \
1987 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \
1988 char, const ctype<_CharT>&); \
1989 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \
1990 const; \
1991 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
1992 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
1993 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
1994 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \
1995 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
1996 /**/
1997
1998_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
1999# if _LIBCPP_HAS_WIDE_CHARACTERS
2000_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2001# endif
2002# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
2003
2004template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
2005class _LIBCPP_TEMPLATE_VIS time_get_byname
2006 : public time_get<_CharT, _InputIterator>,
2007 private __time_get_storage<_CharT> {
2008public:
2009 typedef time_base::dateorder dateorder;
2010 typedef _InputIterator iter_type;
2011 typedef _CharT char_type;
2012 typedef basic_string<char_type> string_type;
2013
2014 _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const char* __nm, size_t __refs = 0)
2015 : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {}
2016 _LIBCPP_HIDE_FROM_ABI explicit time_get_byname(const string& __nm, size_t __refs = 0)
2017 : time_get<_CharT, _InputIterator>(__refs), __time_get_storage<_CharT>(__nm) {}
2018
2019protected:
2020 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_get_byname() override {}
2021
2022 _LIBCPP_HIDE_FROM_ABI_VIRTUAL dateorder do_date_order() const override { return this->__do_date_order(); }
2023
2024private:
2025 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __weeks() const override { return this->__weeks_; }
2026 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __months() const override { return this->__months_; }
2027 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type* __am_pm() const override { return this->__am_pm_; }
2028 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __c() const override { return this->__c_; }
2029 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __r() const override { return this->__r_; }
2030 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __x() const override { return this->__x_; }
2031 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const string_type& __X() const override { return this->__X_; }
2032};
2033
2034extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
2035# if _LIBCPP_HAS_WIDE_CHARACTERS
2036extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
2037# endif
2038
2039class _LIBCPP_EXPORTED_FROM_ABI __time_put {
2040 __locale::__locale_t __loc_;
2041
2042protected:
2043 _LIBCPP_HIDE_FROM_ABI __time_put() : __loc_(_LIBCPP_GET_C_LOCALE) {}
2044 __time_put(const char* __nm);
2045 __time_put(const string& __nm);
2046 ~__time_put();
2047 void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const;
2048# if _LIBCPP_HAS_WIDE_CHARACTERS
2049 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const;
2050# endif
2051};
2052
2053template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2054class _LIBCPP_TEMPLATE_VIS time_put : public locale::facet, private __time_put {
2055public:
2056 typedef _CharT char_type;
2057 typedef _OutputIterator iter_type;
2058
2059 _LIBCPP_HIDE_FROM_ABI explicit time_put(size_t __refs = 0) : locale::facet(__refs) {}
2060
2061 iter_type
2062 put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe)
2063 const;
2064
2065 _LIBCPP_HIDE_FROM_ABI iter_type
2066 put(iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, char __fmt, char __mod = 0) const {
2067 return do_put(__s, __iob, __fl, __tm, __fmt, __mod);
2068 }
2069
2070 static locale::id id;
2071
2072protected:
2073 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put() override {}
2074 virtual iter_type do_put(iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const;
2075
2076 _LIBCPP_HIDE_FROM_ABI explicit time_put(const char* __nm, size_t __refs) : locale::facet(__refs), __time_put(__nm) {}
2077 _LIBCPP_HIDE_FROM_ABI explicit time_put(const string& __nm, size_t __refs)
2078 : locale::facet(__refs), __time_put(__nm) {}
2079};
2080
2081template <class _CharT, class _OutputIterator>
2082locale::id time_put<_CharT, _OutputIterator>::id;
2083
2084template <class _CharT, class _OutputIterator>
2085_OutputIterator time_put<_CharT, _OutputIterator>::put(
2086 iter_type __s, ios_base& __iob, char_type __fl, const tm* __tm, const char_type* __pb, const char_type* __pe)
2087 const {
2088 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__iob.getloc());
2089 for (; __pb != __pe; ++__pb) {
2090 if (__ct.narrow(*__pb, 0) == '%') {
2091 if (++__pb == __pe) {
2092 *__s++ = __pb[-1];
2093 break;
2094 }
2095 char __mod = 0;
2096 char __fmt = __ct.narrow(*__pb, 0);
2097 if (__fmt == 'E' || __fmt == 'O') {
2098 if (++__pb == __pe) {
2099 *__s++ = __pb[-2];
2100 *__s++ = __pb[-1];
2101 break;
2102 }
2103 __mod = __fmt;
2104 __fmt = __ct.narrow(*__pb, 0);
2105 }
2106 __s = do_put(__s, __iob, __fl, __tm, __fmt, __mod);
2107 } else
2108 *__s++ = *__pb;
2109 }
2110 return __s;
2111}
2112
2113template <class _CharT, class _OutputIterator>
2114_OutputIterator time_put<_CharT, _OutputIterator>::do_put(
2115 iter_type __s, ios_base&, char_type, const tm* __tm, char __fmt, char __mod) const {
2116 char_type __nar[100];
2117 char_type* __nb = __nar;
2118 char_type* __ne = __nb + 100;
2119 __do_put(__nb, __ne, __tm, __fmt, __mod);
2120 return std::copy(__nb, __ne, __s);
2121}
2122
2123extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
2124# if _LIBCPP_HAS_WIDE_CHARACTERS
2125extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
2126# endif
2127
2128template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2129class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> {
2130public:
2131 _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const char* __nm, size_t __refs = 0)
2132 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
2133
2134 _LIBCPP_HIDE_FROM_ABI explicit time_put_byname(const string& __nm, size_t __refs = 0)
2135 : time_put<_CharT, _OutputIterator>(__nm, __refs) {}
2136
2137protected:
2138 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~time_put_byname() override {}
2139};
2140
2141extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
2142# if _LIBCPP_HAS_WIDE_CHARACTERS
2143extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
2144# endif
2145
2146// money_base
2147
2148class _LIBCPP_EXPORTED_FROM_ABI money_base {
2149public:
2150 enum part { none, space, symbol, sign, value };
2151 struct pattern {
2152 char field[4];
2153 };
2154
2155 _LIBCPP_HIDE_FROM_ABI money_base() {}
2156};
2157
2158// moneypunct
2159
2160template <class _CharT, bool _International = false>
2161class _LIBCPP_TEMPLATE_VIS moneypunct : public locale::facet, public money_base {
2162public:
2163 typedef _CharT char_type;
2164 typedef basic_string<char_type> string_type;
2165
2166 _LIBCPP_HIDE_FROM_ABI explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {}
2167
2168 _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
2169 _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
2170 _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
2171 _LIBCPP_HIDE_FROM_ABI string_type curr_symbol() const { return do_curr_symbol(); }
2172 _LIBCPP_HIDE_FROM_ABI string_type positive_sign() const { return do_positive_sign(); }
2173 _LIBCPP_HIDE_FROM_ABI string_type negative_sign() const { return do_negative_sign(); }
2174 _LIBCPP_HIDE_FROM_ABI int frac_digits() const { return do_frac_digits(); }
2175 _LIBCPP_HIDE_FROM_ABI pattern pos_format() const { return do_pos_format(); }
2176 _LIBCPP_HIDE_FROM_ABI pattern neg_format() const { return do_neg_format(); }
2177
2178 static locale::id id;
2179 static const bool intl = _International;
2180
2181protected:
2182 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct() override {}
2183
2184 virtual char_type do_decimal_point() const { return numeric_limits<char_type>::max(); }
2185 virtual char_type do_thousands_sep() const { return numeric_limits<char_type>::max(); }
2186 virtual string do_grouping() const { return string(); }
2187 virtual string_type do_curr_symbol() const { return string_type(); }
2188 virtual string_type do_positive_sign() const { return string_type(); }
2189 virtual string_type do_negative_sign() const { return string_type(1, '-'); }
2190 virtual int do_frac_digits() const { return 0; }
2191 virtual pattern do_pos_format() const {
2192 pattern __p = {{symbol, sign, none, value}};
2193 return __p;
2194 }
2195 virtual pattern do_neg_format() const {
2196 pattern __p = {{symbol, sign, none, value}};
2197 return __p;
2198 }
2199};
2200
2201template <class _CharT, bool _International>
2202locale::id moneypunct<_CharT, _International>::id;
2203
2204template <class _CharT, bool _International>
2205const bool moneypunct<_CharT, _International>::intl;
2206
2207extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
2208extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
2209# if _LIBCPP_HAS_WIDE_CHARACTERS
2210extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
2211extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
2212# endif
2213
2214// moneypunct_byname
2215
2216template <class _CharT, bool _International = false>
2217class _LIBCPP_TEMPLATE_VIS moneypunct_byname : public moneypunct<_CharT, _International> {
2218public:
2219 typedef money_base::pattern pattern;
2220 typedef _CharT char_type;
2221 typedef basic_string<char_type> string_type;
2222
2223 _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const char* __nm, size_t __refs = 0)
2224 : moneypunct<_CharT, _International>(__refs) {
2225 init(__nm);
2226 }
2227
2228 _LIBCPP_HIDE_FROM_ABI explicit moneypunct_byname(const string& __nm, size_t __refs = 0)
2229 : moneypunct<_CharT, _International>(__refs) {
2230 init(__nm.c_str());
2231 }
2232
2233protected:
2234 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~moneypunct_byname() override {}
2235
2236 char_type do_decimal_point() const override { return __decimal_point_; }
2237 char_type do_thousands_sep() const override { return __thousands_sep_; }
2238 string do_grouping() const override { return __grouping_; }
2239 string_type do_curr_symbol() const override { return __curr_symbol_; }
2240 string_type do_positive_sign() const override { return __positive_sign_; }
2241 string_type do_negative_sign() const override { return __negative_sign_; }
2242 int do_frac_digits() const override { return __frac_digits_; }
2243 pattern do_pos_format() const override { return __pos_format_; }
2244 pattern do_neg_format() const override { return __neg_format_; }
2245
2246private:
2247 char_type __decimal_point_;
2248 char_type __thousands_sep_;
2249 string __grouping_;
2250 string_type __curr_symbol_;
2251 string_type __positive_sign_;
2252 string_type __negative_sign_;
2253 int __frac_digits_;
2254 pattern __pos_format_;
2255 pattern __neg_format_;
2256
2257 void init(const char*);
2258};
2259
2260template <>
2261_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, false>::init(const char*);
2262template <>
2263_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*);
2264extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
2265extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
2266
2267# if _LIBCPP_HAS_WIDE_CHARACTERS
2268template <>
2269_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*);
2270template <>
2271_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*);
2272extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
2273extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
2274# endif
2275
2276// money_get
2277
2278template <class _CharT>
2279class __money_get {
2280protected:
2281 typedef _CharT char_type;
2282 typedef basic_string<char_type> string_type;
2283
2284 _LIBCPP_HIDE_FROM_ABI __money_get() {}
2285
2286 static void __gather_info(
2287 bool __intl,
2288 const locale& __loc,
2289 money_base::pattern& __pat,
2290 char_type& __dp,
2291 char_type& __ts,
2292 string& __grp,
2293 string_type& __sym,
2294 string_type& __psn,
2295 string_type& __nsn,
2296 int& __fd);
2297};
2298
2299template <class _CharT>
2300void __money_get<_CharT>::__gather_info(
2301 bool __intl,
2302 const locale& __loc,
2303 money_base::pattern& __pat,
2304 char_type& __dp,
2305 char_type& __ts,
2306 string& __grp,
2307 string_type& __sym,
2308 string_type& __psn,
2309 string_type& __nsn,
2310 int& __fd) {
2311 if (__intl) {
2312 const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc);
2313 __pat = __mp.neg_format();
2314 __nsn = __mp.negative_sign();
2315 __psn = __mp.positive_sign();
2316 __dp = __mp.decimal_point();
2317 __ts = __mp.thousands_sep();
2318 __grp = __mp.grouping();
2319 __sym = __mp.curr_symbol();
2320 __fd = __mp.frac_digits();
2321 } else {
2322 const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc);
2323 __pat = __mp.neg_format();
2324 __nsn = __mp.negative_sign();
2325 __psn = __mp.positive_sign();
2326 __dp = __mp.decimal_point();
2327 __ts = __mp.thousands_sep();
2328 __grp = __mp.grouping();
2329 __sym = __mp.curr_symbol();
2330 __fd = __mp.frac_digits();
2331 }
2332}
2333
2334extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
2335# if _LIBCPP_HAS_WIDE_CHARACTERS
2336extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
2337# endif
2338
2339template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
2340class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> {
2341public:
2342 typedef _CharT char_type;
2343 typedef _InputIterator iter_type;
2344 typedef basic_string<char_type> string_type;
2345
2346 _LIBCPP_HIDE_FROM_ABI explicit money_get(size_t __refs = 0) : locale::facet(__refs) {}
2347
2348 _LIBCPP_HIDE_FROM_ABI iter_type
2349 get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
2350 return do_get(__b, __e, __intl, __iob, __err, __v);
2351 }
2352
2353 _LIBCPP_HIDE_FROM_ABI iter_type
2354 get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const {
2355 return do_get(__b, __e, __intl, __iob, __err, __v);
2356 }
2357
2358 static locale::id id;
2359
2360protected:
2361 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_get() override {}
2362
2363 virtual iter_type
2364 do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const;
2365 virtual iter_type
2366 do_get(iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const;
2367
2368private:
2369 static bool __do_get(
2370 iter_type& __b,
2371 iter_type __e,
2372 bool __intl,
2373 const locale& __loc,
2374 ios_base::fmtflags __flags,
2375 ios_base::iostate& __err,
2376 bool& __neg,
2377 const ctype<char_type>& __ct,
2378 unique_ptr<char_type, void (*)(void*)>& __wb,
2379 char_type*& __wn,
2380 char_type* __we);
2381};
2382
2383template <class _CharT, class _InputIterator>
2384locale::id money_get<_CharT, _InputIterator>::id;
2385
2386_LIBCPP_EXPORTED_FROM_ABI void __do_nothing(void*);
2387
2388template <class _Tp>
2389_LIBCPP_HIDE_FROM_ABI void __double_or_nothing(unique_ptr<_Tp, void (*)(void*)>& __b, _Tp*& __n, _Tp*& __e) {
2390 bool __owns = __b.get_deleter() != __do_nothing;
2391 size_t __cur_cap = static_cast<size_t>(__e - __b.get()) * sizeof(_Tp);
2392 size_t __new_cap = __cur_cap < numeric_limits<size_t>::max() / 2 ? 2 * __cur_cap : numeric_limits<size_t>::max();
2393 if (__new_cap == 0)
2394 __new_cap = sizeof(_Tp);
2395 size_t __n_off = static_cast<size_t>(__n - __b.get());
2396 _Tp* __t = (_Tp*)std::realloc(__owns ? __b.get() : 0, __new_cap);
2397 if (__t == 0)
2398 __throw_bad_alloc();
2399 if (__owns)
2400 __b.release();
2401 __b = unique_ptr<_Tp, void (*)(void*)>(__t, free);
2402 __new_cap /= sizeof(_Tp);
2403 __n = __b.get() + __n_off;
2404 __e = __b.get() + __new_cap;
2405}
2406
2407// true == success
2408template <class _CharT, class _InputIterator>
2409bool money_get<_CharT, _InputIterator>::__do_get(
2410 iter_type& __b,
2411 iter_type __e,
2412 bool __intl,
2413 const locale& __loc,
2414 ios_base::fmtflags __flags,
2415 ios_base::iostate& __err,
2416 bool& __neg,
2417 const ctype<char_type>& __ct,
2418 unique_ptr<char_type, void (*)(void*)>& __wb,
2419 char_type*& __wn,
2420 char_type* __we) {
2421 if (__b == __e) {
2422 __err |= ios_base::failbit;
2423 return false;
2424 }
2425 const unsigned __bz = 100;
2426 unsigned __gbuf[__bz];
2427 unique_ptr<unsigned, void (*)(void*)> __gb(__gbuf, __do_nothing);
2428 unsigned* __gn = __gb.get();
2429 unsigned* __ge = __gn + __bz;
2430 money_base::pattern __pat;
2431 char_type __dp;
2432 char_type __ts;
2433 string __grp;
2434 string_type __sym;
2435 string_type __psn;
2436 string_type __nsn;
2437 // Capture the spaces read into money_base::{space,none} so they
2438 // can be compared to initial spaces in __sym.
2439 string_type __spaces;
2440 int __fd;
2441 __money_get<_CharT>::__gather_info(__intl, __loc, __pat, __dp, __ts, __grp, __sym, __psn, __nsn, __fd);
2442 const string_type* __trailing_sign = 0;
2443 __wn = __wb.get();
2444 for (unsigned __p = 0; __p < 4 && __b != __e; ++__p) {
2445 switch (__pat.field[__p]) {
2446 case money_base::space:
2447 if (__p != 3) {
2448 if (__ct.is(ctype_base::space, *__b))
2449 __spaces.push_back(*__b++);
2450 else {
2451 __err |= ios_base::failbit;
2452 return false;
2453 }
2454 }
2455 _LIBCPP_FALLTHROUGH();
2456 case money_base::none:
2457 if (__p != 3) {
2458 while (__b != __e && __ct.is(ctype_base::space, *__b))
2459 __spaces.push_back(*__b++);
2460 }
2461 break;
2462 case money_base::sign:
2463 if (__psn.size() > 0 && *__b == __psn[0]) {
2464 ++__b;
2465 __neg = false;
2466 if (__psn.size() > 1)
2467 __trailing_sign = &__psn;
2468 break;
2469 }
2470 if (__nsn.size() > 0 && *__b == __nsn[0]) {
2471 ++__b;
2472 __neg = true;
2473 if (__nsn.size() > 1)
2474 __trailing_sign = &__nsn;
2475 break;
2476 }
2477 if (__psn.size() > 0 && __nsn.size() > 0) { // sign is required
2478 __err |= ios_base::failbit;
2479 return false;
2480 }
2481 if (__psn.size() == 0 && __nsn.size() == 0)
2482 // locale has no way of specifying a sign. Use the initial value of __neg as a default
2483 break;
2484 __neg = (__nsn.size() == 0);
2485 break;
2486 case money_base::symbol: {
2487 bool __more_needed =
2488 __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none));
2489 bool __sb = (__flags & ios_base::showbase) != 0;
2490 if (__sb || __more_needed) {
2491 typename string_type::const_iterator __sym_space_end = __sym.begin();
2492 if (__p > 0 && (__pat.field[__p - 1] == money_base::none || __pat.field[__p - 1] == money_base::space)) {
2493 // Match spaces we've already read against spaces at
2494 // the beginning of __sym.
2495 while (__sym_space_end != __sym.end() && __ct.is(ctype_base::space, *__sym_space_end))
2496 ++__sym_space_end;
2497 const size_t __num_spaces = __sym_space_end - __sym.begin();
2498 if (__num_spaces > __spaces.size() ||
2499 !std::equal(__spaces.end() - __num_spaces, __spaces.end(), __sym.begin())) {
2500 // No match. Put __sym_space_end back at the
2501 // beginning of __sym, which will prevent a
2502 // match in the next loop.
2503 __sym_space_end = __sym.begin();
2504 }
2505 }
2506 typename string_type::const_iterator __sym_curr_char = __sym_space_end;
2507 while (__sym_curr_char != __sym.end() && __b != __e && *__b == *__sym_curr_char) {
2508 ++__b;
2509 ++__sym_curr_char;
2510 }
2511 if (__sb && __sym_curr_char != __sym.end()) {
2512 __err |= ios_base::failbit;
2513 return false;
2514 }
2515 }
2516 } break;
2517 case money_base::value: {
2518 unsigned __ng = 0;
2519 for (; __b != __e; ++__b) {
2520 char_type __c = *__b;
2521 if (__ct.is(ctype_base::digit, __c)) {
2522 if (__wn == __we)
2523 std::__double_or_nothing(__wb, __wn, __we);
2524 *__wn++ = __c;
2525 ++__ng;
2526 } else if (__grp.size() > 0 && __ng > 0 && __c == __ts) {
2527 if (__gn == __ge)
2528 std::__double_or_nothing(__gb, __gn, __ge);
2529 *__gn++ = __ng;
2530 __ng = 0;
2531 } else
2532 break;
2533 }
2534 if (__gb.get() != __gn && __ng > 0) {
2535 if (__gn == __ge)
2536 std::__double_or_nothing(__gb, __gn, __ge);
2537 *__gn++ = __ng;
2538 }
2539 if (__fd > 0) {
2540 if (__b == __e || *__b != __dp) {
2541 __err |= ios_base::failbit;
2542 return false;
2543 }
2544 for (++__b; __fd > 0; --__fd, ++__b) {
2545 if (__b == __e || !__ct.is(ctype_base::digit, *__b)) {
2546 __err |= ios_base::failbit;
2547 return false;
2548 }
2549 if (__wn == __we)
2550 std::__double_or_nothing(__wb, __wn, __we);
2551 *__wn++ = *__b;
2552 }
2553 }
2554 if (__wn == __wb.get()) {
2555 __err |= ios_base::failbit;
2556 return false;
2557 }
2558 } break;
2559 }
2560 }
2561 if (__trailing_sign) {
2562 for (unsigned __i = 1; __i < __trailing_sign->size(); ++__i, ++__b) {
2563 if (__b == __e || *__b != (*__trailing_sign)[__i]) {
2564 __err |= ios_base::failbit;
2565 return false;
2566 }
2567 }
2568 }
2569 if (__gb.get() != __gn) {
2570 ios_base::iostate __et = ios_base::goodbit;
2571 __check_grouping(__grp, __gb.get(), __gn, __et);
2572 if (__et) {
2573 __err |= ios_base::failbit;
2574 return false;
2575 }
2576 }
2577 return true;
2578}
2579
2580template <class _CharT, class _InputIterator>
2581_InputIterator money_get<_CharT, _InputIterator>::do_get(
2582 iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, long double& __v) const {
2583 const int __bz = 100;
2584 char_type __wbuf[__bz];
2585 unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing);
2586 char_type* __wn;
2587 char_type* __we = __wbuf + __bz;
2588 locale __loc = __iob.getloc();
2589 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
2590 bool __neg = false;
2591 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) {
2592 const char __src[] = "0123456789";
2593 char_type __atoms[sizeof(__src) - 1];
2594 __ct.widen(__src, __src + (sizeof(__src) - 1), __atoms);
2595 char __nbuf[__bz];
2596 char* __nc = __nbuf;
2597 unique_ptr<char, void (*)(void*)> __h(nullptr, free);
2598 if (__wn - __wb.get() > __bz - 2) {
2599 __h.reset((char*)malloc(static_cast<size_t>(__wn - __wb.get() + 2)));
2600 if (__h.get() == nullptr)
2601 __throw_bad_alloc();
2602 __nc = __h.get();
2603 }
2604 if (__neg)
2605 *__nc++ = '-';
2606 for (const char_type* __w = __wb.get(); __w < __wn; ++__w, ++__nc)
2607 *__nc = __src[std::find(__atoms, std::end(__atoms), *__w) - __atoms];
2608 *__nc = char();
2609 if (sscanf(__nbuf, "%Lf", &__v) != 1)
2610 __throw_runtime_error("money_get error");
2611 }
2612 if (__b == __e)
2613 __err |= ios_base::eofbit;
2614 return __b;
2615}
2616
2617template <class _CharT, class _InputIterator>
2618_InputIterator money_get<_CharT, _InputIterator>::do_get(
2619 iter_type __b, iter_type __e, bool __intl, ios_base& __iob, ios_base::iostate& __err, string_type& __v) const {
2620 const int __bz = 100;
2621 char_type __wbuf[__bz];
2622 unique_ptr<char_type, void (*)(void*)> __wb(__wbuf, __do_nothing);
2623 char_type* __wn;
2624 char_type* __we = __wbuf + __bz;
2625 locale __loc = __iob.getloc();
2626 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
2627 bool __neg = false;
2628 if (__do_get(__b, __e, __intl, __loc, __iob.flags(), __err, __neg, __ct, __wb, __wn, __we)) {
2629 __v.clear();
2630 if (__neg)
2631 __v.push_back(__ct.widen('-'));
2632 char_type __z = __ct.widen('0');
2633 char_type* __w;
2634 for (__w = __wb.get(); __w < __wn - 1; ++__w)
2635 if (*__w != __z)
2636 break;
2637 __v.append(__w, __wn);
2638 }
2639 if (__b == __e)
2640 __err |= ios_base::eofbit;
2641 return __b;
2642}
2643
2644extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
2645# if _LIBCPP_HAS_WIDE_CHARACTERS
2646extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
2647# endif
2648
2649// money_put
2650
2651template <class _CharT>
2652class __money_put {
2653protected:
2654 typedef _CharT char_type;
2655 typedef basic_string<char_type> string_type;
2656
2657 _LIBCPP_HIDE_FROM_ABI __money_put() {}
2658
2659 static void __gather_info(
2660 bool __intl,
2661 bool __neg,
2662 const locale& __loc,
2663 money_base::pattern& __pat,
2664 char_type& __dp,
2665 char_type& __ts,
2666 string& __grp,
2667 string_type& __sym,
2668 string_type& __sn,
2669 int& __fd);
2670 static void __format(
2671 char_type* __mb,
2672 char_type*& __mi,
2673 char_type*& __me,
2674 ios_base::fmtflags __flags,
2675 const char_type* __db,
2676 const char_type* __de,
2677 const ctype<char_type>& __ct,
2678 bool __neg,
2679 const money_base::pattern& __pat,
2680 char_type __dp,
2681 char_type __ts,
2682 const string& __grp,
2683 const string_type& __sym,
2684 const string_type& __sn,
2685 int __fd);
2686};
2687
2688template <class _CharT>
2689void __money_put<_CharT>::__gather_info(
2690 bool __intl,
2691 bool __neg,
2692 const locale& __loc,
2693 money_base::pattern& __pat,
2694 char_type& __dp,
2695 char_type& __ts,
2696 string& __grp,
2697 string_type& __sym,
2698 string_type& __sn,
2699 int& __fd) {
2700 if (__intl) {
2701 const moneypunct<char_type, true>& __mp = std::use_facet<moneypunct<char_type, true> >(__loc);
2702 if (__neg) {
2703 __pat = __mp.neg_format();
2704 __sn = __mp.negative_sign();
2705 } else {
2706 __pat = __mp.pos_format();
2707 __sn = __mp.positive_sign();
2708 }
2709 __dp = __mp.decimal_point();
2710 __ts = __mp.thousands_sep();
2711 __grp = __mp.grouping();
2712 __sym = __mp.curr_symbol();
2713 __fd = __mp.frac_digits();
2714 } else {
2715 const moneypunct<char_type, false>& __mp = std::use_facet<moneypunct<char_type, false> >(__loc);
2716 if (__neg) {
2717 __pat = __mp.neg_format();
2718 __sn = __mp.negative_sign();
2719 } else {
2720 __pat = __mp.pos_format();
2721 __sn = __mp.positive_sign();
2722 }
2723 __dp = __mp.decimal_point();
2724 __ts = __mp.thousands_sep();
2725 __grp = __mp.grouping();
2726 __sym = __mp.curr_symbol();
2727 __fd = __mp.frac_digits();
2728 }
2729}
2730
2731template <class _CharT>
2732void __money_put<_CharT>::__format(
2733 char_type* __mb,
2734 char_type*& __mi,
2735 char_type*& __me,
2736 ios_base::fmtflags __flags,
2737 const char_type* __db,
2738 const char_type* __de,
2739 const ctype<char_type>& __ct,
2740 bool __neg,
2741 const money_base::pattern& __pat,
2742 char_type __dp,
2743 char_type __ts,
2744 const string& __grp,
2745 const string_type& __sym,
2746 const string_type& __sn,
2747 int __fd) {
2748 __me = __mb;
2749 for (char __p : __pat.field) {
2750 switch (__p) {
2751 case money_base::none:
2752 __mi = __me;
2753 break;
2754 case money_base::space:
2755 __mi = __me;
2756 *__me++ = __ct.widen(' ');
2757 break;
2758 case money_base::sign:
2759 if (!__sn.empty())
2760 *__me++ = __sn[0];
2761 break;
2762 case money_base::symbol:
2763 if (!__sym.empty() && (__flags & ios_base::showbase))
2764 __me = std::copy(__sym.begin(), __sym.end(), __me);
2765 break;
2766 case money_base::value: {
2767 // remember start of value so we can reverse it
2768 char_type* __t = __me;
2769 // find beginning of digits
2770 if (__neg)
2771 ++__db;
2772 // find end of digits
2773 const char_type* __d;
2774 for (__d = __db; __d < __de; ++__d)
2775 if (!__ct.is(ctype_base::digit, *__d))
2776 break;
2777 // print fractional part
2778 if (__fd > 0) {
2779 int __f;
2780 for (__f = __fd; __d > __db && __f > 0; --__f)
2781 *__me++ = *--__d;
2782 char_type __z = __f > 0 ? __ct.widen('0') : char_type();
2783 for (; __f > 0; --__f)
2784 *__me++ = __z;
2785 *__me++ = __dp;
2786 }
2787 // print units part
2788 if (__d == __db) {
2789 *__me++ = __ct.widen('0');
2790 } else {
2791 unsigned __ng = 0;
2792 unsigned __ig = 0;
2793 unsigned __gl = __grp.empty() ? numeric_limits<unsigned>::max() : static_cast<unsigned>(__grp[__ig]);
2794 while (__d != __db) {
2795 if (__ng == __gl) {
2796 *__me++ = __ts;
2797 __ng = 0;
2798 if (++__ig < __grp.size())
2799 __gl = __grp[__ig] == numeric_limits<char>::max()
2800 ? numeric_limits<unsigned>::max()
2801 : static_cast<unsigned>(__grp[__ig]);
2802 }
2803 *__me++ = *--__d;
2804 ++__ng;
2805 }
2806 }
2807 // reverse it
2808 std::reverse(__t, __me);
2809 } break;
2810 }
2811 }
2812 // print rest of sign, if any
2813 if (__sn.size() > 1)
2814 __me = std::copy(__sn.begin() + 1, __sn.end(), __me);
2815 // set alignment
2816 if ((__flags & ios_base::adjustfield) == ios_base::left)
2817 __mi = __me;
2818 else if ((__flags & ios_base::adjustfield) != ios_base::internal)
2819 __mi = __mb;
2820}
2821
2822extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
2823# if _LIBCPP_HAS_WIDE_CHARACTERS
2824extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
2825# endif
2826
2827template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
2828class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> {
2829public:
2830 typedef _CharT char_type;
2831 typedef _OutputIterator iter_type;
2832 typedef basic_string<char_type> string_type;
2833
2834 _LIBCPP_HIDE_FROM_ABI explicit money_put(size_t __refs = 0) : locale::facet(__refs) {}
2835
2836 _LIBCPP_HIDE_FROM_ABI iter_type
2837 put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const {
2838 return do_put(__s, __intl, __iob, __fl, __units);
2839 }
2840
2841 _LIBCPP_HIDE_FROM_ABI iter_type
2842 put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const {
2843 return do_put(__s, __intl, __iob, __fl, __digits);
2844 }
2845
2846 static locale::id id;
2847
2848protected:
2849 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~money_put() override {}
2850
2851 virtual iter_type do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const;
2852 virtual iter_type
2853 do_put(iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const;
2854};
2855
2856template <class _CharT, class _OutputIterator>
2857locale::id money_put<_CharT, _OutputIterator>::id;
2858
2859template <class _CharT, class _OutputIterator>
2860_OutputIterator money_put<_CharT, _OutputIterator>::do_put(
2861 iter_type __s, bool __intl, ios_base& __iob, char_type __fl, long double __units) const {
2862 // convert to char
2863 const size_t __bs = 100;
2864 char __buf[__bs];
2865 char* __bb = __buf;
2866 char_type __digits[__bs];
2867 char_type* __db = __digits;
2868 int __n = snprintf(__bb, __bs, "%.0Lf", __units);
2869 unique_ptr<char, void (*)(void*)> __hn(nullptr, free);
2870 unique_ptr<char_type, void (*)(void*)> __hd(0, free);
2871 // secure memory for digit storage
2872 if (static_cast<size_t>(__n) > __bs - 1) {
2873 __n = __locale::__asprintf(&__bb, _LIBCPP_GET_C_LOCALE, "%.0Lf", __units);
2874 if (__n == -1)
2875 __throw_bad_alloc();
2876 __hn.reset(__bb);
2877 __hd.reset((char_type*)malloc(static_cast<size_t>(__n) * sizeof(char_type)));
2878 if (__hd == nullptr)
2879 __throw_bad_alloc();
2880 __db = __hd.get();
2881 }
2882 // gather info
2883 locale __loc = __iob.getloc();
2884 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
2885 __ct.widen(__bb, __bb + __n, __db);
2886 bool __neg = __n > 0 && __bb[0] == '-';
2887 money_base::pattern __pat;
2888 char_type __dp;
2889 char_type __ts;
2890 string __grp;
2891 string_type __sym;
2892 string_type __sn;
2893 int __fd;
2894 this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
2895 // secure memory for formatting
2896 char_type __mbuf[__bs];
2897 char_type* __mb = __mbuf;
2898 unique_ptr<char_type, void (*)(void*)> __hw(0, free);
2899 size_t __exn = __n > __fd ? (static_cast<size_t>(__n) - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() +
2900 static_cast<size_t>(__fd) + 1
2901 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
2902 if (__exn > __bs) {
2903 __hw.reset((char_type*)malloc(__exn * sizeof(char_type)));
2904 __mb = __hw.get();
2905 if (__mb == 0)
2906 __throw_bad_alloc();
2907 }
2908 // format
2909 char_type* __mi;
2910 char_type* __me;
2911 this->__format(
2912 __mb, __mi, __me, __iob.flags(), __db, __db + __n, __ct, __neg, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
2913 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
2914}
2915
2916template <class _CharT, class _OutputIterator>
2917_OutputIterator money_put<_CharT, _OutputIterator>::do_put(
2918 iter_type __s, bool __intl, ios_base& __iob, char_type __fl, const string_type& __digits) const {
2919 // gather info
2920 locale __loc = __iob.getloc();
2921 const ctype<char_type>& __ct = std::use_facet<ctype<char_type> >(__loc);
2922 bool __neg = __digits.size() > 0 && __digits[0] == __ct.widen('-');
2923 money_base::pattern __pat;
2924 char_type __dp;
2925 char_type __ts;
2926 string __grp;
2927 string_type __sym;
2928 string_type __sn;
2929 int __fd;
2930 this->__gather_info(__intl, __neg, __loc, __pat, __dp, __ts, __grp, __sym, __sn, __fd);
2931 // secure memory for formatting
2932 char_type __mbuf[100];
2933 char_type* __mb = __mbuf;
2934 unique_ptr<char_type, void (*)(void*)> __h(0, free);
2935 size_t __exn =
2936 static_cast<int>(__digits.size()) > __fd
2937 ? (__digits.size() - static_cast<size_t>(__fd)) * 2 + __sn.size() + __sym.size() + static_cast<size_t>(__fd) +
2938 1
2939 : __sn.size() + __sym.size() + static_cast<size_t>(__fd) + 2;
2940 if (__exn > 100) {
2941 __h.reset((char_type*)malloc(__exn * sizeof(char_type)));
2942 __mb = __h.get();
2943 if (__mb == 0)
2944 __throw_bad_alloc();
2945 }
2946 // format
2947 char_type* __mi;
2948 char_type* __me;
2949 this->__format(
2950 __mb,
2951 __mi,
2952 __me,
2953 __iob.flags(),
2954 __digits.data(),
2955 __digits.data() + __digits.size(),
2956 __ct,
2957 __neg,
2958 __pat,
2959 __dp,
2960 __ts,
2961 __grp,
2962 __sym,
2963 __sn,
2964 __fd);
2965 return std::__pad_and_output(__s, __mb, __mi, __me, __iob, __fl);
2966}
2967
2968extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
2969# if _LIBCPP_HAS_WIDE_CHARACTERS
2970extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
2971# endif
2972
2973// messages
2974
2975class _LIBCPP_EXPORTED_FROM_ABI messages_base {
2976public:
2977 typedef intptr_t catalog;
2978
2979 _LIBCPP_HIDE_FROM_ABI messages_base() {}
2980};
2981
2982template <class _CharT>
2983class _LIBCPP_TEMPLATE_VIS messages : public locale::facet, public messages_base {
2984public:
2985 typedef _CharT char_type;
2986 typedef basic_string<_CharT> string_type;
2987
2988 _LIBCPP_HIDE_FROM_ABI explicit messages(size_t __refs = 0) : locale::facet(__refs) {}
2989
2990 _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const {
2991 return do_open(__nm, __loc);
2992 }
2993
2994 _LIBCPP_HIDE_FROM_ABI string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
2995 return do_get(__c, __set, __msgid, __dflt);
2996 }
2997
2998 _LIBCPP_HIDE_FROM_ABI void close(catalog __c) const { do_close(__c); }
2999
3000 static locale::id id;
3001
3002protected:
3003 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages() override {}
3004
3005 virtual catalog do_open(const basic_string<char>&, const locale&) const;
3006 virtual string_type do_get(catalog, int __set, int __msgid, const string_type& __dflt) const;
3007 virtual void do_close(catalog) const;
3008};
3009
3010template <class _CharT>
3011locale::id messages<_CharT>::id;
3012
3013template <class _CharT>
3014typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const {
3015# if _LIBCPP_HAS_CATOPEN
3016 return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
3017# else // !_LIBCPP_HAS_CATOPEN
3018 (void)__nm;
3019 return -1;
3020# endif // _LIBCPP_HAS_CATOPEN
3021}
3022
3023template <class _CharT>
3024typename messages<_CharT>::string_type
3025messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
3026# if _LIBCPP_HAS_CATOPEN
3027 string __ndflt;
3028 __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()(
3029 std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());
3030 nl_catd __cat = (nl_catd)__c;
3031 static_assert(sizeof(catalog) >= sizeof(nl_catd), "Unexpected nl_catd type");
3032 char* __n = catgets(__cat, __set, __msgid, __ndflt.c_str());
3033 string_type __w;
3034 __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n));
3035 return __w;
3036# else // !_LIBCPP_HAS_CATOPEN
3037 (void)__c;
3038 (void)__set;
3039 (void)__msgid;
3040 return __dflt;
3041# endif // _LIBCPP_HAS_CATOPEN
3042}
3043
3044template <class _CharT>
3045void messages<_CharT>::do_close(catalog __c) const {
3046# if _LIBCPP_HAS_CATOPEN
3047 catclose((nl_catd)__c);
3048# else // !_LIBCPP_HAS_CATOPEN
3049 (void)__c;
3050# endif // _LIBCPP_HAS_CATOPEN
3051}
3052
3053extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
3054# if _LIBCPP_HAS_WIDE_CHARACTERS
3055extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
3056# endif
3057
3058template <class _CharT>
3059class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> {
3060public:
3061 typedef messages_base::catalog catalog;
3062 typedef basic_string<_CharT> string_type;
3063
3064 _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const char*, size_t __refs = 0) : messages<_CharT>(__refs) {}
3065
3066 _LIBCPP_HIDE_FROM_ABI explicit messages_byname(const string&, size_t __refs = 0) : messages<_CharT>(__refs) {}
3067
3068protected:
3069 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~messages_byname() override {}
3070};
3071
3072extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
3073# if _LIBCPP_HAS_WIDE_CHARACTERS
3074extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
3075# endif
3076
3077# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
3078
3079template <class _Codecvt,
3080 class _Elem = wchar_t,
3081 class _WideAlloc = allocator<_Elem>,
3082 class _ByteAlloc = allocator<char> >
3083class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wstring_convert {
3084public:
3085 typedef basic_string<char, char_traits<char>, _ByteAlloc> byte_string;
3086 typedef basic_string<_Elem, char_traits<_Elem>, _WideAlloc> wide_string;
3087 typedef typename _Codecvt::state_type state_type;
3088 typedef typename wide_string::traits_type::int_type int_type;
3089
3090private:
3091 byte_string __byte_err_string_;
3092 wide_string __wide_err_string_;
3093 _Codecvt* __cvtptr_;
3094 state_type __cvtstate_;
3095 size_t __cvtcount_;
3096
3097public:
3098# ifndef _LIBCPP_CXX03_LANG
3099 _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
3100 _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt);
3101# else
3102 _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
3103# endif
3104
3105 _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state);
3106 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3107 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string());
3108# ifndef _LIBCPP_CXX03_LANG
3109 _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc);
3110# endif
3111 _LIBCPP_HIDE_FROM_ABI ~wstring_convert();
3112
3113 wstring_convert(const wstring_convert& __wc) = delete;
3114 wstring_convert& operator=(const wstring_convert& __wc) = delete;
3115
3116 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
3117 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
3118 return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
3119 }
3120 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) {
3121 return from_bytes(__str.data(), __str.data() + __str.size());
3122 }
3123 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last);
3124
3125 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) { return to_bytes(&__wchar, &__wchar + 1); }
3126 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) {
3127 return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));
3128 }
3129 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) {
3130 return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());
3131 }
3132 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last);
3133
3134 _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; }
3135 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; }
3136};
3137
3138_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3139template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3140inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt)
3141 : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) {}
3142_LIBCPP_SUPPRESS_DEPRECATED_POP
3143
3144template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3145inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(_Codecvt* __pcvt, state_type __state)
3146 : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) {}
3147
3148template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3149wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(
3150 const byte_string& __byte_err, const wide_string& __wide_err)
3151 : __byte_err_string_(__byte_err), __wide_err_string_(__wide_err), __cvtstate_(), __cvtcount_(0) {
3152 __cvtptr_ = new _Codecvt;
3153}
3154
3155# ifndef _LIBCPP_CXX03_LANG
3156
3157template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3158inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc)
3159 : __byte_err_string_(std::move(__wc.__byte_err_string_)),
3160 __wide_err_string_(std::move(__wc.__wide_err_string_)),
3161 __cvtptr_(__wc.__cvtptr_),
3162 __cvtstate_(__wc.__cvtstate_),
3163 __cvtcount_(__wc.__cvtcount_) {
3164 __wc.__cvtptr_ = nullptr;
3165}
3166
3167# endif // _LIBCPP_CXX03_LANG
3168
3169_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3170template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3171wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::~wstring_convert() {
3172 delete __cvtptr_;
3173}
3174
3175template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3176typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wide_string
3177wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char* __frm, const char* __frm_end) {
3178 _LIBCPP_SUPPRESS_DEPRECATED_POP
3179 __cvtcount_ = 0;
3180 if (__cvtptr_ != nullptr) {
3181 wide_string __ws(2 * (__frm_end - __frm), _Elem());
3182 if (__frm != __frm_end)
3183 __ws.resize(__ws.capacity());
3184 codecvt_base::result __r = codecvt_base::ok;
3185 state_type __st = __cvtstate_;
3186 if (__frm != __frm_end) {
3187 _Elem* __to = &__ws[0];
3188 _Elem* __to_end = __to + __ws.size();
3189 const char* __frm_nxt;
3190 do {
3191 _Elem* __to_nxt;
3192 __r = __cvtptr_->in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
3193 __cvtcount_ += __frm_nxt - __frm;
3194 if (__frm_nxt == __frm) {
3195 __r = codecvt_base::error;
3196 } else if (__r == codecvt_base::noconv) {
3197 __ws.resize(__to - &__ws[0]);
3198 // This only gets executed if _Elem is char
3199 __ws.append((const _Elem*)__frm, (const _Elem*)__frm_end);
3200 __frm = __frm_nxt;
3201 __r = codecvt_base::ok;
3202 } else if (__r == codecvt_base::ok) {
3203 __ws.resize(__to_nxt - &__ws[0]);
3204 __frm = __frm_nxt;
3205 } else if (__r == codecvt_base::partial) {
3206 ptrdiff_t __s = __to_nxt - &__ws[0];
3207 __ws.resize(2 * __s);
3208 __to = &__ws[0] + __s;
3209 __to_end = &__ws[0] + __ws.size();
3210 __frm = __frm_nxt;
3211 }
3212 } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
3213 }
3214 if (__r == codecvt_base::ok)
3215 return __ws;
3216 }
3217
3218 if (__wide_err_string_.empty())
3219 __throw_range_error("wstring_convert: from_bytes error");
3220
3221 return __wide_err_string_;
3222}
3223
3224template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
3225typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string
3226wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) {
3227 __cvtcount_ = 0;
3228 if (__cvtptr_ != nullptr) {
3229 byte_string __bs(2 * (__frm_end - __frm), char());
3230 if (__frm != __frm_end)
3231 __bs.resize(__bs.capacity());
3232 codecvt_base::result __r = codecvt_base::ok;
3233 state_type __st = __cvtstate_;
3234 if (__frm != __frm_end) {
3235 char* __to = &__bs[0];
3236 char* __to_end = __to + __bs.size();
3237 const _Elem* __frm_nxt;
3238 do {
3239 char* __to_nxt;
3240 __r = __cvtptr_->out(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
3241 __cvtcount_ += __frm_nxt - __frm;
3242 if (__frm_nxt == __frm) {
3243 __r = codecvt_base::error;
3244 } else if (__r == codecvt_base::noconv) {
3245 __bs.resize(__to - &__bs[0]);
3246 // This only gets executed if _Elem is char
3247 __bs.append((const char*)__frm, (const char*)__frm_end);
3248 __frm = __frm_nxt;
3249 __r = codecvt_base::ok;
3250 } else if (__r == codecvt_base::ok) {
3251 __bs.resize(__to_nxt - &__bs[0]);
3252 __frm = __frm_nxt;
3253 } else if (__r == codecvt_base::partial) {
3254 ptrdiff_t __s = __to_nxt - &__bs[0];
3255 __bs.resize(2 * __s);
3256 __to = &__bs[0] + __s;
3257 __to_end = &__bs[0] + __bs.size();
3258 __frm = __frm_nxt;
3259 }
3260 } while (__r == codecvt_base::partial && __frm_nxt < __frm_end);
3261 }
3262 if (__r == codecvt_base::ok) {
3263 size_t __s = __bs.size();
3264 __bs.resize(__bs.capacity());
3265 char* __to = &__bs[0] + __s;
3266 char* __to_end = __to + __bs.size();
3267 do {
3268 char* __to_nxt;
3269 __r = __cvtptr_->unshift(__st, __to, __to_end, __to_nxt);
3270 if (__r == codecvt_base::noconv) {
3271 __bs.resize(__to - &__bs[0]);
3272 __r = codecvt_base::ok;
3273 } else if (__r == codecvt_base::ok) {
3274 __bs.resize(__to_nxt - &__bs[0]);
3275 } else if (__r == codecvt_base::partial) {
3276 ptrdiff_t __sp = __to_nxt - &__bs[0];
3277 __bs.resize(2 * __sp);
3278 __to = &__bs[0] + __sp;
3279 __to_end = &__bs[0] + __bs.size();
3280 }
3281 } while (__r == codecvt_base::partial);
3282 if (__r == codecvt_base::ok)
3283 return __bs;
3284 }
3285 }
3286
3287 if (__byte_err_string_.empty())
3288 __throw_range_error("wstring_convert: to_bytes error");
3289
3290 return __byte_err_string_;
3291}
3292
3293template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
3294class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> {
3295public:
3296 // types:
3297 typedef _Elem char_type;
3298 typedef _Tr traits_type;
3299 typedef typename traits_type::int_type int_type;
3300 typedef typename traits_type::pos_type pos_type;
3301 typedef typename traits_type::off_type off_type;
3302 typedef typename _Codecvt::state_type state_type;
3303
3304private:
3305 char* __extbuf_;
3306 const char* __extbufnext_;
3307 const char* __extbufend_;
3308 char __extbuf_min_[8];
3309 size_t __ebs_;
3310 char_type* __intbuf_;
3311 size_t __ibs_;
3312 streambuf* __bufptr_;
3313 _Codecvt* __cv_;
3314 state_type __st_;
3315 ios_base::openmode __cm_;
3316 bool __owns_eb_;
3317 bool __owns_ib_;
3318 bool __always_noconv_;
3319
3320public:
3321# ifndef _LIBCPP_CXX03_LANG
3322 _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
3323 explicit _LIBCPP_HIDE_FROM_ABI
3324 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3325# else
3326 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
3327 wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3328# endif
3329
3330 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();
3331
3332 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; }
3333 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf(streambuf* __bytebuf) {
3334 streambuf* __r = __bufptr_;
3335 __bufptr_ = __bytebuf;
3336 return __r;
3337 }
3338
3339 wbuffer_convert(const wbuffer_convert&) = delete;
3340 wbuffer_convert& operator=(const wbuffer_convert&) = delete;
3341
3342 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
3343
3344protected:
3345 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type underflow();
3346 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type pbackfail(int_type __c = traits_type::eof());
3347 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type overflow(int_type __c = traits_type::eof());
3348 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual basic_streambuf<char_type, traits_type>* setbuf(char_type* __s, streamsize __n);
3349 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type
3350 seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __wch = ios_base::in | ios_base::out);
3351 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual pos_type
3352 seekpos(pos_type __sp, ios_base::openmode __wch = ios_base::in | ios_base::out);
3353 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int sync();
3354
3355private:
3356 _LIBCPP_HIDE_FROM_ABI_VIRTUAL bool __read_mode();
3357 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __write_mode();
3358 _LIBCPP_HIDE_FROM_ABI_VIRTUAL wbuffer_convert* __close();
3359};
3360
3361_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3362template <class _Codecvt, class _Elem, class _Tr>
3363wbuffer_convert<_Codecvt, _Elem, _Tr>::wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt, state_type __state)
3364 : __extbuf_(nullptr),
3365 __extbufnext_(nullptr),
3366 __extbufend_(nullptr),
3367 __ebs_(0),
3368 __intbuf_(0),
3369 __ibs_(0),
3370 __bufptr_(__bytebuf),
3371 __cv_(__pcvt),
3372 __st_(__state),
3373 __cm_(0),
3374 __owns_eb_(false),
3375 __owns_ib_(false),
3376 __always_noconv_(__cv_ ? __cv_->always_noconv() : false) {
3377 setbuf(0, 4096);
3378}
3379
3380template <class _Codecvt, class _Elem, class _Tr>
3381wbuffer_convert<_Codecvt, _Elem, _Tr>::~wbuffer_convert() {
3382 __close();
3383 delete __cv_;
3384 if (__owns_eb_)
3385 delete[] __extbuf_;
3386 if (__owns_ib_)
3387 delete[] __intbuf_;
3388}
3389
3390template <class _Codecvt, class _Elem, class _Tr>
3391typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow() {
3392 _LIBCPP_SUPPRESS_DEPRECATED_POP
3393 if (__cv_ == 0 || __bufptr_ == nullptr)
3394 return traits_type::eof();
3395 bool __initial = __read_mode();
3396 char_type __1buf;
3397 if (this->gptr() == 0)
3398 this->setg(&__1buf, &__1buf + 1, &__1buf + 1);
3399 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
3400 int_type __c = traits_type::eof();
3401 if (this->gptr() == this->egptr()) {
3402 std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
3403 if (__always_noconv_) {
3404 streamsize __nmemb = static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz);
3405 __nmemb = __bufptr_->sgetn((char*)this->eback() + __unget_sz, __nmemb);
3406 if (__nmemb != 0) {
3407 this->setg(this->eback(), this->eback() + __unget_sz, this->eback() + __unget_sz + __nmemb);
3408 __c = *this->gptr();
3409 }
3410 } else {
3411 if (__extbufend_ != __extbufnext_) {
3412 _LIBCPP_ASSERT_NON_NULL(__extbufnext_ != nullptr, "underflow moving from nullptr");
3413 _LIBCPP_ASSERT_NON_NULL(__extbuf_ != nullptr, "underflow moving into nullptr");
3414 std::memmove(__extbuf_, __extbufnext_, __extbufend_ - __extbufnext_);
3415 }
3416 __extbufnext_ = __extbuf_ + (__extbufend_ - __extbufnext_);
3417 __extbufend_ = __extbuf_ + (__extbuf_ == __extbuf_min_ ? sizeof(__extbuf_min_) : __ebs_);
3418 streamsize __nmemb = std::min(static_cast<streamsize>(this->egptr() - this->eback() - __unget_sz),
3419 static_cast<streamsize>(__extbufend_ - __extbufnext_));
3420 codecvt_base::result __r;
3421 // FIXME: Do we ever need to restore the state here?
3422 // state_type __svs = __st_;
3423 streamsize __nr = __bufptr_->sgetn(const_cast<char*>(__extbufnext_), __nmemb);
3424 if (__nr != 0) {
3425 __extbufend_ = __extbufnext_ + __nr;
3426 char_type* __inext;
3427 __r = __cv_->in(
3428 __st_, __extbuf_, __extbufend_, __extbufnext_, this->eback() + __unget_sz, this->egptr(), __inext);
3429 if (__r == codecvt_base::noconv) {
3430 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_, (char_type*)const_cast<char*>(__extbufend_));
3431 __c = *this->gptr();
3432 } else if (__inext != this->eback() + __unget_sz) {
3433 this->setg(this->eback(), this->eback() + __unget_sz, __inext);
3434 __c = *this->gptr();
3435 }
3436 }
3437 }
3438 } else
3439 __c = *this->gptr();
3440 if (this->eback() == &__1buf)
3441 this->setg(0, 0, 0);
3442 return __c;
3443}
3444
3445_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3446template <class _Codecvt, class _Elem, class _Tr>
3447typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type
3448wbuffer_convert<_Codecvt, _Elem, _Tr>::pbackfail(int_type __c) {
3449 _LIBCPP_SUPPRESS_DEPRECATED_POP
3450 if (__cv_ != 0 && __bufptr_ && this->eback() < this->gptr()) {
3451 if (traits_type::eq_int_type(__c, traits_type::eof())) {
3452 this->gbump(-1);
3453 return traits_type::not_eof(__c);
3454 }
3455 if (traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) {
3456 this->gbump(-1);
3457 *this->gptr() = traits_type::to_char_type(__c);
3458 return __c;
3459 }
3460 }
3461 return traits_type::eof();
3462}
3463
3464_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3465template <class _Codecvt, class _Elem, class _Tr>
3466typename wbuffer_convert<_Codecvt, _Elem, _Tr>::int_type wbuffer_convert<_Codecvt, _Elem, _Tr>::overflow(int_type __c) {
3467 _LIBCPP_SUPPRESS_DEPRECATED_POP
3468 if (__cv_ == 0 || !__bufptr_)
3469 return traits_type::eof();
3470 __write_mode();
3471 char_type __1buf;
3472 char_type* __pb_save = this->pbase();
3473 char_type* __epb_save = this->epptr();
3474 if (!traits_type::eq_int_type(__c, traits_type::eof())) {
3475 if (this->pptr() == 0)
3476 this->setp(&__1buf, &__1buf + 1);
3477 *this->pptr() = traits_type::to_char_type(__c);
3478 this->pbump(1);
3479 }
3480 if (this->pptr() != this->pbase()) {
3481 if (__always_noconv_) {
3482 streamsize __nmemb = static_cast<streamsize>(this->pptr() - this->pbase());
3483 if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
3484 return traits_type::eof();
3485 } else {
3486 char* __extbe = __extbuf_;
3487 codecvt_base::result __r;
3488 do {
3489 const char_type* __e;
3490 __r = __cv_->out(__st_, this->pbase(), this->pptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe);
3491 if (__e == this->pbase())
3492 return traits_type::eof();
3493 if (__r == codecvt_base::noconv) {
3494 streamsize __nmemb = static_cast<size_t>(this->pptr() - this->pbase());
3495 if (__bufptr_->sputn((const char*)this->pbase(), __nmemb) != __nmemb)
3496 return traits_type::eof();
3497 } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) {
3498 streamsize __nmemb = static_cast<size_t>(__extbe - __extbuf_);
3499 if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
3500 return traits_type::eof();
3501 if (__r == codecvt_base::partial) {
3502 this->setp(const_cast<char_type*>(__e), this->pptr());
3503 this->__pbump(this->epptr() - this->pbase());
3504 }
3505 } else
3506 return traits_type::eof();
3507 } while (__r == codecvt_base::partial);
3508 }
3509 this->setp(__pb_save, __epb_save);
3510 }
3511 return traits_type::not_eof(__c);
3512}
3513
3514_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3515template <class _Codecvt, class _Elem, class _Tr>
3516basic_streambuf<_Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::setbuf(char_type* __s, streamsize __n) {
3517 _LIBCPP_SUPPRESS_DEPRECATED_POP
3518 this->setg(0, 0, 0);
3519 this->setp(0, 0);
3520 if (__owns_eb_)
3521 delete[] __extbuf_;
3522 if (__owns_ib_)
3523 delete[] __intbuf_;
3524 __ebs_ = __n;
3525 if (__ebs_ > sizeof(__extbuf_min_)) {
3526 if (__always_noconv_ && __s) {
3527 __extbuf_ = (char*)__s;
3528 __owns_eb_ = false;
3529 } else {
3530 __extbuf_ = new char[__ebs_];
3531 __owns_eb_ = true;
3532 }
3533 } else {
3534 __extbuf_ = __extbuf_min_;
3535 __ebs_ = sizeof(__extbuf_min_);
3536 __owns_eb_ = false;
3537 }
3538 if (!__always_noconv_) {
3539 __ibs_ = max<streamsize>(__n, sizeof(__extbuf_min_));
3540 if (__s && __ibs_ >= sizeof(__extbuf_min_)) {
3541 __intbuf_ = __s;
3542 __owns_ib_ = false;
3543 } else {
3544 __intbuf_ = new char_type[__ibs_];
3545 __owns_ib_ = true;
3546 }
3547 } else {
3548 __ibs_ = 0;
3549 __intbuf_ = 0;
3550 __owns_ib_ = false;
3551 }
3552 return this;
3553}
3554
3555_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3556template <class _Codecvt, class _Elem, class _Tr>
3557typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
3558wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __om) {
3559 int __width = __cv_->encoding();
3560 if (__cv_ == 0 || !__bufptr_ || (__width <= 0 && __off != 0) || sync())
3561 return pos_type(off_type(-1));
3562 // __width > 0 || __off == 0, now check __way
3563 if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end)
3564 return pos_type(off_type(-1));
3565 pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om);
3566 __r.state(__st_);
3567 return __r;
3568}
3569
3570template <class _Codecvt, class _Elem, class _Tr>
3571typename wbuffer_convert<_Codecvt, _Elem, _Tr>::pos_type
3572wbuffer_convert<_Codecvt, _Elem, _Tr>::seekpos(pos_type __sp, ios_base::openmode __wch) {
3573 if (__cv_ == 0 || !__bufptr_ || sync())
3574 return pos_type(off_type(-1));
3575 if (__bufptr_->pubseekpos(__sp, __wch) == pos_type(off_type(-1)))
3576 return pos_type(off_type(-1));
3577 return __sp;
3578}
3579
3580template <class _Codecvt, class _Elem, class _Tr>
3581int wbuffer_convert<_Codecvt, _Elem, _Tr>::sync() {
3582 _LIBCPP_SUPPRESS_DEPRECATED_POP
3583 if (__cv_ == 0 || !__bufptr_)
3584 return 0;
3585 if (__cm_ & ios_base::out) {
3586 if (this->pptr() != this->pbase())
3587 if (overflow() == traits_type::eof())
3588 return -1;
3589 codecvt_base::result __r;
3590 do {
3591 char* __extbe;
3592 __r = __cv_->unshift(__st_, __extbuf_, __extbuf_ + __ebs_, __extbe);
3593 streamsize __nmemb = static_cast<streamsize>(__extbe - __extbuf_);
3594 if (__bufptr_->sputn(__extbuf_, __nmemb) != __nmemb)
3595 return -1;
3596 } while (__r == codecvt_base::partial);
3597 if (__r == codecvt_base::error)
3598 return -1;
3599 if (__bufptr_->pubsync())
3600 return -1;
3601 } else if (__cm_ & ios_base::in) {
3602 off_type __c;
3603 if (__always_noconv_)
3604 __c = this->egptr() - this->gptr();
3605 else {
3606 int __width = __cv_->encoding();
3607 __c = __extbufend_ - __extbufnext_;
3608 if (__width > 0)
3609 __c += __width * (this->egptr() - this->gptr());
3610 else {
3611 if (this->gptr() != this->egptr()) {
3612 std::reverse(this->gptr(), this->egptr());
3613 codecvt_base::result __r;
3614 const char_type* __e = this->gptr();
3615 char* __extbe;
3616 do {
3617 __r = __cv_->out(__st_, __e, this->egptr(), __e, __extbuf_, __extbuf_ + __ebs_, __extbe);
3618 switch (__r) {
3619 case codecvt_base::noconv:
3620 __c += this->egptr() - this->gptr();
3621 break;
3622 case codecvt_base::ok:
3623 case codecvt_base::partial:
3624 __c += __extbe - __extbuf_;
3625 break;
3626 default:
3627 return -1;
3628 }
3629 } while (__r == codecvt_base::partial);
3630 }
3631 }
3632 }
3633 if (__bufptr_->pubseekoff(-__c, ios_base::cur, __cm_) == pos_type(off_type(-1)))
3634 return -1;
3635 this->setg(0, 0, 0);
3636 __cm_ = 0;
3637 }
3638 return 0;
3639}
3640
3641_LIBCPP_SUPPRESS_DEPRECATED_PUSH
3642template <class _Codecvt, class _Elem, class _Tr>
3643bool wbuffer_convert<_Codecvt, _Elem, _Tr>::__read_mode() {
3644 if (!(__cm_ & ios_base::in)) {
3645 this->setp(0, 0);
3646 if (__always_noconv_)
3647 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_);
3648 else
3649 this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
3650 __cm_ = ios_base::in;
3651 return true;
3652 }
3653 return false;
3654}
3655
3656template <class _Codecvt, class _Elem, class _Tr>
3657void wbuffer_convert<_Codecvt, _Elem, _Tr>::__write_mode() {
3658 if (!(__cm_ & ios_base::out)) {
3659 this->setg(0, 0, 0);
3660 if (__ebs_ > sizeof(__extbuf_min_)) {
3661 if (__always_noconv_)
3662 this->setp((char_type*)__extbuf_, (char_type*)__extbuf_ + (__ebs_ - 1));
3663 else
3664 this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
3665 } else
3666 this->setp(0, 0);
3667 __cm_ = ios_base::out;
3668 }
3669}
3670
3671template <class _Codecvt, class _Elem, class _Tr>
3672wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__close() {
3673 wbuffer_convert* __rt = nullptr;
3674 if (__cv_ != nullptr && __bufptr_ != nullptr) {
3675 __rt = this;
3676 if ((__cm_ & ios_base::out) && sync())
3677 __rt = nullptr;
3678 }
3679 return __rt;
3680}
3681
3682_LIBCPP_SUPPRESS_DEPRECATED_POP
3683
3684# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
3685
3686_LIBCPP_END_NAMESPACE_STD
3687
3688_LIBCPP_POP_MACROS
3689
3690// NOLINTEND(libcpp-robust-against-adl)
3691
3692# endif // _LIBCPP_HAS_LOCALIZATION211# endif // _LIBCPP_HAS_LOCALIZATION
3693212
3694# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20213# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
...@@ -3697,6 +216,7 @@ _LIBCPP_POP_MACROS...@@ -3697,6 +216,7 @@ _LIBCPP_POP_MACROS
3697# include <cstdarg>216# include <cstdarg>
3698# include <iterator>217# include <iterator>
3699# include <mutex>218# include <mutex>
219# include <optional>
3700# include <stdexcept>220# include <stdexcept>
3701# include <type_traits>221# include <type_traits>
3702# include <typeinfo>222# include <typeinfo>
lib/libcxx/include/map+94-232
...@@ -582,6 +582,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20...@@ -582,6 +582,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
582# include <__functional/binary_function.h>582# include <__functional/binary_function.h>
583# include <__functional/is_transparent.h>583# include <__functional/is_transparent.h>
584# include <__functional/operations.h>584# include <__functional/operations.h>
585# include <__fwd/map.h>
585# include <__iterator/erase_if_container.h>586# include <__iterator/erase_if_container.h>
586# include <__iterator/iterator_traits.h>587# include <__iterator/iterator_traits.h>
587# include <__iterator/ranges_iterator_traits.h>588# include <__iterator/ranges_iterator_traits.h>
...@@ -592,7 +593,6 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20...@@ -592,7 +593,6 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
592# include <__memory/pointer_traits.h>593# include <__memory/pointer_traits.h>
593# include <__memory/unique_ptr.h>594# include <__memory/unique_ptr.h>
594# include <__memory_resource/polymorphic_allocator.h>595# include <__memory_resource/polymorphic_allocator.h>
595# include <__new/launder.h>
596# include <__node_handle>596# include <__node_handle>
597# include <__ranges/concepts.h>597# include <__ranges/concepts.h>
598# include <__ranges/container_compatible_range.h>598# include <__ranges/container_compatible_range.h>
...@@ -644,13 +644,13 @@ public:...@@ -644,13 +644,13 @@ public:
644 : _Compare(__c) {}644 : _Compare(__c) {}
645 _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; }645 _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; }
646 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const {646 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const {
647 return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y.__get_value().first);647 return static_cast<const _Compare&>(*this)(__x.first, __y.first);
648 }648 }
649 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const {649 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const {
650 return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);650 return static_cast<const _Compare&>(*this)(__x.first, __y);
651 }651 }
652 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {652 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {
653 return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);653 return static_cast<const _Compare&>(*this)(__x, __y.first);
654 }654 }
655 _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {655 _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
656 using std::swap;656 using std::swap;
...@@ -660,12 +660,12 @@ public:...@@ -660,12 +660,12 @@ public:
660# if _LIBCPP_STD_VER >= 14660# if _LIBCPP_STD_VER >= 14
661 template <typename _K2>661 template <typename _K2>
662 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {662 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
663 return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);663 return static_cast<const _Compare&>(*this)(__x, __y.first);
664 }664 }
665665
666 template <typename _K2>666 template <typename _K2>
667 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {667 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
668 return static_cast<const _Compare&>(*this)(__x.__get_value().first, __y);668 return static_cast<const _Compare&>(*this)(__x.first, __y);
669 }669 }
670# endif670# endif
671};671};
...@@ -681,15 +681,9 @@ public:...@@ -681,15 +681,9 @@ public:
681 : __comp_(__c) {}681 : __comp_(__c) {}
682 _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; }682 _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; }
683683
684 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const {684 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.first, __y.first); }
685 return __comp_(__x.__get_value().first, __y.__get_value().first);685 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.first, __y); }
686 }686 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.first); }
687 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const {
688 return __comp_(__x.__get_value().first, __y);
689 }
690 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {
691 return __comp_(__x, __y.__get_value().first);
692 }
693 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {687 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
694 using std::swap;688 using std::swap;
695 swap(__comp_, __y.__comp_);689 swap(__comp_, __y.__comp_);
...@@ -698,12 +692,12 @@ public:...@@ -698,12 +692,12 @@ public:
698# if _LIBCPP_STD_VER >= 14692# if _LIBCPP_STD_VER >= 14
699 template <typename _K2>693 template <typename _K2>
700 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {694 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
701 return __comp_(__x, __y.__get_value().first);695 return __comp_(__x, __y.first);
702 }696 }
703697
704 template <typename _K2>698 template <typename _K2>
705 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {699 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
706 return __comp_(__x.__get_value().first, __y);700 return __comp_(__x.first, __y);
707 }701 }
708# endif702# endif
709};703};
...@@ -748,135 +742,34 @@ public:...@@ -748,135 +742,34 @@ public:
748742
749 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {743 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
750 if (__second_constructed)744 if (__second_constructed)
751 __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second));745 __alloc_traits::destroy(__na_, std::addressof(__p->__value_.second));
752 if (__first_constructed)746 if (__first_constructed)
753 __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().first));747 __alloc_traits::destroy(__na_, std::addressof(__p->__value_.first));
754 if (__p)748 if (__p)
755 __alloc_traits::deallocate(__na_, __p, 1);749 __alloc_traits::deallocate(__na_, __p, 1);
756 }750 }
757};751};
758752
759template <class _Key, class _Tp, class _Compare, class _Allocator>
760class map;
761template <class _Key, class _Tp, class _Compare, class _Allocator>
762class multimap;
763template <class _TreeIterator>
764class __map_const_iterator;
765
766# ifndef _LIBCPP_CXX03_LANG
767
768template <class _Key, class _Tp>753template <class _Key, class _Tp>
769struct _LIBCPP_STANDALONE_DEBUG __value_type {754struct __value_type;
770 typedef _Key key_type;
771 typedef _Tp mapped_type;
772 typedef pair<const key_type, mapped_type> value_type;
773 typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
774 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
775
776private:
777 value_type __cc_;
778
779public:
780 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {
781# if _LIBCPP_STD_VER >= 17
782 return *std::launder(std::addressof(__cc_));
783# else
784 return __cc_;
785# endif
786 }
787
788 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {
789# if _LIBCPP_STD_VER >= 17
790 return *std::launder(std::addressof(__cc_));
791# else
792 return __cc_;
793# endif
794 }
795
796 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
797 value_type& __v = __get_value();
798 return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
799 }
800
801 _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() {
802 value_type& __v = __get_value();
803 return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second));
804 }
805
806 _LIBCPP_HIDE_FROM_ABI __value_type& operator=(const __value_type& __v) {
807 __ref() = __v.__get_value();
808 return *this;
809 }
810
811 _LIBCPP_HIDE_FROM_ABI __value_type& operator=(__value_type&& __v) {
812 __ref() = __v.__move();
813 return *this;
814 }
815
816 template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>
817 _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) {
818 __ref() = std::forward<_ValueTp>(__v);
819 return *this;
820 }
821
822 __value_type() = delete;
823 ~__value_type() = delete;
824 __value_type(const __value_type&) = delete;
825 __value_type(__value_type&&) = delete;
826};
827
828# else
829
830template <class _Key, class _Tp>
831struct __value_type {
832 typedef _Key key_type;
833 typedef _Tp mapped_type;
834 typedef pair<const key_type, mapped_type> value_type;
835
836private:
837 value_type __cc_;
838
839public:
840 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
841 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
842
843 __value_type() = delete;
844 __value_type(__value_type const&) = delete;
845 __value_type& operator=(__value_type const&) = delete;
846 ~__value_type() = delete;
847};
848
849# endif // _LIBCPP_CXX03_LANG
850
851template <class _Tp>
852struct __extract_key_value_types;
853
854template <class _Key, class _Tp>
855struct __extract_key_value_types<__value_type<_Key, _Tp> > {
856 typedef _Key const __key_type;
857 typedef _Tp __mapped_type;
858};
859755
860template <class _TreeIterator>756template <class _TreeIterator>
861class _LIBCPP_TEMPLATE_VIS __map_iterator {757class __map_iterator {
862 typedef typename _TreeIterator::_NodeTypes _NodeTypes;
863 typedef typename _TreeIterator::__pointer_traits __pointer_traits;
864
865 _TreeIterator __i_;758 _TreeIterator __i_;
866759
867public:760public:
868 typedef bidirectional_iterator_tag iterator_category;761 using iterator_category = bidirectional_iterator_tag;
869 typedef typename _NodeTypes::__map_value_type value_type;762 using value_type = typename _TreeIterator::value_type;
870 typedef typename _TreeIterator::difference_type difference_type;763 using difference_type = typename _TreeIterator::difference_type;
871 typedef value_type& reference;764 using reference = value_type&;
872 typedef typename _NodeTypes::__map_value_type_pointer pointer;765 using pointer = typename _TreeIterator::pointer;
873766
874 _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {}767 _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {}
875768
876 _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}769 _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
877770
878 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }771 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
879 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }772 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
880773
881 _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() {774 _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() {
882 ++__i_;775 ++__i_;
...@@ -906,26 +799,23 @@ public:...@@ -906,26 +799,23 @@ public:
906 }799 }
907800
908 template <class, class, class, class>801 template <class, class, class, class>
909 friend class _LIBCPP_TEMPLATE_VIS map;802 friend class map;
910 template <class, class, class, class>803 template <class, class, class, class>
911 friend class _LIBCPP_TEMPLATE_VIS multimap;804 friend class multimap;
912 template <class>805 template <class>
913 friend class _LIBCPP_TEMPLATE_VIS __map_const_iterator;806 friend class __map_const_iterator;
914};807};
915808
916template <class _TreeIterator>809template <class _TreeIterator>
917class _LIBCPP_TEMPLATE_VIS __map_const_iterator {810class __map_const_iterator {
918 typedef typename _TreeIterator::_NodeTypes _NodeTypes;
919 typedef typename _TreeIterator::__pointer_traits __pointer_traits;
920
921 _TreeIterator __i_;811 _TreeIterator __i_;
922812
923public:813public:
924 typedef bidirectional_iterator_tag iterator_category;814 using iterator_category = bidirectional_iterator_tag;
925 typedef typename _NodeTypes::__map_value_type value_type;815 using value_type = typename _TreeIterator::value_type;
926 typedef typename _TreeIterator::difference_type difference_type;816 using difference_type = typename _TreeIterator::difference_type;
927 typedef const value_type& reference;817 using reference = const value_type&;
928 typedef typename _NodeTypes::__const_map_value_type_pointer pointer;818 using pointer = typename _TreeIterator::pointer;
929819
930 _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {}820 _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {}
931821
...@@ -933,8 +823,8 @@ public:...@@ -933,8 +823,8 @@ public:
933 _LIBCPP_HIDE_FROM_ABI823 _LIBCPP_HIDE_FROM_ABI
934 __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {}824 __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {}
935825
936 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }826 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
937 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }827 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
938828
939 _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() {829 _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() {
940 ++__i_;830 ++__i_;
...@@ -964,15 +854,15 @@ public:...@@ -964,15 +854,15 @@ public:
964 }854 }
965855
966 template <class, class, class, class>856 template <class, class, class, class>
967 friend class _LIBCPP_TEMPLATE_VIS map;857 friend class map;
968 template <class, class, class, class>858 template <class, class, class, class>
969 friend class _LIBCPP_TEMPLATE_VIS multimap;859 friend class multimap;
970 template <class, class, class>860 template <class, class, class>
971 friend class _LIBCPP_TEMPLATE_VIS __tree_const_iterator;861 friend class __tree_const_iterator;
972};862};
973863
974template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >864template <class _Key, class _Tp, class _Compare, class _Allocator>
975class _LIBCPP_TEMPLATE_VIS map {865class map {
976public:866public:
977 // types:867 // types:
978 typedef _Key key_type;868 typedef _Key key_type;
...@@ -986,7 +876,7 @@ public:...@@ -986,7 +876,7 @@ public:
986 static_assert(is_same<typename allocator_type::value_type, value_type>::value,876 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
987 "Allocator::value_type must be same type as value_type");877 "Allocator::value_type must be same type as value_type");
988878
989 class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {879 class value_compare : public __binary_function<value_type, value_type, bool> {
990 friend class map;880 friend class map;
991881
992 protected:882 protected:
...@@ -1002,9 +892,8 @@ public:...@@ -1002,9 +892,8 @@ public:
1002892
1003private:893private:
1004 typedef std::__value_type<key_type, mapped_type> __value_type;894 typedef std::__value_type<key_type, mapped_type> __value_type;
1005 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;895 typedef __map_value_compare<key_type, value_type, key_compare> __vc;
1006 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;896 typedef __tree<__value_type, __vc, allocator_type> __base;
1007 typedef __tree<__value_type, __vc, __allocator_type> __base;
1008 typedef typename __base::__node_traits __node_traits;897 typedef typename __base::__node_traits __node_traits;
1009 typedef allocator_traits<allocator_type> __alloc_traits;898 typedef allocator_traits<allocator_type> __alloc_traits;
1010899
...@@ -1028,9 +917,9 @@ public:...@@ -1028,9 +917,9 @@ public:
1028# endif917# endif
1029918
1030 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>919 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1031 friend class _LIBCPP_TEMPLATE_VIS map;920 friend class map;
1032 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>921 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1033 friend class _LIBCPP_TEMPLATE_VIS multimap;922 friend class multimap;
1034923
1035 _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_(924 _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_(
1036 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&925 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
...@@ -1083,31 +972,15 @@ public:...@@ -1083,31 +972,15 @@ public:
1083972
1084 _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); }973 _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); }
1085974
1086 _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) {975 _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) = default;
1087# ifndef _LIBCPP_CXX03_LANG
1088 __tree_ = __m.__tree_;
1089# else
1090 if (this != std::addressof(__m)) {
1091 __tree_.clear();
1092 __tree_.value_comp() = __m.__tree_.value_comp();
1093 __tree_.__copy_assign_alloc(__m.__tree_);
1094 insert(__m.begin(), __m.end());
1095 }
1096# endif
1097 return *this;
1098 }
1099976
1100# ifndef _LIBCPP_CXX03_LANG977# ifndef _LIBCPP_CXX03_LANG
1101978
1102 _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value)979 _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default;
1103 : __tree_(std::move(__m.__tree_)) {}
1104980
1105 _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a);981 _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a);
1106982
1107 _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {983 _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default;
1108 __tree_ = std::move(__m.__tree_);
1109 return *this;
1110 }
1111984
1112 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())985 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
1113 : __tree_(__vc(__comp)) {986 : __tree_(__vc(__comp)) {
...@@ -1138,7 +1011,7 @@ public:...@@ -1138,7 +1011,7 @@ public:
1138 insert(__m.begin(), __m.end());1011 insert(__m.begin(), __m.end());
1139 }1012 }
11401013
1141 _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }1014 _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
11421015
1143 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }1016 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1144 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }1017 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
...@@ -1184,29 +1057,29 @@ public:...@@ -1184,29 +1057,29 @@ public:
11841057
1185 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1058 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1186 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) {1059 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) {
1187 return __tree_.__insert_unique(std::forward<_Pp>(__p));1060 return __tree_.__emplace_unique(std::forward<_Pp>(__p));
1188 }1061 }
11891062
1190 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1063 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1191 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {1064 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
1192 return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p));1065 return __tree_.__emplace_hint_unique(__pos.__i_, std::forward<_Pp>(__p));
1193 }1066 }
11941067
1195# endif // _LIBCPP_CXX03_LANG1068# endif // _LIBCPP_CXX03_LANG
11961069
1197 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }1070 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); }
11981071
1199 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {1072 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1200 return __tree_.__insert_unique(__p.__i_, __v);1073 return __tree_.__emplace_hint_unique(__p.__i_, __v);
1201 }1074 }
12021075
1203# ifndef _LIBCPP_CXX03_LANG1076# ifndef _LIBCPP_CXX03_LANG
1204 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {1077 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
1205 return __tree_.__insert_unique(std::move(__v));1078 return __tree_.__emplace_unique(std::move(__v));
1206 }1079 }
12071080
1208 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {1081 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1209 return __tree_.__insert_unique(__p.__i_, std::move(__v));1082 return __tree_.__emplace_hint_unique(__p.__i_, std::move(__v));
1210 }1083 }
12111084
1212 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1085 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
...@@ -1297,7 +1170,7 @@ public:...@@ -1297,7 +1170,7 @@ public:
1297 auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v));1170 auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v));
12981171
1299 if (!__inserted)1172 if (!__inserted)
1300 __r->__get_value().second = std::forward<_Vp>(__v);1173 __r->second = std::forward<_Vp>(__v);
13011174
1302 return __r;1175 return __r;
1303 }1176 }
...@@ -1308,7 +1181,7 @@ public:...@@ -1308,7 +1181,7 @@ public:
1308 __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v));1181 __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v));
13091182
1310 if (!__inserted)1183 if (!__inserted)
1311 __r->__get_value().second = std::forward<_Vp>(__v);1184 __r->second = std::forward<_Vp>(__v);
13121185
1313 return __r;1186 return __r;
1314 }1187 }
...@@ -1513,8 +1386,9 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)...@@ -1513,8 +1386,9 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a)
1513 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {1386 : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) {
1514 if (__a != __m.get_allocator()) {1387 if (__a != __m.get_allocator()) {
1515 const_iterator __e = cend();1388 const_iterator __e = cend();
1516 while (!__m.empty())1389 while (!__m.empty()) {
1517 __tree_.__insert_unique(__e.__i_, __m.__tree_.remove(__m.begin().__i_)->__value_.__move());1390 __tree_.__insert_unique_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
1391 }
1518 }1392 }
1519}1393}
15201394
...@@ -1522,8 +1396,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>...@@ -1522,8 +1396,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
1522_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {1396_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
1523 return __tree_1397 return __tree_
1524 .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())1398 .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())
1525 .first->__get_value()1399 .first->second;
1526 .second;
1527}1400}
15281401
1529template <class _Key, class _Tp, class _Compare, class _Allocator>1402template <class _Key, class _Tp, class _Compare, class _Allocator>
...@@ -1533,8 +1406,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {...@@ -1533,8 +1406,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {
1533 return __tree_1406 return __tree_
1534 .__emplace_unique_key_args(1407 .__emplace_unique_key_args(
1535 __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())1408 __k, std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())
1536 .first->__get_value()1409 .first->second;
1537 .second;
1538 // NOLINTEND(bugprone-use-after-move)1410 // NOLINTEND(bugprone-use-after-move)
1539}1411}
15401412
...@@ -1545,9 +1417,9 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder...@@ -1545,9 +1417,9 @@ typename map<_Key, _Tp, _Compare, _Allocator>::__node_holder
1545map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) {1417map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __k) {
1546 __node_allocator& __na = __tree_.__node_alloc();1418 __node_allocator& __na = __tree_.__node_alloc();
1547 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));1419 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1548 __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().first), __k);1420 __node_traits::construct(__na, std::addressof(__h->__value_.first), __k);
1549 __h.get_deleter().__first_constructed = true;1421 __h.get_deleter().__first_constructed = true;
1550 __node_traits::construct(__na, std::addressof(__h->__value_.__get_value().second));1422 __node_traits::construct(__na, std::addressof(__h->__value_.second));
1551 __h.get_deleter().__second_constructed = true;1423 __h.get_deleter().__second_constructed = true;
1552 return __h;1424 return __h;
1553}1425}
...@@ -1562,7 +1434,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {...@@ -1562,7 +1434,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
1562 __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));1434 __tree_.__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1563 __r = __h.release();1435 __r = __h.release();
1564 }1436 }
1565 return __r->__value_.__get_value().second;1437 return __r->__value_.second;
1566}1438}
15671439
1568# endif // _LIBCPP_CXX03_LANG1440# endif // _LIBCPP_CXX03_LANG
...@@ -1572,8 +1444,8 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {...@@ -1572,8 +1444,8 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {
1572 __parent_pointer __parent;1444 __parent_pointer __parent;
1573 __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);1445 __node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
1574 if (__child == nullptr)1446 if (__child == nullptr)
1575 __throw_out_of_range("map::at: key not found");1447 std::__throw_out_of_range("map::at: key not found");
1576 return static_cast<__node_pointer>(__child)->__value_.__get_value().second;1448 return static_cast<__node_pointer>(__child)->__value_.second;
1577}1449}
15781450
1579template <class _Key, class _Tp, class _Compare, class _Allocator>1451template <class _Key, class _Tp, class _Compare, class _Allocator>
...@@ -1581,8 +1453,8 @@ const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {...@@ -1581,8 +1453,8 @@ const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {
1581 __parent_pointer __parent;1453 __parent_pointer __parent;
1582 __node_base_pointer __child = __tree_.__find_equal(__parent, __k);1454 __node_base_pointer __child = __tree_.__find_equal(__parent, __k);
1583 if (__child == nullptr)1455 if (__child == nullptr)
1584 __throw_out_of_range("map::at: key not found");1456 std::__throw_out_of_range("map::at: key not found");
1585 return static_cast<__node_pointer>(__child)->__value_.__get_value().second;1457 return static_cast<__node_pointer>(__child)->__value_.second;
1586}1458}
15871459
1588template <class _Key, class _Tp, class _Compare, class _Allocator>1460template <class _Key, class _Tp, class _Compare, class _Allocator>
...@@ -1654,10 +1526,12 @@ struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > {...@@ -1654,10 +1526,12 @@ struct __container_traits<map<_Key, _Tp, _Compare, _Allocator> > {
1654 // For associative containers, if an exception is thrown by any operation from within1526 // For associative containers, if an exception is thrown by any operation from within
1655 // an insert or emplace function inserting a single element, the insertion has no effect.1527 // an insert or emplace function inserting a single element, the insertion has no effect.
1656 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;1528 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1529
1530 static _LIBCPP_CONSTEXPR const bool __reservable = false;
1657};1531};
16581532
1659template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > >1533template <class _Key, class _Tp, class _Compare, class _Allocator>
1660class _LIBCPP_TEMPLATE_VIS multimap {1534class multimap {
1661public:1535public:
1662 // types:1536 // types:
1663 typedef _Key key_type;1537 typedef _Key key_type;
...@@ -1672,7 +1546,7 @@ public:...@@ -1672,7 +1546,7 @@ public:
1672 static_assert(is_same<typename allocator_type::value_type, value_type>::value,1546 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
1673 "Allocator::value_type must be same type as value_type");1547 "Allocator::value_type must be same type as value_type");
16741548
1675 class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {1549 class value_compare : public __binary_function<value_type, value_type, bool> {
1676 friend class multimap;1550 friend class multimap;
16771551
1678 protected:1552 protected:
...@@ -1688,9 +1562,8 @@ public:...@@ -1688,9 +1562,8 @@ public:
16881562
1689private:1563private:
1690 typedef std::__value_type<key_type, mapped_type> __value_type;1564 typedef std::__value_type<key_type, mapped_type> __value_type;
1691 typedef __map_value_compare<key_type, __value_type, key_compare> __vc;1565 typedef __map_value_compare<key_type, value_type, key_compare> __vc;
1692 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;1566 typedef __tree<__value_type, __vc, allocator_type> __base;
1693 typedef __tree<__value_type, __vc, __allocator_type> __base;
1694 typedef typename __base::__node_traits __node_traits;1567 typedef typename __base::__node_traits __node_traits;
1695 typedef allocator_traits<allocator_type> __alloc_traits;1568 typedef allocator_traits<allocator_type> __alloc_traits;
16961569
...@@ -1711,9 +1584,9 @@ public:...@@ -1711,9 +1584,9 @@ public:
1711# endif1584# endif
17121585
1713 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>1586 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1714 friend class _LIBCPP_TEMPLATE_VIS map;1587 friend class map;
1715 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>1588 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
1716 friend class _LIBCPP_TEMPLATE_VIS multimap;1589 friend class multimap;
17171590
1718 _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_(1591 _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_(
1719 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&1592 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
...@@ -1770,31 +1643,16 @@ public:...@@ -1770,31 +1643,16 @@ public:
1770 insert(__m.begin(), __m.end());1643 insert(__m.begin(), __m.end());
1771 }1644 }
17721645
1773 _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) {1646 _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) = default;
1774# ifndef _LIBCPP_CXX03_LANG
1775 __tree_ = __m.__tree_;
1776# else
1777 if (this != std::addressof(__m)) {
1778 __tree_.clear();
1779 __tree_.value_comp() = __m.__tree_.value_comp();
1780 __tree_.__copy_assign_alloc(__m.__tree_);
1781 insert(__m.begin(), __m.end());
1782 }
1783# endif
1784 return *this;
1785 }
17861647
1787# ifndef _LIBCPP_CXX03_LANG1648# ifndef _LIBCPP_CXX03_LANG
17881649
1789 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value)1650 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value) = default;
1790 : __tree_(std::move(__m.__tree_)) {}
17911651
1792 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a);1652 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a);
17931653
1794 _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {1654 _LIBCPP_HIDE_FROM_ABI multimap&
1795 __tree_ = std::move(__m.__tree_);1655 operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) = default;
1796 return *this;
1797 }
17981656
1799 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())1657 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
1800 : __tree_(__vc(__comp)) {1658 : __tree_(__vc(__comp)) {
...@@ -1826,7 +1684,9 @@ public:...@@ -1826,7 +1684,9 @@ public:
1826 insert(__m.begin(), __m.end());1684 insert(__m.begin(), __m.end());
1827 }1685 }
18281686
1829 _LIBCPP_HIDE_FROM_ABI ~multimap() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }1687 _LIBCPP_HIDE_FROM_ABI ~multimap() {
1688 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
1689 }
18301690
1831 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }1691 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1832 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }1692 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
...@@ -1865,34 +1725,34 @@ public:...@@ -1865,34 +1725,34 @@ public:
18651725
1866 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1726 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1867 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) {1727 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) {
1868 return __tree_.__insert_multi(std::forward<_Pp>(__p));1728 return __tree_.__emplace_multi(std::forward<_Pp>(__p));
1869 }1729 }
18701730
1871 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1731 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1872 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {1732 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
1873 return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p));1733 return __tree_.__emplace_hint_multi(__pos.__i_, std::forward<_Pp>(__p));
1874 }1734 }
18751735
1876 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }1736 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); }
18771737
1878 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {1738 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1879 return __tree_.__insert_multi(__p.__i_, std::move(__v));1739 return __tree_.__emplace_hint_multi(__p.__i_, std::move(__v));
1880 }1740 }
18811741
1882 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1742 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
18831743
1884# endif // _LIBCPP_CXX03_LANG1744# endif // _LIBCPP_CXX03_LANG
18851745
1886 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }1746 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); }
18871747
1888 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {1748 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1889 return __tree_.__insert_multi(__p.__i_, __v);1749 return __tree_.__emplace_hint_multi(__p.__i_, __v);
1890 }1750 }
18911751
1892 template <class _InputIterator>1752 template <class _InputIterator>
1893 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {1753 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
1894 for (const_iterator __e = cend(); __f != __l; ++__f)1754 for (const_iterator __e = cend(); __f != __l; ++__f)
1895 __tree_.__insert_multi(__e.__i_, *__f);1755 __tree_.__emplace_hint_multi(__e.__i_, *__f);
1896 }1756 }
18971757
1898# if _LIBCPP_STD_VER >= 231758# if _LIBCPP_STD_VER >= 23
...@@ -1900,7 +1760,7 @@ public:...@@ -1900,7 +1760,7 @@ public:
1900 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1760 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1901 const_iterator __end = cend();1761 const_iterator __end = cend();
1902 for (auto&& __element : __range) {1762 for (auto&& __element : __range) {
1903 __tree_.__insert_multi(__end.__i_, std::forward<decltype(__element)>(__element));1763 __tree_.__emplace_hint_multi(__end.__i_, std::forward<decltype(__element)>(__element));
1904 }1764 }
1905 }1765 }
1906# endif1766# endif
...@@ -2101,7 +1961,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca...@@ -2101,7 +1961,7 @@ multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const alloca
2101 if (__a != __m.get_allocator()) {1961 if (__a != __m.get_allocator()) {
2102 const_iterator __e = cend();1962 const_iterator __e = cend();
2103 while (!__m.empty())1963 while (!__m.empty())
2104 __tree_.__insert_multi(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_.__move()));1964 __tree_.__insert_multi_from_orphaned_node(__e.__i_, std::move(__m.__tree_.remove(__m.begin().__i_)->__value_));
2105 }1965 }
2106}1966}
2107# endif1967# endif
...@@ -2176,6 +2036,8 @@ struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > {...@@ -2176,6 +2036,8 @@ struct __container_traits<multimap<_Key, _Tp, _Compare, _Allocator> > {
2176 // For associative containers, if an exception is thrown by any operation from within2036 // For associative containers, if an exception is thrown by any operation from within
2177 // an insert or emplace function inserting a single element, the insertion has no effect.2037 // an insert or emplace function inserting a single element, the insertion has no effect.
2178 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;2038 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
2039
2040 static _LIBCPP_CONSTEXPR const bool __reservable = false;
2179};2041};
21802042
2181_LIBCPP_END_NAMESPACE_STD2043_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/math.h+1-10
...@@ -378,9 +378,7 @@ extern "C++" {...@@ -378,9 +378,7 @@ extern "C++" {
378# include <__math/traits.h>378# include <__math/traits.h>
379# include <__math/trigonometric_functions.h>379# include <__math/trigonometric_functions.h>
380# include <__type_traits/enable_if.h>380# include <__type_traits/enable_if.h>
381# include <__type_traits/is_floating_point.h>
382# include <__type_traits/is_integral.h>381# include <__type_traits/is_integral.h>
383# include <stdlib.h>
384382
385// fpclassify relies on implementation-defined constants, so we can't move it to a detail header383// fpclassify relies on implementation-defined constants, so we can't move it to a detail header
386_LIBCPP_BEGIN_NAMESPACE_STD384_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -431,19 +429,12 @@ using std::__math::isnormal;...@@ -431,19 +429,12 @@ using std::__math::isnormal;
431using std::__math::isunordered;429using std::__math::isunordered;
432# endif // _LIBCPP_MSVCRT430# endif // _LIBCPP_MSVCRT
433431
434// abs
435//
436// handled in stdlib.h
437
438// div
439//
440// handled in stdlib.h
441
442// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math432// We have to provide double overloads for <math.h> to work on platforms that don't provide the full set of math
443// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads433// functions. To make the overload set work with multiple functions that take the same arguments, we make our overloads
444// templates. Functions are preferred over function templates during overload resolution, which means that our overload434// templates. Functions are preferred over function templates during overload resolution, which means that our overload
445// will only be selected when the C library doesn't provide one.435// will only be selected when the C library doesn't provide one.
446436
437using std::__math::abs;
447using std::__math::acos;438using std::__math::acos;
448using std::__math::acosh;439using std::__math::acosh;
449using std::__math::asin;440using std::__math::asin;
lib/libcxx/include/mdspan+44-3
...@@ -33,10 +33,14 @@ namespace std {...@@ -33,10 +33,14 @@ namespace std {
33 template<class ElementType>33 template<class ElementType>
34 class default_accessor;34 class default_accessor;
3535
36 // [mdspan.accessor.aligned], class template aligned_accessor
37 template<class ElementType, size_t ByteAlignment>
38 class aligned_accessor; // since C++26
39
36 // [mdspan.mdspan], class template mdspan40 // [mdspan.mdspan], class template mdspan
37 template<class ElementType, class Extents, class LayoutPolicy = layout_right,41 template<class ElementType, class Extents, class LayoutPolicy = layout_right,
38 class AccessorPolicy = default_accessor<ElementType>>42 class AccessorPolicy = default_accessor<ElementType>>
39 class mdspan; // not implemented yet43 class mdspan;
40}44}
4145
42// extents synopsis46// extents synopsis
...@@ -269,6 +273,38 @@ namespace std {...@@ -269,6 +273,38 @@ namespace std {
269 };273 };
270}274}
271275
276// aligned_accessor synopsis
277
278namespace std {
279 template<class ElementType, size_t ByteAlignment>
280 struct aligned_accessor {
281 using offset_policy = default_accessor<ElementType>;
282 using element_type = ElementType;
283 using reference = ElementType&;
284 using data_handle_type = ElementType*;
285
286 static constexpr size_t byte_alignment = ByteAlignment;
287
288 constexpr aligned_accessor() noexcept = default;
289
290 template<class OtherElementType, size_t OtherByteAlignment>
291 constexpr aligned_accessor(
292 aligned_accessor<OtherElementType, OtherByteAlignment>) noexcept;
293
294 template<class OtherElementType>
295 explicit constexpr aligned_accessor(
296 default_accessor<OtherElementType>) noexcept;
297
298 template<class OtherElementType>
299 constexpr operator default_accessor<OtherElementType>() const noexcept;
300
301 constexpr reference access(data_handle_type p, size_t i) const noexcept;
302
303 constexpr typename offset_policy::data_handle_type
304 offset(data_handle_type p, size_t i) const noexcept;
305 };
306}
307
272// mdspan synopsis308// mdspan synopsis
273309
274namespace std {310namespace std {
...@@ -409,12 +445,17 @@ namespace std {...@@ -409,12 +445,17 @@ namespace std {
409#define _LIBCPP_MDSPAN445#define _LIBCPP_MDSPAN
410446
411#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)447#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
412# include <__cxx03/mdspan>448# include <__cxx03/__config>
413#else449#else
414# include <__config>450# include <__config>
415451
416# if _LIBCPP_STD_VER >= 23452# if _LIBCPP_STD_VER >= 23
417# include <__fwd/mdspan.h>453# include <__fwd/mdspan.h> // TODO(boomanaiden154): This is currently a
454 // non-standard extension to include
455 // std::dynamic_extent tracked by LWG issue 4275.
456 // This comment should be deleted or the include
457 // deleted upon resolution.
458# include <__fwd/span.h>
418# include <__mdspan/default_accessor.h>459# include <__mdspan/default_accessor.h>
419# include <__mdspan/extents.h>460# include <__mdspan/extents.h>
420# include <__mdspan/layout_left.h>461# include <__mdspan/layout_left.h>
lib/libcxx/include/memory+6
...@@ -912,6 +912,9 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);...@@ -912,6 +912,9 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
912template<size_t N, class T>912template<size_t N, class T>
913[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20913[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
914914
915template<size_t Alignment, class T>
916 bool is_sufficiently_aligned(T* ptr); // since C++26
917
915// [out.ptr.t], class template out_ptr_t918// [out.ptr.t], class template out_ptr_t
916template<class Smart, class Pointer, class... Args>919template<class Smart, class Pointer, class... Args>
917 class out_ptr_t; // since c++23920 class out_ptr_t; // since c++23
...@@ -945,6 +948,7 @@ template<class Pointer = void, class Smart, class... Args>...@@ -945,6 +948,7 @@ template<class Pointer = void, class Smart, class... Args>
945# include <__memory/allocator_traits.h>948# include <__memory/allocator_traits.h>
946# include <__memory/auto_ptr.h>949# include <__memory/auto_ptr.h>
947# include <__memory/inout_ptr.h>950# include <__memory/inout_ptr.h>
951# include <__memory/is_sufficiently_aligned.h>
948# include <__memory/out_ptr.h>952# include <__memory/out_ptr.h>
949# include <__memory/pointer_traits.h>953# include <__memory/pointer_traits.h>
950# include <__memory/raw_storage_iterator.h>954# include <__memory/raw_storage_iterator.h>
...@@ -958,12 +962,14 @@ template<class Pointer = void, class Smart, class... Args>...@@ -958,12 +962,14 @@ template<class Pointer = void, class Smart, class... Args>
958962
959# if _LIBCPP_STD_VER >= 17963# if _LIBCPP_STD_VER >= 17
960# include <__memory/construct_at.h>964# include <__memory/construct_at.h>
965# include <__memory/destroy.h>
961# endif966# endif
962967
963# if _LIBCPP_STD_VER >= 20968# if _LIBCPP_STD_VER >= 20
964# include <__memory/assume_aligned.h>969# include <__memory/assume_aligned.h>
965# include <__memory/concepts.h>970# include <__memory/concepts.h>
966# include <__memory/ranges_construct_at.h>971# include <__memory/ranges_construct_at.h>
972# include <__memory/ranges_destroy.h>
967# include <__memory/ranges_uninitialized_algorithms.h>973# include <__memory/ranges_uninitialized_algorithms.h>
968# include <__memory/uses_allocator_construction.h>974# include <__memory/uses_allocator_construction.h>
969# endif975# endif
lib/libcxx/include/memory_resource+1-1
...@@ -50,7 +50,7 @@ namespace std::pmr {...@@ -50,7 +50,7 @@ namespace std::pmr {
50 */50 */
5151
52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)52#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53# include <__cxx03/memory_resource>53# include <__cxx03/__config>
54#else54#else
55# include <__config>55# include <__config>
5656
lib/libcxx/include/mutex+45-49
...@@ -256,26 +256,24 @@ public:...@@ -256,26 +256,24 @@ public:
256 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {256 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
257 return try_lock_until(chrono::steady_clock::now() + __d);257 return try_lock_until(chrono::steady_clock::now() + __d);
258 }258 }
259
259 template <class _Clock, class _Duration>260 template <class _Clock, class _Duration>
260 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool261 _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
261 try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);262 using namespace chrono;
263 unique_lock<mutex> __lk(__m_);
264 bool __no_timeout = _Clock::now() < __t;
265 while (__no_timeout && __locked_)
266 __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
267 if (!__locked_) {
268 __locked_ = true;
269 return true;
270 }
271 return false;
272 }
273
262 void unlock() _NOEXCEPT;274 void unlock() _NOEXCEPT;
263};275};
264276
265template <class _Clock, class _Duration>
266bool timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
267 using namespace chrono;
268 unique_lock<mutex> __lk(__m_);
269 bool __no_timeout = _Clock::now() < __t;
270 while (__no_timeout && __locked_)
271 __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
272 if (!__locked_) {
273 __locked_ = true;
274 return true;
275 }
276 return false;
277}
278
279class _LIBCPP_EXPORTED_FROM_ABI recursive_timed_mutex {277class _LIBCPP_EXPORTED_FROM_ABI recursive_timed_mutex {
280 mutex __m_;278 mutex __m_;
281 condition_variable __cv_;279 condition_variable __cv_;
...@@ -295,34 +293,32 @@ public:...@@ -295,34 +293,32 @@ public:
295 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {293 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
296 return try_lock_until(chrono::steady_clock::now() + __d);294 return try_lock_until(chrono::steady_clock::now() + __d);
297 }295 }
296
298 template <class _Clock, class _Duration>297 template <class _Clock, class _Duration>
299 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool298 _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
300 try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);299 using namespace chrono;
300 __thread_id __id = this_thread::get_id();
301 unique_lock<mutex> __lk(__m_);
302 if (__id == __id_) {
303 if (__count_ == numeric_limits<size_t>::max())
304 return false;
305 ++__count_;
306 return true;
307 }
308 bool __no_timeout = _Clock::now() < __t;
309 while (__no_timeout && __count_ != 0)
310 __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
311 if (__count_ == 0) {
312 __count_ = 1;
313 __id_ = __id;
314 return true;
315 }
316 return false;
317 }
318
301 void unlock() _NOEXCEPT;319 void unlock() _NOEXCEPT;
302};320};
303321
304template <class _Clock, class _Duration>
305bool recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
306 using namespace chrono;
307 __thread_id __id = this_thread::get_id();
308 unique_lock<mutex> __lk(__m_);
309 if (__id == __id_) {
310 if (__count_ == numeric_limits<size_t>::max())
311 return false;
312 ++__count_;
313 return true;
314 }
315 bool __no_timeout = _Clock::now() < __t;
316 while (__no_timeout && __count_ != 0)
317 __no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
318 if (__count_ == 0) {
319 __count_ = 1;
320 __id_ = __id;
321 return true;
322 }
323 return false;
324}
325
326template <class _L0, class _L1>322template <class _L0, class _L1>
327_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {323_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {
328 unique_lock<_L0> __u0(__l0, try_to_lock_t());324 unique_lock<_L0> __u0(__l0, try_to_lock_t());
...@@ -423,10 +419,10 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&......@@ -423,10 +419,10 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&...
423419
424# if _LIBCPP_STD_VER >= 17420# if _LIBCPP_STD_VER >= 17
425template <class... _Mutexes>421template <class... _Mutexes>
426class _LIBCPP_TEMPLATE_VIS scoped_lock;422class scoped_lock;
427423
428template <>424template <>
429class _LIBCPP_TEMPLATE_VIS scoped_lock<> {425class scoped_lock<> {
430public:426public:
431 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {}427 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {}
432 ~scoped_lock() = default;428 ~scoped_lock() = default;
...@@ -438,7 +434,7 @@ public:...@@ -438,7 +434,7 @@ public:
438};434};
439435
440template <class _Mutex>436template <class _Mutex>
441class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) scoped_lock<_Mutex> {437class _LIBCPP_SCOPED_LOCKABLE scoped_lock<_Mutex> {
442public:438public:
443 typedef _Mutex mutex_type;439 typedef _Mutex mutex_type;
444440
...@@ -446,16 +442,15 @@ private:...@@ -446,16 +442,15 @@ private:
446 mutex_type& __m_;442 mutex_type& __m_;
447443
448public:444public:
449 [[nodiscard]]445 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_ACQUIRE_CAPABILITY(__m)
450 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
451 : __m_(__m) {446 : __m_(__m) {
452 __m_.lock();447 __m_.lock();
453 }448 }
454449
455 ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }450 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __m_.unlock(); }
456451
457 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m)452 [[nodiscard]]
458 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))453 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) _LIBCPP_REQUIRES_CAPABILITY(__m)
459 : __m_(__m) {}454 : __m_(__m) {}
460455
461 scoped_lock(scoped_lock const&) = delete;456 scoped_lock(scoped_lock const&) = delete;
...@@ -463,7 +458,7 @@ public:...@@ -463,7 +458,7 @@ public:
463};458};
464459
465template <class... _MArgs>460template <class... _MArgs>
466class _LIBCPP_TEMPLATE_VIS scoped_lock {461class scoped_lock {
467 static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");462 static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
468 typedef tuple<_MArgs&...> _MutexTuple;463 typedef tuple<_MArgs&...> _MutexTuple;
469464
...@@ -508,6 +503,7 @@ _LIBCPP_POP_MACROS...@@ -508,6 +503,7 @@ _LIBCPP_POP_MACROS
508# include <initializer_list>503# include <initializer_list>
509# include <iosfwd>504# include <iosfwd>
510# include <new>505# include <new>
506# include <optional>
511# include <stdexcept>507# include <stdexcept>
512# include <system_error>508# include <system_error>
513# include <type_traits>509# include <type_traits>
lib/libcxx/include/numbers+1-1
...@@ -59,7 +59,7 @@ namespace std::numbers {...@@ -59,7 +59,7 @@ namespace std::numbers {
59*/59*/
6060
61#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)61#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
62# include <__cxx03/numbers>62# include <__cxx03/__config>
63#else63#else
64# include <__concepts/arithmetic.h>64# include <__concepts/arithmetic.h>
65# include <__config>65# include <__config>
lib/libcxx/include/numeric+1
...@@ -172,6 +172,7 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin...@@ -172,6 +172,7 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin
172# include <__numeric/gcd_lcm.h>172# include <__numeric/gcd_lcm.h>
173# include <__numeric/inclusive_scan.h>173# include <__numeric/inclusive_scan.h>
174# include <__numeric/pstl.h>174# include <__numeric/pstl.h>
175# include <__numeric/ranges_iota.h>
175# include <__numeric/reduce.h>176# include <__numeric/reduce.h>
176# include <__numeric/transform_exclusive_scan.h>177# include <__numeric/transform_exclusive_scan.h>
177# include <__numeric/transform_inclusive_scan.h>178# include <__numeric/transform_inclusive_scan.h>
lib/libcxx/include/optional+154-144
...@@ -178,7 +178,7 @@ namespace std {...@@ -178,7 +178,7 @@ namespace std {
178*/178*/
179179
180#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)180#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
181# include <__cxx03/optional>181# include <__cxx03/__config>
182#else182#else
183# include <__assert>183# include <__assert>
184# include <__compare/compare_three_way_result.h>184# include <__compare/compare_three_way_result.h>
...@@ -205,11 +205,13 @@ namespace std {...@@ -205,11 +205,13 @@ namespace std {
205# include <__type_traits/is_assignable.h>205# include <__type_traits/is_assignable.h>
206# include <__type_traits/is_constructible.h>206# include <__type_traits/is_constructible.h>
207# include <__type_traits/is_convertible.h>207# include <__type_traits/is_convertible.h>
208# include <__type_traits/is_core_convertible.h>
208# include <__type_traits/is_destructible.h>209# include <__type_traits/is_destructible.h>
209# include <__type_traits/is_nothrow_assignable.h>210# include <__type_traits/is_nothrow_assignable.h>
210# include <__type_traits/is_nothrow_constructible.h>211# include <__type_traits/is_nothrow_constructible.h>
211# include <__type_traits/is_object.h>212# include <__type_traits/is_object.h>
212# include <__type_traits/is_reference.h>213# include <__type_traits/is_reference.h>
214# include <__type_traits/is_replaceable.h>
213# include <__type_traits/is_same.h>215# include <__type_traits/is_same.h>
214# include <__type_traits/is_scalar.h>216# include <__type_traits/is_scalar.h>
215# include <__type_traits/is_swappable.h>217# include <__type_traits/is_swappable.h>
...@@ -246,7 +248,7 @@ _LIBCPP_PUSH_MACROS...@@ -246,7 +248,7 @@ _LIBCPP_PUSH_MACROS
246namespace std // purposefully not using versioning namespace248namespace std // purposefully not using versioning namespace
247{249{
248250
249class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public exception {251class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public exception {
250public:252public:
251 _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;253 _LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;
252 _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;254 _LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;
...@@ -262,8 +264,7 @@ public:...@@ -262,8 +264,7 @@ public:
262264
263_LIBCPP_BEGIN_NAMESPACE_STD265_LIBCPP_BEGIN_NAMESPACE_STD
264266
265[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void267[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_optional_access() {
266__throw_bad_optional_access() {
267# if _LIBCPP_HAS_EXCEPTIONS268# if _LIBCPP_HAS_EXCEPTIONS
268 throw bad_optional_access();269 throw bad_optional_access();
269# else270# else
...@@ -590,6 +591,7 @@ public:...@@ -590,6 +591,7 @@ public:
590591
591 using __trivially_relocatable _LIBCPP_NODEBUG =592 using __trivially_relocatable _LIBCPP_NODEBUG =
592 conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;593 conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;
594 using __replaceable _LIBCPP_NODEBUG = conditional_t<__is_replaceable_v<_Tp>, optional, void>;
593595
594private:596private:
595 // Disable the reference extension using this static assert.597 // Disable the reference extension using this static assert.
...@@ -672,44 +674,41 @@ public:...@@ -672,44 +674,41 @@ public:
672 _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default;674 _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default;
673 _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {}675 _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {}
674676
675 template <677 template <class _InPlaceT,
676 class _InPlaceT,678 class... _Args,
677 class... _Args,679 enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...>>::value, int> = 0>
678 class = enable_if_t< _And< _IsSame<_InPlaceT, in_place_t>, is_constructible<value_type, _Args...> >::value > >
679 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args)680 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args)
680 : __base(in_place, std::forward<_Args>(__args)...) {}681 : __base(in_place, std::forward<_Args>(__args)...) {}
681682
682 template <class _Up,683 template <class _Up,
683 class... _Args,684 class... _Args,
684 class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...>> >685 enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0>
685 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)686 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
686 : __base(in_place, __il, std::forward<_Args>(__args)...) {}687 : __base(in_place, __il, std::forward<_Args>(__args)...) {}
687688
688 template <class _Up = value_type,689 template <class _Up = value_type,
689 enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0>690 enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0>
690 _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}691 _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}
691692
692 template <class _Up, enable_if_t< _CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0>693 template <class _Up, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0>
693 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}694 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) : __base(in_place, std::forward<_Up>(__v)) {}
694695
695 // LWG2756: conditionally explicit conversion from const optional<_Up>&696 // LWG2756: conditionally explicit conversion from const optional<_Up>&
696 template <class _Up,697 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
697 enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) {698 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) {
699 this->__construct_from(__v);699 this->__construct_from(__v);
700 }700 }
701 template <class _Up,701 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
702 enable_if_t< _CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
703 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) {702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) {
704 this->__construct_from(__v);703 this->__construct_from(__v);
705 }704 }
706705
707 // LWG2756: conditionally explicit conversion from optional<_Up>&&706 // LWG2756: conditionally explicit conversion from optional<_Up>&&
708 template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0>707 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0>
709 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) {708 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) {
710 this->__construct_from(std::move(__v));709 this->__construct_from(std::move(__v));
711 }710 }
712 template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0>711 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0>
713 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) {712 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) {
714 this->__construct_from(std::move(__v));713 this->__construct_from(std::move(__v));
715 }714 }
...@@ -718,7 +717,7 @@ public:...@@ -718,7 +717,7 @@ public:
718 template <class _Tag,717 template <class _Tag,
719 class _Fp,718 class _Fp,
720 class... _Args,719 class... _Args,
721 __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>720 enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>
722 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)721 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)
723 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}722 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}
724# endif723# endif
...@@ -732,12 +731,12 @@ public:...@@ -732,12 +731,12 @@ public:
732 _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default;731 _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(optional&&) = default;
733732
734 // LWG2756733 // LWG2756
735 template <734 template <class _Up = value_type,
736 class _Up = value_type,735 enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Up>, optional>,
737 class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>,736 _Or<_IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>>>,
738 _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >,737 is_constructible<value_type, _Up>,
739 is_constructible<value_type, _Up>,738 is_assignable<value_type&, _Up>>::value,
740 is_assignable<value_type&, _Up> >::value> >739 int> = 0>
741 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) {740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) {
742 if (this->has_value())741 if (this->has_value())
743 this->__get() = std::forward<_Up>(__v);742 this->__get() = std::forward<_Up>(__v);
...@@ -747,21 +746,20 @@ public:...@@ -747,21 +746,20 @@ public:
747 }746 }
748747
749 // LWG2756748 // LWG2756
750 template <class _Up,749 template <class _Up, enable_if_t<_CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>(), int> = 0>
751 enable_if_t< _CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>(), int> = 0>
752 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(const optional<_Up>& __v) {750 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(const optional<_Up>& __v) {
753 this->__assign_from(__v);751 this->__assign_from(__v);
754 return *this;752 return *this;
755 }753 }
756754
757 // LWG2756755 // LWG2756
758 template <class _Up, enable_if_t< _CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_assign<_Up>(), int> = 0>756 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_assign<_Up>(), int> = 0>
759 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(optional<_Up>&& __v) {757 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(optional<_Up>&& __v) {
760 this->__assign_from(std::move(__v));758 this->__assign_from(std::move(__v));
761 return *this;759 return *this;
762 }760 }
763761
764 template <class... _Args, class = enable_if_t< is_constructible_v<value_type, _Args...> > >762 template <class... _Args, enable_if_t<is_constructible_v<value_type, _Args...>, int> = 0>
765 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {763 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {
766 reset();764 reset();
767 this->__construct(std::forward<_Args>(__args)...);765 this->__construct(std::forward<_Args>(__args)...);
...@@ -770,7 +768,7 @@ public:...@@ -770,7 +768,7 @@ public:
770768
771 template <class _Up,769 template <class _Up,
772 class... _Args,770 class... _Args,
773 class = enable_if_t< is_constructible_v<value_type, initializer_list<_Up>&, _Args...> > >771 enable_if_t<is_constructible_v<value_type, initializer_list<_Up>&, _Args...>, int> = 0>
774 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {772 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
775 reset();773 reset();
776 this->__construct(__il, std::forward<_Args>(__args)...);774 this->__construct(__il, std::forward<_Args>(__args)...);
...@@ -829,27 +827,27 @@ public:...@@ -829,27 +827,27 @@ public:
829 using __base::__get;827 using __base::__get;
830 using __base::has_value;828 using __base::has_value;
831829
832 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const& value() const& {830 _LIBCPP_HIDE_FROM_ABI constexpr value_type const& value() const& {
833 if (!this->has_value())831 if (!this->has_value())
834 __throw_bad_optional_access();832 std::__throw_bad_optional_access();
835 return this->__get();833 return this->__get();
836 }834 }
837835
838 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type& value() & {836 _LIBCPP_HIDE_FROM_ABI constexpr value_type& value() & {
839 if (!this->has_value())837 if (!this->has_value())
840 __throw_bad_optional_access();838 std::__throw_bad_optional_access();
841 return this->__get();839 return this->__get();
842 }840 }
843841
844 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type&& value() && {842 _LIBCPP_HIDE_FROM_ABI constexpr value_type&& value() && {
845 if (!this->has_value())843 if (!this->has_value())
846 __throw_bad_optional_access();844 std::__throw_bad_optional_access();
847 return std::move(this->__get());845 return std::move(this->__get());
848 }846 }
849847
850 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const&& value() const&& {848 _LIBCPP_HIDE_FROM_ABI constexpr value_type const&& value() const&& {
851 if (!this->has_value())849 if (!this->has_value())
852 __throw_bad_optional_access();850 std::__throw_bad_optional_access();
853 return std::move(this->__get());851 return std::move(this->__get());
854 }852 }
855853
...@@ -869,7 +867,7 @@ public:...@@ -869,7 +867,7 @@ public:
869867
870# if _LIBCPP_STD_VER >= 23868# if _LIBCPP_STD_VER >= 23
871 template <class _Func>869 template <class _Func>
872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & {870 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
873 using _Up = invoke_result_t<_Func, value_type&>;871 using _Up = invoke_result_t<_Func, value_type&>;
874 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,872 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
875 "Result of f(value()) must be a specialization of std::optional");873 "Result of f(value()) must be a specialization of std::optional");
...@@ -879,7 +877,7 @@ public:...@@ -879,7 +877,7 @@ public:
879 }877 }
880878
881 template <class _Func>879 template <class _Func>
882 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) const& {880 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {
883 using _Up = invoke_result_t<_Func, const value_type&>;881 using _Up = invoke_result_t<_Func, const value_type&>;
884 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,882 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
885 "Result of f(value()) must be a specialization of std::optional");883 "Result of f(value()) must be a specialization of std::optional");
...@@ -889,7 +887,7 @@ public:...@@ -889,7 +887,7 @@ public:
889 }887 }
890888
891 template <class _Func>889 template <class _Func>
892 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) && {890 _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && {
893 using _Up = invoke_result_t<_Func, value_type&&>;891 using _Up = invoke_result_t<_Func, value_type&&>;
894 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,892 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
895 "Result of f(std::move(value())) must be a specialization of std::optional");893 "Result of f(std::move(value())) must be a specialization of std::optional");
...@@ -909,7 +907,7 @@ public:...@@ -909,7 +907,7 @@ public:
909 }907 }
910908
911 template <class _Func>909 template <class _Func>
912 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) & {910 _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & {
913 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;911 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;
914 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");912 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
915 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");913 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
...@@ -921,7 +919,7 @@ public:...@@ -921,7 +919,7 @@ public:
921 }919 }
922920
923 template <class _Func>921 template <class _Func>
924 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const& {922 _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& {
925 using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;923 using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;
926 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");924 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
927 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");925 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
...@@ -933,7 +931,7 @@ public:...@@ -933,7 +931,7 @@ public:
933 }931 }
934932
935 template <class _Func>933 template <class _Func>
936 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) && {934 _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && {
937 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;935 using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;
938 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");936 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
939 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");937 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
...@@ -945,7 +943,7 @@ public:...@@ -945,7 +943,7 @@ public:
945 }943 }
946944
947 template <class _Func>945 template <class _Func>
948 _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const&& {946 _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& {
949 using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;947 using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;
950 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");948 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
951 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");949 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
...@@ -982,17 +980,17 @@ public:...@@ -982,17 +980,17 @@ public:
982 using __base::reset;980 using __base::reset;
983};981};
984982
985# if _LIBCPP_STD_VER >= 17
986template <class _Tp>983template <class _Tp>
987optional(_Tp) -> optional<_Tp>;984optional(_Tp) -> optional<_Tp>;
988# endif
989985
990// Comparisons between optionals986// [optional.relops] Relational operators
991template <class _Tp, class _Up>987
992_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<988template <
993 is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,989 class _Tp,
994 bool >990 class _Up,
995operator==(const optional<_Tp>& __x, const optional<_Up>& __y) {991 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
992 int> = 0>
993_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const optional<_Up>& __y) {
996 if (static_cast<bool>(__x) != static_cast<bool>(__y))994 if (static_cast<bool>(__x) != static_cast<bool>(__y))
997 return false;995 return false;
998 if (!static_cast<bool>(__x))996 if (!static_cast<bool>(__x))
...@@ -1000,11 +998,12 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1000,11 +998,12 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y) {
1000 return *__x == *__y;998 return *__x == *__y;
1001}999}
10021000
1003template <class _Tp, class _Up>1001template <
1004_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1002 class _Tp,
1005 is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,1003 class _Up,
1006 bool >1004 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,
1007operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) {1005 int> = 0>
1006_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1008 if (static_cast<bool>(__x) != static_cast<bool>(__y))1007 if (static_cast<bool>(__x) != static_cast<bool>(__y))
1009 return true;1008 return true;
1010 if (!static_cast<bool>(__x))1009 if (!static_cast<bool>(__x))
...@@ -1012,11 +1011,11 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1012,11 +1011,11 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1012 return *__x != *__y;1011 return *__x != *__y;
1013}1012}
10141013
1015template <class _Tp, class _Up>1014template < class _Tp,
1016_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1015 class _Up,
1017 is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,1016 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,
1018 bool >1017 int> = 0>
1019operator<(const optional<_Tp>& __x, const optional<_Up>& __y) {1018_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const optional<_Up>& __y) {
1020 if (!static_cast<bool>(__y))1019 if (!static_cast<bool>(__y))
1021 return false;1020 return false;
1022 if (!static_cast<bool>(__x))1021 if (!static_cast<bool>(__x))
...@@ -1024,11 +1023,11 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1024,11 +1023,11 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y) {
1024 return *__x < *__y;1023 return *__x < *__y;
1025}1024}
10261025
1027template <class _Tp, class _Up>1026template < class _Tp,
1028_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1027 class _Up,
1029 is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,1028 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,
1030 bool >1029 int> = 0>
1031operator>(const optional<_Tp>& __x, const optional<_Up>& __y) {1030_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const optional<_Up>& __y) {
1032 if (!static_cast<bool>(__x))1031 if (!static_cast<bool>(__x))
1033 return false;1032 return false;
1034 if (!static_cast<bool>(__y))1033 if (!static_cast<bool>(__y))
...@@ -1036,11 +1035,12 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1036,11 +1035,12 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y) {
1036 return *__x > *__y;1035 return *__x > *__y;
1037}1036}
10381037
1039template <class _Tp, class _Up>1038template <
1040_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1039 class _Tp,
1041 is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,1040 class _Up,
1042 bool >1041 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,
1043operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) {1042 int> = 0>
1043_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1044 if (!static_cast<bool>(__x))1044 if (!static_cast<bool>(__x))
1045 return true;1045 return true;
1046 if (!static_cast<bool>(__y))1046 if (!static_cast<bool>(__y))
...@@ -1048,11 +1048,12 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1048,11 +1048,12 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1048 return *__x <= *__y;1048 return *__x <= *__y;
1049}1049}
10501050
1051template <class _Tp, class _Up>1051template <
1052_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1052 class _Tp,
1053 is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,1053 class _Up,
1054 bool >1054 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,
1055operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) {1055 int> = 0>
1056_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const optional<_Up>& __y) {
1056 if (!static_cast<bool>(__y))1057 if (!static_cast<bool>(__y))
1057 return true;1058 return true;
1058 if (!static_cast<bool>(__x))1059 if (!static_cast<bool>(__x))
...@@ -1072,7 +1073,8 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {...@@ -1072,7 +1073,8 @@ operator<=>(const optional<_Tp>& __x, const optional<_Up>& __y) {
10721073
1073# endif // _LIBCPP_STD_VER >= 201074# endif // _LIBCPP_STD_VER >= 20
10741075
1075// Comparisons with nullopt1076// [optional.nullops] Comparison with nullopt
1077
1076template <class _Tp>1078template <class _Tp>
1077_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept {1079_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, nullopt_t) noexcept {
1078 return !static_cast<bool>(__x);1080 return !static_cast<bool>(__x);
...@@ -1144,100 +1146,109 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>&...@@ -1144,100 +1146,109 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const optional<_Tp>&
11441146
1145# endif // _LIBCPP_STD_VER <= 171147# endif // _LIBCPP_STD_VER <= 17
11461148
1147// Comparisons with T1149// [optional.comp.with.t] Comparison with T
1148template <class _Tp, class _Up>1150
1149_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1151template <
1150 is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,1152 class _Tp,
1151 bool >1153 class _Up,
1152operator==(const optional<_Tp>& __x, const _Up& __v) {1154 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
1155 int> = 0>
1156_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const optional<_Tp>& __x, const _Up& __v) {
1153 return static_cast<bool>(__x) ? *__x == __v : false;1157 return static_cast<bool>(__x) ? *__x == __v : false;
1154}1158}
11551159
1156template <class _Tp, class _Up>1160template <
1157_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1161 class _Tp,
1158 is_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,1162 class _Up,
1159 bool >1163 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() == std::declval<const _Up&>()), bool>,
1160operator==(const _Tp& __v, const optional<_Up>& __x) {1164 int> = 0>
1165_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __v, const optional<_Up>& __x) {
1161 return static_cast<bool>(__x) ? __v == *__x : false;1166 return static_cast<bool>(__x) ? __v == *__x : false;
1162}1167}
11631168
1164template <class _Tp, class _Up>1169template <
1165_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1170 class _Tp,
1166 is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,1171 class _Up,
1167 bool >1172 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,
1168operator!=(const optional<_Tp>& __x, const _Up& __v) {1173 int> = 0>
1174_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const optional<_Tp>& __x, const _Up& __v) {
1169 return static_cast<bool>(__x) ? *__x != __v : true;1175 return static_cast<bool>(__x) ? *__x != __v : true;
1170}1176}
11711177
1172template <class _Tp, class _Up>1178template <
1173_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1179 class _Tp,
1174 is_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,1180 class _Up,
1175 bool >1181 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() != std::declval<const _Up&>()), bool>,
1176operator!=(const _Tp& __v, const optional<_Up>& __x) {1182 int> = 0>
1183_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __v, const optional<_Up>& __x) {
1177 return static_cast<bool>(__x) ? __v != *__x : true;1184 return static_cast<bool>(__x) ? __v != *__x : true;
1178}1185}
11791186
1180template <class _Tp, class _Up>1187template < class _Tp,
1181_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1188 class _Up,
1182 is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,1189 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,
1183 bool >1190 int> = 0>
1184operator<(const optional<_Tp>& __x, const _Up& __v) {1191_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const optional<_Tp>& __x, const _Up& __v) {
1185 return static_cast<bool>(__x) ? *__x < __v : true;1192 return static_cast<bool>(__x) ? *__x < __v : true;
1186}1193}
11871194
1188template <class _Tp, class _Up>1195template < class _Tp,
1189_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1196 class _Up,
1190 is_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,1197 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() < std::declval<const _Up&>()), bool>,
1191 bool >1198 int> = 0>
1192operator<(const _Tp& __v, const optional<_Up>& __x) {1199_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __v, const optional<_Up>& __x) {
1193 return static_cast<bool>(__x) ? __v < *__x : false;1200 return static_cast<bool>(__x) ? __v < *__x : false;
1194}1201}
11951202
1196template <class _Tp, class _Up>1203template <
1197_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1204 class _Tp,
1198 is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,1205 class _Up,
1199 bool >1206 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,
1200operator<=(const optional<_Tp>& __x, const _Up& __v) {1207 int> = 0>
1208_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const optional<_Tp>& __x, const _Up& __v) {
1201 return static_cast<bool>(__x) ? *__x <= __v : true;1209 return static_cast<bool>(__x) ? *__x <= __v : true;
1202}1210}
12031211
1204template <class _Tp, class _Up>1212template <
1205_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1213 class _Tp,
1206 is_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,1214 class _Up,
1207 bool >1215 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() <= std::declval<const _Up&>()), bool>,
1208operator<=(const _Tp& __v, const optional<_Up>& __x) {1216 int> = 0>
1217_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __v, const optional<_Up>& __x) {
1209 return static_cast<bool>(__x) ? __v <= *__x : false;1218 return static_cast<bool>(__x) ? __v <= *__x : false;
1210}1219}
12111220
1212template <class _Tp, class _Up>1221template < class _Tp,
1213_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1222 class _Up,
1214 is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,1223 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,
1215 bool >1224 int> = 0>
1216operator>(const optional<_Tp>& __x, const _Up& __v) {1225_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const optional<_Tp>& __x, const _Up& __v) {
1217 return static_cast<bool>(__x) ? *__x > __v : false;1226 return static_cast<bool>(__x) ? *__x > __v : false;
1218}1227}
12191228
1220template <class _Tp, class _Up>1229template < class _Tp,
1221_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1230 class _Up,
1222 is_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,1231 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() > std::declval<const _Up&>()), bool>,
1223 bool >1232 int> = 0>
1224operator>(const _Tp& __v, const optional<_Up>& __x) {1233_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __v, const optional<_Up>& __x) {
1225 return static_cast<bool>(__x) ? __v > *__x : true;1234 return static_cast<bool>(__x) ? __v > *__x : true;
1226}1235}
12271236
1228template <class _Tp, class _Up>1237template <
1229_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1238 class _Tp,
1230 is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,1239 class _Up,
1231 bool >1240 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,
1232operator>=(const optional<_Tp>& __x, const _Up& __v) {1241 int> = 0>
1242_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const optional<_Tp>& __x, const _Up& __v) {
1233 return static_cast<bool>(__x) ? *__x >= __v : false;1243 return static_cast<bool>(__x) ? *__x >= __v : false;
1234}1244}
12351245
1236template <class _Tp, class _Up>1246template <
1237_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<1247 class _Tp,
1238 is_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,1248 class _Up,
1239 bool >1249 enable_if_t<__is_core_convertible_v<decltype(std::declval<const _Tp&>() >= std::declval<const _Up&>()), bool>,
1240operator>=(const _Tp& __v, const optional<_Up>& __x) {1250 int> = 0>
1251_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __v, const optional<_Up>& __x) {
1241 return static_cast<bool>(__x) ? __v >= *__x : true;1252 return static_cast<bool>(__x) ? __v >= *__x : true;
1242}1253}
12431254
...@@ -1252,9 +1263,8 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {...@@ -1252,9 +1263,8 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {
12521263
1253# endif // _LIBCPP_STD_VER >= 201264# endif // _LIBCPP_STD_VER >= 20
12541265
1255template <class _Tp>1266template <class _Tp, enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, int> = 0>
1256inline _LIBCPP_HIDE_FROM_ABI1267inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1257_LIBCPP_CONSTEXPR_SINCE_CXX20 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void >
1258swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {1268swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {
1259 __x.swap(__y);1269 __x.swap(__y);
1260}1270}
...@@ -1275,7 +1285,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up...@@ -1275,7 +1285,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr optional<_Tp> make_optional(initializer_list<_Up
1275}1285}
12761286
1277template <class _Tp>1287template <class _Tp>
1278struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > {1288struct hash< __enable_hash_helper<optional<_Tp>, remove_const_t<_Tp>> > {
1279# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)1289# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1280 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;1290 _LIBCPP_DEPRECATED_IN_CXX17 typedef optional<_Tp> argument_type;
1281 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;1291 _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type;
lib/libcxx/include/ostream+5
...@@ -205,6 +205,11 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);...@@ -205,6 +205,11 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
205# include <stdexcept>205# include <stdexcept>
206# include <type_traits>206# include <type_traits>
207# endif207# endif
208
209# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
210# include <locale>
211# endif
212
208#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)213#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
209214
210#endif // _LIBCPP_OSTREAM215#endif // _LIBCPP_OSTREAM
lib/libcxx/include/print+2-2
...@@ -34,7 +34,7 @@ namespace std {...@@ -34,7 +34,7 @@ namespace std {
34*/34*/
3535
36#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)36#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
37# include <__cxx03/print>37# include <__cxx03/__config>
38#else38#else
39# include <__assert>39# include <__assert>
40# include <__concepts/same_as.h>40# include <__concepts/same_as.h>
...@@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __encode(_OutIt& __out_it, char32_t __value...@@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __encode(_OutIt& __out_it, char32_t __value
123 _LIBCPP_ASSERT_UNCATEGORIZED(__is_scalar_value(__value), "an invalid unicode scalar value results in invalid UTF-16");123 _LIBCPP_ASSERT_UNCATEGORIZED(__is_scalar_value(__value), "an invalid unicode scalar value results in invalid UTF-16");
124124
125 if (__value < 0x10000) {125 if (__value < 0x10000) {
126 *__out_it++ = __value;126 *__out_it++ = static_cast<iter_value_t<_OutIt>>(__value);
127 return;127 return;
128 }128 }
129129
lib/libcxx/include/queue+88-69
...@@ -299,7 +299,7 @@ template <class _Tp, class _Container>...@@ -299,7 +299,7 @@ template <class _Tp, class _Container>
299_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);299_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
300300
301template <class _Tp, class _Container /*= deque<_Tp>*/>301template <class _Tp, class _Container /*= deque<_Tp>*/>
302class _LIBCPP_TEMPLATE_VIS queue {302class queue {
303public:303public:
304 typedef _Container container_type;304 typedef _Container container_type;
305 typedef typename container_type::value_type value_type;305 typedef typename container_type::value_type value_type;
...@@ -428,6 +428,12 @@ public:...@@ -428,6 +428,12 @@ public:
428 template <class _T1, class _OtherContainer>428 template <class _T1, class _OtherContainer>
429 friend _LIBCPP_HIDE_FROM_ABI bool429 friend _LIBCPP_HIDE_FROM_ABI bool
430 operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);430 operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
431
432# if _LIBCPP_STD_VER >= 20
433 template <class _T1, three_way_comparable _OtherContainer>
434 friend _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_OtherContainer>
435 operator<=>(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y);
436# endif
431};437};
432438
433# if _LIBCPP_STD_VER >= 17439# if _LIBCPP_STD_VER >= 17
...@@ -452,14 +458,12 @@ template <class _InputIterator,...@@ -452,14 +458,12 @@ template <class _InputIterator,
452 class _Alloc,458 class _Alloc,
453 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,459 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
454 __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>460 __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
455queue(_InputIterator,461queue(_InputIterator, _InputIterator, _Alloc)
456 _InputIterator,462 -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
457 _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
458463
459template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>464template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
460queue(from_range_t,465queue(from_range_t, _Range&&, _Alloc)
461 _Range&&,466 -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
462 _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
463# endif467# endif
464468
465template <class _Tp, class _Container>469template <class _Tp, class _Container>
...@@ -497,8 +501,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x,...@@ -497,8 +501,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x,
497template <class _Tp, three_way_comparable _Container>501template <class _Tp, three_way_comparable _Container>
498_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>502_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
499operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {503operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) {
500 // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors504 return __x.c <=> __y.c;
501 return __x.__get_container() <=> __y.__get_container();
502}505}
503506
504# endif507# endif
...@@ -510,11 +513,10 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _...@@ -510,11 +513,10 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _
510}513}
511514
512template <class _Tp, class _Container, class _Alloc>515template <class _Tp, class _Container, class _Alloc>
513struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {516struct uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {};
514};
515517
516template <class _Tp, class _Container, class _Compare>518template <class _Tp, class _Container, class _Compare>
517class _LIBCPP_TEMPLATE_VIS priority_queue {519class priority_queue {
518public:520public:
519 typedef _Container container_type;521 typedef _Container container_type;
520 typedef _Compare value_compare;522 typedef _Compare value_compare;
...@@ -529,24 +531,25 @@ protected:...@@ -529,24 +531,25 @@ protected:
529 value_compare comp;531 value_compare comp;
530532
531public:533public:
532 _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_(534 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue() _NOEXCEPT_(
533 is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value)535 is_nothrow_default_constructible<container_type>::value&& is_nothrow_default_constructible<value_compare>::value)
534 : c(), comp() {}536 : c(), comp() {}
535537
536 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}538 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q)
539 : c(__q.c), comp(__q.comp) {}
537540
538 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {541 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) {
539 c = __q.c;542 c = __q.c;
540 comp = __q.comp;543 comp = __q.comp;
541 return *this;544 return *this;
542 }545 }
543546
544# ifndef _LIBCPP_CXX03_LANG547# ifndef _LIBCPP_CXX03_LANG
545 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(548 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(
546 is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)549 is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)
547 : c(std::move(__q.c)), comp(std::move(__q.comp)) {}550 : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
548551
549 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept(552 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept(
550 is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) {553 is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) {
551 c = std::move(__q.c);554 c = std::move(__q.c);
552 comp = std::move(__q.comp);555 comp = std::move(__q.comp);
...@@ -554,50 +557,56 @@ public:...@@ -554,50 +557,56 @@ public:
554 }557 }
555# endif // _LIBCPP_CXX03_LANG558# endif // _LIBCPP_CXX03_LANG
556559
557 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {}560 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp)
558 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c);561 : c(), comp(__comp) {}
562 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
563 priority_queue(const value_compare& __comp, const container_type& __c);
559# ifndef _LIBCPP_CXX03_LANG564# ifndef _LIBCPP_CXX03_LANG
560 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);565 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
561# endif566# endif
562 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>567 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
563 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());568 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
569 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
564570
565 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>571 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
566 _LIBCPP_HIDE_FROM_ABI572 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
567 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);573 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
568574
569# ifndef _LIBCPP_CXX03_LANG575# ifndef _LIBCPP_CXX03_LANG
570 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>576 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
571 _LIBCPP_HIDE_FROM_ABI577 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
572 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);578 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
573# endif // _LIBCPP_CXX03_LANG579# endif // _LIBCPP_CXX03_LANG
574580
575# if _LIBCPP_STD_VER >= 23581# if _LIBCPP_STD_VER >= 23
576 template <_ContainerCompatibleRange<_Tp> _Range>582 template <_ContainerCompatibleRange<_Tp> _Range>
577 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())583 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
584 priority_queue(from_range_t, _Range&& __range, const value_compare& __comp = value_compare())
578 : c(from_range, std::forward<_Range>(__range)), comp(__comp) {585 : c(from_range, std::forward<_Range>(__range)), comp(__comp) {
579 std::make_heap(c.begin(), c.end(), comp);586 std::make_heap(c.begin(), c.end(), comp);
580 }587 }
581# endif588# endif
582589
583 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>590 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
584 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);591 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
585592
586 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>593 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
587 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);594 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);
588595
589 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>596 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
590 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);597 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
598 priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);
591599
592 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>600 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
593 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);601 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
594602
595# ifndef _LIBCPP_CXX03_LANG603# ifndef _LIBCPP_CXX03_LANG
596 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>604 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
597 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);605 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
606 priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);
598607
599 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>608 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
600 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);609 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);
601# endif // _LIBCPP_CXX03_LANG610# endif // _LIBCPP_CXX03_LANG
602611
603 template <612 template <
...@@ -605,21 +614,22 @@ public:...@@ -605,21 +614,22 @@ public:
605 class _Alloc,614 class _Alloc,
606 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,615 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
607 int> = 0>616 int> = 0>
608 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);617 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);
609618
610 template <619 template <
611 class _InputIter,620 class _InputIter,
612 class _Alloc,621 class _Alloc,
613 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,622 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
614 int> = 0>623 int> = 0>
615 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);624 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
625 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);
616626
617 template <627 template <
618 class _InputIter,628 class _InputIter,
619 class _Alloc,629 class _Alloc,
620 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,630 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
621 int> = 0>631 int> = 0>
622 _LIBCPP_HIDE_FROM_ABI priority_queue(632 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(
623 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);633 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
624634
625# ifndef _LIBCPP_CXX03_LANG635# ifndef _LIBCPP_CXX03_LANG
...@@ -628,7 +638,7 @@ public:...@@ -628,7 +638,7 @@ public:
628 class _Alloc,638 class _Alloc,
629 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,639 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
630 int> = 0>640 int> = 0>
631 _LIBCPP_HIDE_FROM_ABI641 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
632 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);642 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);
633# endif // _LIBCPP_CXX03_LANG643# endif // _LIBCPP_CXX03_LANG
634644
...@@ -637,7 +647,8 @@ public:...@@ -637,7 +647,8 @@ public:
637 template <_ContainerCompatibleRange<_Tp> _Range,647 template <_ContainerCompatibleRange<_Tp> _Range,
638 class _Alloc,648 class _Alloc,
639 class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>649 class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
640 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)650 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
651 priority_queue(from_range_t, _Range&& __range, const value_compare& __comp, const _Alloc& __a)
641 : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) {652 : c(from_range, std::forward<_Range>(__range), __a), comp(__comp) {
642 std::make_heap(c.begin(), c.end(), comp);653 std::make_heap(c.begin(), c.end(), comp);
643 }654 }
...@@ -645,24 +656,24 @@ public:...@@ -645,24 +656,24 @@ public:
645 template <_ContainerCompatibleRange<_Tp> _Range,656 template <_ContainerCompatibleRange<_Tp> _Range,
646 class _Alloc,657 class _Alloc,
647 class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>658 class = enable_if_t<uses_allocator<_Container, _Alloc>::value>>
648 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)659 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI priority_queue(from_range_t, _Range&& __range, const _Alloc& __a)
649 : c(from_range, std::forward<_Range>(__range), __a), comp() {660 : c(from_range, std::forward<_Range>(__range), __a), comp() {
650 std::make_heap(c.begin(), c.end(), comp);661 std::make_heap(c.begin(), c.end(), comp);
651 }662 }
652663
653# endif664# endif
654665
655 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }666 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
656 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }667 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
657 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }668 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
658669
659 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);670 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(const value_type& __v);
660# ifndef _LIBCPP_CXX03_LANG671# ifndef _LIBCPP_CXX03_LANG
661 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);672 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push(value_type&& __v);
662673
663# if _LIBCPP_STD_VER >= 23674# if _LIBCPP_STD_VER >= 23
664 template <_ContainerCompatibleRange<_Tp> _Range>675 template <_ContainerCompatibleRange<_Tp> _Range>
665 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {676 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_range(_Range&& __range) {
666 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {677 if constexpr (requires(container_type& __c) { __c.append_range(std::forward<_Range>(__range)); }) {
667 c.append_range(std::forward<_Range>(__range));678 c.append_range(std::forward<_Range>(__range));
668 } else {679 } else {
...@@ -674,14 +685,16 @@ public:...@@ -674,14 +685,16 @@ public:
674# endif685# endif
675686
676 template <class... _Args>687 template <class... _Args>
677 _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);688 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void emplace(_Args&&... __args);
678# endif // _LIBCPP_CXX03_LANG689# endif // _LIBCPP_CXX03_LANG
679 _LIBCPP_HIDE_FROM_ABI void pop();690 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop();
680691
681 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)692 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
682 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);693 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);
683694
684 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }695 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const {
696 return c;
697 }
685};698};
686699
687# if _LIBCPP_STD_VER >= 17700# if _LIBCPP_STD_VER >= 17
...@@ -763,7 +776,8 @@ priority_queue(from_range_t, _Range&&, _Alloc)...@@ -763,7 +776,8 @@ priority_queue(from_range_t, _Range&&, _Alloc)
763# endif776# endif
764777
765template <class _Tp, class _Container, class _Compare>778template <class _Tp, class _Container, class _Compare>
766inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c)779_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
780 const _Compare& __comp, const container_type& __c)
767 : c(__c), comp(__comp) {781 : c(__c), comp(__comp) {
768 std::make_heap(c.begin(), c.end(), comp);782 std::make_heap(c.begin(), c.end(), comp);
769}783}
...@@ -771,7 +785,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare&...@@ -771,7 +785,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare&
771# ifndef _LIBCPP_CXX03_LANG785# ifndef _LIBCPP_CXX03_LANG
772786
773template <class _Tp, class _Container, class _Compare>787template <class _Tp, class _Container, class _Compare>
774inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, container_type&& __c)788_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
789 const value_compare& __comp, container_type&& __c)
775 : c(std::move(__c)), comp(__comp) {790 : c(std::move(__c)), comp(__comp) {
776 std::make_heap(c.begin(), c.end(), comp);791 std::make_heap(c.begin(), c.end(), comp);
777}792}
...@@ -780,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com...@@ -780,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com
780795
781template <class _Tp, class _Container, class _Compare>796template <class _Tp, class _Container, class _Compare>
782template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >797template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
783inline priority_queue<_Tp, _Container, _Compare>::priority_queue(798_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
784 _InputIter __f, _InputIter __l, const value_compare& __comp)799 _InputIter __f, _InputIter __l, const value_compare& __comp)
785 : c(__f, __l), comp(__comp) {800 : c(__f, __l), comp(__comp) {
786 std::make_heap(c.begin(), c.end(), comp);801 std::make_heap(c.begin(), c.end(), comp);
...@@ -788,7 +803,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -788,7 +803,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
788803
789template <class _Tp, class _Container, class _Compare>804template <class _Tp, class _Container, class _Compare>
790template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >805template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
791inline priority_queue<_Tp, _Container, _Compare>::priority_queue(806_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
792 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)807 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
793 : c(__c), comp(__comp) {808 : c(__c), comp(__comp) {
794 c.insert(c.end(), __f, __l);809 c.insert(c.end(), __f, __l);
...@@ -799,7 +814,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -799,7 +814,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
799814
800template <class _Tp, class _Container, class _Compare>815template <class _Tp, class _Container, class _Compare>
801template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >816template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
802inline priority_queue<_Tp, _Container, _Compare>::priority_queue(817_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
803 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)818 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)
804 : c(std::move(__c)), comp(__comp) {819 : c(std::move(__c)), comp(__comp) {
805 c.insert(c.end(), __f, __l);820 c.insert(c.end(), __f, __l);
...@@ -810,16 +825,18 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -810,16 +825,18 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
810825
811template <class _Tp, class _Container, class _Compare>826template <class _Tp, class _Container, class _Compare>
812template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >827template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
813inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {}828_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a)
829 : c(__a) {}
814830
815template <class _Tp, class _Container, class _Compare>831template <class _Tp, class _Container, class _Compare>
816template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >832template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
817inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a)833_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
834 const value_compare& __comp, const _Alloc& __a)
818 : c(__a), comp(__comp) {}835 : c(__a), comp(__comp) {}
819836
820template <class _Tp, class _Container, class _Compare>837template <class _Tp, class _Container, class _Compare>
821template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >838template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
822inline priority_queue<_Tp, _Container, _Compare>::priority_queue(839_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
823 const value_compare& __comp, const container_type& __c, const _Alloc& __a)840 const value_compare& __comp, const container_type& __c, const _Alloc& __a)
824 : c(__c, __a), comp(__comp) {841 : c(__c, __a), comp(__comp) {
825 std::make_heap(c.begin(), c.end(), comp);842 std::make_heap(c.begin(), c.end(), comp);
...@@ -827,14 +844,15 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -827,14 +844,15 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
827844
828template <class _Tp, class _Container, class _Compare>845template <class _Tp, class _Container, class _Compare>
829template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >846template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
830inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)847_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
848 const priority_queue& __q, const _Alloc& __a)
831 : c(__q.c, __a), comp(__q.comp) {}849 : c(__q.c, __a), comp(__q.comp) {}
832850
833# ifndef _LIBCPP_CXX03_LANG851# ifndef _LIBCPP_CXX03_LANG
834852
835template <class _Tp, class _Container, class _Compare>853template <class _Tp, class _Container, class _Compare>
836template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >854template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
837inline priority_queue<_Tp, _Container, _Compare>::priority_queue(855_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
838 const value_compare& __comp, container_type&& __c, const _Alloc& __a)856 const value_compare& __comp, container_type&& __c, const _Alloc& __a)
839 : c(std::move(__c), __a), comp(__comp) {857 : c(std::move(__c), __a), comp(__comp) {
840 std::make_heap(c.begin(), c.end(), comp);858 std::make_heap(c.begin(), c.end(), comp);
...@@ -842,7 +860,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -842,7 +860,8 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
842860
843template <class _Tp, class _Container, class _Compare>861template <class _Tp, class _Container, class _Compare>
844template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >862template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
845inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)863_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
864 priority_queue&& __q, const _Alloc& __a)
846 : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}865 : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
847866
848# endif // _LIBCPP_CXX03_LANG867# endif // _LIBCPP_CXX03_LANG
...@@ -852,7 +871,8 @@ template <...@@ -852,7 +871,8 @@ template <
852 class _InputIter,871 class _InputIter,
853 class _Alloc,872 class _Alloc,
854 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >873 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
855inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a)874_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
875 _InputIter __f, _InputIter __l, const _Alloc& __a)
856 : c(__f, __l, __a), comp() {876 : c(__f, __l, __a), comp() {
857 std::make_heap(c.begin(), c.end(), comp);877 std::make_heap(c.begin(), c.end(), comp);
858}878}
...@@ -862,7 +882,7 @@ template <...@@ -862,7 +882,7 @@ template <
862 class _InputIter,882 class _InputIter,
863 class _Alloc,883 class _Alloc,
864 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >884 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
865inline priority_queue<_Tp, _Container, _Compare>::priority_queue(885_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
866 _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)886 _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)
867 : c(__f, __l, __a), comp(__comp) {887 : c(__f, __l, __a), comp(__comp) {
868 std::make_heap(c.begin(), c.end(), comp);888 std::make_heap(c.begin(), c.end(), comp);
...@@ -873,7 +893,7 @@ template <...@@ -873,7 +893,7 @@ template <
873 class _InputIter,893 class _InputIter,
874 class _Alloc,894 class _Alloc,
875 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >895 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
876inline priority_queue<_Tp, _Container, _Compare>::priority_queue(896_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
877 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)897 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)
878 : c(__c, __a), comp(__comp) {898 : c(__c, __a), comp(__comp) {
879 c.insert(c.end(), __f, __l);899 c.insert(c.end(), __f, __l);
...@@ -886,7 +906,7 @@ template <...@@ -886,7 +906,7 @@ template <
886 class _InputIter,906 class _InputIter,
887 class _Alloc,907 class _Alloc,
888 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >908 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
889inline priority_queue<_Tp, _Container, _Compare>::priority_queue(909_LIBCPP_CONSTEXPR_SINCE_CXX26 inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
890 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a)910 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a)
891 : c(std::move(__c), __a), comp(__comp) {911 : c(std::move(__c), __a), comp(__comp) {
892 c.insert(c.end(), __f, __l);912 c.insert(c.end(), __f, __l);
...@@ -895,7 +915,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(...@@ -895,7 +915,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
895# endif // _LIBCPP_CXX03_LANG915# endif // _LIBCPP_CXX03_LANG
896916
897template <class _Tp, class _Container, class _Compare>917template <class _Tp, class _Container, class _Compare>
898inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {918_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) {
899 c.push_back(__v);919 c.push_back(__v);
900 std::push_heap(c.begin(), c.end(), comp);920 std::push_heap(c.begin(), c.end(), comp);
901}921}
...@@ -903,14 +923,14 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __...@@ -903,14 +923,14 @@ inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __
903# ifndef _LIBCPP_CXX03_LANG923# ifndef _LIBCPP_CXX03_LANG
904924
905template <class _Tp, class _Container, class _Compare>925template <class _Tp, class _Container, class _Compare>
906inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {926_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) {
907 c.push_back(std::move(__v));927 c.push_back(std::move(__v));
908 std::push_heap(c.begin(), c.end(), comp);928 std::push_heap(c.begin(), c.end(), comp);
909}929}
910930
911template <class _Tp, class _Container, class _Compare>931template <class _Tp, class _Container, class _Compare>
912template <class... _Args>932template <class... _Args>
913inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) {933_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) {
914 c.emplace_back(std::forward<_Args>(__args)...);934 c.emplace_back(std::forward<_Args>(__args)...);
915 std::push_heap(c.begin(), c.end(), comp);935 std::push_heap(c.begin(), c.end(), comp);
916}936}
...@@ -918,13 +938,13 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args...@@ -918,13 +938,13 @@ inline void priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args
918# endif // _LIBCPP_CXX03_LANG938# endif // _LIBCPP_CXX03_LANG
919939
920template <class _Tp, class _Container, class _Compare>940template <class _Tp, class _Container, class _Compare>
921inline void priority_queue<_Tp, _Container, _Compare>::pop() {941_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::pop() {
922 std::pop_heap(c.begin(), c.end(), comp);942 std::pop_heap(c.begin(), c.end(), comp);
923 c.pop_back();943 c.pop_back();
924}944}
925945
926template <class _Tp, class _Container, class _Compare>946template <class _Tp, class _Container, class _Compare>
927inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)947_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
928 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) {948 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) {
929 using std::swap;949 using std::swap;
930 swap(c, __q.c);950 swap(c, __q.c);
...@@ -935,15 +955,14 @@ template <class _Tp,...@@ -935,15 +955,14 @@ template <class _Tp,
935 class _Container,955 class _Container,
936 class _Compare,956 class _Compare,
937 __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0>957 __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0>
938inline _LIBCPP_HIDE_FROM_ABI void958_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void
939swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)959swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)
940 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {960 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
941 __x.swap(__y);961 __x.swap(__y);
942}962}
943963
944template <class _Tp, class _Container, class _Compare, class _Alloc>964template <class _Tp, class _Container, class _Compare, class _Alloc>
945struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>965struct uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> : public uses_allocator<_Container, _Alloc> {};
946 : public uses_allocator<_Container, _Alloc> {};
947966
948_LIBCPP_END_NAMESPACE_STD967_LIBCPP_END_NAMESPACE_STD
949968
lib/libcxx/include/ranges+11-1
...@@ -285,6 +285,15 @@ namespace std::ranges {...@@ -285,6 +285,15 @@ namespace std::ranges {
285 requires view<V> && input_range<range_reference_t<V>>285 requires view<V> && input_range<range_reference_t<V>>
286 class join_view;286 class join_view;
287287
288 // [range.join.with], join with view
289 template<input_range V, forward_range Pattern>
290 requires view<V> && input_range<range_reference_t<V>>
291 && view<Pattern>
292 && concatable<range_reference_t<V>, Pattern>
293 class join_with_view; // since C++23
294
295 namespace views { inline constexpr unspecified join_with = unspecified; } // since C++23
296
288 // [range.lazy.split], lazy split view297 // [range.lazy.split], lazy split view
289 template<class R>298 template<class R>
290 concept tiny-range = see below; // exposition only299 concept tiny-range = see below; // exposition only
...@@ -381,7 +390,7 @@ namespace std {...@@ -381,7 +390,7 @@ namespace std {
381*/390*/
382391
383#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)392#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
384# include <__cxx03/ranges>393# include <__cxx03/__config>
385#else394#else
386# include <__config>395# include <__config>
387396
...@@ -427,6 +436,7 @@ namespace std {...@@ -427,6 +436,7 @@ namespace std {
427# include <__ranges/as_rvalue_view.h>436# include <__ranges/as_rvalue_view.h>
428# include <__ranges/chunk_by_view.h>437# include <__ranges/chunk_by_view.h>
429# include <__ranges/from_range.h>438# include <__ranges/from_range.h>
439# include <__ranges/join_with_view.h>
430# include <__ranges/repeat_view.h>440# include <__ranges/repeat_view.h>
431# include <__ranges/to.h>441# include <__ranges/to.h>
432# include <__ranges/zip_view.h>442# include <__ranges/zip_view.h>
lib/libcxx/include/ratio+11-11
...@@ -229,7 +229,7 @@ public:...@@ -229,7 +229,7 @@ public:
229};229};
230230
231template <intmax_t _Num, intmax_t _Den = 1>231template <intmax_t _Num, intmax_t _Den = 1>
232class _LIBCPP_TEMPLATE_VIS ratio {232class ratio {
233 static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range");233 static_assert(__static_abs<_Num> >= 0, "ratio numerator is out of range");
234 static_assert(_Den != 0, "ratio divide by 0");234 static_assert(_Den != 0, "ratio divide by 0");
235 static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range");235 static_assert(__static_abs<_Den> > 0, "ratio denominator is out of range");
...@@ -290,7 +290,7 @@ using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;...@@ -290,7 +290,7 @@ using ratio_multiply = typename __ratio_multiply<_R1, _R2>::type;
290# else // _LIBCPP_CXX03_LANG290# else // _LIBCPP_CXX03_LANG
291291
292template <class _R1, class _R2>292template <class _R1, class _R2>
293struct _LIBCPP_TEMPLATE_VIS ratio_multiply : public __ratio_multiply<_R1, _R2>::type {};293struct ratio_multiply : public __ratio_multiply<_R1, _R2>::type {};
294294
295# endif // _LIBCPP_CXX03_LANG295# endif // _LIBCPP_CXX03_LANG
296296
...@@ -316,7 +316,7 @@ using ratio_divide = typename __ratio_divide<_R1, _R2>::type;...@@ -316,7 +316,7 @@ using ratio_divide = typename __ratio_divide<_R1, _R2>::type;
316# else // _LIBCPP_CXX03_LANG316# else // _LIBCPP_CXX03_LANG
317317
318template <class _R1, class _R2>318template <class _R1, class _R2>
319struct _LIBCPP_TEMPLATE_VIS ratio_divide : public __ratio_divide<_R1, _R2>::type {};319struct ratio_divide : public __ratio_divide<_R1, _R2>::type {};
320320
321# endif // _LIBCPP_CXX03_LANG321# endif // _LIBCPP_CXX03_LANG
322322
...@@ -345,7 +345,7 @@ using ratio_add = typename __ratio_add<_R1, _R2>::type;...@@ -345,7 +345,7 @@ using ratio_add = typename __ratio_add<_R1, _R2>::type;
345# else // _LIBCPP_CXX03_LANG345# else // _LIBCPP_CXX03_LANG
346346
347template <class _R1, class _R2>347template <class _R1, class _R2>
348struct _LIBCPP_TEMPLATE_VIS ratio_add : public __ratio_add<_R1, _R2>::type {};348struct ratio_add : public __ratio_add<_R1, _R2>::type {};
349349
350# endif // _LIBCPP_CXX03_LANG350# endif // _LIBCPP_CXX03_LANG
351351
...@@ -374,20 +374,20 @@ using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;...@@ -374,20 +374,20 @@ using ratio_subtract = typename __ratio_subtract<_R1, _R2>::type;
374# else // _LIBCPP_CXX03_LANG374# else // _LIBCPP_CXX03_LANG
375375
376template <class _R1, class _R2>376template <class _R1, class _R2>
377struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::type {};377struct ratio_subtract : public __ratio_subtract<_R1, _R2>::type {};
378378
379# endif // _LIBCPP_CXX03_LANG379# endif // _LIBCPP_CXX03_LANG
380380
381// ratio_equal381// ratio_equal
382382
383template <class _R1, class _R2>383template <class _R1, class _R2>
384struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {384struct ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {
385 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");385 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
386 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");386 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
387};387};
388388
389template <class _R1, class _R2>389template <class _R1, class _R2>
390struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {390struct ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {
391 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");391 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
392 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");392 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
393};393};
...@@ -441,25 +441,25 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> {...@@ -441,25 +441,25 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> {
441};441};
442442
443template <class _R1, class _R2>443template <class _R1, class _R2>
444struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {444struct ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {
445 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");445 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
446 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");446 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
447};447};
448448
449template <class _R1, class _R2>449template <class _R1, class _R2>
450struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {450struct ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {
451 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");451 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
452 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");452 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
453};453};
454454
455template <class _R1, class _R2>455template <class _R1, class _R2>
456struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {456struct ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {
457 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");457 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
458 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");458 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
459};459};
460460
461template <class _R1, class _R2>461template <class _R1, class _R2>
462struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {462struct ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {
463 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");463 static_assert(__is_ratio_v<_R1>, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
464 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");464 static_assert(__is_ratio_v<_R2>, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
465};465};
lib/libcxx/include/regex+248-241
...@@ -792,26 +792,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;...@@ -792,26 +792,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
792#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)792#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
793# include <__cxx03/regex>793# include <__cxx03/regex>
794#else794#else
795# include <__algorithm/find.h>
796# include <__algorithm/search.h>
797# include <__assert>
798# include <__config>795# include <__config>
799# include <__iterator/back_insert_iterator.h>
800# include <__iterator/default_sentinel.h>
801# include <__iterator/wrap_iter.h>
802# include <__locale>
803# include <__memory/shared_ptr.h>
804# include <__memory_resource/polymorphic_allocator.h>
805# include <__type_traits/is_swappable.h>
806# include <__utility/move.h>
807# include <__utility/pair.h>
808# include <__utility/swap.h>
809# include <__verbose_abort>
810# include <deque>
811# include <stdexcept>
812# include <string>
813# include <vector>
814# include <version>
815796
816// standard-mandated includes797// standard-mandated includes
817798
...@@ -826,14 +807,37 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;...@@ -826,14 +807,37 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
826# include <compare>807# include <compare>
827# include <initializer_list>808# include <initializer_list>
828809
829# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)810# if _LIBCPP_HAS_LOCALIZATION
830# pragma GCC system_header811
831# endif812# include <__algorithm/find.h>
813# include <__algorithm/search.h>
814# include <__assert>
815# include <__iterator/back_insert_iterator.h>
816# include <__iterator/default_sentinel.h>
817# include <__iterator/wrap_iter.h>
818# include <__locale>
819# include <__memory/addressof.h>
820# include <__memory/shared_ptr.h>
821# include <__memory_resource/polymorphic_allocator.h>
822# include <__type_traits/is_swappable.h>
823# include <__utility/move.h>
824# include <__utility/pair.h>
825# include <__utility/swap.h>
826# include <__verbose_abort>
827# include <deque>
828# include <stdexcept>
829# include <string>
830# include <vector>
831# include <version>
832
833# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
834# pragma GCC system_header
835# endif
832836
833_LIBCPP_PUSH_MACROS837_LIBCPP_PUSH_MACROS
834# include <__undef_macros>838# include <__undef_macros>
835839
836# define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096840# define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
837841
838_LIBCPP_BEGIN_NAMESPACE_STD842_LIBCPP_BEGIN_NAMESPACE_STD
839843
...@@ -846,11 +850,11 @@ enum syntax_option_type {...@@ -846,11 +850,11 @@ enum syntax_option_type {
846 nosubs = 1 << 1,850 nosubs = 1 << 1,
847 optimize = 1 << 2,851 optimize = 1 << 2,
848 collate = 1 << 3,852 collate = 1 << 3,
849# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO853# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
850 ECMAScript = 1 << 9,854 ECMAScript = 1 << 9,
851# else855# else
852 ECMAScript = 0,856 ECMAScript = 0,
853# endif857# endif
854 basic = 1 << 4,858 basic = 1 << 4,
855 extended = 1 << 5,859 extended = 1 << 5,
856 awk = 1 << 6,860 awk = 1 << 6,
...@@ -861,11 +865,11 @@ enum syntax_option_type {...@@ -861,11 +865,11 @@ enum syntax_option_type {
861};865};
862866
863_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) {867_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR syntax_option_type __get_grammar(syntax_option_type __g) {
864# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO868# ifdef _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
865 return static_cast<syntax_option_type>(__g & 0x3F0);869 return static_cast<syntax_option_type>(__g & 0x3F0);
866# else870# else
867 return static_cast<syntax_option_type>(__g & 0x1F0);871 return static_cast<syntax_option_type>(__g & 0x1F0);
868# endif872# endif
869}873}
870874
871inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) {875inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR syntax_option_type operator~(syntax_option_type __x) {
...@@ -987,20 +991,20 @@ public:...@@ -987,20 +991,20 @@ public:
987991
988template <regex_constants::error_type _Ev>992template <regex_constants::error_type _Ev>
989[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() {993[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() {
990# if _LIBCPP_HAS_EXCEPTIONS994# if _LIBCPP_HAS_EXCEPTIONS
991 throw regex_error(_Ev);995 throw regex_error(_Ev);
992# else996# else
993 _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode");997 _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode");
994# endif998# endif
995}999}
9961000
997template <class _CharT>1001template <class _CharT>
998struct _LIBCPP_TEMPLATE_VIS regex_traits {1002struct regex_traits {
999public:1003public:
1000 typedef _CharT char_type;1004 typedef _CharT char_type;
1001 typedef basic_string<char_type> string_type;1005 typedef basic_string<char_type> string_type;
1002 typedef locale locale_type;1006 typedef locale locale_type;
1003# if defined(__BIONIC__) || defined(_NEWLIB_VERSION)1007# if defined(__BIONIC__) || defined(_NEWLIB_VERSION)
1004 // Originally bionic's ctype_base used its own ctype masks because the1008 // Originally bionic's ctype_base used its own ctype masks because the
1005 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask1009 // builtin ctype implementation wasn't in libc++ yet. Bionic's ctype mask
1006 // was only 8 bits wide and already saturated, so it used a wider type here1010 // was only 8 bits wide and already saturated, so it used a wider type here
...@@ -1015,9 +1019,9 @@ public:...@@ -1015,9 +1019,9 @@ public:
1015 // often used for space constrained environments, so it makes sense not to1019 // often used for space constrained environments, so it makes sense not to
1016 // duplicate the ctype table.1020 // duplicate the ctype table.
1017 typedef uint16_t char_class_type;1021 typedef uint16_t char_class_type;
1018# else1022# else
1019 typedef ctype_base::mask char_class_type;1023 typedef ctype_base::mask char_class_type;
1020# endif1024# endif
10211025
1022 static const char_class_type __regex_word = ctype_base::__regex_word;1026 static const char_class_type __regex_word = ctype_base::__regex_word;
10231027
...@@ -1057,30 +1061,30 @@ private:...@@ -1057,30 +1061,30 @@ private:
10571061
1058 template <class _ForwardIterator>1062 template <class _ForwardIterator>
1059 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;1063 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, char) const;
1060# if _LIBCPP_HAS_WIDE_CHARACTERS1064# if _LIBCPP_HAS_WIDE_CHARACTERS
1061 template <class _ForwardIterator>1065 template <class _ForwardIterator>
1062 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1066 string_type __transform_primary(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1063# endif1067# endif
1064 template <class _ForwardIterator>1068 template <class _ForwardIterator>
1065 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;1069 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, char) const;
1066# if _LIBCPP_HAS_WIDE_CHARACTERS1070# if _LIBCPP_HAS_WIDE_CHARACTERS
1067 template <class _ForwardIterator>1071 template <class _ForwardIterator>
1068 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;1072 string_type __lookup_collatename(_ForwardIterator __f, _ForwardIterator __l, wchar_t) const;
1069# endif1073# endif
1070 template <class _ForwardIterator>1074 template <class _ForwardIterator>
1071 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const;1075 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const;
1072# if _LIBCPP_HAS_WIDE_CHARACTERS1076# if _LIBCPP_HAS_WIDE_CHARACTERS
1073 template <class _ForwardIterator>1077 template <class _ForwardIterator>
1074 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const;1078 char_class_type __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const;
1075# endif1079# endif
10761080
1077 static int __regex_traits_value(unsigned char __ch, int __radix);1081 static int __regex_traits_value(unsigned char __ch, int __radix);
1078 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const {1082 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(char __ch, int __radix) const {
1079 return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);1083 return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);
1080 }1084 }
1081# if _LIBCPP_HAS_WIDE_CHARACTERS1085# if _LIBCPP_HAS_WIDE_CHARACTERS
1082 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const;1086 _LIBCPP_HIDE_FROM_ABI int __regex_traits_value(wchar_t __ch, int __radix) const;
1083# endif1087# endif
1084};1088};
10851089
1086template <class _CharT>1090template <class _CharT>
...@@ -1106,8 +1110,8 @@ regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) cons...@@ -1106,8 +1110,8 @@ regex_traits<_CharT>::transform(_ForwardIterator __f, _ForwardIterator __l) cons
11061110
1107template <class _CharT>1111template <class _CharT>
1108void regex_traits<_CharT>::__init() {1112void regex_traits<_CharT>::__init() {
1109 __ct_ = &std::use_facet<ctype<char_type> >(__loc_);1113 __ct_ = std::addressof(std::use_facet<ctype<char_type> >(__loc_));
1110 __col_ = &std::use_facet<collate<char_type> >(__loc_);1114 __col_ = std::addressof(std::use_facet<collate<char_type> >(__loc_));
1111}1115}
11121116
1113template <class _CharT>1117template <class _CharT>
...@@ -1139,7 +1143,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator...@@ -1139,7 +1143,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator
1139 return __d;1143 return __d;
1140}1144}
11411145
1142# if _LIBCPP_HAS_WIDE_CHARACTERS1146# if _LIBCPP_HAS_WIDE_CHARACTERS
1143template <class _CharT>1147template <class _CharT>
1144template <class _ForwardIterator>1148template <class _ForwardIterator>
1145typename regex_traits<_CharT>::string_type1149typename regex_traits<_CharT>::string_type
...@@ -1158,7 +1162,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator...@@ -1158,7 +1162,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, _ForwardIterator
1158 }1162 }
1159 return __d;1163 return __d;
1160}1164}
1161# endif1165# endif
11621166
1163// lookup_collatename is very FreeBSD-specific1167// lookup_collatename is very FreeBSD-specific
11641168
...@@ -1183,7 +1187,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato...@@ -1183,7 +1187,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato
1183 return __r;1187 return __r;
1184}1188}
11851189
1186# if _LIBCPP_HAS_WIDE_CHARACTERS1190# if _LIBCPP_HAS_WIDE_CHARACTERS
1187template <class _CharT>1191template <class _CharT>
1188template <class _ForwardIterator>1192template <class _ForwardIterator>
1189typename regex_traits<_CharT>::string_type1193typename regex_traits<_CharT>::string_type
...@@ -1211,7 +1215,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato...@@ -1211,7 +1215,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, _ForwardIterato
1211 }1215 }
1212 return __r;1216 return __r;
1213}1217}
1214# endif // _LIBCPP_HAS_WIDE_CHARACTERS1218# endif // _LIBCPP_HAS_WIDE_CHARACTERS
12151219
1216// lookup_classname1220// lookup_classname
12171221
...@@ -1222,17 +1226,17 @@ template <class _ForwardIterator>...@@ -1222,17 +1226,17 @@ template <class _ForwardIterator>
1222typename regex_traits<_CharT>::char_class_type1226typename regex_traits<_CharT>::char_class_type
1223regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const {1227regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, char) const {
1224 string_type __s(__f, __l);1228 string_type __s(__f, __l);
1225 __ct_->tolower(&__s[0], &__s[0] + __s.size());1229 __ct_->tolower(std::addressof(__s[0]), std::addressof(__s[0]) + __s.size());
1226 return std::__get_classname(__s.c_str(), __icase);1230 return std::__get_classname(__s.c_str(), __icase);
1227}1231}
12281232
1229# if _LIBCPP_HAS_WIDE_CHARACTERS1233# if _LIBCPP_HAS_WIDE_CHARACTERS
1230template <class _CharT>1234template <class _CharT>
1231template <class _ForwardIterator>1235template <class _ForwardIterator>
1232typename regex_traits<_CharT>::char_class_type1236typename regex_traits<_CharT>::char_class_type
1233regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const {1237regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const {
1234 string_type __s(__f, __l);1238 string_type __s(__f, __l);
1235 __ct_->tolower(&__s[0], &__s[0] + __s.size());1239 __ct_->tolower(std::addressof(__s[0]), std::addressof(__s[0]) + __s.size());
1236 string __n;1240 string __n;
1237 __n.reserve(__s.size());1241 __n.reserve(__s.size());
1238 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); __i != __e; ++__i) {1242 for (typename string_type::const_iterator __i = __s.begin(), __e = __s.end(); __i != __e; ++__i) {
...@@ -1242,7 +1246,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator...@@ -1242,7 +1246,7 @@ regex_traits<_CharT>::__lookup_classname(_ForwardIterator __f, _ForwardIterator
1242 }1246 }
1243 return __get_classname(__n.c_str(), __icase);1247 return __get_classname(__n.c_str(), __icase);
1244}1248}
1245# endif // _LIBCPP_HAS_WIDE_CHARACTERS1249# endif // _LIBCPP_HAS_WIDE_CHARACTERS
12461250
1247template <class _CharT>1251template <class _CharT>
1248bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {1252bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {
...@@ -1253,28 +1257,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {...@@ -1253,28 +1257,28 @@ bool regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const {
12531257
1254inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) {1258inline _LIBCPP_HIDE_FROM_ABI bool __is_07(unsigned char __c) {
1255 return (__c & 0xF8u) ==1259 return (__c & 0xF8u) ==
1256# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1260# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1257 0xF0;1261 0xF0;
1258# else1262# else
1259 0x30;1263 0x30;
1260# endif1264# endif
1261}1265}
12621266
1263inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) {1267inline _LIBCPP_HIDE_FROM_ABI bool __is_89(unsigned char __c) {
1264 return (__c & 0xFEu) ==1268 return (__c & 0xFEu) ==
1265# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1269# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1266 0xF8;1270 0xF8;
1267# else1271# else
1268 0x38;1272 0x38;
1269# endif1273# endif
1270}1274}
12711275
1272inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) {1276inline _LIBCPP_HIDE_FROM_ABI unsigned char __to_lower(unsigned char __c) {
1273# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)1277# if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
1274 return __c & 0xBF;1278 return __c & 0xBF;
1275# else1279# else
1276 return __c | 0x20;1280 return __c | 0x20;
1277# endif1281# endif
1278}1282}
12791283
1280template <class _CharT>1284template <class _CharT>
...@@ -1293,21 +1297,21 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)...@@ -1293,21 +1297,21 @@ int regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix)
1293 return -1;1297 return -1;
1294}1298}
12951299
1296# if _LIBCPP_HAS_WIDE_CHARACTERS1300# if _LIBCPP_HAS_WIDE_CHARACTERS
1297template <class _CharT>1301template <class _CharT>
1298inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const {1302inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const {
1299 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);1303 return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix);
1300}1304}
1301# endif1305# endif
13021306
1303template <class _CharT>1307template <class _CharT>
1304class __node;1308class __node;
13051309
1306template <class _BidirectionalIterator>1310template <class _BidirectionalIterator>
1307class _LIBCPP_TEMPLATE_VIS sub_match;1311class sub_match;
13081312
1309template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > >1313template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > >
1310class _LIBCPP_TEMPLATE_VIS match_results;1314class match_results;
13111315
1312template <class _CharT>1316template <class _CharT>
1313struct __state {1317struct __state {
...@@ -1681,7 +1685,7 @@ public:...@@ -1681,7 +1685,7 @@ public:
1681template <class _CharT>1685template <class _CharT>
1682void __back_ref<_CharT>::__exec(__state& __s) const {1686void __back_ref<_CharT>::__exec(__state& __s) const {
1683 if (__mexp_ > __s.__sub_matches_.size())1687 if (__mexp_ > __s.__sub_matches_.size())
1684 __throw_regex_error<regex_constants::error_backref>();1688 std::__throw_regex_error<regex_constants::error_backref>();
1685 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_ - 1];1689 sub_match<const _CharT*>& __sm = __s.__sub_matches_[__mexp_ - 1];
1686 if (__sm.matched) {1690 if (__sm.matched) {
1687 ptrdiff_t __len = __sm.second - __sm.first;1691 ptrdiff_t __len = __sm.second - __sm.first;
...@@ -1941,10 +1945,10 @@ public:...@@ -1941,10 +1945,10 @@ public:
19411945
1942template <>1946template <>
1943_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const;1947_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<char>::__exec(__state&) const;
1944# if _LIBCPP_HAS_WIDE_CHARACTERS1948# if _LIBCPP_HAS_WIDE_CHARACTERS
1945template <>1949template <>
1946_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const;1950_LIBCPP_EXPORTED_FROM_ABI void __match_any_but_newline<wchar_t>::__exec(__state&) const;
1947# endif1951# endif
19481952
1949// __match_char1953// __match_char
19501954
...@@ -2117,7 +2121,7 @@ public:...@@ -2117,7 +2121,7 @@ public:
2117 std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end())));2121 std::make_pair(__traits_.transform(__b.begin(), __b.end()), __traits_.transform(__e.begin(), __e.end())));
2118 } else {2122 } else {
2119 if (__b.size() != 1 || __e.size() != 1)2123 if (__b.size() != 1 || __e.size() != 1)
2120 __throw_regex_error<regex_constants::error_range>();2124 std::__throw_regex_error<regex_constants::error_range>();
2121 if (__icase_) {2125 if (__icase_) {
2122 __b[0] = __traits_.translate_nocase(__b[0]);2126 __b[0] = __traits_.translate_nocase(__b[0]);
2123 __e[0] = __traits_.translate_nocase(__e[0]);2127 __e[0] = __traits_.translate_nocase(__e[0]);
...@@ -2157,7 +2161,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {...@@ -2157,7 +2161,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {
2157 __ch2.first = __traits_.translate(__ch2.first);2161 __ch2.first = __traits_.translate(__ch2.first);
2158 __ch2.second = __traits_.translate(__ch2.second);2162 __ch2.second = __traits_.translate(__ch2.second);
2159 }2163 }
2160 if (!__traits_.lookup_collatename(&__ch2.first, &__ch2.first + 2).empty()) {2164 if (!__traits_.lookup_collatename(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2).empty()) {
2161 // __ch2 is a digraph in this locale2165 // __ch2 is a digraph in this locale
2162 ++__consumed;2166 ++__consumed;
2163 for (size_t __i = 0; __i < __digraphs_.size(); ++__i) {2167 for (size_t __i = 0; __i < __digraphs_.size(); ++__i) {
...@@ -2167,7 +2171,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {...@@ -2167,7 +2171,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {
2167 }2171 }
2168 }2172 }
2169 if (__collate_ && !__ranges_.empty()) {2173 if (__collate_ && !__ranges_.empty()) {
2170 string_type __s2 = __traits_.transform(&__ch2.first, &__ch2.first + 2);2174 string_type __s2 = __traits_.transform(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2);
2171 for (size_t __i = 0; __i < __ranges_.size(); ++__i) {2175 for (size_t __i = 0; __i < __ranges_.size(); ++__i) {
2172 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) {2176 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) {
2173 __found = true;2177 __found = true;
...@@ -2176,7 +2180,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {...@@ -2176,7 +2180,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {
2176 }2180 }
2177 }2181 }
2178 if (!__equivalences_.empty()) {2182 if (!__equivalences_.empty()) {
2179 string_type __s2 = __traits_.transform_primary(&__ch2.first, &__ch2.first + 2);2183 string_type __s2 =
2184 __traits_.transform_primary(std::addressof(__ch2.first), std::addressof(__ch2.first) + 2);
2180 for (size_t __i = 0; __i < __equivalences_.size(); ++__i) {2185 for (size_t __i = 0; __i < __equivalences_.size(); ++__i) {
2181 if (__s2 == __equivalences_[__i]) {2186 if (__s2 == __equivalences_[__i]) {
2182 __found = true;2187 __found = true;
...@@ -2224,7 +2229,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {...@@ -2224,7 +2229,8 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {
2224 }2229 }
2225 }2230 }
2226 if (!__ranges_.empty()) {2231 if (!__ranges_.empty()) {
2227 string_type __s2 = __collate_ ? __traits_.transform(&__ch, &__ch + 1) : string_type(1, __ch);2232 string_type __s2 =
2233 __collate_ ? __traits_.transform(std::addressof(__ch), std::addressof(__ch) + 1) : string_type(1, __ch);
2228 for (size_t __i = 0; __i < __ranges_.size(); ++__i) {2234 for (size_t __i = 0; __i < __ranges_.size(); ++__i) {
2229 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) {2235 if (__ranges_[__i].first <= __s2 && __s2 <= __ranges_[__i].second) {
2230 __found = true;2236 __found = true;
...@@ -2233,7 +2239,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {...@@ -2233,7 +2239,7 @@ void __bracket_expression<_CharT, _Traits>::__exec(__state& __s) const {
2233 }2239 }
2234 }2240 }
2235 if (!__equivalences_.empty()) {2241 if (!__equivalences_.empty()) {
2236 string_type __s2 = __traits_.transform_primary(&__ch, &__ch + 1);2242 string_type __s2 = __traits_.transform_primary(std::addressof(__ch), std::addressof(__ch) + 1);
2237 for (size_t __i = 0; __i < __equivalences_.size(); ++__i) {2243 for (size_t __i = 0; __i < __equivalences_.size(); ++__i) {
2238 if (__s2 == __equivalences_[__i]) {2244 if (__s2 == __equivalences_[__i]) {
2239 __found = true;2245 __found = true;
...@@ -2262,16 +2268,15 @@ template <class _CharT, class _Traits>...@@ -2262,16 +2268,15 @@ template <class _CharT, class _Traits>
2262class __lookahead;2268class __lookahead;
22632269
2264template <class _CharT, class _Traits = regex_traits<_CharT> >2270template <class _CharT, class _Traits = regex_traits<_CharT> >
2265class _LIBCPP_TEMPLATE_VIS basic_regex;2271class basic_regex;
22662272
2267typedef basic_regex<char> regex;2273typedef basic_regex<char> regex;
2268# if _LIBCPP_HAS_WIDE_CHARACTERS2274# if _LIBCPP_HAS_WIDE_CHARACTERS
2269typedef basic_regex<wchar_t> wregex;2275typedef basic_regex<wchar_t> wregex;
2270# endif2276# endif
22712277
2272template <class _CharT, class _Traits>2278template <class _CharT, class _Traits>
2273class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(regex)2279class _LIBCPP_PREFERRED_NAME(regex) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) basic_regex {
2274 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wregex)) basic_regex {
2275public:2280public:
2276 // types:2281 // types:
2277 typedef _CharT value_type;2282 typedef _CharT value_type;
...@@ -2338,21 +2343,21 @@ public:...@@ -2338,21 +2343,21 @@ public:
2338 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {2343 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {
2339 __init(__first, __last);2344 __init(__first, __last);
2340 }2345 }
2341# ifndef _LIBCPP_CXX03_LANG2346# ifndef _LIBCPP_CXX03_LANG
2342 _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript)2347 _LIBCPP_HIDE_FROM_ABI basic_regex(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript)
2343 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {2348 : __flags_(__f), __marked_count_(0), __loop_count_(0), __open_count_(0), __end_(nullptr) {
2344 __init(__il.begin(), __il.end());2349 __init(__il.begin(), __il.end());
2345 }2350 }
2346# endif // _LIBCPP_CXX03_LANG2351# endif // _LIBCPP_CXX03_LANG
23472352
2348 // ~basic_regex() = default;2353 // ~basic_regex() = default;
23492354
2350 // basic_regex& operator=(const basic_regex&) = default;2355 // basic_regex& operator=(const basic_regex&) = default;
2351 // basic_regex& operator=(basic_regex&&) = default;2356 // basic_regex& operator=(basic_regex&&) = default;
2352 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); }2357 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const value_type* __p) { return assign(__p); }
2353# ifndef _LIBCPP_CXX03_LANG2358# ifndef _LIBCPP_CXX03_LANG
2354 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); }2359 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(initializer_list<value_type> __il) { return assign(__il); }
2355# endif // _LIBCPP_CXX03_LANG2360# endif // _LIBCPP_CXX03_LANG
2356 template <class _ST, class _SA>2361 template <class _ST, class _SA>
2357 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) {2362 _LIBCPP_HIDE_FROM_ABI basic_regex& operator=(const basic_string<value_type, _ST, _SA>& __p) {
2358 return assign(__p);2363 return assign(__p);
...@@ -2360,9 +2365,9 @@ public:...@@ -2360,9 +2365,9 @@ public:
23602365
2361 // assign:2366 // assign:
2362 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; }2367 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const basic_regex& __that) { return *this = __that; }
2363# ifndef _LIBCPP_CXX03_LANG2368# ifndef _LIBCPP_CXX03_LANG
2364 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); }2369 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(basic_regex&& __that) _NOEXCEPT { return *this = std::move(__that); }
2365# endif2370# endif
2366 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) {2371 _LIBCPP_HIDE_FROM_ABI basic_regex& assign(const value_type* __p, flag_type __f = regex_constants::ECMAScript) {
2367 return assign(__p, __p + __traits_.length(__p), __f);2372 return assign(__p, __p + __traits_.length(__p), __f);
2368 }2373 }
...@@ -2399,14 +2404,14 @@ public:...@@ -2399,14 +2404,14 @@ public:
2399 return assign(basic_regex(__first, __last, __f));2404 return assign(basic_regex(__first, __last, __f));
2400 }2405 }
24012406
2402# ifndef _LIBCPP_CXX03_LANG2407# ifndef _LIBCPP_CXX03_LANG
24032408
2404 _LIBCPP_HIDE_FROM_ABI basic_regex&2409 _LIBCPP_HIDE_FROM_ABI basic_regex&
2405 assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) {2410 assign(initializer_list<value_type> __il, flag_type __f = regex_constants::ECMAScript) {
2406 return assign(__il.begin(), __il.end(), __f);2411 return assign(__il.begin(), __il.end(), __f);
2407 }2412 }
24082413
2409# endif // _LIBCPP_CXX03_LANG2414# endif // _LIBCPP_CXX03_LANG
24102415
2411 // const operations:2416 // const operations:
2412 _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; }2417 _LIBCPP_HIDE_FROM_ABI unsigned mark_count() const { return __marked_count_; }
...@@ -2647,11 +2652,11 @@ private:...@@ -2647,11 +2652,11 @@ private:
2647 friend class __lookahead;2652 friend class __lookahead;
2648};2653};
26492654
2650# if _LIBCPP_STD_VER >= 172655# if _LIBCPP_STD_VER >= 17
2651template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>2656template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
2652basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript)2657basic_regex(_ForwardIterator, _ForwardIterator, regex_constants::syntax_option_type = regex_constants::ECMAScript)
2653 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;2658 -> basic_regex<typename iterator_traits<_ForwardIterator>::value_type>;
2654# endif2659# endif
26552660
2656template <class _CharT, class _Traits>2661template <class _CharT, class _Traits>
2657const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;2662const regex_constants::syntax_option_type basic_regex<_CharT, _Traits>::icase;
...@@ -2743,7 +2748,7 @@ void basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIter...@@ -2743,7 +2748,7 @@ void basic_regex<_CharT, _Traits>::__init(_ForwardIterator __first, _ForwardIter
2743 __flags_ |= regex_constants::ECMAScript;2748 __flags_ |= regex_constants::ECMAScript;
2744 _ForwardIterator __temp = __parse(__first, __last);2749 _ForwardIterator __temp = __parse(__first, __last);
2745 if (__temp != __last)2750 if (__temp != __last)
2746 __throw_regex_error<regex_constants::__re_err_parse>();2751 std::__throw_regex_error<regex_constants::__re_err_parse>();
2747}2752}
27482753
2749template <class _CharT, class _Traits>2754template <class _CharT, class _Traits>
...@@ -2773,7 +2778,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,...@@ -2773,7 +2778,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first,
2773 __first = __parse_egrep(__first, __last);2778 __first = __parse_egrep(__first, __last);
2774 break;2779 break;
2775 default:2780 default:
2776 __throw_regex_error<regex_constants::__re_err_grammar>();2781 std::__throw_regex_error<regex_constants::__re_err_grammar>();
2777 }2782 }
2778 return __first;2783 return __first;
2779}2784}
...@@ -2798,7 +2803,7 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, _F...@@ -2798,7 +2803,7 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, _F
2798 }2803 }
2799 }2804 }
2800 if (__first != __last)2805 if (__first != __last)
2801 __throw_regex_error<regex_constants::__re_err_empty>();2806 std::__throw_regex_error<regex_constants::__re_err_empty>();
2802 }2807 }
2803 return __first;2808 return __first;
2804}2809}
...@@ -2810,13 +2815,13 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,...@@ -2810,13 +2815,13 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first,
2810 __owns_one_state<_CharT>* __sa = __end_;2815 __owns_one_state<_CharT>* __sa = __end_;
2811 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);2816 _ForwardIterator __temp = __parse_ERE_branch(__first, __last);
2812 if (__temp == __first)2817 if (__temp == __first)
2813 __throw_regex_error<regex_constants::__re_err_empty>();2818 std::__throw_regex_error<regex_constants::__re_err_empty>();
2814 __first = __temp;2819 __first = __temp;
2815 while (__first != __last && *__first == '|') {2820 while (__first != __last && *__first == '|') {
2816 __owns_one_state<_CharT>* __sb = __end_;2821 __owns_one_state<_CharT>* __sb = __end_;
2817 __temp = __parse_ERE_branch(++__first, __last);2822 __temp = __parse_ERE_branch(++__first, __last);
2818 if (__temp == __first)2823 if (__temp == __first)
2819 __throw_regex_error<regex_constants::__re_err_empty>();2824 std::__throw_regex_error<regex_constants::__re_err_empty>();
2820 __push_alternation(__sa, __sb);2825 __push_alternation(__sa, __sb);
2821 __first = __temp;2826 __first = __temp;
2822 }2827 }
...@@ -2828,7 +2833,7 @@ template <class _ForwardIterator>...@@ -2828,7 +2833,7 @@ template <class _ForwardIterator>
2828_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) {2833_ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) {
2829 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);2834 _ForwardIterator __temp = __parse_ERE_expression(__first, __last);
2830 if (__temp == __first)2835 if (__temp == __first)
2831 __throw_regex_error<regex_constants::__re_err_empty>();2836 std::__throw_regex_error<regex_constants::__re_err_empty>();
2832 do {2837 do {
2833 __first = __temp;2838 __first = __temp;
2834 __temp = __parse_ERE_expression(__first, __last);2839 __temp = __parse_ERE_expression(__first, __last);
...@@ -2859,7 +2864,7 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, _...@@ -2859,7 +2864,7 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, _
2859 ++__open_count_;2864 ++__open_count_;
2860 __temp = __parse_extended_reg_exp(++__temp, __last);2865 __temp = __parse_extended_reg_exp(++__temp, __last);
2861 if (__temp == __last || *__temp != ')')2866 if (__temp == __last || *__temp != ')')
2862 __throw_regex_error<regex_constants::error_paren>();2867 std::__throw_regex_error<regex_constants::error_paren>();
2863 __push_end_marked_subexpression(__temp_count);2868 __push_end_marked_subexpression(__temp_count);
2864 --__open_count_;2869 --__open_count_;
2865 ++__temp;2870 ++__temp;
...@@ -2911,7 +2916,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterat...@@ -2911,7 +2916,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterat
2911 __first = __parse_RE_expression(__temp, __last);2916 __first = __parse_RE_expression(__temp, __last);
2912 __temp = __parse_Back_close_paren(__first, __last);2917 __temp = __parse_Back_close_paren(__first, __last);
2913 if (__temp == __first)2918 if (__temp == __first)
2914 __throw_regex_error<regex_constants::error_paren>();2919 std::__throw_regex_error<regex_constants::error_paren>();
2915 __push_end_marked_subexpression(__temp_count);2920 __push_end_marked_subexpression(__temp_count);
2916 __first = __temp;2921 __first = __temp;
2917 } else2922 } else
...@@ -3154,14 +3159,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(...@@ -3154,14 +3159,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(
3154 __first = __temp;3159 __first = __temp;
3155 __temp = __parse_DUP_COUNT(__first, __last, __min);3160 __temp = __parse_DUP_COUNT(__first, __last, __min);
3156 if (__temp == __first)3161 if (__temp == __first)
3157 __throw_regex_error<regex_constants::error_badbrace>();3162 std::__throw_regex_error<regex_constants::error_badbrace>();
3158 __first = __temp;3163 __first = __temp;
3159 if (__first == __last)3164 if (__first == __last)
3160 __throw_regex_error<regex_constants::error_brace>();3165 std::__throw_regex_error<regex_constants::error_brace>();
3161 if (*__first != ',') {3166 if (*__first != ',') {
3162 __temp = __parse_Back_close_brace(__first, __last);3167 __temp = __parse_Back_close_brace(__first, __last);
3163 if (__temp == __first)3168 if (__temp == __first)
3164 __throw_regex_error<regex_constants::error_brace>();3169 std::__throw_regex_error<regex_constants::error_brace>();
3165 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true);3170 __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true);
3166 __first = __temp;3171 __first = __temp;
3167 } else {3172 } else {
...@@ -3170,12 +3175,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(...@@ -3170,12 +3175,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(
3170 __first = __parse_DUP_COUNT(__first, __last, __max);3175 __first = __parse_DUP_COUNT(__first, __last, __max);
3171 __temp = __parse_Back_close_brace(__first, __last);3176 __temp = __parse_Back_close_brace(__first, __last);
3172 if (__temp == __first)3177 if (__temp == __first)
3173 __throw_regex_error<regex_constants::error_brace>();3178 std::__throw_regex_error<regex_constants::error_brace>();
3174 if (__max == -1)3179 if (__max == -1)
3175 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);3180 __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end);
3176 else {3181 else {
3177 if (__max < __min)3182 if (__max < __min)
3178 __throw_regex_error<regex_constants::error_badbrace>();3183 std::__throw_regex_error<regex_constants::error_badbrace>();
3179 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true);3184 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true);
3180 }3185 }
3181 __first = __temp;3186 __first = __temp;
...@@ -3225,10 +3230,10 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(...@@ -3225,10 +3230,10 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(
3225 int __min;3230 int __min;
3226 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);3231 _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min);
3227 if (__temp == __first)3232 if (__temp == __first)
3228 __throw_regex_error<regex_constants::error_badbrace>();3233 std::__throw_regex_error<regex_constants::error_badbrace>();
3229 __first = __temp;3234 __first = __temp;
3230 if (__first == __last)3235 if (__first == __last)
3231 __throw_regex_error<regex_constants::error_brace>();3236 std::__throw_regex_error<regex_constants::error_brace>();
3232 switch (*__first) {3237 switch (*__first) {
3233 case '}':3238 case '}':
3234 ++__first;3239 ++__first;
...@@ -3241,7 +3246,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(...@@ -3241,7 +3246,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(
3241 case ',':3246 case ',':
3242 ++__first;3247 ++__first;
3243 if (__first == __last)3248 if (__first == __last)
3244 __throw_regex_error<regex_constants::error_badbrace>();3249 std::__throw_regex_error<regex_constants::error_badbrace>();
3245 if (*__first == '}') {3250 if (*__first == '}') {
3246 ++__first;3251 ++__first;
3247 if (__grammar == ECMAScript && __first != __last && *__first == '?') {3252 if (__grammar == ECMAScript && __first != __last && *__first == '?') {
...@@ -3253,13 +3258,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(...@@ -3253,13 +3258,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(
3253 int __max = -1;3258 int __max = -1;
3254 __temp = __parse_DUP_COUNT(__first, __last, __max);3259 __temp = __parse_DUP_COUNT(__first, __last, __max);
3255 if (__temp == __first)3260 if (__temp == __first)
3256 __throw_regex_error<regex_constants::error_brace>();3261 std::__throw_regex_error<regex_constants::error_brace>();
3257 __first = __temp;3262 __first = __temp;
3258 if (__first == __last || *__first != '}')3263 if (__first == __last || *__first != '}')
3259 __throw_regex_error<regex_constants::error_brace>();3264 std::__throw_regex_error<regex_constants::error_brace>();
3260 ++__first;3265 ++__first;
3261 if (__max < __min)3266 if (__max < __min)
3262 __throw_regex_error<regex_constants::error_badbrace>();3267 std::__throw_regex_error<regex_constants::error_badbrace>();
3263 if (__grammar == ECMAScript && __first != __last && *__first == '?') {3268 if (__grammar == ECMAScript && __first != __last && *__first == '?') {
3264 ++__first;3269 ++__first;
3265 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);3270 __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, false);
...@@ -3268,7 +3273,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(...@@ -3268,7 +3273,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(
3268 }3273 }
3269 break;3274 break;
3270 default:3275 default:
3271 __throw_regex_error<regex_constants::error_badbrace>();3276 std::__throw_regex_error<regex_constants::error_badbrace>();
3272 }3277 }
3273 } break;3278 } break;
3274 }3279 }
...@@ -3283,7 +3288,7 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs...@@ -3283,7 +3288,7 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
3283 if (__first != __last && *__first == '[') {3288 if (__first != __last && *__first == '[') {
3284 ++__first;3289 ++__first;
3285 if (__first == __last)3290 if (__first == __last)
3286 __throw_regex_error<regex_constants::error_brack>();3291 std::__throw_regex_error<regex_constants::error_brack>();
3287 bool __negate = false;3292 bool __negate = false;
3288 if (*__first == '^') {3293 if (*__first == '^') {
3289 ++__first;3294 ++__first;
...@@ -3292,20 +3297,20 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs...@@ -3292,20 +3297,20 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs
3292 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);3297 __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate);
3293 // __ml owned by *this3298 // __ml owned by *this
3294 if (__first == __last)3299 if (__first == __last)
3295 __throw_regex_error<regex_constants::error_brack>();3300 std::__throw_regex_error<regex_constants::error_brack>();
3296 if (__get_grammar(__flags_) != ECMAScript && *__first == ']') {3301 if (__get_grammar(__flags_) != ECMAScript && *__first == ']') {
3297 __ml->__add_char(']');3302 __ml->__add_char(']');
3298 ++__first;3303 ++__first;
3299 }3304 }
3300 __first = __parse_follow_list(__first, __last, __ml);3305 __first = __parse_follow_list(__first, __last, __ml);
3301 if (__first == __last)3306 if (__first == __last)
3302 __throw_regex_error<regex_constants::error_brack>();3307 std::__throw_regex_error<regex_constants::error_brack>();
3303 if (*__first == '-') {3308 if (*__first == '-') {
3304 __ml->__add_char('-');3309 __ml->__add_char('-');
3305 ++__first;3310 ++__first;
3306 }3311 }
3307 if (__first == __last || *__first != ']')3312 if (__first == __last || *__first != ']')
3308 __throw_regex_error<regex_constants::error_brack>();3313 std::__throw_regex_error<regex_constants::error_brack>();
3309 ++__first;3314 ++__first;
3310 }3315 }
3311 return __first;3316 return __first;
...@@ -3347,7 +3352,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term(...@@ -3347,7 +3352,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term(
3347 if (__grammar == ECMAScript)3352 if (__grammar == ECMAScript)
3348 __first = __parse_class_escape(++__first, __last, __start_range, __ml);3353 __first = __parse_class_escape(++__first, __last, __start_range, __ml);
3349 else3354 else
3350 __first = __parse_awk_escape(++__first, __last, &__start_range);3355 __first = __parse_awk_escape(++__first, __last, std::addressof(__start_range));
3351 } else {3356 } else {
3352 __start_range = *__first;3357 __start_range = *__first;
3353 ++__first;3358 ++__first;
...@@ -3367,7 +3372,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term(...@@ -3367,7 +3372,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_expression_term(
3367 if (__grammar == ECMAScript)3372 if (__grammar == ECMAScript)
3368 __first = __parse_class_escape(++__first, __last, __end_range, __ml);3373 __first = __parse_class_escape(++__first, __last, __end_range, __ml);
3369 else3374 else
3370 __first = __parse_awk_escape(++__first, __last, &__end_range);3375 __first = __parse_awk_escape(++__first, __last, std::addressof(__end_range));
3371 } else {3376 } else {
3372 __end_range = *__first;3377 __end_range = *__first;
3373 ++__first;3378 ++__first;
...@@ -3398,7 +3403,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape(...@@ -3398,7 +3403,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape(
3398 basic_string<_CharT>& __str,3403 basic_string<_CharT>& __str,
3399 __bracket_expression<_CharT, _Traits>* __ml) {3404 __bracket_expression<_CharT, _Traits>* __ml) {
3400 if (__first == __last)3405 if (__first == __last)
3401 __throw_regex_error<regex_constants::error_escape>();3406 std::__throw_regex_error<regex_constants::error_escape>();
3402 switch (*__first) {3407 switch (*__first) {
3403 case 0:3408 case 0:
3404 __str = *__first;3409 __str = *__first;
...@@ -3427,7 +3432,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape(...@@ -3427,7 +3432,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_class_escape(
3427 __ml->__add_neg_char('_');3432 __ml->__add_neg_char('_');
3428 return ++__first;3433 return ++__first;
3429 }3434 }
3430 __first = __parse_character_escape(__first, __last, &__str);3435 __first = __parse_character_escape(__first, __last, std::addressof(__str));
3431 return __first;3436 return __first;
3432}3437}
34333438
...@@ -3436,7 +3441,7 @@ template <class _ForwardIterator>...@@ -3436,7 +3441,7 @@ template <class _ForwardIterator>
3436_ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape(3441_ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape(
3437 _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) {3442 _ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) {
3438 if (__first == __last)3443 if (__first == __last)
3439 __throw_regex_error<regex_constants::error_escape>();3444 std::__throw_regex_error<regex_constants::error_escape>();
3440 switch (*__first) {3445 switch (*__first) {
3441 case '\\':3446 case '\\':
3442 case '"':3447 case '"':
...@@ -3501,7 +3506,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape(...@@ -3501,7 +3506,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_awk_escape(
3501 else3506 else
3502 __push_char(_CharT(__val));3507 __push_char(_CharT(__val));
3503 } else3508 } else
3504 __throw_regex_error<regex_constants::error_escape>();3509 std::__throw_regex_error<regex_constants::error_escape>();
3505 return __first;3510 return __first;
3506}3511}
35073512
...@@ -3514,11 +3519,11 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class(...@@ -3514,11 +3519,11 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class(
3514 value_type __equal_close[2] = {'=', ']'};3519 value_type __equal_close[2] = {'=', ']'};
3515 _ForwardIterator __temp = std::search(__first, __last, __equal_close, __equal_close + 2);3520 _ForwardIterator __temp = std::search(__first, __last, __equal_close, __equal_close + 2);
3516 if (__temp == __last)3521 if (__temp == __last)
3517 __throw_regex_error<regex_constants::error_brack>();3522 std::__throw_regex_error<regex_constants::error_brack>();
3518 // [__first, __temp) contains all text in [= ... =]3523 // [__first, __temp) contains all text in [= ... =]
3519 string_type __collate_name = __traits_.lookup_collatename(__first, __temp);3524 string_type __collate_name = __traits_.lookup_collatename(__first, __temp);
3520 if (__collate_name.empty())3525 if (__collate_name.empty())
3521 __throw_regex_error<regex_constants::error_collate>();3526 std::__throw_regex_error<regex_constants::error_collate>();
3522 string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end());3527 string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end());
3523 if (!__equiv_name.empty())3528 if (!__equiv_name.empty())
3524 __ml->__add_equivalence(__equiv_name);3529 __ml->__add_equivalence(__equiv_name);
...@@ -3531,7 +3536,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class(...@@ -3531,7 +3536,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_equivalence_class(
3531 __ml->__add_digraph(__collate_name[0], __collate_name[1]);3536 __ml->__add_digraph(__collate_name[0], __collate_name[1]);
3532 break;3537 break;
3533 default:3538 default:
3534 __throw_regex_error<regex_constants::error_collate>();3539 std::__throw_regex_error<regex_constants::error_collate>();
3535 }3540 }
3536 }3541 }
3537 __first = std::next(__temp, 2);3542 __first = std::next(__temp, 2);
...@@ -3547,12 +3552,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_class(...@@ -3547,12 +3552,12 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_class(
3547 value_type __colon_close[2] = {':', ']'};3552 value_type __colon_close[2] = {':', ']'};
3548 _ForwardIterator __temp = std::search(__first, __last, __colon_close, __colon_close + 2);3553 _ForwardIterator __temp = std::search(__first, __last, __colon_close, __colon_close + 2);
3549 if (__temp == __last)3554 if (__temp == __last)
3550 __throw_regex_error<regex_constants::error_brack>();3555 std::__throw_regex_error<regex_constants::error_brack>();
3551 // [__first, __temp) contains all text in [: ... :]3556 // [__first, __temp) contains all text in [: ... :]
3552 typedef typename _Traits::char_class_type char_class_type;3557 typedef typename _Traits::char_class_type char_class_type;
3553 char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase);3558 char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase);
3554 if (__class_type == 0)3559 if (__class_type == 0)
3555 __throw_regex_error<regex_constants::error_ctype>();3560 std::__throw_regex_error<regex_constants::error_ctype>();
3556 __ml->__add_class(__class_type);3561 __ml->__add_class(__class_type);
3557 __first = std::next(__temp, 2);3562 __first = std::next(__temp, 2);
3558 return __first;3563 return __first;
...@@ -3567,7 +3572,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol(...@@ -3567,7 +3572,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol(
3567 value_type __dot_close[2] = {'.', ']'};3572 value_type __dot_close[2] = {'.', ']'};
3568 _ForwardIterator __temp = std::search(__first, __last, __dot_close, __dot_close + 2);3573 _ForwardIterator __temp = std::search(__first, __last, __dot_close, __dot_close + 2);
3569 if (__temp == __last)3574 if (__temp == __last)
3570 __throw_regex_error<regex_constants::error_brack>();3575 std::__throw_regex_error<regex_constants::error_brack>();
3571 // [__first, __temp) contains all text in [. ... .]3576 // [__first, __temp) contains all text in [. ... .]
3572 __col_sym = __traits_.lookup_collatename(__first, __temp);3577 __col_sym = __traits_.lookup_collatename(__first, __temp);
3573 switch (__col_sym.size()) {3578 switch (__col_sym.size()) {
...@@ -3575,7 +3580,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol(...@@ -3575,7 +3580,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_collating_symbol(
3575 case 2:3580 case 2:
3576 break;3581 break;
3577 default:3582 default:
3578 __throw_regex_error<regex_constants::error_collate>();3583 std::__throw_regex_error<regex_constants::error_collate>();
3579 }3584 }
3580 __first = std::next(__temp, 2);3585 __first = std::next(__temp, 2);
3581 return __first;3586 return __first;
...@@ -3591,7 +3596,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _Forwa...@@ -3591,7 +3596,7 @@ basic_regex<_CharT, _Traits>::__parse_DUP_COUNT(_ForwardIterator __first, _Forwa
3591 __c = __val;3596 __c = __val;
3592 for (++__first; __first != __last && (__val = __traits_.value(*__first, 10)) != -1; ++__first) {3597 for (++__first; __first != __last && (__val = __traits_.value(*__first, 10)) != -1; ++__first) {
3593 if (__c >= numeric_limits<int>::max() / 10)3598 if (__c >= numeric_limits<int>::max() / 10)
3594 __throw_regex_error<regex_constants::error_badbrace>();3599 std::__throw_regex_error<regex_constants::error_badbrace>();
3595 __c *= 10;3600 __c *= 10;
3596 __c += __val;3601 __c += __val;
3597 }3602 }
...@@ -3684,7 +3689,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato...@@ -3684,7 +3689,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato
3684 __push_lookahead(std::move(__exp), false, __marked_count_);3689 __push_lookahead(std::move(__exp), false, __marked_count_);
3685 __marked_count_ += __mexp;3690 __marked_count_ += __mexp;
3686 if (__temp == __last || *__temp != ')')3691 if (__temp == __last || *__temp != ')')
3687 __throw_regex_error<regex_constants::error_paren>();3692 std::__throw_regex_error<regex_constants::error_paren>();
3688 __first = ++__temp;3693 __first = ++__temp;
3689 } break;3694 } break;
3690 case '!': {3695 case '!': {
...@@ -3695,7 +3700,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato...@@ -3695,7 +3700,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterato
3695 __push_lookahead(std::move(__exp), true, __marked_count_);3700 __push_lookahead(std::move(__exp), true, __marked_count_);
3696 __marked_count_ += __mexp;3701 __marked_count_ += __mexp;
3697 if (__temp == __last || *__temp != ')')3702 if (__temp == __last || *__temp != ')')
3698 __throw_regex_error<regex_constants::error_paren>();3703 std::__throw_regex_error<regex_constants::error_paren>();
3699 __first = ++__temp;3704 __first = ++__temp;
3700 } break;3705 } break;
3701 }3706 }
...@@ -3725,13 +3730,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f...@@ -3725,13 +3730,13 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f
3725 case '(': {3730 case '(': {
3726 ++__first;3731 ++__first;
3727 if (__first == __last)3732 if (__first == __last)
3728 __throw_regex_error<regex_constants::error_paren>();3733 std::__throw_regex_error<regex_constants::error_paren>();
3729 _ForwardIterator __temp = std::next(__first);3734 _ForwardIterator __temp = std::next(__first);
3730 if (__temp != __last && *__first == '?' && *__temp == ':') {3735 if (__temp != __last && *__first == '?' && *__temp == ':') {
3731 ++__open_count_;3736 ++__open_count_;
3732 __first = __parse_ecma_exp(++__temp, __last);3737 __first = __parse_ecma_exp(++__temp, __last);
3733 if (__first == __last || *__first != ')')3738 if (__first == __last || *__first != ')')
3734 __throw_regex_error<regex_constants::error_paren>();3739 std::__throw_regex_error<regex_constants::error_paren>();
3735 --__open_count_;3740 --__open_count_;
3736 ++__first;3741 ++__first;
3737 } else {3742 } else {
...@@ -3740,7 +3745,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f...@@ -3740,7 +3745,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f
3740 ++__open_count_;3745 ++__open_count_;
3741 __first = __parse_ecma_exp(__first, __last);3746 __first = __parse_ecma_exp(__first, __last);
3742 if (__first == __last || *__first != ')')3747 if (__first == __last || *__first != ')')
3743 __throw_regex_error<regex_constants::error_paren>();3748 std::__throw_regex_error<regex_constants::error_paren>();
3744 __push_end_marked_subexpression(__temp_count);3749 __push_end_marked_subexpression(__temp_count);
3745 --__open_count_;3750 --__open_count_;
3746 ++__first;3751 ++__first;
...@@ -3750,7 +3755,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f...@@ -3750,7 +3755,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __f
3750 case '+':3755 case '+':
3751 case '?':3756 case '?':
3752 case '{':3757 case '{':
3753 __throw_regex_error<regex_constants::error_badrepeat>();3758 std::__throw_regex_error<regex_constants::error_badrepeat>();
3754 break;3759 break;
3755 default:3760 default:
3756 __first = __parse_pattern_character(__first, __last);3761 __first = __parse_pattern_character(__first, __last);
...@@ -3766,7 +3771,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardItera...@@ -3766,7 +3771,7 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardItera
3766 if (__first != __last && *__first == '\\') {3771 if (__first != __last && *__first == '\\') {
3767 _ForwardIterator __t1 = std::next(__first);3772 _ForwardIterator __t1 = std::next(__first);
3768 if (__t1 == __last)3773 if (__t1 == __last)
3769 __throw_regex_error<regex_constants::error_escape>();3774 std::__throw_regex_error<regex_constants::error_escape>();
37703775
3771 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);3776 _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last);
3772 if (__t2 != __t1)3777 if (__t2 != __t1)
...@@ -3797,11 +3802,11 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, _...@@ -3797,11 +3802,11 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, _
3797 unsigned __v = *__first - '0';3802 unsigned __v = *__first - '0';
3798 for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; ++__first) {3803 for (++__first; __first != __last && '0' <= *__first && *__first <= '9'; ++__first) {
3799 if (__v >= numeric_limits<unsigned>::max() / 10)3804 if (__v >= numeric_limits<unsigned>::max() / 10)
3800 __throw_regex_error<regex_constants::error_backref>();3805 std::__throw_regex_error<regex_constants::error_backref>();
3801 __v = 10 * __v + *__first - '0';3806 __v = 10 * __v + *__first - '0';
3802 }3807 }
3803 if (__v == 0 || __v > mark_count())3808 if (__v == 0 || __v > mark_count())
3804 __throw_regex_error<regex_constants::error_backref>();3809 std::__throw_regex_error<regex_constants::error_backref>();
3805 __push_back_ref(__v);3810 __push_back_ref(__v);
3806 }3811 }
3807 }3812 }
...@@ -3905,40 +3910,40 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(...@@ -3905,40 +3910,40 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
3905 __push_char(_CharT(*__t % 32));3910 __push_char(_CharT(*__t % 32));
3906 __first = ++__t;3911 __first = ++__t;
3907 } else3912 } else
3908 __throw_regex_error<regex_constants::error_escape>();3913 std::__throw_regex_error<regex_constants::error_escape>();
3909 } else3914 } else
3910 __throw_regex_error<regex_constants::error_escape>();3915 std::__throw_regex_error<regex_constants::error_escape>();
3911 break;3916 break;
3912 case 'u':3917 case 'u':
3913 ++__first;3918 ++__first;
3914 if (__first == __last)3919 if (__first == __last)
3915 __throw_regex_error<regex_constants::error_escape>();3920 std::__throw_regex_error<regex_constants::error_escape>();
3916 __hd = __traits_.value(*__first, 16);3921 __hd = __traits_.value(*__first, 16);
3917 if (__hd == -1)3922 if (__hd == -1)
3918 __throw_regex_error<regex_constants::error_escape>();3923 std::__throw_regex_error<regex_constants::error_escape>();
3919 __sum = 16 * __sum + static_cast<unsigned>(__hd);3924 __sum = 16 * __sum + static_cast<unsigned>(__hd);
3920 ++__first;3925 ++__first;
3921 if (__first == __last)3926 if (__first == __last)
3922 __throw_regex_error<regex_constants::error_escape>();3927 std::__throw_regex_error<regex_constants::error_escape>();
3923 __hd = __traits_.value(*__first, 16);3928 __hd = __traits_.value(*__first, 16);
3924 if (__hd == -1)3929 if (__hd == -1)
3925 __throw_regex_error<regex_constants::error_escape>();3930 std::__throw_regex_error<regex_constants::error_escape>();
3926 __sum = 16 * __sum + static_cast<unsigned>(__hd);3931 __sum = 16 * __sum + static_cast<unsigned>(__hd);
3927 _LIBCPP_FALLTHROUGH();3932 [[__fallthrough__]];
3928 case 'x':3933 case 'x':
3929 ++__first;3934 ++__first;
3930 if (__first == __last)3935 if (__first == __last)
3931 __throw_regex_error<regex_constants::error_escape>();3936 std::__throw_regex_error<regex_constants::error_escape>();
3932 __hd = __traits_.value(*__first, 16);3937 __hd = __traits_.value(*__first, 16);
3933 if (__hd == -1)3938 if (__hd == -1)
3934 __throw_regex_error<regex_constants::error_escape>();3939 std::__throw_regex_error<regex_constants::error_escape>();
3935 __sum = 16 * __sum + static_cast<unsigned>(__hd);3940 __sum = 16 * __sum + static_cast<unsigned>(__hd);
3936 ++__first;3941 ++__first;
3937 if (__first == __last)3942 if (__first == __last)
3938 __throw_regex_error<regex_constants::error_escape>();3943 std::__throw_regex_error<regex_constants::error_escape>();
3939 __hd = __traits_.value(*__first, 16);3944 __hd = __traits_.value(*__first, 16);
3940 if (__hd == -1)3945 if (__hd == -1)
3941 __throw_regex_error<regex_constants::error_escape>();3946 std::__throw_regex_error<regex_constants::error_escape>();
3942 __sum = 16 * __sum + static_cast<unsigned>(__hd);3947 __sum = 16 * __sum + static_cast<unsigned>(__hd);
3943 if (__str)3948 if (__str)
3944 *__str = _CharT(__sum);3949 *__str = _CharT(__sum);
...@@ -3954,14 +3959,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(...@@ -3954,14 +3959,14 @@ _ForwardIterator basic_regex<_CharT, _Traits>::__parse_character_escape(
3954 ++__first;3959 ++__first;
3955 break;3960 break;
3956 default:3961 default:
3957 if (*__first != '_' && !__traits_.isctype(*__first, ctype_base::alnum)) {3962 if (!__traits_.isctype(*__first, ctype_base::alnum)) {
3958 if (__str)3963 if (__str)
3959 *__str = *__first;3964 *__str = *__first;
3960 else3965 else
3961 __push_char(*__first);3966 __push_char(*__first);
3962 ++__first;3967 ++__first;
3963 } else3968 } else
3964 __throw_regex_error<regex_constants::error_escape>();3969 std::__throw_regex_error<regex_constants::error_escape>();
3965 break;3970 break;
3966 }3971 }
3967 }3972 }
...@@ -4057,7 +4062,7 @@ bool basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) {...@@ -4057,7 +4062,7 @@ bool basic_regex<_CharT, _Traits>::__test_back_ref(_CharT __c) {
4057 unsigned __val = __traits_.value(__c, 10);4062 unsigned __val = __traits_.value(__c, 10);
4058 if (__val >= 1 && __val <= 9) {4063 if (__val >= 1 && __val <= 9) {
4059 if (__val > mark_count())4064 if (__val > mark_count())
4060 __throw_regex_error<regex_constants::error_backref>();4065 std::__throw_regex_error<regex_constants::error_backref>();
4061 __push_back_ref(__val);4066 __push_back_ref(__val);
4062 return true;4067 return true;
4063 }4068 }
...@@ -4184,15 +4189,14 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo...@@ -4184,15 +4189,14 @@ void basic_regex<_CharT, _Traits>::__push_lookahead(const basic_regex& __exp, bo
41844189
4185typedef sub_match<const char*> csub_match;4190typedef sub_match<const char*> csub_match;
4186typedef sub_match<string::const_iterator> ssub_match;4191typedef sub_match<string::const_iterator> ssub_match;
4187# if _LIBCPP_HAS_WIDE_CHARACTERS4192# if _LIBCPP_HAS_WIDE_CHARACTERS
4188typedef sub_match<const wchar_t*> wcsub_match;4193typedef sub_match<const wchar_t*> wcsub_match;
4189typedef sub_match<wstring::const_iterator> wssub_match;4194typedef sub_match<wstring::const_iterator> wssub_match;
4190# endif4195# endif
41914196
4192template <class _BidirectionalIterator>4197template <class _BidirectionalIterator>
4193class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(csub_match)4198class _LIBCPP_PREFERRED_NAME(csub_match) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match))
4194 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcsub_match)) _LIBCPP_PREFERRED_NAME(ssub_match)4199 _LIBCPP_PREFERRED_NAME(ssub_match) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) sub_match
4195 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wssub_match)) sub_match
4196 : public pair<_BidirectionalIterator, _BidirectionalIterator> {4200 : public pair<_BidirectionalIterator, _BidirectionalIterator> {
4197public:4201public:
4198 typedef _BidirectionalIterator iterator;4202 typedef _BidirectionalIterator iterator;
...@@ -4227,7 +4231,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons...@@ -4227,7 +4231,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator==(const sub_match<_BiIter>& __x, cons
4227 return __x.compare(__y) == 0;4231 return __x.compare(__y) == 0;
4228}4232}
42294233
4230# if _LIBCPP_STD_VER >= 204234# if _LIBCPP_STD_VER >= 20
4231template <class _BiIter>4235template <class _BiIter>
4232using __sub_match_cat _LIBCPP_NODEBUG =4236using __sub_match_cat _LIBCPP_NODEBUG =
4233 compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>;4237 compare_three_way_result_t<basic_string<typename iterator_traits<_BiIter>::value_type>>;
...@@ -4236,7 +4240,7 @@ template <class _BiIter>...@@ -4236,7 +4240,7 @@ template <class _BiIter>
4236_LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {4240_LIBCPP_HIDE_FROM_ABI auto operator<=>(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
4237 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);4241 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);
4238}4242}
4239# else // _LIBCPP_STD_VER >= 204243# else // _LIBCPP_STD_VER >= 20
4240template <class _BiIter>4244template <class _BiIter>
4241inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {4245inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const sub_match<_BiIter>& __x, const sub_match<_BiIter>& __y) {
4242 return !(__x == __y);4246 return !(__x == __y);
...@@ -4303,7 +4307,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST...@@ -4303,7 +4307,7 @@ operator<=(const basic_string<typename iterator_traits<_BiIter>::value_type, _ST
4303 const sub_match<_BiIter>& __y) {4307 const sub_match<_BiIter>& __y) {
4304 return !(__y < __x);4308 return !(__y < __x);
4305}4309}
4306# endif // _LIBCPP_STD_VER >= 204310# endif // _LIBCPP_STD_VER >= 20
43074311
4308template <class _BiIter, class _ST, class _SA>4312template <class _BiIter, class _ST, class _SA>
4309inline _LIBCPP_HIDE_FROM_ABI bool4313inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4312,7 +4316,7 @@ operator==(const sub_match<_BiIter>& __x,...@@ -4312,7 +4316,7 @@ operator==(const sub_match<_BiIter>& __x,
4312 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;4316 return __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) == 0;
4313}4317}
43144318
4315# if _LIBCPP_STD_VER >= 204319# if _LIBCPP_STD_VER >= 20
4316template <class _BiIter, class _ST, class _SA>4320template <class _BiIter, class _ST, class _SA>
4317_LIBCPP_HIDE_FROM_ABI auto4321_LIBCPP_HIDE_FROM_ABI auto
4318operator<=>(const sub_match<_BiIter>& __x,4322operator<=>(const sub_match<_BiIter>& __x,
...@@ -4320,7 +4324,7 @@ operator<=>(const sub_match<_BiIter>& __x,...@@ -4320,7 +4324,7 @@ operator<=>(const sub_match<_BiIter>& __x,
4320 return static_cast<__sub_match_cat<_BiIter>>(4324 return static_cast<__sub_match_cat<_BiIter>>(
4321 __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0);4325 __x.compare(typename sub_match<_BiIter>::string_type(__y.data(), __y.size())) <=> 0);
4322}4326}
4323# else // _LIBCPP_STD_VER >= 204327# else // _LIBCPP_STD_VER >= 20
4324template <class _BiIter, class _ST, class _SA>4328template <class _BiIter, class _ST, class _SA>
4325inline _LIBCPP_HIDE_FROM_ABI bool4329inline _LIBCPP_HIDE_FROM_ABI bool
4326operator!=(const sub_match<_BiIter>& __x,4330operator!=(const sub_match<_BiIter>& __x,
...@@ -4391,7 +4395,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4391,7 +4395,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4391operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {4395operator<=(typename iterator_traits<_BiIter>::value_type const* __x, const sub_match<_BiIter>& __y) {
4392 return !(__y < __x);4396 return !(__y < __x);
4393}4397}
4394# endif // _LIBCPP_STD_VER >= 204398# endif // _LIBCPP_STD_VER >= 20
43954399
4396template <class _BiIter>4400template <class _BiIter>
4397inline _LIBCPP_HIDE_FROM_ABI bool4401inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4399,13 +4403,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val...@@ -4399,13 +4403,13 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val
4399 return __x.compare(__y) == 0;4403 return __x.compare(__y) == 0;
4400}4404}
44014405
4402# if _LIBCPP_STD_VER >= 204406# if _LIBCPP_STD_VER >= 20
4403template <class _BiIter>4407template <class _BiIter>
4404_LIBCPP_HIDE_FROM_ABI auto4408_LIBCPP_HIDE_FROM_ABI auto
4405operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {4409operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
4406 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);4410 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(__y) <=> 0);
4407}4411}
4408# else // _LIBCPP_STD_VER >= 204412# else // _LIBCPP_STD_VER >= 20
4409template <class _BiIter>4413template <class _BiIter>
4410inline _LIBCPP_HIDE_FROM_ABI bool4414inline _LIBCPP_HIDE_FROM_ABI bool
4411operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {4415operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const* __y) {
...@@ -4473,7 +4477,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4473,7 +4477,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4473operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {4477operator<=(typename iterator_traits<_BiIter>::value_type const& __x, const sub_match<_BiIter>& __y) {
4474 return !(__y < __x);4478 return !(__y < __x);
4475}4479}
4476# endif // _LIBCPP_STD_VER >= 204480# endif // _LIBCPP_STD_VER >= 20
44774481
4478template <class _BiIter>4482template <class _BiIter>
4479inline _LIBCPP_HIDE_FROM_ABI bool4483inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -4482,14 +4486,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val...@@ -4482,14 +4486,14 @@ operator==(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::val
4482 return __x.compare(string_type(1, __y)) == 0;4486 return __x.compare(string_type(1, __y)) == 0;
4483}4487}
44844488
4485# if _LIBCPP_STD_VER >= 204489# if _LIBCPP_STD_VER >= 20
4486template <class _BiIter>4490template <class _BiIter>
4487_LIBCPP_HIDE_FROM_ABI auto4491_LIBCPP_HIDE_FROM_ABI auto
4488operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4492operator<=>(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
4489 using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>;4493 using string_type = basic_string<typename iterator_traits<_BiIter>::value_type>;
4490 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0);4494 return static_cast<__sub_match_cat<_BiIter>>(__x.compare(string_type(1, __y)) <=> 0);
4491}4495}
4492# else // _LIBCPP_STD_VER >= 204496# else // _LIBCPP_STD_VER >= 20
4493template <class _BiIter>4497template <class _BiIter>
4494inline _LIBCPP_HIDE_FROM_ABI bool4498inline _LIBCPP_HIDE_FROM_ABI bool
4495operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4499operator!=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
...@@ -4520,7 +4524,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool...@@ -4520,7 +4524,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
4520operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {4524operator<=(const sub_match<_BiIter>& __x, typename iterator_traits<_BiIter>::value_type const& __y) {
4521 return !(__y < __x);4525 return !(__y < __x);
4522}4526}
4523# endif // _LIBCPP_STD_VER >= 204527# endif // _LIBCPP_STD_VER >= 20
45244528
4525template <class _CharT, class _ST, class _BiIter>4529template <class _CharT, class _ST, class _BiIter>
4526inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>&4530inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _ST>&
...@@ -4530,13 +4534,13 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) {...@@ -4530,13 +4534,13 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) {
45304534
4531typedef match_results<const char*> cmatch;4535typedef match_results<const char*> cmatch;
4532typedef match_results<string::const_iterator> smatch;4536typedef match_results<string::const_iterator> smatch;
4533# if _LIBCPP_HAS_WIDE_CHARACTERS4537# if _LIBCPP_HAS_WIDE_CHARACTERS
4534typedef match_results<const wchar_t*> wcmatch;4538typedef match_results<const wchar_t*> wcmatch;
4535typedef match_results<wstring::const_iterator> wsmatch;4539typedef match_results<wstring::const_iterator> wsmatch;
4536# endif4540# endif
45374541
4538template <class _BidirectionalIterator, class _Allocator>4542template <class _BidirectionalIterator, class _Allocator>
4539class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))4543class _LIBCPP_PREFERRED_NAME(cmatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcmatch))
4540 _LIBCPP_PREFERRED_NAME(smatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) match_results {4544 _LIBCPP_PREFERRED_NAME(smatch) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsmatch)) match_results {
4541public:4545public:
4542 typedef _Allocator allocator_type;4546 typedef _Allocator allocator_type;
...@@ -4563,12 +4567,12 @@ public:...@@ -4563,12 +4567,12 @@ public:
4563 typedef basic_string<char_type> string_type;4567 typedef basic_string<char_type> string_type;
45644568
4565 // construct/copy/destroy:4569 // construct/copy/destroy:
4566# ifndef _LIBCPP_CXX03_LANG4570# ifndef _LIBCPP_CXX03_LANG
4567 match_results() : match_results(allocator_type()) {}4571 match_results() : match_results(allocator_type()) {}
4568 explicit match_results(const allocator_type& __a);4572 explicit match_results(const allocator_type& __a);
4569# else4573# else
4570 explicit match_results(const allocator_type& __a = allocator_type());4574 explicit match_results(const allocator_type& __a = allocator_type());
4571# endif4575# endif
45724576
4573 // match_results(const match_results&) = default;4577 // match_results(const match_results&) = default;
4574 // match_results& operator=(const match_results&) = default;4578 // match_results& operator=(const match_results&) = default;
...@@ -4778,7 +4782,7 @@ _OutputIter match_results<_BidirectionalIterator, _Allocator>::format(...@@ -4778,7 +4782,7 @@ _OutputIter match_results<_BidirectionalIterator, _Allocator>::format(
4778 if (__fmt_first + 1 != __fmt_last && '0' <= __fmt_first[1] && __fmt_first[1] <= '9') {4782 if (__fmt_first + 1 != __fmt_last && '0' <= __fmt_first[1] && __fmt_first[1] <= '9') {
4779 ++__fmt_first;4783 ++__fmt_first;
4780 if (__idx >= numeric_limits<size_t>::max() / 10)4784 if (__idx >= numeric_limits<size_t>::max() / 10)
4781 __throw_regex_error<regex_constants::error_escape>();4785 std::__throw_regex_error<regex_constants::error_escape>();
4782 __idx = 10 * __idx + *__fmt_first - '0';4786 __idx = 10 * __idx + *__fmt_first - '0';
4783 }4787 }
4784 __output_iter = std::copy((*this)[__idx].first, (*this)[__idx].second, __output_iter);4788 __output_iter = std::copy((*this)[__idx].first, (*this)[__idx].second, __output_iter);
...@@ -4818,13 +4822,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator...@@ -4818,13 +4822,13 @@ _LIBCPP_HIDE_FROM_ABI bool operator==(const match_results<_BidirectionalIterator
4818 return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_;4822 return __x.__matches_ == __y.__matches_ && __x.__prefix_ == __y.__prefix_ && __x.__suffix_ == __y.__suffix_;
4819}4823}
48204824
4821# if _LIBCPP_STD_VER < 204825# if _LIBCPP_STD_VER < 20
4822template <class _BidirectionalIterator, class _Allocator>4826template <class _BidirectionalIterator, class _Allocator>
4823inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,4827inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const match_results<_BidirectionalIterator, _Allocator>& __x,
4824 const match_results<_BidirectionalIterator, _Allocator>& __y) {4828 const match_results<_BidirectionalIterator, _Allocator>& __y) {
4825 return !(__x == __y);4829 return !(__x == __y);
4826}4830}
4827# endif4831# endif
48284832
4829template <class _BidirectionalIterator, class _Allocator>4833template <class _BidirectionalIterator, class _Allocator>
4830inline _LIBCPP_HIDE_FROM_ABI void4834inline _LIBCPP_HIDE_FROM_ABI void
...@@ -4865,7 +4869,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma(...@@ -4865,7 +4869,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma(
4865 do {4869 do {
4866 ++__counter;4870 ++__counter;
4867 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)4871 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
4868 __throw_regex_error<regex_constants::error_complexity>();4872 std::__throw_regex_error<regex_constants::error_complexity>();
4869 __state& __s = __states.back();4873 __state& __s = __states.back();
4870 if (__s.__node_)4874 if (__s.__node_)
4871 __s.__node_->__exec(__s);4875 __s.__node_->__exec(__s);
...@@ -4899,7 +4903,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma(...@@ -4899,7 +4903,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_ecma(
4899 __states.pop_back();4903 __states.pop_back();
4900 break;4904 break;
4901 default:4905 default:
4902 __throw_regex_error<regex_constants::__re_err_unknown>();4906 std::__throw_regex_error<regex_constants::__re_err_unknown>();
4903 break;4907 break;
4904 }4908 }
4905 } while (!__states.empty());4909 } while (!__states.empty());
...@@ -4935,7 +4939,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(...@@ -4935,7 +4939,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
4935 do {4939 do {
4936 ++__counter;4940 ++__counter;
4937 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)4941 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
4938 __throw_regex_error<regex_constants::error_complexity>();4942 std::__throw_regex_error<regex_constants::error_complexity>();
4939 __state& __s = __states.back();4943 __state& __s = __states.back();
4940 if (__s.__node_)4944 if (__s.__node_)
4941 __s.__node_->__exec(__s);4945 __s.__node_->__exec(__s);
...@@ -4976,7 +4980,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(...@@ -4976,7 +4980,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs(
4976 __states.pop_back();4980 __states.pop_back();
4977 break;4981 break;
4978 default:4982 default:
4979 __throw_regex_error<regex_constants::__re_err_unknown>();4983 std::__throw_regex_error<regex_constants::__re_err_unknown>();
4980 break;4984 break;
4981 }4985 }
4982 } while (!__states.empty());4986 } while (!__states.empty());
...@@ -5025,7 +5029,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(...@@ -5025,7 +5029,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5025 do {5029 do {
5026 ++__counter;5030 ++__counter;
5027 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)5031 if (__counter % _LIBCPP_REGEX_COMPLEXITY_FACTOR == 0 && __counter / _LIBCPP_REGEX_COMPLEXITY_FACTOR >= __length)
5028 __throw_regex_error<regex_constants::error_complexity>();5032 std::__throw_regex_error<regex_constants::error_complexity>();
5029 __state& __s = __states.back();5033 __state& __s = __states.back();
5030 if (__s.__node_)5034 if (__s.__node_)
5031 __s.__node_->__exec(__s);5035 __s.__node_->__exec(__s);
...@@ -5063,7 +5067,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(...@@ -5063,7 +5067,7 @@ bool basic_regex<_CharT, _Traits>::__match_at_start_posix_subs(
5063 __states.pop_back();5067 __states.pop_back();
5064 break;5068 break;
5065 default:5069 default:
5066 __throw_regex_error<regex_constants::__re_err_unknown>();5070 std::__throw_regex_error<regex_constants::__re_err_unknown>();
5067 break;5071 break;
5068 }5072 }
5069 } while (!__states.empty());5073 } while (!__states.empty());
...@@ -5236,13 +5240,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,...@@ -5236,13 +5240,13 @@ regex_search(const basic_string<_CharT, _ST, _SA>& __s,
5236 return __r;5240 return __r;
5237}5241}
52385242
5239# if _LIBCPP_STD_VER >= 145243# if _LIBCPP_STD_VER >= 14
5240template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>5244template <class _ST, class _SA, class _Ap, class _Cp, class _Tp>
5241bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s,5245bool regex_search(const basic_string<_Cp, _ST, _SA>&& __s,
5242 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,5246 match_results<typename basic_string<_Cp, _ST, _SA>::const_iterator, _Ap>&,
5243 const basic_regex<_Cp, _Tp>& __e,5247 const basic_regex<_Cp, _Tp>& __e,
5244 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;5248 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
5245# endif5249# endif
52465250
5247// regex_match5251// regex_match
52485252
...@@ -5291,14 +5295,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,...@@ -5291,14 +5295,14 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
5291 return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags);5295 return std::regex_match(__s.begin(), __s.end(), __m, __e, __flags);
5292}5296}
52935297
5294# if _LIBCPP_STD_VER >= 145298# if _LIBCPP_STD_VER >= 14
5295template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>5299template <class _ST, class _SA, class _Allocator, class _CharT, class _Traits>
5296inline _LIBCPP_HIDE_FROM_ABI bool5300inline _LIBCPP_HIDE_FROM_ABI bool
5297regex_match(const basic_string<_CharT, _ST, _SA>&& __s,5301regex_match(const basic_string<_CharT, _ST, _SA>&& __s,
5298 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,5302 match_results<typename basic_string<_CharT, _ST, _SA>::const_iterator, _Allocator>& __m,
5299 const basic_regex<_CharT, _Traits>& __e,5303 const basic_regex<_CharT, _Traits>& __e,
5300 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;5304 regex_constants::match_flag_type __flags = regex_constants::match_default) = delete;
5301# endif5305# endif
53025306
5303template <class _CharT, class _Traits>5307template <class _CharT, class _Traits>
5304inline _LIBCPP_HIDE_FROM_ABI bool5308inline _LIBCPP_HIDE_FROM_ABI bool
...@@ -5321,18 +5325,18 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,...@@ -5321,18 +5325,18 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s,
5321template <class _BidirectionalIterator,5325template <class _BidirectionalIterator,
5322 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,5326 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
5323 class _Traits = regex_traits<_CharT> >5327 class _Traits = regex_traits<_CharT> >
5324class _LIBCPP_TEMPLATE_VIS regex_iterator;5328class regex_iterator;
53255329
5326typedef regex_iterator<const char*> cregex_iterator;5330typedef regex_iterator<const char*> cregex_iterator;
5327typedef regex_iterator<string::const_iterator> sregex_iterator;5331typedef regex_iterator<string::const_iterator> sregex_iterator;
5328# if _LIBCPP_HAS_WIDE_CHARACTERS5332# if _LIBCPP_HAS_WIDE_CHARACTERS
5329typedef regex_iterator<const wchar_t*> wcregex_iterator;5333typedef regex_iterator<const wchar_t*> wcregex_iterator;
5330typedef regex_iterator<wstring::const_iterator> wsregex_iterator;5334typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
5331# endif5335# endif
53325336
5333template <class _BidirectionalIterator, class _CharT, class _Traits>5337template <class _BidirectionalIterator, class _CharT, class _Traits>
5334class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_iterator)5338class _LIBCPP_PREFERRED_NAME(cregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator))
5335 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator)) _LIBCPP_PREFERRED_NAME(sregex_iterator)5339 _LIBCPP_PREFERRED_NAME(sregex_iterator)
5336 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator {5340 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator {
5337public:5341public:
5338 typedef basic_regex<_CharT, _Traits> regex_type;5342 typedef basic_regex<_CharT, _Traits> regex_type;
...@@ -5341,9 +5345,9 @@ public:...@@ -5341,9 +5345,9 @@ public:
5341 typedef const value_type* pointer;5345 typedef const value_type* pointer;
5342 typedef const value_type& reference;5346 typedef const value_type& reference;
5343 typedef forward_iterator_tag iterator_category;5347 typedef forward_iterator_tag iterator_category;
5344# if _LIBCPP_STD_VER >= 205348# if _LIBCPP_STD_VER >= 20
5345 typedef input_iterator_tag iterator_concept;5349 typedef input_iterator_tag iterator_concept;
5346# endif5350# endif
53475351
5348private:5352private:
5349 _BidirectionalIterator __begin_;5353 _BidirectionalIterator __begin_;
...@@ -5358,20 +5362,20 @@ public:...@@ -5358,20 +5362,20 @@ public:
5358 _BidirectionalIterator __b,5362 _BidirectionalIterator __b,
5359 const regex_type& __re,5363 const regex_type& __re,
5360 regex_constants::match_flag_type __m = regex_constants::match_default);5364 regex_constants::match_flag_type __m = regex_constants::match_default);
5361# if _LIBCPP_STD_VER >= 145365# if _LIBCPP_STD_VER >= 14
5362 regex_iterator(_BidirectionalIterator __a,5366 regex_iterator(_BidirectionalIterator __a,
5363 _BidirectionalIterator __b,5367 _BidirectionalIterator __b,
5364 const regex_type&& __re,5368 const regex_type&& __re,
5365 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5369 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5366# endif5370# endif
53675371
5368 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const;5372 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_iterator& __x) const;
5369# if _LIBCPP_STD_VER >= 205373# if _LIBCPP_STD_VER >= 20
5370 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }5374 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_iterator(); }
5371# endif5375# endif
5372# if _LIBCPP_STD_VER < 205376# if _LIBCPP_STD_VER < 20
5373 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); }5377 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_iterator& __x) const { return !(*this == __x); }
5374# endif5378# endif
53755379
5376 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; }5380 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __match_; }
5377 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); }5381 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return std::addressof(__match_); }
...@@ -5451,17 +5455,17 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {...@@ -5451,17 +5455,17 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {
5451template <class _BidirectionalIterator,5455template <class _BidirectionalIterator,
5452 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,5456 class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type,
5453 class _Traits = regex_traits<_CharT> >5457 class _Traits = regex_traits<_CharT> >
5454class _LIBCPP_TEMPLATE_VIS regex_token_iterator;5458class regex_token_iterator;
54555459
5456typedef regex_token_iterator<const char*> cregex_token_iterator;5460typedef regex_token_iterator<const char*> cregex_token_iterator;
5457typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;5461typedef regex_token_iterator<string::const_iterator> sregex_token_iterator;
5458# if _LIBCPP_HAS_WIDE_CHARACTERS5462# if _LIBCPP_HAS_WIDE_CHARACTERS
5459typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;5463typedef regex_token_iterator<const wchar_t*> wcregex_token_iterator;
5460typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;5464typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
5461# endif5465# endif
54625466
5463template <class _BidirectionalIterator, class _CharT, class _Traits>5467template <class _BidirectionalIterator, class _CharT, class _Traits>
5464class _LIBCPP_TEMPLATE_VIS _LIBCPP_PREFERRED_NAME(cregex_token_iterator)5468class _LIBCPP_PREFERRED_NAME(cregex_token_iterator)
5465 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator))5469 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_token_iterator))
5466 _LIBCPP_PREFERRED_NAME(sregex_token_iterator)5470 _LIBCPP_PREFERRED_NAME(sregex_token_iterator)
5467 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) regex_token_iterator {5471 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_token_iterator)) regex_token_iterator {
...@@ -5472,9 +5476,9 @@ public:...@@ -5472,9 +5476,9 @@ public:
5472 typedef const value_type* pointer;5476 typedef const value_type* pointer;
5473 typedef const value_type& reference;5477 typedef const value_type& reference;
5474 typedef forward_iterator_tag iterator_category;5478 typedef forward_iterator_tag iterator_category;
5475# if _LIBCPP_STD_VER >= 205479# if _LIBCPP_STD_VER >= 20
5476 typedef input_iterator_tag iterator_concept;5480 typedef input_iterator_tag iterator_concept;
5477# endif5481# endif
54785482
5479private:5483private:
5480 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;5484 typedef regex_iterator<_BidirectionalIterator, _CharT, _Traits> _Position;
...@@ -5492,67 +5496,67 @@ public:...@@ -5492,67 +5496,67 @@ public:
5492 const regex_type& __re,5496 const regex_type& __re,
5493 int __submatch = 0,5497 int __submatch = 0,
5494 regex_constants::match_flag_type __m = regex_constants::match_default);5498 regex_constants::match_flag_type __m = regex_constants::match_default);
5495# if _LIBCPP_STD_VER >= 145499# if _LIBCPP_STD_VER >= 14
5496 regex_token_iterator(_BidirectionalIterator __a,5500 regex_token_iterator(_BidirectionalIterator __a,
5497 _BidirectionalIterator __b,5501 _BidirectionalIterator __b,
5498 const regex_type&& __re,5502 const regex_type&& __re,
5499 int __submatch = 0,5503 int __submatch = 0,
5500 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5504 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5501# endif5505# endif
55025506
5503 regex_token_iterator(_BidirectionalIterator __a,5507 regex_token_iterator(_BidirectionalIterator __a,
5504 _BidirectionalIterator __b,5508 _BidirectionalIterator __b,
5505 const regex_type& __re,5509 const regex_type& __re,
5506 const vector<int>& __submatches,5510 const vector<int>& __submatches,
5507 regex_constants::match_flag_type __m = regex_constants::match_default);5511 regex_constants::match_flag_type __m = regex_constants::match_default);
5508# if _LIBCPP_STD_VER >= 145512# if _LIBCPP_STD_VER >= 14
5509 regex_token_iterator(_BidirectionalIterator __a,5513 regex_token_iterator(_BidirectionalIterator __a,
5510 _BidirectionalIterator __b,5514 _BidirectionalIterator __b,
5511 const regex_type&& __re,5515 const regex_type&& __re,
5512 const vector<int>& __submatches,5516 const vector<int>& __submatches,
5513 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5517 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5514# endif5518# endif
55155519
5516# ifndef _LIBCPP_CXX03_LANG5520# ifndef _LIBCPP_CXX03_LANG
5517 regex_token_iterator(_BidirectionalIterator __a,5521 regex_token_iterator(_BidirectionalIterator __a,
5518 _BidirectionalIterator __b,5522 _BidirectionalIterator __b,
5519 const regex_type& __re,5523 const regex_type& __re,
5520 initializer_list<int> __submatches,5524 initializer_list<int> __submatches,
5521 regex_constants::match_flag_type __m = regex_constants::match_default);5525 regex_constants::match_flag_type __m = regex_constants::match_default);
55225526
5523# if _LIBCPP_STD_VER >= 145527# if _LIBCPP_STD_VER >= 14
5524 regex_token_iterator(_BidirectionalIterator __a,5528 regex_token_iterator(_BidirectionalIterator __a,
5525 _BidirectionalIterator __b,5529 _BidirectionalIterator __b,
5526 const regex_type&& __re,5530 const regex_type&& __re,
5527 initializer_list<int> __submatches,5531 initializer_list<int> __submatches,
5528 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5532 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5529# endif5533# endif
5530# endif // _LIBCPP_CXX03_LANG5534# endif // _LIBCPP_CXX03_LANG
5531 template <size_t _Np>5535 template <size_t _Np>
5532 regex_token_iterator(_BidirectionalIterator __a,5536 regex_token_iterator(_BidirectionalIterator __a,
5533 _BidirectionalIterator __b,5537 _BidirectionalIterator __b,
5534 const regex_type& __re,5538 const regex_type& __re,
5535 const int (&__submatches)[_Np],5539 const int (&__submatches)[_Np],
5536 regex_constants::match_flag_type __m = regex_constants::match_default);5540 regex_constants::match_flag_type __m = regex_constants::match_default);
5537# if _LIBCPP_STD_VER >= 145541# if _LIBCPP_STD_VER >= 14
5538 template <size_t _Np>5542 template <size_t _Np>
5539 regex_token_iterator(_BidirectionalIterator __a,5543 regex_token_iterator(_BidirectionalIterator __a,
5540 _BidirectionalIterator __b,5544 _BidirectionalIterator __b,
5541 const regex_type&& __re,5545 const regex_type&& __re,
5542 const int (&__submatches)[_Np],5546 const int (&__submatches)[_Np],
5543 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;5547 regex_constants::match_flag_type __m = regex_constants::match_default) = delete;
5544# endif5548# endif
55455549
5546 regex_token_iterator(const regex_token_iterator&);5550 regex_token_iterator(const regex_token_iterator&);
5547 regex_token_iterator& operator=(const regex_token_iterator&);5551 regex_token_iterator& operator=(const regex_token_iterator&);
55485552
5549 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const;5553 _LIBCPP_HIDE_FROM_ABI bool operator==(const regex_token_iterator& __x) const;
5550# if _LIBCPP_STD_VER >= 205554# if _LIBCPP_STD_VER >= 20
5551 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); }5555 _LIBCPP_HIDE_FROM_ABI bool operator==(default_sentinel_t) const { return *this == regex_token_iterator(); }
5552# endif5556# endif
5553# if _LIBCPP_STD_VER < 205557# if _LIBCPP_STD_VER < 20
5554 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); }5558 _LIBCPP_HIDE_FROM_ABI bool operator!=(const regex_token_iterator& __x) const { return !(*this == __x); }
5555# endif5559# endif
55565560
5557 _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; }5561 _LIBCPP_HIDE_FROM_ABI const value_type& operator*() const { return *__result_; }
5558 _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; }5562 _LIBCPP_HIDE_FROM_ABI const value_type* operator->() const { return __result_; }
...@@ -5568,9 +5572,9 @@ private:...@@ -5568,9 +5572,9 @@ private:
5568 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);5572 void __init(_BidirectionalIterator __a, _BidirectionalIterator __b);
5569 void __establish_result() {5573 void __establish_result() {
5570 if (__subs_[__n_] == -1)5574 if (__subs_[__n_] == -1)
5571 __result_ = &__position_->prefix();5575 __result_ = std::addressof(__position_->prefix());
5572 else5576 else
5573 __result_ = &(*__position_)[__subs_[__n_]];5577 __result_ = std::addressof((*__position_)[__subs_[__n_]]);
5574 }5578 }
5575};5579};
55765580
...@@ -5587,7 +5591,7 @@ void regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::__init(...@@ -5587,7 +5591,7 @@ void regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::__init(
5587 __suffix_.matched = true;5591 __suffix_.matched = true;
5588 __suffix_.first = __a;5592 __suffix_.first = __a;
5589 __suffix_.second = __b;5593 __suffix_.second = __b;
5590 __result_ = &__suffix_;5594 __result_ = std::addressof(__suffix_);
5591 } else5595 } else
5592 __result_ = nullptr;5596 __result_ = nullptr;
5593}5597}
...@@ -5614,7 +5618,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5614,7 +5618,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5614 __init(__a, __b);5618 __init(__a, __b);
5615}5619}
56165620
5617# ifndef _LIBCPP_CXX03_LANG5621# ifndef _LIBCPP_CXX03_LANG
56185622
5619template <class _BidirectionalIterator, class _CharT, class _Traits>5623template <class _BidirectionalIterator, class _CharT, class _Traits>
5620regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(5624regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_iterator(
...@@ -5627,7 +5631,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5627,7 +5631,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5627 __init(__a, __b);5631 __init(__a, __b);
5628}5632}
56295633
5630# endif // _LIBCPP_CXX03_LANG5634# endif // _LIBCPP_CXX03_LANG
56315635
5632template <class _BidirectionalIterator, class _CharT, class _Traits>5636template <class _BidirectionalIterator, class _CharT, class _Traits>
5633template <size_t _Np>5637template <size_t _Np>
...@@ -5648,8 +5652,8 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5648,8 +5652,8 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5648 __suffix_(__x.__suffix_),5652 __suffix_(__x.__suffix_),
5649 __n_(__x.__n_),5653 __n_(__x.__n_),
5650 __subs_(__x.__subs_) {5654 __subs_(__x.__subs_) {
5651 if (__x.__result_ == &__x.__suffix_)5655 if (__x.__result_ == std::addressof(__x.__suffix_))
5652 __result_ = &__suffix_;5656 __result_ = std::addressof(__suffix_);
5653 else if (__result_ != nullptr)5657 else if (__result_ != nullptr)
5654 __establish_result();5658 __establish_result();
5655}5659}
...@@ -5657,17 +5661,17 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera...@@ -5657,17 +5661,17 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::regex_token_itera
5657template <class _BidirectionalIterator, class _CharT, class _Traits>5661template <class _BidirectionalIterator, class _CharT, class _Traits>
5658regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&5662regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
5659regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator=(const regex_token_iterator& __x) {5663regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator=(const regex_token_iterator& __x) {
5660 if (this != &__x) {5664 if (this != std::addressof(__x)) {
5661 __position_ = __x.__position_;5665 __position_ = __x.__position_;
5662 if (__x.__result_ == &__x.__suffix_)5666 if (__x.__result_ == std::addressof(__x.__suffix_))
5663 __result_ = &__suffix_;5667 __result_ = std::addressof(__suffix_);
5664 else5668 else
5665 __result_ = __x.__result_;5669 __result_ = __x.__result_;
5666 __suffix_ = __x.__suffix_;5670 __suffix_ = __x.__suffix_;
5667 __n_ = __x.__n_;5671 __n_ = __x.__n_;
5668 __subs_ = __x.__subs_;5672 __subs_ = __x.__subs_;
56695673
5670 if (__result_ != nullptr && __result_ != &__suffix_)5674 if (__result_ != nullptr && __result_ != std::addressof(__suffix_))
5671 __establish_result();5675 __establish_result();
5672 }5676 }
5673 return *this;5677 return *this;
...@@ -5677,11 +5681,12 @@ template <class _BidirectionalIterator, class _CharT, class _Traits>...@@ -5677,11 +5681,12 @@ template <class _BidirectionalIterator, class _CharT, class _Traits>
5677bool regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_token_iterator& __x) const {5681bool regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator==(const regex_token_iterator& __x) const {
5678 if (__result_ == nullptr && __x.__result_ == nullptr)5682 if (__result_ == nullptr && __x.__result_ == nullptr)
5679 return true;5683 return true;
5680 if (__result_ == &__suffix_ && __x.__result_ == &__x.__suffix_ && __suffix_ == __x.__suffix_)5684 if (__result_ == std::addressof(__suffix_) && __x.__result_ == std::addressof(__x.__suffix_) &&
5685 __suffix_ == __x.__suffix_)
5681 return true;5686 return true;
5682 if (__result_ == nullptr || __x.__result_ == nullptr)5687 if (__result_ == nullptr || __x.__result_ == nullptr)
5683 return false;5688 return false;
5684 if (__result_ == &__suffix_ || __x.__result_ == &__x.__suffix_)5689 if (__result_ == std::addressof(__suffix_) || __x.__result_ == std::addressof(__x.__suffix_))
5685 return false;5690 return false;
5686 return __position_ == __x.__position_ && __n_ == __x.__n_ && __subs_ == __x.__subs_;5691 return __position_ == __x.__position_ && __n_ == __x.__n_ && __subs_ == __x.__subs_;
5687}5692}
...@@ -5690,7 +5695,7 @@ template <class _BidirectionalIterator, class _CharT, class _Traits>...@@ -5690,7 +5695,7 @@ template <class _BidirectionalIterator, class _CharT, class _Traits>
5690regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&5695regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>&
5691regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {5696regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {
5692 _Position __prev = __position_;5697 _Position __prev = __position_;
5693 if (__result_ == &__suffix_)5698 if (__result_ == std::addressof(__suffix_))
5694 __result_ = nullptr;5699 __result_ = nullptr;
5695 else if (static_cast<size_t>(__n_ + 1) < __subs_.size()) {5700 else if (static_cast<size_t>(__n_ + 1) < __subs_.size()) {
5696 ++__n_;5701 ++__n_;
...@@ -5705,7 +5710,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {...@@ -5705,7 +5710,7 @@ regex_token_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {
5705 __suffix_.matched = true;5710 __suffix_.matched = true;
5706 __suffix_.first = __prev->suffix().first;5711 __suffix_.first = __prev->suffix().first;
5707 __suffix_.second = __prev->suffix().second;5712 __suffix_.second = __prev->suffix().second;
5708 __result_ = &__suffix_;5713 __result_ = std::addressof(__suffix_);
5709 } else5714 } else
5710 __result_ = nullptr;5715 __result_ = nullptr;
5711 }5716 }
...@@ -5802,7 +5807,7 @@ regex_replace(const _CharT* __s,...@@ -5802,7 +5807,7 @@ regex_replace(const _CharT* __s,
58025807
5803_LIBCPP_END_NAMESPACE_STD5808_LIBCPP_END_NAMESPACE_STD
58045809
5805# if _LIBCPP_STD_VER >= 175810# if _LIBCPP_STD_VER >= 17
5806_LIBCPP_BEGIN_NAMESPACE_STD5811_LIBCPP_BEGIN_NAMESPACE_STD
5807namespace pmr {5812namespace pmr {
5808template <class _BidirT>5813template <class _BidirT>
...@@ -5812,16 +5817,18 @@ using match_results _LIBCPP_AVAILABILITY_PMR =...@@ -5812,16 +5817,18 @@ using match_results _LIBCPP_AVAILABILITY_PMR =
5812using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>;5817using cmatch _LIBCPP_AVAILABILITY_PMR = match_results<const char*>;
5813using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>;5818using smatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::string::const_iterator>;
58145819
5815# if _LIBCPP_HAS_WIDE_CHARACTERS5820# if _LIBCPP_HAS_WIDE_CHARACTERS
5816using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>;5821using wcmatch _LIBCPP_AVAILABILITY_PMR = match_results<const wchar_t*>;
5817using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>;5822using wsmatch _LIBCPP_AVAILABILITY_PMR = match_results<std::pmr::wstring::const_iterator>;
5818# endif5823# endif
5819} // namespace pmr5824} // namespace pmr
5820_LIBCPP_END_NAMESPACE_STD5825_LIBCPP_END_NAMESPACE_STD
5821# endif5826# endif
58225827
5823_LIBCPP_POP_MACROS5828_LIBCPP_POP_MACROS
58245829
5830# endif // _LIBCPP_HAS_LOCALIZATION
5831
5825# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 205832# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
5826# include <atomic>5833# include <atomic>
5827# include <concepts>5834# include <concepts>
lib/libcxx/include/scoped_allocator+2-2
...@@ -110,7 +110,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>...@@ -110,7 +110,7 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
110*/110*/
111111
112#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)112#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
113# include <__cxx03/scoped_allocator>113# include <__cxx03/__config>
114#else114#else
115# include <__config>115# include <__config>
116# include <__memory/allocator_traits.h>116# include <__memory/allocator_traits.h>
...@@ -334,7 +334,7 @@ struct __outermost<_Alloc, true> {...@@ -334,7 +334,7 @@ struct __outermost<_Alloc, true> {
334};334};
335335
336template <class _OuterAlloc, class... _InnerAllocs>336template <class _OuterAlloc, class... _InnerAllocs>
337class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>337class scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
338 : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {338 : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {
339 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;339 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;
340 typedef allocator_traits<_OuterAlloc> _OuterTraits;340 typedef allocator_traits<_OuterAlloc> _OuterTraits;
lib/libcxx/include/semaphore+1-1
...@@ -46,7 +46,7 @@ using binary_semaphore = counting_semaphore<1>; // since C++20...@@ -46,7 +46,7 @@ using binary_semaphore = counting_semaphore<1>; // since C++20
46*/46*/
4747
48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
49# include <__cxx03/semaphore>49# include <__cxx03/__config>
50#else50#else
51# include <__config>51# include <__config>
5252
lib/libcxx/include/set+36-40
...@@ -522,6 +522,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20...@@ -522,6 +522,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
522# include <__config>522# include <__config>
523# include <__functional/is_transparent.h>523# include <__functional/is_transparent.h>
524# include <__functional/operations.h>524# include <__functional/operations.h>
525# include <__fwd/set.h>
525# include <__iterator/erase_if_container.h>526# include <__iterator/erase_if_container.h>
526# include <__iterator/iterator_traits.h>527# include <__iterator/iterator_traits.h>
527# include <__iterator/ranges_iterator_traits.h>528# include <__iterator/ranges_iterator_traits.h>
...@@ -570,10 +571,7 @@ _LIBCPP_PUSH_MACROS...@@ -570,10 +571,7 @@ _LIBCPP_PUSH_MACROS
570_LIBCPP_BEGIN_NAMESPACE_STD571_LIBCPP_BEGIN_NAMESPACE_STD
571572
572template <class _Key, class _Compare, class _Allocator>573template <class _Key, class _Compare, class _Allocator>
573class multiset;574class set {
574
575template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >
576class _LIBCPP_TEMPLATE_VIS set {
577public:575public:
578 // types:576 // types:
579 typedef _Key key_type;577 typedef _Key key_type;
...@@ -611,9 +609,9 @@ public:...@@ -611,9 +609,9 @@ public:
611# endif609# endif
612610
613 template <class _Key2, class _Compare2, class _Alloc2>611 template <class _Key2, class _Compare2, class _Alloc2>
614 friend class _LIBCPP_TEMPLATE_VIS set;612 friend class set;
615 template <class _Key2, class _Compare2, class _Alloc2>613 template <class _Key2, class _Compare2, class _Alloc2>
616 friend class _LIBCPP_TEMPLATE_VIS multiset;614 friend class multiset;
617615
618 _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_(616 _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_(
619 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&617 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
...@@ -664,14 +662,10 @@ public:...@@ -664,14 +662,10 @@ public:
664662
665 _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }663 _LIBCPP_HIDE_FROM_ABI set(const set& __s) : __tree_(__s.__tree_) { insert(__s.begin(), __s.end()); }
666664
667 _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) {665 _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default;
668 __tree_ = __s.__tree_;
669 return *this;
670 }
671666
672# ifndef _LIBCPP_CXX03_LANG667# ifndef _LIBCPP_CXX03_LANG
673 _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value)668 _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default;
674 : __tree_(std::move(__s.__tree_)) {}
675# endif // _LIBCPP_CXX03_LANG669# endif // _LIBCPP_CXX03_LANG
676670
677 _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}671 _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}
...@@ -709,7 +703,7 @@ public:...@@ -709,7 +703,7 @@ public:
709 }703 }
710# endif // _LIBCPP_CXX03_LANG704# endif // _LIBCPP_CXX03_LANG
711705
712 _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }706 _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
713707
714 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }708 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
715 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }709 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
...@@ -742,15 +736,15 @@ public:...@@ -742,15 +736,15 @@ public:
742 }736 }
743# endif // _LIBCPP_CXX03_LANG737# endif // _LIBCPP_CXX03_LANG
744738
745 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__insert_unique(__v); }739 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); }
746 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {740 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
747 return __tree_.__insert_unique(__p, __v);741 return __tree_.__emplace_hint_unique(__p, __v);
748 }742 }
749743
750 template <class _InputIterator>744 template <class _InputIterator>
751 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {745 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
752 for (const_iterator __e = cend(); __f != __l; ++__f)746 for (const_iterator __e = cend(); __f != __l; ++__f)
753 __tree_.__insert_unique(__e, *__f);747 __tree_.__emplace_hint_unique(__e, *__f);
754 }748 }
755749
756# if _LIBCPP_STD_VER >= 23750# if _LIBCPP_STD_VER >= 23
...@@ -758,18 +752,18 @@ public:...@@ -758,18 +752,18 @@ public:
758 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {752 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
759 const_iterator __end = cend();753 const_iterator __end = cend();
760 for (auto&& __element : __range) {754 for (auto&& __element : __range) {
761 __tree_.__insert_unique(__end, std::forward<decltype(__element)>(__element));755 __tree_.__emplace_hint_unique(__end, std::forward<decltype(__element)>(__element));
762 }756 }
763 }757 }
764# endif758# endif
765759
766# ifndef _LIBCPP_CXX03_LANG760# ifndef _LIBCPP_CXX03_LANG
767 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {761 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
768 return __tree_.__insert_unique(std::move(__v));762 return __tree_.__emplace_unique(std::move(__v));
769 }763 }
770764
771 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {765 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
772 return __tree_.__insert_unique(__p, std::move(__v));766 return __tree_.__emplace_hint_unique(__p, std::move(__v));
773 }767 }
774768
775 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }769 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
...@@ -1003,9 +997,9 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,...@@ -1003,9 +997,9 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
1003997
1004# else // _LIBCPP_STD_VER <= 17998# else // _LIBCPP_STD_VER <= 17
1005999
1006template <class _Key, class _Allocator>1000template <class _Key, class _Compare, class _Allocator>
1007_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>1001_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
1008operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) {1002operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
1009 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);1003 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1010}1004}
10111005
...@@ -1032,10 +1026,12 @@ struct __container_traits<set<_Key, _Compare, _Allocator> > {...@@ -1032,10 +1026,12 @@ struct __container_traits<set<_Key, _Compare, _Allocator> > {
1032 // For associative containers, if an exception is thrown by any operation from within1026 // For associative containers, if an exception is thrown by any operation from within
1033 // an insert or emplace function inserting a single element, the insertion has no effect.1027 // an insert or emplace function inserting a single element, the insertion has no effect.
1034 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;1028 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1029
1030 static _LIBCPP_CONSTEXPR const bool __reservable = false;
1035};1031};
10361032
1037template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> >1033template <class _Key, class _Compare, class _Allocator>
1038class _LIBCPP_TEMPLATE_VIS multiset {1034class multiset {
1039public:1035public:
1040 // types:1036 // types:
1041 typedef _Key key_type;1037 typedef _Key key_type;
...@@ -1072,9 +1068,9 @@ public:...@@ -1072,9 +1068,9 @@ public:
1072# endif1068# endif
10731069
1074 template <class _Key2, class _Compare2, class _Alloc2>1070 template <class _Key2, class _Compare2, class _Alloc2>
1075 friend class _LIBCPP_TEMPLATE_VIS set;1071 friend class set;
1076 template <class _Key2, class _Compare2, class _Alloc2>1072 template <class _Key2, class _Compare2, class _Alloc2>
1077 friend class _LIBCPP_TEMPLATE_VIS multiset;1073 friend class multiset;
10781074
1079 // construct/copy/destroy:1075 // construct/copy/destroy:
1080 _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_(1076 _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_(
...@@ -1129,14 +1125,10 @@ public:...@@ -1129,14 +1125,10 @@ public:
1129 insert(__s.begin(), __s.end());1125 insert(__s.begin(), __s.end());
1130 }1126 }
11311127
1132 _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) {1128 _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) = default;
1133 __tree_ = __s.__tree_;
1134 return *this;
1135 }
11361129
1137# ifndef _LIBCPP_CXX03_LANG1130# ifndef _LIBCPP_CXX03_LANG
1138 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value)1131 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value) = default;
1139 : __tree_(std::move(__s.__tree_)) {}
11401132
1141 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);1133 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);
1142# endif // _LIBCPP_CXX03_LANG1134# endif // _LIBCPP_CXX03_LANG
...@@ -1174,7 +1166,9 @@ public:...@@ -1174,7 +1166,9 @@ public:
1174 }1166 }
1175# endif // _LIBCPP_CXX03_LANG1167# endif // _LIBCPP_CXX03_LANG
11761168
1177 _LIBCPP_HIDE_FROM_ABI ~multiset() { static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), ""); }1169 _LIBCPP_HIDE_FROM_ABI ~multiset() {
1170 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
1171 }
11781172
1179 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }1173 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1180 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }1174 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
...@@ -1207,15 +1201,15 @@ public:...@@ -1207,15 +1201,15 @@ public:
1207 }1201 }
1208# endif // _LIBCPP_CXX03_LANG1202# endif // _LIBCPP_CXX03_LANG
12091203
1210 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); }1204 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); }
1211 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {1205 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1212 return __tree_.__insert_multi(__p, __v);1206 return __tree_.__emplace_hint_multi(__p, __v);
1213 }1207 }
12141208
1215 template <class _InputIterator>1209 template <class _InputIterator>
1216 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {1210 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
1217 for (const_iterator __e = cend(); __f != __l; ++__f)1211 for (const_iterator __e = cend(); __f != __l; ++__f)
1218 __tree_.__insert_multi(__e, *__f);1212 __tree_.__emplace_hint_multi(__e, *__f);
1219 }1213 }
12201214
1221# if _LIBCPP_STD_VER >= 231215# if _LIBCPP_STD_VER >= 23
...@@ -1223,16 +1217,16 @@ public:...@@ -1223,16 +1217,16 @@ public:
1223 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1217 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1224 const_iterator __end = cend();1218 const_iterator __end = cend();
1225 for (auto&& __element : __range) {1219 for (auto&& __element : __range) {
1226 __tree_.__insert_multi(__end, std::forward<decltype(__element)>(__element));1220 __tree_.__emplace_hint_multi(__end, std::forward<decltype(__element)>(__element));
1227 }1221 }
1228 }1222 }
1229# endif1223# endif
12301224
1231# ifndef _LIBCPP_CXX03_LANG1225# ifndef _LIBCPP_CXX03_LANG
1232 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); }1226 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); }
12331227
1234 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {1228 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1235 return __tree_.__insert_multi(__p, std::move(__v));1229 return __tree_.__emplace_hint_multi(__p, std::move(__v));
1236 }1230 }
12371231
1238 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1232 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
...@@ -1470,9 +1464,9 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,...@@ -1470,9 +1464,9 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,
14701464
1471# else // _LIBCPP_STD_VER <= 171465# else // _LIBCPP_STD_VER <= 17
14721466
1473template <class _Key, class _Allocator>1467template <class _Key, class _Compare, class _Allocator>
1474_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>1468_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
1475operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {1469operator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
1476 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);1470 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
1477}1471}
14781472
...@@ -1499,6 +1493,8 @@ struct __container_traits<multiset<_Key, _Compare, _Allocator> > {...@@ -1499,6 +1493,8 @@ struct __container_traits<multiset<_Key, _Compare, _Allocator> > {
1499 // For associative containers, if an exception is thrown by any operation from within1493 // For associative containers, if an exception is thrown by any operation from within
1500 // an insert or emplace function inserting a single element, the insertion has no effect.1494 // an insert or emplace function inserting a single element, the insertion has no effect.
1501 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;1495 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee = true;
1496
1497 static _LIBCPP_CONSTEXPR const bool __reservable = false;
1502};1498};
15031499
1504_LIBCPP_END_NAMESPACE_STD1500_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/shared_mutex+76-91
...@@ -123,7 +123,7 @@ template <class Mutex>...@@ -123,7 +123,7 @@ template <class Mutex>
123*/123*/
124124
125#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)125#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
126# include <__cxx03/shared_mutex>126# include <__cxx03/__config>
127#else127#else
128# include <__config>128# include <__config>
129129
...@@ -183,7 +183,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {...@@ -183,7 +183,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {
183};183};
184184
185# if _LIBCPP_STD_VER >= 17185# if _LIBCPP_STD_VER >= 17
186class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex {186class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("shared_mutex") shared_mutex {
187 __shared_mutex_base __base_;187 __shared_mutex_base __base_;
188188
189public:189public:
...@@ -194,35 +194,23 @@ public:...@@ -194,35 +194,23 @@ public:
194 shared_mutex& operator=(const shared_mutex&) = delete;194 shared_mutex& operator=(const shared_mutex&) = delete;
195195
196 // Exclusive ownership196 // Exclusive ownership
197 _LIBCPP_HIDE_FROM_ABI void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_capability__()) {197 _LIBCPP_ACQUIRE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI void lock() { return __base_.lock(); }
198 return __base_.lock();198 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock() { return __base_.try_lock(); }
199 }199 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock() { return __base_.unlock(); }
200 _LIBCPP_HIDE_FROM_ABI bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)) {
201 return __base_.try_lock();
202 }
203 _LIBCPP_HIDE_FROM_ABI void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_capability__()) {
204 return __base_.unlock();
205 }
206200
207 // Shared ownership201 // Shared ownership
208 _LIBCPP_HIDE_FROM_ABI void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_shared_capability__()) {202 _LIBCPP_ACQUIRE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void lock_shared() { return __base_.lock_shared(); }
209 return __base_.lock_shared();203 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock_shared() {
210 }
211 _LIBCPP_HIDE_FROM_ABI bool try_lock_shared()
212 _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)) {
213 return __base_.try_lock_shared();204 return __base_.try_lock_shared();
214 }205 }
215 _LIBCPP_HIDE_FROM_ABI void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_shared_capability__()) {206 _LIBCPP_RELEASE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock_shared() { return __base_.unlock_shared(); }
216 return __base_.unlock_shared();
217 }
218207
219 // typedef __shared_mutex_base::native_handle_type native_handle_type;208 // typedef __shared_mutex_base::native_handle_type native_handle_type;
220 // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }209 // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }
221};210};
222# endif211# endif
223212
224class _LIBCPP_EXPORTED_FROM_ABI213class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("shared_timed_mutex") shared_timed_mutex {
225_LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex {
226 __shared_mutex_base __base_;214 __shared_mutex_base __base_;
227215
228public:216public:
...@@ -233,81 +221,77 @@ public:...@@ -233,81 +221,77 @@ public:
233 shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;221 shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
234222
235 // Exclusive ownership223 // Exclusive ownership
236 void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_capability__());224 void lock() _LIBCPP_ACQUIRE_CAPABILITY();
237 bool try_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true));225 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock();
238 template <class _Rep, class _Period>226 template <class _Rep, class _Period>
239 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)227 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
240 _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true)) {228 try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) {
241 return try_lock_until(chrono::steady_clock::now() + __rel_time);229 return try_lock_until(chrono::steady_clock::now() + __rel_time);
242 }230 }
231
243 template <class _Clock, class _Duration>232 template <class _Clock, class _Duration>
244 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool233 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
245 try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)234 try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {
246 _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_capability__(true));235 unique_lock<mutex> __lk(__base_.__mut_);
247 void unlock() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_capability__());236 if (__base_.__state_ & __base_.__write_entered_) {
237 while (true) {
238 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);
239 if ((__base_.__state_ & __base_.__write_entered_) == 0)
240 break;
241 if (__status == cv_status::timeout)
242 return false;
243 }
244 }
245 __base_.__state_ |= __base_.__write_entered_;
246 if (__base_.__state_ & __base_.__n_readers_) {
247 while (true) {
248 cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time);
249 if ((__base_.__state_ & __base_.__n_readers_) == 0)
250 break;
251 if (__status == cv_status::timeout) {
252 __base_.__state_ &= ~__base_.__write_entered_;
253 __base_.__gate1_.notify_all();
254 return false;
255 }
256 }
257 }
258 return true;
259 }
260
261 _LIBCPP_RELEASE_CAPABILITY void unlock();
248262
249 // Shared ownership263 // Shared ownership
250 void lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__acquire_shared_capability__());264 _LIBCPP_ACQUIRE_SHARED_CAPABILITY void lock_shared();
251 bool try_lock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true));265 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) bool try_lock_shared();
252 template <class _Rep, class _Period>266 template <class _Rep, class _Period>
253 _LIBCPP_HIDE_FROM_ABI bool try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time)267 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
254 _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true)) {268 try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) {
255 return try_lock_shared_until(chrono::steady_clock::now() + __rel_time);269 return try_lock_shared_until(chrono::steady_clock::now() + __rel_time);
256 }270 }
257 template <class _Clock, class _Duration>
258 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
259 try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
260 _LIBCPP_THREAD_SAFETY_ANNOTATION(__try_acquire_shared_capability__(true));
261 void unlock_shared() _LIBCPP_THREAD_SAFETY_ANNOTATION(__release_shared_capability__());
262};
263271
264template <class _Clock, class _Duration>272 template <class _Clock, class _Duration>
265bool shared_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {273 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
266 unique_lock<mutex> __lk(__base_.__mut_);274 try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {
267 if (__base_.__state_ & __base_.__write_entered_) {275 unique_lock<mutex> __lk(__base_.__mut_);
268 while (true) {276 if ((__base_.__state_ & __base_.__write_entered_) ||
269 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);277 (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_) {
270 if ((__base_.__state_ & __base_.__write_entered_) == 0)278 while (true) {
271 break;279 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);
272 if (__status == cv_status::timeout)280 if ((__base_.__state_ & __base_.__write_entered_) == 0 &&
273 return false;281 (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_)
274 }282 break;
275 }283 if (__status == cv_status::timeout)
276 __base_.__state_ |= __base_.__write_entered_;284 return false;
277 if (__base_.__state_ & __base_.__n_readers_) {
278 while (true) {
279 cv_status __status = __base_.__gate2_.wait_until(__lk, __abs_time);
280 if ((__base_.__state_ & __base_.__n_readers_) == 0)
281 break;
282 if (__status == cv_status::timeout) {
283 __base_.__state_ &= ~__base_.__write_entered_;
284 __base_.__gate1_.notify_all();
285 return false;
286 }285 }
287 }286 }
287 unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1;
288 __base_.__state_ &= ~__base_.__n_readers_;
289 __base_.__state_ |= __num_readers;
290 return true;
288 }291 }
289 return true;
290}
291292
292template <class _Clock, class _Duration>293 _LIBCPP_RELEASE_SHARED_CAPABILITY void unlock_shared();
293bool shared_timed_mutex::try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {294};
294 unique_lock<mutex> __lk(__base_.__mut_);
295 if ((__base_.__state_ & __base_.__write_entered_) ||
296 (__base_.__state_ & __base_.__n_readers_) == __base_.__n_readers_) {
297 while (true) {
298 cv_status __status = __base_.__gate1_.wait_until(__lk, __abs_time);
299 if ((__base_.__state_ & __base_.__write_entered_) == 0 &&
300 (__base_.__state_ & __base_.__n_readers_) < __base_.__n_readers_)
301 break;
302 if (__status == cv_status::timeout)
303 return false;
304 }
305 }
306 unsigned __num_readers = (__base_.__state_ & __base_.__n_readers_) + 1;
307 __base_.__state_ &= ~__base_.__n_readers_;
308 __base_.__state_ |= __num_readers;
309 return true;
310}
311295
312template <class _Mutex>296template <class _Mutex>
313class shared_lock {297class shared_lock {
...@@ -400,9 +384,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);...@@ -400,9 +384,9 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
400template <class _Mutex>384template <class _Mutex>
401void shared_lock<_Mutex>::lock() {385void shared_lock<_Mutex>::lock() {
402 if (__m_ == nullptr)386 if (__m_ == nullptr)
403 __throw_system_error(EPERM, "shared_lock::lock: references null mutex");387 std::__throw_system_error(EPERM, "shared_lock::lock: references null mutex");
404 if (__owns_)388 if (__owns_)
405 __throw_system_error(EDEADLK, "shared_lock::lock: already locked");389 std::__throw_system_error(EDEADLK, "shared_lock::lock: already locked");
406 __m_->lock_shared();390 __m_->lock_shared();
407 __owns_ = true;391 __owns_ = true;
408}392}
...@@ -410,9 +394,9 @@ void shared_lock<_Mutex>::lock() {...@@ -410,9 +394,9 @@ void shared_lock<_Mutex>::lock() {
410template <class _Mutex>394template <class _Mutex>
411bool shared_lock<_Mutex>::try_lock() {395bool shared_lock<_Mutex>::try_lock() {
412 if (__m_ == nullptr)396 if (__m_ == nullptr)
413 __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex");397 std::__throw_system_error(EPERM, "shared_lock::try_lock: references null mutex");
414 if (__owns_)398 if (__owns_)
415 __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked");399 std::__throw_system_error(EDEADLK, "shared_lock::try_lock: already locked");
416 __owns_ = __m_->try_lock_shared();400 __owns_ = __m_->try_lock_shared();
417 return __owns_;401 return __owns_;
418}402}
...@@ -421,9 +405,9 @@ template <class _Mutex>...@@ -421,9 +405,9 @@ template <class _Mutex>
421template <class _Rep, class _Period>405template <class _Rep, class _Period>
422bool shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {406bool shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
423 if (__m_ == nullptr)407 if (__m_ == nullptr)
424 __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex");408 std::__throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex");
425 if (__owns_)409 if (__owns_)
426 __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked");410 std::__throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked");
427 __owns_ = __m_->try_lock_shared_for(__d);411 __owns_ = __m_->try_lock_shared_for(__d);
428 return __owns_;412 return __owns_;
429}413}
...@@ -432,9 +416,9 @@ template <class _Mutex>...@@ -432,9 +416,9 @@ template <class _Mutex>
432template <class _Clock, class _Duration>416template <class _Clock, class _Duration>
433bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {417bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
434 if (__m_ == nullptr)418 if (__m_ == nullptr)
435 __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex");419 std::__throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex");
436 if (__owns_)420 if (__owns_)
437 __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked");421 std::__throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked");
438 __owns_ = __m_->try_lock_shared_until(__t);422 __owns_ = __m_->try_lock_shared_until(__t);
439 return __owns_;423 return __owns_;
440}424}
...@@ -442,7 +426,7 @@ bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat...@@ -442,7 +426,7 @@ bool shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Durat
442template <class _Mutex>426template <class _Mutex>
443void shared_lock<_Mutex>::unlock() {427void shared_lock<_Mutex>::unlock() {
444 if (!__owns_)428 if (!__owns_)
445 __throw_system_error(EPERM, "shared_lock::unlock: not locked");429 std::__throw_system_error(EPERM, "shared_lock::unlock: not locked");
446 __m_->unlock_shared();430 __m_->unlock_shared();
447 __owns_ = false;431 __owns_ = false;
448}432}
...@@ -461,6 +445,7 @@ _LIBCPP_POP_MACROS...@@ -461,6 +445,7 @@ _LIBCPP_POP_MACROS
461# endif // _LIBCPP_HAS_THREADS445# endif // _LIBCPP_HAS_THREADS
462446
463# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20447# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
448# include <optional>
464# include <system_error>449# include <system_error>
465# endif450# endif
466#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)451#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/source_location+1-1
...@@ -26,7 +26,7 @@ namespace std {...@@ -26,7 +26,7 @@ namespace std {
26*/26*/
2727
28#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)28#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
29# include <__cxx03/source_location>29# include <__cxx03/__config>
30#else30#else
31# include <__config>31# include <__config>
32# include <cstdint>32# include <cstdint>
lib/libcxx/include/span+3-3
...@@ -145,7 +145,7 @@ template<class R>...@@ -145,7 +145,7 @@ template<class R>
145*/145*/
146146
147#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)147#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
148# include <__cxx03/span>148# include <__cxx03/__config>
149#else149#else
150# include <__assert>150# include <__assert>
151# include <__concepts/convertible_to.h>151# include <__concepts/convertible_to.h>
...@@ -229,7 +229,7 @@ template <class _Sentinel, class _It>...@@ -229,7 +229,7 @@ template <class _Sentinel, class _It>
229concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>;229concept __span_compatible_sentinel_for = sized_sentinel_for<_Sentinel, _It> && !is_convertible_v<_Sentinel, size_t>;
230230
231template <typename _Tp, size_t _Extent>231template <typename _Tp, size_t _Extent>
232class _LIBCPP_TEMPLATE_VIS span {232class span {
233public:233public:
234 // constants and types234 // constants and types
235 using element_type = _Tp;235 using element_type = _Tp;
...@@ -412,7 +412,7 @@ private:...@@ -412,7 +412,7 @@ private:
412};412};
413413
414template <typename _Tp>414template <typename _Tp>
415class _LIBCPP_TEMPLATE_VIS span<_Tp, dynamic_extent> {415class span<_Tp, dynamic_extent> {
416public:416public:
417 // constants and types417 // constants and types
418 using element_type = _Tp;418 using element_type = _Tp;
lib/libcxx/include/sstream+5-5
...@@ -325,7 +325,7 @@ typedef basic_stringstream<wchar_t> wstringstream;...@@ -325,7 +325,7 @@ typedef basic_stringstream<wchar_t> wstringstream;
325# include <__utility/swap.h>325# include <__utility/swap.h>
326# include <ios>326# include <ios>
327# include <istream>327# include <istream>
328# include <locale>328# include <streambuf>
329# include <string>329# include <string>
330# include <string_view>330# include <string_view>
331# include <version>331# include <version>
...@@ -342,7 +342,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -342,7 +342,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
342// Class template basic_stringbuf [stringbuf]342// Class template basic_stringbuf [stringbuf]
343343
344template <class _CharT, class _Traits, class _Allocator>344template <class _CharT, class _Traits, class _Allocator>
345class _LIBCPP_TEMPLATE_VIS basic_stringbuf : public basic_streambuf<_CharT, _Traits> {345class basic_stringbuf : public basic_streambuf<_CharT, _Traits> {
346public:346public:
347 typedef _CharT char_type;347 typedef _CharT char_type;
348 typedef _Traits traits_type;348 typedef _Traits traits_type;
...@@ -864,7 +864,7 @@ typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<...@@ -864,7 +864,7 @@ typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<
864// Class template basic_istringstream [istringstream]864// Class template basic_istringstream [istringstream]
865865
866template <class _CharT, class _Traits, class _Allocator>866template <class _CharT, class _Traits, class _Allocator>
867class _LIBCPP_TEMPLATE_VIS basic_istringstream : public basic_istream<_CharT, _Traits> {867class basic_istringstream : public basic_istream<_CharT, _Traits> {
868public:868public:
869 typedef _CharT char_type;869 typedef _CharT char_type;
870 typedef _Traits traits_type;870 typedef _Traits traits_type;
...@@ -1000,7 +1000,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<...@@ -1000,7 +1000,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<
1000// Class template basic_ostringstream [ostringstream]1000// Class template basic_ostringstream [ostringstream]
10011001
1002template <class _CharT, class _Traits, class _Allocator>1002template <class _CharT, class _Traits, class _Allocator>
1003class _LIBCPP_TEMPLATE_VIS basic_ostringstream : public basic_ostream<_CharT, _Traits> {1003class basic_ostringstream : public basic_ostream<_CharT, _Traits> {
1004public:1004public:
1005 typedef _CharT char_type;1005 typedef _CharT char_type;
1006 typedef _Traits traits_type;1006 typedef _Traits traits_type;
...@@ -1138,7 +1138,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<...@@ -1138,7 +1138,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<
1138// Class template basic_stringstream [stringstream]1138// Class template basic_stringstream [stringstream]
11391139
1140template <class _CharT, class _Traits, class _Allocator>1140template <class _CharT, class _Traits, class _Allocator>
1141class _LIBCPP_TEMPLATE_VIS basic_stringstream : public basic_iostream<_CharT, _Traits> {1141class basic_stringstream : public basic_iostream<_CharT, _Traits> {
1142public:1142public:
1143 typedef _CharT char_type;1143 typedef _CharT char_type;
1144 typedef _Traits traits_type;1144 typedef _Traits traits_type;
lib/libcxx/include/stack+13-7
...@@ -153,7 +153,7 @@ template <class _Tp, class _Container>...@@ -153,7 +153,7 @@ template <class _Tp, class _Container>
153_LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);153_LIBCPP_HIDE_FROM_ABI bool operator<(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
154154
155template <class _Tp, class _Container /*= deque<_Tp>*/>155template <class _Tp, class _Container /*= deque<_Tp>*/>
156class _LIBCPP_TEMPLATE_VIS stack {156class stack {
157public:157public:
158 typedef _Container container_type;158 typedef _Container container_type;
159 typedef typename container_type::value_type value_type;159 typedef typename container_type::value_type value_type;
...@@ -279,10 +279,18 @@ public:...@@ -279,10 +279,18 @@ public:
279 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }279 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
280280
281 template <class _T1, class _OtherContainer>281 template <class _T1, class _OtherContainer>
282 friend bool operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);282 friend _LIBCPP_HIDE_FROM_ABI bool
283 operator==(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);
283284
284 template <class _T1, class _OtherContainer>285 template <class _T1, class _OtherContainer>
285 friend bool operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);286 friend _LIBCPP_HIDE_FROM_ABI bool
287 operator<(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);
288
289# if _LIBCPP_STD_VER >= 20
290 template <class _T1, three_way_comparable _OtherContainer>
291 friend _LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_OtherContainer>
292 operator<=>(const stack<_T1, _OtherContainer>& __x, const stack<_T1, _OtherContainer>& __y);
293# endif
286};294};
287295
288# if _LIBCPP_STD_VER >= 17296# if _LIBCPP_STD_VER >= 17
...@@ -353,8 +361,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x,...@@ -353,8 +361,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const stack<_Tp, _Container>& __x,
353template <class _Tp, three_way_comparable _Container>361template <class _Tp, three_way_comparable _Container>
354_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>362_LIBCPP_HIDE_FROM_ABI compare_three_way_result_t<_Container>
355operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {363operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y) {
356 // clang 16 bug: declaring `friend operator<=>` causes "use of overloaded operator '*' is ambiguous" errors364 return __x.c <=> __y.c;
357 return __x.__get_container() <=> __y.__get_container();
358}365}
359366
360# endif367# endif
...@@ -366,8 +373,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _...@@ -366,8 +373,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _
366}373}
367374
368template <class _Tp, class _Container, class _Alloc>375template <class _Tp, class _Container, class _Alloc>
369struct _LIBCPP_TEMPLATE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {376struct uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {};
370};
371377
372_LIBCPP_END_NAMESPACE_STD378_LIBCPP_END_NAMESPACE_STD
373379
lib/libcxx/include/stdlib.h+2-17
...@@ -106,23 +106,8 @@ extern "C++" {...@@ -106,23 +106,8 @@ extern "C++" {
106# undef llabs106# undef llabs
107# endif107# endif
108108
109// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined109# include <__math/abs.h>
110# if !defined(_LIBCPP_MSVCRT)110using std::__math::abs;
111[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }
112[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }
113# endif // !defined(_LIBCPP_MSVCRT)
114
115[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {
116 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
117}
118
119[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {
120 return __builtin_fabs(__lcpp_x);
121}
122
123[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {
124 return __builtin_fabsl(__lcpp_x);
125}
126111
127// div112// div
128113
lib/libcxx/include/stop_token+1-1
...@@ -32,7 +32,7 @@ namespace std {...@@ -32,7 +32,7 @@ namespace std {
32*/32*/
3333
34#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)34#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
35# include <__cxx03/stop_token>35# include <__cxx03/__config>
36#else36#else
37# include <__config>37# include <__config>
3838
lib/libcxx/include/streambuf+38-25
...@@ -134,7 +134,7 @@ _LIBCPP_PUSH_MACROS...@@ -134,7 +134,7 @@ _LIBCPP_PUSH_MACROS
134_LIBCPP_BEGIN_NAMESPACE_STD134_LIBCPP_BEGIN_NAMESPACE_STD
135135
136template <class _CharT, class _Traits>136template <class _CharT, class _Traits>
137class _LIBCPP_TEMPLATE_VIS basic_streambuf {137class basic_streambuf {
138public:138public:
139 // types:139 // types:
140 typedef _CharT char_type;140 typedef _CharT char_type;
...@@ -178,8 +178,8 @@ public:...@@ -178,8 +178,8 @@ public:
178 // Get and put areas:178 // Get and put areas:
179 // 27.6.2.2.3 Get area:179 // 27.6.2.2.3 Get area:
180 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() {180 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() {
181 if (__ninp_ < __einp_)181 if (gptr() < egptr())
182 return static_cast<streamsize>(__einp_ - __ninp_);182 return static_cast<streamsize>(egptr() - gptr());
183 return showmanyc();183 return showmanyc();
184 }184 }
185185
...@@ -190,37 +190,42 @@ public:...@@ -190,37 +190,42 @@ public:
190 }190 }
191191
192 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() {192 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() {
193 if (__ninp_ == __einp_)193 if (gptr() == egptr())
194 return uflow();194 return uflow();
195 return traits_type::to_int_type(*__ninp_++);195 int_type __c = traits_type::to_int_type(*gptr());
196 this->gbump(1);
197 return __c;
196 }198 }
197199
198 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() {200 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() {
199 if (__ninp_ == __einp_)201 if (gptr() == egptr())
200 return underflow();202 return underflow();
201 return traits_type::to_int_type(*__ninp_);203 return traits_type::to_int_type(*gptr());
202 }204 }
203205
204 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); }206 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); }
205207
206 // 27.6.2.2.4 Putback:208 // 27.6.2.2.4 Putback:
207 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) {209 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) {
208 if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))210 if (eback() == gptr() || !traits_type::eq(__c, *(gptr() - 1)))
209 return pbackfail(traits_type::to_int_type(__c));211 return pbackfail(traits_type::to_int_type(__c));
210 return traits_type::to_int_type(*--__ninp_);212 this->gbump(-1);
213 return traits_type::to_int_type(*gptr());
211 }214 }
212215
213 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() {216 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() {
214 if (__binp_ == __ninp_)217 if (eback() == gptr())
215 return pbackfail();218 return pbackfail();
216 return traits_type::to_int_type(*--__ninp_);219 this->gbump(-1);
220 return traits_type::to_int_type(*gptr());
217 }221 }
218222
219 // 27.6.2.2.5 Put area:223 // 27.6.2.2.5 Put area:
220 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) {224 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) {
221 if (__nout_ == __eout_)225 if (pptr() == epptr())
222 return overflow(traits_type::to_int_type(__c));226 return overflow(traits_type::to_int_type(__c));
223 *__nout_++ = __c;227 *pptr() = __c;
228 this->pbump(1);
224 return traits_type::to_int_type(__c);229 return traits_type::to_int_type(__c);
225 }230 }
226231
...@@ -267,6 +272,9 @@ protected:...@@ -267,6 +272,9 @@ protected:
267272
268 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; }273 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; }
269274
275 // gbump takes an int, so it might not be able to represent the offset we want to add.
276 _LIBCPP_HIDE_FROM_ABI void __gbump_ptrdiff(ptrdiff_t __n) { __ninp_ += __n; }
277
270 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) {278 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) {
271 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range");279 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range");
272 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range");280 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range");
...@@ -309,17 +317,16 @@ protected:...@@ -309,17 +317,16 @@ protected:
309 virtual streamsize showmanyc() { return 0; }317 virtual streamsize showmanyc() { return 0; }
310318
311 virtual streamsize xsgetn(char_type* __s, streamsize __n) {319 virtual streamsize xsgetn(char_type* __s, streamsize __n) {
312 const int_type __eof = traits_type::eof();
313 int_type __c;320 int_type __c;
314 streamsize __i = 0;321 streamsize __i = 0;
315 while (__i < __n) {322 while (__i < __n) {
316 if (__ninp_ < __einp_) {323 if (gptr() < egptr()) {
317 const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i));324 const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(egptr() - gptr(), __n - __i));
318 traits_type::copy(__s, __ninp_, __len);325 traits_type::copy(__s, gptr(), __len);
319 __s += __len;326 __s += __len;
320 __i += __len;327 __i += __len;
321 this->gbump(__len);328 this->gbump(__len);
322 } else if ((__c = uflow()) != __eof) {329 } else if ((__c = uflow()) != traits_type::eof()) {
323 *__s = traits_type::to_char_type(__c);330 *__s = traits_type::to_char_type(__c);
324 ++__s;331 ++__s;
325 ++__i;332 ++__i;
...@@ -333,7 +340,9 @@ protected:...@@ -333,7 +340,9 @@ protected:
333 virtual int_type uflow() {340 virtual int_type uflow() {
334 if (underflow() == traits_type::eof())341 if (underflow() == traits_type::eof())
335 return traits_type::eof();342 return traits_type::eof();
336 return traits_type::to_int_type(*__ninp_++);343 int_type __c = traits_type::to_int_type(*gptr());
344 this->gbump(1);
345 return __c;
337 }346 }
338347
339 // 27.6.2.4.4 Putback:348 // 27.6.2.4.4 Putback:
...@@ -342,17 +351,16 @@ protected:...@@ -342,17 +351,16 @@ protected:
342 // 27.6.2.4.5 Put area:351 // 27.6.2.4.5 Put area:
343 virtual streamsize xsputn(const char_type* __s, streamsize __n) {352 virtual streamsize xsputn(const char_type* __s, streamsize __n) {
344 streamsize __i = 0;353 streamsize __i = 0;
345 int_type __eof = traits_type::eof();
346 while (__i < __n) {354 while (__i < __n) {
347 if (__nout_ >= __eout_) {355 if (pptr() >= epptr()) {
348 if (overflow(traits_type::to_int_type(*__s)) == __eof)356 if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
349 break;357 break;
350 ++__s;358 ++__s;
351 ++__i;359 ++__i;
352 } else {360 } else {
353 streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i);361 streamsize __chunk_size = std::min(epptr() - pptr(), __n - __i);
354 traits_type::copy(__nout_, __s, __chunk_size);362 traits_type::copy(pptr(), __s, __chunk_size);
355 __nout_ += __chunk_size;363 __pbump(__chunk_size);
356 __s += __chunk_size;364 __s += __chunk_size;
357 __i += __chunk_size;365 __i += __chunk_size;
358 }366 }
...@@ -370,6 +378,10 @@ private:...@@ -370,6 +378,10 @@ private:
370 char_type* __bout_ = nullptr;378 char_type* __bout_ = nullptr;
371 char_type* __nout_ = nullptr;379 char_type* __nout_ = nullptr;
372 char_type* __eout_ = nullptr;380 char_type* __eout_ = nullptr;
381
382 template <class _CharT2, class _Traits2, class _Allocator>
383 _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT2, _Traits2>&
384 getline(basic_istream<_CharT2, _Traits2>&, basic_string<_CharT2, _Traits2, _Allocator>&, _CharT2);
373};385};
374386
375extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;387extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
...@@ -386,6 +398,7 @@ _LIBCPP_POP_MACROS...@@ -386,6 +398,7 @@ _LIBCPP_POP_MACROS
386398
387# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20399# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
388# include <cstdint>400# include <cstdint>
401# include <optional>
389# endif402# endif
390#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)403#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
391404
lib/libcxx/include/string+596-912
...@@ -235,9 +235,9 @@ public:...@@ -235,9 +235,9 @@ public:
235 template <class T>235 template <class T>
236 basic_string& insert(size_type pos1, const T& t); // constexpr since C++20236 basic_string& insert(size_type pos1, const T& t); // constexpr since C++20
237 basic_string& insert(size_type pos1, const basic_string& str,237 basic_string& insert(size_type pos1, const basic_string& str,
238 size_type pos2, size_type n); // constexpr since C++20238 size_type pos2, size_type n2=npos); // constexpr since C++20
239 template <class T>239 template <class T>
240 basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n); // C++17, constexpr since C++20240 basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n=npos); // C++17, constexpr since C++20
241 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20241 basic_string& insert(size_type pos, const value_type* s, size_type n=npos); // C++14, constexpr since C++20
242 basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20242 basic_string& insert(size_type pos, const value_type* s); // constexpr since C++20
243 basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20243 basic_string& insert(size_type pos, size_type n, value_type c); // constexpr since C++20
...@@ -260,7 +260,7 @@ public:...@@ -260,7 +260,7 @@ public:
260 size_type pos2, size_type n2=npos); // C++14, constexpr since C++20260 size_type pos2, size_type n2=npos); // C++14, constexpr since C++20
261 template <class T>261 template <class T>
262 basic_string& replace(size_type pos1, size_type n1, const T& t,262 basic_string& replace(size_type pos1, size_type n1, const T& t,
263 size_type pos2, size_type n); // C++17, constexpr since C++20263 size_type pos2, size_type n2=npos); // C++17, constexpr since C++20
264 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20264 basic_string& replace(size_type pos, size_type n1, const value_type* s, size_type n2); // constexpr since C++20
265 basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20265 basic_string& replace(size_type pos, size_type n1, const value_type* s); // constexpr since C++20
266 basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20266 basic_string& replace(size_type pos, size_type n1, size_type n2, value_type c); // constexpr since C++20
...@@ -516,10 +516,10 @@ basic_istream<charT, traits>&...@@ -516,10 +516,10 @@ basic_istream<charT, traits>&
516getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);516getline(basic_istream<charT, traits>& is, basic_string<charT, traits, Allocator>& str);
517517
518template<class charT, class traits, class Allocator, class U>518template<class charT, class traits, class Allocator, class U>
519typename basic_string<charT, traits, Allocator>::size_type519constexpr typename basic_string<charT, traits, Allocator>::size_type
520erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20520erase(basic_string<charT, traits, Allocator>& c, const U& value); // C++20
521template<class charT, class traits, class Allocator, class Predicate>521template<class charT, class traits, class Allocator, class Predicate>
522typename basic_string<charT, traits, Allocator>::size_type522constexpr typename basic_string<charT, traits, Allocator>::size_type
523erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20523erase_if(basic_string<charT, traits, Allocator>& c, Predicate pred); // C++20
524524
525typedef basic_string<char> string;525typedef basic_string<char> string;
...@@ -630,9 +630,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );...@@ -630,9 +630,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
630# include <__type_traits/is_convertible.h>630# include <__type_traits/is_convertible.h>
631# include <__type_traits/is_nothrow_assignable.h>631# include <__type_traits/is_nothrow_assignable.h>
632# include <__type_traits/is_nothrow_constructible.h>632# include <__type_traits/is_nothrow_constructible.h>
633# include <__type_traits/is_replaceable.h>
633# include <__type_traits/is_same.h>634# include <__type_traits/is_same.h>
634# include <__type_traits/is_standard_layout.h>635# include <__type_traits/is_standard_layout.h>
635# include <__type_traits/is_trivial.h>636# include <__type_traits/is_trivially_constructible.h>
637# include <__type_traits/is_trivially_copyable.h>
636# include <__type_traits/is_trivially_relocatable.h>638# include <__type_traits/is_trivially_relocatable.h>
637# include <__type_traits/remove_cvref.h>639# include <__type_traits/remove_cvref.h>
638# include <__type_traits/void_t.h>640# include <__type_traits/void_t.h>
...@@ -676,7 +678,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );...@@ -676,7 +678,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
676_LIBCPP_PUSH_MACROS678_LIBCPP_PUSH_MACROS
677# include <__undef_macros>679# include <__undef_macros>
678680
679# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN681# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
680# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address")))682# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address")))
681// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,683// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,
682// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.684// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.
...@@ -691,50 +693,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -691,50 +693,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
691693
692// basic_string694// basic_string
693695
694template <class _CharT, class _Traits, class _Allocator>
695basic_string<_CharT, _Traits, _Allocator> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
696operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const basic_string<_CharT, _Traits, _Allocator>& __y);
697
698template <class _CharT, class _Traits, class _Allocator>
699_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
700operator+(const _CharT* __x, const basic_string<_CharT, _Traits, _Allocator>& __y);
701
702template <class _CharT, class _Traits, class _Allocator>
703_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
704operator+(_CharT __x, const basic_string<_CharT, _Traits, _Allocator>& __y);
705
706template <class _CharT, class _Traits, class _Allocator>
707inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
708operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, const _CharT* __y);
709
710template <class _CharT, class _Traits, class _Allocator>696template <class _CharT, class _Traits, class _Allocator>
711_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>697_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
712operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);698__concatenate_strings(const _Allocator& __alloc,
713699 __type_identity_t<basic_string_view<_CharT, _Traits> > __str1,
714# if _LIBCPP_STD_VER >= 26700 __type_identity_t<basic_string_view<_CharT, _Traits> > __str2);
715
716template <class _CharT, class _Traits, class _Allocator>
717_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
718operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
719 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);
720
721template <class _CharT, class _Traits, class _Allocator>
722_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
723operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);
724
725template <class _CharT, class _Traits, class _Allocator>
726_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
727operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
728 const basic_string<_CharT, _Traits, _Allocator>& __rhs);
729
730template <class _CharT, class _Traits, class _Allocator>
731_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
732operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs);
733
734# endif
735
736extern template _LIBCPP_EXPORTED_FROM_ABI string operator+
737 <char, char_traits<char>, allocator<char> >(char const*, string const&);
738701
739template <class _Iter>702template <class _Iter>
740struct __string_is_trivial_iterator : public false_type {};703struct __string_is_trivial_iterator : public false_type {};
...@@ -763,22 +726,19 @@ struct __padding<0> {};...@@ -763,22 +726,19 @@ struct __padding<0> {};
763726
764template <class _CharT, class _Traits, class _Allocator>727template <class _CharT, class _Traits, class _Allocator>
765class basic_string {728class basic_string {
766private:
767 using __default_allocator_type _LIBCPP_NODEBUG = allocator<_CharT>;
768
769public:729public:
770 typedef basic_string __self;730 using __self _LIBCPP_NODEBUG = basic_string;
771 typedef basic_string_view<_CharT, _Traits> __self_view;731 using __self_view _LIBCPP_NODEBUG = basic_string_view<_CharT, _Traits>;
772 typedef _Traits traits_type;732 using traits_type = _Traits;
773 typedef _CharT value_type;733 using value_type = _CharT;
774 typedef _Allocator allocator_type;734 using allocator_type = _Allocator;
775 typedef allocator_traits<allocator_type> __alloc_traits;735 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
776 typedef typename __alloc_traits::size_type size_type;736 using size_type = typename __alloc_traits::size_type;
777 typedef typename __alloc_traits::difference_type difference_type;737 using difference_type = typename __alloc_traits::difference_type;
778 typedef value_type& reference;738 using reference = value_type&;
779 typedef const value_type& const_reference;739 using const_reference = const value_type&;
780 typedef typename __alloc_traits::pointer pointer;740 using pointer = typename __alloc_traits::pointer;
781 typedef typename __alloc_traits::const_pointer const_pointer;741 using const_pointer = typename __alloc_traits::const_pointer;
782742
783 // A basic_string contains the following members which may be trivially relocatable:743 // A basic_string contains the following members which may be trivially relocatable:
784 // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes744 // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes
...@@ -789,13 +749,16 @@ public:...@@ -789,13 +749,16 @@ public:
789 //749 //
790 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether750 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether
791 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.751 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
792# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN752# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
793 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially753 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
794 // relocatable. Because the object's memory might be poisoned when its content754 // relocatable. Because the object's memory might be poisoned when its content
795 // is kept inside objects memory (short string optimization), instead of in allocated755 // is kept inside objects memory (short string optimization), instead of in allocated
796 // external memory. In such cases, the destructor is responsible for unpoisoning756 // external memory. In such cases, the destructor is responsible for unpoisoning
797 // the memory to avoid triggering false positives.757 // the memory to avoid triggering false positives.
798 // Therefore it's crucial to ensure the destructor is called.758 // Therefore it's crucial to ensure the destructor is called.
759 //
760 // However, it is replaceable since implementing move-assignment as a destroy + move-construct
761 // will maintain the right ASAN state.
799 using __trivially_relocatable = void;762 using __trivially_relocatable = void;
800# else763# else
801 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<764 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
...@@ -803,8 +766,12 @@ public:...@@ -803,8 +766,12 @@ public:
803 basic_string,766 basic_string,
804 void>;767 void>;
805# endif768# endif
769 using __replaceable _LIBCPP_NODEBUG =
770 __conditional_t<__is_replaceable_v<pointer> && __container_allocator_is_replaceable<__alloc_traits>::value,
771 basic_string,
772 void>;
806773
807# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN774# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {775 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
809 if (__libcpp_is_constant_evaluated())776 if (__libcpp_is_constant_evaluated())
810 return __ptr;777 return __ptr;
...@@ -830,7 +797,9 @@ public:...@@ -830,7 +797,9 @@ public:
830797
831 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");798 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
832 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");799 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
833 static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial");800 static_assert(is_trivially_default_constructible<value_type>::value,
801 "Character type of basic_string must be trivially default constructible");
802 static_assert(is_trivially_copyable<value_type>::value, "Character type of basic_string must be trivially copyable");
834 static_assert(is_same<_CharT, typename traits_type::char_type>::value,803 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
835 "traits_type::char_type must be the same type as CharT");804 "traits_type::char_type must be the same type as CharT");
836 static_assert(is_same<typename allocator_type::value_type, value_type>::value,805 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
...@@ -841,14 +810,14 @@ public:...@@ -841,14 +810,14 @@ public:
841 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's810 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
842 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is811 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
843 // considered contiguous.812 // considered contiguous.
844 typedef __bounded_iter<__wrap_iter<pointer> > iterator;813 using iterator = __bounded_iter<__wrap_iter<pointer> >;
845 typedef __bounded_iter<__wrap_iter<const_pointer> > const_iterator;814 using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >;
846# else815# else
847 typedef __wrap_iter<pointer> iterator;816 using iterator = __wrap_iter<pointer>;
848 typedef __wrap_iter<const_pointer> const_iterator;817 using const_iterator = __wrap_iter<const_pointer>;
849# endif818# endif
850 typedef std::reverse_iterator<iterator> reverse_iterator;819 using reverse_iterator = std::reverse_iterator<iterator>;
851 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;820 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
852821
853private:822private:
854 static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");823 static_assert(CHAR_BIT == 8, "This implementation assumes that one byte contains 8 bits");
...@@ -949,7 +918,7 @@ private:...@@ -949,7 +918,7 @@ private:
949 __uninitialized_size_tag, size_type __size, const allocator_type& __a)918 __uninitialized_size_tag, size_type __size, const allocator_type& __a)
950 : __alloc_(__a) {919 : __alloc_(__a) {
951 if (__size > max_size())920 if (__size > max_size())
952 __throw_length_error();921 this->__throw_length_error();
953 if (__fits_in_sso(__size)) {922 if (__fits_in_sso(__size)) {
954 __rep_ = __rep();923 __rep_ = __rep();
955 __set_short_size(__size);924 __set_short_size(__size);
...@@ -1005,7 +974,12 @@ public:...@@ -1005,7 +974,12 @@ public:
1005974
1006 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()975 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
1007 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)976 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
1008 : __rep_() {977# if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567
978 : __rep_(__short())
979# else
980 : __rep_()
981# endif
982 {
1009 __annotate_new(0);983 __annotate_new(0);
1010 }984 }
1011985
...@@ -1015,7 +989,12 @@ public:...@@ -1015,7 +989,12 @@ public:
1015# else989# else
1016 _NOEXCEPT990 _NOEXCEPT
1017# endif991# endif
1018 : __rep_(), __alloc_(__a) {992# if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567
993 : __rep_(__short()),
994# else
995 : __rep_(),
996# endif
997 __alloc_(__a) {
1019 __annotate_new(0);998 __annotate_new(0);
1020 }999 }
10211000
...@@ -1079,13 +1058,14 @@ public:...@@ -1079,13 +1058,14 @@ public:
1079# endif // _LIBCPP_CXX03_LANG1058# endif // _LIBCPP_CXX03_LANG
10801059
1081 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>1060 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
1082 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s) {1061 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) {
1083 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr");1062 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr");
1084 __init(__s, traits_type::length(__s));1063 __init(__s, traits_type::length(__s));
1085 }1064 }
10861065
1087 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>1066 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, const _Allocator& __a)1067 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1068 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a)
1089 : __alloc_(__a) {1069 : __alloc_(__a) {
1090 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");1070 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
1091 __init(__s, traits_type::length(__s));1071 __init(__s, traits_type::length(__s));
...@@ -1118,7 +1098,7 @@ public:...@@ -1118,7 +1098,7 @@ public:
1118 basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())1098 basic_string&& __str, size_type __pos, size_type __n, const _Allocator& __alloc = _Allocator())
1119 : __alloc_(__alloc) {1099 : __alloc_(__alloc) {
1120 if (__pos > __str.size())1100 if (__pos > __str.size())
1121 __throw_out_of_range();1101 this->__throw_out_of_range();
11221102
1123 auto __len = std::min<size_type>(__n, __str.size() - __pos);1103 auto __len = std::min<size_type>(__n, __str.size() - __pos);
1124 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) {1104 if (__alloc_traits::is_always_equal::value || __alloc == __str.__alloc_) {
...@@ -1141,7 +1121,7 @@ public:...@@ -1141,7 +1121,7 @@ public:
1141 : __alloc_(__a) {1121 : __alloc_(__a) {
1142 size_type __str_sz = __str.size();1122 size_type __str_sz = __str.size();
1143 if (__pos > __str_sz)1123 if (__pos > __str_sz)
1144 __throw_out_of_range();1124 this->__throw_out_of_range();
1145 __init(__str.data() + __pos, std::min(__n, __str_sz - __pos));1125 __init(__str.data() + __pos, std::min(__n, __str_sz - __pos));
1146 }1126 }
11471127
...@@ -1150,15 +1130,15 @@ public:...@@ -1150,15 +1130,15 @@ public:
1150 : __alloc_(__a) {1130 : __alloc_(__a) {
1151 size_type __str_sz = __str.size();1131 size_type __str_sz = __str.size();
1152 if (__pos > __str_sz)1132 if (__pos > __str_sz)
1153 __throw_out_of_range();1133 this->__throw_out_of_range();
1154 __init(__str.data() + __pos, __str_sz - __pos);1134 __init(__str.data() + __pos, __str_sz - __pos);
1155 }1135 }
11561136
1157 template <class _Tp,1137 template <class _Tp,
1158 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1138 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1159 !__is_same_uncvref<_Tp, basic_string>::value,1139 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1160 int> = 0>1140 int> = 0>
1161 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX201141 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1162 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())1142 basic_string(const _Tp& __t, size_type __pos, size_type __n, const allocator_type& __a = allocator_type())
1163 : __alloc_(__a) {1143 : __alloc_(__a) {
1164 __self_view __sv0 = __t;1144 __self_view __sv0 = __t;
...@@ -1168,20 +1148,18 @@ public:...@@ -1168,20 +1148,18 @@ public:
11681148
1169 template <class _Tp,1149 template <class _Tp,
1170 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1150 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1171 !__is_same_uncvref<_Tp, basic_string>::value,1151 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1172 int> = 0>1152 int> = 0>
1173 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1153 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {
1174 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {
1175 __self_view __sv = __t;1154 __self_view __sv = __t;
1176 __init(__sv.data(), __sv.size());1155 __init(__sv.data(), __sv.size());
1177 }1156 }
11781157
1179 template <class _Tp,1158 template <class _Tp,
1180 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1159 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1181 !__is_same_uncvref<_Tp, basic_string>::value,1160 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1182 int> = 0>1161 int> = 0>
1183 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS1162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
1184 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
1185 : __alloc_(__a) {1163 : __alloc_(__a) {
1186 __self_view __sv = __t;1164 __self_view __sv = __t;
1187 __init(__sv.data(), __sv.size());1165 __init(__sv.data(), __sv.size());
...@@ -1238,7 +1216,7 @@ public:...@@ -1238,7 +1216,7 @@ public:
12381216
1239 template <class _Tp,1217 template <class _Tp,
1240 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1218 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1241 !__is_same_uncvref<_Tp, basic_string>::value,1219 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1242 int> = 0>1220 int> = 0>
1243 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {1221 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const _Tp& __t) {
1244 __self_view __sv = __t;1222 __self_view __sv = __t;
...@@ -1256,7 +1234,8 @@ public:...@@ -1256,7 +1234,8 @@ public:
1256 return assign(__il.begin(), __il.size());1234 return assign(__il.begin(), __il.size());
1257 }1235 }
1258# endif1236# endif
1259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const value_type* __s) {1237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1238 operator=(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) {
1260 return assign(__s);1239 return assign(__s);
1261 }1240 }
1262# if _LIBCPP_STD_VER >= 231241# if _LIBCPP_STD_VER >= 23
...@@ -1303,12 +1282,20 @@ public:...@@ -1303,12 +1282,20 @@ public:
1303 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); }1282 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type length() const _NOEXCEPT { return size(); }
13041283
1305 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {1284 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {
1306 size_type __m = __alloc_traits::max_size(__alloc_);1285 if (size_type __m = __alloc_traits::max_size(__alloc_); __m <= std::numeric_limits<size_type>::max() / 2) {
1307 if (__m <= std::numeric_limits<size_type>::max() / 2) {1286 size_type __res = __m - __alignment;
1308 return __m - __alignment;1287
1288 // When the __endian_factor == 2, our string representation assumes that the capacity
1289 // (including the null terminator) is always even, so we have to make sure the lowest bit isn't set when the
1290 // string grows to max_size()
1291 if (__endian_factor == 2)
1292 __res &= ~size_type(1);
1293
1294 // We have to allocate space for the null terminator, but max_size() doesn't include it.
1295 return __res - 1;
1309 } else {1296 } else {
1310 bool __uses_lsb = __endian_factor == 2;1297 bool __uses_lsb = __endian_factor == 2;
1311 return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;1298 return __uses_lsb ? __m - __alignment - 1 : (__m / 2) - __alignment - 1;
1312 }1299 }
1313 }1300 }
13141301
...@@ -1366,15 +1353,15 @@ public:...@@ -1366,15 +1353,15 @@ public:
13661353
1367 template <class _Tp,1354 template <class _Tp,
1368 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1355 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1369 !__is_same_uncvref<_Tp, basic_string >::value,1356 !is_same<__remove_cvref_t<_Tp>, basic_string >::value,
1370 int> = 0>1357 int> = 0>
1371 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const _Tp& __t) {
1372 operator+=(const _Tp& __t) {
1373 __self_view __sv = __t;1359 __self_view __sv = __t;
1374 return append(__sv);1360 return append(__sv);
1375 }1361 }
13761362
1377 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator+=(const value_type* __s) {1363 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1364 operator+=(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) {
1378 return append(__s);1365 return append(__s);
1379 }1366 }
13801367
...@@ -1395,10 +1382,9 @@ public:...@@ -1395,10 +1382,9 @@ public:
13951382
1396 template <class _Tp,1383 template <class _Tp,
1397 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1384 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1398 !__is_same_uncvref<_Tp, basic_string>::value,1385 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1399 int> = 0>1386 int> = 0>
1400 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1387 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const _Tp& __t) {
1401 append(const _Tp& __t) {
1402 __self_view __sv = __t;1388 __self_view __sv = __t;
1403 return append(__sv.data(), __sv.size());1389 return append(__sv.data(), __sv.size());
1404 }1390 }
...@@ -1407,21 +1393,25 @@ public:...@@ -1407,21 +1393,25 @@ public:
14071393
1408 template <class _Tp,1394 template <class _Tp,
1409 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1395 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1410 !__is_same_uncvref<_Tp, basic_string>::value,1396 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1411 int> = 0>1397 int> = 0>
1412 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX201398 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
14131399 append(const _Tp& __t, size_type __pos, size_type __n = npos) {
1414 basic_string&1400 __self_view __sv = __t;
1415 append(const _Tp& __t, size_type __pos, size_type __n = npos);1401 size_type __sz = __sv.size();
1402 if (__pos > __sz)
1403 __throw_out_of_range();
1404 return append(__sv.data() + __pos, std::min(__n, __sz - __pos));
1405 }
14161406
1417 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);1407 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
1418 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);1408 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1419 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);1409 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
14201410
1421 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n);1411 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __append_default_init(size_type __n);
14221412
1423 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1413 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1424 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1414 _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1425 append(_InputIterator __first, _InputIterator __last) {1415 append(_InputIterator __first, _InputIterator __last) {
1426 const basic_string __temp(__first, __last, __alloc_);1416 const basic_string __temp(__first, __last, __alloc_);
1427 append(__temp.data(), __temp.size());1417 append(__temp.data(), __temp.size());
...@@ -1429,8 +1419,26 @@ public:...@@ -1429,8 +1419,26 @@ public:
1429 }1419 }
14301420
1431 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1421 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
1432 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1422 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1433 append(_ForwardIterator __first, _ForwardIterator __last);1423 append(_ForwardIterator __first, _ForwardIterator __last) {
1424 size_type __sz = size();
1425 size_type __cap = capacity();
1426 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1427 if (__n) {
1428 if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) {
1429 if (__cap - __sz < __n)
1430 __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
1431 __annotate_increase(__n);
1432 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz));
1433 traits_type::assign(*__end, value_type());
1434 __set_size(__sz + __n);
1435 } else {
1436 const basic_string __temp(__first, __last, __alloc_);
1437 append(__temp.data(), __temp.size());
1438 }
1439 }
1440 return *this;
1441 }
14341442
1435# if _LIBCPP_STD_VER >= 231443# if _LIBCPP_STD_VER >= 23
1436 template <_ContainerCompatibleRange<_CharT> _Range>1444 template <_ContainerCompatibleRange<_CharT> _Range>
...@@ -1470,8 +1478,7 @@ public:...@@ -1470,8 +1478,7 @@ public:
1470 }1478 }
14711479
1472 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1480 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1473 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1481 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const _Tp& __t) {
1474 assign(const _Tp& __t) {
1475 __self_view __sv = __t;1482 __self_view __sv = __t;
1476 return assign(__sv.data(), __sv.size());1483 return assign(__sv.data(), __sv.size());
1477 }1484 }
...@@ -1513,21 +1520,40 @@ public:...@@ -1513,21 +1520,40 @@ public:
15131520
1514 template <class _Tp,1521 template <class _Tp,
1515 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1522 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1516 !__is_same_uncvref<_Tp, basic_string>::value,1523 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1517 int> = 0>1524 int> = 0>
1518 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1525 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1519 assign(const _Tp& __t, size_type __pos, size_type __n = npos);1526 assign(const _Tp& __t, size_type __pos, size_type __n = npos) {
1527 __self_view __sv = __t;
1528 size_type __sz = __sv.size();
1529 if (__pos > __sz)
1530 __throw_out_of_range();
1531 return assign(__sv.data() + __pos, std::min(__n, __sz - __pos));
1532 }
15201533
1521 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);1534 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n);
1522 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);1535 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s);
1523 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);1536 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);
1537
1524 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1538 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1525 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1539 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1526 assign(_InputIterator __first, _InputIterator __last);1540 assign(_InputIterator __first, _InputIterator __last) {
1541 __assign_with_sentinel(__first, __last);
1542 return *this;
1543 }
15271544
1528 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1545 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
1529 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1546 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1530 assign(_ForwardIterator __first, _ForwardIterator __last);1547 assign(_ForwardIterator __first, _ForwardIterator __last) {
1548 if (__string_is_trivial_iterator<_ForwardIterator>::value) {
1549 size_type __n = static_cast<size_type>(std::distance(__first, __last));
1550 __assign_trivial(__first, __last, __n);
1551 } else {
1552 __assign_with_sentinel(__first, __last);
1553 }
1554
1555 return *this;
1556 }
15311557
1532# if _LIBCPP_STD_VER >= 231558# if _LIBCPP_STD_VER >= 23
1533 template <_ContainerCompatibleRange<_CharT> _Range>1559 template <_ContainerCompatibleRange<_CharT> _Range>
...@@ -1557,23 +1583,28 @@ public:...@@ -1557,23 +1583,28 @@ public:
1557 }1583 }
15581584
1559 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1585 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1560 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1586 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos1, const _Tp& __t) {
1561 insert(size_type __pos1, const _Tp& __t) {
1562 __self_view __sv = __t;1587 __self_view __sv = __t;
1563 return insert(__pos1, __sv.data(), __sv.size());1588 return insert(__pos1, __sv.data(), __sv.size());
1564 }1589 }
15651590
1566 template <class _Tp,1591 template <class _Tp,
1567 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1592 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1568 !__is_same_uncvref<_Tp, basic_string>::value,1593 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1569 int> = 0>1594 int> = 0>
1570 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1595 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1571 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos);1596 insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n = npos) {
1597 __self_view __sv = __t;
1598 size_type __str_sz = __sv.size();
1599 if (__pos2 > __str_sz)
1600 __throw_out_of_range();
1601 return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2));
1602 }
15721603
1573 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1604 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1574 insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos);1605 insert(size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n = npos);
1575 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);1606 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s, size_type __n);
1576 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* __s);1607 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1577 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);1608 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& insert(size_type __pos, size_type __n, value_type __c);
1578 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);1609 _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator insert(const_iterator __pos, value_type __c);
15791610
...@@ -1599,12 +1630,18 @@ public:...@@ -1599,12 +1630,18 @@ public:
1599 }1630 }
16001631
1601 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>1632 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
1602 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1633 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1603 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last);1634 insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) {
1635 const basic_string __temp(__first, __last, __alloc_);
1636 return insert(__pos, __temp.data(), __temp.data() + __temp.size());
1637 }
16041638
1605 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>1639 template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> = 0>
1606 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1640 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
1607 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last);1641 insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) {
1642 auto __n = static_cast<size_type>(std::distance(__first, __last));
1643 return __insert_with_size(__pos, __first, __last, __n);
1644 }
16081645
1609# ifndef _LIBCPP_CXX03_LANG1646# ifndef _LIBCPP_CXX03_LANG
1610 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator1647 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator
...@@ -1623,7 +1660,7 @@ public:...@@ -1623,7 +1660,7 @@ public:
1623 }1660 }
16241661
1625 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1662 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1626 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1663 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1627 replace(size_type __pos1, size_type __n1, const _Tp& __t) {1664 replace(size_type __pos1, size_type __n1, const _Tp& __t) {
1628 __self_view __sv = __t;1665 __self_view __sv = __t;
1629 return replace(__pos1, __n1, __sv.data(), __sv.size());1666 return replace(__pos1, __n1, __sv.data(), __sv.size());
...@@ -1634,10 +1671,16 @@ public:...@@ -1634,10 +1671,16 @@ public:
16341671
1635 template <class _Tp,1672 template <class _Tp,
1636 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&1673 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1637 !__is_same_uncvref<_Tp, basic_string>::value,1674 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1638 int> = 0>1675 int> = 0>
1639 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1640 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos);1677 replace(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) {
1678 __self_view __sv = __t;
1679 size_type __str_sz = __sv.size();
1680 if (__pos2 > __str_sz)
1681 __throw_out_of_range();
1682 return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2));
1683 }
16411684
1642 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1685 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1643 replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);1686 replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2);
...@@ -1651,7 +1694,7 @@ public:...@@ -1651,7 +1694,7 @@ public:
1651 }1694 }
16521695
1653 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1696 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1654 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1697 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1655 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) {1698 replace(const_iterator __i1, const_iterator __i2, const _Tp& __t) {
1656 __self_view __sv = __t;1699 __self_view __sv = __t;
1657 return replace(__i1 - begin(), __i2 - __i1, __sv);1700 return replace(__i1 - begin(), __i2 - __i1, __sv);
...@@ -1673,8 +1716,11 @@ public:...@@ -1673,8 +1716,11 @@ public:
1673 }1716 }
16741717
1675 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>1718 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
1676 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&1719 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1677 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2);1720 replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) {
1721 const basic_string __temp(__j1, __j2, __alloc_);
1722 return replace(__i1, __i2, __temp);
1723 }
16781724
1679# if _LIBCPP_STD_VER >= 231725# if _LIBCPP_STD_VER >= 23
1680 template <_ContainerCompatibleRange<_CharT> _Range>1726 template <_ContainerCompatibleRange<_CharT> _Range>
...@@ -1716,6 +1762,9 @@ public:...@@ -1716,6 +1762,9 @@ public:
1716 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);1762 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
1717# endif1763# endif
17181764
1765 // [string.ops]
1766 // ------------
1767
1719 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }1768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }
1720 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {1769 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* data() const _NOEXCEPT {
1721 return std::__to_address(__get_pointer());1770 return std::__to_address(__get_pointer());
...@@ -1730,113 +1779,267 @@ public:...@@ -1730,113 +1779,267 @@ public:
1730 return __alloc_;1779 return __alloc_;
1731 }1780 }
17321781
1782 // find
1783
1733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1784 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1734 find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1785 find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1786 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
1787 }
17351788
1736 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1789 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1737 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1738 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1791 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
1792 __self_view __sv = __t;
1793 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
1794 }
1795
1796 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1797 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr");
1798 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1799 }
17391800
1740 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1741 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1801 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1742 find(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1802 find(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
1743 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT;1803 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr");
1804 return std::__str_find<value_type, size_type, traits_type, npos>(
1805 data(), size(), __s, __pos, traits_type::length(__s));
1806 }
1807
1808 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT {
1809 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
1810 }
1811
1812 // rfind
17441813
1745 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1814 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1746 rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1815 rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1816 return std::__str_rfind<value_type, size_type, traits_type, npos>(
1817 data(), size(), __str.data(), __pos, __str.size());
1818 }
17471819
1748 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1820 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1749 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1821 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1750 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1822 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
1823 __self_view __sv = __t;
1824 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
1825 }
1826
1827 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1828 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
1829 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1830 }
17511831
1752 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;
1753 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1832 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1754 rfind(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1833 rfind(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
1755 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT;1834 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr");
1835 return std::__str_rfind<value_type, size_type, traits_type, npos>(
1836 data(), size(), __s, __pos, traits_type::length(__s));
1837 }
1838
1839 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type rfind(value_type __c, size_type __pos = npos) const _NOEXCEPT {
1840 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
1841 }
1842
1843 // find_first_of
17561844
1757 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1845 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1758 find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1846 find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1847 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1848 data(), size(), __str.data(), __pos, __str.size());
1849 }
17591850
1760 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1851 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1761 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1852 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1762 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1853 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
1854 __self_view __sv = __t;
1855 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1856 data(), size(), __sv.data(), __pos, __sv.size());
1857 }
17631858
1764 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1859 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1765 find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1860 find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1861 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
1862 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1863 }
1864
1766 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1865 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1767 find_first_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1866 find_first_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
1867 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr");
1868 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1869 data(), size(), __s, __pos, traits_type::length(__s));
1870 }
1871
1768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1769 find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1873 find_first_of(value_type __c, size_type __pos = 0) const _NOEXCEPT {
1874 return find(__c, __pos);
1875 }
1876
1877 // find_last_of
17701878
1771 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1879 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1772 find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1880 find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1881 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1882 data(), size(), __str.data(), __pos, __str.size());
1883 }
17731884
1774 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1885 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1775 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1886 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1776 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1887 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
1888 __self_view __sv = __t;
1889 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1890 data(), size(), __sv.data(), __pos, __sv.size());
1891 }
17771892
1778 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1893 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1779 find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1894 find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1895 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
1896 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1897 }
1898
1780 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1899 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1781 find_last_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1900 find_last_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
1901 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr");
1902 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1903 data(), size(), __s, __pos, traits_type::length(__s));
1904 }
1905
1782 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1906 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1783 find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1907 find_last_of(value_type __c, size_type __pos = npos) const _NOEXCEPT {
1908 return rfind(__c, __pos);
1909 }
1910
1911 // find_first_not_of
17841912
1785 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1913 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1786 find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT;1914 find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1915 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1916 data(), size(), __str.data(), __pos, __str.size());
1917 }
17871918
1788 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1919 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1789 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1920 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1790 find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT;1921 find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
1922 __self_view __sv = __t;
1923 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1924 data(), size(), __sv.data(), __pos, __sv.size());
1925 }
17911926
1792 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1927 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1793 find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1928 find_first_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1929 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
1930 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1931 }
1932
1794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1933 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1795 find_first_not_of(const value_type* __s, size_type __pos = 0) const _NOEXCEPT;1934 find_first_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
1935 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr");
1936 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1937 data(), size(), __s, __pos, traits_type::length(__s));
1938 }
1939
1796 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1940 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1797 find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT;1941 find_first_not_of(value_type __c, size_type __pos = 0) const _NOEXCEPT {
1942 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
1943 }
1944
1945 // find_last_not_of
17981946
1799 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1947 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1800 find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT;1948 find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1949 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
1950 data(), size(), __str.data(), __pos, __str.size());
1951 }
18011952
1802 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1953 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1803 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1804 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT;1955 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
1956 __self_view __sv = __t;
1957 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
1958 data(), size(), __sv.data(), __pos, __sv.size());
1959 }
18051960
1806 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1961 _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1807 find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT;1962 find_last_not_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
1963 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
1964 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
1965 }
1966
1808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1967 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1809 find_last_not_of(const value_type* __s, size_type __pos = npos) const _NOEXCEPT;1968 find_last_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
1969 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr");
1970 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
1971 data(), size(), __s, __pos, traits_type::length(__s));
1972 }
1973
1810 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type1974 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
1811 find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT;1975 find_last_not_of(value_type __c, size_type __pos = npos) const _NOEXCEPT {
1976 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
1977 }
18121978
1813 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT;1979 // compare
1980
1981 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const basic_string& __str) const _NOEXCEPT {
1982 return compare(__self_view(__str));
1983 }
18141984
1815 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>1985 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1816 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int1986 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const _Tp& __t) const _NOEXCEPT {
1817 compare(const _Tp& __t) const _NOEXCEPT;1987 __self_view __sv = __t;
1988 size_t __lhs_sz = size();
1989 size_t __rhs_sz = __sv.size();
1990 int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz));
1991 if (__result != 0)
1992 return __result;
1993 if (__lhs_sz < __rhs_sz)
1994 return -1;
1995 if (__lhs_sz > __rhs_sz)
1996 return 1;
1997 return 0;
1998 }
18181999
1819 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>2000 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> = 0>
1820 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 int2001 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1821 compare(size_type __pos1, size_type __n1, const _Tp& __t) const;2002 compare(size_type __pos1, size_type __n1, const _Tp& __t) const {
2003 __self_view __sv = __t;
2004 return compare(__pos1, __n1, __sv.data(), __sv.size());
2005 }
18222006
1823 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int2007 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1824 compare(size_type __pos1, size_type __n1, const basic_string& __str) const;2008 compare(size_type __pos1, size_type __n1, const basic_string& __str) const {
2009 return compare(__pos1, __n1, __str.data(), __str.size());
2010 }
2011
1825 _LIBCPP_CONSTEXPR_SINCE_CXX20 int2012 _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1826 compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const;2013 compare(size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2 = npos) const {
2014 return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
2015 }
18272016
1828 template <class _Tp,2017 template <class _Tp,
1829 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&2018 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
1830 !__is_same_uncvref<_Tp, basic_string>::value,2019 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1831 int> = 0>2020 int> = 0>
1832 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int2021 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1833 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const;2022 compare(size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2 = npos) const {
2023 __self_view __sv = __t;
2024 return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2025 }
2026
2027 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const _NOEXCEPT {
2028 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr");
2029 return compare(0, npos, __s, traits_type::length(__s));
2030 }
2031
2032 _LIBCPP_CONSTEXPR_SINCE_CXX20 int
2033 compare(size_type __pos1, size_type __n1, const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const {
2034 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr");
2035 return compare(__pos1, __n1, __s, traits_type::length(__s));
2036 }
18342037
1835 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(const value_type* __s) const _NOEXCEPT;
1836 _LIBCPP_CONSTEXPR_SINCE_CXX20 int compare(size_type __pos1, size_type __n1, const value_type* __s) const;
1837 _LIBCPP_CONSTEXPR_SINCE_CXX20 int2038 _LIBCPP_CONSTEXPR_SINCE_CXX20 int
1838 compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;2039 compare(size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const;
18392040
2041 // starts_with
2042
1840# if _LIBCPP_STD_VER >= 202043# if _LIBCPP_STD_VER >= 20
1841 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept {2044 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(__self_view __sv) const noexcept {
1842 return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv);2045 return __self_view(typename __self_view::__assume_valid(), data(), size()).starts_with(__sv);
...@@ -1846,10 +2049,12 @@ public:...@@ -1846,10 +2049,12 @@ public:
1846 return !empty() && _Traits::eq(front(), __c);2049 return !empty() && _Traits::eq(front(), __c);
1847 }2050 }
18482051
1849 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* __s) const noexcept {2052 constexpr _LIBCPP_HIDE_FROM_ABI bool starts_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept {
1850 return starts_with(__self_view(__s));2053 return starts_with(__self_view(__s));
1851 }2054 }
18522055
2056 // ends_with
2057
1853 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept {2058 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(__self_view __sv) const noexcept {
1854 return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv);2059 return __self_view(typename __self_view::__assume_valid(), data(), size()).ends_with(__sv);
1855 }2060 }
...@@ -1858,11 +2063,13 @@ public:...@@ -1858,11 +2063,13 @@ public:
1858 return !empty() && _Traits::eq(back(), __c);2063 return !empty() && _Traits::eq(back(), __c);
1859 }2064 }
18602065
1861 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* __s) const noexcept {2066 constexpr _LIBCPP_HIDE_FROM_ABI bool ends_with(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const noexcept {
1862 return ends_with(__self_view(__s));2067 return ends_with(__self_view(__s));
1863 }2068 }
1864# endif2069# endif
18652070
2071 // contains
2072
1866# if _LIBCPP_STD_VER >= 232073# if _LIBCPP_STD_VER >= 23
1867 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept {2074 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(__self_view __sv) const noexcept {
1868 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv);2075 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__sv);
...@@ -1872,18 +2079,14 @@ public:...@@ -1872,18 +2079,14 @@ public:
1872 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c);2079 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__c);
1873 }2080 }
18742081
1875 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* __s) const {2082 constexpr _LIBCPP_HIDE_FROM_ABI bool contains(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s) const {
1876 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s);2083 return __self_view(typename __self_view::__assume_valid(), data(), size()).contains(__s);
1877 }2084 }
1878# endif2085# endif
18792086
1880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;2087 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
18812088
1882 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __clear_and_shrink() _NOEXCEPT;
1883
1884private:2089private:
1885 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __shrink_or_extend(size_type __target_capacity);
1886
1887 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool2090 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool
1888 __is_long() const _NOEXCEPT {2091 __is_long() const _NOEXCEPT {
1889 if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) {2092 if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) {
...@@ -2038,7 +2241,7 @@ private:...@@ -2038,7 +2241,7 @@ private:
2038 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {2241 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
2039 (void)__old_mid;2242 (void)__old_mid;
2040 (void)__new_mid;2243 (void)__new_mid;
2041# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN2244# if _LIBCPP_INSTRUMENTED_WITH_ASAN
2042# if defined(__APPLE__)2245# if defined(__APPLE__)
2043 // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)2246 // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
2044 if (!__is_long())2247 if (!__is_long())
...@@ -2049,36 +2252,36 @@ private:...@@ -2049,36 +2252,36 @@ private:
2049 }2252 }
20502253
2051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {2254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
2052 (void)__current_size;2255 __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
2053# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2054 if (!__libcpp_is_constant_evaluated())
2055 __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
2056# endif
2057 }2256 }
20582257
2059 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {2258 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
2060# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN2259 __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
2061 if (!__libcpp_is_constant_evaluated())
2062 __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
2063# endif
2064 }2260 }
20652261
2066 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {2262 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
2067 (void)__n;2263 __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
2068# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2069 if (!__libcpp_is_constant_evaluated())
2070 __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
2071# endif
2072 }2264 }
20732265
2074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {2266 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
2075 (void)__old_size;2267 __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
2076# if _LIBCPP_HAS_ASAN && _LIBCPP_INSTRUMENTED_WITH_ASAN
2077 if (!__libcpp_is_constant_evaluated())
2078 __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
2079# endif
2080 }2268 }
20812269
2270 // Disable ASan annotations and enable them again when going out of scope. It is assumed that the string is in a valid
2271 // state at that point, so `size()` can be called safely.
2272 struct [[__nodiscard__]] __annotation_guard {
2273 __annotation_guard(const __annotation_guard&) = delete;
2274 __annotation_guard& operator=(const __annotation_guard&) = delete;
2275
2276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __annotation_guard(basic_string& __str) : __str_(__str) {
2277 __str_.__annotate_delete();
2278 }
2279
2280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__annotation_guard() { __str_.__annotate_new(__str_.size()); }
2281
2282 basic_string& __str_;
2283 };
2284
2082 template <size_type __a>2285 template <size_type __a>
2083 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {2286 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {
2084 return (__s + (__a - 1)) & ~(__a - 1);2287 return (__s + (__a - 1)) & ~(__a - 1);
...@@ -2097,7 +2300,6 @@ private:...@@ -2097,7 +2300,6 @@ private:
2097 return __guess;2300 return __guess;
2098 }2301 }
20992302
2100 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz, size_type __reserve);
2101 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz);2303 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(const value_type* __s, size_type __sz);
2102 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c);2304 inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init(size_type __n, value_type __c);
21032305
...@@ -2176,7 +2378,11 @@ private:...@@ -2176,7 +2378,11 @@ private:
2176 __alloc_ = __str.__alloc_;2378 __alloc_ = __str.__alloc_;
2177 else {2379 else {
2178 if (!__str.__is_long()) {2380 if (!__str.__is_long()) {
2179 __clear_and_shrink();2381 if (__is_long()) {
2382 __annotate_delete();
2383 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
2384 __rep_ = __rep();
2385 }
2180 __alloc_ = __str.__alloc_;2386 __alloc_ = __str.__alloc_;
2181 } else {2387 } else {
2182 __annotate_delete();2388 __annotate_delete();
...@@ -2189,7 +2395,7 @@ private:...@@ -2189,7 +2395,7 @@ private:
2189 __alloc_ = std::move(__a);2395 __alloc_ = std::move(__a);
2190 __set_long_pointer(__allocation.ptr);2396 __set_long_pointer(__allocation.ptr);
2191 __set_long_cap(__allocation.count);2397 __set_long_cap(__allocation.count);
2192 __set_long_size(__str.size());2398 __set_long_size(__str.__get_long_size());
2193 }2399 }
2194 }2400 }
2195 }2401 }
...@@ -2231,8 +2437,14 @@ private:...@@ -2231,8 +2437,14 @@ private:
2231 size_type __old_size = size();2437 size_type __old_size = size();
2232 if (__n > __old_size)2438 if (__n > __old_size)
2233 __annotate_increase(__n - __old_size);2439 __annotate_increase(__n - __old_size);
2234 pointer __p =2440 pointer __p;
2235 __is_long() ? (__set_long_size(__n), __get_long_pointer()) : (__set_short_size(__n), __get_short_pointer());2441 if (__is_long()) {
2442 __set_long_size(__n);
2443 __p = __get_long_pointer();
2444 } else {
2445 __set_short_size(__n);
2446 __p = __get_short_pointer();
2447 }
2236 traits_type::move(std::__to_address(__p), __s, __n);2448 traits_type::move(std::__to_address(__p), __s, __n);
2237 traits_type::assign(__p[__n], value_type());2449 traits_type::assign(__p[__n], value_type());
2238 if (__old_size > __n)2450 if (__old_size > __n)
...@@ -2265,24 +2477,23 @@ private:...@@ -2265,24 +2477,23 @@ private:
2265 std::__throw_out_of_range("basic_string");2477 std::__throw_out_of_range("basic_string");
2266 }2478 }
22672479
2268 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const basic_string&);2480 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string
2269 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const value_type*, const basic_string&);2481 __concatenate_strings<>(const _Allocator&, __type_identity_t<__self_view>, __type_identity_t<__self_view>);
2270 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&);
2271 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*);
2272 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type);
2273# if _LIBCPP_STD_VER >= 26
2274 friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>);
2275 friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&);
2276# endif
22772482
2278 template <class _CharT2, class _Traits2, class _Allocator2>2483 template <class _CharT2, class _Traits2, class _Allocator2>
2279 friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool2484 friend inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
2280 operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT;2485 operator==(const basic_string<_CharT2, _Traits2, _Allocator2>&, const _CharT2*) _NOEXCEPT;
2486
2487 // These functions aren't used anymore but are part of out ABI, so we need to provide them in the dylib for backwards
2488 // compatibility
2489# ifdef _LIBCPP_BUILDING_LIBRARY
2490 void __init(const value_type* __s, size_type __sz, size_type __reserve);
2491# endif
2281};2492};
22822493
2283// These declarations must appear before any functions are implicitly used2494// These declarations must appear before any functions are implicitly used
2284// so that they have the correct visibility specifier.2495// so that they have the correct visibility specifier.
2285# define _LIBCPP_DECLARE(...) extern template __VA_ARGS__;2496# define _LIBCPP_DECLARE(...) extern template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__;
2286# ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION2497# ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
2287_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)2498_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_DECLARE, char)
2288# if _LIBCPP_HAS_WIDE_CHARACTERS2499# if _LIBCPP_HAS_WIDE_CHARACTERS
...@@ -2309,8 +2520,8 @@ template <class _CharT,...@@ -2309,8 +2520,8 @@ template <class _CharT,
2309 class _Traits,2520 class _Traits,
2310 class _Allocator = allocator<_CharT>,2521 class _Allocator = allocator<_CharT>,
2311 class = enable_if_t<__is_allocator<_Allocator>::value> >2522 class = enable_if_t<__is_allocator<_Allocator>::value> >
2312explicit basic_string(basic_string_view<_CharT, _Traits>,2523explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
2313 const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>;2524 -> basic_string<_CharT, _Traits, _Allocator>;
23142525
2315template <class _CharT,2526template <class _CharT,
2316 class _Traits,2527 class _Traits,
...@@ -2329,37 +2540,13 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator())...@@ -2329,37 +2540,13 @@ basic_string(from_range_t, _Range&&, _Allocator = _Allocator())
2329 -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>;2540 -> basic_string<ranges::range_value_t<_Range>, char_traits<ranges::range_value_t<_Range>>, _Allocator>;
2330# endif2541# endif
23312542
2332template <class _CharT, class _Traits, class _Allocator>
2333_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2334basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {
2335 if (__libcpp_is_constant_evaluated())
2336 __rep_ = __rep();
2337 if (__reserve > max_size())
2338 __throw_length_error();
2339 pointer __p;
2340 if (__fits_in_sso(__reserve)) {
2341 __set_short_size(__sz);
2342 __p = __get_short_pointer();
2343 } else {
2344 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1);
2345 __p = __allocation.ptr;
2346 __begin_lifetime(__p, __allocation.count);
2347 __set_long_pointer(__p);
2348 __set_long_cap(__allocation.count);
2349 __set_long_size(__sz);
2350 }
2351 traits_type::copy(std::__to_address(__p), __s, __sz);
2352 traits_type::assign(__p[__sz], value_type());
2353 __annotate_new(__sz);
2354}
2355
2356template <class _CharT, class _Traits, class _Allocator>2543template <class _CharT, class _Traits, class _Allocator>
2357_LIBCPP_CONSTEXPR_SINCE_CXX20 void2544_LIBCPP_CONSTEXPR_SINCE_CXX20 void
2358basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) {2545basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz) {
2359 if (__libcpp_is_constant_evaluated())2546 if (__libcpp_is_constant_evaluated())
2360 __rep_ = __rep();2547 __rep_ = __rep();
2361 if (__sz > max_size())2548 if (__sz > max_size())
2362 __throw_length_error();2549 this->__throw_length_error();
2363 pointer __p;2550 pointer __p;
2364 if (__fits_in_sso(__sz)) {2551 if (__fits_in_sso(__sz)) {
2365 __set_short_size(__sz);2552 __set_short_size(__sz);
...@@ -2389,7 +2576,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value...@@ -2389,7 +2576,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_copy_ctor_external(const value
2389 __set_short_size(__sz);2576 __set_short_size(__sz);
2390 } else {2577 } else {
2391 if (__sz > max_size())2578 if (__sz > max_size())
2392 __throw_length_error();2579 this->__throw_length_error();
2393 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);2580 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__sz) + 1);
2394 __p = __allocation.ptr;2581 __p = __allocation.ptr;
2395 __begin_lifetime(__p, __allocation.count);2582 __begin_lifetime(__p, __allocation.count);
...@@ -2407,7 +2594,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2407,7 +2594,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2407 __rep_ = __rep();2594 __rep_ = __rep();
24082595
2409 if (__n > max_size())2596 if (__n > max_size())
2410 __throw_length_error();2597 this->__throw_length_error();
2411 pointer __p;2598 pointer __p;
2412 if (__fits_in_sso(__n)) {2599 if (__fits_in_sso(__n)) {
2413 __set_short_size(__n);2600 __set_short_size(__n);
...@@ -2470,7 +2657,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir...@@ -2470,7 +2657,7 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir
2470 __rep_ = __rep();2657 __rep_ = __rep();
24712658
2472 if (__sz > max_size())2659 if (__sz > max_size())
2473 __throw_length_error();2660 this->__throw_length_error();
24742661
2475 pointer __p;2662 pointer __p;
2476 if (__fits_in_sso(__sz)) {2663 if (__fits_in_sso(__sz)) {
...@@ -2511,11 +2698,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__...@@ -2511,11 +2698,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
2511 size_type __n_add,2698 size_type __n_add,
2512 const value_type* __p_new_stuff) {2699 const value_type* __p_new_stuff) {
2513 size_type __ms = max_size();2700 size_type __ms = max_size();
2514 if (__delta_cap > __ms - __old_cap - 1)2701 if (__delta_cap > __ms - __old_cap)
2515 __throw_length_error();2702 __throw_length_error();
2516 pointer __old_p = __get_pointer();2703 pointer __old_p = __get_pointer();
2517 size_type __cap =2704 size_type __cap =
2518 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;2705 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms;
2519 __annotate_delete();2706 __annotate_delete();
2520 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));2707 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
2521 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);2708 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);
...@@ -2555,10 +2742,10 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait...@@ -2555,10 +2742,10 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait
2555 size_type __n_add) {2742 size_type __n_add) {
2556 size_type __ms = max_size();2743 size_type __ms = max_size();
2557 if (__delta_cap > __ms - __old_cap)2744 if (__delta_cap > __ms - __old_cap)
2558 __throw_length_error();2745 this->__throw_length_error();
2559 pointer __old_p = __get_pointer();2746 pointer __old_p = __get_pointer();
2560 size_type __cap =2747 size_type __cap =
2561 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms - 1;2748 __old_cap < __ms / 2 - __alignment ? __recommend(std::max(__old_cap + __delta_cap, 2 * __old_cap)) : __ms;
2562 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);2749 auto __allocation = std::__allocate_at_least(__alloc_, __cap + 1);
2563 pointer __p = __allocation.ptr;2750 pointer __p = __allocation.ptr;
2564 __begin_lifetime(__p, __allocation.count);2751 __begin_lifetime(__p, __allocation.count);
...@@ -2597,20 +2784,25 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2597,20 +2784,25 @@ template <class _CharT, class _Traits, class _Allocator>
2597template <bool __is_short>2784template <bool __is_short>
2598_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&2785_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&
2599basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) {2786basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* __s, size_type __n) {
2600 size_type __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap();2787 const auto __cap = __is_short ? static_cast<size_type>(__min_cap) : __get_long_cap();
2788 const auto __size = __is_short ? __get_short_size() : __get_long_size();
2601 if (__n < __cap) {2789 if (__n < __cap) {
2602 size_type __old_size = __is_short ? __get_short_size() : __get_long_size();2790 if (__n > __size)
2603 if (__n > __old_size)2791 __annotate_increase(__n - __size);
2604 __annotate_increase(__n - __old_size);2792 pointer __p;
2605 pointer __p = __is_short ? __get_short_pointer() : __get_long_pointer();2793 if (__is_short) {
2606 __is_short ? __set_short_size(__n) : __set_long_size(__n);2794 __p = __get_short_pointer();
2795 __set_short_size(__n);
2796 } else {
2797 __p = __get_long_pointer();
2798 __set_long_size(__n);
2799 }
2607 traits_type::copy(std::__to_address(__p), __s, __n);2800 traits_type::copy(std::__to_address(__p), __s, __n);
2608 traits_type::assign(__p[__n], value_type());2801 traits_type::assign(__p[__n], value_type());
2609 if (__old_size > __n)2802 if (__size > __n)
2610 __annotate_shrink(__old_size);2803 __annotate_shrink(__size);
2611 } else {2804 } else {
2612 size_type __sz = __is_short ? __get_short_size() : __get_long_size();2805 __grow_by_and_replace(__cap - 1, __n - __cap + 1, __size, 0, __size, __n, __s);
2613 __grow_by_and_replace(__cap - 1, __n - __cap + 1, __sz, 0, __sz, __n, __s);
2614 }2806 }
2615 return *this;2807 return *this;
2616}2808}
...@@ -2618,17 +2810,16 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* _...@@ -2618,17 +2810,16 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_no_alias(const value_type* _
2618template <class _CharT, class _Traits, class _Allocator>2810template <class _CharT, class _Traits, class _Allocator>
2619_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&2811_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&
2620basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) {2812basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s, size_type __n) {
2621 size_type __cap = capacity();2813 const auto __cap = capacity();
2814 const auto __size = size();
2622 if (__cap >= __n) {2815 if (__cap >= __n) {
2623 size_type __old_size = size();2816 if (__n > __size)
2624 if (__n > __old_size)2817 __annotate_increase(__n - __size);
2625 __annotate_increase(__n - __old_size);
2626 value_type* __p = std::__to_address(__get_pointer());2818 value_type* __p = std::__to_address(__get_pointer());
2627 traits_type::move(__p, __s, __n);2819 traits_type::move(__p, __s, __n);
2628 return __null_terminate_at(__p, __n);2820 return __null_terminate_at(__p, __n);
2629 } else {2821 } else {
2630 size_type __sz = size();2822 __grow_by_and_replace(__cap, __n - __cap, __size, 0, __size, __n, __s);
2631 __grow_by_and_replace(__cap, __n - __cap, __sz, 0, __sz, __n, __s);
2632 return *this;2823 return *this;
2633 }2824 }
2634}2825}
...@@ -2646,8 +2837,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)...@@ -2646,8 +2837,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2646 size_type __cap = capacity();2837 size_type __cap = capacity();
2647 size_type __old_size = size();2838 size_type __old_size = size();
2648 if (__cap < __n) {2839 if (__cap < __n) {
2649 size_type __sz = size();2840 __grow_by_without_replace(__cap, __n - __cap, __old_size, 0, __old_size);
2650 __grow_by_without_replace(__cap, __n - __cap, __sz, 0, __sz);
2651 __annotate_increase(__n);2841 __annotate_increase(__n);
2652 } else if (__n > __old_size)2842 } else if (__n > __old_size)
2653 __annotate_increase(__n - __old_size);2843 __annotate_increase(__n - __old_size);
...@@ -2659,10 +2849,10 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)...@@ -2659,10 +2849,10 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
2659template <class _CharT, class _Traits, class _Allocator>2849template <class _CharT, class _Traits, class _Allocator>
2660_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&2850_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2661basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {2851basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {
2662 pointer __p;
2663 size_type __old_size = size();2852 size_type __old_size = size();
2664 if (__old_size == 0)2853 if (__old_size == 0)
2665 __annotate_increase(1);2854 __annotate_increase(1);
2855 pointer __p;
2666 if (__is_long()) {2856 if (__is_long()) {
2667 __p = __get_long_pointer();2857 __p = __get_long_pointer();
2668 __set_long_size(1);2858 __set_long_size(1);
...@@ -2680,23 +2870,21 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {...@@ -2680,23 +2870,21 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {
2680template <class _CharT, class _Traits, class _Allocator>2870template <class _CharT, class _Traits, class _Allocator>
2681_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>&2871_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>&
2682basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) {2872basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) {
2683 if (this != std::addressof(__str)) {2873 if (this == std::addressof(__str))
2684 __copy_assign_alloc(__str);2874 return *this;
2685 if (!__is_long()) {2875
2686 if (!__str.__is_long()) {2876 __copy_assign_alloc(__str);
2687 size_type __old_size = __get_short_size();2877
2688 if (__get_short_size() < __str.__get_short_size())2878 if (__is_long())
2689 __annotate_increase(__str.__get_short_size() - __get_short_size());2879 return __assign_no_alias<false>(__str.data(), __str.size());
2690 __rep_ = __str.__rep_;2880
2691 if (__old_size > __get_short_size())2881 if (__str.__is_long())
2692 __annotate_shrink(__old_size);2882 return __assign_no_alias<true>(__str.data(), __str.size());
2693 } else {2883
2694 return __assign_no_alias<true>(__str.data(), __str.size());2884 __annotate_delete();
2695 }2885 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
2696 } else {2886 __rep_ = __str.__rep_;
2697 return __assign_no_alias<false>(__str.data(), __str.size());2887
2698 }
2699 }
2700 return *this;2888 return *this;
2701}2889}
27022890
...@@ -2760,14 +2948,6 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr...@@ -2760,14 +2948,6 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr
27602948
2761# endif2949# endif
27622950
2763template <class _CharT, class _Traits, class _Allocator>
2764template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
2765_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2766basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) {
2767 __assign_with_sentinel(__first, __last);
2768 return *this;
2769}
2770
2771template <class _CharT, class _Traits, class _Allocator>2951template <class _CharT, class _Traits, class _Allocator>
2772template <class _InputIterator, class _Sentinel>2952template <class _InputIterator, class _Sentinel>
2773_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void2953_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
...@@ -2776,20 +2956,6 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator...@@ -2776,20 +2956,6 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_with_sentinel(_InputIterator
2776 assign(__temp.data(), __temp.size());2956 assign(__temp.data(), __temp.size());
2777}2957}
27782958
2779template <class _CharT, class _Traits, class _Allocator>
2780template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2781_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2782basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) {
2783 if (__string_is_trivial_iterator<_ForwardIterator>::value) {
2784 size_type __n = static_cast<size_type>(std::distance(__first, __last));
2785 __assign_trivial(__first, __last, __n);
2786 } else {
2787 __assign_with_sentinel(__first, __last);
2788 }
2789
2790 return *this;
2791}
2792
2793template <class _CharT, class _Traits, class _Allocator>2959template <class _CharT, class _Traits, class _Allocator>
2794template <class _Iterator, class _Sentinel>2960template <class _Iterator, class _Sentinel>
2795_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void2961_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
...@@ -2825,24 +2991,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&...@@ -2825,24 +2991,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2825basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) {2991basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str, size_type __pos, size_type __n) {
2826 size_type __sz = __str.size();2992 size_type __sz = __str.size();
2827 if (__pos > __sz)2993 if (__pos > __sz)
2828 __throw_out_of_range();2994 this->__throw_out_of_range();
2829 return assign(__str.data() + __pos, std::min(__n, __sz - __pos));2995 return assign(__str.data() + __pos, std::min(__n, __sz - __pos));
2830}2996}
28312997
2832template <class _CharT, class _Traits, class _Allocator>
2833template <class _Tp,
2834 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
2835 !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
2836 int> >
2837_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2838basic_string<_CharT, _Traits, _Allocator>::assign(const _Tp& __t, size_type __pos, size_type __n) {
2839 __self_view __sv = __t;
2840 size_type __sz = __sv.size();
2841 if (__pos > __sz)
2842 __throw_out_of_range();
2843 return assign(__sv.data() + __pos, std::min(__n, __sz - __pos));
2844}
2845
2846template <class _CharT, class _Traits, class _Allocator>2998template <class _CharT, class _Traits, class _Allocator>
2847_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&2999_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NOINLINE basic_string<_CharT, _Traits, _Allocator>&
2848basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {3000basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* __s) {
...@@ -2853,10 +3005,9 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -2853,10 +3005,9 @@ template <class _CharT, class _Traits, class _Allocator>
2853_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3005_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2854basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) {3006basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) {
2855 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::assign received nullptr");3007 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::assign received nullptr");
2856 return __builtin_constant_p(*__s)3008 if (auto __len = traits_type::length(__s); __builtin_constant_p(__len) && __fits_in_sso(__len))
2857 ? (__fits_in_sso(traits_type::length(__s)) ? __assign_short(__s, traits_type::length(__s))3009 return __assign_short(__s, __len);
2858 : __assign_external(__s, traits_type::length(__s)))3010 return __assign_external(__s);
2859 : __assign_external(__s);
2860}3011}
2861// append3012// append
28623013
...@@ -2928,11 +3079,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu...@@ -2928,11 +3079,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu
2928 }3079 }
2929 if (__sz == __cap) {3080 if (__sz == __cap) {
2930 __grow_by_without_replace(__cap, 1, __sz, __sz, 0);3081 __grow_by_without_replace(__cap, 1, __sz, __sz, 0);
2931 __annotate_increase(1);
2932 __is_short = false; // the string is always long after __grow_by3082 __is_short = false; // the string is always long after __grow_by
2933 } else3083 }
2934 __annotate_increase(1);3084 __annotate_increase(1);
2935 pointer __p = __get_pointer();3085 pointer __p;
2936 if (__is_short) {3086 if (__is_short) {
2937 __p = __get_short_pointer() + __sz;3087 __p = __get_short_pointer() + __sz;
2938 __set_short_size(__sz + 1);3088 __set_short_size(__sz + 1);
...@@ -2944,52 +3094,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu...@@ -2944,52 +3094,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::pu
2944 traits_type::assign(*++__p, value_type());3094 traits_type::assign(*++__p, value_type());
2945}3095}
29463096
2947template <class _CharT, class _Traits, class _Allocator>
2948template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
2949_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2950basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) {
2951 size_type __sz = size();
2952 size_type __cap = capacity();
2953 size_type __n = static_cast<size_type>(std::distance(__first, __last));
2954 if (__n) {
2955 if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first)) {
2956 if (__cap - __sz < __n)
2957 __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
2958 __annotate_increase(__n);
2959 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz));
2960 traits_type::assign(*__end, value_type());
2961 __set_size(__sz + __n);
2962 } else {
2963 const basic_string __temp(__first, __last, __alloc_);
2964 append(__temp.data(), __temp.size());
2965 }
2966 }
2967 return *this;
2968}
2969
2970template <class _CharT, class _Traits, class _Allocator>3097template <class _CharT, class _Traits, class _Allocator>
2971_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3098_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2972basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) {3099basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str, size_type __pos, size_type __n) {
2973 size_type __sz = __str.size();3100 size_type __sz = __str.size();
2974 if (__pos > __sz)3101 if (__pos > __sz)
2975 __throw_out_of_range();3102 this->__throw_out_of_range();
2976 return append(__str.data() + __pos, std::min(__n, __sz - __pos));3103 return append(__str.data() + __pos, std::min(__n, __sz - __pos));
2977}3104}
29783105
2979template <class _CharT, class _Traits, class _Allocator>
2980template <class _Tp,
2981 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
2982 !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
2983 int> >
2984_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2985basic_string<_CharT, _Traits, _Allocator>::append(const _Tp& __t, size_type __pos, size_type __n) {
2986 __self_view __sv = __t;
2987 size_type __sz = __sv.size();
2988 if (__pos > __sz)
2989 __throw_out_of_range();
2990 return append(__sv.data() + __pos, std::min(__n, __sz - __pos));
2991}
2992
2993template <class _CharT, class _Traits, class _Allocator>3106template <class _CharT, class _Traits, class _Allocator>
2994_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3107_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2995basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) {3108basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) {
...@@ -3005,7 +3118,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t...@@ -3005,7 +3118,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
3005 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::insert received nullptr");3118 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::insert received nullptr");
3006 size_type __sz = size();3119 size_type __sz = size();
3007 if (__pos > __sz)3120 if (__pos > __sz)
3008 __throw_out_of_range();3121 this->__throw_out_of_range();
3009 size_type __cap = capacity();3122 size_type __cap = capacity();
3010 if (__cap - __sz >= __n) {3123 if (__cap - __sz >= __n) {
3011 if (__n) {3124 if (__n) {
...@@ -3032,7 +3145,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&...@@ -3032,7 +3145,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3032basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) {3145basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n, value_type __c) {
3033 size_type __sz = size();3146 size_type __sz = size();
3034 if (__pos > __sz)3147 if (__pos > __sz)
3035 __throw_out_of_range();3148 this->__throw_out_of_range();
3036 if (__n) {3149 if (__n) {
3037 size_type __cap = capacity();3150 size_type __cap = capacity();
3038 value_type* __p;3151 value_type* __p;
...@@ -3054,23 +3167,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n...@@ -3054,23 +3167,6 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
3054 return *this;3167 return *this;
3055}3168}
30563169
3057template <class _CharT, class _Traits, class _Allocator>
3058template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> >
3059_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator
3060basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) {
3061 const basic_string __temp(__first, __last, __alloc_);
3062 return insert(__pos, __temp.data(), __temp.data() + __temp.size());
3063}
3064
3065template <class _CharT, class _Traits, class _Allocator>
3066template <class _ForwardIterator, __enable_if_t<__has_forward_iterator_category<_ForwardIterator>::value, int> >
3067_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator
3068basic_string<_CharT, _Traits, _Allocator>::insert(
3069 const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) {
3070 auto __n = static_cast<size_type>(std::distance(__first, __last));
3071 return __insert_with_size(__pos, __first, __last, __n);
3072}
3073
3074template <class _CharT, class _Traits, class _Allocator>3170template <class _CharT, class _Traits, class _Allocator>
3075template <class _Iterator, class _Sentinel>3171template <class _Iterator, class _Sentinel>
3076_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator3172_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::iterator
...@@ -3094,24 +3190,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(...@@ -3094,24 +3190,10 @@ basic_string<_CharT, _Traits, _Allocator>::insert(
3094 size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) {3190 size_type __pos1, const basic_string& __str, size_type __pos2, size_type __n) {
3095 size_type __str_sz = __str.size();3191 size_type __str_sz = __str.size();
3096 if (__pos2 > __str_sz)3192 if (__pos2 > __str_sz)
3097 __throw_out_of_range();3193 this->__throw_out_of_range();
3098 return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2));3194 return insert(__pos1, __str.data() + __pos2, std::min(__n, __str_sz - __pos2));
3099}3195}
31003196
3101template <class _CharT, class _Traits, class _Allocator>
3102template <class _Tp,
3103 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
3104 !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
3105 int> >
3106_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3107basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const _Tp& __t, size_type __pos2, size_type __n) {
3108 __self_view __sv = __t;
3109 size_type __str_sz = __sv.size();
3110 if (__pos2 > __str_sz)
3111 __throw_out_of_range();
3112 return insert(__pos1, __sv.data() + __pos2, std::min(__n, __str_sz - __pos2));
3113}
3114
3115template <class _CharT, class _Traits, class _Allocator>3197template <class _CharT, class _Traits, class _Allocator>
3116_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3198_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3117basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) {3199basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) {
...@@ -3152,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(...@@ -3152,7 +3234,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(
3152 _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::replace received nullptr");3234 _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::replace received nullptr");
3153 size_type __sz = size();3235 size_type __sz = size();
3154 if (__pos > __sz)3236 if (__pos > __sz)
3155 __throw_out_of_range();3237 this->__throw_out_of_range();
3156 __n1 = std::min(__n1, __sz - __pos);3238 __n1 = std::min(__n1, __sz - __pos);
3157 size_type __cap = capacity();3239 size_type __cap = capacity();
3158 if (__cap - __sz + __n1 >= __n2) {3240 if (__cap - __sz + __n1 >= __n2) {
...@@ -3194,7 +3276,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&...@@ -3194,7 +3276,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3194basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) {3276basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, size_type __n2, value_type __c) {
3195 size_type __sz = size();3277 size_type __sz = size();
3196 if (__pos > __sz)3278 if (__pos > __sz)
3197 __throw_out_of_range();3279 this->__throw_out_of_range();
3198 __n1 = std::min(__n1, __sz - __pos);3280 __n1 = std::min(__n1, __sz - __pos);
3199 size_type __cap = capacity();3281 size_type __cap = capacity();
3200 value_type* __p;3282 value_type* __p;
...@@ -3215,40 +3297,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __...@@ -3215,40 +3297,16 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
3215 return __null_terminate_at(__p, __sz - (__n1 - __n2));3297 return __null_terminate_at(__p, __sz - (__n1 - __n2));
3216}3298}
32173299
3218template <class _CharT, class _Traits, class _Allocator>
3219template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
3220_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3221basic_string<_CharT, _Traits, _Allocator>::replace(
3222 const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) {
3223 const basic_string __temp(__j1, __j2, __alloc_);
3224 return replace(__i1, __i2, __temp);
3225}
3226
3227template <class _CharT, class _Traits, class _Allocator>3300template <class _CharT, class _Traits, class _Allocator>
3228_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3301_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3229basic_string<_CharT, _Traits, _Allocator>::replace(3302basic_string<_CharT, _Traits, _Allocator>::replace(
3230 size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) {3303 size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) {
3231 size_type __str_sz = __str.size();3304 size_type __str_sz = __str.size();
3232 if (__pos2 > __str_sz)3305 if (__pos2 > __str_sz)
3233 __throw_out_of_range();3306 this->__throw_out_of_range();
3234 return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2));3307 return replace(__pos1, __n1, __str.data() + __pos2, std::min(__n2, __str_sz - __pos2));
3235}3308}
32363309
3237template <class _CharT, class _Traits, class _Allocator>
3238template <class _Tp,
3239 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
3240 !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
3241 int> >
3242_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3243basic_string<_CharT, _Traits, _Allocator>::replace(
3244 size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) {
3245 __self_view __sv = __t;
3246 size_type __str_sz = __sv.size();
3247 if (__pos2 > __str_sz)
3248 __throw_out_of_range();
3249 return replace(__pos1, __n1, __sv.data() + __pos2, std::min(__n2, __str_sz - __pos2));
3250}
3251
3252template <class _CharT, class _Traits, class _Allocator>3310template <class _CharT, class _Traits, class _Allocator>
3253_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3311_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3254basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) {3312basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) {
...@@ -3278,7 +3336,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -3278,7 +3336,7 @@ template <class _CharT, class _Traits, class _Allocator>
3278_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&3336_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3279basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) {3337basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) {
3280 if (__pos > size())3338 if (__pos > size())
3281 __throw_out_of_range();3339 this->__throw_out_of_range();
3282 if (__n == npos) {3340 if (__n == npos) {
3283 __erase_to_end(__pos);3341 __erase_to_end(__pos);
3284 } else {3342 } else {
...@@ -3316,11 +3374,13 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat...@@ -3316,11 +3374,13 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
33163374
3317template <class _CharT, class _Traits, class _Allocator>3375template <class _CharT, class _Traits, class _Allocator>
3318inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT {3376inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT {
3319 size_type __old_size = size();3377 size_type __old_size;
3320 if (__is_long()) {3378 if (__is_long()) {
3379 __old_size = __get_long_size();
3321 traits_type::assign(*__get_long_pointer(), value_type());3380 traits_type::assign(*__get_long_pointer(), value_type());
3322 __set_long_size(0);3381 __set_long_size(0);
3323 } else {3382 } else {
3383 __old_size = __get_short_size();
3324 traits_type::assign(*__get_short_pointer(), value_type());3384 traits_type::assign(*__get_short_pointer(), value_type());
3325 __set_short_size(0);3385 __set_short_size(0);
3326 }3386 }
...@@ -3349,7 +3409,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)...@@ -3349,7 +3409,7 @@ basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n)
3349template <class _CharT, class _Traits, class _Allocator>3409template <class _CharT, class _Traits, class _Allocator>
3350_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) {3410_LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __requested_capacity) {
3351 if (__requested_capacity > max_size())3411 if (__requested_capacity > max_size())
3352 __throw_length_error();3412 this->__throw_length_error();
33533413
3354 // Make sure reserve(n) never shrinks. This is technically only required in C++203414 // Make sure reserve(n) never shrinks. This is technically only required in C++20
3355 // and later (since P0966R1), however we provide consistent behavior in all Standard3415 // and later (since P0966R1), however we provide consistent behavior in all Standard
...@@ -3357,7 +3417,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re...@@ -3357,7 +3417,16 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
3357 if (__requested_capacity <= capacity())3417 if (__requested_capacity <= capacity())
3358 return;3418 return;
33593419
3360 __shrink_or_extend(__recommend(__requested_capacity));3420 __annotation_guard __g(*this);
3421 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__requested_capacity) + 1);
3422 auto __size = size();
3423 __begin_lifetime(__allocation.ptr, __allocation.count);
3424 traits_type::copy(std::__to_address(__allocation.ptr), data(), __size + 1);
3425 if (__is_long())
3426 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
3427 __set_long_cap(__allocation.count);
3428 __set_long_size(__size);
3429 __set_long_pointer(__allocation.ptr);
3361}3430}
33623431
3363template <class _CharT, class _Traits, class _Allocator>3432template <class _CharT, class _Traits, class _Allocator>
...@@ -3366,76 +3435,52 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat...@@ -3366,76 +3435,52 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
3366 if (__target_capacity == capacity())3435 if (__target_capacity == capacity())
3367 return;3436 return;
33683437
3369 __shrink_or_extend(__target_capacity);3438 _LIBCPP_ASSERT_INTERNAL(__is_long(), "Trying to shrink small string");
3370}
33713439
3372template <class _CharT, class _Traits, class _Allocator>3440 // We're a long string and we're shrinking into the small buffer.
3373inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void3441 const auto __ptr = __get_long_pointer();
3374basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target_capacity) {3442 const auto __size = __get_long_size();
3375 __annotate_delete();3443 const auto __cap = __get_long_cap();
3376 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
3377 size_type __cap = capacity();
3378 size_type __sz = size();
33793444
3380 pointer __new_data, __p;
3381 bool __was_long, __now_long;
3382 if (__fits_in_sso(__target_capacity)) {3445 if (__fits_in_sso(__target_capacity)) {
3383 __was_long = true;3446 __annotation_guard __g(*this);
3384 __now_long = false;3447 __set_short_size(__size);
3385 __new_data = __get_short_pointer();3448 traits_type::copy(std::__to_address(__get_short_pointer()), std::__to_address(__ptr), __size + 1);
3386 __p = __get_long_pointer();3449 __alloc_traits::deallocate(__alloc_, __ptr, __cap);
3387 } else {3450 return;
3388 if (__target_capacity > __cap) {3451 }
3389 // Extend3452
3390 // - called from reserve should propagate the exception thrown.
3391 auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
3392 __new_data = __allocation.ptr;
3393 __target_capacity = __allocation.count - 1;
3394 } else {
3395 // Shrink
3396 // - called from shrink_to_fit should not throw.
3397 // - called from reserve may throw but is not required to.
3398# if _LIBCPP_HAS_EXCEPTIONS3453# if _LIBCPP_HAS_EXCEPTIONS
3399 try {3454 try {
3400# endif // _LIBCPP_HAS_EXCEPTIONS3455# endif // _LIBCPP_HAS_EXCEPTIONS
3401 auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);3456 __annotation_guard __g(*this);
34023457 auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);
3403 // The Standard mandates shrink_to_fit() does not increase the capacity.3458
3404 // With equal capacity keep the existing buffer. This avoids extra work3459 // The Standard mandates shrink_to_fit() does not increase the capacity.
3405 // due to swapping the elements.3460 // With equal capacity keep the existing buffer. This avoids extra work
3406 if (__allocation.count - 1 > capacity()) {3461 // due to swapping the elements.
3407 __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count);3462 if (__allocation.count - 1 >= capacity()) {
3408 return;3463 __alloc_traits::deallocate(__alloc_, __allocation.ptr, __allocation.count);
3409 }3464 return;
3410 __new_data = __allocation.ptr;3465 }
3411 __target_capacity = __allocation.count - 1;3466
3467 __begin_lifetime(__allocation.ptr, __allocation.count);
3468 traits_type::copy(std::__to_address(__allocation.ptr), std::__to_address(__ptr), __size + 1);
3469 __alloc_traits::deallocate(__alloc_, __ptr, __cap);
3470 __set_long_cap(__allocation.count);
3471 __set_long_pointer(__allocation.ptr);
3412# if _LIBCPP_HAS_EXCEPTIONS3472# if _LIBCPP_HAS_EXCEPTIONS
3413 } catch (...) {3473 } catch (...) {
3414 return;3474 return;
3415 }3475 }
3416# endif // _LIBCPP_HAS_EXCEPTIONS3476# endif // _LIBCPP_HAS_EXCEPTIONS
3417 }
3418 __begin_lifetime(__new_data, __target_capacity + 1);
3419 __now_long = true;
3420 __was_long = __is_long();
3421 __p = __get_pointer();
3422 }
3423 traits_type::copy(std::__to_address(__new_data), std::__to_address(__p), size() + 1);
3424 if (__was_long)
3425 __alloc_traits::deallocate(__alloc_, __p, __cap + 1);
3426 if (__now_long) {
3427 __set_long_cap(__target_capacity + 1);
3428 __set_long_size(__sz);
3429 __set_long_pointer(__new_data);
3430 } else
3431 __set_short_size(__sz);
3432}3477}
34333478
3434template <class _CharT, class _Traits, class _Allocator>3479template <class _CharT, class _Traits, class _Allocator>
3435_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::const_reference3480_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::const_reference
3436basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const {3481basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) const {
3437 if (__n >= size())3482 if (__n >= size())
3438 __throw_out_of_range();3483 this->__throw_out_of_range();
3439 return (*this)[__n];3484 return (*this)[__n];
3440}3485}
34413486
...@@ -3443,7 +3488,7 @@ template <class _CharT, class _Traits, class _Allocator>...@@ -3443,7 +3488,7 @@ template <class _CharT, class _Traits, class _Allocator>
3443_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::reference3488_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::reference
3444basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) {3489basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) {
3445 if (__n >= size())3490 if (__n >= size())
3446 __throw_out_of_range();3491 this->__throw_out_of_range();
3447 return (*this)[__n];3492 return (*this)[__n];
3448}3493}
34493494
...@@ -3452,7 +3497,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>...@@ -3452,7 +3497,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>
3452basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const {3497basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, size_type __pos) const {
3453 size_type __sz = size();3498 size_type __sz = size();
3454 if (__pos > __sz)3499 if (__pos > __sz)
3455 __throw_out_of_range();3500 this->__throw_out_of_range();
3456 size_type __rlen = std::min(__n, __sz - __pos);3501 size_type __rlen = std::min(__n, __sz - __pos);
3457 traits_type::copy(__s, data() + __pos, __rlen);3502 traits_type::copy(__s, data() + __pos, __rlen);
3458 return __rlen;3503 return __rlen;
...@@ -3482,274 +3527,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat...@@ -3482,274 +3527,15 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
3482 __str.__annotate_new(__str.__get_short_size());3527 __str.__annotate_new(__str.__get_short_size());
3483}3528}
34843529
3485// find
3486
3487template <class _CharT, class _Traits, class _Allocator>
3488_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3489basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3490 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find(): received nullptr");
3491 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3492}
3493
3494template <class _CharT, class _Traits, class _Allocator>
3495inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3496basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT {
3497 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
3498}
3499
3500template <class _CharT, class _Traits, class _Allocator>
3501template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3502_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3503basic_string<_CharT, _Traits, _Allocator>::find(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3504 __self_view __sv = __t;
3505 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
3506}
3507
3508template <class _CharT, class _Traits, class _Allocator>
3509inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3510basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT {
3511 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr");
3512 return std::__str_find<value_type, size_type, traits_type, npos>(
3513 data(), size(), __s, __pos, traits_type::length(__s));
3514}
3515
3516template <class _CharT, class _Traits, class _Allocator>
3517_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3518basic_string<_CharT, _Traits, _Allocator>::find(value_type __c, size_type __pos) const _NOEXCEPT {
3519 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
3520}
3521
3522// rfind
3523
3524template <class _CharT, class _Traits, class _Allocator>
3525_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3526basic_string<_CharT, _Traits, _Allocator>::rfind(
3527 const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3528 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::rfind(): received nullptr");
3529 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3530}
3531
3532template <class _CharT, class _Traits, class _Allocator>
3533inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3534basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT {
3535 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
3536}
3537
3538template <class _CharT, class _Traits, class _Allocator>
3539template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3540_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3541basic_string<_CharT, _Traits, _Allocator>::rfind(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3542 __self_view __sv = __t;
3543 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
3544}
3545
3546template <class _CharT, class _Traits, class _Allocator>
3547inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3548basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT {
3549 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr");
3550 return std::__str_rfind<value_type, size_type, traits_type, npos>(
3551 data(), size(), __s, __pos, traits_type::length(__s));
3552}
3553
3554template <class _CharT, class _Traits, class _Allocator>
3555_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3556basic_string<_CharT, _Traits, _Allocator>::rfind(value_type __c, size_type __pos) const _NOEXCEPT {
3557 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
3558}
3559
3560// find_first_of
3561
3562template <class _CharT, class _Traits, class _Allocator>
3563_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3564basic_string<_CharT, _Traits, _Allocator>::find_first_of(
3565 const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3566 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_of(): received nullptr");
3567 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3568}
3569
3570template <class _CharT, class _Traits, class _Allocator>
3571inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3572basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT {
3573 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
3574 data(), size(), __str.data(), __pos, __str.size());
3575}
3576
3577template <class _CharT, class _Traits, class _Allocator>
3578template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3579_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3580basic_string<_CharT, _Traits, _Allocator>::find_first_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3581 __self_view __sv = __t;
3582 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
3583 data(), size(), __sv.data(), __pos, __sv.size());
3584}
3585
3586template <class _CharT, class _Traits, class _Allocator>
3587inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3588basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT {
3589 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr");
3590 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
3591 data(), size(), __s, __pos, traits_type::length(__s));
3592}
3593
3594template <class _CharT, class _Traits, class _Allocator>
3595inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3596basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT {
3597 return find(__c, __pos);
3598}
3599
3600// find_last_of
3601
3602template <class _CharT, class _Traits, class _Allocator>
3603inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3604basic_string<_CharT, _Traits, _Allocator>::find_last_of(
3605 const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3606 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_of(): received nullptr");
3607 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3608}
3609
3610template <class _CharT, class _Traits, class _Allocator>
3611inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3612basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT {
3613 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
3614 data(), size(), __str.data(), __pos, __str.size());
3615}
3616
3617template <class _CharT, class _Traits, class _Allocator>
3618template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3619_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3620basic_string<_CharT, _Traits, _Allocator>::find_last_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3621 __self_view __sv = __t;
3622 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
3623 data(), size(), __sv.data(), __pos, __sv.size());
3624}
3625
3626template <class _CharT, class _Traits, class _Allocator>
3627inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3628basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT {
3629 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr");
3630 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
3631 data(), size(), __s, __pos, traits_type::length(__s));
3632}
3633
3634template <class _CharT, class _Traits, class _Allocator>
3635inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3636basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT {
3637 return rfind(__c, __pos);
3638}
3639
3640// find_first_not_of
3641
3642template <class _CharT, class _Traits, class _Allocator>
3643_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3644basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(
3645 const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3646 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_first_not_of(): received nullptr");
3647 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3648}
3649
3650template <class _CharT, class _Traits, class _Allocator>
3651inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3652basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(
3653 const basic_string& __str, size_type __pos) const _NOEXCEPT {
3654 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
3655 data(), size(), __str.data(), __pos, __str.size());
3656}
3657
3658template <class _CharT, class _Traits, class _Allocator>
3659template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3660_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3661basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3662 __self_view __sv = __t;
3663 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
3664 data(), size(), __sv.data(), __pos, __sv.size());
3665}
3666
3667template <class _CharT, class _Traits, class _Allocator>
3668inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3669basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT {
3670 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr");
3671 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
3672 data(), size(), __s, __pos, traits_type::length(__s));
3673}
3674
3675template <class _CharT, class _Traits, class _Allocator>
3676inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3677basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT {
3678 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
3679}
3680
3681// find_last_not_of
3682
3683template <class _CharT, class _Traits, class _Allocator>
3684_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3685basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(
3686 const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT {
3687 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::find_last_not_of(): received nullptr");
3688 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __s, __pos, __n);
3689}
3690
3691template <class _CharT, class _Traits, class _Allocator>
3692inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3693basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(
3694 const basic_string& __str, size_type __pos) const _NOEXCEPT {
3695 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
3696 data(), size(), __str.data(), __pos, __str.size());
3697}
3698
3699template <class _CharT, class _Traits, class _Allocator>
3700template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3701_LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3702basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const _Tp& __t, size_type __pos) const _NOEXCEPT {
3703 __self_view __sv = __t;
3704 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
3705 data(), size(), __sv.data(), __pos, __sv.size());
3706}
3707
3708template <class _CharT, class _Traits, class _Allocator>
3709inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3710basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT {
3711 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr");
3712 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
3713 data(), size(), __s, __pos, traits_type::length(__s));
3714}
3715
3716template <class _CharT, class _Traits, class _Allocator>
3717inline _LIBCPP_CONSTEXPR_SINCE_CXX20 typename basic_string<_CharT, _Traits, _Allocator>::size_type
3718basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT {
3719 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(data(), size(), __c, __pos);
3720}
3721
3722// compare3530// compare
37233531
3724template <class _CharT, class _Traits, class _Allocator>
3725template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3726_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(const _Tp& __t) const _NOEXCEPT {
3727 __self_view __sv = __t;
3728 size_t __lhs_sz = size();
3729 size_t __rhs_sz = __sv.size();
3730 int __result = traits_type::compare(data(), __sv.data(), std::min(__lhs_sz, __rhs_sz));
3731 if (__result != 0)
3732 return __result;
3733 if (__lhs_sz < __rhs_sz)
3734 return -1;
3735 if (__lhs_sz > __rhs_sz)
3736 return 1;
3737 return 0;
3738}
3739
3740template <class _CharT, class _Traits, class _Allocator>
3741inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int
3742basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT {
3743 return compare(__self_view(__str));
3744}
3745
3746template <class _CharT, class _Traits, class _Allocator>3532template <class _CharT, class _Traits, class _Allocator>
3747inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(3533inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(
3748 size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const {3534 size_type __pos1, size_type __n1, const value_type* __s, size_type __n2) const {
3749 _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");3535 _LIBCPP_ASSERT_NON_NULL(__n2 == 0 || __s != nullptr, "string::compare(): received nullptr");
3750 size_type __sz = size();3536 size_type __sz = size();
3751 if (__pos1 > __sz || __n2 == npos)3537 if (__pos1 > __sz || __n2 == npos)
3752 __throw_out_of_range();3538 this->__throw_out_of_range();
3753 size_type __rlen = std::min(__n1, __sz - __pos1);3539 size_type __rlen = std::min(__n1, __sz - __pos1);
3754 int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2));3540 int __r = traits_type::compare(data() + __pos1, __s, std::min(__rlen, __n2));
3755 if (__r == 0) {3541 if (__r == 0) {
...@@ -3761,51 +3547,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocato...@@ -3761,51 +3547,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocato
3761 return __r;3547 return __r;
3762}3548}
37633549
3764template <class _CharT, class _Traits, class _Allocator>
3765template <class _Tp, __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value, int> >
3766_LIBCPP_CONSTEXPR_SINCE_CXX20 int
3767basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const _Tp& __t) const {
3768 __self_view __sv = __t;
3769 return compare(__pos1, __n1, __sv.data(), __sv.size());
3770}
3771
3772template <class _CharT, class _Traits, class _Allocator>
3773inline _LIBCPP_CONSTEXPR_SINCE_CXX20 int
3774basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const basic_string& __str) const {
3775 return compare(__pos1, __n1, __str.data(), __str.size());
3776}
3777
3778template <class _CharT, class _Traits, class _Allocator>
3779template <class _Tp,
3780 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
3781 !__is_same_uncvref<_Tp, basic_string<_CharT, _Traits, _Allocator> >::value,
3782 int> >
3783_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(
3784 size_type __pos1, size_type __n1, const _Tp& __t, size_type __pos2, size_type __n2) const {
3785 __self_view __sv = __t;
3786 return __self_view(*this).substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3787}
3788
3789template <class _CharT, class _Traits, class _Allocator>
3790_LIBCPP_CONSTEXPR_SINCE_CXX20 int basic_string<_CharT, _Traits, _Allocator>::compare(
3791 size_type __pos1, size_type __n1, const basic_string& __str, size_type __pos2, size_type __n2) const {
3792 return compare(__pos1, __n1, __self_view(__str), __pos2, __n2);
3793}
3794
3795template <class _CharT, class _Traits, class _Allocator>
3796_LIBCPP_CONSTEXPR_SINCE_CXX20 int
3797basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT {
3798 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr");
3799 return compare(0, npos, __s, traits_type::length(__s));
3800}
3801
3802template <class _CharT, class _Traits, class _Allocator>
3803_LIBCPP_CONSTEXPR_SINCE_CXX20 int
3804basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const {
3805 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::compare(): received nullptr");
3806 return compare(__pos1, __n1, __s, traits_type::length(__s));
3807}
3808
3809// __invariants3550// __invariants
38103551
3811template <class _CharT, class _Traits, class _Allocator>3552template <class _CharT, class _Traits, class _Allocator>
...@@ -3821,18 +3562,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 bool basic_string<_CharT, _Traits, _Allocat...@@ -3821,18 +3562,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 bool basic_string<_CharT, _Traits, _Allocat
3821 return true;3562 return true;
3822}3563}
38233564
3824// __clear_and_shrink
3825
3826template <class _CharT, class _Traits, class _Allocator>
3827inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__clear_and_shrink() _NOEXCEPT {
3828 clear();
3829 if (__is_long()) {
3830 __annotate_delete();
3831 __alloc_traits::deallocate(__alloc_, __get_long_pointer(), capacity() + 1);
3832 __rep_ = __rep();
3833 }
3834}
3835
3836// operator==3565// operator==
38373566
3838template <class _CharT, class _Traits, class _Allocator>3567template <class _CharT, class _Traits, class _Allocator>
...@@ -3987,83 +3716,73 @@ operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>&...@@ -3987,83 +3716,73 @@ operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>&
39873716
3988template <class _CharT, class _Traits, class _Allocator>3717template <class _CharT, class _Traits, class _Allocator>
3989_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>3718_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
3990operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,3719__concatenate_strings(const _Allocator& __alloc,
3991 const basic_string<_CharT, _Traits, _Allocator>& __rhs) {3720 __type_identity_t<basic_string_view<_CharT, _Traits> > __str1,
3721 __type_identity_t<basic_string_view<_CharT, _Traits> > __str2) {
3992 using _String = basic_string<_CharT, _Traits, _Allocator>;3722 using _String = basic_string<_CharT, _Traits, _Allocator>;
3993 auto __lhs_sz = __lhs.size();
3994 auto __rhs_sz = __rhs.size();
3995 _String __r(__uninitialized_size_tag(),3723 _String __r(__uninitialized_size_tag(),
3996 __lhs_sz + __rhs_sz,3724 __str1.size() + __str2.size(),
3997 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));3725 _String::__alloc_traits::select_on_container_copy_construction(__alloc));
3998 auto __ptr = std::__to_address(__r.__get_pointer());3726 auto __ptr = std::__to_address(__r.__get_pointer());
3999 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);3727 _Traits::copy(__ptr, __str1.data(), __str1.size());
4000 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);3728 _Traits::copy(__ptr + __str1.size(), __str2.data(), __str2.size());
4001 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());3729 _Traits::assign(__ptr[__str1.size() + __str2.size()], _CharT());
4002 return __r;3730 return __r;
4003}3731}
40043732
3733template <class _CharT, class _Traits, class _Allocator>
3734_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
3735operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
3736 const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
3737 return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs);
3738}
3739
4005template <class _CharT, class _Traits, class _Allocator>3740template <class _CharT, class _Traits, class _Allocator>
4006_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>3741_LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
4007operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {3742operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
4008 using _String = basic_string<_CharT, _Traits, _Allocator>;3743 return std::__concatenate_strings<_CharT, _Traits>(__rhs.get_allocator(), __lhs, __rhs);
4009 auto __lhs_sz = _Traits::length(__lhs);
4010 auto __rhs_sz = __rhs.size();
4011 _String __r(__uninitialized_size_tag(),
4012 __lhs_sz + __rhs_sz,
4013 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4014 auto __ptr = std::__to_address(__r.__get_pointer());
4015 _Traits::copy(__ptr, __lhs, __lhs_sz);
4016 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4017 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4018 return __r;
4019}3744}
40203745
3746extern template _LIBCPP_EXPORTED_FROM_ABI string operator+
3747 <char, char_traits<char>, allocator<char> >(char const*, string const&);
3748
4021template <class _CharT, class _Traits, class _Allocator>3749template <class _CharT, class _Traits, class _Allocator>
4022_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>3750_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
4023operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {3751operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
4024 using _String = basic_string<_CharT, _Traits, _Allocator>;3752 return std::__concatenate_strings<_CharT, _Traits>(
4025 typename _String::size_type __rhs_sz = __rhs.size();3753 __rhs.get_allocator(), basic_string_view<_CharT, _Traits>(std::addressof(__lhs), 1), __rhs);
4026 _String __r(__uninitialized_size_tag(),
4027 __rhs_sz + 1,
4028 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4029 auto __ptr = std::__to_address(__r.__get_pointer());
4030 _Traits::assign(__ptr, 1, __lhs);
4031 _Traits::copy(__ptr + 1, __rhs.data(), __rhs_sz);
4032 _Traits::assign(__ptr + 1 + __rhs_sz, 1, _CharT());
4033 return __r;
4034}3754}
40353755
4036template <class _CharT, class _Traits, class _Allocator>3756template <class _CharT, class _Traits, class _Allocator>
4037inline _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>3757_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
4038operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {3758operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) {
4039 using _String = basic_string<_CharT, _Traits, _Allocator>;3759 return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs);
4040 typename _String::size_type __lhs_sz = __lhs.size();
4041 typename _String::size_type __rhs_sz = _Traits::length(__rhs);
4042 _String __r(__uninitialized_size_tag(),
4043 __lhs_sz + __rhs_sz,
4044 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4045 auto __ptr = std::__to_address(__r.__get_pointer());
4046 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4047 _Traits::copy(__ptr + __lhs_sz, __rhs, __rhs_sz);
4048 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4049 return __r;
4050}3760}
40513761
4052template <class _CharT, class _Traits, class _Allocator>3762template <class _CharT, class _Traits, class _Allocator>
4053_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>3763_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
4054operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) {3764operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) {
4055 using _String = basic_string<_CharT, _Traits, _Allocator>;3765 return std::__concatenate_strings<_CharT, _Traits>(
4056 typename _String::size_type __lhs_sz = __lhs.size();3766 __lhs.get_allocator(), __lhs, basic_string_view<_CharT, _Traits>(std::addressof(__rhs), 1));
4057 _String __r(__uninitialized_size_tag(),3767}
4058 __lhs_sz + 1,3768# if _LIBCPP_STD_VER >= 26
4059 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));3769
4060 auto __ptr = std::__to_address(__r.__get_pointer());3770template <class _CharT, class _Traits, class _Allocator>
4061 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);3771_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4062 _Traits::assign(__ptr + __lhs_sz, 1, __rhs);3772operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4063 _Traits::assign(__ptr + 1 + __lhs_sz, 1, _CharT());3773 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {
4064 return __r;3774 return std::__concatenate_strings<_CharT, _Traits>(__lhs.get_allocator(), __lhs, __rhs);
4065}3775}
40663776
3777template <class _CharT, class _Traits, class _Allocator>
3778_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
3779operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
3780 const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
3781 return std::__concatenate_strings<_CharT, _Traits>(__rhs.get_allocator(), __lhs, __rhs);
3782}
3783
3784# endif // _LIBCPP_STD_VER >= 26
3785
4067# ifndef _LIBCPP_CXX03_LANG3786# ifndef _LIBCPP_CXX03_LANG
40683787
4069template <class _CharT, class _Traits, class _Allocator>3788template <class _CharT, class _Traits, class _Allocator>
...@@ -4114,54 +3833,18 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {...@@ -4114,54 +3833,18 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {
41143833
4115# if _LIBCPP_STD_VER >= 263834# if _LIBCPP_STD_VER >= 26
41163835
4117template <class _CharT, class _Traits, class _Allocator>
4118_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4119operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4120 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {
4121 using _String = basic_string<_CharT, _Traits, _Allocator>;
4122 typename _String::size_type __lhs_sz = __lhs.size();
4123 typename _String::size_type __rhs_sz = __rhs.size();
4124 _String __r(__uninitialized_size_tag(),
4125 __lhs_sz + __rhs_sz,
4126 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4127 auto __ptr = std::__to_address(__r.__get_pointer());
4128 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4129 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4130 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4131 return __r;
4132}
4133
4134template <class _CharT, class _Traits, class _Allocator>3836template <class _CharT, class _Traits, class _Allocator>
4135_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>3837_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4136operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs,3838operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs,
4137 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {3839 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {
4138 __lhs.append(__rhs);3840 return std::move(__lhs.append(__rhs));
4139 return std::move(__lhs);
4140}
4141
4142template <class _CharT, class _Traits, class _Allocator>
4143_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4144operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
4145 const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
4146 using _String = basic_string<_CharT, _Traits, _Allocator>;
4147 typename _String::size_type __lhs_sz = __lhs.size();
4148 typename _String::size_type __rhs_sz = __rhs.size();
4149 _String __r(__uninitialized_size_tag(),
4150 __lhs_sz + __rhs_sz,
4151 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4152 auto __ptr = std::__to_address(__r.__get_pointer());
4153 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4154 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4155 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4156 return __r;
4157}3841}
41583842
4159template <class _CharT, class _Traits, class _Allocator>3843template <class _CharT, class _Traits, class _Allocator>
4160_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>3844_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4161operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,3845operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
4162 basic_string<_CharT, _Traits, _Allocator>&& __rhs) {3846 basic_string<_CharT, _Traits, _Allocator>&& __rhs) {
4163 __rhs.insert(0, __lhs);3847 return std::move(__rhs.insert(0, __lhs));
4164 return std::move(__rhs);
4165}3848}
41663849
4167# endif // _LIBCPP_STD_VER >= 263850# endif // _LIBCPP_STD_VER >= 26
...@@ -4274,7 +3957,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Al...@@ -4274,7 +3957,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Al
42743957
4275# if _LIBCPP_STD_VER >= 203958# if _LIBCPP_STD_VER >= 20
4276template <class _CharT, class _Traits, class _Allocator, class _Up>3959template <class _CharT, class _Traits, class _Allocator, class _Up>
4277inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type3960inline _LIBCPP_HIDE_FROM_ABI constexpr typename basic_string<_CharT, _Traits, _Allocator>::size_type
4278erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {3961erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
4279 auto __old_size = __str.size();3962 auto __old_size = __str.size();
4280 __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end());3963 __str.erase(std::remove(__str.begin(), __str.end(), __v), __str.end());
...@@ -4282,7 +3965,7 @@ erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {...@@ -4282,7 +3965,7 @@ erase(basic_string<_CharT, _Traits, _Allocator>& __str, const _Up& __v) {
4282}3965}
42833966
4284template <class _CharT, class _Traits, class _Allocator, class _Predicate>3967template <class _CharT, class _Traits, class _Allocator, class _Predicate>
4285inline _LIBCPP_HIDE_FROM_ABI typename basic_string<_CharT, _Traits, _Allocator>::size_type3968inline _LIBCPP_HIDE_FROM_ABI constexpr typename basic_string<_CharT, _Traits, _Allocator>::size_type
4286erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {3969erase_if(basic_string<_CharT, _Traits, _Allocator>& __str, _Predicate __pred) {
4287 auto __old_size = __str.size();3970 auto __old_size = __str.size();
4288 __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end());3971 __str.erase(std::remove_if(__str.begin(), __str.end(), __pred), __str.end());
...@@ -4345,6 +4028,7 @@ _LIBCPP_POP_MACROS...@@ -4345,6 +4028,7 @@ _LIBCPP_POP_MACROS
4345# include <cstdlib>4028# include <cstdlib>
4346# include <iterator>4029# include <iterator>
4347# include <new>4030# include <new>
4031# include <optional>
4348# include <type_traits>4032# include <type_traits>
4349# include <typeinfo>4033# include <typeinfo>
4350# include <utility>4034# include <utility>
lib/libcxx/include/string_view+8-3
...@@ -235,7 +235,8 @@ namespace std {...@@ -235,7 +235,8 @@ namespace std {
235# include <__type_traits/is_convertible.h>235# include <__type_traits/is_convertible.h>
236# include <__type_traits/is_same.h>236# include <__type_traits/is_same.h>
237# include <__type_traits/is_standard_layout.h>237# include <__type_traits/is_standard_layout.h>
238# include <__type_traits/is_trivial.h>238# include <__type_traits/is_trivially_constructible.h>
239# include <__type_traits/is_trivially_copyable.h>
239# include <__type_traits/remove_cvref.h>240# include <__type_traits/remove_cvref.h>
240# include <__type_traits/remove_reference.h>241# include <__type_traits/remove_reference.h>
241# include <__type_traits/type_identity.h>242# include <__type_traits/type_identity.h>
...@@ -302,7 +303,10 @@ public:...@@ -302,7 +303,10 @@ public:
302303
303 static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");304 static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");
304 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");305 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
305 static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");306 static_assert(is_trivially_default_constructible<value_type>::value,
307 "Character type of basic_string_view must be trivially default constructible");
308 static_assert(is_trivially_copyable<value_type>::value,
309 "Character type of basic_string_view must be trivially copyable");
306 static_assert(is_same<_CharT, typename traits_type::char_type>::value,310 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
307 "traits_type::char_type must be the same type as CharT");311 "traits_type::char_type must be the same type as CharT");
308312
...@@ -447,7 +451,7 @@ public:...@@ -447,7 +451,7 @@ public:
447 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type451 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
448 copy(_CharT* __s, size_type __n, size_type __pos = 0) const {452 copy(_CharT* __s, size_type __n, size_type __pos = 0) const {
449 if (__pos > size())453 if (__pos > size())
450 __throw_out_of_range("string_view::copy");454 std::__throw_out_of_range("string_view::copy");
451 size_type __rlen = std::min(__n, size() - __pos);455 size_type __rlen = std::min(__n, size() - __pos);
452 _Traits::copy(__s, data() + __pos, __rlen);456 _Traits::copy(__s, data() + __pos, __rlen);
453 return __rlen;457 return __rlen;
...@@ -948,6 +952,7 @@ _LIBCPP_POP_MACROS...@@ -948,6 +952,7 @@ _LIBCPP_POP_MACROS
948# include <concepts>952# include <concepts>
949# include <cstdlib>953# include <cstdlib>
950# include <iterator>954# include <iterator>
955# include <optional>
951# include <type_traits>956# include <type_traits>
952# endif957# endif
953#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)958#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/strstream+31-24
...@@ -133,30 +133,33 @@ private:...@@ -133,30 +133,33 @@ private:
133# include <__cxx03/strstream>133# include <__cxx03/strstream>
134#else134#else
135# include <__config>135# include <__config>
136# include <__ostream/basic_ostream.h>
137# include <istream>
138# include <streambuf>
139# include <version>
140136
141# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)137# if _LIBCPP_HAS_LOCALIZATION
142# pragma GCC system_header
143# endif
144138
145# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)139# include <__ostream/basic_ostream.h>
140# include <istream>
141# include <streambuf>
142# include <version>
143
144# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
145# pragma GCC system_header
146# endif
147
148# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)
146149
147_LIBCPP_PUSH_MACROS150_LIBCPP_PUSH_MACROS
148# include <__undef_macros>151# include <__undef_macros>
149152
150_LIBCPP_BEGIN_NAMESPACE_STD153_LIBCPP_BEGIN_NAMESPACE_STD
151154
152class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {155class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {
153public:156public:
154# ifndef _LIBCPP_CXX03_LANG157# ifndef _LIBCPP_CXX03_LANG
155 _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}158 _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}
156 explicit strstreambuf(streamsize __alsize);159 explicit strstreambuf(streamsize __alsize);
157# else160# else
158 explicit strstreambuf(streamsize __alsize = 0);161 explicit strstreambuf(streamsize __alsize = 0);
159# endif162# endif
160 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));163 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
161 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);164 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
162 strstreambuf(const char* __gnext, streamsize __n);165 strstreambuf(const char* __gnext, streamsize __n);
...@@ -166,10 +169,10 @@ public:...@@ -166,10 +169,10 @@ public:
166 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);169 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
167 strstreambuf(const unsigned char* __gnext, streamsize __n);170 strstreambuf(const unsigned char* __gnext, streamsize __n);
168171
169# ifndef _LIBCPP_CXX03_LANG172# ifndef _LIBCPP_CXX03_LANG
170 _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);173 _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);
171 _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);174 _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);
172# endif // _LIBCPP_CXX03_LANG175# endif // _LIBCPP_CXX03_LANG
173176
174 ~strstreambuf() override;177 ~strstreambuf() override;
175178
...@@ -203,7 +206,7 @@ private:...@@ -203,7 +206,7 @@ private:
203 void __init(char* __gnext, streamsize __n, char* __pbeg);206 void __init(char* __gnext, streamsize __n, char* __pbeg);
204};207};
205208
206# ifndef _LIBCPP_CXX03_LANG209# ifndef _LIBCPP_CXX03_LANG
207210
208inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)211inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)
209 : streambuf(__rhs),212 : streambuf(__rhs),
...@@ -232,7 +235,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&...@@ -232,7 +235,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&
232 return *this;235 return *this;
233}236}
234237
235# endif // _LIBCPP_CXX03_LANG238# endif // _LIBCPP_CXX03_LANG
236239
237class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {240class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {
238public:241public:
...@@ -241,7 +244,7 @@ public:...@@ -241,7 +244,7 @@ public:
241 _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}244 _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
242 _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}245 _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
243246
244# ifndef _LIBCPP_CXX03_LANG247# ifndef _LIBCPP_CXX03_LANG
245 _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension248 _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension
246 : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {249 : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
247 istream::set_rdbuf(&__sb_);250 istream::set_rdbuf(&__sb_);
...@@ -252,7 +255,7 @@ public:...@@ -252,7 +255,7 @@ public:
252 istream::operator=(std::move(__rhs));255 istream::operator=(std::move(__rhs));
253 return *this;256 return *this;
254 }257 }
255# endif // _LIBCPP_CXX03_LANG258# endif // _LIBCPP_CXX03_LANG
256259
257 ~istrstream() override;260 ~istrstream() override;
258261
...@@ -274,7 +277,7 @@ public:...@@ -274,7 +277,7 @@ public:
274 _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)277 _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
275 : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}278 : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
276279
277# ifndef _LIBCPP_CXX03_LANG280# ifndef _LIBCPP_CXX03_LANG
278 _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension281 _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension
279 : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {282 : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
280 ostream::set_rdbuf(&__sb_);283 ostream::set_rdbuf(&__sb_);
...@@ -285,7 +288,7 @@ public:...@@ -285,7 +288,7 @@ public:
285 ostream::operator=(std::move(__rhs));288 ostream::operator=(std::move(__rhs));
286 return *this;289 return *this;
287 }290 }
288# endif // _LIBCPP_CXX03_LANG291# endif // _LIBCPP_CXX03_LANG
289292
290 ~ostrstream() override;293 ~ostrstream() override;
291294
...@@ -316,7 +319,7 @@ public:...@@ -316,7 +319,7 @@ public:
316 _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)319 _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
317 : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}320 : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
318321
319# ifndef _LIBCPP_CXX03_LANG322# ifndef _LIBCPP_CXX03_LANG
320 _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension323 _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension
321 : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {324 : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
322 iostream::set_rdbuf(&__sb_);325 iostream::set_rdbuf(&__sb_);
...@@ -327,7 +330,7 @@ public:...@@ -327,7 +330,7 @@ public:
327 iostream::operator=(std::move(__rhs));330 iostream::operator=(std::move(__rhs));
328 return *this;331 return *this;
329 }332 }
330# endif // _LIBCPP_CXX03_LANG333# endif // _LIBCPP_CXX03_LANG
331334
332 ~strstream() override;335 ~strstream() override;
333336
...@@ -350,7 +353,11 @@ _LIBCPP_END_NAMESPACE_STD...@@ -350,7 +353,11 @@ _LIBCPP_END_NAMESPACE_STD
350353
351_LIBCPP_POP_MACROS354_LIBCPP_POP_MACROS
352355
353# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)356# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) ||
354#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)357 // defined(_LIBCPP_BUILDING_LIBRARY)
358
359# endif // _LIBCPP_HAS_LOCALIZATION
360
361#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
355362
356#endif // _LIBCPP_STRSTREAM363#endif // _LIBCPP_STRSTREAM
lib/libcxx/include/syncstream+8-9
...@@ -118,10 +118,15 @@ namespace std {...@@ -118,10 +118,15 @@ namespace std {
118*/118*/
119119
120#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)120#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
121# include <__cxx03/syncstream>121# include <__cxx03/__config>
122#else122#else
123# include <__config>123# include <__config>
124124
125// standard-mandated includes
126
127// [syncstream.syn]
128# include <ostream>
129
125# if _LIBCPP_HAS_LOCALIZATION130# if _LIBCPP_HAS_LOCALIZATION
126131
127# include <__mutex/lock_guard.h>132# include <__mutex/lock_guard.h>
...@@ -130,17 +135,11 @@ namespace std {...@@ -130,17 +135,11 @@ namespace std {
130# include <iosfwd> // required for declaration of default arguments135# include <iosfwd> // required for declaration of default arguments
131# include <streambuf>136# include <streambuf>
132# include <string>137# include <string>
133
134# if _LIBCPP_HAS_THREADS138# if _LIBCPP_HAS_THREADS
135# include <map>139# include <map>
136# include <shared_mutex>140# include <shared_mutex>
137# endif141# endif
138142
139// standard-mandated includes
140
141// [syncstream.syn]
142# include <ostream>
143
144# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)143# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
145# pragma GCC system_header144# pragma GCC system_header
146# endif145# endif
...@@ -248,7 +247,7 @@ private:...@@ -248,7 +247,7 @@ private:
248// Therefore the allocator used in the constructor is passed to the247// Therefore the allocator used in the constructor is passed to the
249// basic_string. The class does not keep a copy of this allocator.248// basic_string. The class does not keep a copy of this allocator.
250template <class _CharT, class _Traits, class _Allocator>249template <class _CharT, class _Traits, class _Allocator>
251class _LIBCPP_TEMPLATE_VIS basic_syncbuf : public basic_streambuf<_CharT, _Traits> {250class basic_syncbuf : public basic_streambuf<_CharT, _Traits> {
252public:251public:
253 using char_type = _CharT;252 using char_type = _CharT;
254 using traits_type = _Traits;253 using traits_type = _Traits;
...@@ -439,7 +438,7 @@ swap(basic_syncbuf<_CharT, _Traits, _Allocator>& __lhs, basic_syncbuf<_CharT, _T...@@ -439,7 +438,7 @@ swap(basic_syncbuf<_CharT, _Traits, _Allocator>& __lhs, basic_syncbuf<_CharT, _T
439// basic_osyncstream438// basic_osyncstream
440439
441template <class _CharT, class _Traits, class _Allocator>440template <class _CharT, class _Traits, class _Allocator>
442class _LIBCPP_TEMPLATE_VIS basic_osyncstream : public basic_ostream<_CharT, _Traits> {441class basic_osyncstream : public basic_ostream<_CharT, _Traits> {
443public:442public:
444 using char_type = _CharT;443 using char_type = _CharT;
445 using traits_type = _Traits;444 using traits_type = _Traits;
lib/libcxx/include/system_error+1
...@@ -168,6 +168,7 @@ template <> struct hash<std::error_condition>;...@@ -168,6 +168,7 @@ template <> struct hash<std::error_condition>;
168# include <cstdint>168# include <cstdint>
169# include <cstring>169# include <cstring>
170# include <limits>170# include <limits>
171# include <optional>
171# include <type_traits>172# include <type_traits>
172# endif173# endif
173#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)174#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/tuple+24-19
...@@ -211,11 +211,12 @@ template <class... Types>...@@ -211,11 +211,12 @@ template <class... Types>
211// clang-format on211// clang-format on
212212
213#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)213#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
214# include <__cxx03/tuple>214# include <__cxx03/__config>
215#else215#else
216# include <__compare/common_comparison_category.h>216# include <__compare/common_comparison_category.h>
217# include <__compare/ordering.h>217# include <__compare/ordering.h>
218# include <__compare/synth_three_way.h>218# include <__compare/synth_three_way.h>
219# include <__concepts/boolean_testable.h>
219# include <__config>220# include <__config>
220# include <__cstddef/size_t.h>221# include <__cstddef/size_t.h>
221# include <__fwd/array.h>222# include <__fwd/array.h>
...@@ -250,6 +251,7 @@ template <class... Types>...@@ -250,6 +251,7 @@ template <class... Types>
250# include <__type_traits/is_nothrow_assignable.h>251# include <__type_traits/is_nothrow_assignable.h>
251# include <__type_traits/is_nothrow_constructible.h>252# include <__type_traits/is_nothrow_constructible.h>
252# include <__type_traits/is_reference.h>253# include <__type_traits/is_reference.h>
254# include <__type_traits/is_replaceable.h>
253# include <__type_traits/is_same.h>255# include <__type_traits/is_same.h>
254# include <__type_traits/is_swappable.h>256# include <__type_traits/is_swappable.h>
255# include <__type_traits/is_trivially_relocatable.h>257# include <__type_traits/is_trivially_relocatable.h>
...@@ -257,6 +259,7 @@ template <class... Types>...@@ -257,6 +259,7 @@ template <class... Types>
257# include <__type_traits/maybe_const.h>259# include <__type_traits/maybe_const.h>
258# include <__type_traits/nat.h>260# include <__type_traits/nat.h>
259# include <__type_traits/negation.h>261# include <__type_traits/negation.h>
262# include <__type_traits/reference_constructs_from_temporary.h>
260# include <__type_traits/remove_cv.h>263# include <__type_traits/remove_cv.h>
261# include <__type_traits/remove_cvref.h>264# include <__type_traits/remove_cvref.h>
262# include <__type_traits/remove_reference.h>265# include <__type_traits/remove_reference.h>
...@@ -307,15 +310,6 @@ template <size_t _Ip, class _Hp, bool>...@@ -307,15 +310,6 @@ template <size_t _Ip, class _Hp, bool>
307class __tuple_leaf {310class __tuple_leaf {
308 _Hp __value_;311 _Hp __value_;
309312
310 template <class _Tp>
311 static _LIBCPP_HIDE_FROM_ABI constexpr bool __can_bind_reference() {
312# if __has_keyword(__reference_binds_to_temporary)
313 return !__reference_binds_to_temporary(_Hp, _Tp);
314# else
315 return true;
316# endif
317 }
318
319public:313public:
320 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;314 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
321315
...@@ -345,7 +339,7 @@ public:...@@ -345,7 +339,7 @@ public:
345 _LIBCPP_HIDE_FROM_ABI339 _LIBCPP_HIDE_FROM_ABI
346 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)340 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
347 : __value_(std::forward<_Tp>(__t)) {341 : __value_(std::forward<_Tp>(__t)) {
348 static_assert(__can_bind_reference<_Tp&&>(),342 static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>,
349 "Attempted construction of reference element binds to a temporary whose lifetime has ended");343 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
350 }344 }
351345
...@@ -353,7 +347,7 @@ public:...@@ -353,7 +347,7 @@ public:
353 _LIBCPP_HIDE_FROM_ABI347 _LIBCPP_HIDE_FROM_ABI
354 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)348 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
355 : __value_(std::forward<_Tp>(__t)) {349 : __value_(std::forward<_Tp>(__t)) {
356 static_assert(__can_bind_reference<_Tp&&>(),350 static_assert(!__reference_constructs_from_temporary_v<_Hp, _Tp&&>,
357 "Attempted construction of reference element binds to a temporary whose lifetime has ended");351 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
358 }352 }
359353
...@@ -462,8 +456,8 @@ template <class _Indx, class... _Tp>...@@ -462,8 +456,8 @@ template <class _Indx, class... _Tp>
462struct __tuple_impl;456struct __tuple_impl;
463457
464template <size_t... _Indx, class... _Tp>458template <size_t... _Indx, class... _Tp>
465struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>459struct _LIBCPP_DECLSPEC_EMPTY_BASES
466 : public __tuple_leaf<_Indx, _Tp>... {460 __tuple_impl<__tuple_indices<_Indx...>, _Tp...> : public __tuple_leaf<_Indx, _Tp>... {
467 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept(461 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept(
468 __all<is_nothrow_default_constructible<_Tp>::value...>::value) {}462 __all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
469463
...@@ -535,7 +529,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up...@@ -535,7 +529,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __tuple_types<_Up
535}529}
536530
537template <class... _Tp>531template <class... _Tp>
538class _LIBCPP_TEMPLATE_VIS tuple {532class _LIBCPP_NO_SPECIALIZATIONS tuple {
539 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;533 typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> _BaseT;
540534
541 _BaseT __base_;535 _BaseT __base_;
...@@ -555,6 +549,7 @@ class _LIBCPP_TEMPLATE_VIS tuple {...@@ -555,6 +549,7 @@ class _LIBCPP_TEMPLATE_VIS tuple {
555public:549public:
556 using __trivially_relocatable _LIBCPP_NODEBUG =550 using __trivially_relocatable _LIBCPP_NODEBUG =
557 __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;551 __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;
552 using __replaceable _LIBCPP_NODEBUG = __conditional_t<_And<__is_replaceable<_Tp>...>::value, tuple, void>;
558553
559 // [tuple.cnstr]554 // [tuple.cnstr]
560555
...@@ -1005,8 +1000,12 @@ public:...@@ -1005,8 +1000,12 @@ public:
1005# endif // _LIBCPP_STD_VER >= 231000# endif // _LIBCPP_STD_VER >= 23
1006};1001};
10071002
1003_LIBCPP_DIAGNOSTIC_PUSH
1004# if __has_warning("-Winvalid-specialization")
1005_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
1006# endif
1008template <>1007template <>
1009class _LIBCPP_TEMPLATE_VIS tuple<> {1008class tuple<> {
1010public:1009public:
1011 constexpr tuple() _NOEXCEPT = default;1010 constexpr tuple() _NOEXCEPT = default;
1012 template <class _Alloc>1011 template <class _Alloc>
...@@ -1022,18 +1021,19 @@ public:...@@ -1022,18 +1021,19 @@ public:
1022 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}1021 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const tuple&) const noexcept {}
1023# endif1022# endif
1024};1023};
1024_LIBCPP_DIAGNOSTIC_POP
10251025
1026# if _LIBCPP_STD_VER >= 231026# if _LIBCPP_STD_VER >= 23
1027template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>1027template <class... _TTypes, class... _UTypes, template <class> class _TQual, template <class> class _UQual>
1028 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }1028 requires requires { typename tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>; }
1029struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {1029struct basic_common_reference<tuple<_TTypes...>, tuple<_UTypes...>, _TQual, _UQual> {
1030 using type = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;1030 using type _LIBCPP_NODEBUG = tuple<common_reference_t<_TQual<_TTypes>, _UQual<_UTypes>>...>;
1031};1031};
10321032
1033template <class... _TTypes, class... _UTypes>1033template <class... _TTypes, class... _UTypes>
1034 requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }1034 requires requires { typename tuple<common_type_t<_TTypes, _UTypes>...>; }
1035struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {1035struct common_type<tuple<_TTypes...>, tuple<_UTypes...>> {
1036 using type = tuple<common_type_t<_TTypes, _UTypes>...>;1036 using type _LIBCPP_NODEBUG = tuple<common_type_t<_TTypes, _UTypes>...>;
1037};1037};
1038# endif // _LIBCPP_STD_VER >= 231038# endif // _LIBCPP_STD_VER >= 23
10391039
...@@ -1154,6 +1154,11 @@ struct __tuple_equal<0> {...@@ -1154,6 +1154,11 @@ struct __tuple_equal<0> {
1154};1154};
11551155
1156template <class... _Tp, class... _Up>1156template <class... _Tp, class... _Up>
1157# if _LIBCPP_STD_VER >= 26
1158 requires(__all<requires(const _Tp& __t, const _Up& __u) {
1159 { __t == __u } -> __boolean_testable;
1160 }...>::value && (sizeof...(_Tp) == sizeof...(_Up)))
1161# endif
1157inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool1162inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
1158operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {1163operator==(const tuple<_Tp...>& __x, const tuple<_Up...>& __y) {
1159 static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");1164 static_assert(sizeof...(_Tp) == sizeof...(_Up), "Can't compare tuples of different sizes");
...@@ -1361,7 +1366,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {...@@ -1361,7 +1366,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
1361}1366}
13621367
1363template <class... _Tp, class _Alloc>1368template <class... _Tp, class _Alloc>
1364struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};1369struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
13651370
1366# if _LIBCPP_STD_VER >= 171371# if _LIBCPP_STD_VER >= 17
1367# define _LIBCPP_NOEXCEPT_RETURN(...) \1372# define _LIBCPP_NOEXCEPT_RETURN(...) \
lib/libcxx/include/type_traits+189-155
...@@ -18,13 +18,11 @@ namespace std...@@ -18,13 +18,11 @@ namespace std
1818
19 // helper class:19 // helper class:
20 template <class T, T v> struct integral_constant;20 template <class T, T v> struct integral_constant;
21 typedef integral_constant<bool, true> true_type; // C++1121 typedef integral_constant<bool, true> true_type; // since C++11
22 typedef integral_constant<bool, false> false_type; // C++1122 typedef integral_constant<bool, false> false_type; // since C++11
2323
24 template <bool B> // C++1424 template <bool B>
25 using bool_constant = integral_constant<bool, B>; // C++1425 using bool_constant = integral_constant<bool, B>; // since C++17
26 typedef bool_constant<true> true_type; // C++14
27 typedef bool_constant<false> false_type; // C++14
2826
29 // helper traits27 // helper traits
30 template <bool, class T = void> struct enable_if;28 template <bool, class T = void> struct enable_if;
...@@ -32,7 +30,7 @@ namespace std...@@ -32,7 +30,7 @@ namespace std
3230
33 // Primary classification traits:31 // Primary classification traits:
34 template <class T> struct is_void;32 template <class T> struct is_void;
35 template <class T> struct is_null_pointer; // C++1433 template <class T> struct is_null_pointer; // since C++14
36 template <class T> struct is_integral;34 template <class T> struct is_integral;
37 template <class T> struct is_floating_point;35 template <class T> struct is_floating_point;
38 template <class T> struct is_array;36 template <class T> struct is_array;
...@@ -51,7 +49,7 @@ namespace std...@@ -51,7 +49,7 @@ namespace std
51 template <class T> struct is_arithmetic;49 template <class T> struct is_arithmetic;
52 template <class T> struct is_fundamental;50 template <class T> struct is_fundamental;
53 template <class T> struct is_member_pointer;51 template <class T> struct is_member_pointer;
54 template <class T> struct is_scoped_enum; // C++2352 template <class T> struct is_scoped_enum; // since C++23
55 template <class T> struct is_scalar;53 template <class T> struct is_scalar;
56 template <class T> struct is_object;54 template <class T> struct is_object;
57 template <class T> struct is_compound;55 template <class T> struct is_compound;
...@@ -75,9 +73,9 @@ namespace std...@@ -75,9 +73,9 @@ namespace std
75 template <class T> struct remove_pointer;73 template <class T> struct remove_pointer;
76 template <class T> struct add_pointer;74 template <class T> struct add_pointer;
7775
78 template<class T> struct type_identity; // C++2076 template<class T> struct type_identity; // since C++20
79 template<class T>77 template<class T>
80 using type_identity_t = typename type_identity<T>::type; // C++2078 using type_identity_t = typename type_identity<T>::type; // since C++20
8179
82 // Integral properties:80 // Integral properties:
83 template <class T> struct is_signed;81 template <class T> struct is_signed;
...@@ -91,20 +89,20 @@ namespace std...@@ -91,20 +89,20 @@ namespace std
91 template <class T> struct remove_extent;89 template <class T> struct remove_extent;
92 template <class T> struct remove_all_extents;90 template <class T> struct remove_all_extents;
9391
94 template <class T> struct is_bounded_array; // C++2092 template <class T> struct is_bounded_array; // since C++20
95 template <class T> struct is_unbounded_array; // C++2093 template <class T> struct is_unbounded_array; // since C++20
9694
97 // Member introspection:95 // Member introspection:
98 template <class T> struct is_pod;96 template <class T> struct is_trivial; // deprecated in C++26
99 template <class T> struct is_trivial;97 template <class T> struct is_pod; // deprecated in C++20
100 template <class T> struct is_trivially_copyable;98 template <class T> struct is_trivially_copyable;
101 template <class T> struct is_standard_layout;99 template <class T> struct is_standard_layout;
102 template <class T> struct is_literal_type; // Deprecated in C++17; removed in C++20100 template <class T> struct is_literal_type; // deprecated in C++17; removed in C++20
103 template <class T> struct is_empty;101 template <class T> struct is_empty;
104 template <class T> struct is_polymorphic;102 template <class T> struct is_polymorphic;
105 template <class T> struct is_abstract;103 template <class T> struct is_abstract;
106 template <class T> struct is_final; // C++14104 template <class T> struct is_final; // since C++14
107 template <class T> struct is_aggregate; // C++17105 template <class T> struct is_aggregate; // since C++17
108106
109 template <class T, class... Args> struct is_constructible;107 template <class T, class... Args> struct is_constructible;
110 template <class T> struct is_default_constructible;108 template <class T> struct is_default_constructible;
...@@ -113,8 +111,8 @@ namespace std...@@ -113,8 +111,8 @@ namespace std
113 template <class T, class U> struct is_assignable;111 template <class T, class U> struct is_assignable;
114 template <class T> struct is_copy_assignable;112 template <class T> struct is_copy_assignable;
115 template <class T> struct is_move_assignable;113 template <class T> struct is_move_assignable;
116 template <class T, class U> struct is_swappable_with; // C++17114 template <class T, class U> struct is_swappable_with; // since C++17
117 template <class T> struct is_swappable; // C++17115 template <class T> struct is_swappable; // since C++17
118 template <class T> struct is_destructible;116 template <class T> struct is_destructible;
119117
120 template <class T, class... Args> struct is_trivially_constructible;118 template <class T, class... Args> struct is_trivially_constructible;
...@@ -133,292 +131,328 @@ namespace std...@@ -133,292 +131,328 @@ namespace std
133 template <class T, class U> struct is_nothrow_assignable;131 template <class T, class U> struct is_nothrow_assignable;
134 template <class T> struct is_nothrow_copy_assignable;132 template <class T> struct is_nothrow_copy_assignable;
135 template <class T> struct is_nothrow_move_assignable;133 template <class T> struct is_nothrow_move_assignable;
136 template <class T, class U> struct is_nothrow_swappable_with; // C++17134 template <class T, class U>
137 template <class T> struct is_nothrow_swappable; // C++17135 struct is_nothrow_swappable_with; // since C++17
136 template <class T>
137 struct is_nothrow_swappable; // since C++17
138 template <class T> struct is_nothrow_destructible;138 template <class T> struct is_nothrow_destructible;
139139
140 template<class T> struct is_implicit_lifetime; // Since C++23140 template <class T> struct is_implicit_lifetime; // since C++23
141141
142 template <class T> struct has_virtual_destructor;142 template <class T> struct has_virtual_destructor;
143143
144 template<class T> struct has_unique_object_representations; // C++17144 template <class T>
145 struct has_unique_object_representations; // since C++17
146
147 template<class T, class U>
148 struct reference_constructs_from_temporary; // since C++23
149 template<class T, class U>
150 struct reference_converts_from_temporary; // since C++23
145151
146 // Relationships between types:152 // Relationships between types:
147 template <class T, class U> struct is_same;153 template <class T, class U> struct is_same;
148 template <class Base, class Derived> struct is_base_of;154 template <class Base, class Derived> struct is_base_of;
149 template <class Base, class Derived> struct is_virtual_base_of; // C++26155 template <class Base, class Derived>
156 struct is_virtual_base_of; // since C++26
150157
151 template <class From, class To> struct is_convertible;158 template <class From, class To> struct is_convertible;
152 template <typename From, typename To> struct is_nothrow_convertible; // C++20159 template <class From, class To>
153 template <typename From, typename To> inline constexpr bool is_nothrow_convertible_v; // C++20160 struct is_nothrow_convertible; // since C++20
154161
155 template <class Fn, class... ArgTypes> struct is_invocable;162 template <class Fn, class... ArgTypes> struct is_invocable; // since C++17
156 template <class R, class Fn, class... ArgTypes> struct is_invocable_r;163 template <class R, class Fn, class... ArgTypes>
164 struct is_invocable_r; // since C++17
157165
158 template <class Fn, class... ArgTypes> struct is_nothrow_invocable;166 template <class Fn, class... ArgTypes>
159 template <class R, class Fn, class... ArgTypes> struct is_nothrow_invocable_r;167 struct is_nothrow_invocable; // since C++17
168 template <class R, class Fn, class... ArgTypes>
169 struct is_nothrow_invocable_r; // since C++17
160170
161 // Alignment properties and transformations:171 // Alignment properties and transformations:
162 template <class T> struct alignment_of;172 template <class T> struct alignment_of;
163 template <size_t Len, size_t Align = most_stringent_alignment_requirement>173 template <size_t Len, size_t Align = most_stringent_alignment_requirement>
164 struct aligned_storage; // deprecated in C++23174 struct aligned_storage; // deprecated in C++23
165 template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23175 template <size_t Len, class... Types> struct aligned_union; // deprecated in C++23
166 template <class T> struct remove_cvref; // C++20176 template <class T> struct remove_cvref; // since C++20
167177
168 template <class T> struct decay;178 template <class T> struct decay;
169 template <class... T> struct common_type;179 template <class... T> struct common_type;
170 template <class T> struct underlying_type;180 template <class T> struct underlying_type;
171 template <class> class result_of; // undefined; deprecated in C++17; removed in C++20181 template <class> struct result_of; // undefined; deprecated in C++17; removed in C++20
172 template <class Fn, class... ArgTypes> class result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20182 template <class Fn, class... ArgTypes>
173 template <class Fn, class... ArgTypes> struct invoke_result; // C++17183 struct result_of<Fn(ArgTypes...)>; // deprecated in C++17; removed in C++20
184 template <class Fn, class... ArgTypes>
185 struct invoke_result; // since C++17
174186
175 // const-volatile modifications:187 // const-volatile modifications:
176 template <class T>188 template <class T>
177 using remove_const_t = typename remove_const<T>::type; // C++14189 using remove_const_t = typename remove_const<T>::type; // since C++14
178 template <class T>190 template <class T>
179 using remove_volatile_t = typename remove_volatile<T>::type; // C++14191 using remove_volatile_t
192 = typename remove_volatile<T>::type; // since C++14
180 template <class T>193 template <class T>
181 using remove_cv_t = typename remove_cv<T>::type; // C++14194 using remove_cv_t = typename remove_cv<T>::type; // since C++14
182 template <class T>195 template <class T>
183 using add_const_t = typename add_const<T>::type; // C++14196 using add_const_t = typename add_const<T>::type; // since C++14
184 template <class T>197 template <class T>
185 using add_volatile_t = typename add_volatile<T>::type; // C++14198 using add_volatile_t = typename add_volatile<T>::type; // since C++14
186 template <class T>199 template <class T>
187 using add_cv_t = typename add_cv<T>::type; // C++14200 using add_cv_t = typename add_cv<T>::type; // since C++14
188201
189 // reference modifications:202 // reference modifications:
190 template <class T>203 template <class T>
191 using remove_reference_t = typename remove_reference<T>::type; // C++14204 using remove_reference_t
205 = typename remove_reference<T>::type; // since C++14
192 template <class T>206 template <class T>
193 using add_lvalue_reference_t = typename add_lvalue_reference<T>::type; // C++14207 using add_lvalue_reference_t
208 = typename add_lvalue_reference<T>::type; // since C++14
194 template <class T>209 template <class T>
195 using add_rvalue_reference_t = typename add_rvalue_reference<T>::type; // C++14210 using add_rvalue_reference_t
211 = typename add_rvalue_reference<T>::type; // since C++14
196212
197 // sign modifications:213 // sign modifications:
198 template <class T>214 template <class T>
199 using make_signed_t = typename make_signed<T>::type; // C++14215 using make_signed_t = typename make_signed<T>::type; // since C++14
200 template <class T>216 template <class T>
201 using make_unsigned_t = typename make_unsigned<T>::type; // C++14217 using make_unsigned_t = typename make_unsigned<T>::type; // since C++14
202218
203 // array modifications:219 // array modifications:
204 template <class T>220 template <class T>
205 using remove_extent_t = typename remove_extent<T>::type; // C++14221 using remove_extent_t
222 = typename remove_extent<T>::type; // since C++14
206 template <class T>223 template <class T>
207 using remove_all_extents_t = typename remove_all_extents<T>::type; // C++14224 using remove_all_extents_t
225 = typename remove_all_extents<T>::type; // since C++14
208226
209 template <class T>227 template <class T>
210 inline constexpr bool is_bounded_array_v228 inline constexpr bool is_bounded_array_v
211 = is_bounded_array<T>::value; // C++20229 = is_bounded_array<T>::value; // since C++20
212 inline constexpr bool is_unbounded_array_v230 inline constexpr bool is_unbounded_array_v
213 = is_unbounded_array<T>::value; // C++20231 = is_unbounded_array<T>::value; // since C++20
214232
215 // pointer modifications:233 // pointer modifications:
216 template <class T>234 template <class T>
217 using remove_pointer_t = typename remove_pointer<T>::type; // C++14235 using remove_pointer_t
236 = typename remove_pointer<T>::type; // since C++14
218 template <class T>237 template <class T>
219 using add_pointer_t = typename add_pointer<T>::type; // C++14238 using add_pointer_t = typename add_pointer<T>::type; // since C++14
220239
221 // other transformations:240 // other transformations:
222 template <size_t Len, size_t Align=default-alignment>241 template <size_t Len, size_t Align=default-alignment>
223 using aligned_storage_t = typename aligned_storage<Len,Align>::type; // C++14242 using aligned_storage_t
243 = typename aligned_storage<Len,Align>::type; // since C++14
224 template <size_t Len, class... Types>244 template <size_t Len, class... Types>
225 using aligned_union_t = typename aligned_union<Len,Types...>::type; // C++14245 using aligned_union_t
246 = typename aligned_union<Len,Types...>::type; // since C++14
226 template <class T>247 template <class T>
227 using remove_cvref_t = typename remove_cvref<T>::type; // C++20248 using remove_cvref_t
249 = typename remove_cvref<T>::type; // since C++20
228 template <class T>250 template <class T>
229 using decay_t = typename decay<T>::type; // C++14251 using decay_t = typename decay<T>::type; // since C++14
230 template <bool b, class T=void>252 template <bool b, class T=void>
231 using enable_if_t = typename enable_if<b,T>::type; // C++14253 using enable_if_t = typename enable_if<b,T>::type; // since C++14
232 template <bool b, class T, class F>254 template <bool b, class T, class F>
233 using conditional_t = typename conditional<b,T,F>::type; // C++14255 using conditional_t
256 = typename conditional<b,T,F>::type; // since C++14
234 template <class... T>257 template <class... T>
235 using common_type_t = typename common_type<T...>::type; // C++14258 using common_type_t
259 = typename common_type<T...>::type; // since C++14
236 template <class T>260 template <class T>
237 using underlying_type_t = typename underlying_type<T>::type; // C++14261 using underlying_type_t
262 = typename underlying_type<T>::type; // since C++14
238 template <class T>263 template <class T>
239 using result_of_t = typename result_of<T>::type; // C++14; deprecated in C++17; removed in C++20264 using result_of_t = typename result_of<T>::type; // since C++14; deprecated in C++17; removed in C++20
240 template <class Fn, class... ArgTypes>265 template <class Fn, class... ArgTypes>
241 using invoke_result_t = typename invoke_result<Fn, ArgTypes...>::type; // C++17266 using invoke_result_t
267 = typename invoke_result<Fn, ArgTypes...>::type; // since C++17
242268
243 template <class...>269 template <class...>
244 using void_t = void; // C++17270 using void_t = void; // since C++17
245271
246 // See C++14 20.10.4.1, primary type categories272 // See C++14 20.10.4.1, primary type categories
247 template <class T> inline constexpr bool is_void_v273 template <class T> inline constexpr bool is_void_v
248 = is_void<T>::value; // C++17274 = is_void<T>::value; // since C++17
249 template <class T> inline constexpr bool is_null_pointer_v275 template <class T> inline constexpr bool is_null_pointer_v
250 = is_null_pointer<T>::value; // C++17276 = is_null_pointer<T>::value; // since C++17
251 template <class T> inline constexpr bool is_integral_v277 template <class T> inline constexpr bool is_integral_v
252 = is_integral<T>::value; // C++17278 = is_integral<T>::value; // since C++17
253 template <class T> inline constexpr bool is_floating_point_v279 template <class T> inline constexpr bool is_floating_point_v
254 = is_floating_point<T>::value; // C++17280 = is_floating_point<T>::value; // since C++17
255 template <class T> inline constexpr bool is_array_v281 template <class T> inline constexpr bool is_array_v
256 = is_array<T>::value; // C++17282 = is_array<T>::value; // since C++17
257 template <class T> inline constexpr bool is_pointer_v283 template <class T> inline constexpr bool is_pointer_v
258 = is_pointer<T>::value; // C++17284 = is_pointer<T>::value; // since C++17
259 template <class T> inline constexpr bool is_lvalue_reference_v285 template <class T> inline constexpr bool is_lvalue_reference_v
260 = is_lvalue_reference<T>::value; // C++17286 = is_lvalue_reference<T>::value; // since C++17
261 template <class T> inline constexpr bool is_rvalue_reference_v287 template <class T> inline constexpr bool is_rvalue_reference_v
262 = is_rvalue_reference<T>::value; // C++17288 = is_rvalue_reference<T>::value; // since C++17
263 template <class T> inline constexpr bool is_member_object_pointer_v289 template <class T> inline constexpr bool is_member_object_pointer_v
264 = is_member_object_pointer<T>::value; // C++17290 = is_member_object_pointer<T>::value; // since C++17
265 template <class T> inline constexpr bool is_member_function_pointer_v291 template <class T> inline constexpr bool is_member_function_pointer_v
266 = is_member_function_pointer<T>::value; // C++17292 = is_member_function_pointer<T>::value; // since C++17
267 template <class T> inline constexpr bool is_enum_v293 template <class T> inline constexpr bool is_enum_v
268 = is_enum<T>::value; // C++17294 = is_enum<T>::value; // since C++17
269 template <class T> inline constexpr bool is_union_v295 template <class T> inline constexpr bool is_union_v
270 = is_union<T>::value; // C++17296 = is_union<T>::value; // since C++17
271 template <class T> inline constexpr bool is_class_v297 template <class T> inline constexpr bool is_class_v
272 = is_class<T>::value; // C++17298 = is_class<T>::value; // since C++17
273 template <class T> inline constexpr bool is_function_v299 template <class T> inline constexpr bool is_function_v
274 = is_function<T>::value; // C++17300 = is_function<T>::value; // since C++17
275301
276 // See C++14 20.10.4.2, composite type categories302 // See C++14 20.10.4.2, composite type categories
277 template <class T> inline constexpr bool is_reference_v303 template <class T> inline constexpr bool is_reference_v
278 = is_reference<T>::value; // C++17304 = is_reference<T>::value; // since C++17
279 template <class T> inline constexpr bool is_arithmetic_v305 template <class T> inline constexpr bool is_arithmetic_v
280 = is_arithmetic<T>::value; // C++17306 = is_arithmetic<T>::value; // since C++17
281 template <class T> inline constexpr bool is_fundamental_v307 template <class T> inline constexpr bool is_fundamental_v
282 = is_fundamental<T>::value; // C++17308 = is_fundamental<T>::value; // since C++17
283 template <class T> inline constexpr bool is_object_v309 template <class T> inline constexpr bool is_object_v
284 = is_object<T>::value; // C++17310 = is_object<T>::value; // since C++17
285 template <class T> inline constexpr bool is_scalar_v311 template <class T> inline constexpr bool is_scalar_v
286 = is_scalar<T>::value; // C++17312 = is_scalar<T>::value; // since C++17
287 template <class T> inline constexpr bool is_compound_v313 template <class T> inline constexpr bool is_compound_v
288 = is_compound<T>::value; // C++17314 = is_compound<T>::value; // since C++17
289 template <class T> inline constexpr bool is_member_pointer_v315 template <class T> inline constexpr bool is_member_pointer_v
290 = is_member_pointer<T>::value; // C++17316 = is_member_pointer<T>::value; // since C++17
291 template <class T> inline constexpr bool is_scoped_enum_v317 template <class T> inline constexpr bool is_scoped_enum_v
292 = is_scoped_enum<T>::value; // C++23318 = is_scoped_enum<T>::value; // since C++23
293319
294 // See C++14 20.10.4.3, type properties320 // See C++14 20.10.4.3, type properties
295 template <class T> inline constexpr bool is_const_v321 template <class T> inline constexpr bool is_const_v
296 = is_const<T>::value; // C++17322 = is_const<T>::value; // since C++17
297 template <class T> inline constexpr bool is_volatile_v323 template <class T> inline constexpr bool is_volatile_v
298 = is_volatile<T>::value; // C++17324 = is_volatile<T>::value; // since C++17
299 template <class T> inline constexpr bool is_trivial_v325 template <class T> inline constexpr bool is_trivial_v
300 = is_trivial<T>::value; // C++17326 = is_trivial<T>::value; // since C++17; deprecated in C++26
301 template <class T> inline constexpr bool is_trivially_copyable_v327 template <class T> inline constexpr bool is_trivially_copyable_v
302 = is_trivially_copyable<T>::value; // C++17328 = is_trivially_copyable<T>::value; // since C++17
303 template <class T> inline constexpr bool is_standard_layout_v329 template <class T> inline constexpr bool is_standard_layout_v
304 = is_standard_layout<T>::value; // C++17330 = is_standard_layout<T>::value; // since C++17
305 template <class T> inline constexpr bool is_pod_v331 template <class T> inline constexpr bool is_pod_v
306 = is_pod<T>::value; // C++17332 = is_pod<T>::value; // since C++17; deprecated in C++20
307 template <class T> inline constexpr bool is_literal_type_v333 template <class T> inline constexpr bool is_literal_type_v
308 = is_literal_type<T>::value; // C++17; deprecated in C++17; removed in C++20334 = is_literal_type<T>::value; // since C++17; deprecated in C++17; removed in C++20
309 template <class T> inline constexpr bool is_empty_v335 template <class T> inline constexpr bool is_empty_v
310 = is_empty<T>::value; // C++17336 = is_empty<T>::value; // since C++17
311 template <class T> inline constexpr bool is_polymorphic_v337 template <class T> inline constexpr bool is_polymorphic_v
312 = is_polymorphic<T>::value; // C++17338 = is_polymorphic<T>::value; // since C++17
313 template <class T> inline constexpr bool is_abstract_v339 template <class T> inline constexpr bool is_abstract_v
314 = is_abstract<T>::value; // C++17340 = is_abstract<T>::value; // since C++17
315 template <class T> inline constexpr bool is_final_v341 template <class T> inline constexpr bool is_final_v
316 = is_final<T>::value; // C++17342 = is_final<T>::value; // since C++17
317 template <class T> inline constexpr bool is_aggregate_v343 template <class T> inline constexpr bool is_aggregate_v
318 = is_aggregate<T>::value; // C++17344 = is_aggregate<T>::value; // since C++17
319 template <class T> inline constexpr bool is_signed_v345 template <class T> inline constexpr bool is_signed_v
320 = is_signed<T>::value; // C++17346 = is_signed<T>::value; // since C++17
321 template <class T> inline constexpr bool is_unsigned_v347 template <class T> inline constexpr bool is_unsigned_v
322 = is_unsigned<T>::value; // C++17348 = is_unsigned<T>::value; // since C++17
323 template <class T, class... Args> inline constexpr bool is_constructible_v349 template <class T, class... Args> inline constexpr bool is_constructible_v
324 = is_constructible<T, Args...>::value; // C++17350 = is_constructible<T, Args...>::value; // since C++17
325 template <class T> inline constexpr bool is_default_constructible_v351 template <class T> inline constexpr bool is_default_constructible_v
326 = is_default_constructible<T>::value; // C++17352 = is_default_constructible<T>::value; // since C++17
327 template <class T> inline constexpr bool is_copy_constructible_v353 template <class T> inline constexpr bool is_copy_constructible_v
328 = is_copy_constructible<T>::value; // C++17354 = is_copy_constructible<T>::value; // since C++17
329 template <class T> inline constexpr bool is_move_constructible_v355 template <class T> inline constexpr bool is_move_constructible_v
330 = is_move_constructible<T>::value; // C++17356 = is_move_constructible<T>::value; // since C++17
331 template <class T, class U> inline constexpr bool is_assignable_v357 template <class T, class U> inline constexpr bool is_assignable_v
332 = is_assignable<T, U>::value; // C++17358 = is_assignable<T, U>::value; // since C++17
333 template <class T> inline constexpr bool is_copy_assignable_v359 template <class T> inline constexpr bool is_copy_assignable_v
334 = is_copy_assignable<T>::value; // C++17360 = is_copy_assignable<T>::value; // since C++17
335 template <class T> inline constexpr bool is_move_assignable_v361 template <class T> inline constexpr bool is_move_assignable_v
336 = is_move_assignable<T>::value; // C++17362 = is_move_assignable<T>::value; // since C++17
337 template <class T, class U> inline constexpr bool is_swappable_with_v363 template <class T, class U> inline constexpr bool is_swappable_with_v
338 = is_swappable_with<T, U>::value; // C++17364 = is_swappable_with<T, U>::value; // since C++17
339 template <class T> inline constexpr bool is_swappable_v365 template <class T> inline constexpr bool is_swappable_v
340 = is_swappable<T>::value; // C++17366 = is_swappable<T>::value; // since C++17
341 template <class T> inline constexpr bool is_destructible_v367 template <class T> inline constexpr bool is_destructible_v
342 = is_destructible<T>::value; // C++17368 = is_destructible<T>::value; // since C++17
343 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v369 template <class T, class... Args> inline constexpr bool is_trivially_constructible_v
344 = is_trivially_constructible<T, Args...>::value; // C++17370 = is_trivially_constructible<T, Args...>::value; // since C++17
345 template <class T> inline constexpr bool is_trivially_default_constructible_v371 template <class T> inline constexpr bool is_trivially_default_constructible_v
346 = is_trivially_default_constructible<T>::value; // C++17372 = is_trivially_default_constructible<T>::value; // since C++17
347 template <class T> inline constexpr bool is_trivially_copy_constructible_v373 template <class T> inline constexpr bool is_trivially_copy_constructible_v
348 = is_trivially_copy_constructible<T>::value; // C++17374 = is_trivially_copy_constructible<T>::value; // since C++17
349 template <class T> inline constexpr bool is_trivially_move_constructible_v375 template <class T> inline constexpr bool is_trivially_move_constructible_v
350 = is_trivially_move_constructible<T>::value; // C++17376 = is_trivially_move_constructible<T>::value; // since C++17
351 template <class T, class U> inline constexpr bool is_trivially_assignable_v377 template <class T, class U> inline constexpr bool is_trivially_assignable_v
352 = is_trivially_assignable<T, U>::value; // C++17378 = is_trivially_assignable<T, U>::value; // since C++17
353 template <class T> inline constexpr bool is_trivially_copy_assignable_v379 template <class T> inline constexpr bool is_trivially_copy_assignable_v
354 = is_trivially_copy_assignable<T>::value; // C++17380 = is_trivially_copy_assignable<T>::value; // since C++17
355 template <class T> inline constexpr bool is_trivially_move_assignable_v381 template <class T> inline constexpr bool is_trivially_move_assignable_v
356 = is_trivially_move_assignable<T>::value; // C++17382 = is_trivially_move_assignable<T>::value; // since C++17
357 template <class T> inline constexpr bool is_trivially_destructible_v383 template <class T> inline constexpr bool is_trivially_destructible_v
358 = is_trivially_destructible<T>::value; // C++17384 = is_trivially_destructible<T>::value; // since C++17
359 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v385 template <class T, class... Args> inline constexpr bool is_nothrow_constructible_v
360 = is_nothrow_constructible<T, Args...>::value; // C++17386 = is_nothrow_constructible<T, Args...>::value; // since C++17
361 template <class T> inline constexpr bool is_nothrow_default_constructible_v387 template <class T> inline constexpr bool is_nothrow_default_constructible_v
362 = is_nothrow_default_constructible<T>::value; // C++17388 = is_nothrow_default_constructible<T>::value; // since C++17
363 template <class T> inline constexpr bool is_nothrow_copy_constructible_v389 template <class T> inline constexpr bool is_nothrow_copy_constructible_v
364 = is_nothrow_copy_constructible<T>::value; // C++17390 = is_nothrow_copy_constructible<T>::value; // since C++17
365 template <class T> inline constexpr bool is_nothrow_move_constructible_v391 template <class T> inline constexpr bool is_nothrow_move_constructible_v
366 = is_nothrow_move_constructible<T>::value; // C++17392 = is_nothrow_move_constructible<T>::value; // since C++17
367 template <class T, class U> inline constexpr bool is_nothrow_assignable_v393 template <class T, class U> inline constexpr bool is_nothrow_assignable_v
368 = is_nothrow_assignable<T, U>::value; // C++17394 = is_nothrow_assignable<T, U>::value; // since C++17
369 template <class T> inline constexpr bool is_nothrow_copy_assignable_v395 template <class T> inline constexpr bool is_nothrow_copy_assignable_v
370 = is_nothrow_copy_assignable<T>::value; // C++17396 = is_nothrow_copy_assignable<T>::value; // since C++17
371 template <class T> inline constexpr bool is_nothrow_move_assignable_v397 template <class T> inline constexpr bool is_nothrow_move_assignable_v
372 = is_nothrow_move_assignable<T>::value; // C++17398 = is_nothrow_move_assignable<T>::value; // since C++17
373 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v399 template <class T, class U> inline constexpr bool is_nothrow_swappable_with_v
374 = is_nothrow_swappable_with<T, U>::value; // C++17400 = is_nothrow_swappable_with<T, U>::value; // since C++17
375 template <class T> inline constexpr bool is_nothrow_swappable_v401 template <class T> inline constexpr bool is_nothrow_swappable_v
376 = is_nothrow_swappable<T>::value; // C++17402 = is_nothrow_swappable<T>::value; // since C++17
377 template <class T> inline constexpr bool is_nothrow_destructible_v403 template <class T> inline constexpr bool is_nothrow_destructible_v
378 = is_nothrow_destructible<T>::value; // C++17404 = is_nothrow_destructible<T>::value; // since C++17
379 template<class T>405 template <class T> inline constexpr bool is_implicit_lifetime_v
380 constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value; // Since C++23406 = is_implicit_lifetime<T>::value; // since C++23
381 template <class T> inline constexpr bool has_virtual_destructor_v407 template <class T> inline constexpr bool has_virtual_destructor_v
382 = has_virtual_destructor<T>::value; // C++17408 = has_virtual_destructor<T>::value; // since C++17
383 template<class T> inline constexpr bool has_unique_object_representations_v // C++17409 template<class T> inline constexpr bool has_unique_object_representations_v
384 = has_unique_object_representations<T>::value;410 = has_unique_object_representations<T>::value; // since C++17
411 template<class T, class U>
412 constexpr bool reference_constructs_from_temporary_v
413 = reference_constructs_from_temporary<T, U>::value; // since C++23
414 template<class T, class U>
415 constexpr bool reference_converts_from_temporary_v
416 = reference_converts_from_temporary<T, U>::value; // since C++23
385417
386 // See C++14 20.10.5, type property queries418 // See C++14 20.10.5, type property queries
387 template <class T> inline constexpr size_t alignment_of_v419 template <class T> inline constexpr size_t alignment_of_v
388 = alignment_of<T>::value; // C++17420 = alignment_of<T>::value; // since C++17
389 template <class T> inline constexpr size_t rank_v421 template <class T> inline constexpr size_t rank_v
390 = rank<T>::value; // C++17422 = rank<T>::value; // since C++17
391 template <class T, unsigned I = 0> inline constexpr size_t extent_v423 template <class T, unsigned I = 0> inline constexpr size_t extent_v
392 = extent<T, I>::value; // C++17424 = extent<T, I>::value; // since C++17
393425
394 // See C++14 20.10.6, type relations426 // See C++14 20.10.6, type relations
395 template <class T, class U> inline constexpr bool is_same_v427 template <class T, class U> inline constexpr bool is_same_v
396 = is_same<T, U>::value; // C++17428 = is_same<T, U>::value; // since C++17
397 template <class Base, class Derived> inline constexpr bool is_base_of_v429 template <class Base, class Derived> inline constexpr bool is_base_of_v
398 = is_base_of<Base, Derived>::value; // C++17430 = is_base_of<Base, Derived>::value; // since C++17
399 template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v431 template <class Base, class Derived> inline constexpr bool is_virtual_base_of_v
400 = is_virtual_base_of<Base, Derived>::value; // C++26432 = is_virtual_base_of<Base, Derived>::value; // since C++26
401 template <class From, class To> inline constexpr bool is_convertible_v433 template <class From, class To> inline constexpr bool is_convertible_v
402 = is_convertible<From, To>::value; // C++17434 = is_convertible<From, To>::value; // since C++17
435 template <class From, class To> inline constexpr bool is_nothrow_convertible_v
436 = is_nothrow_convertible<From, To>::value; // since C++20
403 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v437 template <class Fn, class... ArgTypes> inline constexpr bool is_invocable_v
404 = is_invocable<Fn, ArgTypes...>::value; // C++17438 = is_invocable<Fn, ArgTypes...>::value; // since C++17
405 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v439 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_invocable_r_v
406 = is_invocable_r<R, Fn, ArgTypes...>::value; // C++17440 = is_invocable_r<R, Fn, ArgTypes...>::value; // since C++17
407 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v441 template <class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_v
408 = is_nothrow_invocable<Fn, ArgTypes...>::value; // C++17442 = is_nothrow_invocable<Fn, ArgTypes...>::value; // since C++17
409 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v443 template <class R, class Fn, class... ArgTypes> inline constexpr bool is_nothrow_invocable_r_v
410 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // C++17444 = is_nothrow_invocable_r<R, Fn, ArgTypes...>::value; // since C++17
411445
412 // [meta.logical], logical operator traits:446 // [meta.logical], logical operator traits:
413 template<class... B> struct conjunction; // C++17447 template<class... B> struct conjunction; // since C++17
414 template<class... B>448 template<class... B> inline constexpr bool conjunction_v
415 inline constexpr bool conjunction_v = conjunction<B...>::value; // C++17449 = conjunction<B...>::value; // since C++17
416 template<class... B> struct disjunction; // C++17450 template<class... B> struct disjunction; // since C++17
417 template<class... B>451 template<class... B> inline constexpr bool disjunction_v
418 inline constexpr bool disjunction_v = disjunction<B...>::value; // C++17452 = disjunction<B...>::value; // since C++17
419 template<class B> struct negation; // C++17453 template<class B> struct negation; // since C++17
420 template<class B>454 template<class B> inline constexpr bool negation_v
421 inline constexpr bool negation_v = negation<B>::value; // C++17455 = negation<B>::value; // since C++17
422456
423}457}
424458
...@@ -429,9 +463,8 @@ namespace std...@@ -429,9 +463,8 @@ namespace std
429#else463#else
430# include <__config>464# include <__config>
431# include <__type_traits/add_cv_quals.h>465# include <__type_traits/add_cv_quals.h>
432# include <__type_traits/add_lvalue_reference.h>
433# include <__type_traits/add_pointer.h>466# include <__type_traits/add_pointer.h>
434# include <__type_traits/add_rvalue_reference.h>467# include <__type_traits/add_reference.h>
435# include <__type_traits/aligned_storage.h>468# include <__type_traits/aligned_storage.h>
436# include <__type_traits/aligned_union.h>469# include <__type_traits/aligned_union.h>
437# include <__type_traits/alignment_of.h>470# include <__type_traits/alignment_of.h>
...@@ -515,7 +548,6 @@ namespace std...@@ -515,7 +548,6 @@ namespace std
515# include <__type_traits/common_reference.h>548# include <__type_traits/common_reference.h>
516# include <__type_traits/is_bounded_array.h>549# include <__type_traits/is_bounded_array.h>
517# include <__type_traits/is_constant_evaluated.h>550# include <__type_traits/is_constant_evaluated.h>
518# include <__type_traits/is_nothrow_convertible.h>
519# include <__type_traits/is_unbounded_array.h>551# include <__type_traits/is_unbounded_array.h>
520# include <__type_traits/type_identity.h>552# include <__type_traits/type_identity.h>
521# include <__type_traits/unwrap_ref.h>553# include <__type_traits/unwrap_ref.h>
...@@ -523,6 +555,8 @@ namespace std...@@ -523,6 +555,8 @@ namespace std
523555
524# if _LIBCPP_STD_VER >= 23556# if _LIBCPP_STD_VER >= 23
525# include <__type_traits/is_implicit_lifetime.h>557# include <__type_traits/is_implicit_lifetime.h>
558# include <__type_traits/reference_constructs_from_temporary.h>
559# include <__type_traits/reference_converts_from_temporary.h>
526# endif560# endif
527561
528# include <version>562# include <version>
lib/libcxx/include/typeindex+3-3
...@@ -62,7 +62,7 @@ struct hash<type_index>...@@ -62,7 +62,7 @@ struct hash<type_index>
6262
63_LIBCPP_BEGIN_NAMESPACE_STD63_LIBCPP_BEGIN_NAMESPACE_STD
6464
65class _LIBCPP_TEMPLATE_VIS type_index {65class type_index {
66 const type_info* __t_;66 const type_info* __t_;
6767
68public:68public:
...@@ -91,10 +91,10 @@ public:...@@ -91,10 +91,10 @@ public:
91};91};
9292
93template <class _Tp>93template <class _Tp>
94struct _LIBCPP_TEMPLATE_VIS hash;94struct hash;
9595
96template <>96template <>
97struct _LIBCPP_TEMPLATE_VIS hash<type_index> : public __unary_function<type_index, size_t> {97struct hash<type_index> : public __unary_function<type_index, size_t> {
98 _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); }98 _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); }
99};99};
100100
lib/libcxx/include/typeinfo+2-2
...@@ -354,7 +354,7 @@ public:...@@ -354,7 +354,7 @@ public:
354354
355# if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0355# if defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
356356
357namespace std {357_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
358358
359class bad_cast : public exception {359class bad_cast : public exception {
360public:360public:
...@@ -372,7 +372,7 @@ private:...@@ -372,7 +372,7 @@ private:
372 bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}372 bad_typeid(const char* const __message) _NOEXCEPT : exception(__message) {}
373};373};
374374
375} // namespace std375_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
376376
377# endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0377# endif // defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
378378
lib/libcxx/include/unordered_map+68-161
...@@ -654,9 +654,7 @@ public:...@@ -654,9 +654,7 @@ public:
654 _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)654 _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
655 : _Hash(__h) {}655 : _Hash(__h) {}
656 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; }656 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return *this; }
657 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const {657 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return static_cast<const _Hash&>(*this)(__x.first); }
658 return static_cast<const _Hash&>(*this)(__x.__get_value().first);
659 }
660 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); }658 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return static_cast<const _Hash&>(*this)(__x); }
661# if _LIBCPP_STD_VER >= 20659# if _LIBCPP_STD_VER >= 20
662 template <typename _K2>660 template <typename _K2>
...@@ -680,7 +678,7 @@ public:...@@ -680,7 +678,7 @@ public:
680 _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)678 _LIBCPP_HIDE_FROM_ABI __unordered_map_hasher(const _Hash& __h) _NOEXCEPT_(is_nothrow_copy_constructible<_Hash>::value)
681 : __hash_(__h) {}679 : __hash_(__h) {}
682 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; }680 _LIBCPP_HIDE_FROM_ABI const _Hash& hash_function() const _NOEXCEPT { return __hash_; }
683 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.__get_value().first); }681 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Cp& __x) const { return __hash_(__x.first); }
684 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); }682 _LIBCPP_HIDE_FROM_ABI size_t operator()(const _Key& __x) const { return __hash_(__x); }
685# if _LIBCPP_STD_VER >= 20683# if _LIBCPP_STD_VER >= 20
686 template <typename _K2>684 template <typename _K2>
...@@ -713,10 +711,10 @@ public:...@@ -713,10 +711,10 @@ public:
713 : _Pred(__p) {}711 : _Pred(__p) {}
714 _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; }712 _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return *this; }
715 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const {713 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const {
716 return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y.__get_value().first);714 return static_cast<const _Pred&>(*this)(__x.first, __y.first);
717 }715 }
718 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const {716 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const {
719 return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);717 return static_cast<const _Pred&>(*this)(__x.first, __y);
720 }718 }
721 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {719 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
722 return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);720 return static_cast<const _Pred&>(*this)(__x, __y.__get_value().first);
...@@ -724,7 +722,7 @@ public:...@@ -724,7 +722,7 @@ public:
724# if _LIBCPP_STD_VER >= 20722# if _LIBCPP_STD_VER >= 20
725 template <typename _K2>723 template <typename _K2>
726 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {724 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
727 return static_cast<const _Pred&>(*this)(__x.__get_value().first, __y);725 return static_cast<const _Pred&>(*this)(__x.first, __y);
728 }726 }
729 template <typename _K2>727 template <typename _K2>
730 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {728 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {
...@@ -755,23 +753,17 @@ public:...@@ -755,23 +753,17 @@ public:
755 _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)753 _LIBCPP_HIDE_FROM_ABI __unordered_map_equal(const _Pred& __p) _NOEXCEPT_(is_nothrow_copy_constructible<_Pred>::value)
756 : __pred_(__p) {}754 : __pred_(__p) {}
757 _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; }755 _LIBCPP_HIDE_FROM_ABI const _Pred& key_eq() const _NOEXCEPT { return __pred_; }
758 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const {756 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Cp& __y) const { return __pred_(__x.first, __y.first); }
759 return __pred_(__x.__get_value().first, __y.__get_value().first);757 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const { return __pred_(__x.first, __y); }
760 }758 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const { return __pred_(__x, __y.first); }
761 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _Key& __y) const {
762 return __pred_(__x.__get_value().first, __y);
763 }
764 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _Cp& __y) const {
765 return __pred_(__x, __y.__get_value().first);
766 }
767# if _LIBCPP_STD_VER >= 20759# if _LIBCPP_STD_VER >= 20
768 template <typename _K2>760 template <typename _K2>
769 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {761 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Cp& __x, const _K2& __y) const {
770 return __pred_(__x.__get_value().first, __y);762 return __pred_(__x.first, __y);
771 }763 }
772 template <typename _K2>764 template <typename _K2>
773 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {765 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _Cp& __y) const {
774 return __pred_(__x, __y.__get_value().first);766 return __pred_(__x, __y.first);
775 }767 }
776 template <typename _K2>768 template <typename _K2>
777 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const {769 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _K2& __y) const {
...@@ -833,99 +825,19 @@ public:...@@ -833,99 +825,19 @@ public:
833825
834 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {826 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
835 if (__second_constructed)827 if (__second_constructed)
836 __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().second));828 __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().second));
837 if (__first_constructed)829 if (__first_constructed)
838 __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().__get_value().first));830 __alloc_traits::destroy(__na_, std::addressof(__p->__get_value().first));
839 if (__p)831 if (__p)
840 __alloc_traits::deallocate(__na_, __p, 1);832 __alloc_traits::deallocate(__na_, __p, 1);
841 }833 }
842};834};
843835
844# ifndef _LIBCPP_CXX03_LANG
845template <class _Key, class _Tp>836template <class _Key, class _Tp>
846struct _LIBCPP_STANDALONE_DEBUG __hash_value_type {837struct __hash_value_type;
847 typedef _Key key_type;
848 typedef _Tp mapped_type;
849 typedef pair<const key_type, mapped_type> value_type;
850 typedef pair<key_type&, mapped_type&> __nc_ref_pair_type;
851 typedef pair<key_type&&, mapped_type&&> __nc_rref_pair_type;
852
853private:
854 value_type __cc_;
855
856public:
857 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() {
858# if _LIBCPP_STD_VER >= 17
859 return *std::launder(std::addressof(__cc_));
860# else
861 return __cc_;
862# endif
863 }
864
865 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const {
866# if _LIBCPP_STD_VER >= 17
867 return *std::launder(std::addressof(__cc_));
868# else
869 return __cc_;
870# endif
871 }
872
873 _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
874 value_type& __v = __get_value();
875 return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
876 }
877
878 _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() {
879 value_type& __v = __get_value();
880 return __nc_rref_pair_type(std::move(const_cast<key_type&>(__v.first)), std::move(__v.second));
881 }
882
883 _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(const __hash_value_type& __v) {
884 __ref() = __v.__get_value();
885 return *this;
886 }
887
888 _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(__hash_value_type&& __v) {
889 __ref() = __v.__move();
890 return *this;
891 }
892
893 template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>
894 _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) {
895 __ref() = std::forward<_ValueTp>(__v);
896 return *this;
897 }
898
899 __hash_value_type(const __hash_value_type& __v) = delete;
900 __hash_value_type(__hash_value_type&& __v) = delete;
901 template <class... _Args>
902 explicit __hash_value_type(_Args&&... __args) = delete;
903
904 ~__hash_value_type() = delete;
905};
906
907# else
908
909template <class _Key, class _Tp>
910struct __hash_value_type {
911 typedef _Key key_type;
912 typedef _Tp mapped_type;
913 typedef pair<const key_type, mapped_type> value_type;
914
915private:
916 value_type __cc_;
917
918public:
919 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
920 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
921
922 ~__hash_value_type() = delete;
923};
924
925# endif
926838
927template <class _HashIterator>839template <class _HashIterator>
928class _LIBCPP_TEMPLATE_VIS __hash_map_iterator {840class __hash_map_iterator {
929 _HashIterator __i_;841 _HashIterator __i_;
930842
931 typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;843 typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
...@@ -941,8 +853,8 @@ public:...@@ -941,8 +853,8 @@ public:
941853
942 _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}854 _LIBCPP_HIDE_FROM_ABI __hash_map_iterator(_HashIterator __i) _NOEXCEPT : __i_(__i) {}
943855
944 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }856 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
945 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }857 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
946858
947 _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() {859 _LIBCPP_HIDE_FROM_ABI __hash_map_iterator& operator++() {
948 ++__i_;860 ++__i_;
...@@ -964,19 +876,19 @@ public:...@@ -964,19 +876,19 @@ public:
964# endif876# endif
965877
966 template <class, class, class, class, class>878 template <class, class, class, class, class>
967 friend class _LIBCPP_TEMPLATE_VIS unordered_map;879 friend class unordered_map;
968 template <class, class, class, class, class>880 template <class, class, class, class, class>
969 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;881 friend class unordered_multimap;
970 template <class>882 template <class>
971 friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;883 friend class __hash_const_iterator;
972 template <class>884 template <class>
973 friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;885 friend class __hash_const_local_iterator;
974 template <class>886 template <class>
975 friend class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator;887 friend class __hash_map_const_iterator;
976};888};
977889
978template <class _HashIterator>890template <class _HashIterator>
979class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator {891class __hash_map_const_iterator {
980 _HashIterator __i_;892 _HashIterator __i_;
981893
982 typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;894 typedef __hash_node_types_from_iterator<_HashIterator> _NodeTypes;
...@@ -995,8 +907,8 @@ public:...@@ -995,8 +907,8 @@ public:
995 __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT907 __hash_map_const_iterator(__hash_map_iterator<typename _HashIterator::__non_const_iterator> __i) _NOEXCEPT
996 : __i_(__i.__i_) {}908 : __i_(__i.__i_) {}
997909
998 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); }910 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
999 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__i_->__get_value()); }911 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
1000912
1001 _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() {913 _LIBCPP_HIDE_FROM_ABI __hash_map_const_iterator& operator++() {
1002 ++__i_;914 ++__i_;
...@@ -1020,13 +932,13 @@ public:...@@ -1020,13 +932,13 @@ public:
1020# endif932# endif
1021933
1022 template <class, class, class, class, class>934 template <class, class, class, class, class>
1023 friend class _LIBCPP_TEMPLATE_VIS unordered_map;935 friend class unordered_map;
1024 template <class, class, class, class, class>936 template <class, class, class, class, class>
1025 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;937 friend class unordered_multimap;
1026 template <class>938 template <class>
1027 friend class _LIBCPP_TEMPLATE_VIS __hash_const_iterator;939 friend class __hash_const_iterator;
1028 template <class>940 template <class>
1029 friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;941 friend class __hash_const_local_iterator;
1030};942};
1031943
1032template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>944template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1037,7 +949,7 @@ template <class _Key,...@@ -1037,7 +949,7 @@ template <class _Key,
1037 class _Hash = hash<_Key>,949 class _Hash = hash<_Key>,
1038 class _Pred = equal_to<_Key>,950 class _Pred = equal_to<_Key>,
1039 class _Alloc = allocator<pair<const _Key, _Tp> > >951 class _Alloc = allocator<pair<const _Key, _Tp> > >
1040class _LIBCPP_TEMPLATE_VIS unordered_map {952class unordered_map {
1041public:953public:
1042 // types954 // types
1043 typedef _Key key_type;955 typedef _Key key_type;
...@@ -1053,11 +965,10 @@ public:...@@ -1053,11 +965,10 @@ public:
1053965
1054private:966private:
1055 typedef __hash_value_type<key_type, mapped_type> __value_type;967 typedef __hash_value_type<key_type, mapped_type> __value_type;
1056 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;968 typedef __unordered_map_hasher<key_type, value_type, hasher, key_equal> __hasher;
1057 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;969 typedef __unordered_map_equal<key_type, value_type, key_equal, hasher> __key_equal;
1058 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
1059970
1060 typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table;971 typedef __hash_table<__value_type, __hasher, __key_equal, allocator_type> __table;
1061972
1062 __table __table_;973 __table __table_;
1063974
...@@ -1073,9 +984,6 @@ private:...@@ -1073,9 +984,6 @@ private:
1073984
1074 static_assert(__check_valid_allocator<allocator_type>::value, "");985 static_assert(__check_valid_allocator<allocator_type>::value, "");
1075986
1076 static_assert(is_same<typename __table::__container_value_type, value_type>::value, "");
1077 static_assert(is_same<typename __table::__node_value_type, __value_type>::value, "");
1078
1079public:987public:
1080 typedef typename __alloc_traits::pointer pointer;988 typedef typename __alloc_traits::pointer pointer;
1081 typedef typename __alloc_traits::const_pointer const_pointer;989 typedef typename __alloc_traits::const_pointer const_pointer;
...@@ -1093,9 +1001,9 @@ public:...@@ -1093,9 +1001,9 @@ public:
1093# endif1001# endif
10941002
1095 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1003 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1096 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1004 friend class unordered_map;
1097 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1005 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1098 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;1006 friend class unordered_multimap;
10991007
1100 _LIBCPP_HIDE_FROM_ABI unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}1008 _LIBCPP_HIDE_FROM_ABI unordered_map() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1101 explicit _LIBCPP_HIDE_FROM_ABI1009 explicit _LIBCPP_HIDE_FROM_ABI
...@@ -1227,7 +1135,7 @@ public:...@@ -1227,7 +1135,7 @@ public:
1227 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }1135 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
1228 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }1136 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
12291137
1230 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }1138 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); }
12311139
1232 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }1140 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
12331141
...@@ -1238,7 +1146,7 @@ public:...@@ -1238,7 +1146,7 @@ public:
1238 template <_ContainerCompatibleRange<value_type> _Range>1146 template <_ContainerCompatibleRange<value_type> _Range>
1239 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1147 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1240 for (auto&& __element : __range) {1148 for (auto&& __element : __range) {
1241 __table_.__insert_unique(std::forward<decltype(__element)>(__element));1149 __table_.__emplace_unique(std::forward<decltype(__element)>(__element));
1242 }1150 }
1243 }1151 }
1244# endif1152# endif
...@@ -1247,16 +1155,16 @@ public:...@@ -1247,16 +1155,16 @@ public:
1247 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1155 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
12481156
1249 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {1157 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
1250 return __table_.__insert_unique(std::move(__x));1158 return __table_.__emplace_unique(std::move(__x));
1251 }1159 }
12521160
1253 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) {1161 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) {
1254 return __table_.__insert_unique(std::move(__x)).first;1162 return __table_.__emplace_unique(std::move(__x)).first;
1255 }1163 }
12561164
1257 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1165 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1258 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) {1166 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) {
1259 return __table_.__insert_unique(std::forward<_Pp>(__x));1167 return __table_.__emplace_unique(std::forward<_Pp>(__x));
1260 }1168 }
12611169
1262 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1170 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
...@@ -1680,9 +1588,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __...@@ -1680,9 +1588,8 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map(unordered_map&& __
1680 : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {1588 : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {
1681 if (__a != __u.get_allocator()) {1589 if (__a != __u.get_allocator()) {
1682 iterator __i = __u.begin();1590 iterator __i = __u.begin();
1683 while (__u.size() != 0) {1591 while (__u.size() != 0)
1684 __table_.__emplace_unique(__u.__table_.remove((__i++).__i_)->__get_value().__move());1592 __table_.__insert_unique_from_orphaned_node(std::move(__u.__table_.remove((__i++).__i_)->__get_value()));
1685 }
1686 }1593 }
1687}1594}
16881595
...@@ -1732,7 +1639,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -1732,7 +1639,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1732template <class _InputIterator>1639template <class _InputIterator>
1733inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {1640inline void unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
1734 for (; __first != __last; ++__first)1641 for (; __first != __last; ++__first)
1735 __table_.__insert_unique(*__first);1642 __table_.__emplace_unique(*__first);
1736}1643}
17371644
1738# ifndef _LIBCPP_CXX03_LANG1645# ifndef _LIBCPP_CXX03_LANG
...@@ -1741,8 +1648,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -1741,8 +1648,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1741_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {1648_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k) {
1742 return __table_1649 return __table_
1743 .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())1650 .__emplace_unique_key_args(__k, piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())
1744 .first->__get_value()1651 .first->second;
1745 .second;
1746}1652}
17471653
1748template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>1654template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -1750,8 +1656,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)...@@ -1750,8 +1656,7 @@ _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&& __k)
1750 return __table_1656 return __table_
1751 .__emplace_unique_key_args(1657 .__emplace_unique_key_args(
1752 __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())1658 __k, piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())
1753 .first->__get_value()1659 .first->second;
1754 .second;
1755}1660}
1756# else // _LIBCPP_CXX03_LANG1661# else // _LIBCPP_CXX03_LANG
17571662
...@@ -1760,9 +1665,9 @@ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder...@@ -1760,9 +1665,9 @@ typename unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__node_holder
1760unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) {1665unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const key_type& __k) {
1761 __node_allocator& __na = __table_.__node_alloc();1666 __node_allocator& __na = __table_.__node_alloc();
1762 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));1667 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
1763 __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().first), __k);1668 __node_traits::construct(__na, std::addressof(__h->__get_value().first), __k);
1764 __h.get_deleter().__first_constructed = true;1669 __h.get_deleter().__first_constructed = true;
1765 __node_traits::construct(__na, std::addressof(__h->__get_value().__get_value().second));1670 __node_traits::construct(__na, std::addressof(__h->__get_value().second));
1766 __h.get_deleter().__second_constructed = true;1671 __h.get_deleter().__second_constructed = true;
1767 return __h;1672 return __h;
1768}1673}
...@@ -1784,7 +1689,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -1784,7 +1689,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1784_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) {1689_Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) {
1785 iterator __i = find(__k);1690 iterator __i = find(__k);
1786 if (__i == end())1691 if (__i == end())
1787 __throw_out_of_range("unordered_map::at: key not found");1692 std::__throw_out_of_range("unordered_map::at: key not found");
1788 return __i->second;1693 return __i->second;
1789}1694}
17901695
...@@ -1792,7 +1697,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -1792,7 +1697,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
1792const _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const {1697const _Tp& unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::at(const key_type& __k) const {
1793 const_iterator __i = find(__k);1698 const_iterator __i = find(__k);
1794 if (__i == end())1699 if (__i == end())
1795 __throw_out_of_range("unordered_map::at: key not found");1700 std::__throw_out_of_range("unordered_map::at: key not found");
1796 return __i->second;1701 return __i->second;
1797}1702}
17981703
...@@ -1843,6 +1748,8 @@ struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > {...@@ -1843,6 +1748,8 @@ struct __container_traits<unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> > {
1843 // inserting a single element, the insertion has no effect.1748 // inserting a single element, the insertion has no effect.
1844 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =1749 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1845 __is_nothrow_invocable_v<_Hash, const _Key&>;1750 __is_nothrow_invocable_v<_Hash, const _Key&>;
1751
1752 static _LIBCPP_CONSTEXPR const bool __reservable = true;
1846};1753};
18471754
1848template <class _Key,1755template <class _Key,
...@@ -1850,7 +1757,7 @@ template <class _Key,...@@ -1850,7 +1757,7 @@ template <class _Key,
1850 class _Hash = hash<_Key>,1757 class _Hash = hash<_Key>,
1851 class _Pred = equal_to<_Key>,1758 class _Pred = equal_to<_Key>,
1852 class _Alloc = allocator<pair<const _Key, _Tp> > >1759 class _Alloc = allocator<pair<const _Key, _Tp> > >
1853class _LIBCPP_TEMPLATE_VIS unordered_multimap {1760class unordered_multimap {
1854public:1761public:
1855 // types1762 // types
1856 typedef _Key key_type;1763 typedef _Key key_type;
...@@ -1867,11 +1774,10 @@ public:...@@ -1867,11 +1774,10 @@ public:
18671774
1868private:1775private:
1869 typedef __hash_value_type<key_type, mapped_type> __value_type;1776 typedef __hash_value_type<key_type, mapped_type> __value_type;
1870 typedef __unordered_map_hasher<key_type, __value_type, hasher, key_equal> __hasher;1777 typedef __unordered_map_hasher<key_type, value_type, hasher, key_equal> __hasher;
1871 typedef __unordered_map_equal<key_type, __value_type, key_equal, hasher> __key_equal;1778 typedef __unordered_map_equal<key_type, value_type, key_equal, hasher> __key_equal;
1872 typedef __rebind_alloc<allocator_traits<allocator_type>, __value_type> __allocator_type;
18731779
1874 typedef __hash_table<__value_type, __hasher, __key_equal, __allocator_type> __table;1780 typedef __hash_table<__value_type, __hasher, __key_equal, allocator_type> __table;
18751781
1876 __table __table_;1782 __table __table_;
18771783
...@@ -1901,9 +1807,9 @@ public:...@@ -1901,9 +1807,9 @@ public:
1901# endif1807# endif
19021808
1903 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1809 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1904 friend class _LIBCPP_TEMPLATE_VIS unordered_map;1810 friend class unordered_map;
1905 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>1811 template <class _Key2, class _Tp2, class _Hash2, class _Pred2, class _Alloc2>
1906 friend class _LIBCPP_TEMPLATE_VIS unordered_multimap;1812 friend class unordered_multimap;
19071813
1908 _LIBCPP_HIDE_FROM_ABI unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}1814 _LIBCPP_HIDE_FROM_ABI unordered_multimap() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1909 explicit _LIBCPP_HIDE_FROM_ABI1815 explicit _LIBCPP_HIDE_FROM_ABI
...@@ -2036,10 +1942,10 @@ public:...@@ -2036,10 +1942,10 @@ public:
2036 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }1942 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __table_.begin(); }
2037 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }1943 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __table_.end(); }
20381944
2039 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }1945 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); }
20401946
2041 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {1947 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {
2042 return __table_.__insert_multi(__p.__i_, __x);1948 return __table_.__emplace_hint_multi(__p.__i_, __x);
2043 }1949 }
20441950
2045 template <class _InputIterator>1951 template <class _InputIterator>
...@@ -2049,27 +1955,27 @@ public:...@@ -2049,27 +1955,27 @@ public:
2049 template <_ContainerCompatibleRange<value_type> _Range>1955 template <_ContainerCompatibleRange<value_type> _Range>
2050 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1956 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
2051 for (auto&& __element : __range) {1957 for (auto&& __element : __range) {
2052 __table_.__insert_multi(std::forward<decltype(__element)>(__element));1958 __table_.__emplace_multi(std::forward<decltype(__element)>(__element));
2053 }1959 }
2054 }1960 }
2055# endif1961# endif
20561962
2057# ifndef _LIBCPP_CXX03_LANG1963# ifndef _LIBCPP_CXX03_LANG
2058 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1964 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
2059 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }1965 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__emplace_multi(std::move(__x)); }
20601966
2061 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {1967 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {
2062 return __table_.__insert_multi(__p.__i_, std::move(__x));1968 return __table_.__emplace_hint_multi(__p.__i_, std::move(__x));
2063 }1969 }
20641970
2065 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1971 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
2066 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) {1972 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) {
2067 return __table_.__insert_multi(std::forward<_Pp>(__x));1973 return __table_.__emplace_multi(std::forward<_Pp>(__x));
2068 }1974 }
20691975
2070 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>1976 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
2071 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) {1977 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) {
2072 return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x));1978 return __table_.__emplace_hint_multi(__p.__i_, std::forward<_Pp>(__x));
2073 }1979 }
20741980
2075 template <class... _Args>1981 template <class... _Args>
...@@ -2437,9 +2343,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(...@@ -2437,9 +2343,8 @@ unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_multimap(
2437 : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {2343 : __table_(std::move(__u.__table_), typename __table::allocator_type(__a)) {
2438 if (__a != __u.get_allocator()) {2344 if (__a != __u.get_allocator()) {
2439 iterator __i = __u.begin();2345 iterator __i = __u.begin();
2440 while (__u.size() != 0) {2346 while (__u.size() != 0)
2441 __table_.__insert_multi(__u.__table_.remove((__i++).__i_)->__get_value().__move());2347 __table_.__insert_multi_from_orphaned_node(std::move(__u.__table_.remove((__i++).__i_)->__get_value()));
2442 }
2443 }2348 }
2444}2349}
24452350
...@@ -2489,7 +2394,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>...@@ -2489,7 +2394,7 @@ template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
2489template <class _InputIterator>2394template <class _InputIterator>
2490inline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {2395inline void unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
2491 for (; __first != __last; ++__first)2396 for (; __first != __last; ++__first)
2492 __table_.__insert_multi(*__first);2397 __table_.__emplace_multi(*__first);
2493}2398}
24942399
2495template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>2400template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc>
...@@ -2543,6 +2448,8 @@ struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> >...@@ -2543,6 +2448,8 @@ struct __container_traits<unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> >
2543 // inserting a single element, the insertion has no effect.2448 // inserting a single element, the insertion has no effect.
2544 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =2449 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
2545 __is_nothrow_invocable_v<_Hash, const _Key&>;2450 __is_nothrow_invocable_v<_Hash, const _Key&>;
2451
2452 static _LIBCPP_CONSTEXPR const bool __reservable = true;
2546};2453};
25472454
2548_LIBCPP_END_NAMESPACE_STD2455_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/unordered_set+22-18
...@@ -594,7 +594,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -594,7 +594,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
594class unordered_multiset;594class unordered_multiset;
595595
596template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >596template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
597class _LIBCPP_TEMPLATE_VIS unordered_set {597class unordered_set {
598public:598public:
599 // types599 // types
600 typedef _Value key_type;600 typedef _Value key_type;
...@@ -630,9 +630,9 @@ public:...@@ -630,9 +630,9 @@ public:
630# endif630# endif
631631
632 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>632 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
633 friend class _LIBCPP_TEMPLATE_VIS unordered_set;633 friend class unordered_set;
634 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>634 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
635 friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;635 friend class unordered_multiset;
636636
637 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}637 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
638 explicit _LIBCPP_HIDE_FROM_ABI638 explicit _LIBCPP_HIDE_FROM_ABI
...@@ -769,13 +769,13 @@ public:...@@ -769,13 +769,13 @@ public:
769 }769 }
770770
771 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {771 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __x) {
772 return __table_.__insert_unique(std::move(__x));772 return __table_.__emplace_unique(std::move(__x));
773 }773 }
774 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }774 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, value_type&& __x) { return insert(std::move(__x)).first; }
775775
776 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }776 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
777# endif // _LIBCPP_CXX03_LANG777# endif // _LIBCPP_CXX03_LANG
778 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__insert_unique(__x); }778 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __x) { return __table_.__emplace_unique(__x); }
779779
780 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }780 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, const value_type& __x) { return insert(__x).first; }
781 template <class _InputIterator>781 template <class _InputIterator>
...@@ -785,7 +785,7 @@ public:...@@ -785,7 +785,7 @@ public:
785 template <_ContainerCompatibleRange<value_type> _Range>785 template <_ContainerCompatibleRange<value_type> _Range>
786 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {786 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
787 for (auto&& __element : __range) {787 for (auto&& __element : __range) {
788 __table_.__insert_unique(std::forward<decltype(__element)>(__element));788 __table_.__emplace_unique(std::forward<decltype(__element)>(__element));
789 }789 }
790 }790 }
791# endif791# endif
...@@ -1096,7 +1096,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u,...@@ -1096,7 +1096,7 @@ unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set(unordered_set&& __u,
1096 if (__a != __u.get_allocator()) {1096 if (__a != __u.get_allocator()) {
1097 iterator __i = __u.begin();1097 iterator __i = __u.begin();
1098 while (__u.size() != 0)1098 while (__u.size() != 0)
1099 __table_.__insert_unique(std::move(__u.__table_.remove(__i++)->__get_value()));1099 __table_.__emplace_unique(std::move(__u.__table_.remove(__i++)->__get_value()));
1100 }1100 }
1101}1101}
11021102
...@@ -1146,7 +1146,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -1146,7 +1146,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
1146template <class _InputIterator>1146template <class _InputIterator>
1147inline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {1147inline void unordered_set<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
1148 for (; __first != __last; ++__first)1148 for (; __first != __last; ++__first)
1149 __table_.__insert_unique(*__first);1149 __table_.__emplace_unique(*__first);
1150}1150}
11511151
1152template <class _Value, class _Hash, class _Pred, class _Alloc>1152template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1196,10 +1196,12 @@ struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > {...@@ -1196,10 +1196,12 @@ struct __container_traits<unordered_set<_Value, _Hash, _Pred, _Alloc> > {
1196 // inserting a single element, the insertion has no effect.1196 // inserting a single element, the insertion has no effect.
1197 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =1197 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1198 __is_nothrow_invocable_v<_Hash, const _Value&>;1198 __is_nothrow_invocable_v<_Hash, const _Value&>;
1199
1200 static _LIBCPP_CONSTEXPR const bool __reservable = true;
1199};1201};
12001202
1201template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >1203template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> >
1202class _LIBCPP_TEMPLATE_VIS unordered_multiset {1204class unordered_multiset {
1203public:1205public:
1204 // types1206 // types
1205 typedef _Value key_type;1207 typedef _Value key_type;
...@@ -1233,9 +1235,9 @@ public:...@@ -1233,9 +1235,9 @@ public:
1233# endif1235# endif
12341236
1235 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>1237 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1236 friend class _LIBCPP_TEMPLATE_VIS unordered_set;1238 friend class unordered_set;
1237 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>1239 template <class _Value2, class _Hash2, class _Pred2, class _Alloc2>
1238 friend class _LIBCPP_TEMPLATE_VIS unordered_multiset;1240 friend class unordered_multiset;
12391241
1240 _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}1242 _LIBCPP_HIDE_FROM_ABI unordered_multiset() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
1241 explicit _LIBCPP_HIDE_FROM_ABI1243 explicit _LIBCPP_HIDE_FROM_ABI
...@@ -1372,17 +1374,17 @@ public:...@@ -1372,17 +1374,17 @@ public:
1372 return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);1374 return __table_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);
1373 }1375 }
13741376
1375 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__insert_multi(std::move(__x)); }1377 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __x) { return __table_.__emplace_multi(std::move(__x)); }
1376 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {1378 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x) {
1377 return __table_.__insert_multi(__p, std::move(__x));1379 return __table_.__emplace_hint_multi(__p, std::move(__x));
1378 }1380 }
1379 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }1381 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1380# endif // _LIBCPP_CXX03_LANG1382# endif // _LIBCPP_CXX03_LANG
13811383
1382 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__insert_multi(__x); }1384 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __x) { return __table_.__emplace_multi(__x); }
13831385
1384 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {1386 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x) {
1385 return __table_.__insert_multi(__p, __x);1387 return __table_.__emplace_hint_multi(__p, __x);
1386 }1388 }
13871389
1388 template <class _InputIterator>1390 template <class _InputIterator>
...@@ -1392,7 +1394,7 @@ public:...@@ -1392,7 +1394,7 @@ public:
1392 template <_ContainerCompatibleRange<value_type> _Range>1394 template <_ContainerCompatibleRange<value_type> _Range>
1393 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {1395 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1394 for (auto&& __element : __range) {1396 for (auto&& __element : __range) {
1395 __table_.__insert_multi(std::forward<decltype(__element)>(__element));1397 __table_.__emplace_multi(std::forward<decltype(__element)>(__element));
1396 }1398 }
1397 }1399 }
1398# endif1400# endif
...@@ -1712,7 +1714,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(...@@ -1712,7 +1714,7 @@ unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset(
1712 if (__a != __u.get_allocator()) {1714 if (__a != __u.get_allocator()) {
1713 iterator __i = __u.begin();1715 iterator __i = __u.begin();
1714 while (__u.size() != 0)1716 while (__u.size() != 0)
1715 __table_.__insert_multi(std::move(__u.__table_.remove(__i++)->__get_value()));1717 __table_.__emplace_multi(std::move(__u.__table_.remove(__i++)->__get_value()));
1716 }1718 }
1717}1719}
17181720
...@@ -1762,7 +1764,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>...@@ -1762,7 +1764,7 @@ template <class _Value, class _Hash, class _Pred, class _Alloc>
1762template <class _InputIterator>1764template <class _InputIterator>
1763inline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {1765inline void unordered_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first, _InputIterator __last) {
1764 for (; __first != __last; ++__first)1766 for (; __first != __last; ++__first)
1765 __table_.__insert_multi(*__first);1767 __table_.__emplace_multi(*__first);
1766}1768}
17671769
1768template <class _Value, class _Hash, class _Pred, class _Alloc>1770template <class _Value, class _Hash, class _Pred, class _Alloc>
...@@ -1816,6 +1818,8 @@ struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > {...@@ -1816,6 +1818,8 @@ struct __container_traits<unordered_multiset<_Value, _Hash, _Pred, _Alloc> > {
1816 // inserting a single element, the insertion has no effect.1818 // inserting a single element, the insertion has no effect.
1817 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =1819 static _LIBCPP_CONSTEXPR const bool __emplacement_has_strong_exception_safety_guarantee =
1818 __is_nothrow_invocable_v<_Hash, const _Value&>;1820 __is_nothrow_invocable_v<_Hash, const _Value&>;
1821
1822 static _LIBCPP_CONSTEXPR const bool __reservable = true;
1819};1823};
18201824
1821_LIBCPP_END_NAMESPACE_STD1825_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/utility+4
...@@ -279,6 +279,10 @@ template <class T>...@@ -279,6 +279,10 @@ template <class T>
279# include <__utility/unreachable.h>279# include <__utility/unreachable.h>
280# endif280# endif
281281
282# if _LIBCPP_STD_VER >= 26
283# include <__variant/monostate.h>
284# endif
285
282# include <version>286# include <version>
283287
284// standard-mandated includes288// standard-mandated includes
lib/libcxx/include/valarray+18-18
...@@ -382,9 +382,9 @@ _LIBCPP_PUSH_MACROS...@@ -382,9 +382,9 @@ _LIBCPP_PUSH_MACROS
382_LIBCPP_BEGIN_NAMESPACE_STD382_LIBCPP_BEGIN_NAMESPACE_STD
383383
384template <class _Tp>384template <class _Tp>
385class _LIBCPP_TEMPLATE_VIS valarray;385class valarray;
386386
387class _LIBCPP_TEMPLATE_VIS slice {387class slice {
388 size_t __start_;388 size_t __start_;
389 size_t __size_;389 size_t __size_;
390 size_t __stride_;390 size_t __stride_;
...@@ -409,14 +409,14 @@ public:...@@ -409,14 +409,14 @@ public:
409};409};
410410
411template <class _Tp>411template <class _Tp>
412class _LIBCPP_TEMPLATE_VIS slice_array;412class slice_array;
413class _LIBCPP_EXPORTED_FROM_ABI gslice;413class _LIBCPP_EXPORTED_FROM_ABI gslice;
414template <class _Tp>414template <class _Tp>
415class _LIBCPP_TEMPLATE_VIS gslice_array;415class gslice_array;
416template <class _Tp>416template <class _Tp>
417class _LIBCPP_TEMPLATE_VIS mask_array;417class mask_array;
418template <class _Tp>418template <class _Tp>
419class _LIBCPP_TEMPLATE_VIS indirect_array;419class indirect_array;
420420
421template <class _Tp>421template <class _Tp>
422_LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);422_LIBCPP_HIDE_FROM_ABI _Tp* begin(valarray<_Tp>& __v);
...@@ -638,7 +638,7 @@ public:...@@ -638,7 +638,7 @@ public:
638 template <class>638 template <class>
639 friend class __val_expr;639 friend class __val_expr;
640 template <class>640 template <class>
641 friend class _LIBCPP_TEMPLATE_VIS valarray;641 friend class valarray;
642};642};
643643
644template <class _ValExpr>644template <class _ValExpr>
...@@ -780,7 +780,7 @@ template <class _Tp>...@@ -780,7 +780,7 @@ template <class _Tp>
780struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};780struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};
781781
782template <class _Tp>782template <class _Tp>
783class _LIBCPP_TEMPLATE_VIS valarray {783class valarray {
784public:784public:
785 typedef _Tp value_type;785 typedef _Tp value_type;
786 typedef _Tp __result_type;786 typedef _Tp __result_type;
...@@ -918,17 +918,17 @@ public:...@@ -918,17 +918,17 @@ public:
918918
919private:919private:
920 template <class>920 template <class>
921 friend class _LIBCPP_TEMPLATE_VIS valarray;921 friend class valarray;
922 template <class>922 template <class>
923 friend class _LIBCPP_TEMPLATE_VIS slice_array;923 friend class slice_array;
924 template <class>924 template <class>
925 friend class _LIBCPP_TEMPLATE_VIS gslice_array;925 friend class gslice_array;
926 template <class>926 template <class>
927 friend class _LIBCPP_TEMPLATE_VIS mask_array;927 friend class mask_array;
928 template <class>928 template <class>
929 friend class __mask_expr;929 friend class __mask_expr;
930 template <class>930 template <class>
931 friend class _LIBCPP_TEMPLATE_VIS indirect_array;931 friend class indirect_array;
932 template <class>932 template <class>
933 friend class __indirect_expr;933 friend class __indirect_expr;
934 template <class>934 template <class>
...@@ -1038,7 +1038,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {...@@ -1038,7 +1038,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > {
1038// slice_array1038// slice_array
10391039
1040template <class _Tp>1040template <class _Tp>
1041class _LIBCPP_TEMPLATE_VIS slice_array {1041class slice_array {
1042public:1042public:
1043 typedef _Tp value_type;1043 typedef _Tp value_type;
10441044
...@@ -1268,7 +1268,7 @@ private:...@@ -1268,7 +1268,7 @@ private:
1268// gslice_array1268// gslice_array
12691269
1270template <class _Tp>1270template <class _Tp>
1271class _LIBCPP_TEMPLATE_VIS gslice_array {1271class gslice_array {
1272public:1272public:
1273 typedef _Tp value_type;1273 typedef _Tp value_type;
12741274
...@@ -1453,7 +1453,7 @@ inline void gslice_array<_Tp>::operator=(const value_type& __x) const {...@@ -1453,7 +1453,7 @@ inline void gslice_array<_Tp>::operator=(const value_type& __x) const {
1453// mask_array1453// mask_array
14541454
1455template <class _Tp>1455template <class _Tp>
1456class _LIBCPP_TEMPLATE_VIS mask_array {1456class mask_array {
1457public:1457public:
1458 typedef _Tp value_type;1458 typedef _Tp value_type;
14591459
...@@ -1658,7 +1658,7 @@ public:...@@ -1658,7 +1658,7 @@ public:
1658// indirect_array1658// indirect_array
16591659
1660template <class _Tp>1660template <class _Tp>
1661class _LIBCPP_TEMPLATE_VIS indirect_array {1661class indirect_array {
1662public:1662public:
1663 typedef _Tp value_type;1663 typedef _Tp value_type;
16641664
...@@ -1860,7 +1860,7 @@ public:...@@ -1860,7 +1860,7 @@ public:
1860 template <class>1860 template <class>
1861 friend class __val_expr;1861 friend class __val_expr;
1862 template <class>1862 template <class>
1863 friend class _LIBCPP_TEMPLATE_VIS valarray;1863 friend class valarray;
1864};1864};
18651865
1866template <class _ValExpr>1866template <class _ValExpr>
lib/libcxx/include/variant+96-76
...@@ -213,7 +213,7 @@ namespace std {...@@ -213,7 +213,7 @@ namespace std {
213*/213*/
214214
215#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)215#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
216# include <__cxx03/variant>216# include <__cxx03/__config>
217#else217#else
218# include <__compare/common_comparison_category.h>218# include <__compare/common_comparison_category.h>
219# include <__compare/compare_three_way_result.h>219# include <__compare/compare_three_way_result.h>
...@@ -242,10 +242,12 @@ namespace std {...@@ -242,10 +242,12 @@ namespace std {
242# include <__type_traits/is_assignable.h>242# include <__type_traits/is_assignable.h>
243# include <__type_traits/is_constructible.h>243# include <__type_traits/is_constructible.h>
244# include <__type_traits/is_convertible.h>244# include <__type_traits/is_convertible.h>
245# include <__type_traits/is_core_convertible.h>
245# include <__type_traits/is_destructible.h>246# include <__type_traits/is_destructible.h>
246# include <__type_traits/is_nothrow_assignable.h>247# include <__type_traits/is_nothrow_assignable.h>
247# include <__type_traits/is_nothrow_constructible.h>248# include <__type_traits/is_nothrow_constructible.h>
248# include <__type_traits/is_reference.h>249# include <__type_traits/is_reference.h>
250# include <__type_traits/is_replaceable.h>
249# include <__type_traits/is_same.h>251# include <__type_traits/is_same.h>
250# include <__type_traits/is_swappable.h>252# include <__type_traits/is_swappable.h>
251# include <__type_traits/is_trivially_assignable.h>253# include <__type_traits/is_trivially_assignable.h>
...@@ -283,14 +285,14 @@ namespace std {...@@ -283,14 +285,14 @@ namespace std {
283_LIBCPP_PUSH_MACROS285_LIBCPP_PUSH_MACROS
284# include <__undef_macros>286# include <__undef_macros>
285287
286namespace std { // explicitly not using versioning namespace288_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
287289
288class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {290class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception {
289public:291public:
290 const char* what() const _NOEXCEPT override;292 const char* what() const _NOEXCEPT override;
291};293};
292294
293} // namespace std295_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
294296
295_LIBCPP_BEGIN_NAMESPACE_STD297_LIBCPP_BEGIN_NAMESPACE_STD
296298
...@@ -306,8 +308,7 @@ struct __farray {...@@ -306,8 +308,7 @@ struct __farray {
306 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }308 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }
307};309};
308310
309[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void311[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access() {
310__throw_bad_variant_access() {
311# if _LIBCPP_HAS_EXCEPTIONS312# if _LIBCPP_HAS_EXCEPTIONS
312 throw bad_variant_access();313 throw bad_variant_access();
313# else314# else
...@@ -317,31 +318,31 @@ __throw_bad_variant_access() {...@@ -317,31 +318,31 @@ __throw_bad_variant_access() {
317318
318// variant_size319// variant_size
319template <class _Tp>320template <class _Tp>
320struct _LIBCPP_TEMPLATE_VIS variant_size<const _Tp> : variant_size<_Tp> {};321struct variant_size<const _Tp> : variant_size<_Tp> {};
321322
322template <class _Tp>323template <class _Tp>
323struct _LIBCPP_TEMPLATE_VIS variant_size<volatile _Tp> : variant_size<_Tp> {};324struct variant_size<volatile _Tp> : variant_size<_Tp> {};
324325
325template <class _Tp>326template <class _Tp>
326struct _LIBCPP_TEMPLATE_VIS variant_size<const volatile _Tp> : variant_size<_Tp> {};327struct variant_size<const volatile _Tp> : variant_size<_Tp> {};
327328
328template <class... _Types>329template <class... _Types>
329struct _LIBCPP_TEMPLATE_VIS variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {};330struct variant_size<variant<_Types...>> : integral_constant<size_t, sizeof...(_Types)> {};
330331
331// variant_alternative332// variant_alternative
332template <size_t _Ip, class _Tp>333template <size_t _Ip, class _Tp>
333struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {};334struct variant_alternative<_Ip, const _Tp> : add_const<variant_alternative_t<_Ip, _Tp>> {};
334335
335template <size_t _Ip, class _Tp>336template <size_t _Ip, class _Tp>
336struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, volatile _Tp> : add_volatile<variant_alternative_t<_Ip, _Tp>> {};337struct variant_alternative<_Ip, volatile _Tp> : add_volatile<variant_alternative_t<_Ip, _Tp>> {};
337338
338template <size_t _Ip, class _Tp>339template <size_t _Ip, class _Tp>
339struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, const volatile _Tp> : add_cv<variant_alternative_t<_Ip, _Tp>> {};340struct variant_alternative<_Ip, const volatile _Tp> : add_cv<variant_alternative_t<_Ip, _Tp>> {};
340341
341template <size_t _Ip, class... _Types>342template <size_t _Ip, class... _Types>
342struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {343struct variant_alternative<_Ip, variant<_Types...>> {
343 static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>");344 static_assert(_Ip < sizeof...(_Types), "Index out of bounds in std::variant_alternative<>");
344 using type = __type_pack_element<_Ip, _Types...>;345 using type _LIBCPP_NODEBUG = __type_pack_element<_Ip, _Types...>;
345};346};
346347
347template <size_t _NumAlternatives>348template <size_t _NumAlternatives>
...@@ -409,7 +410,8 @@ template <>...@@ -409,7 +410,8 @@ template <>
409struct __find_unambiguous_index_sfinae_impl<__ambiguous> {};410struct __find_unambiguous_index_sfinae_impl<__ambiguous> {};
410411
411template <class _Tp, class... _Types>412template <class _Tp, class... _Types>
412struct __find_unambiguous_index_sfinae : __find_unambiguous_index_sfinae_impl<__find_index<_Tp, _Types...>()> {};413struct __find_unambiguous_index_sfinae
414 : __find_unambiguous_index_sfinae_impl<__find_detail::__find_index<_Tp, _Types...>()> {};
413415
414} // namespace __find_detail416} // namespace __find_detail
415417
...@@ -657,7 +659,7 @@ private:...@@ -657,7 +659,7 @@ private:
657# define _LIBCPP_EAT_SEMICOLON static_assert(true, "")659# define _LIBCPP_EAT_SEMICOLON static_assert(true, "")
658660
659template <size_t _Index, class _Tp>661template <size_t _Index, class _Tp>
660struct _LIBCPP_TEMPLATE_VIS __alt {662struct __alt {
661 using __value_type _LIBCPP_NODEBUG = _Tp;663 using __value_type _LIBCPP_NODEBUG = _Tp;
662 static constexpr size_t __index = _Index;664 static constexpr size_t __index = _Index;
663665
...@@ -669,14 +671,14 @@ struct _LIBCPP_TEMPLATE_VIS __alt {...@@ -669,14 +671,14 @@ struct _LIBCPP_TEMPLATE_VIS __alt {
669};671};
670672
671template <_Trait _DestructibleTrait, size_t _Index, class... _Types>673template <_Trait _DestructibleTrait, size_t _Index, class... _Types>
672union _LIBCPP_TEMPLATE_VIS __union;674union __union;
673675
674template <_Trait _DestructibleTrait, size_t _Index>676template <_Trait _DestructibleTrait, size_t _Index>
675union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};677union __union<_DestructibleTrait, _Index> {};
676678
677# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \679# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \
678 template <size_t _Index, class _Tp, class... _Types> \680 template <size_t _Index, class _Tp, class... _Types> \
679 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \681 union __union<destructible_trait, _Index, _Tp, _Types...> { \
680 public: \682 public: \
681 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \683 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(__valueless_t) noexcept : __dummy{} {} \
682 \684 \
...@@ -711,7 +713,7 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTE...@@ -711,7 +713,7 @@ _LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTE
711# undef _LIBCPP_VARIANT_UNION713# undef _LIBCPP_VARIANT_UNION
712714
713template <_Trait _DestructibleTrait, class... _Types>715template <_Trait _DestructibleTrait, class... _Types>
714class _LIBCPP_TEMPLATE_VIS __base {716class __base {
715public:717public:
716 using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>;718 using __index_t _LIBCPP_NODEBUG = __variant_index_t<sizeof...(_Types)>;
717719
...@@ -747,12 +749,11 @@ protected:...@@ -747,12 +749,11 @@ protected:
747};749};
748750
749template <class _Traits, _Trait = _Traits::__destructible_trait>751template <class _Traits, _Trait = _Traits::__destructible_trait>
750class _LIBCPP_TEMPLATE_VIS __dtor;752class __dtor;
751753
752# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \754# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \
753 template <class... _Types> \755 template <class... _Types> \
754 class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \756 class __dtor<__traits<_Types...>, destructible_trait> : public __base<destructible_trait, _Types...> { \
755 : public __base<destructible_trait, _Types...> { \
756 using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \757 using __base_type _LIBCPP_NODEBUG = __base<destructible_trait, _Types...>; \
757 using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \758 using __index_t _LIBCPP_NODEBUG = typename __base_type::__index_t; \
758 \759 \
...@@ -798,7 +799,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable,...@@ -798,7 +799,7 @@ _LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable,
798# undef _LIBCPP_VARIANT_DESTRUCTOR799# undef _LIBCPP_VARIANT_DESTRUCTOR
799800
800template <class _Traits>801template <class _Traits>
801class _LIBCPP_TEMPLATE_VIS __ctor : public __dtor<_Traits> {802class __ctor : public __dtor<_Traits> {
802 using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>;803 using __base_type _LIBCPP_NODEBUG = __dtor<_Traits>;
803804
804public:805public:
...@@ -825,12 +826,11 @@ protected:...@@ -825,12 +826,11 @@ protected:
825};826};
826827
827template <class _Traits, _Trait = _Traits::__move_constructible_trait>828template <class _Traits, _Trait = _Traits::__move_constructible_trait>
828class _LIBCPP_TEMPLATE_VIS __move_constructor;829class __move_constructor;
829830
830# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \831# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \
831 template <class... _Types> \832 template <class... _Types> \
832 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \833 class __move_constructor<__traits<_Types...>, move_constructible_trait> : public __ctor<__traits<_Types...>> { \
833 : public __ctor<__traits<_Types...>> { \
834 using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \834 using __base_type _LIBCPP_NODEBUG = __ctor<__traits<_Types...>>; \
835 \835 \
836 public: \836 public: \
...@@ -851,8 +851,7 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(...@@ -851,8 +851,7 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
851_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(851_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
852 _Trait::_Available,852 _Trait::_Available,
853 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept(853 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept(
854 __all<is_nothrow_move_constructible_v<_Types>...>::value)854 __all<is_nothrow_move_constructible_v<_Types>...>::value) : __move_constructor(__valueless_t{}) {
855 : __move_constructor(__valueless_t{}) {
856 this->__generic_construct(*this, std::move(__that));855 this->__generic_construct(*this, std::move(__that));
857 } _LIBCPP_EAT_SEMICOLON);856 } _LIBCPP_EAT_SEMICOLON);
858857
...@@ -863,11 +862,11 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(...@@ -863,11 +862,11 @@ _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
863# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR862# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR
864863
865template <class _Traits, _Trait = _Traits::__copy_constructible_trait>864template <class _Traits, _Trait = _Traits::__copy_constructible_trait>
866class _LIBCPP_TEMPLATE_VIS __copy_constructor;865class __copy_constructor;
867866
868# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \867# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \
869 template <class... _Types> \868 template <class... _Types> \
870 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \869 class __copy_constructor<__traits<_Types...>, copy_constructible_trait> \
871 : public __move_constructor<__traits<_Types...>> { \870 : public __move_constructor<__traits<_Types...>> { \
872 using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \871 using __base_type _LIBCPP_NODEBUG = __move_constructor<__traits<_Types...>>; \
873 \872 \
...@@ -888,8 +887,9 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(...@@ -888,8 +887,9 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
888887
889_LIBCPP_VARIANT_COPY_CONSTRUCTOR(888_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
890 _Trait::_Available,889 _Trait::_Available,
891 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that)890 _LIBCPP_HIDE_FROM_ABI
892 : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON);891 _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) : __copy_constructor(
892 __valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON);
893893
894_LIBCPP_VARIANT_COPY_CONSTRUCTOR(894_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
895 _Trait::_Unavailable,895 _Trait::_Unavailable,
...@@ -898,7 +898,7 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(...@@ -898,7 +898,7 @@ _LIBCPP_VARIANT_COPY_CONSTRUCTOR(
898# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR898# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR
899899
900template <class _Traits>900template <class _Traits>
901class _LIBCPP_TEMPLATE_VIS __assignment : public __copy_constructor<_Traits> {901class __assignment : public __copy_constructor<_Traits> {
902 using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>;902 using __base_type _LIBCPP_NODEBUG = __copy_constructor<_Traits>;
903903
904public:904public:
...@@ -952,12 +952,11 @@ protected:...@@ -952,12 +952,11 @@ protected:
952};952};
953953
954template <class _Traits, _Trait = _Traits::__move_assignable_trait>954template <class _Traits, _Trait = _Traits::__move_assignable_trait>
955class _LIBCPP_TEMPLATE_VIS __move_assignment;955class __move_assignment;
956956
957# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \957# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \
958 template <class... _Types> \958 template <class... _Types> \
959 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \959 class __move_assignment<__traits<_Types...>, move_assignable_trait> : public __assignment<__traits<_Types...>> { \
960 : public __assignment<__traits<_Types...>> { \
961 using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \960 using __base_type _LIBCPP_NODEBUG = __assignment<__traits<_Types...>>; \
962 \961 \
963 public: \962 public: \
...@@ -991,11 +990,11 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT(...@@ -991,11 +990,11 @@ _LIBCPP_VARIANT_MOVE_ASSIGNMENT(
991# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT990# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT
992991
993template <class _Traits, _Trait = _Traits::__copy_assignable_trait>992template <class _Traits, _Trait = _Traits::__copy_assignable_trait>
994class _LIBCPP_TEMPLATE_VIS __copy_assignment;993class __copy_assignment;
995994
996# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \995# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \
997 template <class... _Types> \996 template <class... _Types> \
998 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \997 class __copy_assignment<__traits<_Types...>, copy_assignable_trait> \
999 : public __move_assignment<__traits<_Types...>> { \998 : public __move_assignment<__traits<_Types...>> { \
1000 using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \999 using __base_type _LIBCPP_NODEBUG = __move_assignment<__traits<_Types...>>; \
1001 \1000 \
...@@ -1029,7 +1028,7 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable,...@@ -1029,7 +1028,7 @@ _LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable,
1029# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT1028# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT
10301029
1031template <class... _Types>1030template <class... _Types>
1032class _LIBCPP_TEMPLATE_VIS __impl : public __copy_assignment<__traits<_Types...>> {1031class __impl : public __copy_assignment<__traits<_Types...>> {
1033 using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>;1032 using __base_type _LIBCPP_NODEBUG = __copy_assignment<__traits<_Types...>>;
10341033
1035public:1034public:
...@@ -1143,20 +1142,18 @@ using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_...@@ -1143,20 +1142,18 @@ using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_
1143} // namespace __variant_detail1142} // namespace __variant_detail
11441143
1145template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>1144template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>
1146_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)1145_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs);
1147visit(_Visitor&& __visitor, _Vs&&... __vs);
11481146
1149# if _LIBCPP_STD_VER >= 201147# if _LIBCPP_STD_VER >= 20
1150template <class _Rp,1148template <class _Rp,
1151 class _Visitor,1149 class _Visitor,
1152 class... _Vs,1150 class... _Vs,
1153 typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>1151 typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>
1154_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp1152_LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs);
1155visit(_Visitor&& __visitor, _Vs&&... __vs);
1156# endif1153# endif
11571154
1158template <class... _Types>1155template <class... _Types>
1159class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant1156class _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIONS variant
1160 : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value,1157 : private __sfinae_ctor_base< __all<is_copy_constructible_v<_Types>...>::value,
1161 __all<is_move_constructible_v<_Types>...>::value>,1158 __all<is_move_constructible_v<_Types>...>::value>,
1162 private __sfinae_assign_base<1159 private __sfinae_assign_base<
...@@ -1175,6 +1172,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIO...@@ -1175,6 +1172,7 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES _LIBCPP_NO_SPECIALIZATIO
1175public:1172public:
1176 using __trivially_relocatable _LIBCPP_NODEBUG =1173 using __trivially_relocatable _LIBCPP_NODEBUG =
1177 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;1174 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;
1175 using __replaceable _LIBCPP_NODEBUG = conditional_t<_And<__is_replaceable<_Types>...>::value, variant, void>;
11781176
1179 template <bool _Dummy = true,1177 template <bool _Dummy = true,
1180 enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0>1178 enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0>
...@@ -1338,35 +1336,30 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>&...@@ -1338,35 +1336,30 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>&
1338}1336}
13391337
1340template <size_t _Ip, class _Vp>1338template <size_t _Ip, class _Vp>
1341_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr auto&& __generic_get(_Vp&& __v) {1339_LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) {
1342 using __variant_detail::__access::__variant;1340 using __variant_detail::__access::__variant;
1343 if (!std::__holds_alternative<_Ip>(__v)) {1341 if (!std::__holds_alternative<_Ip>(__v)) {
1344 __throw_bad_variant_access();1342 std::__throw_bad_variant_access();
1345 }1343 }
1346 return __variant::__get_alt<_Ip>(std::forward<_Vp>(__v)).__value;1344 return __variant::__get_alt<_Ip>(std::forward<_Vp>(__v)).__value;
1347}1345}
13481346
1349template <size_t _Ip, class... _Types>1347template <size_t _Ip, class... _Types>
1350_LIBCPP_HIDE_FROM_ABI1348_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>& __v) {
1351_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
1352get(variant<_Types...>& __v) {
1353 static_assert(_Ip < sizeof...(_Types));1349 static_assert(_Ip < sizeof...(_Types));
1354 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1350 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1355 return std::__generic_get<_Ip>(__v);1351 return std::__generic_get<_Ip>(__v);
1356}1352}
13571353
1358template <size_t _Ip, class... _Types>1354template <size_t _Ip, class... _Types>
1359_LIBCPP_HIDE_FROM_ABI1355_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&& __v) {
1360_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
1361get(variant<_Types...>&& __v) {
1362 static_assert(_Ip < sizeof...(_Types));1356 static_assert(_Ip < sizeof...(_Types));
1363 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1357 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
1364 return std::__generic_get<_Ip>(std::move(__v));1358 return std::__generic_get<_Ip>(std::move(__v));
1365}1359}
13661360
1367template <size_t _Ip, class... _Types>1361template <size_t _Ip, class... _Types>
1368_LIBCPP_HIDE_FROM_ABI1362_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
1369_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
1370get(const variant<_Types...>& __v) {1363get(const variant<_Types...>& __v) {
1371 static_assert(_Ip < sizeof...(_Types));1364 static_assert(_Ip < sizeof...(_Types));
1372 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1365 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
...@@ -1374,8 +1367,7 @@ get(const variant<_Types...>& __v) {...@@ -1374,8 +1367,7 @@ get(const variant<_Types...>& __v) {
1374}1367}
13751368
1376template <size_t _Ip, class... _Types>1369template <size_t _Ip, class... _Types>
1377_LIBCPP_HIDE_FROM_ABI1370_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
1378_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
1379get(const variant<_Types...>&& __v) {1371get(const variant<_Types...>&& __v) {
1380 static_assert(_Ip < sizeof...(_Types));1372 static_assert(_Ip < sizeof...(_Types));
1381 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);1373 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
...@@ -1383,27 +1375,25 @@ get(const variant<_Types...>&& __v) {...@@ -1383,27 +1375,25 @@ get(const variant<_Types...>&& __v) {
1383}1375}
13841376
1385template <class _Tp, class... _Types>1377template <class _Tp, class... _Types>
1386_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>& __v) {1378_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>& __v) {
1387 static_assert(!is_void_v<_Tp>);1379 static_assert(!is_void_v<_Tp>);
1388 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);1380 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1389}1381}
13901382
1391template <class _Tp, class... _Types>1383template <class _Tp, class... _Types>
1392_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&& __v) {1384_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&& __v) {
1393 static_assert(!is_void_v<_Tp>);1385 static_assert(!is_void_v<_Tp>);
1394 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));1386 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));
1395}1387}
13961388
1397template <class _Tp, class... _Types>1389template <class _Tp, class... _Types>
1398_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&1390_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>& __v) {
1399get(const variant<_Types...>& __v) {
1400 static_assert(!is_void_v<_Tp>);1391 static_assert(!is_void_v<_Tp>);
1401 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);1392 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
1402}1393}
14031394
1404template <class _Tp, class... _Types>1395template <class _Tp, class... _Types>
1405_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&&1396_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&& __v) {
1406get(const variant<_Types...>&& __v) {
1407 static_assert(!is_void_v<_Tp>);1397 static_assert(!is_void_v<_Tp>);
1408 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));1398 return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));
1409}1399}
...@@ -1453,6 +1443,11 @@ struct __convert_to_bool {...@@ -1453,6 +1443,11 @@ struct __convert_to_bool {
1453};1443};
14541444
1455template <class... _Types>1445template <class... _Types>
1446# if _LIBCPP_STD_VER >= 26
1447 requires(requires(const _Types& __t) {
1448 { __t == __t } -> __core_convertible_to<bool>;
1449 } && ...)
1450# endif
1456_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1451_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1457 using __variant_detail::__visitation::__variant;1452 using __variant_detail::__visitation::__variant;
1458 if (__lhs.index() != __rhs.index())1453 if (__lhs.index() != __rhs.index())
...@@ -1485,6 +1480,11 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {...@@ -1485,6 +1480,11 @@ operator<=>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1485# endif // _LIBCPP_STD_VER >= 201480# endif // _LIBCPP_STD_VER >= 20
14861481
1487template <class... _Types>1482template <class... _Types>
1483# if _LIBCPP_STD_VER >= 26
1484 requires(requires(const _Types& __t) {
1485 { __t != __t } -> __core_convertible_to<bool>;
1486 } && ...)
1487# endif
1488_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1488_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1489 using __variant_detail::__visitation::__variant;1489 using __variant_detail::__visitation::__variant;
1490 if (__lhs.index() != __rhs.index())1490 if (__lhs.index() != __rhs.index())
...@@ -1495,6 +1495,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs,...@@ -1495,6 +1495,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const variant<_Types...>& __lhs,
1495}1495}
14961496
1497template <class... _Types>1497template <class... _Types>
1498# if _LIBCPP_STD_VER >= 26
1499 requires(requires(const _Types& __t) {
1500 { __t < __t } -> __core_convertible_to<bool>;
1501 } && ...)
1502# endif
1498_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1503_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1499 using __variant_detail::__visitation::__variant;1504 using __variant_detail::__visitation::__variant;
1500 if (__rhs.valueless_by_exception())1505 if (__rhs.valueless_by_exception())
...@@ -1509,6 +1514,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs,...@@ -1509,6 +1514,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const variant<_Types...>& __lhs,
1509}1514}
15101515
1511template <class... _Types>1516template <class... _Types>
1517# if _LIBCPP_STD_VER >= 26
1518 requires(requires(const _Types& __t) {
1519 { __t > __t } -> __core_convertible_to<bool>;
1520 } && ...)
1521# endif
1512_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1522_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1513 using __variant_detail::__visitation::__variant;1523 using __variant_detail::__visitation::__variant;
1514 if (__lhs.valueless_by_exception())1524 if (__lhs.valueless_by_exception())
...@@ -1523,6 +1533,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs,...@@ -1523,6 +1533,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const variant<_Types...>& __lhs,
1523}1533}
15241534
1525template <class... _Types>1535template <class... _Types>
1536# if _LIBCPP_STD_VER >= 26
1537 requires(requires(const _Types& __t) {
1538 { __t <= __t } -> __core_convertible_to<bool>;
1539 } && ...)
1540# endif
1526_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1541_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1527 using __variant_detail::__visitation::__variant;1542 using __variant_detail::__visitation::__variant;
1528 if (__lhs.valueless_by_exception())1543 if (__lhs.valueless_by_exception())
...@@ -1537,6 +1552,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs,...@@ -1537,6 +1552,11 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const variant<_Types...>& __lhs,
1537}1552}
15381553
1539template <class... _Types>1554template <class... _Types>
1555# if _LIBCPP_STD_VER >= 26
1556 requires(requires(const _Types& __t) {
1557 { __t >= __t } -> __core_convertible_to<bool>;
1558 } && ...)
1559# endif
1540_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {1560_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs, const variant<_Types...>& __rhs) {
1541 using __variant_detail::__visitation::__variant;1561 using __variant_detail::__visitation::__variant;
1542 if (__rhs.valueless_by_exception())1562 if (__rhs.valueless_by_exception())
...@@ -1551,16 +1571,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs,...@@ -1551,16 +1571,15 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs,
1551}1571}
15521572
1553template <class... _Vs>1573template <class... _Vs>
1554_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void __throw_if_valueless(_Vs&&... __vs) {1574_LIBCPP_HIDE_FROM_ABI constexpr void __throw_if_valueless(_Vs&&... __vs) {
1555 const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception());1575 const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception());
1556 if (__valueless) {1576 if (__valueless) {
1557 __throw_bad_variant_access();1577 std::__throw_bad_variant_access();
1558 }1578 }
1559}1579}
15601580
1561template < class _Visitor, class... _Vs, typename>1581template < class _Visitor, class... _Vs, typename>
1562_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)1582_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
1563visit(_Visitor&& __visitor, _Vs&&... __vs) {
1564 using __variant_detail::__visitation::__variant;1583 using __variant_detail::__visitation::__variant;
1565 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);1584 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
1566 return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);1585 return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
...@@ -1568,8 +1587,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {...@@ -1568,8 +1587,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
15681587
1569# if _LIBCPP_STD_VER >= 201588# if _LIBCPP_STD_VER >= 20
1570template < class _Rp, class _Visitor, class... _Vs, typename>1589template < class _Rp, class _Visitor, class... _Vs, typename>
1571_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp1590_LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
1572visit(_Visitor&& __visitor, _Vs&&... __vs) {
1573 using __variant_detail::__visitation::__variant;1591 using __variant_detail::__visitation::__variant;
1574 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);1592 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
1575 return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);1593 return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
...@@ -1578,17 +1596,19 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {...@@ -1578,17 +1596,19 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
15781596
1579template <class... _Types>1597template <class... _Types>
1580_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto1598_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto
1581swap(variant<_Types...>& __lhs,1599swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs)))
1582 variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) {1600 -> decltype(__lhs.swap(__rhs)) {
1583 return __lhs.swap(__rhs);1601 return __lhs.swap(__rhs);
1584}1602}
15851603
1586template <class... _Types>1604template <class... _Types>
1587struct _LIBCPP_TEMPLATE_VIS hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> {1605struct hash< __enable_hash_helper<variant<_Types...>, remove_const_t<_Types>...>> {
1588 using argument_type = variant<_Types...>;1606# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
1589 using result_type = size_t;1607 using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = variant<_Types...>;
1608 using result_type _LIBCPP_DEPRECATED_IN_CXX17 = size_t;
1609# endif
15901610
1591 _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type& __v) const {1611 _LIBCPP_HIDE_FROM_ABI size_t operator()(const variant<_Types...>& __v) const {
1592 using __variant_detail::__visitation::__variant;1612 using __variant_detail::__visitation::__variant;
1593 size_t __res =1613 size_t __res =
1594 __v.valueless_by_exception()1614 __v.valueless_by_exception()
lib/libcxx/include/vector+1
...@@ -362,6 +362,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++...@@ -362,6 +362,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
362# if _LIBCPP_HAS_LOCALIZATION362# if _LIBCPP_HAS_LOCALIZATION
363# include <locale>363# include <locale>
364# endif364# endif
365# include <optional>
365# include <string>366# include <string>
366# include <string_view>367# include <string_view>
367# include <tuple>368# include <tuple>
lib/libcxx/include/version+24-7
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16Macro name Value Headers16Macro name Value Headers
17__cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack>17__cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack>
18__cpp_lib_addressof_constexpr 201603L <memory>18__cpp_lib_addressof_constexpr 201603L <memory>
19__cpp_lib_aligned_accessor 202411L <mdspan>
19__cpp_lib_allocate_at_least 202302L <memory>20__cpp_lib_allocate_at_least 202302L <memory>
20__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>21__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>
21 <map> <memory> <scoped_allocator>22 <map> <memory> <scoped_allocator>
...@@ -58,28 +59,34 @@ __cpp_lib_char8_t 201907L <atomic> <filesy...@@ -58,28 +59,34 @@ __cpp_lib_char8_t 201907L <atomic> <filesy
58__cpp_lib_chrono 201611L <chrono>59__cpp_lib_chrono 201611L <chrono>
59__cpp_lib_chrono_udls 201304L <chrono>60__cpp_lib_chrono_udls 201304L <chrono>
60__cpp_lib_clamp 201603L <algorithm>61__cpp_lib_clamp 201603L <algorithm>
62__cpp_lib_common_reference 202302L <type_traits>
63__cpp_lib_common_reference_wrapper 202302L <functional>
61__cpp_lib_complex_udls 201309L <complex>64__cpp_lib_complex_udls 201309L <complex>
62__cpp_lib_concepts 202002L <concepts>65__cpp_lib_concepts 202002L <concepts>
63__cpp_lib_constexpr_algorithms 201806L <algorithm> <utility>66__cpp_lib_constexpr_algorithms 202306L <algorithm> <utility>
67 201806L // C++20
64__cpp_lib_constexpr_bitset 202207L <bitset>68__cpp_lib_constexpr_bitset 202207L <bitset>
65__cpp_lib_constexpr_charconv 202207L <charconv>69__cpp_lib_constexpr_charconv 202207L <charconv>
66__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>70__cpp_lib_constexpr_cmath 202202L <cmath> <cstdlib>
67__cpp_lib_constexpr_complex 201711L <complex>71__cpp_lib_constexpr_complex 201711L <complex>
68__cpp_lib_constexpr_dynamic_alloc 201907L <memory>72__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
73__cpp_lib_constexpr_forward_list 202502L <forward_list>
69__cpp_lib_constexpr_functional 201907L <functional>74__cpp_lib_constexpr_functional 201907L <functional>
70__cpp_lib_constexpr_iterator 201811L <iterator>75__cpp_lib_constexpr_iterator 201811L <iterator>
76__cpp_lib_constexpr_list 202502L <list>
71__cpp_lib_constexpr_memory 202202L <memory>77__cpp_lib_constexpr_memory 202202L <memory>
72 201811L // C++2078 201811L // C++20
73__cpp_lib_constexpr_new 202406L <new>79__cpp_lib_constexpr_new 202406L <new>
74__cpp_lib_constexpr_numeric 201911L <numeric>80__cpp_lib_constexpr_numeric 201911L <numeric>
81__cpp_lib_constexpr_queue 202502L <queue>
75__cpp_lib_constexpr_string 201907L <string>82__cpp_lib_constexpr_string 201907L <string>
76__cpp_lib_constexpr_string_view 201811L <string_view>83__cpp_lib_constexpr_string_view 201811L <string_view>
77__cpp_lib_constexpr_tuple 201811L <tuple>84__cpp_lib_constexpr_tuple 201811L <tuple>
78__cpp_lib_constexpr_typeinfo 202106L <typeinfo>85__cpp_lib_constexpr_typeinfo 202106L <typeinfo>
79__cpp_lib_constexpr_utility 201811L <utility>86__cpp_lib_constexpr_utility 201811L <utility>
80__cpp_lib_constexpr_vector 201907L <vector>87__cpp_lib_constexpr_vector 201907L <vector>
81__cpp_lib_constrained_equality 202403L <optional> <tuple> <utility>88__cpp_lib_constrained_equality 202411L <expected> <optional> <tuple>
82 <variant>89 <utility> <variant>
83__cpp_lib_containers_ranges 202202L <deque> <forward_list> <list>90__cpp_lib_containers_ranges 202202L <deque> <forward_list> <list>
84 <map> <queue> <set>91 <map> <queue> <set>
85 <stack> <string> <unordered_map>92 <stack> <string> <unordered_map>
...@@ -147,6 +154,7 @@ __cpp_lib_is_nothrow_convertible 201806L <type_traits>...@@ -147,6 +154,7 @@ __cpp_lib_is_nothrow_convertible 201806L <type_traits>
147__cpp_lib_is_null_pointer 201309L <type_traits>154__cpp_lib_is_null_pointer 201309L <type_traits>
148__cpp_lib_is_pointer_interconvertible 201907L <type_traits>155__cpp_lib_is_pointer_interconvertible 201907L <type_traits>
149__cpp_lib_is_scoped_enum 202011L <type_traits>156__cpp_lib_is_scoped_enum 202011L <type_traits>
157__cpp_lib_is_sufficiently_aligned 202411L <memory>
150__cpp_lib_is_swappable 201603L <type_traits>158__cpp_lib_is_swappable 201603L <type_traits>
151__cpp_lib_is_virtual_base_of 202406L <type_traits>159__cpp_lib_is_virtual_base_of 202406L <type_traits>
152__cpp_lib_is_within_lifetime 202306L <type_traits>160__cpp_lib_is_within_lifetime 202306L <type_traits>
...@@ -396,6 +404,8 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -396,6 +404,8 @@ __cpp_lib_void_t 201411L <type_traits>
396# if _LIBCPP_HAS_CHAR8_T404# if _LIBCPP_HAS_CHAR8_T
397# define __cpp_lib_char8_t 201907L405# define __cpp_lib_char8_t 201907L
398# endif406# endif
407# define __cpp_lib_common_reference 202302L
408# define __cpp_lib_common_reference_wrapper 202302L
399# define __cpp_lib_concepts 202002L409# define __cpp_lib_concepts 202002L
400# define __cpp_lib_constexpr_algorithms 201806L410# define __cpp_lib_constexpr_algorithms 201806L
401# define __cpp_lib_constexpr_complex 201711L411# define __cpp_lib_constexpr_complex 201711L
...@@ -485,7 +495,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -485,7 +495,7 @@ __cpp_lib_void_t 201411L <type_traits>
485# define __cpp_lib_containers_ranges 202202L495# define __cpp_lib_containers_ranges 202202L
486# define __cpp_lib_expected 202211L496# define __cpp_lib_expected 202211L
487# define __cpp_lib_flat_map 202207L497# define __cpp_lib_flat_map 202207L
488// # define __cpp_lib_flat_set 202207L498# define __cpp_lib_flat_set 202207L
489# define __cpp_lib_format_ranges 202207L499# define __cpp_lib_format_ranges 202207L
490// # define __cpp_lib_formatters 202302L500// # define __cpp_lib_formatters 202302L
491# define __cpp_lib_forward_like 202207L501# define __cpp_lib_forward_like 202207L
...@@ -512,8 +522,8 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -512,8 +522,8 @@ __cpp_lib_void_t 201411L <type_traits>
512# define __cpp_lib_ranges_chunk_by 202202L522# define __cpp_lib_ranges_chunk_by 202202L
513# define __cpp_lib_ranges_contains 202207L523# define __cpp_lib_ranges_contains 202207L
514# define __cpp_lib_ranges_find_last 202207L524# define __cpp_lib_ranges_find_last 202207L
515// # define __cpp_lib_ranges_iota 202202L525# define __cpp_lib_ranges_iota 202202L
516// # define __cpp_lib_ranges_join_with 202202L526# define __cpp_lib_ranges_join_with 202202L
517# define __cpp_lib_ranges_repeat 202207L527# define __cpp_lib_ranges_repeat 202207L
518// # define __cpp_lib_ranges_slide 202202L528// # define __cpp_lib_ranges_slide 202202L
519# define __cpp_lib_ranges_starts_ends_with 202106L529# define __cpp_lib_ranges_starts_ends_with 202106L
...@@ -531,15 +541,21 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -531,15 +541,21 @@ __cpp_lib_void_t 201411L <type_traits>
531#endif541#endif
532542
533#if _LIBCPP_STD_VER >= 26543#if _LIBCPP_STD_VER >= 26
544# define __cpp_lib_aligned_accessor 202411L
534// # define __cpp_lib_associative_heterogeneous_insertion 202306L545// # define __cpp_lib_associative_heterogeneous_insertion 202306L
535// # define __cpp_lib_atomic_min_max 202403L546// # define __cpp_lib_atomic_min_max 202403L
536# undef __cpp_lib_bind_front547# undef __cpp_lib_bind_front
537# define __cpp_lib_bind_front 202306L548# define __cpp_lib_bind_front 202306L
538# define __cpp_lib_bitset 202306L549# define __cpp_lib_bitset 202306L
550# undef __cpp_lib_constexpr_algorithms
551# define __cpp_lib_constexpr_algorithms 202306L
552# define __cpp_lib_constexpr_forward_list 202502L
553# define __cpp_lib_constexpr_list 202502L
539# if !defined(_LIBCPP_ABI_VCRUNTIME)554# if !defined(_LIBCPP_ABI_VCRUNTIME)
540# define __cpp_lib_constexpr_new 202406L555# define __cpp_lib_constexpr_new 202406L
541# endif556# endif
542// # define __cpp_lib_constrained_equality 202403L557# define __cpp_lib_constexpr_queue 202502L
558// # define __cpp_lib_constrained_equality 202411L
543// # define __cpp_lib_copyable_function 202306L559// # define __cpp_lib_copyable_function 202306L
544// # define __cpp_lib_debugging 202311L560// # define __cpp_lib_debugging 202311L
545// # define __cpp_lib_default_template_type_for_algorithm_values 202403L561// # define __cpp_lib_default_template_type_for_algorithm_values 202403L
...@@ -559,6 +575,7 @@ __cpp_lib_void_t 201411L <type_traits>...@@ -559,6 +575,7 @@ __cpp_lib_void_t 201411L <type_traits>
559// # define __cpp_lib_generate_random 202403L575// # define __cpp_lib_generate_random 202403L
560// # define __cpp_lib_hazard_pointer 202306L576// # define __cpp_lib_hazard_pointer 202306L
561// # define __cpp_lib_inplace_vector 202406L577// # define __cpp_lib_inplace_vector 202406L
578# define __cpp_lib_is_sufficiently_aligned 202411L
562# if __has_builtin(__builtin_is_virtual_base_of)579# if __has_builtin(__builtin_is_virtual_base_of)
563# define __cpp_lib_is_virtual_base_of 202406L580# define __cpp_lib_is_virtual_base_of 202406L
564# endif581# endif
lib/libcxx/src/any.cpp+1-1
...@@ -18,7 +18,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; }...@@ -18,7 +18,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
18// Even though it no longer exists in a header file18// Even though it no longer exists in a header file
19_LIBCPP_BEGIN_NAMESPACE_LFTS19_LIBCPP_BEGIN_NAMESPACE_LFTS
2020
21class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {21class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
22public:22public:
23 virtual const char* what() const noexcept;23 virtual const char* what() const noexcept;
24};24};
lib/libcxx/src/atomic.cpp+5-2
...@@ -151,7 +151,10 @@ __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__con...@@ -151,7 +151,10 @@ __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__con
151static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state,151static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state,
152 __cxx_atomic_contention_t const volatile* __platform_state,152 __cxx_atomic_contention_t const volatile* __platform_state,
153 __cxx_contention_t __old_value) {153 __cxx_contention_t __old_value) {
154 __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst);154 __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_relaxed);
155 // https://github.com/llvm/llvm-project/issues/109290
156 // There are no platform guarantees of a memory barrier in the platform wait implementation
157 __cxx_atomic_thread_fence(memory_order_seq_cst);
155 // We sleep as long as the monitored value hasn't changed.158 // We sleep as long as the monitored value hasn't changed.
156 __libcpp_platform_wait_on_address(__platform_state, __old_value);159 __libcpp_platform_wait_on_address(__platform_state, __old_value);
157 __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);160 __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);
...@@ -163,7 +166,7 @@ static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __conte...@@ -163,7 +166,7 @@ static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __conte
163static void __libcpp_atomic_notify(void const volatile* __location) {166static void __libcpp_atomic_notify(void const volatile* __location) {
164 auto const __entry = __libcpp_contention_state(__location);167 auto const __entry = __libcpp_contention_state(__location);
165 // The value sequence laundering happens on the next line below.168 // The value sequence laundering happens on the next line below.
166 __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release);169 __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_seq_cst);
167 __libcpp_contention_notify(170 __libcpp_contention_notify(
168 &__entry->__contention_state,171 &__entry->__contention_state,
169 &__entry->__platform_state,172 &__entry->__platform_state,
lib/libcxx/src/call_once.cpp+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__config>
9#include <__mutex/once_flag.h>10#include <__mutex/once_flag.h>
10#include <__utility/exception_guard.h>11#include <__utility/exception_guard.h>
1112
lib/libcxx/src/chrono.cpp+6-6
...@@ -124,7 +124,7 @@ static system_clock::time_point __libcpp_system_clock_now() {...@@ -124,7 +124,7 @@ static system_clock::time_point __libcpp_system_clock_now() {
124static system_clock::time_point __libcpp_system_clock_now() {124static system_clock::time_point __libcpp_system_clock_now() {
125 struct timespec ts;125 struct timespec ts;
126 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)126 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)
127 __throw_system_error(errno, "timespec_get(TIME_UTC) failed");127 std::__throw_system_error(errno, "timespec_get(TIME_UTC) failed");
128 return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));128 return system_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));
129}129}
130130
...@@ -133,7 +133,7 @@ static system_clock::time_point __libcpp_system_clock_now() {...@@ -133,7 +133,7 @@ static system_clock::time_point __libcpp_system_clock_now() {
133static system_clock::time_point __libcpp_system_clock_now() {133static system_clock::time_point __libcpp_system_clock_now() {
134 struct timespec tp;134 struct timespec tp;
135 if (0 != clock_gettime(CLOCK_REALTIME, &tp))135 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
136 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");136 std::__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
137 return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));137 return system_clock::time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
138}138}
139139
...@@ -180,7 +180,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s...@@ -180,7 +180,7 @@ system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return s
180static steady_clock::time_point __libcpp_steady_clock_now() {180static steady_clock::time_point __libcpp_steady_clock_now() {
181 struct timespec tp;181 struct timespec tp;
182 if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))182 if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))
183 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");183 std::__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");
184 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));184 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
185}185}
186186
...@@ -213,7 +213,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() {...@@ -213,7 +213,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
213static steady_clock::time_point __libcpp_steady_clock_now() {213static steady_clock::time_point __libcpp_steady_clock_now() {
214 struct timespec64 ts;214 struct timespec64 ts;
215 if (0 != gettimeofdayMonotonic(&ts))215 if (0 != gettimeofdayMonotonic(&ts))
216 __throw_system_error(errno, "failed to obtain time of day");216 std::__throw_system_error(errno, "failed to obtain time of day");
217217
218 return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));218 return steady_clock::time_point(seconds(ts.tv_sec) + nanoseconds(ts.tv_nsec));
219}219}
...@@ -234,7 +234,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept {...@@ -234,7 +234,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept {
234static steady_clock::time_point __libcpp_steady_clock_now() {234static steady_clock::time_point __libcpp_steady_clock_now() {
235 struct timespec ts;235 struct timespec ts;
236 if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC)236 if (timespec_get(&ts, TIME_MONOTONIC) != TIME_MONOTONIC)
237 __throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed");237 std::__throw_system_error(errno, "timespec_get(TIME_MONOTONIC) failed");
238 return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));238 return steady_clock::time_point(seconds(ts.tv_sec) + microseconds(ts.tv_nsec / 1000));
239}239}
240240
...@@ -243,7 +243,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() {...@@ -243,7 +243,7 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
243static steady_clock::time_point __libcpp_steady_clock_now() {243static steady_clock::time_point __libcpp_steady_clock_now() {
244 struct timespec tp;244 struct timespec tp;
245 if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))245 if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
246 __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");246 std::__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
247 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));247 return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
248}248}
249249
lib/libcxx/src/condition_variable.cpp+10-4
...@@ -7,7 +7,13 @@...@@ -7,7 +7,13 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <condition_variable>9#include <condition_variable>
10#include <limits>
11#include <ratio>
10#include <thread>12#include <thread>
13#include <__chrono/duration.h>
14#include <__chrono/system_clock.h>
15#include <__chrono/time_point.h>
16#include <__system_error/throw_system_error.h>
1117
12#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)18#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
13# pragma comment(lib, "pthread")19# pragma comment(lib, "pthread")
...@@ -26,17 +32,17 @@ void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__c...@@ -26,17 +32,17 @@ void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__c
2632
27void condition_variable::wait(unique_lock<mutex>& lk) noexcept {33void condition_variable::wait(unique_lock<mutex>& lk) noexcept {
28 if (!lk.owns_lock())34 if (!lk.owns_lock())
29 __throw_system_error(EPERM, "condition_variable::wait: mutex not locked");35 std::__throw_system_error(EPERM, "condition_variable::wait: mutex not locked");
30 int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());36 int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
31 if (ec)37 if (ec)
32 __throw_system_error(ec, "condition_variable wait failed");38 std::__throw_system_error(ec, "condition_variable wait failed");
33}39}
3440
35void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,41void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
36 chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept {42 chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept {
37 using namespace chrono;43 using namespace chrono;
38 if (!lk.owns_lock())44 if (!lk.owns_lock())
39 __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");45 std::__throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
40 nanoseconds d = tp.time_since_epoch();46 nanoseconds d = tp.time_since_epoch();
41 if (d > nanoseconds(0x59682F000000E941))47 if (d > nanoseconds(0x59682F000000E941))
42 d = nanoseconds(0x59682F000000E941);48 d = nanoseconds(0x59682F000000E941);
...@@ -53,7 +59,7 @@ void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,...@@ -53,7 +59,7 @@ void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
53 }59 }
54 int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);60 int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
55 if (ec != 0 && ec != ETIMEDOUT)61 if (ec != 0 && ec != ETIMEDOUT)
56 __throw_system_error(ec, "condition_variable timed_wait failed");62 std::__throw_system_error(ec, "condition_variable timed_wait failed");
57}63}
5864
59void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) {65void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) {
lib/libcxx/src/experimental/log_hardening_failure.cpp created+31
...@@ -0,0 +1,31 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include <__config>
10#include <__log_hardening_failure>
11#include <cstdio>
12
13#ifdef __BIONIC__
14# include <syslog.h>
15#endif // __BIONIC__
16
17_LIBCPP_BEGIN_NAMESPACE_STD
18
19void __log_hardening_failure(const char* message) noexcept {
20 // Always log the message to `stderr` in case the platform-specific system calls fail.
21 std::fputs(message, stderr);
22
23#if defined(__BIONIC__)
24 // Show error in logcat. The latter two arguments are ignored on Android.
25 openlog("libc++", 0, 0);
26 syslog(LOG_CRIT, "%s", message);
27 closelog();
28#endif
29}
30
31_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/time_zone.cpp+9
...@@ -29,6 +29,15 @@...@@ -29,6 +29,15 @@
29// These quirks often use a 12h interval; this is the scan interval of zdump,29// These quirks often use a 12h interval; this is the scan interval of zdump,
30// which implies there are no sys_info objects with a duration of less than 12h.30// which implies there are no sys_info objects with a duration of less than 12h.
3131
32// Work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120502
33
34#include <__config>
35
36// TODO(LLVM 23): When upgrading to GCC 16 this can be removed
37#ifdef _LIBCPP_COMPILER_GCC
38# pragma GCC optimize("-O0")
39#endif
40
32#include <algorithm>41#include <algorithm>
33#include <cctype>42#include <cctype>
34#include <chrono>43#include <chrono>
lib/libcxx/src/experimental/tzdb.cpp+50-18
...@@ -709,6 +709,39 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {...@@ -709,6 +709,39 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {
709 std::__throw_runtime_error("unknown time zone");709 std::__throw_runtime_error("unknown time zone");
710}710}
711#else // ifdef _WIN32711#else // ifdef _WIN32
712
713[[nodiscard]] static string __current_zone_environment() {
714 if (const char* __tz = std::getenv("TZ"))
715 return __tz;
716
717 return {};
718}
719
720[[nodiscard]] static string __current_zone_etc_localtime() {
721 filesystem::path __path = "/etc/localtime";
722 if (!filesystem::exists(__path) || !filesystem::is_symlink(__path))
723 return {};
724
725 filesystem::path __tz = filesystem::read_symlink(__path);
726 // The path may be a relative path, in that case convert it to an absolute
727 // path based on the proper initial directory.
728 if (__tz.is_relative())
729 __tz = filesystem::canonical("/etc" / __tz);
730
731 return filesystem::relative(__tz, "/usr/share/zoneinfo/");
732}
733
734[[nodiscard]] static string __current_zone_etc_timezone() {
735 filesystem::path __path = "/etc/timezone";
736 if (!filesystem::exists(__path))
737 return {};
738
739 ifstream __f(__path);
740 string __name;
741 std::getline(__f, __name);
742 return __name;
743}
744
712[[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) {745[[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) {
713 // On POSIX systems there are several ways to configure the time zone.746 // On POSIX systems there are several ways to configure the time zone.
714 // In order of priority they are:747 // In order of priority they are:
...@@ -727,30 +760,29 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {...@@ -727,30 +760,29 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {
727 //760 //
728 // - The time zone name is the target of the symlink /etc/localtime761 // - The time zone name is the target of the symlink /etc/localtime
729 // relative to /usr/share/zoneinfo/762 // relative to /usr/share/zoneinfo/
763 //
764 // - The file /etc/timezone. This text file contains the name of the time
765 // zone.
766 //
767 // On Linux systems it seems /etc/timezone is deprecated and being phased out.
768 // This file is used when /etc/localtime does not exist, or when it exists but
769 // is not a symlink. For more information and links see
770 // https://github.com/llvm/llvm-project/issues/105634
730771
731 // The algorithm is like this:772 string __name = chrono::__current_zone_environment();
732 // - If the environment variable TZ is set and points to a valid
733 // record use this value.
734 // - Else use the name based on the `/etc/localtime` symlink.
735773
736 if (const char* __tz = getenv("TZ"))774 // Ignore invalid names in the environment.
737 if (const time_zone* __result = tzdb.__locate_zone(__tz))775 if (!__name.empty())
776 if (const time_zone* __result = tzdb.__locate_zone(__name))
738 return __result;777 return __result;
739778
740 filesystem::path __path = "/etc/localtime";779 __name = chrono::__current_zone_etc_localtime();
741 if (!filesystem::exists(__path))780 if (__name.empty())
742 std::__throw_runtime_error("tzdb: the symlink '/etc/localtime' does not exist");781 __name = chrono::__current_zone_etc_timezone();
743
744 if (!filesystem::is_symlink(__path))
745 std::__throw_runtime_error("tzdb: the path '/etc/localtime' is not a symlink");
746782
747 filesystem::path __tz = filesystem::read_symlink(__path);783 if (__name.empty())
748 // The path may be a relative path, in that case convert it to an absolute784 std::__throw_runtime_error("tzdb: unable to determine the name of the current time zone");
749 // path based on the proper initial directory.
750 if (__tz.is_relative())
751 __tz = filesystem::canonical("/etc" / __tz);
752785
753 string __name = filesystem::relative(__tz, "/usr/share/zoneinfo/");
754 if (const time_zone* __result = tzdb.__locate_zone(__name))786 if (const time_zone* __result = tzdb.__locate_zone(__name))
755 return __result;787 return __result;
756788
lib/libcxx/src/filesystem/directory_iterator.cpp+1
...@@ -8,6 +8,7 @@...@@ -8,6 +8,7 @@
88
9#include <__assert>9#include <__assert>
10#include <__config>10#include <__config>
11#include <__memory/shared_ptr.h>
11#include <errno.h>12#include <errno.h>
12#include <filesystem>13#include <filesystem>
13#include <stack>14#include <stack>
lib/libcxx/src/filesystem/error.h+7-6
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
10#define FILESYSTEM_ERROR_H10#define FILESYSTEM_ERROR_H
1111
12#include <__assert>12#include <__assert>
13#include <__chrono/time_point.h>
13#include <__config>14#include <__config>
14#include <cerrno>15#include <cerrno>
15#include <cstdarg>16#include <cstdarg>
...@@ -96,11 +97,11 @@ struct ErrorHandler {...@@ -96,11 +97,11 @@ struct ErrorHandler {
96 string what = string("in ") + func_name_;97 string what = string("in ") + func_name_;
97 switch (bool(p1_) + bool(p2_)) {98 switch (bool(p1_) + bool(p2_)) {
98 case 0:99 case 0:
99 __throw_filesystem_error(what, ec);100 filesystem::__throw_filesystem_error(what, ec);
100 case 1:101 case 1:
101 __throw_filesystem_error(what, *p1_, ec);102 filesystem::__throw_filesystem_error(what, *p1_, ec);
102 case 2:103 case 2:
103 __throw_filesystem_error(what, *p1_, *p2_, ec);104 filesystem::__throw_filesystem_error(what, *p1_, *p2_, ec);
104 }105 }
105 __libcpp_unreachable();106 __libcpp_unreachable();
106 }107 }
...@@ -114,11 +115,11 @@ struct ErrorHandler {...@@ -114,11 +115,11 @@ struct ErrorHandler {
114 string what = string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap);115 string what = string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap);
115 switch (bool(p1_) + bool(p2_)) {116 switch (bool(p1_) + bool(p2_)) {
116 case 0:117 case 0:
117 __throw_filesystem_error(what, ec);118 filesystem::__throw_filesystem_error(what, ec);
118 case 1:119 case 1:
119 __throw_filesystem_error(what, *p1_, ec);120 filesystem::__throw_filesystem_error(what, *p1_, ec);
120 case 2:121 case 2:
121 __throw_filesystem_error(what, *p1_, *p2_, ec);122 filesystem::__throw_filesystem_error(what, *p1_, *p2_, ec);
122 }123 }
123 __libcpp_unreachable();124 __libcpp_unreachable();
124 }125 }
lib/libcxx/src/filesystem/filesystem_clock.cpp+4-2
...@@ -8,8 +8,10 @@...@@ -8,8 +8,10 @@
88
9#include <__config>9#include <__config>
10#include <__system_error/throw_system_error.h>10#include <__system_error/throw_system_error.h>
11#include <cerrno>
11#include <chrono>12#include <chrono>
12#include <filesystem>13#include <filesystem>
14#include <ratio>
13#include <time.h>15#include <time.h>
1416
15#if defined(_LIBCPP_WIN32API)17#if defined(_LIBCPP_WIN32API)
...@@ -58,13 +60,13 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {...@@ -58,13 +60,13 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {
58 typedef chrono::duration<rep, nano> __nsecs;60 typedef chrono::duration<rep, nano> __nsecs;
59 struct timespec ts;61 struct timespec ts;
60 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)62 if (timespec_get(&ts, TIME_UTC) != TIME_UTC)
61 __throw_system_error(errno, "timespec_get(TIME_UTC) failed");63 std::__throw_system_error(errno, "timespec_get(TIME_UTC) failed");
62 return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec)));64 return time_point(__secs(ts.tv_sec) + chrono::duration_cast<duration>(__nsecs(ts.tv_nsec)));
63#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)65#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
64 typedef chrono::duration<rep, nano> __nsecs;66 typedef chrono::duration<rep, nano> __nsecs;
65 struct timespec tp;67 struct timespec tp;
66 if (0 != clock_gettime(CLOCK_REALTIME, &tp))68 if (0 != clock_gettime(CLOCK_REALTIME, &tp))
67 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");69 std::__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
68 return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));70 return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
69#else71#else
70 typedef chrono::duration<rep, micro> __microsecs;72 typedef chrono::duration<rep, micro> __microsecs;
lib/libcxx/src/filesystem/filesystem_error.cpp+1
...@@ -7,6 +7,7 @@...@@ -7,6 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__config>9#include <__config>
10#include <__memory/shared_ptr.h>
10#include <__utility/unreachable.h>11#include <__utility/unreachable.h>
11#include <filesystem>12#include <filesystem>
12#include <system_error>13#include <system_error>
lib/libcxx/src/filesystem/operations.cpp+1
...@@ -6,6 +6,7 @@...@@ -6,6 +6,7 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__algorithm/copy.h>
9#include <__assert>10#include <__assert>
10#include <__config>11#include <__config>
11#include <__utility/unreachable.h>12#include <__utility/unreachable.h>
lib/libcxx/src/filesystem/path_parser.h+1-1
...@@ -90,7 +90,7 @@ public:...@@ -90,7 +90,7 @@ public:
90 if (TkEnd)90 if (TkEnd)
91 return makeState(PS_InRootName, Start, TkEnd);91 return makeState(PS_InRootName, Start, TkEnd);
92 }92 }
93 _LIBCPP_FALLTHROUGH();93 [[__fallthrough__]];
94 case PS_InRootName: {94 case PS_InRootName: {
95 PosPtr TkEnd = consumeAllSeparators(Start, End);95 PosPtr TkEnd = consumeAllSeparators(Start, End);
96 if (TkEnd)96 if (TkEnd)
lib/libcxx/src/functional.cpp+4-2
...@@ -12,8 +12,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -12,8 +12,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1212
13bad_function_call::~bad_function_call() noexcept {}13bad_function_call::~bad_function_call() noexcept {}
1414
15#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
16const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }15const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }
17#endif16
17size_t __hash_memory(_LIBCPP_NOESCAPE const void* ptr, size_t size) noexcept {
18 return __murmur2_or_cityhash<size_t>()(ptr, size);
19}
1820
19_LIBCPP_END_NAMESPACE_STD21_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/future.cpp+10-10
...@@ -62,7 +62,7 @@ void __assoc_sub_state::__on_zero_shared() noexcept { delete this; }...@@ -62,7 +62,7 @@ void __assoc_sub_state::__on_zero_shared() noexcept { delete this; }
62void __assoc_sub_state::set_value() {62void __assoc_sub_state::set_value() {
63 unique_lock<mutex> __lk(__mut_);63 unique_lock<mutex> __lk(__mut_);
64 if (__has_value())64 if (__has_value())
65 __throw_future_error(future_errc::promise_already_satisfied);65 std::__throw_future_error(future_errc::promise_already_satisfied);
66 __state_ |= __constructed | ready;66 __state_ |= __constructed | ready;
67 __cv_.notify_all();67 __cv_.notify_all();
68}68}
...@@ -70,7 +70,7 @@ void __assoc_sub_state::set_value() {...@@ -70,7 +70,7 @@ void __assoc_sub_state::set_value() {
70void __assoc_sub_state::set_value_at_thread_exit() {70void __assoc_sub_state::set_value_at_thread_exit() {
71 unique_lock<mutex> __lk(__mut_);71 unique_lock<mutex> __lk(__mut_);
72 if (__has_value())72 if (__has_value())
73 __throw_future_error(future_errc::promise_already_satisfied);73 std::__throw_future_error(future_errc::promise_already_satisfied);
74 __state_ |= __constructed;74 __state_ |= __constructed;
75 __thread_local_data()->__make_ready_at_thread_exit(this);75 __thread_local_data()->__make_ready_at_thread_exit(this);
76}76}
...@@ -78,7 +78,7 @@ void __assoc_sub_state::set_value_at_thread_exit() {...@@ -78,7 +78,7 @@ void __assoc_sub_state::set_value_at_thread_exit() {
78void __assoc_sub_state::set_exception(exception_ptr __p) {78void __assoc_sub_state::set_exception(exception_ptr __p) {
79 unique_lock<mutex> __lk(__mut_);79 unique_lock<mutex> __lk(__mut_);
80 if (__has_value())80 if (__has_value())
81 __throw_future_error(future_errc::promise_already_satisfied);81 std::__throw_future_error(future_errc::promise_already_satisfied);
82 __exception_ = __p;82 __exception_ = __p;
83 __state_ |= ready;83 __state_ |= ready;
84 __cv_.notify_all();84 __cv_.notify_all();
...@@ -87,7 +87,7 @@ void __assoc_sub_state::set_exception(exception_ptr __p) {...@@ -87,7 +87,7 @@ void __assoc_sub_state::set_exception(exception_ptr __p) {
87void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) {87void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) {
88 unique_lock<mutex> __lk(__mut_);88 unique_lock<mutex> __lk(__mut_);
89 if (__has_value())89 if (__has_value())
90 __throw_future_error(future_errc::promise_already_satisfied);90 std::__throw_future_error(future_errc::promise_already_satisfied);
91 __exception_ = __p;91 __exception_ = __p;
92 __thread_local_data()->__make_ready_at_thread_exit(this);92 __thread_local_data()->__make_ready_at_thread_exit(this);
93}93}
...@@ -122,7 +122,7 @@ void __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) {...@@ -122,7 +122,7 @@ void __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) {
122 }122 }
123}123}
124124
125void __assoc_sub_state::__execute() { __throw_future_error(future_errc::no_state); }125void __assoc_sub_state::__execute() { std::__throw_future_error(future_errc::no_state); }
126126
127future<void>::future(__assoc_sub_state* __state) : __state_(__state) { __state_->__attach_future(); }127future<void>::future(__assoc_sub_state* __state) : __state_(__state) { __state_->__attach_future(); }
128128
...@@ -152,31 +152,31 @@ promise<void>::~promise() {...@@ -152,31 +152,31 @@ promise<void>::~promise() {
152152
153future<void> promise<void>::get_future() {153future<void> promise<void>::get_future() {
154 if (__state_ == nullptr)154 if (__state_ == nullptr)
155 __throw_future_error(future_errc::no_state);155 std::__throw_future_error(future_errc::no_state);
156 return future<void>(__state_);156 return future<void>(__state_);
157}157}
158158
159void promise<void>::set_value() {159void promise<void>::set_value() {
160 if (__state_ == nullptr)160 if (__state_ == nullptr)
161 __throw_future_error(future_errc::no_state);161 std::__throw_future_error(future_errc::no_state);
162 __state_->set_value();162 __state_->set_value();
163}163}
164164
165void promise<void>::set_exception(exception_ptr __p) {165void promise<void>::set_exception(exception_ptr __p) {
166 if (__state_ == nullptr)166 if (__state_ == nullptr)
167 __throw_future_error(future_errc::no_state);167 std::__throw_future_error(future_errc::no_state);
168 __state_->set_exception(__p);168 __state_->set_exception(__p);
169}169}
170170
171void promise<void>::set_value_at_thread_exit() {171void promise<void>::set_value_at_thread_exit() {
172 if (__state_ == nullptr)172 if (__state_ == nullptr)
173 __throw_future_error(future_errc::no_state);173 std::__throw_future_error(future_errc::no_state);
174 __state_->set_value_at_thread_exit();174 __state_->set_value_at_thread_exit();
175}175}
176176
177void promise<void>::set_exception_at_thread_exit(exception_ptr __p) {177void promise<void>::set_exception_at_thread_exit(exception_ptr __p) {
178 if (__state_ == nullptr)178 if (__state_ == nullptr)
179 __throw_future_error(future_errc::no_state);179 std::__throw_future_error(future_errc::no_state);
180 __state_->set_exception_at_thread_exit(__p);180 __state_->set_exception_at_thread_exit(__p);
181}181}
182182
lib/libcxx/src/hash.cpp+8-11
...@@ -9,7 +9,6 @@...@@ -9,7 +9,6 @@
9#include <__hash_table>9#include <__hash_table>
10#include <algorithm>10#include <algorithm>
11#include <stdexcept>11#include <stdexcept>
12#include <type_traits>
1312
14_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")13_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
1514
...@@ -52,16 +51,14 @@ const unsigned indices[] = {...@@ -52,16 +51,14 @@ const unsigned indices[] = {
52// are fewer potential primes to search, and fewer potential primes to divide51// are fewer potential primes to search, and fewer potential primes to divide
53// against.52// against.
5453
55template <size_t _Sz = sizeof(size_t)>54inline void __check_for_overflow(size_t N) {
56inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 4, void>::type __check_for_overflow(size_t N) {55 if constexpr (sizeof(size_t) == 4) {
57 if (N > 0xFFFFFFFB)56 if (N > 0xFFFFFFFB)
58 __throw_overflow_error("__next_prime overflow");57 std::__throw_overflow_error("__next_prime overflow");
59}58 } else {
6059 if (N > 0xFFFFFFFFFFFFFFC5ull)
61template <size_t _Sz = sizeof(size_t)>60 std::__throw_overflow_error("__next_prime overflow");
62inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 8, void>::type __check_for_overflow(size_t N) {61 }
63 if (N > 0xFFFFFFFFFFFFFFC5ull)
64 __throw_overflow_error("__next_prime overflow");
65}62}
6663
67size_t __next_prime(size_t n) {64size_t __next_prime(size_t n) {
lib/libcxx/src/include/overridable_function.h+16-15
...@@ -29,14 +29,14 @@...@@ -29,14 +29,14 @@
29// This is a low-level utility which does not work on all platforms, since it needs29// This is a low-level utility which does not work on all platforms, since it needs
30// to make assumptions about the object file format in use. Furthermore, it requires30// to make assumptions about the object file format in use. Furthermore, it requires
31// the "base definition" of the function (the one we want to check whether it has been31// the "base definition" of the function (the one we want to check whether it has been
32// overridden) to be annotated with the _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro.32// overridden) to be defined using the _LIBCPP_OVERRIDABLE_FUNCTION macro.
33//33//
34// This currently works with Mach-O files (used on Darwin) and with ELF files (used on Linux34// This currently works with Mach-O files (used on Darwin) and with ELF files (used on Linux
35// and others). On platforms where we know how to implement this detection, the macro35// and others). On platforms where we know how to implement this detection, the macro
36// _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION is defined to 1, and it is defined to 0 on36// _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION is defined to 1, and it is defined to 0 on
37// other platforms. The _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro is defined to37// other platforms. The _LIBCPP_OVERRIDABLE_FUNCTION macro is defined to perform a normal
38// nothing on unsupported platforms so that it can be used to decorate functions regardless38// function definition on unsupported platforms so that it can be used to define functions
39// of whether detection is actually supported.39// regardless of whether detection is actually supported.
40//40//
41// How does this work?41// How does this work?
42// -------------------42// -------------------
...@@ -44,7 +44,7 @@...@@ -44,7 +44,7 @@
44// Let's say we want to check whether a weak function `f` has been overridden by the user.44// Let's say we want to check whether a weak function `f` has been overridden by the user.
45// The general mechanism works by placing `f`'s definition (in the libc++ built library)45// The general mechanism works by placing `f`'s definition (in the libc++ built library)
46// inside a special section, which we do using the `__section__` attribute via the46// inside a special section, which we do using the `__section__` attribute via the
47// _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE macro.47// _LIBCPP_OVERRIDABLE_FUNCTION macro.
48//48//
49// Then, when comes the time to check whether the function has been overridden, we take49// Then, when comes the time to check whether the function has been overridden, we take
50// the address of the function and we check whether it falls inside the special function50// the address of the function and we check whether it falls inside the special function
...@@ -66,12 +66,12 @@...@@ -66,12 +66,12 @@
66#if defined(_LIBCPP_OBJECT_FORMAT_MACHO)66#if defined(_LIBCPP_OBJECT_FORMAT_MACHO)
6767
68# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 168# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
69# define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE \69# define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \
70 __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions")))70 __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) _LIBCPP_WEAK type name arglist
7171
72_LIBCPP_BEGIN_NAMESPACE_STD72_LIBCPP_BEGIN_NAMESPACE_STD
73template <class _Ret, class... _Args>73template <typename T, T* _Func>
74_LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) noexcept {74_LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
75 // Declare two dummy bytes and give them these special `__asm` values. These values are75 // Declare two dummy bytes and give them these special `__asm` values. These values are
76 // defined by the linker, which means that referring to `&__lcxx_override_start` will76 // defined by the linker, which means that referring to `&__lcxx_override_start` will
77 // effectively refer to the address where the section starts (and same for the end).77 // effectively refer to the address where the section starts (and same for the end).
...@@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no...@@ -81,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
81 // Now get a uintptr_t out of these locations, and out of the function pointer.81 // Now get a uintptr_t out of these locations, and out of the function pointer.
82 uintptr_t __start = reinterpret_cast<uintptr_t>(&__lcxx_override_start);82 uintptr_t __start = reinterpret_cast<uintptr_t>(&__lcxx_override_start);
83 uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end);83 uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end);
84 uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);84 uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
8585
86# if __has_feature(ptrauth_calls)86# if __has_feature(ptrauth_calls)
87 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,87 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
...@@ -100,7 +100,8 @@ _LIBCPP_END_NAMESPACE_STD...@@ -100,7 +100,8 @@ _LIBCPP_END_NAMESPACE_STD
100#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)100#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)
101101
102# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1102# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
103# define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE __attribute__((__section__("__lcxx_override")))103# define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) \
104 __attribute__((__section__("__lcxx_override"))) _LIBCPP_WEAK type name arglist
104105
105// This is very similar to what we do for Mach-O above. The ELF linker will implicitly define106// This is very similar to what we do for Mach-O above. The ELF linker will implicitly define
106// variables with those names corresponding to the start and the end of the section.107// variables with those names corresponding to the start and the end of the section.
...@@ -110,11 +111,11 @@ extern char __start___lcxx_override;...@@ -110,11 +111,11 @@ extern char __start___lcxx_override;
110extern char __stop___lcxx_override;111extern char __stop___lcxx_override;
111112
112_LIBCPP_BEGIN_NAMESPACE_STD113_LIBCPP_BEGIN_NAMESPACE_STD
113template <class _Ret, class... _Args>114template <typename T, T* _Func>
114_LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) noexcept {115_LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
115 uintptr_t __start = reinterpret_cast<uintptr_t>(&__start___lcxx_override);116 uintptr_t __start = reinterpret_cast<uintptr_t>(&__start___lcxx_override);
116 uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);117 uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
117 uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);118 uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
118119
119# if __has_feature(ptrauth_calls)120# if __has_feature(ptrauth_calls)
120 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above.121 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above.
...@@ -128,7 +129,7 @@ _LIBCPP_END_NAMESPACE_STD...@@ -128,7 +129,7 @@ _LIBCPP_END_NAMESPACE_STD
128#else129#else
129130
130# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0131# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0
131# define _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE /* nothing */132# define _LIBCPP_OVERRIDABLE_FUNCTION(type, name, arglist) _LIBCPP_WEAK type name arglist
132133
133#endif134#endif
134135
lib/libcxx/src/include/ryu/common.h+1
...@@ -44,6 +44,7 @@...@@ -44,6 +44,7 @@
4444
45#include <__assert>45#include <__assert>
46#include <__config>46#include <__config>
47#include <cstdint>
47#include <cstring>48#include <cstring>
4849
49_LIBCPP_BEGIN_NAMESPACE_STD50_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/src/ios.cpp+5-5
...@@ -217,7 +217,7 @@ void ios_base::clear(iostate state) {...@@ -217,7 +217,7 @@ void ios_base::clear(iostate state) {
217 __rdstate_ = state | badbit;217 __rdstate_ = state | badbit;
218218
219 if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)219 if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
220 __throw_failure("ios_base::clear");220 std::__throw_failure("ios_base::clear");
221}221}
222222
223// init223// init
...@@ -253,24 +253,24 @@ void ios_base::copyfmt(const ios_base& rhs) {...@@ -253,24 +253,24 @@ void ios_base::copyfmt(const ios_base& rhs) {
253 size_t newesize = sizeof(event_callback) * rhs.__event_size_;253 size_t newesize = sizeof(event_callback) * rhs.__event_size_;
254 new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));254 new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
255 if (!new_callbacks)255 if (!new_callbacks)
256 __throw_bad_alloc();256 std::__throw_bad_alloc();
257257
258 size_t newisize = sizeof(int) * rhs.__event_size_;258 size_t newisize = sizeof(int) * rhs.__event_size_;
259 new_ints.reset(static_cast<int*>(malloc(newisize)));259 new_ints.reset(static_cast<int*>(malloc(newisize)));
260 if (!new_ints)260 if (!new_ints)
261 __throw_bad_alloc();261 std::__throw_bad_alloc();
262 }262 }
263 if (__iarray_cap_ < rhs.__iarray_size_) {263 if (__iarray_cap_ < rhs.__iarray_size_) {
264 size_t newsize = sizeof(long) * rhs.__iarray_size_;264 size_t newsize = sizeof(long) * rhs.__iarray_size_;
265 new_longs.reset(static_cast<long*>(malloc(newsize)));265 new_longs.reset(static_cast<long*>(malloc(newsize)));
266 if (!new_longs)266 if (!new_longs)
267 __throw_bad_alloc();267 std::__throw_bad_alloc();
268 }268 }
269 if (__parray_cap_ < rhs.__parray_size_) {269 if (__parray_cap_ < rhs.__parray_size_) {
270 size_t newsize = sizeof(void*) * rhs.__parray_size_;270 size_t newsize = sizeof(void*) * rhs.__parray_size_;
271 new_pointers.reset(static_cast<void**>(malloc(newsize)));271 new_pointers.reset(static_cast<void**>(malloc(newsize)));
272 if (!new_pointers)272 if (!new_pointers)
273 __throw_bad_alloc();273 std::__throw_bad_alloc();
274 }274 }
275 // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_275 // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
276 __fmtflags_ = rhs.__fmtflags_;276 __fmtflags_ = rhs.__fmtflags_;
lib/libcxx/src/iostream.cpp+66-95
...@@ -7,90 +7,64 @@...@@ -7,90 +7,64 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include "std_stream.h"9#include "std_stream.h"
10#include <__locale>
11#include <new>
12#include <string>
1310
14#define _str(s) #s11#include <__memory/construct_at.h>
15#define str(s) _str(s)12#include <__ostream/basic_ostream.h>
16#define _LIBCPP_ABI_NAMESPACE_STR str(_LIBCPP_ABI_NAMESPACE)13#include <istream>
14
15#define ABI_NAMESPACE_STR _LIBCPP_TOSTRING(_LIBCPP_ABI_NAMESPACE)
1716
18_LIBCPP_BEGIN_NAMESPACE_STD17_LIBCPP_BEGIN_NAMESPACE_STD
1918
20alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]19template <class StreamT, class BufferT>
21#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)20union stream_data {
22 __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR21 constexpr stream_data() {}
23 "@std@@@12@A")22 constexpr ~stream_data() {}
24#endif23 struct {
25 ;24 // The stream has to be the first element, since that's referenced by the stream declarations in <iostream>
26alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];25 StreamT stream;
27static mbstate_t mb_cin;26 BufferT buffer;
27 mbstate_t mb;
28 };
29
30 void init(FILE* stdstream) {
31 mb = {};
32 std::construct_at(&buffer, stdstream, &mb);
33 std::construct_at(&stream, &buffer);
34 }
35};
2836
29#if _LIBCPP_HAS_WIDE_CHARACTERS37#define CHAR_MANGLING_char "D"
30alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]38#define CHAR_MANGLING_wchar_t "_W"
31# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)39#define CHAR_MANGLING(CharT) CHAR_MANGLING_##CharT
32 __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
33 "@std@@@12@A")
34# endif
35 ;
36alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];
37static mbstate_t mb_wcin;
38#endif // _LIBCPP_HAS_WIDE_CHARACTERS
3940
40alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]41#ifdef _LIBCPP_COMPILER_CLANG_BASED
41#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)42# define STRING_DATA_CONSTINIT constinit
42 __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR43#else
43 "@std@@@12@A")44# define STRING_DATA_CONSTINIT
44#endif45#endif
45 ;
46alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
47static mbstate_t mb_cout;
4846
49#if _LIBCPP_HAS_WIDE_CHARACTERS47#ifdef _LIBCPP_ABI_MICROSOFT
50alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]48# define STREAM(StreamT, BufferT, CharT, var) \
51# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)49 STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var __asm__( \
52 __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR50 "?" #var "@" ABI_NAMESPACE_STR "@std@@3V?$" #StreamT \
53 "@std@@@12@A")51 "@" CHAR_MANGLING(CharT) "U?$char_traits@" CHAR_MANGLING(CharT) "@" ABI_NAMESPACE_STR "@std@@@12@A")
54# endif52#else
55 ;53# define STREAM(StreamT, BufferT, CharT, var) STRING_DATA_CONSTINIT stream_data<StreamT<CharT>, BufferT<CharT>> var
56alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
57static mbstate_t mb_wcout;
58#endif // _LIBCPP_HAS_WIDE_CHARACTERS
59
60alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
61#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
62 __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
63 "@std@@@12@A")
64#endif54#endif
65 ;
66alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
67static mbstate_t mb_cerr;
68
69#if _LIBCPP_HAS_WIDE_CHARACTERS
70alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
71# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
72 __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
73 "@std@@@12@A")
74# endif
75 ;
76alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
77static mbstate_t mb_wcerr;
78#endif // _LIBCPP_HAS_WIDE_CHARACTERS
7955
80alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]56// These definitions and the declarations in <iostream> technically cause ODR violations, since they have different
81#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)57// types (stream_data and {i,o}stream respectively). This means that <iostream> should never be included in this TU.
82 __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
83 "@std@@@12@A")
84#endif
85 ;
8658
59_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, char, cin);
60_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cout);
61_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, cerr);
62_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, char, clog);
87#if _LIBCPP_HAS_WIDE_CHARACTERS63#if _LIBCPP_HAS_WIDE_CHARACTERS
88alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]64_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_istream, __stdinbuf, wchar_t, wcin);
89# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)65_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcout);
90 __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR66_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wcerr);
91 "@std@@@12@A")67_LIBCPP_EXPORTED_FROM_ABI STREAM(basic_ostream, __stdoutbuf, wchar_t, wclog);
92# endif
93 ;
94#endif // _LIBCPP_HAS_WIDE_CHARACTERS68#endif // _LIBCPP_HAS_WIDE_CHARACTERS
9569
96// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority70// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
...@@ -124,37 +98,34 @@ public:...@@ -124,37 +98,34 @@ public:
124DoIOSInit::DoIOSInit() {98DoIOSInit::DoIOSInit() {
125 force_locale_initialization();99 force_locale_initialization();
126100
127 istream* cin_ptr = ::new (cin) istream(::new (__cin) __stdinbuf<char>(stdin, &mb_cin));101 cin.init(stdin);
128 ostream* cout_ptr = ::new (cout) ostream(::new (__cout) __stdoutbuf<char>(stdout, &mb_cout));102 cout.init(stdout);
129 ostream* cerr_ptr = ::new (cerr) ostream(::new (__cerr) __stdoutbuf<char>(stderr, &mb_cerr));103 cerr.init(stderr);
130 ::new (clog) ostream(cerr_ptr->rdbuf());104 clog.init(stderr);
131 cin_ptr->tie(cout_ptr);105
132 std::unitbuf(*cerr_ptr);106 cin.stream.tie(&cout.stream);
133 cerr_ptr->tie(cout_ptr);107 std::unitbuf(cerr.stream);
108 cerr.stream.tie(&cout.stream);
134109
135#if _LIBCPP_HAS_WIDE_CHARACTERS110#if _LIBCPP_HAS_WIDE_CHARACTERS
136 wistream* wcin_ptr = ::new (wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin));111 wcin.init(stdin);
137 wostream* wcout_ptr = ::new (wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));112 wcout.init(stdout);
138 wostream* wcerr_ptr = ::new (wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));113 wcerr.init(stderr);
139 ::new (wclog) wostream(wcerr_ptr->rdbuf());114 wclog.init(stderr);
140115
141 wcin_ptr->tie(wcout_ptr);116 wcin.stream.tie(&wcout.stream);
142 std::unitbuf(*wcerr_ptr);117 std::unitbuf(wcerr.stream);
143 wcerr_ptr->tie(wcout_ptr);118 wcerr.stream.tie(&wcout.stream);
144#endif119#endif
145}120}
146121
147DoIOSInit::~DoIOSInit() {122DoIOSInit::~DoIOSInit() {
148 ostream* cout_ptr = reinterpret_cast<ostream*>(cout);123 cout.stream.flush();
149 cout_ptr->flush();124 clog.stream.flush();
150 ostream* clog_ptr = reinterpret_cast<ostream*>(clog);
151 clog_ptr->flush();
152125
153#if _LIBCPP_HAS_WIDE_CHARACTERS126#if _LIBCPP_HAS_WIDE_CHARACTERS
154 wostream* wcout_ptr = reinterpret_cast<wostream*>(wcout);127 wcout.stream.flush();
155 wcout_ptr->flush();128 wclog.stream.flush();
156 wostream* wclog_ptr = reinterpret_cast<wostream*>(wclog);
157 wclog_ptr->flush();
158#endif129#endif
159}130}
160131
lib/libcxx/src/locale.cpp+67-146
...@@ -34,10 +34,6 @@...@@ -34,10 +34,6 @@
34# define _CTYPE_DISABLE_MACROS34# define _CTYPE_DISABLE_MACROS
35#endif35#endif
3636
37#if __has_include("<langinfo.h>")
38# include <langinfo.h>
39#endif
40
41#include "include/atomic_support.h"37#include "include/atomic_support.h"
42#include "include/sso_allocator.h"38#include "include/sso_allocator.h"
4339
...@@ -482,7 +478,7 @@ void locale::__imp::install(facet* f, long id) {...@@ -482,7 +478,7 @@ void locale::__imp::install(facet* f, long id) {
482478
483const locale::facet* locale::__imp::use_facet(long id) const {479const locale::facet* locale::__imp::use_facet(long id) const {
484 if (!has_facet(id))480 if (!has_facet(id))
485 __throw_bad_cast();481 std::__throw_bad_cast();
486 return facets_[static_cast<size_t>(id)];482 return facets_[static_cast<size_t>(id)];
487}483}
488484
...@@ -602,7 +598,7 @@ long locale::id::__get() {...@@ -602,7 +598,7 @@ long locale::id::__get() {
602collate_byname<char>::collate_byname(const char* n, size_t refs)598collate_byname<char>::collate_byname(const char* n, size_t refs)
603 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {599 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {
604 if (__l_ == 0)600 if (__l_ == 0)
605 __throw_runtime_error(601 std::__throw_runtime_error(
606 ("collate_byname<char>::collate_byname"602 ("collate_byname<char>::collate_byname"
607 " failed to construct for " +603 " failed to construct for " +
608 string(n))604 string(n))
...@@ -612,7 +608,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs)...@@ -612,7 +608,7 @@ collate_byname<char>::collate_byname(const char* n, size_t refs)
612collate_byname<char>::collate_byname(const string& name, size_t refs)608collate_byname<char>::collate_byname(const string& name, size_t refs)
613 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {609 : collate<char>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
614 if (__l_ == 0)610 if (__l_ == 0)
615 __throw_runtime_error(611 std::__throw_runtime_error(
616 ("collate_byname<char>::collate_byname"612 ("collate_byname<char>::collate_byname"
617 " failed to construct for " +613 " failed to construct for " +
618 name)614 name)
...@@ -646,7 +642,7 @@ collate_byname<char>::string_type collate_byname<char>::do_transform(const char_...@@ -646,7 +642,7 @@ collate_byname<char>::string_type collate_byname<char>::do_transform(const char_
646collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)642collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
647 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {643 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, n, 0)) {
648 if (__l_ == 0)644 if (__l_ == 0)
649 __throw_runtime_error(645 std::__throw_runtime_error(
650 ("collate_byname<wchar_t>::collate_byname(size_t refs)"646 ("collate_byname<wchar_t>::collate_byname(size_t refs)"
651 " failed to construct for " +647 " failed to construct for " +
652 string(n))648 string(n))
...@@ -656,7 +652,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)...@@ -656,7 +652,7 @@ collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
656collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)652collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
657 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {653 : collate<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
658 if (__l_ == 0)654 if (__l_ == 0)
659 __throw_runtime_error(655 std::__throw_runtime_error(
660 ("collate_byname<wchar_t>::collate_byname(size_t refs)"656 ("collate_byname<wchar_t>::collate_byname(size_t refs)"
661 " failed to construct for " +657 " failed to construct for " +
662 name)658 name)
...@@ -701,6 +697,20 @@ const ctype_base::mask ctype_base::graph;...@@ -701,6 +697,20 @@ const ctype_base::mask ctype_base::graph;
701697
702// template <> class ctype<wchar_t>;698// template <> class ctype<wchar_t>;
703699
700template <class CharT>
701static CharT to_upper_impl(CharT c) {
702 if (c < 'a' || c > 'z')
703 return c;
704 return c & ~0x20;
705}
706
707template <class CharT>
708static CharT to_lower_impl(CharT c) {
709 if (c < 'A' || c > 'Z')
710 return c;
711 return c | 0x20;
712}
713
704#if _LIBCPP_HAS_WIDE_CHARACTERS714#if _LIBCPP_HAS_WIDE_CHARACTERS
705constinit locale::id ctype<wchar_t>::id;715constinit locale::id ctype<wchar_t>::id;
706716
...@@ -730,48 +740,19 @@ const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const c...@@ -730,48 +740,19 @@ const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const c
730 return low;740 return low;
731}741}
732742
733wchar_t ctype<wchar_t>::do_toupper(char_type c) const {743wchar_t ctype<wchar_t>::do_toupper(char_type c) const { return to_upper_impl(c); }
734# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
735 return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
736# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
737 return std::__libcpp_isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
738# else
739 return (std::__libcpp_isascii(c) && __locale::__iswlower(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c;
740# endif
741}
742744
743const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const {745const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const {
744 for (; low != high; ++low)746 for (; low != high; ++low)
745# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE747 *low = to_upper_impl(*low);
746 *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
747# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
748 *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low;
749# else
750 *low =
751 (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low;
752# endif
753 return low;748 return low;
754}749}
755750
756wchar_t ctype<wchar_t>::do_tolower(char_type c) const {751wchar_t ctype<wchar_t>::do_tolower(char_type c) const { return to_lower_impl(c); }
757# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
758 return std::__libcpp_isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
759# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
760 return std::__libcpp_isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
761# else
762 return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c;
763# endif
764}
765752
766const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const {753const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const {
767 for (; low != high; ++low)754 for (; low != high; ++low)
768# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE755 *low = to_lower_impl(*low);
769 *low = std::__libcpp_isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
770# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
771 *low = std::__libcpp_isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low;
772# else
773 *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low;
774# endif
775 return low;756 return low;
776}757}
777758
...@@ -815,59 +796,19 @@ ctype<char>::~ctype() {...@@ -815,59 +796,19 @@ ctype<char>::~ctype() {
815 delete[] __tab_;796 delete[] __tab_;
816}797}
817798
818char ctype<char>::do_toupper(char_type c) const {799char ctype<char>::do_toupper(char_type c) const { return to_upper_impl(c); }
819#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
820 return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
821#elif defined(__NetBSD__)
822 return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
823#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
824 return std::__libcpp_isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
825#else
826 return (std::__libcpp_isascii(c) && __locale::__islower(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c;
827#endif
828}
829800
830const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const {801const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const {
831 for (; low != high; ++low)802 for (; low != high; ++low)
832#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE803 *low = to_upper_impl(*low);
833 *low = std::__libcpp_isascii(*low)
834 ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)])
835 : *low;
836#elif defined(__NetBSD__)
837 *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
838#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
839 *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
840#else
841 *low = (std::__libcpp_isascii(*low) && __locale::__islower(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low;
842#endif
843 return low;804 return low;
844}805}
845806
846char ctype<char>::do_tolower(char_type c) const {807char ctype<char>::do_tolower(char_type c) const { return to_lower_impl(c); }
847#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
848 return std::__libcpp_isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
849#elif defined(__NetBSD__)
850 return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
851#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
852 return std::__libcpp_isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
853#else
854 return (std::__libcpp_isascii(c) && __locale::__isupper(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c;
855#endif
856}
857808
858const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const {809const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const {
859 for (; low != high; ++low)810 for (; low != high; ++low)
860#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE811 *low = to_lower_impl(*low);
861 *low = std::__libcpp_isascii(*low)
862 ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)])
863 : *low;
864#elif defined(__NetBSD__)
865 *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
866#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
867 *low = std::__libcpp_isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
868#else
869 *low = (std::__libcpp_isascii(*low) && __locale::__isupper(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low;
870#endif
871 return low;812 return low;
872}813}
873814
...@@ -1014,42 +955,12 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {...@@ -1014,42 +955,12 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
1014}955}
1015#endif956#endif
1016957
1017#if defined(__GLIBC__)
1018const int* ctype<char>::__classic_lower_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_tolower; }
1019
1020const int* ctype<char>::__classic_upper_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_toupper; }
1021#elif defined(__NetBSD__)
1022const short* ctype<char>::__classic_lower_table() noexcept { return _C_tolower_tab_ + 1; }
1023
1024const short* ctype<char>::__classic_upper_table() noexcept { return _C_toupper_tab_ + 1; }
1025
1026#elif defined(__EMSCRIPTEN__)
1027const int* ctype<char>::__classic_lower_table() noexcept { return *__ctype_tolower_loc(); }
1028
1029const int* ctype<char>::__classic_upper_table() noexcept { return *__ctype_toupper_loc(); }
1030#elif defined(__MVS__)
1031const unsigned short* ctype<char>::__classic_lower_table() _NOEXCEPT {
1032# if defined(__NATIVE_ASCII_F)
1033 return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->lower);
1034# else
1035 return const_cast<const unsigned short*>(__ctype + __TOLOWER_INDEX);
1036# endif
1037}
1038const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT {
1039# if defined(__NATIVE_ASCII_F)
1040 return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->upper);
1041# else
1042 return const_cast<const unsigned short*>(__ctype + __TOUPPER_INDEX);
1043# endif
1044}
1045#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ || __MVS__
1046
1047// template <> class ctype_byname<char>958// template <> class ctype_byname<char>
1048959
1049ctype_byname<char>::ctype_byname(const char* name, size_t refs)960ctype_byname<char>::ctype_byname(const char* name, size_t refs)
1050 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {961 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {
1051 if (__l_ == 0)962 if (__l_ == 0)
1052 __throw_runtime_error(963 std::__throw_runtime_error(
1053 ("ctype_byname<char>::ctype_byname"964 ("ctype_byname<char>::ctype_byname"
1054 " failed to construct for " +965 " failed to construct for " +
1055 string(name))966 string(name))
...@@ -1059,7 +970,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs)...@@ -1059,7 +970,7 @@ ctype_byname<char>::ctype_byname(const char* name, size_t refs)
1059ctype_byname<char>::ctype_byname(const string& name, size_t refs)970ctype_byname<char>::ctype_byname(const string& name, size_t refs)
1060 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {971 : ctype<char>(0, false, refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
1061 if (__l_ == 0)972 if (__l_ == 0)
1062 __throw_runtime_error(973 std::__throw_runtime_error(
1063 ("ctype_byname<char>::ctype_byname"974 ("ctype_byname<char>::ctype_byname"
1064 " failed to construct for " +975 " failed to construct for " +
1065 name)976 name)
...@@ -1094,7 +1005,7 @@ const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high...@@ -1094,7 +1005,7 @@ const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high
1094ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)1005ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
1095 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {1006 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name, 0)) {
1096 if (__l_ == 0)1007 if (__l_ == 0)
1097 __throw_runtime_error(1008 std::__throw_runtime_error(
1098 ("ctype_byname<wchar_t>::ctype_byname"1009 ("ctype_byname<wchar_t>::ctype_byname"
1099 " failed to construct for " +1010 " failed to construct for " +
1100 string(name))1011 string(name))
...@@ -1104,7 +1015,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)...@@ -1104,7 +1015,7 @@ ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
1104ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)1015ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
1105 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {1016 : ctype<wchar_t>(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, name.c_str(), 0)) {
1106 if (__l_ == 0)1017 if (__l_ == 0)
1107 __throw_runtime_error(1018 std::__throw_runtime_error(
1108 ("ctype_byname<wchar_t>::ctype_byname"1019 ("ctype_byname<wchar_t>::ctype_byname"
1109 " failed to construct for " +1020 " failed to construct for " +
1110 name)1021 name)
...@@ -1344,7 +1255,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), _...@@ -1344,7 +1255,7 @@ codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), _
1344codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)1255codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
1345 : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {1256 : locale::facet(refs), __l_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
1346 if (__l_ == 0)1257 if (__l_ == 0)
1347 __throw_runtime_error(1258 std::__throw_runtime_error(
1348 ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"1259 ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
1349 " failed to construct for " +1260 " failed to construct for " +
1350 string(nm))1261 string(nm))
...@@ -3957,7 +3868,7 @@ static bool is_narrow_non_breaking_space(const char* ptr) {...@@ -3957,7 +3868,7 @@ static bool is_narrow_non_breaking_space(const char* ptr) {
3957}3868}
39583869
3959static bool is_non_breaking_space(const char* ptr) {3870static bool is_non_breaking_space(const char* ptr) {
3960 // https://www.fileformat.info/info/unicode/char/0a/index.htm3871 // https://www.fileformat.info/info/unicode/char/a0/index.htm
3961 return ptr[0] == '\xc2' && ptr[1] == '\xa0';3872 return ptr[0] == '\xc2' && ptr[1] == '\xa0';
3962}3873}
3963#endif // _LIBCPP_HAS_WIDE_CHARACTERS3874#endif // _LIBCPP_HAS_WIDE_CHARACTERS
...@@ -4061,7 +3972,7 @@ void numpunct_byname<char>::__init(const char* nm) {...@@ -4061,7 +3972,7 @@ void numpunct_byname<char>::__init(const char* nm) {
4061 if (strcmp(nm, "C") != 0) {3972 if (strcmp(nm, "C") != 0) {
4062 __libcpp_unique_locale loc(nm);3973 __libcpp_unique_locale loc(nm);
4063 if (!loc)3974 if (!loc)
4064 __throw_runtime_error(3975 std::__throw_runtime_error(
4065 ("numpunct_byname<char>::numpunct_byname"3976 ("numpunct_byname<char>::numpunct_byname"
4066 " failed to construct for " +3977 " failed to construct for " +
4067 string(nm))3978 string(nm))
...@@ -4092,7 +4003,7 @@ void numpunct_byname<wchar_t>::__init(const char* nm) {...@@ -4092,7 +4003,7 @@ void numpunct_byname<wchar_t>::__init(const char* nm) {
4092 if (strcmp(nm, "C") != 0) {4003 if (strcmp(nm, "C") != 0) {
4093 __libcpp_unique_locale loc(nm);4004 __libcpp_unique_locale loc(nm);
4094 if (!loc)4005 if (!loc)
4095 __throw_runtime_error(4006 std::__throw_runtime_error(
4096 ("numpunct_byname<wchar_t>::numpunct_byname"4007 ("numpunct_byname<wchar_t>::numpunct_byname"
4097 " failed to construct for " +4008 " failed to construct for " +
4098 string(nm))4009 string(nm))
...@@ -4444,12 +4355,12 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const {...@@ -4444,12 +4355,12 @@ const wstring& __time_get_c_storage<wchar_t>::__r() const {
44444355
4445__time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {4356__time_get::__time_get(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
4446 if (__loc_ == 0)4357 if (__loc_ == 0)
4447 __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());4358 std::__throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());
4448}4359}
44494360
4450__time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {4361__time_get::__time_get(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {
4451 if (__loc_ == 0)4362 if (__loc_ == 0)
4452 __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());4363 std::__throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());
4453}4364}
44544365
4455__time_get::~__time_get() { __locale::__freelocale(__loc_); }4366__time_get::~__time_get() { __locale::__freelocale(__loc_); }
...@@ -4610,7 +4521,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c...@@ -4610,7 +4521,7 @@ wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& c
4610 const char* bb = buf;4521 const char* bb = buf;
4611 size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_);4522 size_t j = __locale::__mbsrtowcs(wbb, &bb, countof(wbuf), &mb, __loc_);
4612 if (j == size_t(-1))4523 if (j == size_t(-1))
4613 __throw_runtime_error("locale not supported");4524 std::__throw_runtime_error("locale not supported");
4614 wchar_t* wbe = wbb + j;4525 wchar_t* wbe = wbb + j;
4615 wstring result;4526 wstring result;
4616 while (wbb != wbe) {4527 while (wbb != wbe) {
...@@ -4771,7 +4682,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4771,7 +4682,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4771 const char* bb = buf;4682 const char* bb = buf;
4772 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4683 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4773 if (j == size_t(-1) || j == 0)4684 if (j == size_t(-1) || j == 0)
4774 __throw_runtime_error("locale not supported");4685 std::__throw_runtime_error("locale not supported");
4775 wbe = wbuf + j;4686 wbe = wbuf + j;
4776 __weeks_[i].assign(wbuf, wbe);4687 __weeks_[i].assign(wbuf, wbe);
4777 __locale::__strftime(buf, countof(buf), "%a", &t, __loc_);4688 __locale::__strftime(buf, countof(buf), "%a", &t, __loc_);
...@@ -4779,7 +4690,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4779,7 +4690,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4779 bb = buf;4690 bb = buf;
4780 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4691 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4781 if (j == size_t(-1) || j == 0)4692 if (j == size_t(-1) || j == 0)
4782 __throw_runtime_error("locale not supported");4693 std::__throw_runtime_error("locale not supported");
4783 wbe = wbuf + j;4694 wbe = wbuf + j;
4784 __weeks_[i + 7].assign(wbuf, wbe);4695 __weeks_[i + 7].assign(wbuf, wbe);
4785 }4696 }
...@@ -4791,7 +4702,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4791,7 +4702,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4791 const char* bb = buf;4702 const char* bb = buf;
4792 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4703 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4793 if (j == size_t(-1) || j == 0)4704 if (j == size_t(-1) || j == 0)
4794 __throw_runtime_error("locale not supported");4705 std::__throw_runtime_error("locale not supported");
4795 wbe = wbuf + j;4706 wbe = wbuf + j;
4796 __months_[i].assign(wbuf, wbe);4707 __months_[i].assign(wbuf, wbe);
4797 __locale::__strftime(buf, countof(buf), "%b", &t, __loc_);4708 __locale::__strftime(buf, countof(buf), "%b", &t, __loc_);
...@@ -4799,7 +4710,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4799,7 +4710,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4799 bb = buf;4710 bb = buf;
4800 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4711 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4801 if (j == size_t(-1) || j == 0)4712 if (j == size_t(-1) || j == 0)
4802 __throw_runtime_error("locale not supported");4713 std::__throw_runtime_error("locale not supported");
4803 wbe = wbuf + j;4714 wbe = wbuf + j;
4804 __months_[i + 12].assign(wbuf, wbe);4715 __months_[i + 12].assign(wbuf, wbe);
4805 }4716 }
...@@ -4810,7 +4721,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4810,7 +4721,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4810 const char* bb = buf;4721 const char* bb = buf;
4811 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4722 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4812 if (j == size_t(-1))4723 if (j == size_t(-1))
4813 __throw_runtime_error("locale not supported");4724 std::__throw_runtime_error("locale not supported");
4814 wbe = wbuf + j;4725 wbe = wbuf + j;
4815 __am_pm_[0].assign(wbuf, wbe);4726 __am_pm_[0].assign(wbuf, wbe);
4816 t.tm_hour = 13;4727 t.tm_hour = 13;
...@@ -4819,7 +4730,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {...@@ -4819,7 +4730,7 @@ void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
4819 bb = buf;4730 bb = buf;
4820 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);4731 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, __loc_);
4821 if (j == size_t(-1))4732 if (j == size_t(-1))
4822 __throw_runtime_error("locale not supported");4733 std::__throw_runtime_error("locale not supported");
4823 wbe = wbuf + j;4734 wbe = wbuf + j;
4824 __am_pm_[1].assign(wbuf, wbe);4735 __am_pm_[1].assign(wbuf, wbe);
4825 __c_ = __analyze('c', ct);4736 __c_ = __analyze('c', ct);
...@@ -5029,12 +4940,12 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {...@@ -5029,12 +4940,12 @@ time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {
50294940
5030__time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {4941__time_put::__time_put(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {
5031 if (__loc_ == 0)4942 if (__loc_ == 0)
5032 __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());4943 std::__throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());
5033}4944}
50344945
5035__time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {4946__time_put::__time_put(const string& nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm.c_str(), 0)) {
5036 if (__loc_ == 0)4947 if (__loc_ == 0)
5037 __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());4948 std::__throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());
5038}4949}
50394950
5040__time_put::~__time_put() {4951__time_put::~__time_put() {
...@@ -5059,7 +4970,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __...@@ -5059,7 +4970,7 @@ void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __
5059 const char* __nb = __nar;4970 const char* __nb = __nar;
5060 size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_);4971 size_t j = __locale::__mbsrtowcs(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
5061 if (j == size_t(-1))4972 if (j == size_t(-1))
5062 __throw_runtime_error("locale not supported");4973 std::__throw_runtime_error("locale not supported");
5063 __we = __wb + j;4974 __we = __wb + j;
5064}4975}
5065#endif // _LIBCPP_HAS_WIDE_CHARACTERS4976#endif // _LIBCPP_HAS_WIDE_CHARACTERS
...@@ -5431,7 +5342,7 @@ void moneypunct_byname<char, false>::init(const char* nm) {...@@ -5431,7 +5342,7 @@ void moneypunct_byname<char, false>::init(const char* nm) {
5431 typedef moneypunct<char, false> base;5342 typedef moneypunct<char, false> base;
5432 __libcpp_unique_locale loc(nm);5343 __libcpp_unique_locale loc(nm);
5433 if (!loc)5344 if (!loc)
5434 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5345 std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
54355346
5436 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());5347 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5437 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5348 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
...@@ -5466,7 +5377,7 @@ void moneypunct_byname<char, true>::init(const char* nm) {...@@ -5466,7 +5377,7 @@ void moneypunct_byname<char, true>::init(const char* nm) {
5466 typedef moneypunct<char, true> base;5377 typedef moneypunct<char, true> base;
5467 __libcpp_unique_locale loc(nm);5378 __libcpp_unique_locale loc(nm);
5468 if (!loc)5379 if (!loc)
5469 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5380 std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
54705381
5471 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());5382 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5472 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5383 if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
...@@ -5522,7 +5433,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5522,7 +5433,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5522 typedef moneypunct<wchar_t, false> base;5433 typedef moneypunct<wchar_t, false> base;
5523 __libcpp_unique_locale loc(nm);5434 __libcpp_unique_locale loc(nm);
5524 if (!loc)5435 if (!loc)
5525 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5436 std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
5526 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());5437 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5527 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5438 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
5528 __decimal_point_ = base::do_decimal_point();5439 __decimal_point_ = base::do_decimal_point();
...@@ -5534,7 +5445,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5534,7 +5445,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5534 const char* bb = lc->currency_symbol;5445 const char* bb = lc->currency_symbol;
5535 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5446 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5536 if (j == size_t(-1))5447 if (j == size_t(-1))
5537 __throw_runtime_error("locale not supported");5448 std::__throw_runtime_error("locale not supported");
5538 wchar_t* wbe = wbuf + j;5449 wchar_t* wbe = wbuf + j;
5539 __curr_symbol_.assign(wbuf, wbe);5450 __curr_symbol_.assign(wbuf, wbe);
5540 if (lc->frac_digits != CHAR_MAX)5451 if (lc->frac_digits != CHAR_MAX)
...@@ -5548,7 +5459,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5548,7 +5459,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5548 bb = lc->positive_sign;5459 bb = lc->positive_sign;
5549 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5460 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5550 if (j == size_t(-1))5461 if (j == size_t(-1))
5551 __throw_runtime_error("locale not supported");5462 std::__throw_runtime_error("locale not supported");
5552 wbe = wbuf + j;5463 wbe = wbuf + j;
5553 __positive_sign_.assign(wbuf, wbe);5464 __positive_sign_.assign(wbuf, wbe);
5554 }5465 }
...@@ -5559,7 +5470,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {...@@ -5559,7 +5470,7 @@ void moneypunct_byname<wchar_t, false>::init(const char* nm) {
5559 bb = lc->negative_sign;5470 bb = lc->negative_sign;
5560 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5471 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5561 if (j == size_t(-1))5472 if (j == size_t(-1))
5562 __throw_runtime_error("locale not supported");5473 std::__throw_runtime_error("locale not supported");
5563 wbe = wbuf + j;5474 wbe = wbuf + j;
5564 __negative_sign_.assign(wbuf, wbe);5475 __negative_sign_.assign(wbuf, wbe);
5565 }5476 }
...@@ -5576,7 +5487,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5576,7 +5487,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5576 typedef moneypunct<wchar_t, true> base;5487 typedef moneypunct<wchar_t, true> base;
5577 __libcpp_unique_locale loc(nm);5488 __libcpp_unique_locale loc(nm);
5578 if (!loc)5489 if (!loc)
5579 __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());5490 std::__throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
55805491
5581 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());5492 __locale::__lconv_t* lc = __locale::__localeconv(loc.get());
5582 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))5493 if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
...@@ -5589,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5589,7 +5500,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5589 const char* bb = lc->int_curr_symbol;5500 const char* bb = lc->int_curr_symbol;
5590 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5501 size_t j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5591 if (j == size_t(-1))5502 if (j == size_t(-1))
5592 __throw_runtime_error("locale not supported");5503 std::__throw_runtime_error("locale not supported");
5593 wchar_t* wbe = wbuf + j;5504 wchar_t* wbe = wbuf + j;
5594 __curr_symbol_.assign(wbuf, wbe);5505 __curr_symbol_.assign(wbuf, wbe);
5595 if (lc->int_frac_digits != CHAR_MAX)5506 if (lc->int_frac_digits != CHAR_MAX)
...@@ -5607,7 +5518,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5607,7 +5518,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5607 bb = lc->positive_sign;5518 bb = lc->positive_sign;
5608 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5519 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5609 if (j == size_t(-1))5520 if (j == size_t(-1))
5610 __throw_runtime_error("locale not supported");5521 std::__throw_runtime_error("locale not supported");
5611 wbe = wbuf + j;5522 wbe = wbuf + j;
5612 __positive_sign_.assign(wbuf, wbe);5523 __positive_sign_.assign(wbuf, wbe);
5613 }5524 }
...@@ -5622,7 +5533,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5622,7 +5533,7 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
5622 bb = lc->negative_sign;5533 bb = lc->negative_sign;
5623 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());5534 j = __locale::__mbsrtowcs(wbuf, &bb, countof(wbuf), &mb, loc.get());
5624 if (j == size_t(-1))5535 if (j == size_t(-1))
5625 __throw_runtime_error("locale not supported");5536 std::__throw_runtime_error("locale not supported");
5626 wbe = wbuf + j;5537 wbe = wbuf + j;
5627 __negative_sign_.assign(wbuf, wbe);5538 __negative_sign_.assign(wbuf, wbe);
5628 }5539 }
...@@ -5650,6 +5561,16 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {...@@ -5650,6 +5561,16 @@ void moneypunct_byname<wchar_t, true>::init(const char* nm) {
56505561
5651void __do_nothing(void*) {}5562void __do_nothing(void*) {}
56525563
5564// Legacy ABI __num_get functions - the new ones are _LIBCPP_HIDE_FROM_ABI
5565template <class _CharT>
5566string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) {
5567 locale __loc = __iob.getloc();
5568 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
5569 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
5570 __thousands_sep = __np.thousands_sep();
5571 return __np.grouping();
5572}
5573
5653template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>;5574template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>;
5654_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;)5575_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;)
56555576
lib/libcxx/src/memory.cpp+2
...@@ -11,7 +11,9 @@...@@ -11,7 +11,9 @@
11# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS11# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
12#endif12#endif
1313
14#include <__functional/hash.h>
14#include <memory>15#include <memory>
16#include <typeinfo>
1517
16#if _LIBCPP_HAS_THREADS18#if _LIBCPP_HAS_THREADS
17# include <mutex>19# include <mutex>
lib/libcxx/src/memory_resource.cpp+4-4
...@@ -38,7 +38,7 @@ static bool is_aligned_to(void* ptr, size_t align) {...@@ -38,7 +38,7 @@ static bool is_aligned_to(void* ptr, size_t align) {
38}38}
39#endif39#endif
4040
41class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource {41class _LIBCPP_HIDDEN __new_delete_memory_resource_imp : public memory_resource {
42 void* do_allocate(size_t bytes, size_t align) override {42 void* do_allocate(size_t bytes, size_t align) override {
43#if _LIBCPP_HAS_ALIGNED_ALLOCATION43#if _LIBCPP_HAS_ALIGNED_ALLOCATION
44 return std::__libcpp_allocate<std::byte>(__element_count(bytes), align);44 return std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
...@@ -48,7 +48,7 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory...@@ -48,7 +48,7 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory
48 std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align);48 std::byte* result = std::__libcpp_allocate<std::byte>(__element_count(bytes), align);
49 if (!is_aligned_to(result, align)) {49 if (!is_aligned_to(result, align)) {
50 std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align);50 std::__libcpp_deallocate<std::byte>(result, __element_count(bytes), align);
51 __throw_bad_alloc();51 std::__throw_bad_alloc();
52 }52 }
53 return result;53 return result;
54#endif54#endif
...@@ -63,8 +63,8 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory...@@ -63,8 +63,8 @@ class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory
6363
64// null_memory_resource()64// null_memory_resource()
6565
66class _LIBCPP_EXPORTED_FROM_ABI __null_memory_resource_imp : public memory_resource {66class _LIBCPP_HIDDEN __null_memory_resource_imp : public memory_resource {
67 void* do_allocate(size_t, size_t) override { __throw_bad_alloc(); }67 void* do_allocate(size_t, size_t) override { std::__throw_bad_alloc(); }
68 void do_deallocate(void*, size_t, size_t) override {}68 void do_deallocate(void*, size_t, size_t) override {}
69 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }69 bool do_is_equal(const memory_resource& other) const noexcept override { return &other == this; }
70};70};
lib/libcxx/src/mutex.cpp+5-4
...@@ -7,6 +7,7 @@...@@ -7,6 +7,7 @@
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__assert>9#include <__assert>
10#include <__system_error/throw_system_error.h>
10#include <__thread/id.h>11#include <__thread/id.h>
11#include <__utility/exception_guard.h>12#include <__utility/exception_guard.h>
12#include <limits>13#include <limits>
...@@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -28,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
28void mutex::lock() {29void mutex::lock() {
29 int ec = __libcpp_mutex_lock(&__m_);30 int ec = __libcpp_mutex_lock(&__m_);
30 if (ec)31 if (ec)
31 __throw_system_error(ec, "mutex lock failed");32 std::__throw_system_error(ec, "mutex lock failed");
32}33}
3334
34bool mutex::try_lock() noexcept { return __libcpp_mutex_trylock(&__m_); }35bool mutex::try_lock() noexcept { return __libcpp_mutex_trylock(&__m_); }
...@@ -45,7 +46,7 @@ void mutex::unlock() noexcept {...@@ -45,7 +46,7 @@ void mutex::unlock() noexcept {
45recursive_mutex::recursive_mutex() {46recursive_mutex::recursive_mutex() {
46 int ec = __libcpp_recursive_mutex_init(&__m_);47 int ec = __libcpp_recursive_mutex_init(&__m_);
47 if (ec)48 if (ec)
48 __throw_system_error(ec, "recursive_mutex constructor failed");49 std::__throw_system_error(ec, "recursive_mutex constructor failed");
49}50}
5051
51recursive_mutex::~recursive_mutex() {52recursive_mutex::~recursive_mutex() {
...@@ -57,7 +58,7 @@ recursive_mutex::~recursive_mutex() {...@@ -57,7 +58,7 @@ recursive_mutex::~recursive_mutex() {
57void recursive_mutex::lock() {58void recursive_mutex::lock() {
58 int ec = __libcpp_recursive_mutex_lock(&__m_);59 int ec = __libcpp_recursive_mutex_lock(&__m_);
59 if (ec)60 if (ec)
60 __throw_system_error(ec, "recursive_mutex lock failed");61 std::__throw_system_error(ec, "recursive_mutex lock failed");
61}62}
6263
63void recursive_mutex::unlock() noexcept {64void recursive_mutex::unlock() noexcept {
...@@ -108,7 +109,7 @@ void recursive_timed_mutex::lock() {...@@ -108,7 +109,7 @@ void recursive_timed_mutex::lock() {
108 unique_lock<mutex> lk(__m_);109 unique_lock<mutex> lk(__m_);
109 if (id == __id_) {110 if (id == __id_) {
110 if (__count_ == numeric_limits<size_t>::max())111 if (__count_ == numeric_limits<size_t>::max())
111 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");112 std::__throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
112 ++__count_;113 ++__count_;
113 return;114 return;
114 }115 }
lib/libcxx/src/new.cpp+9-14
...@@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) {...@@ -43,7 +43,7 @@ static void* operator_new_impl(std::size_t size) {
43 return p;43 return p;
44}44}
4545
46_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {46_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size)) _THROW_BAD_ALLOC {
47 void* p = operator_new_impl(size);47 void* p = operator_new_impl(size);
48 if (p == nullptr)48 if (p == nullptr)
49 __throw_bad_alloc_shim();49 __throw_bad_alloc_shim();
...@@ -54,7 +54,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {...@@ -54,7 +54,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
54# if !_LIBCPP_HAS_EXCEPTIONS54# if !_LIBCPP_HAS_EXCEPTIONS
55# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION55# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
56 _LIBCPP_ASSERT_SHIM(56 _LIBCPP_ASSERT_SHIM(
57 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new)),57 (!std::__is_function_overridden < void*(std::size_t), &operator new>()),
58 "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, "58 "libc++ was configured with exceptions disabled and `operator new(size_t)` has been overridden, "
59 "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because "59 "but `operator new(size_t, nothrow_t)` has not been overridden. This is problematic because "
60 "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case "60 "`operator new(size_t, nothrow_t)` must call `operator new(size_t)`, which will terminate in case "
...@@ -74,15 +74,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {...@@ -74,15 +74,13 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
74# endif74# endif
75}75}
7676
77_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](size_t size) _THROW_BAD_ALLOC {77_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size)) _THROW_BAD_ALLOC { return ::operator new(size); }
78 return ::operator new(size);
79}
8078
81_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {79_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
82# if !_LIBCPP_HAS_EXCEPTIONS80# if !_LIBCPP_HAS_EXCEPTIONS
83# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION81# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
84 _LIBCPP_ASSERT_SHIM(82 _LIBCPP_ASSERT_SHIM(
85 !std::__is_function_overridden(static_cast<void* (*)(std::size_t)>(&operator new[])),83 (!std::__is_function_overridden < void*(std::size_t), &operator new[]>()),
86 "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, "84 "libc++ was configured with exceptions disabled and `operator new[](size_t)` has been overridden, "
87 "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because "85 "but `operator new[](size_t, nothrow_t)` has not been overridden. This is problematic because "
88 "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case "86 "`operator new[](size_t, nothrow_t)` must call `operator new[](size_t)`, which will terminate in case "
...@@ -136,8 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm...@@ -136,8 +134,7 @@ static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignm
136 return p;134 return p;
137}135}
138136
139_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*137_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new, (std::size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
140operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
141 void* p = operator_new_aligned_impl(size, alignment);138 void* p = operator_new_aligned_impl(size, alignment);
142 if (p == nullptr)139 if (p == nullptr)
143 __throw_bad_alloc_shim();140 __throw_bad_alloc_shim();
...@@ -148,7 +145,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s...@@ -148,7 +145,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
148# if !_LIBCPP_HAS_EXCEPTIONS145# if !_LIBCPP_HAS_EXCEPTIONS
149# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION146# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
150 _LIBCPP_ASSERT_SHIM(147 _LIBCPP_ASSERT_SHIM(
151 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new)),148 (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new>()),
152 "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, "149 "libc++ was configured with exceptions disabled and `operator new(size_t, align_val_t)` has been overridden, "
153 "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "150 "but `operator new(size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
154 "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will "151 "`operator new(size_t, align_val_t, nothrow_t)` must call `operator new(size_t, align_val_t)`, which will "
...@@ -168,8 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s...@@ -168,8 +165,7 @@ _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const s
168# endif165# endif
169}166}
170167
171_LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void*168_LIBCPP_OVERRIDABLE_FUNCTION(void*, operator new[], (size_t size, std::align_val_t alignment)) _THROW_BAD_ALLOC {
172operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC {
173 return ::operator new(size, alignment);169 return ::operator new(size, alignment);
174}170}
175171
...@@ -177,14 +173,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const...@@ -177,14 +173,13 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const
177# if !_LIBCPP_HAS_EXCEPTIONS173# if !_LIBCPP_HAS_EXCEPTIONS
178# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION174# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
179 _LIBCPP_ASSERT_SHIM(175 _LIBCPP_ASSERT_SHIM(
180 !std::__is_function_overridden(static_cast<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),176 (!std::__is_function_overridden < void*(std::size_t, std::align_val_t), &operator new[]>()),
181 "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, "177 "libc++ was configured with exceptions disabled and `operator new[](size_t, align_val_t)` has been overridden, "
182 "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "178 "but `operator new[](size_t, align_val_t, nothrow_t)` has not been overridden. This is problematic because "
183 "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will "179 "`operator new[](size_t, align_val_t, nothrow_t)` must call `operator new[](size_t, align_val_t)`, which will "
184 "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, "180 "terminate in case it fails to allocate, making it impossible for `operator new[](size_t, align_val_t, "
185 "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you "181 "nothrow_t)` to fulfill its contract (since it should return nullptr upon failure). Please make sure you "
186 "override "182 "override `operator new[](size_t, align_val_t, nothrow_t)` as well.");
187 "`operator new[](size_t, align_val_t, nothrow_t)` as well.");
188# endif183# endif
189184
190 return operator_new_aligned_impl(size, alignment);185 return operator_new_aligned_impl(size, alignment);
lib/libcxx/src/optional.cpp+1-1
...@@ -23,7 +23,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac...@@ -23,7 +23,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac
23// Even though it no longer exists in a header file23// Even though it no longer exists in a header file
24_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL24_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
2525
26class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error {26class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public std::logic_error {
27public:27public:
28 bad_optional_access() : std::logic_error("Bad optional Access") {}28 bad_optional_access() : std::logic_error("Bad optional Access") {}
2929
lib/libcxx/src/print.cpp+1-1
...@@ -51,7 +51,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst...@@ -51,7 +51,7 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst
51 __view.size(),51 __view.size(),
52 nullptr,52 nullptr,
53 nullptr) == 0) {53 nullptr) == 0) {
54 __throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output");54 std::__throw_system_error(filesystem::detail::get_last_error(), "failed to write formatted output");
55 }55 }
56}56}
57# endif // _LIBCPP_HAS_WIDE_CHARACTERS57# endif // _LIBCPP_HAS_WIDE_CHARACTERS
lib/libcxx/src/random.cpp+13-12
...@@ -16,6 +16,7 @@...@@ -16,6 +16,7 @@
16#include <__system_error/throw_system_error.h>16#include <__system_error/throw_system_error.h>
17#include <limits>17#include <limits>
18#include <random>18#include <random>
19#include <string>
1920
20#include <errno.h>21#include <errno.h>
21#include <stdio.h>22#include <stdio.h>
...@@ -42,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -42,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4243
43random_device::random_device(const string& __token) {44random_device::random_device(const string& __token) {
44 if (__token != "/dev/urandom")45 if (__token != "/dev/urandom")
45 __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());46 std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
46}47}
4748
48random_device::~random_device() {}49random_device::~random_device() {}
...@@ -52,7 +53,7 @@ unsigned random_device::operator()() {...@@ -52,7 +53,7 @@ unsigned random_device::operator()() {
52 size_t n = sizeof(r);53 size_t n = sizeof(r);
53 int err = getentropy(&r, n);54 int err = getentropy(&r, n);
54 if (err)55 if (err)
55 __throw_system_error(errno, "random_device getentropy failed");56 std::__throw_system_error(errno, "random_device getentropy failed");
56 return r;57 return r;
57}58}
5859
...@@ -68,7 +69,7 @@ unsigned random_device::operator()() { return arc4random(); }...@@ -68,7 +69,7 @@ unsigned random_device::operator()() { return arc4random(); }
6869
69random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) {70random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) {
70 if (__f_ < 0)71 if (__f_ < 0)
71 __throw_system_error(errno, ("random_device failed to open " + __token).c_str());72 std::__throw_system_error(errno, ("random_device failed to open " + __token).c_str());
72}73}
7374
74random_device::~random_device() { close(__f_); }75random_device::~random_device() { close(__f_); }
...@@ -80,10 +81,10 @@ unsigned random_device::operator()() {...@@ -80,10 +81,10 @@ unsigned random_device::operator()() {
80 while (n > 0) {81 while (n > 0) {
81 ssize_t s = read(__f_, p, n);82 ssize_t s = read(__f_, p, n);
82 if (s == 0)83 if (s == 0)
83 __throw_system_error(ENOMSG, "random_device got EOF");84 std::__throw_system_error(ENOMSG, "random_device got EOF");
84 if (s == -1) {85 if (s == -1) {
85 if (errno != EINTR)86 if (errno != EINTR)
86 __throw_system_error(errno, "random_device got an unexpected error");87 std::__throw_system_error(errno, "random_device got an unexpected error");
87 continue;88 continue;
88 }89 }
89 n -= static_cast<size_t>(s);90 n -= static_cast<size_t>(s);
...@@ -96,10 +97,10 @@ unsigned random_device::operator()() {...@@ -96,10 +97,10 @@ unsigned random_device::operator()() {
9697
97random_device::random_device(const string& __token) {98random_device::random_device(const string& __token) {
98 if (__token != "/dev/urandom")99 if (__token != "/dev/urandom")
99 __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());100 std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
100 int error = nacl_secure_random_init();101 int error = nacl_secure_random_init();
101 if (error)102 if (error)
102 __throw_system_error(error, ("random device failed to open " + __token).c_str());103 std::__throw_system_error(error, ("random device failed to open " + __token).c_str());
103}104}
104105
105random_device::~random_device() {}106random_device::~random_device() {}
...@@ -110,9 +111,9 @@ unsigned random_device::operator()() {...@@ -110,9 +111,9 @@ unsigned random_device::operator()() {
110 size_t bytes_written;111 size_t bytes_written;
111 int error = nacl_secure_random(&r, n, &bytes_written);112 int error = nacl_secure_random(&r, n, &bytes_written);
112 if (error != 0)113 if (error != 0)
113 __throw_system_error(error, "random_device failed getting bytes");114 std::__throw_system_error(error, "random_device failed getting bytes");
114 else if (bytes_written != n)115 else if (bytes_written != n)
115 __throw_runtime_error("random_device failed to obtain enough bytes");116 std::__throw_runtime_error("random_device failed to obtain enough bytes");
116 return r;117 return r;
117}118}
118119
...@@ -120,7 +121,7 @@ unsigned random_device::operator()() {...@@ -120,7 +121,7 @@ unsigned random_device::operator()() {
120121
121random_device::random_device(const string& __token) {122random_device::random_device(const string& __token) {
122 if (__token != "/dev/urandom")123 if (__token != "/dev/urandom")
123 __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());124 std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
124}125}
125126
126random_device::~random_device() {}127random_device::~random_device() {}
...@@ -129,7 +130,7 @@ unsigned random_device::operator()() {...@@ -129,7 +130,7 @@ unsigned random_device::operator()() {
129 unsigned r;130 unsigned r;
130 errno_t err = rand_s(&r);131 errno_t err = rand_s(&r);
131 if (err)132 if (err)
132 __throw_system_error(err, "random_device rand_s failed.");133 std::__throw_system_error(err, "random_device rand_s failed.");
133 return r;134 return r;
134}135}
135136
...@@ -137,7 +138,7 @@ unsigned random_device::operator()() {...@@ -137,7 +138,7 @@ unsigned random_device::operator()() {
137138
138random_device::random_device(const string& __token) {139random_device::random_device(const string& __token) {
139 if (__token != "/dev/urandom")140 if (__token != "/dev/urandom")
140 __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());141 std::__throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
141}142}
142143
143random_device::~random_device() {}144random_device::~random_device() {}
lib/libcxx/src/ryu/d2fixed.cpp+1
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
42#include <__assert>42#include <__assert>
43#include <__config>43#include <__config>
44#include <charconv>44#include <charconv>
45#include <cstddef>
45#include <cstring>46#include <cstring>
4647
47#include "include/ryu/common.h"48#include "include/ryu/common.h"
lib/libcxx/src/ryu/d2s.cpp+1
...@@ -42,6 +42,7 @@...@@ -42,6 +42,7 @@
42#include <__assert>42#include <__assert>
43#include <__config>43#include <__config>
44#include <charconv>44#include <charconv>
45#include <cstddef>
4546
46#include "include/ryu/common.h"47#include "include/ryu/common.h"
47#include "include/ryu/d2fixed.h"48#include "include/ryu/d2fixed.h"
lib/libcxx/src/ryu/f2s.cpp+2
...@@ -42,6 +42,8 @@...@@ -42,6 +42,8 @@
42#include <__assert>42#include <__assert>
43#include <__config>43#include <__config>
44#include <charconv>44#include <charconv>
45#include <cstdint>
46#include <cstddef>
4547
46#include "include/ryu/common.h"48#include "include/ryu/common.h"
47#include "include/ryu/d2fixed.h"49#include "include/ryu/d2fixed.h"
lib/libcxx/src/std_stream.h+1-1
...@@ -86,7 +86,7 @@ void __stdinbuf<_CharT>::imbue(const locale& __loc) {...@@ -86,7 +86,7 @@ void __stdinbuf<_CharT>::imbue(const locale& __loc) {
86 __encoding_ = __cv_->encoding();86 __encoding_ = __cv_->encoding();
87 __always_noconv_ = __cv_->always_noconv();87 __always_noconv_ = __cv_->always_noconv();
88 if (__encoding_ > __limit)88 if (__encoding_ > __limit)
89 __throw_runtime_error("unsupported locale for standard input");89 std::__throw_runtime_error("unsupported locale for standard input");
90}90}
9191
92template <class _CharT>92template <class _CharT>
lib/libcxx/src/string.cpp+39-1
...@@ -37,7 +37,45 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou...@@ -37,7 +37,45 @@ void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_ou
3737
38#endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON38#endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
3939
40#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;40// Define legacy ABI functions
41// ---------------------------
42
43#ifndef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
44
45template <class _CharT, class _Traits, class _Allocator>
46void basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_type __sz, size_type __reserve) {
47 if (__libcpp_is_constant_evaluated())
48 __rep_ = __rep();
49 if (__reserve > max_size())
50 __throw_length_error();
51 pointer __p;
52 if (__fits_in_sso(__reserve)) {
53 __set_short_size(__sz);
54 __p = __get_short_pointer();
55 } else {
56 auto __allocation = std::__allocate_at_least(__alloc_, __recommend(__reserve) + 1);
57 __p = __allocation.ptr;
58 __begin_lifetime(__p, __allocation.count);
59 __set_long_pointer(__p);
60 __set_long_cap(__allocation.count);
61 __set_long_size(__sz);
62 }
63 traits_type::copy(std::__to_address(__p), __s, __sz);
64 traits_type::assign(__p[__sz], value_type());
65 __annotate_new(__sz);
66}
67
68# define STRING_LEGACY_API(CharT) \
69 template _LIBCPP_EXPORTED_FROM_ABI void basic_string<CharT>::__init(const value_type*, size_type, size_type)
70
71STRING_LEGACY_API(char);
72# if _LIBCPP_HAS_WIDE_CHARACTERS
73STRING_LEGACY_API(wchar_t);
74# endif
75
76#endif // _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
77
78#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template _LIBCPP_EXPORTED_FROM_ABI __VA_ARGS__;
41#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION79#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
42_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)80_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
43# if _LIBCPP_HAS_WIDE_CHARACTERS81# if _LIBCPP_HAS_WIDE_CHARACTERS
lib/libcxx/src/thread.cpp+4-2
...@@ -6,8 +6,10 @@...@@ -6,8 +6,10 @@
6//6//
7//===----------------------------------------------------------------------===//7//===----------------------------------------------------------------------===//
88
9#include <__system_error/throw_system_error.h>
9#include <__thread/poll_with_backoff.h>10#include <__thread/poll_with_backoff.h>
10#include <__thread/timed_backoff_policy.h>11#include <__thread/timed_backoff_policy.h>
12#include <__utility/pair.h>
11#include <exception>13#include <exception>
12#include <future>14#include <future>
13#include <limits>15#include <limits>
...@@ -46,7 +48,7 @@ void thread::join() {...@@ -46,7 +48,7 @@ void thread::join() {
46 }48 }
4749
48 if (ec)50 if (ec)
49 __throw_system_error(ec, "thread::join failed");51 std::__throw_system_error(ec, "thread::join failed");
50}52}
5153
52void thread::detach() {54void thread::detach() {
...@@ -58,7 +60,7 @@ void thread::detach() {...@@ -58,7 +60,7 @@ void thread::detach() {
58 }60 }
5961
60 if (ec)62 if (ec)
61 __throw_system_error(ec, "thread::detach failed");63 std::__throw_system_error(ec, "thread::detach failed");
62}64}
6365
64unsigned thread::hardware_concurrency() noexcept {66unsigned thread::hardware_concurrency() noexcept {
lib/libcxx/src/verbose_abort.cpp+1-1
...@@ -23,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg);...@@ -23,7 +23,7 @@ extern "C" void android_set_abort_message(const char* msg);
2323
24_LIBCPP_BEGIN_NAMESPACE_STD24_LIBCPP_BEGIN_NAMESPACE_STD
2525
26_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) _LIBCPP_VERBOSE_ABORT_NOEXCEPT {26_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
27 // Write message to stderr. We do this before formatting into a27 // Write message to stderr. We do this before formatting into a
28 // buffer so that we still get some information out if that fails.28 // buffer so that we still get some information out if that fails.
29 {29 {