authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-03 12:35:12+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-09-05 14:54:30+02:00
loga585482c352a77d4f4b6cc1ede616adf6db7d7b3
tree098411639ff52d9a7897ee14fa3034164013c875
parentb0ce1c53cc852503e00da3cebc99bee719a54372
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

libcxx: update to LLVM 23


623 files changed, 13815 insertions(+), 9409 deletions(-)

lib/libcxx/include/__algorithm/clamp.h+4-2
......@@ -17,9 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20#if _LIBCPP_STD_VER >= 17
21
2022_LIBCPP_BEGIN_NAMESPACE_STD
2123
22#if _LIBCPP_STD_VER >= 17
2324template <class _Tp, class _Compare>
2425[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
2526clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
......@@ -37,8 +38,9 @@ clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
3738 _LIBCPP_LIFETIMEBOUND const _Tp& __hi) {
3839 return std::clamp(__v, __lo, __hi, __less<>());
3940}
40#endif
4141
4242_LIBCPP_END_NAMESPACE_STD
4343
44#endif // _LIBCPP_STD_VER >= 17
45
4446#endif // _LIBCPP___ALGORITHM_CLAMP_H
lib/libcxx/include/__algorithm/copy.h+16-15
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/copy_move_common.h>
1313#include <__algorithm/for_each_segment.h>
14#include <__algorithm/in_out_result.h>
1415#include <__algorithm/min.h>
1516#include <__algorithm/specialized_algorithms.h>
1617#include <__config>
......@@ -19,7 +20,6 @@
1920#include <__type_traits/common_type.h>
2021#include <__type_traits/enable_if.h>
2122#include <__utility/move.h>
22#include <__utility/pair.h>
2323
2424#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2525# pragma GCC system_header
......@@ -35,7 +35,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
3535copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result);
3636
3737template <class _InIter, class _Sent, class _OutIter>
38inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
38inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
39 __copy(_InIter, _Sent, _OutIter);
3940
4041struct __copy_impl {
4142 template <class _InIter,
......@@ -45,7 +46,7 @@ struct __copy_impl {
4546 __iterator_pair<_InIter, _Sent>,
4647 __single_iterator<_OutIter> >::__has_algorithm,
4748 int> = 0>
48 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
49 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
4950 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
5051 while (__first != __last) {
5152 *__result = *__first;
......@@ -53,7 +54,7 @@ struct __copy_impl {
5354 ++__result;
5455 }
5556
56 return std::make_pair(std::move(__first), std::move(__result));
57 return {std::move(__first), std::move(__result)};
5758 }
5859
5960 template <class _InIter,
......@@ -63,20 +64,20 @@ struct __copy_impl {
6364 __iterator_pair<_InIter, _Sent>,
6465 __single_iterator<_OutIter> >::__has_algorithm,
6566 int> = 0>
66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static pair<_InIter, _OutIter>
67 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __in_out_result<_InIter, _OutIter>
6768 operator()(_InIter __first, _Sent __last, _OutIter __result) {
6869 return __specialized_algorithm<_Algorithm::__copy, __iterator_pair<_InIter, _Sent>, __single_iterator<_OutIter> >()(
6970 std::move(__first), std::move(__last), std::move(__result));
7071 }
7172
7273 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0>
73 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
74 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
7475 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
7576 using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator;
7677 std::__for_each_segment(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) {
77 __result = std::__copy(std::move(__lfirst), std::move(__llast), std::move(__result)).second;
78 __result = std::__copy(std::move(__lfirst), std::move(__llast), std::move(__result)).__out_;
7879 });
79 return std::make_pair(__last, std::move(__result));
80 return {__last, std::move(__result)};
8081 }
8182
8283 template <class _InIter,
......@@ -84,14 +85,14 @@ struct __copy_impl {
8485 __enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
8586 !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>,
8687 int> = 0>
87 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
88 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
8889 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
8990 using _Traits = __segmented_iterator_traits<_OutIter>;
9091 using _DiffT =
9192 typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type;
9293
9394 if (__first == __last)
94 return std::make_pair(std::move(__first), std::move(__result));
95 return {std::move(__first), std::move(__result)};
9596
9697 auto __local_first = _Traits::__local(__result);
9798 auto __segment_iterator = _Traits::__segment(__result);
......@@ -99,10 +100,10 @@ struct __copy_impl {
99100 auto __local_last = _Traits::__end(__segment_iterator);
100101 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
101102 auto __iters = std::__copy(__first, __first + __size, __local_first);
102 __first = std::move(__iters.first);
103 __first = std::move(__iters.__in_);
103104
104105 if (__first == __last)
105 return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
106 return {std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.__out_))};
106107
107108 __local_first = _Traits::__begin(++__segment_iterator);
108109 }
......@@ -110,14 +111,14 @@ struct __copy_impl {
110111
111112 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
112113 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
113 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
114115 operator()(_In* __first, _In* __last, _Out* __result) const {
115116 return std::__copy_trivial_impl(__first, __last, __result);
116117 }
117118};
118119
119120template <class _InIter, class _Sent, class _OutIter>
120pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
121__in_out_result<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
121122__copy(_InIter __first, _Sent __last, _OutIter __result) {
122123 return std::__copy_move_unwrap_iters<__copy_impl>(std::move(__first), std::move(__last), std::move(__result));
123124}
......@@ -125,7 +126,7 @@ __copy(_InIter __first, _Sent __last, _OutIter __result) {
125126template <class _InputIterator, class _OutputIterator>
126127_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
127128copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
128 return std::__copy(__first, __last, __result).second;
129 return std::__copy(__first, __last, __result).__out_;
129130}
130131
131132_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_backward.h+18-17
......@@ -12,6 +12,7 @@
1212#include <__algorithm/copy_move_common.h>
1313#include <__algorithm/copy_n.h>
1414#include <__algorithm/for_each_segment.h>
15#include <__algorithm/in_out_result.h>
1516#include <__algorithm/iterator_operations.h>
1617#include <__algorithm/min.h>
1718#include <__config>
......@@ -23,7 +24,6 @@
2324#include <__type_traits/enable_if.h>
2425#include <__type_traits/is_constructible.h>
2526#include <__utility/move.h>
26#include <__utility/pair.h>
2727
2828#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2929# pragma GCC system_header
......@@ -35,7 +35,7 @@ _LIBCPP_PUSH_MACROS
3535_LIBCPP_BEGIN_NAMESPACE_STD
3636
3737template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_InIter, _OutIter>
3939__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
4040
4141template <class _Cp, bool _IsConst>
......@@ -159,7 +159,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __bit_iterator<_Cp, false> _
159159template <class _AlgPolicy>
160160struct __copy_backward_impl {
161161 template <class _InIter, class _Sent, class _OutIter>
162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
163163 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
164164 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
165165 auto __original_last_iter = __last_iter;
......@@ -168,17 +168,17 @@ struct __copy_backward_impl {
168168 *--__result = *--__last_iter;
169169 }
170170
171 return std::make_pair(std::move(__original_last_iter), std::move(__result));
171 return {std::move(__original_last_iter), std::move(__result)};
172172 }
173173
174174 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0>
175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
176176 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
177177 using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator;
178178 std::__for_each_segment_backward(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) {
179 __result = std::__copy_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).second;
179 __result = std::__copy_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).__out_;
180180 });
181 return std::make_pair(__last, std::move(__result));
181 return {__last, std::move(__result)};
182182 }
183183
184184 template <class _InIter,
......@@ -186,7 +186,7 @@ struct __copy_backward_impl {
186186 __enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
187187 !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>,
188188 int> = 0>
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
190190 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
191191 using _Traits = __segmented_iterator_traits<_OutIter>;
192192 auto __orig_last = __last;
......@@ -194,7 +194,7 @@ struct __copy_backward_impl {
194194
195195 // When the range contains no elements, __result might not be a valid iterator
196196 if (__first == __last)
197 return std::make_pair(__first, __result);
197 return {__first, __result};
198198
199199 auto __local_last = _Traits::__local(__result);
200200 while (true) {
......@@ -203,36 +203,37 @@ struct __copy_backward_impl {
203203
204204 auto __local_first = _Traits::__begin(__segment_iterator);
205205 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
206 auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
206 auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).__out_;
207207 __last -= __size;
208208
209209 if (__first == __last)
210 return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
210 return {std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter))};
211211 --__segment_iterator;
212212 __local_last = _Traits::__end(__segment_iterator);
213213 }
214214 }
215215
216216 template <class _Cp, bool _IsConst>
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
217 _LIBCPP_HIDE_FROM_ABI
218 _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
218219 operator()(__bit_iterator<_Cp, _IsConst> __first,
219220 __bit_iterator<_Cp, _IsConst> __last,
220221 __bit_iterator<_Cp, false> __result) {
221222 if (__last.__ctz_ == __result.__ctz_)
222 return std::make_pair(__last, std::__copy_backward_aligned(__first, __last, __result));
223 return std::make_pair(__last, std::__copy_backward_unaligned(__first, __last, __result));
223 return {__last, std::__copy_backward_aligned(__first, __last, __result)};
224 return {__last, std::__copy_backward_unaligned(__first, __last, __result)};
224225 }
225226
226227 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
227228 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
228 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
229230 operator()(_In* __first, _In* __last, _Out* __result) const {
230231 return std::__copy_backward_trivial_impl(__first, __last, __result);
231232 }
232233};
233234
234235template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
235_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
236_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_BidirectionalIterator1, _BidirectionalIterator2>
236237__copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
237238 return std::__copy_move_unwrap_iters<__copy_backward_impl<_AlgPolicy> >(
238239 std::move(__first), std::move(__last), std::move(__result));
......@@ -245,7 +246,7 @@ copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _
245246 std::is_copy_constructible<_BidirectionalIterator1>::value,
246247 "Iterators must be copy constructible.");
247248
248 return std::__copy_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
249 return std::__copy_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).__out_;
249250}
250251
251252_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_if.h+4-3
......@@ -9,6 +9,7 @@
99#ifndef _LIBCPP___ALGORITHM_COPY_IF_H
1010#define _LIBCPP___ALGORITHM_COPY_IF_H
1111
12#include <__algorithm/in_out_result.h>
1213#include <__config>
1314#include <__functional/identity.h>
1415#include <__type_traits/invoke.h>
......@@ -25,7 +26,7 @@ _LIBCPP_PUSH_MACROS
2526_LIBCPP_BEGIN_NAMESPACE_STD
2627
2728template <class _InIter, class _Sent, class _OutIter, class _Proj, class _Pred>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
2930__copy_if(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj& __proj) {
3031 for (; __first != __last; ++__first) {
3132 if (std::__invoke(__pred, std::__invoke(__proj, *__first))) {
......@@ -33,14 +34,14 @@ __copy_if(_InIter __first, _Sent __last, _OutIter __result, _Pred& __pred, _Proj
3334 ++__result;
3435 }
3536 }
36 return std::make_pair(std::move(__first), std::move(__result));
37 return {std::move(__first), std::move(__result)};
3738}
3839
3940template <class _InputIterator, class _OutputIterator, class _Predicate>
4041inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
4142copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) {
4243 __identity __proj;
43 return std::__copy_if(__first, __last, __result, __pred, __proj).second;
44 return std::__copy_if(__first, __last, __result, __pred, __proj).__out_;
4445}
4546
4647_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/copy_move_common.h+9-12
......@@ -9,21 +9,18 @@
99#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1010#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H
1111
12#include <__algorithm/in_out_result.h>
1213#include <__algorithm/unwrap_iter.h>
1314#include <__algorithm/unwrap_range.h>
1415#include <__config>
1516#include <__cstddef/size_t.h>
16#include <__iterator/iterator_traits.h>
17#include <__memory/pointer_traits.h>
1817#include <__string/constexpr_c_functions.h>
1918#include <__type_traits/enable_if.h>
2019#include <__type_traits/is_always_bitcastable.h>
21#include <__type_traits/is_constant_evaluated.h>
2220#include <__type_traits/is_constructible.h>
2321#include <__type_traits/is_trivially_assignable.h>
2422#include <__type_traits/is_volatile.h>
2523#include <__utility/move.h>
26#include <__utility/pair.h>
2724
2825#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2926# pragma GCC system_header
......@@ -57,24 +54,24 @@ struct __can_lower_move_assignment_to_memmove {
5754// `memmove` algorithms implementation.
5855
5956template <class _In, class _Out>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
57_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
6158__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) {
6259 const size_t __n = static_cast<size_t>(__last - __first);
6360
6461 std::__constexpr_memmove(__result, __first, __element_count(__n));
6562
66 return std::make_pair(__last, __result + __n);
63 return {__last, __result + __n};
6764}
6865
6966template <class _In, class _Out>
70_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
7168__copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) {
7269 const size_t __n = static_cast<size_t>(__last - __first);
7370 __result -= __n;
7471
7572 std::__constexpr_memmove(__result, __first, __element_count(__n));
7673
77 return std::make_pair(__last, __result);
74 return {__last, __result};
7875}
7976
8077// Iterator unwrapping and dispatching to the correct overload.
......@@ -88,12 +85,12 @@ template <class _Algorithm,
8885 class _Sent,
8986 class _OutIter,
9087 __enable_if_t<__can_rewrap<_InIter, _OutIter>::value, int> = 0>
91_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
88_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __in_out_result<_InIter, _OutIter>
9289__copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) {
9390 auto __range = std::__unwrap_range(__first, std::move(__last));
9491 auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
95 return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
96 std::__rewrap_iter(std::move(__out_first), std::move(__result.second)));
92 return {std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.__in_)),
93 std::__rewrap_iter(std::move(__out_first), std::move(__result.__out_))};
9794}
9895
9996template <class _Algorithm,
......@@ -101,7 +98,7 @@ template <class _Algorithm,
10198 class _Sent,
10299 class _OutIter,
103100 __enable_if_t<!__can_rewrap<_InIter, _OutIter>::value, int> = 0>
104_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
101_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 __in_out_result<_InIter, _OutIter>
105102__copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) {
106103 return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
107104}
lib/libcxx/include/__algorithm/copy_n.h+5-5
......@@ -10,13 +10,13 @@
1010#define _LIBCPP___ALGORITHM_COPY_N_H
1111
1212#include <__algorithm/copy.h>
13#include <__algorithm/in_out_result.h>
1314#include <__algorithm/iterator_operations.h>
1415#include <__config>
1516#include <__iterator/iterator_traits.h>
1617#include <__type_traits/enable_if.h>
1718#include <__utility/convert_to_integral.h>
1819#include <__utility/move.h>
19#include <__utility/pair.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2222# pragma GCC system_header
......@@ -31,7 +31,7 @@ template <class _AlgPolicy,
3131 class _InIter,
3232 class _OutIter,
3333 __enable_if_t<__has_random_access_iterator_category<_InIter>::value, int> = 0>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_InIter, _OutIter>
3535__copy_n(_InIter __first, typename _IterOps<_AlgPolicy>::template __difference_type<_InIter> __n, _OutIter __result) {
3636 return std::__copy(__first, __first + __n, std::move(__result));
3737}
......@@ -40,7 +40,7 @@ template <class _AlgPolicy,
4040 class _InIter,
4141 class _OutIter,
4242 __enable_if_t<!__has_random_access_iterator_category<_InIter>::value, int> = 0>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_InIter, _OutIter>
4444__copy_n(_InIter __first, typename _IterOps<_AlgPolicy>::template __difference_type<_InIter> __n, _OutIter __result) {
4545 while (__n != 0) {
4646 *__result = *__first;
......@@ -48,7 +48,7 @@ __copy_n(_InIter __first, typename _IterOps<_AlgPolicy>::template __difference_t
4848 ++__result;
4949 --__n;
5050 }
51 return std::make_pair(std::move(__first), std::move(__result));
51 return {std::move(__first), std::move(__result)};
5252}
5353
5454// The InputIterator case is handled specially here because it's been written in a way to avoid incrementing __first
......@@ -84,7 +84,7 @@ copy_n(_InputIterator __first, _Size __n, _OutputIterator __result) {
8484 using _IntegralSize = decltype(std::__convert_to_integral(__n));
8585 _IntegralSize __converted = __n;
8686 return std::__copy_n<_ClassicAlgPolicy>(__first, __iterator_difference_type<_InputIterator>(__converted), __result)
87 .second;
87 .__out_;
8888}
8989
9090_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/equal.h+58-13
......@@ -11,15 +11,16 @@
1111#define _LIBCPP___ALGORITHM_EQUAL_H
1212
1313#include <__algorithm/comp.h>
14#include <__algorithm/find_segment_if.h>
1415#include <__algorithm/min.h>
1516#include <__algorithm/unwrap_iter.h>
1617#include <__config>
1718#include <__functional/identity.h>
1819#include <__fwd/bit_reference.h>
19#include <__iterator/distance.h>
2020#include <__iterator/iterator_traits.h>
21#include <__memory/pointer_traits.h>
21#include <__iterator/segmented_iterator.h>
2222#include <__string/constexpr_c_functions.h>
23#include <__type_traits/common_type.h>
2324#include <__type_traits/desugars_to.h>
2425#include <__type_traits/enable_if.h>
2526#include <__type_traits/invoke.h>
......@@ -27,6 +28,7 @@
2728#include <__type_traits/is_same.h>
2829#include <__type_traits/is_volatile.h>
2930#include <__utility/move.h>
31#include <__utility/unreachable.h>
3032
3133#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3234# pragma GCC system_header
......@@ -177,15 +179,6 @@ template <class _Cp,
177179 return std::__equal_unaligned(__first1, __last1, __first2);
178180}
179181
180template <class _InIter1, class _Sent1, class _InIter2, class _Pred, class _Proj1, class _Proj2>
181[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(
182 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
183 for (; __first1 != __last1; ++__first1, (void)++__first2)
184 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
185 return false;
186 return true;
187}
188
189182template <class _Tp,
190183 class _Up,
191184 class _BinaryPredicate,
......@@ -200,6 +193,58 @@ __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&,
200193 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
201194}
202195
196template <class _InIter1, class _Sent1, class _InIter2, class _Pred, class _Proj1, class _Proj2>
197[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_iter_impl(
198 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
199#ifndef _LIBCPP_CXX03_LANG
200 if constexpr (__has_random_access_iterator_category<_InIter1>::value &&
201 __has_random_access_iterator_category<_InIter2>::value) {
202 if constexpr (is_same<_InIter1, _Sent1>::value && __is_segmented_iterator_v<_InIter1>) {
203 using __local_iterator_t = typename __segmented_iterator_traits<_InIter1>::__local_iterator;
204 bool __is_equal = true;
205 std::__find_segment_if(__first1, __last1, [&](__local_iterator_t __lfirst, __local_iterator_t __llast) {
206 if (std::__equal_iter_impl(
207 std::__unwrap_iter(__lfirst), std::__unwrap_iter(__llast), __first2, __pred, __proj1, __proj2)) {
208 __first2 += __llast - __lfirst;
209 return __llast;
210 }
211 __is_equal = false;
212 return __lfirst;
213 });
214 return __is_equal;
215 } else if constexpr (__is_segmented_iterator_v<_InIter2>) {
216 using _Traits = __segmented_iterator_traits<_InIter2>;
217 using _DiffT =
218 typename common_type<__iterator_difference_type<_InIter1>, __iterator_difference_type<_InIter2> >::type;
219
220 if (__first1 == __last1)
221 return true;
222
223 auto __local_first = _Traits::__local(__first2);
224 auto __segment_iterator = _Traits::__segment(__first2);
225
226 while (true) {
227 auto __local_last = _Traits::__end(__segment_iterator);
228 auto __size = std::min<_DiffT>(__local_last - __local_first, __last1 - __first1);
229 if (!std::__equal_iter_impl(
230 __first1, __first1 + __size, std::__unwrap_iter(__local_first), __pred, __proj1, __proj2))
231 return false;
232
233 __first1 += __size;
234 if (__first1 == __last1)
235 return true;
236
237 __local_first = _Traits::__begin(++__segment_iterator);
238 }
239 }
240 }
241#endif
242 for (; __first1 != __last1; ++__first1, (void)++__first2)
243 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
244 return false;
245 return true;
246}
247
203248template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
204249[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
205250equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
......@@ -247,11 +292,11 @@ equal(_InputIterator1 __first1,
247292 _InputIterator2 __first2,
248293 _InputIterator2 __last2,
249294 _BinaryPredicate __pred) {
250 static constexpr bool __both_random_access =
295 constexpr bool __both_random_access =
251296 __has_random_access_iterator_category<_InputIterator1>::value &&
252297 __has_random_access_iterator_category<_InputIterator2>::value;
253298 if constexpr (__both_random_access) {
254 if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
299 if (__last1 - __first1 != __last2 - __first2)
255300 return false;
256301 }
257302 __identity __proj;
lib/libcxx/include/__algorithm/find.h+13-14
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___ALGORITHM_FIND_H
1111#define _LIBCPP___ALGORITHM_FIND_H
1212
13#include <__algorithm/find_if.h>
1314#include <__algorithm/find_segment_if.h>
1415#include <__algorithm/min.h>
1516#include <__algorithm/simd_utils.h>
......@@ -47,17 +48,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4748// generic implementation
4849template <class _Iter, class _Sent, class _Tp, class _Proj>
4950_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
50__find_loop(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
51 for (; __first != __last; ++__first)
52 if (std::__invoke(__proj, *__first) == __value)
53 break;
54 return __first;
51__find_generic(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
52 return std::__find_if(
53 std::move(__first),
54 std::move(__last),
55 [&]<class _ValT>(_ValT&& __val) -> bool { return __val == __value; },
56 __proj);
5557}
5658
5759template <class _Iter, class _Sent, class _Tp, class _Proj>
5860_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
5961__find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
60 return std::__find_loop(std::move(__first), std::move(__last), __value, __proj);
62 return std::__find_generic(std::move(__first), std::move(__last), __value, __proj);
6163}
6264
6365#if _LIBCPP_VECTORIZE_ALGORITHMS
......@@ -108,7 +110,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find_vectorized(_Tp* __first, _Tp* __last,
108110 }
109111
110112 __identity __proj;
111 return std::__find_loop(__first, __last, __value, __proj);
113 return std::__find_generic(__first, __last, __value, __proj);
112114}
113115#endif
114116
......@@ -138,7 +140,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _T
138140# endif
139141 else {
140142 __identity __proj;
141 return std::__find_loop(__first, __last, __value, __proj);
143 return std::__find_generic(__first, __last, __value, __proj);
142144 }
143145}
144146#endif
......@@ -216,13 +218,10 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
216218__find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) {
217219 using __local_iterator = typename __segmented_iterator_traits<_SegmentedIterator>::__local_iterator;
218220 return std::__find_segment_if(
219 std::move(__first),
220 std::move(__last),
221 [&__value](__local_iterator __lfirst, __local_iterator __llast, _Proj& __lproj) {
221 std::move(__first), std::move(__last), [&__value, &__proj](__local_iterator __lfirst, __local_iterator __llast) {
222222 return std::__rewrap_iter(
223 __lfirst, std::__find(std::__unwrap_iter(__lfirst), std::__unwrap_iter(__llast), __value, __lproj));
224 },
225 __proj);
223 __lfirst, std::__find(std::__unwrap_iter(__lfirst), std::__unwrap_iter(__llast), __value, __proj));
224 });
226225}
227226
228227// public API
lib/libcxx/include/__algorithm/find_if.h+15-4
......@@ -11,6 +11,9 @@
1111#define _LIBCPP___ALGORITHM_FIND_IF_H
1212
1313#include <__config>
14#include <__functional/identity.h>
15#include <__memory/valid_range.h>
16#include <__type_traits/invoke.h>
1417
1518#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1619# pragma GCC system_header
......@@ -18,15 +21,23 @@
1821
1922_LIBCPP_BEGIN_NAMESPACE_STD
2023
21template <class _InputIterator, class _Predicate>
22[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
23find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24template <class _Iter, class _Sent, class _Pred, class _Proj>
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter
26__find_if(_Iter __first, _Sent __last, _Pred&& __pred, _Proj&& __proj) {
27 std::__assume_valid_range(__first, __last);
28
2429 for (; __first != __last; ++__first)
25 if (__pred(*__first))
30 if (std::__invoke(__pred, std::__invoke(__proj, *__first)))
2631 break;
2732 return __first;
2833}
2934
35template <class _InputIterator, class _Predicate>
36[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
37find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
38 return std::__find_if(__first, __last, __pred, __identity());
39}
40
3041_LIBCPP_END_NAMESPACE_STD
3142
3243#endif // _LIBCPP___ALGORITHM_FIND_IF_H
lib/libcxx/include/__algorithm/find_if_not.h+20-4
......@@ -10,23 +10,39 @@
1010#ifndef _LIBCPP___ALGORITHM_FIND_IF_NOT_H
1111#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H
1212
13#include <__algorithm/find_if.h>
1314#include <__config>
15#include <__functional/identity.h>
16#include <__type_traits/invoke.h>
17#include <__utility/move.h>
1418
1519#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1620# pragma GCC system_header
1721#endif
1822
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
1926_LIBCPP_BEGIN_NAMESPACE_STD
2027
28template <class _Iter, class _Sent, class _Pred, class _Proj>
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30__find_if_not(_Iter __first, _Sent __last, _Pred&& __pred, _Proj&& __proj) {
31 return std::__find_if(
32 std::move(__first),
33 std::move(__last),
34 [&]<class _ValT>(_ValT&& __val) -> bool { return !std::__invoke(__pred, __val); },
35 __proj);
36}
37
2138template <class _InputIterator, class _Predicate>
2239[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2340find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24 for (; __first != __last; ++__first)
25 if (!__pred(*__first))
26 break;
27 return __first;
41 return std::__find_if_not(__first, __last, __pred, __identity());
2842}
2943
3044_LIBCPP_END_NAMESPACE_STD
3145
46_LIBCPP_POP_MACROS
47
3248#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H
lib/libcxx/include/__algorithm/find_segment_if.h+8-9
......@@ -19,14 +19,13 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121// __find_segment_if is a utility function for optimizing iteration over segmented iterators linearly.
22// [__first, __last) has to be a segmented range. __pred is expected to take a range of local iterators and the __proj.
22// [__first, __last) has to be a segmented range. __pred is expected to take a range of local iterators.
2323// It returns an iterator to the first element that satisfies the predicate, or a one-past-the-end iterator if there was
24// no match. __proj may be anything that should be passed to __pred, but is expected to be a projection to support
25// ranges algorithms, or __identity for classic algorithms.
24// no match.
2625
27template <class _SegmentedIterator, class _Pred, class _Proj>
26template <class _SegmentedIterator, class _Pred>
2827_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
29__find_segment_if(_SegmentedIterator __first, _SegmentedIterator __last, _Pred __pred, _Proj& __proj) {
28__find_segment_if(_SegmentedIterator __first, _SegmentedIterator __last, _Pred __pred) {
3029 using _Traits = __segmented_iterator_traits<_SegmentedIterator>;
3130
3231 auto __sfirst = _Traits::__segment(__first);
......@@ -34,11 +33,11 @@ __find_segment_if(_SegmentedIterator __first, _SegmentedIterator __last, _Pred _
3433
3534 // We are in a single segment, so we might not be at the beginning or end
3635 if (__sfirst == __slast)
37 return _Traits::__compose(__sfirst, __pred(_Traits::__local(__first), _Traits::__local(__last), __proj));
36 return _Traits::__compose(__sfirst, __pred(_Traits::__local(__first), _Traits::__local(__last)));
3837
3938 { // We have more than one segment. Iterate over the first segment, since we might not start at the beginning
4039 auto __llast = _Traits::__end(__sfirst);
41 auto __liter = __pred(_Traits::__local(__first), __llast, __proj);
40 auto __liter = __pred(_Traits::__local(__first), __llast);
4241 if (__liter != __llast)
4342 return _Traits::__compose(__sfirst, __liter);
4443 }
......@@ -47,14 +46,14 @@ __find_segment_if(_SegmentedIterator __first, _SegmentedIterator __last, _Pred _
4746 // Iterate over the segments which are guaranteed to be completely in the range
4847 while (__sfirst != __slast) {
4948 auto __llast = _Traits::__end(__sfirst);
50 auto __liter = __pred(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), __proj);
49 auto __liter = __pred(_Traits::__begin(__sfirst), _Traits::__end(__sfirst));
5150 if (__liter != __llast)
5251 return _Traits::__compose(__sfirst, __liter);
5352 ++__sfirst;
5453 }
5554
5655 // Iterate over the last segment
57 return _Traits::__compose(__sfirst, __pred(_Traits::__begin(__sfirst), _Traits::__local(__last), __proj));
56 return _Traits::__compose(__sfirst, __pred(_Traits::__begin(__sfirst), _Traits::__local(__last)));
5857}
5958
6059_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/for_each.h+1-1
......@@ -26,7 +26,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _InputIterator, class _Sent, class _Func, class _Proj>
2828_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
29__for_each(_InputIterator __first, _Sent __last, _Func& __func, _Proj& __proj) {
29__for_each(_InputIterator __first, _Sent __last, _Func&& __func, _Proj& __proj) {
3030#ifndef _LIBCPP_CXX03_LANG
3131 if constexpr (using _SpecialAlg =
3232 __specialized_algorithm<_Algorithm::__for_each, __iterator_pair<_InputIterator, _Sent>>;
lib/libcxx/include/__algorithm/for_each_n.h+3-2
......@@ -18,6 +18,7 @@
1818#include <__iterator/segmented_iterator.h>
1919#include <__type_traits/invoke.h>
2020#include <__utility/convert_to_integral.h>
21#include <__utility/forward.h>
2122#include <__utility/move.h>
2223
2324#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -31,7 +32,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3132
3233template <class _InputIterator, class _Size, class _Func, class _Proj>
3334_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
34__for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj) {
35__for_each_n(_InputIterator __first, _Size __orig_n, _Func&& __f, _Proj& __proj) {
3536 typedef decltype(std::__convert_to_integral(__orig_n)) _IntegralSize;
3637 _IntegralSize __n = __orig_n;
3738
......@@ -43,7 +44,7 @@ __for_each_n(_InputIterator __first, _Size __orig_n, _Func& __f, _Proj& __proj)
4344 std::__for_each(__lfirst, __llast, __f, __proj);
4445 });
4546 } else {
46 return std::__for_each(__first, __first + __n, __f, __proj);
47 return std::__for_each(__first, __first + __n, std::forward<_Func>(__f), __proj);
4748 }
4849 } else
4950#endif
lib/libcxx/include/__algorithm/generate_n.h+5-2
......@@ -29,8 +29,11 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
2929__generate_n(_OutputIterator __first, _Size __orig_n, _Generator& __gen) {
3030 using __iter_ref = decltype(*__first);
3131 __identity __proj;
32 auto __f = [&](__iter_ref __element) { std::forward<__iter_ref>(__element) = __gen(); };
33 return std::__for_each_n(std::move(__first), __orig_n, __f, __proj);
32 return std::__for_each_n(
33 std::move(__first),
34 __orig_n,
35 [&](__iter_ref __element) { std::forward<__iter_ref>(__element) = __gen(); },
36 __proj);
3437}
3538
3639template <class _OutputIterator, class _Size, class _Generator>
lib/libcxx/include/__algorithm/in_out_result.h+14
......@@ -49,6 +49,20 @@ struct in_out_result {
4949
5050#endif // _LIBCPP_STD_VER >= 20
5151
52template <class _InIter, class _OutIter>
53struct __in_out_result {
54 _InIter __in_;
55 _OutIter __out_;
56
57#if _LIBCPP_STD_VER >= 20
58 template <class _InIter2, class _OutIter2>
59 requires convertible_to<_InIter, _InIter2> && convertible_to<_OutIter, _OutIter2>
60 constexpr operator ranges::in_out_result<_InIter2, _OutIter2>() && {
61 return {std::move(__in_), std::move(__out_)};
62 }
63#endif
64};
65
5266_LIBCPP_END_NAMESPACE_STD
5367
5468_LIBCPP_POP_MACROS
lib/libcxx/include/__algorithm/lexicographical_compare_three_way.h+4-4
......@@ -27,10 +27,10 @@
2727_LIBCPP_PUSH_MACROS
2828#include <__undef_macros>
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230#if _LIBCPP_STD_VER >= 20
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3434// Fast path for random access iterators which computes the number of loop iterations up-front and
3535// then skips the iterator comparisons inside the loop.
3636template <class _InputIterator1, class _InputIterator2, class _Cmp>
......@@ -116,10 +116,10 @@ template <class _InputIterator1, class _InputIterator2>
116116 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::compare_three_way());
117117}
118118
119#endif // _LIBCPP_STD_VER >= 20
120
121119_LIBCPP_END_NAMESPACE_STD
122120
121#endif // _LIBCPP_STD_VER >= 20
122
123123_LIBCPP_POP_MACROS
124124
125125#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_THREE_WAY_H
lib/libcxx/include/__algorithm/lower_bound.h+5-4
......@@ -56,11 +56,11 @@ template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp>
5656// would yield \Omega(n*log(n)) comparisons and, for non-random-access iterators, \Omega(n^2) iterator increments,
5757// whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of
5858// comparisons.
59template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>
59template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Comp>
6060[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
61__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
61__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp) {
6262 // step = 0, ensuring we can always short-circuit when distance is 1 later on
63 if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value))
63 if (__first == __last || !std::__invoke(__comp, *__first, __value))
6464 return __first;
6565
6666 using _Distance = typename iterator_traits<_ForwardIterator>::difference_type;
......@@ -69,11 +69,12 @@ __lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __va
6969 auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to(__it, __step, __last);
7070 // once we reach the last range where needle can be we must start
7171 // looking inwards, bisecting that range
72 if (__it == __last || !std::__invoke(__comp, std::__invoke(__proj, *__it), __value)) {
72 if (__it == __last || !std::__invoke(__comp, *__it, __value)) {
7373 // we've already checked the previous value and it was less, we can save
7474 // one comparison by skipping bisection
7575 if (__dist == 1)
7676 return __it;
77 __identity __proj;
7778 return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);
7879 }
7980 // range not found, move forward!
lib/libcxx/include/__algorithm/move.h+16-15
......@@ -12,6 +12,7 @@
1212#include <__algorithm/copy.h>
1313#include <__algorithm/copy_move_common.h>
1414#include <__algorithm/for_each_segment.h>
15#include <__algorithm/in_out_result.h>
1516#include <__algorithm/iterator_operations.h>
1617#include <__algorithm/min.h>
1718#include <__config>
......@@ -22,7 +23,6 @@
2223#include <__type_traits/enable_if.h>
2324#include <__type_traits/is_constructible.h>
2425#include <__utility/move.h>
25#include <__utility/pair.h>
2626
2727#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2828# pragma GCC system_header
......@@ -34,30 +34,30 @@ _LIBCPP_PUSH_MACROS
3434_LIBCPP_BEGIN_NAMESPACE_STD
3535
3636template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
37inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
37inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
3838__move(_InIter __first, _Sent __last, _OutIter __result);
3939
4040template <class _AlgPolicy>
4141struct __move_impl {
4242 template <class _InIter, class _Sent, class _OutIter>
43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
4444 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
4545 while (__first != __last) {
4646 *__result = _IterOps<_AlgPolicy>::__iter_move(__first);
4747 ++__first;
4848 ++__result;
4949 }
50 return std::make_pair(std::move(__first), std::move(__result));
50 return {std::move(__first), std::move(__result)};
5151 }
5252
5353 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0>
54 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
54 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
5555 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
5656 using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator;
5757 std::__for_each_segment(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) {
58 __result = std::__move<_AlgPolicy>(__lfirst, __llast, std::move(__result)).second;
58 __result = std::__move<_AlgPolicy>(__lfirst, __llast, std::move(__result)).__out_;
5959 });
60 return std::make_pair(__last, std::move(__result));
60 return {__last, std::move(__result)};
6161 }
6262
6363 template <class _InIter,
......@@ -65,14 +65,14 @@ struct __move_impl {
6565 __enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
6666 !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>,
6767 int> = 0>
68 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
68 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
6969 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
7070 using _Traits = __segmented_iterator_traits<_OutIter>;
7171 using _DiffT =
7272 typename common_type<__iterator_difference_type<_InIter>, __iterator_difference_type<_OutIter> >::type;
7373
7474 if (__first == __last)
75 return std::make_pair(std::move(__first), std::move(__result));
75 return {std::move(__first), std::move(__result)};
7676
7777 auto __local_first = _Traits::__local(__result);
7878 auto __segment_iterator = _Traits::__segment(__result);
......@@ -80,17 +80,18 @@ struct __move_impl {
8080 auto __local_last = _Traits::__end(__segment_iterator);
8181 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
8282 auto __iters = std::__move<_AlgPolicy>(__first, __first + __size, __local_first);
83 __first = std::move(__iters.first);
83 __first = std::move(__iters.__in_);
8484
8585 if (__first == __last)
86 return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second)));
86 return {std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.__out_))};
8787
8888 __local_first = _Traits::__begin(++__segment_iterator);
8989 }
9090 }
9191
9292 template <class _Cp, bool _IsConst>
93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
93 _LIBCPP_HIDE_FROM_ABI
94 _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
9495 operator()(__bit_iterator<_Cp, _IsConst> __first,
9596 __bit_iterator<_Cp, _IsConst> __last,
9697 __bit_iterator<_Cp, false> __result) {
......@@ -99,14 +100,14 @@ struct __move_impl {
99100
100101 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
101102 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
102 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
103104 operator()(_In* __first, _In* __last, _Out* __result) const {
104105 return std::__copy_trivial_impl(__first, __last, __result);
105106 }
106107};
107108
108109template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
109inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
110inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
110111__move(_InIter __first, _Sent __last, _OutIter __result) {
111112 return std::__copy_move_unwrap_iters<__move_impl<_AlgPolicy> >(
112113 std::move(__first), std::move(__last), std::move(__result));
......@@ -118,7 +119,7 @@ move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
118119 static_assert(is_copy_constructible<_InputIterator>::value, "Iterators has to be copy constructible.");
119120 static_assert(is_copy_constructible<_OutputIterator>::value, "The output iterator has to be copy constructible.");
120121
121 return std::__move<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
122 return std::__move<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).__out_;
122123}
123124
124125_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/move_backward.h+16-14
......@@ -12,6 +12,7 @@
1212#include <__algorithm/copy_backward.h>
1313#include <__algorithm/copy_move_common.h>
1414#include <__algorithm/for_each_segment.h>
15#include <__algorithm/in_out_result.h>
1516#include <__algorithm/iterator_operations.h>
1617#include <__algorithm/min.h>
1718#include <__config>
......@@ -34,13 +35,13 @@ _LIBCPP_PUSH_MACROS
3435_LIBCPP_BEGIN_NAMESPACE_STD
3536
3637template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_BidirectionalIterator1, _BidirectionalIterator2>
3839__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result);
3940
4041template <class _AlgPolicy>
4142struct __move_backward_impl {
4243 template <class _InIter, class _Sent, class _OutIter>
43 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
4445 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
4546 auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last);
4647 auto __original_last_iter = __last_iter;
......@@ -49,17 +50,17 @@ struct __move_backward_impl {
4950 *--__result = _IterOps<_AlgPolicy>::__iter_move(--__last_iter);
5051 }
5152
52 return std::make_pair(std::move(__original_last_iter), std::move(__result));
53 return {std::move(__original_last_iter), std::move(__result)};
5354 }
5455
5556 template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator_v<_InIter>, int> = 0>
56 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
57 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
5758 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
5859 using __local_iterator = typename __segmented_iterator_traits<_InIter>::__local_iterator;
5960 std::__for_each_segment_backward(__first, __last, [&__result](__local_iterator __lfirst, __local_iterator __llast) {
60 __result = std::__move_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).second;
61 __result = std::__move_backward<_AlgPolicy>(std::move(__lfirst), std::move(__llast), std::move(__result)).__out_;
6162 });
62 return std::make_pair(__last, std::move(__result));
63 return {__last, std::move(__result)};
6364 }
6465
6566 template <class _InIter,
......@@ -67,7 +68,7 @@ struct __move_backward_impl {
6768 __enable_if_t<__has_random_access_iterator_category<_InIter>::value &&
6869 !__is_segmented_iterator_v<_InIter> && __is_segmented_iterator_v<_OutIter>,
6970 int> = 0>
70 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
71 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_InIter, _OutIter>
7172 operator()(_InIter __first, _InIter __last, _OutIter __result) const {
7273 using _Traits = __segmented_iterator_traits<_OutIter>;
7374 using _DiffT =
......@@ -75,7 +76,7 @@ struct __move_backward_impl {
7576
7677 // When the range contains no elements, __result might not be a valid iterator
7778 if (__first == __last)
78 return std::make_pair(__first, __result);
79 return {__first, __result};
7980
8081 auto __orig_last = __last;
8182
......@@ -84,18 +85,19 @@ struct __move_backward_impl {
8485 while (true) {
8586 auto __local_first = _Traits::__begin(__segment_iterator);
8687 auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first);
87 auto __iter = std::__move_backward<_AlgPolicy>(__last - __size, __last, __local_last).second;
88 auto __iter = std::__move_backward<_AlgPolicy>(__last - __size, __last, __local_last).__out_;
8889 __last -= __size;
8990
9091 if (__first == __last)
91 return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter)));
92 return {std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter))};
9293
9394 __local_last = _Traits::__end(--__segment_iterator);
9495 }
9596 }
9697
9798 template <class _Cp, bool _IsConst>
98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
99 _LIBCPP_HIDE_FROM_ABI
100 _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
99101 operator()(__bit_iterator<_Cp, _IsConst> __first,
100102 __bit_iterator<_Cp, _IsConst> __last,
101103 __bit_iterator<_Cp, false> __result) {
......@@ -104,14 +106,14 @@ struct __move_backward_impl {
104106
105107 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
106108 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
109 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __in_out_result<_In*, _Out*>
108110 operator()(_In* __first, _In* __last, _Out* __result) const {
109111 return std::__copy_backward_trivial_impl(__first, __last, __result);
110112 }
111113};
112114
113115template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
114_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
116_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_BidirectionalIterator1, _BidirectionalIterator2>
115117__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
116118 static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value &&
117119 std::is_copy_constructible<_BidirectionalIterator1>::value,
......@@ -124,7 +126,7 @@ __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _Bidirectiona
124126template <class _BidirectionalIterator1, class _BidirectionalIterator2>
125127inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _BidirectionalIterator2
126128move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, _BidirectionalIterator2 __result) {
127 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).second;
129 return std::__move_backward<_ClassicAlgPolicy>(std::move(__first), std::move(__last), std::move(__result)).__out_;
128130}
129131
130132_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/out_value_result.h+4-4
......@@ -21,10 +21,10 @@
2121_LIBCPP_PUSH_MACROS
2222#include <__undef_macros>
2323
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2624#if _LIBCPP_STD_VER >= 23
2725
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2828namespace ranges {
2929
3030template <class _OutIter1, class _ValType1>
......@@ -47,10 +47,10 @@ struct out_value_result {
4747
4848} // namespace ranges
4949
50#endif // _LIBCPP_STD_VER >= 23
51
5250_LIBCPP_END_NAMESPACE_STD
5351
52#endif // _LIBCPP_STD_VER >= 23
53
5454_LIBCPP_POP_MACROS
5555
5656#endif // _LIBCPP___ALGORITHM_OUT_VALUE_RESULT_H
lib/libcxx/include/__algorithm/partial_sort_copy.h+5-4
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
14#include <__algorithm/in_out_result.h>
1415#include <__algorithm/iterator_operations.h>
1516#include <__algorithm/make_heap.h>
1617#include <__algorithm/make_projected.h>
......@@ -41,7 +42,8 @@ template <class _AlgPolicy,
4142 class _Sentinel2,
4243 class _Proj1,
4344 class _Proj2>
44_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _RandomAccessIterator> __partial_sort_copy(
45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<_InputIterator, _RandomAccessIterator>
46__partial_sort_copy(
4547 _InputIterator __first,
4648 _Sentinel1 __last,
4749 _RandomAccessIterator __result_first,
......@@ -65,8 +67,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator, _Random
6567 std::__sort_heap<_AlgPolicy>(__result_first, __r, __projected_comp);
6668 }
6769
68 return pair<_InputIterator, _RandomAccessIterator>(
69 _IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r));
70 return {_IterOps<_AlgPolicy>::next(std::move(__first), std::move(__last)), std::move(__r)};
7071}
7172
7273template <class _InputIterator, class _RandomAccessIterator, class _Compare>
......@@ -87,7 +88,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
8788 static_cast<__comp_ref_type<_Compare> >(__comp),
8889 __identity(),
8990 __identity());
90 return __result.second;
91 return __result.__out_;
9192}
9293
9394template <class _InputIterator, class _RandomAccessIterator>
lib/libcxx/include/__algorithm/pstl.h+90
......@@ -293,6 +293,54 @@ find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __l
293293 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
294294}
295295
296template <class _ExecutionPolicy,
297 class _ForwardIterator1,
298 class _ForwardIterator2,
299 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
300 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
301[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator1 find_first_of(
302 _ExecutionPolicy&& __policy,
303 _ForwardIterator1 __first1,
304 _ForwardIterator1 __last1,
305 _ForwardIterator2 __first2,
306 _ForwardIterator2 __last2) {
307 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "find_first_of requires ForwardIterators");
308 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "find_first_of requires ForwardIterators");
309 using _Implementation = __pstl::__dispatch<__pstl::__find_first_of, __pstl::__current_configuration, _RawPolicy>;
310 return __pstl::__handle_exception<_Implementation>(
311 std::forward<_ExecutionPolicy>(__policy),
312 std::move(__first1),
313 std::move(__last1),
314 std::move(__first2),
315 std::move(__last2),
316 std::equal_to<>{});
317}
318
319template <class _ExecutionPolicy,
320 class _ForwardIterator1,
321 class _ForwardIterator2,
322 class _BinaryPredicate,
323 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
324 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
325[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator1 find_first_of(
326 _ExecutionPolicy&& __policy,
327 _ForwardIterator1 __first1,
328 _ForwardIterator1 __last1,
329 _ForwardIterator2 __first2,
330 _ForwardIterator2 __last2,
331 _BinaryPredicate __pred) {
332 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "find_first_of requires ForwardIterators");
333 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "find_first_of requires ForwardIterators");
334 using _Implementation = __pstl::__dispatch<__pstl::__find_first_of, __pstl::__current_configuration, _RawPolicy>;
335 return __pstl::__handle_exception<_Implementation>(
336 std::forward<_ExecutionPolicy>(__policy),
337 std::move(__first1),
338 std::move(__last1),
339 std::move(__first2),
340 std::move(__last2),
341 std::move(__pred));
342}
343
296344template <class _ExecutionPolicy,
297345 class _ForwardIterator,
298346 class _Function,
......@@ -347,6 +395,23 @@ generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Ge
347395 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__gen));
348396}
349397
398template <class _ExecutionPolicy,
399 class _BidirectionalIterator,
400 class _ForwardIterator,
401 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
402 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
403[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ForwardIterator reverse_copy(
404 _ExecutionPolicy&& __policy,
405 _BidirectionalIterator __first,
406 _BidirectionalIterator __last,
407 _ForwardIterator __result) {
408 _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(_BidirectionalIterator, "reverse_copy requires a BidirectionalIterator");
409 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reverse_copy requires a ForwardIterator");
410 using _Implementation = __pstl::__dispatch<__pstl::__reverse_copy, __pstl::__current_configuration, _RawPolicy>;
411 return __pstl::__handle_exception<_Implementation>(
412 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result));
413}
414
350415template <class _ExecutionPolicy,
351416 class _ForwardIterator,
352417 class _Predicate,
......@@ -654,6 +719,31 @@ _LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
654719 std::move(__op));
655720}
656721
722template <class _ExecutionPolicy,
723 class _ForwardIterator,
724 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
725 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
726[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
727is_sorted(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) {
728 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_sorted requires ForwardIterators");
729 using _Implementation = __pstl::__dispatch<__pstl::__is_sorted, __pstl::__current_configuration, _RawPolicy>;
730 return __pstl::__handle_exception<_Implementation>(
731 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
732}
733
734template <class _ExecutionPolicy,
735 class _ForwardIterator,
736 class _Comp,
737 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
738 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
739[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
740is_sorted(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Comp __comp) {
741 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_sorted requires ForwardIterators");
742 using _Implementation = __pstl::__dispatch<__pstl::__is_sorted, __pstl::__current_configuration, _RawPolicy>;
743 return __pstl::__handle_exception<_Implementation>(
744 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp));
745}
746
657747_LIBCPP_END_NAMESPACE_STD
658748
659749#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
lib/libcxx/include/__algorithm/radix_sort.h+4-4
......@@ -67,10 +67,10 @@
6767_LIBCPP_PUSH_MACROS
6868#include <__undef_macros>
6969
70_LIBCPP_BEGIN_NAMESPACE_STD
71
7270#if _LIBCPP_STD_VER >= 14
7371
72_LIBCPP_BEGIN_NAMESPACE_STD
73
7474template <class _InputIterator, class _OutputIterator>
7575_LIBCPP_HIDE_FROM_ABI constexpr pair<_OutputIterator, __iterator_value_type<_InputIterator>>
7676__partial_sum_max(_InputIterator __first, _InputIterator __last, _OutputIterator __result) {
......@@ -422,10 +422,10 @@ __radix_sort(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _Ran
422422 std::__radix_sort(__first, __last, __buffer, __identity{}, __low_byte_fn{});
423423}
424424
425#endif // _LIBCPP_STD_VER >= 14
426
427425_LIBCPP_END_NAMESPACE_STD
428426
427#endif // _LIBCPP_STD_VER >= 14
428
429429_LIBCPP_POP_MACROS
430430
431431#endif // _LIBCPP___ALGORITHM_RADIX_SORT_H
lib/libcxx/include/__algorithm/ranges_copy.h+2-4
......@@ -41,16 +41,14 @@ struct __copy {
4141 requires indirectly_copyable<_InIter, _OutIter>
4242 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<_InIter, _OutIter>
4343 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
44 auto __ret = std::__copy(std::move(__first), std::move(__last), std::move(__result));
45 return {std::move(__ret.first), std::move(__ret.second)};
44 return std::__copy(std::move(__first), std::move(__last), std::move(__result));
4645 }
4746
4847 template <input_range _Range, weakly_incrementable _OutIter>
4948 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
5049 _LIBCPP_HIDE_FROM_ABI constexpr copy_result<borrowed_iterator_t<_Range>, _OutIter>
5150 operator()(_Range&& __r, _OutIter __result) const {
52 auto __ret = std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
53 return {std::move(__ret.first), std::move(__ret.second)};
51 return std::__copy(ranges::begin(__r), ranges::end(__r), std::move(__result));
5452 }
5553};
5654
lib/libcxx/include/__algorithm/ranges_copy_backward.h+2-4
......@@ -40,16 +40,14 @@ struct __copy_backward {
4040 requires indirectly_copyable<_InIter1, _InIter2>
4141 _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<_InIter1, _InIter2>
4242 operator()(_InIter1 __first, _Sent1 __last, _InIter2 __result) const {
43 auto __ret = std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
44 return {std::move(__ret.first), std::move(__ret.second)};
43 return std::__copy_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
4544 }
4645
4746 template <bidirectional_range _Range, bidirectional_iterator _Iter>
4847 requires indirectly_copyable<iterator_t<_Range>, _Iter>
4948 _LIBCPP_HIDE_FROM_ABI constexpr copy_backward_result<borrowed_iterator_t<_Range>, _Iter>
5049 operator()(_Range&& __r, _Iter __result) const {
51 auto __ret = std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
52 return {std::move(__ret.first), std::move(__ret.second)};
50 return std::__copy_backward<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), std::move(__result));
5351 }
5452};
5553
lib/libcxx/include/__algorithm/ranges_copy_if.h+2-4
......@@ -46,8 +46,7 @@ struct __copy_if {
4646 requires indirectly_copyable<_Iter, _OutIter>
4747 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<_Iter, _OutIter>
4848 operator()(_Iter __first, _Sent __last, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
49 auto __res = std::__copy_if(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
50 return {std::move(__res.first), std::move(__res.second)};
49 return std::__copy_if(std::move(__first), std::move(__last), std::move(__result), __pred, __proj);
5150 }
5251
5352 template <input_range _Range,
......@@ -57,8 +56,7 @@ struct __copy_if {
5756 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
5857 _LIBCPP_HIDE_FROM_ABI constexpr copy_if_result<borrowed_iterator_t<_Range>, _OutIter>
5958 operator()(_Range&& __r, _OutIter __result, _Pred __pred, _Proj __proj = {}) const {
60 auto __res = std::__copy_if(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
61 return {std::move(__res.first), std::move(__res.second)};
59 return std::__copy_if(ranges::begin(__r), ranges::end(__r), std::move(__result), __pred, __proj);
6260 }
6361};
6462
lib/libcxx/include/__algorithm/ranges_copy_n.h+5-6
......@@ -24,10 +24,10 @@
2424_LIBCPP_PUSH_MACROS
2525#include <__undef_macros>
2626
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2927#if _LIBCPP_STD_VER >= 20
3028
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3131namespace ranges {
3232
3333template <class _Ip, class _Op>
......@@ -38,8 +38,7 @@ struct __copy_n {
3838 requires indirectly_copyable<_Ip, _Op>
3939 _LIBCPP_HIDE_FROM_ABI constexpr copy_n_result<_Ip, _Op>
4040 operator()(_Ip __first, iter_difference_t<_Ip> __n, _Op __result) const {
41 auto __res = std::__copy_n<_RangeAlgPolicy>(std::move(__first), __n, std::move(__result));
42 return {std::move(__res.first), std::move(__res.second)};
41 return std::__copy_n<_RangeAlgPolicy>(std::move(__first), __n, std::move(__result));
4342 }
4443};
4544
......@@ -48,10 +47,10 @@ inline constexpr auto copy_n = __copy_n{};
4847} // namespace __cpo
4948} // namespace ranges
5049
51#endif // _LIBCPP_STD_VER >= 20
52
5350_LIBCPP_END_NAMESPACE_STD
5451
52#endif // _LIBCPP_STD_VER >= 20
53
5554_LIBCPP_POP_MACROS
5655
5756#endif // _LIBCPP___ALGORITHM_RANGES_COPY_N_H
lib/libcxx/include/__algorithm/ranges_equal.h+2-2
......@@ -50,7 +50,7 @@ struct __equal {
5050 _Pred __pred = {},
5151 _Proj1 __proj1 = {},
5252 _Proj2 __proj2 = {}) const {
53 static constexpr bool __both_sized = sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>;
53 constexpr bool __both_sized = sized_sentinel_for<_Sent1, _Iter1> && sized_sentinel_for<_Sent2, _Iter2>;
5454 if constexpr (__both_sized) {
5555 if (__last1 - __first1 != __last2 - __first2)
5656 return false;
......@@ -71,7 +71,7 @@ struct __equal {
7171 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
7272 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
7373 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
74 static constexpr bool __both_sized = sized_range<_Range1> && sized_range<_Range2>;
74 constexpr bool __both_sized = sized_range<_Range1> && sized_range<_Range2>;
7575 if constexpr (__both_sized) {
7676 if (ranges::size(__range1) != ranges::size(__range2))
7777 return false;
lib/libcxx/include/__algorithm/ranges_find_if.h+3-12
......@@ -9,10 +9,10 @@
99#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
1010#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_H
1111
12#include <__algorithm/find_if.h>
1213#include <__config>
1314#include <__functional/identity.h>
1415#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
1616#include <__iterator/concepts.h>
1717#include <__iterator/projected.h>
1818#include <__ranges/access.h>
......@@ -33,15 +33,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3333
3434namespace ranges {
3535
36template <class _Ip, class _Sp, class _Pred, class _Proj>
37_LIBCPP_HIDE_FROM_ABI constexpr _Ip __find_if_impl(_Ip __first, _Sp __last, _Pred& __pred, _Proj& __proj) {
38 for (; __first != __last; ++__first) {
39 if (std::invoke(__pred, std::invoke(__proj, *__first)))
40 break;
41 }
42 return __first;
43}
44
4536struct __find_if {
4637 template <input_iterator _Ip,
4738 sentinel_for<_Ip> _Sp,
......@@ -49,13 +40,13 @@ struct __find_if {
4940 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
5041 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
5142 operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
52 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
43 return std::__find_if(std::move(__first), std::move(__last), __pred, __proj);
5344 }
5445
5546 template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
5647 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
5748 operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
58 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
49 return std::__find_if(ranges::begin(__r), ranges::end(__r), __pred, __proj);
5950 }
6051};
6152
lib/libcxx/include/__algorithm/ranges_find_if_not.h+3-8
......@@ -9,17 +9,14 @@
99#ifndef _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
1010#define _LIBCPP___ALGORITHM_RANGES_FIND_IF_NOT_H
1111
12#include <__algorithm/ranges_find_if.h>
12#include <__algorithm/find_if_not.h>
1313#include <__config>
1414#include <__functional/identity.h>
15#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
1715#include <__iterator/concepts.h>
1816#include <__iterator/projected.h>
1917#include <__ranges/access.h>
2018#include <__ranges/concepts.h>
2119#include <__ranges/dangling.h>
22#include <__utility/forward.h>
2320#include <__utility/move.h>
2421
2522#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -41,15 +38,13 @@ struct __find_if_not {
4138 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
4239 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
4340 operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
44 auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
45 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
41 return std::__find_if_not(std::move(__first), std::move(__last), __pred, __proj);
4642 }
4743
4844 template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
4945 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
5046 operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
51 auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
52 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
47 return std::__find_if_not(ranges::begin(__r), ranges::end(__r), __pred, __proj);
5348 }
5449};
5550
lib/libcxx/include/__algorithm/ranges_fold.h+145-4
......@@ -10,17 +10,21 @@
1010#ifndef _LIBCPP___ALGORITHM_RANGES_FOLD_H
1111#define _LIBCPP___ALGORITHM_RANGES_FOLD_H
1212
13#include <__algorithm/for_each.h>
1314#include <__concepts/assignable.h>
1415#include <__concepts/constructible.h>
1516#include <__concepts/convertible_to.h>
1617#include <__concepts/invocable.h>
1718#include <__concepts/movable.h>
1819#include <__config>
20#include <__functional/identity.h>
1921#include <__functional/invoke.h>
2022#include <__functional/reference_wrapper.h>
2123#include <__iterator/concepts.h>
2224#include <__iterator/iterator_traits.h>
2325#include <__iterator/next.h>
26#include <__iterator/prev.h>
27#include <__iterator/reverse_iterator.h>
2428#include <__ranges/access.h>
2529#include <__ranges/concepts.h>
2630#include <__ranges/dangling.h>
......@@ -28,6 +32,7 @@
2832#include <__type_traits/invoke.h>
2933#include <__utility/forward.h>
3034#include <__utility/move.h>
35#include <optional>
3136
3237#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3338# pragma GCC system_header
......@@ -62,6 +67,9 @@ struct in_value_result {
6267template <class _Ip, class _Tp>
6368using fold_left_with_iter_result = in_value_result<_Ip, _Tp>;
6469
70template <class _Ip, class _Tp>
71using fold_left_first_with_iter_result = in_value_result<_Ip, _Tp>;
72
6573template <class _Fp, class _Tp, class _Ip, class _Rp, class _Up = decay_t<_Rp>>
6674concept __indirectly_binary_left_foldable_impl =
6775 convertible_to<_Rp, _Up> && //
......@@ -77,6 +85,22 @@ concept __indirectly_binary_left_foldable =
7785 invocable<_Fp&, _Tp, iter_reference_t<_Ip>> && //
7886 __indirectly_binary_left_foldable_impl<_Fp, _Tp, _Ip, invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
7987
88template <class _Func>
89struct __flipped {
90 _Func __func;
91
92 template <class _Tp, class _Up>
93 requires invocable<_Func&, _Up, _Tp>
94 invoke_result_t<_Func&, _Up, _Tp> operator()(_Tp&&, _Up&&);
95};
96
97template <class _Func, class _Tp, class _Iter>
98concept __indirectly_binary_right_foldable =
99 __indirectly_binary_left_foldable_impl<__flipped<_Func>,
100 _Tp,
101 _Iter,
102 invoke_result_t<_Func&, _Tp, iter_reference_t<_Iter>>>;
103
80104struct __fold_left_with_iter {
81105 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
82106 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
......@@ -87,11 +111,17 @@ struct __fold_left_with_iter {
87111 }
88112
89113 _Up __result = std::invoke(__f, std::move(__init), *__first);
90 for (++__first; __first != __last; ++__first) {
91 __result = std::invoke(__f, std::move(__result), *__first);
92 }
114 ++__first;
115 __identity __proj;
116 auto __end = std::__for_each(
117 std::move(__first),
118 std::move(__last),
119 [&](auto&& __element) {
120 __result = std::invoke(__f, std::move(__result), std::forward<decltype(__element)>(__element));
121 },
122 __proj);
93123
94 return fold_left_with_iter_result<_Ip, _Up>{std::move(__first), std::move(__result)};
124 return fold_left_with_iter_result<_Ip, _Up>{std::move(__end), std::move(__result)};
95125 }
96126
97127 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
......@@ -118,6 +148,117 @@ struct __fold_left {
118148};
119149
120150inline constexpr auto fold_left = __fold_left();
151
152struct __fold_left_first_with_iter {
153 template <input_iterator _Iter,
154 sentinel_for<_Iter> _Sent,
155 __indirectly_binary_left_foldable<iter_value_t<_Iter>, _Iter> _Func>
156 requires constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>>
157 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Iter __first, _Sent __last, _Func __func) {
158 using _Up = decltype(fold_left(std::move(__first), __last, iter_value_t<_Iter>(*__first), __func));
159
160 if (__first == __last)
161 return fold_left_first_with_iter_result<_Iter, optional<_Up>>{std::move(__first), optional<_Up>()};
162
163 _Up __result(*__first);
164 ++__first;
165 __identity __proj;
166 auto __end = std::__for_each(
167 std::move(__first),
168 std::move(__last),
169 [&](auto&& __element) {
170 __result = std::invoke(__func, std::move(__result), std::forward<decltype(__element)>(__element));
171 },
172 __proj);
173
174 return fold_left_first_with_iter_result<_Iter, optional<_Up>>{std::move(__end), optional<_Up>(std::move(__result))};
175 }
176
177 template <input_range _Range, __indirectly_binary_left_foldable<range_value_t<_Range>, iterator_t<_Range>> _Func>
178 requires constructible_from<range_value_t<_Range>, range_reference_t<_Range>>
179 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Func __func) {
180 auto __result = operator()(ranges::begin(__range), ranges::end(__range), std::ref(__func));
181
182 using _Up = decltype(fold_left(
183 ranges::begin(__range), ranges::end(__range), range_value_t<_Range>(*ranges::begin(__range)), __func));
184 return fold_left_first_with_iter_result<borrowed_iterator_t<_Range>, optional<_Up>>{
185 std::move(__result.in), std::move(__result.value)};
186 }
187};
188
189inline constexpr auto fold_left_first_with_iter = __fold_left_first_with_iter();
190
191struct __fold_left_first {
192 template <input_iterator _Iter,
193 sentinel_for<_Iter> _Sent,
194 __indirectly_binary_left_foldable<iter_value_t<_Iter>, _Iter> _Func>
195 requires constructible_from<iter_value_t<_Iter>, iter_reference_t<_Iter>>
196 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Iter __first, _Sent __last, _Func __func) {
197 return fold_left_first_with_iter(std::move(__first), std::move(__last), std::ref(__func)).value;
198 }
199
200 template <input_range _Range, __indirectly_binary_left_foldable<range_value_t<_Range>, iterator_t<_Range>> _Func>
201 requires constructible_from<range_value_t<_Range>, range_reference_t<_Range>>
202 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Func __func) {
203 return fold_left_first_with_iter(ranges::begin(__range), ranges::end(__range), std::ref(__func)).value;
204 }
205};
206
207inline constexpr auto fold_left_first = __fold_left_first();
208
209struct __fold_right {
210 template <bidirectional_iterator _Iter,
211 sentinel_for<_Iter> _Sp,
212 class _Tp,
213 __indirectly_binary_right_foldable<_Tp, _Iter> _Func>
214 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
215 operator()(_Iter __first, _Sp __last, _Tp __init, _Func __func) {
216 using _Up = decay_t<invoke_result_t<_Func&, iter_reference_t<_Iter>, _Tp>>;
217
218 if (__first == __last)
219 return _Up(std::move(__init));
220
221 _Iter __tail = ranges::next(__first, __last);
222 --__tail;
223 _Up __result = std::invoke(__func, *__tail, std::move(__init));
224 std::for_each(std::make_reverse_iterator(__tail), std::make_reverse_iterator(__first), [&](auto&& __element) {
225 __result = std::invoke(__func, std::forward<decltype(__element)>(__element), std::move(__result));
226 });
227
228 return __result;
229 }
230
231 template <bidirectional_range _Range, class _Tp, __indirectly_binary_right_foldable<_Tp, iterator_t<_Range>> _Func>
232 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Tp __init, _Func __func) {
233 return operator()(ranges::begin(__range), ranges::end(__range), std::move(__init), std::ref(__func));
234 }
235};
236
237inline constexpr auto fold_right = __fold_right();
238
239struct __fold_right_last {
240 template <bidirectional_iterator _Iter,
241 sentinel_for<_Iter> _Sp,
242 __indirectly_binary_right_foldable<iter_value_t<_Iter>, _Iter> _Func>
243 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Iter __first, _Sp __last, _Func __func) {
244 using _Up = decltype(fold_right(__first, __last, iter_value_t<_Iter>(*__first), __func));
245
246 if (__first == __last)
247 return optional<_Up>();
248
249 _Iter __tail = ranges::prev(ranges::next(__first, __last));
250 return optional<_Up>(
251 in_place, ranges::fold_right(std::move(__first), __tail, iter_value_t<_Iter>(*__tail), std::move(__func)));
252 }
253
254 template <bidirectional_range _Range,
255 __indirectly_binary_right_foldable<range_value_t<_Range>, iterator_t<_Range>> _Func>
256 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Func __func) {
257 return operator()(ranges::begin(__range), ranges::end(__range), std::ref(__func));
258 }
259};
260
261inline constexpr auto fold_right_last = __fold_right_last();
121262} // namespace ranges
122263
123264#endif // _LIBCPP_STD_VER >= 23
lib/libcxx/include/__algorithm/ranges_move.h+2-9
......@@ -36,25 +36,18 @@ template <class _InIter, class _OutIter>
3636using move_result = in_out_result<_InIter, _OutIter>;
3737
3838struct __move {
39 template <class _InIter, class _Sent, class _OutIter>
40 _LIBCPP_HIDE_FROM_ABI constexpr static move_result<_InIter, _OutIter>
41 __move_impl(_InIter __first, _Sent __last, _OutIter __result) {
42 auto __ret = std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
43 return {std::move(__ret.first), std::move(__ret.second)};
44 }
45
4639 template <input_iterator _InIter, sentinel_for<_InIter> _Sent, weakly_incrementable _OutIter>
4740 requires indirectly_movable<_InIter, _OutIter>
4841 _LIBCPP_HIDE_FROM_ABI constexpr move_result<_InIter, _OutIter>
4942 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
50 return __move_impl(std::move(__first), std::move(__last), std::move(__result));
43 return std::__move<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
5144 }
5245
5346 template <input_range _Range, weakly_incrementable _OutIter>
5447 requires indirectly_movable<iterator_t<_Range>, _OutIter>
5548 _LIBCPP_HIDE_FROM_ABI constexpr move_result<borrowed_iterator_t<_Range>, _OutIter>
5649 operator()(_Range&& __range, _OutIter __result) const {
57 return __move_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
50 return std::__move<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), std::move(__result));
5851 }
5952};
6053
lib/libcxx/include/__algorithm/ranges_move_backward.h+2-9
......@@ -38,25 +38,18 @@ template <class _InIter, class _OutIter>
3838using move_backward_result = in_out_result<_InIter, _OutIter>;
3939
4040struct __move_backward {
41 template <class _InIter, class _Sent, class _OutIter>
42 _LIBCPP_HIDE_FROM_ABI constexpr static move_backward_result<_InIter, _OutIter>
43 __move_backward_impl(_InIter __first, _Sent __last, _OutIter __result) {
44 auto __ret = std::__move_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
45 return {std::move(__ret.first), std::move(__ret.second)};
46 }
47
4841 template <bidirectional_iterator _InIter, sentinel_for<_InIter> _Sent, bidirectional_iterator _OutIter>
4942 requires indirectly_movable<_InIter, _OutIter>
5043 _LIBCPP_HIDE_FROM_ABI constexpr move_backward_result<_InIter, _OutIter>
5144 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
52 return __move_backward_impl(std::move(__first), std::move(__last), std::move(__result));
45 return std::__move_backward<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__result));
5346 }
5447
5548 template <bidirectional_range _Range, bidirectional_iterator _Iter>
5649 requires indirectly_movable<iterator_t<_Range>, _Iter>
5750 _LIBCPP_HIDE_FROM_ABI constexpr move_backward_result<borrowed_iterator_t<_Range>, _Iter>
5851 operator()(_Range&& __range, _Iter __result) const {
59 return __move_backward_impl(ranges::begin(__range), ranges::end(__range), std::move(__result));
52 return std::__move_backward<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), std::move(__result));
6053 }
6154};
6255
lib/libcxx/include/__algorithm/ranges_partial_sort_copy.h+2-4
......@@ -60,7 +60,7 @@ struct __partial_sort_copy {
6060 _Comp __comp = {},
6161 _Proj1 __proj1 = {},
6262 _Proj2 __proj2 = {}) const {
63 auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
63 return std::__partial_sort_copy<_RangeAlgPolicy>(
6464 std::move(__first),
6565 std::move(__last),
6666 std::move(__result_first),
......@@ -68,7 +68,6 @@ struct __partial_sort_copy {
6868 __comp,
6969 __proj1,
7070 __proj2);
71 return {std::move(__result.first), std::move(__result.second)};
7271 }
7372
7473 template <input_range _Range1,
......@@ -84,7 +83,7 @@ struct __partial_sort_copy {
8483 _LIBCPP_HIDE_FROM_ABI constexpr partial_sort_copy_result<borrowed_iterator_t<_Range1>, borrowed_iterator_t<_Range2>>
8584 operator()(
8685 _Range1&& __range, _Range2&& __result_range, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
87 auto __result = std::__partial_sort_copy<_RangeAlgPolicy>(
86 return std::__partial_sort_copy<_RangeAlgPolicy>(
8887 ranges::begin(__range),
8988 ranges::end(__range),
9089 ranges::begin(__result_range),
......@@ -92,7 +91,6 @@ struct __partial_sort_copy {
9291 __comp,
9392 __proj1,
9493 __proj2);
95 return {std::move(__result.first), std::move(__result.second)};
9694 }
9795};
9896
lib/libcxx/include/__algorithm/ranges_remove_if.h+2-3
......@@ -10,10 +10,9 @@
1010#define _LIBCPP___ALGORITHM_RANGES_REMOVE_IF_H
1111#include <__config>
1212
13#include <__algorithm/ranges_find_if.h>
13#include <__algorithm/find_if.h>
1414#include <__functional/identity.h>
1515#include <__functional/invoke.h>
16#include <__functional/ranges_operations.h>
1716#include <__iterator/concepts.h>
1817#include <__iterator/iter_move.h>
1918#include <__iterator/permutable.h>
......@@ -39,7 +38,7 @@ namespace ranges {
3938template <class _Iter, class _Sent, class _Proj, class _Pred>
4039_LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
4140__remove_if_impl(_Iter __first, _Sent __last, _Pred& __pred, _Proj& __proj) {
42 auto __new_end = ranges::__find_if_impl(__first, __last, __pred, __proj);
41 auto __new_end = std::__find_if(__first, __last, __pred, __proj);
4342 if (__new_end == __last)
4443 return {__new_end, __new_end};
4544
lib/libcxx/include/__algorithm/ranges_reverse_copy.h+2-1
......@@ -18,6 +18,7 @@
1818#include <__ranges/access.h>
1919#include <__ranges/concepts.h>
2020#include <__ranges/dangling.h>
21#include <__ranges/reverse_view.h>
2122#include <__ranges/subrange.h>
2223#include <__utility/move.h>
2324
......@@ -49,7 +50,7 @@ struct __reverse_copy {
4950 requires indirectly_copyable<iterator_t<_Range>, _OutIter>
5051 _LIBCPP_HIDE_FROM_ABI constexpr reverse_copy_result<borrowed_iterator_t<_Range>, _OutIter>
5152 operator()(_Range&& __range, _OutIter __result) const {
52 auto __ret = ranges::copy(std::__reverse_range(__range), std::move(__result));
53 auto __ret = ranges::copy(__range | views::reverse, std::move(__result));
5354 return {ranges::next(ranges::begin(__range), ranges::end(__range)), std::move(__ret.out)};
5455 }
5556};
lib/libcxx/include/__algorithm/ranges_set_difference.h+2-7
......@@ -14,16 +14,13 @@
1414#include <__algorithm/set_difference.h>
1515#include <__config>
1616#include <__functional/identity.h>
17#include <__functional/invoke.h>
1817#include <__functional/ranges_operations.h>
1918#include <__iterator/concepts.h>
2019#include <__iterator/mergeable.h>
2120#include <__ranges/access.h>
2221#include <__ranges/concepts.h>
2322#include <__ranges/dangling.h>
24#include <__type_traits/decay.h>
2523#include <__utility/move.h>
26#include <__utility/pair.h>
2724
2825#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2926# pragma GCC system_header
......@@ -60,9 +57,8 @@ struct __set_difference {
6057 _Comp __comp = {},
6158 _Proj1 __proj1 = {},
6259 _Proj2 __proj2 = {}) const {
63 auto __ret = std::__set_difference(
60 return std::__set_difference(
6461 __first1, __last1, __first2, __last2, __result, ranges::__make_projected_comp(__comp, __proj1, __proj2));
65 return {std::move(__ret.first), std::move(__ret.second)};
6662 }
6763
6864 template <input_range _Range1,
......@@ -79,14 +75,13 @@ struct __set_difference {
7975 _Comp __comp = {},
8076 _Proj1 __proj1 = {},
8177 _Proj2 __proj2 = {}) const {
82 auto __ret = std::__set_difference(
78 return std::__set_difference(
8379 ranges::begin(__range1),
8480 ranges::end(__range1),
8581 ranges::begin(__range2),
8682 ranges::end(__range2),
8783 __result,
8884 ranges::__make_projected_comp(__comp, __proj1, __proj2));
89 return {std::move(__ret.first), std::move(__ret.second)};
9085 }
9186};
9287
lib/libcxx/include/__algorithm/ranges_shift_left.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___ALGORITHM_RANGES_SHIFT_LEFT_H
10#define _LIBCPP___ALGORITHM_RANGES_SHIFT_LEFT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/shift_left.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/distance.h>
17#include <__iterator/incrementable_traits.h>
18#include <__iterator/permutable.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/subrange.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 >= 23
34
35namespace ranges {
36namespace __shift_left {
37
38struct __fn {
39 template <permutable _Iter, sentinel_for<_Iter> _Sent>
40 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter>
41 operator()(_Iter __first, _Sent __last, iter_difference_t<_Iter> __n) {
42 auto __ret = std::__shift_left<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__n));
43 return {std::move(__ret.first), std::move(__ret.second)};
44 }
45
46 template <forward_range _Range>
47 requires permutable<iterator_t<_Range>>
48 _LIBCPP_HIDE_FROM_ABI static constexpr borrowed_subrange_t<_Range>
49 operator()(_Range&& __range, range_difference_t<_Range> __n) {
50 if constexpr (sized_range<_Range>) {
51 if (__n >= ranges::distance(__range)) {
52 return {ranges::begin(__range), ranges::begin(__range)};
53 }
54 }
55
56 auto __ret = std::__shift_left<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), std::move(__n));
57 return {std::move(__ret.first), std::move(__ret.second)};
58 }
59};
60} // namespace __shift_left
61
62inline namespace __cpo {
63inline constexpr auto shift_left = __shift_left::__fn{};
64} // namespace __cpo
65} // namespace ranges
66
67#endif // _LIBCPP_STD_VER >= 23
68
69_LIBCPP_END_NAMESPACE_STD
70
71_LIBCPP_POP_MACROS
72
73#endif // _LIBCPP___ALGORITHM_RANGES_SHIFT_LEFT_H
lib/libcxx/include/__algorithm/ranges_shift_right.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___ALGORITHM_RANGES_SHIFT_RIGHT_H
10#define _LIBCPP___ALGORITHM_RANGES_SHIFT_RIGHT_H
11
12#include <__algorithm/iterator_operations.h>
13#include <__algorithm/shift_right.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/distance.h>
17#include <__iterator/incrementable_traits.h>
18#include <__iterator/permutable.h>
19#include <__ranges/access.h>
20#include <__ranges/concepts.h>
21#include <__ranges/subrange.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 >= 23
34
35namespace ranges {
36namespace __shift_right {
37
38struct __fn {
39 template <permutable _Iter, sentinel_for<_Iter> _Sent>
40 _LIBCPP_HIDE_FROM_ABI static constexpr subrange<_Iter>
41 operator()(_Iter __first, _Sent __last, iter_difference_t<_Iter> __n) {
42 auto __ret = std::__shift_right<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::move(__n));
43 return {std::move(__ret.first), std::move(__ret.second)};
44 }
45
46 template <forward_range _Range>
47 requires permutable<iterator_t<_Range>>
48 _LIBCPP_HIDE_FROM_ABI static constexpr borrowed_subrange_t<_Range>
49 operator()(_Range&& __range, range_difference_t<_Range> __n) {
50 if constexpr (sized_range<_Range>) {
51 if (__n >= ranges::distance(__range)) {
52 auto __iter = ranges::begin(__range);
53 auto __end = ranges::end(__range);
54 ranges::advance(__iter, __end);
55 return {__iter, std::move(__iter)};
56 }
57 }
58
59 auto __ret = std::__shift_right<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), std::move(__n));
60 return {std::move(__ret.first), std::move(__ret.second)};
61 }
62};
63} // namespace __shift_right
64
65inline namespace __cpo {
66inline constexpr auto shift_right = __shift_right::__fn{};
67} // namespace __cpo
68} // namespace ranges
69
70#endif // _LIBCPP_STD_VER >= 23
71
72_LIBCPP_END_NAMESPACE_STD
73
74_LIBCPP_POP_MACROS
75
76#endif // _LIBCPP___ALGORITHM_RANGES_SHIFT_RIGHT_H
lib/libcxx/include/__algorithm/ranges_swap_ranges.h+30-3
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/in_in_result.h>
1313#include <__algorithm/iterator_operations.h>
14#include <__algorithm/min.h>
1415#include <__algorithm/swap_ranges.h>
1516#include <__config>
1617#include <__iterator/concepts.h>
......@@ -18,7 +19,9 @@
1819#include <__ranges/access.h>
1920#include <__ranges/concepts.h>
2021#include <__ranges/dangling.h>
22#include <__type_traits/is_same.h>
2123#include <__utility/move.h>
24#include <__utility/pair.h>
2225
2326#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2427# pragma GCC system_header
......@@ -41,9 +44,33 @@ struct __swap_ranges {
4144 requires indirectly_swappable<_I1, _I2>
4245 _LIBCPP_HIDE_FROM_ABI constexpr swap_ranges_result<_I1, _I2>
4346 operator()(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2) const {
44 auto __ret = std::__swap_ranges<_RangeAlgPolicy>(
45 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2));
46 return {std::move(__ret.first), std::move(__ret.second)};
47 if constexpr (sized_sentinel_for<_I1, _S1> && sized_sentinel_for<_I2, _S2> &&
48 (random_access_iterator<_I1> || random_access_iterator<_I2> ||
49 (is_same_v<_I1, _S1> && is_same_v<_I2, _S2>))) {
50 auto __offset = std::min(__last1 - __first1, __last2 - __first2);
51
52 auto __ret = [&] {
53 if constexpr (random_access_iterator<_I1>)
54 return std::__swap_ranges<_RangeAlgPolicy>(__first1, __first1 + __offset, std::move(__first2));
55 else if constexpr (random_access_iterator<_I2>)
56 return std::__swap_ranges<_RangeAlgPolicy>(__first2, __first2 + __offset, std::move(__first1));
57 else if (__last2 - __first2 < __last1 - __first1) {
58 auto __reversed =
59 std::__swap_ranges<_RangeAlgPolicy>(std::move(__first2), std::move(__last2), std::move(__first1));
60 return std::pair<_I1, _I2>(std::move(__reversed.second), std::move(__reversed.first));
61 } else
62 return std::__swap_ranges<_RangeAlgPolicy>(std::move(__first1), std::move(__last1), std::move(__first2));
63 }();
64 return {std::move(__ret.first), std::move(__ret.second)};
65 } else {
66 while (__first1 != __last1 && __first2 != __last2) {
67 ranges::iter_swap(__first1, __first2);
68 ++__first1;
69 ++__first2;
70 }
71
72 return {std::move(__first1), std::move(__first2)};
73 }
4774 }
4875
4976 template <input_range _R1, input_range _R2>
lib/libcxx/include/__algorithm/ranges_unique_copy.h+2-5
......@@ -26,7 +26,6 @@
2626#include <__ranges/dangling.h>
2727#include <__utility/forward.h>
2828#include <__utility/move.h>
29#include <__utility/pair.h>
3029
3130#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3231# pragma GCC system_header
......@@ -73,13 +72,12 @@ struct __unique_copy {
7372 indirectly_copyable_storable<_InIter, _OutIter>)
7473 _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<_InIter, _OutIter>
7574 operator()(_InIter __first, _Sent __last, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
76 auto __ret = std::__unique_copy<_RangeAlgPolicy>(
75 return std::__unique_copy<_RangeAlgPolicy>(
7776 std::move(__first),
7877 std::move(__last),
7978 std::move(__result),
8079 std::__make_projected(__comp, __proj),
8180 __algo_tag_t<_InIter, _OutIter>());
82 return {std::move(__ret.first), std::move(__ret.second)};
8381 }
8482
8583 template <input_range _Range,
......@@ -92,13 +90,12 @@ struct __unique_copy {
9290 indirectly_copyable_storable<iterator_t<_Range>, _OutIter>)
9391 _LIBCPP_HIDE_FROM_ABI constexpr unique_copy_result<borrowed_iterator_t<_Range>, _OutIter>
9492 operator()(_Range&& __range, _OutIter __result, _Comp __comp = {}, _Proj __proj = {}) const {
95 auto __ret = std::__unique_copy<_RangeAlgPolicy>(
93 return std::__unique_copy<_RangeAlgPolicy>(
9694 ranges::begin(__range),
9795 ranges::end(__range),
9896 std::move(__result),
9997 std::__make_projected(__comp, __proj),
10098 __algo_tag_t<iterator_t<_Range>, _OutIter>());
101 return {std::move(__ret.first), std::move(__ret.second)};
10299 }
103100};
104101
lib/libcxx/include/__algorithm/rotate.h+2-2
......@@ -39,7 +39,7 @@ __rotate_left(_ForwardIterator __first, _ForwardIterator __last) {
3939 using _Ops = _IterOps<_AlgPolicy>;
4040
4141 value_type __tmp = _Ops::__iter_move(__first);
42 _ForwardIterator __lm1 = std::__move<_AlgPolicy>(_Ops::next(__first), __last, __first).second;
42 _ForwardIterator __lm1 = std::__move<_AlgPolicy>(_Ops::next(__first), __last, __first).__out_;
4343 *__lm1 = std::move(__tmp);
4444 return __lm1;
4545}
......@@ -52,7 +52,7 @@ __rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) {
5252
5353 _BidirectionalIterator __lm1 = _Ops::prev(__last);
5454 value_type __tmp = _Ops::__iter_move(__lm1);
55 _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)).second;
55 _BidirectionalIterator __fp1 = std::__move_backward<_AlgPolicy>(__first, __lm1, std::move(__last)).__out_;
5656 *__first = std::move(__tmp);
5757 return __fp1;
5858}
lib/libcxx/include/__algorithm/set_difference.h+5-6
......@@ -12,12 +12,10 @@
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
1414#include <__algorithm/copy.h>
15#include <__algorithm/in_out_result.h>
1516#include <__config>
16#include <__functional/identity.h>
17#include <__iterator/iterator_traits.h>
1817#include <__type_traits/remove_cvref.h>
1918#include <__utility/move.h>
20#include <__utility/pair.h>
2119
2220#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2321# pragma GCC system_header
......@@ -29,7 +27,8 @@ _LIBCPP_PUSH_MACROS
2927_LIBCPP_BEGIN_NAMESPACE_STD
3028
3129template <class _Comp, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
30_LIBCPP_HIDE_FROM_ABI
31_LIBCPP_CONSTEXPR_SINCE_CXX20 __in_out_result<__remove_cvref_t<_InIter1>, __remove_cvref_t<_OutIter> >
3332__set_difference(
3433 _InIter1&& __first1, _Sent1&& __last1, _InIter2&& __first2, _Sent2&& __last2, _OutIter&& __result, _Comp&& __comp) {
3534 while (__first1 != __last1 && __first2 != __last2) {
......@@ -56,7 +55,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
5655 _OutputIterator __result,
5756 _Compare __comp) {
5857 return std::__set_difference<__comp_ref_type<_Compare> >(__first1, __last1, __first2, __last2, __result, __comp)
59 .second;
58 .__out_;
6059}
6160
6261template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
......@@ -66,7 +65,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_d
6665 _InputIterator2 __first2,
6766 _InputIterator2 __last2,
6867 _OutputIterator __result) {
69 return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).second;
68 return std::__set_difference(__first1, __last1, __first2, __last2, __result, __less<>()).__out_;
7069}
7170
7271_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/set_intersection.h+2-5
......@@ -96,12 +96,10 @@ __set_intersection(
9696 _Compare&& __comp,
9797 std::forward_iterator_tag,
9898 std::forward_iterator_tag) {
99 _LIBCPP_CONSTEXPR std::__identity __proj;
10099 bool __prev_may_be_equal = false;
101100
102101 while (__first2 != __last2) {
103 _InForwardIter1 __first1_next =
104 std::__lower_bound_onesided<_AlgPolicy>(__first1, __last1, *__first2, __comp, __proj);
102 _InForwardIter1 __first1_next = std::__lower_bound_onesided<_AlgPolicy>(__first1, __last1, *__first2, __comp);
105103 std::swap(__first1_next, __first1);
106104 // keeping in mind that a==b iff !(a<b) && !(b<a):
107105 // if we can't advance __first1, that means !(*__first1 < *_first2), therefore __may_be_equal==true
......@@ -110,8 +108,7 @@ __set_intersection(
110108 if (__first1 == __last1)
111109 break;
112110
113 _InForwardIter2 __first2_next =
114 std::__lower_bound_onesided<_AlgPolicy>(__first2, __last2, *__first1, __comp, __proj);
111 _InForwardIter2 __first2_next = std::__lower_bound_onesided<_AlgPolicy>(__first2, __last2, *__first1, __comp);
115112 std::swap(__first2_next, __first2);
116113 std::__set_intersection_add_output_if_equal(
117114 __first2 == __first2_next, __first1, __first2, __result, __prev_may_be_equal);
lib/libcxx/include/__algorithm/set_symmetric_difference.h+2-2
......@@ -46,7 +46,7 @@ __set_symmetric_difference(
4646 if (__first2 == __last2) {
4747 auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
4848 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
49 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
49 std::move(__ret1.__in_), std::move(__first2), std::move((__ret1.__out_)));
5050 }
5151 if (__comp(*__first1, *__first2)) {
5252 *__result = *__first1;
......@@ -64,7 +64,7 @@ __set_symmetric_difference(
6464 }
6565 auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
6666 return __set_symmetric_difference_result<_InIter1, _InIter2, _OutIter>(
67 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
67 std::move(__first1), std::move(__ret2.__in_), std::move((__ret2.__out_)));
6868}
6969
7070template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
lib/libcxx/include/__algorithm/set_union.h+2-2
......@@ -45,7 +45,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1,
4545 if (__first2 == __last2) {
4646 auto __ret1 = std::__copy(std::move(__first1), std::move(__last1), std::move(__result));
4747 return __set_union_result<_InIter1, _InIter2, _OutIter>(
48 std::move(__ret1.first), std::move(__first2), std::move((__ret1.second)));
48 std::move(__ret1.__in_), std::move(__first2), std::move((__ret1.__out_)));
4949 }
5050 if (__comp(*__first2, *__first1)) {
5151 *__result = *__first2;
......@@ -60,7 +60,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_union_result<_InIter1,
6060 }
6161 auto __ret2 = std::__copy(std::move(__first2), std::move(__last2), std::move(__result));
6262 return __set_union_result<_InIter1, _InIter2, _OutIter>(
63 std::move(__first1), std::move(__ret2.first), std::move((__ret2.second)));
63 std::move(__first1), std::move(__ret2.__in_), std::move((__ret2.__out_)));
6464}
6565
6666template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
lib/libcxx/include/__algorithm/shift_left.h+30-13
......@@ -9,9 +9,14 @@
99#ifndef _LIBCPP___ALGORITHM_SHIFT_LEFT_H
1010#define _LIBCPP___ALGORITHM_SHIFT_LEFT_H
1111
12#include <__algorithm/iterator_operations.h>
1213#include <__algorithm/move.h>
14#include <__assert>
1315#include <__config>
16#include <__iterator/concepts.h>
1417#include <__iterator/iterator_traits.h>
18#include <__utility/move.h>
19#include <__utility/pair.h>
1520
1621#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1722# pragma GCC system_header
......@@ -24,30 +29,42 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2429
2530#if _LIBCPP_STD_VER >= 20
2631
27template <class _ForwardIterator>
28inline _LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator
29shift_left(_ForwardIterator __first,
30 _ForwardIterator __last,
31 typename iterator_traits<_ForwardIterator>::difference_type __n) {
32template <class _AlgPolicy, class _Iter, class _Sent>
33_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter, _Iter>
34__shift_left(_Iter __first, _Sent __last, typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __n) {
35 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "n must be greater than or equal to 0");
36
3237 if (__n == 0) {
33 return __last;
38 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
39 return {std::move(__first), std::move(__end)};
3440 }
3541
36 _ForwardIterator __m = __first;
37 if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) {
38 if (__n >= __last - __first) {
39 return __first;
42 _Iter __m = __first;
43 if constexpr (sized_sentinel_for<_Sent, _Iter>) {
44 auto __size = _IterOps<_AlgPolicy>::distance(__first, __last);
45 if (__n >= __size) {
46 return {__first, std::move(__first)};
4047 }
41 __m += __n;
48 _IterOps<_AlgPolicy>::advance(__m, __n);
4249 } else {
4350 for (; __n > 0; --__n) {
4451 if (__m == __last) {
45 return __first;
52 return {__first, std::move(__first)};
4653 }
4754 ++__m;
4855 }
4956 }
50 return std::move(__m, __last, __first);
57
58 _Iter __result = std::__move<_AlgPolicy>(__m, __last, __first).__out_;
59 return {std::move(__first), std::move(__result)};
60}
61
62template <class _ForwardIterator>
63_LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator
64shift_left(_ForwardIterator __first,
65 _ForwardIterator __last,
66 typename iterator_traits<_ForwardIterator>::difference_type __n) {
67 return std::__shift_left<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __n).second;
5168}
5269
5370#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__algorithm/shift_right.h+53-27
......@@ -9,11 +9,17 @@
99#ifndef _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
1010#define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H
1111
12#include <__algorithm/iterator_operations.h>
1213#include <__algorithm/move.h>
1314#include <__algorithm/move_backward.h>
1415#include <__algorithm/swap_ranges.h>
16#include <__assert>
17#include <__concepts/derived_from.h>
1518#include <__config>
19#include <__iterator/concepts.h>
1620#include <__iterator/iterator_traits.h>
21#include <__utility/move.h>
22#include <__utility/pair.h>
1723#include <__utility/swap.h>
1824
1925#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -27,36 +33,48 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2733
2834#if _LIBCPP_STD_VER >= 20
2935
30template <class _ForwardIterator>
31inline _LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator
32shift_right(_ForwardIterator __first,
33 _ForwardIterator __last,
34 typename iterator_traits<_ForwardIterator>::difference_type __n) {
36template <class _AlgPolicy, class _Iter, class _Sent>
37_LIBCPP_HIDE_FROM_ABI constexpr pair<_Iter, _Iter>
38__shift_right(_Iter __first, _Sent __last, typename _IterOps<_AlgPolicy>::template __difference_type<_Iter> __n) {
39 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n >= 0, "Providing a negative shift amount to shift_right is UB");
3540 if (__n == 0) {
36 return __first;
41 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
42 return pair<_Iter, _Iter>(std::move(__first), std::move(__end));
3743 }
3844
39 if constexpr (__has_random_access_iterator_category<_ForwardIterator>::value) {
40 decltype(__n) __d = __last - __first;
41 if (__n >= __d) {
42 return __last;
45 using _IterCategory = typename _IterOps<_AlgPolicy>::template __iterator_category<_Iter>;
46
47 if constexpr (derived_from<_IterCategory, random_access_iterator_tag>) {
48 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
49 auto __size = __end - __first;
50 if (__n >= __size) {
51 return pair<_Iter, _Iter>(__end, std::move(__end));
52 }
53 _Iter __m = __first;
54 _IterOps<_AlgPolicy>::advance(__m, (__size - __n));
55 auto __ret = std::__move_backward<_AlgPolicy>(std::move(__first), std::move(__m), __end);
56 return pair<_Iter, _Iter>(std::move(__ret.__out_), std::move(__end));
57 } else if constexpr (derived_from<_IterCategory, bidirectional_iterator_tag>) {
58 _Iter __end = _IterOps<_AlgPolicy>::next(__first, __last);
59 if constexpr (sized_sentinel_for<_Sent, _Iter>) {
60 if (__n >= ranges::distance(__first, __last)) {
61 return pair<_Iter, _Iter>(__end, std::move(__end));
62 }
4363 }
44 _ForwardIterator __m = __first + (__d - __n);
45 return std::move_backward(__first, __m, __last);
46 } else if constexpr (__has_bidirectional_iterator_category<_ForwardIterator>::value) {
47 _ForwardIterator __m = __last;
64 _Iter __m = __end;
4865 for (; __n > 0; --__n) {
4966 if (__m == __first) {
50 return __last;
67 return pair<_Iter, _Iter>(__end, std::move(__end));
5168 }
5269 --__m;
5370 }
54 return std::move_backward(__first, __m, __last);
71 auto __ret = std::__move_backward<_AlgPolicy>(std::move(__first), std::move(__m), __end);
72 return pair<_Iter, _Iter>(std::move(__ret.__out_), std::move(__end));
5573 } else {
56 _ForwardIterator __ret = __first;
74 _Iter __ret = __first;
5775 for (; __n > 0; --__n) {
5876 if (__ret == __last) {
59 return __last;
77 return pair<_Iter, _Iter>(__ret, std::move(__ret));
6078 }
6179 ++__ret;
6280 }
......@@ -64,28 +82,28 @@ shift_right(_ForwardIterator __first,
6482 // We have an __n-element scratch space from __first to __ret.
6583 // Slide an __n-element window [__trail, __lead) from left to right.
6684 // We're essentially doing swap_ranges(__first, __ret, __trail, __lead)
67 // over and over; but once __lead reaches __last we needn't bother
68 // to save the values of elements [__trail, __last).
85 // over and over; but once __lead reaches __end we needn't bother
86 // to save the values of elements [__trail, __end).
6987
7088 auto __trail = __first;
7189 auto __lead = __ret;
7290 while (__trail != __ret) {
7391 if (__lead == __last) {
74 std::move(__first, __trail, __ret);
75 return __ret;
92 std::__move<_AlgPolicy>(std::move(__first), std::move(__trail), __ret);
93 return pair<_Iter, _Iter>(__ret, std::move(__lead));
7694 }
7795 ++__trail;
7896 ++__lead;
7997 }
8098
81 _ForwardIterator __mid = __first;
99 _Iter __mid = __first;
82100 while (true) {
83101 if (__lead == __last) {
84 __trail = std::move(__mid, __ret, __trail);
85 std::move(__first, __mid, __trail);
86 return __ret;
102 __trail = std::__move<_AlgPolicy>(__mid, __ret, __trail).__out_;
103 std::__move<_AlgPolicy>(std::move(__first), std::move(__mid), std::move(__trail));
104 return pair<_Iter, _Iter>(__ret, std::move(__lead));
87105 }
88 swap(*__mid, *__trail);
106 _IterOps<_AlgPolicy>::iter_swap(__mid, __trail);
89107 ++__mid;
90108 ++__trail;
91109 ++__lead;
......@@ -96,6 +114,14 @@ shift_right(_ForwardIterator __first,
96114 }
97115}
98116
117template <class _ForwardIterator>
118_LIBCPP_HIDE_FROM_ABI constexpr _ForwardIterator
119shift_right(_ForwardIterator __first,
120 _ForwardIterator __last,
121 typename iterator_traits<_ForwardIterator>::difference_type __n) {
122 return std::__shift_right<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __n).first;
123}
124
99125#endif // _LIBCPP_STD_VER >= 20
100126
101127_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/shuffle.h+2
......@@ -28,6 +28,7 @@ _LIBCPP_PUSH_MACROS
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
3030
31_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3132class _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_randomizer {
3233public:
3334 _LIBCPP_HIDE_FROM_ABI __libcpp_debug_randomizer() {
......@@ -160,6 +161,7 @@ shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRan
160161 std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
161162}
162163
164_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
163165_LIBCPP_END_NAMESPACE_STD
164166
165167_LIBCPP_POP_MACROS
lib/libcxx/include/__algorithm/simd_utils.h+4-12
......@@ -90,6 +90,9 @@ inline constexpr size_t __native_vector_size = 1;
9090template <class _ArithmeticT, size_t _Np>
9191using __simd_vector __attribute__((__ext_vector_type__(_Np))) _LIBCPP_NODEBUG = _ArithmeticT;
9292
93_LIBCPP_DIAGNOSTIC_PUSH
94_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi")
95
9396template <class _VecT>
9497inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
9598 static_assert(_False, "Not a vector!");
......@@ -115,8 +118,6 @@ template <class _VecT, class _Iter>
115118}
116119
117120// Load the first _Np elements, zero the rest
118_LIBCPP_DIAGNOSTIC_PUSH
119_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi")
120121template <class _VecT, size_t _Np, class _Iter>
121122[[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __partial_load(_Iter __iter) noexcept {
122123 return [=]<size_t... _LoadIndices, size_t... _ZeroIndices>(
......@@ -125,16 +126,6 @@ template <class _VecT, size_t _Np, class _Iter>
125126 }(make_index_sequence<_Np>{}, make_index_sequence<__simd_vector_size_v<_VecT> - _Np>{});
126127}
127128
128// Create a vector where every elements is __val
129template <class _VecT>
130[[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT
131__broadcast(__simd_vector_underlying_type_t<_VecT> __val) {
132 return [&]<std::size_t... _Indices>(index_sequence<_Indices...>) {
133 return _VecT{((void)_Indices, __val)...};
134 }(make_index_sequence<__simd_vector_size_v<_VecT>>());
135}
136_LIBCPP_DIAGNOSTIC_POP
137
138129template <class _Tp, size_t _Np>
139130[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __any_of(__simd_vector<_Tp, _Np> __vec) noexcept {
140131 return __builtin_reduce_or(__builtin_convertvector(__vec, __simd_vector<bool, _Np>));
......@@ -183,6 +174,7 @@ template <class _Tp, size_t _Np>
183174[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept {
184175 return std::__find_first_set(~__vec);
185176}
177_LIBCPP_DIAGNOSTIC_POP
186178
187179_LIBCPP_END_NAMESPACE_STD
188180
lib/libcxx/include/__algorithm/sort.h+2
......@@ -828,6 +828,7 @@ void __introsort(_RandomAccessIterator __first,
828828 }
829829}
830830
831_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
831832template <class _Comp, class _RandomAccessIterator>
832833void __sort(_RandomAccessIterator, _RandomAccessIterator, _Comp);
833834
......@@ -856,6 +857,7 @@ extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<float>&, float*>(fl
856857extern template _LIBCPP_EXPORTED_FROM_ABI void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
857858extern template _LIBCPP_EXPORTED_FROM_ABI void
858859__sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
860_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
859861
860862template <class _AlgPolicy, class _RandomAccessIterator, class _Comp>
861863_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
lib/libcxx/include/__algorithm/specialized_algorithms.h+1
......@@ -21,6 +21,7 @@ namespace _Algorithm {
2121struct __copy {};
2222struct __fill_n {};
2323struct __for_each {};
24struct __swap_ranges {};
2425} // namespace _Algorithm
2526
2627template <class>
lib/libcxx/include/__algorithm/swap_ranges.h+24-178
......@@ -10,12 +10,11 @@
1010#define _LIBCPP___ALGORITHM_SWAP_RANGES_H
1111
1212#include <__algorithm/iterator_operations.h>
13#include <__algorithm/min.h>
13#include <__algorithm/specialized_algorithms.h>
1414#include <__config>
15#include <__fwd/bit_reference.h>
15#include <__type_traits/enable_if.h>
1616#include <__utility/move.h>
1717#include <__utility/pair.h>
18#include <__utility/swap.h>
1918
2019#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2120# pragma GCC system_header
......@@ -26,189 +25,36 @@ _LIBCPP_PUSH_MACROS
2625
2726_LIBCPP_BEGIN_NAMESPACE_STD
2827
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
188// 2+2 iterators: the shorter size will be used.
189template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _Sentinel2>
190_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>
191__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _Sentinel2 __last2) {
192 while (__first1 != __last1 && __first2 != __last2) {
193 _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
194 ++__first1;
195 ++__first2;
196 }
197
198 return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
28template <
29 class _AlgPolicy,
30 class _Iter1,
31 class _Sent1,
32 class _Iter2,
33 class _SpecialAlg =
34 __specialized_algorithm<_Algorithm::__swap_ranges, __iterator_pair<_Iter1, _Sent1>, __single_iterator<_Iter2> >,
35 __enable_if_t<_SpecialAlg::__has_algorithm, int> = 0>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
37__swap_ranges(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
38 return _SpecialAlg()(std::move(__first1), std::move(__last1), std::move(__first2));
19939}
20040
201// 2+1 iterators: size2 >= size1.
202template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2>
203_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator1, _ForwardIterator2>
204__swap_ranges(_ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2) {
41template <
42 class _AlgPolicy,
43 class _Iter1,
44 class _Sent1,
45 class _Iter2,
46 class _SpecialAlg =
47 __specialized_algorithm<_Algorithm::__swap_ranges, __iterator_pair<_Iter1, _Sent1>, __single_iterator<_Iter2> >,
48 __enable_if_t<!_SpecialAlg::__has_algorithm, int> = 0>
49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
50__swap_ranges(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
20551 while (__first1 != __last1) {
20652 _IterOps<_AlgPolicy>::iter_swap(__first1, __first2);
20753 ++__first1;
20854 ++__first2;
20955 }
21056
211 return pair<_ForwardIterator1, _ForwardIterator2>(std::move(__first1), std::move(__first2));
57 return pair<_Iter1, _Iter2>(std::move(__first1), std::move(__first2));
21258}
21359
21460template <class _ForwardIterator1, class _ForwardIterator2>
lib/libcxx/include/__algorithm/three_way_comp_ref_type.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <class _Comp>
2727struct __debug_three_way_comp {
2828 _Comp& __comp_;
......@@ -67,8 +67,8 @@ template <class _Comp>
6767using __three_way_comp_ref_type _LIBCPP_NODEBUG = _Comp&;
6868# endif
6969
70#endif // _LIBCPP_STD_VER >= 20
71
7270_LIBCPP_END_NAMESPACE_STD
7371
72#endif // _LIBCPP_STD_VER >= 20
73
7474#endif // _LIBCPP___ALGORITHM_THREE_WAY_COMP_REF_TYPE_H
lib/libcxx/include/__algorithm/unique_copy.h+8-8
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H
1111
1212#include <__algorithm/comp.h>
13#include <__algorithm/in_out_result.h>
1314#include <__algorithm/iterator_operations.h>
1415#include <__config>
1516#include <__iterator/iterator_traits.h>
......@@ -17,7 +18,6 @@
1718#include <__type_traits/is_base_of.h>
1819#include <__type_traits/is_same.h>
1920#include <__utility/move.h>
20#include <__utility/pair.h>
2121
2222#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2323# pragma GCC system_header
......@@ -37,7 +37,7 @@ struct __read_from_tmp_value_tag {};
3737} // namespace __unique_copy_tags
3838
3939template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _OutputIterator>
40_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _OutputIterator>
40_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __in_out_result<_InputIterator, _OutputIterator>
4141__unique_copy(_InputIterator __first,
4242 _Sent __last,
4343 _OutputIterator __result,
......@@ -55,11 +55,11 @@ __unique_copy(_InputIterator __first,
5555 }
5656 }
5757 }
58 return pair<_InputIterator, _OutputIterator>(std::move(__first), std::move(__result));
58 return {std::move(__first), std::move(__result)};
5959}
6060
6161template <class _AlgPolicy, class _BinaryPredicate, class _ForwardIterator, class _Sent, class _OutputIterator>
62_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_ForwardIterator, _OutputIterator>
62_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __in_out_result<_ForwardIterator, _OutputIterator>
6363__unique_copy(_ForwardIterator __first,
6464 _Sent __last,
6565 _OutputIterator __result,
......@@ -77,11 +77,11 @@ __unique_copy(_ForwardIterator __first,
7777 }
7878 }
7979 }
80 return pair<_ForwardIterator, _OutputIterator>(std::move(__first), std::move(__result));
80 return {std::move(__first), std::move(__result)};
8181}
8282
8383template <class _AlgPolicy, class _BinaryPredicate, class _InputIterator, class _Sent, class _InputAndOutputIterator>
84_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _InputAndOutputIterator>
84_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __in_out_result<_InputIterator, _InputAndOutputIterator>
8585__unique_copy(_InputIterator __first,
8686 _Sent __last,
8787 _InputAndOutputIterator __result,
......@@ -94,7 +94,7 @@ __unique_copy(_InputIterator __first,
9494 *++__result = *__first;
9595 ++__result;
9696 }
97 return pair<_InputIterator, _InputAndOutputIterator>(std::move(__first), std::move(__result));
97 return {std::move(__first), std::move(__result)};
9898}
9999
100100template <class _InputIterator, class _OutputIterator, class _BinaryPredicate>
......@@ -111,7 +111,7 @@ unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __res
111111 __unique_copy_tags::__read_from_tmp_value_tag> >;
112112 return std::__unique_copy<_ClassicAlgPolicy>(
113113 std::move(__first), std::move(__last), std::move(__result), __pred, __algo_tag())
114 .second;
114 .__out_;
115115}
116116
117117template <class _InputIterator, class _OutputIterator>
lib/libcxx/include/__algorithm/unwrap_iter.h+8-10
......@@ -57,21 +57,19 @@ struct __unwrap_iter_impl<_Iter, true> {
5757 }
5858};
5959
60template <class _Iter,
61 class _Impl = __unwrap_iter_impl<_Iter>,
62 __enable_if_t<is_copy_constructible<_Iter>::value, int> = 0>
60template <class _Iter, class _Impl = __unwrap_iter_impl<_Iter> >
6361inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 decltype(_Impl::__unwrap(std::declval<_Iter>()))
6462__unwrap_iter(_Iter __i) _NOEXCEPT {
65 return _Impl::__unwrap(__i);
66}
67
6863// Allow input_iterators to be passed to __unwrap_iter (but not __rewrap_iter)
6964#if _LIBCPP_STD_VER >= 20
70template <class _Iter, __enable_if_t<!is_copy_constructible<_Iter>::value, int> = 0>
71inline _LIBCPP_HIDE_FROM_ABI constexpr _Iter __unwrap_iter(_Iter __i) noexcept {
72 return __i;
73}
65 if constexpr (!is_copy_constructible_v<_Iter>) {
66 return __i;
67 } else
7468#endif
69 {
70 return _Impl::__unwrap(__i);
71 }
72}
7573
7674template <class _OrigIter, class _Iter, class _Impl = __unwrap_iter_impl<_OrigIter> >
7775_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _OrigIter __rewrap_iter(_OrigIter __orig_iter, _Iter __iter) _NOEXCEPT {
lib/libcxx/include/__algorithm/unwrap_range.h+13-42
......@@ -10,10 +10,9 @@
1010#define _LIBCPP___ALGORITHM_UNWRAP_RANGE_H
1111
1212#include <__algorithm/unwrap_iter.h>
13#include <__concepts/constructible.h>
1413#include <__config>
1514#include <__iterator/concepts.h>
16#include <__iterator/next.h>
15#include <__type_traits/is_same.h>
1716#include <__utility/declval.h>
1817#include <__utility/move.h>
1918#include <__utility/pair.h>
......@@ -33,52 +32,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3332
3433#if _LIBCPP_STD_VER >= 20
3534template <class _Iter, class _Sent>
36struct __unwrap_range_impl {
37 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __sent)
38 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
39 {
40 auto __last = ranges::next(__first, __sent);
35_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
36 if constexpr (is_same_v<_Iter, _Sent>)
4137 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
42 }
43
44 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Sent __last) {
38 else if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>) {
39 auto __iter_last = __first + (__last - __first);
40 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__iter_last))};
41 } else
4542 return pair{std::move(__first), std::move(__last)};
46 }
47
48 _LIBCPP_HIDE_FROM_ABI static constexpr auto
49 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(std::move(__orig_iter))) __iter)
50 requires random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>
51 {
52 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
53 }
54
55 _LIBCPP_HIDE_FROM_ABI static constexpr auto __rewrap(const _Iter&, _Iter __iter)
56 requires(!(random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>))
57 {
58 return __iter;
59 }
60};
61
62template <class _Iter>
63struct __unwrap_range_impl<_Iter, _Iter> {
64 _LIBCPP_HIDE_FROM_ABI static constexpr auto __unwrap(_Iter __first, _Iter __last) {
65 return pair{std::__unwrap_iter(std::move(__first)), std::__unwrap_iter(std::move(__last))};
66 }
67
68 _LIBCPP_HIDE_FROM_ABI static constexpr auto
69 __rewrap(_Iter __orig_iter, decltype(std::__unwrap_iter(__orig_iter)) __iter) {
70 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
71 }
72};
73
74template <class _Iter, class _Sent>
75_LIBCPP_HIDE_FROM_ABI constexpr auto __unwrap_range(_Iter __first, _Sent __last) {
76 return __unwrap_range_impl<_Iter, _Sent>::__unwrap(std::move(__first), std::move(__last));
7743}
7844
7945template < class _Sent, class _Iter, class _Unwrapped>
8046_LIBCPP_HIDE_FROM_ABI constexpr _Iter __rewrap_range(_Iter __orig_iter, _Unwrapped __iter) {
81 return __unwrap_range_impl<_Iter, _Sent>::__rewrap(std::move(__orig_iter), std::move(__iter));
47 if constexpr (is_same_v<_Iter, _Sent>)
48 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
49 else if constexpr (random_access_iterator<_Iter> && sized_sentinel_for<_Sent, _Iter>)
50 return std::__rewrap_iter(std::move(__orig_iter), std::move(__iter));
51 else
52 return __iter;
8253}
8354#else // _LIBCPP_STD_VER >= 20
8455template <class _Iter, class _Unwrapped = decltype(std::__unwrap_iter(std::declval<_Iter>()))>
lib/libcxx/include/__assert+1-1
......@@ -20,7 +20,7 @@
2020#define _LIBCPP_ASSERT(expression, message) \
2121 (__builtin_expect(static_cast<bool>(expression), 1) \
2222 ? (void)0 \
23 : _LIBCPP_ASSERTION_HANDLER(__FILE__ ":" _LIBCPP_TOSTRING( \
23 : _LIBCPP_ASSERTION_HANDLER(__FILE_NAME__ ":" _LIBCPP_TOSTRING( \
2424 __LINE__) ": libc++ Hardening assertion " _LIBCPP_TOSTRING(expression) " failed: " message "\n"))
2525
2626// WARNING: __builtin_assume can currently inhibit optimizations. Only add assumptions with a clear
lib/libcxx/include/__atomic/atomic.h+2-4
......@@ -26,9 +26,7 @@
2626#include <__type_traits/is_nothrow_constructible.h>
2727#include <__type_traits/is_same.h>
2828#include <__type_traits/is_trivially_copyable.h>
29#include <__type_traits/remove_const.h>
3029#include <__type_traits/remove_pointer.h>
31#include <__type_traits/remove_volatile.h>
3230#include <__utility/forward.h>
3331#include <cstring>
3432
......@@ -297,13 +295,13 @@ struct atomic<_Tp*> : public __atomic_base<_Tp*> {
297295 }
298296
299297 _LIBCPP_HIDE_FROM_ABI _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
300 // __atomic_fetch_add accepts function pointers, guard against them.
298 // __atomic_fetch_sub accepts function pointers, guard against them.
301299 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
302300 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
303301 }
304302
305303 _LIBCPP_HIDE_FROM_ABI _Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT {
306 // __atomic_fetch_add accepts function pointers, guard against them.
304 // __atomic_fetch_sub accepts function pointers, guard against them.
307305 static_assert(!is_function<__remove_pointer_t<_Tp> >::value, "Pointer to function isn't allowed");
308306 return std::__cxx_atomic_fetch_sub(std::addressof(this->__a_), __op, __m);
309307 }
lib/libcxx/include/__atomic/atomic_flag.h+14-20
......@@ -11,14 +11,10 @@
1111
1212#include <__atomic/atomic_sync.h>
1313#include <__atomic/atomic_waitable_traits.h>
14#include <__atomic/contention_t.h>
1514#include <__atomic/memory_order.h>
1615#include <__atomic/support.h>
17#include <__chrono/duration.h>
1816#include <__config>
1917#include <__memory/addressof.h>
20#include <__thread/support.h>
21#include <cstdint>
2218
2319#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2420# pragma GCC system_header
......@@ -27,34 +23,34 @@
2723_LIBCPP_BEGIN_NAMESPACE_STD
2824
2925struct atomic_flag {
30 __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_;
26 __cxx_atomic_impl<bool> __a_;
3127
3228 _LIBCPP_HIDE_FROM_ABI bool test(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT {
33 return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);
29 return __cxx_atomic_load(&__a_, __m);
3430 }
3531 _LIBCPP_HIDE_FROM_ABI bool test(memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
36 return _LIBCPP_ATOMIC_FLAG_TYPE(true) == __cxx_atomic_load(&__a_, __m);
32 return __cxx_atomic_load(&__a_, __m);
3733 }
3834
3935 _LIBCPP_HIDE_FROM_ABI bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
40 return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);
36 return __cxx_atomic_exchange(&__a_, true, __m);
4137 }
4238 _LIBCPP_HIDE_FROM_ABI bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT {
43 return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);
39 return __cxx_atomic_exchange(&__a_, true, __m);
4440 }
4541 _LIBCPP_HIDE_FROM_ABI void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT {
46 __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);
42 __cxx_atomic_store(&__a_, false, __m);
4743 }
4844 _LIBCPP_HIDE_FROM_ABI void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT {
49 __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);
45 __cxx_atomic_store(&__a_, false, __m);
5046 }
5147
5248#if _LIBCPP_STD_VER >= 20
5349 _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT {
54 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
50 std::__atomic_wait(*this, __v, __m);
5551 }
5652 _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
57 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
53 std::__atomic_wait(*this, __v, __m);
5854 }
5955 _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT { std::__atomic_notify_one(*this); }
6056 _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
......@@ -78,23 +74,21 @@ struct atomic_flag {
7874#if _LIBCPP_STD_VER >= 20
7975template <>
8076struct __atomic_waitable_traits<atomic_flag> {
81 using __value_type _LIBCPP_NODEBUG = _LIBCPP_ATOMIC_FLAG_TYPE;
77 using __value_type _LIBCPP_NODEBUG = bool;
8278
83 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE __atomic_load(const atomic_flag& __a, memory_order __order) {
79 static _LIBCPP_HIDE_FROM_ABI bool __atomic_load(const atomic_flag& __a, memory_order __order) {
8480 return std::__cxx_atomic_load(&__a.__a_, __order);
8581 }
8682
87 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE
88 __atomic_load(const volatile atomic_flag& __a, memory_order __order) {
83 static _LIBCPP_HIDE_FROM_ABI bool __atomic_load(const volatile atomic_flag& __a, memory_order __order) {
8984 return std::__cxx_atomic_load(&__a.__a_, __order);
9085 }
9186
92 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>*
93 __atomic_contention_address(const atomic_flag& __a) {
87 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<bool>* __atomic_contention_address(const atomic_flag& __a) {
9488 return std::addressof(__a.__a_);
9589 }
9690
97 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>*
91 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<bool>*
9892 __atomic_contention_address(const volatile atomic_flag& __a) {
9993 return std::addressof(__a.__a_);
10094 }
lib/libcxx/include/__atomic/atomic_ref.h+14-5
......@@ -30,9 +30,10 @@
3030#include <__cstddef/byte.h>
3131#include <__cstddef/ptrdiff_t.h>
3232#include <__memory/addressof.h>
33#include <__memory/is_sufficiently_aligned.h>
34#include <__type_traits/copy_cv.h>
3335#include <__type_traits/has_unique_object_representation.h>
3436#include <__type_traits/is_trivially_copyable.h>
35#include <cstdint>
3637#include <cstring>
3738
3839#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -224,7 +225,7 @@ public:
224225 _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); }
225226 _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }
226227# if _LIBCPP_STD_VER >= 26
227 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* address() const noexcept { return __ptr_; }
228 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __copy_cv_t<_Tp, void>* address() const noexcept { return __ptr_; }
228229# endif
229230
230231protected:
......@@ -254,10 +255,12 @@ struct atomic_ref : public __atomic_ref_base<_Tp> {
254255
255256 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
256257 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
257 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
258 std::__is_sufficiently_aligned<__base::required_alignment>(std::addressof(__obj)),
258259 "atomic_ref ctor: referenced object must be aligned to required_alignment");
259260 }
260261
262 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp&&) = delete;
263
261264 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
262265
263266 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
......@@ -274,10 +277,12 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
274277
275278 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
276279 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
277 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
280 std::__is_sufficiently_aligned<__base::required_alignment>(std::addressof(__obj)),
278281 "atomic_ref ctor: referenced object must be aligned to required_alignment");
279282 }
280283
284 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp&&) = delete;
285
281286 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
282287
283288 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
......@@ -320,10 +325,12 @@ struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
320325
321326 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
322327 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
323 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
328 std::__is_sufficiently_aligned<__base::required_alignment>(std::addressof(__obj)),
324329 "atomic_ref ctor: referenced object must be aligned to required_alignment");
325330 }
326331
332 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp&&) = delete;
333
327334 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
328335
329336 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
......@@ -367,6 +374,8 @@ struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {
367374
368375 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp*& __ptr) : __base(__ptr) {}
369376
377 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp*&&) = delete;
378
370379 _LIBCPP_HIDE_FROM_ABI _Tp* operator=(_Tp* __desired) const noexcept { return __base::operator=(__desired); }
371380
372381 atomic_ref& operator=(const atomic_ref&) = delete;
lib/libcxx/include/__atomic/atomic_sync.h+8-9
......@@ -12,28 +12,25 @@
1212#include <__atomic/atomic_waitable_traits.h>
1313#include <__atomic/contention_t.h>
1414#include <__atomic/memory_order.h>
15#include <__atomic/to_gcc_order.h>
1615#include <__chrono/duration.h>
1716#include <__config>
1817#include <__memory/addressof.h>
1918#include <__thread/poll_with_backoff.h>
20#include <__type_traits/conjunction.h>
2119#include <__type_traits/decay.h>
22#include <__type_traits/invoke.h>
23#include <__type_traits/is_same.h>
24#include <__type_traits/void_t.h>
25#include <__utility/declval.h>
2620#include <cstring>
2721
2822#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2923# pragma GCC system_header
3024#endif
3125
26#if _LIBCPP_STD_VER >= 20
27
3228_LIBCPP_BEGIN_NAMESPACE_STD
3329
34#if _LIBCPP_STD_VER >= 20
3530# if _LIBCPP_HAS_THREADS
3631
32_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
33
3734# if !_LIBCPP_AVAILABILITY_HAS_NEW_SYNC
3835
3936// old dylib interface kept for backwards compatibility
......@@ -79,6 +76,8 @@ _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one
7976template <std::size_t _Size>
8077_LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_native(const void*) _NOEXCEPT;
8178
79_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
80
8281# if _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
8382
8483template <class _AtomicWaitable, class _Poll>
......@@ -260,8 +259,8 @@ _LIBCPP_HIDE_FROM_ABI void __atomic_wait(_AtomicWaitable& __a, _Tp __val, memory
260259 });
261260}
262261
263#endif // C++20
264
265262_LIBCPP_END_NAMESPACE_STD
266263
264#endif // _LIBCPP_STD_VER >= 20
265
267266#endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_H
lib/libcxx/include/__atomic/atomic_sync_timed.h+9-14
......@@ -12,20 +12,12 @@
1212#include <__atomic/atomic_waitable_traits.h>
1313#include <__atomic/contention_t.h>
1414#include <__atomic/memory_order.h>
15#include <__atomic/to_gcc_order.h>
1615#include <__chrono/duration.h>
1716#include <__config>
1817#include <__memory/addressof.h>
1918#include <__thread/poll_with_backoff.h>
2019#include <__thread/timed_backoff_policy.h>
21#include <__type_traits/conjunction.h>
2220#include <__type_traits/decay.h>
23#include <__type_traits/has_unique_object_representation.h>
24#include <__type_traits/invoke.h>
25#include <__type_traits/is_same.h>
26#include <__type_traits/is_trivially_copyable.h>
27#include <__type_traits/void_t.h>
28#include <__utility/declval.h>
2921#include <cstdint>
3022#include <cstring>
3123
......@@ -33,11 +25,13 @@
3325# pragma GCC system_header
3426#endif
3527
28#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
29
3630_LIBCPP_BEGIN_NAMESPACE_STD
3731
38#if _LIBCPP_STD_VER >= 20
39# if _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
32# if _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
4033
34_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4135_LIBCPP_AVAILABILITY_NEW_SYNC
4236_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __atomic_monitor_global(void const* __address) _NOEXCEPT;
4337
......@@ -49,6 +43,7 @@ _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_globa
4943template <std::size_t _Size>
5044_LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_EXPORTED_FROM_ABI void
5145__atomic_wait_native_with_timeout(void const* __address, void const* __old_value, uint64_t __timeout_ns) _NOEXCEPT;
46_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5247
5348template <class _AtomicWaitable, class _Poll, class _Rep, class _Period>
5449struct __atomic_wait_timed_backoff_impl {
......@@ -116,7 +111,7 @@ _LIBCPP_HIDE_FROM_ABI bool __atomic_wait_unless_with_timeout(
116111 return __poll_result == __poll_with_backoff_results::__poll_success;
117112}
118113
119# elif _LIBCPP_HAS_THREADS // _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
114# else // _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
120115
121116template <class _AtomicWaitable, class _Poll, class _Rep, class _Period>
122117_LIBCPP_HIDE_FROM_ABI bool __atomic_wait_unless_with_timeout(
......@@ -135,10 +130,10 @@ _LIBCPP_HIDE_FROM_ABI bool __atomic_wait_unless_with_timeout(
135130 return __res == __poll_with_backoff_results::__poll_success;
136131}
137132
138# endif // _LIBCPP_HAS_THREADS && _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
139
140#endif // C++20
133# endif // _LIBCPP_AVAILABILITY_HAS_NEW_SYNC
141134
142135_LIBCPP_END_NAMESPACE_STD
143136
137#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
138
144139#endif // _LIBCPP___ATOMIC_ATOMIC_SYNC_TIMED_H
lib/libcxx/include/__atomic/atomic_waitable_traits.h+4-6
......@@ -16,18 +16,16 @@
1616#include <__type_traits/has_unique_object_representation.h>
1717#include <__type_traits/is_same.h>
1818#include <__type_traits/is_trivially_copyable.h>
19#include <__type_traits/void_t.h>
20#include <__utility/declval.h>
2119#include <cstring>
2220
2321#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2422# pragma GCC system_header
2523#endif
2624
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2925#if _LIBCPP_STD_VER >= 20
3026
27_LIBCPP_BEGIN_NAMESPACE_STD
28
3129// The customisation points to enable the following functions:
3230// - __atomic_wait
3331// - __atomic_wait_unless
......@@ -96,8 +94,8 @@ concept __has_native_atomic_wait = is_same_v<_Tp, __cxx_contention_t>;
9694
9795# endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE
9896
99#endif // C++20
100
10197_LIBCPP_END_NAMESPACE_STD
10298
99#endif // _LIBCPP_STD_VER >= 20
100
103101#endif // _LIBCPP___ATOMIC_ATOMIC_WAITABLE_TRAITS_H
lib/libcxx/include/__atomic/contention_t.h+4-4
......@@ -25,7 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525// instead.
2626#if defined(_LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE)
2727
28# ifdef __linux__
28# if defined(__linux__) || defined(__Fuchsia__)
2929using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
3030# elif defined(__APPLE__)
3131using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
......@@ -37,15 +37,15 @@ using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
3737using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
3838# else
3939using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
40# endif // __linux__
40# endif // __linux__ || __Fuchsia__
4141
4242#else // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE
4343
44# if defined(__linux__) || (defined(_AIX) && !defined(__64BIT__))
44# if defined(__linux__) || defined(__Fuchsia__) || (defined(_AIX) && !defined(__64BIT__))
4545using __cxx_contention_t _LIBCPP_NODEBUG = int32_t;
4646# else
4747using __cxx_contention_t _LIBCPP_NODEBUG = int64_t;
48# endif // __linux__ || (_AIX && !__64BIT__)
48# endif // __linux__ || __Fuchsia__ || (_AIX && !__64BIT__)
4949
5050#endif // _LIBCPP_ABI_ATOMIC_WAIT_NATIVE_BY_SIZE
5151
lib/libcxx/include/__atomic/floating_point_helper.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Tp>
2525_LIBCPP_HIDE_FROM_ABI constexpr bool __is_fp80_long_double() {
2626 // Only x87-fp80 long double has 64-bit mantissa
......@@ -48,8 +48,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_rmw_builtin() {
4848# endif
4949}
5050
51#endif
52
5351_LIBCPP_END_NAMESPACE_STD
5452
53#endif // _LIBCPP_STD_VER >= 20
54
5555#endif // _LIBCPP___ATOMIC_FLOATING_POINT_HELPER_H
lib/libcxx/include/__atomic/support.h+2-2
......@@ -102,9 +102,9 @@
102102// clang-format on
103103//
104104
105#if _LIBCPP_HAS_GCC_ATOMIC_IMP
105#ifdef _LIBCPP_COMPILER_GCC
106106# include <__atomic/support/gcc.h>
107#elif _LIBCPP_HAS_C_ATOMIC_IMP
107#else
108108# include <__atomic/support/c11.h>
109109#endif
110110
lib/libcxx/include/__bit/bit_cast.h+6-6
......@@ -17,18 +17,16 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#ifndef _LIBCPP_CXX03_LANG
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _ToType, class _FromType>
2525[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept {
2626 return __builtin_bit_cast(_ToType, __from);
2727}
2828
29#endif // _LIBCPP_CXX03_LANG
30
31#if _LIBCPP_STD_VER >= 20
29# if _LIBCPP_STD_VER >= 20
3230
3331template <class _ToType, class _FromType>
3432 requires(sizeof(_ToType) == sizeof(_FromType) && is_trivially_copyable_v<_ToType> &&
......@@ -37,8 +35,10 @@ template <class _ToType, class _FromType>
3735 return __builtin_bit_cast(_ToType, __from);
3836}
3937
40#endif // _LIBCPP_STD_VER >= 20
38# endif // _LIBCPP_STD_VER >= 20
4139
4240_LIBCPP_END_NAMESPACE_STD
4341
42#endif // _LIBCPP_CXX03_LANG
43
4444#endif // _LIBCPP___BIT_BIT_CAST_H
lib/libcxx/include/__bit/bit_ceil.h+4-3
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 17
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <class _Tp>
2727[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept {
2828 if (__t < 2)
......@@ -47,8 +47,9 @@ template <__unsigned_integer _Tp>
4747}
4848
4949# endif // _LIBCPP_STD_VER >= 20
50#endif // _LIBCPP_STD_VER >= 17
5150
5251_LIBCPP_END_NAMESPACE_STD
5352
53#endif // _LIBCPP_STD_VER >= 17
54
5455#endif // _LIBCPP___BIT_BIT_CEIL_H
lib/libcxx/include/__bit/byteswap.h+25-6
......@@ -12,7 +12,11 @@
1212
1313#include <__concepts/arithmetic.h>
1414#include <__config>
15#include <__type_traits/is_same.h>
16#include <__type_traits/remove_cv.h>
17#include <climits>
1518#include <cstdint>
19#include <limits>
1620
1721#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1822# pragma GCC system_header
......@@ -24,26 +28,41 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2428
2529template <integral _Tp>
2630[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
31 // [bit.byteswap]/Mandates: T does not have padding bits.
32 // bool is grandfathered: every shipping implementation admits it and the
33 // size-1 identity path can't shuffle padding bits into value positions.
34 // LWG 4583 proposes relaxing this to allow byte-aligned padding (e.g.
35 // _BitInt(48) where 2 whole bytes are padding); revisit once it resolves.
36 static_assert(is_same_v<remove_cv_t<_Tp>, bool> ||
37 numeric_limits<_Tp>::digits + numeric_limits<_Tp>::is_signed == sizeof(_Tp) * CHAR_BIT,
38 "std::byteswap requires T to have no padding bits");
39
2740 if constexpr (sizeof(_Tp) == 1) {
2841 return __val;
42# if __has_builtin(__builtin_bswapg)
43 } else {
44 return __builtin_bswapg(__val);
45 }
46# else
2947 } else if constexpr (sizeof(_Tp) == 2) {
3048 return __builtin_bswap16(__val);
3149 } else if constexpr (sizeof(_Tp) == 4) {
3250 return __builtin_bswap32(__val);
3351 } else if constexpr (sizeof(_Tp) == 8) {
3452 return __builtin_bswap64(__val);
35# if _LIBCPP_HAS_INT128
53# if _LIBCPP_HAS_INT128
3654 } else if constexpr (sizeof(_Tp) == 16) {
37# if __has_builtin(__builtin_bswap128)
55# if __has_builtin(__builtin_bswap128)
3856 return __builtin_bswap128(__val);
39# else
40 return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |
57# else
58 return (static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64) |
4159 static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val >> 64)));
42# endif // __has_builtin(__builtin_bswap128)
43# endif // _LIBCPP_HAS_INT128
60# endif // __has_builtin(__builtin_bswap128)
61# endif // _LIBCPP_HAS_INT128
4462 } else {
4563 static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size");
4664 }
65# endif // __has_builtin(__builtin_bswapg)
4766}
4867
4968#endif // _LIBCPP_STD_VER >= 23
lib/libcxx/include/__bit_reference+164-23
......@@ -16,10 +16,10 @@
1616#include <__algorithm/copy_n.h>
1717#include <__algorithm/equal.h>
1818#include <__algorithm/fill_n.h>
19#include <__algorithm/in_out_result.h>
1920#include <__algorithm/min.h>
2021#include <__algorithm/rotate.h>
2122#include <__algorithm/specialized_algorithms.h>
22#include <__algorithm/swap_ranges.h>
2323#include <__assert>
2424#include <__bit/countr.h>
2525#include <__compare/ordering.h>
......@@ -35,7 +35,6 @@
3535#include <__type_traits/desugars_to.h>
3636#include <__type_traits/enable_if.h>
3737#include <__type_traits/is_constant_evaluated.h>
38#include <__type_traits/is_same.h>
3938#include <__type_traits/is_unsigned.h>
4039#include <__type_traits/void_t.h>
4140#include <__utility/pair.h>
......@@ -166,9 +165,6 @@ public:
166165 }
167166
168167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void flip() _NOEXCEPT { *__seg_ ^= __mask_; }
169 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT {
170 return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(std::__countr_zero(__mask_)));
171 }
172168
173169private:
174170 _LIBCPP_HIDE_FROM_ABI
......@@ -340,7 +336,7 @@ public:
340336 }
341337#endif
342338
343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
339 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator*() const _NOEXCEPT {
344340 _LIBCPP_ASSERT_INTERNAL(__ctz_ < __bits_per_word, "Dereferencing an invalid __bit_iterator.");
345341 return __conditional_t<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >(
346342 __seg_, __storage_type(1) << __ctz_);
......@@ -393,29 +389,32 @@ public:
393389 return *this += -__n;
394390 }
395391
396 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator+(difference_type __n) const {
392 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator
393 operator+(difference_type __n) const {
397394 __bit_iterator __t(*this);
398395 __t += __n;
399396 return __t;
400397 }
401398
402 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator operator-(difference_type __n) const {
399 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator
400 operator-(difference_type __n) const {
403401 __bit_iterator __t(*this);
404402 __t -= __n;
405403 return __t;
406404 }
407405
408 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator
406 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator
409407 operator+(difference_type __n, const __bit_iterator& __it) {
410408 return __it + __n;
411409 }
412410
413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend difference_type
411 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend difference_type
414412 operator-(const __bit_iterator& __x, const __bit_iterator& __y) {
415413 return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;
416414 }
417415
418 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference operator[](difference_type __n) const {
416 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference
417 operator[](difference_type __n) const {
419418 return *(*this + __n);
420419 }
421420
......@@ -487,15 +486,6 @@ private:
487486 __bit_iterator<_Dp, _IC> __first, __bit_iterator<_Dp, _IC> __last, __bit_iterator<_Dp, false> __result);
488487 template <class _AlgPolicy>
489488 friend struct __copy_backward_impl;
490 template <class _Cl, class _Cr>
491 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false>
492 __swap_ranges_aligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
493 template <class _Cl, class _Cr>
494 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Cr, false>
495 __swap_ranges_unaligned(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
496 template <class, class _Cl, class _Cr>
497 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> >
498 __swap_ranges(__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false>, __bit_iterator<_Cr, false>);
499489 template <class, class _Dp>
500490 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend pair<__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false> >
501491 __rotate(__bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>, __bit_iterator<_Dp, false>);
......@@ -718,13 +708,164 @@ struct __specialized_algorithm<_Algorithm::__copy,
718708 }
719709
720710 _LIBCPP_HIDE_FROM_ABI
721 _LIBCPP_CONSTEXPR_SINCE_CXX20 static pair<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
711 _LIBCPP_CONSTEXPR_SINCE_CXX20 static __in_out_result<__bit_iterator<_Cp, _IsConst>, __bit_iterator<_Cp, false> >
722712 operator()(__bit_iterator<_Cp, _IsConst> __first,
723713 __bit_iterator<_Cp, _IsConst> __last,
724714 __bit_iterator<_Cp, false> __result) {
725715 if (__first.__ctz_ == __result.__ctz_)
726 return std::make_pair(__last, __aligned_impl(__first, __last, __result));
727 return std::make_pair(__last, __unaligned_impl(__first, __last, __result));
716 return {__last, __aligned_impl(__first, __last, __result)};
717 return {__last, __unaligned_impl(__first, __last, __result)};
718 }
719};
720
721template <class _Cl, class _Cr>
722struct __specialized_algorithm<_Algorithm::__swap_ranges,
723 __iterator_pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cl, false> >,
724 __single_iterator<__bit_iterator<_Cr, false> > > {
725 static const bool __has_algorithm = true;
726
727 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __aligned_impl(
728 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
729 using _I1 = __bit_iterator<_Cl, false>;
730 using difference_type = typename _I1::difference_type;
731 using __storage_type = typename _I1::__storage_type;
732
733 const int __bits_per_word = _I1::__bits_per_word;
734 difference_type __n = __last - __first;
735 if (__n > 0) {
736 // do first word
737 if (__first.__ctz_ != 0) {
738 unsigned __clz = __bits_per_word - __first.__ctz_;
739 difference_type __dn = std::min(static_cast<difference_type>(__clz), __n);
740 __n -= __dn;
741 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz - __dn));
742 __storage_type __b1 = *__first.__seg_ & __m;
743 *__first.__seg_ &= ~__m;
744 __storage_type __b2 = *__result.__seg_ & __m;
745 *__result.__seg_ &= ~__m;
746 *__result.__seg_ |= __b1;
747 *__first.__seg_ |= __b2;
748 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
749 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
750 ++__first.__seg_;
751 // __first.__ctz_ = 0;
752 }
753 // __first.__ctz_ == 0;
754 // do middle words
755 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_, ++__result.__seg_)
756 swap(*__first.__seg_, *__result.__seg_);
757 // do last word
758 if (__n > 0) {
759 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
760 __storage_type __b1 = *__first.__seg_ & __m;
761 *__first.__seg_ &= ~__m;
762 __storage_type __b2 = *__result.__seg_ & __m;
763 *__result.__seg_ &= ~__m;
764 *__result.__seg_ |= __b1;
765 *__first.__seg_ |= __b2;
766 __result.__ctz_ = static_cast<unsigned>(__n);
767 }
768 }
769 return __result;
770 }
771
772 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cr, false> __unaligned_impl(
773 __bit_iterator<_Cl, false> __first, __bit_iterator<_Cl, false> __last, __bit_iterator<_Cr, false> __result) {
774 using _I1 = __bit_iterator<_Cl, false>;
775 using difference_type = typename _I1::difference_type;
776 using __storage_type = typename _I1::__storage_type;
777
778 const int __bits_per_word = _I1::__bits_per_word;
779 difference_type __n = __last - __first;
780 if (__n > 0) {
781 // do first word
782 if (__first.__ctz_ != 0) {
783 unsigned __clz_f = __bits_per_word - __first.__ctz_;
784 difference_type __dn = std::min(static_cast<difference_type>(__clz_f), __n);
785 __n -= __dn;
786 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
787 __storage_type __b1 = *__first.__seg_ & __m;
788 *__first.__seg_ &= ~__m;
789 unsigned __clz_r = __bits_per_word - __result.__ctz_;
790 __storage_type __ddn = std::min<__storage_type>(__dn, __clz_r);
791 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __ddn));
792 __storage_type __b2 = *__result.__seg_ & __m;
793 *__result.__seg_ &= ~__m;
794 if (__result.__ctz_ > __first.__ctz_) {
795 unsigned __s = __result.__ctz_ - __first.__ctz_;
796 *__result.__seg_ |= __b1 << __s;
797 *__first.__seg_ |= __b2 >> __s;
798 } else {
799 unsigned __s = __first.__ctz_ - __result.__ctz_;
800 *__result.__seg_ |= __b1 >> __s;
801 *__first.__seg_ |= __b2 << __s;
802 }
803 __result.__seg_ += (__ddn + __result.__ctz_) / __bits_per_word;
804 __result.__ctz_ = static_cast<unsigned>((__ddn + __result.__ctz_) % __bits_per_word);
805 __dn -= __ddn;
806 if (__dn > 0) {
807 __m = ~__storage_type(0) >> (__bits_per_word - __dn);
808 __b2 = *__result.__seg_ & __m;
809 *__result.__seg_ &= ~__m;
810 unsigned __s = __first.__ctz_ + __ddn;
811 *__result.__seg_ |= __b1 >> __s;
812 *__first.__seg_ |= __b2 << __s;
813 __result.__ctz_ = static_cast<unsigned>(__dn);
814 }
815 ++__first.__seg_;
816 // __first.__ctz_ = 0;
817 }
818 // __first.__ctz_ == 0;
819 // do middle words
820 __storage_type __m = ~__storage_type(0) << __result.__ctz_;
821 unsigned __clz_r = __bits_per_word - __result.__ctz_;
822 for (; __n >= __bits_per_word; __n -= __bits_per_word, ++__first.__seg_) {
823 __storage_type __b1 = *__first.__seg_;
824 __storage_type __b2 = *__result.__seg_ & __m;
825 *__result.__seg_ &= ~__m;
826 *__result.__seg_ |= __b1 << __result.__ctz_;
827 *__first.__seg_ = __b2 >> __result.__ctz_;
828 ++__result.__seg_;
829 __b2 = *__result.__seg_ & ~__m;
830 *__result.__seg_ &= __m;
831 *__result.__seg_ |= __b1 >> __clz_r;
832 *__first.__seg_ |= __b2 << __clz_r;
833 }
834 // do last word
835 if (__n > 0) {
836 __m = ~__storage_type(0) >> (__bits_per_word - __n);
837 __storage_type __b1 = *__first.__seg_ & __m;
838 *__first.__seg_ &= ~__m;
839 __storage_type __dn = std::min<__storage_type>(__n, __clz_r);
840 __m = (~__storage_type(0) << __result.__ctz_) & (~__storage_type(0) >> (__clz_r - __dn));
841 __storage_type __b2 = *__result.__seg_ & __m;
842 *__result.__seg_ &= ~__m;
843 *__result.__seg_ |= __b1 << __result.__ctz_;
844 *__first.__seg_ |= __b2 >> __result.__ctz_;
845 __result.__seg_ += (__dn + __result.__ctz_) / __bits_per_word;
846 __result.__ctz_ = static_cast<unsigned>((__dn + __result.__ctz_) % __bits_per_word);
847 __n -= __dn;
848 if (__n > 0) {
849 __m = ~__storage_type(0) >> (__bits_per_word - __n);
850 __b2 = *__result.__seg_ & __m;
851 *__result.__seg_ &= ~__m;
852 *__result.__seg_ |= __b1 >> __dn;
853 *__first.__seg_ |= __b2 << __dn;
854 __result.__ctz_ = static_cast<unsigned>(__n);
855 }
856 }
857 }
858 return __result;
859 }
860
861 _LIBCPP_HIDE_FROM_ABI static
862 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<__bit_iterator<_Cl, false>, __bit_iterator<_Cr, false> >
863 operator()(__bit_iterator<_Cl, false> __first1,
864 __bit_iterator<_Cl, false> __last1,
865 __bit_iterator<_Cr, false> __first2) {
866 if (__first1.__ctz_ == __first2.__ctz_)
867 return std::make_pair(__last1, __aligned_impl(__first1, __last1, __first2));
868 return std::make_pair(__last1, __unaligned_impl(__first1, __last1, __first2));
728869 }
729870};
730871
lib/libcxx/include/__charconv/from_chars_floating_point.h+2
......@@ -35,6 +35,7 @@ struct __from_chars_result {
3535 errc __ec;
3636};
3737
38_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3839template <class _Fp>
3940_LIBCPP_EXPORTED_FROM_ABI __from_chars_result<_Fp> __from_chars_floating_point(
4041 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
......@@ -44,6 +45,7 @@ extern template __from_chars_result<float> __from_chars_floating_point(
4445
4546extern template __from_chars_result<double> __from_chars_floating_point(
4647 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
48_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4749
4850template <class _Fp>
4951_LIBCPP_HIDE_FROM_ABI from_chars_result
lib/libcxx/include/__charconv/from_chars_integral.h+1-4
......@@ -10,12 +10,10 @@
1010#ifndef _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
1111#define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
1212
13#include <__algorithm/copy_n.h>
1413#include <__assert>
1514#include <__charconv/from_chars_result.h>
1615#include <__charconv/traits.h>
1716#include <__config>
18#include <__memory/addressof.h>
1917#include <__system_error/errc.h>
2018#include <__type_traits/enable_if.h>
2119#include <__type_traits/is_integral.h>
......@@ -56,8 +54,7 @@ __sign_combinator(_It __first, _It __last, _Tp& __value, _Fn __f, _Ts... __args)
5654
5755 if (__neg) {
5856 if (__x <= std::__complement(std::__to_unsigned_like(__tl::min()))) {
59 __x = std::__complement(__x);
60 std::copy_n(std::addressof(__x), 1, std::addressof(__value));
57 __value = std::__complement(__x);
6158 return __r;
6259 }
6360 } else {
lib/libcxx/include/__charconv/to_chars.h-4
......@@ -18,8 +18,4 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23_LIBCPP_END_NAMESPACE_STD
24
2521#endif // _LIBCPP___CHARCONV_TO_CHARS
lib/libcxx/include/__charconv/to_chars_floating_point.h+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324#if _LIBCPP_STD_VER >= 17
2425
......@@ -50,6 +51,7 @@ _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_EXPORTED_FROM_ABI to_chars_
5051to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision);
5152#endif // _LIBCPP_STD_VER >= 17
5253
54_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5355_LIBCPP_END_NAMESPACE_STD
5456
5557#endif // _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
lib/libcxx/include/__chrono/convert_to_tm.h+4-1
......@@ -127,7 +127,10 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(chrono::tai_time<_Duration> __tp) {
127127
128128template <class _Tm, class _Duration>
129129_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)));
130 using _Rp = common_type_t<_Duration, chrono::seconds>;
131 // The time between the GPS epoch (1980-01-06) and UNIX epoch (1970-01-01).
132 constexpr chrono::seconds __offset{3657 * 24 * 60 * 60};
133 return std::__convert_to_tm<_Tm>(chrono::sys_time<_Rp>{__tp.time_since_epoch() + __offset});
131134}
132135
133136# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/day.h+8-6
......@@ -55,7 +55,7 @@ public:
5555 _LIBCPP_HIDE_FROM_ABI constexpr day& operator+=(const days& __dd) noexcept;
5656 _LIBCPP_HIDE_FROM_ABI constexpr day& operator-=(const days& __dd) noexcept;
5757 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __d_; }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
58 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __d_ >= 1 && __d_ <= 31; }
5959};
6060
6161_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const day& __lhs, const day& __rhs) noexcept {
......@@ -66,19 +66,19 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const day& __
6666 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
6767}
6868
69_LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const day& __lhs, const days& __rhs) noexcept {
69[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const day& __lhs, const days& __rhs) noexcept {
7070 return day(static_cast<unsigned>(__lhs) + __rhs.count());
7171}
7272
73_LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const days& __lhs, const day& __rhs) noexcept {
73[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr day operator+(const days& __lhs, const day& __rhs) noexcept {
7474 return __rhs + __lhs;
7575}
7676
77_LIBCPP_HIDE_FROM_ABI inline constexpr day operator-(const day& __lhs, const days& __rhs) noexcept {
77[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr day operator-(const day& __lhs, const days& __rhs) noexcept {
7878 return __lhs + -__rhs;
7979}
8080
81_LIBCPP_HIDE_FROM_ABI inline constexpr days operator-(const day& __lhs, const day& __rhs) noexcept {
81[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr days operator-(const day& __lhs, const day& __rhs) noexcept {
8282 return days(static_cast<int>(static_cast<unsigned>(__lhs)) - static_cast<int>(static_cast<unsigned>(__rhs)));
8383}
8484
......@@ -98,7 +98,9 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr day& day::operator-=(const days& __dd) no
9898
9999template <>
100100struct hash<chrono::day> {
101 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::day& __d) noexcept { return static_cast<unsigned>(__d); }
101 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::day& __d) noexcept {
102 return static_cast<unsigned>(__d);
103 }
102104};
103105
104106# endif // _LIBCPP_STD_VER >= 26
lib/libcxx/include/__chrono/duration.h+12-38
......@@ -19,6 +19,7 @@
1919#include <__type_traits/enable_if.h>
2020#include <__type_traits/is_convertible.h>
2121#include <__type_traits/is_floating_point.h>
22#include <__type_traits/is_unqualified.h>
2223#include <limits>
2324#include <ratio>
2425
......@@ -164,6 +165,7 @@ template <class _ToDuration, class _Rep, class _Period, enable_if_t<__is_duratio
164165
165166template <class _Rep, class _Period>
166167class duration {
168 static_assert(__is_unqualified_v<_Rep>, "A duration representation cannot be qualified");
167169 static_assert(!__is_duration_v<_Rep>, "A duration representation can not be a duration");
168170 static_assert(__is_ratio_v<_Period>, "Second template parameter of duration must be a std::ratio");
169171 static_assert(_Period::num > 0, "duration period must be positive");
......@@ -291,35 +293,21 @@ typedef duration<long long, nano> nanoseconds;
291293typedef duration<long long, micro> microseconds;
292294typedef duration<long long, milli> milliseconds;
293295typedef duration<long long > seconds;
294typedef duration< long, ratio< 60> > minutes;
295typedef duration< long, ratio<3600> > hours;
296typedef duration<long, ratio<60> > minutes;
297typedef duration<long, ratio<60 * 60> > hours;
296298#if _LIBCPP_STD_VER >= 20
297typedef duration< int, ratio_multiply<ratio<24>, hours::period>> days;
298typedef duration< int, ratio_multiply<ratio<7>, days::period>> weeks;
299typedef duration< int, ratio_multiply<ratio<146097, 400>, days::period>> years;
300typedef duration< int, ratio_divide<years::period, ratio<12>>> months;
299typedef duration<int, ratio<60 * 60 * 24>> days;
300typedef duration<int, ratio<60 * 60 * 24 * 7>> weeks;
301typedef duration<int, ratio<static_cast<int>(365.2425 * 60 * 60 * 24)>> years;
302typedef duration<int, ratio<static_cast<int>(365.2425 * 60 * 60 * 24) / 12>> months;
301303#endif
302304// Duration ==
303305
304template <class _LhsDuration, class _RhsDuration>
305struct __duration_eq {
306 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {
307 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
308 return _Ct(__lhs).count() == _Ct(__rhs).count();
309 }
310};
311
312template <class _LhsDuration>
313struct __duration_eq<_LhsDuration, _LhsDuration> {
314 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {
315 return __lhs.count() == __rhs.count();
316 }
317};
318
319306template <class _Rep1, class _Period1, class _Rep2, class _Period2>
320307inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
321308operator==(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
322 return __duration_eq<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
309 using _Ct = typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type;
310 return _Ct(__lhs).count() == _Ct(__rhs).count();
323311}
324312
325313#if _LIBCPP_STD_VER <= 17
......@@ -336,25 +324,11 @@ operator!=(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period
336324
337325// Duration <
338326
339template <class _LhsDuration, class _RhsDuration>
340struct __duration_lt {
341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _RhsDuration& __rhs) const {
342 typedef typename common_type<_LhsDuration, _RhsDuration>::type _Ct;
343 return _Ct(__lhs).count() < _Ct(__rhs).count();
344 }
345};
346
347template <class _LhsDuration>
348struct __duration_lt<_LhsDuration, _LhsDuration> {
349 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator()(const _LhsDuration& __lhs, const _LhsDuration& __rhs) const {
350 return __lhs.count() < __rhs.count();
351 }
352};
353
354327template <class _Rep1, class _Period1, class _Rep2, class _Period2>
355328inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
356329operator<(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
357 return __duration_lt<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >()(__lhs, __rhs);
330 using _Ct = typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type;
331 return _Ct(__lhs).count() < _Ct(__rhs).count();
358332}
359333
360334// Duration >
lib/libcxx/include/__chrono/exception.h+2
......@@ -31,6 +31,7 @@
3131# endif
3232
3333_LIBCPP_BEGIN_NAMESPACE_STD
34_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3435
3536# if _LIBCPP_STD_VER >= 20
3637
......@@ -128,6 +129,7 @@ template <class _Duration>
128129
129130# endif // _LIBCPP_STD_VER >= 20
130131
132_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
131133_LIBCPP_END_NAMESPACE_STD
132134
133135#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/file_clock.h+4
......@@ -46,6 +46,8 @@ _LIBCPP_END_NAMESPACE_STD
4646
4747#ifndef _LIBCPP_CXX03_LANG
4848_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
49_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
50
4951struct _FilesystemClock {
5052# if _LIBCPP_HAS_INT128
5153 typedef __int128_t rep;
......@@ -76,6 +78,8 @@ struct _FilesystemClock {
7678 }
7779# endif // _LIBCPP_STD_VER >= 20
7880};
81
82_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7983_LIBCPP_END_NAMESPACE_FILESYSTEM
8084#endif // !_LIBCPP_CXX03_LANG
8185
lib/libcxx/include/__chrono/gps_clock.h+4-4
......@@ -28,10 +28,10 @@
2828_LIBCPP_PUSH_MACROS
2929# include <__undef_macros>
3030
31_LIBCPP_BEGIN_NAMESPACE_STD
32
3331# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
3432
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3535namespace chrono {
3636
3737class gps_clock;
......@@ -78,11 +78,11 @@ public:
7878
7979} // namespace chrono
8080
81_LIBCPP_END_NAMESPACE_STD
82
8183# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
8284 // _LIBCPP_HAS_LOCALIZATION
8385
84_LIBCPP_END_NAMESPACE_STD
85
8686_LIBCPP_POP_MACROS
8787
8888#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/hh_mm_ss.h+10-10
......@@ -59,13 +59,13 @@ public:
5959 __s_(chrono::duration_cast<chrono::seconds>(chrono::abs(__d) - hours() - minutes())),
6060 __f_(chrono::duration_cast<precision>(chrono::abs(__d) - hours() - minutes() - seconds())) {}
6161
62 _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg_; }
63 _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h_; }
64 _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m_; }
65 _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s_; }
66 _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f_; }
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool is_negative() const noexcept { return __is_neg_; }
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::hours hours() const noexcept { return __h_; }
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::minutes minutes() const noexcept { return __m_; }
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::seconds seconds() const noexcept { return __s_; }
66 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr precision subseconds() const noexcept { return __f_; }
6767
68 _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept {
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr precision to_duration() const noexcept {
6969 auto __dur = __h_ + __m_ + __s_ + __f_;
7070 return __is_neg_ ? -__dur : __dur;
7171 }
......@@ -81,14 +81,14 @@ private:
8181};
8282_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(hh_mm_ss);
8383
84_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_am(const hours& __h) noexcept {
84[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_am(const hours& __h) noexcept {
8585 return __h >= hours(0) && __h < hours(12);
8686}
87_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_pm(const hours& __h) noexcept {
87[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_pm(const hours& __h) noexcept {
8888 return __h >= hours(12) && __h < hours(24);
8989}
9090
91_LIBCPP_HIDE_FROM_ABI inline constexpr hours make12(const hours& __h) noexcept {
91[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr hours make12(const hours& __h) noexcept {
9292 if (__h == hours(0))
9393 return hours(12);
9494 else if (__h <= hours(12))
......@@ -97,7 +97,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr hours make12(const hours& __h) noexcept {
9797 return __h - hours(12);
9898}
9999
100_LIBCPP_HIDE_FROM_ABI inline constexpr hours make24(const hours& __h, bool __is_pm) noexcept {
100[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr hours make24(const hours& __h, bool __is_pm) noexcept {
101101 if (__is_pm)
102102 return __h == hours(12) ? __h : __h + hours(12);
103103 else
lib/libcxx/include/__chrono/literals.h+2-2
......@@ -24,11 +24,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
2525inline namespace literals {
2626inline namespace chrono_literals {
27_LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator""d(unsigned long long __d) noexcept {
27[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::day operator""d(unsigned long long __d) noexcept {
2828 return chrono::day(static_cast<unsigned>(__d));
2929}
3030
31_LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator""y(unsigned long long __y) noexcept {
31[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::year operator""y(unsigned long long __y) noexcept {
3232 return chrono::year(static_cast<int>(__y));
3333}
3434} // namespace chrono_literals
lib/libcxx/include/__chrono/month.h+6-6
......@@ -55,7 +55,7 @@ public:
5555 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
5656 _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
5757 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m_; }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
58 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
5959};
6060
6161_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const month& __lhs, const month& __rhs) noexcept {
......@@ -66,21 +66,21 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const month&
6666 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
6767}
6868
69_LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const month& __lhs, const months& __rhs) noexcept {
69[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const month& __lhs, const months& __rhs) noexcept {
7070 auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
7171 auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
7272 return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
7373}
7474
75_LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const months& __lhs, const month& __rhs) noexcept {
75[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const months& __lhs, const month& __rhs) noexcept {
7676 return __rhs + __lhs;
7777}
7878
79_LIBCPP_HIDE_FROM_ABI inline constexpr month operator-(const month& __lhs, const months& __rhs) noexcept {
79[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month operator-(const month& __lhs, const months& __rhs) noexcept {
8080 return __lhs + -__rhs;
8181}
8282
83_LIBCPP_HIDE_FROM_ABI inline constexpr months operator-(const month& __lhs, const month& __rhs) noexcept {
83[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr months operator-(const month& __lhs, const month& __rhs) noexcept {
8484 auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
8585 return months(__dm <= 11 ? __dm : __dm + 12);
8686}
......@@ -114,7 +114,7 @@ inline constexpr month December{12};
114114
115115template <>
116116struct hash<chrono::month> {
117 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept {
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept {
118118 return static_cast<unsigned>(__m);
119119 }
120120};
lib/libcxx/include/__chrono/month_weekday.h+24-16
......@@ -35,9 +35,11 @@ public:
3535 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday(const chrono::month& __mval,
3636 const chrono::weekday_indexed& __wdival) noexcept
3737 : __m_{__mval}, __wdi_{__wdival} {}
38 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
39 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
38 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept {
40 return __wdi_;
41 }
42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdi_.ok(); }
4143};
4244
4345_LIBCPP_HIDE_FROM_ABI inline constexpr bool
......@@ -45,21 +47,23 @@ operator==(const month_weekday& __lhs, const month_weekday& __rhs) noexcept {
4547 return __lhs.month() == __rhs.month() && __lhs.weekday_indexed() == __rhs.weekday_indexed();
4648}
4749
48_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
50[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
4951operator/(const month& __lhs, const weekday_indexed& __rhs) noexcept {
5052 return month_weekday{__lhs, __rhs};
5153}
5254
53_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(int __lhs, const weekday_indexed& __rhs) noexcept {
55[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
56operator/(int __lhs, const weekday_indexed& __rhs) noexcept {
5457 return month_weekday{month(__lhs), __rhs};
5558}
5659
57_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
60[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
5861operator/(const weekday_indexed& __lhs, const month& __rhs) noexcept {
5962 return month_weekday{__rhs, __lhs};
6063}
6164
62_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept {
65[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday
66operator/(const weekday_indexed& __lhs, int __rhs) noexcept {
6367 return month_weekday{month(__rhs), __lhs};
6468}
6569
......@@ -71,9 +75,11 @@ public:
7175 _LIBCPP_HIDE_FROM_ABI constexpr month_weekday_last(const chrono::month& __mval,
7276 const chrono::weekday_last& __wdlval) noexcept
7377 : __m_{__mval}, __wdl_{__wdlval} {}
74 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
75 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
76 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
78 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept {
80 return __wdl_;
81 }
82 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok() && __wdl_.ok(); }
7783};
7884
7985_LIBCPP_HIDE_FROM_ABI inline constexpr bool
......@@ -81,21 +87,23 @@ operator==(const month_weekday_last& __lhs, const month_weekday_last& __rhs) noe
8187 return __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last();
8288}
8389
84_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
90[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
8591operator/(const month& __lhs, const weekday_last& __rhs) noexcept {
8692 return month_weekday_last{__lhs, __rhs};
8793}
8894
89_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(int __lhs, const weekday_last& __rhs) noexcept {
95[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
96operator/(int __lhs, const weekday_last& __rhs) noexcept {
9097 return month_weekday_last{month(__lhs), __rhs};
9198}
9299
93_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
100[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
94101operator/(const weekday_last& __lhs, const month& __rhs) noexcept {
95102 return month_weekday_last{__rhs, __lhs};
96103}
97104
98_LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept {
105[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last
106operator/(const weekday_last& __lhs, int __rhs) noexcept {
99107 return month_weekday_last{month(__rhs), __lhs};
100108}
101109} // namespace chrono
......@@ -104,7 +112,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_weekday_last operator/(const weekda
104112
105113template <>
106114struct hash<chrono::month_weekday> {
107 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday& __mw) noexcept {
115 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday& __mw) noexcept {
108116 return std::__hash_combine(
109117 hash<chrono::month>{}(__mw.month()), hash<chrono::weekday_indexed>{}(__mw.weekday_indexed()));
110118 }
......@@ -112,7 +120,7 @@ struct hash<chrono::month_weekday> {
112120
113121template <>
114122struct hash<chrono::month_weekday_last> {
115 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday_last& __mwl) noexcept {
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_weekday_last& __mwl) noexcept {
116124 return std::__hash_combine(
117125 hash<chrono::month>{}(__mwl.month()), hash<chrono::weekday_last>{}(__mwl.weekday_last()));
118126 }
lib/libcxx/include/__chrono/monthday.h+18-16
......@@ -37,9 +37,9 @@ public:
3737 month_day() = default;
3838 _LIBCPP_HIDE_FROM_ABI constexpr month_day(const chrono::month& __mval, const chrono::day& __dval) noexcept
3939 : __m_{__mval}, __d_{__dval} {}
40 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
41 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
42 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
4343};
4444
4545_LIBCPP_HIDE_FROM_ABI inline constexpr bool month_day::ok() const noexcept {
......@@ -70,23 +70,25 @@ operator<=>(const month_day& __lhs, const month_day& __rhs) noexcept {
7070 return __lhs.day() <=> __rhs.day();
7171}
7272
73_LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const month& __lhs, const day& __rhs) noexcept {
73[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day
74operator/(const month& __lhs, const day& __rhs) noexcept {
7475 return month_day{__lhs, __rhs};
7576}
7677
77_LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const day& __lhs, const month& __rhs) noexcept {
78[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day
79operator/(const day& __lhs, const month& __rhs) noexcept {
7880 return __rhs / __lhs;
7981}
8082
81_LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const month& __lhs, int __rhs) noexcept {
83[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const month& __lhs, int __rhs) noexcept {
8284 return __lhs / day(__rhs);
8385}
8486
85_LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(int __lhs, const day& __rhs) noexcept {
87[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(int __lhs, const day& __rhs) noexcept {
8688 return month(__lhs) / __rhs;
8789}
8890
89_LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const day& __lhs, int __rhs) noexcept {
91[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day operator/(const day& __lhs, int __rhs) noexcept {
9092 return month(__rhs) / __lhs;
9193}
9294
......@@ -96,8 +98,8 @@ private:
9698
9799public:
98100 _LIBCPP_HIDE_FROM_ABI explicit constexpr month_day_last(const chrono::month& __val) noexcept : __m_{__val} {}
99 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
100 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok(); }
101 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
102 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_.ok(); }
101103};
102104
103105_LIBCPP_HIDE_FROM_ABI inline constexpr bool
......@@ -110,19 +112,19 @@ operator<=>(const month_day_last& __lhs, const month_day_last& __rhs) noexcept {
110112 return __lhs.month() <=> __rhs.month();
111113}
112114
113_LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(const month& __lhs, last_spec) noexcept {
115[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(const month& __lhs, last_spec) noexcept {
114116 return month_day_last{__lhs};
115117}
116118
117_LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, const month& __rhs) noexcept {
119[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, const month& __rhs) noexcept {
118120 return month_day_last{__rhs};
119121}
120122
121_LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(int __lhs, last_spec) noexcept {
123[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(int __lhs, last_spec) noexcept {
122124 return month_day_last{month(__lhs)};
123125}
124126
125_LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int __rhs) noexcept {
127[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int __rhs) noexcept {
126128 return month_day_last{month(__rhs)};
127129}
128130
......@@ -132,14 +134,14 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr month_day_last operator/(last_spec, int _
132134
133135template <>
134136struct hash<chrono::month_day> {
135 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day& __md) noexcept {
137 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day& __md) noexcept {
136138 return std::__hash_combine(hash<chrono::month>{}(__md.month()), hash<chrono::day>{}(__md.day()));
137139 }
138140};
139141
140142template <>
141143struct hash<chrono::month_day_last> {
142 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day_last& __mdl) noexcept {
144 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month_day_last& __mdl) noexcept {
143145 return hash<chrono::month>{}(__mdl.month());
144146 }
145147};
lib/libcxx/include/__chrono/steady_clock.h+6-2
......@@ -18,11 +18,13 @@
1818# pragma GCC system_header
1919#endif
2020
21#if _LIBCPP_HAS_MONOTONIC_CLOCK
22
2123_LIBCPP_BEGIN_NAMESPACE_STD
24_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2225
2326namespace chrono {
2427
25#if _LIBCPP_HAS_MONOTONIC_CLOCK
2628class _LIBCPP_EXPORTED_FROM_ABI steady_clock {
2729public:
2830 typedef nanoseconds duration;
......@@ -33,10 +35,12 @@ public:
3335
3436 [[__nodiscard__]] static time_point now() _NOEXCEPT;
3537};
36#endif
3738
3839} // namespace chrono
3940
41_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4042_LIBCPP_END_NAMESPACE_STD
4143
44#endif
45
4246#endif // _LIBCPP___CHRONO_STEADY_CLOCK_H
lib/libcxx/include/__chrono/system_clock.h+2
......@@ -20,6 +20,7 @@
2020#endif
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
23_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2324
2425namespace chrono {
2526
......@@ -47,6 +48,7 @@ using sys_days = sys_time<days>;
4748
4849} // namespace chrono
4950
51_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5052_LIBCPP_END_NAMESPACE_STD
5153
5254#endif // _LIBCPP___CHRONO_SYSTEM_CLOCK_H
lib/libcxx/include/__chrono/tai_clock.h+4-4
......@@ -28,10 +28,10 @@
2828_LIBCPP_PUSH_MACROS
2929# include <__undef_macros>
3030
31_LIBCPP_BEGIN_NAMESPACE_STD
32
3331# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
3432
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3535namespace chrono {
3636
3737class tai_clock;
......@@ -96,11 +96,11 @@ public:
9696
9797} // namespace chrono
9898
99_LIBCPP_END_NAMESPACE_STD
100
99101# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
100102 // _LIBCPP_HAS_LOCALIZATION
101103
102_LIBCPP_END_NAMESPACE_STD
103
104104_LIBCPP_POP_MACROS
105105
106106#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/time_zone.h+6-4
......@@ -35,10 +35,11 @@
3535_LIBCPP_PUSH_MACROS
3636# include <__undef_macros>
3737
38_LIBCPP_BEGIN_NAMESPACE_STD
39
4038# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
4139
40_LIBCPP_BEGIN_NAMESPACE_STD
41_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
42
4243namespace chrono {
4344
4445enum class choose { earliest, latest };
......@@ -173,11 +174,12 @@ operator<=>(const time_zone& __x, const time_zone& __y) noexcept {
173174
174175} // namespace chrono
175176
177_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
178_LIBCPP_END_NAMESPACE_STD
179
176180# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
177181 // _LIBCPP_HAS_LOCALIZATION
178182
179_LIBCPP_END_NAMESPACE_STD
180
181183_LIBCPP_POP_MACROS
182184
183185#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/time_zone_link.h+4-4
......@@ -29,10 +29,10 @@
2929_LIBCPP_PUSH_MACROS
3030# include <__undef_macros>
3131
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3432# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
3533
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3636namespace chrono {
3737
3838class time_zone_link {
......@@ -67,11 +67,11 @@ operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {
6767
6868} // namespace chrono
6969
70_LIBCPP_END_NAMESPACE_STD
71
7072# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
7173 // _LIBCPP_HAS_LOCALIZATION
7274
73_LIBCPP_END_NAMESPACE_STD
74
7575_LIBCPP_POP_MACROS
7676
7777#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/tzdb.h+6-4
......@@ -34,10 +34,11 @@
3434_LIBCPP_PUSH_MACROS
3535# include <__undef_macros>
3636
37_LIBCPP_BEGIN_NAMESPACE_STD
38
3937# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
4038
39_LIBCPP_BEGIN_NAMESPACE_STD
40_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
41
4142namespace chrono {
4243
4344struct tzdb {
......@@ -84,11 +85,12 @@ private:
8485
8586} // namespace chrono
8687
88_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
89_LIBCPP_END_NAMESPACE_STD
90
8791# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
8892 // _LIBCPP_HAS_LOCALIZATION
8993
90_LIBCPP_END_NAMESPACE_STD
91
9294_LIBCPP_POP_MACROS
9395
9496#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__chrono/tzdb_list.h+6-4
......@@ -27,10 +27,11 @@
2727# pragma GCC system_header
2828# endif
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
34
3435namespace chrono {
3536
3637// TODO TZDB
......@@ -98,11 +99,12 @@ _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();
9899
99100} // namespace chrono
100101
102_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
103_LIBCPP_END_NAMESPACE_STD
104
101105# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
102106 // _LIBCPP_HAS_LOCALIZATION
103107
104_LIBCPP_END_NAMESPACE_STD
105
106108#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
107109
108110#endif // _LIBCPP___CHRONO_TZDB_LIST_H
lib/libcxx/include/__chrono/utc_clock.h+4-4
......@@ -27,10 +27,10 @@
2727# pragma GCC system_header
2828# endif
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3434namespace chrono {
3535
3636class utc_clock;
......@@ -153,11 +153,11 @@ utc_clock::to_sys(const utc_time<_Duration>& __time) {
153153
154154} // namespace chrono
155155
156_LIBCPP_END_NAMESPACE_STD
157
156158# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
157159 // _LIBCPP_HAS_LOCALIZATION
158160
159_LIBCPP_END_NAMESPACE_STD
160
161161#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
162162
163163#endif // _LIBCPP___CHRONO_UTC_CLOCK_H
lib/libcxx/include/__chrono/weekday.h+27-17
......@@ -65,11 +65,13 @@ public:
6565 }
6666 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator+=(const days& __dd) noexcept;
6767 _LIBCPP_HIDE_FROM_ABI constexpr weekday& operator-=(const days& __dd) noexcept;
68 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd_; }
69 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept { return __wd_ == 0u ? 7 : __wd_; }
70 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_ <= 6; }
71 _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
72 _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned c_encoding() const noexcept { return __wd_; }
69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned iso_encoding() const noexcept {
70 return __wd_ == 0u ? 7 : __wd_;
71 }
72 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_ <= 6; }
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr weekday_indexed operator[](unsigned __index) const noexcept;
74 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr weekday_last operator[](last_spec) const noexcept;
7375};
7476
7577// https://howardhinnant.github.io/date_algorithms.html#weekday_from_days
......@@ -81,21 +83,25 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con
8183 return __lhs.c_encoding() == __rhs.c_encoding();
8284}
8385
84_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept {
86[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr weekday
87operator+(const weekday& __lhs, const days& __rhs) noexcept {
8588 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
8689 auto const __yr = (__mu >= 0 ? __mu : __mu - 6) / 7;
8790 return weekday{static_cast<unsigned>(__mu - __yr * 7)};
8891}
8992
90_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const days& __lhs, const weekday& __rhs) noexcept {
93[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr weekday
94operator+(const days& __lhs, const weekday& __rhs) noexcept {
9195 return __rhs + __lhs;
9296}
9397
94_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator-(const weekday& __lhs, const days& __rhs) noexcept {
98[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr weekday
99operator-(const weekday& __lhs, const days& __rhs) noexcept {
95100 return __lhs + -__rhs;
96101}
97102
98_LIBCPP_HIDE_FROM_ABI inline constexpr days operator-(const weekday& __lhs, const weekday& __rhs) noexcept {
103[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr days
104operator-(const weekday& __lhs, const weekday& __rhs) noexcept {
99105 const int __wdu = __lhs.c_encoding() - __rhs.c_encoding();
100106 const int __wk = (__wdu >= 0 ? __wdu : __wdu - 6) / 7;
101107 return days{__wdu - __wk * 7};
......@@ -120,9 +126,11 @@ public:
120126 weekday_indexed() = default;
121127 _LIBCPP_HIDE_FROM_ABI inline constexpr weekday_indexed(const chrono::weekday& __wdval, unsigned __idxval) noexcept
122128 : __wd_{__wdval}, __idx_(__idxval) {}
123 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd_; }
124 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx_; }
125 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __wd_.ok() && __idx_ >= 1 && __idx_ <= 5; }
129 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wd_; }
130 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __idx_; }
131 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept {
132 return __wd_.ok() && __idx_ >= 1 && __idx_ <= 5;
133 }
126134};
127135
128136_LIBCPP_HIDE_FROM_ABI inline constexpr bool
......@@ -136,8 +144,8 @@ private:
136144
137145public:
138146 _LIBCPP_HIDE_FROM_ABI explicit constexpr weekday_last(const chrono::weekday& __val) noexcept : __wd_{__val} {}
139 _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd_; }
140 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd_.ok(); }
147 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::weekday weekday() const noexcept { return __wd_; }
148 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept { return __wd_.ok(); }
141149};
142150
143151_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday_last& __lhs, const weekday_last& __rhs) noexcept {
......@@ -166,19 +174,21 @@ inline constexpr weekday Saturday{6};
166174
167175template <>
168176struct hash<chrono::weekday> {
169 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept { return __w.c_encoding(); }
177 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept {
178 return __w.c_encoding();
179 }
170180};
171181
172182template <>
173183struct hash<chrono::weekday_indexed> {
174 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept {
184 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept {
175185 return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), __wi.index());
176186 }
177187};
178188
179189template <>
180190struct hash<chrono::weekday_last> {
181 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_last& __wl) noexcept {
191 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_last& __wl) noexcept {
182192 return hash<chrono::weekday>{}(__wl.weekday());
183193 }
184194};
lib/libcxx/include/__chrono/year.h+13-11
......@@ -58,16 +58,16 @@ public:
5858 }
5959 _LIBCPP_HIDE_FROM_ABI constexpr year& operator+=(const years& __dy) noexcept;
6060 _LIBCPP_HIDE_FROM_ABI constexpr year& operator-=(const years& __dy) noexcept;
61 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
62 _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y_}; }
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+() const noexcept { return *this; }
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-() const noexcept { return year{-__y_}; }
6363
64 _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept {
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_leap() const noexcept {
6565 return __y_ % 4 == 0 && (__y_ % 100 != 0 || __y_ % 400 == 0);
6666 }
6767 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator int() const noexcept { return __y_; }
68 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
69 _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
70 _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{32767}; }
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static inline constexpr year min() noexcept { return year{-32767}; }
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static inline constexpr year max() noexcept { return year{32767}; }
7171};
7272
7373_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const year& __lhs, const year& __rhs) noexcept {
......@@ -78,19 +78,19 @@ _LIBCPP_HIDE_FROM_ABI constexpr strong_ordering operator<=>(const year& __lhs, c
7878 return static_cast<int>(__lhs) <=> static_cast<int>(__rhs);
7979}
8080
81_LIBCPP_HIDE_FROM_ABI inline constexpr year operator+(const year& __lhs, const years& __rhs) noexcept {
81[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+(const year& __lhs, const years& __rhs) noexcept {
8282 return year(static_cast<int>(__lhs) + __rhs.count());
8383}
8484
85_LIBCPP_HIDE_FROM_ABI inline constexpr year operator+(const years& __lhs, const year& __rhs) noexcept {
85[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year operator+(const years& __lhs, const year& __rhs) noexcept {
8686 return __rhs + __lhs;
8787}
8888
89_LIBCPP_HIDE_FROM_ABI inline constexpr year operator-(const year& __lhs, const years& __rhs) noexcept {
89[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year operator-(const year& __lhs, const years& __rhs) noexcept {
9090 return __lhs + -__rhs;
9191}
9292
93_LIBCPP_HIDE_FROM_ABI inline constexpr years operator-(const year& __lhs, const year& __rhs) noexcept {
93[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr years operator-(const year& __lhs, const year& __rhs) noexcept {
9494 return years{static_cast<int>(__lhs) - static_cast<int>(__rhs)};
9595}
9696
......@@ -115,7 +115,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
115115
116116template <>
117117struct hash<chrono::year> {
118 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept { return static_cast<int>(__y); }
118 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept {
119 return static_cast<int>(__y);
120 }
119121};
120122
121123# endif // _LIBCPP_STD_VER >= 26
lib/libcxx/include/__chrono/year_month.h+20-13
......@@ -36,20 +36,20 @@ public:
3636 year_month() = default;
3737 _LIBCPP_HIDE_FROM_ABI constexpr year_month(const chrono::year& __yval, const chrono::month& __mval) noexcept
3838 : __y_{__yval}, __m_{__mval} {}
39 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
40 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
39 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
4141 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const months& __dm) noexcept;
4242 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const months& __dm) noexcept;
4343 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator+=(const years& __dy) noexcept;
4444 _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& operator-=(const years& __dy) noexcept;
45 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok(); }
45 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok(); }
4646};
4747
48_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator/(const year& __y, const month& __m) noexcept {
48[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator/(const year& __y, const month& __m) noexcept {
4949 return year_month{__y, __m};
5050}
5151
52_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator/(const year& __y, int __m) noexcept {
52[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator/(const year& __y, int __m) noexcept {
5353 return year_month{__y, month(__m)};
5454}
5555
......@@ -64,35 +64,42 @@ operator<=>(const year_month& __lhs, const year_month& __rhs) noexcept {
6464 return __lhs.month() <=> __rhs.month();
6565}
6666
67_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator+(const year_month& __lhs, const months& __rhs) noexcept {
67[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
68operator+(const year_month& __lhs, const months& __rhs) noexcept {
6869 int __dmi = static_cast<int>(static_cast<unsigned>(__lhs.month())) - 1 + __rhs.count();
6970 const int __dy = (__dmi >= 0 ? __dmi : __dmi - 11) / 12;
7071 __dmi = __dmi - __dy * 12 + 1;
7172 return (__lhs.year() + years(__dy)) / month(static_cast<unsigned>(__dmi));
7273}
7374
74_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator+(const months& __lhs, const year_month& __rhs) noexcept {
75[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
76operator+(const months& __lhs, const year_month& __rhs) noexcept {
7577 return __rhs + __lhs;
7678}
7779
78_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator+(const year_month& __lhs, const years& __rhs) noexcept {
80[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
81operator+(const year_month& __lhs, const years& __rhs) noexcept {
7982 return (__lhs.year() + __rhs) / __lhs.month();
8083}
8184
82_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator+(const years& __lhs, const year_month& __rhs) noexcept {
85[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
86operator+(const years& __lhs, const year_month& __rhs) noexcept {
8387 return __rhs + __lhs;
8488}
8589
86_LIBCPP_HIDE_FROM_ABI inline constexpr months operator-(const year_month& __lhs, const year_month& __rhs) noexcept {
90[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr months
91operator-(const year_month& __lhs, const year_month& __rhs) noexcept {
8792 return (__lhs.year() - __rhs.year()) +
8893 months(static_cast<unsigned>(__lhs.month()) - static_cast<unsigned>(__rhs.month()));
8994}
9095
91_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator-(const year_month& __lhs, const months& __rhs) noexcept {
96[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
97operator-(const year_month& __lhs, const months& __rhs) noexcept {
9298 return __lhs + -__rhs;
9399}
94100
95_LIBCPP_HIDE_FROM_ABI inline constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noexcept {
101[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month
102operator-(const year_month& __lhs, const years& __rhs) noexcept {
96103 return __lhs + -__rhs;
97104}
98105
......@@ -122,7 +129,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr year_month& year_month::operator-=(const
122129
123130template <>
124131struct hash<chrono::year_month> {
125 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month& __ym) noexcept {
132 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month& __ym) noexcept {
126133 return std::__hash_combine(hash<chrono::year>{}(__ym.year()), hash<chrono::month>{}(__ym.month()));
127134 }
128135};
lib/libcxx/include/__chrono/year_month_day.h+45-34
......@@ -59,15 +59,15 @@ public:
5959 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator+=(const years& __dy) noexcept;
6060 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day& operator-=(const years& __dy) noexcept;
6161
62 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
63 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
64 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day day() const noexcept { return __d_; }
6565 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
6666 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept {
6767 return local_days{__to_days()};
6868 }
6969
70 _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool ok() const noexcept;
7171
7272 _LIBCPP_HIDE_FROM_ABI static constexpr year_month_day __from_days(days __d) noexcept;
7373 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
......@@ -119,56 +119,62 @@ operator<=>(const year_month_day& __lhs, const year_month_day& __rhs) noexcept {
119119 return __lhs.day() <=> __rhs.day();
120120}
121121
122_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(const year_month& __lhs, const day& __rhs) noexcept {
122[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
123operator/(const year_month& __lhs, const day& __rhs) noexcept {
123124 return year_month_day{__lhs.year(), __lhs.month(), __rhs};
124125}
125126
126_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(const year_month& __lhs, int __rhs) noexcept {
127[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
128operator/(const year_month& __lhs, int __rhs) noexcept {
127129 return __lhs / day(__rhs);
128130}
129131
130_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(const year& __lhs, const month_day& __rhs) noexcept {
132[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
133operator/(const year& __lhs, const month_day& __rhs) noexcept {
131134 return __lhs / __rhs.month() / __rhs.day();
132135}
133136
134_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(int __lhs, const month_day& __rhs) noexcept {
137[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
138operator/(int __lhs, const month_day& __rhs) noexcept {
135139 return year(__lhs) / __rhs;
136140}
137141
138_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(const month_day& __lhs, const year& __rhs) noexcept {
142[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
143operator/(const month_day& __lhs, const year& __rhs) noexcept {
139144 return __rhs / __lhs;
140145}
141146
142_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day operator/(const month_day& __lhs, int __rhs) noexcept {
147[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
148operator/(const month_day& __lhs, int __rhs) noexcept {
143149 return year(__rhs) / __lhs;
144150}
145151
146_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
152[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
147153operator+(const year_month_day& __lhs, const months& __rhs) noexcept {
148154 return (__lhs.year() / __lhs.month() + __rhs) / __lhs.day();
149155}
150156
151_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
157[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
152158operator+(const months& __lhs, const year_month_day& __rhs) noexcept {
153159 return __rhs + __lhs;
154160}
155161
156_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
162[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
157163operator-(const year_month_day& __lhs, const months& __rhs) noexcept {
158164 return __lhs + -__rhs;
159165}
160166
161_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
167[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
162168operator+(const year_month_day& __lhs, const years& __rhs) noexcept {
163169 return (__lhs.year() + __rhs) / __lhs.month() / __lhs.day();
164170}
165171
166_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
172[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
167173operator+(const years& __lhs, const year_month_day& __rhs) noexcept {
168174 return __rhs + __lhs;
169175}
170176
171_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
177[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day
172178operator-(const year_month_day& __lhs, const years& __rhs) noexcept {
173179 return __lhs + -__rhs;
174180}
......@@ -204,17 +210,19 @@ public:
204210 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator+=(const years& __y) noexcept;
205211 _LIBCPP_HIDE_FROM_ABI constexpr year_month_day_last& operator-=(const years& __y) noexcept;
206212
207 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
208 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl_.month(); }
209 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept { return __mdl_; }
210 _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
213 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
214 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __mdl_.month(); }
215 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month_day_last month_day_last() const noexcept {
216 return __mdl_;
217 }
218 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr chrono::day day() const noexcept;
211219 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept {
212220 return sys_days{year() / month() / day()};
213221 }
214222 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept {
215223 return local_days{year() / month() / day()};
216224 }
217 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __mdl_.ok(); }
225 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __mdl_.ok(); }
218226};
219227
220228_LIBCPP_HIDE_FROM_ABI inline constexpr chrono::day year_month_day_last::day() const noexcept {
......@@ -248,54 +256,57 @@ operator<=>(const year_month_day_last& __lhs, const year_month_day_last& __rhs)
248256 return __lhs.month_day_last() <=> __rhs.month_day_last();
249257}
250258
251_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept {
259[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
260operator/(const year_month& __lhs, last_spec) noexcept {
252261 return year_month_day_last{__lhs.year(), month_day_last{__lhs.month()}};
253262}
254263
255_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
264[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
256265operator/(const year& __lhs, const month_day_last& __rhs) noexcept {
257266 return year_month_day_last{__lhs, __rhs};
258267}
259268
260_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(int __lhs, const month_day_last& __rhs) noexcept {
269[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
270operator/(int __lhs, const month_day_last& __rhs) noexcept {
261271 return year_month_day_last{year{__lhs}, __rhs};
262272}
263273
264_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
274[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
265275operator/(const month_day_last& __lhs, const year& __rhs) noexcept {
266276 return __rhs / __lhs;
267277}
268278
269_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const month_day_last& __lhs, int __rhs) noexcept {
279[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
280operator/(const month_day_last& __lhs, int __rhs) noexcept {
270281 return year{__rhs} / __lhs;
271282}
272283
273_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
284[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
274285operator+(const year_month_day_last& __lhs, const months& __rhs) noexcept {
275286 return (__lhs.year() / __lhs.month() + __rhs) / last;
276287}
277288
278_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
289[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
279290operator+(const months& __lhs, const year_month_day_last& __rhs) noexcept {
280291 return __rhs + __lhs;
281292}
282293
283_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
294[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
284295operator-(const year_month_day_last& __lhs, const months& __rhs) noexcept {
285296 return __lhs + (-__rhs);
286297}
287298
288_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
299[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
289300operator+(const year_month_day_last& __lhs, const years& __rhs) noexcept {
290301 return year_month_day_last{__lhs.year() + __rhs, __lhs.month_day_last()};
291302}
292303
293_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
304[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
294305operator+(const years& __lhs, const year_month_day_last& __rhs) noexcept {
295306 return __rhs + __lhs;
296307}
297308
298_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
309[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last
299310operator-(const year_month_day_last& __lhs, const years& __rhs) noexcept {
300311 return __lhs + (-__rhs);
301312}
......@@ -336,7 +347,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool year_month_day::ok() const noexcept
336347
337348template <>
338349struct hash<chrono::year_month_day> {
339 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day& __ymd) noexcept {
350 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day& __ymd) noexcept {
340351 return std::__hash_combine(
341352 hash<chrono::year>{}(__ymd.year()),
342353 std::__hash_combine(hash<chrono::month>{}(__ymd.month()), hash<chrono::day>{}(__ymd.day())));
......@@ -345,7 +356,7 @@ struct hash<chrono::year_month_day> {
345356
346357template <>
347358struct hash<chrono::year_month_day_last> {
348 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day_last& __ymdl) noexcept {
359 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_day_last& __ymdl) noexcept {
349360 return std::__hash_combine(
350361 hash<chrono::year>{}(__ymdl.year()), hash<chrono::month_day_last>{}(__ymdl.month_day_last()));
351362 }
lib/libcxx/include/__chrono/year_month_weekday.h+47-35
......@@ -54,17 +54,21 @@ public:
5454 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator+=(const years&) noexcept;
5555 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday& operator-=(const years&) noexcept;
5656
57 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
58 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
59 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdi_.weekday(); }
60 _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi_.index(); }
61 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept { return __wdi_; }
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
58 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept {
60 return __wdi_.weekday();
61 }
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr unsigned index() const noexcept { return __wdi_.index(); }
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_indexed weekday_indexed() const noexcept {
64 return __wdi_;
65 }
6266
6367 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
6468 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept {
6569 return local_days{__to_days()};
6670 }
67 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept {
71 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept {
6872 if (!__y_.ok() || !__m_.ok() || !__wdi_.ok())
6973 return false;
7074 if (__wdi_.index() <= 4)
......@@ -96,55 +100,57 @@ operator==(const year_month_weekday& __lhs, const year_month_weekday& __rhs) noe
96100 __lhs.weekday_indexed() == __rhs.weekday_indexed();
97101}
98102
99_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
103[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
100104operator/(const year_month& __lhs, const weekday_indexed& __rhs) noexcept {
101105 return year_month_weekday{__lhs.year(), __lhs.month(), __rhs};
102106}
103107
104_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
108[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
105109operator/(const year& __lhs, const month_weekday& __rhs) noexcept {
106110 return year_month_weekday{__lhs, __rhs.month(), __rhs.weekday_indexed()};
107111}
108112
109_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday operator/(int __lhs, const month_weekday& __rhs) noexcept {
113[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
114operator/(int __lhs, const month_weekday& __rhs) noexcept {
110115 return year(__lhs) / __rhs;
111116}
112117
113_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
118[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
114119operator/(const month_weekday& __lhs, const year& __rhs) noexcept {
115120 return __rhs / __lhs;
116121}
117122
118_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday operator/(const month_weekday& __lhs, int __rhs) noexcept {
123[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
124operator/(const month_weekday& __lhs, int __rhs) noexcept {
119125 return year(__rhs) / __lhs;
120126}
121127
122_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
128[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
123129operator+(const year_month_weekday& __lhs, const months& __rhs) noexcept {
124130 return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_indexed();
125131}
126132
127_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
133[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
128134operator+(const months& __lhs, const year_month_weekday& __rhs) noexcept {
129135 return __rhs + __lhs;
130136}
131137
132_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
138[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
133139operator-(const year_month_weekday& __lhs, const months& __rhs) noexcept {
134140 return __lhs + (-__rhs);
135141}
136142
137_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
143[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
138144operator+(const year_month_weekday& __lhs, const years& __rhs) noexcept {
139145 return year_month_weekday{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_indexed()};
140146}
141147
142_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
148[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
143149operator+(const years& __lhs, const year_month_weekday& __rhs) noexcept {
144150 return __rhs + __lhs;
145151}
146152
147_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
153[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday
148154operator-(const year_month_weekday& __lhs, const years& __rhs) noexcept {
149155 return __lhs + (-__rhs);
150156}
......@@ -181,15 +187,21 @@ public:
181187 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator+=(const years& __dy) noexcept;
182188 _LIBCPP_HIDE_FROM_ABI constexpr year_month_weekday_last& operator-=(const years& __dy) noexcept;
183189
184 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
185 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
186 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept { return __wdl_.weekday(); }
187 _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept { return __wdl_; }
190 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::year year() const noexcept { return __y_; }
191 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::month month() const noexcept { return __m_; }
192 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday weekday() const noexcept {
193 return __wdl_.weekday();
194 }
195 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr chrono::weekday_last weekday_last() const noexcept {
196 return __wdl_;
197 }
188198 _LIBCPP_HIDE_FROM_ABI inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
189199 _LIBCPP_HIDE_FROM_ABI inline explicit constexpr operator local_days() const noexcept {
190200 return local_days{__to_days()};
191201 }
192 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __y_.ok() && __m_.ok() && __wdl_.ok(); }
202 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept {
203 return __y_.ok() && __m_.ok() && __wdl_.ok();
204 }
193205
194206 _LIBCPP_HIDE_FROM_ABI constexpr days __to_days() const noexcept;
195207};
......@@ -204,57 +216,57 @@ operator==(const year_month_weekday_last& __lhs, const year_month_weekday_last&
204216 return __lhs.year() == __rhs.year() && __lhs.month() == __rhs.month() && __lhs.weekday_last() == __rhs.weekday_last();
205217}
206218
207_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
219[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
208220operator/(const year_month& __lhs, const weekday_last& __rhs) noexcept {
209221 return year_month_weekday_last{__lhs.year(), __lhs.month(), __rhs};
210222}
211223
212_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
224[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
213225operator/(const year& __lhs, const month_weekday_last& __rhs) noexcept {
214226 return year_month_weekday_last{__lhs, __rhs.month(), __rhs.weekday_last()};
215227}
216228
217_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
229[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
218230operator/(int __lhs, const month_weekday_last& __rhs) noexcept {
219231 return year(__lhs) / __rhs;
220232}
221233
222_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
234[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
223235operator/(const month_weekday_last& __lhs, const year& __rhs) noexcept {
224236 return __rhs / __lhs;
225237}
226238
227_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
239[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
228240operator/(const month_weekday_last& __lhs, int __rhs) noexcept {
229241 return year(__rhs) / __lhs;
230242}
231243
232_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
244[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
233245operator+(const year_month_weekday_last& __lhs, const months& __rhs) noexcept {
234246 return (__lhs.year() / __lhs.month() + __rhs) / __lhs.weekday_last();
235247}
236248
237_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
249[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
238250operator+(const months& __lhs, const year_month_weekday_last& __rhs) noexcept {
239251 return __rhs + __lhs;
240252}
241253
242_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
254[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
243255operator-(const year_month_weekday_last& __lhs, const months& __rhs) noexcept {
244256 return __lhs + (-__rhs);
245257}
246258
247_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
259[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
248260operator+(const year_month_weekday_last& __lhs, const years& __rhs) noexcept {
249261 return year_month_weekday_last{__lhs.year() + __rhs, __lhs.month(), __lhs.weekday_last()};
250262}
251263
252_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
264[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
253265operator+(const years& __lhs, const year_month_weekday_last& __rhs) noexcept {
254266 return __rhs + __lhs;
255267}
256268
257_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
269[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr year_month_weekday_last
258270operator-(const year_month_weekday_last& __lhs, const years& __rhs) noexcept {
259271 return __lhs + (-__rhs);
260272}
......@@ -286,7 +298,7 @@ year_month_weekday_last::operator-=(const years& __dy) noexcept {
286298
287299template <>
288300struct hash<chrono::year_month_weekday> {
289 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday& __ymw) noexcept {
301 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday& __ymw) noexcept {
290302 return std::__hash_combine(
291303 hash<chrono::year>{}(__ymw.year()),
292304 std::__hash_combine(
......@@ -296,7 +308,7 @@ struct hash<chrono::year_month_weekday> {
296308
297309template <>
298310struct hash<chrono::year_month_weekday_last> {
299 _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday_last& __ymwl) noexcept {
311 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year_month_weekday_last& __ymwl) noexcept {
300312 return std::__hash_combine(
301313 hash<chrono::year>{}(__ymwl.year()),
302314 std::__hash_combine(
lib/libcxx/include/__chrono/zoned_time.h+4-4
......@@ -40,10 +40,10 @@
4040_LIBCPP_PUSH_MACROS
4141# include <__undef_macros>
4242
43_LIBCPP_BEGIN_NAMESPACE_STD
44
4543# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
4644
45_LIBCPP_BEGIN_NAMESPACE_STD
46
4747namespace chrono {
4848
4949template <class>
......@@ -232,11 +232,11 @@ struct hash<chrono::zoned_time<_Duration, _TimeZonePtr>> {
232232
233233# endif // _LIBCPP_STD_VER >= 26
234234
235_LIBCPP_END_NAMESPACE_STD
236
235237# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM &&
236238 // _LIBCPP_HAS_LOCALIZATION
237239
238_LIBCPP_END_NAMESPACE_STD
239
240240_LIBCPP_POP_MACROS
241241
242242#endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
lib/libcxx/include/__compare/common_comparison_category.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525namespace __comp_detail {
2626
2727enum _ClassifyCompCategory : unsigned { _None, _PartialOrd, _WeakOrd, _StrongOrd, _CCC_Size };
......@@ -79,8 +79,8 @@ struct common_comparison_category {
7979template <class... _Ts>
8080using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
8181
82#endif // _LIBCPP_STD_VER >= 20
83
8482_LIBCPP_END_NAMESPACE_STD
8583
84#endif // _LIBCPP_STD_VER >= 20
85
8686#endif // _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
lib/libcxx/include/__compare/compare_three_way.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525struct compare_three_way {
2626 template <class _T1, class _T2>
2727 requires three_way_comparable_with<_T1, _T2>
......@@ -33,8 +33,8 @@ struct compare_three_way {
3333 using is_transparent = void;
3434};
3535
36#endif // _LIBCPP_STD_VER >= 20
37
3836_LIBCPP_END_NAMESPACE_STD
3937
38#endif // _LIBCPP_STD_VER >= 20
39
4040#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
lib/libcxx/include/__compare/compare_three_way_result.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class, class, class>
2525struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result {};
2626
......@@ -39,8 +39,8 @@ struct _LIBCPP_NO_SPECIALIZATIONS compare_three_way_result : __compare_three_way
3939template <class _Tp, class _Up = _Tp>
4040using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
4141
42#endif // _LIBCPP_STD_VER >= 20
43
4442_LIBCPP_END_NAMESPACE_STD
4543
44#endif // _LIBCPP_STD_VER >= 20
45
4646#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
lib/libcxx/include/__compare/ordering.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// exposition only
2525enum class _OrdResult : signed char { __less = -1, __equiv = 0, __greater = 1 };
2626
......@@ -275,8 +275,8 @@ template <class _Tp>
275275concept __comparison_category =
276276 is_same_v<_Tp, partial_ordering> || is_same_v<_Tp, weak_ordering> || is_same_v<_Tp, strong_ordering>;
277277
278#endif // _LIBCPP_STD_VER >= 20
279
280278_LIBCPP_END_NAMESPACE_STD
281279
280#endif // _LIBCPP_STD_VER >= 20
281
282282#endif // _LIBCPP___COMPARE_ORDERING_H
lib/libcxx/include/__compare/synth_three_way.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626// [expos.only.func]
2727
2828_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
......@@ -46,8 +46,8 @@ template <class _Tp, class _Up = _Tp>
4646using __synth_three_way_result _LIBCPP_NODEBUG =
4747 decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
4848
49#endif // _LIBCPP_STD_VER >= 20
50
5149_LIBCPP_END_NAMESPACE_STD
5250
51#endif // _LIBCPP_STD_VER >= 20
52
5353#endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
lib/libcxx/include/__compare/three_way_comparable.h+4-4
......@@ -24,10 +24,10 @@
2424# pragma GCC system_header
2525#endif
2626
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2927#if _LIBCPP_STD_VER >= 20
3028
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3131template <class _Tp, class _Cat>
3232concept __compares_as = same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
3333
......@@ -48,8 +48,8 @@ concept three_way_comparable_with =
4848 { __u <=> __t } -> __compares_as<_Cat>;
4949 };
5050
51#endif // _LIBCPP_STD_VER >= 20
52
5351_LIBCPP_END_NAMESPACE_STD
5452
53#endif // _LIBCPP_STD_VER >= 20
54
5555#endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
lib/libcxx/include/__concepts/arithmetic.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// [concepts.arithmetic], arithmetic concepts
2626
2727template <class _Tp>
......@@ -36,8 +36,8 @@ concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;
3636template <class _Tp>
3737concept floating_point = is_floating_point_v<_Tp>;
3838
39#endif // _LIBCPP_STD_VER >= 20
40
4139_LIBCPP_END_NAMESPACE_STD
4240
41#endif // _LIBCPP_STD_VER >= 20
42
4343#endif // _LIBCPP___CONCEPTS_ARITHMETIC_H
lib/libcxx/include/__concepts/assignable.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727// [concept.assignable]
2828
2929template <class _Lhs, class _Rhs>
......@@ -34,8 +34,8 @@ concept assignable_from =
3434 { __lhs = std::forward<_Rhs>(__rhs) } -> same_as<_Lhs>;
3535 };
3636
37#endif // _LIBCPP_STD_VER >= 20
38
3937_LIBCPP_END_NAMESPACE_STD
4038
39#endif // _LIBCPP_STD_VER >= 20
40
4141#endif // _LIBCPP___CONCEPTS_ASSIGNABLE_H
lib/libcxx/include/__concepts/boolean_testable.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concepts.booleantestable]
2525
2626template <class _Tp>
......@@ -31,8 +31,8 @@ concept __boolean_testable = __boolean_testable_impl<_Tp> && requires(_Tp&& __t)
3131 { !std::forward<_Tp>(__t) } -> __boolean_testable_impl;
3232};
3333
34#endif // _LIBCPP_STD_VER >= 20
35
3634_LIBCPP_END_NAMESPACE_STD
3735
36#endif // _LIBCPP_STD_VER >= 20
37
3838#endif // _LIBCPP___CONCEPTS_BOOLEAN_TESTABLE_H
lib/libcxx/include/__concepts/class_or_enum.h+4-4
......@@ -18,17 +18,17 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// Whether a type is a class type or enumeration type according to the Core wording.
2626
2727template <class _Tp>
2828concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
2929
30#endif // _LIBCPP_STD_VER >= 20
31
3230_LIBCPP_END_NAMESPACE_STD
3331
32#endif // _LIBCPP_STD_VER >= 20
33
3434#endif // _LIBCPP___CONCEPTS_CLASS_OR_ENUM_H
lib/libcxx/include/__concepts/common_reference_with.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// [concept.commonref]
2626
2727template <class _Tp, class _Up>
......@@ -29,8 +29,8 @@ concept common_reference_with =
2929 same_as<common_reference_t<_Tp, _Up>, common_reference_t<_Up, _Tp>> &&
3030 convertible_to<_Tp, common_reference_t<_Tp, _Up>> && convertible_to<_Up, common_reference_t<_Tp, _Up>>;
3131
32#endif // _LIBCPP_STD_VER >= 20
33
3432_LIBCPP_END_NAMESPACE_STD
3533
34#endif // _LIBCPP_STD_VER >= 20
35
3636#endif // _LIBCPP___CONCEPTS_COMMON_REFERENCE_WITH_H
lib/libcxx/include/__concepts/comparison_common_type.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <class _Tp, class _Up, class _CommonRef = common_reference_t<const _Tp&, const _Up&>>
2727concept __comparison_common_type_with_impl =
2828 same_as<common_reference_t<const _Tp&, const _Up&>, common_reference_t<const _Up&, const _Tp&>> && requires {
......@@ -33,8 +33,8 @@ concept __comparison_common_type_with_impl =
3333template <class _Tp, class _Up>
3434concept __comparison_common_type_with = __comparison_common_type_with_impl<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
3535
36#endif // _LIBCPP_STD_VER >= 20
37
3836_LIBCPP_END_NAMESPACE_STD
3937
38#endif // _LIBCPP_STD_VER >= 20
39
4040#endif // _LIBCPP___CONCEPTS_COMPARISON_COMMON_TYPE_H
lib/libcxx/include/__concepts/constructible.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// [concept.constructible]
2626template <class _Tp, class... _Args>
2727concept constructible_from = destructible<_Tp> && is_constructible_v<_Tp, _Args...>;
......@@ -48,8 +48,8 @@ concept copy_constructible =
4848 constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;
4949// clang-format on
5050
51#endif // _LIBCPP_STD_VER >= 20
52
5351_LIBCPP_END_NAMESPACE_STD
5452
53#endif // _LIBCPP_STD_VER >= 20
54
5555#endif // _LIBCPP___CONCEPTS_CONSTRUCTIBLE_H
lib/libcxx/include/__concepts/convertible_to.h+4-4
......@@ -17,17 +17,17 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concept.convertible]
2525
2626template <class _From, class _To>
2727concept convertible_to = is_convertible_v<_From, _To> && requires { static_cast<_To>(std::declval<_From>()); };
2828
29#endif // _LIBCPP_STD_VER >= 20
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 20
32
3333#endif // _LIBCPP___CONCEPTS_CONVERTIBLE_TO_H
lib/libcxx/include/__concepts/copyable.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// [concepts.object]
2626
2727// clang-format off
......@@ -34,8 +34,8 @@ concept copyable =
3434 assignable_from<_Tp&, const _Tp>;
3535// clang-format on
3636
37#endif // _LIBCPP_STD_VER >= 20
38
3937_LIBCPP_END_NAMESPACE_STD
4038
39#endif // _LIBCPP_STD_VER >= 20
40
4141#endif // _LIBCPP___CONCEPTS_COPYABLE_H
lib/libcxx/include/__concepts/derived_from.h+4-4
......@@ -17,17 +17,17 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concept.derived]
2525
2626template <class _Dp, class _Bp>
2727concept derived_from = is_base_of_v<_Bp, _Dp> && is_convertible_v<const volatile _Dp*, const volatile _Bp*>;
2828
29#endif // _LIBCPP_STD_VER >= 20
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 20
32
3333#endif // _LIBCPP___CONCEPTS_DERIVED_FROM_H
lib/libcxx/include/__concepts/destructible.h+4-4
......@@ -16,17 +16,17 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 20
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323// [concept.destructible]
2424
2525template <class _Tp>
2626concept destructible = is_nothrow_destructible_v<_Tp>;
2727
28#endif // _LIBCPP_STD_VER >= 20
29
3028_LIBCPP_END_NAMESPACE_STD
3129
30#endif // _LIBCPP_STD_VER >= 20
31
3232#endif // _LIBCPP___CONCEPTS_DESTRUCTIBLE_H
lib/libcxx/include/__concepts/different_from.h+4-4
......@@ -17,15 +17,15 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Tp, class _Up>
2525concept __different_from = !same_as<remove_cvref_t<_Tp>, remove_cvref_t<_Up>>;
2626
27#endif // _LIBCPP_STD_VER >= 20
28
2927_LIBCPP_END_NAMESPACE_STD
3028
29#endif // _LIBCPP_STD_VER >= 20
30
3131#endif // _LIBCPP___CONCEPTS_DIFFERENT_FROM_H
lib/libcxx/include/__concepts/equality_comparable.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727// [concept.equalitycomparable]
2828
2929template <class _Tp, class _Up>
......@@ -50,8 +50,8 @@ concept equality_comparable_with =
5050 __weakly_equality_comparable_with<_Tp, _Up>;
5151// clang-format on
5252
53#endif // _LIBCPP_STD_VER >= 20
54
5553_LIBCPP_END_NAMESPACE_STD
5654
55#endif // _LIBCPP_STD_VER >= 20
56
5757#endif // _LIBCPP___CONCEPTS_EQUALITY_COMPARABLE_H
lib/libcxx/include/__concepts/invocable.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concept.invocable]
2525
2626template <class _Fn, class... _Args>
......@@ -33,8 +33,8 @@ concept invocable = requires(_Fn&& __fn, _Args&&... __args) {
3333template <class _Fn, class... _Args>
3434concept regular_invocable = invocable<_Fn, _Args...>;
3535
36#endif // _LIBCPP_STD_VER >= 20
37
3836_LIBCPP_END_NAMESPACE_STD
3937
38#endif // _LIBCPP_STD_VER >= 20
39
4040#endif // _LIBCPP___CONCEPTS_INVOCABLE_H
lib/libcxx/include/__concepts/movable.h+4-4
......@@ -19,17 +19,17 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626// [concepts.object]
2727
2828template <class _Tp>
2929concept movable = is_object_v<_Tp> && move_constructible<_Tp> && assignable_from<_Tp&, _Tp> && swappable<_Tp>;
3030
31#endif // _LIBCPP_STD_VER >= 20
32
3331_LIBCPP_END_NAMESPACE_STD
3432
33#endif // _LIBCPP_STD_VER >= 20
34
3535#endif // _LIBCPP___CONCEPTS_MOVABLE_H
lib/libcxx/include/__concepts/predicate.h+4-4
......@@ -18,17 +18,17 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525// [concept.predicate]
2626
2727template <class _Fn, class... _Args>
2828concept predicate = regular_invocable<_Fn, _Args...> && __boolean_testable<invoke_result_t<_Fn, _Args...>>;
2929
30#endif // _LIBCPP_STD_VER >= 20
31
3230_LIBCPP_END_NAMESPACE_STD
3331
32#endif // _LIBCPP_STD_VER >= 20
33
3434#endif // _LIBCPP___CONCEPTS_PREDICATE_H
lib/libcxx/include/__concepts/primary_template.h created+33
......@@ -0,0 +1,33 @@
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_PRIMARY_TEMPLATE_H
10#define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
11
12#include <__config>
13#include <__type_traits/is_same.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#if _LIBCPP_STD_VER >= 20
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp>
24concept __primary_template = requires {
25 typename _Tp::__primary_template;
26 requires _IsSame<typename _Tp::__primary_template, _Tp>::value;
27};
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP_STD_VER >= 20
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
lib/libcxx/include/__concepts/referenceable.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___TYPE_TRAITS_IS_REFERENCEABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
11
12#include <__config>
13#include <__type_traits/void_t.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19#if _LIBCPP_STD_VER >= 20
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23template <class _Tp>
24concept __referenceable = requires { typename __void_t<_Tp&>; };
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif
29
30#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
lib/libcxx/include/__concepts/regular.h+4-4
......@@ -17,17 +17,17 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concept.object]
2525
2626template <class _Tp>
2727concept regular = semiregular<_Tp> && equality_comparable<_Tp>;
2828
29#endif // _LIBCPP_STD_VER >= 20
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 20
32
3333#endif // _LIBCPP___CONCEPTS_REGULAR_H
lib/libcxx/include/__concepts/relation.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 20
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323// [concept.relation]
2424
2525template <class _Rp, class _Tp, class _Up>
......@@ -36,8 +36,8 @@ concept equivalence_relation = relation<_Rp, _Tp, _Up>;
3636template <class _Rp, class _Tp, class _Up>
3737concept strict_weak_order = relation<_Rp, _Tp, _Up>;
3838
39#endif // _LIBCPP_STD_VER >= 20
40
4139_LIBCPP_END_NAMESPACE_STD
4240
41#endif // _LIBCPP_STD_VER >= 20
42
4343#endif // _LIBCPP___CONCEPTS_RELATION_H
lib/libcxx/include/__concepts/same_as.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 20
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323// [concept.same]
2424
2525template <class _Tp, class _Up>
......@@ -28,8 +28,8 @@ concept __same_as_impl = _IsSame<_Tp, _Up>::value;
2828template <class _Tp, class _Up>
2929concept same_as = __same_as_impl<_Tp, _Up> && __same_as_impl<_Up, _Tp>;
3030
31#endif // _LIBCPP_STD_VER >= 20
32
3331_LIBCPP_END_NAMESPACE_STD
3432
33#endif // _LIBCPP_STD_VER >= 20
34
3535#endif // _LIBCPP___CONCEPTS_SAME_AS_H
lib/libcxx/include/__concepts/semiregular.h+4-4
......@@ -17,17 +17,17 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424// [concept.object]
2525
2626template <class _Tp>
2727concept semiregular = copyable<_Tp> && default_initializable<_Tp>;
2828
29#endif // _LIBCPP_STD_VER >= 20
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 20
32
3333#endif // _LIBCPP___CONCEPTS_SEMIREGULAR_H
lib/libcxx/include/__concepts/swappable.h+4-4
......@@ -30,10 +30,10 @@
3030_LIBCPP_PUSH_MACROS
3131#include <__undef_macros>
3232
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3533#if _LIBCPP_STD_VER >= 20
3634
35_LIBCPP_BEGIN_NAMESPACE_STD
36
3737// [concept.swappable]
3838
3939namespace ranges {
......@@ -113,10 +113,10 @@ concept swappable_with = common_reference_with<_Tp, _Up> && requires(_Tp&& __t,
113113 ranges::swap(std::forward<_Up>(__u), std::forward<_Tp>(__t));
114114};
115115
116#endif // _LIBCPP_STD_VER >= 20
117
118116_LIBCPP_END_NAMESPACE_STD
119117
118#endif // _LIBCPP_STD_VER >= 20
119
120120_LIBCPP_POP_MACROS
121121
122122#endif // _LIBCPP___CONCEPTS_SWAPPABLE_H
lib/libcxx/include/__concepts/totally_ordered.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626// [concept.totallyordered]
2727
2828template <class _Tp, class _Up>
......@@ -52,8 +52,8 @@ concept totally_ordered_with =
5252 __partially_ordered_with<_Tp, _Up>;
5353// clang-format on
5454
55#endif // _LIBCPP_STD_VER >= 20
56
5755_LIBCPP_END_NAMESPACE_STD
5856
57#endif // _LIBCPP_STD_VER >= 20
58
5959#endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H
lib/libcxx/include/__condition_variable/condition_variable.h+6-4
......@@ -31,10 +31,11 @@
3131_LIBCPP_PUSH_MACROS
3232#include <__undef_macros>
3333
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3634#if _LIBCPP_HAS_THREADS
3735
36_LIBCPP_BEGIN_NAMESPACE_STD
37_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
38
3839// enum class cv_status
3940_LIBCPP_DECLARE_STRONG_ENUM(cv_status){no_timeout, timeout};
4041_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
......@@ -223,10 +224,11 @@ inline void condition_variable::__do_timed_wait(unique_lock<mutex>& __lk,
223224 wait_for(__lk, __tp - _Clock::now());
224225}
225226
226#endif // _LIBCPP_HAS_THREADS
227
227_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
228228_LIBCPP_END_NAMESPACE_STD
229229
230#endif // _LIBCPP_HAS_THREADS
231
230232_LIBCPP_POP_MACROS
231233
232234#endif // _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H
lib/libcxx/include/__config+26-696
......@@ -25,61 +25,30 @@
2525
2626#ifdef __cplusplus
2727
28# include <__configuration/abi.h>
29# include <__configuration/attributes.h>
30# include <__configuration/availability.h>
31# include <__configuration/compiler.h>
32# include <__configuration/diagnostic_suppression.h>
33# include <__configuration/experimental.h>
34# include <__configuration/hardening.h>
35# include <__configuration/language.h>
36# include <__configuration/namespace.h>
37# include <__configuration/platform.h>
38# include <__configuration/pstl.h>
39# include <__configuration/utility.h>
40
2841// The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
2942
3043// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
3144// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
3245// defined to XXYYZZ.
33# define _LIBCPP_VERSION 220108
34
35# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
36# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
37# define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z))
38
39# if __STDC_HOSTED__ == 0
40# define _LIBCPP_FREESTANDING
41# endif
42
43# define _LIBCPP_TOSTRING2(x) #x
44# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
45
46# ifndef __has_constexpr_builtin
47# define __has_constexpr_builtin(x) 0
48# endif
49
50// This checks wheter a Clang module is built
51# ifndef __building_module
52# define __building_module(...) 0
53# endif
54
55// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
56// the compiler and '1' otherwise.
57# ifndef __is_identifier
58# define __is_identifier(__x) 1
59# endif
60
61# ifndef __has_declspec_attribute
62# define __has_declspec_attribute(__x) 0
63# endif
64
65# define __has_keyword(__x) !(__is_identifier(__x))
66
67# ifndef __has_warning
68# define __has_warning(...) 0
69# endif
70
71# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
72# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
73# endif
46# define _LIBCPP_VERSION 230100
7447
7548# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
7649# define _LIBCPP_ABI_VCRUNTIME
7750# endif
7851
79# if defined(__MVS__)
80# include <features.h> // for __NATIVE_ASCII_F
81# endif
82
8352# if defined(_WIN32)
8453# define _LIBCPP_WIN32API
8554# define _LIBCPP_SHORT_WCHAR 1
......@@ -90,15 +59,9 @@
9059# if defined(_MSC_VER) && !defined(__MINGW32__)
9160# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
9261# endif
93# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
94# define _LIBCPP_HAS_BITSCAN64 1
95# else
96# define _LIBCPP_HAS_BITSCAN64 0
97# endif
9862# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1
9963# else
10064# define _LIBCPP_HAS_OPEN_WITH_WCHAR 0
101# define _LIBCPP_HAS_BITSCAN64 0
10265# endif // defined(_WIN32)
10366
10467# if defined(_AIX) && !defined(__64BIT__)
......@@ -184,259 +147,6 @@ typedef __char32_t char32_t;
184147# define _LIBCPP_HAS_BLOCKS_RUNTIME 0
185148# endif
186149
187# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
188
189# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
190
191# ifdef _DLL
192# define _LIBCPP_CRT_FUNC __declspec(dllimport)
193# else
194# define _LIBCPP_CRT_FUNC
195# endif
196
197# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
198# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
199# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
200# define _LIBCPP_OVERRIDABLE_FUNC_VIS
201# define _LIBCPP_EXPORTED_FROM_ABI
202# elif defined(_LIBCPP_BUILDING_LIBRARY)
203# if defined(__MINGW32__)
204# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
205# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
206# else
207# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
208# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
209# endif
210# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
211# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
212# else
213# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
214# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
215# define _LIBCPP_OVERRIDABLE_FUNC_VIS
216# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
217# endif
218
219# define _LIBCPP_HIDDEN
220# define _LIBCPP_TEMPLATE_DATA_VIS
221# define _LIBCPP_NAMESPACE_VISIBILITY
222
223# else
224
225# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
226# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
227# else
228# define _LIBCPP_VISIBILITY(vis)
229# endif
230
231# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
232# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
233# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
234# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
235# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
236
237// TODO: Make this a proper customization point or remove the option to override it.
238# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
239# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
240# endif
241
242# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
243# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
244# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
245# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
246# else
247# define _LIBCPP_NAMESPACE_VISIBILITY
248# endif
249
250# endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
251
252# if __has_attribute(exclude_from_explicit_instantiation)
253# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
254# else
255// Try to approximate the effect of exclude_from_explicit_instantiation
256// (which is that entities are not assumed to be provided by explicit
257// template instantiations in the dylib) by always inlining those entities.
258# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
259# endif
260
261# ifdef _LIBCPP_COMPILER_CLANG_BASED
262# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
263# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
264# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
265# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
266# elif defined(_LIBCPP_COMPILER_GCC)
267# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
268# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
269# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
270# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
271# else
272# define _LIBCPP_DIAGNOSTIC_PUSH
273# define _LIBCPP_DIAGNOSTIC_POP
274# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
275# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
276# endif
277
278// Macros to enter and leave a state where deprecation warnings are suppressed.
279# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
280 _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") \
281 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
282# define _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_DIAGNOSTIC_POP
283
284# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
285# define _LIBCPP_HARDENING_SIG f
286# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
287# define _LIBCPP_HARDENING_SIG s
288# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
289# define _LIBCPP_HARDENING_SIG d
290# else
291# define _LIBCPP_HARDENING_SIG n // "none"
292# endif
293
294# if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE
295# define _LIBCPP_ASSERTION_SEMANTIC_SIG o
296# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
297# define _LIBCPP_ASSERTION_SEMANTIC_SIG q
298# elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
299# define _LIBCPP_ASSERTION_SEMANTIC_SIG e
300# else
301# define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore`
302# endif
303
304# if !_LIBCPP_HAS_EXCEPTIONS
305# define _LIBCPP_EXCEPTIONS_SIG n
306# else
307# define _LIBCPP_EXCEPTIONS_SIG e
308# endif
309
310# define _LIBCPP_ODR_SIGNATURE \
311 _LIBCPP_CONCAT( \
312 _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \
313 _LIBCPP_VERSION)
314
315// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
316// on two levels:
317// 1. The symbol is given hidden visibility, which ensures that users won't start exporting
318// symbols from their dynamic library by means of using the libc++ headers. This ensures
319// that those symbols stay private to the dynamic library in which it is defined.
320//
321// 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
322// This ensures that no ODR violation can arise from mixing two TUs compiled with different
323// versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
324// program contains two definitions of a function, the ODR requires them to be token-by-token
325// equivalent, and the linker is allowed to pick either definition and discard the other one.
326//
327// For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
328// *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
329// compiled with different settings), the two definitions are both visible by the linker and they
330// have the same name, but they have a meaningfully different implementation (one throws an exception
331// and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
332// practice what will happen is that the linker will pick one of the definitions at random and will
333// discard the other one. This can quite clearly lead to incorrect program behavior.
334//
335// A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
336// property that causes the code of a function to differ from the code in another configuration
337// can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
338// tag, but we encode the ones that we think are most important: library version, exceptions, and
339// hardening mode.
340//
341// Note that historically, solving this problem has been achieved in various ways, including
342// force-inlining all functions or giving internal linkage to all functions. Both these previous
343// solutions suffer from drawbacks that lead notably to code bloat.
344//
345// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
346// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
347//
348// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
349// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
350// name of a virtual function is part of its ABI, since some architectures like arm64e can sign
351// the virtual function pointer in the vtable based on the mangled name of the function. Since
352// we use an ABI tag that changes with each released version, the mangled name of the virtual
353// function would change, which is incorrect. Note that it doesn't make much sense to change
354// the implementation of a virtual function in an ABI-incompatible way in the first place,
355// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
356//
357// The macro can be applied to record and enum types. When the tagged type is nested in
358// a record this "parent" record needs to have the macro too. Another use case for applying
359// this macro to records and unions is to apply an ABI tag to inline constexpr variables.
360// This can be useful for inline variables that are implementation details which are expected
361// to change in the future.
362//
363// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
364// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
365// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
366# ifndef _LIBCPP_NO_ABI_TAG
367# define _LIBCPP_HIDE_FROM_ABI \
368 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
369 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
370# else
371# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
372# endif
373# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
374
375// Clang modules take a significant compile time hit when pushing and popping diagnostics.
376// Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can
377// simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined.
378# ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
379# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
380 _LIBCPP_DIAGNOSTIC_PUSH \
381 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
382 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
383 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
384 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
385 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
386 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
387 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
388 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
389 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
390# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
391# else
392# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
393# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
394# endif
395
396// clang-format off
397
398// The unversioned namespace is used when we want to be ABI compatible with other standard libraries in some way. There
399// are two main categories where that's the case:
400// - Historically, we have made exception types ABI compatible with libstdc++ to allow throwing them between libstdc++
401// and libc++. This is not used anymore for new exception types, since there is no use-case for it anymore.
402// - Types and functions which are used by the compiler are in the unversioned namespace, since the compiler has to know
403// their mangling without the appropriate declaration in some cases.
404// If it's not clear whether using the unversioned namespace is the correct thing to do, it's not. The versioned
405// namespace (_LIBCPP_BEGIN_NAMESPACE_STD) should almost always be used.
406# define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \
407 _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS namespace _LIBCPP_NAMESPACE_VISIBILITY std {
408
409# define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_POP_EXTENSION_DIAGNOSTICS
410
411# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD inline namespace _LIBCPP_ABI_NAMESPACE {
412# define _LIBCPP_END_NAMESPACE_STD } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
413
414// TODO: This should really be in the versioned namespace
415#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD namespace experimental {
416#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
417
418#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
419#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
420
421#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
422#define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
423
424#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
425# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
426# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
427#else
428# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
429 inline namespace __fs { namespace filesystem {
430
431# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
432#endif
433
434// clang-format on
435
436# if __has_attribute(__enable_if__)
437# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
438# endif
439
440150# if !defined(__SIZEOF_INT128__) || defined(_MSC_VER)
441151# define _LIBCPP_HAS_INT128 0
442152# else
......@@ -488,34 +198,14 @@ typedef __char32_t char32_t;
488198# endif
489199# endif
490200
491# if defined(__APPLE__) || defined(__FreeBSD__)
492# define _LIBCPP_WCTYPE_IS_MASK
493# endif
494
495# if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
496# define _LIBCPP_HAS_CHAR8_T 0
201# if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606)
202# define _LIBCPP_HAS_ALIGNED_ALLOCATION 0
497203# else
498# define _LIBCPP_HAS_CHAR8_T 1
204# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1
499205# endif
500206
501// Deprecation macros.
502//
503// Deprecations warnings are always enabled, except when users explicitly opt-out
504// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
505# if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
506# if __has_attribute(__deprecated__)
507# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
508# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
509# elif _LIBCPP_STD_VER >= 14
510# define _LIBCPP_DEPRECATED [[deprecated]]
511# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
512# else
513# define _LIBCPP_DEPRECATED
514# define _LIBCPP_DEPRECATED_(m)
515# endif
516# else
517# define _LIBCPP_DEPRECATED
518# define _LIBCPP_DEPRECATED_(m)
207# if defined(__APPLE__) || defined(__FreeBSD__)
208# define _LIBCPP_WCTYPE_IS_MASK
519209# endif
520210
521211// FIXME: using `#warning` causes diagnostics from system headers which include deprecated headers. This can only be
......@@ -527,102 +217,13 @@ typedef __char32_t char32_t;
527217# define _LIBCPP_DIAGNOSE_DEPRECATED_HEADERS 0
528218# endif
529219
530# if !defined(_LIBCPP_CXX03_LANG)
531# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
532# else
533# define _LIBCPP_DEPRECATED_IN_CXX11
534# endif
535
536# if _LIBCPP_STD_VER >= 14
537# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
538# else
539# define _LIBCPP_DEPRECATED_IN_CXX14
540# endif
541
542# if _LIBCPP_STD_VER >= 17
543# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
544# else
545# define _LIBCPP_DEPRECATED_IN_CXX17
546# endif
547
548# if _LIBCPP_STD_VER >= 20
549# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
550# else
551# define _LIBCPP_DEPRECATED_IN_CXX20
552# endif
553
554# if _LIBCPP_STD_VER >= 23
555# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
556# else
557# define _LIBCPP_DEPRECATED_IN_CXX23
558# endif
559
560# if _LIBCPP_STD_VER >= 26
561# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
562# define _LIBCPP_DEPRECATED_IN_CXX26_(m) _LIBCPP_DEPRECATED_(m)
563# else
564# define _LIBCPP_DEPRECATED_IN_CXX26
565# define _LIBCPP_DEPRECATED_IN_CXX26_(m)
566# endif
567
568# if _LIBCPP_HAS_CHAR8_T
569# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
570# else
571# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
572# endif
573
574# if _LIBCPP_STD_VER <= 11
575# define _LIBCPP_EXPLICIT_SINCE_CXX14
576# else
577# define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
578# endif
579
580# if _LIBCPP_STD_VER >= 23
581# define _LIBCPP_EXPLICIT_SINCE_CXX23 explicit
582# else
583# define _LIBCPP_EXPLICIT_SINCE_CXX23
584# endif
585
586# if _LIBCPP_STD_VER >= 14
587# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
588# else
589# define _LIBCPP_CONSTEXPR_SINCE_CXX14
590# endif
591
592# if _LIBCPP_STD_VER >= 17
593# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
594# else
595# define _LIBCPP_CONSTEXPR_SINCE_CXX17
596# endif
597
598# if _LIBCPP_STD_VER >= 20
599# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
600# else
601# define _LIBCPP_CONSTEXPR_SINCE_CXX20
602# endif
603
604# if _LIBCPP_STD_VER >= 23
605# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
606# else
607# define _LIBCPP_CONSTEXPR_SINCE_CXX23
608# endif
609
610# if _LIBCPP_STD_VER >= 26
611# define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr
612# else
613# define _LIBCPP_CONSTEXPR_SINCE_CXX26
614# endif
615
616# ifndef _LIBCPP_WEAK
617# define _LIBCPP_WEAK __attribute__((__weak__))
618# endif
619
620220// Thread API
621221// clang-format off
622222# if _LIBCPP_HAS_THREADS && \
623223 !_LIBCPP_HAS_THREAD_API_PTHREAD && \
624224 !_LIBCPP_HAS_THREAD_API_WIN32 && \
625 !_LIBCPP_HAS_THREAD_API_EXTERNAL
225 !_LIBCPP_HAS_THREAD_API_EXTERNAL && \
226 !_LIBCPP_HAS_THREAD_API_C11
626227
627228# if defined(__FreeBSD__) || \
628229 defined(__wasi__) || \
......@@ -666,6 +267,10 @@ typedef __char32_t char32_t;
666267# error _LIBCPP_HAS_THREAD_API_EXTERNAL may only be true when _LIBCPP_HAS_THREADS is true.
667268# endif
668269
270# if !_LIBCPP_HAS_THREADS && _LIBCPP_HAS_THREAD_API_C11
271# error _LIBCPP_HAS_THREAD_API_C11 may only be true when _LIBCPP_HAS_THREADS is true.
272# endif
273
669274# if !_LIBCPP_HAS_MONOTONIC_CLOCK && _LIBCPP_HAS_THREADS
670275# error _LIBCPP_HAS_MONOTONIC_CLOCK may only be false when _LIBCPP_HAS_THREADS is false.
671276# endif
......@@ -709,60 +314,10 @@ typedef __char32_t char32_t;
709314# endif
710315
711316# if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \
712 _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || defined(__LLVM_LIBC__)
317 _LIBCPP_HAS_MUSL_LIBC || defined(__OpenBSD__) || _LIBCPP_LIBC_LLVM_LIBC
713318# define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
714319# endif
715320
716# if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
717# define _LIBCPP_HAS_C_ATOMIC_IMP 1
718# define _LIBCPP_HAS_GCC_ATOMIC_IMP 0
719# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
720# elif defined(_LIBCPP_COMPILER_GCC)
721# define _LIBCPP_HAS_C_ATOMIC_IMP 0
722# define _LIBCPP_HAS_GCC_ATOMIC_IMP 1
723# define _LIBCPP_HAS_EXTERNAL_ATOMIC_IMP 0
724# endif
725
726# if !_LIBCPP_HAS_C_ATOMIC_IMP && !_LIBCPP_HAS_GCC_ATOMIC_IMP && !_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP
727# define _LIBCPP_HAS_ATOMIC_HEADER 0
728# else
729# define _LIBCPP_HAS_ATOMIC_HEADER 1
730# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
731# define _LIBCPP_ATOMIC_FLAG_TYPE bool
732# endif
733# endif
734
735# if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__)
736# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]]
737# else
738# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
739# endif
740
741# if _LIBCPP_STD_VER >= 20
742# define _LIBCPP_CONSTINIT constinit
743# elif __has_attribute(__require_constant_initialization__)
744# define _LIBCPP_CONSTINIT __attribute__((__require_constant_initialization__))
745# else
746# define _LIBCPP_CONSTINIT
747# endif
748
749# if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
750// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
751// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
752// when compiling for CUDA we use the non-underscored version of the noinline
753// attribute.
754//
755// This is a temporary workaround and we still expect the CUDA SDK team to solve
756// this issue properly in the SDK headers.
757//
758// See https://github.com/llvm/llvm-project/pull/73838 for more details.
759# define _LIBCPP_NOINLINE __attribute__((noinline))
760# elif __has_attribute(__noinline__)
761# define _LIBCPP_NOINLINE __attribute__((__noinline__))
762# else
763# define _LIBCPP_NOINLINE
764# endif
765
766321// We often repeat things just for handling wide characters in the library.
767322// When wide characters are disabled, it can be useful to have a quick way of
768323// disabling it without having to resort to #if-#endif, which has a larger
......@@ -788,27 +343,6 @@ typedef __char32_t char32_t;
788343# endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_BUILDING_LIBRARY)
789344# endif // _LIBCPP_NO_AUTO_LINK
790345
791// Configures the fopen close-on-exec mode character, if any. This string will
792// be appended to any mode string used by fstream for fopen/fdopen.
793//
794// Not all platforms support this, but it helps avoid fd-leaks on platforms that
795// do.
796# if defined(__BIONIC__)
797# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
798# else
799# define _LIBCPP_FOPEN_CLOEXEC_MODE
800# endif
801
802# if __has_cpp_attribute(msvc::no_unique_address)
803// MSVC implements [[no_unique_address]] as a silent no-op currently.
804// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
805// However, MSVC implements [[msvc::no_unique_address]] which does what
806// [[no_unique_address]] is supposed to do, in general.
807# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
808# else
809# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
810# endif
811
812346// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
813347// functions is gradually being added to existing C libraries. The conditions
814348// below check for known C library versions and conditions under which these
......@@ -844,210 +378,6 @@ typedef __char32_t char32_t;
844378# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
845379# endif
846380
847# if defined(__OBJC__) && defined(_LIBCPP_APPLE_CLANG_VER)
848# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
849# endif
850
851# define _PSTL_PRAGMA(x) _Pragma(#x)
852
853// Enable SIMD for compilers that support OpenMP 4.0
854# if (defined(_OPENMP) && _OPENMP >= 201307)
855
856# define _PSTL_UDR_PRESENT
857# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
858# define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
859# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
860# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
861# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
862# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
863
864// Declaration of reduction functor, where
865// NAME - the name of the functor
866// OP - type of the callable object with the reduction operation
867// omp_in - refers to the local partial result
868// omp_out - refers to the final value of the combiner operator
869// omp_priv - refers to the private copy of the initial value
870// omp_orig - refers to the original variable to be reduced
871# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
872 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
873
874# elif defined(_LIBCPP_COMPILER_CLANG_BASED)
875
876# define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
877# define _PSTL_PRAGMA_DECLARE_SIMD
878# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
879# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
880# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
881# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
882# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
883
884# else // (defined(_OPENMP) && _OPENMP >= 201307)
885
886# define _PSTL_PRAGMA_SIMD
887# define _PSTL_PRAGMA_DECLARE_SIMD
888# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
889# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
890# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
891# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
892# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
893
894# endif // (defined(_OPENMP) && _OPENMP >= 201307)
895
896# define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
897
898// Optional attributes - these are useful for a better QoI, but not required to be available
899
900# define _LIBCPP_NOALIAS __attribute__((__malloc__))
901# define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
902# define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
903# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
904# define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
905 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
906# define _LIBCPP_PACKED __attribute__((__packed__))
907
908# if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
909# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
910# else
911# define _LIBCPP_NO_CFI
912# endif
913
914# if __has_attribute(__using_if_exists__)
915# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
916# else
917# define _LIBCPP_USING_IF_EXISTS
918# endif
919
920# if __has_cpp_attribute(_Clang::__no_destroy__)
921# define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]]
922# else
923# define _LIBCPP_NO_DESTROY
924# endif
925
926# if __has_attribute(__diagnose_if__)
927# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
928# else
929# define _LIBCPP_DIAGNOSE_WARNING(...)
930# endif
931
932# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_APPLE_CLANG_VER) && \
933 (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2001)
934# define _LIBCPP_DIAGNOSE_IF(...) __attribute__((__diagnose_if__(__VA_ARGS__)))
935# else
936# define _LIBCPP_DIAGNOSE_IF(...)
937# endif
938
939# define _LIBCPP_DIAGNOSE_NULLPTR_IF(condition, condition_description) \
940 _LIBCPP_DIAGNOSE_IF( \
941 condition, \
942 "null passed to callee that requires a non-null argument" condition_description, \
943 "warning", \
944 "nonnull")
945
946# if __has_cpp_attribute(_Clang::__lifetimebound__)
947# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
948# else
949# define _LIBCPP_LIFETIMEBOUND
950# endif
951
952// This is to work around https://llvm.org/PR156809
953# ifndef _LIBCPP_CXX03_LANG
954# define _LIBCPP_CTOR_LIFETIMEBOUND _LIBCPP_LIFETIMEBOUND
955# else
956# define _LIBCPP_CTOR_LIFETIMEBOUND
957# endif
958
959# if __has_cpp_attribute(_Clang::__noescape__)
960# define _LIBCPP_NOESCAPE [[_Clang::__noescape__]]
961# else
962# define _LIBCPP_NOESCAPE
963# endif
964
965# if __has_cpp_attribute(_Clang::__no_specializations__)
966# define _LIBCPP_NO_SPECIALIZATIONS \
967 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
968# else
969# define _LIBCPP_NO_SPECIALIZATIONS
970# endif
971
972# if __has_cpp_attribute(_Clang::__preferred_name__)
973# define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]]
974# else
975# define _LIBCPP_PREFERRED_NAME(x)
976# endif
977
978# if __has_cpp_attribute(_Clang::__scoped_lockable__)
979# define _LIBCPP_SCOPED_LOCKABLE [[_Clang::__scoped_lockable__]]
980# else
981# define _LIBCPP_SCOPED_LOCKABLE
982# endif
983
984# if __has_cpp_attribute(_Clang::__capability__)
985# define _LIBCPP_CAPABILITY(...) [[_Clang::__capability__(__VA_ARGS__)]]
986# else
987# define _LIBCPP_CAPABILITY(...)
988# endif
989
990# if __has_attribute(__acquire_capability__)
991# define _LIBCPP_ACQUIRE_CAPABILITY(...) __attribute__((__acquire_capability__(__VA_ARGS__)))
992# else
993# define _LIBCPP_ACQUIRE_CAPABILITY(...)
994# endif
995
996# if __has_cpp_attribute(_Clang::__try_acquire_capability__)
997# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) [[_Clang::__try_acquire_capability__(__VA_ARGS__)]]
998# else
999# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...)
1000# endif
1001
1002# if __has_cpp_attribute(_Clang::__acquire_shared_capability__)
1003# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY [[_Clang::__acquire_shared_capability__]]
1004# else
1005# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY
1006# endif
1007
1008# if __has_cpp_attribute(_Clang::__try_acquire_shared_capability__)
1009# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) [[_Clang::__try_acquire_shared_capability__(__VA_ARGS__)]]
1010# else
1011# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...)
1012# endif
1013
1014# if __has_cpp_attribute(_Clang::__release_capability__)
1015# define _LIBCPP_RELEASE_CAPABILITY [[_Clang::__release_capability__]]
1016# else
1017# define _LIBCPP_RELEASE_CAPABILITY
1018# endif
1019
1020# if __has_cpp_attribute(_Clang::__release_shared_capability__)
1021# define _LIBCPP_RELEASE_SHARED_CAPABILITY [[_Clang::__release_shared_capability__]]
1022# else
1023# define _LIBCPP_RELEASE_SHARED_CAPABILITY
1024# endif
1025
1026# if __has_attribute(__requires_capability__)
1027# define _LIBCPP_REQUIRES_CAPABILITY(...) __attribute__((__requires_capability__(__VA_ARGS__)))
1028# else
1029# define _LIBCPP_REQUIRES_CAPABILITY(...)
1030# endif
1031
1032# if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
1033# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
1034# else
1035# define _LIBCPP_DECLSPEC_EMPTY_BASES
1036# endif
1037
1038// Allow for build-time disabling of unsigned integer sanitization
1039# if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
1040# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
1041# else
1042# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
1043# endif
1044
1045# if __has_feature(nullability)
1046# define _LIBCPP_DIAGNOSE_NULLPTR _Nonnull
1047# else
1048# define _LIBCPP_DIAGNOSE_NULLPTR
1049# endif
1050
1051381#endif // __cplusplus
1052382
1053383#endif // _LIBCPP___CONFIG
lib/libcxx/include/__configuration/abi.h+4-16
......@@ -52,12 +52,6 @@
5252#if _LIBCPP_ABI_VERSION >= 2
5353// TODO: Move the description of the remaining ABI flags to ABIGuarantees.rst or remove them.
5454
55// Override the default return value of exception::what() for bad_function_call::what()
56// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).
57// This is an ABI break on platforms that sign and authenticate vtable function pointers
58// because it changes the mangling of the virtual function located in the vtable, which
59// changes how it gets signed.
60# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
6155// According to the Standard, `bitset::operator[] const` returns bool
6256# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
6357
......@@ -77,11 +71,14 @@
7771# define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER
7872# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
7973# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
74# define _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
8075# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
8176# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
8277# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
8378# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
8479# define _LIBCPP_ABI_TRIVIALLY_COPYABLE_BIT_ITERATOR
80# define _LIBCPP_ABI_USE_SMALL_DEQUE_BLOCK_SIZE
81# define _LIBCPP_ABI_VECTORIZED_MERSENNE_TWISTER_ENGINE
8582
8683#elif _LIBCPP_ABI_VERSION == 1
8784// Feature macros for disabling pre ABI v1 features. All of these options
......@@ -91,15 +88,6 @@
9188# endif
9289#endif
9390
94// TODO(LLVM 22): Remove this check
95#if defined(_LIBCPP_ABI_NO_ITERATOR_BASES) && !defined(_LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER)
96# ifndef _LIBCPP_ONLY_NO_ITERATOR_BASES
97# error "You probably want to define _LIBCPP_ABI_NO_REVERSE_ITERATOR_SECOND_MEMBER. This has been split out from" \
98 " _LIBCPP_ABI_NO_ITERATOR_BASES to allow only removing the second iterator member, since they aren't really related." \
99 "If you actually want this ABI configuration, please define _LIBCPP_ONLY_NO_ITERATOR_BASES instead."
100# endif
101#endif
102
10391// We had some bugs where we use [[no_unique_address]] together with construct_at,
10492// which causes UB as the call on construct_at could write to overlapping subobjects
10593//
......@@ -108,7 +96,7 @@
10896//
10997// To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions.
11098// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.
111#define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))
99#define _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG __attribute__((__abi_tag__("llvm18_nua")))
112100
113101// [[msvc::no_unique_address]] seems to mostly affect empty classes, so the padding scheme for Itanium doesn't work.
114102#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING)
lib/libcxx/include/__configuration/attributes.h created+476
......@@ -0,0 +1,476 @@
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___CONFIGURATION_ATTRIBUTES_H
10#define _LIBCPP___CONFIGURATION_ATTRIBUTES_H
11
12/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
13#include <__configuration/hardening.h>
14#include <__configuration/language.h>
15#include <__configuration/utility.h>
16
17#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
18# pragma GCC system_header
19#endif
20
21#ifndef __has_declspec_attribute
22# define __has_declspec_attribute(__x) 0
23#endif
24
25// Attributes relevant for layout ABI
26// ----------------------------------
27
28#if __has_cpp_attribute(msvc::no_unique_address)
29// MSVC implements [[no_unique_address]] as a silent no-op currently.
30// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
31// However, MSVC implements [[msvc::no_unique_address]] which does what
32// [[no_unique_address]] is supposed to do, in general.
33# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
34#else
35# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
36#endif
37
38#define _LIBCPP_PACKED __attribute__((__packed__))
39
40// Attributes affecting overload resolution
41// ----------------------------------------
42
43#if __has_attribute(__enable_if__)
44# define _LIBCPP_PREFERRED_OVERLOAD __attribute__((__enable_if__(true, "")))
45#endif
46
47// Visibility attributes
48// ---------------------
49
50#if defined(_LIBCPP_OBJECT_FORMAT_COFF)
51
52# ifdef _DLL
53# define _LIBCPP_CRT_FUNC __declspec(dllimport)
54# else
55# define _LIBCPP_CRT_FUNC
56# endif
57
58# if defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) || (defined(__MINGW32__) && !defined(_LIBCPP_BUILDING_LIBRARY))
59# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
60# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
61# define _LIBCPP_OVERRIDABLE_FUNC_VIS
62# define _LIBCPP_EXPORTED_FROM_ABI
63# elif defined(_LIBCPP_BUILDING_LIBRARY)
64# if defined(__MINGW32__)
65# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllexport)
66# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
67# else
68# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
69# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __declspec(dllexport)
70# endif
71# define _LIBCPP_OVERRIDABLE_FUNC_VIS __declspec(dllexport)
72# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
73# else
74# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __declspec(dllimport)
75# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
76# define _LIBCPP_OVERRIDABLE_FUNC_VIS
77# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllimport)
78# endif
79
80# define _LIBCPP_HIDDEN
81# define _LIBCPP_TEMPLATE_DATA_VIS
82# define _LIBCPP_NAMESPACE_VISIBILITY
83
84#else
85
86# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
87# define _LIBCPP_VISIBILITY(vis) __attribute__((__visibility__(vis)))
88# else
89# define _LIBCPP_VISIBILITY(vis)
90# endif
91
92# define _LIBCPP_HIDDEN _LIBCPP_VISIBILITY("hidden")
93# define _LIBCPP_TEMPLATE_DATA_VIS _LIBCPP_VISIBILITY("default")
94# define _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_VISIBILITY("default")
95# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_VISIBILITY("default")
96# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
97
98// TODO: Make this a proper customization point or remove the option to override it.
99# ifndef _LIBCPP_OVERRIDABLE_FUNC_VIS
100# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_VISIBILITY("default")
101# endif
102
103# if !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) && __has_attribute(__type_visibility__)
104# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__type_visibility__("default")))
105# elif !defined(_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS)
106# define _LIBCPP_NAMESPACE_VISIBILITY __attribute__((__visibility__("default")))
107# else
108# define _LIBCPP_NAMESPACE_VISIBILITY
109# endif
110
111#endif // defined(_LIBCPP_OBJECT_FORMAT_COFF)
112
113// hide_from_abi
114// -------------
115
116#define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
117
118#if __has_attribute(exclude_from_explicit_instantiation)
119# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION __attribute__((__exclude_from_explicit_instantiation__))
120#else
121// Try to approximate the effect of exclude_from_explicit_instantiation
122// (which is that entities are not assumed to be provided by explicit
123// template instantiations in the dylib) by always inlining those entities.
124# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
125#endif
126
127#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
128# define _LIBCPP_HARDENING_SIG f
129#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
130# define _LIBCPP_HARDENING_SIG s
131#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
132# define _LIBCPP_HARDENING_SIG d
133#else
134# define _LIBCPP_HARDENING_SIG n // "none"
135#endif
136
137#if _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_OBSERVE
138# define _LIBCPP_ASSERTION_SEMANTIC_SIG o
139#elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_QUICK_ENFORCE
140# define _LIBCPP_ASSERTION_SEMANTIC_SIG q
141#elif _LIBCPP_ASSERTION_SEMANTIC == _LIBCPP_ASSERTION_SEMANTIC_ENFORCE
142# define _LIBCPP_ASSERTION_SEMANTIC_SIG e
143#else
144# define _LIBCPP_ASSERTION_SEMANTIC_SIG i // `ignore`
145#endif
146
147#if !_LIBCPP_HAS_EXCEPTIONS
148# define _LIBCPP_EXCEPTIONS_SIG n
149#else
150# define _LIBCPP_EXCEPTIONS_SIG e
151#endif
152
153#define _LIBCPP_ODR_SIGNATURE \
154 _LIBCPP_CONCAT( \
155 _LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_ASSERTION_SEMANTIC_SIG), _LIBCPP_EXCEPTIONS_SIG), \
156 _LIBCPP_VERSION)
157
158// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
159// on two levels:
160// 1. The symbol is given hidden visibility, which ensures that users won't start exporting
161// symbols from their dynamic library by means of using the libc++ headers. This ensures
162// that those symbols stay private to the dynamic library in which it is defined.
163//
164// 2. The symbol is given an ABI tag that encodes the ODR-relevant properties of the library.
165// This ensures that no ODR violation can arise from mixing two TUs compiled with different
166// versions or configurations of libc++ (such as exceptions vs no-exceptions). Indeed, if the
167// program contains two definitions of a function, the ODR requires them to be token-by-token
168// equivalent, and the linker is allowed to pick either definition and discard the other one.
169//
170// For example, if a program contains a copy of `vector::at()` compiled with exceptions enabled
171// *and* a copy of `vector::at()` compiled with exceptions disabled (by means of having two TUs
172// compiled with different settings), the two definitions are both visible by the linker and they
173// have the same name, but they have a meaningfully different implementation (one throws an exception
174// and the other aborts the program). This violates the ODR and makes the program ill-formed, and in
175// practice what will happen is that the linker will pick one of the definitions at random and will
176// discard the other one. This can quite clearly lead to incorrect program behavior.
177//
178// A similar reasoning holds for many other properties that are ODR-affecting. Essentially any
179// property that causes the code of a function to differ from the code in another configuration
180// can be considered ODR-affecting. In practice, we don't encode all such properties in the ABI
181// tag, but we encode the ones that we think are most important: library version, exceptions, and
182// hardening mode.
183//
184// Note that historically, solving this problem has been achieved in various ways, including
185// force-inlining all functions or giving internal linkage to all functions. Both these previous
186// solutions suffer from drawbacks that lead notably to code bloat.
187//
188// Note that we use _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION to ensure that we don't depend
189// on _LIBCPP_HIDE_FROM_ABI methods of classes explicitly instantiated in the dynamic library.
190//
191// Also note that the _LIBCPP_HIDE_FROM_ABI_VIRTUAL macro should be used on virtual functions
192// instead of _LIBCPP_HIDE_FROM_ABI. That macro does not use an ABI tag. Indeed, the mangled
193// name of a virtual function is part of its ABI, since some architectures like arm64e can sign
194// the virtual function pointer in the vtable based on the mangled name of the function. Since
195// we use an ABI tag that changes with each released version, the mangled name of the virtual
196// function would change, which is incorrect. Note that it doesn't make much sense to change
197// the implementation of a virtual function in an ABI-incompatible way in the first place,
198// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
199//
200// The macro can be applied to record and enum types. When the tagged type is nested in
201// a record this "parent" record needs to have the macro too. Another use case for applying
202// this macro to records and unions is to apply an ABI tag to inline constexpr variables.
203// This can be useful for inline variables that are implementation details which are expected
204// to change in the future.
205//
206// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
207// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
208// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
209#ifndef _LIBCPP_NO_ABI_TAG
210# define _LIBCPP_HIDE_FROM_ABI \
211 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
212 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
213#else
214# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
215#endif
216#define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
217
218// This macro makes sure that private classes which aren't necessarily part of the ABI change their name every release.
219// The intention is _not_ to put it on every private class, but only on classes where type name stability implies ABI
220// stability. This is essentially the case for classes that are only accessed through the vtable after instantiation,
221// for example the control blocks of `shared_ptr`. These classes can change in ABI breaking ways as long as their name
222// (and hence their vtable symbol) changes too. Note that the vtable and RTTI are not marked with
223// [[gnu::visibility("hidden")]], since the vtable and RTTI should still be deduplicated across dylibs with the same
224// instatiations.
225#define _LIBCPP_HIDE_STRUCT_FROM_ABI [[__gnu__::__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))]]
226
227// Optional attributes
228// -------------------
229
230// these are useful for a better QoI, but not required to be available
231
232#define _LIBCPP_NOALIAS __attribute__((__malloc__))
233#define _LIBCPP_NODEBUG [[__gnu__::__nodebug__]]
234#define _LIBCPP_NO_SANITIZE(...) __attribute__((__no_sanitize__(__VA_ARGS__)))
235#define _LIBCPP_INIT_PRIORITY_MAX __attribute__((__init_priority__(100)))
236#define _LIBCPP_ATTRIBUTE_FORMAT(archetype, format_string_index, first_format_arg_index) \
237 __attribute__((__format__(archetype, format_string_index, first_format_arg_index)))
238
239#if __has_attribute(__no_sanitize__) && !defined(_LIBCPP_COMPILER_GCC)
240# define _LIBCPP_NO_CFI __attribute__((__no_sanitize__("cfi")))
241#else
242# define _LIBCPP_NO_CFI
243#endif
244
245#if __has_attribute(__using_if_exists__)
246# define _LIBCPP_USING_IF_EXISTS __attribute__((__using_if_exists__))
247#else
248# define _LIBCPP_USING_IF_EXISTS
249#endif
250
251#if __has_cpp_attribute(_Clang::__no_destroy__)
252# define _LIBCPP_NO_DESTROY [[_Clang::__no_destroy__]]
253#else
254# define _LIBCPP_NO_DESTROY
255#endif
256
257#if __has_attribute(__diagnose_if__)
258# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
259#else
260# define _LIBCPP_DIAGNOSE_WARNING(...)
261#endif
262
263#if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_APPLE_CLANG_VER) && \
264 (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2001)
265# define _LIBCPP_DIAGNOSE_IF(...) __attribute__((__diagnose_if__(__VA_ARGS__)))
266#else
267# define _LIBCPP_DIAGNOSE_IF(...)
268#endif
269
270#define _LIBCPP_DIAGNOSE_NULLPTR_IF(condition, condition_description) \
271 _LIBCPP_DIAGNOSE_IF( \
272 condition, \
273 "null passed to callee that requires a non-null argument" condition_description, \
274 "warning", \
275 "nonnull")
276
277#if __has_cpp_attribute(_Clang::__lifetimebound__)
278# define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
279#else
280# define _LIBCPP_LIFETIMEBOUND
281#endif
282
283// This is to work around https://llvm.org/PR156809
284#ifndef _LIBCPP_CXX03_LANG
285# define _LIBCPP_CTOR_LIFETIMEBOUND _LIBCPP_LIFETIMEBOUND
286#else
287# define _LIBCPP_CTOR_LIFETIMEBOUND
288#endif
289
290#if __has_cpp_attribute(_Clang::__noescape__)
291# define _LIBCPP_NOESCAPE [[_Clang::__noescape__]]
292#else
293# define _LIBCPP_NOESCAPE
294#endif
295
296#if __has_cpp_attribute(_Clang::__no_specializations__)
297# define _LIBCPP_NO_SPECIALIZATIONS \
298 [[_Clang::__no_specializations__("Users are not allowed to specialize this standard library entity")]]
299#else
300# define _LIBCPP_NO_SPECIALIZATIONS
301#endif
302
303#if __has_cpp_attribute(_Clang::__preferred_name__)
304# define _LIBCPP_PREFERRED_NAME(x) [[_Clang::__preferred_name__(x)]]
305#else
306# define _LIBCPP_PREFERRED_NAME(x)
307#endif
308
309#if __has_cpp_attribute(_Clang::__scoped_lockable__)
310# define _LIBCPP_SCOPED_LOCKABLE [[_Clang::__scoped_lockable__]]
311#else
312# define _LIBCPP_SCOPED_LOCKABLE
313#endif
314
315#if __has_cpp_attribute(_Clang::__capability__)
316# define _LIBCPP_CAPABILITY(...) [[_Clang::__capability__(__VA_ARGS__)]]
317#else
318# define _LIBCPP_CAPABILITY(...)
319#endif
320
321#if __has_attribute(__acquire_capability__)
322# define _LIBCPP_ACQUIRE_CAPABILITY(...) __attribute__((__acquire_capability__(__VA_ARGS__)))
323#else
324# define _LIBCPP_ACQUIRE_CAPABILITY(...)
325#endif
326
327#if __has_cpp_attribute(_Clang::__try_acquire_capability__)
328# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...) [[_Clang::__try_acquire_capability__(__VA_ARGS__)]]
329#else
330# define _LIBCPP_TRY_ACQUIRE_CAPABILITY(...)
331#endif
332
333#if __has_cpp_attribute(_Clang::__acquire_shared_capability__)
334# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY [[_Clang::__acquire_shared_capability__]]
335#else
336# define _LIBCPP_ACQUIRE_SHARED_CAPABILITY
337#endif
338
339#if __has_cpp_attribute(_Clang::__try_acquire_shared_capability__)
340# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...) [[_Clang::__try_acquire_shared_capability__(__VA_ARGS__)]]
341#else
342# define _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(...)
343#endif
344
345#if __has_attribute(__release_capability__)
346# define _LIBCPP_RELEASE_CAPABILITY(...) __attribute__((__release_capability__(__VA_ARGS__)))
347#else
348# define _LIBCPP_RELEASE_CAPABILITY(...)
349#endif
350
351#if __has_cpp_attribute(_Clang::__release_shared_capability__)
352# define _LIBCPP_RELEASE_SHARED_CAPABILITY [[_Clang::__release_shared_capability__]]
353#else
354# define _LIBCPP_RELEASE_SHARED_CAPABILITY
355#endif
356
357#if __has_attribute(__requires_capability__)
358# define _LIBCPP_REQUIRES_CAPABILITY(...) __attribute__((__requires_capability__(__VA_ARGS__)))
359#else
360# define _LIBCPP_REQUIRES_CAPABILITY(...)
361#endif
362
363#if __has_cpp_attribute(_Clang::__no_thread_safety_analysis__)
364# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[_Clang::__no_thread_safety_analysis__]]
365#else
366# define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
367#endif
368
369#if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
370# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
371#else
372# define _LIBCPP_DECLSPEC_EMPTY_BASES
373#endif
374
375// Allow for build-time disabling of unsigned integer sanitization
376#if __has_attribute(no_sanitize) && !defined(_LIBCPP_COMPILER_GCC)
377# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute__((__no_sanitize__("unsigned-integer-overflow")))
378#else
379# define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
380#endif
381
382#if __has_feature(nullability)
383# define _LIBCPP_DIAGNOSE_NULLPTR _Nonnull
384#else
385# define _LIBCPP_DIAGNOSE_NULLPTR
386#endif
387
388#if defined(__CUDACC__) || defined(__CUDA_ARCH__) || defined(__CUDA_LIBDEVICE__)
389// The CUDA SDK contains an unfortunate definition for the __noinline__ macro,
390// which breaks the regular __attribute__((__noinline__)) syntax. Therefore,
391// when compiling for CUDA we use the non-underscored version of the noinline
392// attribute.
393//
394// This is a temporary workaround and we still expect the CUDA SDK team to solve
395// this issue properly in the SDK headers.
396//
397// See https://github.com/llvm/llvm-project/pull/73838 for more details.
398# define _LIBCPP_NOINLINE __attribute__((noinline))
399#elif __has_attribute(__noinline__)
400# define _LIBCPP_NOINLINE __attribute__((__noinline__))
401#else
402# define _LIBCPP_NOINLINE
403#endif
404
405// Deprecation macros
406// ------------------
407
408// Deprecations warnings are always enabled, except when users explicitly opt-out
409// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
410#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
411# if __has_attribute(__deprecated__)
412# define _LIBCPP_DEPRECATED __attribute__((__deprecated__))
413# define _LIBCPP_DEPRECATED_(m) __attribute__((__deprecated__(m)))
414# elif _LIBCPP_STD_VER >= 14
415# define _LIBCPP_DEPRECATED [[deprecated]]
416# define _LIBCPP_DEPRECATED_(m) [[deprecated(m)]]
417# else
418# define _LIBCPP_DEPRECATED
419# define _LIBCPP_DEPRECATED_(m)
420# endif
421#else
422# define _LIBCPP_DEPRECATED
423# define _LIBCPP_DEPRECATED_(m)
424#endif
425
426#if !defined(_LIBCPP_CXX03_LANG)
427# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
428#else
429# define _LIBCPP_DEPRECATED_IN_CXX11
430#endif
431
432#if _LIBCPP_STD_VER >= 14
433# define _LIBCPP_DEPRECATED_IN_CXX14 _LIBCPP_DEPRECATED
434#else
435# define _LIBCPP_DEPRECATED_IN_CXX14
436#endif
437
438#if _LIBCPP_STD_VER >= 17
439# define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED
440#else
441# define _LIBCPP_DEPRECATED_IN_CXX17
442#endif
443
444#if _LIBCPP_STD_VER >= 20
445# define _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_DEPRECATED
446#else
447# define _LIBCPP_DEPRECATED_IN_CXX20
448#endif
449
450#if _LIBCPP_STD_VER >= 23
451# define _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_DEPRECATED
452#else
453# define _LIBCPP_DEPRECATED_IN_CXX23
454#endif
455
456#if _LIBCPP_STD_VER >= 26
457# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
458# define _LIBCPP_DEPRECATED_IN_CXX26_(m) _LIBCPP_DEPRECATED_(m)
459#else
460# define _LIBCPP_DEPRECATED_IN_CXX26
461# define _LIBCPP_DEPRECATED_IN_CXX26_(m)
462#endif
463
464#if _LIBCPP_HAS_CHAR8_T
465# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
466#else
467# define _LIBCPP_DEPRECATED_WITH_CHAR8_T
468#endif
469
470#if __has_cpp_attribute(_Clang::__no_field_protection__)
471# define _LIBCPP_DISABLE_POINTER_FIELD_PROTECTION [[_Clang::__no_field_protection__]]
472#else
473# define _LIBCPP_DISABLE_POINTER_FIELD_PROTECTION
474#endif
475
476#endif // _LIBCPP___CONFIGURATION_ATTRIBUTES_H
lib/libcxx/include/__configuration/availability.h+93-68
......@@ -38,6 +38,11 @@
3838// When availability annotations are disabled, we take for granted that features introduced
3939// in all versions of the library are available.
4040#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
41# define _LIBCPP_INTRODUCED_IN_LLVM_23 1
42# define _LIBCPP_INTRODUCED_IN_LLVM_23_ATTRIBUTE /* nothing */
43
44# define _LIBCPP_INTRODUCED_IN_LLVM_23 1
45# define _LIBCPP_INTRODUCED_IN_LLVM_23_ATTRIBUTE /* nothing */
4146
4247# define _LIBCPP_INTRODUCED_IN_LLVM_22 1
4348# define _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE /* nothing */
......@@ -70,15 +75,34 @@
7075
7176// clang-format off
7277
78// LLVM 23
79// TODO: Fill this in
80# define _LIBCPP_INTRODUCED_IN_LLVM_23 0
81# define _LIBCPP_INTRODUCED_IN_LLVM_23_ATTRIBUTE __attribute__((unavailable))
82
7383// LLVM 22
7484// TODO: Fill this in
7585# define _LIBCPP_INTRODUCED_IN_LLVM_22 0
7686# define _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE __attribute__((unavailable))
7787
7888// LLVM 21
79// TODO: Fill this in
80# define _LIBCPP_INTRODUCED_IN_LLVM_21 0
81# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable))
89# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 260400) || \
90 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 260400) || \
91 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 260400) || \
92 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 260400) || \
93 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 100400) || \
94 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 250400)
95# define _LIBCPP_INTRODUCED_IN_LLVM_21 0
96# else
97# define _LIBCPP_INTRODUCED_IN_LLVM_21 1
98# endif
99# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE \
100 __attribute__((availability(macos, strict, introduced = 26.4))) \
101 __attribute__((availability(ios, strict, introduced = 26.4))) \
102 __attribute__((availability(tvos, strict, introduced = 26.4))) \
103 __attribute__((availability(watchos, strict, introduced = 26.4))) \
104 __attribute__((availability(bridgeos, strict, introduced = 10.4))) \
105 __attribute__((availability(driverkit, strict, introduced = 25.4)))
82106
83107// LLVM 20
84108//
......@@ -87,7 +111,8 @@
87111 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 260000) || \
88112 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 260000) || \
89113 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 260000) || \
90 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 100000)
114 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 100000) || \
115 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 250000)
91116# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
92117# else
93118# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
......@@ -97,14 +122,16 @@
97122 __attribute__((availability(ios, strict, introduced = 26.0))) \
98123 __attribute__((availability(tvos, strict, introduced = 26.0))) \
99124 __attribute__((availability(watchos, strict, introduced = 26.0))) \
100 __attribute__((availability(bridgeos, strict, introduced = 10.0)))
125 __attribute__((availability(bridgeos, strict, introduced = 10.0))) \
126 __attribute__((availability(driverkit, strict, introduced = 25.0)))
101127
102128// LLVM 19
103129# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150400) || \
104130 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 180400) || \
105131 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 180400) || \
106132 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 110400) || \
107 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90400)
133 (defined(__ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_BRIDGE_OS_VERSION_MIN_REQUIRED__ < 90400) || \
134 (defined(__ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_DRIVERKIT_VERSION_MIN_REQUIRED__ < 240400)
108135# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
109136# else
110137# define _LIBCPP_INTRODUCED_IN_LLVM_19 1
......@@ -114,7 +141,8 @@
114141 __attribute__((availability(ios, strict, introduced = 18.4))) \
115142 __attribute__((availability(tvos, strict, introduced = 18.4))) \
116143 __attribute__((availability(watchos, strict, introduced = 11.4))) \
117 __attribute__((availability(bridgeos, strict, introduced = 9.4)))
144 __attribute__((availability(bridgeos, strict, introduced = 9.4))) \
145 __attribute__((availability(driverkit, strict, introduced = 24.4)))
118146
119147// LLVM 18
120148# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 150000) || \
......@@ -220,51 +248,28 @@
220248#define _LIBCPP_AVAILABILITY_HAS_NEW_SYNC _LIBCPP_INTRODUCED_IN_LLVM_22
221249#define _LIBCPP_AVAILABILITY_NEW_SYNC _LIBCPP_INTRODUCED_IN_LLVM_22_ATTRIBUTE
222250
223// Enable additional explicit instantiations of iostreams components. This
224// reduces the number of weak definitions generated in programs that use
225// iostreams by providing a single strong definition in the shared library.
226//
227// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
228// or once libc++ doesn't use the attribute anymore.
229// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
230#if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
231# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12
232#else
233# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
234#endif
235
236// This controls the availability of floating-point std::to_chars functions.
237// These overloads were added later than the integer overloads.
238#define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14
239#define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE
240
241// This controls whether the library claims to provide a default verbose
242// termination function, and consequently whether the headers will try
243// to use it when the mechanism isn't overriden at compile-time.
244#define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15
245#define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
251// This controls whether `std::__hash_memory` is available in the dylib, which
252// is used for some `std::hash` specializations.
253#define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21
254// No attribute, since we've had hash in the headers before
246255
247// This controls the availability of the C++17 std::pmr library,
248// which is implemented in large part in the built library.
249//
250// TODO: Enable std::pmr markup once https://llvm.org/PR40340 has been fixed
251// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
252// it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we
253// use availability annotations until that bug has been fixed.
254#define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16
255#define _LIBCPP_AVAILABILITY_PMR
256// This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`.
257// See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib.
258#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
259// No attribute, since we've had bad_function_call::what() in the headers before
256260
257// These macros controls the availability of __cxa_init_primary_exception
258// in the built library, which std::make_exception_ptr might use
259// (see libcxx/include/__exception/exception_ptr.h).
260#define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18
261#define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
261// This determines whether we assume that the internal std::__bad_variant_access_with_msg class
262// (which carries a message describing the cause of the failure in bad_variant_access::what())
263// provides a key function in the dylib. This allows centralizing its vtable and typeinfo instead
264// of having all TUs provide a weak definition that then gets deduplicated. When it is not available
265// in the dylib, what() is defined inline instead, so the descriptive message is provided regardless.
266#define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS_WITH_MSG_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_23
267// No attribute, since we've had bad_variant_access in the headers before
262268
263// This controls the availability of C++23 <print>, which
264// has a dependency on the built library (it needs access to
265// the underlying buffer types of std::cout, std::cerr, and std::clog.
266#define _LIBCPP_AVAILABILITY_HAS_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18
267#define _LIBCPP_AVAILABILITY_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
269// This controls the availability of floating-point std::from_chars functions.
270// These overloads were added later than the integer overloads.
271#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
272#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
268273
269274// This controls the availability of the C++20 time zone database.
270275// The parser code is built in the library.
......@@ -280,30 +285,50 @@
280285#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
281286#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
282287
283// This controls the availability of floating-point std::from_chars functions.
284// These overloads were added later than the integer overloads.
285#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
286#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
288// These macros controls the availability of __cxa_init_primary_exception
289// in the built library, which std::make_exception_ptr might use
290// (see libcxx/include/__exception/exception_ptr.h).
291#define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18
292#define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
287293
288// This controls whether `std::__hash_memory` is available in the dylib, which
289// is used for some `std::hash` specializations.
290#define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21
291// No attribute, since we've had hash in the headers before
294// This controls the availability of the C++17 std::pmr library,
295// which is implemented in large part in the built library.
296//
297// TODO: Enable std::pmr markup once https://llvm.org/PR40340 has been fixed
298// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
299// it and it'll be a load-time error, but we don't have a good alternative because the library won't compile if we
300// use availability annotations until that bug has been fixed.
301#define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16
302#define _LIBCPP_AVAILABILITY_PMR
292303
293// This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`.
294// See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib.
295#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
296// No attribute, since we've had bad_function_call::what() in the headers before
304// This controls whether the library claims to provide a default verbose
305// termination function, and consequently whether the headers will try
306// to use it when the mechanism isn't overriden at compile-time.
307#define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15
308#define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
309
310// This controls the availability of floating-point std::to_chars functions.
311// These overloads were added later than the integer overloads.
312#define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14
313#define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE
297314
298// Define availability attributes that depend on both
299// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
300#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI
301# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
302# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
303# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
304# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
315// Enable additional explicit instantiations of iostreams components. This
316// reduces the number of weak definitions generated in programs that use
317// iostreams by providing a single strong definition in the shared library.
318//
319// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
320// or once libc++ doesn't use the attribute anymore.
321// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
322#if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
323# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12
324#else
325# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
305326#endif
306327
328// Controls whether the implementation for text_encoding::environment() is available
329#define _LIBCPP_AVAILABILITY_HAS_TEXT_ENCODING_ENVIRONMENT _LIBCPP_INTRODUCED_IN_LLVM_23
330#define _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT _LIBCPP_INTRODUCED_IN_LLVM_23_ATTRIBUTE
331
307332// Only define a bunch of symbols in the dylib if we need to be compatible with LLVM 7 headers or older
308333# if defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 8
309334# define _LIBCPP_HIDE_FROM_ABI_SINCE_LLVM8
lib/libcxx/include/__configuration/compiler.h+29-4
......@@ -33,12 +33,12 @@
3333// Warn if a compiler version is used that is not supported anymore
3434// LLVM RELEASE Update the minimum compiler versions
3535# if defined(_LIBCPP_CLANG_VER)
36# if _LIBCPP_CLANG_VER < 2001
37# warning "Libc++ only supports Clang 20 and later"
36# if _LIBCPP_CLANG_VER < 2101
37# warning "Libc++ only supports Clang 21 and later"
3838# endif
3939# elif defined(_LIBCPP_APPLE_CLANG_VER)
40# if _LIBCPP_APPLE_CLANG_VER < 1700
41# warning "Libc++ only supports AppleClang 26 and later"
40# if _LIBCPP_APPLE_CLANG_VER < 2100
41# warning "Libc++ only supports AppleClang 26.4 and later"
4242# endif
4343# elif defined(_LIBCPP_GCC_VER)
4444# if _LIBCPP_GCC_VER < 1500
......@@ -46,6 +46,31 @@
4646# endif
4747# endif
4848
49# ifndef __has_constexpr_builtin
50# define __has_constexpr_builtin(x) 0
51# endif
52
53// This checks wheter a Clang module is built
54# ifndef __building_module
55# define __building_module(...) 0
56# endif
57
58// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
59// the compiler and '1' otherwise.
60# ifndef __is_identifier
61# define __is_identifier(__x) 1
62# endif
63
64# define __has_keyword(__x) !(__is_identifier(__x))
65
66# ifndef __has_warning
67# define __has_warning(...) 0
68# endif
69
70# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
71# error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
72# endif
73
4974#endif
5075
5176#endif // _LIBCPP___CONFIGURATION_COMPILER_H
lib/libcxx/include/__configuration/diagnostic_suppression.h created+44
......@@ -0,0 +1,44 @@
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___CONFIGURATION_DIAGNOSTIC_SUPPRESSION_H
11#define _LIBCPP___CONFIGURATION_DIAGNOSTIC_SUPPRESSION_H
12
13/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14#include <__configuration/compiler.h>
15#include <__configuration/utility.h>
16
17#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
18# pragma GCC system_header
19#endif
20
21#ifdef _LIBCPP_COMPILER_CLANG_BASED
22# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
23# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
24# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
25# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
26#elif defined(_LIBCPP_COMPILER_GCC)
27# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
28# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
29# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
30# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
31#else
32# define _LIBCPP_DIAGNOSTIC_PUSH
33# define _LIBCPP_DIAGNOSTIC_POP
34# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
35# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
36#endif
37
38// Macros to enter and leave a state where deprecation warnings are suppressed.
39#define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
40 _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated") \
41 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
42#define _LIBCPP_SUPPRESS_DEPRECATED_POP _LIBCPP_DIAGNOSTIC_POP
43
44#endif // _LIBCPP___CONFIGURATION_DIAGNOSTIC_SUPPRESSION_H
lib/libcxx/include/__configuration/hardening.h-17
......@@ -17,23 +17,6 @@
1717# pragma GCC system_header
1818#endif
1919
20// TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated.
21// Since hardening went through several changes (many of which impacted user-facing macros),
22// we're keeping these checks around for a bit longer than usual. Failure to properly configure
23// hardening results in checks being dropped silently, which is a pretty big deal.
24#if defined(_LIBCPP_ENABLE_ASSERTIONS)
25# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
26#endif
27#if defined(_LIBCPP_ENABLE_HARDENED_MODE)
28# error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
29#endif
30#if defined(_LIBCPP_ENABLE_SAFE_MODE)
31# error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
32#endif
33#if defined(_LIBCPP_ENABLE_DEBUG_MODE)
34# error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
35#endif
36
3720// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
3821//
3922// - `_LIBCPP_HARDENING_MODE_NONE`;
lib/libcxx/include/__configuration/language.h+42
......@@ -50,4 +50,46 @@
5050# define _LIBCPP_HAS_EXCEPTIONS 0
5151#endif
5252
53#if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t)
54# define _LIBCPP_HAS_CHAR8_T 0
55#else
56# define _LIBCPP_HAS_CHAR8_T 1
57#endif
58
59#if _LIBCPP_STD_VER <= 11
60# define _LIBCPP_EXPLICIT_SINCE_CXX14
61#else
62# define _LIBCPP_EXPLICIT_SINCE_CXX14 explicit
63#endif
64
65#if _LIBCPP_STD_VER >= 14
66# define _LIBCPP_CONSTEXPR_SINCE_CXX14 constexpr
67#else
68# define _LIBCPP_CONSTEXPR_SINCE_CXX14
69#endif
70
71#if _LIBCPP_STD_VER >= 17
72# define _LIBCPP_CONSTEXPR_SINCE_CXX17 constexpr
73#else
74# define _LIBCPP_CONSTEXPR_SINCE_CXX17
75#endif
76
77#if _LIBCPP_STD_VER >= 20
78# define _LIBCPP_CONSTEXPR_SINCE_CXX20 constexpr
79#else
80# define _LIBCPP_CONSTEXPR_SINCE_CXX20
81#endif
82
83#if _LIBCPP_STD_VER >= 23
84# define _LIBCPP_CONSTEXPR_SINCE_CXX23 constexpr
85#else
86# define _LIBCPP_CONSTEXPR_SINCE_CXX23
87#endif
88
89#if _LIBCPP_STD_VER >= 26
90# define _LIBCPP_CONSTEXPR_SINCE_CXX26 constexpr
91#else
92# define _LIBCPP_CONSTEXPR_SINCE_CXX26
93#endif
94
5395#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H
lib/libcxx/include/__configuration/namespace.h created+99
......@@ -0,0 +1,99 @@
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___CONFIGURATION_NAMESPACE_H
11#define _LIBCPP___CONFIGURATION_NAMESPACE_H
12
13/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14#include <__configuration/attributes.h>
15#include <__configuration/diagnostic_suppression.h>
16#include <__configuration/utility.h>
17
18#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
19# pragma GCC system_header
20#endif
21
22// Clang modules take a significant compile time hit when pushing and popping diagnostics.
23// Since all the headers are marked as system headers unless _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER is defined, we can
24// simply disable this pushing and popping when _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER isn't defined.
25#ifdef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
26# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
27 _LIBCPP_DIAGNOSTIC_PUSH \
28 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
29 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
30 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
31 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
32 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions") \
33 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
34 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
35 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
36 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
37# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
38# define _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS \
39 _LIBCPP_DIAGNOSTIC_PUSH _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpragma-clang-attribute") \
40 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wignored-attributes")
41# define _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
42#else
43# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
44# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
45# define _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS
46# define _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
47#endif
48
49#define _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS \
50 _LIBCPP_PUSH_ABI_PRAGMA_DIAGNOSTICS \
51 _Pragma(_LIBCPP_TOSTRING(clang attribute _LibcxxExplicitABIAnnotations.push( \
52 __attribute__((__exclude_from_explicit_instantiation__, \
53 __visibility__("hidden"), \
54 __abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE)))), \
55 apply_to = function))) _LIBCPP_POP_ABI_PRAGMA_DIAGNOSTICS
56
57#define _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS _Pragma("clang attribute _LibcxxExplicitABIAnnotations.pop")
58
59// clang-format off
60
61// The unversioned namespace is used when we want to be ABI compatible with other standard libraries in some way. There
62// are two main categories where that's the case:
63// - Historically, we have made exception types ABI compatible with libstdc++ to allow throwing them between libstdc++
64// and libc++. This is not used anymore for new exception types, since there is no use-case for it anymore.
65// - Types and functions which are used by the compiler are in the unversioned namespace, since the compiler has to know
66// their mangling without the appropriate declaration in some cases.
67// If it's not clear whether using the unversioned namespace is the correct thing to do, it's not. The versioned
68// namespace (_LIBCPP_BEGIN_NAMESPACE_STD) should almost always be used.
69# define _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD \
70 _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS _LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS namespace _LIBCPP_NAMESPACE_VISIBILITY std {
71
72# define _LIBCPP_END_UNVERSIONED_NAMESPACE_STD } _LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS _LIBCPP_POP_EXTENSION_DIAGNOSTICS
73
74# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD inline namespace _LIBCPP_ABI_NAMESPACE {
75# define _LIBCPP_END_NAMESPACE_STD } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
76
77// TODO: This should really be in the versioned namespace
78#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD namespace experimental {
79#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL } _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
80
81#define _LIBCPP_BEGIN_NAMESPACE_LFTS _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v1 {
82#define _LIBCPP_END_NAMESPACE_LFTS } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
83
84#define _LIBCPP_BEGIN_NAMESPACE_LFTS_V2 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL inline namespace fundamentals_v2 {
85#define _LIBCPP_END_NAMESPACE_LFTS_V2 } _LIBCPP_END_NAMESPACE_EXPERIMENTAL
86
87#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
88# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
89# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
90#else
91# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
92 inline namespace __fs { namespace filesystem {
93
94# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
95#endif
96
97// clang-format on
98
99#endif // _LIBCPP___CONFIGURATION_NAMESPACE_H
lib/libcxx/include/__configuration/platform.h+4
......@@ -30,6 +30,10 @@
3030// ... add new file formats here ...
3131#endif
3232
33#if defined(__MVS__)
34# include <features.h> // for __NATIVE_ASCII_F
35#endif
36
3337// Need to detect which libc we're using if we're on Linux.
3438#if (defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)) && __has_include(<features.h>)
3539# include <features.h>
lib/libcxx/include/__configuration/pstl.h created+66
......@@ -0,0 +1,66 @@
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___CONFIGURATION_PSTL_H
11#define _LIBCPP___CONFIGURATION_PSTL_H
12
13/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14
15#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# pragma GCC system_header
17#endif
18
19#define _PSTL_PRAGMA(x) _Pragma(#x)
20
21// Enable SIMD for compilers that support OpenMP 4.0
22#if (defined(_OPENMP) && _OPENMP >= 201307)
23
24# define _PSTL_UDR_PRESENT
25# define _PSTL_PRAGMA_SIMD _PSTL_PRAGMA(omp simd)
26# define _PSTL_PRAGMA_DECLARE_SIMD _PSTL_PRAGMA(omp declare simd)
27# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _PSTL_PRAGMA(omp simd reduction(PRM))
28# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _PSTL_PRAGMA(omp simd reduction(inscan, PRM))
29# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan inclusive(PRM))
30# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM) _PSTL_PRAGMA(omp scan exclusive(PRM))
31
32// Declaration of reduction functor, where
33// NAME - the name of the functor
34// OP - type of the callable object with the reduction operation
35// omp_in - refers to the local partial result
36// omp_out - refers to the final value of the combiner operator
37// omp_priv - refers to the private copy of the initial value
38// omp_orig - refers to the original variable to be reduced
39# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP) \
40 _PSTL_PRAGMA(omp declare reduction(NAME:OP : omp_out(omp_in)) initializer(omp_priv = omp_orig))
41
42#elif defined(_LIBCPP_COMPILER_CLANG_BASED)
43
44# define _PSTL_PRAGMA_SIMD _Pragma("clang loop vectorize(enable) interleave(enable)")
45# define _PSTL_PRAGMA_DECLARE_SIMD
46# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
47# define _PSTL_PRAGMA_SIMD_SCAN(PRM) _Pragma("clang loop vectorize(enable) interleave(enable)")
48# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
49# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
50# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
51
52#else // (defined(_OPENMP) && _OPENMP >= 201307)
53
54# define _PSTL_PRAGMA_SIMD
55# define _PSTL_PRAGMA_DECLARE_SIMD
56# define _PSTL_PRAGMA_SIMD_REDUCTION(PRM)
57# define _PSTL_PRAGMA_SIMD_SCAN(PRM)
58# define _PSTL_PRAGMA_SIMD_INCLUSIVE_SCAN(PRM)
59# define _PSTL_PRAGMA_SIMD_EXCLUSIVE_SCAN(PRM)
60# define _PSTL_PRAGMA_DECLARE_REDUCTION(NAME, OP)
61
62#endif // (defined(_OPENMP) && _OPENMP >= 201307)
63
64#define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
65
66#endif // _LIBCPP___CONFIGURATION_PSTL_H
lib/libcxx/include/__configuration/utility.h created+26
......@@ -0,0 +1,26 @@
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___CONFIGURATION_UTILITY_H
11#define _LIBCPP___CONFIGURATION_UTILITY_H
12
13/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14
15#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# pragma GCC system_header
17#endif
18
19#define _LIBCPP_TOSTRING2(x) #x
20#define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x)
21
22#define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
23#define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
24#define _LIBCPP_CONCAT3(X, Y, Z) _LIBCPP_CONCAT(X, _LIBCPP_CONCAT(Y, Z))
25
26#endif // _LIBCPP___CONFIGURATION_UTILITY_H
lib/libcxx/include/__cstddef/byte.h+6-6
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
2323
2424enum class byte : unsigned char {};
2525
26_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
26[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
2727 return static_cast<byte>(
2828 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) | static_cast<unsigned int>(__rhs)));
2929}
......@@ -32,7 +32,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator|=(byte& __lhs, byte __rhs)
3232 return __lhs = __lhs | __rhs;
3333}
3434
35_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
35[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator&(byte __lhs, byte __rhs) noexcept {
3636 return static_cast<byte>(
3737 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) & static_cast<unsigned int>(__rhs)));
3838}
......@@ -41,7 +41,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator&=(byte& __lhs, byte __rhs)
4141 return __lhs = __lhs & __rhs;
4242}
4343
44_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
44[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator^(byte __lhs, byte __rhs) noexcept {
4545 return static_cast<byte>(
4646 static_cast<unsigned char>(static_cast<unsigned int>(__lhs) ^ static_cast<unsigned int>(__rhs)));
4747}
......@@ -50,7 +50,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr byte& operator^=(byte& __lhs, byte __rhs)
5050 return __lhs = __lhs ^ __rhs;
5151}
5252
53_LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
53[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator~(byte __b) noexcept {
5454 return static_cast<byte>(static_cast<unsigned char>(~static_cast<unsigned int>(__b)));
5555}
5656
......@@ -60,7 +60,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr byte& operator<<=(byte& __lhs, _Integer __shift)
6060}
6161
6262template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
63_LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
63[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr byte operator<<(byte __lhs, _Integer __shift) noexcept {
6464 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) << __shift));
6565}
6666
......@@ -70,7 +70,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr byte& operator>>=(byte& __lhs, _Integer __shift)
7070}
7171
7272template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
73_LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
73[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) noexcept {
7474 return static_cast<byte>(static_cast<unsigned char>(static_cast<unsigned int>(__lhs) >> __shift));
7575}
7676
lib/libcxx/include/__cstddef/max_align_t.h+4-2
......@@ -16,12 +16,14 @@
1616# pragma GCC system_header
1717#endif
1818
19#if !defined(_LIBCPP_CXX03_LANG)
20
1921_LIBCPP_BEGIN_NAMESPACE_STD
2022
21#if !defined(_LIBCPP_CXX03_LANG)
2223using ::max_align_t _LIBCPP_USING_IF_EXISTS;
23#endif
2424
2525_LIBCPP_END_NAMESPACE_STD
2626
27#endif
28
2729#endif // _LIBCPP___CSTDDEF_MAX_ALIGN_T_H
lib/libcxx/include/__debug_utils/sanitizers.h+30-5
......@@ -17,7 +17,32 @@
1717# pragma GCC system_header
1818#endif
1919
20#if __has_feature(address_sanitizer)
20// Within libc++, _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS determines whether the containers should
21// provide ASAN container overflow checks. That setting attempts to honour ASAN's documented option
22// __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ which can be defined by users to disable container overflow
23// checks.
24//
25// However, since parts of some containers (e.g. std::string) are compiled separately into the built
26// library, there are caveats:
27// - __SANITIZER_DISABLE_CONTAINER_OVERFLOW__ can't always be honoured, i.e. if the built library
28// was compiled with ASAN container checks, it's impossible to turn them off afterwards. We diagnose
29// this with an error to avoid the proliferation of invalid configurations that appear to work.
30//
31// - The container overflow checks themselves are not always available even when the user is compiling
32// with -fsanitize=address. If a container is compiled separately like std::string, it can't provide
33// container checks unless the separately compiled code was built with container checks enabled. These
34// containers need to also conditionalize whether they provide overflow checks on `_LIBCPP_INSTRUMENTED_WITH_ASAN`.
35#if __has_feature(address_sanitizer) && !defined(__SANITIZER_DISABLE_CONTAINER_OVERFLOW__)
36# define _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS 1
37#else
38# define _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS 0
39#endif
40
41#if _LIBCPP_INSTRUMENTED_WITH_ASAN && !_LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
42# error "We can't disable ASAN container checks when libc++ has been built with ASAN container checks enabled"
43#endif
44
45#if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
2146
2247extern "C" {
2348_LIBCPP_EXPORTED_FROM_ABI void
......@@ -28,12 +53,12 @@ _LIBCPP_EXPORTED_FROM_ABI int
2853__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
2954}
3055
31#endif // __has_feature(address_sanitizer)
56#endif // _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
3257
3358_LIBCPP_BEGIN_NAMESPACE_STD
3459
3560// ASan choices
36#if __has_feature(address_sanitizer)
61#if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
3762# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1
3863#endif
3964
......@@ -57,7 +82,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
5782 const void* __last_old_contained,
5883 const void* __first_new_contained,
5984 const void* __last_new_contained) {
60#if !__has_feature(address_sanitizer)
85#if !_LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
6186 (void)__first_storage;
6287 (void)__last_storage;
6388 (void)__first_old_contained;
......@@ -86,7 +111,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c
86111 const void* __last_storage,
87112 const void* __old_last_contained,
88113 const void* __new_last_contained) {
89#if !__has_feature(address_sanitizer)
114#if !_LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
90115 (void)__first_storage;
91116 (void)__last_storage;
92117 (void)__old_last_contained;
lib/libcxx/include/__exception/exception.h+2
......@@ -22,6 +22,7 @@
2222#endif
2323
2424_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
2627#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
2728// The std::exception class was already included above, but we're explicit about this condition here for clarity.
......@@ -91,6 +92,7 @@ public:
9192};
9293#endif // !_LIBCPP_ABI_VCRUNTIME
9394
95_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
9496_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
9597
9698#endif // _LIBCPP___EXCEPTION_EXCEPTION_H
lib/libcxx/include/__exception/exception_ptr.h+15-37
......@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS
3131
3232#ifndef _LIBCPP_ABI_MICROSOFT
3333
34# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
34# if _LIBCPP_HAS_EXCEPTIONS && _LIBCPP_HAS_RTTI && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
3535
3636namespace __cxxabiv1 {
3737
......@@ -55,13 +55,12 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
5555
5656} // namespace __cxxabiv1
5757
58# endif
58# endif // _LIBCPP_HAS_EXCEPTIONS && _LIBCPP_HAS_RTTI && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
5959
60#endif
60#endif // !defined(_LIBCPP_ABI_MICROSOFT)
6161
6262_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
63
64#ifndef _LIBCPP_ABI_MICROSOFT
63_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
6564
6665inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT;
6766
......@@ -73,6 +72,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
7372 template <class _Ep>
7473 friend _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep&) _NOEXCEPT;
7574
75 friend _LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void*, const void*);
76
7677public:
7778 // exception_ptr is basically a COW string so it is trivially relocatable.
7879 using __trivially_relocatable _LIBCPP_NODEBUG = exception_ptr;
......@@ -112,8 +113,10 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _
112113 std::swap(__x.__ptr_, __y.__ptr_);
113114}
114115
116#ifndef _LIBCPP_ABI_MICROSOFT
117
115118# if _LIBCPP_HAS_EXCEPTIONS
116# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
119# if _LIBCPP_HAS_RTTI && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
117120template <class _Ep>
118121_LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep& __e) _NOEXCEPT {
119122 using _Ep2 = __decay_t<_Ep>;
......@@ -136,7 +139,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_explicit(_Ep& __e) _NOE
136139 return current_exception();
137140 }
138141}
139# endif
142# endif // _LIBCPP_HAS_RTTI && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
140143
141144template <class _Ep>
142145_LIBCPP_HIDE_FROM_ABI exception_ptr __make_exception_ptr_via_throw(_Ep& __e) _NOEXCEPT {
......@@ -164,7 +167,7 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
164167 return std::__make_exception_ptr_via_throw(__e);
165168 }
166169
167# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && !defined(_LIBCPP_CXX03_LANG)
170# if _LIBCPP_HAS_RTTI && _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && !defined(_LIBCPP_CXX03_LANG)
168171 return std::__make_exception_ptr_explicit(__e);
169172# else
170173 return std::__make_exception_ptr_via_throw(__e);
......@@ -177,36 +180,9 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT {
177180}
178181# endif // _LIBCPP_HAS_EXCEPTIONS
179182
180#else // _LIBCPP_ABI_MICROSOFT
181
182class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
183 _LIBCPP_DIAGNOSTIC_PUSH
184 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
185 void* __ptr1_;
186 void* __ptr2_;
187 _LIBCPP_DIAGNOSTIC_POP
188
189public:
190 exception_ptr() _NOEXCEPT;
191 exception_ptr(nullptr_t) _NOEXCEPT;
192 exception_ptr(const exception_ptr& __other) _NOEXCEPT;
193 exception_ptr& operator=(const exception_ptr& __other) _NOEXCEPT;
194 exception_ptr& operator=(nullptr_t) _NOEXCEPT;
195 ~exception_ptr() _NOEXCEPT;
196 explicit operator bool() const _NOEXCEPT;
197};
198
199_LIBCPP_EXPORTED_FROM_ABI bool operator==(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT;
200
201inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {
202 return !(__x == __y);
203}
204
205_LIBCPP_EXPORTED_FROM_ABI void swap(exception_ptr&, exception_ptr&) _NOEXCEPT;
183#else // defined(_LIBCPP_ABI_MICROSOFT)
206184
207185_LIBCPP_EXPORTED_FROM_ABI exception_ptr __copy_exception_ptr(void* __except, const void* __ptr);
208_LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
209[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
210186
211187// This is a built-in template function which automagically extracts the required
212188// information.
......@@ -218,7 +194,9 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
218194 return __copy_exception_ptr(std::addressof(__e), __GetExceptionInfo(__e));
219195}
220196
221#endif // _LIBCPP_ABI_MICROSOFT
197#endif // defined(_LIBCPP_ABI_MICROSOFT)
198
199_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
222200_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
223201
224202_LIBCPP_POP_MACROS
lib/libcxx/include/__exception/nested_exception.h+6-6
......@@ -14,7 +14,6 @@
1414#include <__memory/addressof.h>
1515#include <__type_traits/decay.h>
1616#include <__type_traits/enable_if.h>
17#include <__type_traits/integral_constant.h>
1817#include <__type_traits/is_base_of.h>
1918#include <__type_traits/is_class.h>
2019#include <__type_traits/is_constructible.h>
......@@ -28,6 +27,7 @@
2827#endif
2928
3029_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
30_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3131
3232class _LIBCPP_EXPORTED_FROM_ABI nested_exception {
3333 exception_ptr __ptr_;
......@@ -81,20 +81,20 @@ template <class _Tp>
8181}
8282
8383template <class _From, class _To>
84struct __can_dynamic_cast
85 : _BoolConstant< is_polymorphic<_From>::value &&
86 (!is_base_of<_To, _From>::value || is_convertible<const _From*, const _To*>::value)> {};
84inline const bool __can_dynamic_cast_v =
85 is_polymorphic<_From>::value && (!is_base_of<_To, _From>::value || is_convertible<const _From*, const _To*>::value);
8786
88template <class _Ep, __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>
87template <class _Ep, __enable_if_t<__can_dynamic_cast_v<_Ep, nested_exception>, int> = 0>
8988inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep& __e) {
9089 const nested_exception* __nep = dynamic_cast<const nested_exception*>(std::addressof(__e));
9190 if (__nep)
9291 __nep->rethrow_nested();
9392}
9493
95template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>
94template <class _Ep, __enable_if_t<!__can_dynamic_cast_v<_Ep, nested_exception>, int> = 0>
9695inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {}
9796
97_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
9898_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
9999
100100#endif // _LIBCPP___EXCEPTION_NESTED_EXCEPTION_H
lib/libcxx/include/__exception/operations.h+4
......@@ -16,6 +16,8 @@
1616#endif
1717
1818_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
19_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
20
1921#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) || \
2022 defined(_LIBCPP_BUILDING_LIBRARY)
2123using unexpected_handler = void (*)();
......@@ -37,6 +39,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr;
3739
3840[[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI exception_ptr current_exception() _NOEXCEPT;
3941[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
42
43_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4044_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
4145
4246#endif // _LIBCPP___EXCEPTION_OPERATIONS_H
lib/libcxx/include/__exception/terminate.h+4
......@@ -16,7 +16,11 @@
1616#endif
1717
1818_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
19_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
20
1921[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void terminate() _NOEXCEPT;
22
23_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2024_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
2125
2226#endif // _LIBCPP___EXCEPTION_TERMINATE_H
lib/libcxx/include/__expected/bad_expected_access.h+2
......@@ -23,6 +23,7 @@ _LIBCPP_PUSH_MACROS
2323#if _LIBCPP_STD_VER >= 23
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2627
2728template <class _Err>
2829class bad_expected_access;
......@@ -66,6 +67,7 @@ private:
6667 _Err __unex_;
6768};
6869
70_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
6971_LIBCPP_END_NAMESPACE_STD
7072
7173#endif // _LIBCPP_STD_VER >= 23
lib/libcxx/include/__expected/expected.h+19-13
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___EXPECTED_EXPECTED_H
1111
1212#include <__assert>
13#include <__concepts/same_as.h>
1314#include <__config>
1415#include <__expected/bad_expected_access.h>
1516#include <__expected/unexpect.h>
......@@ -36,7 +37,6 @@
3637#include <__type_traits/is_trivially_destructible.h>
3738#include <__type_traits/is_trivially_relocatable.h>
3839#include <__type_traits/is_void.h>
39#include <__type_traits/lazy.h>
4040#include <__type_traits/negation.h>
4141#include <__type_traits/remove_cv.h>
4242#include <__type_traits/remove_cvref.h>
......@@ -446,6 +446,10 @@ private:
446446 _LIBCPP_NO_UNIQUE_ADDRESS __conditional_no_unique_address<__allow_reusing_expected_tail_padding, __repr> __repr_;
447447};
448448
449// Helper to handle comparisons that produce a value whose type is not bool,
450// but allows only implicit (and not explicit) conversions to bool.
451constexpr bool __into_bool(bool __b) noexcept { return __b; }
452
449453template <class _Tp, class _Err>
450454class expected : private __expected_base<_Tp, _Err> {
451455 static_assert(!is_reference_v<_Tp> && !is_function_v<_Tp> && !is_same_v<remove_cv_t<_Tp>, in_place_t> &&
......@@ -684,12 +688,11 @@ public:
684688private:
685689 template <class _OtherErrQual>
686690 static constexpr bool __can_assign_from_unexpected =
687 _And< is_constructible<_Err, _OtherErrQual>,
688 is_assignable<_Err&, _OtherErrQual>,
689 _Lazy<_Or,
690 is_nothrow_constructible<_Err, _OtherErrQual>,
691 is_nothrow_move_constructible<_Tp>,
692 is_nothrow_move_constructible<_Err>> >::value;
691 _And<is_constructible<_Err, _OtherErrQual>,
692 is_assignable<_Err&, _OtherErrQual>,
693 _Or<is_nothrow_constructible<_Err, _OtherErrQual>,
694 is_nothrow_move_constructible<_Tp>,
695 is_nothrow_move_constructible<_Err>>>::value;
693696
694697public:
695698 template <class _OtherErr>
......@@ -1161,15 +1164,18 @@ public:
11611164 }
11621165 }
11631166
1164 template <class _T2>
1165 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected& __x, const _T2& __v)
1167 // The unusual signature avoids constraint recursion via ADL through
1168 // std::expected, see https://llvm.org/PR160431. Note that this only
1169 // triggers with compilers that implement https://wg21.link/CWG2369.
1170 template <class _T2, same_as<_Tp> _Tp2>
1171 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const expected<_Tp2, _Err>& __x, const _T2& __v)
11661172# if _LIBCPP_STD_VER >= 26
11671173 requires(!__is_std_expected<_T2>::value) && requires {
11681174 { *__x == __v } -> __core_convertible_to<bool>;
11691175 }
11701176# endif
11711177 {
1172 return __x.__has_val() && static_cast<bool>(__x.__val() == __v);
1178 return __x.__has_val() && std::__into_bool(__x.__val() == __v);
11731179 }
11741180
11751181 template <class _E2>
......@@ -1180,7 +1186,7 @@ public:
11801186 }
11811187# endif
11821188 {
1183 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __e.error());
1189 return !__x.__has_val() && std::__into_bool(__x.__unex() == __e.error());
11841190 }
11851191};
11861192
......@@ -1882,7 +1888,7 @@ public:
18821888 if (__x.__has_val() != __y.__has_val()) {
18831889 return false;
18841890 } else {
1885 return __x.__has_val() || static_cast<bool>(__x.__unex() == __y.__unex());
1891 return __x.__has_val() || std::__into_bool(__x.__unex() == __y.__unex());
18861892 }
18871893 }
18881894
......@@ -1894,7 +1900,7 @@ public:
18941900 }
18951901# endif
18961902 {
1897 return !__x.__has_val() && static_cast<bool>(__x.__unex() == __y.error());
1903 return !__x.__has_val() && std::__into_bool(__x.__unex() == __y.error());
18981904 }
18991905};
19001906
lib/libcxx/include/__filesystem/directory_entry.h+2
......@@ -39,6 +39,7 @@ _LIBCPP_PUSH_MACROS
3939#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
4040
4141_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
42_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4243
4344class directory_entry {
4445 typedef filesystem::path _Path;
......@@ -465,6 +466,7 @@ private:
465466 directory_entry __elem_;
466467};
467468
469_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
468470_LIBCPP_END_NAMESPACE_FILESYSTEM
469471
470472#endif // _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
lib/libcxx/include/__filesystem/directory_iterator.h+2
......@@ -33,6 +33,7 @@ _LIBCPP_PUSH_MACROS
3333#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3434
3535_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
36_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3637
3738class _LIBCPP_HIDDEN __dir_stream;
3839class directory_iterator {
......@@ -129,6 +130,7 @@ operator!=(const directory_iterator& __lhs, const directory_iterator& __rhs) noe
129130 return directory_iterator();
130131}
131132
133_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
132134_LIBCPP_END_NAMESPACE_FILESYSTEM
133135
134136# if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__filesystem/filesystem_error.h+2
......@@ -26,6 +26,7 @@
2626#if _LIBCPP_STD_VER >= 17
2727
2828_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
29_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2930
3031class _LIBCPP_EXPORTED_FROM_ABI filesystem_error : public system_error {
3132public:
......@@ -80,6 +81,7 @@ template <class... _Args>
8081}
8182# endif
8283
84_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
8385_LIBCPP_END_NAMESPACE_FILESYSTEM
8486
8587#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__filesystem/operations.h+2
......@@ -31,6 +31,7 @@
3131
3232_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3333
34_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3435_LIBCPP_EXPORTED_FROM_ABI path __absolute(const path&, error_code* __ec = nullptr);
3536_LIBCPP_EXPORTED_FROM_ABI path __canonical(const path&, error_code* __ec = nullptr);
3637_LIBCPP_EXPORTED_FROM_ABI bool
......@@ -67,6 +68,7 @@ _LIBCPP_EXPORTED_FROM_ABI path __temp_directory_path(error_code* __ec = nullptr)
6768_LIBCPP_EXPORTED_FROM_ABI bool __fs_is_empty(const path& __p, error_code* __ec = nullptr);
6869_LIBCPP_EXPORTED_FROM_ABI void __permissions(const path&, perms, perm_options, error_code* = nullptr);
6970_LIBCPP_EXPORTED_FROM_ABI space_info __space(const path&, error_code* __ec = nullptr);
71_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7072
7173[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p) { return __absolute(__p); }
7274[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI path absolute(const path& __p, error_code& __ec) {
lib/libcxx/include/__filesystem/path.h+37-52
......@@ -23,6 +23,7 @@
2323#include <__type_traits/is_pointer.h>
2424#include <__type_traits/remove_const.h>
2525#include <__type_traits/remove_pointer.h>
26#include <__type_traits/void_t.h>
2627#include <__utility/move.h>
2728#include <string>
2829#include <string_view>
......@@ -41,6 +42,7 @@ _LIBCPP_PUSH_MACROS
4142#if _LIBCPP_STD_VER >= 17
4243
4344_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
45_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4446
4547template <class _Tp>
4648struct __can_convert_char {
......@@ -93,15 +95,12 @@ typedef string __u8_string;
9395
9496struct _NullSentinel {};
9597
96template <class _Tp>
97using _Void _LIBCPP_NODEBUG = void;
98
9998template <class _Tp, class = void>
10099struct __is_pathable_string : public false_type {};
101100
102101template <class _ECharT, class _Traits, class _Alloc>
103102struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>,
104 _Void<typename __can_convert_char<_ECharT>::__char_type> >
103 void_t<typename __can_convert_char<_ECharT>::__char_type> >
105104 : public __can_convert_char<_ECharT> {
106105 using _Str _LIBCPP_NODEBUG = basic_string<_ECharT, _Traits, _Alloc>;
107106
......@@ -114,7 +113,7 @@ struct __is_pathable_string< basic_string<_ECharT, _Traits, _Alloc>,
114113
115114template <class _ECharT, class _Traits>
116115struct __is_pathable_string< basic_string_view<_ECharT, _Traits>,
117 _Void<typename __can_convert_char<_ECharT>::__char_type> >
116 void_t<typename __can_convert_char<_ECharT>::__char_type> >
118117 : public __can_convert_char<_ECharT> {
119118 using _Str _LIBCPP_NODEBUG = basic_string_view<_ECharT, _Traits>;
120119
......@@ -154,7 +153,7 @@ template <class _Iter>
154153struct __is_pathable_iter<
155154 _Iter,
156155 true,
157 _Void<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> >
156 void_t<typename __can_convert_char< typename iterator_traits<_Iter>::value_type>::__char_type> >
158157 : __can_convert_char<typename iterator_traits<_Iter>::value_type> {
159158 using _ECharT _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::value_type;
160159
......@@ -261,15 +260,14 @@ struct _PathCVT {
261260
262261template <>
263262struct _PathCVT<__path_value> {
264 template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
265 _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
266 for (; __b != __e; ++__b)
267 __dest.push_back(*__b);
268 }
269
270 template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
263 template <class _Iter>
271264 _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
272 __dest.append(__b, __e);
265 if constexpr (__has_forward_iterator_category<_Iter>::value) {
266 __dest.append(__b, __e);
267 } else {
268 for (; __b != __e; ++__b)
269 __dest.push_back(*__b);
270 }
273271 }
274272
275273 template <class _Iter>
......@@ -296,13 +294,7 @@ struct _PathCVT<char> {
296294 __char_to_wide(__str, const_cast<__path_value*>(__dest.data()) + __pos, __size);
297295 }
298296
299 template <class _Iter, __enable_if_t<__has_exactly_input_iterator_category<_Iter>::value, int> = 0>
300 _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
301 basic_string<char> __tmp(__b, __e);
302 __append_string(__dest, __tmp);
303 }
304
305 template <class _Iter, __enable_if_t<__has_forward_iterator_category<_Iter>::value, int> = 0>
297 template <class _Iter>
306298 _LIBCPP_HIDE_FROM_ABI static void __append_range(__path_string& __dest, _Iter __b, _Iter __e) {
307299 basic_string<char> __tmp(__b, __e);
308300 __append_string(__dest, __tmp);
......@@ -449,7 +441,7 @@ public:
449441 return *this;
450442 }
451443
452 _LIBCPP_HIDE_FROM_ABI path& assign(string_type&& __s) noexcept {
444 _LIBCPP_HIDE_FROM_ABI path& assign(string_type&& __s) noexcept _LIBCPP_LIFETIMEBOUND {
453445 __pn_ = std::move(__s);
454446 return *this;
455447 }
......@@ -460,14 +452,14 @@ public:
460452 }
461453
462454 template <class _Source>
463 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> assign(const _Source& __src) {
455 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> assign(const _Source& __src) _LIBCPP_LIFETIMEBOUND {
464456 __pn_.clear();
465457 _SourceCVT<_Source>::__append_source(__pn_, __src);
466458 return *this;
467459 }
468460
469461 template <class _InputIt>
470 _LIBCPP_HIDE_FROM_ABI path& assign(_InputIt __first, _InputIt __last) {
462 _LIBCPP_HIDE_FROM_ABI path& assign(_InputIt __first, _InputIt __last) _LIBCPP_LIFETIMEBOUND {
471463 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
472464 __pn_.clear();
473465 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
......@@ -501,12 +493,12 @@ public:
501493 }
502494
503495 template <class _Source>
504 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
496 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) _LIBCPP_LIFETIMEBOUND {
505497 return operator/=(path(__src));
506498 }
507499
508500 template <class _InputIt>
509 _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) {
501 _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) _LIBCPP_LIFETIMEBOUND {
510502 return operator/=(path(__first, __last));
511503 }
512504# else
......@@ -530,7 +522,7 @@ public:
530522 }
531523
532524 template <class _Source>
533 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) {
525 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> append(const _Source& __src) _LIBCPP_LIFETIMEBOUND {
534526 using _Traits = __is_pathable<_Source>;
535527 using _CVT = _PathCVT<_SourceChar<_Source> >;
536528 bool __source_is_absolute = filesystem::__is_separator(_Traits::__first_or_null(__src));
......@@ -543,7 +535,7 @@ public:
543535 }
544536
545537 template <class _InputIt>
546 _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) {
538 _LIBCPP_HIDE_FROM_ABI path& append(_InputIt __first, _InputIt __last) _LIBCPP_LIFETIMEBOUND {
547539 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
548540 static_assert(__can_convert_char<_ItVal>::value, "Must convertible");
549541 using _CVT = _PathCVT<_ItVal>;
......@@ -594,13 +586,13 @@ public:
594586 }
595587
596588 template <class _Source>
597 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> concat(const _Source& __x) {
589 _LIBCPP_HIDE_FROM_ABI _EnableIfPathable<_Source> concat(const _Source& __x) _LIBCPP_LIFETIMEBOUND {
598590 _SourceCVT<_Source>::__append_source(__pn_, __x);
599591 return *this;
600592 }
601593
602594 template <class _InputIt>
603 _LIBCPP_HIDE_FROM_ABI path& concat(_InputIt __first, _InputIt __last) {
595 _LIBCPP_HIDE_FROM_ABI path& concat(_InputIt __first, _InputIt __last) _LIBCPP_LIFETIMEBOUND {
604596 typedef typename iterator_traits<_InputIt>::value_type _ItVal;
605597 _PathCVT<_ItVal>::__append_range(__pn_, __first, __last);
606598 return *this;
......@@ -609,26 +601,26 @@ public:
609601 // modifiers
610602 _LIBCPP_HIDE_FROM_ABI void clear() noexcept { __pn_.clear(); }
611603
612 _LIBCPP_HIDE_FROM_ABI path& make_preferred() {
604 _LIBCPP_HIDE_FROM_ABI path& make_preferred() _LIBCPP_LIFETIMEBOUND {
613605# if defined(_LIBCPP_WIN32API)
614606 std::replace(__pn_.begin(), __pn_.end(), L'/', L'\\');
615607# endif
616608 return *this;
617609 }
618610
619 _LIBCPP_HIDE_FROM_ABI path& remove_filename() {
611 _LIBCPP_HIDE_FROM_ABI path& remove_filename() _LIBCPP_LIFETIMEBOUND {
620612 auto __fname = __filename();
621613 if (!__fname.empty())
622614 __pn_.erase(__fname.data() - __pn_.data());
623615 return *this;
624616 }
625617
626 _LIBCPP_HIDE_FROM_ABI path& replace_filename(const path& __replacement) {
618 _LIBCPP_HIDE_FROM_ABI path& replace_filename(const path& __replacement) _LIBCPP_LIFETIMEBOUND {
627619 remove_filename();
628620 return (*this /= __replacement);
629621 }
630622
631 path& replace_extension(const path& __replacement = path());
623 path& replace_extension(const path& __replacement = path()) _LIBCPP_LIFETIMEBOUND;
632624
633625 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const path& __lhs, const path& __rhs) noexcept {
634626 return __lhs.__compare(__rhs.__pn_) == 0;
......@@ -667,9 +659,11 @@ public:
667659 _LIBCPP_HIDE_FROM_ABI void __reserve(size_t __s) { __pn_.reserve(__s); }
668660
669661 // native format observers
670 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const string_type& native() const noexcept { return __pn_; }
662 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const string_type& native() const noexcept _LIBCPP_LIFETIMEBOUND { return __pn_; }
671663
672 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const value_type* c_str() const noexcept { return __pn_.c_str(); }
664 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const value_type* c_str() const noexcept _LIBCPP_LIFETIMEBOUND {
665 return __pn_.c_str();
666 }
673667
674668 _LIBCPP_HIDE_FROM_ABI operator string_type() const { return __pn_; }
675669
......@@ -874,23 +868,13 @@ public:
874868 [[nodiscard]] iterator end() const;
875869
876870# if _LIBCPP_HAS_LOCALIZATION
877 template <
878 class _CharT,
879 class _Traits,
880 __enable_if_t<is_same<_CharT, value_type>::value && is_same<_Traits, char_traits<value_type> >::value, int> = 0>
881 _LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
882 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
883 __os << std::__quoted(__p.native());
884 return __os;
885 }
886
887 template <
888 class _CharT,
889 class _Traits,
890 __enable_if_t<!is_same<_CharT, value_type>::value || !is_same<_Traits, char_traits<value_type> >::value, int> = 0>
871 template <class _CharT, class _Traits>
891872 _LIBCPP_HIDE_FROM_ABI friend basic_ostream<_CharT, _Traits>&
892873 operator<<(basic_ostream<_CharT, _Traits>& __os, const path& __p) {
893 __os << std::__quoted(__p.string<_CharT, _Traits>());
874 if constexpr (is_same<_CharT, value_type>::value && is_same<_Traits, char_traits<value_type> >::value)
875 __os << std::quoted(__p.native());
876 else
877 __os << std::quoted(__p.string<_CharT, _Traits>());
894878 return __os;
895879 }
896880
......@@ -898,7 +882,7 @@ public:
898882 _LIBCPP_HIDE_FROM_ABI friend basic_istream<_CharT, _Traits>&
899883 operator>>(basic_istream<_CharT, _Traits>& __is, path& __p) {
900884 basic_string<_CharT, _Traits> __tmp;
901 __is >> std::__quoted(__tmp);
885 __is >> std::quoted(__tmp);
902886 __p = __tmp;
903887 return __is;
904888 }
......@@ -916,6 +900,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(path& __lhs, path& __rhs) noexcept { __lh
916900
917901[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI size_t hash_value(const path& __p) noexcept;
918902
903_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
919904_LIBCPP_END_NAMESPACE_FILESYSTEM
920905
921906_LIBCPP_BEGIN_NAMESPACE_STD
lib/libcxx/include/__filesystem/path_iterator.h+2
......@@ -22,6 +22,7 @@
2222#if _LIBCPP_STD_VER >= 17
2323
2424_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
2627class _LIBCPP_EXPORTED_FROM_ABI path::iterator {
2728public:
......@@ -103,6 +104,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const path::iterator& __lhs, const
103104 return !(__lhs == __rhs);
104105}
105106
107_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
106108_LIBCPP_END_NAMESPACE_FILESYSTEM
107109
108110#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__filesystem/recursive_directory_iterator.h+2
......@@ -32,6 +32,7 @@ _LIBCPP_PUSH_MACROS
3232#if _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_FILESYSTEM
3333
3434_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
35_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3536
3637class recursive_directory_iterator {
3738public:
......@@ -139,6 +140,7 @@ begin(recursive_directory_iterator __iter) noexcept {
139140 return recursive_directory_iterator();
140141}
141142
143_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
142144_LIBCPP_END_NAMESPACE_FILESYSTEM
143145
144146# if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__flat_map/flat_multimap.h-9
......@@ -934,15 +934,6 @@ private:
934934
935935 containers __containers_;
936936 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
937
938 struct __key_equiv {
939 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {}
940 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
941 operator()(const_reference __x, const_reference __y) const {
942 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
943 }
944 key_compare __comp_;
945 };
946937};
947938
948939template <class _KeyContainer, class _MappedContainer, class _Compare = less<typename _KeyContainer::value_type>>
lib/libcxx/include/__flat_set/flat_multiset.h-9
......@@ -745,15 +745,6 @@ private:
745745
746746 _KeyContainer __keys_;
747747 _LIBCPP_NO_UNIQUE_ADDRESS key_compare __compare_;
748
749 struct __key_equiv {
750 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __key_equiv(key_compare __c) : __comp_(__c) {}
751 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
752 operator()(const_reference __x, const_reference __y) const {
753 return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
754 }
755 key_compare __comp_;
756 };
757748};
758749
759750template <class _KeyContainer, class _Compare = less<typename _KeyContainer::value_type>>
lib/libcxx/include/__format/container_adaptor.h+4-4
......@@ -24,10 +24,10 @@
2424#include <__type_traits/is_const.h>
2525#include <__type_traits/maybe_const.h>
2626
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2927#if _LIBCPP_STD_VER >= 23
3028
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3131// [container.adaptors.format] only specifies the library should provide the
3232// formatter specializations, not which header should provide them.
3333// Since <format> includes a lot of headers, add these headers here instead of
......@@ -66,8 +66,8 @@ template <class _CharT, class _Tp, formattable<_CharT> _Container>
6666struct formatter<stack<_Tp, _Container>, _CharT>
6767 : public __formatter_container_adaptor<stack<_Tp, _Container>, _CharT> {};
6868
69#endif // _LIBCPP_STD_VER >= 23
70
7169_LIBCPP_END_NAMESPACE_STD
7270
71#endif // _LIBCPP_STD_VER >= 23
72
7373#endif // _LIBCPP___FORMAT_CONTAINER_ADAPTOR_H
lib/libcxx/include/__format/enable_insertable.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 20
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323namespace __format {
2424
2525/// Opt-in to enable \ref __insertable for a \a _Container.
......@@ -28,8 +28,8 @@ inline constexpr bool __enable_insertable = false;
2828
2929} // namespace __format
3030
31#endif // _LIBCPP_STD_VER >= 20
32
3331_LIBCPP_END_NAMESPACE_STD
3432
33#endif // _LIBCPP_STD_VER >= 20
34
3535#endif // _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
lib/libcxx/include/__format/escaped_output_table.h+7-6
......@@ -61,19 +61,20 @@
6161#ifndef _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
6262#define _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
6363
64#include <__algorithm/ranges_upper_bound.h>
64#include <__algorithm/upper_bound.h>
6565#include <__config>
6666#include <__cstddef/ptrdiff_t.h>
67#include <__iterator/access.h>
6768#include <cstdint>
6869
6970#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7071# pragma GCC system_header
7172#endif
7273
73_LIBCPP_BEGIN_NAMESPACE_STD
74
7574#if _LIBCPP_STD_VER >= 23
7675
76_LIBCPP_BEGIN_NAMESPACE_STD
77
7778namespace __escaped_output_table {
7879// clang-format off
7980
......@@ -868,7 +869,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[735] = {
868869 if (__code_point >= 0x000323b0)
869870 return true;
870871
871 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 14) | 0x3fffu) - __entries;
872 ptrdiff_t __i = std::upper_bound(std::begin(__entries), std::end(__entries), (__code_point << 14) | 0x3fffu) - __entries;
872873 if (__i == 0)
873874 return false;
874875
......@@ -880,8 +881,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[735] = {
880881// clang-format on
881882} // namespace __escaped_output_table
882883
883#endif // _LIBCPP_STD_VER >= 23
884
885884_LIBCPP_END_NAMESPACE_STD
886885
886#endif // _LIBCPP_STD_VER >= 23
887
887888#endif // _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
lib/libcxx/include/__format/fmt_pair_like.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 23
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727// [tuple.like] defines a tuple-like exposition only concept. This concept is not related to that. Therefore it uses a
2828// different name for the concept.
2929//
......@@ -35,8 +35,8 @@ template <class _Tp>
3535concept __fmt_pair_like =
3636 __is_specialization_v<_Tp, pair> || (__is_specialization_v<_Tp, tuple> && tuple_size_v<_Tp> == 2);
3737
38#endif // _LIBCPP_STD_VER >= 23
39
4038_LIBCPP_END_NAMESPACE_STD
4139
40#endif // _LIBCPP_STD_VER >= 23
41
4242#endif // _LIBCPP___FORMAT_FMT_PAIR_LIKE_H
lib/libcxx/include/__format/format_context.h+4-7
......@@ -40,10 +40,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4040
4141#if _LIBCPP_STD_VER >= 20
4242
43template <class _OutIt, class _CharT>
44 requires output_iterator<_OutIt, const _CharT&>
45class basic_format_context;
46
4743# if _LIBCPP_HAS_LOCALIZATION
4844/**
4945 * Helper to create a basic_format_context.
......@@ -71,15 +67,16 @@ using wformat_context = basic_format_context< back_insert_iterator<__format::__o
7167# endif
7268
7369template <class _OutIt, class _CharT>
74 requires output_iterator<_OutIt, const _CharT&>
75class _LIBCPP_PREFERRED_NAME(format_context)
76 _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context)) basic_format_context {
70class _LIBCPP_PREFERRED_NAME(format_context) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
71 basic_format_context {
7772public:
7873 using iterator = _OutIt;
7974 using char_type = _CharT;
8075 template <class _Tp>
8176 using formatter_type = formatter<_Tp, _CharT>;
8277
78 static_assert(output_iterator<_OutIt, const _CharT&>, "[format.context]/p3 requires OutIt to be an output_iterator");
79
8380 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context> arg(size_t __id) const noexcept {
8481 return __args_.get(__id);
8582 }
lib/libcxx/include/__format/format_error.h+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324#if _LIBCPP_STD_VER >= 20
2425
......@@ -45,6 +46,7 @@ _LIBCPP_DIAGNOSTIC_POP
4546
4647#endif // _LIBCPP_STD_VER >= 20
4748
49_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4850_LIBCPP_END_NAMESPACE_STD
4951
5052#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
lib/libcxx/include/__format/format_functions.h+15-11
......@@ -11,7 +11,7 @@
1111#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS
1212
1313#include <__algorithm/clamp.h>
14#include <__algorithm/ranges_find_first_of.h>
14#include <__algorithm/find_first_of.h>
1515#include <__chrono/statically_widen.h>
1616#include <__concepts/convertible_to.h>
1717#include <__concepts/same_as.h>
......@@ -26,7 +26,7 @@
2626#include <__format/format_string.h>
2727#include <__format/format_to_n_result.h>
2828#include <__format/formatter.h>
29#include <__format/formatter_bool.h>
29#include <__format/formatter_bool_impl.h>
3030#include <__format/formatter_char.h>
3131#include <__format/formatter_floating_point.h>
3232#include <__format/formatter_integer.h>
......@@ -342,7 +342,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator __vformat_to(_ParseCtx&&
342342
343343# if _LIBCPP_STD_VER >= 26
344344template <class _CharT>
345struct __runtime_format_string {
345struct __dynamic_format_string {
346346private:
347347 basic_string_view<_CharT> __str_;
348348
......@@ -350,15 +350,15 @@ private:
350350 friend struct basic_format_string;
351351
352352public:
353 _LIBCPP_HIDE_FROM_ABI __runtime_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {}
353 _LIBCPP_HIDE_FROM_ABI __dynamic_format_string(basic_string_view<_CharT> __s) noexcept : __str_(__s) {}
354354
355 __runtime_format_string(const __runtime_format_string&) = delete;
356 __runtime_format_string& operator=(const __runtime_format_string&) = delete;
355 __dynamic_format_string(const __dynamic_format_string&) = delete;
356 __dynamic_format_string& operator=(const __dynamic_format_string&) = delete;
357357};
358358
359_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<char> runtime_format(string_view __fmt) noexcept { return __fmt; }
359_LIBCPP_HIDE_FROM_ABI inline __dynamic_format_string<char> dynamic_format(string_view __fmt) noexcept { return __fmt; }
360360# if _LIBCPP_HAS_WIDE_CHARACTERS
361_LIBCPP_HIDE_FROM_ABI inline __runtime_format_string<wchar_t> runtime_format(wstring_view __fmt) noexcept {
361_LIBCPP_HIDE_FROM_ABI inline __dynamic_format_string<wchar_t> dynamic_format(wstring_view __fmt) noexcept {
362362 return __fmt;
363363}
364364# endif
......@@ -375,7 +375,7 @@ struct basic_format_string {
375375
376376 _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<_CharT> get() const noexcept { return __str_; }
377377# if _LIBCPP_STD_VER >= 26
378 _LIBCPP_HIDE_FROM_ABI basic_format_string(__runtime_format_string<_CharT> __s) noexcept : __str_(__s.__str_) {}
378 _LIBCPP_HIDE_FROM_ABI basic_format_string(__dynamic_format_string<_CharT> __s) noexcept : __str_(__s.__str_) {}
379379# endif
380380
381381private:
......@@ -459,8 +459,12 @@ template <class _CharT>
459459 basic_string_view<_CharT> __fmt,
460460 basic_format_args<basic_format_context<back_insert_iterator<__format::__output_buffer<_CharT>>, _CharT>> __args) {
461461 // 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(); }();
462 if (bool __is_identity =
463 [&] [[__gnu__::__pure__]] // Make sure the compiler knows this call can be eliminated
464 {
465 char __vals[] = {'{', '}'};
466 return std::find_first_of(__fmt.begin(), __fmt.end(), std::begin(__vals), std::end(__vals)) == __fmt.end();
467 }();
464468 __builtin_constant_p(__is_identity) && __is_identity)
465469 return basic_string<_CharT>{__fmt};
466470
lib/libcxx/include/__format/formatter_bool.h+5-30
......@@ -10,19 +10,10 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H
1111#define _LIBCPP___FORMAT_FORMATTER_BOOL_H
1212
13#include <__algorithm/copy.h>
14#include <__assert>
1513#include <__config>
1614#include <__format/concepts.h>
17#include <__format/format_parse_context.h>
1815#include <__format/formatter.h>
19#include <__format/formatter_integral.h>
2016#include <__format/parser_std_format_spec.h>
21#include <__utility/unreachable.h>
22
23#if _LIBCPP_HAS_LOCALIZATION
24# include <__locale>
25#endif
2617
2718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2819# pragma GCC system_header
......@@ -32,9 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3223
3324#if _LIBCPP_STD_VER >= 20
3425
26template <__fmt_char_type _CharT, class _FormatContext>
27_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
28__formatter_bool_format(bool __value, __format_spec::__parser<_CharT>, _FormatContext&);
29
3530template <__fmt_char_type _CharT>
3631struct formatter<bool, _CharT> {
37public:
3832 template <class _ParseContext>
3933 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
4034 typename _ParseContext::iterator __result = __parser_.__parse(__ctx, __format_spec::__fields_integral);
......@@ -44,26 +38,7 @@ public:
4438
4539 template <class _FormatContext>
4640 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(bool __value, _FormatContext& __ctx) const {
47 switch (__parser_.__type_) {
48 case __format_spec::__type::__default:
49 case __format_spec::__type::__string:
50 return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
51
52 case __format_spec::__type::__binary_lower_case:
53 case __format_spec::__type::__binary_upper_case:
54 case __format_spec::__type::__octal:
55 case __format_spec::__type::__decimal:
56 case __format_spec::__type::__hexadecimal_lower_case:
57 case __format_spec::__type::__hexadecimal_upper_case:
58 // Promotes bool to an integral type. This reduces the number of
59 // instantiations of __format_integer reducing code size.
60 return __formatter::__format_integer(
61 static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx));
62
63 default:
64 _LIBCPP_ASSERT_INTERNAL(false, "The parse function should have validated the type");
65 __libcpp_unreachable();
66 }
41 return std::__formatter_bool_format(__value, __parser_, __ctx);
6742 }
6843
6944 __format_spec::__parser<_CharT> __parser_;
lib/libcxx/include/__format/formatter_bool_impl.h created+60
......@@ -0,0 +1,60 @@
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___FORMAT_FORMATTER_BOOL_IMPL_H
11#define _LIBCPP___FORMAT_FORMATTER_BOOL_IMPL_H
12
13#include <__assert>
14#include <__config>
15#include <__format/concepts.h>
16#include <__format/formatter_bool.h>
17#include <__format/formatter_integral.h>
18#include <__format/parser_std_format_spec.h>
19#include <__utility/unreachable.h>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25#if _LIBCPP_STD_VER >= 20
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29// This function is separated from formatter<bool> to avoid pulling in a bunch of code from <format> that we aren't
30// required to provide in other headers where we need formatter<bool> itself to be complete.
31template <__fmt_char_type _CharT, class _FormatContext>
32_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
33__formatter_bool_format(bool __value, __format_spec::__parser<_CharT> __parser, _FormatContext& __ctx) {
34 switch (__parser.__type_) {
35 case __format_spec::__type::__default:
36 case __format_spec::__type::__string:
37 return __formatter::__format_bool(__value, __ctx, __parser.__get_parsed_std_specifications(__ctx));
38
39 case __format_spec::__type::__binary_lower_case:
40 case __format_spec::__type::__binary_upper_case:
41 case __format_spec::__type::__octal:
42 case __format_spec::__type::__decimal:
43 case __format_spec::__type::__hexadecimal_lower_case:
44 case __format_spec::__type::__hexadecimal_upper_case:
45 // Promotes bool to an integral type. This reduces the number of
46 // instantiations of __format_integer reducing code size.
47 return __formatter::__format_integer(
48 static_cast<unsigned>(__value), __ctx, __parser.__get_parsed_std_specifications(__ctx));
49
50 default:
51 _LIBCPP_ASSERT_INTERNAL(false, "The parse function should have validated the type");
52 __libcpp_unreachable();
53 }
54}
55
56_LIBCPP_END_NAMESPACE_STD
57
58#endif // _LIBCPP_STD_VER >= 20
59
60#endif // _LIBCPP___FORMAT_FORMATTER_BOOL_IMPL_H
lib/libcxx/include/__format/formatter_floating_point.h+4-4
......@@ -32,12 +32,12 @@
3232#include <__format/formatter_output.h>
3333#include <__format/parser_std_format_spec.h>
3434#include <__iterator/concepts.h>
35#include <__math/traits.h>
3536#include <__memory/allocator.h>
3637#include <__system_error/errc.h>
3738#include <__type_traits/conditional.h>
3839#include <__utility/move.h>
3940#include <__utility/unreachable.h>
40#include <cmath>
4141
4242#if _LIBCPP_HAS_LOCALIZATION
4343# include <__locale>
......@@ -637,10 +637,10 @@ _LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
637637template <floating_point _Tp, class _CharT, class _FormatContext>
638638_LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator
639639__format_floating_point(_Tp __value, _FormatContext& __ctx, __format_spec::__parsed_specifications<_CharT> __specs) {
640 bool __negative = std::signbit(__value);
640 bool __negative = __math::signbit(__value);
641641
642 if (!std::isfinite(__value)) [[unlikely]]
643 return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, std::isnan(__value));
642 if (!__math::isfinite(__value)) [[unlikely]]
643 return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, __math::isnan(__value));
644644
645645 // Depending on the std-format-spec string the sign and the value
646646 // might not be outputted together:
lib/libcxx/include/__format/formatter_tuple.h+4-4
......@@ -31,10 +31,10 @@
3131# pragma GCC system_header
3232#endif
3333
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3634#if _LIBCPP_STD_VER >= 23
3735
36_LIBCPP_BEGIN_NAMESPACE_STD
37
3838template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>
3939struct __formatter_tuple {
4040 _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) noexcept {
......@@ -141,8 +141,8 @@ struct formatter<pair<_Args...>, _CharT> : public __formatter_tuple<_CharT, pair
141141template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
142142struct formatter<tuple<_Args...>, _CharT> : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
143143
144#endif // _LIBCPP_STD_VER >= 23
145
146144_LIBCPP_END_NAMESPACE_STD
147145
146#endif // _LIBCPP_STD_VER >= 23
147
148148#endif // _LIBCPP___FORMAT_FORMATTER_TUPLE_H
lib/libcxx/include/__format/range_default_formatter.h+5-4
......@@ -22,6 +22,7 @@
2222#include <__format/formatter.h>
2323#include <__format/range_format.h>
2424#include <__format/range_formatter.h>
25#include <__fwd/format.h>
2526#include <__iterator/back_insert_iterator.h>
2627#include <__ranges/concepts.h>
2728#include <__ranges/data.h>
......@@ -32,10 +33,10 @@
3233#include <__utility/pair.h>
3334#include <string_view>
3435
35_LIBCPP_BEGIN_NAMESPACE_STD
36
3736#if _LIBCPP_STD_VER >= 23
3837
38_LIBCPP_BEGIN_NAMESPACE_STD
39
3940template <class _Rp, class _CharT>
4041concept __const_formattable_range =
4142 ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;
......@@ -168,8 +169,8 @@ template <ranges::input_range _Rp, class _CharT>
168169 requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
169170struct formatter<_Rp, _CharT> : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
170171
171#endif // _LIBCPP_STD_VER >= 23
172
173172_LIBCPP_END_NAMESPACE_STD
174173
174#endif // _LIBCPP_STD_VER >= 23
175
175176#endif // _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
lib/libcxx/include/__format/range_format.h+4-18
......@@ -17,27 +17,13 @@
1717#include <__concepts/same_as.h>
1818#include <__config>
1919#include <__format/fmt_pair_like.h>
20#include <__fwd/format.h>
2021#include <__ranges/concepts.h>
2122#include <__type_traits/remove_cvref.h>
2223
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2524#if _LIBCPP_STD_VER >= 23
2625
27_LIBCPP_DIAGNOSTIC_PUSH
28_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
29_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow")
30// This shadows map, set, and string.
31enum class range_format { disabled, map, set, sequence, string, debug_string };
32_LIBCPP_DIAGNOSTIC_POP
33
34template <class _Rp>
35constexpr range_format format_kind = [] {
36 // [format.range.fmtkind]/1
37 // A program that instantiates the primary template of format_kind is ill-formed.
38 static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type");
39 return range_format::disabled;
40}();
26_LIBCPP_BEGIN_NAMESPACE_STD
4127
4228template <ranges::input_range _Rp>
4329 requires same_as<_Rp, remove_cvref_t<_Rp>>
......@@ -64,8 +50,8 @@ inline constexpr range_format format_kind<_Rp> = [] {
6450 return range_format::sequence;
6551}();
6652
67#endif // _LIBCPP_STD_VER >= 23
68
6953_LIBCPP_END_NAMESPACE_STD
7054
55#endif // _LIBCPP_STD_VER >= 23
56
7157#endif
lib/libcxx/include/__format/range_formatter.h+6-4
......@@ -34,10 +34,10 @@
3434#include <__type_traits/remove_cvref.h>
3535#include <string_view>
3636
37_LIBCPP_BEGIN_NAMESPACE_STD
38
3937#if _LIBCPP_STD_VER >= 23
4038
39_LIBCPP_BEGIN_NAMESPACE_STD
40
4141template <class _Tp, class _CharT = char>
4242 requires same_as<remove_cvref_t<_Tp>, _Tp> && formattable<_Tp, _CharT>
4343struct range_formatter {
......@@ -215,6 +215,8 @@ private:
215215 switch (*__begin) {
216216 case _CharT('m'):
217217 if constexpr (__fmt_pair_like<_Tp>) {
218 __underlying_.set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
219 __underlying_.set_brackets({}, {});
218220 set_brackets(_LIBCPP_STATICALLY_WIDEN(_CharT, "{"), _LIBCPP_STATICALLY_WIDEN(_CharT, "}"));
219221 set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ", "));
220222 ++__begin;
......@@ -258,8 +260,8 @@ private:
258260 basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "]");
259261};
260262
261#endif // _LIBCPP_STD_VER >= 23
262
263263_LIBCPP_END_NAMESPACE_STD
264264
265#endif // _LIBCPP_STD_VER >= 23
266
265267#endif // _LIBCPP___FORMAT_RANGE_FORMATTER_H
lib/libcxx/include/__format/unicode.h+1-1
......@@ -101,7 +101,7 @@ inline constexpr __consume_result __consume_result_error{__replacement_character
101101 return __unicode::__is_code_point(__value) && !__unicode::__is_surrogate(__value);
102102}
103103
104template <contiguous_iterator _Iterator>
104template <class _Iterator>
105105 requires same_as<iter_value_t<_Iterator>, char>
106106_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(_Iterator __char, int __count) {
107107 do {
lib/libcxx/include/__functional/binary_negate.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Predicate>
2525class _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
2626 : public __binary_function<typename _Predicate::first_argument_type,
......@@ -44,8 +44,8 @@ not2(const _Predicate& __pred) {
4444 return binary_negate<_Predicate>(__pred);
4545}
4646
47#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
48
4947_LIBCPP_END_NAMESPACE_STD
5048
49#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
50
5151#endif // _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
lib/libcxx/include/__functional/bind_front.h+49
......@@ -17,6 +17,8 @@
1717#include <__type_traits/decay.h>
1818#include <__type_traits/enable_if.h>
1919#include <__type_traits/is_constructible.h>
20#include <__type_traits/is_member_pointer.h>
21#include <__type_traits/is_pointer.h>
2022#include <__utility/forward.h>
2123
2224#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -49,6 +51,53 @@ template <class _Fn, class... _Args>
4951
5052#endif // _LIBCPP_STD_VER >= 20
5153
54#if _LIBCPP_STD_VER >= 26
55
56template <auto _Fn, class _Indices, class... _BoundArgs>
57struct __nttp_bind_front_t;
58
59template <auto _Fn, size_t... _Indices, class... _BoundArgs>
60struct __nttp_bind_front_t<_Fn, index_sequence<_Indices...>, _BoundArgs...> {
61 tuple<_BoundArgs...> __bound_args_;
62
63 template <class _Self, class... _Args>
64 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(this _Self&& __self, _Args&&... __args) noexcept(noexcept(std::invoke(
65 _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...)))
66 -> decltype(std::invoke(
67 _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...)) {
68 return std::invoke(
69 _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...);
70 }
71};
72
73template <auto _Fn>
74struct __nttp_bind_without_bound_args_t {
75 template <class... _Args>
76 _LIBCPP_HIDE_FROM_ABI static constexpr auto
77 operator()(_Args&&... __args) noexcept(noexcept(std::invoke(_Fn, std::forward<_Args>(__args)...)))
78 -> decltype(std::invoke(_Fn, std::forward<_Args>(__args)...)) {
79 return std::invoke(_Fn, std::forward<_Args>(__args)...);
80 }
81};
82
83template <auto _Fn, class... _Args>
84[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Args&&... __args) {
85 static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...),
86 "bind_front requires all decay_t<Args> to be constructible from respective Args");
87 static_assert((is_move_constructible_v<decay_t<_Args>> && ...),
88 "bind_front requires all decay_t<Args> to be move constructible");
89 if constexpr (using _Ty = decltype(_Fn); is_pointer_v<_Ty> || is_member_pointer_v<_Ty>)
90 static_assert(_Fn != nullptr, "bind_front: f cannot be equal to nullptr");
91
92 if constexpr (sizeof...(_Args) == 0)
93 return __nttp_bind_without_bound_args_t<_Fn>{};
94 else
95 return __nttp_bind_front_t<_Fn, index_sequence_for<_Args...>, decay_t<_Args>...>{
96 .__bound_args_{std::forward<_Args>(__args)...}};
97}
98
99#endif // _LIBCPP_STD_VER >= 26
100
52101_LIBCPP_END_NAMESPACE_STD
53102
54103#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H
lib/libcxx/include/__functional/binder1st.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Operation>
2525class _LIBCPP_DEPRECATED_IN_CXX11 binder1st
2626 : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
......@@ -47,8 +47,8 @@ bind1st(const _Operation& __op, const _Tp& __x) {
4747 return binder1st<_Operation>(__op, __x);
4848}
4949
50#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
51
5250_LIBCPP_END_NAMESPACE_STD
5351
52#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
53
5454#endif // _LIBCPP___FUNCTIONAL_BINDER1ST_H
lib/libcxx/include/__functional/binder2nd.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Operation>
2525class _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
2626 : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
......@@ -47,8 +47,8 @@ bind2nd(const _Operation& __op, const _Tp& __x) {
4747 return binder2nd<_Operation>(__op, __x);
4848}
4949
50#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
51
5250_LIBCPP_END_NAMESPACE_STD
5351
52#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
53
5454#endif // _LIBCPP___FUNCTIONAL_BINDER2ND_H
lib/libcxx/include/__functional/compose.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727struct __compose_op {
2828 template <class _Fn1, class _Fn2, class... _Args>
2929 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const noexcept(noexcept(
......@@ -46,8 +46,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) noexcep
4646 return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2));
4747}
4848
49#endif // _LIBCPP_STD_VER >= 20
50
5149_LIBCPP_END_NAMESPACE_STD
5250
51#endif // _LIBCPP_STD_VER >= 20
52
5353#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H
lib/libcxx/include/__functional/function.h+12-3
......@@ -17,6 +17,7 @@
1717#include <__functional/binary_function.h>
1818#include <__functional/unary_function.h>
1919#include <__memory/addressof.h>
20#include <__new/placement_new_delete.h>
2021#include <__type_traits/aligned_storage.h>
2122#include <__type_traits/decay.h>
2223#include <__type_traits/invoke.h>
......@@ -44,6 +45,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4445// bad_function_call
4546
4647_LIBCPP_DIAGNOSTIC_PUSH
48_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4749# if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
4850_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
4951# endif
......@@ -65,6 +67,7 @@ public:
6567 const char* what() const _NOEXCEPT override;
6668# endif
6769};
70_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
6871_LIBCPP_DIAGNOSTIC_POP
6972
7073[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() {
......@@ -128,6 +131,7 @@ namespace __function {
128131template <class _Fp>
129132class __base;
130133
134_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
131135template <class _Rp, class... _ArgTypes>
132136class __base<_Rp(_ArgTypes...)> {
133137public:
......@@ -146,6 +150,7 @@ public:
146150 virtual const std::type_info& target_type() const _NOEXCEPT = 0;
147151# endif // _LIBCPP_HAS_RTTI
148152};
153_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
149154
150155// __func implements __base for a given functor type.
151156
......@@ -527,9 +532,13 @@ public:
527532
528533# if _LIBCPP_HAS_BLOCKS_RUNTIME
529534
535_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
536
530537extern "C" void* _Block_copy(const void*);
531538extern "C" void _Block_release(const void*);
532539
540_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
541
533542template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
534543class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
535544 typedef _Rp1 (^__block_type)(_ArgTypes1...);
......@@ -540,7 +549,7 @@ public:
540549# if __has_feature(objc_arc)
541550 : __f_(__f)
542551# else
543 : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr))
552 : __f_(reinterpret_cast<__block_type>(__f ? __function::_Block_copy(__f) : nullptr))
544553# endif
545554 {
546555 }
......@@ -563,7 +572,7 @@ public:
563572 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
564573# if !__has_feature(objc_arc)
565574 if (__f_)
566 _Block_release(__f_);
575 __function::_Block_release(__f_);
567576# endif
568577 __f_ = 0;
569578 }
......@@ -684,7 +693,7 @@ public:
684693template <class _Rp, class... _Ap>
685694function(_Rp (*)(_Ap...)) -> function<_Rp(_Ap...)>;
686695
687template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
696template <class _Fp, class _Stripped = __strip_signature_t<decltype(&_Fp::operator())>>
688697function(_Fp) -> function<_Stripped>;
689698# endif // _LIBCPP_STD_VER >= 17
690699
lib/libcxx/include/__functional/hash.h+16-12
......@@ -23,7 +23,6 @@
2323#include <__type_traits/is_integral.h>
2424#include <__type_traits/is_unqualified.h>
2525#include <__type_traits/underlying_type.h>
26#include <__utility/pair.h>
2726#include <__utility/swap.h>
2827#include <cstdint>
2928#include <cstring>
......@@ -41,6 +40,11 @@ inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) {
4140 return __r;
4241}
4342
43struct _PairT {
44 size_t first;
45 size_t second;
46};
47
4448// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
4549// is 64 bits. This is because cityhash64 uses 64bit x 64bit
4650// multiplication, which can be very slow on 32-bit systems.
......@@ -104,9 +108,9 @@ struct __murmur2_or_cityhash<_Size, 64> {
104108 _Size __y = std::__loadword<_Size>(__s + __len - 16) + std::__loadword<_Size>(__s + __len - 56);
105109 _Size __z =
106110 __hash_len_16(std::__loadword<_Size>(__s + __len - 48) + __len, std::__loadword<_Size>(__s + __len - 24));
107 pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
108 pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
109 __x = __x * __k1 + std::__loadword<_Size>(__s);
111 _PairT __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
112 _PairT __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
113 __x = __x * __k1 + std::__loadword<_Size>(__s);
110114
111115 // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
112116 __len = (__len - 1) & ~static_cast<_Size>(63);
......@@ -192,7 +196,7 @@ private:
192196
193197 // Return a 16-byte hash for 48 bytes. Quick and dirty.
194198 // Callers do best to use "random-looking" values for a and b.
195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static pair<_Size, _Size>
199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _PairT
196200 __weak_hash_len_32_with_seeds(_Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) {
197201 __a += __w;
198202 __b = __rotate(__b + __a + __z, 21);
......@@ -200,11 +204,14 @@ private:
200204 __a += __x;
201205 __a += __y;
202206 __b += __rotate(__a, 44);
203 return pair<_Size, _Size>(__a + __z, __b + __c);
207 _PairT __ret;
208 __ret.first = __a + __z;
209 __ret.second = __b + __c;
210 return __ret;
204211 }
205212
206213 // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
207 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static pair<_Size, _Size>
214 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _PairT
208215 __weak_hash_len_32_with_seeds(const char* __s, _Size __a, _Size __b) {
209216 return __weak_hash_len_32_with_seeds(
210217 std::__loadword<_Size>(__s),
......@@ -242,7 +249,9 @@ private:
242249};
243250
244251#if _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY
252_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
245253[[__gnu__::__pure__]] _LIBCPP_EXPORTED_FROM_ABI size_t __hash_memory(_LIBCPP_NOESCAPE const void*, size_t) _NOEXCEPT;
254_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
246255#else
247256_LIBCPP_HIDE_FROM_ABI inline size_t __hash_memory(const void* __ptr, size_t __size) _NOEXCEPT {
248257 return __murmur2_or_cityhash<size_t>()(__ptr, __size);
......@@ -325,11 +334,6 @@ struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> {
325334 }
326335};
327336
328struct _PairT {
329 size_t first;
330 size_t second;
331};
332
333337_LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
334338 typedef __scalar_hash<_PairT> _HashT;
335339 const _PairT __p = {__lhs, __rhs};
lib/libcxx/include/__functional/invoke.h+6-6
......@@ -19,19 +19,17 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 17
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <class _Fn, class... _Args>
2727_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 invoke_result_t<_Fn, _Args...>
2828invoke(_Fn&& __f, _Args&&... __args) noexcept(is_nothrow_invocable_v<_Fn, _Args...>) {
2929 return std::__invoke(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
3030}
3131
32#endif // _LIBCPP_STD_VER >= 17
33
34#if _LIBCPP_STD_VER >= 23
32# if _LIBCPP_STD_VER >= 23
3533template <class _Result, class _Fn, class... _Args>
3634 requires is_invocable_r_v<_Result, _Fn, _Args...>
3735_LIBCPP_HIDE_FROM_ABI constexpr _Result
......@@ -48,8 +46,10 @@ invoke_r(_Fn&& __f, _Args&&... __args) noexcept(is_nothrow_invocable_r_v<_Result
4846 return std::invoke(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
4947 }
5048}
51#endif
49# endif
5250
5351_LIBCPP_END_NAMESPACE_STD
5452
53#endif // _LIBCPP_STD_VER >= 17
54
5555#endif // _LIBCPP___FUNCTIONAL_INVOKE_H
lib/libcxx/include/__functional/is_transparent.h+3-3
......@@ -21,11 +21,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
2222#if _LIBCPP_STD_VER >= 14
2323
24template <class _Tp, class _Key = void, class = void>
24template <class _Comparator, class = void>
2525inline const bool __is_transparent_v = false;
2626
27template <class _Tp, class _Key>
28inline const bool __is_transparent_v<_Tp, _Key, __void_t<typename _Tp::is_transparent> > = true;
27template <class _Comparator>
28inline const bool __is_transparent_v<_Comparator, __void_t<typename _Comparator::is_transparent> > = true;
2929
3030#endif
3131
lib/libcxx/include/__functional/mem_fun_ref.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525template <class _Sp, class _Tp>
2626class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {
2727 _Sp (_Tp::*__p_)();
......@@ -138,8 +138,8 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {
138138 return const_mem_fun1_ref_t<_Sp, _Tp, _Ap>(__f);
139139}
140140
141#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
142
143141_LIBCPP_END_NAMESPACE_STD
144142
143#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
144
145145#endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
lib/libcxx/include/__functional/operations.h+4-4
......@@ -379,8 +379,8 @@ struct less<void> {
379379 typedef void is_transparent;
380380};
381381
382template <class _Tp>
383struct __make_transparent<_Tp, less<_Tp> > {
382template <class _ArgumentType>
383struct __make_transparent<_ArgumentType, less<_ArgumentType> > {
384384 using type _LIBCPP_NODEBUG = less<>;
385385};
386386
......@@ -477,8 +477,8 @@ struct greater<void> {
477477template <class _Tp, class _Up>
478478inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true;
479479
480template <class _Tp>
481struct __make_transparent<_Tp, greater<_Tp>> {
480template <class _ArgumentType>
481struct __make_transparent<_ArgumentType, greater<_ArgumentType>> {
482482 using type _LIBCPP_NODEBUG = greater<>;
483483};
484484
lib/libcxx/include/__functional/perfect_forward.h+4-4
......@@ -28,10 +28,10 @@
2828_LIBCPP_PUSH_MACROS
2929#include <__undef_macros>
3030
31_LIBCPP_BEGIN_NAMESPACE_STD
32
3331#if _LIBCPP_STD_VER >= 17
3432
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3535template <class _Op, class _Indices, class... _BoundArgs>
3636struct __perfect_forward_impl;
3737
......@@ -96,10 +96,10 @@ public:
9696template <class _Op, class... _Args>
9797using __perfect_forward _LIBCPP_NODEBUG = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;
9898
99#endif // _LIBCPP_STD_VER >= 17
100
10199_LIBCPP_END_NAMESPACE_STD
102100
101#endif // _LIBCPP_STD_VER >= 17
102
103103_LIBCPP_POP_MACROS
104104
105105#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
lib/libcxx/include/__functional/pointer_to_binary_function.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Arg1, class _Arg2, class _Result>
2525class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> {
2626 _Result (*__f_)(_Arg1, _Arg2);
......@@ -36,8 +36,8 @@ ptr_fun(_Result (*__f)(_Arg1, _Arg2)) {
3636 return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__f);
3737}
3838
39#endif
40
4139_LIBCPP_END_NAMESPACE_STD
4240
41#endif
42
4343#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
lib/libcxx/include/__functional/pointer_to_unary_function.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Arg, class _Result>
2525class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
2626 _Result (*__f_)(_Arg);
......@@ -36,8 +36,8 @@ ptr_fun(_Result (*__f)(_Arg)) {
3636 return pointer_to_unary_function<_Arg, _Result>(__f);
3737}
3838
39#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
40
4139_LIBCPP_END_NAMESPACE_STD
4240
41#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
42
4343#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
lib/libcxx/include/__functional/ranges_operations.h+4-4
......@@ -21,10 +21,10 @@
2121# pragma GCC system_header
2222#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2624#if _LIBCPP_STD_VER >= 20
2725
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2828namespace ranges {
2929
3030struct equal_to {
......@@ -115,8 +115,8 @@ inline const bool __is_generic_transparent_comparator_v<ranges::less> = true;
115115template <>
116116inline const bool __is_generic_transparent_comparator_v<ranges::greater> = true;
117117
118#endif // _LIBCPP_STD_VER >= 20
119
120118_LIBCPP_END_NAMESPACE_STD
121119
120#endif // _LIBCPP_STD_VER >= 20
121
122122#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
lib/libcxx/include/__functional/unary_negate.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Predicate>
2525class _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
2626 _Predicate __pred_;
......@@ -40,8 +40,8 @@ not1(const _Predicate& __pred) {
4040 return unary_negate<_Predicate>(__pred);
4141}
4242
43#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
44
4543_LIBCPP_END_NAMESPACE_STD
4644
45#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
46
4747#endif // _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
lib/libcxx/include/__fwd/format.h+22-5
......@@ -11,28 +11,45 @@
1111#define _LIBCPP___FWD_FORMAT_H
1212
1313#include <__config>
14#include <__iterator/concepts.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
1817#endif
1918
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2219#if _LIBCPP_STD_VER >= 20
2320
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2423template <class _Context>
2524class basic_format_arg;
2625
2726template <class _OutIt, class _CharT>
28 requires output_iterator<_OutIt, const _CharT&>
2927class basic_format_context;
3028
3129template <class _Tp, class _CharT = char>
3230struct formatter;
3331
34#endif // _LIBCPP_STD_VER >= 20
32# if _LIBCPP_STD_VER >= 23
33
34_LIBCPP_DIAGNOSTIC_PUSH
35_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
36_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow")
37// This shadows map, set, and string.
38enum class range_format { disabled, map, set, sequence, string, debug_string };
39_LIBCPP_DIAGNOSTIC_POP
40
41template <class _Rp>
42constexpr range_format format_kind = [] {
43 // [format.range.fmtkind]/1
44 // A program that instantiates the primary template of format_kind is ill-formed.
45 static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type");
46 return range_format::disabled;
47}();
48
49# endif // _LIBCPP_STD_VER >= 23
3550
3651_LIBCPP_END_NAMESPACE_STD
3752
53#endif // _LIBCPP_STD_VER >= 20
54
3855#endif // _LIBCPP___FWD_FORMAT_H
lib/libcxx/include/__fwd/map.h deleted-31
......@@ -1,31 +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___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/set.h deleted-30
......@@ -1,30 +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___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/span.h+4-4
......@@ -21,18 +21,18 @@
2121_LIBCPP_PUSH_MACROS
2222#include <__undef_macros>
2323
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2624#if _LIBCPP_STD_VER >= 20
2725
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2828inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
2929template <typename _Tp, size_t _Extent = dynamic_extent>
3030class span;
3131
32#endif
33
3432_LIBCPP_END_NAMESPACE_STD
3533
34#endif
35
3636_LIBCPP_POP_MACROS
3737
3838#endif // _LIBCPP___FWD_SPAN_H
lib/libcxx/include/__fwd/variant.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 17
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323template <class... _Types>
2424class variant;
2525
......@@ -61,8 +61,8 @@ _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>&);
6161template <class _Tp, class... _Types>
6262_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&&);
6363
64#endif // _LIBCPP_STD_VER >= 17
65
6664_LIBCPP_END_NAMESPACE_STD
6765
66#endif // _LIBCPP_STD_VER >= 17
67
6868#endif // _LIBCPP___FWD_VARIANT_H
lib/libcxx/include/__hash_table+17-3
......@@ -41,6 +41,8 @@
4141#include <__type_traits/is_swappable.h>
4242#include <__type_traits/remove_const.h>
4343#include <__type_traits/remove_cvref.h>
44#include <__utility/exception_guard.h>
45#include <__utility/exchange.h>
4446#include <__utility/forward.h>
4547#include <__utility/move.h>
4648#include <__utility/pair.h>
......@@ -73,7 +75,9 @@ struct __is_hash_value_type : false_type {};
7375template <class _One>
7476struct __is_hash_value_type<_One> : __is_hash_value_type_imp<__remove_cvref_t<_One> > {};
7577
78_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
7679_LIBCPP_EXPORTED_FROM_ABI size_t __next_prime(size_t __n);
80_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7781
7882template <class _NodePtr>
7983struct __hash_node_base {
......@@ -524,9 +528,7 @@ public:
524528
525529 _LIBCPP_HIDE_FROM_ABI __bucket_list_deallocator(__bucket_list_deallocator&& __x)
526530 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
527 : __size_(std::move(__x.__size_)), __alloc_(std::move(__x.__alloc_)) {
528 __x.size() = 0;
529 }
531 : __size_(std::__exchange(__x.__size_, 0)), __alloc_(std::move(__x.__alloc_)) {}
530532
531533 _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; }
532534 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
......@@ -696,6 +698,17 @@ private:
696698
697699 _LIBCPP_HIDE_FROM_ABI void __copy_construct(__next_pointer __other_iter) {
698700 __next_pointer __own_iter = __first_node_.__ptr();
701 // If copying a node throws, the nodes that have already been constructed and linked into the
702 // list have to be deallocated. When this is called from the copy constructor the enclosing
703 // __hash_table is not fully constructed yet, so its destructor would not run to release them.
704 // This is also reached from operator= when assigning into an empty table; there the table
705 // stays alive, so we must leave it in a valid empty state: besides releasing the nodes we
706 // clear the bucket pointers, which were made to point into the now-deallocated node list.
707 auto __guard = std::__make_exception_guard([&] {
708 __deallocate_node_list(__first_node_.__next_);
709 __first_node_.__next_ = nullptr;
710 std::fill_n(__bucket_list_.get(), bucket_count(), nullptr);
711 });
699712 {
700713 __node_holder __new_node = __construct_node_hash(__other_iter->__hash(), __other_iter->__upcast()->__get_value());
701714 __own_iter->__next_ = static_cast<__next_pointer>(__new_node.release());
......@@ -706,6 +719,7 @@ private:
706719 __other_iter = __other_iter->__next_;
707720 __own_iter = __own_iter->__next_;
708721 __copy_construct(__other_iter, __own_iter, __current_chash);
722 __guard.__complete();
709723 }
710724
711725public:
lib/libcxx/include/__iterator/access.h+15-13
......@@ -20,47 +20,49 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _Tp, size_t _Np>
23_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* begin(_Tp (&__array)[_Np]) _NOEXCEPT {
23[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* begin(_Tp (&__array)[_Np]) _NOEXCEPT {
2424 return __array;
2525}
2626
2727template <class _Tp, size_t _Np>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* end(_Tp (&__array)[_Np]) _NOEXCEPT {
28[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* end(_Tp (&__array)[_Np]) _NOEXCEPT {
2929 return __array + _Np;
3030}
3131
3232#if !defined(_LIBCPP_CXX03_LANG)
3333
3434template <class _Cp>
35_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(_Cp& __c) -> decltype(__c.begin()) {
35[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(_Cp& __c) -> decltype(__c.begin()) {
3636 return __c.begin();
3737}
3838
3939template <class _Cp>
40_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(const _Cp& __c) -> decltype(__c.begin()) {
40[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto begin(const _Cp& __c)
41 -> decltype(__c.begin()) {
4142 return __c.begin();
4243}
4344
4445template <class _Cp>
45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(_Cp& __c) -> decltype(__c.end()) {
46[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(_Cp& __c) -> decltype(__c.end()) {
4647 return __c.end();
4748}
4849
4950template <class _Cp>
50_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> decltype(__c.end()) {
51[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) -> decltype(__c.end()) {
5152 return __c.end();
5253}
5354
5455# if _LIBCPP_STD_VER >= 14
5556
5657template <class _Cp>
57_LIBCPP_HIDE_FROM_ABI constexpr auto
58cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) -> decltype(std::begin(__c)) {
58[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c)))
59 -> decltype(std::begin(__c)) {
5960 return std::begin(__c);
6061}
6162
6263template <class _Cp>
63_LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std::end(__c))) -> decltype(std::end(__c)) {
64[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std::end(__c)))
65 -> decltype(std::end(__c)) {
6466 return std::end(__c);
6567}
6668
......@@ -69,22 +71,22 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto cend(const _Cp& __c) noexcept(noexcept(std:
6971#else // defined(_LIBCPP_CXX03_LANG)
7072
7173template <class _Cp>
72_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) {
74[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI typename _Cp::iterator begin(_Cp& __c) {
7375 return __c.begin();
7476}
7577
7678template <class _Cp>
77_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator begin(const _Cp& __c) {
79[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator begin(const _Cp& __c) {
7880 return __c.begin();
7981}
8082
8183template <class _Cp>
82_LIBCPP_HIDE_FROM_ABI typename _Cp::iterator end(_Cp& __c) {
84[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI typename _Cp::iterator end(_Cp& __c) {
8385 return __c.end();
8486}
8587
8688template <class _Cp>
87_LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) {
89[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI typename _Cp::const_iterator end(const _Cp& __c) {
8890 return __c.end();
8991}
9092
lib/libcxx/include/__iterator/back_insert_iterator.h+3-1
......@@ -58,7 +58,9 @@ public:
5858 return *this;
5959 }
6060#endif // _LIBCPP_CXX03_LANG
61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() { return *this; }
61 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator*() {
62 return *this;
63 }
6264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator& operator++() { return *this; }
6365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 back_insert_iterator operator++(int) { return *this; }
6466
lib/libcxx/include/__iterator/bounded_iter.h+7-9
......@@ -53,9 +53,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5353// optimizations deleting non-redundant bounds checks.
5454template <class _Iterator>
5555struct __bounded_iter {
56 static_assert(__libcpp_is_contiguous_iterator<_Iterator>::value,
57 "Only contiguous iterators can be adapted by __bounded_iter.");
58
5956 using value_type = typename iterator_traits<_Iterator>::value_type;
6057 using difference_type = typename iterator_traits<_Iterator>::difference_type;
6158 using pointer = typename iterator_traits<_Iterator>::pointer;
......@@ -117,7 +114,7 @@ public:
117114 // that the iterator is always within `[begin, end]`, we only need to check it's not pointing to
118115 // `end`. This is easier for the optimizer because it aligns with the `iter != container.end()`
119116 // checks that typical callers already use (see https://llvm.org/PR78829).
120 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
117 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
121118 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
122119 __current_ != __end_, "__bounded_iter::operator*: Attempt to dereference an iterator at the end");
123120 return *__current_;
......@@ -129,7 +126,8 @@ public:
129126 return std::__to_address(__current_);
130127 }
131128
132 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
129 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference
130 operator[](difference_type __n) const _NOEXCEPT {
133131 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
134132 __n >= __begin_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator past the start");
135133 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
......@@ -172,13 +170,13 @@ public:
172170 __current_ += __n;
173171 return *this;
174172 }
175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
173 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
176174 operator+(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
177175 __bounded_iter __tmp(__self);
178176 __tmp += __n;
179177 return __tmp;
180178 }
181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
179 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
182180 operator+(difference_type __n, __bounded_iter const& __self) _NOEXCEPT {
183181 __bounded_iter __tmp(__self);
184182 __tmp += __n;
......@@ -193,13 +191,13 @@ public:
193191 __current_ -= __n;
194192 return *this;
195193 }
196 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
194 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __bounded_iter
197195 operator-(__bounded_iter const& __self, difference_type __n) _NOEXCEPT {
198196 __bounded_iter __tmp(__self);
199197 __tmp -= __n;
200198 return __tmp;
201199 }
202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
200 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
203201 operator-(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
204202 return __x.__current_ - __y.__current_;
205203 }
lib/libcxx/include/__iterator/capacity_aware_iterator.h created+186
......@@ -0,0 +1,186 @@
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___CAPACITY_AWARE_ITERATOR_H
11#define _LIBCPP___CAPACITY_AWARE_ITERATOR_H
12
13#include <__assert>
14#include <__compare/ordering.h>
15#include <__compare/three_way_comparable.h>
16#include <__config>
17#include <__cstddef/size_t.h>
18#include <__iterator/concepts.h>
19#include <__iterator/incrementable_traits.h>
20#include <__iterator/iterator_traits.h>
21#include <__memory/pointer_traits.h>
22#include <__type_traits/is_constructible.h>
23#include <__type_traits/is_convertible.h>
24#include <__utility/move.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
32
33#if _LIBCPP_STD_VER >= 26
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37// __capacity_aware_iterator is an iterator that wraps a contiguous iterator and encodes the maximum number of
38// elements that can appear in a range of such iterators. That maximum number of elements must be known at compile-time.
39// As of writing, the only standard library containers which fulfill these requirements are inplace_vector and optional.
40//
41// It also embeds a tag type to prevent mixing iterators from e.g. different containers. This also allows for some
42// algorithms to detect this iterator and perform optimizations based on the added semantic information.
43
44template <class _Iter, class _Tag, size_t _RangeMaxElements>
45class __capacity_aware_iterator {
46private:
47 _Iter __iter_;
48
49 template <class, class, size_t>
50 friend class __capacity_aware_iterator;
51
52public:
53 static_assert(contiguous_iterator<_Iter>, "__capacity_aware_iterator can only be used with contiguous iterators");
54
55 using iterator_category = iterator_traits<_Iter>::iterator_category;
56 using iterator_concept = contiguous_iterator_tag;
57 using difference_type = iter_difference_t<_Iter>;
58 using pointer = iterator_traits<_Iter>::pointer;
59 using reference = iter_reference_t<_Iter>;
60 using value_type = iter_value_t<_Iter>;
61
62 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator()
63 requires is_default_constructible_v<_Iter>
64 = default;
65
66 template <typename _Iter2>
67 requires is_convertible_v<_Iter2, _Iter>
68 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator(
69 const __capacity_aware_iterator<_Iter2, _Tag, _RangeMaxElements>& __y) noexcept
70 : __iter_(__y.__iter_) {}
71
72 template <class _It, class _Tag2, size_t _RangeMaxElems2>
73 _LIBCPP_HIDE_FROM_ABI friend constexpr auto __make_capacity_aware_iterator(_It __iter) noexcept;
74
75private:
76 _LIBCPP_HIDE_FROM_ABI constexpr explicit __capacity_aware_iterator(_Iter __iter) : __iter_(std::move(__iter)) {}
77
78public:
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const noexcept { return *__iter_; }
80 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator->() const noexcept { return std::__to_address(__iter_); }
81
82 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator& operator++() noexcept {
83 ++__iter_;
84 return *this;
85 }
86
87 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator operator++(int) noexcept {
88 __capacity_aware_iterator __tmp(*this);
89 ++*this;
90 return __tmp;
91 }
92
93 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator& operator--() noexcept {
94 --__iter_;
95 return *this;
96 }
97
98 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator operator--(int) noexcept {
99 __capacity_aware_iterator __tmp(*this);
100 --*this;
101 return __tmp;
102 }
103
104 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator& operator+=(difference_type __n) noexcept {
105 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
106 static_cast<size_t>(__n >= 0 ? __n : -__n) <= _RangeMaxElements,
107 "__capacity_aware_iterator::operator+=: Attempting to move iterator past its container's possible range");
108
109 __iter_ += __n;
110 return *this;
111 }
112
113 _LIBCPP_HIDE_FROM_ABI constexpr __capacity_aware_iterator& operator-=(difference_type __n) noexcept {
114 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
115 static_cast<size_t>(__n >= 0 ? __n : -__n) <= _RangeMaxElements,
116 "__capacity_aware_iterator::operator-=: Attempting to move iterator past its container's possible range");
117
118 __iter_ -= __n;
119 return *this;
120 }
121
122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const noexcept {
123 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
124 static_cast<size_t>(__n >= 0 ? __n : -__n) < _RangeMaxElements,
125 "__capacity_aware_iterator::operator[]: Attempting to index iterator past its container's possible range");
126 return *(*this + __n);
127 }
128
129 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
130 operator==(const __capacity_aware_iterator& __x, const __capacity_aware_iterator& __y) noexcept {
131 return __x.__iter_ == __y.__iter_;
132 }
133
134 _LIBCPP_HIDE_FROM_ABI friend constexpr auto
135 operator<=>(const __capacity_aware_iterator& __x, const __capacity_aware_iterator& __y) noexcept {
136 if constexpr (three_way_comparable_with<_Iter, _Iter, strong_ordering>) {
137 return __x.__iter_ <=> __y.__iter_;
138 } else {
139 if (__x.__iter_ < __y.__iter_) {
140 return strong_ordering::less;
141 } else if (__x.__iter_ == __y.__iter_) {
142 return strong_ordering::equal;
143 }
144 return strong_ordering::greater;
145 }
146 }
147
148 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __capacity_aware_iterator
149 operator+(const __capacity_aware_iterator& __i, difference_type __n) noexcept {
150 auto __tmp = __i;
151 __tmp += __n;
152 return __tmp;
153 }
154
155 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __capacity_aware_iterator
156 operator+(difference_type __n, const __capacity_aware_iterator& __i) noexcept {
157 auto __tmp = __i;
158 __tmp += __n;
159 return __tmp;
160 }
161
162 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __capacity_aware_iterator
163 operator-(const __capacity_aware_iterator& __i, difference_type __n) noexcept {
164 auto __tmp = __i;
165 __tmp -= __n;
166 return __tmp;
167 }
168
169 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
170 operator-(const __capacity_aware_iterator& __x, const __capacity_aware_iterator& __y) noexcept {
171 return difference_type(__x.__iter_ - __y.__iter_);
172 }
173};
174
175template <class _It, class _Tag2, size_t _RangeMaxElems2>
176_LIBCPP_HIDE_FROM_ABI constexpr auto __make_capacity_aware_iterator(_It __iter) noexcept {
177 return __capacity_aware_iterator<_It, _Tag2, _RangeMaxElems2>(__iter);
178}
179
180_LIBCPP_END_NAMESPACE_STD
181
182#endif // _LIBCPP_STD_VER >= 26
183
184_LIBCPP_POP_MACROS
185
186#endif // _LIBCPP___CAPACITY_AWARE_ITERATOR_H
lib/libcxx/include/__iterator/common_iterator.h+3-3
......@@ -17,6 +17,7 @@
1717#include <__concepts/copyable.h>
1818#include <__concepts/derived_from.h>
1919#include <__concepts/equality_comparable.h>
20#include <__concepts/referenceable.h>
2021#include <__concepts/same_as.h>
2122#include <__config>
2223#include <__iterator/concepts.h>
......@@ -28,7 +29,6 @@
2829#include <__memory/addressof.h>
2930#include <__type_traits/conditional.h>
3031#include <__type_traits/is_pointer.h>
31#include <__type_traits/is_referenceable.h>
3232#include <__utility/declval.h>
3333#include <variant>
3434
......@@ -111,7 +111,7 @@ public:
111111 return *this;
112112 }
113113
114 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
115115 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
116116 std::holds_alternative<_Iter>(__hold_), "Attempted to dereference a non-dereferenceable common_iterator");
117117 return *std::__unchecked_get<_Iter>(__hold_);
......@@ -237,7 +237,7 @@ public:
237237 return std::__unchecked_get<_Sent>(__x.__hold_) - std::__unchecked_get<_I2>(__y.__hold_);
238238 }
239239
240 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
240 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
241241 iter_move(const common_iterator& __i) noexcept(noexcept(ranges::iter_move(std::declval<const _Iter&>())))
242242 requires input_iterator<_Iter>
243243 {
lib/libcxx/include/__iterator/concepts.h+8-9
......@@ -20,6 +20,8 @@
2020#include <__concepts/invocable.h>
2121#include <__concepts/movable.h>
2222#include <__concepts/predicate.h>
23#include <__concepts/primary_template.h>
24#include <__concepts/referenceable.h>
2325#include <__concepts/regular.h>
2426#include <__concepts/relation.h>
2527#include <__concepts/same_as.h>
......@@ -38,10 +40,7 @@
3840#include <__type_traits/integral_constant.h>
3941#include <__type_traits/invoke.h>
4042#include <__type_traits/is_pointer.h>
41#include <__type_traits/is_primary_template.h>
4243#include <__type_traits/is_reference.h>
43#include <__type_traits/is_referenceable.h>
44#include <__type_traits/is_valid_expansion.h>
4544#include <__type_traits/remove_cv.h>
4645#include <__type_traits/remove_cvref.h>
4746#include <__utility/forward.h>
......@@ -80,7 +79,7 @@ template <class _Tp>
8079concept __specialization_of_projected = requires {
8180 typename __projected_iterator_t<_Tp>;
8281 typename __projected_projection_t<_Tp>;
83} && __is_primary_template<_Tp>::value;
82} && __primary_template<_Tp>;
8483
8584template <class _Tp>
8685struct __indirect_value_t_impl {
......@@ -153,8 +152,7 @@ concept sized_sentinel_for =
153152
154153template <class _Iter>
155154struct __iter_traits_cache {
156 using type _LIBCPP_NODEBUG =
157 _If<__is_primary_template<iterator_traits<_Iter> >::value, _Iter, iterator_traits<_Iter> >;
155 using type _LIBCPP_NODEBUG = _If<__primary_template<iterator_traits<_Iter> >, _Iter, iterator_traits<_Iter> >;
158156};
159157template <class _Iter>
160158using _ITER_TRAITS _LIBCPP_NODEBUG = typename __iter_traits_cache<_Iter>::type;
......@@ -169,12 +167,13 @@ struct __iter_concept_category_test {
169167};
170168struct __iter_concept_random_fallback {
171169 template <class _Iter>
172 using _Apply _LIBCPP_NODEBUG =
173 __enable_if_t<__is_primary_template<iterator_traits<_Iter> >::value, random_access_iterator_tag>;
170 using _Apply _LIBCPP_NODEBUG = __enable_if_t<__primary_template<iterator_traits<_Iter> >, random_access_iterator_tag>;
174171};
175172
176173template <class _Iter, class _Tester>
177struct __test_iter_concept : _IsValidExpansion<_Tester::template _Apply, _Iter>, _Tester {};
174 struct __test_iter_concept : bool_constant < requires {
175 typename _Tester::template _Apply<_Iter>;
176} >, _Tester{};
178177
179178template <class _Iter>
180179struct __iter_concept_cache {
lib/libcxx/include/__iterator/counted_iterator.h+13-13
......@@ -98,18 +98,18 @@ public:
9898 return *this;
9999 }
100100
101 _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const& noexcept { return __current_; }
101 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const& noexcept { return __current_; }
102102
103 _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
104104
105 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; }
105 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; }
106106
107 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
107 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() {
108108 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
109109 return *__current_;
110110 }
111111
112 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
112 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
113113 requires __dereferenceable<const _Iter>
114114 {
115115 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__count_ > 0, "Iterator is equal to or past end.");
......@@ -169,13 +169,13 @@ public:
169169 return __tmp;
170170 }
171171
172 _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const
172 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const
173173 requires random_access_iterator<_Iter>
174174 {
175175 return counted_iterator(__current_ + __n, __count_ - __n);
176176 }
177177
178 _LIBCPP_HIDE_FROM_ABI friend constexpr counted_iterator
178 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr counted_iterator
179179 operator+(iter_difference_t<_Iter> __n, const counted_iterator& __x)
180180 requires random_access_iterator<_Iter>
181181 {
......@@ -191,24 +191,24 @@ public:
191191 return *this;
192192 }
193193
194 _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const
194 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const
195195 requires random_access_iterator<_Iter>
196196 {
197197 return counted_iterator(__current_ - __n, __count_ + __n);
198198 }
199199
200200 template <common_with<_Iter> _I2>
201 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_I2>
201 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_I2>
202202 operator-(const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) {
203203 return __rhs.__count_ - __lhs.__count_;
204204 }
205205
206 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Iter>
206 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Iter>
207207 operator-(const counted_iterator& __lhs, default_sentinel_t) {
208208 return -__lhs.__count_;
209209 }
210210
211 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Iter>
211 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr iter_difference_t<_Iter>
212212 operator-(default_sentinel_t, const counted_iterator& __rhs) {
213213 return __rhs.__count_;
214214 }
......@@ -226,7 +226,7 @@ public:
226226 return *this;
227227 }
228228
229 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const
229 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const
230230 requires random_access_iterator<_Iter>
231231 {
232232 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < __count_, "Subscript argument must be less than size.");
......@@ -249,7 +249,7 @@ public:
249249 return __rhs.__count_ <=> __lhs.__count_;
250250 }
251251
252 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
252 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
253253 iter_move(const counted_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_)))
254254 requires input_iterator<_Iter>
255255 {
lib/libcxx/include/__iterator/data.h+10-8
......@@ -17,32 +17,34 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 17
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Cont>
25constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) {
25[[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) noexcept(noexcept(__c.data()))
26 -> decltype(__c.data()) {
2627 return __c.data();
2728}
2829
2930template <class _Cont>
30constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) {
31[[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) noexcept(noexcept(__c.data()))
32 -> decltype(__c.data()) {
3133 return __c.data();
3234}
3335
3436template <class _Tp, size_t _Sz>
35_LIBCPP_HIDE_FROM_ABI constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept {
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept {
3638 return __array;
3739}
3840
3941template <class _Ep>
40_LIBCPP_HIDE_FROM_ABI constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept {
42[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept {
4143 return __il.begin();
4244}
4345
44#endif
45
4646_LIBCPP_END_NAMESPACE_STD
4747
48#endif // _LIBCPP_STD_VER >= 17
49
4850#endif // _LIBCPP___ITERATOR_DATA_H
lib/libcxx/include/__iterator/default_sentinel.h+4-4
......@@ -16,15 +16,15 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 20
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323struct default_sentinel_t {};
2424inline constexpr default_sentinel_t default_sentinel{};
2525
26#endif // _LIBCPP_STD_VER >= 20
27
2826_LIBCPP_END_NAMESPACE_STD
2927
28#endif // _LIBCPP_STD_VER >= 20
29
3030#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H
lib/libcxx/include/__iterator/distance.h+5-4
......@@ -67,7 +67,8 @@ __distance(_InputIter __first, _Sent __last) {
6767}
6868
6969template <class _InputIter>
70inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 typename iterator_traits<_InputIter>::difference_type
70[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17
71typename iterator_traits<_InputIter>::difference_type
7172distance(_InputIter __first, _InputIter __last) {
7273 return std::__distance(__first, __last);
7374}
......@@ -80,12 +81,12 @@ namespace ranges {
8081struct __distance {
8182 template <class _Ip, sentinel_for<_Ip> _Sp>
8283 requires(!sized_sentinel_for<_Sp, _Ip>)
83 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
84 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip __first, _Sp __last) const {
8485 return std::__distance(std::move(__first), std::move(__last));
8586 }
8687
8788 template <class _Ip, sized_sentinel_for<decay_t<_Ip>> _Sp>
88 _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
89 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Ip> operator()(_Ip&& __first, _Sp __last) const {
8990 if constexpr (sized_sentinel_for<_Sp, __remove_cvref_t<_Ip>>) {
9091 return __last - __first;
9192 } else {
......@@ -94,7 +95,7 @@ struct __distance {
9495 }
9596
9697 template <range _Rp>
97 _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
98 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Rp> operator()(_Rp&& __r) const {
9899 if constexpr (sized_range<_Rp>) {
99100 return static_cast<range_difference_t<_Rp>>(ranges::size(__r));
100101 } else {
lib/libcxx/include/__iterator/empty.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 17
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Cont>
2525[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
2626empty(const _Cont& __c) noexcept(noexcept(__c.empty())) -> decltype(__c.empty()) {
......@@ -37,8 +37,8 @@ template <class _Ep>
3737 return __il.size() == 0;
3838}
3939
40#endif // _LIBCPP_STD_VER >= 17
41
4240_LIBCPP_END_NAMESPACE_STD
4341
42#endif // _LIBCPP_STD_VER >= 17
43
4444#endif // _LIBCPP___ITERATOR_EMPTY_H
lib/libcxx/include/__iterator/erase_if_container.h+2-1
......@@ -22,7 +22,8 @@ _LIBCPP_PUSH_MACROS
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _Container, class _Predicate>
25_LIBCPP_HIDE_FROM_ABI typename _Container::size_type __libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename _Container::size_type
26__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
2627 typename _Container::size_type __old_size = __c.size();
2728
2829 const typename _Container::iterator __last = __c.end();
lib/libcxx/include/__iterator/front_insert_iterator.h+4-2
......@@ -58,14 +58,16 @@ public:
5858 return *this;
5959 }
6060#endif // _LIBCPP_CXX03_LANG
61 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() { return *this; }
61 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator*() {
62 return *this;
63 }
6264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator& operator++() { return *this; }
6365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator operator++(int) { return *this; }
6466};
6567_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(front_insert_iterator);
6668
6769template <class _Container>
68inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator<_Container>
70[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 front_insert_iterator<_Container>
6971front_inserter(_Container& __x) {
7072 return front_insert_iterator<_Container>(__x);
7173}
lib/libcxx/include/__iterator/incrementable_traits.h+6-6
......@@ -11,11 +11,11 @@
1111#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
1212
1313#include <__concepts/arithmetic.h>
14#include <__concepts/primary_template.h>
1415#include <__config>
1516#include <__cstddef/ptrdiff_t.h>
1617#include <__type_traits/conditional.h>
1718#include <__type_traits/is_object.h>
18#include <__type_traits/is_primary_template.h>
1919#include <__type_traits/make_signed.h>
2020#include <__type_traits/remove_cvref.h>
2121#include <__utility/declval.h>
......@@ -24,10 +24,10 @@
2424# pragma GCC system_header
2525#endif
2626
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2927#if _LIBCPP_STD_VER >= 20
3028
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3131// [incrementable.traits]
3232template <class>
3333struct incrementable_traits {};
......@@ -68,12 +68,12 @@ struct iterator_traits;
6868// generated from the primary template, and `iterator_traits<RI>::difference_type` otherwise.
6969template <class _Ip>
7070using iter_difference_t =
71 typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
71 typename conditional_t<__primary_template<iterator_traits<remove_cvref_t<_Ip> > >,
7272 incrementable_traits<remove_cvref_t<_Ip> >,
7373 iterator_traits<remove_cvref_t<_Ip> > >::difference_type;
7474
75#endif // _LIBCPP_STD_VER >= 20
76
7775_LIBCPP_END_NAMESPACE_STD
7876
77#endif // _LIBCPP_STD_VER >= 20
78
7979#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H
lib/libcxx/include/__iterator/insert_iterator.h+2-2
......@@ -71,13 +71,13 @@ public:
7171 return *this;
7272 }
7373#endif // _LIBCPP_CXX03_LANG
74 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() { return *this; }
74 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator*() { return *this; }
7575 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++() { return *this; }
7676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator& operator++(int) { return *this; }
7777};
7878
7979template <class _Container>
80inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator<_Container>
80[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 insert_iterator<_Container>
8181inserter(_Container& __x, __insert_iterator_iter_t<_Container> __i) {
8282 return insert_iterator<_Container>(__x, __i);
8383}
lib/libcxx/include/__iterator/istream_iterator.h+1-1
......@@ -60,7 +60,7 @@ public:
6060 // LWG3600 Changed the wording of the copy constructor. In libc++ this constructor
6161 // can still be trivial after this change.
6262
63 _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; }
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Tp& operator*() const { return __value_; }
6464 _LIBCPP_HIDE_FROM_ABI const _Tp* operator->() const { return std::addressof((operator*())); }
6565 _LIBCPP_HIDE_FROM_ABI istream_iterator& operator++() {
6666 if (!(*__in_stream_ >> __value_))
lib/libcxx/include/__iterator/istreambuf_iterator.h+4-2
......@@ -73,14 +73,16 @@ public:
7373 _LIBCPP_HIDE_FROM_ABI istreambuf_iterator(streambuf_type* __s) _NOEXCEPT : __sbuf_(__s) {}
7474 _LIBCPP_HIDE_FROM_ABI istreambuf_iterator(const __proxy& __p) _NOEXCEPT : __sbuf_(__p.__sbuf_) {}
7575
76 _LIBCPP_HIDE_FROM_ABI char_type operator*() const { return static_cast<char_type>(__sbuf_->sgetc()); }
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type operator*() const {
77 return static_cast<char_type>(__sbuf_->sgetc());
78 }
7779 _LIBCPP_HIDE_FROM_ABI istreambuf_iterator& operator++() {
7880 __sbuf_->sbumpc();
7981 return *this;
8082 }
8183 _LIBCPP_HIDE_FROM_ABI __proxy operator++(int) { return __proxy(__sbuf_->sbumpc(), __sbuf_); }
8284
83 _LIBCPP_HIDE_FROM_ABI bool equal(const istreambuf_iterator& __b) const {
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool equal(const istreambuf_iterator& __b) const {
8486 return __test_for_eof() == __b.__test_for_eof();
8587 }
8688
lib/libcxx/include/__iterator/iter_move.h+5-5
......@@ -11,10 +11,10 @@
1111#define _LIBCPP___ITERATOR_ITER_MOVE_H
1212
1313#include <__concepts/class_or_enum.h>
14#include <__concepts/referenceable.h>
1415#include <__config>
1516#include <__iterator/iterator_traits.h>
1617#include <__type_traits/is_reference.h>
17#include <__type_traits/is_referenceable.h>
1818#include <__type_traits/remove_cvref.h>
1919#include <__utility/declval.h>
2020#include <__utility/forward.h>
......@@ -27,10 +27,10 @@
2727_LIBCPP_PUSH_MACROS
2828#include <__undef_macros>
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230#if _LIBCPP_STD_VER >= 20
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3434// [iterator.cust.move]
3535
3636namespace ranges {
......@@ -95,10 +95,10 @@ template <__dereferenceable _Tp>
9595 }
9696using iter_rvalue_reference_t = decltype(ranges::iter_move(std::declval<_Tp&>()));
9797
98#endif // _LIBCPP_STD_VER >= 20
99
10098_LIBCPP_END_NAMESPACE_STD
10199
100#endif // _LIBCPP_STD_VER >= 20
101
102102_LIBCPP_POP_MACROS
103103
104104#endif // _LIBCPP___ITERATOR_ITER_MOVE_H
lib/libcxx/include/__iterator/iter_swap.h+4-4
......@@ -29,10 +29,10 @@
2929_LIBCPP_PUSH_MACROS
3030#include <__undef_macros>
3131
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3432#if _LIBCPP_STD_VER >= 20
3533
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3636// [iter.cust.swap]
3737
3838namespace ranges {
......@@ -99,10 +99,10 @@ concept indirectly_swappable =
9999 ranges::iter_swap(__i2, __i1);
100100 };
101101
102#endif // _LIBCPP_STD_VER >= 20
103
104102_LIBCPP_END_NAMESPACE_STD
105103
104#endif // _LIBCPP_STD_VER >= 20
105
106106_LIBCPP_POP_MACROS
107107
108108#endif // _LIBCPP___ITERATOR_ITER_SWAP_H
lib/libcxx/include/__iterator/iterator_traits.h+3-3
......@@ -15,6 +15,8 @@
1515#include <__concepts/convertible_to.h>
1616#include <__concepts/copyable.h>
1717#include <__concepts/equality_comparable.h>
18#include <__concepts/primary_template.h>
19#include <__concepts/referenceable.h>
1820#include <__concepts/same_as.h>
1921#include <__concepts/totally_ordered.h>
2022#include <__config>
......@@ -30,9 +32,7 @@
3032#include <__type_traits/integral_constant.h>
3133#include <__type_traits/is_convertible.h>
3234#include <__type_traits/is_object.h>
33#include <__type_traits/is_primary_template.h>
3435#include <__type_traits/is_reference.h>
35#include <__type_traits/is_referenceable.h>
3636#include <__type_traits/nat.h>
3737#include <__type_traits/remove_const.h>
3838#include <__type_traits/remove_cv.h>
......@@ -468,7 +468,7 @@ using __iterator_reference _LIBCPP_NODEBUG = typename iterator_traits<_Iter>::re
468468// This has to be in this file and not readable_traits.h to break the include cycle between the two.
469469template <class _Ip>
470470using iter_value_t =
471 typename conditional_t<__is_primary_template<iterator_traits<remove_cvref_t<_Ip> > >::value,
471 typename conditional_t<__primary_template<iterator_traits<remove_cvref_t<_Ip> > >,
472472 indirectly_readable_traits<remove_cvref_t<_Ip> >,
473473 iterator_traits<remove_cvref_t<_Ip> > >::value_type;
474474
lib/libcxx/include/__iterator/move_iterator.h+25-20
......@@ -13,6 +13,7 @@
1313#include <__compare/compare_three_way_result.h>
1414#include <__compare/three_way_comparable.h>
1515#include <__concepts/assignable.h>
16#include <__concepts/constructible.h>
1617#include <__concepts/convertible_to.h>
1718#include <__concepts/derived_from.h>
1819#include <__concepts/same_as.h>
......@@ -27,7 +28,6 @@
2728#include <__type_traits/conditional.h>
2829#include <__type_traits/enable_if.h>
2930#include <__type_traits/is_assignable.h>
30#include <__type_traits/is_constructible.h>
3131#include <__type_traits/is_convertible.h>
3232#include <__type_traits/is_reference.h>
3333#include <__type_traits/is_same.h>
......@@ -122,7 +122,7 @@ public:
122122
123123#if _LIBCPP_STD_VER >= 20
124124 _LIBCPP_HIDE_FROM_ABI constexpr move_iterator()
125 requires is_constructible_v<_Iter>
125 requires default_initializable<_Iter>
126126 : __current_() {}
127127
128128 template <class _Up>
......@@ -136,11 +136,11 @@ public:
136136 return *this;
137137 }
138138
139 _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const& noexcept { return __current_; }
140 _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
139 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Iter& base() const& noexcept { return __current_; }
140 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() && { return std::move(__current_); }
141141
142 _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { return ranges::iter_move(__current_); }
143 _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](difference_type __n) const {
142 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const { return ranges::iter_move(__current_); }
143 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](difference_type __n) const {
144144 return ranges::iter_move(__current_ + __n);
145145 }
146146
......@@ -169,12 +169,13 @@ public:
169169 return *this;
170170 }
171171
172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter base() const { return __current_; }
172 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter base() const { return __current_; }
173173
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {
174 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {
175175 return static_cast<reference>(*__current_);
176176 }
177 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const {
177 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference
178 operator[](difference_type __n) const {
178179 return static_cast<reference>(__current_[__n]);
179180 }
180181
......@@ -194,14 +195,16 @@ public:
194195 --__current_;
195196 return __tmp;
196197 }
197 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator operator+(difference_type __n) const {
198 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator
199 operator+(difference_type __n) const {
198200 return move_iterator(__current_ + __n);
199201 }
200202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator+=(difference_type __n) {
201203 __current_ += __n;
202204 return *this;
203205 }
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator operator-(difference_type __n) const {
206 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator
207 operator-(difference_type __n) const {
205208 return move_iterator(__current_ - __n);
206209 }
207210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator-=(difference_type __n) {
......@@ -218,18 +221,18 @@ public:
218221 }
219222
220223 template <sized_sentinel_for<_Iter> _Sent>
221 friend _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
224 [[nodiscard]] friend _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
222225 operator-(const move_sentinel<_Sent>& __x, const move_iterator& __y) {
223226 return __x.base() - __y.base();
224227 }
225228
226229 template <sized_sentinel_for<_Iter> _Sent>
227 friend _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
230 [[nodiscard]] friend _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
228231 operator-(const move_iterator& __x, const move_sentinel<_Sent>& __y) {
229232 return __x.base() - __y.base();
230233 }
231234
232 friend _LIBCPP_HIDE_FROM_ABI constexpr iter_rvalue_reference_t<_Iter>
235 [[nodiscard]] friend _LIBCPP_HIDE_FROM_ABI constexpr iter_rvalue_reference_t<_Iter>
233236 iter_move(const move_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__current_))) {
234237 return ranges::iter_move(__i.__current_);
235238 }
......@@ -299,13 +302,14 @@ operator<=>(const move_iterator<_Iter1>& __x,
299302
300303#ifndef _LIBCPP_CXX03_LANG
301304template <class _Iter1, class _Iter2>
302inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
303operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) -> decltype(__x.base() - __y.base()) {
305[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
306_LIBCPP_CONSTEXPR_SINCE_CXX17 auto operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
307 -> decltype(__x.base() - __y.base()) {
304308 return __x.base() - __y.base();
305309}
306310#else
307311template <class _Iter1, class _Iter2>
308inline _LIBCPP_HIDE_FROM_ABI typename move_iterator<_Iter1>::difference_type
312[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename move_iterator<_Iter1>::difference_type
309313operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
310314 return __x.base() - __y.base();
311315}
......@@ -313,7 +317,7 @@ operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
313317
314318#if _LIBCPP_STD_VER >= 20
315319template <class _Iter>
316inline _LIBCPP_HIDE_FROM_ABI constexpr move_iterator<_Iter>
320[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr move_iterator<_Iter>
317321operator+(iter_difference_t<_Iter> __n, const move_iterator<_Iter>& __x)
318322 requires requires {
319323 { __x.base() + __n } -> same_as<_Iter>;
......@@ -323,7 +327,7 @@ operator+(iter_difference_t<_Iter> __n, const move_iterator<_Iter>& __x)
323327}
324328#else
325329template <class _Iter>
326inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter>
330[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter>
327331operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) {
328332 return move_iterator<_Iter>(__x.base() + __n);
329333}
......@@ -336,7 +340,8 @@ inline constexpr bool disable_sized_sentinel_for<move_iterator<_Iter1>, move_ite
336340#endif // _LIBCPP_STD_VER >= 20
337341
338342template <class _Iter>
339inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {
343[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
344_LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {
340345 return move_iterator<_Iter>(std::move(__i));
341346}
342347
lib/libcxx/include/__iterator/move_sentinel.h+5-5
......@@ -22,10 +22,10 @@
2222_LIBCPP_PUSH_MACROS
2323#include <__undef_macros>
2424
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2725#if _LIBCPP_STD_VER >= 20
2826
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2929template <semiregular _Sent>
3030class move_sentinel {
3131public:
......@@ -44,7 +44,7 @@ public:
4444 return *this;
4545 }
4646
47 _LIBCPP_HIDE_FROM_ABI constexpr _Sent base() const { return __last_; }
47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Sent base() const { return __last_; }
4848
4949private:
5050 _Sent __last_ = _Sent();
......@@ -52,10 +52,10 @@ private:
5252
5353_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(move_sentinel);
5454
55#endif // _LIBCPP_STD_VER >= 20
56
5755_LIBCPP_END_NAMESPACE_STD
5856
57#endif // _LIBCPP_STD_VER >= 20
58
5959_LIBCPP_POP_MACROS
6060
6161#endif // _LIBCPP___ITERATOR_MOVE_SENTINEL_H
lib/libcxx/include/__iterator/ostream_iterator.h+1-1
......@@ -59,7 +59,7 @@ public:
5959 return *this;
6060 }
6161
62 _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator*() { return *this; }
62 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator*() { return *this; }
6363 _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++() { return *this; }
6464 _LIBCPP_HIDE_FROM_ABI ostream_iterator& operator++(int) { return *this; }
6565};
lib/libcxx/include/__iterator/ostreambuf_iterator.h+25-2
......@@ -10,6 +10,8 @@
1010#ifndef _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
1111#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H
1212
13#include <__algorithm/in_out_result.h>
14#include <__algorithm/specialized_algorithms.h>
1315#include <__config>
1416#include <__cstddef/ptrdiff_t.h>
1517#include <__fwd/ios.h>
......@@ -17,6 +19,7 @@
1719#include <__fwd/streambuf.h>
1820#include <__iterator/iterator.h>
1921#include <__iterator/iterator_traits.h>
22#include <__type_traits/is_same.h>
2023#include <iosfwd> // for forward declaration of ostreambuf_iterator
2124
2225#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -54,16 +57,36 @@ public:
5457 __sbuf_ = nullptr;
5558 return *this;
5659 }
57 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator*() { return *this; }
60 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator*() { return *this; }
5861 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++() { return *this; }
5962 _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator& operator++(int) { return *this; }
60 _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool failed() const _NOEXCEPT { return __sbuf_ == nullptr; }
6164
6265#if _LIBCPP_HAS_LOCALIZATION
6366 template <class _Ch, class _Tr>
6467 friend _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_Ch, _Tr> __pad_and_output(
6568 ostreambuf_iterator<_Ch, _Tr> __s, const _Ch* __ob, const _Ch* __op, const _Ch* __oe, ios_base& __iob, _Ch __fl);
6669#endif // _LIBCPP_HAS_LOCALIZATION
70
71 template <class, class...>
72 friend struct __specialized_algorithm;
73};
74
75template <class _InCharT, class _CharT, class _Traits>
76struct __specialized_algorithm<_Algorithm::__copy,
77 __iterator_pair<_InCharT*, _InCharT*>,
78 __single_iterator<ostreambuf_iterator<_CharT, _Traits> > > {
79 static const bool __has_algorithm = is_same<const _CharT, const _InCharT>::value;
80
81 _LIBCPP_HIDE_FROM_ABI static __in_out_result<_InCharT*, ostreambuf_iterator<_CharT, _Traits> >
82 operator()(_InCharT* __first, _InCharT* __last, ostreambuf_iterator<_CharT, _Traits> __result) {
83 auto __size = __last - __first;
84 if (__result.__sbuf_ && __size > 0) {
85 if (__result.__sbuf_->sputn(__first, __last - __first) != __size)
86 __result.__sbuf_ = nullptr;
87 }
88 return {__last, __result};
89 }
6790};
6891
6992_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__iterator/ranges_iterator_traits.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 23
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <ranges::input_range _Range>
2727using __range_key_type _LIBCPP_NODEBUG = __remove_const_t<typename ranges::range_value_t<_Range>::first_type>;
2828
......@@ -33,8 +33,8 @@ template <ranges::input_range _Range>
3333using __range_to_alloc_type _LIBCPP_NODEBUG =
3434 pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>;
3535
36#endif
37
3836_LIBCPP_END_NAMESPACE_STD
3937
38#endif
39
4040#endif // _LIBCPP___ITERATOR_RANGES_ITERATOR_TRAITS_H
lib/libcxx/include/__iterator/readable_traits.h+5-5
......@@ -10,12 +10,12 @@
1010#ifndef _LIBCPP___ITERATOR_READABLE_TRAITS_H
1111#define _LIBCPP___ITERATOR_READABLE_TRAITS_H
1212
13#include <__concepts/primary_template.h>
1314#include <__concepts/same_as.h>
1415#include <__config>
1516#include <__type_traits/conditional.h>
1617#include <__type_traits/is_array.h>
1718#include <__type_traits/is_object.h>
18#include <__type_traits/is_primary_template.h>
1919#include <__type_traits/remove_cv.h>
2020#include <__type_traits/remove_cvref.h>
2121#include <__type_traits/remove_extent.h>
......@@ -24,10 +24,10 @@
2424# pragma GCC system_header
2525#endif
2626
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2927#if _LIBCPP_STD_VER >= 20
3028
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3131// [readable.traits]
3232template <class>
3333struct __cond_value_type {};
......@@ -74,8 +74,8 @@ template <__has_member_value_type _Tp>
7474 same_as<remove_cv_t<typename _Tp::element_type>, remove_cv_t<typename _Tp::value_type>>
7575struct indirectly_readable_traits<_Tp> : __cond_value_type<typename _Tp::value_type> {};
7676
77#endif // _LIBCPP_STD_VER >= 20
78
7977_LIBCPP_END_NAMESPACE_STD
8078
79#endif // _LIBCPP_STD_VER >= 20
80
8181#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H
lib/libcxx/include/__iterator/reverse_access.h+21-14
......@@ -18,62 +18,69 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 14
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525template <class _Tp, size_t _Np>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) {
26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
27_LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) {
2728 return reverse_iterator<_Tp*>(__array + _Np);
2829}
2930
3031template <class _Tp, size_t _Np>
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) {
32[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) {
3233 return reverse_iterator<_Tp*>(__array);
3334}
3435
3536template <class _Ep>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) {
37[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*>
38rbegin(initializer_list<_Ep> __il) {
3739 return reverse_iterator<const _Ep*>(__il.end());
3840}
3941
4042template <class _Ep>
41_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) {
43[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<const _Ep*>
44rend(initializer_list<_Ep> __il) {
4245 return reverse_iterator<const _Ep*>(__il.begin());
4346}
4447
4548template <class _Cp>
46_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) {
49[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) {
4750 return __c.rbegin();
4851}
4952
5053template <class _Cp>
51_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) {
54[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rbegin(const _Cp& __c)
55 -> decltype(__c.rbegin()) {
5256 return __c.rbegin();
5357}
5458
5559template <class _Cp>
56_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(_Cp& __c) -> decltype(__c.rend()) {
60[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(_Cp& __c) -> decltype(__c.rend()) {
5761 return __c.rend();
5862}
5963
6064template <class _Cp>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(const _Cp& __c) -> decltype(__c.rend()) {
65[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto rend(const _Cp& __c)
66 -> decltype(__c.rend()) {
6267 return __c.rend();
6368}
6469
6570template <class _Cp>
66_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crbegin(const _Cp& __c) -> decltype(std::rbegin(__c)) {
71[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crbegin(const _Cp& __c)
72 -> decltype(std::rbegin(__c)) {
6773 return std::rbegin(__c);
6874}
6975
7076template <class _Cp>
71_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crend(const _Cp& __c) -> decltype(std::rend(__c)) {
77[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto crend(const _Cp& __c)
78 -> decltype(std::rend(__c)) {
7279 return std::rend(__c);
7380}
7481
75#endif // _LIBCPP_STD_VER >= 14
76
7782_LIBCPP_END_NAMESPACE_STD
7883
84#endif // _LIBCPP_STD_VER >= 14
85
7986#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H
lib/libcxx/include/__iterator/reverse_iterator.h+16-30
......@@ -15,21 +15,13 @@
1515#include <__compare/three_way_comparable.h>
1616#include <__concepts/convertible_to.h>
1717#include <__config>
18#include <__iterator/advance.h>
1918#include <__iterator/concepts.h>
2019#include <__iterator/incrementable_traits.h>
2120#include <__iterator/iter_move.h>
2221#include <__iterator/iter_swap.h>
2322#include <__iterator/iterator.h>
2423#include <__iterator/iterator_traits.h>
25#include <__iterator/next.h>
26#include <__iterator/prev.h>
27#include <__iterator/readable_traits.h>
28#include <__iterator/segmented_iterator.h>
2924#include <__memory/addressof.h>
30#include <__ranges/access.h>
31#include <__ranges/concepts.h>
32#include <__ranges/subrange.h>
3325#include <__type_traits/conditional.h>
3426#include <__type_traits/enable_if.h>
3527#include <__type_traits/is_assignable.h>
......@@ -38,7 +30,6 @@
3830#include <__type_traits/is_pointer.h>
3931#include <__type_traits/is_same.h>
4032#include <__utility/declval.h>
41#include <__utility/move.h>
4233
4334#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4435# pragma GCC system_header
......@@ -121,8 +112,8 @@ public:
121112 return *this;
122113 }
123114#endif
124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter base() const { return current; }
125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {
115 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 _Iter base() const { return current; }
116 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator*() const {
126117 _Iter __tmp = current;
127118 return *--__tmp;
128119 }
......@@ -161,25 +152,29 @@ public:
161152 ++current;
162153 return __tmp;
163154 }
164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator operator+(difference_type __n) const {
155 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator
156 operator+(difference_type __n) const {
165157 return reverse_iterator(current - __n);
166158 }
167159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator+=(difference_type __n) {
168160 current -= __n;
169161 return *this;
170162 }
171 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator operator-(difference_type __n) const {
163 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator
164 operator-(difference_type __n) const {
172165 return reverse_iterator(current + __n);
173166 }
174167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator-=(difference_type __n) {
175168 current += __n;
176169 return *this;
177170 }
178 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](difference_type __n) const {
171 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference
172 operator[](difference_type __n) const {
179173 return *(*this + __n);
180174 }
181175
182176#if _LIBCPP_STD_VER >= 20
177 [[nodiscard]]
183178 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) noexcept(
184179 is_nothrow_copy_constructible_v<_Iter> && noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
185180 auto __tmp = __i.base();
......@@ -280,21 +275,21 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
280275
281276#ifndef _LIBCPP_CXX03_LANG
282277template <class _Iter1, class _Iter2>
283inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
284operator-(const reverse_iterator<_Iter1>& __x,
285 const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) {
278[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
279_LIBCPP_CONSTEXPR_SINCE_CXX17 auto operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
280 -> decltype(__y.base() - __x.base()) {
286281 return __y.base() - __x.base();
287282}
288283#else
289284template <class _Iter1, class _Iter2>
290inline _LIBCPP_HIDE_FROM_ABI typename reverse_iterator<_Iter1>::difference_type
285[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI typename reverse_iterator<_Iter1>::difference_type
291286operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) {
292287 return __y.base() - __x.base();
293288}
294289#endif
295290
296291template <class _Iter>
297inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter>
292[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter>
298293operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) {
299294 return reverse_iterator<_Iter>(__x.base() - __n);
300295}
......@@ -307,21 +302,12 @@ inline constexpr bool disable_sized_sentinel_for<reverse_iterator<_Iter1>, rever
307302
308303#if _LIBCPP_STD_VER >= 14
309304template <class _Iter>
310inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) {
305[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
306_LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) {
311307 return reverse_iterator<_Iter>(__i);
312308}
313309#endif
314310
315#if _LIBCPP_STD_VER >= 20
316template <ranges::bidirectional_range _Range>
317_LIBCPP_HIDE_FROM_ABI constexpr ranges::subrange<reverse_iterator<ranges::iterator_t<_Range>>,
318 reverse_iterator<ranges::iterator_t<_Range>>>
319__reverse_range(_Range&& __range) {
320 auto __first = ranges::begin(__range);
321 return {std::make_reverse_iterator(ranges::next(__first, ranges::end(__range))), std::make_reverse_iterator(__first)};
322}
323#endif
324
325311template <class _Iter, bool __b>
326312struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> {
327313 using _UnwrappedIter _LIBCPP_NODEBUG = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
lib/libcxx/include/__iterator/segmented_iterator.h-2
......@@ -42,8 +42,6 @@
4242
4343#include <__config>
4444#include <__cstddef/size_t.h>
45#include <__iterator/iterator_traits.h>
46#include <__type_traits/integral_constant.h>
4745
4846#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4947# pragma GCC system_header
lib/libcxx/include/__iterator/size.h+10-9
......@@ -20,25 +20,26 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 17
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727template <class _Cont>
28[[nodiscard]]
2829_LIBCPP_HIDE_FROM_ABI constexpr auto size(const _Cont& __c) noexcept(noexcept(__c.size())) -> decltype(__c.size()) {
2930 return __c.size();
3031}
3132
3233template <class _Tp, size_t _Sz>
33_LIBCPP_HIDE_FROM_ABI constexpr size_t size(const _Tp (&)[_Sz]) noexcept {
34[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t size(const _Tp (&)[_Sz]) noexcept {
3435 return _Sz;
3536}
3637
3738# if _LIBCPP_STD_VER >= 20
3839template <class _Cont>
39_LIBCPP_HIDE_FROM_ABI constexpr auto
40ssize(const _Cont& __c) noexcept(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(
41 __c.size()))) -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> {
40[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto ssize(const _Cont& __c) noexcept(
41 noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size())))
42 -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> {
4243 return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size());
4344}
4445
......@@ -47,14 +48,14 @@ ssize(const _Cont& __c) noexcept(noexcept(static_cast<common_type_t<ptrdiff_t, m
4748_LIBCPP_DIAGNOSTIC_PUSH
4849_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wsign-conversion")
4950template <class _Tp, ptrdiff_t _Sz>
50_LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept {
51[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept {
5152 return _Sz;
5253}
5354_LIBCPP_DIAGNOSTIC_POP
5455# endif
5556
56#endif // _LIBCPP_STD_VER >= 17
57
5857_LIBCPP_END_NAMESPACE_STD
5958
59#endif // _LIBCPP_STD_VER >= 17
60
6061#endif // _LIBCPP___ITERATOR_SIZE_H
lib/libcxx/include/__iterator/static_bounded_iter.h+7-6
......@@ -128,7 +128,7 @@ private:
128128
129129public:
130130 // Dereference and indexing operations.
131 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
131 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
132132 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
133133 __current() != __end(), "__static_bounded_iter::operator*: Attempt to dereference an iterator at the end");
134134 return *__current();
......@@ -140,7 +140,8 @@ public:
140140 return std::__to_address(__current());
141141 }
142142
143 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
143 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference
144 operator[](difference_type __n) const _NOEXCEPT {
144145 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
145146 __n >= __begin() - __current(),
146147 "__static_bounded_iter::operator[]: Attempt to index an iterator past the start");
......@@ -186,13 +187,13 @@ public:
186187 __current() += __n;
187188 return *this;
188189 }
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
190 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
190191 operator+(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT {
191192 __static_bounded_iter __tmp(__self);
192193 __tmp += __n;
193194 return __tmp;
194195 }
195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
196 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
196197 operator+(difference_type __n, __static_bounded_iter const& __self) _NOEXCEPT {
197198 __static_bounded_iter __tmp(__self);
198199 __tmp += __n;
......@@ -208,13 +209,13 @@ public:
208209 __current() -= __n;
209210 return *this;
210211 }
211 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
212 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend __static_bounded_iter
212213 operator-(__static_bounded_iter const& __self, difference_type __n) _NOEXCEPT {
213214 __static_bounded_iter __tmp(__self);
214215 __tmp -= __n;
215216 return __tmp;
216217 }
217 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
218 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 friend difference_type
218219 operator-(__static_bounded_iter const& __x, __static_bounded_iter const& __y) _NOEXCEPT {
219220 return __x.__current() - __y.__current();
220221 }
lib/libcxx/include/__iterator/wrap_iter.h+116-127
......@@ -15,7 +15,6 @@
1515#include <__config>
1616#include <__cstddef/size_t.h>
1717#include <__iterator/iterator_traits.h>
18#include <__memory/addressof.h>
1918#include <__memory/pointer_traits.h>
2019#include <__type_traits/conjunction.h>
2120#include <__type_traits/disjunction.h>
......@@ -34,18 +33,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3433template <class _Iter>
3534class __wrap_iter {
3635public:
37 typedef _Iter iterator_type;
38 typedef typename iterator_traits<iterator_type>::value_type value_type;
39 typedef typename iterator_traits<iterator_type>::difference_type difference_type;
40 typedef typename iterator_traits<iterator_type>::pointer pointer;
41 typedef typename iterator_traits<iterator_type>::reference reference;
42 typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
36 typedef typename iterator_traits<_Iter>::value_type value_type;
37 typedef typename iterator_traits<_Iter>::difference_type difference_type;
38 typedef typename iterator_traits<_Iter>::pointer pointer;
39 typedef typename iterator_traits<_Iter>::reference reference;
40 typedef typename iterator_traits<_Iter>::iterator_category iterator_category;
4341#if _LIBCPP_STD_VER >= 20
4442 typedef contiguous_iterator_tag iterator_concept;
4543#endif
4644
4745private:
48 iterator_type __i_;
46 _Iter __i_;
4947
5048public:
5149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter() _NOEXCEPT : __i_() {}
......@@ -57,7 +55,9 @@ public:
5755 int> = 0>
5856 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter(const __wrap_iter<_OtherIter>& __u) _NOEXCEPT
5957 : __i_(__u.__i_) {}
60 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT { return *__i_; }
58 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
59 return *__i_;
60 }
6161 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
6262 return std::__to_address(__i_);
6363 }
......@@ -80,7 +80,8 @@ public:
8080 --(*this);
8181 return __tmp;
8282 }
83 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator+(difference_type __n) const _NOEXCEPT {
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter
84 operator+(difference_type __n) const _NOEXCEPT {
8485 __wrap_iter __w(*this);
8586 __w += __n;
8687 return __w;
......@@ -89,21 +90,21 @@ public:
8990 __i_ += __n;
9091 return *this;
9192 }
92 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter operator-(difference_type __n) const _NOEXCEPT {
93 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter
94 operator-(difference_type __n) const _NOEXCEPT {
9395 return *this + (-__n);
9496 }
9597 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter& operator-=(difference_type __n) _NOEXCEPT {
9698 *this += -__n;
9799 return *this;
98100 }
99 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
101 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference
102 operator[](difference_type __n) const _NOEXCEPT {
100103 return __i_[__n];
101104 }
102105
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator_type base() const _NOEXCEPT { return __i_; }
104
105106private:
106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __wrap_iter(iterator_type __x) _NOEXCEPT : __i_(__x) {}
107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __wrap_iter(_Iter __x) _NOEXCEPT : __i_(__x) {}
107108
108109 template <class _Up>
109110 friend class __wrap_iter;
......@@ -117,137 +118,125 @@ private:
117118 friend class span;
118119 template <class _Tp, size_t _Size>
119120 friend struct array;
120 template <class _Tp, class>
121 friend struct __optional_iterator;
122};
123
124template <class _Iter1>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
126operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
127 return __x.base() == __y.base();
128}
129
130template <class _Iter1, class _Iter2>
131_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
132operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
133 return __x.base() == __y.base();
134}
135
136template <class _Iter1>
137_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
138operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
139 return __x.base() < __y.base();
140}
141
142template <class _Iter1, class _Iter2>
143_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
144operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
145 return __x.base() < __y.base();
146}
147121
148122#if _LIBCPP_STD_VER <= 17
149template <class _Iter1>
150_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
151operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
152 return !(__x == __y);
153}
154
155template <class _Iter1, class _Iter2>
156_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
157operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
158 return !(__x == __y);
159}
160template <class _Iter1>
161_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
162operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
163 return __y < __x;
164}
165
166template <class _Iter1, class _Iter2>
167_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
168operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
169 return __y < __x;
170}
171
172template <class _Iter1>
173_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
174operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
175 return !(__x < __y);
176}
177
178template <class _Iter1, class _Iter2>
179_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
180operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
181 return !(__x < __y);
182}
183
184template <class _Iter1>
185_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
186operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
187 return !(__y < __x);
188}
189
190template <class _Iter1, class _Iter2>
191_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
192operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
193 return !(__y < __x);
194}
123 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
124 operator==(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
125 return __x.__i_ == __y.__i_;
126 }
127
128 template <class _Iter2>
129 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
130 operator==(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
131 return __x.__i_ == __y.__i_;
132 }
133
134 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
135 operator<(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
136 return __x.__i_ < __y.__i_;
137 }
138
139 template <class _Iter2>
140 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
141 operator<(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
142 return __x.__i_ < __y.__i_;
143 }
144
145 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
146 operator!=(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
147 return !(__x == __y);
148 }
149
150 template <class _Iter2>
151 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
152 operator!=(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
153 return !(__x == __y);
154 }
155
156 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
157 operator>(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
158 return __y < __x;
159 }
160
161 template <class _Iter2>
162 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
163 operator>(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
164 return __y < __x;
165 }
166
167 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
168 operator>=(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
169 return !(__x < __y);
170 }
171
172 template <class _Iter2>
173 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
174 operator>=(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
175 return !(__x < __y);
176 }
177
178 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
179 operator<=(const __wrap_iter& __x, const __wrap_iter& __y) _NOEXCEPT {
180 return !(__y < __x);
181 }
182
183 template <class _Iter2>
184 _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR bool
185 operator<=(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
186 return !(__y < __x);
187 }
195188
196189#else
197template <class _Iter1, class _Iter2>
198_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
199operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
200 if constexpr (three_way_comparable_with<_Iter1, _Iter2, strong_ordering>) {
201 return __x.base() <=> __y.base();
202 } else {
203 if (__x.base() < __y.base())
204 return strong_ordering::less;
190 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __wrap_iter&, const __wrap_iter&) = default;
191
192 template <class _Iter2>
193 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
194 operator==(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) noexcept {
195 return __x.__i_ == __y.__i_;
196 }
205197
206 if (__x.base() == __y.base())
207 return strong_ordering::equal;
198 template <class _Iter2>
199 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering
200 operator<=>(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) noexcept {
201 if constexpr (three_way_comparable_with<_Iter, _Iter2, strong_ordering>) {
202 return __x.__i_ <=> __y.__i_;
203 } else {
204 if (__x.__i_ < __y.__i_)
205 return strong_ordering::less;
208206
209 return strong_ordering::greater;
207 if (__x.__i_ == __y.__i_)
208 return strong_ordering::equal;
209
210 return strong_ordering::greater;
211 }
210212 }
211}
212213#endif // _LIBCPP_STD_VER >= 20
213214
214template <class _Iter1, class _Iter2>
215_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
216215#ifndef _LIBCPP_CXX03_LANG
217 auto
218 operator-(const __wrap_iter<_Iter1>& __x,
219 const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base())
216 template <class _Iter2>
217 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 auto
218 operator-(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.__i_ - __y.__i_)
220219#else
221typename __wrap_iter<_Iter1>::difference_type
222operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
220 template <class _Iter2>
221 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14
222 typename __wrap_iter::difference_type operator-(const __wrap_iter& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
223223#endif // C++03
224{
225 return __x.base() - __y.base();
226}
224 {
225 return __x.__i_ - __y.__i_;
226 }
227227
228template <class _Iter1>
229_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter<_Iter1>
230operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT {
231 __x += __n;
232 return __x;
233}
228 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI friend _LIBCPP_CONSTEXPR_SINCE_CXX14 __wrap_iter
229 operator+(typename __wrap_iter::difference_type __n, __wrap_iter __x) _NOEXCEPT {
230 __x += __n;
231 return __x;
232 }
233};
234234
235235#if _LIBCPP_STD_VER <= 17
236236template <class _It>
237237struct __libcpp_is_contiguous_iterator<__wrap_iter<_It> > : true_type {};
238238#endif
239239
240template <class _It>
241struct pointer_traits<__wrap_iter<_It> > {
242 typedef __wrap_iter<_It> pointer;
243 typedef typename pointer_traits<_It>::element_type element_type;
244 typedef typename pointer_traits<_It>::difference_type difference_type;
245
246 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static element_type* to_address(pointer __w) _NOEXCEPT {
247 return std::__to_address(__w.base());
248 }
249};
250
251240_LIBCPP_END_NAMESPACE_STD
252241
253242#endif // _LIBCPP___ITERATOR_WRAP_ITER_H
lib/libcxx/include/__locale+104-72
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___LOCALE
1212
1313#include <__config>
14#include <__configuration/availability.h>
1415
1516#if _LIBCPP_HAS_LOCALIZATION
1617
......@@ -26,6 +27,7 @@
2627# include <cstdint>
2728# include <cstdlib>
2829# include <string>
30# include <text_encoding>
2931
3032// Some platforms require more includes than others. Keep the includes on all plaforms for now.
3133# include <cstddef>
......@@ -42,6 +44,7 @@
4244# endif
4345
4446_LIBCPP_BEGIN_NAMESPACE_STD
47_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4548
4649class _LIBCPP_EXPORTED_FROM_ABI locale;
4750
......@@ -88,7 +91,7 @@ public:
8891 const locale& operator=(const locale&) _NOEXCEPT;
8992
9093 template <class _Facet>
91 _LIBCPP_HIDE_FROM_ABI locale combine(const locale& __other) const {
94 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI locale combine(const locale& __other) const {
9295 if (!std::has_facet<_Facet>(__other))
9396 __throw_runtime_error("locale::combine: locale missing facet");
9497
......@@ -96,21 +99,29 @@ public:
9699 }
97100
98101 // locale operations:
99 string name() const;
102 [[__nodiscard__]] string name() const;
100103 bool operator==(const locale&) const;
101104# if _LIBCPP_STD_VER <= 17
102105 _LIBCPP_HIDE_FROM_ABI bool operator!=(const locale& __y) const { return !(*this == __y); }
103106# endif
104107 template <class _CharT, class _Traits, class _Allocator>
108 [[__nodiscard__]]
105109 _LIBCPP_HIDE_FROM_ABI bool operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
106110 const basic_string<_CharT, _Traits, _Allocator>& __y) const {
107111 return std::use_facet<std::collate<_CharT> >(*this).compare(
108112 __x.data(), __x.data() + __x.size(), __y.data(), __y.data() + __y.size()) < 0;
109113 }
114# if _LIBCPP_STD_VER >= 26
115 [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT
116 _LIBCPP_HIDE_FROM_ABI std::text_encoding encoding() const {
117 std::string __name = name();
118 return std::__get_locale_encoding(__name.c_str());
119 }
120# endif
110121
111122 // global locale objects:
112123 static locale global(const locale&);
113 static const locale& classic();
124 [[__nodiscard__]] static const locale& classic();
114125
115126private:
116127 class __imp;
......@@ -118,6 +129,9 @@ private:
118129
119130 template <class>
120131 friend struct __no_destroy;
132
133 friend ios_base;
134
121135 _LIBCPP_HIDE_FROM_ABI explicit locale(__private_constructor_tag, __imp* __loc) : __locale_(__loc) {}
122136
123137 void __install_ctor(const locale&, facet*, long);
......@@ -168,12 +182,12 @@ inline _LIBCPP_HIDE_FROM_ABI locale::locale(const locale& __other, _Facet* __f)
168182}
169183
170184template <class _Facet>
171inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT {
185[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool has_facet(const locale& __l) _NOEXCEPT {
172186 return __l.has_facet(_Facet::id);
173187}
174188
175189template <class _Facet>
176inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) {
190[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale& __l) {
177191 return static_cast<const _Facet&>(*__l.use_facet(_Facet::id));
178192}
179193
......@@ -187,19 +201,21 @@ public:
187201
188202 _LIBCPP_HIDE_FROM_ABI explicit collate(size_t __refs = 0) : locale::facet(__refs) {}
189203
190 _LIBCPP_HIDE_FROM_ABI int
204 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int
191205 compare(const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {
192206 return do_compare(__lo1, __hi1, __lo2, __hi2);
193207 }
194208
195209 // FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work
196210 // around a dllimport bug that expects an external instantiation.
197 _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE string_type
211 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE string_type
198212 transform(const char_type* __lo, const char_type* __hi) const {
199213 return do_transform(__lo, __hi);
200214 }
201215
202 _LIBCPP_HIDE_FROM_ABI long hash(const char_type* __lo, const char_type* __hi) const { return do_hash(__lo, __hi); }
216 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI long hash(const char_type* __lo, const char_type* __hi) const {
217 return do_hash(__lo, __hi);
218 }
203219
204220 static locale::id id;
205221
......@@ -318,6 +334,8 @@ public:
318334# endif // defined(__BIONIC__)
319335# elif defined(__GLIBC__)
320336 typedef unsigned short mask;
337 _LIBCPP_DIAGNOSTIC_PUSH
338 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmodules-ambiguous-internal-linkage")
321339 static const mask space = _ISspace;
322340 static const mask print = _ISprint;
323341 static const mask cntrl = _IScntrl;
......@@ -328,6 +346,7 @@ public:
328346 static const mask punct = _ISpunct;
329347 static const mask xdigit = _ISxdigit;
330348 static const mask blank = _ISblank;
349 _LIBCPP_DIAGNOSTIC_POP
331350# if defined(__mips__) || (BYTE_ORDER == BIG_ENDIAN)
332351 static const mask __regex_word = static_cast<mask>(_ISbit(15));
333352# else
......@@ -459,39 +478,43 @@ public:
459478
460479 _LIBCPP_HIDE_FROM_ABI explicit ctype(size_t __refs = 0) : locale::facet(__refs) {}
461480
462 _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const { return do_is(__m, __c); }
481 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const { return do_is(__m, __c); }
463482
464483 _LIBCPP_HIDE_FROM_ABI const char_type* is(const char_type* __low, const char_type* __high, mask* __vec) const {
465484 return do_is(__low, __high, __vec);
466485 }
467486
468 _LIBCPP_HIDE_FROM_ABI const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const {
487 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char_type*
488 scan_is(mask __m, const char_type* __low, const char_type* __high) const {
469489 return do_scan_is(__m, __low, __high);
470490 }
471491
472 _LIBCPP_HIDE_FROM_ABI const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const {
492 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char_type*
493 scan_not(mask __m, const char_type* __low, const char_type* __high) const {
473494 return do_scan_not(__m, __low, __high);
474495 }
475496
476 _LIBCPP_HIDE_FROM_ABI char_type toupper(char_type __c) const { return do_toupper(__c); }
497 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type toupper(char_type __c) const { return do_toupper(__c); }
477498
478499 _LIBCPP_HIDE_FROM_ABI const char_type* toupper(char_type* __low, const char_type* __high) const {
479500 return do_toupper(__low, __high);
480501 }
481502
482 _LIBCPP_HIDE_FROM_ABI char_type tolower(char_type __c) const { return do_tolower(__c); }
503 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type tolower(char_type __c) const { return do_tolower(__c); }
483504
484505 _LIBCPP_HIDE_FROM_ABI const char_type* tolower(char_type* __low, const char_type* __high) const {
485506 return do_tolower(__low, __high);
486507 }
487508
488 _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const { return do_widen(__c); }
509 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const { return do_widen(__c); }
489510
490511 _LIBCPP_HIDE_FROM_ABI const char* widen(const char* __low, const char* __high, char_type* __to) const {
491512 return do_widen(__low, __high, __to);
492513 }
493514
494 _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const { return do_narrow(__c, __dfault); }
515 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const {
516 return do_narrow(__c, __dfault);
517 }
495518
496519 _LIBCPP_HIDE_FROM_ABI const char_type*
497520 narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const {
......@@ -530,7 +553,7 @@ public:
530553
531554 explicit ctype(const mask* __tab = nullptr, bool __del = false, size_t __refs = 0);
532555
533 _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const {
556 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool is(mask __m, char_type __c) const {
534557 return std::__libcpp_isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) != 0 : false;
535558 }
536559
......@@ -540,39 +563,43 @@ public:
540563 return __low;
541564 }
542565
543 _LIBCPP_HIDE_FROM_ABI const char_type* scan_is(mask __m, const char_type* __low, const char_type* __high) const {
566 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char_type*
567 scan_is(mask __m, const char_type* __low, const char_type* __high) const {
544568 for (; __low != __high; ++__low)
545569 if (std::__libcpp_isascii(*__low) && (__tab_[static_cast<int>(*__low)] & __m))
546570 break;
547571 return __low;
548572 }
549573
550 _LIBCPP_HIDE_FROM_ABI const char_type* scan_not(mask __m, const char_type* __low, const char_type* __high) const {
574 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const char_type*
575 scan_not(mask __m, const char_type* __low, const char_type* __high) const {
551576 for (; __low != __high; ++__low)
552577 if (!std::__libcpp_isascii(*__low) || !(__tab_[static_cast<int>(*__low)] & __m))
553578 break;
554579 return __low;
555580 }
556581
557 _LIBCPP_HIDE_FROM_ABI char_type toupper(char_type __c) const { return do_toupper(__c); }
582 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type toupper(char_type __c) const { return do_toupper(__c); }
558583
559584 _LIBCPP_HIDE_FROM_ABI const char_type* toupper(char_type* __low, const char_type* __high) const {
560585 return do_toupper(__low, __high);
561586 }
562587
563 _LIBCPP_HIDE_FROM_ABI char_type tolower(char_type __c) const { return do_tolower(__c); }
588 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type tolower(char_type __c) const { return do_tolower(__c); }
564589
565590 _LIBCPP_HIDE_FROM_ABI const char_type* tolower(char_type* __low, const char_type* __high) const {
566591 return do_tolower(__low, __high);
567592 }
568593
569 _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const { return do_widen(__c); }
594 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const { return do_widen(__c); }
570595
571596 _LIBCPP_HIDE_FROM_ABI const char* widen(const char* __low, const char* __high, char_type* __to) const {
572597 return do_widen(__low, __high, __to);
573598 }
574599
575 _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const { return do_narrow(__c, __dfault); }
600 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const {
601 return do_narrow(__c, __dfault);
602 }
576603
577604 _LIBCPP_HIDE_FROM_ABI const char*
578605 narrow(const char_type* __low, const char_type* __high, char __dfault, char* __to) const {
......@@ -586,8 +613,8 @@ public:
586613# else
587614 static const size_t table_size = 256;
588615# endif
589 _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; }
590 static const mask* classic_table() _NOEXCEPT;
616 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mask* table() const _NOEXCEPT { return __tab_; }
617 [[__nodiscard__]] static const mask* classic_table() _NOEXCEPT;
591618
592619protected:
593620 ~ctype() override;
......@@ -650,72 +677,72 @@ protected:
650677# endif // _LIBCPP_HAS_WIDE_CHARACTERS
651678
652679template <class _CharT>
653inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {
680[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isspace(_CharT __c, const locale& __loc) {
654681 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::space, __c);
655682}
656683
657684template <class _CharT>
658inline _LIBCPP_HIDE_FROM_ABI bool isprint(_CharT __c, const locale& __loc) {
685[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isprint(_CharT __c, const locale& __loc) {
659686 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::print, __c);
660687}
661688
662689template <class _CharT>
663inline _LIBCPP_HIDE_FROM_ABI bool iscntrl(_CharT __c, const locale& __loc) {
690[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool iscntrl(_CharT __c, const locale& __loc) {
664691 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::cntrl, __c);
665692}
666693
667694template <class _CharT>
668inline _LIBCPP_HIDE_FROM_ABI bool isupper(_CharT __c, const locale& __loc) {
695[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isupper(_CharT __c, const locale& __loc) {
669696 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::upper, __c);
670697}
671698
672699template <class _CharT>
673inline _LIBCPP_HIDE_FROM_ABI bool islower(_CharT __c, const locale& __loc) {
700[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool islower(_CharT __c, const locale& __loc) {
674701 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::lower, __c);
675702}
676703
677704template <class _CharT>
678inline _LIBCPP_HIDE_FROM_ABI bool isalpha(_CharT __c, const locale& __loc) {
705[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isalpha(_CharT __c, const locale& __loc) {
679706 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alpha, __c);
680707}
681708
682709template <class _CharT>
683inline _LIBCPP_HIDE_FROM_ABI bool isdigit(_CharT __c, const locale& __loc) {
710[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isdigit(_CharT __c, const locale& __loc) {
684711 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::digit, __c);
685712}
686713
687714template <class _CharT>
688inline _LIBCPP_HIDE_FROM_ABI bool ispunct(_CharT __c, const locale& __loc) {
715[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool ispunct(_CharT __c, const locale& __loc) {
689716 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::punct, __c);
690717}
691718
692719template <class _CharT>
693inline _LIBCPP_HIDE_FROM_ABI bool isxdigit(_CharT __c, const locale& __loc) {
720[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isxdigit(_CharT __c, const locale& __loc) {
694721 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::xdigit, __c);
695722}
696723
697724template <class _CharT>
698inline _LIBCPP_HIDE_FROM_ABI bool isalnum(_CharT __c, const locale& __loc) {
725[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isalnum(_CharT __c, const locale& __loc) {
699726 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::alnum, __c);
700727}
701728
702729template <class _CharT>
703inline _LIBCPP_HIDE_FROM_ABI bool isgraph(_CharT __c, const locale& __loc) {
730[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI bool isgraph(_CharT __c, const locale& __loc) {
704731 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::graph, __c);
705732}
706733
707734template <class _CharT>
708_LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) {
735[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool isblank(_CharT __c, const locale& __loc) {
709736 return std::use_facet<ctype<_CharT> >(__loc).is(ctype_base::blank, __c);
710737}
711738
712739template <class _CharT>
713inline _LIBCPP_HIDE_FROM_ABI _CharT toupper(_CharT __c, const locale& __loc) {
740[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _CharT toupper(_CharT __c, const locale& __loc) {
714741 return std::use_facet<ctype<_CharT> >(__loc).toupper(__c);
715742}
716743
717744template <class _CharT>
718inline _LIBCPP_HIDE_FROM_ABI _CharT tolower(_CharT __c, const locale& __loc) {
745[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _CharT tolower(_CharT __c, const locale& __loc) {
719746 return std::use_facet<ctype<_CharT> >(__loc).tolower(__c);
720747}
721748
......@@ -770,16 +797,16 @@ public:
770797 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
771798 }
772799
773 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
800 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
774801
775 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
802 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
776803
777804 _LIBCPP_HIDE_FROM_ABI int
778805 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
779806 return do_length(__st, __frm, __end, __mx);
780807 }
781808
782 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
809 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
783810
784811 static locale::id id;
785812
......@@ -852,16 +879,16 @@ public:
852879 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
853880 }
854881
855 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
882 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
856883
857 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
884 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
858885
859886 _LIBCPP_HIDE_FROM_ABI int
860887 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
861888 return do_length(__st, __frm, __end, __mx);
862889 }
863890
864 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
891 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
865892
866893 static locale::id id;
867894
......@@ -933,16 +960,16 @@ public:
933960 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
934961 }
935962
936 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
963 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
937964
938 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
965 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
939966
940967 _LIBCPP_HIDE_FROM_ABI int
941968 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
942969 return do_length(__st, __frm, __end, __mx);
943970 }
944971
945 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
972 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
946973
947974 static locale::id id;
948975
......@@ -976,10 +1003,11 @@ protected:
9761003
9771004# if _LIBCPP_HAS_CHAR8_T
9781005
979// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20
1006// template <> class codecvt<char16_t, char8_t, mbstate_t> // C++20, deprecated in C++20
9801007
9811008template <>
982class _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t> : public locale::facet, public codecvt_base {
1009class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char16_t, char8_t, mbstate_t>
1010 : public locale::facet, public codecvt_base {
9831011public:
9841012 typedef char16_t intern_type;
9851013 typedef char8_t extern_type;
......@@ -1014,16 +1042,16 @@ public:
10141042 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
10151043 }
10161044
1017 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
1045 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
10181046
1019 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
1047 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
10201048
10211049 _LIBCPP_HIDE_FROM_ABI int
10221050 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
10231051 return do_length(__st, __frm, __end, __mx);
10241052 }
10251053
1026 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
1054 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
10271055
10281056 static locale::id id;
10291057
......@@ -1096,16 +1124,16 @@ public:
10961124 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
10971125 }
10981126
1099 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
1127 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
11001128
1101 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
1129 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
11021130
11031131 _LIBCPP_HIDE_FROM_ABI int
11041132 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
11051133 return do_length(__st, __frm, __end, __mx);
11061134 }
11071135
1108 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
1136 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
11091137
11101138 static locale::id id;
11111139
......@@ -1139,10 +1167,11 @@ protected:
11391167
11401168# if _LIBCPP_HAS_CHAR8_T
11411169
1142// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20
1170// template <> class codecvt<char32_t, char8_t, mbstate_t> // C++20, deprecated in C++20
11431171
11441172template <>
1145class _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t> : public locale::facet, public codecvt_base {
1173class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXPORTED_FROM_ABI codecvt<char32_t, char8_t, mbstate_t>
1174 : public locale::facet, public codecvt_base {
11461175public:
11471176 typedef char32_t intern_type;
11481177 typedef char8_t extern_type;
......@@ -1177,16 +1206,16 @@ public:
11771206 return do_in(__st, __frm, __frm_end, __frm_nxt, __to, __to_end, __to_nxt);
11781207 }
11791208
1180 _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
1209 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int encoding() const _NOEXCEPT { return do_encoding(); }
11811210
1182 _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
1211 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool always_noconv() const _NOEXCEPT { return do_always_noconv(); }
11831212
11841213 _LIBCPP_HIDE_FROM_ABI int
11851214 length(state_type& __st, const extern_type* __frm, const extern_type* __end, size_t __mx) const {
11861215 return do_length(__st, __frm, __end, __mx);
11871216 }
11881217
1189 _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
1218 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI int max_length() const _NOEXCEPT { return do_max_length(); }
11901219
11911220 static locale::id id;
11921221
......@@ -1248,8 +1277,10 @@ _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // d
12481277extern template class _LIBCPP_DEPRECATED_IN_CXX20
12491278_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
12501279# if _LIBCPP_HAS_CHAR8_T
1251extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
1252extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
1280extern template class _LIBCPP_DEPRECATED_IN_CXX20
1281_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20, deprecated in C++20
1282extern template class _LIBCPP_DEPRECATED_IN_CXX20
1283_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20, deprecated in C++20
12531284# endif
12541285
12551286template <size_t _Np>
......@@ -1409,11 +1440,11 @@ public:
14091440
14101441 explicit numpunct(size_t __refs = 0);
14111442
1412 _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
1413 _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
1414 _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
1415 _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
1416 _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
1443 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
1444 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
1445 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
1446 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
1447 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
14171448
14181449 static locale::id id;
14191450
......@@ -1439,11 +1470,11 @@ public:
14391470
14401471 explicit numpunct(size_t __refs = 0);
14411472
1442 _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
1443 _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
1444 _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
1445 _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
1446 _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
1473 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
1474 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
1475 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
1476 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type truename() const { return do_truename(); }
1477 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type falsename() const { return do_falsename(); }
14471478
14481479 static locale::id id;
14491480
......@@ -1494,6 +1525,7 @@ protected:
14941525};
14951526# endif // _LIBCPP_HAS_WIDE_CHARACTERS
14961527
1528_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
14971529_LIBCPP_END_NAMESPACE_STD
14981530
14991531#endif // _LIBCPP_HAS_LOCALIZATION
lib/libcxx/include/__locale_dir/check_grouping.h+2
......@@ -20,10 +20,12 @@
2020# endif
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
23_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2324
2425_LIBCPP_EXPORTED_FROM_ABI void
2526__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err);
2627
28_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2729_LIBCPP_END_NAMESPACE_STD
2830
2931#endif // _LIBCPP_HAS_LOCALIZATION
lib/libcxx/include/__locale_dir/get_c_locale.h+2
......@@ -29,7 +29,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929# else
3030# define _LIBCPP_GET_C_LOCALE __cloc()
3131// Get the C locale object
32_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3233_LIBCPP_EXPORTED_FROM_ABI __locale::__locale_t __cloc();
34_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3335# define __cloc_defined
3436# endif
3537
lib/libcxx/include/__locale_dir/locale_base_api.h+16-8
......@@ -102,6 +102,8 @@
102102//
103103// int __snprintf(char*, size_t, __locale_t, const char*, ...); // required by the headers
104104// int __asprintf(char**, __locale_t, const char*, ...); // required by the headers
105//
106// const char* __get_locale_encoding(__locale_t);
105107// }
106108
107109#if _LIBCPP_HAS_LOCALIZATION
......@@ -112,10 +114,14 @@
112114# include <__locale_dir/support/freebsd.h>
113115# elif defined(__NetBSD__)
114116# include <__locale_dir/support/netbsd.h>
117# elif defined(__OpenBSD__)
118# include <__locale_dir/support/openbsd.h>
115119# elif defined(_LIBCPP_MSVCRT_LIKE)
116120# include <__locale_dir/support/windows.h>
117121# elif defined(__Fuchsia__)
118122# include <__locale_dir/support/fuchsia.h>
123# elif _LIBCPP_LIBC_LLVM_LIBC
124# include <__locale_dir/support/llvm_libc.h>
119125# elif defined(__linux__)
120126# include <__locale_dir/support/linux.h>
121127# elif _LIBCPP_LIBC_NEWLIB
......@@ -128,17 +134,14 @@
128134// (by providing global non-reserved names) and the new API. As we move individual platforms
129135// towards the new way of defining the locale base API, this should disappear since each platform
130136// will define those directly.
131# if defined(__MVS__)
132# include <__locale_dir/locale_base_api/ibm.h>
133# elif defined(__OpenBSD__)
134# include <__locale_dir/locale_base_api/openbsd.h>
135# endif
137# include <__locale_dir/locale_base_api/ibm.h>
136138
137139# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
138140
139141# include <__cstddef/size_t.h>
140142# include <__utility/forward.h>
141143# include <ctype.h>
144# include <langinfo.h>
142145# include <string.h>
143146# include <time.h>
144147# if _LIBCPP_HAS_WIDE_CHARACTERS
......@@ -228,8 +231,8 @@ inline _LIBCPP_HIDE_FROM_ABI wint_t __towupper(wint_t __ch, __locale_t __loc) {
228231inline _LIBCPP_HIDE_FROM_ABI wint_t __towlower(wint_t __ch, __locale_t __loc) { return towlower_l(__ch, __loc); }
229232# endif
230233
231inline _LIBCPP_HIDE_FROM_ABI size_t
232__strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {
234inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
235 __strftime(char* __s, size_t __max, const char* __format, const tm* __tm, __locale_t __loc) {
233236 return strftime_l(__s, __max, __format, __tm, __loc);
234237}
235238
......@@ -268,7 +271,12 @@ __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps,
268271 return __libcpp_mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
269272}
270273# endif // _LIBCPP_HAS_WIDE_CHARACTERS
271# endif // _LIBCPP_BUILDING_LIBRARY
274
275inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
276 return ::nl_langinfo_l(CODESET, __loc);
277}
278
279# endif // _LIBCPP_BUILDING_LIBRARY
272280
273281_LIBCPP_DIAGNOSTIC_PUSH
274282_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
lib/libcxx/include/__locale_dir/locale_base_api/android.h deleted-45
......@@ -1,45 +0,0 @@
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___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
12
13#include <stdlib.h>
14
15// FIXME: Is this actually required?
16extern "C" {
17#include <xlocale.h>
18}
19
20#include <android/api-level.h>
21
22// If we do not have this header, we are in a platform build rather than an NDK
23// build, which will always be at least as new as the ToT NDK, in which case we
24// don't need any of the inlines below since libc provides them.
25#if __has_include(<android/ndk-version.h>)
26# include <android/ndk-version.h>
27// In NDK versions later than 16, locale-aware functions are provided by
28// legacy_stdlib_inlines.h
29# if __NDK_MAJOR__ <= 16
30# if __ANDROID_API__ < 26
31
32inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
33 return ::strtof(__nptr, __endptr);
34}
35
36inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
37 return ::strtod(__nptr, __endptr);
38}
39
40# endif // __ANDROID_API__ < 26
41
42# endif // __NDK_MAJOR__ <= 16
43#endif // __has_include(<android/ndk-version.h>)
44
45#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_ANDROID_H
lib/libcxx/include/__locale_dir/locale_base_api/ibm.h created+97
......@@ -0,0 +1,97 @@
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___LOCALE_DIR_LOCALE_BASE_API_IBM_H
11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H
12
13#if defined(__MVS__)
14# include <__support/ibm/locale_mgmt_zos.h>
15#endif // defined(__MVS__)
16
17#include <locale.h>
18#include <stdarg.h>
19#include <stdio.h>
20
21#include "cstdlib"
22
23#if defined(__MVS__)
24# include <wctype.h>
25// POSIX routines
26# include <__support/xlocale/__posix_l_fallback.h>
27#endif // defined(__MVS__)
28
29namespace {
30
31struct __setAndRestore {
32 explicit __setAndRestore(locale_t locale) {
33 if (locale == (locale_t)0) {
34 __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
35 __stored = uselocale(__cloc);
36 } else {
37 __stored = uselocale(locale);
38 }
39 }
40
41 ~__setAndRestore() {
42 uselocale(__stored);
43 if (__cloc)
44 freelocale(__cloc);
45 }
46
47private:
48 locale_t __stored = (locale_t)0;
49 locale_t __cloc = (locale_t)0;
50};
51
52} // namespace
53
54// The following are not POSIX routines. These are quick-and-dirty hacks
55// to make things pretend to work
56inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
57 __setAndRestore __newloc(locale);
58 return ::strtod(__nptr, __endptr);
59}
60
61inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) {
62 __setAndRestore __newloc(locale);
63 return ::strtof(__nptr, __endptr);
64}
65
66inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) {
67 __setAndRestore __newloc(locale);
68 return ::strtold(__nptr, __endptr);
69}
70
71inline _LIBCPP_HIDE_FROM_ABI
72_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
73 const size_t buff_size = 256;
74 if ((*strp = (char*)malloc(buff_size)) == nullptr) {
75 return -1;
76 }
77
78 va_list ap_copy;
79 // va_copy may not be provided by the C library in C++03 mode.
80#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
81 __builtin_va_copy(ap_copy, ap);
82#else
83 va_copy(ap_copy, ap);
84#endif
85 int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
86 va_end(ap_copy);
87
88 if ((size_t)str_size >= buff_size) {
89 if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
90 return -1;
91 }
92 str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
93 }
94 return str_size;
95}
96
97#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_IBM_H
lib/libcxx/include/__locale_dir/locale_base_api/musl.h deleted-31
......@@ -1,31 +0,0 @@
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// This adds support for the extended locale functions that are currently
10// missing from the Musl C library.
11//
12// This only works when the specified locale is "C" or "POSIX", but that's
13// about as good as we can do without implementing full xlocale support
14// in Musl.
15//===----------------------------------------------------------------------===//
16
17#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
18#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
19
20#include <cstdlib>
21#include <cwchar>
22
23inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
24 return ::strtoll(__nptr, __endptr, __base);
25}
26
27inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
28 return ::strtoull(__nptr, __endptr, __base);
29}
30
31#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_MUSL_H
lib/libcxx/include/__locale_dir/locale_base_api/openbsd.h deleted-19
......@@ -1,19 +0,0 @@
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___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
12
13#include <__support/xlocale/__strtonum_fallback.h>
14#include <clocale>
15#include <cstdlib>
16#include <ctype.h>
17#include <cwctype>
18
19#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
lib/libcxx/include/__locale_dir/messages.h+5-2
......@@ -33,6 +33,7 @@
3333# endif
3434
3535_LIBCPP_BEGIN_NAMESPACE_STD
36_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3637
3738class _LIBCPP_EXPORTED_FROM_ABI messages_base {
3839public:
......@@ -49,11 +50,12 @@ public:
4950
5051 _LIBCPP_HIDE_FROM_ABI explicit messages(size_t __refs = 0) : locale::facet(__refs) {}
5152
52 _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const {
53 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI catalog open(const basic_string<char>& __nm, const locale& __loc) const {
5354 return do_open(__nm, __loc);
5455 }
5556
56 _LIBCPP_HIDE_FROM_ABI string_type get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
57 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type
58 get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
5759 return do_get(__c, __set, __msgid, __dflt);
5860 }
5961
......@@ -136,6 +138,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
136138extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
137139# endif
138140
141_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
139142_LIBCPP_END_NAMESPACE_STD
140143
141144#endif // _LIBCPP_HAS_LOCALIZATION
lib/libcxx/include/__locale_dir/money.h+11-9
......@@ -32,6 +32,7 @@ _LIBCPP_PUSH_MACROS
3232# include <__undef_macros>
3333
3434_LIBCPP_BEGIN_NAMESPACE_STD
35_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3536
3637// money_base
3738
......@@ -55,15 +56,15 @@ public:
5556
5657 _LIBCPP_HIDE_FROM_ABI explicit moneypunct(size_t __refs = 0) : locale::facet(__refs) {}
5758
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(); }
59 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type decimal_point() const { return do_decimal_point(); }
60 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI char_type thousands_sep() const { return do_thousands_sep(); }
61 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string grouping() const { return do_grouping(); }
62 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type curr_symbol() const { return do_curr_symbol(); }
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type positive_sign() const { return do_positive_sign(); }
64 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI string_type negative_sign() const { return do_negative_sign(); }
65 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI int frac_digits() const { return do_frac_digits(); }
66 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pattern pos_format() const { return do_pos_format(); }
67 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pattern neg_format() const { return do_neg_format(); }
6768
6869 static locale::id id;
6970 static const bool intl = _International;
......@@ -864,6 +865,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
864865extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
865866# endif
866867
868_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
867869_LIBCPP_END_NAMESPACE_STD
868870
869871_LIBCPP_POP_MACROS
lib/libcxx/include/__locale_dir/num.h+3-2
......@@ -42,6 +42,7 @@ _LIBCPP_PUSH_MACROS
4242# include <__undef_macros>
4343
4444_LIBCPP_BEGIN_NAMESPACE_STD
45_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4546
4647struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base {
4748 static const int __num_get_buf_sz = 40;
......@@ -95,9 +96,8 @@ struct __num_get : protected __num_get_base {
9596 _LIBCPP_DIAGNOSTIC_PUSH
9697 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wpsabi")
9798 using __vec = __simd_vector<char, 32>;
98 __vec __chars = std::__broadcast<__vec>(__val);
9999 __vec __cmp = std::__partial_load<__vec, __int_chr_cnt>(__atoms);
100 auto __res = __chars == __cmp;
100 auto __res = __vec(__val) == __cmp;
101101 if (std::__none_of(__res))
102102 return __int_chr_cnt;
103103 return std::min(__int_chr_cnt, std::__find_first_set(__res));
......@@ -1008,6 +1008,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
10081008extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
10091009# endif
10101010
1011_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
10111012_LIBCPP_END_NAMESPACE_STD
10121013
10131014_LIBCPP_POP_MACROS
lib/libcxx/include/__locale_dir/pad_and_output.h+2-14
......@@ -55,13 +55,7 @@ _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
5555 __ns -= __sz;
5656 else
5757 __ns = 0;
58 streamsize __np = __op - __ob;
59 if (__np > 0) {
60 if (__s.__sbuf_->sputn(__ob, __np) != __np) {
61 __s.__sbuf_ = nullptr;
62 return __s;
63 }
64 }
58 __s = std::copy(__ob, __op, __s);
6559 if (__ns > 0) {
6660 basic_string<_CharT, _Traits> __sp(__ns, __fl);
6761 if (__s.__sbuf_->sputn(__sp.data(), __ns) != __ns) {
......@@ -69,13 +63,7 @@ _LIBCPP_HIDE_FROM_ABI ostreambuf_iterator<_CharT, _Traits> __pad_and_output(
6963 return __s;
7064 }
7165 }
72 __np = __oe - __op;
73 if (__np > 0) {
74 if (__s.__sbuf_->sputn(__op, __np) != __np) {
75 __s.__sbuf_ = nullptr;
76 return __s;
77 }
78 }
66 __s = std::copy(__op, __oe, __s);
7967 __iob.width(0);
8068 return __s;
8169}
lib/libcxx/include/__locale_dir/support/bsd_like.h+8-3
......@@ -15,6 +15,7 @@
1515#include <__utility/forward.h>
1616#include <clocale> // std::lconv
1717#include <ctype.h>
18#include <langinfo.h>
1819#include <stdio.h>
1920#include <stdlib.h>
2021#include <string.h>
......@@ -133,8 +134,8 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __
133134}
134135# endif // _LIBCPP_HAS_WIDE_CHARACTERS
135136
136inline _LIBCPP_HIDE_FROM_ABI size_t
137__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
137inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
138 __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
138139 return ::strftime_l(__s, __max, __format, __tm, __loc);
139140}
140141
......@@ -180,7 +181,11 @@ __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps,
180181 return ::mbsrtowcs_l(__dest, __src, __len, __ps, __loc);
181182}
182183# endif // _LIBCPP_HAS_WIDE_CHARACTERS
183#endif // _LIBCPP_BUILDING_LIBRARY
184
185inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
186 return ::nl_langinfo_l(CODESET, __loc);
187}
188#endif // _LIBCPP_BUILDING_LIBRARY
184189
185190_LIBCPP_DIAGNOSTIC_PUSH
186191_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
lib/libcxx/include/__locale_dir/support/fuchsia.h+5
......@@ -15,6 +15,7 @@
1515#include <cstdio>
1616#include <cstdlib>
1717#include <cwchar>
18#include <langinfo.h>
1819
1920#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2021# pragma GCC system_header
......@@ -69,6 +70,10 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
6970 return std::localeconv();
7071}
7172
73inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
74 return ::nl_langinfo_l(CODESET, __loc);
75}
76
7277//
7378// Other functions
7479//
lib/libcxx/include/__locale_dir/support/linux.h+12-3
......@@ -17,6 +17,7 @@
1717#include <cstdio>
1818#include <cstdlib>
1919#include <ctype.h>
20#include <langinfo.h>
2021#include <stdarg.h>
2122#include <string.h>
2223#include <time.h>
......@@ -148,8 +149,8 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __
148149}
149150# endif // _LIBCPP_HAS_WIDE_CHARACTERS
150151
151inline _LIBCPP_HIDE_FROM_ABI size_t
152__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
152inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
153 __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
153154 return strftime_l(__s, __max, __format, __tm, __loc);
154155}
155156
......@@ -211,7 +212,15 @@ __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps,
211212 return std::mbsrtowcs(__dest, __src, __len, __ps);
212213}
213214# endif // _LIBCPP_HAS_WIDE_CHARACTERS
214#endif // _LIBCPP_BUILDING_LIBRARY
215
216inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding([[maybe_unused]] __locale_t __loc) {
217# if defined(__ANDROID__)
218 return "UTF-8";
219# else
220 return ::nl_langinfo_l(CODESET, __loc);
221# endif
222}
223#endif // _LIBCPP_BUILDING_LIBRARY
215224
216225#ifndef _LIBCPP_COMPILER_GCC // GCC complains that this can't be always_inline due to C-style varargs
217226_LIBCPP_HIDE_FROM_ABI
lib/libcxx/include/__locale_dir/support/newlib.h+7-2
......@@ -16,6 +16,7 @@
1616#include <cstdio>
1717#include <cstdlib>
1818#include <ctype.h>
19#include <langinfo.h>
1920#include <stdarg.h>
2021#include <string.h>
2122#include <time.h>
......@@ -76,6 +77,10 @@ inline _LIBCPP_HIDE_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc) {
7677 __locale_guard __current(__loc);
7778 return std::localeconv();
7879}
80
81inline _LIBCPP_HIDE_FROM_ABI const char* __get_locale_encoding(__locale_t __loc) {
82 return ::nl_langinfo_l(CODESET, __loc);
83}
7984#endif // _LIBCPP_BUILDING_LIBRARY
8085
8186//
......@@ -147,8 +152,8 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __
147152}
148153# endif // _LIBCPP_HAS_WIDE_CHARACTERS
149154
150inline _LIBCPP_HIDE_FROM_ABI
151size_t __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
155inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
156 __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
152157 return strftime_l(__s, __max, __format, __tm, __loc);
153158}
154159
lib/libcxx/include/__locale_dir/support/no_locale/characters.h+6-4
......@@ -16,6 +16,7 @@
1616#include <cstring>
1717#include <ctime>
1818#if _LIBCPP_HAS_WIDE_CHARACTERS
19# include <cwchar>
1920# include <cwctype>
2021#endif
2122
......@@ -23,13 +24,14 @@
2324# pragma GCC system_header
2425#endif
2526
27#if defined(_LIBCPP_BUILDING_LIBRARY)
28
2629_LIBCPP_BEGIN_NAMESPACE_STD
2730namespace __locale {
2831
2932//
3033// Character manipulation functions
3134//
32#if defined(_LIBCPP_BUILDING_LIBRARY)
3335inline _LIBCPP_HIDE_FROM_ABI int __toupper(int __c, __locale_t) { return std::toupper(__c); }
3436
3537inline _LIBCPP_HIDE_FROM_ABI int __tolower(int __c, __locale_t) { return std::tolower(__c); }
......@@ -80,13 +82,13 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __
8082}
8183# endif // _LIBCPP_HAS_WIDE_CHARACTERS
8284
83inline _LIBCPP_HIDE_FROM_ABI size_t
84__strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t) {
85inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
86 __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t) {
8587 return std::strftime(__s, __max, __format, __tm);
8688}
87#endif // _LIBCPP_BUILDING_LIBRARY
8889
8990} // namespace __locale
9091_LIBCPP_END_NAMESPACE_STD
9192
93#endif // _LIBCPP_BUILDING_LIBRARY
9294#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CHARACTERS_H
lib/libcxx/include/__locale_dir/support/no_locale/conversions.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___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__std_mbstate_t.h>
15#include <cstdlib>
16#if _LIBCPP_HAS_WIDE_CHARACTERS
17# include <cwchar>
18#endif
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#if defined(_LIBCPP_BUILDING_LIBRARY)
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __locale {
28
29inline _LIBCPP_HIDE_FROM_ABI decltype(MB_CUR_MAX) __mb_len_max(__locale_t) { return MB_CUR_MAX; }
30
31# if _LIBCPP_HAS_WIDE_CHARACTERS
32inline _LIBCPP_HIDE_FROM_ABI wint_t __btowc(int __c, __locale_t) { return std::btowc(__c); }
33
34inline _LIBCPP_HIDE_FROM_ABI int __wctob(wint_t __c, __locale_t) { return std::wctob(__c); }
35
36inline _LIBCPP_HIDE_FROM_ABI size_t
37__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t) {
38 return ::wcsnrtombs(__dest, __src, __nwc, __len, __ps); // Non-standard
39}
40
41inline _LIBCPP_HIDE_FROM_ABI size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t) {
42 return std::wcrtomb(__s, __wc, __ps);
43}
44
45inline _LIBCPP_HIDE_FROM_ABI size_t
46__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t) {
47 return ::mbsnrtowcs(__dest, __src, __nms, __len, __ps); // Non-standard
48}
49
50inline _LIBCPP_HIDE_FROM_ABI size_t
51__mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t) {
52 return std::mbrtowc(__pwc, __s, __n, __ps);
53}
54
55inline _LIBCPP_HIDE_FROM_ABI int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t) {
56 return std::mbtowc(__pwc, __pmb, __max);
57}
58
59inline _LIBCPP_HIDE_FROM_ABI size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t) {
60 return std::mbrlen(__s, __n, __ps);
61}
62
63inline _LIBCPP_HIDE_FROM_ABI size_t
64__mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t) {
65 return std::mbsrtowcs(__dest, __src, __len, __ps);
66}
67# endif // _LIBCPP_HAS_WIDE_CHARACTERS
68
69} // namespace __locale
70_LIBCPP_END_NAMESPACE_STD
71
72#endif // _LIBCPP_BUILDING_LIBRARY
73#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_CONVERSIONS_H
lib/libcxx/include/__locale_dir/support/no_locale/formatting.h created+50
......@@ -0,0 +1,50 @@
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_NO_LOCALE_FORMATTING_H
10#define _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_FORMATTING_H
11
12#include <__config>
13#include <__utility/forward.h>
14#include <cstdio>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21namespace __locale {
22
23_LIBCPP_DIAGNOSTIC_PUSH
24_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
25_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
26#ifdef _LIBCPP_COMPILER_CLANG_BASED
27# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
28#else
29# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
30#endif
31
32template <class... _Args>
33_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int __snprintf(
34 char* __s, size_t __n, __locale_t, const char* __format, _Args&&... __args) {
35 return std::snprintf(__s, __n, __format, std::forward<_Args>(__args)...);
36}
37
38template <class... _Args>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __asprintf(
40 char** __s, __locale_t, const char* __format, _Args&&... __args) {
41 return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard
42}
43
44_LIBCPP_DIAGNOSTIC_POP
45#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
46
47} // namespace __locale
48_LIBCPP_END_NAMESPACE_STD
49
50#endif // _LIBCPP___LOCALE_DIR_SUPPORT_NO_LOCALE_FORMATTING_H
lib/libcxx/include/__locale_dir/support/openbsd.h created+229
......@@ -0,0 +1,229 @@
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___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
11#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
12
13#include <__config>
14#include <__cstddef/size_t.h>
15#include <__std_mbstate_t.h>
16#include <__utility/forward.h>
17#include <clocale> // std::lconv
18#include <ctype.h>
19#include <stdio.h>
20#include <stdlib.h>
21#include <string.h>
22#include <time.h>
23#if _LIBCPP_HAS_WIDE_CHARACTERS
24# include <wchar.h>
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 __locale_guard(locale_t& __loc) : __old_loc_(::uselocale(__loc)) {}
37
38 ~__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#if defined(_LIBCPP_BUILDING_LIBRARY)
63using __lconv_t _LIBCPP_NODEBUG = std::lconv;
64
65inline __locale_t __newlocale(int __category_mask, const char* __locale, __locale_t __base) {
66 return ::newlocale(__category_mask, __locale, __base);
67}
68
69inline void __freelocale(__locale_t __loc) { ::freelocale(__loc); }
70
71inline char* __setlocale(int __category, char const* __locale) { return ::setlocale(__category, __locale); }
72
73inline __lconv_t* __localeconv(__locale_t& __loc) {
74 __locale_guard __current(__loc);
75 return ::localeconv();
76}
77#endif // _LIBCPP_BUILDING_LIBRARY
78
79//
80// Strtonum functions
81//
82inline float __strtof(const char* __nptr, char** __endptr, __locale_t) { return ::strtof(__nptr, __endptr); }
83
84inline double __strtod(const char* __nptr, char** __endptr, __locale_t) { return ::strtod(__nptr, __endptr); }
85
86inline long double __strtold(const char* __nptr, char** __endptr, __locale_t) { return ::strtold(__nptr, __endptr); }
87
88//
89// Character manipulation functions
90//
91#if defined(_LIBCPP_BUILDING_LIBRARY)
92inline int __toupper(int __c, __locale_t __loc) { return ::toupper_l(__c, __loc); }
93
94inline int __tolower(int __c, __locale_t __loc) { return ::tolower_l(__c, __loc); }
95
96inline int __strcoll(const char* __s1, const char* __s2, __locale_t __loc) { return ::strcoll_l(__s1, __s2, __loc); }
97
98inline size_t __strxfrm(char* __dest, const char* __src, size_t __n, __locale_t __loc) {
99 return ::strxfrm_l(__dest, __src, __n, __loc);
100}
101
102# if _LIBCPP_HAS_WIDE_CHARACTERS
103inline int __iswctype(wint_t __c, wctype_t __type, __locale_t __loc) { return ::iswctype_l(__c, __type, __loc); }
104
105inline int __iswspace(wint_t __c, __locale_t __loc) { return ::iswspace_l(__c, __loc); }
106
107inline int __iswprint(wint_t __c, __locale_t __loc) { return ::iswprint_l(__c, __loc); }
108
109inline int __iswcntrl(wint_t __c, __locale_t __loc) { return ::iswcntrl_l(__c, __loc); }
110
111inline int __iswupper(wint_t __c, __locale_t __loc) { return ::iswupper_l(__c, __loc); }
112
113inline int __iswlower(wint_t __c, __locale_t __loc) { return ::iswlower_l(__c, __loc); }
114
115inline int __iswalpha(wint_t __c, __locale_t __loc) { return ::iswalpha_l(__c, __loc); }
116
117inline int __iswblank(wint_t __c, __locale_t __loc) { return ::iswblank_l(__c, __loc); }
118
119inline int __iswdigit(wint_t __c, __locale_t __loc) { return ::iswdigit_l(__c, __loc); }
120
121inline int __iswpunct(wint_t __c, __locale_t __loc) { return ::iswpunct_l(__c, __loc); }
122
123inline int __iswxdigit(wint_t __c, __locale_t __loc) { return ::iswxdigit_l(__c, __loc); }
124
125inline wint_t __towupper(wint_t __c, __locale_t __loc) { return ::towupper_l(__c, __loc); }
126
127inline wint_t __towlower(wint_t __c, __locale_t __loc) { return ::towlower_l(__c, __loc); }
128
129inline int __wcscoll(const wchar_t* __ws1, const wchar_t* __ws2, __locale_t __loc) {
130 return ::wcscoll_l(__ws1, __ws2, __loc);
131}
132
133inline size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __src, size_t __n, __locale_t __loc) {
134 return ::wcsxfrm_l(__dest, __src, __n, __loc);
135}
136# endif // _LIBCPP_HAS_WIDE_CHARACTERS
137
138inline _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
139 __strftime(char* __s, size_t __max, const char* __format, const struct tm* __tm, __locale_t __loc) {
140 return ::strftime_l(__s, __max, __format, __tm, __loc);
141}
142
143//
144// Other functions
145//
146inline decltype(MB_CUR_MAX) __mb_len_max(__locale_t __loc) {
147 __locale_guard __current(__loc);
148 return MB_CUR_MAX;
149}
150
151# if _LIBCPP_HAS_WIDE_CHARACTERS
152inline wint_t __btowc(int __c, __locale_t __loc) {
153 __locale_guard __current(__loc);
154 return btowc(__c);
155}
156
157inline int __wctob(wint_t __c, __locale_t __loc) {
158 __locale_guard __current(__loc);
159 return wctob(__c);
160}
161
162inline size_t
163__wcsnrtombs(char* __dest, const wchar_t** __src, size_t __nwc, size_t __len, mbstate_t* __ps, __locale_t __loc) {
164 __locale_guard __current(__loc);
165 return wcsnrtombs(__dest, __src, __nwc, __len, __ps); // wcsnrtombs is a POSIX extension
166}
167
168inline size_t __wcrtomb(char* __s, wchar_t __wc, mbstate_t* __ps, __locale_t __loc) {
169 __locale_guard __current(__loc);
170 return wcrtomb(__s, __wc, __ps);
171}
172
173inline size_t
174__mbsnrtowcs(wchar_t* __dest, const char** __src, size_t __nms, size_t __len, mbstate_t* __ps, __locale_t __loc) {
175 __locale_guard __current(__loc);
176 return mbsnrtowcs(__dest, __src, __nms, __len, __ps); // mbsnrtowcs is a POSIX extension
177}
178
179inline size_t __mbrtowc(wchar_t* __pwc, const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
180 __locale_guard __current(__loc);
181 return mbrtowc(__pwc, __s, __n, __ps);
182}
183
184inline int __mbtowc(wchar_t* __pwc, const char* __pmb, size_t __max, __locale_t __loc) {
185 __locale_guard __current(__loc);
186 return mbtowc(__pwc, __pmb, __max);
187}
188
189inline size_t __mbrlen(const char* __s, size_t __n, mbstate_t* __ps, __locale_t __loc) {
190 __locale_guard __current(__loc);
191 return mbrlen(__s, __n, __ps);
192}
193
194inline size_t __mbsrtowcs(wchar_t* __dest, const char** __src, size_t __len, mbstate_t* __ps, __locale_t __loc) {
195 __locale_guard __current(__loc);
196 return mbsrtowcs(__dest, __src, __len, __ps);
197}
198# endif // _LIBCPP_HAS_WIDE_CHARACTERS
199#endif // _LIBCPP_BUILDING_LIBRARY
200
201_LIBCPP_DIAGNOSTIC_PUSH
202_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wgcc-compat")
203_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // GCC doesn't support [[gnu::format]] on variadic templates
204#ifdef _LIBCPP_COMPILER_CLANG_BASED
205# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) _LIBCPP_ATTRIBUTE_FORMAT(__VA_ARGS__)
206#else
207# define _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(...) /* nothing */
208#endif
209
210template <class... _Args>
211_LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5)
212int __snprintf(char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... __args) {
213 __locale_guard __current(__loc);
214 return ::snprintf(__s, __n, __format, std::forward<_Args>(__args)...);
215}
216
217template <class... _Args>
218_LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4)
219int __asprintf(char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
220 __locale_guard __current(__loc);
221 return ::asprintf(__s, __format, std::forward<_Args>(__args)...); // non-standard
222}
223_LIBCPP_DIAGNOSTIC_POP
224#undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
225
226} // namespace __locale
227_LIBCPP_END_NAMESPACE_STD
228
229#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_OPENBSD_H
lib/libcxx/include/__locale_dir/support/windows.h+7-3
......@@ -27,6 +27,7 @@
2727#endif
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
30_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3031namespace __locale {
3132
3233using __lconv_t _LIBCPP_NODEBUG = std::lconv;
......@@ -163,6 +164,7 @@ inline _LIBCPP_HIDE_FROM_ABI char* __setlocale(int __category, const char* __loc
163164 return __new_locale;
164165}
165166_LIBCPP_EXPORTED_FROM_ABI __lconv_t* __localeconv(__locale_t& __loc);
167_LIBCPP_EXPORTED_FROM_ABI const char* __get_locale_encoding(__locale_t __loc);
166168#endif // _LIBCPP_BUILDING_LIBRARY
167169
168170//
......@@ -230,10 +232,11 @@ inline _LIBCPP_HIDE_FROM_ABI size_t __wcsxfrm(wchar_t* __dest, const wchar_t* __
230232# endif // _LIBCPP_HAS_WIDE_CHARACTERS
231233
232234# if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
233_LIBCPP_EXPORTED_FROM_ABI size_t __strftime(char*, size_t, const char*, const struct tm*, __locale_t);
235_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
236 __strftime(char*, size_t, const char*, const struct tm*, __locale_t);
234237# else
235inline _LIBCPP_HIDE_FROM_ABI size_t
236__strftime(char* __ret, size_t __n, const char* __format, const struct tm* __tm, __locale_t __loc) {
238inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATTRIBUTE_FORMAT(__strftime__, 3, 0) size_t
239 __strftime(char* __ret, size_t __n, const char* __format, const struct tm* __tm, __locale_t __loc) {
237240 return ::_strftime_l(__ret, __n, __format, __tm, __loc);
238241}
239242# endif
......@@ -303,6 +306,7 @@ struct __locale_guard {
303306#endif // _LIBCPP_BUILDING_LIBRARY
304307
305308} // namespace __locale
309_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
306310_LIBCPP_END_NAMESPACE_STD
307311
308312#endif // _LIBCPP___LOCALE_DIR_SUPPORT_WINDOWS_H
lib/libcxx/include/__locale_dir/time.h+2
......@@ -22,6 +22,7 @@
2222# endif
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
2627template <class _CharT, class _InputIterator>
2728_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(
......@@ -755,6 +756,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
755756extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
756757# endif
757758
759_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
758760_LIBCPP_END_NAMESPACE_STD
759761
760762#endif // _LIBCPP_HAS_LOCALIZATION
lib/libcxx/include/__locale_dir/wbuffer_convert.h+4-2
......@@ -27,6 +27,7 @@ _LIBCPP_PUSH_MACROS
2727# include <__undef_macros>
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
30_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3031
3132template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> >
3233class _LIBCPP_DEPRECATED_IN_CXX17 wbuffer_convert : public basic_streambuf<_Elem, _Tr> {
......@@ -67,7 +68,7 @@ public:
6768
6869 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();
6970
70 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; }
71 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf() const { return __bufptr_; }
7172 _LIBCPP_HIDE_FROM_ABI streambuf* rdbuf(streambuf* __bytebuf) {
7273 streambuf* __r = __bufptr_;
7374 __bufptr_ = __bytebuf;
......@@ -77,7 +78,7 @@ public:
7778 wbuffer_convert(const wbuffer_convert&) = delete;
7879 wbuffer_convert& operator=(const wbuffer_convert&) = delete;
7980
80 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
8182
8283protected:
8384 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual int_type underflow();
......@@ -419,6 +420,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__
419420
420421_LIBCPP_SUPPRESS_DEPRECATED_POP
421422
423_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
422424_LIBCPP_END_NAMESPACE_STD
423425
424426_LIBCPP_POP_MACROS
lib/libcxx/include/__locale_dir/wstring_convert.h+14-10
......@@ -64,28 +64,30 @@ public:
6464 wstring_convert(const wstring_convert& __wc) = delete;
6565 wstring_convert& operator=(const wstring_convert& __wc) = delete;
6666
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) {
67 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) {
68 return from_bytes(&__byte, &__byte + 1);
69 }
70 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
6971 return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
7072 }
71 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) {
73 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const byte_string& __str) {
7274 return from_bytes(__str.data(), __str.data() + __str.size());
7375 }
74 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last);
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __first, const char* __last);
7577
76 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) {
78 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(_Elem __wchar) {
7779 return to_bytes(std::addressof(__wchar), std::addressof(__wchar) + 1);
7880 }
79 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) {
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __wptr) {
8082 return to_bytes(__wptr, __wptr + char_traits<_Elem>::length(__wptr));
8183 }
82 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) {
84 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const wide_string& __wstr) {
8385 return to_bytes(__wstr.data(), __wstr.data() + __wstr.size());
8486 }
85 _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last);
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI byte_string to_bytes(const _Elem* __first, const _Elem* __last);
8688
87 _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; }
88 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; }
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t converted() const _NOEXCEPT { return __cvtcount_; }
90 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI state_type state() const { return __cvtstate_; }
8991};
9092
9193_LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -174,9 +176,11 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::from_bytes(const char*
174176 return __wide_err_string_;
175177}
176178
179_LIBCPP_SUPPRESS_DEPRECATED_PUSH
177180template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
178181typename wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::byte_string
179182wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::to_bytes(const _Elem* __frm, const _Elem* __frm_end) {
183 _LIBCPP_SUPPRESS_DEPRECATED_POP
180184 __cvtcount_ = 0;
181185 if (__cvtptr_ != nullptr) {
182186 byte_string __bs(2 * (__frm_end - __frm), char());
lib/libcxx/include/__log_hardening_failure+2
......@@ -24,7 +24,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424
2525// This function should never be called directly from the code -- it should only be called through the
2626// `_LIBCPP_LOG_HARDENING_FAILURE` macro.
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728[[__gnu__::__cold__]] _LIBCPP_EXPORTED_FROM_ABI void __log_hardening_failure(const char* __message) noexcept;
29_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2830
2931// _LIBCPP_LOG_HARDENING_FAILURE(message)
3032//
lib/libcxx/include/__math/abs.h+13
......@@ -63,6 +63,19 @@ template <class = int>
6363 return __builtin_llabs(__x);
6464}
6565
66#if _LIBCPP_HAS_INT128
67[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline __int128_t abs(__int128_t __x) _NOEXCEPT { return __x < 0 ? -__x : __x; }
68#endif
69
70#if defined(__BITINT_MAXWIDTH__)
71// _BitInt does not integer-promote, so without a same-type overload a narrow
72// signed _BitInt would be an ambiguous call against abs(int/long/long long).
73template <int _Np>
74[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _BitInt(_Np) abs(_BitInt(_Np) __x) _NOEXCEPT {
75 return __x < 0 ? -__x : __x;
76}
77#endif
78
6679} // namespace __math
6780
6881_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__math/gamma.h+28
......@@ -55,6 +55,34 @@ inline _LIBCPP_HIDE_FROM_ABI double tgamma(_A1 __x) _NOEXCEPT {
5555 return __builtin_tgamma((double)__x);
5656}
5757
58// __lgamma_r
59//
60// POSIX systems provide a function named lgamma_r which is a reentrant version of lgamma. Use that
61// whenever possible. However, we avoid re-declaring the actual function since different platforms
62// declare it differently in the first place: instead use `asm` to get the compiler to call the right
63// function.
64
65#if defined(_LIBCPP_MSVCRT_LIKE) // reentrant version is not available on Windows
66
67inline _LIBCPP_HIDE_FROM_ABI double __lgamma_r(double __d) _NOEXCEPT { return __builtin_lgamma(__d); }
68
69#else
70
71_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
72# if defined(_LIBCPP_OBJECT_FORMAT_MACHO)
73double __lgamma_r_shim(double, int*) _NOEXCEPT __asm__("_lgamma_r");
74# else
75double __lgamma_r_shim(double, int*) _NOEXCEPT __asm__("lgamma_r");
76# endif
77_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
78
79inline _LIBCPP_HIDE_FROM_ABI double __lgamma_r(double __d) _NOEXCEPT {
80 int __sign;
81 return __math::__lgamma_r_shim(__d, &__sign);
82}
83
84#endif
85
5886} // namespace __math
5987
6088_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__math/special_functions.h+5-5
......@@ -21,10 +21,10 @@
2121# pragma GCC system_header
2222#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2624#if _LIBCPP_STD_VER >= 17
2725
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2828template <class _Real>
2929_LIBCPP_HIDE_FROM_ABI _Real __hermite(unsigned __n, _Real __x) {
3030 // The Hermite polynomial H_n(x).
......@@ -49,7 +49,7 @@ _LIBCPP_HIDE_FROM_ABI _Real __hermite(unsigned __n, _Real __x) {
4949 }
5050
5151 if (!__math::isfinite(__H_n)) {
52 // Overflow occured. Two possible cases:
52 // Overflow occurred. Two possible cases:
5353 // n is odd: return infinity of the same sign as x.
5454 // n is even: return +Inf
5555 _Real __inf = std::numeric_limits<_Real>::infinity();
......@@ -77,8 +77,8 @@ _LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, _Integer __x) {
7777 return std::hermite(__n, static_cast<double>(__x));
7878}
7979
80#endif // _LIBCPP_STD_VER >= 17
81
8280_LIBCPP_END_NAMESPACE_STD
8381
82#endif // _LIBCPP_STD_VER >= 17
83
8484#endif // _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
lib/libcxx/include/__mbstate_t.h+4
......@@ -39,10 +39,14 @@
3939# define __NEED_mbstate_t
4040# include <bits/alltypes.h>
4141# undef __NEED_mbstate_t
42#elif _LIBCPP_LIBC_LLVM_LIBC
43# include <llvm-libc-types/mbstate_t.h>
4244#elif __has_include(<bits/types/mbstate_t.h>)
4345# include <bits/types/mbstate_t.h> // works on most Unixes
4446#elif __has_include(<sys/_types/_mbstate_t.h>)
4547# include <sys/_types/_mbstate_t.h> // works on Darwin
48#elif __has_include(<bits/mbstate_t.h>)
49# include <bits/mbstate_t.h> // works for Android
4650#elif __has_include_next(<wchar.h>)
4751# include_next <wchar.h> // use the C standard provider of mbstate_t if present
4852#elif __has_include_next(<uchar.h>)
lib/libcxx/include/__mdspan/aligned_accessor.h+4-4
......@@ -33,10 +33,10 @@
3333_LIBCPP_PUSH_MACROS
3434#include <__undef_macros>
3535
36_LIBCPP_BEGIN_NAMESPACE_STD
37
3836#if _LIBCPP_STD_VER >= 26
3937
38_LIBCPP_BEGIN_NAMESPACE_STD
39
4040template <class _ElementType, size_t _ByteAlignment>
4141struct aligned_accessor {
4242 static_assert(_ByteAlignment != 0 && (_ByteAlignment & (_ByteAlignment - 1)) == 0,
......@@ -78,10 +78,10 @@ struct aligned_accessor {
7878 }
7979};
8080
81#endif // _LIBCPP_STD_VER >= 26
82
8381_LIBCPP_END_NAMESPACE_STD
8482
83#endif // _LIBCPP_STD_VER >= 26
84
8585_LIBCPP_POP_MACROS
8686
8787#endif // _LIBCPP___MDSPAN_ALIGNED_ACCESSOR_H
lib/libcxx/include/__mdspan/extents.h+76-81
......@@ -21,12 +21,16 @@
2121#include <__config>
2222
2323#include <__concepts/arithmetic.h>
24#include <__concepts/same_as.h>
2425#include <__type_traits/common_type.h>
2526#include <__type_traits/integer_traits.h>
2627#include <__type_traits/is_convertible.h>
2728#include <__type_traits/is_nothrow_constructible.h>
2829#include <__type_traits/is_signed.h>
2930#include <__type_traits/make_unsigned.h>
31#include <__type_traits/remove_cvref.h>
32#include <__utility/as_const.h>
33#include <__utility/forward.h>
3034#include <__utility/integer_sequence.h>
3135#include <__utility/unreachable.h>
3236#include <array>
......@@ -46,25 +50,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4650#if _LIBCPP_STD_VER >= 23
4751
4852namespace __mdspan_detail {
49
50// ------------------------------------------------------------------
51// ------------ __static_array --------------------------------------
52// ------------------------------------------------------------------
53// array like class which provides an array of static values with get
54template <class _Tp, _Tp... _Values>
55struct __static_array {
56 static constexpr array<_Tp, sizeof...(_Values)> __array = {_Values...};
57
58public:
59 _LIBCPP_HIDE_FROM_ABI static constexpr size_t __size() { return sizeof...(_Values); }
60 _LIBCPP_HIDE_FROM_ABI static constexpr _Tp __get(size_t __index) noexcept { return __array[__index]; }
61
62 template <size_t _Index>
63 _LIBCPP_HIDE_FROM_ABI static constexpr _Tp __get() {
64 return __get(_Index);
65 }
66};
67
6853// ------------------------------------------------------------------
6954// ------------ __possibly_empty_array -----------------------------
7055// ------------------------------------------------------------------
......@@ -117,35 +102,28 @@ struct __static_partial_sums {
117102// array like class which has a mix of static and runtime values but
118103// only stores the runtime values.
119104// The type of the static and the runtime values can be different.
120// The position of a dynamic value is indicated through a tag value.
121template <class _TDynamic, class _TStatic, _TStatic _DynTag, _TStatic... _Values>
105// The position of a dynamic value is indicated by dynamic_extent.
106template <class _TDynamic, class _TStatic, _TStatic... _Values>
122107struct __maybe_static_array {
123 static_assert(is_convertible<_TStatic, _TDynamic>::value,
108 static_assert(is_convertible_v<_TStatic, _TDynamic>,
124109 "__maybe_static_array: _TStatic must be convertible to _TDynamic");
125 static_assert(is_convertible<_TDynamic, _TStatic>::value,
110 static_assert(is_convertible_v<_TDynamic, _TStatic>,
126111 "__maybe_static_array: _TDynamic must be convertible to _TStatic");
127112
128113private:
129114 // Static values member
130115 static constexpr size_t __size_ = sizeof...(_Values);
131 static constexpr size_t __size_dynamic_ = ((_Values == _DynTag) + ... + 0);
132 using _StaticValues _LIBCPP_NODEBUG = __static_array<_TStatic, _Values...>;
116 static constexpr size_t __size_dynamic_ = ((_Values == dynamic_extent) + ... + 0);
133117 using _DynamicValues _LIBCPP_NODEBUG = __possibly_empty_array<_TDynamic, __size_dynamic_>;
134118
135 // Dynamic values member
119 static constexpr array<_TStatic, sizeof...(_Values)> __static_values_ = {_Values...};
136120 _LIBCPP_NO_UNIQUE_ADDRESS _DynamicValues __dyn_vals_;
137121
138122 // static mapping of indices to the position in the dynamic values array
139 using _DynamicIdxMap _LIBCPP_NODEBUG = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>;
140
141 template <size_t... _Indices>
142 _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept {
143 return _DynamicValues{((void)_Indices, 0)...};
144 }
123 using _DynamicIdxMap _LIBCPP_NODEBUG = __static_partial_sums<static_cast<size_t>(_Values == dynamic_extent)...>;
145124
146125public:
147 _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array() noexcept
148 : __dyn_vals_{__zeros(make_index_sequence<__size_dynamic_>())} {}
126 _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array() noexcept : __dyn_vals_{} {}
149127
150128 // constructors from dynamic values only -- this covers the case for rank() == 0
151129 template <class... _DynVals>
......@@ -169,8 +147,8 @@ public:
169147 static_assert(sizeof...(_DynVals) == __size_, "Invalid number of values.");
170148 _TDynamic __values[__size_] = {static_cast<_TDynamic>(__vals)...};
171149 for (size_t __i = 0; __i < __size_; __i++) {
172 _TStatic __static_val = _StaticValues::__get(__i);
173 if (__static_val == _DynTag) {
150 _TStatic __static_val = __static_values_[__i];
151 if (__static_val == dynamic_extent) {
174152 __dyn_vals_[_DynamicIdxMap::__get(__i)] = __values[__i];
175153 } else
176154 // Not catching this could lead to out of bounds errors later
......@@ -188,8 +166,8 @@ public:
188166 _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(const span<_Tp, _Size>& __vals) {
189167 static_assert(_Size == __size_ || __size_ == dynamic_extent);
190168 for (size_t __i = 0; __i < __size_; __i++) {
191 _TStatic __static_val = _StaticValues::__get(__i);
192 if (__static_val == _DynTag) {
169 _TStatic __static_val = __static_values_[__i];
170 if (__static_val == dynamic_extent) {
193171 __dyn_vals_[_DynamicIdxMap::__get(__i)] = static_cast<_TDynamic>(__vals[__i]);
194172 } else
195173 // Not catching this could lead to out of bounds errors later
......@@ -205,13 +183,15 @@ public:
205183 // access functions
206184 _LIBCPP_HIDE_FROM_ABI static constexpr _TStatic __static_value(size_t __i) noexcept {
207185 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "extents access: index must be less than rank");
208 return _StaticValues::__get(__i);
186 return __static_values_[__i];
209187 }
210188
211189 _LIBCPP_HIDE_FROM_ABI constexpr _TDynamic __value(size_t __i) const {
212190 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "extents access: index must be less than rank");
213 _TStatic __static_val = _StaticValues::__get(__i);
214 return __static_val == _DynTag ? __dyn_vals_[_DynamicIdxMap::__get(__i)] : static_cast<_TDynamic>(__static_val);
191 _TStatic __static_val = __static_values_[__i];
192 return __static_val == dynamic_extent
193 ? __dyn_vals_[_DynamicIdxMap::__get(__i)]
194 : static_cast<_TDynamic>(__static_val);
215195 }
216196 _LIBCPP_HIDE_FROM_ABI constexpr _TDynamic operator[](size_t __i) const {
217197 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "extents access: index must be less than rank");
......@@ -252,19 +232,6 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __is_representable_as(_From __value) {
252232 return true;
253233}
254234
255template <integral _To, class... _From>
256_LIBCPP_HIDE_FROM_ABI constexpr bool __are_representable_as(_From... __values) {
257 return (__mdspan_detail::__is_representable_as<_To>(__values) && ... && true);
258}
259
260template <integral _To, class _From, size_t _Size>
261_LIBCPP_HIDE_FROM_ABI constexpr bool __are_representable_as(span<_From, _Size> __values) {
262 for (size_t __i = 0; __i < _Size; __i++)
263 if (!__mdspan_detail::__is_representable_as<_To>(__values[__i]))
264 return false;
265 return true;
266}
267
268235} // namespace __mdspan_detail
269236
270237// ------------------------------------------------------------------
......@@ -293,10 +260,45 @@ private:
293260 static constexpr rank_type __rank_dynamic_ = ((_Extents == dynamic_extent) + ... + 0);
294261
295262 // internal storage type using __maybe_static_array
296 using _Values _LIBCPP_NODEBUG =
297 __mdspan_detail::__maybe_static_array<_IndexType, size_t, dynamic_extent, _Extents...>;
263 using _Values _LIBCPP_NODEBUG = __mdspan_detail::__maybe_static_array<_IndexType, size_t, _Extents...>;
298264 [[no_unique_address]] _Values __vals_;
299265
266 template <class _OtherIndexType>
267 _LIBCPP_HIDE_FROM_ABI static constexpr index_type __checked_index_cast(_OtherIndexType&& __value) noexcept {
268 using _OtherType = remove_cvref_t<_OtherIndexType>;
269 if constexpr (integral<_OtherType> && !same_as<_OtherType, bool>) {
270 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
271 __mdspan_detail::__is_representable_as<index_type>(__value),
272 "extents ctor: arguments must be representable as index_type and nonnegative");
273 return static_cast<index_type>(__value);
274 } else {
275 auto __converted_val = static_cast<index_type>(std::forward<_OtherIndexType>(__value));
276 if constexpr (is_signed_v<index_type>) {
277 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
278 __converted_val >= 0, "extents ctor: arguments must be representable as index_type and nonnegative");
279 }
280 return __converted_val;
281 }
282 }
283
284 template <class... _OtherIndexTypes>
285 _LIBCPP_HIDE_FROM_ABI static constexpr _Values
286 __representability_checked_cast(_OtherIndexTypes&&... __values) noexcept {
287 return _Values{__checked_index_cast(std::forward<_OtherIndexTypes>(__values))...};
288 }
289
290 template <class _OtherIndexType, size_t _Size, size_t... _Idxs>
291 _LIBCPP_HIDE_FROM_ABI static constexpr _Values
292 __representability_checked_cast(const array<_OtherIndexType, _Size>& __exts, index_sequence<_Idxs...>) noexcept {
293 return __representability_checked_cast(__exts[_Idxs]...);
294 }
295
296 template <class _OtherIndexType, size_t _Size, size_t... _Idxs>
297 _LIBCPP_HIDE_FROM_ABI static constexpr _Values
298 __representability_checked_cast(const span<_OtherIndexType, _Size>& __exts, index_sequence<_Idxs...>) noexcept {
299 return __representability_checked_cast(std::as_const(__exts[_Idxs])...);
300 }
301
300302public:
301303 // [mdspan.extents.obs], observers of multidimensional index space
302304 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return __rank_; }
......@@ -319,12 +321,9 @@ public:
319321 (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
320322 (sizeof...(_OtherIndexTypes) == __rank_ || sizeof...(_OtherIndexTypes) == __rank_dynamic_))
321323 _LIBCPP_HIDE_FROM_ABI constexpr explicit extents(_OtherIndexTypes... __dynvals) noexcept
322 : __vals_(static_cast<index_type>(__dynvals)...) {
323 // Not catching this could lead to out of bounds errors later
324 // e.g. mdspan m(ptr, dextents<char, 1>(200u)); leads to an extent of -56 on m
325 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__are_representable_as<index_type>(__dynvals...),
326 "extents ctor: arguments must be representable as index_type and nonnegative");
327 }
324 // Not catching this could lead to out of bounds errors later
325 // e.g. mdspan m(ptr, dextents<char, 1>(200u)); leads to an extent of -56 on m
326 : __vals_(__representability_checked_cast(std::move(__dynvals)...)) {}
328327
329328 template <class _OtherIndexType, size_t _Size>
330329 requires(is_convertible_v<const _OtherIndexType&, index_type> &&
......@@ -332,12 +331,9 @@ public:
332331 (_Size == __rank_ || _Size == __rank_dynamic_))
333332 explicit(_Size != __rank_dynamic_)
334333 _LIBCPP_HIDE_FROM_ABI constexpr extents(const array<_OtherIndexType, _Size>& __exts) noexcept
335 : __vals_(span(__exts)) {
336 // Not catching this could lead to out of bounds errors later
337 // e.g. mdspan m(ptr, dextents<char, 1>(array<unsigned,1>(200))); leads to an extent of -56 on m
338 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__are_representable_as<index_type>(span(__exts)),
339 "extents ctor: arguments must be representable as index_type and nonnegative");
340 }
334 // Not catching this could lead to out of bounds errors later
335 // e.g. mdspan m(ptr, dextents<char, 1>(200u)); leads to an extent of -56 on m
336 : __vals_(__representability_checked_cast(__exts, make_index_sequence<_Size>())) {}
341337
342338 template <class _OtherIndexType, size_t _Size>
343339 requires(is_convertible_v<const _OtherIndexType&, index_type> &&
......@@ -345,13 +341,9 @@ public:
345341 (_Size == __rank_ || _Size == __rank_dynamic_))
346342 explicit(_Size != __rank_dynamic_)
347343 _LIBCPP_HIDE_FROM_ABI constexpr extents(const span<_OtherIndexType, _Size>& __exts) noexcept
348 : __vals_(__exts) {
349 // Not catching this could lead to out of bounds errors later
350 // e.g. array a{200u}; mdspan<int, dextents<char,1>> m(ptr, extents(span<unsigned,1>(a))); leads to an extent of -56
351 // on m
352 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__are_representable_as<index_type>(__exts),
353 "extents ctor: arguments must be representable as index_type and nonnegative");
354 }
344 // Not catching this could lead to out of bounds errors later
345 // e.g. mdspan m(ptr, dextents<char, 1>(200u)); leads to an extent of -56 on m
346 : __vals_(__representability_checked_cast(__exts, make_index_sequence<_Size>())) {}
355347
356348private:
357349 // Function to construct extents storage from other extents.
......@@ -433,6 +425,15 @@ public:
433425 }
434426 return true;
435427 }
428
429 template <class _OtherIndexType>
430 _LIBCPP_HIDE_FROM_ABI static constexpr auto __index_cast(_OtherIndexType&& __i) noexcept {
431 using _OtherIndex = remove_cvref_t<_OtherIndexType>;
432 if constexpr (integral<_OtherIndex> && !same_as<_OtherIndex, bool>)
433 return __i;
434 else
435 return static_cast<index_type>(std::forward<_OtherIndexType>(__i));
436 }
436437};
437438
438439// Recursive helper classes to implement dextents alias for extents
......@@ -465,15 +466,9 @@ using dims = dextents<_IndexType, _Rank>;
465466# endif
466467
467468// Deduction guide for extents
468# if _LIBCPP_STD_VER >= 26
469469template <class... _IndexTypes>
470470 requires(is_convertible_v<_IndexTypes, size_t> && ...)
471471explicit extents(_IndexTypes...) -> extents<size_t, __maybe_static_ext<_IndexTypes>...>;
472# else
473template <class... _IndexTypes>
474 requires(is_convertible_v<_IndexTypes, size_t> && ...)
475explicit extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>;
476# endif
477472
478473namespace __mdspan_detail {
479474
lib/libcxx/include/__mdspan/layout_left.h+3-3
......@@ -47,9 +47,9 @@ public:
4747 "layout_left::mapping template argument must be a specialization of extents.");
4848
4949 using extents_type = _Extents;
50 using index_type = typename extents_type::index_type;
51 using size_type = typename extents_type::size_type;
52 using rank_type = typename extents_type::rank_type;
50 using index_type = extents_type::index_type;
51 using size_type = extents_type::size_type;
52 using rank_type = extents_type::rank_type;
5353 using layout_type = layout_left;
5454
5555private:
lib/libcxx/include/__mdspan/layout_right.h+3-3
......@@ -47,9 +47,9 @@ public:
4747 "layout_right::mapping template argument must be a specialization of extents.");
4848
4949 using extents_type = _Extents;
50 using index_type = typename extents_type::index_type;
51 using size_type = typename extents_type::size_type;
52 using rank_type = typename extents_type::rank_type;
50 using index_type = extents_type::index_type;
51 using size_type = extents_type::size_type;
52 using rank_type = extents_type::rank_type;
5353 using layout_type = layout_right;
5454
5555private:
lib/libcxx/include/__mdspan/layout_stride.h+18-30
......@@ -72,9 +72,9 @@ public:
7272 "layout_stride::mapping template argument must be a specialization of extents.");
7373
7474 using extents_type = _Extents;
75 using index_type = typename extents_type::index_type;
76 using size_type = typename extents_type::size_type;
77 using rank_type = typename extents_type::rank_type;
75 using index_type = extents_type::index_type;
76 using size_type = extents_type::size_type;
77 using rank_type = extents_type::rank_type;
7878 using layout_type = layout_stride;
7979
8080private:
......@@ -296,38 +296,26 @@ public:
296296 }
297297
298298 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_unique() noexcept { return true; }
299 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive() noexcept { return false; }
299 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_exhaustive() noexcept {
300 if constexpr (__rank_ == 0)
301 return true;
302 for (size_t __r = 0; __r < __rank_; ++__r)
303 if (extents_type::static_extent(__r) == 0)
304 return true;
305 return false;
306 }
300307 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_always_strided() noexcept { return true; }
301308
302309 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_unique() noexcept { return true; }
303 // The answer of this function is fairly complex in the case where one or more
304 // extents are zero.
305 // Technically it is meaningless to query is_exhaustive() in that case, but unfortunately
306 // the way the standard defines this function, we can't give a simple true or false then.
307310 _LIBCPP_HIDE_FROM_ABI constexpr bool is_exhaustive() const noexcept {
308 if constexpr (__rank_ == 0)
311 if constexpr (is_always_exhaustive())
309312 return true;
310 else {
311 index_type __span_size = required_span_size();
312 if (__span_size == static_cast<index_type>(0)) {
313 if constexpr (__rank_ == 1)
314 return __strides_[0] == 1;
315 else {
316 rank_type __r_largest = 0;
317 for (rank_type __r = 1; __r < __rank_; __r++)
318 if (__strides_[__r] > __strides_[__r_largest])
319 __r_largest = __r;
320 for (rank_type __r = 0; __r < __rank_; __r++)
321 if (__extents_.extent(__r) == 0 && __r != __r_largest)
322 return false;
323 return true;
324 }
325 } else {
326 return required_span_size() == [&]<size_t... _Pos>(index_sequence<_Pos...>) {
327 return (__extents_.extent(_Pos) * ... * static_cast<index_type>(1));
328 }(make_index_sequence<__rank_>());
329 }
330 }
313 index_type __span_size = required_span_size();
314 if (__span_size == static_cast<index_type>(0))
315 return true;
316 return __span_size == [&]<size_t... _Pos>(index_sequence<_Pos...>) {
317 return (__extents_.extent(_Pos) * ... * static_cast<index_type>(1));
318 }(make_index_sequence<__rank_>());
331319 }
332320 _LIBCPP_HIDE_FROM_ABI static constexpr bool is_strided() noexcept { return true; }
333321
lib/libcxx/include/__mdspan/mdspan.h+55-21
......@@ -30,6 +30,7 @@
3030#include <__type_traits/is_constructible.h>
3131#include <__type_traits/is_convertible.h>
3232#include <__type_traits/is_nothrow_constructible.h>
33#include <__type_traits/is_object.h>
3334#include <__type_traits/is_pointer.h>
3435#include <__type_traits/is_same.h>
3536#include <__type_traits/rank.h>
......@@ -37,9 +38,11 @@
3738#include <__type_traits/remove_cv.h>
3839#include <__type_traits/remove_pointer.h>
3940#include <__type_traits/remove_reference.h>
41#include <__utility/as_const.h>
4042#include <__utility/integer_sequence.h>
4143#include <array>
4244#include <span>
45#include <stdexcept>
4346
4447#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4548# pragma GCC system_header
......@@ -66,6 +69,9 @@ class mdspan {
6669private:
6770 static_assert(__mdspan_detail::__is_extents_v<_Extents>,
6871 "mdspan: Extents template parameter must be a specialization of extents.");
72 static_assert(
73 is_object_v<_ElementType> && requires { sizeof(_ElementType); },
74 "mdspan: ElementType template parameter must be a complete object type");
6975 static_assert(!is_array_v<_ElementType>, "mdspan: ElementType template parameter may not be an array type");
7076 static_assert(!is_abstract_v<_ElementType>, "mdspan: ElementType template parameter may not be an abstract class");
7177 static_assert(is_same_v<_ElementType, typename _AccessorPolicy::element_type>,
......@@ -78,14 +84,14 @@ public:
7884 using extents_type = _Extents;
7985 using layout_type = _LayoutPolicy;
8086 using accessor_type = _AccessorPolicy;
81 using mapping_type = typename layout_type::template mapping<extents_type>;
87 using mapping_type = layout_type::template mapping<extents_type>;
8288 using element_type = _ElementType;
8389 using value_type = remove_cv_t<element_type>;
84 using index_type = typename extents_type::index_type;
85 using size_type = typename extents_type::size_type;
86 using rank_type = typename extents_type::rank_type;
87 using data_handle_type = typename accessor_type::data_handle_type;
88 using reference = typename accessor_type::reference;
90 using index_type = extents_type::index_type;
91 using size_type = extents_type::size_type;
92 using rank_type = extents_type::rank_type;
93 using data_handle_type = accessor_type::data_handle_type;
94 using reference = accessor_type::reference;
8995
9096 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank() noexcept { return extents_type::rank(); }
9197 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr rank_type rank_dynamic() noexcept {
......@@ -187,11 +193,11 @@ public:
187193 (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
188194 (sizeof...(_OtherIndexTypes) == rank()))
189195 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](_OtherIndexTypes... __indices) const {
190 // Note the standard layouts would also check this, but user provided ones may not, so we
191 // check the precondition here
192 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__is_multidimensional_index_in(extents(), __indices...),
193 "mdspan: operator[] out of bounds access");
194 return __acc_.access(__ptr_, __map_(static_cast<index_type>(std::move(__indices))...));
196 return [&]<class... _IndexTypes>(_IndexTypes... __idxs) -> reference {
197 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__mdspan_detail::__is_multidimensional_index_in(extents(), __idxs...),
198 "mdspan: operator[] out of bounds access");
199 return __acc_.access(__ptr_, __map_(static_cast<index_type>(std::move(__idxs))...));
200 }(extents_type::__index_cast(std::move(__indices))...);
195201 }
196202
197203 template <class _OtherIndexType>
......@@ -200,7 +206,7 @@ public:
200206 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference
201207 operator[](const array< _OtherIndexType, rank()>& __indices) const {
202208 return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) {
203 return __map_(__indices[_Idxs]...);
209 return __map_(extents_type::__index_cast(__indices[_Idxs])...);
204210 }(make_index_sequence<rank()>()));
205211 }
206212
......@@ -209,10 +215,41 @@ public:
209215 is_nothrow_constructible_v<index_type, const _OtherIndexType&>)
210216 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference operator[](span<_OtherIndexType, rank()> __indices) const {
211217 return __acc_.access(__ptr_, [&]<size_t... _Idxs>(index_sequence<_Idxs...>) {
212 return __map_(__indices[_Idxs]...);
218 return __map_(extents_type::__index_cast(__indices[_Idxs])...);
213219 }(make_index_sequence<rank()>()));
214220 }
215221
222# if _LIBCPP_STD_VER >= 26
223 template <class... _OtherIndexTypes>
224 requires((is_convertible_v<_OtherIndexTypes, index_type> && ...) &&
225 (is_nothrow_constructible_v<index_type, _OtherIndexTypes> && ...) &&
226 (sizeof...(_OtherIndexTypes) == rank()))
227 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(_OtherIndexTypes... __indices) const {
228 if (!__mdspan_detail::__is_multidimensional_index_in(__map_.extents(), __indices...)) {
229 __throw_out_of_range();
230 }
231 return (*this)[extents_type::__index_cast(std::move(__indices))...];
232 }
233
234 template <class _OtherIndexType>
235 requires(is_convertible_v<const _OtherIndexType&, index_type> &&
236 is_nothrow_constructible_v<index_type, const _OtherIndexType&>)
237 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(const array<_OtherIndexType, rank()>& __indices) const {
238 return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) -> reference {
239 return at(extents_type::__index_cast(__indices[_Idxs])...);
240 }(make_index_sequence<rank()>());
241 }
242
243 template <class _OtherIndexType>
244 requires(is_convertible_v<const _OtherIndexType&, index_type> &&
245 is_nothrow_constructible_v<index_type, const _OtherIndexType&>)
246 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reference at(span<_OtherIndexType, rank()> __indices) const {
247 return [&]<size_t... _Idxs>(index_sequence<_Idxs...>) -> reference {
248 return at(extents_type::__index_cast(std::as_const(__indices[_Idxs]))...);
249 }(make_index_sequence<rank()>());
250 }
251# endif
252
216253 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept {
217254 // Could leave this as only checked in debug mode: semantically size() is never
218255 // guaranteed to be related to any accessible range
......@@ -269,19 +306,16 @@ private:
269306
270307 template <class, class, class, class>
271308 friend class mdspan;
272};
273309
274310# if _LIBCPP_STD_VER >= 26
311 _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { std::__throw_out_of_range("mdspan"); }
312# endif
313};
314
275315template <class _ElementType, class... _OtherIndexTypes>
276316 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
277317explicit mdspan(_ElementType*, _OtherIndexTypes...)
278318 -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>;
279# else
280template <class _ElementType, class... _OtherIndexTypes>
281 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
282explicit mdspan(_ElementType*, _OtherIndexTypes...)
283 -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>;
284# endif
285319
286320template <class _Pointer>
287321 requires(is_pointer_v<remove_reference_t<_Pointer>>)
......@@ -309,7 +343,7 @@ mdspan(_ElementType*, const _MappingType&)
309343 -> mdspan<_ElementType, typename _MappingType::extents_type, typename _MappingType::layout_type>;
310344
311345template <class _MappingType, class _AccessorType>
312mdspan(const typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
346mdspan(typename _AccessorType::data_handle_type, const _MappingType&, const _AccessorType&)
313347 -> mdspan<typename _AccessorType::element_type,
314348 typename _MappingType::extents_type,
315349 typename _MappingType::layout_type,
lib/libcxx/include/__memory/aligned_alloc.h deleted-63
......@@ -1,63 +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___MEMORY_ALIGNED_ALLOC_H
10#define _LIBCPP___MEMORY_ALIGNED_ALLOC_H
11
12#include <__config>
13#include <cstdlib>
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_HAS_LIBRARY_ALIGNED_ALLOCATION
22
23// Low-level helpers to call the aligned allocation and deallocation functions
24// on the target platform. This is used to implement libc++'s own memory
25// allocation routines -- if you need to allocate memory inside the library,
26// chances are that you want to use `__libcpp_allocate` instead.
27//
28// Returns the allocated memory, or `nullptr` on failure.
29inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) {
30# if defined(_LIBCPP_MSVCRT_LIKE)
31 return ::_aligned_malloc(__size, __alignment);
32# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC
33 // aligned_alloc() requires that __size is a multiple of __alignment,
34 // but for C++ [new.delete.general], only states "if the value of an
35 // alignment argument passed to any of these functions is not a valid
36 // alignment value, the behavior is undefined".
37 // To handle calls such as ::operator new(1, std::align_val_t(128)), we
38 // round __size up to the next multiple of __alignment.
39 size_t __rounded_size = (__size + __alignment - 1) & ~(__alignment - 1);
40 // Rounding up could have wrapped around to zero, so we have to add another
41 // max() ternary to the actual call site to avoid succeeded in that case.
42 return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
43# else
44 void* __result = nullptr;
45 (void)::posix_memalign(&__result, __alignment, __size);
46 // If posix_memalign fails, __result is unmodified so we still return `nullptr`.
47 return __result;
48# endif
49}
50
51inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) {
52# if defined(_LIBCPP_MSVCRT_LIKE)
53 ::_aligned_free(__ptr);
54# else
55 ::free(__ptr);
56# endif
57}
58
59#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
60
61_LIBCPP_END_NAMESPACE_STD
62
63#endif // _LIBCPP___MEMORY_ALIGNED_ALLOC_H
lib/libcxx/include/__memory/allocator_traits.h+61-1
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H
1212
1313#include <__config>
14#include <__cstddef/ptrdiff_t.h>
1415#include <__cstddef/size_t.h>
1516#include <__fwd/memory.h>
1617#include <__memory/construct_at.h>
......@@ -223,8 +224,13 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
223224
224225#endif // _LIBCPP_STD_VER
225226
227template <class>
228struct allocator_traits;
229
230// We have a base class that can be specialized for different allocators, since the metaprogramming to get the aliases
231// is quite expensive and the definition of these aliases is usually quite trivial in the end.
226232template <class _Alloc>
227struct allocator_traits {
233struct __allocator_traits_base {
228234 using allocator_type = _Alloc;
229235 using value_type = typename allocator_type::value_type;
230236 using pointer = __pointer<value_type, allocator_type>;
......@@ -253,6 +259,60 @@ struct allocator_traits {
253259 using other = allocator_traits<typename rebind_alloc<_Tp>::other>;
254260 };
255261#endif // _LIBCPP_CXX03_LANG
262};
263
264template <class _Tp>
265struct __allocator_traits_base<allocator<_Tp> > {
266 using allocator_type = allocator<_Tp>;
267 using value_type = _Tp;
268 using pointer = _Tp*;
269 using const_pointer = const _Tp*;
270 using void_pointer = void*;
271 using const_void_pointer = const void*;
272 using difference_type = ptrdiff_t;
273 using size_type = size_t;
274 using propagate_on_container_copy_assignment = false_type;
275 using propagate_on_container_move_assignment = true_type;
276 using propagate_on_container_swap = false_type;
277 using is_always_equal = true_type;
278
279#ifndef _LIBCPP_CXX03_LANG
280 template <class _Up>
281 using rebind_alloc = allocator<_Up>;
282 template <class _Up>
283 using rebind_traits = allocator_traits<allocator<_Up> >;
284#else
285 template <class _Up>
286 struct rebind_alloc {
287 using other = allocator<_Up>;
288 };
289 template <class _Up>
290 struct rebind_traits {
291 using other = allocator_traits<allocator<_Up> >;
292 };
293#endif
294};
295
296template <class _Alloc>
297struct allocator_traits : __allocator_traits_base<_Alloc> {
298 using __base _LIBCPP_NODEBUG = __allocator_traits_base<_Alloc>;
299
300 using allocator_type = typename __base::allocator_type;
301 using value_type = typename __base::value_type;
302 using pointer = typename __base::pointer;
303 using const_pointer = typename __base::const_pointer;
304 using void_pointer = typename __base::void_pointer;
305 using const_void_pointer = typename __base::const_void_pointer;
306 using difference_type = typename __base::difference_type;
307 using size_type = typename __base::size_type;
308 using propagate_on_container_copy_assignment = typename __base::propagate_on_container_copy_assignment;
309 using propagate_on_container_move_assignment = typename __base::propagate_on_container_move_assignment;
310 using is_always_equal = typename __base::is_always_equal;
311
312 template <class _Tp>
313 using rebind_alloc = typename __base::template rebind_alloc<_Tp>;
314 template <class _Tp>
315 using rebind_traits = typename __base::template rebind_traits<_Tp>;
256316
257317 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
258318 allocate(allocator_type& __a, size_type __n) {
lib/libcxx/include/__memory/compressed_pair.h+4-29
......@@ -20,8 +20,6 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523// ================================================================================================================== //
2624// The utilites here are for staying ABI compatible with the legacy `__compressed_pair`. They should not be used //
2725// for new data structures. Use `_LIBCPP_NO_UNIQUE_ADDRESS` for new data structures instead (but make sure you //
......@@ -59,6 +57,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5957
6058#ifndef _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
6159
60_LIBCPP_BEGIN_NAMESPACE_STD
61
6262template <class _Tp>
6363inline const size_t __compressed_pair_alignment = _LIBCPP_ALIGNOF(_Tp);
6464
......@@ -94,16 +94,6 @@ class __compressed_pair_padding<_ToPad, true> {};
9494 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
9595 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
9696 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _)
97
98# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
99 _LIBCPP_NO_UNIQUE_ADDRESS \
100 __attribute__((__aligned__(::std::__compressed_pair_alignment<T2>), \
101 __aligned__(::std::__compressed_pair_alignment<T3>))) T1 Initializer1; \
102 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
103 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
104 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
105 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \
106 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _)
10797# else
10898# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \
10999 struct { \
......@@ -112,31 +102,16 @@ class __compressed_pair_padding<_ToPad, true> {};
112102 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
113103 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
114104 }
115
116# define _LIBCPP_COMPRESSED_TRIPLE(T1, Initializer1, T2, Initializer2, T3, Initializer3) \
117 struct { \
118 _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1; \
119 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T1> _LIBCPP_CONCAT3(__padding1_, __LINE__, _); \
120 _LIBCPP_NO_UNIQUE_ADDRESS T2 Initializer2; \
121 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T2> _LIBCPP_CONCAT3(__padding2_, __LINE__, _); \
122 _LIBCPP_NO_UNIQUE_ADDRESS T3 Initializer3; \
123 _LIBCPP_NO_UNIQUE_ADDRESS ::std::__compressed_pair_padding<T3> _LIBCPP_CONCAT3(__padding3_, __LINE__, _); \
124 }
125105# endif
126106
107_LIBCPP_END_NAMESPACE_STD
108
127109#else
128110# define _LIBCPP_COMPRESSED_ELEMENT(T1, Initializer1) _LIBCPP_NO_UNIQUE_ADDRESS T1 Initializer1
129111
130112# define _LIBCPP_COMPRESSED_PAIR(T1, Name1, T2, Name2) \
131113 _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \
132114 _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2
133
134# define _LIBCPP_COMPRESSED_TRIPLE(T1, Name1, T2, Name2, T3, Name3) \
135 _LIBCPP_NO_UNIQUE_ADDRESS T1 Name1; \
136 _LIBCPP_NO_UNIQUE_ADDRESS T2 Name2; \
137 _LIBCPP_NO_UNIQUE_ADDRESS T3 Name3
138115#endif // _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING
139116
140_LIBCPP_END_NAMESPACE_STD
141
142117#endif // _LIBCPP___MEMORY_COMPRESSED_PAIR_H
lib/libcxx/include/__memory/inout_ptr.h+5-6
......@@ -11,10 +11,9 @@
1111#define _LIBCPP___INOUT_PTR_H
1212
1313#include <__config>
14#include <__fwd/memory.h>
1415#include <__memory/addressof.h>
1516#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>
1817#include <__type_traits/is_pointer.h>
1918#include <__type_traits/is_same.h>
2019#include <__type_traits/is_specialization.h>
......@@ -30,10 +29,10 @@
3029_LIBCPP_PUSH_MACROS
3130#include <__undef_macros>
3231
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3532#if _LIBCPP_STD_VER >= 23
3633
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3736template <class _Smart, class _Pointer, class... _Args>
3837class inout_ptr_t {
3938 static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr.");
......@@ -101,10 +100,10 @@ template <class _Pointer = void, class _Smart, class... _Args>
101100 return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
102101}
103102
104#endif // _LIBCPP_STD_VER >= 23
105
106103_LIBCPP_END_NAMESPACE_STD
107104
105#endif // _LIBCPP_STD_VER >= 23
106
108107_LIBCPP_POP_MACROS
109108
110109#endif // _LIBCPP___INOUT_PTR_H
lib/libcxx/include/__memory/is_sufficiently_aligned.h+6-1
......@@ -20,11 +20,16 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23template <size_t _Alignment, class _Tp>
24[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool __is_sufficiently_aligned(_Tp* __ptr) {
25 return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0;
26}
27
2328#if _LIBCPP_STD_VER >= 26
2429
2530template <size_t _Alignment, class _Tp>
2631[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool is_sufficiently_aligned(_Tp* __ptr) {
27 return reinterpret_cast<uintptr_t>(__ptr) % _Alignment == 0;
32 return std::__is_sufficiently_aligned<_Alignment>(__ptr);
2833}
2934
3035#endif // _LIBCPP_STD_VER >= 26
lib/libcxx/include/__memory/out_ptr.h+5-6
......@@ -11,10 +11,9 @@
1111#define _LIBCPP___OUT_PTR_H
1212
1313#include <__config>
14#include <__fwd/memory.h>
1415#include <__memory/addressof.h>
1516#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>
1817#include <__type_traits/is_pointer.h>
1918#include <__type_traits/is_specialization.h>
2019#include <__type_traits/is_void.h>
......@@ -29,10 +28,10 @@
2928_LIBCPP_PUSH_MACROS
3029#include <__undef_macros>
3130
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3431#if _LIBCPP_STD_VER >= 23
3532
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3635template <class _Smart, class _Pointer, class... _Args>
3736class out_ptr_t {
3837 static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0,
......@@ -93,10 +92,10 @@ template <class _Pointer = void, class _Smart, class... _Args>
9392 return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
9493}
9594
96#endif // _LIBCPP_STD_VER >= 23
97
9895_LIBCPP_END_NAMESPACE_STD
9996
97#endif // _LIBCPP_STD_VER >= 23
98
10099_LIBCPP_POP_MACROS
101100
102101#endif // _LIBCPP___OUT_PTR_H
lib/libcxx/include/__memory/pointer_traits.h+20-35
......@@ -14,12 +14,10 @@
1414#include <__cstddef/ptrdiff_t.h>
1515#include <__memory/addressof.h>
1616#include <__type_traits/conditional.h>
17#include <__type_traits/conjunction.h>
1817#include <__type_traits/decay.h>
1918#include <__type_traits/detected_or.h>
2019#include <__type_traits/enable_if.h>
2120#include <__type_traits/integral_constant.h>
22#include <__type_traits/is_class.h>
2321#include <__type_traits/is_function.h>
2422#include <__type_traits/is_void.h>
2523#include <__type_traits/nat.h>
......@@ -139,9 +137,6 @@ using __rebind_pointer_t _LIBCPP_NODEBUG = typename pointer_traits<_From>::templ
139137
140138// to_address
141139
142template <class _Pointer, class = void>
143struct __to_address_helper;
144
145140template <class _Tp>
146141_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __to_address(_Tp* __p) _NOEXCEPT {
147142 static_assert(!is_function<_Tp>::value, "_Tp is a function type");
......@@ -149,48 +144,38 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __to_address(_Tp* __p) _NOEXCEPT {
149144}
150145
151146template <class _Pointer, class = void>
152struct _HasToAddress : false_type {};
147inline const bool __has_to_address_v = false;
153148
154149template <class _Pointer>
155struct _HasToAddress<_Pointer, decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>())) >
156 : true_type {};
150inline const bool
151 __has_to_address_v<_Pointer,
152 decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> = true;
157153
158154template <class _Pointer, class = void>
159struct _HasArrow : false_type {};
160
161template <class _Pointer>
162struct _HasArrow<_Pointer, decltype((void)std::declval<const _Pointer&>().operator->()) > : true_type {};
155inline const bool __has_arrow_v = false;
163156
164157template <class _Pointer>
165struct _IsFancyPointer {
166 static const bool value = _HasArrow<_Pointer>::value || _HasToAddress<_Pointer>::value;
167};
158inline const bool __has_arrow_v<_Pointer, decltype((void)std::declval<const _Pointer&>().operator->()) > = true;
168159
169// enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers
170template <class _Pointer, __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value, int> = 0>
171_LIBCPP_HIDE_FROM_ABI
172_LIBCPP_CONSTEXPR __decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>
160template <class _Pointer, __enable_if_t<__has_to_address_v<_Pointer>, int> = 0>
161_LIBCPP_CONSTEXPR __decay_t<decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))>
173162__to_address(const _Pointer& __p) _NOEXCEPT {
174 return __to_address_helper<_Pointer>::__call(__p);
163 return pointer_traits<_Pointer>::to_address(__p);
175164}
176165
177template <class _Pointer, class>
178struct __to_address_helper {
179 _LIBCPP_HIDE_FROM_ABI
180 _LIBCPP_CONSTEXPR static decltype(std::__to_address(std::declval<const _Pointer&>().operator->()))
181 __call(const _Pointer& __p) _NOEXCEPT {
182 return std::__to_address(__p.operator->());
183 }
184};
166template <class _Pointer>
167struct __to_address_arrow_result;
185168
169template <class _Pointer, __enable_if_t<!__has_to_address_v<_Pointer> && __has_arrow_v<_Pointer>, int> = 0>
170_LIBCPP_CONSTEXPR typename __to_address_arrow_result<_Pointer>::type __to_address(const _Pointer& __p) _NOEXCEPT {
171 return std::__to_address(__p.operator->());
172}
173
174// The return type needs to see all `__to_address` overloads, so this is delayed until after all the overloads have been
175// defined. This could also be moved to a trailing return type, but that's not available in C++03.
186176template <class _Pointer>
187struct __to_address_helper<_Pointer,
188 decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> {
189 _LIBCPP_HIDE_FROM_ABI
190 _LIBCPP_CONSTEXPR static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
191 __call(const _Pointer& __p) _NOEXCEPT {
192 return pointer_traits<_Pointer>::to_address(__p);
193 }
177struct __to_address_arrow_result {
178 using type _LIBCPP_NODEBUG = __decay_t<decltype(std::__to_address(std::declval<const _Pointer&>().operator->()))>;
194179};
195180
196181#if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__memory/ranges_uninitialized_algorithms.h+29-26
......@@ -44,14 +44,16 @@ namespace ranges {
4444struct __uninitialized_default_construct {
4545 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
4646 requires default_initializable<iter_value_t<_ForwardIterator>>
47 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
47 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
48 operator()(_ForwardIterator __first, _Sentinel __last) const {
4849 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
4950 return std::__uninitialized_default_construct<_ValueType>(std::move(__first), std::move(__last));
5051 }
5152
5253 template <__nothrow_forward_range _ForwardRange>
5354 requires default_initializable<range_value_t<_ForwardRange>>
54 _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const {
55 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_ForwardRange>
56 operator()(_ForwardRange&& __range) const {
5557 return (*this)(ranges::begin(__range), ranges::end(__range));
5658 }
5759};
......@@ -65,7 +67,7 @@ inline constexpr auto uninitialized_default_construct = __uninitialized_default_
6567struct __uninitialized_default_construct_n {
6668 template <__nothrow_forward_iterator _ForwardIterator>
6769 requires default_initializable<iter_value_t<_ForwardIterator>>
68 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
70 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
6971 operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n) const {
7072 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
7173 return std::__uninitialized_default_construct_n<_ValueType>(std::move(__first), __n);
......@@ -81,14 +83,16 @@ inline constexpr auto uninitialized_default_construct_n = __uninitialized_defaul
8183struct __uninitialized_value_construct {
8284 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel>
8385 requires default_initializable<iter_value_t<_ForwardIterator>>
84 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last) const {
86 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
87 operator()(_ForwardIterator __first, _Sentinel __last) const {
8588 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
8689 return std::__uninitialized_value_construct<_ValueType>(std::move(__first), std::move(__last));
8790 }
8891
8992 template <__nothrow_forward_range _ForwardRange>
9093 requires default_initializable<range_value_t<_ForwardRange>>
91 _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range) const {
94 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_ForwardRange>
95 operator()(_ForwardRange&& __range) const {
9296 return (*this)(ranges::begin(__range), ranges::end(__range));
9397 }
9498};
......@@ -102,7 +106,7 @@ inline constexpr auto uninitialized_value_construct = __uninitialized_value_cons
102106struct __uninitialized_value_construct_n {
103107 template <__nothrow_forward_iterator _ForwardIterator>
104108 requires default_initializable<iter_value_t<_ForwardIterator>>
105 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
109 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
106110 operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n) const {
107111 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
108112 return std::__uninitialized_value_construct_n<_ValueType>(std::move(__first), __n);
......@@ -118,14 +122,16 @@ inline constexpr auto uninitialized_value_construct_n = __uninitialized_value_co
118122struct __uninitialized_fill {
119123 template <__nothrow_forward_iterator _ForwardIterator, __nothrow_sentinel_for<_ForwardIterator> _Sentinel, class _Tp>
120124 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
121 _LIBCPP_HIDE_FROM_ABI _ForwardIterator operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const {
125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
126 operator()(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) const {
122127 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
123128 return std::__uninitialized_fill<_ValueType>(std::move(__first), std::move(__last), __x);
124129 }
125130
126131 template <__nothrow_forward_range _ForwardRange, class _Tp>
127132 requires constructible_from<range_value_t<_ForwardRange>, const _Tp&>
128 _LIBCPP_HIDE_FROM_ABI borrowed_iterator_t<_ForwardRange> operator()(_ForwardRange&& __range, const _Tp& __x) const {
133 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 borrowed_iterator_t<_ForwardRange>
134 operator()(_ForwardRange&& __range, const _Tp& __x) const {
129135 return (*this)(ranges::begin(__range), ranges::end(__range), __x);
130136 }
131137};
......@@ -139,7 +145,7 @@ inline constexpr auto uninitialized_fill = __uninitialized_fill{};
139145struct __uninitialized_fill_n {
140146 template <__nothrow_forward_iterator _ForwardIterator, class _Tp>
141147 requires constructible_from<iter_value_t<_ForwardIterator>, const _Tp&>
142 _LIBCPP_HIDE_FROM_ABI _ForwardIterator
148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
143149 operator()(_ForwardIterator __first, iter_difference_t<_ForwardIterator> __n, const _Tp& __x) const {
144150 using _ValueType = remove_reference_t<iter_reference_t<_ForwardIterator>>;
145151 return std::__uninitialized_fill_n<_ValueType>(std::move(__first), __n, __x);
......@@ -161,20 +167,20 @@ struct __uninitialized_copy {
161167 __nothrow_forward_iterator _OutputIterator,
162168 __nothrow_sentinel_for<_OutputIterator> _Sentinel2>
163169 requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
164 _LIBCPP_HIDE_FROM_ABI uninitialized_copy_result<_InputIterator, _OutputIterator>
170 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 uninitialized_copy_result<_InputIterator, _OutputIterator>
165171 operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
166172 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
167173
168174 auto __stop_copying = [&__olast](auto&& __out_iter) -> bool { return __out_iter == __olast; };
169 auto __result = std::__uninitialized_copy<_ValueType>(
175 return std::__uninitialized_copy<_ValueType>(
170176 std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __stop_copying);
171 return {std::move(__result.first), std::move(__result.second)};
172177 }
173178
174179 template <input_range _InputRange, __nothrow_forward_range _OutputRange>
175180 requires constructible_from<range_value_t<_OutputRange>, range_reference_t<_InputRange>>
176 _LIBCPP_HIDE_FROM_ABI uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
177 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
182 uninitialized_copy_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
183 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
178184 return (*this)(
179185 ranges::begin(__in_range), ranges::end(__in_range), ranges::begin(__out_range), ranges::end(__out_range));
180186 }
......@@ -194,16 +200,14 @@ struct __uninitialized_copy_n {
194200 __nothrow_forward_iterator _OutputIterator,
195201 __nothrow_sentinel_for<_OutputIterator> _Sentinel>
196202 requires constructible_from<iter_value_t<_OutputIterator>, iter_reference_t<_InputIterator>>
197 _LIBCPP_HIDE_FROM_ABI uninitialized_copy_n_result<_InputIterator, _OutputIterator>
203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 uninitialized_copy_n_result<_InputIterator, _OutputIterator>
198204 operator()(_InputIterator __ifirst,
199205 iter_difference_t<_InputIterator> __n,
200206 _OutputIterator __ofirst,
201207 _Sentinel __olast) const {
202208 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
203209 auto __stop_copying = [&__olast](auto&& __out_iter) -> bool { return __out_iter == __olast; };
204 auto __result =
205 std::__uninitialized_copy_n<_ValueType>(std::move(__ifirst), __n, std::move(__ofirst), __stop_copying);
206 return {std::move(__result.first), std::move(__result.second)};
210 return std::__uninitialized_copy_n<_ValueType>(std::move(__ifirst), __n, std::move(__ofirst), __stop_copying);
207211 }
208212};
209213
......@@ -222,20 +226,20 @@ struct __uninitialized_move {
222226 __nothrow_forward_iterator _OutputIterator,
223227 __nothrow_sentinel_for<_OutputIterator> _Sentinel2>
224228 requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>>
225 _LIBCPP_HIDE_FROM_ABI uninitialized_move_result<_InputIterator, _OutputIterator>
229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 uninitialized_move_result<_InputIterator, _OutputIterator>
226230 operator()(_InputIterator __ifirst, _Sentinel1 __ilast, _OutputIterator __ofirst, _Sentinel2 __olast) const {
227231 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
228232 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); };
229233 auto __stop_moving = [&__olast](auto&& __out_iter) -> bool { return __out_iter == __olast; };
230 auto __result = std::__uninitialized_move<_ValueType>(
234 return std::__uninitialized_move<_ValueType>(
231235 std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __stop_moving, __iter_move);
232 return {std::move(__result.first), std::move(__result.second)};
233236 }
234237
235238 template <input_range _InputRange, __nothrow_forward_range _OutputRange>
236239 requires constructible_from<range_value_t<_OutputRange>, range_rvalue_reference_t<_InputRange>>
237 _LIBCPP_HIDE_FROM_ABI uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
238 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
240 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
241 uninitialized_move_result<borrowed_iterator_t<_InputRange>, borrowed_iterator_t<_OutputRange>>
242 operator()(_InputRange&& __in_range, _OutputRange&& __out_range) const {
239243 return (*this)(
240244 ranges::begin(__in_range), ranges::end(__in_range), ranges::begin(__out_range), ranges::end(__out_range));
241245 }
......@@ -255,7 +259,7 @@ struct __uninitialized_move_n {
255259 __nothrow_forward_iterator _OutputIterator,
256260 __nothrow_sentinel_for<_OutputIterator> _Sentinel>
257261 requires constructible_from<iter_value_t<_OutputIterator>, iter_rvalue_reference_t<_InputIterator>>
258 _LIBCPP_HIDE_FROM_ABI uninitialized_move_n_result<_InputIterator, _OutputIterator>
262 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 uninitialized_move_n_result<_InputIterator, _OutputIterator>
259263 operator()(_InputIterator __ifirst,
260264 iter_difference_t<_InputIterator> __n,
261265 _OutputIterator __ofirst,
......@@ -263,9 +267,8 @@ struct __uninitialized_move_n {
263267 using _ValueType = remove_reference_t<iter_reference_t<_OutputIterator>>;
264268 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return ranges::iter_move(__iter); };
265269 auto __stop_moving = [&__olast](auto&& __out_iter) -> bool { return __out_iter == __olast; };
266 auto __result = std::__uninitialized_move_n<_ValueType>(
270 return std::__uninitialized_move_n<_ValueType>(
267271 std::move(__ifirst), __n, std::move(__ofirst), __stop_moving, __iter_move);
268 return {std::move(__result.first), std::move(__result.second)};
269272 }
270273};
271274
lib/libcxx/include/__memory/raw_storage_iterator.h+4-4
......@@ -21,13 +21,13 @@
2121# pragma GCC system_header
2222#endif
2323
24#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
25
2426_LIBCPP_PUSH_MACROS
2527#include <__undef_macros>
2628
2729_LIBCPP_BEGIN_NAMESPACE_STD
2830
29#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
30
3131template <class _OutputIterator, class _Tp>
3232class _LIBCPP_DEPRECATED_IN_CXX17 raw_storage_iterator
3333 : public __iterator_base<raw_storage_iterator<_OutputIterator, _Tp>, output_iterator_tag, void, void, void, void> {
......@@ -71,10 +71,10 @@ public:
7171# endif
7272};
7373
74#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
75
7674_LIBCPP_END_NAMESPACE_STD
7775
7876_LIBCPP_POP_MACROS
7977
78#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR)
79
8080#endif // _LIBCPP___MEMORY_RAW_STORAGE_ITERATOR_H
lib/libcxx/include/__memory/shared_count.h+2
......@@ -18,6 +18,7 @@
1818#endif
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
21_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2122
2223// NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively)
2324// should be sufficient for thread safety.
......@@ -111,6 +112,7 @@ private:
111112 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
112113};
113114
115_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
114116_LIBCPP_END_NAMESPACE_STD
115117
116118#endif // _LIBCPP___MEMORY_SHARED_COUNT_H
lib/libcxx/include/__memory/shared_ptr.h+209-277
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___MEMORY_SHARED_PTR_H
1111#define _LIBCPP___MEMORY_SHARED_PTR_H
1212
13#include <__atomic/memory_order.h>
1314#include <__compare/compare_three_way.h>
1415#include <__compare/ordering.h>
1516#include <__config>
......@@ -27,19 +28,17 @@
2728#include <__memory/allocator_destructor.h>
2829#include <__memory/allocator_traits.h>
2930#include <__memory/auto_ptr.h>
30#include <__memory/compressed_pair.h>
3131#include <__memory/construct_at.h>
3232#include <__memory/destroy.h>
3333#include <__memory/pointer_traits.h>
3434#include <__memory/shared_count.h>
3535#include <__memory/uninitialized_algorithms.h>
36#include <__memory/uninitialized_multidimensional_algorithms.h>
3637#include <__memory/unique_ptr.h>
3738#include <__type_traits/add_reference.h>
3839#include <__type_traits/conditional.h>
3940#include <__type_traits/conjunction.h>
40#include <__type_traits/disjunction.h>
4141#include <__type_traits/enable_if.h>
42#include <__type_traits/integral_constant.h>
4342#include <__type_traits/is_array.h>
4443#include <__type_traits/is_constructible.h>
4544#include <__type_traits/is_convertible.h>
......@@ -47,10 +46,11 @@
4746#include <__type_traits/is_reference.h>
4847#include <__type_traits/is_same.h>
4948#include <__type_traits/nat.h>
50#include <__type_traits/negation.h>
5149#include <__type_traits/remove_cv.h>
5250#include <__type_traits/remove_extent.h>
51#include <__type_traits/remove_pointer.h>
5352#include <__type_traits/remove_reference.h>
53#include <__type_traits/void_t.h>
5454#include <__utility/declval.h>
5555#include <__utility/exception_guard.h>
5656#include <__utility/forward.h>
......@@ -58,9 +58,6 @@
5858#include <__utility/swap.h>
5959#include <__verbose_abort>
6060#include <typeinfo>
61#if _LIBCPP_HAS_ATOMIC_HEADER
62# include <__atomic/memory_order.h>
63#endif
6461
6562#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6663# pragma GCC system_header
......@@ -70,6 +67,7 @@ _LIBCPP_PUSH_MACROS
7067#include <__undef_macros>
7168
7269_LIBCPP_BEGIN_NAMESPACE_STD
70_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
7371
7472class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception {
7573public:
......@@ -92,47 +90,36 @@ template <class _Tp>
9290class weak_ptr;
9391
9492template <class _Tp, class _Dp, class _Alloc>
95class __shared_ptr_pointer : public __shared_weak_count {
96 _LIBCPP_COMPRESSED_TRIPLE(_Tp, __ptr_, _Dp, __deleter_, _Alloc, __alloc_);
93class _LIBCPP_HIDE_STRUCT_FROM_ABI __shared_ptr_pointer final : public __shared_weak_count {
94 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
95 _LIBCPP_NO_UNIQUE_ADDRESS _Dp __deleter_;
96 _LIBCPP_NO_UNIQUE_ADDRESS _Tp __ptr_;
9797
9898public:
9999 _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a)
100 : __ptr_(__p), __deleter_(std::move(__d)), __alloc_(std::move(__a)) {}
100 : __alloc_(std::move(__a)), __deleter_(std::move(__d)), __ptr_(__p) {}
101101
102102#if _LIBCPP_HAS_RTTI
103 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override;
103 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info& __t) const _NOEXCEPT override {
104 return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr;
105 }
104106#endif
105107
106108private:
107 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override;
108 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override;
109};
110
111#if _LIBCPP_HAS_RTTI
112
113template <class _Tp, class _Dp, class _Alloc>
114const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT {
115 return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr;
116}
117
118#endif // _LIBCPP_HAS_RTTI
109 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override {
110 __deleter_(__ptr_);
111 __ptr_.~_Tp();
112 __deleter_.~_Dp();
113 }
119114
120template <class _Tp, class _Dp, class _Alloc>
121void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT {
122 __deleter_(__ptr_);
123 __deleter_.~_Dp();
124}
115 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override {
116 using __alloc_t = __allocator_traits_rebind_t<_Alloc, __shared_ptr_pointer>;
125117
126template <class _Tp, class _Dp, class _Alloc>
127void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT {
128 typedef typename __allocator_traits_rebind<_Alloc, __shared_ptr_pointer>::type _Al;
129 typedef allocator_traits<_Al> _ATraits;
130 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
131
132 _Al __a(__alloc_);
133 __alloc_.~_Alloc();
134 __a.deallocate(_PTraits::pointer_to(*this), 1);
135}
118 __alloc_t __a(__alloc_);
119 __alloc_.~_Alloc();
120 __a.deallocate(pointer_traits<typename allocator_traits<__alloc_t>::pointer>::pointer_to(*this), 1);
121 }
122};
136123
137124// This tag is used to instantiate an allocator type. The various shared_ptr control blocks
138125// detect that the allocator has been instantiated for this type and perform alternative
......@@ -140,79 +127,54 @@ void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT {
140127struct __for_overwrite_tag {};
141128
142129template <class _Tp, class _Alloc>
143struct __shared_ptr_emplace : __shared_weak_count {
144 using __value_type _LIBCPP_NODEBUG = __remove_cv_t<_Tp>;
130struct _LIBCPP_HIDE_STRUCT_FROM_ABI __shared_ptr_emplace : __shared_weak_count {
131 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<_Alloc>;
132 using __value_type _LIBCPP_NODEBUG = __remove_cv_t<_Tp>;
145133
146 template <class... _Args,
147 class _Allocator = _Alloc,
148 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
149 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&...) : __storage_(std::move(__a)) {
150 static_assert(
151 sizeof...(_Args) == 0, "No argument should be provided to the control block when using _for_overwrite");
152 ::new (static_cast<void*>(__get_elem())) __value_type;
134 template <class... _Args>
135 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __alloc_(std::move(__a)) {
136 allocator_traits<_Alloc>::construct(__alloc_, __get_elem(), std::forward<_Args>(__args)...);
153137 }
154138
155 template <class... _Args,
156 class _Allocator = _Alloc,
157 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
158 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) {
159 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __value_type>::type;
160 _TpAlloc __tmp(*__get_alloc());
161 allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...);
162 }
163
164 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT { return __storage_.__get_alloc(); }
165
166 _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT { return __storage_.__get_elem(); }
139 _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT { return reinterpret_cast<__value_type*>(__buffer_); }
167140
168141private:
169 template <class _Allocator = _Alloc,
170 __enable_if_t<is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
171 _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT {
172 __get_elem()->~__value_type();
173 }
174
175 template <class _Allocator = _Alloc,
176 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
177 _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT {
178 using _TpAlloc = typename __allocator_traits_rebind<_Allocator, __remove_cv_t<_Tp> >::type;
179 _TpAlloc __tmp(*__get_alloc());
180 allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem());
142 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override {
143 allocator_traits<_Alloc>::destroy(__alloc_, __get_elem());
181144 }
182145
183 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { __on_zero_shared_impl(); }
184
185146 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override {
186 using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, __shared_ptr_emplace>::type;
187 using _ControlBlockPointer = typename allocator_traits<_ControlBlockAlloc>::pointer;
188 _ControlBlockAlloc __tmp(*__get_alloc());
189 __storage_.~_Storage();
190 allocator_traits<_ControlBlockAlloc>::deallocate(__tmp, pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
147 using __alloc_t = __allocator_traits_rebind_t<_Alloc, __shared_ptr_emplace>;
148 __alloc_t __tmp(__alloc_);
149 __alloc_.~_Alloc();
150 allocator_traits<__alloc_t>::deallocate(
151 __tmp, pointer_traits<typename allocator_traits<__alloc_t>::pointer>::pointer_to(*this), 1);
191152 }
192153
193 // TODO: It should be possible to refactor this to remove `_Storage` entirely.
194 // This class implements the control block for non-array shared pointers created
195 // through `std::allocate_shared` and `std::make_shared`.
196 struct _Storage {
197 struct _Data {
198 _LIBCPP_COMPRESSED_PAIR(_Alloc, __alloc_, __value_type, __elem_);
199 };
154 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
155 _ALIGNAS_TYPE(__value_type) char __buffer_[sizeof(__value_type)];
156};
200157
201 _ALIGNAS_TYPE(_Data) char __buffer_[sizeof(_Data)];
158template <class _Tp, class _Alloc>
159struct _LIBCPP_HIDE_STRUCT_FROM_ABI __shared_ptr_emplace_for_overwrite : __shared_weak_count {
160 using __value_type _LIBCPP_NODEBUG = __remove_cv_t<_Tp>;
202161
203 _LIBCPP_HIDE_FROM_ABI explicit _Storage(_Alloc&& __a) { ::new ((void*)__get_alloc()) _Alloc(std::move(__a)); }
204 _LIBCPP_HIDE_FROM_ABI ~_Storage() { __get_alloc()->~_Alloc(); }
162 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace_for_overwrite(_Alloc __a) : __alloc_(std::move(__a)) {}
205163
206 _LIBCPP_HIDE_FROM_ABI _Alloc* __get_alloc() _NOEXCEPT {
207 return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__alloc_);
208 }
164 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared() _NOEXCEPT override { __value_.~__value_type(); }
165 _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override {
166 using __alloc_t = __allocator_traits_rebind_t<_Alloc, __shared_ptr_emplace_for_overwrite>;
167 using __alloc_traits = allocator_traits<__alloc_t>;
168 __alloc_t __tmp(__alloc_);
169 __alloc_.~_Alloc();
170 __alloc_traits::deallocate(__tmp, pointer_traits<typename __alloc_traits::pointer>::pointer_to(*this), 1);
171 }
209172
210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI __value_type* __get_elem() _NOEXCEPT {
211 return std::addressof(reinterpret_cast<_Data*>(__buffer_)->__elem_);
212 }
213 };
173 _LIBCPP_HIDE_FROM_ABI __value_type* __get_elem() _NOEXCEPT { return std::addressof(__value_); }
214174
215 _Storage __storage_;
175private:
176 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
177 _LIBCPP_NO_UNIQUE_ADDRESS __value_type __value_;
216178};
217179
218180struct __shared_ptr_dummy_rebind_allocator_type;
......@@ -233,16 +195,16 @@ class enable_shared_from_this;
233195// when either Y* is convertible to T* or Y is U[N] and T is cv U[].
234196#if _LIBCPP_STD_VER >= 17
235197template <class _Yp, class _Tp>
236struct __bounded_convertible_to_unbounded : false_type {};
198inline const bool __bounded_convertible_to_unbounded_v = false;
237199
238200template <class _Up, std::size_t _Np, class _Tp>
239struct __bounded_convertible_to_unbounded<_Up[_Np], _Tp> : is_same<__remove_cv_t<_Tp>, _Up[]> {};
201inline const bool __bounded_convertible_to_unbounded_v<_Up[_Np], _Tp> = is_same_v<remove_cv_t<_Tp>, _Up[]>;
240202
241203template <class _Yp, class _Tp>
242struct __compatible_with : _Or< is_convertible<_Yp*, _Tp*>, __bounded_convertible_to_unbounded<_Yp, _Tp> > {};
204inline const bool __compatible_with_v = is_convertible_v<_Yp*, _Tp*> || __bounded_convertible_to_unbounded_v<_Yp, _Tp>;
243205#else
244206template <class _Yp, class _Tp>
245struct __compatible_with : is_convertible<_Yp*, _Tp*> {};
207inline const bool __compatible_with_v = is_convertible<_Yp*, _Tp*>::value;
246208#endif // _LIBCPP_STD_VER >= 17
247209
248210// Constructors that take raw pointers have a different set of "compatible" constraints
......@@ -252,49 +214,46 @@ struct __compatible_with : is_convertible<_Yp*, _Tp*> {};
252214// - If T is not an array type, then Y* is convertible to T*.
253215#if _LIBCPP_STD_VER >= 17
254216template <class _Yp, class _Tp, class = void>
255struct __raw_pointer_compatible_with : _And< _Not<is_array<_Tp>>, is_convertible<_Yp*, _Tp*> > {};
217inline const bool __raw_pointer_compatible_with_v = !is_array_v<_Tp> && is_convertible_v<_Yp*, _Tp*>;
256218
257219template <class _Yp, class _Up, std::size_t _Np>
258struct __raw_pointer_compatible_with<_Yp, _Up[_Np], __enable_if_t< is_convertible<_Yp (*)[_Np], _Up (*)[_Np]>::value> >
259 : true_type {};
220inline const bool
221 __raw_pointer_compatible_with_v<_Yp, _Up[_Np], enable_if_t<is_convertible_v<_Yp (*)[_Np], _Up (*)[_Np]>>> = true;
260222
261223template <class _Yp, class _Up>
262struct __raw_pointer_compatible_with<_Yp, _Up[], __enable_if_t< is_convertible<_Yp (*)[], _Up (*)[]>::value> >
263 : true_type {};
224inline const bool __raw_pointer_compatible_with_v<_Yp, _Up[], enable_if_t<is_convertible_v<_Yp (*)[], _Up (*)[]>>> =
225 true;
264226
265227#else
266228template <class _Yp, class _Tp>
267struct __raw_pointer_compatible_with : is_convertible<_Yp*, _Tp*> {};
229inline const bool __raw_pointer_compatible_with_v = is_convertible<_Yp*, _Tp*>::value;
268230#endif // _LIBCPP_STD_VER >= 17
269231
270232template <class _Ptr, class = void>
271struct __is_deletable : false_type {};
233inline const bool __is_deletable_v = false;
272234template <class _Ptr>
273struct __is_deletable<_Ptr, decltype(delete std::declval<_Ptr>())> : true_type {};
235inline const bool __is_deletable_v<_Ptr, decltype(delete std::declval<_Ptr>())> = true;
274236
275237template <class _Ptr, class = void>
276struct __is_array_deletable : false_type {};
238inline const bool __is_array_deletable_v = false;
277239template <class _Ptr>
278struct __is_array_deletable<_Ptr, decltype(delete[] std::declval<_Ptr>())> : true_type {};
279
280template <class _Dp, class _Pt, class = decltype(std::declval<_Dp>()(std::declval<_Pt>()))>
281true_type __well_formed_deleter_test(int);
240inline const bool __is_array_deletable_v<_Ptr, decltype(delete[] std::declval<_Ptr>())> = true;
282241
283template <class, class>
284false_type __well_formed_deleter_test(...);
242template <class _Dp, class _Pt, class = void>
243inline const bool __well_formed_deleter_v = false;
285244
286245template <class _Dp, class _Pt>
287struct __well_formed_deleter : decltype(std::__well_formed_deleter_test<_Dp, _Pt>(0)) {};
246inline const bool __well_formed_deleter_v<_Dp, _Pt, __void_t<decltype(std::declval<_Dp>()(std::declval<_Pt>()))> > =
247 true;
288248
289249template <class _Dp, class _Yp, class _Tp>
290struct __shared_ptr_deleter_ctor_reqs {
291 static const bool value = __raw_pointer_compatible_with<_Yp, _Tp>::value && is_move_constructible<_Dp>::value &&
292 __well_formed_deleter<_Dp, _Yp*>::value;
293};
250inline const bool __shared_ptr_deleter_ctor_reqs_v =
251 __raw_pointer_compatible_with_v<_Yp, _Tp> && is_move_constructible<_Dp>::value &&
252 __well_formed_deleter_v<_Dp, _Yp*>;
294253
295254template <class _Dp>
296using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG =
297 _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >;
255inline const bool __shared_ptr_nullptr_deleter_ctor_reqs_v =
256 is_move_constructible<_Dp>::value && __well_formed_deleter_v<_Dp, nullptr_t>;
298257
299258#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
300259# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))
......@@ -328,16 +287,15 @@ public:
328287 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
329288
330289 template <class _Yp,
331 __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp>
290 __enable_if_t<__raw_pointer_compatible_with_v<_Yp, _Tp>
332291 // In C++03 we get errors when trying to do SFINAE with the
333292 // delete operator, so we always pretend that it's deletable.
334293 // The same happens on GCC.
335#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC)
336 ,
337 _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
294#if !defined(_LIBCPP_CXX03_LANG)
295 && (is_array<_Tp>::value ? __is_array_deletable_v<_Yp*> : __is_deletable_v<_Yp*>)
338296#endif
339 >::value,
340 int> = 0>
297 ,
298 int> = 0>
341299 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) {
342300 unique_ptr<_Yp> __hold(__p);
343301 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
......@@ -347,7 +305,7 @@ public:
347305 __enable_weak_this(__p, __p);
348306 }
349307
350 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
308 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs_v<_Dp, _Yp, _Tp>, int> = 0>
351309 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) {
352310 auto __guard = std::__make_exception_guard([&] { __d(__p); });
353311 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
......@@ -361,10 +319,7 @@ public:
361319 __guard.__complete();
362320 }
363321
364 template <class _Yp,
365 class _Dp,
366 class _Alloc,
367 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
322 template <class _Yp, class _Dp, class _Alloc, __enable_if_t<__shared_ptr_deleter_ctor_reqs_v<_Dp, _Yp, _Tp>, int> = 0>
368323 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) {
369324 auto __guard = std::__make_exception_guard([&] { __d(__p); });
370325 typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk;
......@@ -387,7 +342,7 @@ public:
387342 _LIBCPP_HIDE_FROM_ABI shared_ptr(
388343 nullptr_t __p,
389344 _Dp __d,
390 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
345 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs_v<_Dp>, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
391346 : __ptr_(nullptr) {
392347 auto __guard = std::__make_exception_guard([&] { __d(__p); });
393348 typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
......@@ -405,7 +360,7 @@ public:
405360 nullptr_t __p,
406361 _Dp __d,
407362 _Alloc __a,
408 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
363 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs_v<_Dp>, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
409364 : __ptr_(nullptr) {
410365 auto __guard = std::__make_exception_guard([&] { __d(__p); });
411366 typedef __shared_ptr_pointer<nullptr_t, _Dp, _Alloc> _CntrlBlk;
......@@ -447,7 +402,7 @@ public:
447402 __cntrl_->__add_shared();
448403 }
449404
450 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
405 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
451406 _LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
452407 if (__cntrl_)
453408 __cntrl_->__add_shared();
......@@ -458,13 +413,13 @@ public:
458413 __r.__cntrl_ = nullptr;
459414 }
460415
461 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
416 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
462417 _LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
463418 __r.__ptr_ = nullptr;
464419 __r.__cntrl_ = nullptr;
465420 }
466421
467 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
422 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
468423 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r)
469424 : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) {
470425 if (__cntrl_ == nullptr)
......@@ -483,7 +438,7 @@ public:
483438
484439 template <class _Yp,
485440 class _Dp,
486 __enable_if_t<__compatible_with<_Yp, _Tp>::value &&
441 __enable_if_t<__compatible_with_v<_Yp, _Tp> &&
487442 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
488443 int> = 0>
489444 _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
......@@ -506,7 +461,7 @@ public:
506461 return *this;
507462 }
508463
509 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
464 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
510465 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT {
511466 shared_ptr(__r).swap(*this);
512467 return *this;
......@@ -517,7 +472,7 @@ public:
517472 return *this;
518473 }
519474
520 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
475 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
521476 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) {
522477 shared_ptr(std::move(__r)).swap(*this);
523478 return *this;
......@@ -535,8 +490,8 @@ public:
535490
536491 template <class _Yp,
537492 class _Dp,
538 __enable_if_t<_And< __compatible_with<_Yp, _Tp>,
539 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*> >::value,
493 __enable_if_t<__compatible_with_v<_Yp, _Tp> &&
494 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
540495 int> = 0>
541496 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) {
542497 shared_ptr(std::move(__r)).swap(*this);
......@@ -550,20 +505,17 @@ public:
550505
551506 _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { shared_ptr().swap(*this); }
552507
553 template <class _Yp, __enable_if_t<__raw_pointer_compatible_with<_Yp, _Tp>::value, int> = 0>
508 template <class _Yp, __enable_if_t<__raw_pointer_compatible_with_v<_Yp, _Tp>, int> = 0>
554509 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p) {
555510 shared_ptr(__p).swap(*this);
556511 }
557512
558 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
513 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs_v<_Dp, _Yp, _Tp>, int> = 0>
559514 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d) {
560515 shared_ptr(__p, __d).swap(*this);
561516 }
562517
563 template <class _Yp,
564 class _Dp,
565 class _Alloc,
566 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
518 template <class _Yp, class _Dp, class _Alloc, __enable_if_t<__shared_ptr_deleter_ctor_reqs_v<_Dp, _Yp, _Tp>, int> = 0>
567519 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d, _Alloc __a) {
568520 shared_ptr(__p, __d, __a).swap(*this);
569521 }
......@@ -647,7 +599,26 @@ private:
647599 }
648600 }
649601
650 _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(...) _NOEXCEPT {}
602 template <class _Vp>
603 static __type_identity<_Vp> __get_shared_from_this_impl(const enable_shared_from_this<_Vp>*);
604
605 template <class _Vp, class = void>
606 struct __get_shared_from_this {
607 using type _LIBCPP_NODEBUG = __nat;
608 };
609
610 template <class _Vp>
611 struct __get_shared_from_this<_Vp, __void_t<decltype(__get_shared_from_this_impl(static_cast<_Vp*>(nullptr)))> > {
612 using type _LIBCPP_NODEBUG = const enable_shared_from_this<typename decltype(__get_shared_from_this_impl(
613 static_cast<_Vp*>(nullptr)))::type>*;
614 };
615
616 template <
617 class _Yp,
618 class _OrigPtr,
619 __enable_if_t<!is_convertible<_OrigPtr, typename __get_shared_from_this<__remove_pointer_t<_Yp> >::type>::value,
620 int> = 0>
621 _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(_Yp, _OrigPtr) {}
651622
652623 template <class, class _Yp>
653624 struct __shared_ptr_default_delete : default_delete<_Yp> {};
......@@ -674,15 +645,22 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
674645//
675646// std::allocate_shared and std::make_shared
676647//
677template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
678[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) {
679 using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
648
649template <class _ControlBlock, class _Tp, class _Alloc, class... _Args>
650_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> __allocate_shared_impl(const _Alloc& __alloc, _Args&&... __args) {
680651 using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
681 __allocation_guard<_ControlBlockAllocator> __guard(__a, 1);
682 ::new ((void*)std::addressof(*__guard.__get())) _ControlBlock(__a, std::forward<_Args>(__args)...);
652 __allocation_guard<_ControlBlockAllocator> __guard(__alloc, 1);
653 ::new ((void*)std::addressof(*__guard.__get())) _ControlBlock(__alloc, std::forward<_Args>(__args)...);
683654 auto __control_block = __guard.__release_ptr();
684655 return shared_ptr<_Tp>::__create_with_control_block(
685 (*__control_block).__get_elem(), std::addressof(*__control_block));
656 __control_block->__get_elem(), std::__to_address(__control_block));
657}
658
659template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
660[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) {
661 using _CanonicalAlloc = __allocator_traits_rebind_t<_Alloc, __remove_cv_t<_Tp> >;
662 using _ControlBlock = __shared_ptr_emplace<_Tp, _CanonicalAlloc>;
663 return std::__allocate_shared_impl<_ControlBlock, _Tp>(_CanonicalAlloc(__a), std::forward<_Args>(__args)...);
686664}
687665
688666template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
......@@ -694,9 +672,9 @@ template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> =
694672
695673template <class _Tp, class _Alloc, __enable_if_t<!is_array<_Tp>::value, int> = 0>
696674[[nodiscard]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc& __a) {
697 using _ForOverwriteAllocator = __allocator_traits_rebind_t<_Alloc, __for_overwrite_tag>;
698 _ForOverwriteAllocator __alloc(__a);
699 return std::allocate_shared<_Tp>(__alloc);
675 using _CanonicalAlloc = __allocator_traits_rebind_t<_Alloc, remove_cv_t<_Tp>>;
676 using _ControlBlock = __shared_ptr_emplace_for_overwrite<_Tp, _CanonicalAlloc>;
677 return std::__allocate_shared_impl<_ControlBlock, _Tp>(_CanonicalAlloc(__a));
700678}
701679
702680template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>
......@@ -752,7 +730,7 @@ struct __unbounded_array_control_block<_Tp[], _Alloc> : __shared_weak_count {
752730 // [1]: https://en.wikipedia.org/wiki/Data_structure_alignment#Computing_padding
753731 size_t __bytes = __elements == 0 ? sizeof(__unbounded_array_control_block)
754732 : (__elements - 1) * sizeof(_Tp) + sizeof(__unbounded_array_control_block);
755 constexpr size_t __align = alignof(_Tp);
733 constexpr size_t __align = alignof(__unbounded_array_control_block);
756734 return (__bytes + __align - 1) & ~(__align - 1);
757735 }
758736
......@@ -1171,44 +1149,93 @@ private:
11711149 __shared_weak_count* __cntrl_;
11721150
11731151public:
1174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT;
1152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
1153
1154 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1155 _LIBCPP_HIDE_FROM_ABI weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1156 if (__cntrl_)
1157 __cntrl_->__add_weak();
1158 }
1159
1160 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1161 if (__cntrl_)
1162 __cntrl_->__add_weak();
1163 }
1164
1165 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1166 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {
1167 shared_ptr<_Yp> __s = __r.lock();
1168 *this = weak_ptr<_Tp>(__s);
1169 }
11751170
1176 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1177 _LIBCPP_HIDE_FROM_ABI weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT;
1171 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1172 __r.__ptr_ = nullptr;
1173 __r.__cntrl_ = nullptr;
1174 }
11781175
1179 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr const& __r) _NOEXCEPT;
1176 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1177 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {
1178 shared_ptr<_Yp> __s = __r.lock();
1179 *this = weak_ptr<_Tp>(__s);
1180 __r.reset();
1181 }
11801182
1181 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1182 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT;
1183 _LIBCPP_HIDE_FROM_ABI ~weak_ptr() {
1184 if (__cntrl_)
1185 __cntrl_->__release_weak();
1186 }
11831187
1184 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr&& __r) _NOEXCEPT;
1188 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT {
1189 weak_ptr(__r).swap(*this);
1190 return *this;
1191 }
11851192
1186 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1187 _LIBCPP_HIDE_FROM_ABI weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT;
1193 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1194 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT {
1195 weak_ptr(__r).swap(*this);
1196 return *this;
1197 }
11881198
1189 _LIBCPP_HIDE_FROM_ABI ~weak_ptr();
1199 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT {
1200 weak_ptr(std::move(__r)).swap(*this);
1201 return *this;
1202 }
11901203
1191 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT;
1192 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1193 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT;
1204 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1205 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT {
1206 weak_ptr(std::move(__r)).swap(*this);
1207 return *this;
1208 }
11941209
1195 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT;
1196 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1197 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT;
1210 template <class _Yp, __enable_if_t<__compatible_with_v<_Yp, _Tp>, int> = 0>
1211 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT {
1212 weak_ptr(__r).swap(*this);
1213 return *this;
1214 }
11981215
1199 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
1200 _LIBCPP_HIDE_FROM_ABI weak_ptr& operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT;
1216 _LIBCPP_HIDE_FROM_ABI void swap(weak_ptr& __r) _NOEXCEPT {
1217 std::swap(__ptr_, __r.__ptr_);
1218 std::swap(__cntrl_, __r.__cntrl_);
1219 }
12011220
1202 _LIBCPP_HIDE_FROM_ABI void swap(weak_ptr& __r) _NOEXCEPT;
1203 _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT;
1221 _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { weak_ptr().swap(*this); }
12041222
12051223 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI long use_count() const _NOEXCEPT {
12061224 return __cntrl_ ? __cntrl_->use_count() : 0;
12071225 }
1226
12081227 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool expired() const _NOEXCEPT {
12091228 return __cntrl_ == nullptr || __cntrl_->use_count() == 0;
12101229 }
1211 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> lock() const _NOEXCEPT;
1230
1231 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> lock() const _NOEXCEPT {
1232 shared_ptr<_Tp> __r;
1233 __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
1234 if (__r.__cntrl_)
1235 __r.__ptr_ = __ptr_;
1236 return __r;
1237 }
1238
12121239 template <class _Up>
12131240 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owner_before(const shared_ptr<_Up>& __r) const _NOEXCEPT {
12141241 return __cntrl_ < __r.__cntrl_;
......@@ -1229,107 +1256,11 @@ template <class _Tp>
12291256weak_ptr(shared_ptr<_Tp>) -> weak_ptr<_Tp>;
12301257#endif
12311258
1232template <class _Tp>
1233inline _LIBCPP_CONSTEXPR weak_ptr<_Tp>::weak_ptr() _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
1234
1235template <class _Tp>
1236inline weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1237 if (__cntrl_)
1238 __cntrl_->__add_weak();
1239}
1240
1241template <class _Tp>
1242template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1243inline weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1244 if (__cntrl_)
1245 __cntrl_->__add_weak();
1246}
1247
1248template <class _Tp>
1249template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1250inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {
1251 shared_ptr<_Yp> __s = __r.lock();
1252 *this = weak_ptr<_Tp>(__s);
1253}
1254
1255template <class _Tp>
1256inline weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
1257 __r.__ptr_ = nullptr;
1258 __r.__cntrl_ = nullptr;
1259}
1260
1261template <class _Tp>
1262template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1263inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {
1264 shared_ptr<_Yp> __s = __r.lock();
1265 *this = weak_ptr<_Tp>(__s);
1266 __r.reset();
1267}
1268
1269template <class _Tp>
1270weak_ptr<_Tp>::~weak_ptr() {
1271 if (__cntrl_)
1272 __cntrl_->__release_weak();
1273}
1274
1275template <class _Tp>
1276inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT {
1277 weak_ptr(__r).swap(*this);
1278 return *this;
1279}
1280
1281template <class _Tp>
1282template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1283inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT {
1284 weak_ptr(__r).swap(*this);
1285 return *this;
1286}
1287
1288template <class _Tp>
1289inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT {
1290 weak_ptr(std::move(__r)).swap(*this);
1291 return *this;
1292}
1293
1294template <class _Tp>
1295template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1296inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT {
1297 weak_ptr(std::move(__r)).swap(*this);
1298 return *this;
1299}
1300
1301template <class _Tp>
1302template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> >
1303inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT {
1304 weak_ptr(__r).swap(*this);
1305 return *this;
1306}
1307
1308template <class _Tp>
1309inline void weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT {
1310 std::swap(__ptr_, __r.__ptr_);
1311 std::swap(__cntrl_, __r.__cntrl_);
1312}
1313
13141259template <class _Tp>
13151260inline _LIBCPP_HIDE_FROM_ABI void swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT {
13161261 __x.swap(__y);
13171262}
13181263
1319template <class _Tp>
1320inline void weak_ptr<_Tp>::reset() _NOEXCEPT {
1321 weak_ptr().swap(*this);
1322}
1323
1324template <class _Tp>
1325shared_ptr<_Tp> weak_ptr<_Tp>::lock() const _NOEXCEPT {
1326 shared_ptr<_Tp> __r;
1327 __r.__cntrl_ = __cntrl_ ? __cntrl_->lock() : __cntrl_;
1328 if (__r.__cntrl_)
1329 __r.__ptr_ = __ptr_;
1330 return __r;
1331}
1332
13331264#if _LIBCPP_STD_VER >= 17
13341265template <class _Tp = void>
13351266struct owner_less;
......@@ -1536,6 +1467,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
15361467
15371468#endif // _LIBCPP_HAS_THREADS
15381469
1470_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
15391471_LIBCPP_END_NAMESPACE_STD
15401472
15411473_LIBCPP_POP_MACROS
lib/libcxx/include/__memory/temporary_buffer.h+3
......@@ -26,6 +26,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626template <class _Tp>
2727[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>
2828get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {
29 if (__n <= 0)
30 return pair<_Tp*, ptrdiff_t>();
31
2932 __unique_temporary_buffer<_Tp> __unique_buf = std::__allocate_unique_temporary_buffer<_Tp>(__n);
3033 pair<_Tp*, ptrdiff_t> __result(__unique_buf.get(), __unique_buf.get_deleter().__count_);
3134 __unique_buf.release();
lib/libcxx/include/__memory/uninitialized_algorithms.h+53-192
......@@ -11,11 +11,10 @@
1111#define _LIBCPP___MEMORY_UNINITIALIZED_ALGORITHMS_H
1212
1313#include <__algorithm/copy.h>
14#include <__algorithm/move.h>
14#include <__algorithm/in_out_result.h>
1515#include <__algorithm/unwrap_iter.h>
1616#include <__algorithm/unwrap_range.h>
1717#include <__config>
18#include <__cstddef/size_t.h>
1918#include <__fwd/memory.h>
2019#include <__iterator/iterator_traits.h>
2120#include <__iterator/reverse_iterator.h>
......@@ -25,15 +24,13 @@
2524#include <__memory/destroy.h>
2625#include <__memory/pointer_traits.h>
2726#include <__type_traits/enable_if.h>
28#include <__type_traits/extent.h>
29#include <__type_traits/is_array.h>
3027#include <__type_traits/is_constant_evaluated.h>
28#include <__type_traits/is_reference.h>
3129#include <__type_traits/is_same.h>
3230#include <__type_traits/is_trivially_assignable.h>
3331#include <__type_traits/is_trivially_constructible.h>
3432#include <__type_traits/is_trivially_relocatable.h>
3533#include <__type_traits/remove_const.h>
36#include <__type_traits/remove_extent.h>
3734#include <__utility/exception_guard.h>
3835#include <__utility/move.h>
3936#include <__utility/pair.h>
......@@ -57,7 +54,8 @@ struct __always_false {
5754// uninitialized_copy
5855
5956template <class _ValueType, class _InputIterator, class _Sentinel1, class _ForwardIterator, class _EndPredicate>
60inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_copy(
57inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __in_out_result<_InputIterator, _ForwardIterator>
58__uninitialized_copy(
6159 _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {
6260 _ForwardIterator __idx = __ofirst;
6361 auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); });
......@@ -65,22 +63,22 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali
6563 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);
6664 __guard.__complete();
6765
68 return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx));
66 return {std::move(__ifirst), std::move(__idx)};
6967}
7068
7169template <class _InputIterator, class _ForwardIterator>
72_LIBCPP_HIDE_FROM_ABI _ForwardIterator
70_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
7371uninitialized_copy(_InputIterator __ifirst, _InputIterator __ilast, _ForwardIterator __ofirst) {
7472 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
7573 auto __result = std::__uninitialized_copy<_ValueType>(
7674 std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __always_false());
77 return std::move(__result.second);
75 return std::move(__result.__out_);
7876}
7977
8078// uninitialized_copy_n
8179
8280template <class _ValueType, class _InputIterator, class _Size, class _ForwardIterator, class _EndPredicate>
83inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
81inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __in_out_result<_InputIterator, _ForwardIterator>
8482__uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) {
8583 _ForwardIterator __idx = __ofirst;
8684 auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); });
......@@ -88,22 +86,22 @@ __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __of
8886 ::new (static_cast<void*>(std::addressof(*__idx))) _ValueType(*__ifirst);
8987 __guard.__complete();
9088
91 return pair<_InputIterator, _ForwardIterator>(std::move(__ifirst), std::move(__idx));
89 return {std::move(__ifirst), std::move(__idx)};
9290}
9391
9492template <class _InputIterator, class _Size, class _ForwardIterator>
95inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
93inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
9694uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {
9795 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
9896 auto __result =
9997 std::__uninitialized_copy_n<_ValueType>(std::move(__ifirst), __n, std::move(__ofirst), __always_false());
100 return std::move(__result.second);
98 return std::move(__result.__out_);
10199}
102100
103101// uninitialized_fill
104102
105103template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>
106inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
104inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
107105__uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) {
108106 _ForwardIterator __idx = __first;
109107 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
......@@ -115,7 +113,7 @@ __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x)
115113}
116114
117115template <class _ForwardIterator, class _Tp>
118inline _LIBCPP_HIDE_FROM_ABI void
116inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
119117uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __x) {
120118 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
121119 (void)std::__uninitialized_fill<_ValueType>(__first, __last, __x);
......@@ -124,7 +122,7 @@ uninitialized_fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp&
124122// uninitialized_fill_n
125123
126124template <class _ValueType, class _ForwardIterator, class _Size, class _Tp>
127inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
125inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
128126__uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
129127 _ForwardIterator __idx = __first;
130128 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
......@@ -136,7 +134,7 @@ __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
136134}
137135
138136template <class _ForwardIterator, class _Size, class _Tp>
139inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
137inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
140138uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
141139 typedef typename iterator_traits<_ForwardIterator>::value_type _ValueType;
142140 return std::__uninitialized_fill_n<_ValueType>(__first, __n, __x);
......@@ -144,10 +142,18 @@ uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) {
144142
145143#if _LIBCPP_STD_VER >= 17
146144
145template <class _Iter>
146_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) __deref_move(_Iter& __it) {
147 if constexpr (is_lvalue_reference_v<decltype(*__it)>)
148 return std::move(*__it);
149 else
150 return *__it;
151}
152
147153// uninitialized_default_construct
148154
149155template <class _ValueType, class _ForwardIterator, class _Sentinel>
150inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
156inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
151157__uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {
152158 auto __idx = __first;
153159 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
......@@ -159,7 +165,8 @@ __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) {
159165}
160166
161167template <class _ForwardIterator>
162inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
168inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
169uninitialized_default_construct(_ForwardIterator __first, _ForwardIterator __last) {
163170 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
164171 (void)std::__uninitialized_default_construct<_ValueType>(std::move(__first), std::move(__last));
165172}
......@@ -167,7 +174,8 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat
167174// uninitialized_default_construct_n
168175
169176template <class _ValueType, class _ForwardIterator, class _Size>
170inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
177inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
178__uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
171179 auto __idx = __first;
172180 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
173181 for (; __n > 0; ++__idx, (void)--__n)
......@@ -178,7 +186,8 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_
178186}
179187
180188template <class _ForwardIterator, class _Size>
181inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
189inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
190uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) {
182191 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
183192 return std::__uninitialized_default_construct_n<_ValueType>(std::move(__first), __n);
184193}
......@@ -186,7 +195,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_default_construct_n(
186195// uninitialized_value_construct
187196
188197template <class _ValueType, class _ForwardIterator, class _Sentinel>
189inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
198inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
190199__uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {
191200 auto __idx = __first;
192201 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
......@@ -198,7 +207,8 @@ __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) {
198207}
199208
200209template <class _ForwardIterator>
201inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
210inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
211uninitialized_value_construct(_ForwardIterator __first, _ForwardIterator __last) {
202212 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
203213 (void)std::__uninitialized_value_construct<_ValueType>(std::move(__first), std::move(__last));
204214}
......@@ -206,7 +216,8 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator
206216// uninitialized_value_construct_n
207217
208218template <class _ValueType, class _ForwardIterator, class _Size>
209inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
219inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
220__uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
210221 auto __idx = __first;
211222 auto __guard = std::__make_exception_guard([&] { std::__destroy(__first, __idx); });
212223 for (; __n > 0; ++__idx, (void)--__n)
......@@ -217,7 +228,8 @@ inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(
217228}
218229
219230template <class _ForwardIterator, class _Size>
220inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
231inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
232uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) {
221233 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
222234 return std::__uninitialized_value_construct_n<_ValueType>(std::move(__first), __n);
223235}
......@@ -230,12 +242,12 @@ template <class _ValueType,
230242 class _ForwardIterator,
231243 class _EndPredicate,
232244 class _IterMove>
233inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move(
234 _InputIterator __ifirst,
235 _Sentinel1 __ilast,
236 _ForwardIterator __ofirst,
237 _EndPredicate __stop_moving,
238 _IterMove __iter_move) {
245inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __in_out_result<_InputIterator, _ForwardIterator>
246__uninitialized_move(_InputIterator __ifirst,
247 _Sentinel1 __ilast,
248 _ForwardIterator __ofirst,
249 _EndPredicate __stop_moving,
250 _IterMove __iter_move) {
239251 auto __idx = __ofirst;
240252 auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); });
241253 for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) {
......@@ -247,14 +259,14 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali
247259}
248260
249261template <class _InputIterator, class _ForwardIterator>
250inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator
262inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _ForwardIterator
251263uninitialized_move(_InputIterator __ifirst, _InputIterator __ilast, _ForwardIterator __ofirst) {
252264 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
253 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };
265 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::__deref_move(__iter); };
254266
255267 auto __result = std::__uninitialized_move<_ValueType>(
256268 std::move(__ifirst), std::move(__ilast), std::move(__ofirst), __always_false(), __iter_move);
257 return std::move(__result.second);
269 return std::move(__result.__out_);
258270}
259271
260272// uninitialized_move_n
......@@ -265,7 +277,8 @@ template <class _ValueType,
265277 class _ForwardIterator,
266278 class _EndPredicate,
267279 class _IterMove>
268inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitialized_move_n(
280inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __in_out_result<_InputIterator, _ForwardIterator>
281__uninitialized_move_n(
269282 _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) {
270283 auto __idx = __ofirst;
271284 auto __guard = std::__make_exception_guard([&] { std::__destroy(__ofirst, __idx); });
......@@ -277,166 +290,14 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali
277290}
278291
279292template <class _InputIterator, class _Size, class _ForwardIterator>
280inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
293inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<_InputIterator, _ForwardIterator>
281294uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst) {
282295 using _ValueType = typename iterator_traits<_ForwardIterator>::value_type;
283 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::move(*__iter); };
296 auto __iter_move = [](auto&& __iter) -> decltype(auto) { return std::__deref_move(__iter); };
284297
285 return std::__uninitialized_move_n<_ValueType>(
298 auto __result = std::__uninitialized_move_n<_ValueType>(
286299 std::move(__ifirst), __n, std::move(__ofirst), __always_false(), __iter_move);
287}
288
289// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling
290// Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator
291// destruction. If elements are themselves C-style arrays, they are recursively destroyed
292// in the same manner.
293//
294// This function assumes that destructors do not throw, and that the allocator is bound to
295// the correct type.
296template <class _Alloc,
297 class _BidirIter,
298 __enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0>
299_LIBCPP_HIDE_FROM_ABI constexpr void
300__allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {
301 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
302 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>,
303 "The allocator should already be rebound to the correct type");
304
305 if (__first == __last)
306 return;
307
308 if constexpr (is_array_v<_ValueType>) {
309 static_assert(!__is_unbounded_array_v<_ValueType>,
310 "arrays of unbounded arrays don't exist, but if they did we would mess up here");
311
312 using _Element = remove_extent_t<_ValueType>;
313 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
314 do {
315 --__last;
316 decltype(auto) __array = *__last;
317 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>);
318 } while (__last != __first);
319 } else {
320 do {
321 --__last;
322 allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last));
323 } while (__last != __first);
324 }
325}
326
327// Constructs the object at the given location using the allocator's construct method.
328//
329// If the object being constructed is an array, each element of the array is allocator-constructed,
330// recursively. If an exception is thrown during the construction of an array, the initialized
331// elements are destroyed in reverse order of initialization using allocator destruction.
332//
333// This function assumes that the allocator is bound to the correct type.
334template <class _Alloc, class _Tp>
335_LIBCPP_HIDE_FROM_ABI constexpr void __allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc) {
336 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
337 "The allocator should already be rebound to the correct type");
338
339 if constexpr (is_array_v<_Tp>) {
340 using _Element = remove_extent_t<_Tp>;
341 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
342 size_t __i = 0;
343 _Tp& __array = *__loc;
344
345 // If an exception is thrown, destroy what we have constructed so far in reverse order.
346 auto __guard = std::__make_exception_guard([&]() {
347 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
348 });
349
350 for (; __i != extent_v<_Tp>; ++__i) {
351 std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]));
352 }
353 __guard.__complete();
354 } else {
355 allocator_traits<_Alloc>::construct(__alloc, __loc);
356 }
357}
358
359// Constructs the object at the given location using the allocator's construct method, passing along
360// the provided argument.
361//
362// If the object being constructed is an array, the argument is also assumed to be an array. Each
363// each element of the array being constructed is allocator-constructed from the corresponding
364// element of the argument array. If an exception is thrown during the construction of an array,
365// the initialized elements are destroyed in reverse order of initialization using allocator
366// destruction.
367//
368// This function assumes that the allocator is bound to the correct type.
369template <class _Alloc, class _Tp, class _Arg>
370_LIBCPP_HIDE_FROM_ABI constexpr void
371__allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) {
372 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
373 "The allocator should already be rebound to the correct type");
374
375 if constexpr (is_array_v<_Tp>) {
376 static_assert(is_array_v<_Arg>,
377 "Provided non-array initialization argument to __allocator_construct_at_multidimensional when "
378 "trying to construct an array.");
379
380 using _Element = remove_extent_t<_Tp>;
381 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
382 size_t __i = 0;
383 _Tp& __array = *__loc;
384
385 // If an exception is thrown, destroy what we have constructed so far in reverse order.
386 auto __guard = std::__make_exception_guard([&]() {
387 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
388 });
389 for (; __i != extent_v<_Tp>; ++__i) {
390 std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
391 }
392 __guard.__complete();
393 } else {
394 allocator_traits<_Alloc>::construct(__alloc, __loc, __arg);
395 }
396}
397
398// Given a range starting at it and containing n elements, initializes each element in the
399// range from left to right using the construct method of the allocator (rebound to the
400// correct type).
401//
402// If an exception is thrown, the initialized elements are destroyed in reverse order of
403// initialization using allocator_traits destruction. If the elements in the range are C-style
404// arrays, they are initialized element-wise using allocator construction, and recursively so.
405template <class _Alloc,
406 class _BidirIter,
407 class _Tp,
408 class _Size = typename iterator_traits<_BidirIter>::difference_type>
409_LIBCPP_HIDE_FROM_ABI constexpr void
410__uninitialized_allocator_fill_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) {
411 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
412 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
413 _BidirIter __begin = __it;
414
415 // If an exception is thrown, destroy what we have constructed so far in reverse order.
416 auto __guard =
417 std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
418 for (; __n != 0; --__n, ++__it) {
419 std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it), __value);
420 }
421 __guard.__complete();
422}
423
424// Same as __uninitialized_allocator_fill_n_multidimensional, but doesn't pass any initialization argument
425// to the allocator's construct method, which results in value initialization.
426template <class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type>
427_LIBCPP_HIDE_FROM_ABI constexpr void
428__uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n) {
429 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
430 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
431 _BidirIter __begin = __it;
432
433 // If an exception is thrown, destroy what we have constructed so far in reverse order.
434 auto __guard =
435 std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
436 for (; __n != 0; --__n, ++__it) {
437 std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it));
438 }
439 __guard.__complete();
300 return {std::move(__result.__in_), std::move(__result.__out_)};
440301}
441302
442303#endif // _LIBCPP_STD_VER >= 17
......@@ -486,7 +347,7 @@ inline const bool __allocator_has_trivial_copy_construct_v<allocator<_Type>, _Ty
486347template <class _Alloc,
487348 class _In,
488349 class _Out,
489 __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_copy_assignable<_In>::value &&
350 __enable_if_t<is_trivially_copy_constructible<_In>::value && is_trivially_assignable<_Out&, _In&>::value &&
490351 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
491352 __allocator_has_trivial_copy_construct_v<_Alloc, _In>,
492353 int> = 0>
lib/libcxx/include/__memory/uninitialized_multidimensional_algorithms.h created+194
......@@ -0,0 +1,194 @@
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_UNINITIALIZED_MULTIDIMENSIONAL_ALGORITHMS_H
10#define _LIBCPP___MEMORY_UNINITIALIZED_MULTIDIMENSIONAL_ALGORITHMS_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__iterator/iterator_traits.h>
15#include <__memory/addressof.h>
16#include <__memory/allocator_traits.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/extent.h>
19#include <__type_traits/is_array.h>
20#include <__type_traits/is_same.h>
21#include <__type_traits/remove_extent.h>
22#include <__utility/exception_guard.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#if _LIBCPP_STD_VER >= 17
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35// TODO: Rewrite this to iterate left to right and use reverse_iterators when calling
36// Destroys every element in the range [first, last) FROM RIGHT TO LEFT using allocator
37// destruction. If elements are themselves C-style arrays, they are recursively destroyed
38// in the same manner.
39//
40// This function assumes that destructors do not throw, and that the allocator is bound to
41// the correct type.
42template <class _Alloc,
43 class _BidirIter,
44 __enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0>
45_LIBCPP_HIDE_FROM_ABI constexpr void
46__allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {
47 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
48 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _ValueType>,
49 "The allocator should already be rebound to the correct type");
50
51 if (__first == __last)
52 return;
53
54 if constexpr (is_array_v<_ValueType>) {
55 static_assert(!__is_unbounded_array_v<_ValueType>,
56 "arrays of unbounded arrays don't exist, but if they did we would mess up here");
57
58 using _Element = remove_extent_t<_ValueType>;
59 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
60 do {
61 --__last;
62 decltype(auto) __array = *__last;
63 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + extent_v<_ValueType>);
64 } while (__last != __first);
65 } else {
66 do {
67 --__last;
68 allocator_traits<_Alloc>::destroy(__alloc, std::addressof(*__last));
69 } while (__last != __first);
70 }
71}
72
73// Constructs the object at the given location using the allocator's construct method.
74//
75// If the object being constructed is an array, each element of the array is allocator-constructed,
76// recursively. If an exception is thrown during the construction of an array, the initialized
77// elements are destroyed in reverse order of initialization using allocator destruction.
78//
79// This function assumes that the allocator is bound to the correct type.
80template <class _Alloc, class _Tp>
81_LIBCPP_HIDE_FROM_ABI constexpr void __allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc) {
82 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
83 "The allocator should already be rebound to the correct type");
84
85 if constexpr (is_array_v<_Tp>) {
86 using _Element = remove_extent_t<_Tp>;
87 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
88 size_t __i = 0;
89 _Tp& __array = *__loc;
90
91 // If an exception is thrown, destroy what we have constructed so far in reverse order.
92 auto __guard = std::__make_exception_guard([&]() {
93 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
94 });
95
96 for (; __i != extent_v<_Tp>; ++__i) {
97 std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]));
98 }
99 __guard.__complete();
100 } else {
101 allocator_traits<_Alloc>::construct(__alloc, __loc);
102 }
103}
104
105// Constructs the object at the given location using the allocator's construct method, passing along
106// the provided argument.
107//
108// If the object being constructed is an array, the argument is also assumed to be an array. Each
109// each element of the array being constructed is allocator-constructed from the corresponding
110// element of the argument array. If an exception is thrown during the construction of an array,
111// the initialized elements are destroyed in reverse order of initialization using allocator
112// destruction.
113//
114// This function assumes that the allocator is bound to the correct type.
115template <class _Alloc, class _Tp, class _Arg>
116_LIBCPP_HIDE_FROM_ABI constexpr void
117__allocator_construct_at_multidimensional(_Alloc& __alloc, _Tp* __loc, _Arg const& __arg) {
118 static_assert(is_same_v<typename allocator_traits<_Alloc>::value_type, _Tp>,
119 "The allocator should already be rebound to the correct type");
120
121 if constexpr (is_array_v<_Tp>) {
122 static_assert(is_array_v<_Arg>,
123 "Provided non-array initialization argument to __allocator_construct_at_multidimensional when "
124 "trying to construct an array.");
125
126 using _Element = remove_extent_t<_Tp>;
127 __allocator_traits_rebind_t<_Alloc, _Element> __elem_alloc(__alloc);
128 size_t __i = 0;
129 _Tp& __array = *__loc;
130
131 // If an exception is thrown, destroy what we have constructed so far in reverse order.
132 auto __guard = std::__make_exception_guard([&]() {
133 std::__allocator_destroy_multidimensional(__elem_alloc, __array, __array + __i);
134 });
135 for (; __i != extent_v<_Tp>; ++__i) {
136 std::__allocator_construct_at_multidimensional(__elem_alloc, std::addressof(__array[__i]), __arg[__i]);
137 }
138 __guard.__complete();
139 } else {
140 allocator_traits<_Alloc>::construct(__alloc, __loc, __arg);
141 }
142}
143
144// Given a range starting at it and containing n elements, initializes each element in the
145// range from left to right using the construct method of the allocator (rebound to the
146// correct type).
147//
148// If an exception is thrown, the initialized elements are destroyed in reverse order of
149// initialization using allocator_traits destruction. If the elements in the range are C-style
150// arrays, they are initialized element-wise using allocator construction, and recursively so.
151template <class _Alloc,
152 class _BidirIter,
153 class _Tp,
154 class _Size = typename iterator_traits<_BidirIter>::difference_type>
155_LIBCPP_HIDE_FROM_ABI constexpr void
156__uninitialized_allocator_fill_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n, _Tp const& __value) {
157 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
158 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
159 _BidirIter __begin = __it;
160
161 // If an exception is thrown, destroy what we have constructed so far in reverse order.
162 auto __guard =
163 std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
164 for (; __n != 0; --__n, ++__it) {
165 std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it), __value);
166 }
167 __guard.__complete();
168}
169
170// Same as __uninitialized_allocator_fill_n_multidimensional, but doesn't pass any initialization argument
171// to the allocator's construct method, which results in value initialization.
172template <class _Alloc, class _BidirIter, class _Size = typename iterator_traits<_BidirIter>::difference_type>
173_LIBCPP_HIDE_FROM_ABI constexpr void
174__uninitialized_allocator_value_construct_n_multidimensional(_Alloc& __alloc, _BidirIter __it, _Size __n) {
175 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
176 __allocator_traits_rebind_t<_Alloc, _ValueType> __value_alloc(__alloc);
177 _BidirIter __begin = __it;
178
179 // If an exception is thrown, destroy what we have constructed so far in reverse order.
180 auto __guard =
181 std::__make_exception_guard([&]() { std::__allocator_destroy_multidimensional(__value_alloc, __begin, __it); });
182 for (; __n != 0; --__n, ++__it) {
183 std::__allocator_construct_at_multidimensional(__value_alloc, std::addressof(*__it));
184 }
185 __guard.__complete();
186}
187
188_LIBCPP_END_NAMESPACE_STD
189
190#endif // _LIBCPP_STD_VER >= 17
191
192_LIBCPP_POP_MACROS
193
194#endif // _LIBCPP___MEMORY_UNINITIALIZED_MULTIDIMENSIONAL_ALGORITHMS_H
lib/libcxx/include/__memory/unique_ptr.h+62-110
......@@ -27,7 +27,6 @@
2727#include <__type_traits/add_reference.h>
2828#include <__type_traits/common_type.h>
2929#include <__type_traits/conditional.h>
30#include <__type_traits/dependent_type.h>
3130#include <__type_traits/enable_if.h>
3231#include <__type_traits/integral_constant.h>
3332#include <__type_traits/is_array.h>
......@@ -43,7 +42,8 @@
4342#include <__type_traits/is_trivially_relocatable.h>
4443#include <__type_traits/is_void.h>
4544#include <__type_traits/remove_extent.h>
46#include <__type_traits/type_identity.h>
45#include <__type_traits/remove_reference.h>
46#include <__type_traits/void_t.h>
4747#include <__utility/declval.h>
4848#include <__utility/forward.h>
4949#include <__utility/move.h>
......@@ -95,27 +95,17 @@ inline const bool __is_default_deleter_v = false;
9595template <class _Tp>
9696inline const bool __is_default_deleter_v<default_delete<_Tp> > = true;
9797
98template <class _Deleter>
99struct __unique_ptr_deleter_sfinae {
100 static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
101 typedef const _Deleter& __lval_ref_type;
102 typedef _Deleter&& __good_rval_ref_type;
103 typedef true_type __enable_rval_overload;
104};
98template <class, class = void>
99inline const bool __can_dereference = false;
105100
106template <class _Deleter>
107struct __unique_ptr_deleter_sfinae<_Deleter const&> {
108 typedef const _Deleter& __lval_ref_type;
109 typedef const _Deleter&& __bad_rval_ref_type;
110 typedef false_type __enable_rval_overload;
111};
101template <class _Tp>
102inline const bool __can_dereference<_Tp, decltype((void)*std::declval<_Tp>())> = true;
112103
113template <class _Deleter>
114struct __unique_ptr_deleter_sfinae<_Deleter&> {
115 typedef _Deleter& __lval_ref_type;
116 typedef _Deleter&& __bad_rval_ref_type;
117 typedef false_type __enable_rval_overload;
118};
104template <class _Tp, class = void>
105inline const bool __can_add_pointer = false;
106
107template <class _Tp>
108inline const bool __can_add_pointer<_Tp, __void_t<_Tp*> > = true;
119109
120110#if defined(_LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI)
121111# define _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))
......@@ -125,13 +115,14 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
125115
126116template <class _Tp, class _Dp = default_delete<_Tp> >
127117class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
118 static_assert(__can_add_pointer<_Tp>, "unique_ptr<T, D> requires T* to be a valid type");
119 static_assert(!is_rvalue_reference<_Dp>::value, "the specified deleter type cannot be an rvalue reference");
120
128121public:
129122 typedef _Tp element_type;
130123 typedef _Dp deleter_type;
131124 using pointer _LIBCPP_NODEBUG = __pointer<_Tp, deleter_type>;
132125
133 static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference");
134
135126 // A unique_ptr contains the following members which may be trivially relocatable:
136127 // - pointer : this may be trivially relocatable, so it's checked
137128 // - deleter_type: this may be trivially relocatable, so it's checked
......@@ -146,24 +137,6 @@ public:
146137private:
147138 _LIBCPP_COMPRESSED_PAIR(pointer, __ptr_, deleter_type, __deleter_);
148139
149 using _DeleterSFINAE _LIBCPP_NODEBUG = __unique_ptr_deleter_sfinae<_Dp>;
150
151 template <bool _Dummy>
152 using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
153
154 template <bool _Dummy>
155 using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
156
157 template <bool _Dummy>
158 using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
159
160 template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
161 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
162 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
163
164 template <class _ArgType>
165 using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
166
167140 template <class _UPtr, class _Up>
168141 using _EnableIfMoveConvertible _LIBCPP_NODEBUG =
169142 __enable_if_t< is_convertible<typename _UPtr::pointer, pointer>::value && !is_array<_Up>::value >;
......@@ -177,31 +150,33 @@ private:
177150 using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;
178151
179152public:
180 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
153 template <class _Deleter = deleter_type,
154 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0>
181155 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}
182156
183 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
157 template <class _Deleter = deleter_type,
158 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0>
184159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}
185160
186 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
161 template <class _Deleter = deleter_type,
162 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0>
187163 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
188164 : __ptr_(__p),
189165 __deleter_() {}
190166
191 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
167 template <class _Deleter = deleter_type, __enable_if_t<is_copy_constructible<_Deleter>::value, int> = 0>
168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, const deleter_type& __d) _NOEXCEPT
193169 : __ptr_(__p),
194170 __deleter_(__d) {}
195171
196 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
197 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
172 template <class _Deleter = deleter_type,
173 __enable_if_t<!is_reference<_Deleter>::value && is_move_constructible<_Deleter>::value, int> = 0>
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, deleter_type&& __d) _NOEXCEPT
198175 : __ptr_(__p),
199 __deleter_(std::move(__d)) {
200 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
201 }
176 __deleter_(std::move(__d)) {}
202177
203 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
204 _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
178 template <class _Deleter = deleter_type, __enable_if_t<is_reference<_Deleter>::value, int> = 0>
179 _LIBCPP_HIDE_FROM_ABI unique_ptr(pointer, __libcpp_remove_reference_t<deleter_type>&&) = delete;
205180
206181 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
207182 : __ptr_(__u.release()),
......@@ -222,7 +197,7 @@ public:
222197#endif
223198
224199 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
225 reset(__u.release());
200 reset(__u.release()); // NOLINT(misc-uniqueptr-reset-release)
226201 __deleter_ = std::forward<deleter_type>(__u.get_deleter());
227202 return *this;
228203 }
......@@ -258,6 +233,7 @@ public:
258233 return *this;
259234 }
260235
236 template <class _Ptr = pointer, __enable_if_t<__can_dereference<_Ptr>, int> = 0>
261237 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
262238 _NOEXCEPT_(_NOEXCEPT_(*std::declval<pointer>())) {
263239 return *__ptr_;
......@@ -434,27 +410,6 @@ private:
434410 (is_same<pointer, element_type*>::value &&
435411 is_convertible<_FromElem (*)[], element_type (*)[]>::value) > {};
436412
437 typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
438
439 template <bool _Dummy>
440 using _LValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
441
442 template <bool _Dummy>
443 using _GoodRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
444
445 template <bool _Dummy>
446 using _BadRValRefType _LIBCPP_NODEBUG = typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
447
448 template <bool _Dummy, class _Deleter = typename __dependent_type< __type_identity<deleter_type>, _Dummy>::type>
449 using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG =
450 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value>;
451
452 template <class _ArgType>
453 using _EnableIfDeleterConstructible _LIBCPP_NODEBUG = __enable_if_t<is_constructible<deleter_type, _ArgType>::value>;
454
455 template <class _Pp>
456 using _EnableIfPointerConvertible _LIBCPP_NODEBUG = __enable_if_t< _CheckArrayPointerConversion<_Pp>::value >;
457
458413 template <class _UPtr, class _Up, class _ElemT = typename _UPtr::element_type>
459414 using _EnableIfMoveConvertible _LIBCPP_NODEBUG =
460415 __enable_if_t< is_array<_Up>::value && is_same<pointer, element_type*>::value &&
......@@ -470,17 +425,19 @@ private:
470425 using _EnableIfDeleterAssignable _LIBCPP_NODEBUG = __enable_if_t< is_assignable<_Dp&, _UDel&&>::value >;
471426
472427public:
473 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
428 template <class _Deleter = deleter_type,
429 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0>
474430 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(), __deleter_() {}
475431
476 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
432 template <class _Deleter = deleter_type,
433 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0>
477434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(), __deleter_() {}
478435
479 template <class _Pp,
480 bool _Dummy = true,
481 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
482 class = _EnableIfPointerConvertible<_Pp> >
483 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __ptr) _NOEXCEPT
436 template <class _Ptr,
437 class _Deleter = deleter_type,
438 __enable_if_t<is_default_constructible<_Deleter>::value && !is_pointer<_Deleter>::value, int> = 0,
439 __enable_if_t<_CheckArrayPointerConversion<_Ptr>::value, int> = 0>
440 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Ptr __ptr) _NOEXCEPT
484441 : __ptr_(__ptr),
485442 __deleter_() {}
486443
......@@ -490,43 +447,38 @@ public:
490447 : __ptr_(__ptr),
491448 __checker_(__size) {}
492449
493 template <class _Pp,
494 bool _Dummy = true,
495 class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
496 class = _EnableIfPointerConvertible<_Pp> >
497 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Pp __ptr, _LValRefType<_Dummy> __deleter) _NOEXCEPT
450 template <class _Ptr,
451 class _Deleter = deleter_type,
452 __enable_if_t<is_copy_constructible<_Deleter>::value, int> = 0,
453 __enable_if_t<_CheckArrayPointerConversion<_Ptr>::value, int> = 0>
454 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Ptr __ptr, const deleter_type& __deleter) _NOEXCEPT
498455 : __ptr_(__ptr),
499456 __deleter_(__deleter) {}
500457
501 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
502 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, _LValRefType<_Dummy> __deleter) _NOEXCEPT
458 template <class _Deleter = deleter_type, __enable_if_t<is_copy_constructible<_Deleter>::value, int> = 0>
459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, const deleter_type& __deleter) _NOEXCEPT
503460 : __ptr_(nullptr),
504461 __deleter_(__deleter) {}
505462
506 template <class _Pp,
507 bool _Dummy = true,
508 class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
509 class = _EnableIfPointerConvertible<_Pp> >
510 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
511 unique_ptr(_Pp __ptr, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
463 template <class _Ptr,
464 class _Deleter = deleter_type,
465 __enable_if_t<!is_reference<_Deleter>::value && is_move_constructible<_Deleter>::value, int> = 0,
466 __enable_if_t<_CheckArrayPointerConversion<_Ptr>::value, int> = 0>
467 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(_Ptr __ptr, deleter_type&& __deleter) _NOEXCEPT
512468 : __ptr_(__ptr),
513 __deleter_(std::move(__deleter)) {
514 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
515 }
469 __deleter_(std::move(__deleter)) {}
516470
517 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
518 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23
519 unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __deleter) _NOEXCEPT
471 template <class _Deleter = deleter_type,
472 __enable_if_t<!is_reference<_Deleter>::value && is_move_constructible<_Deleter>::value, int> = 0>
473 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(nullptr_t, deleter_type&& __deleter) _NOEXCEPT
520474 : __ptr_(nullptr),
521 __deleter_(std::move(__deleter)) {
522 static_assert(!is_reference<deleter_type>::value, "rvalue deleter bound to reference");
523 }
475 __deleter_(std::move(__deleter)) {}
524476
525 template <class _Pp,
526 bool _Dummy = true,
527 class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
528 class = _EnableIfPointerConvertible<_Pp> >
529 _LIBCPP_HIDE_FROM_ABI unique_ptr(_Pp __ptr, _BadRValRefType<_Dummy> __deleter) = delete;
477 template <class _Ptr,
478 class _Deleter = deleter_type,
479 __enable_if_t<is_reference<_Deleter>::value, int> = 0,
480 __enable_if_t<_CheckArrayPointerConversion<_Ptr>::value, int> = 0>
481 _LIBCPP_HIDE_FROM_ABI unique_ptr(_Ptr, __libcpp_remove_reference_t<deleter_type>&&) = delete;
530482
531483 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(unique_ptr&& __u) _NOEXCEPT
532484 : __ptr_(__u.release()),
......@@ -534,7 +486,7 @@ public:
534486 __checker_(std::move(__u.__checker_)) {}
535487
536488 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
537 reset(__u.release());
489 reset(__u.release()); // NOLINT(misc-uniqueptr-reset-release)
538490 __deleter_ = std::forward<deleter_type>(__u.get_deleter());
539491 __checker_ = std::move(__u.__checker_);
540492 return *this;
lib/libcxx/include/__memory/uses_allocator_construction.h+6-6
......@@ -27,10 +27,10 @@
2727_LIBCPP_PUSH_MACROS
2828#include <__undef_macros>
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230#if _LIBCPP_STD_VER >= 17
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3434template <class _Tp>
3535inline constexpr bool __is_cv_std_pair = __is_pair_v<remove_cv_t<_Tp>>;
3636
......@@ -202,9 +202,7 @@ __uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _
202202 __uses_allocator_construction_args<_Type>::__apply(__alloc, std::forward<_Args>(__args)...));
203203}
204204
205#endif // _LIBCPP_STD_VER >= 17
206
207#if _LIBCPP_STD_VER >= 20
205# if _LIBCPP_STD_VER >= 20
208206
209207template <class _Type, class _Alloc, class... _Args>
210208_LIBCPP_HIDE_FROM_ABI constexpr auto uses_allocator_construction_args(const _Alloc& __alloc, _Args&&... __args) noexcept
......@@ -225,10 +223,12 @@ uninitialized_construct_using_allocator(_Type* __ptr, const _Alloc& __alloc, _Ar
225223 return /*--*/ std::__uninitialized_construct_using_allocator(__ptr, __alloc, std::forward<_Args>(__args)...);
226224}
227225
228#endif // _LIBCPP_STD_VER >= 20
226# endif // _LIBCPP_STD_VER >= 20
229227
230228_LIBCPP_END_NAMESPACE_STD
231229
230#endif // _LIBCPP_STD_VER >= 17
231
232232_LIBCPP_POP_MACROS
233233
234234#endif // _LIBCPP___MEMORY_USES_ALLOCATOR_CONSTRUCTION_H
lib/libcxx/include/__memory/valid_range.h created+74
......@@ -0,0 +1,74 @@
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_VALID_RANGE_H
10#define _LIBCPP___MEMORY_VALID_RANGE_H
11
12#include <__algorithm/comp.h>
13#include <__assert>
14#include <__config>
15#include <__iterator/iterator_traits.h>
16#include <__memory/assume_aligned.h>
17#include <__memory/pointer_traits.h>
18#include <__type_traits/is_constant_evaluated.h>
19#include <__type_traits/is_same.h>
20#include <__type_traits/remove_cvref.h>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28// A valid range as defined by the C++ Standard has the following constraints:
29// - [__first, __last) is dereferenceable
30// - __last is reachable from __first
31// - if __first and __last are contiguous iterators, the pointers they "decay to" are correctly aligned according to the
32// language rules for pointers
33
34// This function attempts to detect invalid ranges as defined above. Specifically, it checks bullet (2). This also means
35// that it doesn't return whether a range is actually valid, but only whether a range is definitely not valid.
36// The checks may be extended in the future.
37template <class _Tp>
38_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
39__is_valid_range(const _Tp* __first, const _Tp* __last) {
40 if (__libcpp_is_constant_evaluated()) {
41 // If this is not a constant during constant evaluation, that is because __first and __last are not
42 // part of the same allocation. If they are part of the same allocation, we must still make sure they
43 // are ordered properly.
44 return __builtin_constant_p(__first <= __last) && __first <= __last;
45 }
46
47 return !__less<>()(__last, __first);
48}
49
50// This function allows the compiler to assume that [__first, __last) is a valid range as defined above.
51//
52// In practice, we only add explicit assumptions for bullets (1) and (3). These assumptions allow (currently only
53// clang-based compilers) to auto-vectorize algorithms that contain early returns.
54template <class _Iter, class _Sent>
55_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
56__assume_valid_range([[__maybe_unused__]] _Iter&& __first, [[__maybe_unused__]] _Sent&& __last) {
57#if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2300 && !defined(_LIBCPP_CXX03_LANG)
58 if constexpr (__libcpp_is_contiguous_iterator<__remove_cvref_t<_Iter>>::value &&
59 is_same<__remove_cvref_t<_Iter>, __remove_cvref_t<_Sent>>::value) {
60 _LIBCPP_ASSERT_INTERNAL(std::__is_valid_range(std::__to_address(__first), std::__to_address(__last)),
61 "Valid range assumption does not hold");
62 if (!__libcpp_is_constant_evaluated()) {
63 using __value_type = typename iterator_traits<__remove_cvref_t<_Iter>>::value_type;
64 __builtin_assume_dereferenceable(std::__to_address(__first), (__last - __first) * sizeof(__value_type));
65 (void)std::__assume_aligned<_LIBCPP_ALIGNOF(__value_type)>(std::__to_address(__first));
66 (void)std::__assume_aligned<_LIBCPP_ALIGNOF(__value_type)>(std::__to_address(__last));
67 }
68 }
69#endif
70}
71
72_LIBCPP_END_NAMESPACE_STD
73
74#endif // _LIBCPP___MEMORY_VALID_RANGE_H
lib/libcxx/include/__memory_resource/memory_resource.h+2
......@@ -21,6 +21,7 @@
2121#if _LIBCPP_STD_VER >= 17
2222
2323_LIBCPP_BEGIN_NAMESPACE_STD
24_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2425
2526namespace pmr {
2627
......@@ -84,6 +85,7 @@ null_memory_resource() noexcept;
8485
8586} // namespace pmr
8687
88_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
8789_LIBCPP_END_NAMESPACE_STD
8890
8991#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h+2
......@@ -21,6 +21,7 @@
2121#if _LIBCPP_STD_VER >= 17
2222
2323_LIBCPP_BEGIN_NAMESPACE_STD
24_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2425
2526namespace pmr {
2627
......@@ -112,6 +113,7 @@ private:
112113
113114} // namespace pmr
114115
116_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
115117_LIBCPP_END_NAMESPACE_STD
116118
117119#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h+2
......@@ -24,6 +24,7 @@
2424#if _LIBCPP_STD_VER >= 17
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728
2829namespace pmr {
2930
......@@ -88,6 +89,7 @@ private:
8889
8990} // namespace pmr
9091
92_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
9193_LIBCPP_END_NAMESPACE_STD
9294
9395#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h+2
......@@ -22,6 +22,7 @@
2222#if _LIBCPP_STD_VER >= 17
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
2627namespace pmr {
2728
......@@ -99,6 +100,7 @@ private:
99100
100101} // namespace pmr
101102
103_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
102104_LIBCPP_END_NAMESPACE_STD
103105
104106#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__mutex/lock_guard.h+1-1
......@@ -34,7 +34,7 @@ public:
3434
3535 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t) _LIBCPP_REQUIRES_CAPABILITY(__m)
3636 : __m_(__m) {}
37 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~lock_guard() { __m_.unlock(); }
37 _LIBCPP_RELEASE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI ~lock_guard() { __m_.unlock(); }
3838
3939 lock_guard(lock_guard const&) = delete;
4040 lock_guard& operator=(lock_guard const&) = delete;
lib/libcxx/include/__mutex/mutex.h+3-1
......@@ -20,6 +20,7 @@
2020#if _LIBCPP_HAS_THREADS
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
23_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2324
2425class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_CAPABILITY("mutex") mutex {
2526 __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
......@@ -38,7 +39,7 @@ public:
3839
3940 _LIBCPP_ACQUIRE_CAPABILITY() void lock();
4041 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock() _NOEXCEPT;
41 _LIBCPP_RELEASE_CAPABILITY void unlock() _NOEXCEPT;
42 _LIBCPP_RELEASE_CAPABILITY() void unlock() _NOEXCEPT;
4243
4344 typedef __libcpp_mutex_t* native_handle_type;
4445 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; }
......@@ -46,6 +47,7 @@ public:
4647
4748static_assert(is_nothrow_default_constructible<mutex>::value, "the default constructor for std::mutex must be nothrow");
4849
50_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4951_LIBCPP_END_NAMESPACE_STD
5052
5153#endif // _LIBCPP_HAS_THREADS
lib/libcxx/include/__mutex/once_flag.h+2
......@@ -113,7 +113,9 @@ void _LIBCPP_HIDE_FROM_ABI __call_once_proxy(void* __vp) {
113113 (*__p)();
114114}
115115
116_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
116117_LIBCPP_EXPORTED_FROM_ABI void __call_once(volatile once_flag::_State_type&, void*, void (*)(void*));
118_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
117119
118120template <class _ValueType>
119121inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* __value) {
lib/libcxx/include/__mutex/unique_lock.h+5-5
......@@ -84,13 +84,13 @@ public:
8484 }
8585
8686 _LIBCPP_HIDE_FROM_ABI void lock();
87 _LIBCPP_HIDE_FROM_ABI bool try_lock();
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock();
8888
8989 template <class _Rep, class _Period>
90 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
90 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d);
9191
9292 template <class _Clock, class _Duration>
93 _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
93 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
9494
9595 _LIBCPP_HIDE_FROM_ABI void unlock();
9696
......@@ -106,9 +106,9 @@ public:
106106 return __m;
107107 }
108108
109 _LIBCPP_HIDE_FROM_ABI bool owns_lock() const _NOEXCEPT { return __owns_; }
109 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owns_lock() const _NOEXCEPT { return __owns_; }
110110 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __owns_; }
111 _LIBCPP_HIDE_FROM_ABI mutex_type* mutex() const _NOEXCEPT { return __m_; }
111 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mutex_type* mutex() const _NOEXCEPT { return __m_; }
112112};
113113_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(unique_lock);
114114
lib/libcxx/include/__new/exceptions.h+3
......@@ -24,6 +24,8 @@
2424#endif
2525
2626_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
28
2729#if !defined(_LIBCPP_ABI_VCRUNTIME)
2830
2931class _LIBCPP_EXPORTED_FROM_ABI bad_alloc : public exception {
......@@ -74,6 +76,7 @@ public:
7476 _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
7577#endif
7678}
79_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7780_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
7881
7982#endif // _LIBCPP___NEW_EXCEPTIONS_H
lib/libcxx/include/__new/new_handler.h+4
......@@ -19,9 +19,13 @@
1919# include <new.h>
2020#else
2121_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
23
2224typedef void (*new_handler)();
2325_LIBCPP_EXPORTED_FROM_ABI new_handler set_new_handler(new_handler) _NOEXCEPT;
2426_LIBCPP_EXPORTED_FROM_ABI new_handler get_new_handler() _NOEXCEPT;
27
28_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2529_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
2630#endif // _LIBCPP_ABI_VCRUNTIME
2731
lib/libcxx/include/__new/placement_new_delete.h+2-2
......@@ -27,8 +27,8 @@ operator new(std::size_t, void* __p) _NOEXCEPT {
2727operator new[](std::size_t, void* __p) _NOEXCEPT {
2828 return __p;
2929}
30inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {}
31inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {}
30inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator delete(void*, void*) _NOEXCEPT {}
31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator delete[](void*, void*) _NOEXCEPT {}
3232#endif
3333
3434#endif // _LIBCPP___NEW_PLACEMENT_NEW_DELETE_H
lib/libcxx/include/__node_handle+37-36
......@@ -31,29 +31,29 @@ private:
3131public:
3232 // [container.node.cons], constructors, copy, and assignment
3333 constexpr node-handle() noexcept : ptr_(), alloc_() {}
34 node-handle(node-handle&&) noexcept;
35 node-handle& operator=(node-handle&&);
34 constexpr node-handle(node-handle&&) noexcept; // constexpr since C++26
35 constexpr node-handle& operator=(node-handle&&); // constexpr since C++26
3636
3737 // [container.node.dtor], destructor
38 ~node-handle();
38 constexpr ~node-handle(); // constexpr since C++26
3939
4040 // [container.node.observers], observers
41 value_type& value() const; // not present for map containers
42 key_type& key() const; // not present for set containers
43 mapped_type& mapped() const; // not present for set containers
41 value_type& value() const; // not present for map containers
42 key_type& key() const; // not present for set containers
43 constexpr mapped_type& mapped() const; // not present for set containers, constexpr since C++26
4444
45 allocator_type get_allocator() const;
46 explicit operator bool() const noexcept;
47 [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20
45 constexpr allocator_type get_allocator() const; // constexpr since C++26
46 constexpr explicit operator bool() const noexcept; // constexpr since C++26
47 [[nodiscard]] constexpr bool empty() const noexcept; // nodiscard since C++20, constexpr since C++26
4848
4949 // [container.node.modifiers], modifiers
50 void swap(node-handle&)
50 constexpr void swap(node-handle&)
5151 noexcept(ator_traits::propagate_on_container_swap::value ||
52 ator_traits::is_always_equal::value);
52 ator_traits::is_always_equal::value); // constexpr since C++26
5353
54 friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
54 constexpr friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
5555 x.swap(y);
56 }
56 } // constexpr since C++26
5757};
5858
5959*/
......@@ -63,6 +63,7 @@ public:
6363#include <__memory/allocator_traits.h>
6464#include <__memory/pointer_traits.h>
6565#include <__type_traits/is_specialization.h>
66#include <__utility/exchange.h>
6667#include <optional>
6768
6869#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -72,10 +73,10 @@ public:
7273_LIBCPP_PUSH_MACROS
7374#include <__undef_macros>
7475
75_LIBCPP_BEGIN_NAMESPACE_STD
76
7776#if _LIBCPP_STD_VER >= 17
7877
78_LIBCPP_BEGIN_NAMESPACE_STD
79
7980// Specialized in __tree & __hash_table for their _NodeType.
8081template <class _NodeType, class _Alloc>
8182struct __generic_container_node_destructor;
......@@ -99,12 +100,12 @@ private:
99100 __node_pointer_type __ptr_ = nullptr;
100101 optional<allocator_type> __alloc_;
101102
102 _LIBCPP_HIDE_FROM_ABI void __release_ptr() {
103 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __release_ptr() {
103104 __ptr_ = nullptr;
104105 __alloc_ = std::nullopt;
105106 }
106107
107 _LIBCPP_HIDE_FROM_ABI void __destroy_node_pointer() {
108 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __destroy_node_pointer() {
108109 if (__ptr_ != nullptr) {
109110 typedef typename __allocator_traits_rebind< allocator_type, _NodeType>::type __node_alloc_type;
110111 __node_alloc_type __alloc(*__alloc_);
......@@ -113,19 +114,17 @@ private:
113114 }
114115 }
115116
116 _LIBCPP_HIDE_FROM_ABI __basic_node_handle(__node_pointer_type __ptr, allocator_type const& __alloc)
117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
118 __basic_node_handle(__node_pointer_type __ptr, allocator_type const& __alloc)
117119 : __ptr_(__ptr), __alloc_(__alloc) {}
118120
119121public:
120 _LIBCPP_HIDE_FROM_ABI __basic_node_handle() = default;
122 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle() = default;
121123
122 _LIBCPP_HIDE_FROM_ABI __basic_node_handle(__basic_node_handle&& __other) noexcept
123 : __ptr_(__other.__ptr_), __alloc_(std::move(__other.__alloc_)) {
124 __other.__ptr_ = nullptr;
125 __other.__alloc_ = std::nullopt;
126 }
124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle(__basic_node_handle&& __other) noexcept
125 : __ptr_(std::exchange(__other.__ptr_, nullptr)), __alloc_(std::exchange(__other.__alloc_, std::nullopt)) {}
127126
128 _LIBCPP_HIDE_FROM_ABI __basic_node_handle& operator=(__basic_node_handle&& __other) {
127 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle& operator=(__basic_node_handle&& __other) {
129128 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
130129 __alloc_ == std::nullopt || __alloc_traits::propagate_on_container_move_assignment::value ||
131130 __alloc_ == __other.__alloc_,
......@@ -133,24 +132,23 @@ public:
133132 "node_type::operator=(node_type&&)");
134133
135134 __destroy_node_pointer();
136 __ptr_ = __other.__ptr_;
135 __ptr_ = std::exchange(__other.__ptr_, nullptr);
137136
138137 if (__alloc_traits::propagate_on_container_move_assignment::value || __alloc_ == std::nullopt)
139138 __alloc_ = std::move(__other.__alloc_);
140139
141 __other.__ptr_ = nullptr;
142140 __other.__alloc_ = std::nullopt;
143141
144142 return *this;
145143 }
146144
147 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const { return *__alloc_; }
145 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const { return *__alloc_; }
148146
149 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ptr_ != nullptr; }
147 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit operator bool() const { return __ptr_ != nullptr; }
150148
151 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; }
149 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const { return __ptr_ == nullptr; }
152150
153 _LIBCPP_HIDE_FROM_ABI void swap(__basic_node_handle& __other) noexcept(
151 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__basic_node_handle& __other) noexcept(
154152 __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value) {
155153 using std::swap;
156154 swap(__ptr_, __other.__ptr_);
......@@ -159,19 +157,21 @@ public:
159157 swap(__alloc_, __other.__alloc_);
160158 }
161159
162 _LIBCPP_HIDE_FROM_ABI friend void
160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend void
163161 swap(__basic_node_handle& __a, __basic_node_handle& __b) noexcept(noexcept(__a.swap(__b))) {
164162 __a.swap(__b);
165163 }
166164
167 _LIBCPP_HIDE_FROM_ABI ~__basic_node_handle() { __destroy_node_pointer(); }
165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__basic_node_handle() { __destroy_node_pointer(); }
168166};
169167
170168template <class _NodeType, class _Derived>
171169struct __set_node_handle_specifics {
172170 typedef typename _NodeType::__node_value_type value_type;
173171
174 _LIBCPP_HIDE_FROM_ABI value_type& value() const { return static_cast<_Derived const*>(this)->__ptr_->__get_value(); }
172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_type& value() const {
173 return static_cast<_Derived const*>(this)->__ptr_->__get_value();
174 }
175175};
176176
177177template <class _NodeType, class _Derived>
......@@ -179,6 +179,7 @@ struct __map_node_handle_specifics {
179179 using key_type = __remove_const_t<typename _NodeType::__node_value_type::first_type>;
180180 using mapped_type = typename _NodeType::__node_value_type::second_type;
181181
182 // This method is not constexpr as per the standard.
182183 _LIBCPP_HIDE_FROM_ABI key_type& key() const {
183184 return const_cast<key_type&>(static_cast<_Derived const*>(this)->__ptr_->__get_value().first);
184185 }
......@@ -201,10 +202,10 @@ struct __insert_return_type {
201202 _NodeType node;
202203};
203204
204#endif // _LIBCPP_STD_VER >= 17
205
206205_LIBCPP_END_NAMESPACE_STD
207206
207#endif // _LIBCPP_STD_VER >= 17
208
208209_LIBCPP_POP_MACROS
209210
210211#endif // _LIBCPP___NODE_HANDLE
lib/libcxx/include/__numeric/accumulate.h+2-2
......@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _InputIterator, class _Tp>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
2727accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) {
2828 for (; __first != __last; ++__first)
2929#if _LIBCPP_STD_VER >= 20
......@@ -35,7 +35,7 @@ accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) {
3535}
3636
3737template <class _InputIterator, class _Tp, class _BinaryOperation>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
38[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
3939accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOperation __binary_op) {
4040 for (; __first != __last; ++__first)
4141#if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__numeric/gcd_lcm.h+2-2
......@@ -47,7 +47,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI _Result __abs_in_type(_Source __t) noexcept {
4747}
4848
4949template <class _Tp, class _Up>
50constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) {
50[[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) {
5151 static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to gcd must be integer types");
5252 static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to gcd cannot be bool");
5353 static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to gcd cannot be bool");
......@@ -95,7 +95,7 @@ constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) {
9595}
9696
9797template <class _Tp, class _Up>
98constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
98[[nodiscard]] constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
9999 static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to lcm must be integer types");
100100 static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to lcm cannot be bool");
101101 static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to lcm cannot be bool");
lib/libcxx/include/__numeric/inner_product.h+2-2
......@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _InputIterator1, class _InputIterator2, class _Tp>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
26[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
2727inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) {
2828 for (; __first1 != __last1; ++__first1, (void)++__first2)
2929#if _LIBCPP_STD_VER >= 20
......@@ -35,7 +35,7 @@ inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2
3535}
3636
3737template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOperation1, class _BinaryOperation2>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp inner_product(
38[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp inner_product(
3939 _InputIterator1 __first1,
4040 _InputIterator1 __last1,
4141 _InputIterator2 __first2,
lib/libcxx/include/__numeric/pstl.h+6-6
......@@ -41,7 +41,7 @@ template <class _ExecutionPolicy,
4141 class _BinaryOperation,
4242 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
4343 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
44_LIBCPP_HIDE_FROM_ABI _Tp reduce(
44[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp reduce(
4545 _ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init, _BinaryOperation __op) {
4646 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
4747 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
......@@ -58,7 +58,7 @@ template <class _ExecutionPolicy,
5858 class _Tp,
5959 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
6060 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
61_LIBCPP_HIDE_FROM_ABI _Tp
61[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp
6262reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init) {
6363 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
6464 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
......@@ -70,7 +70,7 @@ template <class _ExecutionPolicy,
7070 class _ForwardIterator,
7171 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
7272 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
73_LIBCPP_HIDE_FROM_ABI __iterator_value_type<_ForwardIterator>
73[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __iterator_value_type<_ForwardIterator>
7474reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) {
7575 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
7676 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
......@@ -90,7 +90,7 @@ template <class _ExecutionPolicy,
9090 class _BinaryOperation2,
9191 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
9292 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
93_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
93[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
9494 _ExecutionPolicy&& __policy,
9595 _ForwardIterator1 __first1,
9696 _ForwardIterator1 __last1,
......@@ -120,7 +120,7 @@ template <class _ExecutionPolicy,
120120 class _Tp,
121121 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
122122 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
123_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
123[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
124124 _ExecutionPolicy&& __policy,
125125 _ForwardIterator1 __first1,
126126 _ForwardIterator1 __last1,
......@@ -147,7 +147,7 @@ template <class _ExecutionPolicy,
147147 class _UnaryOperation,
148148 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
149149 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
150_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
150[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
151151 _ExecutionPolicy&& __policy,
152152 _ForwardIterator __first,
153153 _ForwardIterator __last,
lib/libcxx/include/__numeric/ranges_iota.h+4-3
......@@ -26,9 +26,10 @@
2626_LIBCPP_PUSH_MACROS
2727#include <__undef_macros>
2828
29#if _LIBCPP_STD_VER >= 23
30
2931_LIBCPP_BEGIN_NAMESPACE_STD
3032
31#if _LIBCPP_STD_VER >= 23
3233namespace ranges {
3334template <typename _Out, typename _Tp>
3435using iota_result = ranges::out_value_result<_Out, _Tp>;
......@@ -56,10 +57,10 @@ public:
5657inline constexpr auto iota = __iota_fn{};
5758} // namespace ranges
5859
59#endif // _LIBCPP_STD_VER >= 23
60
6160_LIBCPP_END_NAMESPACE_STD
6261
62#endif // _LIBCPP_STD_VER >= 23
63
6364_LIBCPP_POP_MACROS
6465
6566#endif // _LIBCPP___NUMERIC_RANGES_IOTA_H
lib/libcxx/include/__numeric/reduce.h+8-6
......@@ -22,32 +22,34 @@
2222_LIBCPP_PUSH_MACROS
2323#include <__undef_macros>
2424
25#if _LIBCPP_STD_VER >= 17
26
2527_LIBCPP_BEGIN_NAMESPACE_STD
2628
27#if _LIBCPP_STD_VER >= 17
2829template <class _InputIterator, class _Tp, class _BinaryOp>
29_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
30reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b) {
30[[nodiscard]] _LIBCPP_HIDE_FROM_ABI
31_LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b) {
3132 for (; __first != __last; ++__first)
3233 __init = __b(std::move(__init), *__first);
3334 return __init;
3435}
3536
3637template <class _InputIterator, class _Tp>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
38[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
3839reduce(_InputIterator __first, _InputIterator __last, _Tp __init) {
3940 return std::reduce(__first, __last, __init, std::plus<>());
4041}
4142
4243template <class _InputIterator>
43_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type
44[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename iterator_traits<_InputIterator>::value_type
4445reduce(_InputIterator __first, _InputIterator __last) {
4546 return std::reduce(__first, __last, typename iterator_traits<_InputIterator>::value_type{});
4647}
47#endif
4848
4949_LIBCPP_END_NAMESPACE_STD
5050
51#endif // _LIBCPP_STD_VER >= 17
52
5153_LIBCPP_POP_MACROS
5254
5355#endif // _LIBCPP___NUMERIC_REDUCE_H
lib/libcxx/include/__numeric/saturation_arithmetic.h+15-15
......@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929#if _LIBCPP_STD_VER >= 20
3030
3131template <__signed_or_unsigned_integer _Tp>
32_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
32_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_add(_Tp __x, _Tp __y) noexcept {
3333# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101
3434 return __builtin_elementwise_add_sat(__x, __y);
3535# else
......@@ -51,7 +51,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
5151}
5252
5353template <__signed_or_unsigned_integer _Tp>
54_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
54_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_sub(_Tp __x, _Tp __y) noexcept {
5555# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101
5656 return __builtin_elementwise_sub_sat(__x, __y);
5757# else
......@@ -74,7 +74,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
7474}
7575
7676template <__signed_or_unsigned_integer _Tp>
77_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
77_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_mul(_Tp __x, _Tp __y) noexcept {
7878 if (_Tp __mul; !__builtin_mul_overflow(__x, __y, std::addressof(__mul)))
7979 return __mul;
8080 // Handle overflow
......@@ -90,7 +90,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
9090}
9191
9292template <__signed_or_unsigned_integer _Tp>
93_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
93_LIBCPP_HIDE_FROM_ABI constexpr _Tp __saturating_div(_Tp __x, _Tp __y) noexcept {
9494 _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
9595 if constexpr (__unsigned_integer<_Tp>) {
9696 return __x / __y;
......@@ -103,7 +103,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
103103}
104104
105105template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
106_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
106_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturating_cast(_Tp __x) noexcept {
107107 // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be
108108 // optimized out by the compiler.
109109
......@@ -121,28 +121,28 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
121121#if _LIBCPP_STD_VER >= 26
122122
123123template <__signed_or_unsigned_integer _Tp>
124[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
125 return std::__add_sat(__x, __y);
124[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_add(_Tp __x, _Tp __y) noexcept {
125 return std::__saturating_add(__x, __y);
126126}
127127
128128template <__signed_or_unsigned_integer _Tp>
129[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
130 return std::__sub_sat(__x, __y);
129[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_sub(_Tp __x, _Tp __y) noexcept {
130 return std::__saturating_sub(__x, __y);
131131}
132132
133133template <__signed_or_unsigned_integer _Tp>
134[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
135 return std::__mul_sat(__x, __y);
134[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_mul(_Tp __x, _Tp __y) noexcept {
135 return std::__saturating_mul(__x, __y);
136136}
137137
138138template <__signed_or_unsigned_integer _Tp>
139[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
140 return std::__div_sat(__x, __y);
139[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp saturating_div(_Tp __x, _Tp __y) noexcept {
140 return std::__saturating_div(__x, __y);
141141}
142142
143143template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
144[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
145 return std::__saturate_cast<_Rp>(__x);
144[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturating_cast(_Tp __x) noexcept {
145 return std::__saturating_cast<_Rp>(__x);
146146}
147147
148148#endif // _LIBCPP_STD_VER >= 26
lib/libcxx/include/__numeric/transform_reduce.h+8-6
......@@ -21,19 +21,20 @@
2121_LIBCPP_PUSH_MACROS
2222#include <__undef_macros>
2323
24#if _LIBCPP_STD_VER >= 17
25
2426_LIBCPP_BEGIN_NAMESPACE_STD
2527
26#if _LIBCPP_STD_VER >= 17
2728template <class _InputIterator, class _Tp, class _BinaryOp, class _UnaryOp>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
29transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b, _UnaryOp __u) {
29[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
30_Tp transform_reduce(_InputIterator __first, _InputIterator __last, _Tp __init, _BinaryOp __b, _UnaryOp __u) {
3031 for (; __first != __last; ++__first)
3132 __init = __b(std::move(__init), __u(*__first));
3233 return __init;
3334}
3435
3536template <class _InputIterator1, class _InputIterator2, class _Tp, class _BinaryOp1, class _BinaryOp2>
36_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(
3738 _InputIterator1 __first1,
3839 _InputIterator1 __last1,
3940 _InputIterator2 __first2,
......@@ -46,14 +47,15 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp transform_reduce(
4647}
4748
4849template <class _InputIterator1, class _InputIterator2, class _Tp>
49_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
50[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp
5051transform_reduce(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init) {
5152 return std::transform_reduce(__first1, __last1, __first2, std::move(__init), std::plus<>(), std::multiplies<>());
5253}
53#endif
5454
5555_LIBCPP_END_NAMESPACE_STD
5656
57#endif // _LIBCPP_STD_VER >= 17
58
5759_LIBCPP_POP_MACROS
5860
5961#endif // _LIBCPP___NUMERIC_TRANSFORM_REDUCE_H
lib/libcxx/include/__ostream/basic_ostream.h+2
......@@ -41,6 +41,7 @@ _LIBCPP_PUSH_MACROS
4141# include <__undef_macros>
4242
4343_LIBCPP_BEGIN_NAMESPACE_STD
44_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4445
4546template <class _CharT, class _Traits>
4647class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
......@@ -672,6 +673,7 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
672673extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
673674# endif
674675
676_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
675677_LIBCPP_END_NAMESPACE_STD
676678
677679_LIBCPP_POP_MACROS
lib/libcxx/include/__ostream/print.h+8-9
......@@ -82,12 +82,14 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view _
8282// native Unicode API;
8383// Whether the returned FILE* is "a terminal capable of displaying Unicode"
8484// is determined in the same way as the print(FILE*, ...) overloads.
85_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
8586_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
87_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
8688
8789# if _LIBCPP_HAS_UNICODE
8890template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
8991_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
90# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
92# ifndef _LIBCPP_WIN32API
9193 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
9294# else
9395 FILE* __file = std::__get_ostream_file(__os);
......@@ -110,13 +112,10 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
110112# endif // _LIBCPP_HAS_EXCEPTIONS
111113 ostream::sentry __s(__os);
112114 if (__s) {
113# ifndef _LIBCPP_WIN32API
114 __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);
115# elif _LIBCPP_HAS_WIDE_CHARACTERS
116 __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);
117# else
118# error "Windows builds with wchar_t disabled are not supported."
119# endif
115 auto __result = std::vformat(__fmt, __args);
116 if (__write_nl)
117 __result.push_back('\n');
118 __print::__output_unicode_windows(__file, __result);
120119 }
121120
122121# if _LIBCPP_HAS_EXCEPTIONS
......@@ -124,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo
124123 __os.__set_badbit_and_consider_rethrow();
125124 }
126125# endif // _LIBCPP_HAS_EXCEPTIONS
127# endif // _LIBCPP_AVAILABILITY_HAS_PRINT
126# endif // _LIBCPP_WIN32API
128127}
129128
130129template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
lib/libcxx/include/__pstl/backend_fwd.h+20
......@@ -109,6 +109,13 @@ struct __is_partitioned;
109109// optional<bool>
110110// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
111111
112template <class _Backend, class _ExecutionPolicy>
113struct __find_first_of;
114// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
115// optional<_ForwardIterator1>
116// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
117// _ForwardIterator2 __first2, _ForwardIterator2 __last2, _Predicate __pred) const noexcept;
118
112119template <class _Backend, class _ExecutionPolicy>
113120struct __for_each;
114121// template <class _Policy, class _ForwardIterator, class _Function>
......@@ -159,6 +166,13 @@ struct __generate_n;
159166// optional<__empty>
160167// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Generator __gen) const noexcept;
161168
169template <class _Backend, class _ExecutionPolicy>
170struct __reverse_copy;
171// template <class _Policy, class _BidirectionalIterator, class _ForwardIterator>
172// optional<_ForwardIterator>
173// operator()(_Policy&&, _BidirectionalIterator __first, _BidirectionalIterator __last,
174// _ForwardIterator __result) const noexcept;
175
162176template <class _Backend, class _ExecutionPolicy>
163177struct __merge;
164178// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp>
......@@ -297,6 +311,12 @@ struct __reduce;
297311// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
298312// _Tp __init, _BinaryOperation __op) const noexcept;
299313
314template <class _Backend, class _ExecutionPolicy>
315struct __is_sorted;
316// template <class _Policy, class _ForwardIterator, class _Comp>
317// optional<bool>
318// operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Comp&& __comp) const noexcept;
319
300320} // namespace __pstl
301321_LIBCPP_END_NAMESPACE_STD
302322
lib/libcxx/include/__pstl/backends/default.h+78
......@@ -12,15 +12,21 @@
1212#include <__algorithm/copy_n.h>
1313#include <__algorithm/equal.h>
1414#include <__algorithm/fill_n.h>
15#include <__algorithm/find.h>
16#include <__algorithm/find_if.h>
1517#include <__algorithm/for_each_n.h>
18#include <__algorithm/is_sorted.h>
1619#include <__config>
1720#include <__functional/identity.h>
1821#include <__functional/not_fn.h>
1922#include <__functional/operations.h>
2023#include <__iterator/concepts.h>
2124#include <__iterator/iterator_traits.h>
25#include <__iterator/next.h>
26#include <__iterator/reverse_iterator.h>
2227#include <__pstl/backend_fwd.h>
2328#include <__pstl/dispatch.h>
29#include <__type_traits/desugars_to.h>
2430#include <__utility/empty.h>
2531#include <__utility/forward.h>
2632#include <__utility/move.h>
......@@ -55,6 +61,7 @@ namespace __pstl {
5561// - all_of
5662// - none_of
5763// - is_partitioned
64// - find_first_of
5865//
5966// for_each family
6067// ---------------
......@@ -80,6 +87,7 @@ namespace __pstl {
8087// - count
8188// - equal(3 legs)
8289// - equal
90// - is_sorted
8391// - reduce
8492//
8593// transform and transform_binary family
......@@ -89,6 +97,7 @@ namespace __pstl {
8997// - move
9098// - copy
9199// - copy_n
100// - reverse_copy
92101// - rotate_copy
93102//
94103
......@@ -178,6 +187,30 @@ struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> {
178187 }
179188};
180189
190template <class _ExecutionPolicy>
191struct __find_first_of<__default_backend_tag, _ExecutionPolicy> {
192 template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
193 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator1>
194 operator()(_Policy&& __policy,
195 _ForwardIterator1 __first1,
196 _ForwardIterator1 __last1,
197 _ForwardIterator2 __first2,
198 _ForwardIterator2 __last2,
199 _Predicate&& __pred) const noexcept {
200 using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>;
201 using _Ref1 = __iterator_reference<_ForwardIterator1>;
202 using _Ref2 = __iterator_reference<_ForwardIterator2>;
203 return _FindIf()(__policy, std::move(__first1), std::move(__last1), [&](_Ref1 __element) {
204 if constexpr (__desugars_to_v<__equal_tag, _Predicate, _Ref1, _Ref2>) {
205 // bypass an equality predicate and call directly to std::find() to allow more vectorization
206 return std::find(__first2, __last2, __element) != __last2;
207 } else {
208 return std::find_if(__first2, __last2, [&](_Ref2 __value) { return __pred(__element, __value); }) != __last2;
209 }
210 });
211 }
212};
213
181214//////////////////////////////////////////////////////////////
182215// for_each family
183216//////////////////////////////////////////////////////////////
......@@ -388,6 +421,35 @@ struct __reduce<__default_backend_tag, _ExecutionPolicy> {
388421 }
389422};
390423
424template <class _ExecutionPolicy>
425struct __is_sorted<__default_backend_tag, _ExecutionPolicy> {
426 template <class _Policy, class _ForwardIterator, class _Comp>
427 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
428 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Comp&& __comp) const noexcept {
429 if constexpr (__has_bidirectional_iterator_category<_ForwardIterator>::value) {
430 if (__first == __last)
431 return true; // Empty, sorted by definition
432 _ForwardIterator __first2 = std::next(__first);
433 if (__first2 == __last)
434 return true; // Only one element, sorted by definition
435 --__last; // Make two iterator ranges: [__first, __first + n - 1) and [__first + 1, __first + n)
436 using _TransformReduce = __dispatch<__transform_reduce_binary, __current_configuration, _ExecutionPolicy>;
437 using _Ref = __iterator_reference<_ForwardIterator>;
438 return _TransformReduce()(
439 __policy,
440 std::move(__first),
441 std::move(__last),
442 std::move(__first2),
443 true,
444 std::logical_and{},
445 [&](_Ref __left, _Ref __right) -> bool { return !__comp(__right, __left); });
446 } else {
447 // Currently anything outside bidirectional iterators has to be processed serially
448 return std::is_sorted(std::move(__first), std::move(__last), std::forward<_Comp>(__comp));
449 }
450 }
451};
452
391453//////////////////////////////////////////////////////////////
392454// transform family
393455//////////////////////////////////////////////////////////////
......@@ -497,6 +559,22 @@ struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
497559 }
498560};
499561
562template <class _ExecutionPolicy>
563struct __reverse_copy<__default_backend_tag, _ExecutionPolicy> {
564 template <class _Policy, class _BidirectionalIterator, class _ForwardIterator>
565 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
566 operator()(_Policy&& __policy,
567 _BidirectionalIterator __first,
568 _BidirectionalIterator __last,
569 _ForwardIterator __result) const noexcept {
570 using _Copy = __dispatch<__copy, __current_configuration, _ExecutionPolicy>;
571 return _Copy()(__policy,
572 std::reverse_iterator<_BidirectionalIterator>(std::move(__last)),
573 std::reverse_iterator<_BidirectionalIterator>(std::move(__first)),
574 std::move(__result));
575 }
576};
577
500578} // namespace __pstl
501579_LIBCPP_END_NAMESPACE_STD
502580
lib/libcxx/include/__pstl/backends/libdispatch.h+2
......@@ -48,6 +48,7 @@ _LIBCPP_PUSH_MACROS
4848#if _LIBCPP_STD_VER >= 17
4949
5050_LIBCPP_BEGIN_NAMESPACE_STD
51_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
5152namespace __pstl {
5253
5354namespace __libdispatch {
......@@ -393,6 +394,7 @@ struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
393394 : __cpu_parallel_fill<__libdispatch_backend_tag, _ExecutionPolicy> {};
394395
395396} // namespace __pstl
397_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
396398_LIBCPP_END_NAMESPACE_STD
397399
398400#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__random/bernoulli_distribution.h+7-7
......@@ -36,7 +36,7 @@ public:
3636
3737 _LIBCPP_HIDE_FROM_ABI explicit param_type(double __p = 0.5) : __p_(__p) {}
3838
39 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
39 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
4040
4141 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4242 return __x.__p_ == __y.__p_;
......@@ -60,20 +60,20 @@ public:
6060
6161 // generating functions
6262 template <class _URNG>
63 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
6464 return (*this)(__g, __p_);
6565 }
6666 template <class _URNG>
67 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
67 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
6868
6969 // property functions
70 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
70 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
7171
72 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
72 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
7373 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
7474
75 _LIBCPP_HIDE_FROM_ABI result_type min() const { return false; }
76 _LIBCPP_HIDE_FROM_ABI result_type max() const { return true; }
75 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return false; }
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return true; }
7777
7878 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const bernoulli_distribution& __x, const bernoulli_distribution& __y) {
7979 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/binomial_distribution.h+13-32
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___RANDOM_BINOMIAL_DISTRIBUTION_H
1111
1212#include <__config>
13#include <__math/gamma.h>
1314#include <__random/is_valid.h>
1415#include <__random/uniform_real_distribution.h>
1516#include <cmath>
......@@ -44,8 +45,8 @@ public:
4445
4546 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __t = 1, double __p = 0.5);
4647
47 _LIBCPP_HIDE_FROM_ABI result_type t() const { return __t_; }
48 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
48 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type t() const { return __t_; }
49 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
4950
5051 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5152 return __x.__t_ == __y.__t_ && __x.__p_ == __y.__p_;
......@@ -73,21 +74,21 @@ public:
7374
7475 // generating functions
7576 template <class _URNG>
76 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7778 return (*this)(__g, __p_);
7879 }
7980 template <class _URNG>
80 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
8182
8283 // property functions
83 _LIBCPP_HIDE_FROM_ABI result_type t() const { return __p_.t(); }
84 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
84 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type t() const { return __p_.t(); }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
8586
86 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8788 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8889
89 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
90 _LIBCPP_HIDE_FROM_ABI result_type max() const { return t(); }
90 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
91 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return t(); }
9192
9293 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const binomial_distribution& __x, const binomial_distribution& __y) {
9394 return __x.__p_ == __y.__p_;
......@@ -97,33 +98,13 @@ public:
9798 }
9899};
99100
100// Some libc declares the math functions to be `noexcept`.
101#if _LIBCPP_GLIBC_PREREQ(2, 8) || defined(__LLVM_LIBC__)
102# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
103#else
104# define _LIBCPP_LGAMMA_R_NOEXCEPT
105#endif
106
107#if !defined(_LIBCPP_MSVCRT_LIKE)
108extern "C" double lgamma_r(double, int*) _LIBCPP_LGAMMA_R_NOEXCEPT;
109#endif
110
111inline _LIBCPP_HIDE_FROM_ABI double __libcpp_lgamma(double __d) {
112#if defined(_LIBCPP_MSVCRT_LIKE)
113 return lgamma(__d);
114#else
115 int __sign;
116 return lgamma_r(__d, &__sign);
117#endif
118}
119
120101template <class _IntType>
121102binomial_distribution<_IntType>::param_type::param_type(result_type __t, double __p) : __t_(__t), __p_(__p) {
122103 if (0 < __p_ && __p_ < 1) {
123104 __r0_ = static_cast<result_type>((__t_ + 1) * __p_);
124 __pr_ = std::exp(
125 std::__libcpp_lgamma(__t_ + 1.) - std::__libcpp_lgamma(__r0_ + 1.) - std::__libcpp_lgamma(__t_ - __r0_ + 1.) +
126 __r0_ * std::log(__p_) + (__t_ - __r0_) * std::log(1 - __p_));
105 __pr_ =
106 std::exp(__math::__lgamma_r(__t_ + 1.) - __math::__lgamma_r(__r0_ + 1.) -
107 __math::__lgamma_r(__t_ - __r0_ + 1.) + __r0_ * std::log(__p_) + (__t_ - __r0_) * std::log(1 - __p_));
127108 __odds_ratio_ = __p_ / (1 - __p_);
128109 }
129110}
lib/libcxx/include/__random/cauchy_distribution.h+9-9
......@@ -43,8 +43,8 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
4848
4949 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5050 return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;
......@@ -70,21 +70,21 @@ public:
7070
7171 // generating functions
7272 template <class _URNG>
73 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
73 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7474 return (*this)(__g, __p_);
7575 }
7676 template <class _URNG>
77 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7878
7979 // property functions
80 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
81 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
8282
83 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8484 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8585
86 _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
87 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8888
8989 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const cauchy_distribution& __x, const cauchy_distribution& __y) {
9090 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/chi_squared_distribution.h+7-7
......@@ -41,7 +41,7 @@ public:
4141
4242 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __n = 1) : __n_(__n) {}
4343
44 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
44 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
4545
4646 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4747 return __x.__n_ == __y.__n_;
......@@ -65,22 +65,22 @@ public:
6565
6666 // generating functions
6767 template <class _URNG>
68 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
68 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
6969 return (*this)(__g, __p_);
7070 }
7171 template <class _URNG>
72 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
72 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
7373 return gamma_distribution<result_type>(__p.n() / 2, 2)(__g);
7474 }
7575
7676 // property functions
77 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
7878
79 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8080 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8181
82 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
83 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8484
8585 friend _LIBCPP_HIDE_FROM_ABI bool
8686 operator==(const chi_squared_distribution& __x, const chi_squared_distribution& __y) {
lib/libcxx/include/__random/discard_block_engine.h+9-10
......@@ -54,8 +54,8 @@ public:
5454 static constexpr result_type _Max = _Engine::max();
5555#endif
5656
57 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); }
58 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); }
57 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); }
58 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Engine::max(); }
5959
6060 // constructors and seeding functions
6161 _LIBCPP_HIDE_FROM_ABI discard_block_engine() : __n_(0) {}
......@@ -64,10 +64,9 @@ public:
6464 _LIBCPP_HIDE_FROM_ABI explicit discard_block_engine(_Engine&& __e) : __e_(std::move(__e)), __n_(0) {}
6565#endif // _LIBCPP_CXX03_LANG
6666 _LIBCPP_HIDE_FROM_ABI explicit discard_block_engine(result_type __sd) : __e_(__sd), __n_(0) {}
67 template <
68 class _Sseq,
69 __enable_if_t<__is_seed_sequence<_Sseq, discard_block_engine>::value && !is_convertible<_Sseq, _Engine>::value,
70 int> = 0>
67 template <class _Sseq,
68 __enable_if_t<__is_seed_sequence_v<_Sseq, discard_block_engine> && !is_convertible<_Sseq, _Engine>::value,
69 int> = 0>
7170 _LIBCPP_HIDE_FROM_ABI explicit discard_block_engine(_Sseq& __q) : __e_(__q), __n_(0) {}
7271 _LIBCPP_HIDE_FROM_ABI void seed() {
7372 __e_.seed();
......@@ -77,21 +76,21 @@ public:
7776 __e_.seed(__sd);
7877 __n_ = 0;
7978 }
80 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, discard_block_engine>::value, int> = 0>
79 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, discard_block_engine>, int> = 0>
8180 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
8281 __e_.seed(__q);
8382 __n_ = 0;
8483 }
8584
8685 // generating functions
87 _LIBCPP_HIDE_FROM_ABI result_type operator()();
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()();
8887 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
8988 for (; __z; --__z)
90 operator()();
89 (void)operator()();
9190 }
9291
9392 // property functions
94 _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
93 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
9594
9695 template <class _Eng, size_t _Pp, size_t _Rp>
9796 friend bool
lib/libcxx/include/__random/discrete_distribution.h+7-7
......@@ -52,7 +52,7 @@ public:
5252 template <class _UnaryOperation>
5353 _LIBCPP_HIDE_FROM_ABI param_type(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw);
5454
55 _LIBCPP_HIDE_FROM_ABI vector<double> probabilities() const;
55 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<double> probabilities() const;
5656
5757 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5858 return __x.__p_ == __y.__p_;
......@@ -92,20 +92,20 @@ public:
9292
9393 // generating functions
9494 template <class _URNG>
95 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
95 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
9696 return (*this)(__g, __p_);
9797 }
9898 template <class _URNG>
99 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
99 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
100100
101101 // property functions
102 _LIBCPP_HIDE_FROM_ABI vector<double> probabilities() const { return __p_.probabilities(); }
102 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<double> probabilities() const { return __p_.probabilities(); }
103103
104 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
104 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
105105 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
106106
107 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
108 _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__p_.size(); }
107 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
108 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__p_.size(); }
109109
110110 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const discrete_distribution& __x, const discrete_distribution& __y) {
111111 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/exponential_distribution.h+7-7
......@@ -43,7 +43,7 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __lambda = 1) : __lambda_(__lambda) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type lambda() const { return __lambda_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type lambda() const { return __lambda_; }
4747
4848 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4949 return __x.__lambda_ == __y.__lambda_;
......@@ -67,20 +67,20 @@ public:
6767
6868 // generating functions
6969 template <class _URNG>
70 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
70 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7171 return (*this)(__g, __p_);
7272 }
7373 template <class _URNG>
74 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
74 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7575
7676 // property functions
77 _LIBCPP_HIDE_FROM_ABI result_type lambda() const { return __p_.lambda(); }
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type lambda() const { return __p_.lambda(); }
7878
79 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8080 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8181
82 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
83 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8484
8585 friend _LIBCPP_HIDE_FROM_ABI bool
8686 operator==(const exponential_distribution& __x, const exponential_distribution& __y) {
lib/libcxx/include/__random/extreme_value_distribution.h+9-9
......@@ -43,8 +43,8 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
4848
4949 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5050 return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;
......@@ -70,21 +70,21 @@ public:
7070
7171 // generating functions
7272 template <class _URNG>
73 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
73 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7474 return (*this)(__g, __p_);
7575 }
7676 template <class _URNG>
77 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7878
7979 // property functions
80 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
81 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
8282
83 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8484 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8585
86 _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
87 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8888
8989 friend _LIBCPP_HIDE_FROM_ABI bool
9090 operator==(const extreme_value_distribution& __x, const extreme_value_distribution& __y) {
lib/libcxx/include/__random/fisher_f_distribution.h+9-9
......@@ -42,8 +42,8 @@ public:
4242
4343 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __m = 1, result_type __n = 1) : __m_(__m), __n_(__n) {}
4444
45 _LIBCPP_HIDE_FROM_ABI result_type m() const { return __m_; }
46 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
45 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type m() const { return __m_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
4747
4848 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4949 return __x.__m_ == __y.__m_ && __x.__n_ == __y.__n_;
......@@ -69,21 +69,21 @@ public:
6969
7070 // generating functions
7171 template <class _URNG>
72 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
72 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7373 return (*this)(__g, __p_);
7474 }
7575 template <class _URNG>
76 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7777
7878 // property functions
79 _LIBCPP_HIDE_FROM_ABI result_type m() const { return __p_.m(); }
80 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type m() const { return __p_.m(); }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
8181
82 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8383 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8484
85 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
86 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8787
8888 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const fisher_f_distribution& __x, const fisher_f_distribution& __y) {
8989 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/gamma_distribution.h+9-9
......@@ -45,8 +45,8 @@ public:
4545 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __alpha = 1, result_type __beta = 1)
4646 : __alpha_(__alpha), __beta_(__beta) {}
4747
48 _LIBCPP_HIDE_FROM_ABI result_type alpha() const { return __alpha_; }
49 _LIBCPP_HIDE_FROM_ABI result_type beta() const { return __beta_; }
48 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type alpha() const { return __alpha_; }
49 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type beta() const { return __beta_; }
5050
5151 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5252 return __x.__alpha_ == __y.__alpha_ && __x.__beta_ == __y.__beta_;
......@@ -72,21 +72,21 @@ public:
7272
7373 // generating functions
7474 template <class _URNG>
75 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
75 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7676 return (*this)(__g, __p_);
7777 }
7878 template <class _URNG>
79 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
8080
8181 // property functions
82 _LIBCPP_HIDE_FROM_ABI result_type alpha() const { return __p_.alpha(); }
83 _LIBCPP_HIDE_FROM_ABI result_type beta() const { return __p_.beta(); }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type alpha() const { return __p_.alpha(); }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type beta() const { return __p_.beta(); }
8484
85 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8686 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8787
88 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
89 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
88 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
9090
9191 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const gamma_distribution& __x, const gamma_distribution& __y) {
9292 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/generate_canonical.h+1-1
......@@ -27,7 +27,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727// generate_canonical
2828
2929template <class _RealType, size_t __bits, class _URNG>
30_LIBCPP_HIDE_FROM_ABI _RealType generate_canonical(_URNG& __g) {
30[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _RealType generate_canonical(_URNG& __g) {
3131 const size_t __dt = numeric_limits<_RealType>::digits;
3232 const size_t __b = __dt < __bits ? __dt : __bits;
3333#ifdef _LIBCPP_CXX03_LANG
lib/libcxx/include/__random/geometric_distribution.h+7-7
......@@ -40,7 +40,7 @@ public:
4040
4141 _LIBCPP_HIDE_FROM_ABI explicit param_type(double __p = 0.5) : __p_(__p) {}
4242
43 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
43 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
4444
4545 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4646 return __x.__p_ == __y.__p_;
......@@ -64,22 +64,22 @@ public:
6464
6565 // generating functions
6666 template <class _URNG>
67 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
67 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
6868 return (*this)(__g, __p_);
6969 }
7070 template <class _URNG>
71 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
71 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
7272 return negative_binomial_distribution<result_type>(1, __p.p())(__g);
7373 }
7474
7575 // property functions
76 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
7777
78 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
78 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
7979 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8080
81 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
82 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
8383
8484 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const geometric_distribution& __x, const geometric_distribution& __y) {
8585 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/independent_bits_engine.h+29-35
......@@ -82,8 +82,8 @@ public:
8282 static_assert(_Min < _Max, "independent_bits_engine invalid parameters");
8383
8484 // engine characteristics
85 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
86 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
8787
8888 // constructors and seeding functions
8989 _LIBCPP_HIDE_FROM_ABI independent_bits_engine() {}
......@@ -94,25 +94,47 @@ public:
9494 _LIBCPP_HIDE_FROM_ABI explicit independent_bits_engine(result_type __sd) : __e_(__sd) {}
9595 template <
9696 class _Sseq,
97 __enable_if_t<__is_seed_sequence<_Sseq, independent_bits_engine>::value && !is_convertible<_Sseq, _Engine>::value,
97 __enable_if_t<__is_seed_sequence_v<_Sseq, independent_bits_engine> && !is_convertible<_Sseq, _Engine>::value,
9898 int> = 0>
9999 _LIBCPP_HIDE_FROM_ABI explicit independent_bits_engine(_Sseq& __q) : __e_(__q) {}
100100 _LIBCPP_HIDE_FROM_ABI void seed() { __e_.seed(); }
101101 _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd) { __e_.seed(__sd); }
102 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, independent_bits_engine>::value, int> = 0>
102 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, independent_bits_engine>, int> = 0>
103103 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
104104 __e_.seed(__q);
105105 }
106106
107107 // generating functions
108 _LIBCPP_HIDE_FROM_ABI result_type operator()() { return __eval(integral_constant<bool, _Rp != 0>()); }
108 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()() {
109 if _LIBCPP_CONSTEXPR (_Rp != 0) {
110 result_type __sp = 0;
111 for (size_t __k = 0; __k < __n0; ++__k) {
112 _Engine_result_type __u;
113 do {
114 __u = __e_() - _Engine::min();
115 } while (__u >= __y0);
116 __sp = static_cast<result_type>(__lshift<__w0>(__sp) + (__u & __mask0));
117 }
118 for (size_t __k = __n0; __k < __n; ++__k) {
119 _Engine_result_type __u;
120 do {
121 __u = __e_() - _Engine::min();
122 } while (__u >= __y1);
123 __sp = static_cast<result_type>(__lshift<__w0 + 1>(__sp) + (__u & __mask1));
124 }
125 return __sp;
126 } else {
127 return static_cast<result_type>(__e_() & __mask0);
128 }
129 }
130
109131 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
110132 for (; __z; --__z)
111 operator()();
133 (void)operator()();
112134 }
113135
114136 // property functions
115 _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
137 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
116138
117139 template <class _Eng, size_t _Wp, class _UInt>
118140 friend bool operator==(const independent_bits_engine<_Eng, _Wp, _UInt>& __x,
......@@ -131,9 +153,6 @@ public:
131153 operator>>(basic_istream<_CharT, _Traits>& __is, independent_bits_engine<_Eng, _Wp, _UInt>& __x);
132154
133155private:
134 _LIBCPP_HIDE_FROM_ABI result_type __eval(false_type);
135 _LIBCPP_HIDE_FROM_ABI result_type __eval(true_type);
136
137156 template <size_t __count,
138157 __enable_if_t<__count< _Dt, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) {
139158 return __x << __count;
......@@ -145,31 +164,6 @@ private:
145164 }
146165};
147166
148template <class _Engine, size_t __w, class _UIntType>
149inline _UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) {
150 return static_cast<result_type>(__e_() & __mask0);
151}
152
153template <class _Engine, size_t __w, class _UIntType>
154_UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) {
155 result_type __sp = 0;
156 for (size_t __k = 0; __k < __n0; ++__k) {
157 _Engine_result_type __u;
158 do {
159 __u = __e_() - _Engine::min();
160 } while (__u >= __y0);
161 __sp = static_cast<result_type>(__lshift<__w0>(__sp) + (__u & __mask0));
162 }
163 for (size_t __k = __n0; __k < __n; ++__k) {
164 _Engine_result_type __u;
165 do {
166 __u = __e_() - _Engine::min();
167 } while (__u >= __y1);
168 __sp = static_cast<result_type>(__lshift<__w0 + 1>(__sp) + (__u & __mask1));
169 }
170 return __sp;
171}
172
173167template <class _Eng, size_t _Wp, class _UInt>
174168inline _LIBCPP_HIDE_FROM_ABI bool
175169operator==(const independent_bits_engine<_Eng, _Wp, _UInt>& __x, const independent_bits_engine<_Eng, _Wp, _UInt>& __y) {
lib/libcxx/include/__random/is_seed_sequence.h+2-4
......@@ -21,10 +21,8 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Sseq, class _Engine>
24struct __is_seed_sequence {
25 static _LIBCPP_CONSTEXPR const bool value =
26 !is_convertible<_Sseq, typename _Engine::result_type>::value && !is_same<__remove_cv_t<_Sseq>, _Engine>::value;
27};
24inline const bool __is_seed_sequence_v =
25 !is_convertible<_Sseq, typename _Engine::result_type>::value && !is_same<__remove_cv_t<_Sseq>, _Engine>::value;
2826
2927_LIBCPP_END_NAMESPACE_STD
3028
lib/libcxx/include/__random/linear_congruential_engine.h+26-41
......@@ -254,8 +254,8 @@ public:
254254 static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a;
255255 static inline _LIBCPP_CONSTEXPR const result_type increment = __c;
256256 static inline _LIBCPP_CONSTEXPR const result_type modulus = __m;
257 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
258 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
257 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
258 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
259259 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
260260
261261 // constructors and seeding functions
......@@ -265,28 +265,43 @@ public:
265265#else
266266 _LIBCPP_HIDE_FROM_ABI explicit linear_congruential_engine(result_type __s = default_seed) { seed(__s); }
267267#endif
268 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, linear_congruential_engine>::value, int> = 0>
268 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, linear_congruential_engine>, int> = 0>
269269 _LIBCPP_HIDE_FROM_ABI explicit linear_congruential_engine(_Sseq& __q) {
270270 seed(__q);
271271 }
272
272273 _LIBCPP_HIDE_FROM_ABI void seed(result_type __s = default_seed) {
273 seed(integral_constant<bool, __m == 0>(), integral_constant<bool, __c == 0>(), __s);
274 if _LIBCPP_CONSTEXPR (__m == 0) {
275 if _LIBCPP_CONSTEXPR (__c == 0)
276 __x_ = __s == 0 ? 1 : __s;
277 else
278 __x_ = __s;
279 } else {
280 if _LIBCPP_CONSTEXPR (__c == 0)
281 __x_ = __s % __m == 0 ? 1 : __s % __m;
282 else
283 __x_ = __s % __m;
284 }
274285 }
275 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, linear_congruential_engine>::value, int> = 0>
286
287 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, linear_congruential_engine>, int> = 0>
276288 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
277 __seed(
278 __q,
279 integral_constant<unsigned,
280 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1) / 32 : (__m > 0x100000000ull))>());
289 const _LIBCPP_CONSTEXPR unsigned __k =
290 1 + (__m == 0 ? (sizeof(result_type) * __CHAR_BIT__ - 1) / 32 : (__m > 0x100000000ull));
291 static_assert(__k <= 2);
292 uint32_t __ar[__k + 3];
293 __q.generate(__ar, __ar + __k + 3);
294 result_type __s = static_cast<result_type>((__ar[3] + (__k == 1 ? 0 : (uint64_t)__ar[4] << 32)) % __m);
295 __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
281296 }
282297
283298 // generating functions
284 _LIBCPP_HIDE_FROM_ABI result_type operator()() {
299 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()() {
285300 return __x_ = static_cast<result_type>(__lce_ta<__a, __c, __m, _Mp>::next(__x_));
286301 }
287302 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
288303 for (; __z; --__z)
289 operator()();
304 (void)operator()();
290305 }
291306
292307 friend _LIBCPP_HIDE_FROM_ABI bool
......@@ -299,16 +314,6 @@ public:
299314 }
300315
301316private:
302 _LIBCPP_HIDE_FROM_ABI void seed(true_type, true_type, result_type __s) { __x_ = __s == 0 ? 1 : __s; }
303 _LIBCPP_HIDE_FROM_ABI void seed(true_type, false_type, result_type __s) { __x_ = __s; }
304 _LIBCPP_HIDE_FROM_ABI void seed(false_type, true_type, result_type __s) { __x_ = __s % __m == 0 ? 1 : __s % __m; }
305 _LIBCPP_HIDE_FROM_ABI void seed(false_type, false_type, result_type __s) { __x_ = __s % __m; }
306
307 template <class _Sseq>
308 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
309 template <class _Sseq>
310 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
311
312317 template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np>
313318 friend basic_ostream<_CharT, _Traits>&
314319 operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_Up, _Ap, _Cp, _Np>&);
......@@ -318,26 +323,6 @@ private:
318323 operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
319324};
320325
321template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
322template <class _Sseq>
323void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {
324 const unsigned __k = 1;
325 uint32_t __ar[__k + 3];
326 __q.generate(__ar, __ar + __k + 3);
327 result_type __s = static_cast<result_type>(__ar[3] % __m);
328 __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
329}
330
331template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
332template <class _Sseq>
333void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 2>) {
334 const unsigned __k = 2;
335 uint32_t __ar[__k + 3];
336 __q.generate(__ar, __ar + __k + 3);
337 result_type __s = static_cast<result_type>((__ar[3] + ((uint64_t)__ar[4] << 32)) % __m);
338 __x_ = __c == 0 && __s == 0 ? result_type(1) : __s;
339}
340
341326template <class _CharT, class _Traits, class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
342327inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
343328operator<<(basic_ostream<_CharT, _Traits>& __os, const linear_congruential_engine<_UIntType, __a, __c, __m>& __x) {
lib/libcxx/include/__random/lognormal_distribution.h+9-9
......@@ -43,8 +43,8 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __m = 0, result_type __s = 1) : __m_(__m), __s_(__s) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type m() const { return __m_; }
47 _LIBCPP_HIDE_FROM_ABI result_type s() const { return __s_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type m() const { return __m_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type s() const { return __s_; }
4848
4949 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5050 return __x.__m_ == __y.__m_ && __x.__s_ == __y.__s_;
......@@ -68,28 +68,28 @@ public:
6868
6969 // generating functions
7070 template <class _URNG>
71 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
71 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7272 return std::exp(__nd_(__g));
7373 }
7474
7575 template <class _URNG>
76 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
7777 typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s());
7878 return std::exp(__nd_(__g, __pn));
7979 }
8080
8181 // property functions
82 _LIBCPP_HIDE_FROM_ABI result_type m() const { return __nd_.mean(); }
83 _LIBCPP_HIDE_FROM_ABI result_type s() const { return __nd_.stddev(); }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type m() const { return __nd_.mean(); }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type s() const { return __nd_.stddev(); }
8484
85 _LIBCPP_HIDE_FROM_ABI param_type param() const { return param_type(__nd_.mean(), __nd_.stddev()); }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return param_type(__nd_.mean(), __nd_.stddev()); }
8686 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) {
8787 typename normal_distribution<result_type>::param_type __pn(__p.m(), __p.s());
8888 __nd_.param(__pn);
8989 }
9090
91 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
92 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
91 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
92 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
9393
9494 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const lognormal_distribution& __x, const lognormal_distribution& __y) {
9595 return __x.__nd_ == __y.__nd_;
lib/libcxx/include/__random/mersenne_twister_engine.h+73-62
......@@ -161,8 +161,8 @@ public:
161161 static inline _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
162162 static inline _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
163163 static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
164 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
165 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
164 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
165 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
166166 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
167167
168168 // constructors and seeding functions
......@@ -172,7 +172,7 @@ public:
172172#else
173173 _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(result_type __sd = default_seed) { seed(__sd); }
174174#endif
175 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>
175 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, mersenne_twister_engine>, int> = 0>
176176 _LIBCPP_HIDE_FROM_ABI explicit mersenne_twister_engine(_Sseq& __q) {
177177 seed(__q);
178178 }
......@@ -181,21 +181,68 @@ public:
181181 for (size_t __i = 1; __i < __n; ++__i)
182182 __x_[__i] = (__f * (__x_[__i - 1] ^ __rshift<__w - 2>(__x_[__i - 1])) + __i) & _Max;
183183 __i_ = 0;
184#ifdef _LIBCPP_ABI_VECTORIZED_MERSENNE_TWISTER_ENGINE
185 __update_all_states();
186#endif
184187 }
185 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, mersenne_twister_engine>::value, int> = 0>
188 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, mersenne_twister_engine>, int> = 0>
186189 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
187 __seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());
190 const unsigned __k = 1 + (__w - 1) / 32;
191 static_assert(__k <= 2);
192 uint32_t __ar[__n * __k];
193 __q.generate(__ar, __ar + __n * __k);
194 for (size_t __i = 0; __i < __n; ++__i) {
195 if _LIBCPP_CONSTEXPR (__k == 1) {
196 __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
197 } else {
198 __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
199 }
200 }
201 const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
202 __i_ = 0;
203 if ((__x_[0] & ~__mask) == 0) {
204 for (size_t __i = 1; __i < __n; ++__i)
205 if (__x_[__i] != 0)
206 return;
207 __x_[0] = result_type(1) << (__w - 1);
208 }
209#ifdef _LIBCPP_ABI_VECTORIZED_MERSENNE_TWISTER_ENGINE
210 __update_all_states();
211#endif
188212 }
189213
190 // generating functions
191 _LIBCPP_HIDE_FROM_ABI result_type operator()() {
192 const size_t __j = (__i_ + 1) % __n;
214 void __update_state(size_t __i, size_t __k) {
215 const size_t __j = (__i + 1) % __n;
193216 const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
194 const result_type __yp = (__x_[__i_] & ~__mask) | (__x_[__j] & __mask);
195 const size_t __k = (__i_ + __m) % __n;
196 __x_[__i_] = __x_[__k] ^ __rshift<1>(__yp) ^ (__a * (__yp & 1));
197 result_type __z = __x_[__i_] ^ (__rshift<__u>(__x_[__i_]) & __d);
198 __i_ = __j;
217 const result_type __yp = (__x_[__i] & ~__mask) | (__x_[__j] & __mask);
218 __x_[__i] = __x_[__k] ^ __rshift<1>(__yp) ^ (__a * (__yp & 1));
219 }
220
221 void __update_state(size_t __i) { __update_state(__i, (__i + __m) % __n); }
222
223 void __update_all_states() {
224 size_t __i = 0;
225 // This is split into two loops to help the compiler vectorize the code
226 for (; __i != (__n - __m); ++__i)
227 __update_state(__i);
228 for (size_t __j = 0; __i != __n; ++__i, ++__j)
229 __update_state(__i, __j);
230 }
231
232 // generating functions
233 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()() {
234#ifdef _LIBCPP_ABI_VECTORIZED_MERSENNE_TWISTER_ENGINE
235 result_type __val = __x_[__i_];
236 if (++__i_ == __n) [[__unlikely__]] {
237 __update_all_states();
238 __i_ = 0;
239 }
240#else
241 __update_state(__i_);
242 result_type __val = __x_[__i_];
243 __i_ = (__i_ + 1) % __n;
244#endif
245 result_type __z = __val ^ (__rshift<__u>(__val) & __d);
199246 __z ^= __lshift<__s>(__z) & __b;
200247 __z ^= __lshift<__t>(__z) & __c;
201248 return __z ^ __rshift<__l>(__z);
......@@ -203,7 +250,7 @@ public:
203250
204251 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
205252 for (; __z; --__z)
206 operator()();
253 (void)operator()();
207254 }
208255
209256 template <class _UInt,
......@@ -265,59 +312,23 @@ public:
265312 mersenne_twister_engine<_UInt, _Wp, _Np, _Mp, _Rp, _Ap, _Up, _Dp, _Sp, _Bp, _Tp, _Cp, _Lp, _Fp>& __x);
266313
267314private:
268 template <class _Sseq>
269 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>) {
270 const unsigned __k = 1;
271 uint32_t __ar[__n * __k];
272 __q.generate(__ar, __ar + __n * __k);
273 for (size_t __i = 0; __i < __n; ++__i)
274 __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
275 const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
276 __i_ = 0;
277 if ((__x_[0] & ~__mask) == 0) {
278 for (size_t __i = 1; __i < __n; ++__i)
279 if (__x_[__i] != 0)
280 return;
281 __x_[0] = result_type(1) << (__w - 1);
315 template <size_t __count>
316 _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) {
317 if _LIBCPP_CONSTEXPR (__count < __w) {
318 return (__x << __count) & _Max;
319 } else {
320 return result_type(0);
282321 }
283322 }
284323
285 template <class _Sseq>
286 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>) {
287 const unsigned __k = 2;
288 uint32_t __ar[__n * __k];
289 __q.generate(__ar, __ar + __n * __k);
290 for (size_t __i = 0; __i < __n; ++__i)
291 __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
292 const result_type __mask = __r == _Dt ? result_type(~0) : (result_type(1) << __r) - result_type(1);
293 __i_ = 0;
294 if ((__x_[0] & ~__mask) == 0) {
295 for (size_t __i = 1; __i < __n; ++__i)
296 if (__x_[__i] != 0)
297 return;
298 __x_[0] = result_type(1) << (__w - 1);
324 template <size_t __count>
325 _LIBCPP_HIDE_FROM_ABI static result_type __rshift(result_type __x) {
326 if _LIBCPP_CONSTEXPR (__count < _Dt) {
327 return __x >> __count;
328 } else {
329 return result_type(0);
299330 }
300331 }
301
302 template <size_t __count,
303 __enable_if_t<__count< __w, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type __x) {
304 return (__x << __count) & _Max;
305 }
306
307 template <size_t __count, __enable_if_t<(__count >= __w), int> = 0>
308 _LIBCPP_HIDE_FROM_ABI static result_type __lshift(result_type) {
309 return result_type(0);
310 }
311
312 template <size_t __count,
313 __enable_if_t<__count< _Dt, int> = 0> _LIBCPP_HIDE_FROM_ABI static result_type __rshift(result_type __x) {
314 return __x >> __count;
315 }
316
317 template <size_t __count, __enable_if_t<(__count >= _Dt), int> = 0>
318 _LIBCPP_HIDE_FROM_ABI static result_type __rshift(result_type) {
319 return result_type(0);
320 }
321332};
322333
323334template <class _UInt,
lib/libcxx/include/__random/negative_binomial_distribution.h+9-9
......@@ -44,8 +44,8 @@ public:
4444
4545 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __k = 1, double __p = 0.5) : __k_(__k), __p_(__p) {}
4646
47 _LIBCPP_HIDE_FROM_ABI result_type k() const { return __k_; }
48 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type k() const { return __k_; }
48 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_; }
4949
5050 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5151 return __x.__k_ == __y.__k_ && __x.__p_ == __y.__p_;
......@@ -70,21 +70,21 @@ public:
7070
7171 // generating functions
7272 template <class _URNG>
73 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
73 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7474 return (*this)(__g, __p_);
7575 }
7676 template <class _URNG>
77 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7878
7979 // property functions
80 _LIBCPP_HIDE_FROM_ABI result_type k() const { return __p_.k(); }
81 _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type k() const { return __p_.k(); }
81 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double p() const { return __p_.p(); }
8282
83 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8484 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8585
86 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
87 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
87 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
8888
8989 friend _LIBCPP_HIDE_FROM_ABI bool
9090 operator==(const negative_binomial_distribution& __x, const negative_binomial_distribution& __y) {
lib/libcxx/include/__random/normal_distribution.h+9-9
......@@ -44,8 +44,8 @@ public:
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __mean = 0, result_type __stddev = 1)
4545 : __mean_(__mean), __stddev_(__stddev) {}
4646
47 _LIBCPP_HIDE_FROM_ABI result_type mean() const { return __mean_; }
48 _LIBCPP_HIDE_FROM_ABI result_type stddev() const { return __stddev_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type mean() const { return __mean_; }
48 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type stddev() const { return __stddev_; }
4949
5050 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5151 return __x.__mean_ == __y.__mean_ && __x.__stddev_ == __y.__stddev_;
......@@ -73,21 +73,21 @@ public:
7373
7474 // generating functions
7575 template <class _URNG>
76 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7777 return (*this)(__g, __p_);
7878 }
7979 template <class _URNG>
80 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
8181
8282 // property functions
83 _LIBCPP_HIDE_FROM_ABI result_type mean() const { return __p_.mean(); }
84 _LIBCPP_HIDE_FROM_ABI result_type stddev() const { return __p_.stddev(); }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type mean() const { return __p_.mean(); }
84 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type stddev() const { return __p_.stddev(); }
8585
86 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8787 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8888
89 _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
90 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
90 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
9191
9292 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const normal_distribution& __x, const normal_distribution& __y) {
9393 return __x.__p_ == __y.__p_ && __x.__v_hot_ == __y.__v_hot_ && (!__x.__v_hot_ || __x.__v_ == __y.__v_);
lib/libcxx/include/__random/piecewise_constant_distribution.h+9-9
......@@ -59,8 +59,8 @@ public:
5959 _LIBCPP_HIDE_FROM_ABI param_type(param_type const&) = default;
6060 _LIBCPP_HIDE_FROM_ABI param_type& operator=(const param_type& __rhs);
6161
62 _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __b_; }
63 _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __densities_; }
62 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __b_; }
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __densities_; }
6464
6565 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
6666 return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;
......@@ -109,21 +109,21 @@ public:
109109
110110 // generating functions
111111 template <class _URNG>
112 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
112 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
113113 return (*this)(__g, __p_);
114114 }
115115 template <class _URNG>
116 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
116 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
117117
118118 // property functions
119 _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __p_.intervals(); }
120 _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __p_.densities(); }
119 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __p_.intervals(); }
120 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __p_.densities(); }
121121
122 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
122 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
123123 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
124124
125 _LIBCPP_HIDE_FROM_ABI result_type min() const { return __p_.__b_.front(); }
126 _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__b_.back(); }
125 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return __p_.__b_.front(); }
126 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__b_.back(); }
127127
128128 friend _LIBCPP_HIDE_FROM_ABI bool
129129 operator==(const piecewise_constant_distribution& __x, const piecewise_constant_distribution& __y) {
lib/libcxx/include/__random/piecewise_linear_distribution.h+9-9
......@@ -60,8 +60,8 @@ public:
6060 _LIBCPP_HIDE_FROM_ABI param_type(param_type const&) = default;
6161 _LIBCPP_HIDE_FROM_ABI param_type& operator=(const param_type& __rhs);
6262
63 _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __b_; }
64 _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __densities_; }
63 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __b_; }
64 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __densities_; }
6565
6666 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
6767 return __x.__densities_ == __y.__densities_ && __x.__b_ == __y.__b_;
......@@ -110,21 +110,21 @@ public:
110110
111111 // generating functions
112112 template <class _URNG>
113 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
113 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
114114 return (*this)(__g, __p_);
115115 }
116116 template <class _URNG>
117 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
117 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
118118
119119 // property functions
120 _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __p_.intervals(); }
121 _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __p_.densities(); }
120 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> intervals() const { return __p_.intervals(); }
121 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI vector<result_type> densities() const { return __p_.densities(); }
122122
123 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
123 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
124124 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
125125
126 _LIBCPP_HIDE_FROM_ABI result_type min() const { return __p_.__b_.front(); }
127 _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__b_.back(); }
126 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return __p_.__b_.front(); }
127 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return __p_.__b_.back(); }
128128
129129 friend _LIBCPP_HIDE_FROM_ABI bool
130130 operator==(const piecewise_linear_distribution& __x, const piecewise_linear_distribution& __y) {
lib/libcxx/include/__random/poisson_distribution.h+7-7
......@@ -53,7 +53,7 @@ public:
5353
5454 _LIBCPP_HIDE_FROM_ABI explicit param_type(double __mean = 1.0);
5555
56 _LIBCPP_HIDE_FROM_ABI double mean() const { return __mean_; }
56 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double mean() const { return __mean_; }
5757
5858 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5959 return __x.__mean_ == __y.__mean_;
......@@ -79,20 +79,20 @@ public:
7979
8080 // generating functions
8181 template <class _URNG>
82 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
8383 return (*this)(__g, __p_);
8484 }
8585 template <class _URNG>
86 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
8787
8888 // property functions
89 _LIBCPP_HIDE_FROM_ABI double mean() const { return __p_.mean(); }
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI double mean() const { return __p_.mean(); }
9090
91 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
91 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
9292 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
9393
94 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
95 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
94 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
95 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::max(); }
9696
9797 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const poisson_distribution& __x, const poisson_distribution& __y) {
9898 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/random_device.h+11-13
......@@ -19,27 +19,24 @@
1919_LIBCPP_PUSH_MACROS
2020#include <__undef_macros>
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_HAS_RANDOM_DEVICE
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
26
2627class _LIBCPP_EXPORTED_FROM_ABI random_device {
2728# ifdef _LIBCPP_USING_DEV_RANDOM
2829 int __f_;
2930# elif !defined(_LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT)
30 _LIBCPP_DIAGNOSTIC_PUSH
31 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wunused-private-field")
32
3331 // Apple platforms used to use the `_LIBCPP_USING_DEV_RANDOM` code path, and now
3432 // use `arc4random()` as of this comment. In order to avoid breaking the ABI, we
3533 // retain the same layout as before.
3634# if defined(__APPLE__)
37 int __padding_; // padding to fake the `__f_` field above
35 [[__maybe_unused__]] int __padding_; // padding to fake the `__f_` field above
3836# endif
3937
4038 // ... vendors can add workarounds here if they switch to a different representation ...
4139
42 _LIBCPP_DIAGNOSTIC_POP
4340# endif
4441
4542public:
......@@ -50,8 +47,8 @@ public:
5047 static _LIBCPP_CONSTEXPR const result_type _Min = 0;
5148 static _LIBCPP_CONSTEXPR const result_type _Max = 0xFFFFFFFFu;
5249
53 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
54 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
50 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
51 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
5552
5653 // constructors
5754# ifndef _LIBCPP_CXX03_LANG
......@@ -63,19 +60,20 @@ public:
6360 ~random_device();
6461
6562 // generating functions
66 result_type operator()();
63 [[__nodiscard__]] result_type operator()();
6764
6865 // property functions
69 double entropy() const _NOEXCEPT;
66 [[__nodiscard__]] double entropy() const _NOEXCEPT;
7067
7168 random_device(const random_device&) = delete;
7269 void operator=(const random_device&) = delete;
7370};
7471
75#endif // _LIBCPP_HAS_RANDOM_DEVICE
76
72_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7773_LIBCPP_END_NAMESPACE_STD
7874
75#endif // _LIBCPP_HAS_RANDOM_DEVICE
76
7977_LIBCPP_POP_MACROS
8078
8179#endif // _LIBCPP___RANDOM_RANDOM_DEVICE_H
lib/libcxx/include/__random/seed_seq.h+2-2
......@@ -56,7 +56,7 @@ public:
5656 _LIBCPP_HIDE_FROM_ABI void generate(_RandomAccessIterator __first, _RandomAccessIterator __last);
5757
5858 // property functions
59 _LIBCPP_HIDE_FROM_ABI size_t size() const _NOEXCEPT { return __v_.size(); }
59 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t size() const _NOEXCEPT { return __v_.size(); }
6060 template <class _OutputIterator>
6161 _LIBCPP_HIDE_FROM_ABI void param(_OutputIterator __dest) const {
6262 std::copy(__v_.begin(), __v_.end(), __dest);
......@@ -65,7 +65,7 @@ public:
6565 seed_seq(const seed_seq&) = delete;
6666 void operator=(const seed_seq&) = delete;
6767
68 _LIBCPP_HIDE_FROM_ABI static result_type _Tp(result_type __x) { return __x ^ (__x >> 27); }
68 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static result_type _Tp(result_type __x) { return __x ^ (__x >> 27); }
6969
7070private:
7171 template <class _InputIterator>
lib/libcxx/include/__random/shuffle_order_engine.h+23-33
......@@ -76,8 +76,8 @@ public:
7676 static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
7777#endif
7878 static_assert(_Min < _Max, "shuffle_order_engine invalid parameters");
79 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
80 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
8181
8282 static _LIBCPP_CONSTEXPR const unsigned long long _Rp = _Max - _Min + 1ull;
8383
......@@ -88,10 +88,9 @@ public:
8888 _LIBCPP_HIDE_FROM_ABI explicit shuffle_order_engine(_Engine&& __e) : __e_(std::move(__e)) { __init(); }
8989#endif // _LIBCPP_CXX03_LANG
9090 _LIBCPP_HIDE_FROM_ABI explicit shuffle_order_engine(result_type __sd) : __e_(__sd) { __init(); }
91 template <
92 class _Sseq,
93 __enable_if_t<__is_seed_sequence<_Sseq, shuffle_order_engine>::value && !is_convertible<_Sseq, _Engine>::value,
94 int> = 0>
91 template <class _Sseq,
92 __enable_if_t<__is_seed_sequence_v<_Sseq, shuffle_order_engine> && !is_convertible<_Sseq, _Engine>::value,
93 int> = 0>
9594 _LIBCPP_HIDE_FROM_ABI explicit shuffle_order_engine(_Sseq& __q) : __e_(__q) {
9695 __init();
9796 }
......@@ -103,21 +102,35 @@ public:
103102 __e_.seed(__sd);
104103 __init();
105104 }
106 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, shuffle_order_engine>::value, int> = 0>
105 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, shuffle_order_engine>, int> = 0>
107106 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
108107 __e_.seed(__q);
109108 __init();
110109 }
111110
112111 // generating functions
113 _LIBCPP_HIDE_FROM_ABI result_type operator()() { return __eval(integral_constant<bool, _Rp != 0>()); }
112 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()() {
113 if _LIBCPP_CONSTEXPR (_Rp != 0 || !(__k & 1)) {
114 using _Ratio = __uratio<__k, _Rp != 0 ? _Rp : 0x8000000000000000ull>;
115 if _LIBCPP_CONSTEXPR (_Ratio::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)) {
116 return __evalf<_Ratio::num, _Ratio::den>();
117 } else {
118 const size_t __j = static_cast<size_t>(_Ratio::num * (__y_ - _Min) / _Ratio::den);
119 __y_ = __v_[__j];
120 __v_[__j] = __e_();
121 return __y_;
122 }
123 } else
124 return __evalf<__k, 0>();
125 }
126
114127 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
115128 for (; __z; --__z)
116 operator()();
129 (void)operator()();
117130 }
118131
119132 // property functions
120 _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
133 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Engine& base() const _NOEXCEPT { return __e_; }
121134
122135private:
123136 template <class _Eng, size_t _Kp>
......@@ -140,29 +153,6 @@ private:
140153 __y_ = __e_();
141154 }
142155
143 _LIBCPP_HIDE_FROM_ABI result_type __eval(false_type) { return __eval2(integral_constant<bool, __k & 1>()); }
144 _LIBCPP_HIDE_FROM_ABI result_type __eval(true_type) { return __eval(__uratio<__k, _Rp>()); }
145
146 _LIBCPP_HIDE_FROM_ABI result_type __eval2(false_type) { return __eval(__uratio<__k / 2, 0x8000000000000000ull>()); }
147 _LIBCPP_HIDE_FROM_ABI result_type __eval2(true_type) { return __evalf<__k, 0>(); }
148
149 template <uint64_t _Np,
150 uint64_t _Dp,
151 __enable_if_t<(__uratio<_Np, _Dp>::num > 0xFFFFFFFFFFFFFFFFull / (_Max - _Min)), int> = 0>
152 _LIBCPP_HIDE_FROM_ABI result_type __eval(__uratio<_Np, _Dp>) {
153 return __evalf<__uratio<_Np, _Dp>::num, __uratio<_Np, _Dp>::den>();
154 }
155
156 template <uint64_t _Np,
157 uint64_t _Dp,
158 __enable_if_t<__uratio<_Np, _Dp>::num <= 0xFFFFFFFFFFFFFFFFull / (_Max - _Min), int> = 0>
159 _LIBCPP_HIDE_FROM_ABI result_type __eval(__uratio<_Np, _Dp>) {
160 const size_t __j = static_cast<size_t>(__uratio<_Np, _Dp>::num * (__y_ - _Min) / __uratio<_Np, _Dp>::den);
161 __y_ = __v_[__j];
162 __v_[__j] = __e_();
163 return __y_;
164 }
165
166156 template <uint64_t __n, uint64_t __d>
167157 _LIBCPP_HIDE_FROM_ABI result_type __evalf() {
168158 const double __fp = __d == 0 ? __n / (2. * 0x8000000000000000ull) : __n / (double)__d;
lib/libcxx/include/__random/student_t_distribution.h+7-7
......@@ -43,7 +43,7 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __n = 1) : __n_(__n) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __n_; }
4747
4848 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4949 return __x.__n_ == __y.__n_;
......@@ -68,20 +68,20 @@ public:
6868
6969 // generating functions
7070 template <class _URNG>
71 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
71 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7272 return (*this)(__g, __p_);
7373 }
7474 template <class _URNG>
75 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
75 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7676
7777 // property functions
78 _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
78 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type n() const { return __p_.n(); }
7979
80 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8181 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8282
83 _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
84 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return -numeric_limits<result_type>::infinity(); }
84 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
8585
8686 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const student_t_distribution& __x, const student_t_distribution& __y) {
8787 return __x.__p_ == __y.__p_;
lib/libcxx/include/__random/subtract_with_carry_engine.h+31-60
......@@ -75,8 +75,8 @@ public:
7575 static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
7676 static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s;
7777 static inline _LIBCPP_CONSTEXPR const size_t long_lag = __r;
78 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
79 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
78 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
8080 static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
8181
8282 // constructors and seeding functions
......@@ -86,23 +86,46 @@ public:
8686#else
8787 _LIBCPP_HIDE_FROM_ABI explicit subtract_with_carry_engine(result_type __sd = default_seed) { seed(__sd); }
8888#endif
89 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, int> = 0>
89 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, subtract_with_carry_engine>, int> = 0>
9090 _LIBCPP_HIDE_FROM_ABI explicit subtract_with_carry_engine(_Sseq& __q) {
9191 seed(__q);
9292 }
93
9394 _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd = default_seed) {
94 seed(__sd, integral_constant<unsigned, 1 + (__w - 1) / 32>());
95 linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);
96 for (size_t __i = 0; __i < __r; ++__i) {
97 if _LIBCPP_CONSTEXPR ((1 + (__w - 1) / 32) == 1) {
98 __x_[__i] = static_cast<result_type>(__e() & _Max);
99 } else {
100 result_type __e0 = __e();
101 __x_[__i] = static_cast<result_type>((__e0 + ((uint64_t)__e() << 32)) & _Max);
102 }
103 }
104 __c_ = __x_[__r - 1] == 0;
105 __i_ = 0;
95106 }
96 template <class _Sseq, __enable_if_t<__is_seed_sequence<_Sseq, subtract_with_carry_engine>::value, int> = 0>
107
108 template <class _Sseq, __enable_if_t<__is_seed_sequence_v<_Sseq, subtract_with_carry_engine>, int> = 0>
97109 _LIBCPP_HIDE_FROM_ABI void seed(_Sseq& __q) {
98 __seed(__q, integral_constant<unsigned, 1 + (__w - 1) / 32>());
110 const unsigned __k = 1 + (__w - 1) / 32;
111 static_assert(__k <= 2);
112 uint32_t __ar[__r * __k];
113 __q.generate(__ar, __ar + __r * __k);
114 for (size_t __i = 0; __i < __r; ++__i) {
115 if _LIBCPP_CONSTEXPR (__k == 1)
116 __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
117 else
118 __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
119 }
120 __c_ = __x_[__r - 1] == 0;
121 __i_ = 0;
99122 }
100123
101124 // generating functions
102 _LIBCPP_HIDE_FROM_ABI result_type operator()();
125 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()();
103126 _LIBCPP_HIDE_FROM_ABI void discard(unsigned long long __z) {
104127 for (; __z; --__z)
105 operator()();
128 (void)operator()();
106129 }
107130
108131 template <class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
......@@ -120,60 +143,8 @@ public:
120143 template <class _CharT, class _Traits, class _UInt, size_t _Wp, size_t _Sp, size_t _Rp>
121144 friend basic_istream<_CharT, _Traits>&
122145 operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UInt, _Wp, _Sp, _Rp>& __x);
123
124private:
125 _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd, integral_constant<unsigned, 1>);
126 _LIBCPP_HIDE_FROM_ABI void seed(result_type __sd, integral_constant<unsigned, 2>);
127 template <class _Sseq>
128 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 1>);
129 template <class _Sseq>
130 _LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
131146};
132147
133template <class _UIntType, size_t __w, size_t __s, size_t __r>
134void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) {
135 linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);
136 for (size_t __i = 0; __i < __r; ++__i)
137 __x_[__i] = static_cast<result_type>(__e() & _Max);
138 __c_ = __x_[__r - 1] == 0;
139 __i_ = 0;
140}
141
142template <class _UIntType, size_t __w, size_t __s, size_t __r>
143void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 2>) {
144 linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);
145 for (size_t __i = 0; __i < __r; ++__i) {
146 result_type __e0 = __e();
147 __x_[__i] = static_cast<result_type>((__e0 + ((uint64_t)__e() << 32)) & _Max);
148 }
149 __c_ = __x_[__r - 1] == 0;
150 __i_ = 0;
151}
152
153template <class _UIntType, size_t __w, size_t __s, size_t __r>
154template <class _Sseq>
155void subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {
156 const unsigned __k = 1;
157 uint32_t __ar[__r * __k];
158 __q.generate(__ar, __ar + __r * __k);
159 for (size_t __i = 0; __i < __r; ++__i)
160 __x_[__i] = static_cast<result_type>(__ar[__i] & _Max);
161 __c_ = __x_[__r - 1] == 0;
162 __i_ = 0;
163}
164
165template <class _UIntType, size_t __w, size_t __s, size_t __r>
166template <class _Sseq>
167void subtract_with_carry_engine<_UIntType, __w, __s, __r>::__seed(_Sseq& __q, integral_constant<unsigned, 2>) {
168 const unsigned __k = 2;
169 uint32_t __ar[__r * __k];
170 __q.generate(__ar, __ar + __r * __k);
171 for (size_t __i = 0; __i < __r; ++__i)
172 __x_[__i] = static_cast<result_type>((__ar[2 * __i] + ((uint64_t)__ar[2 * __i + 1] << 32)) & _Max);
173 __c_ = __x_[__r - 1] == 0;
174 __i_ = 0;
175}
176
177148template <class _UIntType, size_t __w, size_t __s, size_t __r>
178149_UIntType subtract_with_carry_engine<_UIntType, __w, __s, __r>::operator()() {
179150 const result_type& __xs = __x_[(__i_ + (__r - __s)) % __r];
lib/libcxx/include/__random/uniform_int_distribution.h+9-9
......@@ -151,8 +151,8 @@ public:
151151 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __a = 0, result_type __b = numeric_limits<result_type>::max())
152152 : __a_(__a), __b_(__b) {}
153153
154 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
155 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
154 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
155 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
156156
157157 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const param_type& __x, const param_type& __y) {
158158 return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;
......@@ -179,21 +179,21 @@ public:
179179
180180 // generating functions
181181 template <class _URNG>
182 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
182 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
183183 return (*this)(__g, __p_);
184184 }
185185 template <class _URNG>
186 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
186 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
187187
188188 // property functions
189 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
190 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
189 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
190 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
191191
192 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
192 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
193193 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
194194
195 _LIBCPP_HIDE_FROM_ABI result_type min() const { return a(); }
196 _LIBCPP_HIDE_FROM_ABI result_type max() const { return b(); }
195 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return a(); }
196 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return b(); }
197197
198198 _LIBCPP_HIDE_FROM_ABI friend bool
199199 operator==(const uniform_int_distribution& __x, const uniform_int_distribution& __y) {
lib/libcxx/include/__random/uniform_random_bit_generator.h+4-4
......@@ -23,10 +23,10 @@
2323_LIBCPP_PUSH_MACROS
2424#include <__undef_macros>
2525
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2826#if _LIBCPP_STD_VER >= 20
2927
28_LIBCPP_BEGIN_NAMESPACE_STD
29
3030// [rand.req.urng]
3131template <class _Gen>
3232concept uniform_random_bit_generator = invocable<_Gen&> && unsigned_integral<invoke_result_t<_Gen&>> && requires {
......@@ -35,10 +35,10 @@ concept uniform_random_bit_generator = invocable<_Gen&> && unsigned_integral<inv
3535 requires bool_constant<(_Gen::min() < _Gen::max())>::value;
3636};
3737
38#endif // _LIBCPP_STD_VER >= 20
39
4038_LIBCPP_END_NAMESPACE_STD
4139
40#endif // _LIBCPP_STD_VER >= 20
41
4242_LIBCPP_POP_MACROS
4343
4444#endif // _LIBCPP___RANDOM_UNIFORM_RANDOM_BIT_GENERATOR_H
lib/libcxx/include/__random/uniform_real_distribution.h+9-9
......@@ -42,8 +42,8 @@ public:
4242
4343 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __a = 0, result_type __b = 1) : __a_(__a), __b_(__b) {}
4444
45 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
46 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
45 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
4747
4848 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
4949 return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;
......@@ -69,21 +69,21 @@ public:
6969
7070 // generating functions
7171 template <class _URNG>
72 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
72 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7373 return (*this)(__g, __p_);
7474 }
7575 template <class _URNG>
76 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
76 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p);
7777
7878 // property functions
79 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
80 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
79 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
80 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
8181
82 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8383 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8484
85 _LIBCPP_HIDE_FROM_ABI result_type min() const { return a(); }
86 _LIBCPP_HIDE_FROM_ABI result_type max() const { return b(); }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return a(); }
86 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return b(); }
8787
8888 friend _LIBCPP_HIDE_FROM_ABI bool
8989 operator==(const uniform_real_distribution& __x, const uniform_real_distribution& __y) {
lib/libcxx/include/__random/weibull_distribution.h+9-9
......@@ -43,8 +43,8 @@ public:
4343
4444 _LIBCPP_HIDE_FROM_ABI explicit param_type(result_type __a = 1, result_type __b = 1) : __a_(__a), __b_(__b) {}
4545
46 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
46 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __a_; }
47 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __b_; }
4848
4949 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const param_type& __x, const param_type& __y) {
5050 return __x.__a_ == __y.__a_ && __x.__b_ == __y.__b_;
......@@ -70,23 +70,23 @@ public:
7070
7171 // generating functions
7272 template <class _URNG>
73 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
73 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g) {
7474 return (*this)(__g, __p_);
7575 }
7676 template <class _URNG>
77 _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
77 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type operator()(_URNG& __g, const param_type& __p) {
7878 return __p.b() * std::pow(exponential_distribution<result_type>()(__g), 1 / __p.a());
7979 }
8080
8181 // property functions
82 _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
83 _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
82 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type a() const { return __p_.a(); }
83 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type b() const { return __p_.b(); }
8484
85 _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
85 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI param_type param() const { return __p_; }
8686 _LIBCPP_HIDE_FROM_ABI void param(const param_type& __p) { __p_ = __p; }
8787
88 _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
89 _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
88 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type min() const { return 0; }
89 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI result_type max() const { return numeric_limits<result_type>::infinity(); }
9090
9191 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const weibull_distribution& __x, const weibull_distribution& __y) {
9292 return __x.__p_ == __y.__p_;
lib/libcxx/include/__ranges/access.h+4-4
......@@ -27,10 +27,10 @@
2727# pragma GCC system_header
2828#endif
2929
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3230#if _LIBCPP_STD_VER >= 20
3331
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3434namespace ranges {
3535template <class _Tp>
3636concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remove_cvref_t<_Tp>>;
......@@ -203,8 +203,8 @@ inline constexpr auto cend = __cend::__fn{};
203203} // namespace __cpo
204204} // namespace ranges
205205
206#endif // _LIBCPP_STD_VER >= 20
207
208206_LIBCPP_END_NAMESPACE_STD
209207
208#endif // _LIBCPP_STD_VER >= 20
209
210210#endif // _LIBCPP___RANGES_ACCESS_H
lib/libcxx/include/__ranges/adjacent_transform_view.h+20-19
......@@ -19,6 +19,7 @@
1919#include <__concepts/derived_from.h>
2020#include <__concepts/equality_comparable.h>
2121#include <__concepts/invocable.h>
22#include <__concepts/referenceable.h>
2223#include <__cstddef/size_t.h>
2324#include <__functional/bind_back.h>
2425#include <__functional/invoke.h>
......@@ -45,7 +46,6 @@
4546#include <__type_traits/decay.h>
4647#include <__type_traits/is_nothrow_constructible.h>
4748#include <__type_traits/is_object.h>
48#include <__type_traits/is_referenceable.h>
4949#include <__type_traits/make_unsigned.h>
5050#include <__type_traits/maybe_const.h>
5151#include <__utility/declval.h>
......@@ -105,22 +105,22 @@ public:
105105 _LIBCPP_HIDE_FROM_ABI constexpr explicit adjacent_transform_view(_View __base, _Fn __fun)
106106 : __inner_(std::move(__base)), __fun_(std::in_place, std::move(__fun)) {}
107107
108 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
108 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
109109 requires copy_constructible<_View>
110110 {
111111 return __inner_.base();
112112 }
113 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__inner_).base(); }
113 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__inner_).base(); }
114114
115 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __inner_.begin()); }
115 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __inner_.begin()); }
116116
117 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
118118 requires range<const _InnerView> && regular_invocable<__apply_n<const _Fn&, _Np>, range_reference_t<const _View>>
119119 {
120120 return __iterator<true>(*this, __inner_.begin());
121121 }
122122
123 _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
124124 if constexpr (common_range<_InnerView>) {
125125 return __iterator<false>(*this, __inner_.end());
126126 } else {
......@@ -128,7 +128,7 @@ public:
128128 }
129129 }
130130
131 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
131 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
132132 requires range<const _InnerView> && regular_invocable<__apply_n<const _Fn&, _Np>, range_reference_t<const _View>>
133133 {
134134 if constexpr (common_range<const _InnerView>) {
......@@ -138,13 +138,13 @@ public:
138138 }
139139 }
140140
141 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
141 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
142142 requires sized_range<_InnerView>
143143 {
144144 return __inner_.size();
145145 }
146146
147 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
147 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
148148 requires sized_range<const _InnerView>
149149 {
150150 return __inner_.size();
......@@ -202,7 +202,7 @@ public:
202202 requires _Const && convertible_to<__inner_iterator<false>, __inner_iterator<true>>
203203 : __parent_(__i.__parent_), __inner_(std::move(__i.__inner_)) {}
204204
205 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
205 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
206206 noexcept(__noexcept_dereference(make_index_sequence<_Np>{})) {
207207 return std::apply(
208208 [&](const auto&... __iters) -> decltype(auto) { return std::invoke(*__parent_->__fun_, *__iters...); },
......@@ -249,7 +249,7 @@ public:
249249 return *this;
250250 }
251251
252 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
252 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
253253 requires random_access_range<_Base>
254254 {
255255 return std::apply(
......@@ -291,25 +291,26 @@ public:
291291 return __x.__inner_ <=> __y.__inner_;
292292 }
293293
294 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
294 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
295295 requires random_access_range<_Base>
296296 {
297297 return __iterator(*__i.__parent_, __i.__inner_ + __n);
298298 }
299299
300 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
300 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
301301 requires random_access_range<_Base>
302302 {
303303 return __iterator(*__i.__parent_, __i.__inner_ + __n);
304304 }
305305
306 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
306 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
307307 requires random_access_range<_Base>
308308 {
309309 return __iterator(*__i.__parent_, __i.__inner_ - __n);
310310 }
311311
312 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
312 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
313 operator-(const __iterator& __x, const __iterator& __y)
313314 requires sized_sentinel_for<__inner_iterator<_Const>, __inner_iterator<_Const>>
314315 {
315316 return __x.__inner_ - __y.__inner_;
......@@ -344,14 +345,14 @@ public:
344345
345346 template <bool _OtherConst>
346347 requires sized_sentinel_for<__inner_sentinel<_Const>, __inner_iterator<_OtherConst>>
347 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
348 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
348349 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
349350 return __x.__inner_ - __y.__inner_;
350351 }
351352
352353 template <bool _OtherConst>
353354 requires sized_sentinel_for<__inner_sentinel<_Const>, __inner_iterator<_OtherConst>>
354 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
355 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
355356 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
356357 return __x.__inner_ - __y.__inner_;
357358 }
......@@ -364,14 +365,14 @@ template <size_t _Np>
364365struct __fn : __range_adaptor_closure<__fn<_Np>> {
365366 template <class _Range, class _Fn>
366367 requires(_Np == 0 && forward_range<_Range &&>)
367 _LIBCPP_HIDE_FROM_ABI static constexpr auto
368 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
368369 operator()(_Range&&, _Fn&& __fn) noexcept(noexcept(views::zip_transform(std::forward<_Fn>(__fn))))
369370 -> decltype(views::zip_transform(std::forward<_Fn>(__fn))) {
370371 return views::zip_transform(std::forward<_Fn>(__fn));
371372 }
372373
373374 template <class _Range, class _Fn>
374 _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Fn&& __fn) noexcept(
375 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&& __range, _Fn&& __fn) noexcept(
375376 noexcept(adjacent_transform_view<views::all_t<_Range&&>, decay_t<_Fn>, _Np>(
376377 std::forward<_Range>(__range), std::forward<_Fn>(__fn))))
377378 -> decltype(adjacent_transform_view<views::all_t<_Range&&>, decay_t<_Fn>, _Np>(
lib/libcxx/include/__ranges/adjacent_view.h+19-18
......@@ -81,26 +81,26 @@ public:
8181
8282 _LIBCPP_HIDE_FROM_ABI constexpr explicit adjacent_view(_View __base) : __base_(std::move(__base)) {}
8383
84 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
84 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
8585 requires copy_constructible<_View>
8686 {
8787 return __base_;
8888 }
89 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
9089
91 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
90 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
91 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
9292 requires(!__simple_view<_View>)
9393 {
9494 return __iterator<false>(ranges::begin(__base_), ranges::end(__base_));
9595 }
9696
97 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
9898 requires range<const _View> // LWG4482 This is under-constrained.
9999 {
100100 return __iterator<true>(ranges::begin(__base_), ranges::end(__base_));
101101 }
102102
103 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
104104 requires(!__simple_view<_View>)
105105 {
106106 if constexpr (common_range<_View>) {
......@@ -110,7 +110,7 @@ public:
110110 }
111111 }
112112
113 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
113 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
114114 requires range<const _View> // LWG4482 This is under-constrained.
115115 {
116116 if constexpr (common_range<const _View>) {
......@@ -120,7 +120,7 @@ public:
120120 }
121121 }
122122
123 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
124124 requires sized_range<_View>
125125 {
126126 using _ST = decltype(ranges::size(__base_));
......@@ -130,7 +130,7 @@ public:
130130 return static_cast<_ST>(__sz);
131131 }
132132
133 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
133 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
134134 requires sized_range<const _View>
135135 {
136136 using _ST = decltype(ranges::size(__base_));
......@@ -205,7 +205,7 @@ public:
205205 requires _Const && convertible_to<iterator_t<_View>, iterator_t<const _View>>
206206 : __iterator(std::move(__i), make_index_sequence<_Np>{}) {}
207207
208 _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const {
208 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const {
209209 return std::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_);
210210 }
211211
......@@ -257,7 +257,7 @@ public:
257257 return *this;
258258 }
259259
260 _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const
260 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const
261261 requires random_access_range<_Base>
262262 {
263263 return std::__tuple_transform([&](auto& __i) -> decltype(auto) { return __i[__n]; }, __current_);
......@@ -297,7 +297,7 @@ public:
297297 return __x.__current_.back() <=> __y.__current_.back();
298298 }
299299
300 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
300 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
301301 requires random_access_range<_Base>
302302 {
303303 auto __r = __i;
......@@ -305,13 +305,13 @@ public:
305305 return __r;
306306 }
307307
308 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
308 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
309309 requires random_access_range<_Base>
310310 {
311311 return __i + __n;
312312 }
313313
314 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
314 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
315315 requires random_access_range<_Base>
316316 {
317317 auto __r = __i;
......@@ -319,7 +319,8 @@ public:
319319 return __r;
320320 }
321321
322 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
322 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
323 operator-(const __iterator& __x, const __iterator& __y)
323324 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
324325 {
325326 return __x.__current_.back() - __y.__current_.back();
......@@ -366,14 +367,14 @@ public:
366367
367368 template <bool _OtherConst>
368369 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
369 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
370 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
370371 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
371372 return __x.__current_.back() - __y.__end_;
372373 }
373374
374375 template <bool _OtherConst>
375376 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
376 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
377 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
377378 operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) {
378379 return __y.__end_ - __x.__current_.back();
379380 }
......@@ -389,12 +390,12 @@ template <size_t _Np>
389390struct __fn : __range_adaptor_closure<__fn<_Np>> {
390391 template <class _Range>
391392 requires(_Np == 0 && forward_range<_Range &&>)
392 _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&&) noexcept {
393 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Range&&) noexcept {
393394 return empty_view<tuple<>>{};
394395 }
395396
396397 template <class _Ranges>
397 _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ranges&& __range) noexcept(
398 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ranges&& __range) noexcept(
398399 noexcept(adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range))))
399400 -> decltype(adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range))) {
400401 return adjacent_view<views::all_t<_Ranges&&>, _Np>(std::forward<_Ranges>(__range));
lib/libcxx/include/__ranges/all.h+4-4
......@@ -29,10 +29,10 @@
2929# pragma GCC system_header
3030#endif
3131
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3432#if _LIBCPP_STD_VER >= 20
3533
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3636namespace ranges::views {
3737
3838namespace __all {
......@@ -71,8 +71,8 @@ using all_t = decltype(views::all(std::declval<_Range>()));
7171
7272} // namespace ranges::views
7373
74#endif // _LIBCPP_STD_VER >= 20
75
7674_LIBCPP_END_NAMESPACE_STD
7775
76#endif // _LIBCPP_STD_VER >= 20
77
7878#endif // _LIBCPP___RANGES_ALL_H
lib/libcxx/include/__ranges/chunk_by_view.h+1-1
......@@ -54,7 +54,7 @@ namespace ranges {
5454
5555template <forward_range _View, indirect_binary_predicate<iterator_t<_View>, iterator_t<_View>> _Pred>
5656 requires view<_View> && is_object_v<_Pred>
57class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS chunk_by_view : public view_interface<chunk_by_view<_View, _Pred>> {
57class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG chunk_by_view : public view_interface<chunk_by_view<_View, _Pred>> {
5858 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
5959 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;
6060
lib/libcxx/include/__ranges/concat_view.h created+651
......@@ -0,0 +1,651 @@
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_CONCAT_VIEW_H
11#define _LIBCPP___RANGES_CONCAT_VIEW_H
12
13#include <__assert>
14#include <__concepts/common_reference_with.h>
15#include <__concepts/constructible.h>
16#include <__concepts/convertible_to.h>
17#include <__concepts/copyable.h>
18#include <__concepts/derived_from.h>
19#include <__concepts/equality_comparable.h>
20#include <__concepts/swappable.h>
21#include <__config>
22#include <__iterator/concepts.h>
23#include <__iterator/default_sentinel.h>
24#include <__iterator/distance.h>
25#include <__iterator/incrementable_traits.h>
26#include <__iterator/iter_move.h>
27#include <__iterator/iter_swap.h>
28#include <__iterator/iterator_traits.h>
29#include <__iterator/next.h>
30#include <__ranges/access.h>
31#include <__ranges/all.h>
32#include <__ranges/concepts.h>
33#include <__ranges/movable_box.h>
34#include <__ranges/range_adaptor.h>
35#include <__ranges/size.h>
36#include <__ranges/view_interface.h>
37#include <__tuple/tuple_transform.h>
38#include <__type_traits/conditional.h>
39#include <__type_traits/decay.h>
40#include <__type_traits/is_nothrow_constructible.h>
41#include <__type_traits/make_unsigned.h>
42#include <__type_traits/maybe_const.h>
43#include <__utility/forward.h>
44#include <__utility/in_place.h>
45#include <__utility/move.h>
46#include <tuple>
47#include <variant>
48
49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50# pragma GCC system_header
51#endif
52
53_LIBCPP_PUSH_MACROS
54#include <__undef_macros>
55
56_LIBCPP_BEGIN_NAMESPACE_STD
57
58#if _LIBCPP_STD_VER >= 26
59
60namespace ranges {
61
62# ifdef __cpp_pack_indexing
63template <class... _Tp>
64using __extract_last _LIBCPP_NODEBUG = _Tp...[sizeof...(_Tp) - 1];
65# else
66template <class _Tp, class... _Tail>
67struct __extract_last_impl : __extract_last_impl<_Tail...> {};
68template <class _Tp>
69struct __extract_last_impl<_Tp> {
70 using type _LIBCPP_NODEBUG = _Tp;
71};
72
73template <class... _Tp>
74using __extract_last _LIBCPP_NODEBUG = __extract_last_impl<_Tp...>::type;
75# endif
76
77template <bool _Const, class... _Tp>
78struct __all_but_first_model_sized_range;
79
80template <bool _Const, class _Head, class... _Tail>
81struct __all_but_first_model_sized_range<_Const, _Head, _Tail...> {
82 static constexpr bool value = (sized_range<__maybe_const<_Const, _Tail>> && ...);
83};
84
85template <bool _Const, class... _Views>
86concept __all_random_access = (random_access_range<__maybe_const<_Const, _Views>> && ...);
87
88template <bool _Const, class... _Views>
89concept __all_bidirectional = (bidirectional_range<__maybe_const<_Const, _Views>> && ...);
90
91template <bool _Const, class... _Views>
92concept __all_forward = (forward_range<__maybe_const<_Const, _Views>> && ...);
93
94template <bool _Const, class _First, class... _Tail>
95struct __all_common_ignore_last {
96 static constexpr bool value =
97 common_range<__maybe_const<_Const, _First>> && __all_common_ignore_last<_Const, _Tail...>::value;
98};
99
100template <bool _Const, class _Tail>
101struct __all_common_ignore_last<_Const, _Tail> {
102 static constexpr bool value = true;
103};
104
105template <bool _Const, class... _Rs>
106concept __concat_is_random_access =
107 (__all_random_access<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
108
109template <bool _Const, class... _Rs>
110concept __concat_is_bidirectional =
111 (__all_bidirectional<_Const, _Rs...>) && (__all_common_ignore_last<_Const, _Rs...>::value);
112
113template <input_range... _Views>
114 requires((view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>)
115class concat_view : public view_interface<concat_view<_Views...>> {
116 tuple<_Views...> __views_;
117
118 template <bool _Const>
119 class __iterator;
120
121public:
122 _LIBCPP_HIDE_FROM_ABI constexpr concat_view() = default;
123
124 _LIBCPP_HIDE_FROM_ABI constexpr explicit concat_view(_Views... __views) : __views_(std::move(__views)...) {}
125
126 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<false> begin()
127 requires(!(__simple_view<_Views> && ...))
128 {
129 __iterator<false> __it(this, in_place_index<0>, ranges::begin(std::get<0>(__views_)));
130 __it.template __satisfy<0>();
131 return __it;
132 }
133
134 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<true> begin() const
135 requires((range<const _Views> && ...) && __concatable<const _Views...>)
136 {
137 __iterator<true> __it(this, in_place_index<0>, ranges::begin(std::get<0>(__views_)));
138 __it.template __satisfy<0>();
139 return __it;
140 }
141
142 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
143 requires(!(__simple_view<_Views> && ...))
144 {
145 if constexpr (__all_forward<false, _Views...> && common_range<__maybe_const<false, __extract_last<_Views...>>>) {
146 constexpr auto __n = sizeof...(_Views);
147 return __iterator<false>(this, in_place_index<__n - 1>, ranges::end(std::get<__n - 1>(__views_)));
148 } else {
149 return default_sentinel;
150 }
151 }
152
153 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
154 requires((range<const _Views> && ...) && __concatable<const _Views...>)
155 {
156 if constexpr (__all_forward<true, _Views...> && common_range<__maybe_const<true, __extract_last<_Views...>>>) {
157 constexpr auto __n = sizeof...(_Views);
158 return __iterator<true>(this, in_place_index<__n - 1>, ranges::end(std::get<__n - 1>(__views_)));
159 } else {
160 return default_sentinel;
161 }
162 }
163
164 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
165 requires(sized_range<_Views> && ...)
166 {
167 return std::apply(
168 [](auto... __sizes) { return (make_unsigned_t<common_type_t<decltype(__sizes)...>>(__sizes) + ...); },
169 std::__tuple_transform(ranges::size, __views_));
170 }
171
172 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
173 requires(sized_range<const _Views> && ...)
174 {
175 return std::apply(
176 [](auto... __sizes) { return (make_unsigned_t<common_type_t<decltype(__sizes)...>>(__sizes) + ...); },
177 std::__tuple_transform(ranges::size, __views_));
178 }
179};
180
181template <class... _Views>
182concat_view(_Views&&...) -> concat_view<views::all_t<_Views>...>;
183
184template <bool _Const, typename... _Views>
185struct __concat_view_iterator_category {};
186
187template <bool _Const, typename... _Views>
188 requires __all_forward<_Const, _Views...>
189struct __concat_view_iterator_category<_Const, _Views...> {
190private:
191 constexpr static bool __derive_pack_random_iterator =
192 (derived_from<typename iterator_traits<iterator_t<__maybe_const<_Const, _Views>>>::iterator_category,
193 random_access_iterator_tag> &&
194 ...);
195 constexpr static bool __derive_pack_bidirectional_iterator =
196 (derived_from<typename iterator_traits<iterator_t<__maybe_const<_Const, _Views>>>::iterator_category,
197 bidirectional_iterator_tag> &&
198 ...);
199 constexpr static bool __derive_pack_forward_iterator =
200 (derived_from<typename iterator_traits< iterator_t<__maybe_const<_Const, _Views>>>::iterator_category,
201 forward_iterator_tag> &&
202 ...);
203
204public:
205 using iterator_category =
206 _If<!is_reference_v<__concat_reference_t<__maybe_const<_Const, _Views>...>>,
207 input_iterator_tag,
208 _If<__derive_pack_random_iterator,
209 random_access_iterator_tag,
210 _If<__derive_pack_bidirectional_iterator,
211 bidirectional_iterator_tag,
212 _If<__derive_pack_forward_iterator, forward_iterator_tag, input_iterator_tag > > > >;
213};
214
215template <input_range... _Views>
216 requires((view<_Views> && ...) && (sizeof...(_Views) > 0) && __concatable<_Views...>)
217template <bool _Const>
218class concat_view<_Views...>::__iterator : public __concat_view_iterator_category<_Const, _Views...> {
219public:
220 using iterator_concept =
221 _If<__concat_is_random_access<_Const, _Views...>,
222 random_access_iterator_tag,
223 _If<__concat_is_bidirectional<_Const, _Views...>,
224 bidirectional_iterator_tag,
225 _If< __all_forward<_Const, _Views...>, forward_iterator_tag, input_iterator_tag > > >;
226 using value_type = __concat_value_t<__maybe_const<_Const, _Views>...>;
227 using difference_type = common_type_t<range_difference_t<__maybe_const<_Const, _Views>>...>;
228
229private:
230 using __base_iter _LIBCPP_NODEBUG = variant<iterator_t<__maybe_const<_Const, _Views>>...>;
231 __base_iter __it_;
232 __maybe_const<_Const, concat_view>* __parent_ = nullptr;
233
234 template <size_t _Idx>
235 _LIBCPP_HIDE_FROM_ABI constexpr void __satisfy() {
236 if constexpr (_Idx < (sizeof...(_Views) - 1)) {
237 if (std::get<_Idx>(__it_) == ranges::end(std::get<_Idx>(__parent_->__views_))) {
238 __it_.template emplace<_Idx + 1>(ranges::begin(std::get<_Idx + 1>(__parent_->__views_)));
239 __satisfy<_Idx + 1>();
240 }
241 }
242 }
243
244 template <size_t _Idx>
245 _LIBCPP_HIDE_FROM_ABI constexpr void __prev() {
246 if constexpr (_Idx == 0) {
247 --std::get<0>(__it_);
248 } else {
249 if (std::get<_Idx>(__it_) == ranges::begin(std::get<_Idx>(__parent_->__views_))) {
250 __it_.template emplace<_Idx - 1>(ranges::end(std::get<_Idx - 1>(__parent_->__views_)));
251 __prev<_Idx - 1>();
252 } else {
253 --std::get<_Idx>(__it_);
254 }
255 }
256 }
257
258 template <size_t _Idx>
259 _LIBCPP_HIDE_FROM_ABI constexpr void __advance_fwd(difference_type __offset, difference_type __steps) {
260 using __underlying_diff_type = iter_difference_t<variant_alternative_t<_Idx, __base_iter>>;
261 if constexpr (_Idx == sizeof...(_Views) - 1) {
262 std::get<_Idx>(__it_) += static_cast<__underlying_diff_type>(__steps);
263 } else {
264 auto __n_size = ranges::distance(std::get<_Idx>(__parent_->__views_));
265 if (__offset + __steps < __n_size) {
266 std::get<_Idx>(__it_) += static_cast<__underlying_diff_type>(__steps);
267 } else {
268 __it_.template emplace<_Idx + 1>(ranges::begin(std::get<_Idx + 1>(__parent_->__views_)));
269 __advance_fwd<_Idx + 1>(0, __offset + __steps - __n_size);
270 }
271 }
272 }
273
274 template <size_t _Idx>
275 _LIBCPP_HIDE_FROM_ABI constexpr void __advance_bwd(difference_type __offset, difference_type __steps) {
276 using __underlying_diff_type = iter_difference_t<variant_alternative_t<_Idx, __base_iter>>;
277 if constexpr (_Idx == 0) {
278 std::get<_Idx>(__it_) -= static_cast<__underlying_diff_type>(__steps);
279 } else {
280 if (__offset >= __steps) {
281 std::get<_Idx>(__it_) -= static_cast<__underlying_diff_type>(__steps);
282 } else {
283 auto __prev_size = ranges::distance(std::get<_Idx - 1>(__parent_->__views_));
284 __it_.template emplace<_Idx - 1>(ranges::end(std::get<_Idx - 1>(__parent_->__views_)));
285 __advance_bwd<_Idx - 1>(__prev_size, __steps - __offset);
286 }
287 }
288 }
289
290 template <typename _Func>
291 _LIBCPP_HIDE_FROM_ABI constexpr auto __invoke_at_index(_Func&& __func) const {
292 // TODO(GCC 16): Just capture `this` when GCC PR113563 and PR121008 are fixed.
293 return [&__func, &__view_iter = *this]<std::size_t _Is>(this auto&& __self) {
294 if (_Is == __view_iter.__it_.index()) {
295 return __func.template operator()<_Is>();
296 }
297 if constexpr (_Is + 1 < sizeof...(_Views)) {
298 return __self.template operator()<_Is + 1>();
299 }
300 __builtin_unreachable();
301 }.template operator()<0>();
302 }
303
304 template <size_t... _Is, typename _Func>
305 _LIBCPP_HIDE_FROM_ABI constexpr void __apply_at_index(size_t __index, _Func&& __func, index_sequence<_Is...>) const {
306 ((__index == _Is ? (static_cast<void>(__func(integral_constant<size_t, _Is>{})), 0) : 0), ...);
307 }
308
309 template <size_t _Idx, typename _Func>
310 _LIBCPP_HIDE_FROM_ABI constexpr void __apply_at_index(size_t __index, _Func&& __func) const {
311 __apply_at_index(__index, std::forward<_Func>(__func), make_index_sequence<_Idx>{});
312 }
313
314 template <class... _Args>
315 _LIBCPP_HIDE_FROM_ABI explicit constexpr __iterator(__maybe_const<_Const, concat_view>* __parent, _Args&&... __args)
316 requires constructible_from<__base_iter, _Args&&...>
317 : __it_(std::forward<_Args>(__args)...), __parent_(__parent) {}
318
319 friend class concat_view;
320 friend class __iterator<!_Const>;
321
322public:
323 _LIBCPP_HIDE_FROM_ABI __iterator() = default;
324
325 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i)
326 requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<const _Views>> && ...)
327 : __it_([&__src = __i.__it_]<size_t... _Indices>(size_t __idx, index_sequence<_Indices...>) -> __base_iter {
328 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
329 !__src.valueless_by_exception(), "Trying to convert from a valueless iterator of concat_view.");
330 using __src_lref = decltype((__src));
331 using __construction_fptr = __base_iter (*)(__src_lref);
332 static constexpr __construction_fptr __vtable[]{[](__src_lref __src_var) -> __base_iter {
333 return __base_iter(in_place_index<_Indices>, std::__unchecked_get<_Indices>(std::move(__src_var)));
334 }...};
335 return __vtable[__idx](__src);
336 }(__i.__it_.index(), make_index_sequence<variant_size_v<__base_iter>>{})),
337 __parent_(__i.__parent_) {}
338
339 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const {
340 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
341 !__it_.valueless_by_exception(), "Trying to dereference a valueless iterator of concat_view.");
342 return __variant_detail::__visitation::__variant::__visit_value(
343 [](auto&& __it) -> __concat_reference_t<__maybe_const<_Const, _Views>...> { return *__it; }, __it_);
344 }
345
346 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
347 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
348 !__it_.valueless_by_exception(), "Trying to increment a valueless iterator of concat_view.");
349 size_t __active_index = __it_.index();
350 __apply_at_index<variant_size_v<decltype(__it_)>>(__active_index, [&](auto __index_constant) {
351 constexpr size_t __i = __index_constant.value;
352 ++std::__unchecked_get<__i>(__it_);
353 __satisfy<__i>();
354 });
355 return *this;
356 }
357
358 _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { ++*this; }
359
360 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int)
361 requires(__all_forward<_Const, _Views...>)
362 {
363 auto __tmp = *this;
364 ++*this;
365 return __tmp;
366 }
367
368 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--()
369 requires __concat_is_bidirectional<_Const, _Views...>
370 {
371 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
372 !__it_.valueless_by_exception(), "Trying to decrement a valueless iterator of concat_view.");
373 size_t __active_index = __it_.index();
374 __apply_at_index<variant_size_v<decltype(__it_)>>(__active_index, [&](auto __index_constant) {
375 constexpr size_t __i = __index_constant.value;
376 __prev<__i>();
377 });
378 return *this;
379 }
380
381 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
382 requires __concat_is_bidirectional<_Const, _Views...>
383 {
384 auto __tmp = *this;
385 --*this;
386 return __tmp;
387 }
388
389 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
390 requires(equality_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...)
391 {
392 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
393 "Trying to compare a valueless iterator of concat_view.");
394 return __x.__it_ == __y.__it_;
395 }
396
397 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
398 requires __concat_is_random_access<_Const, _Views...>
399 {
400 return *((*this) + __n);
401 }
402
403 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __it, difference_type __n)
404 requires __concat_is_random_access<_Const, _Views...>
405 {
406 auto __temp = __it;
407 __temp += __n;
408 return __temp;
409 }
410
411 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __it)
412 requires __concat_is_random_access<_Const, _Views...>
413 {
414 return __it + __n;
415 }
416
417 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n)
418 requires __concat_is_random_access<_Const, _Views...>
419 {
420 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
421 !__it_.valueless_by_exception(), "Trying to increment a valueless iterator of concat_view.");
422 size_t __active_index = __it_.index();
423 if (__n > 0) {
424 __apply_at_index<tuple_size_v<decltype(__parent_->__views_)>>(__active_index, [&](auto __index_constant) {
425 constexpr size_t __i = __index_constant.value;
426 auto& __active_view = std::get<__i>(__parent_->__views_);
427 difference_type __idx = std::get<__i>(__it_) - ranges::begin(__active_view);
428 __advance_fwd<__i>(__idx, __n);
429 });
430
431 }
432
433 else if (__n < 0) {
434 __apply_at_index<tuple_size_v<decltype(__parent_->__views_)>>(__active_index, [&](auto __index_constant) {
435 constexpr size_t __i = __index_constant.value;
436 auto& __active_view = std::get<__i>(__parent_->__views_);
437 difference_type __idx = std::get<__i>(__it_) - ranges::begin(__active_view);
438 __advance_bwd<__i>(__idx, -__n);
439 });
440 }
441
442 return *this;
443 }
444
445 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n)
446 requires __concat_is_random_access<_Const, _Views...>
447 {
448 *this += -__n;
449 return *this;
450 }
451
452 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __it, default_sentinel_t) {
453 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
454 !__it.__it_.valueless_by_exception(),
455 "Trying to compare a valueless iterator of concat_view with the default sentinel.");
456 constexpr auto __last_idx = sizeof...(_Views) - 1;
457 return __it.__it_.index() == __last_idx &&
458 std::__unchecked_get<__last_idx>(__it.__it_) == ranges::end(std::get<__last_idx>(__it.__parent_->__views_));
459 }
460
461 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(const __iterator& __x, const __iterator& __y)
462 requires(__all_random_access<_Const, _Views> && ...)
463 {
464 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
465 "Trying to compare a valueless iterator of concat_view.");
466 return __x.__it_ < __y.__it_;
467 }
468
469 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(const __iterator& __x, const __iterator& __y)
470 requires(__all_random_access<_Const, _Views> && ...)
471 {
472 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
473 "Trying to compare a valueless iterator of concat_view.");
474 return __x.__it_ > __y.__it_;
475 }
476
477 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(const __iterator& __x, const __iterator& __y)
478 requires(__all_random_access<_Const, _Views> && ...)
479 {
480 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
481 "Trying to compare a valueless iterator of concat_view.");
482 return __x.__it_ <= __y.__it_;
483 }
484
485 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(const __iterator& __x, const __iterator& __y)
486 requires(__all_random_access<_Const, _Views> && ...)
487 {
488 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
489 "Trying to compare a valueless iterator of concat_view.");
490 return __x.__it_ >= __y.__it_;
491 }
492
493 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(const __iterator& __x, const __iterator& __y)
494 requires((__all_random_access<_Const, _Views> && ...) &&
495 (three_way_comparable<iterator_t<__maybe_const<_Const, _Views>>> && ...))
496 {
497 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
498 "Trying to compare a valueless iterator of concat_view.");
499 return __x.__it_ <=> __y.__it_;
500 }
501
502 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __it) noexcept(
503
504 ((is_nothrow_invocable_v< decltype(ranges::iter_move), const iterator_t<__maybe_const<_Const, _Views>>& > &&
505 is_nothrow_convertible_v< range_rvalue_reference_t<__maybe_const<_Const, _Views>>,
506 __concat_rvalue_reference_t<__maybe_const<_Const, _Views>...> >) &&
507 ...))
508
509 {
510 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
511 !__it.__it_.valueless_by_exception(), "Trying to apply iter_move to a valueless iterator of concat_view.");
512 return __variant_detail::__visitation::__variant::__visit_value(
513 [](const auto& __i) -> __concat_rvalue_reference_t<__maybe_const<_Const, _Views>...> {
514 return ranges::iter_move(__i);
515 },
516 __it.__it_);
517 }
518
519 _LIBCPP_HIDE_FROM_ABI friend constexpr void iter_swap(const __iterator& __x, const __iterator& __y)
520
521 noexcept((noexcept(ranges::swap(*__x, *__y))) &&
522 (noexcept(ranges::iter_swap(std::declval<const iterator_t<__maybe_const<_Const, _Views>>>(),
523 std::declval<const iterator_t<__maybe_const<_Const, _Views>>>())) &&
524 ...))
525
526 requires swappable_with<iter_reference_t<__iterator>, iter_reference_t<__iterator>> &&
527 (... && indirectly_swappable<iterator_t<__maybe_const<_Const, _Views>>>)
528 {
529 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
530 !__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
531 "Trying to swap iterators of concat_view where at least one iterator is valueless.");
532 __variant_detail::__visitation::__variant::__visit_value(
533 [&](const auto& __it1, const auto& __it2) {
534 if constexpr (is_same_v<decltype(__it1), decltype(__it2)>) {
535 ranges::iter_swap(__it1, __it2);
536 } else {
537 ranges::swap(*__x, *__y);
538 }
539 },
540 __x.__it_,
541 __y.__it_);
542 }
543
544 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
545 operator-(const __iterator& __x, const __iterator& __y)
546 requires __concat_is_random_access<_Const, _Views...>
547 {
548 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
549 !__x.__it_.valueless_by_exception() && !__y.__it_.valueless_by_exception(),
550 "Trying to subtract two iterators of concat_view where at least one iterator is valueless.");
551 return __x.__invoke_at_index([&]<std::size_t __index_x>() -> difference_type {
552 return __y.__invoke_at_index([&]<std::size_t __index_y>() -> difference_type {
553 if constexpr (__index_x > __index_y) {
554 auto __dx = ranges::distance(
555 ranges::begin(std::get<__index_x>(__x.__parent_->__views_)), std::get<__index_x>(__x.__it_));
556 auto __dy = ranges::distance(
557 std::get<__index_y>(__y.__it_), ranges::end(std::get<__index_y>(__y.__parent_->__views_)));
558 difference_type __s = [&]<std::size_t __start, std::size_t __end>(this auto&& __self) -> difference_type {
559 if constexpr (__start < __end) {
560 return ranges::size(std::get<__start>(__x.__parent_->__views_)) +
561 __self.template operator()<__start + 1, __end>();
562 }
563 return 0;
564 }.template operator()<__index_y + 1, __index_x>();
565 return __dy + __s + __dx;
566 } else if constexpr (__index_x < __index_y) {
567 return -(__y - __x);
568 } else {
569 return std::get<__index_x>(__x.__it_) - std::get<__index_y>(__y.__it_);
570 }
571 });
572 });
573 }
574
575 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __it, difference_type __n)
576 requires __concat_is_random_access<_Const, _Views...>
577 {
578 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
579 !__it.__it_.valueless_by_exception(), "Trying to subtract a valuess iterators of concat_view.");
580 auto __temp = __it;
581 __temp -= __n;
582 return __temp;
583 }
584
585 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
586 operator-(const __iterator& __x, default_sentinel_t)
587 requires(sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
588 ...) &&
589 (__all_but_first_model_sized_range<_Const, _Views...>::value)
590 {
591 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
592 !__x.__it_.valueless_by_exception(),
593 "Trying to subtract a valuess iterators of concat_view from the default sentinel.");
594 return __x.__invoke_at_index([&]<std::size_t __index_x>() -> difference_type {
595 auto __dx =
596 ranges::distance(std::get<__index_x>(__x.__it_), ranges::end(std::get<__index_x>(__x.__parent_->__views_)));
597 difference_type __s = [&]<std::size_t __start, std::size_t __end>(this auto&& __self) -> difference_type {
598 if constexpr (__start < __end) {
599 return ranges::size(std::get<__start>(__x.__parent_->__views_)) +
600 __self.template operator()<__start + 1, __end>();
601 }
602 return 0;
603 }.template operator()<__index_x + 1, sizeof...(_Views)>();
604 return -(__dx + __s);
605 });
606 }
607
608 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
609 operator-(default_sentinel_t, const __iterator& __x)
610 requires(sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
611 ...) &&
612 (__all_but_first_model_sized_range<_Const, _Views...>::value)
613 {
614 return -(__x - default_sentinel);
615 }
616};
617
618namespace views {
619namespace __concat {
620struct __fn {
621 template <input_range _Range>
622 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
623 operator()(_Range&& __range) noexcept(noexcept(views::all((std::forward<_Range>(__range)))))
624 -> decltype(views::all((std::forward<_Range>(__range)))) {
625 return views::all(std::forward<_Range>(__range));
626 }
627
628 template <class _FirstRange, class... _TailRanges>
629 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
630 operator()(_FirstRange&& __first, _TailRanges&&... __tail) noexcept(
631 noexcept(concat_view(std::forward<_FirstRange>(__first), std::forward<_TailRanges>(__tail)...)))
632 -> decltype(concat_view(std::forward<_FirstRange>(__first), std::forward<_TailRanges>(__tail)...)) {
633 return concat_view(std::forward<_FirstRange>(__first), std::forward<_TailRanges>(__tail)...);
634 }
635};
636} // namespace __concat
637
638inline namespace __cpo {
639inline constexpr auto concat = __concat::__fn{};
640} // namespace __cpo
641} // namespace views
642
643} // namespace ranges
644
645#endif // _LIBCPP_STD_VER >= 26
646
647_LIBCPP_END_NAMESPACE_STD
648
649_LIBCPP_POP_MACROS
650
651#endif // _LIBCPP___RANGES_CONCAT_VIEW_H
lib/libcxx/include/__ranges/concepts.h+4-4
......@@ -39,10 +39,10 @@
3939# pragma GCC system_header
4040#endif
4141
42_LIBCPP_BEGIN_NAMESPACE_STD
43
4442#if _LIBCPP_STD_VER >= 20
4543
44_LIBCPP_BEGIN_NAMESPACE_STD
45
4646namespace ranges {
4747
4848// [range.range]
......@@ -175,8 +175,8 @@ concept __concatable = requires {
175175
176176} // namespace ranges
177177
178#endif // _LIBCPP_STD_VER >= 20
179
180178_LIBCPP_END_NAMESPACE_STD
181179
180#endif // _LIBCPP_STD_VER >= 20
181
182182#endif // _LIBCPP___RANGES_CONCEPTS_H
lib/libcxx/include/__ranges/container_compatible_range.h+4-4
......@@ -18,16 +18,16 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 23
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525template <class _Range, class _Tp>
2626concept _ContainerCompatibleRange =
2727 ranges::input_range<_Range> && convertible_to<ranges::range_reference_t<_Range>, _Tp>;
2828
29#endif // _LIBCPP_STD_VER >= 23
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 23
32
3333#endif // _LIBCPP___RANGES_CONTAINER_COMPATIBLE_RANGE_H
lib/libcxx/include/__ranges/dangling.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626namespace ranges {
2727struct dangling {
2828 dangling() = default;
......@@ -35,8 +35,8 @@ using borrowed_iterator_t = _If<borrowed_range<_Rp>, iterator_t<_Rp>, dangling>;
3535// borrowed_subrange_t defined in <__ranges/subrange.h>
3636} // namespace ranges
3737
38#endif // _LIBCPP_STD_VER >= 20
39
4038_LIBCPP_END_NAMESPACE_STD
4139
40#endif // _LIBCPP_STD_VER >= 20
41
4242#endif // _LIBCPP___RANGES_DANGLING_H
lib/libcxx/include/__ranges/data.h+6-6
......@@ -28,10 +28,10 @@
2828# pragma GCC system_header
2929#endif
3030
31_LIBCPP_BEGIN_NAMESPACE_STD
32
3331#if _LIBCPP_STD_VER >= 20
3432
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3535// [range.prim.data]
3636
3737namespace ranges {
......@@ -51,12 +51,12 @@ concept __ranges_begin_invocable = !__member_data<_Tp> && __can_borrow<_Tp> && r
5151
5252struct __fn {
5353 template <__member_data _Tp>
54 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(__t.data())) {
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(noexcept(__t.data())) {
5555 return __t.data();
5656 }
5757
5858 template <__ranges_begin_invocable _Tp>
59 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
6060 noexcept(noexcept(std::to_address(ranges::begin(__t)))) {
6161 return std::to_address(ranges::begin(__t));
6262 }
......@@ -95,8 +95,8 @@ inline constexpr auto cdata = __cdata::__fn{};
9595} // namespace __cpo
9696} // namespace ranges
9797
98#endif // _LIBCPP_STD_VER >= 20
99
10098_LIBCPP_END_NAMESPACE_STD
10199
100#endif // _LIBCPP_STD_VER >= 20
101
102102#endif // _LIBCPP___RANGES_DATA_H
lib/libcxx/include/__ranges/drop_view.h+1-2
......@@ -74,8 +74,7 @@ public:
7474 requires default_initializable<_View>
7575 = default;
7676
77 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23
78 drop_view(_View __base, range_difference_t<_View> __count)
77 _LIBCPP_HIDE_FROM_ABI constexpr explicit drop_view(_View __base, range_difference_t<_View> __count)
7978 : __count_(__count), __base_(std::move(__base)) {
8079 _LIBCPP_ASSERT_UNCATEGORIZED(__count_ >= 0, "count must be greater than or equal to zero.");
8180 }
lib/libcxx/include/__ranges/drop_while_view.h+2-2
......@@ -48,13 +48,13 @@ namespace ranges {
4848
4949template <view _View, class _Pred>
5050 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
51class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS drop_while_view : public view_interface<drop_while_view<_View, _Pred>> {
51class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG drop_while_view : public view_interface<drop_while_view<_View, _Pred>> {
5252public:
5353 _LIBCPP_HIDE_FROM_ABI drop_while_view()
5454 requires default_initializable<_View> && default_initializable<_Pred>
5555 = default;
5656
57 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 drop_while_view(_View __base, _Pred __pred)
57 _LIBCPP_HIDE_FROM_ABI constexpr explicit drop_while_view(_View __base, _Pred __pred)
5858 : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
5959
6060 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
lib/libcxx/include/__ranges/elements_of.h+4-4
......@@ -23,10 +23,10 @@
2323_LIBCPP_PUSH_MACROS
2424#include <__undef_macros>
2525
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2826#if _LIBCPP_STD_VER >= 23
2927
28_LIBCPP_BEGIN_NAMESPACE_STD
29
3030namespace ranges {
3131
3232template <range _Range, class _Allocator = allocator<byte>>
......@@ -40,10 +40,10 @@ elements_of(_Range&&, _Allocator = _Allocator()) -> elements_of<_Range&&, _Alloc
4040
4141} // namespace ranges
4242
43#endif // _LIBCPP_STD_VER >= 23
44
4543_LIBCPP_END_NAMESPACE_STD
4644
45#endif // _LIBCPP_STD_VER >= 23
46
4747_LIBCPP_POP_MACROS
4848
4949#endif // _LIBCPP___RANGES_ELEMENTS_OF_H
lib/libcxx/include/__ranges/elements_view.h+21-20
......@@ -77,57 +77,57 @@ public:
7777
7878 _LIBCPP_HIDE_FROM_ABI constexpr explicit elements_view(_View __base) : __base_(std::move(__base)) {}
7979
80 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
80 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
8181 requires copy_constructible<_View>
8282 {
8383 return __base_;
8484 }
8585
86 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
8787
88 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
88 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
8989 requires(!__simple_view<_View>)
9090 {
9191 return __iterator</*_Const=*/false>(ranges::begin(__base_));
9292 }
9393
94 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
94 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
9595 requires range<const _View>
9696 {
9797 return __iterator</*_Const=*/true>(ranges::begin(__base_));
9898 }
9999
100 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
100 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
101101 requires(!__simple_view<_View> && !common_range<_View>)
102102 {
103103 return __sentinel</*_Const=*/false>{ranges::end(__base_)};
104104 }
105105
106 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
106 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
107107 requires(!__simple_view<_View> && common_range<_View>)
108108 {
109109 return __iterator</*_Const=*/false>{ranges::end(__base_)};
110110 }
111111
112 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
112 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
113113 requires range<const _View>
114114 {
115115 return __sentinel</*_Const=*/true>{ranges::end(__base_)};
116116 }
117117
118 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
118 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
119119 requires common_range<const _View>
120120 {
121121 return __iterator</*_Const=*/true>{ranges::end(__base_)};
122122 }
123123
124 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
124 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
125125 requires sized_range<_View>
126126 {
127127 return ranges::size(__base_);
128128 }
129129
130 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
130 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
131131 requires sized_range<const _View>
132132 {
133133 return ranges::size(__base_);
......@@ -211,11 +211,11 @@ public:
211211 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
212212 : __current_(std::move(__i.__current_)) {}
213213
214 _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
214 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
215215
216 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
216 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
217217
218 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return __get_element(__current_); }
218 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return __get_element(__current_); }
219219
220220 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
221221 ++__current_;
......@@ -261,7 +261,7 @@ public:
261261 return *this;
262262 }
263263
264 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
264 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
265265 requires random_access_range<_Base>
266266 {
267267 return __get_element(__current_ + __n);
......@@ -303,25 +303,26 @@ public:
303303 return __x.__current_ <=> __y.__current_;
304304 }
305305
306 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __x, difference_type __y)
306 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __x, difference_type __y)
307307 requires random_access_range<_Base>
308308 {
309309 return __iterator{__x} += __y;
310310 }
311311
312 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __x, const __iterator& __y)
312 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __x, const __iterator& __y)
313313 requires random_access_range<_Base>
314314 {
315315 return __y + __x;
316316 }
317317
318 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __x, difference_type __y)
318 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __x, difference_type __y)
319319 requires random_access_range<_Base>
320320 {
321321 return __iterator{__x} -= __y;
322322 }
323323
324 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
324 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
325 operator-(const __iterator& __x, const __iterator& __y)
325326 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
326327 {
327328 return __x.__current_ - __y.__current_;
......@@ -365,14 +366,14 @@ public:
365366
366367 template <bool _OtherConst>
367368 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
368 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
369 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
369370 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
370371 return __get_current(__x) - __y.__end_;
371372 }
372373
373374 template <bool _OtherConst>
374375 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
375 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
376 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
376377 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
377378 return __x.__end_ - __get_current(__y);
378379 }
lib/libcxx/include/__ranges/empty.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727// [range.prim.empty]
2828
2929namespace ranges {
......@@ -64,8 +64,8 @@ inline constexpr auto empty = __empty::__fn{};
6464} // namespace __cpo
6565} // namespace ranges
6666
67#endif // _LIBCPP_STD_VER >= 20
68
6967_LIBCPP_END_NAMESPACE_STD
7068
69#endif // _LIBCPP_STD_VER >= 20
70
7171#endif // _LIBCPP___RANGES_EMPTY_H
lib/libcxx/include/__ranges/enable_borrowed_range.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727namespace ranges {
2828
2929// [range.range], ranges
......@@ -33,8 +33,8 @@ inline constexpr bool enable_borrowed_range = false;
3333
3434} // namespace ranges
3535
36#endif // _LIBCPP_STD_VER >= 20
37
3836_LIBCPP_END_NAMESPACE_STD
3937
38#endif // _LIBCPP_STD_VER >= 20
39
4040#endif // _LIBCPP___RANGES_ENABLE_BORROWED_RANGE_H
lib/libcxx/include/__ranges/enable_view.h+4-4
......@@ -20,10 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2523#if _LIBCPP_STD_VER >= 20
2624
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2727namespace ranges {
2828
2929struct view_base {};
......@@ -43,8 +43,8 @@ inline constexpr bool enable_view = derived_from<_Tp, view_base> || requires {
4343
4444} // namespace ranges
4545
46#endif // _LIBCPP_STD_VER >= 20
47
4846_LIBCPP_END_NAMESPACE_STD
4947
48#endif // _LIBCPP_STD_VER >= 20
49
5050#endif // _LIBCPP___RANGES_ENABLE_VIEW_H
lib/libcxx/include/__ranges/enumerate_view.h created+350
......@@ -0,0 +1,350 @@
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_ENUMERATE_VIEW_H
11#define _LIBCPP___RANGES_ENUMERATE_VIEW_H
12
13#include <__concepts/constructible.h>
14#include <__concepts/convertible_to.h>
15#include <__config>
16#include <__iterator/concepts.h>
17#include <__iterator/distance.h>
18#include <__iterator/iter_move.h>
19#include <__iterator/iterator_traits.h>
20#include <__ranges/access.h>
21#include <__ranges/all.h>
22#include <__ranges/concepts.h>
23#include <__ranges/enable_borrowed_range.h>
24#include <__ranges/range_adaptor.h>
25#include <__ranges/size.h>
26#include <__ranges/view_interface.h>
27#include <__type_traits/maybe_const.h>
28#include <__utility/forward.h>
29#include <__utility/move.h>
30#include <tuple>
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36_LIBCPP_PUSH_MACROS
37#include <__undef_macros>
38
39_LIBCPP_BEGIN_NAMESPACE_STD
40
41#if _LIBCPP_STD_VER >= 23
42
43namespace ranges {
44
45// [concept.object]
46
47template <class _Rp>
48concept __range_with_movable_references =
49 input_range<_Rp> && std::move_constructible<range_reference_t<_Rp>> &&
50 std::move_constructible<range_rvalue_reference_t<_Rp>>;
51
52// [range.enumerate.view]
53
54template <view _View>
55 requires __range_with_movable_references<_View>
56class enumerate_view : public view_interface<enumerate_view<_View>> {
57 _View __base_ = _View();
58
59 // [range.enumerate.iterator]
60 template <bool _Const>
61 class __iterator;
62
63 // [range.enumerate.sentinel]
64 template <bool _Const>
65 class __sentinel;
66
67public:
68 _LIBCPP_HIDE_FROM_ABI constexpr enumerate_view()
69 requires default_initializable<_View>
70 = default;
71 _LIBCPP_HIDE_FROM_ABI constexpr explicit enumerate_view(_View __base) : __base_(std::move(__base)) {}
72
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
74 requires(!__simple_view<_View>)
75 {
76 return __iterator<false>(ranges::begin(__base_), 0);
77 }
78 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
79 requires __range_with_movable_references<const _View>
80 {
81 return __iterator<true>(ranges::begin(__base_), 0);
82 }
83
84 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
85 requires(!__simple_view<_View>)
86 {
87 if constexpr (forward_range<_View> && common_range<_View> && sized_range<_View>)
88 return __iterator<false>(ranges::end(__base_), ranges::distance(__base_));
89 else
90 return __sentinel<false>(ranges::end(__base_));
91 }
92 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
93 requires __range_with_movable_references<const _View>
94 {
95 if constexpr (forward_range<_View> && common_range<const _View> && sized_range<const _View>)
96 return __iterator<true>(ranges::end(__base_), ranges::distance(__base_));
97 else
98 return __sentinel<true>(ranges::end(__base_));
99 }
100
101 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
102 requires sized_range<_View>
103 {
104 return ranges::size(__base_);
105 }
106 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
107 requires sized_range<const _View>
108 {
109 return ranges::size(__base_);
110 }
111
112 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
113 requires copy_constructible<_View>
114 {
115 return __base_;
116 }
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
118};
119
120template <class _Range>
121enumerate_view(_Range&&) -> enumerate_view<views::all_t<_Range>>;
122
123// [range.enumerate.iterator]
124
125template <view _View>
126 requires __range_with_movable_references<_View>
127template <bool _Const>
128class enumerate_view<_View>::__iterator {
129 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
130
131 static consteval auto __get_iterator_concept() {
132 if constexpr (random_access_range<_Base>) {
133 return random_access_iterator_tag{};
134 } else if constexpr (bidirectional_range<_Base>) {
135 return bidirectional_iterator_tag{};
136 } else if constexpr (forward_range<_Base>) {
137 return forward_iterator_tag{};
138 } else {
139 return input_iterator_tag{};
140 }
141 }
142
143 friend class enumerate_view<_View>;
144
145public:
146 using iterator_category = input_iterator_tag;
147 using iterator_concept = decltype(__get_iterator_concept());
148 using difference_type = range_difference_t<_Base>;
149 using value_type = tuple<difference_type, range_value_t<_Base>>;
150
151private:
152 using __reference_type _LIBCPP_NODEBUG = tuple<difference_type, range_reference_t<_Base>>;
153
154 iterator_t<_Base> __current_ = iterator_t<_Base>();
155 difference_type __pos_ = 0;
156
157 _LIBCPP_HIDE_FROM_ABI constexpr explicit __iterator(iterator_t<_Base> __current, difference_type __pos)
158 : __current_(std::move(__current)), __pos_(__pos) {}
159
160public:
161 _LIBCPP_HIDE_FROM_ABI __iterator()
162 requires default_initializable<iterator_t<_Base>>
163 = default;
164
165 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i)
166 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
167 : __current_(std::move(__i.__current_)), __pos_(__i.__pos_) {}
168
169 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
170
171 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
172
173 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr difference_type index() const noexcept { return __pos_; }
174
175 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const { return __reference_type(__pos_, *__current_); }
176
177 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
178 ++__current_;
179 ++__pos_;
180 return *this;
181 }
182
183 _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) { return ++*this; }
184
185 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int)
186 requires forward_range<_Base>
187 {
188 auto __temp = *this;
189 ++*this;
190 return __temp;
191 }
192
193 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--()
194 requires bidirectional_range<_Base>
195 {
196 --__current_;
197 --__pos_;
198 return *this;
199 }
200
201 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
202 requires bidirectional_range<_Base>
203 {
204 auto __temp = *this;
205 --*this;
206 return *__temp;
207 }
208
209 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n)
210 requires random_access_range<_Base>
211 {
212 __current_ += __n;
213 __pos_ += __n;
214 return *this;
215 }
216
217 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n)
218 requires random_access_range<_Base>
219 {
220 __current_ -= __n;
221 __pos_ -= __n;
222 return *this;
223 }
224
225 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const
226 requires random_access_range<_Base>
227 {
228 return __reference_type(__pos_ + __n, __current_[__n]);
229 }
230
231 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y) noexcept {
232 return __x.__pos_ == __y.__pos_;
233 }
234
235 _LIBCPP_HIDE_FROM_ABI friend constexpr strong_ordering
236 operator<=>(const __iterator& __x, const __iterator& __y) noexcept {
237 return __x.__pos_ <=> __y.__pos_;
238 }
239
240 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
241 requires random_access_range<_Base>
242 {
243 auto __temp = __i;
244 __temp += __n;
245 return __temp;
246 }
247
248 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
249 requires random_access_range<_Base>
250 {
251 return __i + __n;
252 }
253
254 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
255 requires random_access_range<_Base>
256 {
257 auto __temp = __i;
258 __temp -= __n;
259 return __temp;
260 }
261
262 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
263 operator-(const __iterator& __x, const __iterator& __y) noexcept {
264 return __x.__pos_ - __y.__pos_;
265 }
266
267 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept(
268 noexcept(ranges::iter_move(__i.__current_)) && is_nothrow_move_constructible_v<range_rvalue_reference_t<_Base>>) {
269 return tuple<difference_type, range_rvalue_reference_t<_Base>>(__i.__pos_, ranges::iter_move(__i.__current_));
270 }
271};
272
273// [range.enumerate.sentinel]
274
275template <view _View>
276 requires __range_with_movable_references<_View>
277template <bool _Const>
278class enumerate_view<_View>::__sentinel {
279 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
280
281 sentinel_t<_Base> __end_ = sentinel_t<_Base>();
282
283 _LIBCPP_HIDE_FROM_ABI constexpr explicit __sentinel(sentinel_t<_Base> __end) : __end_(std::move(__end)) {}
284
285 friend class enumerate_view<_View>;
286
287public:
288 _LIBCPP_HIDE_FROM_ABI __sentinel() = default;
289
290 _LIBCPP_HIDE_FROM_ABI constexpr __sentinel(__sentinel<!_Const> __other)
291 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
292 : __end_(std::move(__other.__end_)) {}
293
294 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
295
296 template <bool _OtherConst>
297 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
298 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
299 return __x.__current_ == __y.__end_;
300 }
301
302 template <bool _OtherConst>
303 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
304 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
305 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
306 return __x.__current_ - __y.__end_;
307 }
308
309 template <bool _OtherConst>
310 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
311 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
312 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
313 return __x.__end_ - __y.__current_;
314 }
315};
316
317template <class _View>
318constexpr bool enable_borrowed_range<enumerate_view<_View>> = enable_borrowed_range<_View>;
319
320namespace views {
321namespace __enumerate {
322
323// [range.enumerate.overview]
324
325struct __fn : __range_adaptor_closure<__fn> {
326 template <class _Range>
327 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
328 operator()(_Range&& __range) noexcept(noexcept(enumerate_view<views::all_t<_Range>>(std::forward<_Range>(__range))))
329 -> decltype(/*--------------------------*/ enumerate_view<views::all_t<_Range>>(std::forward<_Range>(__range))) {
330 return /*---------------------------------*/ enumerate_view<views::all_t<_Range>>(std::forward<_Range>(__range));
331 }
332};
333
334} // namespace __enumerate
335
336inline namespace __cpo {
337
338inline constexpr auto enumerate = __enumerate::__fn{};
339
340} // namespace __cpo
341} // namespace views
342} // namespace ranges
343
344#endif // _LIBCPP_STD_VER >= 23
345
346_LIBCPP_END_NAMESPACE_STD
347
348_LIBCPP_POP_MACROS
349
350#endif // _LIBCPP___RANGES_ENUMERATE_VIEW_H
lib/libcxx/include/__ranges/filter_view.h+2-2
......@@ -54,7 +54,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5454namespace ranges {
5555template <input_range _View, indirect_unary_predicate<iterator_t<_View>> _Pred>
5656 requires view<_View> && is_object_v<_Pred>
57class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS filter_view : public view_interface<filter_view<_View, _Pred>> {
57class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG filter_view : public view_interface<filter_view<_View, _Pred>> {
5858 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
5959 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Pred> __pred_;
6060
......@@ -72,7 +72,7 @@ public:
7272 requires default_initializable<_View> && default_initializable<_Pred>
7373 = default;
7474
75 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 filter_view(_View __base, _Pred __pred)
75 _LIBCPP_HIDE_FROM_ABI constexpr explicit filter_view(_View __base, _Pred __pred)
7676 : __base_(std::move(__base)), __pred_(in_place, std::move(__pred)) {}
7777
7878 template <class _Vp = _View>
lib/libcxx/include/__ranges/from_range.h+4-4
......@@ -16,18 +16,18 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 23
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323struct from_range_t {
2424 explicit from_range_t() = default;
2525};
2626
2727inline constexpr from_range_t from_range{};
2828
29#endif // _LIBCPP_STD_VER >= 23
30
3129_LIBCPP_END_NAMESPACE_STD
3230
31#endif // _LIBCPP_STD_VER >= 23
32
3333#endif // _LIBCPP___RANGES_FROM_RANGE_H
lib/libcxx/include/__ranges/iota_view.h+6-6
......@@ -316,8 +316,8 @@ public:
316316
317317 _LIBCPP_HIDE_FROM_ABI constexpr explicit iota_view(_Start __value) : __value_(std::move(__value)) {}
318318
319 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23
320 iota_view(type_identity_t<_Start> __value, type_identity_t<_BoundSentinel> __bound_sentinel)
319 _LIBCPP_HIDE_FROM_ABI constexpr explicit iota_view(type_identity_t<_Start> __value,
320 type_identity_t<_BoundSentinel> __bound_sentinel)
321321 : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
322322 // Validate the precondition if possible.
323323 if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
......@@ -326,15 +326,15 @@ public:
326326 }
327327 }
328328
329 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 iota_view(__iterator __first, __iterator __last)
329 _LIBCPP_HIDE_FROM_ABI constexpr explicit iota_view(__iterator __first, __iterator __last)
330330 requires same_as<_Start, _BoundSentinel>
331331 : iota_view(std::move(__first.__value_), std::move(__last.__value_)) {}
332332
333 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 iota_view(__iterator __first, _BoundSentinel __last)
333 _LIBCPP_HIDE_FROM_ABI constexpr explicit iota_view(__iterator __first, _BoundSentinel __last)
334334 requires same_as<_BoundSentinel, unreachable_sentinel_t>
335335 : iota_view(std::move(__first.__value_), std::move(__last)) {}
336336
337 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 iota_view(__iterator __first, __sentinel __last)
337 _LIBCPP_HIDE_FROM_ABI constexpr explicit iota_view(__iterator __first, __sentinel __last)
338338 requires(!same_as<_Start, _BoundSentinel> && !same_as<_BoundSentinel, unreachable_sentinel_t>)
339339 : iota_view(std::move(__first.__value_), std::move(__last.__bound_sentinel_)) {}
340340
......@@ -357,7 +357,7 @@ public:
357357
358358 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
359359 requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
360 (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
360 (__integer_like<_Start> && __integer_like<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
361361 {
362362 if constexpr (__integer_like<_Start> && __integer_like<_BoundSentinel>) {
363363 return (__value_ < 0)
lib/libcxx/include/__ranges/istream_view.h+4-4
......@@ -46,12 +46,12 @@ public:
4646 _LIBCPP_HIDE_FROM_ABI constexpr explicit basic_istream_view(basic_istream<_CharT, _Traits>& __stream)
4747 : __stream_(std::addressof(__stream)) {}
4848
49 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
5050 *__stream_ >> __value_;
5151 return __iterator{*this};
5252 }
5353
54 _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
5555
5656private:
5757 basic_istream<_CharT, _Traits>* __stream_;
......@@ -82,7 +82,7 @@ public:
8282
8383 _LIBCPP_HIDE_FROM_ABI void operator++(int) { ++*this; }
8484
85 _LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; }
85 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _Val& operator*() const { return __parent_->__value_; }
8686
8787 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __iterator& __x, default_sentinel_t) {
8888 return !*__x.__get_parent_stream();
......@@ -113,7 +113,7 @@ struct __fn {
113113 template <class _Up, class _UnCVRef = remove_cvref_t<_Up>>
114114 requires derived_from<_UnCVRef, basic_istream<typename _UnCVRef::char_type,
115115 typename _UnCVRef::traits_type>>
116 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Up&& __u) const
116 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Up&& __u) const
117117 noexcept(noexcept(basic_istream_view<_Tp, typename _UnCVRef::char_type,
118118 typename _UnCVRef::traits_type>(std::forward<_Up>(__u))))
119119 -> decltype( basic_istream_view<_Tp, typename _UnCVRef::char_type,
lib/libcxx/include/__ranges/join_view.h+8-8
......@@ -100,15 +100,15 @@ public:
100100
101101 _LIBCPP_HIDE_FROM_ABI constexpr explicit join_view(_View __base) : __base_(std::move(__base)) {}
102102
103 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
104104 requires copy_constructible<_View>
105105 {
106106 return __base_;
107107 }
108108
109 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
110110
111 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
111 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
112112 if constexpr (forward_range<_View>) {
113113 constexpr bool __use_const = __simple_view<_View> && is_reference_v<range_reference_t<_View>>;
114114 return __iterator<__use_const>{*this, ranges::begin(__base_)};
......@@ -119,14 +119,14 @@ public:
119119 }
120120
121121 template <class _V2 = _View>
122 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
123123 requires forward_range<const _V2> && is_reference_v<range_reference_t<const _V2>> &&
124124 input_range<range_reference_t<const _V2>>
125125 {
126126 return __iterator<true>{*this, ranges::begin(__base_)};
127127 }
128128
129 _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
129 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
130130 if constexpr (forward_range<_View> && is_reference_v<_InnerRange> && forward_range<_InnerRange> &&
131131 common_range<_View> && common_range<_InnerRange>)
132132 return __iterator<__simple_view<_View>>{*this, ranges::end(__base_)};
......@@ -135,7 +135,7 @@ public:
135135 }
136136
137137 template <class _V2 = _View>
138 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
138 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
139139 requires forward_range<const _V2> && is_reference_v<range_reference_t<const _V2>> &&
140140 input_range<range_reference_t<const _V2>>
141141 {
......@@ -276,7 +276,7 @@ public:
276276 requires _Const && convertible_to<iterator_t<_View>, _Outer> && convertible_to<iterator_t<_InnerRange>, _Inner>
277277 : __outer_(std::move(__i.__outer_)), __inner_(std::move(__i.__inner_)), __parent_(__i.__parent_) {}
278278
279 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return **__inner_; }
279 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return **__inner_; }
280280
281281 _LIBCPP_HIDE_FROM_ABI constexpr _Inner operator->() const
282282 requires __has_arrow<_Inner> && copyable<_Inner>
......@@ -339,7 +339,7 @@ public:
339339 return __x.__outer_ == __y.__outer_ && __x.__inner_ == __y.__inner_;
340340 }
341341
342 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
342 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
343343 iter_move(const __iterator& __i) noexcept(noexcept(ranges::iter_move(*__i.__inner_))) {
344344 return ranges::iter_move(*__i.__inner_);
345345 }
lib/libcxx/include/__ranges/join_with_view.h+2-3
......@@ -372,7 +372,7 @@ public:
372372 return __tmp;
373373 }
374374
375 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
375 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator& __x, const __iterator& __y)
376376 requires __ref_is_glvalue && forward_range<_Base> && equality_comparable<_InnerIter>
377377 {
378378 return __x.__outer_it_ == __y.__outer_it_ && __x.__inner_it_ == __y.__inner_it_;
......@@ -420,8 +420,7 @@ public:
420420
421421 template <bool _OtherConst>
422422 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) {
423 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
425424 return __get_outer_of(__x) == __y.__end_;
426425 }
427426};
lib/libcxx/include/__ranges/lazy_split_view.h+19-15
......@@ -86,23 +86,23 @@ public:
8686 requires default_initializable<_View> && default_initializable<_Pattern>
8787 = default;
8888
89 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_View __base, _Pattern __pattern)
89 _LIBCPP_HIDE_FROM_ABI constexpr explicit lazy_split_view(_View __base, _Pattern __pattern)
9090 : __base_(std::move(__base)), __pattern_(std::move(__pattern)) {}
9191
9292 template <input_range _Range>
9393 requires constructible_from<_View, views::all_t<_Range>> &&
9494 constructible_from<_Pattern, single_view<range_value_t<_Range>>>
95 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
95 _LIBCPP_HIDE_FROM_ABI constexpr explicit lazy_split_view(_Range&& __r, range_value_t<_Range> __e)
9696 : __base_(views::all(std::forward<_Range>(__r))), __pattern_(views::single(std::move(__e))) {}
9797
98 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
98 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
9999 requires copy_constructible<_View>
100100 {
101101 return __base_;
102102 }
103 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
104104
105 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
105 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() {
106106 if constexpr (forward_range<_View>) {
107107 return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::begin(__base_)};
108108 } else {
......@@ -111,19 +111,19 @@ public:
111111 }
112112 }
113113
114 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
115115 requires forward_range<_View> && forward_range<const _View>
116116 {
117117 return __outer_iterator<true>{*this, ranges::begin(__base_)};
118118 }
119119
120 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
120 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
121121 requires forward_range<_View> && common_range<_View>
122122 {
123123 return __outer_iterator < __simple_view<_View> && __simple_view < _Pattern >> {*this, ranges::end(__base_)};
124124 }
125125
126 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const {
126 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const {
127127 if constexpr (forward_range<_View> && forward_range<const _View> && common_range<const _View>) {
128128 return __outer_iterator<true>{*this, ranges::end(__base_)};
129129 } else {
......@@ -188,8 +188,10 @@ private:
188188 _LIBCPP_HIDE_FROM_ABI value_type() = default;
189189 _LIBCPP_HIDE_FROM_ABI constexpr explicit value_type(__outer_iterator __i) : __i_(std::move(__i)) {}
190190
191 _LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator<_Const> begin() const { return __inner_iterator<_Const>{__i_}; }
192 _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
191 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator<_Const> begin() const {
192 return __inner_iterator<_Const>{__i_};
193 }
194 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr default_sentinel_t end() const noexcept { return default_sentinel; }
193195 };
194196
195197 _LIBCPP_HIDE_FROM_ABI __outer_iterator() = default;
......@@ -206,7 +208,7 @@ private:
206208 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
207209 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
208210
209 _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return value_type{*this}; }
211 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return value_type{*this}; }
210212
211213 _LIBCPP_HIDE_FROM_ABI constexpr __outer_iterator& operator++() {
212214 const auto __end = ranges::end(__parent_->__base_);
......@@ -342,14 +344,16 @@ private:
342344
343345 _LIBCPP_HIDE_FROM_ABI constexpr explicit __inner_iterator(__outer_iterator<_Const> __i) : __i_(std::move(__i)) {}
344346
345 _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __i_.__current(); }
346 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() &&
347 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept {
348 return __i_.__current();
349 }
350 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() &&
347351 requires forward_range<_View>
348352 {
349353 return std::move(__i_.__current());
350354 }
351355
352 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__i_.__current(); }
356 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const { return *__i_.__current(); }
353357
354358 _LIBCPP_HIDE_FROM_ABI constexpr __inner_iterator& operator++() {
355359 __incremented_ = true;
......@@ -385,7 +389,7 @@ private:
385389 return __x.__is_done();
386390 }
387391
388 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
392 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
389393 iter_move(const __inner_iterator& __i) noexcept(noexcept(ranges::iter_move(__i.__outer_current()))) {
390394 return ranges::iter_move(__i.__outer_current());
391395 }
lib/libcxx/include/__ranges/owning_view.h+4-4
......@@ -30,10 +30,10 @@
3030_LIBCPP_PUSH_MACROS
3131#include <__undef_macros>
3232
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3533#if _LIBCPP_STD_VER >= 20
3634
35_LIBCPP_BEGIN_NAMESPACE_STD
36
3737namespace ranges {
3838template <range _Rp>
3939 requires movable<_Rp> && (!__is_std_initializer_list<remove_cvref_t<_Rp>>)
......@@ -107,10 +107,10 @@ inline constexpr bool enable_borrowed_range<owning_view<_Tp>> = enable_borrowed_
107107
108108} // namespace ranges
109109
110#endif // _LIBCPP_STD_VER >= 20
111
112110_LIBCPP_END_NAMESPACE_STD
113111
112#endif // _LIBCPP_STD_VER >= 20
113
114114_LIBCPP_POP_MACROS
115115
116116#endif // _LIBCPP___RANGES_OWNING_VIEW_H
lib/libcxx/include/__ranges/range_adaptor.h+4-4
......@@ -34,10 +34,10 @@
3434_LIBCPP_PUSH_MACROS
3535#include <__undef_macros>
3636
37_LIBCPP_BEGIN_NAMESPACE_STD
38
3937#if _LIBCPP_STD_VER >= 20
4038
39_LIBCPP_BEGIN_NAMESPACE_STD
40
4141namespace ranges {
4242
4343// CRTP base that one can derive from in order to be considered a range adaptor closure
......@@ -90,10 +90,10 @@ class _LIBCPP_NO_SPECIALIZATIONS range_adaptor_closure : public __range_adaptor_
9090
9191} // namespace ranges
9292
93#endif // _LIBCPP_STD_VER >= 20
94
9593_LIBCPP_END_NAMESPACE_STD
9694
95#endif // _LIBCPP_STD_VER >= 20
96
9797_LIBCPP_POP_MACROS
9898
9999#endif // _LIBCPP___RANGES_RANGE_ADAPTOR_H
lib/libcxx/include/__ranges/ref_view.h+4-4
......@@ -32,10 +32,10 @@
3232# pragma GCC system_header
3333#endif
3434
35_LIBCPP_BEGIN_NAMESPACE_STD
36
3735#if _LIBCPP_STD_VER >= 20
3836
37_LIBCPP_BEGIN_NAMESPACE_STD
38
3939namespace ranges {
4040template <range _Range>
4141 requires is_object_v<_Range>
......@@ -82,8 +82,8 @@ template <class _Tp>
8282inline constexpr bool enable_borrowed_range<ref_view<_Tp>> = true;
8383} // namespace ranges
8484
85#endif // _LIBCPP_STD_VER >= 20
86
8785_LIBCPP_END_NAMESPACE_STD
8886
87#endif // _LIBCPP_STD_VER >= 20
88
8989#endif // _LIBCPP___RANGES_REF_VIEW_H
lib/libcxx/include/__ranges/repeat_view.h+5-5
......@@ -40,10 +40,10 @@
4040_LIBCPP_PUSH_MACROS
4141#include <__undef_macros>
4242
43_LIBCPP_BEGIN_NAMESPACE_STD
44
4543#if _LIBCPP_STD_VER >= 23
4644
45_LIBCPP_BEGIN_NAMESPACE_STD
46
4747namespace ranges {
4848
4949template <class _Tp>
......@@ -74,7 +74,7 @@ struct __fn;
7474template <move_constructible _Tp, semiregular _Bound = unreachable_sentinel_t>
7575 requires(is_object_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>> &&
7676 (__integer_like_with_usable_difference_type<_Bound> || same_as<_Bound, unreachable_sentinel_t>))
77class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS repeat_view : public view_interface<repeat_view<_Tp, _Bound>> {
77class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG repeat_view : public view_interface<repeat_view<_Tp, _Bound>> {
7878 friend struct views::__take::__fn;
7979 friend struct views::__drop::__fn;
8080 class __iterator;
......@@ -265,10 +265,10 @@ inline constexpr bool __is_repeat_specialization<repeat_view<_Tp, _Bound>> = tru
265265
266266} // namespace ranges
267267
268#endif // _LIBCPP_STD_VER >= 23
269
270268_LIBCPP_END_NAMESPACE_STD
271269
270#endif // _LIBCPP_STD_VER >= 23
271
272272_LIBCPP_POP_MACROS
273273
274274#endif // _LIBCPP___RANGES_REPEAT_VIEW_H
lib/libcxx/include/__ranges/reverse_view.h+8-8
......@@ -59,13 +59,13 @@ public:
5959
6060 _LIBCPP_HIDE_FROM_ABI constexpr explicit reverse_view(_View __view) : __base_(std::move(__view)) {}
6161
62 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
6363 requires copy_constructible<_View>
6464 {
6565 return __base_;
6666 }
6767
68 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
6969
7070 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator<iterator_t<_View>> begin() {
7171 if constexpr (_UseCache)
......@@ -78,35 +78,35 @@ public:
7878 return __tmp;
7979 }
8080
81 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator<iterator_t<_View>> begin()
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator<iterator_t<_View>> begin()
8282 requires common_range<_View>
8383 {
8484 return std::make_reverse_iterator(ranges::end(__base_));
8585 }
8686
87 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
87 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
8888 requires common_range<const _View>
8989 {
9090 return std::make_reverse_iterator(ranges::end(__base_));
9191 }
9292
93 _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator<iterator_t<_View>> end() {
93 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr reverse_iterator<iterator_t<_View>> end() {
9494 return std::make_reverse_iterator(ranges::begin(__base_));
9595 }
9696
97 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
9898 requires common_range<const _View>
9999 {
100100 return std::make_reverse_iterator(ranges::begin(__base_));
101101 }
102102
103 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
104104 requires sized_range<_View>
105105 {
106106 return ranges::size(__base_);
107107 }
108108
109 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
110110 requires sized_range<const _View>
111111 {
112112 return ranges::size(__base_);
lib/libcxx/include/__ranges/single_view.h+1-1
......@@ -41,7 +41,7 @@ template <move_constructible _Tp>
4141template <copy_constructible _Tp>
4242# endif
4343 requires is_object_v<_Tp>
44class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS single_view : public view_interface<single_view<_Tp>> {
44class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG single_view : public view_interface<single_view<_Tp>> {
4545 _LIBCPP_NO_UNIQUE_ADDRESS __movable_box<_Tp> __value_;
4646
4747public:
lib/libcxx/include/__ranges/size.h+4-4
......@@ -29,10 +29,10 @@
2929# pragma GCC system_header
3030#endif
3131
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3432#if _LIBCPP_STD_VER >= 20
3533
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3636namespace ranges {
3737template <class>
3838inline constexpr bool disable_sized_range = false;
......@@ -131,8 +131,8 @@ inline constexpr auto ssize = __ssize::__fn{};
131131} // namespace __cpo
132132} // namespace ranges
133133
134#endif // _LIBCPP_STD_VER >= 20
135
136134_LIBCPP_END_NAMESPACE_STD
137135
136#endif // _LIBCPP_STD_VER >= 20
137
138138#endif // _LIBCPP___RANGES_SIZE_H
lib/libcxx/include/__ranges/split_view.h+8-9
......@@ -78,32 +78,31 @@ public:
7878 requires default_initializable<_View> && default_initializable<_Pattern>
7979 = default;
8080
81 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 split_view(_View __base, _Pattern __pattern)
81 _LIBCPP_HIDE_FROM_ABI constexpr explicit split_view(_View __base, _Pattern __pattern)
8282 : __base_(std::move(__base)), __pattern_(std::move((__pattern))) {}
8383
8484 template <forward_range _Range>
8585 requires constructible_from<_View, views::all_t<_Range>> &&
8686 constructible_from<_Pattern, single_view<range_value_t<_Range>>>
87 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23
88 split_view(_Range&& __range, range_value_t<_Range> __elem)
87 _LIBCPP_HIDE_FROM_ABI constexpr explicit split_view(_Range&& __range, range_value_t<_Range> __elem)
8988 : __base_(views::all(std::forward<_Range>(__range))), __pattern_(views::single(std::move(__elem))) {}
9089
91 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
90 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
9291 requires copy_constructible<_View>
9392 {
9493 return __base_;
9594 }
9695
97 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
96 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
9897
99 _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() {
98 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator begin() {
10099 if (!__cached_begin_.__has_value()) {
101100 __cached_begin_.__emplace(__find_next(ranges::begin(__base_)));
102101 }
103102 return {*this, ranges::begin(__base_), *__cached_begin_};
104103 }
105104
106 _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
105 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
107106 if constexpr (common_range<_View>) {
108107 return __iterator{*this, ranges::end(__base_), {}};
109108 } else {
......@@ -142,9 +141,9 @@ public:
142141 split_view<_View, _Pattern>& __parent, iterator_t<_View> __current, subrange<iterator_t<_View>> __next)
143142 : __parent_(std::addressof(__parent)), __cur_(std::move(__current)), __next_(std::move(__next)) {}
144143
145 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() const { return __cur_; }
144 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_View> base() const { return __cur_; }
146145
147 _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return {__cur_, __next_.begin()}; }
146 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr value_type operator*() const { return {__cur_, __next_.begin()}; }
148147
149148 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
150149 __cur_ = __next_.begin();
lib/libcxx/include/__ranges/stride_view.h created+410
......@@ -0,0 +1,410 @@
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_STRIDE_VIEW_H
11#define _LIBCPP___RANGES_STRIDE_VIEW_H
12
13#include <__assert>
14#include <__compare/three_way_comparable.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/advance.h>
22#include <__iterator/concepts.h>
23#include <__iterator/default_sentinel.h>
24#include <__iterator/distance.h>
25#include <__iterator/iter_move.h>
26#include <__iterator/iter_swap.h>
27#include <__iterator/iterator_traits.h>
28#include <__ranges/access.h>
29#include <__ranges/all.h>
30#include <__ranges/concepts.h>
31#include <__ranges/enable_borrowed_range.h>
32#include <__ranges/range_adaptor.h>
33#include <__ranges/view_interface.h>
34#include <__type_traits/make_unsigned.h>
35
36#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
37# pragma GCC system_header
38#endif
39
40_LIBCPP_PUSH_MACROS
41#include <__undef_macros>
42
43_LIBCPP_BEGIN_NAMESPACE_STD
44
45#if _LIBCPP_STD_VER >= 23
46
47namespace ranges {
48
49template <class _Value>
50_LIBCPP_HIDE_FROM_ABI constexpr _Value __div_ceil(_Value __left, _Value __right) {
51 _Value __r = __left / __right;
52 if (__left % __right) {
53 ++__r;
54 }
55 return __r;
56}
57
58template <input_range _View>
59 requires view<_View>
60class stride_view : public view_interface<stride_view<_View>> {
61 _LIBCPP_NO_UNIQUE_ADDRESS _View __base_ = _View();
62 range_difference_t<_View> __stride_ = 0;
63
64 template <bool _Const>
65 class __iterator;
66
67public:
68 _LIBCPP_HIDE_FROM_ABI constexpr explicit stride_view(_View __base, range_difference_t<_View> __stride)
69 : __base_(std::move(__base)), __stride_(__stride) {
70 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__stride > 0, "The value of stride must be greater than 0");
71 }
72
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
74 requires copy_constructible<_View>
75 {
76 return __base_;
77 }
78
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
80
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_View> stride() const noexcept { return __stride_; }
82
83 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
84 requires(!__simple_view<_View>)
85 {
86 return __iterator</*_Const=*/false>(this, ranges::begin(__base_), 0);
87 }
88
89 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
90 requires range<const _View>
91 {
92 return __iterator</*_Const=*/true>(this, ranges::begin(__base_), 0);
93 }
94
95 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
96 requires(!__simple_view<_View>)
97 {
98 if constexpr (common_range<_View> && sized_range<_View> && forward_range<_View>) {
99 auto __missing = (__stride_ - ranges::distance(__base_) % __stride_) % __stride_;
100 return __iterator</*_Const=*/false>(this, ranges::end(__base_), __missing);
101 } else if constexpr (common_range<_View> && !bidirectional_range<_View>) {
102 return __iterator</*_Const=*/false>(this, ranges::end(__base_), 0);
103 } else {
104 return default_sentinel;
105 }
106 }
107
108 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
109 requires(range<const _View>)
110 {
111 if constexpr (common_range<const _View> && sized_range<const _View> && forward_range<const _View>) {
112 auto __missing = (__stride_ - ranges::distance(__base_) % __stride_) % __stride_;
113 return __iterator</*_Const=*/true>(this, ranges::end(__base_), __missing);
114 } else if constexpr (common_range<const _View> && !bidirectional_range<const _View>) {
115 return __iterator</*_Const=*/true>(this, ranges::end(__base_), 0);
116 } else {
117 return default_sentinel;
118 }
119 }
120
121 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
122 requires sized_range<_View>
123 {
124 return std::__to_unsigned_like(ranges::__div_ceil(ranges::distance(__base_), __stride_));
125 }
126
127 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
128 requires sized_range<const _View>
129 {
130 return std::__to_unsigned_like(ranges::__div_ceil(ranges::distance(__base_), __stride_));
131 }
132}; // class stride_view
133
134template <class _Range>
135stride_view(_Range&&, range_difference_t<_Range>) -> stride_view<views::all_t<_Range>>;
136
137template <class _View>
138struct __stride_iterator_category {};
139
140template <forward_range _View>
141struct __stride_iterator_category<_View> {
142 using _Cat _LIBCPP_NODEBUG = typename iterator_traits<iterator_t<_View>>::iterator_category;
143 using iterator_category =
144 _If<derived_from<_Cat, random_access_iterator_tag>,
145 /* then */ random_access_iterator_tag,
146 /* else */ _Cat >;
147};
148
149template <input_range _View>
150 requires view<_View>
151template <bool _Const>
152class stride_view<_View>::__iterator : public __stride_iterator_category<__maybe_const<_Const, _View>> {
153 using _Parent _LIBCPP_NODEBUG = __maybe_const<_Const, stride_view<_View>>;
154 using _Base _LIBCPP_NODEBUG = __maybe_const<_Const, _View>;
155
156 _LIBCPP_NO_UNIQUE_ADDRESS iterator_t<_Base> __current_ = iterator_t<_Base>();
157 _LIBCPP_NO_UNIQUE_ADDRESS ranges::sentinel_t<_Base> __end_ = ranges::sentinel_t<_Base>();
158 range_difference_t<_Base> __stride_ = 0;
159 range_difference_t<_Base> __missing_ = 0;
160
161 friend stride_view;
162
163 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(
164 _Parent* __parent, ranges::iterator_t<_Base> __current, range_difference_t<_Base> __missing)
165 : __current_(std::move(__current)),
166 __end_(ranges::end(__parent->__base_)),
167 __stride_(__parent->__stride_),
168 __missing_(__missing) {}
169
170 static consteval auto __get_stride_view_iterator_concept() {
171 if constexpr (random_access_range<_Base>) {
172 return random_access_iterator_tag{};
173 } else if constexpr (bidirectional_range<_Base>) {
174 return bidirectional_iterator_tag{};
175 } else if constexpr (forward_range<_Base>) {
176 return forward_iterator_tag{};
177 } else {
178 return input_iterator_tag{};
179 }
180 }
181
182public:
183 using difference_type = range_difference_t<_Base>;
184 using value_type = range_value_t<_Base>;
185 using iterator_concept = decltype(__get_stride_view_iterator_concept());
186 // using iterator_category = inherited;
187
188 _LIBCPP_HIDE_FROM_ABI __iterator()
189 requires default_initializable<iterator_t<_Base>>
190 = default;
191
192 _LIBCPP_HIDE_FROM_ABI constexpr __iterator(__iterator<!_Const> __i)
193 requires _Const && convertible_to<ranges::iterator_t<_View>, iterator_t<_Base>> &&
194 convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
195 : __current_(std::move(__i.__current_)),
196 __end_(std::move(__i.__end_)),
197 __stride_(__i.__stride_),
198 __missing_(__i.__missing_) {}
199
200 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> const& base() const& noexcept { return __current_; }
201 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
202
203 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const {
204 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__current_ != __end_, "Cannot dereference an iterator at the end.");
205 return *__current_;
206 }
207
208 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator++() {
209 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__current_ != __end_, "Cannot increment an iterator already at the end.");
210 __missing_ = ranges::advance(__current_, __stride_, __end_);
211 return *this;
212 }
213
214 _LIBCPP_HIDE_FROM_ABI constexpr void operator++(int) {
215 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__current_ != __end_, "Cannot increment an iterator already at the end.");
216 ++*this;
217 }
218 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator++(int)
219 requires forward_range<_Base>
220 {
221 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__current_ != __end_, "Cannot increment an iterator already at the end.");
222 auto __tmp = *this;
223 ++*this;
224 return __tmp;
225 }
226
227 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator--()
228 requires bidirectional_range<_Base>
229 {
230 ranges::advance(__current_, __missing_ - __stride_);
231 __missing_ = 0;
232 return *this;
233 }
234 _LIBCPP_HIDE_FROM_ABI constexpr __iterator operator--(int)
235 requires bidirectional_range<_Base>
236 {
237 auto __tmp = *this;
238 --*this;
239 return __tmp;
240 }
241
242 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator+=(difference_type __n)
243 requires random_access_range<_Base>
244 {
245 if (__n > 0) {
246 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(ranges::distance(__current_, __end_) > __stride_ * (__n - 1),
247 "Advancing the iterator beyond the end is not allowed.");
248 ranges::advance(__current_, __stride_ * (__n - 1));
249 __missing_ = ranges::advance(__current_, __stride_, __end_);
250
251 } else if (__n < 0) {
252 ranges::advance(__current_, __stride_ * __n + __missing_);
253 __missing_ = 0;
254 }
255 return *this;
256 }
257
258 _LIBCPP_HIDE_FROM_ABI constexpr __iterator& operator-=(difference_type __n)
259 requires random_access_range<_Base>
260 {
261 return *this += -__n;
262 }
263
264 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
265 requires random_access_range<_Base>
266 {
267 return *(*this + __n);
268 }
269
270 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(__iterator const& __x, default_sentinel_t) {
271 return __x.__current_ == __x.__end_;
272 }
273
274 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(__iterator const& __x, __iterator const& __y)
275 requires equality_comparable<iterator_t<_Base>>
276 {
277 return __x.__current_ == __y.__current_;
278 }
279
280 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<(__iterator const& __x, __iterator const& __y)
281 requires random_access_range<_Base>
282 {
283 return __x.__current_ < __y.__current_;
284 }
285
286 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>(__iterator const& __x, __iterator const& __y)
287 requires random_access_range<_Base>
288 {
289 return __y < __x;
290 }
291
292 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator<=(__iterator const& __x, __iterator const& __y)
293 requires random_access_range<_Base>
294 {
295 return !(__y < __x);
296 }
297
298 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator>=(__iterator const& __x, __iterator const& __y)
299 requires random_access_range<_Base>
300 {
301 return !(__x < __y);
302 }
303
304 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(__iterator const& __x, __iterator const& __y)
305 requires random_access_range<_Base> && three_way_comparable<iterator_t<_Base>>
306 {
307 return __x.__current_ <=> __y.__current_;
308 }
309
310 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator const& __i, difference_type __s)
311 requires random_access_range<_Base>
312 {
313 auto __r = __i;
314 __r += __s;
315 return __r;
316 }
317 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __s, __iterator const& __i)
318 requires random_access_range<_Base>
319 {
320 auto __r = __i;
321 __r += __s;
322 return __r;
323 }
324
325 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator const& __i, difference_type __s)
326 requires random_access_range<_Base>
327 {
328 auto __r = __i;
329 __r -= __s;
330 return __r;
331 }
332
333 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
334 operator-(__iterator const& __x, __iterator const& __y)
335 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
336 {
337 if constexpr (forward_range<_Base>) {
338 auto __n = __x.__current_ - __y.__current_;
339 return (__n + __x.__missing_ - __y.__missing_) / __x.__stride_;
340 }
341 auto __n = __x.__current_ - __y.__current_;
342 if (__n < 0) {
343 return -ranges::__div_ceil(-__n, __x.__stride_);
344 }
345 return ranges::__div_ceil(__n, __x.__stride_);
346 }
347
348 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
349 operator-(default_sentinel_t, __iterator const& __x)
350 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>>
351 {
352 return ranges::__div_ceil(__x.__end_ - __x.__current_, __x.__stride_);
353 }
354 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
355 operator-(__iterator const& __x, default_sentinel_t __y)
356 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<_Base>>
357 {
358 return -(__y - __x);
359 }
360
361 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_rvalue_reference_t<_Base>
362 iter_move(__iterator const& __it) noexcept(noexcept(ranges::iter_move(__it.__current_))) {
363 return ranges::iter_move(__it.__current_);
364 }
365
366 _LIBCPP_HIDE_FROM_ABI friend constexpr void
367 iter_swap(__iterator const& __x,
368 __iterator const& __y) noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_)))
369 requires indirectly_swappable<iterator_t<_Base>>
370 {
371 return ranges::iter_swap(__x.__current_, __y.__current_);
372 }
373}; // class stride_view::__iterator
374
375template <class _Tp>
376inline constexpr bool enable_borrowed_range<stride_view<_Tp>> = enable_borrowed_range<_Tp>;
377
378namespace views {
379namespace __stride_view {
380struct __fn {
381 // clang-format off
382 template <viewable_range _Range>
383 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
384 constexpr auto operator()(_Range&& __range, range_difference_t<_Range> __n) const
385 noexcept(noexcept(stride_view{std::forward<_Range>(__range), __n}))
386 -> decltype( stride_view{std::forward<_Range>(__range), __n})
387 { return stride_view(std::forward<_Range>(__range), __n); }
388 // clang-format on
389
390 template <class _Np>
391 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Np&& __n) const {
392 return __pipeable(std::__bind_back(*this, std::forward<_Np>(__n)));
393 }
394};
395} // namespace __stride_view
396
397inline namespace __cpo {
398inline constexpr auto stride = __stride_view::__fn{};
399} // namespace __cpo
400} // namespace views
401
402} // namespace ranges
403
404#endif // _LIBCPP_STD_VER >= 23
405
406_LIBCPP_END_NAMESPACE_STD
407
408_LIBCPP_POP_MACROS
409
410#endif // _LIBCPP___RANGES_STRIDE_VIEW_H
lib/libcxx/include/__ranges/subrange.h+15-14
......@@ -49,10 +49,10 @@
4949_LIBCPP_PUSH_MACROS
5050#include <__undef_macros>
5151
52_LIBCPP_BEGIN_NAMESPACE_STD
53
5452#if _LIBCPP_STD_VER >= 20
5553
54_LIBCPP_BEGIN_NAMESPACE_STD
55
5656namespace ranges {
5757template <class _From, class _To>
5858concept __uses_nonqualification_pointer_conversion =
......@@ -131,7 +131,7 @@ public:
131131 return _Pair(__begin_, __end_);
132132 }
133133
134 _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() const
134 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter begin() const
135135 requires copyable<_Iter>
136136 {
137137 return __begin_;
......@@ -143,11 +143,11 @@ public:
143143 return std::move(__begin_);
144144 }
145145
146 _LIBCPP_HIDE_FROM_ABI constexpr _Sent end() const { return __end_; }
146 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Sent end() const { return __end_; }
147147
148148 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __begin_ == __end_; }
149149
150 _LIBCPP_HIDE_FROM_ABI constexpr make_unsigned_t<iter_difference_t<_Iter>> size() const
150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr make_unsigned_t<iter_difference_t<_Iter>> size() const
151151 requires(_Kind == subrange_kind::sized)
152152 {
153153 if constexpr (_StoreSize)
......@@ -201,11 +201,12 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
201201subrange(_Iter, _Sent, make_unsigned_t<iter_difference_t<_Iter>>) -> subrange<_Iter, _Sent, subrange_kind::sized>;
202202
203203template <borrowed_range _Range>
204subrange(_Range&&) -> subrange<iterator_t<_Range>,
205 sentinel_t<_Range>,
206 (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>)
207 ? subrange_kind::sized
208 : subrange_kind::unsized>;
204subrange(_Range&&)
205 -> subrange<iterator_t<_Range>,
206 sentinel_t<_Range>,
207 (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>)
208 ? subrange_kind::sized
209 : subrange_kind::unsized>;
209210
210211template <borrowed_range _Range>
211212subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>)
......@@ -213,7 +214,7 @@ subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>)
213214
214215template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
215216 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
216_LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange) {
217[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange) {
217218 if constexpr (_Index == 0)
218219 return __subrange.begin();
219220 else
......@@ -222,7 +223,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __
222223
223224template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
224225 requires(_Index < 2)
225_LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange) {
226[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange) {
226227 if constexpr (_Index == 0)
227228 return __subrange.begin();
228229 else
......@@ -265,10 +266,10 @@ struct tuple_element<1, const ranges::subrange<_Ip, _Sp, _Kp>> {
265266 using type _LIBCPP_NODEBUG = _Sp;
266267};
267268
268#endif // _LIBCPP_STD_VER >= 20
269
270269_LIBCPP_END_NAMESPACE_STD
271270
271#endif // _LIBCPP_STD_VER >= 20
272
272273_LIBCPP_POP_MACROS
273274
274275#endif // _LIBCPP___RANGES_SUBRANGE_H
lib/libcxx/include/__ranges/take_view.h+1-2
......@@ -69,8 +69,7 @@ public:
6969 requires default_initializable<_View>
7070 = default;
7171
72 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23
73 take_view(_View __base, range_difference_t<_View> __count)
72 _LIBCPP_HIDE_FROM_ABI constexpr explicit take_view(_View __base, range_difference_t<_View> __count)
7473 : __base_(std::move(__base)), __count_(__count) {
7574 _LIBCPP_ASSERT_UNCATEGORIZED(__count >= 0, "count has to be greater than or equal to zero");
7675 }
lib/libcxx/include/__ranges/take_while_view.h+10-10
......@@ -46,7 +46,7 @@ namespace ranges {
4646
4747template <view _View, class _Pred>
4848 requires input_range<_View> && is_object_v<_Pred> && indirect_unary_predicate<const _Pred, iterator_t<_View>>
49class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS take_while_view : public view_interface<take_while_view<_View, _Pred>> {
49class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG take_while_view : public view_interface<take_while_view<_View, _Pred>> {
5050 template <bool>
5151 class __sentinel;
5252
......@@ -58,38 +58,38 @@ public:
5858 requires default_initializable<_View> && default_initializable<_Pred>
5959 = default;
6060
61 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 take_while_view(_View __base, _Pred __pred)
61 _LIBCPP_HIDE_FROM_ABI constexpr explicit take_while_view(_View __base, _Pred __pred)
6262 : __base_(std::move(__base)), __pred_(std::in_place, std::move(__pred)) {}
6363
64 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
6565 requires copy_constructible<_View>
6666 {
6767 return __base_;
6868 }
6969
70 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
7171
72 _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; }
72 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Pred& pred() const { return *__pred_; }
7373
74 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
74 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
7575 requires(!__simple_view<_View>)
7676 {
7777 return ranges::begin(__base_);
7878 }
7979
80 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
80 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
8181 requires range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>
8282 {
8383 return ranges::begin(__base_);
8484 }
8585
86 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
8787 requires(!__simple_view<_View>)
8888 {
8989 return __sentinel</*_Const=*/false>(ranges::end(__base_), std::addressof(*__pred_));
9090 }
9191
92 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
92 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
9393 requires range<const _View> && indirect_unary_predicate<const _Pred, iterator_t<const _View>>
9494 {
9595 return __sentinel</*_Const=*/true>(ranges::end(__base_), std::addressof(*__pred_));
......@@ -120,7 +120,7 @@ public:
120120 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
121121 : __end_(std::move(__s.__end_)), __pred_(__s.__pred_) {}
122122
123 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
124124
125125 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const iterator_t<_Base>& __x, const __sentinel& __y) {
126126 return __x == __y.__end_ || !std::invoke(*__y.__pred_, *__x);
lib/libcxx/include/__ranges/transform_view.h+35-24
......@@ -16,6 +16,7 @@
1616#include <__concepts/derived_from.h>
1717#include <__concepts/equality_comparable.h>
1818#include <__concepts/invocable.h>
19#include <__concepts/referenceable.h>
1920#include <__config>
2021#include <__functional/bind_back.h>
2122#include <__functional/invoke.h>
......@@ -37,7 +38,6 @@
3738#include <__type_traits/is_nothrow_constructible.h>
3839#include <__type_traits/is_object.h>
3940#include <__type_traits/is_reference.h>
40#include <__type_traits/is_referenceable.h>
4141#include <__type_traits/maybe_const.h>
4242#include <__type_traits/remove_cvref.h>
4343#include <__utility/forward.h>
......@@ -71,7 +71,7 @@ template <input_range _View, move_constructible _Fn>
7171template <input_range _View, copy_constructible _Fn>
7272# endif
7373 requires __transform_view_constraints<_View, _Fn>
74class _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS transform_view : public view_interface<transform_view<_View, _Fn>> {
74class _LIBCPP_LLVM18_NO_UNIQUE_ADDRESS_ABI_TAG transform_view : public view_interface<transform_view<_View, _Fn>> {
7575 template <bool>
7676 class __iterator;
7777 template <bool>
......@@ -85,46 +85,56 @@ public:
8585 requires default_initializable<_View> && default_initializable<_Fn>
8686 = default;
8787
88 _LIBCPP_HIDE_FROM_ABI constexpr _LIBCPP_EXPLICIT_SINCE_CXX23 transform_view(_View __base, _Fn __func)
88 _LIBCPP_HIDE_FROM_ABI constexpr explicit transform_view(_View __base, _Fn __func)
8989 : __func_(std::in_place, std::move(__func)), __base_(std::move(__base)) {}
9090
91 _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
91 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() const&
9292 requires copy_constructible<_View>
9393 {
9494 return __base_;
9595 }
96 _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
9796
98 _LIBCPP_HIDE_FROM_ABI constexpr __iterator<false> begin() { return __iterator<false>{*this, ranges::begin(__base_)}; }
99 _LIBCPP_HIDE_FROM_ABI constexpr __iterator<true> begin() const
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _View base() && { return std::move(__base_); }
98
99 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<false> begin() {
100 return __iterator<false>{*this, ranges::begin(__base_)};
101 }
102
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<true> begin() const
100104 requires range<const _View> && __regular_invocable_with_range_ref<const _Fn&, const _View>
101105 {
102106 return __iterator<true>(*this, ranges::begin(__base_));
103107 }
104108
105 _LIBCPP_HIDE_FROM_ABI constexpr __sentinel<false> end() { return __sentinel<false>(ranges::end(__base_)); }
106 _LIBCPP_HIDE_FROM_ABI constexpr __iterator<false> end()
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __sentinel<false> end() {
110 return __sentinel<false>(ranges::end(__base_));
111 }
112
113 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<false> end()
107114 requires common_range<_View>
108115 {
109116 return __iterator<false>(*this, ranges::end(__base_));
110117 }
111 _LIBCPP_HIDE_FROM_ABI constexpr __sentinel<true> end() const
118
119 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __sentinel<true> end() const
112120 requires range<const _View> && __regular_invocable_with_range_ref<const _Fn&, const _View>
113121 {
114122 return __sentinel<true>(ranges::end(__base_));
115123 }
116 _LIBCPP_HIDE_FROM_ABI constexpr __iterator<true> end() const
124
125 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __iterator<true> end() const
117126 requires common_range<const _View> && __regular_invocable_with_range_ref<const _Fn&, const _View>
118127 {
119128 return __iterator<true>(*this, ranges::end(__base_));
120129 }
121130
122 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
131 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
123132 requires sized_range<_View>
124133 {
125134 return ranges::size(__base_);
126135 }
127 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
136
137 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
128138 requires sized_range<const _View>
129139 {
130140 return ranges::size(__base_);
......@@ -209,11 +219,11 @@ public:
209219 requires _Const && convertible_to<iterator_t<_View>, iterator_t<_Base>>
210220 : __parent_(__i.__parent_), __current_(std::move(__i.__current_)) {}
211221
212 _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
222 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const iterator_t<_Base>& base() const& noexcept { return __current_; }
213223
214 _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
224 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator_t<_Base> base() && { return std::move(__current_); }
215225
216 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
226 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
217227 noexcept(noexcept(std::invoke(*__parent_->__func_, *__current_))) {
218228 return std::invoke(*__parent_->__func_, *__current_);
219229 }
......@@ -262,7 +272,7 @@ public:
262272 return *this;
263273 }
264274
265 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
275 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
266276 noexcept(noexcept(std::invoke(*__parent_->__func_, __current_[__n])))
267277 requires random_access_range<_Base>
268278 {
......@@ -305,25 +315,26 @@ public:
305315 return __x.__current_ <=> __y.__current_;
306316 }
307317
308 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n)
318 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(__iterator __i, difference_type __n)
309319 requires random_access_range<_Base>
310320 {
311321 return __iterator{*__i.__parent_, __i.__current_ + __n};
312322 }
313323
314 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i)
324 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, __iterator __i)
315325 requires random_access_range<_Base>
316326 {
317327 return __iterator{*__i.__parent_, __i.__current_ + __n};
318328 }
319329
320 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n)
330 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(__iterator __i, difference_type __n)
321331 requires random_access_range<_Base>
322332 {
323333 return __iterator{*__i.__parent_, __i.__current_ - __n};
324334 }
325335
326 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
336 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
337 operator-(const __iterator& __x, const __iterator& __y)
327338 requires sized_sentinel_for<iterator_t<_Base>, iterator_t<_Base>>
328339 {
329340 return __x.__current_ - __y.__current_;
......@@ -361,7 +372,7 @@ public:
361372 requires _Const && convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
362373 : __end_(std::move(__i.__end_)) {}
363374
364 _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
375 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr sentinel_t<_Base> base() const { return __end_; }
365376
366377 template <bool _OtherConst>
367378 requires sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
......@@ -371,14 +382,14 @@ public:
371382
372383 template <bool _OtherConst>
373384 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
374 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
385 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
375386 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
376387 return __x.__current_ - __y.__end_;
377388 }
378389
379390 template <bool _OtherConst>
380391 requires sized_sentinel_for<sentinel_t<_Base>, iterator_t<__maybe_const<_OtherConst, _View>>>
381 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
392 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _View>>
382393 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
383394 return __x.__end_ - __y.__current_;
384395 }
lib/libcxx/include/__ranges/view_interface.h+4-4
......@@ -30,10 +30,10 @@
3030# pragma GCC system_header
3131#endif
3232
33_LIBCPP_BEGIN_NAMESPACE_STD
34
3533#if _LIBCPP_STD_VER >= 20
3634
35_LIBCPP_BEGIN_NAMESPACE_STD
36
3737namespace ranges {
3838
3939template <class _Derived>
......@@ -163,8 +163,8 @@ public:
163163
164164} // namespace ranges
165165
166#endif // _LIBCPP_STD_VER >= 20
167
168166_LIBCPP_END_NAMESPACE_STD
169167
168#endif // _LIBCPP_STD_VER >= 20
169
170170#endif // _LIBCPP___RANGES_VIEW_INTERFACE_H
lib/libcxx/include/__ranges/views.h+2-1
......@@ -22,7 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323namespace ranges {
2424
25namespace views {}
25namespace views { // NOLINT(libcpp-avoid-empty-namespaces) // This is needed to declare the alias below.
26} // namespace views
2627
2728} // namespace ranges
2829
lib/libcxx/include/__ranges/zip_transform_view.h+18-17
......@@ -17,6 +17,7 @@
1717#include <__concepts/derived_from.h>
1818#include <__concepts/equality_comparable.h>
1919#include <__concepts/invocable.h>
20#include <__concepts/referenceable.h>
2021#include <__functional/invoke.h>
2122#include <__iterator/concepts.h>
2223#include <__iterator/incrementable_traits.h>
......@@ -33,7 +34,6 @@
3334#include <__type_traits/invoke.h>
3435#include <__type_traits/is_object.h>
3536#include <__type_traits/is_reference.h>
36#include <__type_traits/is_referenceable.h>
3737#include <__type_traits/maybe_const.h>
3838#include <__type_traits/remove_cvref.h>
3939#include <__utility/forward.h>
......@@ -79,15 +79,15 @@ public:
7979 _LIBCPP_HIDE_FROM_ABI constexpr explicit zip_transform_view(_Fn __fun, _Views... __views)
8080 : __zip_(std::move(__views)...), __fun_(in_place, std::move(__fun)) {}
8181
82 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __zip_.begin()); }
82 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() { return __iterator<false>(*this, __zip_.begin()); }
8383
84 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
84 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
8585 requires range<const _InnerView> && regular_invocable<const _Fn&, range_reference_t<const _Views>...>
8686 {
8787 return __iterator<true>(*this, __zip_.begin());
8888 }
8989
90 _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
90 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() {
9191 if constexpr (common_range<_InnerView>) {
9292 return __iterator<false>(*this, __zip_.end());
9393 } else {
......@@ -95,7 +95,7 @@ public:
9595 }
9696 }
9797
98 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
98 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
9999 requires range<const _InnerView> && regular_invocable<const _Fn&, range_reference_t<const _Views>...>
100100 {
101101 if constexpr (common_range<const _InnerView>) {
......@@ -105,13 +105,13 @@ public:
105105 }
106106 }
107107
108 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
108 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
109109 requires sized_range<_InnerView>
110110 {
111111 return __zip_.size();
112112 }
113113
114 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
115115 requires sized_range<const _InnerView>
116116 {
117117 return __zip_.size();
......@@ -184,7 +184,7 @@ public:
184184 requires _Const && convertible_to<__ziperator<false>, __ziperator<_Const>>
185185 : __parent_(__i.__parent_), __inner_(std::move(__i.__inner_)) {}
186186
187 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
187 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator*() const
188188 noexcept(noexcept(std::apply(__get_deref_and_invoke(), __zip_view_iterator_access::__get_underlying(__inner_)))) {
189189 return std::apply(__get_deref_and_invoke(), __zip_view_iterator_access::__get_underlying(__inner_));
190190 }
......@@ -233,7 +233,7 @@ public:
233233 return *this;
234234 }
235235
236 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
236 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator[](difference_type __n) const
237237 requires random_access_range<_Base>
238238 {
239239 return std::apply(
......@@ -255,25 +255,26 @@ public:
255255 return __x.__inner_ <=> __y.__inner_;
256256 }
257257
258 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
258 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
259259 requires random_access_range<_Base>
260260 {
261261 return __iterator(*__i.__parent_, __i.__inner_ + __n);
262262 }
263263
264 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
264 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
265265 requires random_access_range<_Base>
266266 {
267267 return __iterator(*__i.__parent_, __i.__inner_ + __n);
268268 }
269269
270 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
270 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
271271 requires random_access_range<_Base>
272272 {
273273 return __iterator(*__i.__parent_, __i.__inner_ - __n);
274274 }
275275
276 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
276 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
277 operator-(const __iterator& __x, const __iterator& __y)
277278 requires sized_sentinel_for<__ziperator<_Const>, __ziperator<_Const>>
278279 {
279280 return __x.__inner_ - __y.__inner_;
......@@ -307,14 +308,14 @@ public:
307308
308309 template <bool _OtherConst>
309310 requires sized_sentinel_for<__zentinel<_Const>, __ziperator<_OtherConst>>
310 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
311 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
311312 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
312313 return __x.__inner_ - __y.__inner_;
313314 }
314315
315316 template <bool _OtherConst>
316317 requires sized_sentinel_for<__zentinel<_Const>, __ziperator<_OtherConst>>
317 _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
318 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr range_difference_t<__maybe_const<_OtherConst, _InnerView>>
318319 operator-(const __sentinel& __x, const __iterator<_OtherConst>& __y) {
319320 return __x.__inner_ - __y.__inner_;
320321 }
......@@ -327,14 +328,14 @@ struct __fn {
327328 template <class _Fn>
328329 requires(move_constructible<decay_t<_Fn>> && regular_invocable<decay_t<_Fn>&> &&
329330 is_object_v<invoke_result_t<decay_t<_Fn>&>>)
330 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&&) const
331 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&&) const
331332 noexcept(noexcept(auto(views::empty<decay_t<invoke_result_t<decay_t<_Fn>&>>>))) {
332333 return views::empty<decay_t<invoke_result_t<decay_t<_Fn>&>>>;
333334 }
334335
335336 template <class _Fn, class... _Ranges>
336337 requires(sizeof...(_Ranges) > 0)
337 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __fun, _Ranges&&... __rs) const
338 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __fun, _Ranges&&... __rs) const
338339 noexcept(noexcept(zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...)))
339340 -> decltype(zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...)) {
340341 return zip_transform_view(std::forward<_Fn>(__fun), std::forward<_Ranges>(__rs)...);
lib/libcxx/include/__ranges/zip_view.h+18-15
......@@ -134,19 +134,19 @@ public:
134134
135135 _LIBCPP_HIDE_FROM_ABI constexpr explicit zip_view(_Views... __views) : __views_(std::move(__views)...) {}
136136
137 _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
137 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin()
138138 requires(!(__simple_view<_Views> && ...))
139139 {
140140 return __iterator<false>(std::__tuple_transform(ranges::begin, __views_));
141141 }
142142
143 _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
143 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const
144144 requires(range<const _Views> && ...)
145145 {
146146 return __iterator<true>(std::__tuple_transform(ranges::begin, __views_));
147147 }
148148
149 _LIBCPP_HIDE_FROM_ABI constexpr auto end()
149 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end()
150150 requires(!(__simple_view<_Views> && ...))
151151 {
152152 if constexpr (!__zip_is_common<_Views...>) {
......@@ -158,7 +158,7 @@ public:
158158 }
159159 }
160160
161 _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
161 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const
162162 requires(range<const _Views> && ...)
163163 {
164164 if constexpr (!__zip_is_common<const _Views...>) {
......@@ -170,7 +170,7 @@ public:
170170 }
171171 }
172172
173 _LIBCPP_HIDE_FROM_ABI constexpr auto size()
173 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size()
174174 requires(sized_range<_Views> && ...)
175175 {
176176 return std::apply(
......@@ -181,7 +181,7 @@ public:
181181 std::__tuple_transform(ranges::size, __views_));
182182 }
183183
184 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
184 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
185185 requires(sized_range<const _Views> && ...)
186186 {
187187 return std::apply(
......@@ -267,7 +267,7 @@ public:
267267 requires _Const && (convertible_to<iterator_t<_Views>, iterator_t<__maybe_const<_Const, _Views>>> && ...)
268268 : __current_(std::move(__i.__current_)) {}
269269
270 _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const {
270 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator*() const {
271271 return std::__tuple_transform([](auto& __i) -> decltype(auto) { return *__i; }, __current_);
272272 }
273273
......@@ -315,7 +315,7 @@ public:
315315 return *this;
316316 }
317317
318 _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const
318 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const
319319 requires __zip_all_random_access<_Const, _Views...>
320320 {
321321 return std::__tuple_transform(
......@@ -338,7 +338,7 @@ public:
338338 return __x.__current_ <=> __y.__current_;
339339 }
340340
341 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
341 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(const __iterator& __i, difference_type __n)
342342 requires __zip_all_random_access<_Const, _Views...>
343343 {
344344 auto __r = __i;
......@@ -346,13 +346,13 @@ public:
346346 return __r;
347347 }
348348
349 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
349 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator+(difference_type __n, const __iterator& __i)
350350 requires __zip_all_random_access<_Const, _Views...>
351351 {
352352 return __i + __n;
353353 }
354354
355 _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
355 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr __iterator operator-(const __iterator& __i, difference_type __n)
356356 requires __zip_all_random_access<_Const, _Views...>
357357 {
358358 auto __r = __i;
......@@ -360,7 +360,8 @@ public:
360360 return __r;
361361 }
362362
363 _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type operator-(const __iterator& __x, const __iterator& __y)
363 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr difference_type
364 operator-(const __iterator& __x, const __iterator& __y)
364365 requires(sized_sentinel_for<iterator_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_Const, _Views>>> &&
365366 ...)
366367 {
......@@ -374,7 +375,7 @@ public:
374375 __diffs);
375376 }
376377
377 _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept(
378 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto iter_move(const __iterator& __i) noexcept(
378379 (noexcept(ranges::iter_move(std::declval<const iterator_t<__maybe_const<_Const, _Views>>&>())) && ...) &&
379380 (is_nothrow_move_constructible_v<range_rvalue_reference_t<__maybe_const<_Const, _Views>>> && ...)) {
380381 return std::__tuple_transform(ranges::iter_move, __i.__current_);
......@@ -426,6 +427,7 @@ public:
426427 requires(
427428 sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
428429 ...)
430 [[nodiscard]]
429431 _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
430432 operator-(const __iterator<_OtherConst>& __x, const __sentinel& __y) {
431433 const auto __diffs = ranges::__tuple_zip_transform(minus<>(), __iter_current(__x), __y.__end_);
......@@ -443,6 +445,7 @@ public:
443445 requires(
444446 sized_sentinel_for<sentinel_t<__maybe_const<_Const, _Views>>, iterator_t<__maybe_const<_OtherConst, _Views>>> &&
445447 ...)
448 [[nodiscard]]
446449 _LIBCPP_HIDE_FROM_ABI friend constexpr common_type_t<range_difference_t<__maybe_const<_OtherConst, _Views>>...>
447450 operator-(const __sentinel& __y, const __iterator<_OtherConst>& __x) {
448451 return -(__x - __y);
......@@ -456,10 +459,10 @@ namespace views {
456459namespace __zip {
457460
458461struct __fn {
459 _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()() noexcept { return empty_view<tuple<>>{}; }
462 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()() noexcept { return empty_view<tuple<>>{}; }
460463
461464 template <class... _Ranges>
462 _LIBCPP_HIDE_FROM_ABI static constexpr auto
465 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
463466 operator()(_Ranges&&... __rs) noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
464467 -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
465468 return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
lib/libcxx/include/__split_buffer+131-16
......@@ -25,6 +25,7 @@
2525#include <__memory/compressed_pair.h>
2626#include <__memory/pointer_traits.h>
2727#include <__memory/swap_allocator.h>
28#include <__memory/uninitialized_algorithms.h>
2829#include <__type_traits/conditional.h>
2930#include <__type_traits/enable_if.h>
3031#include <__type_traits/integral_constant.h>
......@@ -156,10 +157,8 @@ public:
156157
157158 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { return *(__end_ - 1); }
158159
159 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_without_allocator(
160 __split_buffer_pointer_layout<__split_buffer<value_type, allocator_type, __split_buffer_pointer_layout>,
161 value_type,
162 allocator_type>& __other) _NOEXCEPT {
160 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
161 __swap_without_allocator(__split_buffer_pointer_layout& __other) _NOEXCEPT {
163162 std::swap(__front_cap_, __other.__front_cap_);
164163 std::swap(__begin_, __other.__begin_);
165164 std::swap(__back_cap_, __other.__back_cap_);
......@@ -190,6 +189,65 @@ public:
190189 __back_cap_ = __other.__back_cap_;
191190 }
192191
192 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
193 __swap_layouts(pointer& __begin, pointer& __end, pointer& __back_capacity) {
194 using std::swap;
195 swap(__begin_, __begin);
196 swap(__end_, __end);
197 swap(__back_cap_, __back_capacity);
198 }
199
200 /// Relocates the objects in the range `[__first, __last)` to the front of the buffer, then swaps
201 /// `__first`, `__last`, and `__capacity` with `__begin_`, `__end_`, and `__back_cap_`,
202 /// respectively.
203 ///
204 /// Precondition: `__front_spare() == __last - __first`.
205 /// Exceptions: This function has a strong exception guarantee.
206 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
207 __relocate(pointer& __first, pointer& __last, pointer& __capacity) {
208 auto __size = __last - __first;
209 auto __new_begin = __begin_ - __size;
210 std::__uninitialized_allocator_relocate(
211 __alloc_, std::__to_address(__first), std::__to_address(__last), std::__to_address(__new_begin));
212 __begin_ = __new_begin;
213 __last = __first;
214
215 __swap_layouts(__first, __last, __capacity);
216 __front_cap_ = __begin_;
217 }
218
219 /// Relocates the objects in the range `[__first, __pivot)` to the front of the buffer, the
220 /// objects in `[__pivot, __last)` into the back of the buffer, then swaps `__first`, `__last`,
221 /// and `__capacity` with `__begin_`, `__end_`, and `__back_cap_`, respectively.
222 ///
223 /// Preconditions:
224 /// * `__front_spare() == __pivot - __first`
225 /// * `__back_spare() == __last - __pivot`
226 /// Exceptions: This function has a strong exception guarantee if `__first == __pivot` or
227 /// `__last == __pivot`.
228 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
229 __relocate_with_pivot(pointer __pivot, pointer& __first, pointer& __last, pointer& __capacity) {
230 pointer __result = __begin_;
231
232 // Relocate [__p, __last) first to avoid having a hole in [__first, __last)
233 // in case something in [__first, __p) throws.
234 std::__uninitialized_allocator_relocate(
235 __alloc_, std::__to_address(__pivot), std::__to_address(__last), std::__to_address(__end_));
236 auto __relocated_so_far = __last - __pivot;
237 __end_ += __relocated_so_far;
238 __last = __pivot; // The objects in [__p, __last) have been destroyed by relocating them.
239
240 auto __new_begin = __begin_ - (__pivot - __first);
241 std::__uninitialized_allocator_relocate(
242 __alloc_, std::__to_address(__first), std::__to_address(__pivot), std::__to_address(__new_begin));
243 __begin_ = __new_begin;
244
245 __last = __first; // All the objects have been destroyed by relocating them.
246 __swap_layouts(__first, __last, __capacity);
247 __front_cap_ = __begin_;
248 return __result;
249 }
250
193251private:
194252 pointer __front_cap_ = nullptr;
195253 pointer __begin_ = nullptr;
......@@ -263,25 +321,19 @@ public:
263321
264322 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
265323 __set_valid_range(pointer __new_begin, pointer __new_end) _NOEXCEPT {
266 // Size-based __split_buffers track their size directly: we need to explicitly update the size
267 // when the front is adjusted.
268 __size_ -= __new_begin - __begin_;
269324 __begin_ = __new_begin;
270325 __set_sentinel(__new_end);
271326 }
272327
273328 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
274329 __set_valid_range(pointer __new_begin, size_type __new_size) _NOEXCEPT {
275 // Size-based __split_buffers track their size directly: we need to explicitly update the size
276 // when the front is adjusted.
277 __size_ -= __new_begin - __begin_;
278330 __begin_ = __new_begin;
279331 __set_sentinel(__new_size);
280332 }
281333
282334 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(pointer __new_end) _NOEXCEPT {
283335 _LIBCPP_ASSERT_INTERNAL(__front_cap_ <= __new_end, "__new_end cannot precede __front_cap_");
284 __size_ += __new_end - end();
336 __size_ = __new_end - __begin_;
285337 }
286338
287339 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_sentinel(size_type __new_size) _NOEXCEPT {
......@@ -312,10 +364,8 @@ public:
312364 return __begin_[__size_ - 1];
313365 }
314366
315 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_without_allocator(
316 __split_buffer_pointer_layout<__split_buffer<value_type, allocator_type, __split_buffer_pointer_layout>,
317 value_type,
318 allocator_type>& __other) _NOEXCEPT {
367 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
368 __swap_without_allocator(__split_buffer_size_layout& __other) _NOEXCEPT {
319369 std::swap(__front_cap_, __other.__front_cap_);
320370 std::swap(__begin_, __other.__begin_);
321371 std::swap(__cap_, __other.__cap_);
......@@ -346,6 +396,68 @@ public:
346396 __size_ = __other.__size_;
347397 }
348398
399 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
400 __swap_layouts(pointer& __begin, size_type& __size, size_type& __capacity) {
401 using std::swap;
402 swap(__begin_, __begin);
403 swap(__size_, __size);
404 swap(__cap_, __capacity);
405 }
406
407 /// Relocates the objects in the range `[__first, __first + __n)` to the front of the buffer, then
408 /// swaps `__first`, `__n`, and `__capacity` with `__begin_`, `__size_`, and `__capacity_`,
409 /// respectively.
410 ///
411 /// Precondition: `__front_spare() == __n`.
412 /// Exceptions: This function has a strong exception guarantee.
413 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
414 __relocate(pointer& __first, size_type& __n, size_type& __capacity) {
415 auto __new_begin = __begin_ - __n;
416 auto __last = __first + __n;
417 std::__uninitialized_allocator_relocate(
418 __alloc_, std::__to_address(__first), std::__to_address(__last), std::__to_address(__new_begin));
419 __set_valid_range(__new_begin, end());
420 __n = 0;
421
422 __swap_layouts(__first, __n, __capacity);
423 __front_cap_ = __begin_;
424 }
425
426 /// Relocates the objects in the range `[__first, __pivot)` to the front of the buffer, the
427 /// objects in `[__pivot, __first + __n)` to the back of the buffer, then swaps `__first`, `__n`,
428 /// and `__capacity` with `__begin_`, `__size_`, and `__capacity_`, respectively.
429 ///
430 /// Preconditions:
431 /// * `__front_spare() == __pivot - __first`
432 /// * `__back_spare() == __last - __pivot`
433 /// Exceptions: This function has a strong exception guarantee if `__first == __pivot` or
434 /// `__first + __n == __pivot`.
435 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
436 __relocate_with_pivot(pointer __pivot, pointer& __first, size_type& __n, size_type& __capacity) {
437 pointer __result = __begin_;
438 pointer __last = __first + __n;
439
440 // We relocate elements in reverse order to ensure that a throwing relocation operation leaves the
441 // buffer in a valid state.
442 std::__uninitialized_allocator_relocate(
443 __alloc_, std::__to_address(__pivot), std::__to_address(__last), std::__to_address(end()));
444
445 auto const __relocated_so_far = __last - __pivot;
446 __size_ += __relocated_so_far;
447 __n -= __relocated_so_far; // The objects in [__pivot, __last) have been destroyed by relocating them.
448
449 auto __new_begin = __begin_ - __n;
450 std::__uninitialized_allocator_relocate(
451 __alloc_, std::__to_address(__first), std::__to_address(__pivot), std::__to_address(__new_begin));
452 __begin_ = __new_begin;
453 __size_ += __n;
454 __n = 0; // All the objects have been destroyed by relocating them.
455
456 __swap_layouts(__first, __n, __capacity);
457 __front_cap_ = __begin_;
458 return __result;
459 }
460
349461private:
350462 pointer __front_cap_ = nullptr;
351463 pointer __begin_ = nullptr;
......@@ -452,11 +564,14 @@ public:
452564 using __base_type::__get_allocator;
453565 using __base_type::__raw_capacity;
454566 using __base_type::__raw_sentinel;
567 using __base_type::__relocate;
568 using __base_type::__relocate_with_pivot;
455569 using __base_type::__reset;
456570 using __base_type::__set_capacity;
457571 using __base_type::__set_data;
458572 using __base_type::__set_sentinel;
459573 using __base_type::__set_valid_range;
574 using __base_type::__swap_layouts;
460575
461576 using typename __base_type::__alloc_traits;
462577 using typename __base_type::allocator_type;
......@@ -585,7 +700,7 @@ public:
585700
586701 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
587702 __swap_without_allocator(__split_buffer<value_type, allocator_type, _Layout>& __other) _NOEXCEPT {
588 __base_type::__swap_without_allocator(__other);
703 __base_type::__swap_without_allocator(static_cast<__base_type&>(__other));
589704 }
590705
591706private:
lib/libcxx/include/__stop_token/atomic_unique_lock.h+8-7
......@@ -10,25 +10,26 @@
1010#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
1111#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
1212
13#include <__bit/popcount.h>
13#include <__atomic/atomic.h>
14#include <__atomic/memory_order.h>
15#include <__bit/has_single_bit.h>
1416#include <__config>
15#include <atomic>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
1920#endif
2021
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2322#if _LIBCPP_STD_VER >= 20
2423
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2526// This class implements an RAII unique_lock without a mutex.
2627// It uses std::atomic<State>,
2728// where State contains a lock bit and might contain other data,
2829// and LockedBit is the value of State when the lock bit is set, e.g 1 << 2
2930template <class _State, _State _LockedBit>
3031class __atomic_unique_lock {
31 static_assert(std::__popcount(static_cast<unsigned long long>(_LockedBit)) == 1,
32 static_assert(std::has_single_bit(static_cast<unsigned long long>(_LockedBit)),
3233 "LockedBit must be an integer where only one bit is set");
3334
3435 std::atomic<_State>& __state_;
......@@ -133,8 +134,8 @@ private:
133134 _LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; };
134135};
135136
136#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
137
138137_LIBCPP_END_NAMESPACE_STD
139138
139#endif // _LIBCPP_STD_VER >= 20
140
140141#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
lib/libcxx/include/__stop_token/intrusive_list_view.h+4-4
......@@ -17,10 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2220#if _LIBCPP_STD_VER >= 20
2321
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2424template <class _Derived>
2525struct __intrusive_node_base {
2626 _Derived* __next_ = nullptr;
......@@ -78,8 +78,8 @@ private:
7878 _Node* __head_ = nullptr;
7979};
8080
81#endif // _LIBCPP_STD_VER >= 20
82
8381_LIBCPP_END_NAMESPACE_STD
8482
83#endif // _LIBCPP_STD_VER >= 20
84
8585#endif // _LIBCPP___STOP_TOKEN_INTRUSIVE_LIST_VIEW_H
lib/libcxx/include/__stop_token/intrusive_shared_ptr.h+4-5
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H
1111#define _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H
1212
13#include <__atomic/atomic.h>
1413#include <__atomic/memory_order.h>
1514#include <__config>
1615#include <__cstddef/nullptr_t.h>
......@@ -26,10 +25,10 @@
2625_LIBCPP_PUSH_MACROS
2726#include <__undef_macros>
2827
29_LIBCPP_BEGIN_NAMESPACE_STD
30
3128#if _LIBCPP_STD_VER >= 20
3229
30_LIBCPP_BEGIN_NAMESPACE_STD
31
3332// For intrusive_shared_ptr to work with a type T, specialize __intrusive_shared_ptr_traits<T> and implement
3433// the following function:
3534//
......@@ -126,10 +125,10 @@ private:
126125 }
127126};
128127
129#endif // _LIBCPP_STD_VER >= 20
130
131128_LIBCPP_END_NAMESPACE_STD
132129
130#endif // _LIBCPP_STD_VER >= 20
131
133132_LIBCPP_POP_MACROS
134133
135134#endif // _LIBCPP___STOP_TOKEN_INTRUSIVE_SHARED_PTR_H
lib/libcxx/include/__stop_token/stop_callback.h+4-4
......@@ -29,10 +29,10 @@
2929_LIBCPP_PUSH_MACROS
3030#include <__undef_macros>
3131
32_LIBCPP_BEGIN_NAMESPACE_STD
33
3432#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
3533
34_LIBCPP_BEGIN_NAMESPACE_STD
35
3636template <class _Callback>
3737class stop_callback : private __stop_callback_base {
3838 static_assert(invocable<_Callback>,
......@@ -93,10 +93,10 @@ private:
9393template <class _Callback>
9494stop_callback(stop_token, _Callback) -> stop_callback<_Callback>;
9595
96#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
97
9896_LIBCPP_END_NAMESPACE_STD
9997
98#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
99
100100_LIBCPP_POP_MACROS
101101
102102#endif // _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
lib/libcxx/include/__stop_token/stop_state.h+6-5
......@@ -11,21 +11,22 @@
1111#define _LIBCPP___STOP_TOKEN_STOP_STATE_H
1212
1313#include <__assert>
14#include <__atomic/atomic.h>
15#include <__atomic/memory_order.h>
1416#include <__config>
1517#include <__stop_token/atomic_unique_lock.h>
1618#include <__stop_token/intrusive_list_view.h>
1719#include <__thread/id.h>
18#include <atomic>
1920#include <cstdint>
2021
2122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2223# pragma GCC system_header
2324#endif
2425
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2726#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
2827
28_LIBCPP_BEGIN_NAMESPACE_STD
29
2930struct __stop_callback_base : __intrusive_node_base<__stop_callback_base> {
3031 using __callback_fn_t _LIBCPP_NODEBUG = void(__stop_callback_base*) noexcept;
3132 _LIBCPP_HIDE_FROM_ABI explicit __stop_callback_base(__callback_fn_t* __callback_fn) : __callback_fn_(__callback_fn) {}
......@@ -229,8 +230,8 @@ struct __intrusive_shared_ptr_traits<__stop_state> {
229230 }
230231};
231232
232#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
233
234233_LIBCPP_END_NAMESPACE_STD
235234
235#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
236
236237#endif // _LIBCPP___STOP_TOKEN_STOP_STATE_H
lib/libcxx/include/__stop_token/stop_token.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525class stop_token {
2626public:
2727 _LIBCPP_HIDE_FROM_ABI stop_token() noexcept = default;
......@@ -56,8 +56,8 @@ private:
5656 _LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {}
5757};
5858
59#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
60
6159_LIBCPP_END_NAMESPACE_STD
6260
61#endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_THREADS
62
6363#endif // _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h deleted-33
......@@ -1,33 +0,0 @@
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___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
11#define _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
12
13#include <__config>
14
15// Patch over lack of extended locale support
16typedef void* locale_t;
17
18inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return nullptr; }
19
20inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
21
22inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return nullptr; }
23
24#define LC_COLLATE_MASK (1 << LC_COLLATE)
25#define LC_CTYPE_MASK (1 << LC_CTYPE)
26#define LC_MESSAGES_MASK (1 << LC_MESSAGES)
27#define LC_MONETARY_MASK (1 << LC_MONETARY)
28#define LC_NUMERIC_MASK (1 << LC_NUMERIC)
29#define LC_TIME_MASK (1 << LC_TIME)
30#define LC_ALL_MASK \
31 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK)
32
33#endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h deleted-37
......@@ -1,37 +0,0 @@
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// These are reimplementations of some extended locale functions ( *_l ) that
10// aren't part of POSIX. They are widely available though (GLIBC, BSD, maybe
11// others). The unifying aspect in this case is that all of these functions
12// convert strings to some numeric type.
13//===----------------------------------------------------------------------===//
14
15#ifndef _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
16#define _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
17
18#include <__config>
19#include <stdlib.h>
20
21#if _LIBCPP_HAS_WIDE_CHARACTERS
22# include <wchar.h>
23#endif
24
25inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
26 return ::strtof(__nptr, __endptr);
27}
28
29inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
30 return ::strtod(__nptr, __endptr);
31}
32
33inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t) {
34 return ::strtold(__nptr, __endptr);
35}
36
37#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
lib/libcxx/include/__system_error/error_category.h+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324class error_condition;
2425class _LIBCPP_EXPORTED_FROM_ABI error_code;
......@@ -70,6 +71,7 @@ public:
7071[[__gnu__::__const__]] [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
7172[[__gnu__::__const__]] [[__nodiscard__]] _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
7273
74_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7375_LIBCPP_END_NAMESPACE_STD
7476
7577#endif // _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H
lib/libcxx/include/__system_error/error_code.h+2
......@@ -24,6 +24,7 @@
2424#endif
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728
2829template <class _Tp>
2930struct is_error_code_enum : public false_type {};
......@@ -137,6 +138,7 @@ struct hash<error_code> : public __unary_function<error_code, size_t> {
137138 }
138139};
139140
141_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
140142_LIBCPP_END_NAMESPACE_STD
141143
142144#endif // _LIBCPP___SYSTEM_ERROR_ERROR_CODE_H
lib/libcxx/include/__system_error/error_condition.h+2
......@@ -23,6 +23,7 @@
2323#endif
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2627
2728template <class _Tp>
2829struct is_error_condition_enum : public false_type {};
......@@ -124,6 +125,7 @@ struct hash<error_condition> : public __unary_function<error_condition, size_t>
124125 }
125126};
126127
128_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
127129_LIBCPP_END_NAMESPACE_STD
128130
129131#endif // _LIBCPP___SYSTEM_ERROR_ERROR_CONDITION_H
lib/libcxx/include/__system_error/system_error.h+2
......@@ -22,6 +22,7 @@
2222#endif
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
2627class _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error {
2728 error_code __ec_;
......@@ -52,6 +53,7 @@ public:
5253#endif
5354}
5455
56_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5557_LIBCPP_END_NAMESPACE_STD
5658
5759#endif // _LIBCPP___SYSTEM_ERROR_SYSTEM_ERROR_H
lib/libcxx/include/__system_error/throw_system_error.h+2
......@@ -17,9 +17,11 @@
1717#endif
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
20_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2021
2122[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
2223
24_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2325_LIBCPP_END_NAMESPACE_STD
2426
2527#endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
lib/libcxx/include/__thread/formatter.h+1-8
......@@ -51,20 +51,13 @@ public:
5151 // On Linux systems pthread_t is an unsigned long long.
5252 // On Apple systems pthread_t is a pointer type.
5353 //
54 // Note the output should match what the stream operator does. Since
55 // the ostream operator has been shipped years before this formatter
56 // was added to the Standard, this formatter does what the stream
57 // operator does. This may require platform specific changes.
54 // Note the output should match what the stream operator does.
5855
5956 using _Tp = decltype(__get_underlying_id(__id));
6057 using _Cp = conditional_t<integral<_Tp>, _Tp, conditional_t<is_pointer_v<_Tp>, uintptr_t, void>>;
6158 static_assert(!is_same_v<_Cp, void>, "unsupported thread::id type, please file a bug report");
6259
6360 __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
64 if constexpr (is_pointer_v<_Tp>) {
65 __specs.__std_.__alternate_form_ = true;
66 __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case;
67 }
6861 return __formatter::__format_integer(reinterpret_cast<_Cp>(__get_underlying_id(__id)), __ctx, __specs);
6962 }
7063
lib/libcxx/include/__thread/id.h+4-3
......@@ -20,9 +20,10 @@
2020# pragma GCC system_header
2121#endif
2222
23#if _LIBCPP_HAS_THREADS
24
2325_LIBCPP_BEGIN_NAMESPACE_STD
2426
25#if _LIBCPP_HAS_THREADS
2627class __thread_id;
2728
2829namespace this_thread {
......@@ -114,8 +115,8 @@ inline _LIBCPP_HIDE_FROM_ABI __thread_id get_id() _NOEXCEPT { return __libcpp_th
114115
115116} // namespace this_thread
116117
117#endif // _LIBCPP_HAS_THREADS
118
119118_LIBCPP_END_NAMESPACE_STD
120119
120#endif // _LIBCPP_HAS_THREADS
121
121122#endif // _LIBCPP___THREAD_ID_H
lib/libcxx/include/__thread/support/pthread.h+16-3
......@@ -144,7 +144,9 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag*
144144//
145145// Thread id
146146//
147#if defined(__MVS__)
147#if _LIBCPP_LIBC_LLVM_LIBC
148typedef pthread_id_np_t __libcpp_thread_id;
149#elif defined(__MVS__)
148150typedef unsigned long long __libcpp_thread_id;
149151#else
150152typedef pthread_t __libcpp_thread_id;
......@@ -163,11 +165,18 @@ inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t
163165//
164166// Thread
165167//
166#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
168#if defined(PTHREAD_NULL)
169# define _LIBCPP_NULL_THREAD PTHREAD_NULL
170#else
171# define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
172#endif
167173typedef pthread_t __libcpp_thread_t;
168174
169175inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) {
170#if defined(__MVS__)
176#if _LIBCPP_LIBC_LLVM_LIBC
177 __libcpp_thread_id __id;
178 return pthread_getunique_np(__t, &__id) ? 0 : __id;
179#elif defined(__MVS__)
171180 return __t->__;
172181#else
173182 return *__t;
......@@ -183,8 +192,12 @@ inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t,
183192}
184193
185194inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id() {
195#if _LIBCPP_LIBC_LLVM_LIBC
196 return pthread_getthreadid_np();
197#else
186198 const __libcpp_thread_t __current_thread = pthread_self();
187199 return __libcpp_thread_get_id(&__current_thread);
200#endif
188201}
189202
190203inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t) { return pthread_join(*__t, nullptr); }
lib/libcxx/include/__thread/support/windows.h+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324using __libcpp_timespec_t = ::timespec;
2425
......@@ -126,6 +127,7 @@ _LIBCPP_EXPORTED_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key);
126127
127128_LIBCPP_EXPORTED_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
128129
130_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
129131_LIBCPP_END_NAMESPACE_STD
130132
131133#endif // _LIBCPP___THREAD_SUPPORT_WINDOWS_H
lib/libcxx/include/__thread/this_thread.h+2
......@@ -32,7 +32,9 @@ namespace this_thread {
3232
3333#if _LIBCPP_HAS_THREADS
3434
35_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3536_LIBCPP_EXPORTED_FROM_ABI void sleep_for(const chrono::nanoseconds& __ns);
37_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3638
3739template <class _Rep, class _Period>
3840_LIBCPP_HIDE_FROM_ABI void sleep_for(const chrono::duration<_Rep, _Period>& __d) {
lib/libcxx/include/__thread/thread.h+23-14
......@@ -11,12 +11,13 @@
1111#define _LIBCPP___THREAD_THREAD_H
1212
1313#include <__assert>
14#include <__charconv/to_chars_integral.h>
1415#include <__condition_variable/condition_variable.h>
1516#include <__config>
1617#include <__exception/terminate.h>
1718#include <__functional/hash.h>
1819#include <__functional/unary_function.h>
19#include <__locale>
20#include <__fwd/ostream.h>
2021#include <__memory/addressof.h>
2122#include <__memory/unique_ptr.h>
2223#include <__mutex/mutex.h>
......@@ -27,15 +28,16 @@
2728#include <__type_traits/enable_if.h>
2829#include <__type_traits/invoke.h>
2930#include <__type_traits/is_constructible.h>
31#include <__type_traits/is_integral.h>
32#include <__type_traits/is_pointer.h>
3033#include <__type_traits/is_same.h>
3134#include <__type_traits/remove_cvref.h>
35#include <__utility/exchange.h>
3236#include <__utility/forward.h>
37#include <cstdint>
38#include <limits>
3339#include <tuple>
3440
35#if _LIBCPP_HAS_LOCALIZATION
36# include <sstream>
37#endif
38
3941#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4042# pragma GCC system_header
4143#endif
......@@ -44,6 +46,7 @@ _LIBCPP_PUSH_MACROS
4446#include <__undef_macros>
4547
4648_LIBCPP_BEGIN_NAMESPACE_STD
49_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4750
4851#if _LIBCPP_HAS_THREADS
4952
......@@ -144,13 +147,19 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, __thread_id __id) {
144147 //
145148 // Since various flags in the output stream can affect how the
146149 // thread id is represented (e.g. numpunct or showbase), we
147 // use a temporary stream instead and just output the thread
148 // id representation as a string.
150 // use `to_chars` directly and output the id as a string.
151
152 static_assert(is_pointer<__libcpp_thread_id>::value || is_integral<__libcpp_thread_id>::value);
153
154 using __int_type = __conditional_t<is_pointer<__libcpp_thread_id>::value, uintptr_t, __libcpp_thread_id>;
149155
150 basic_ostringstream<_CharT, _Traits> __sstr;
151 __sstr.imbue(locale::classic());
152 __sstr << __id.__id_;
153 return __os << __sstr.str();
156 static const size_t __buffer_size = numeric_limits<__int_type>::digits10 + 2;
157 char __buffer[__buffer_size];
158 auto __ret =
159 std::__to_chars_integral(__buffer, __buffer + __buffer_size - 1, reinterpret_cast<__int_type>(__id.__id_), 10);
160 _LIBCPP_ASSERT_INTERNAL(__ret.__ec == std::errc(), "to_chars failed!");
161 *__ret.__ptr = '\0';
162 return __os << __buffer;
154163}
155164# endif // _LIBCPP_HAS_LOCALIZATION
156165
......@@ -236,13 +245,12 @@ public:
236245# endif
237246 ~thread();
238247
239 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) { __t.__t_ = _LIBCPP_NULL_THREAD; }
248 _LIBCPP_HIDE_FROM_ABI thread(thread&& __t) _NOEXCEPT : __t_(std::__exchange(__t.__t_, __libcpp_thread_t())) {}
240249
241250 _LIBCPP_HIDE_FROM_ABI thread& operator=(thread&& __t) _NOEXCEPT {
242251 if (!__libcpp_thread_isnull(&__t_))
243252 terminate();
244 __t_ = __t.__t_;
245 __t.__t_ = _LIBCPP_NULL_THREAD;
253 __t_ = std::__exchange(__t.__t_, __libcpp_thread_t());
246254 return *this;
247255 }
248256
......@@ -261,6 +269,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(thread& __x, thread& __y) _NOEXCEPT { __x
261269
262270#endif // _LIBCPP_HAS_THREADS
263271
272_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
264273_LIBCPP_END_NAMESPACE_STD
265274
266275_LIBCPP_POP_MACROS
lib/libcxx/include/__tree+469-358
......@@ -113,7 +113,7 @@ __root, have a non-null __parent_ field.
113113// Returns: true if __x is a left child of its parent, else false
114114// Precondition: __x != nullptr.
115115template <class _NodePtr>
116inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
116inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
117117 return __x == __x->__parent_->__left_;
118118}
119119
......@@ -121,7 +121,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
121121// __x is a proper subtree, returns the black height (null counts as 1). If
122122// __x is an improper subtree, returns 0.
123123template <class _NodePtr>
124unsigned __tree_sub_invariant(_NodePtr __x) {
124_LIBCPP_CONSTEXPR_SINCE_CXX26 unsigned __tree_sub_invariant(_NodePtr __x) {
125125 if (__x == nullptr)
126126 return 1;
127127 // parent consistency checked by caller
......@@ -153,7 +153,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) {
153153// __root == nullptr is a proper tree. Returns true if __root is a proper
154154// red black tree, else returns false.
155155template <class _NodePtr>
156_LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {
156_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __tree_invariant(_NodePtr __root) {
157157 if (__root == nullptr)
158158 return true;
159159 // check __x->__parent_ consistency
......@@ -170,7 +170,7 @@ _LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {
170170
171171// Returns: pointer to the left-most node under __x.
172172template <class _NodePtr>
173inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
173inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
174174 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Root node shouldn't be null");
175175 while (__x->__left_ != nullptr)
176176 __x = __x->__left_;
......@@ -179,7 +179,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
179179
180180// Returns: pointer to the right-most node under __x.
181181template <class _NodePtr>
182inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
182inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
183183 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Root node shouldn't be null");
184184 while (__x->__right_ != nullptr)
185185 __x = __x->__right_;
......@@ -188,7 +188,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
188188
189189// Returns: pointer to the next in-order node after __x.
190190template <class _NodePtr>
191_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
191_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
192192 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
193193 if (__x->__right_ != nullptr)
194194 return std::__tree_min(__x->__right_);
......@@ -203,23 +203,23 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
203203// to the actual root of the tree through a __left_ pointer. Incrementing the end() pointer is UB, so we can assume that
204204// never happens.
205205template <class _EndNodePtr, class _NodePtr>
206inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT {
206inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT {
207207 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
208208 if (__x->__right_ != nullptr)
209 return static_cast<_EndNodePtr>(std::__tree_min(__x->__right_));
209 return std::__static_fancy_pointer_cast<_EndNodePtr>(std::__tree_min(__x->__right_));
210210 while (!std::__tree_is_left_child(__x))
211211 __x = __x->__parent_unsafe();
212 return static_cast<_EndNodePtr>(__x->__parent_);
212 return std::__static_fancy_pointer_cast<_EndNodePtr>(__x->__parent_);
213213}
214214
215215// Returns: pointer to the previous in-order node before __x.
216216// Note: __x may be the end node.
217217template <class _NodePtr, class _EndNodePtr>
218inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT {
218inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT {
219219 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
220220 if (__x->__left_ != nullptr)
221221 return std::__tree_max(__x->__left_);
222 _NodePtr __xx = static_cast<_NodePtr>(__x);
222 _NodePtr __xx = std::__static_fancy_pointer_cast<_NodePtr>(__x);
223223 while (std::__tree_is_left_child(__xx))
224224 __xx = __xx->__parent_unsafe();
225225 return __xx->__parent_unsafe();
......@@ -227,7 +227,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEP
227227
228228// Returns: pointer to a node which has no children
229229template <class _NodePtr>
230_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
230_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
231231 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
232232 while (true) {
233233 if (__x->__left_ != nullptr) {
......@@ -246,7 +246,7 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
246246// Effects: Makes __x->__right_ the subtree root with __x as its left child
247247// while preserving in-order order.
248248template <class _NodePtr>
249_LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
249_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
250250 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
251251 _LIBCPP_ASSERT_INTERNAL(__x->__right_ != nullptr, "node should have a right child");
252252 _NodePtr __y = __x->__right_;
......@@ -265,7 +265,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
265265// Effects: Makes __x->__left_ the subtree root with __x as its right child
266266// while preserving in-order order.
267267template <class _NodePtr>
268_LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
268_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
269269 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
270270 _LIBCPP_ASSERT_INTERNAL(__x->__left_ != nullptr, "node should have a left child");
271271 _NodePtr __y = __x->__left_;
......@@ -289,7 +289,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
289289// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
290290// may be different than the value passed in as __root.
291291template <class _NodePtr>
292_LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT {
292_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
293__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT {
293294 _LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root of the tree shouldn't be null");
294295 _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Can't attach null node to a leaf");
295296 __x->__is_black_ = __x == __root;
......@@ -345,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr
345346// nor any of its children refer to __z. end_node->__left_
346347// may be different than the value passed in as __root.
347348template <class _NodePtr>
348_LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT {
349_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT {
349350 _LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root node should not be null");
350351 _LIBCPP_ASSERT_INTERNAL(__z != nullptr, "The node to remove should not be null");
351352 _LIBCPP_ASSERT_INTERNAL(std::__tree_invariant(__root), "The tree invariants should hold");
......@@ -560,7 +561,7 @@ public:
560561 using pointer = _Pointer;
561562 pointer __left_;
562563
563 _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {}
564 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_end_node() _NOEXCEPT : __left_() {}
564565};
565566
566567template <class _VoidPtr>
......@@ -573,9 +574,13 @@ public:
573574 __end_node_pointer __parent_;
574575 bool __is_black_;
575576
576 _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); }
577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer __parent_unsafe() const {
578 return std::__static_fancy_pointer_cast<pointer>(__parent_);
579 }
577580
578 _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); }
581 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set_parent(pointer __p) {
582 __parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__p);
583 }
579584
580585 _LIBCPP_HIDE_FROM_ABI __tree_node_base() = default;
581586 __tree_node_base(__tree_node_base const&) = delete;
......@@ -598,7 +603,7 @@ private:
598603 };
599604
600605public:
601 _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
606 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_value_type& __get_value() { return __value_; }
602607#else
603608
604609private:
......@@ -609,9 +614,10 @@ public:
609614#endif
610615
611616 template <class _Alloc, class... _Args>
612 _LIBCPP_HIDE_FROM_ABI explicit __tree_node(_Alloc& __na, _Args&&... __args) {
617 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node(_Alloc& __na, _Args&&... __args) {
613618 allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...);
614619 }
620
615621 ~__tree_node() = delete;
616622 __tree_node(__tree_node const&) = delete;
617623 __tree_node& operator=(__tree_node const&) = delete;
......@@ -631,14 +637,15 @@ private:
631637public:
632638 bool __value_constructed;
633639
634 _LIBCPP_HIDE_FROM_ABI __tree_node_destructor(const __tree_node_destructor&) = default;
640 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node_destructor(const __tree_node_destructor&) = default;
635641 __tree_node_destructor& operator=(const __tree_node_destructor&) = delete;
636642
637 _LIBCPP_HIDE_FROM_ABI explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
643 _LIBCPP_HIDE_FROM_ABI
644 _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
638645 : __na_(__na),
639646 __value_constructed(__val) {}
640647
641 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
648 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(pointer __p) _NOEXCEPT {
642649 if (__value_constructed)
643650 __alloc_traits::destroy(__na_, std::addressof(__p->__get_value()));
644651 if (__p)
......@@ -663,7 +670,8 @@ template <class _Reference, class _Break, class _NodePtr, class _Func, class _Pr
663670#ifndef _LIBCPP_COMPILER_GCC // This function is recursive, so GCC complains about always_inline.
664671_LIBCPP_HIDE_FROM_ABI
665672#endif
666bool __tree_iterate_from_root(_Break __break, _NodePtr __root, _Func& __func, _Proj& __proj) {
673_LIBCPP_CONSTEXPR_SINCE_CXX26 bool
674__tree_iterate_from_root(_Break __break, _NodePtr __root, _Func& __func, _Proj& __proj) {
667675 if (__root->__left_) {
668676 if (std::__tree_iterate_from_root<_Reference>(__break, static_cast<_NodePtr>(__root->__left_), __func, __proj))
669677 return true;
......@@ -678,7 +686,7 @@ bool __tree_iterate_from_root(_Break __break, _NodePtr __root, _Func& __func, _P
678686
679687// Do an in-order traversal of the tree from __first to __last.
680688template <class _NodeIter, class _Func, class _Proj>
681_LIBCPP_HIDE_FROM_ABI void
689_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
682690__tree_iterate_subrange(_NodeIter __first_it, _NodeIter __last_it, _Func& __func, _Proj& __proj) {
683691 using _NodePtr = typename _NodeIter::__node_pointer;
684692 using _Reference = typename _NodeIter::reference;
......@@ -722,51 +730,57 @@ public:
722730 using reference = value_type&;
723731 using pointer = __rebind_pointer_t<_NodePtr, value_type>;
724732
725 _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT : __ptr_(nullptr) {}
733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator() _NOEXCEPT : __ptr_(nullptr) {}
726734
727 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); }
728 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
735 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __get_np()->__get_value(); }
736 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
729737 return pointer_traits<pointer>::pointer_to(__get_np()->__get_value());
730738 }
731739
732 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() {
733 __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator++() {
741 __ptr_ = std::__tree_next_iter<__end_node_pointer>(std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr_));
734742 return *this;
735743 }
736 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) {
744 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator operator++(int) {
737745 __tree_iterator __t(*this);
738746 ++(*this);
739747 return __t;
740748 }
741749
742 _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() {
743 __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
750 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator--() {
751 __ptr_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
744752 return *this;
745753 }
746 _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) {
754 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator operator--(int) {
747755 __tree_iterator __t(*this);
748756 --(*this);
749757 return __t;
750758 }
751759
752 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) {
760 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
761 operator==(const __tree_iterator& __x, const __tree_iterator& __y) {
753762 return __x.__ptr_ == __y.__ptr_;
754763 }
755 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {
764 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
765 operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {
756766 return !(__x == __y);
757767 }
758768
759769private:
760 _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
761 _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
762 _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
770 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator(__node_pointer __p) _NOEXCEPT
771 : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
772 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT
773 : __ptr_(__p) {}
774 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const {
775 return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_);
776 }
763777 template <class, class, class>
764778 friend class __tree;
765779 template <class, class, class>
766780 friend class __tree_const_iterator;
767781
768782 template <class _NodeIter, class _Func, class _Proj>
769 friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&);
783 _LIBCPP_CONSTEXPR_SINCE_CXX26 friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&);
770784};
771785
772786#ifndef _LIBCPP_CXX03_LANG
......@@ -780,7 +794,8 @@ struct __specialized_algorithm<
780794 using __iterator _LIBCPP_NODEBUG = __tree_iterator<_Tp, _NodePtr, _DiffType>;
781795
782796 template <class _Func, class _Proj>
783 _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) {
797 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
798 operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) {
784799 std::__tree_iterate_subrange(__first, __last, __func, __proj);
785800 }
786801};
......@@ -804,54 +819,61 @@ public:
804819 using pointer = __rebind_pointer_t<_NodePtr, const value_type>;
805820 using __non_const_iterator _LIBCPP_NODEBUG = __tree_iterator<_Tp, __node_pointer, difference_type>;
806821
807 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
822 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
808823
809 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
824 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT
825 : __ptr_(__p.__ptr_) {}
810826
811 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); }
812 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
827 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __get_np()->__get_value(); }
828 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
813829 return pointer_traits<pointer>::pointer_to(__get_np()->__get_value());
814830 }
815831
816 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() {
817 __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
832 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator++() {
833 __ptr_ = std::__tree_next_iter<__end_node_pointer>(std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr_));
818834 return *this;
819835 }
820836
821 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator++(int) {
837 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator operator++(int) {
822838 __tree_const_iterator __t(*this);
823839 ++(*this);
824840 return __t;
825841 }
826842
827 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() {
828 __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
843 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator--() {
844 __ptr_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
829845 return *this;
830846 }
831847
832 _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator--(int) {
848 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator operator--(int) {
833849 __tree_const_iterator __t(*this);
834850 --(*this);
835851 return __t;
836852 }
837853
838 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
854 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
855 operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
839856 return __x.__ptr_ == __y.__ptr_;
840857 }
841 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
858 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
859 operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
842860 return !(__x == __y);
843861 }
844862
845863private:
846 _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
847 _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
848 _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
864 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT
865 : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
866 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT
867 : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
868 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const {
869 return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_);
870 }
849871
850872 template <class, class, class>
851873 friend class __tree;
852874
853875 template <class _NodeIter, class _Func, class _Proj>
854 friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&);
876 _LIBCPP_CONSTEXPR_SINCE_CXX26 friend void __tree_iterate_subrange(_NodeIter, _NodeIter, _Func&, _Proj&);
855877};
856878
857879#ifndef _LIBCPP_CXX03_LANG
......@@ -865,7 +887,8 @@ struct __specialized_algorithm<
865887 using __iterator _LIBCPP_NODEBUG = __tree_const_iterator<_Tp, _NodePtr, _DiffType>;
866888
867889 template <class _Func, class _Proj>
868 _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) {
890 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
891 operator()(__iterator __first, __iterator __last, _Func& __func, _Proj& __proj) {
869892 std::__tree_iterate_subrange(__first, __last, __func, __proj);
870893 }
871894};
......@@ -927,98 +950,114 @@ private:
927950 _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);
928951
929952public:
930 _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() _NOEXCEPT {
953 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer __end_node() _NOEXCEPT {
931954 return pointer_traits<__end_node_pointer>::pointer_to(__end_node_);
932955 }
933 _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() const _NOEXCEPT {
956 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer __end_node() const _NOEXCEPT {
934957 return pointer_traits<__end_node_pointer>::pointer_to(const_cast<__end_node_t&>(__end_node_));
935958 }
936 _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }
959 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_allocator& __node_alloc() _NOEXCEPT {
960 return __node_alloc_;
961 }
937962
938963private:
939 _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }
964 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const __node_allocator& __node_alloc() const _NOEXCEPT {
965 return __node_alloc_;
966 }
940967
941968public:
942 _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }
969 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type __alloc() const _NOEXCEPT {
970 return allocator_type(__node_alloc());
971 }
943972
944 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
945 _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; }
946 _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; }
973 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT { return __size_; }
974 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare& value_comp() _NOEXCEPT { return __value_comp_; }
975 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const value_compare& value_comp() const _NOEXCEPT {
976 return __value_comp_;
977 }
947978
948979public:
949 _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {
950 return static_cast<__node_pointer>(__end_node()->__left_);
980 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __root() const _NOEXCEPT {
981 return std::__static_fancy_pointer_cast<__node_pointer>(__end_node()->__left_);
951982 }
952983
953 _LIBCPP_HIDE_FROM_ABI __node_base_pointer* __root_ptr() const _NOEXCEPT {
984 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer* __root_ptr() const _NOEXCEPT {
954985 return std::addressof(__end_node()->__left_);
955986 }
956987
957988 using iterator = __tree_iterator<_Tp, __node_pointer, difference_type>;
958989 using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>;
959990
960 _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
991 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree(const value_compare& __comp) _NOEXCEPT_(
961992 is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
962993 : __size_(0), __value_comp_(__comp) {
963994 __begin_node_ = __end_node();
964995 }
965996
966 _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a)
997 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree(const allocator_type& __a)
967998 : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
968999 __begin_node_ = __end_node();
9691000 }
9701001
971 _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a)
1002 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const value_compare& __comp, const allocator_type& __a)
9721003 : __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
9731004 __begin_node_ = __end_node();
9741005 }
9751006
976 _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t);
1007 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const __tree& __t);
9771008
978 _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __other, const allocator_type& __alloc)
1009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const __tree& __other, const allocator_type& __alloc)
9791010 : __begin_node_(__end_node()), __node_alloc_(__alloc), __size_(0), __value_comp_(__other.value_comp()) {
9801011 if (__other.size() == 0)
9811012 return;
9821013
983 *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__other.__root()));
1014 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_construct_tree(__other.__root()));
9841015 __root()->__parent_ = __end_node();
985 __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
1016 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
9861017 __size_ = __other.size();
9871018 }
9881019
989 _LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t);
1020 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree& operator=(const __tree& __t);
9901021 template <class _ForwardIterator>
991 _LIBCPP_HIDE_FROM_ABI void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
992 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(
1022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1023 __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
1024 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(__tree&& __t) _NOEXCEPT_(
9931025 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);
994 _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);
1026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(__tree&& __t, const allocator_type& __a);
9951027
996 _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t)
1028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree& operator=(__tree&& __t)
9971029 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
9981030 ((__node_traits::propagate_on_container_move_assignment::value &&
9991031 is_nothrow_move_assignable<__node_allocator>::value) ||
10001032 allocator_traits<__node_allocator>::is_always_equal::value)) {
1001 __move_assign(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
1033 __move_assign(__t,
1034 integral_constant<bool,
1035 __node_traits::propagate_on_container_move_assignment::value ||
1036 __node_traits::is_always_equal::value>());
10021037 return *this;
10031038 }
10041039
1005 _LIBCPP_HIDE_FROM_ABI ~__tree() {
1040 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__tree() {
10061041 static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
10071042 destroy(__root());
10081043 }
10091044
1010 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
1011 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node_); }
1012 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_node()); }
1013 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_node()); }
1045 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
1046 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
1047 return const_iterator(__begin_node_);
1048 }
1049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT { return iterator(__end_node()); }
1050 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
1051 return const_iterator(__end_node());
1052 }
10141053
1015 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
1054 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
10161055 return std::min<size_type>(__node_traits::max_size(__node_alloc()), numeric_limits<difference_type >::max());
10171056 }
10181057
1019 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
1058 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT;
10201059
1021 _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t)
1060 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__tree& __t)
10221061#if _LIBCPP_STD_VER <= 11
10231062 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
10241063 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
......@@ -1027,21 +1066,22 @@ public:
10271066#endif
10281067
10291068 template <class... _Args>
1030 _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args);
1069 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_multi(_Args&&... __args);
10311070
10321071 template <class... _Args>
1033 _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
1072 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1073 __emplace_hint_multi(const_iterator __p, _Args&&... __args);
10341074
10351075 template <class... _Args>
1036 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) {
1076 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace_unique(_Args&&... __args) {
10371077 return std::__try_key_extraction<key_type>(
10381078 [this](const key_type& __key, _Args&&... __args2) {
10391079 auto [__parent, __child] = __find_equal(__key);
1040 __node_pointer __r = static_cast<__node_pointer>(__child);
1080 __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10411081 bool __inserted = false;
10421082 if (__child == nullptr) {
10431083 __node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
1044 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1084 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10451085 __r = __h.release();
10461086 __inserted = true;
10471087 }
......@@ -1050,10 +1090,10 @@ public:
10501090 [this](_Args&&... __args2) {
10511091 __node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
10521092 auto [__parent, __child] = __find_equal(__h->__get_value());
1053 __node_pointer __r = static_cast<__node_pointer>(__child);
1093 __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10541094 bool __inserted = false;
10551095 if (__child == nullptr) {
1056 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1096 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10571097 __r = __h.release();
10581098 __inserted = true;
10591099 }
......@@ -1063,16 +1103,17 @@ public:
10631103 }
10641104
10651105 template <class... _Args>
1066 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
1106 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1107 __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
10671108 return std::__try_key_extraction<key_type>(
10681109 [this, __p](const key_type& __key, _Args&&... __args2) {
10691110 __node_base_pointer __dummy;
10701111 auto [__parent, __child] = __find_equal(__p, __dummy, __key);
1071 __node_pointer __r = static_cast<__node_pointer>(__child);
1112 __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10721113 bool __inserted = false;
10731114 if (__child == nullptr) {
10741115 __node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
1075 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1116 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10761117 __r = __h.release();
10771118 __inserted = true;
10781119 }
......@@ -1082,9 +1123,9 @@ public:
10821123 __node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
10831124 __node_base_pointer __dummy;
10841125 auto [__parent, __child] = __find_equal(__p, __dummy, __h->__get_value());
1085 __node_pointer __r = static_cast<__node_pointer>(__child);
1126 __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
10861127 if (__child == nullptr) {
1087 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1128 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
10881129 __r = __h.release();
10891130 }
10901131 return pair<iterator, bool>(iterator(__r), __child == nullptr);
......@@ -1093,46 +1134,50 @@ public:
10931134 }
10941135
10951136 template <class _InIter, class _Sent>
1096 _LIBCPP_HIDE_FROM_ABI void __insert_range_multi(_InIter __first, _Sent __last) {
1137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_range_multi(_InIter __first, _Sent __last) {
10971138 if (__first == __last)
10981139 return;
10991140
11001141 if (__root() == nullptr) { // Make sure we always have a root node
1101 __insert_node_at(
1102 __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release()));
1142 __insert_node_at(__end_node(),
1143 __end_node()->__left_,
1144 std::__static_fancy_pointer_cast<__node_base_pointer>(__construct_node(*__first).release()));
11031145 ++__first;
11041146 }
11051147
1106 auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root())));
1148 auto __max_node = std::__static_fancy_pointer_cast<__node_pointer>(
1149 std::__tree_max(std::__static_fancy_pointer_cast<__node_base_pointer>(__root())));
11071150
11081151 for (; __first != __last; ++__first) {
11091152 __node_holder __nd = __construct_node(*__first);
11101153 // Always check the max node first. This optimizes for sorted ranges inserted at the end.
11111154 if (!value_comp()(__nd->__get_value(), __max_node->__get_value())) { // __node >= __max_val
1112 __insert_node_at(static_cast<__end_node_pointer>(__max_node),
1155 __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
11131156 __max_node->__right_,
1114 static_cast<__node_base_pointer>(__nd.get()));
1157 std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
11151158 __max_node = __nd.release();
11161159 } else {
11171160 __end_node_pointer __parent;
11181161 __node_base_pointer& __child = __find_leaf_high(__parent, __nd->__get_value());
1119 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
1162 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
11201163 }
11211164 }
11221165 }
11231166
11241167 template <class _InIter, class _Sent>
1125 _LIBCPP_HIDE_FROM_ABI void __insert_range_unique(_InIter __first, _Sent __last) {
1168 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_range_unique(_InIter __first, _Sent __last) {
11261169 if (__first == __last)
11271170 return;
11281171
11291172 if (__root() == nullptr) {
1130 __insert_node_at(
1131 __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release()));
1173 __insert_node_at(__end_node(),
1174 __end_node()->__left_,
1175 std::__static_fancy_pointer_cast<__node_base_pointer>(__construct_node(*__first).release()));
11321176 ++__first;
11331177 }
11341178
1135 auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root())));
1179 auto __max_node = std::__static_fancy_pointer_cast<__node_pointer>(
1180 std::__tree_max(std::__static_fancy_pointer_cast<__node_base_pointer>(__root())));
11361181
11371182 using __reference = decltype(*__first);
11381183
......@@ -1141,29 +1186,31 @@ public:
11411186 [this, &__max_node](const key_type& __key, __reference&& __val) {
11421187 if (value_comp()(__max_node->__get_value(), __key)) { // __key > __max_node
11431188 __node_holder __nd = __construct_node(std::forward<__reference>(__val));
1144 __insert_node_at(static_cast<__end_node_pointer>(__max_node),
1189 __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
11451190 __max_node->__right_,
1146 static_cast<__node_base_pointer>(__nd.get()));
1191 std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
11471192 __max_node = __nd.release();
11481193 } else {
11491194 auto [__parent, __child] = __find_equal(__key);
11501195 if (__child == nullptr) {
11511196 __node_holder __nd = __construct_node(std::forward<__reference>(__val));
1152 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
1197 __insert_node_at(
1198 __parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
11531199 }
11541200 }
11551201 },
11561202 [this, &__max_node](__reference&& __val) {
11571203 __node_holder __nd = __construct_node(std::forward<__reference>(__val));
11581204 if (value_comp()(__max_node->__get_value(), __nd->__get_value())) { // __node > __max_node
1159 __insert_node_at(static_cast<__end_node_pointer>(__max_node),
1205 __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
11601206 __max_node->__right_,
1161 static_cast<__node_base_pointer>(__nd.get()));
1207 std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
11621208 __max_node = __nd.release();
11631209 } else {
11641210 auto [__parent, __child] = __find_equal(__nd->__get_value());
11651211 if (__child == nullptr) {
1166 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
1212 __insert_node_at(
1213 __parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
11671214 }
11681215 }
11691216 },
......@@ -1171,62 +1218,67 @@ public:
11711218 }
11721219 }
11731220
1174 _LIBCPP_HIDE_FROM_ABI iterator __remove_node_pointer(__node_pointer) _NOEXCEPT;
1221 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __remove_node_pointer(__node_pointer) _NOEXCEPT;
11751222
11761223#if _LIBCPP_STD_VER >= 17
11771224 template <class _NodeHandle, class _InsertReturnType>
1178 _LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
1225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
11791226 template <class _NodeHandle>
1180 _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);
1227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1228 __node_handle_insert_unique(const_iterator, _NodeHandle&&);
11811229 template <class _Comp2>
1182 _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source);
1230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1231 __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source);
11831232
11841233 template <class _NodeHandle>
1185 _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&);
1234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __node_handle_insert_multi(_NodeHandle&&);
11861235 template <class _NodeHandle>
1187 _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);
1236 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1237 __node_handle_insert_multi(const_iterator, _NodeHandle&&);
11881238 template <class _Comp2>
1189 _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source);
1239 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1240 __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source);
11901241
11911242 template <class _NodeHandle>
1192 _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&);
1243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle __node_handle_extract(key_type const&);
11931244 template <class _NodeHandle>
1194 _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(const_iterator);
1245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle __node_handle_extract(const_iterator);
11951246#endif
11961247
1197 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
1198 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
1248 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p);
1249 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l);
11991250 template <class _Key>
1200 _LIBCPP_HIDE_FROM_ABI size_type __erase_unique(const _Key& __k);
1251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __erase_unique(const _Key& __k);
12011252 template <class _Key>
1202 _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k);
1253 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __erase_multi(const _Key& __k);
12031254
1204 _LIBCPP_HIDE_FROM_ABI void
1255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
12051256 __insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;
12061257
12071258 template <class _Key>
1208 _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __key) {
1209 auto [__, __match] = __find_equal(__key);
1259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Key& __key) {
1260 auto [__dummy, __match] = __find_equal(__key);
12101261 if (__match == nullptr)
12111262 return end();
1212 return iterator(static_cast<__node_pointer>(__match));
1263 return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
12131264 }
12141265
12151266 template <class _Key>
1216 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __key) const {
1217 auto [__, __match] = __find_equal(__key);
1267 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Key& __key) const {
1268 auto [__dummy, __match] = __find_equal(__key);
12181269 if (__match == nullptr)
12191270 return end();
1220 return const_iterator(static_cast<__node_pointer>(__match));
1271 return const_iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
12211272 }
12221273
12231274 template <class _Key>
1224 _LIBCPP_HIDE_FROM_ABI size_type __count_unique(const _Key& __k) const;
1275 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __count_unique(const _Key& __k) const;
12251276 template <class _Key>
1226 _LIBCPP_HIDE_FROM_ABI size_type __count_multi(const _Key& __k) const;
1277 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __count_multi(const _Key& __k) const;
12271278
12281279 template <bool _LowerBound, class _Key>
1229 _LIBCPP_HIDE_FROM_ABI __end_node_pointer __lower_upper_bound_unique_impl(const _Key& __v) const {
1280 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer
1281 __lower_upper_bound_unique_impl(const _Key& __v) const {
12301282 auto __rt = __root();
12311283 auto __result = __end_node();
12321284 auto __comp = __lazy_synth_three_way_comparator<_Compare, _Key, value_type>(value_comp());
......@@ -1234,14 +1286,15 @@ public:
12341286 auto __comp_res = __comp(__v, __rt->__get_value());
12351287
12361288 if (__comp_res.__less()) {
1237 __result = static_cast<__end_node_pointer>(__rt);
1238 __rt = static_cast<__node_pointer>(__rt->__left_);
1289 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
1290 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
12391291 } else if (__comp_res.__greater()) {
1240 __rt = static_cast<__node_pointer>(__rt->__right_);
1292 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
12411293 } else if _LIBCPP_CONSTEXPR (_LowerBound) {
1242 return static_cast<__end_node_pointer>(__rt);
1294 return std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
12431295 } else {
1244 return __rt->__right_ ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result;
1296 return __rt->__right_ ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
1297 : __result;
12451298 }
12461299 }
12471300 return __result;
......@@ -1282,7 +1335,7 @@ public:
12821335#endif // _LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND
12831336
12841337 template <class _Key>
1285 _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_unique(const _Key& __v) {
1338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __lower_bound_unique(const _Key& __v) {
12861339#if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND)
12871340 return iterator(__lower_bound_unique_compat_impl(__v));
12881341#else
......@@ -1291,7 +1344,7 @@ public:
12911344 }
12921345
12931346 template <class _Key>
1294 _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_unique(const _Key& __v) const {
1347 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __lower_bound_unique(const _Key& __v) const {
12951348#if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND)
12961349 return const_iterator(__lower_bound_unique_compat_impl(__v));
12971350#else
......@@ -1300,7 +1353,7 @@ public:
13001353 }
13011354
13021355 template <class _Key>
1303 _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_unique(const _Key& __v) {
1356 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __upper_bound_unique(const _Key& __v) {
13041357#if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND)
13051358 return iterator(__upper_bound_unique_compat_impl(__v));
13061359#else
......@@ -1309,7 +1362,7 @@ public:
13091362 }
13101363
13111364 template <class _Key>
1312 _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_unique(const _Key& __v) const {
1365 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __upper_bound_unique(const _Key& __v) const {
13131366#if defined(_LIBCPP_ENABLE_LEGACY_TREE_LOWER_UPPER_BOUND)
13141367 return iterator(__upper_bound_unique_compat_impl(__v));
13151368#else
......@@ -1319,117 +1372,138 @@ public:
13191372
13201373private:
13211374 template <class _Key>
1322 _LIBCPP_HIDE_FROM_ABI iterator
1375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
13231376 __lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
13241377
13251378 template <class _Key>
1326 _LIBCPP_HIDE_FROM_ABI const_iterator
1379 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
13271380 __lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
13281381
13291382public:
13301383 template <class _Key>
1331 _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_multi(const _Key& __v) {
1384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __lower_bound_multi(const _Key& __v) {
13321385 return __lower_bound_multi(__v, __root(), __end_node());
13331386 }
13341387 template <class _Key>
1335 _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_multi(const _Key& __v) const {
1388 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __lower_bound_multi(const _Key& __v) const {
13361389 return __lower_bound_multi(__v, __root(), __end_node());
13371390 }
13381391
13391392 template <class _Key>
1340 _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_multi(const _Key& __v) {
1393 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __upper_bound_multi(const _Key& __v) {
13411394 return __upper_bound_multi(__v, __root(), __end_node());
13421395 }
13431396
13441397 template <class _Key>
1345 _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_multi(const _Key& __v) const {
1398 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __upper_bound_multi(const _Key& __v) const {
13461399 return __upper_bound_multi(__v, __root(), __end_node());
13471400 }
13481401
13491402private:
13501403 template <class _Key>
1351 _LIBCPP_HIDE_FROM_ABI iterator
1404 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
13521405 __upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
13531406
13541407 template <class _Key>
1355 _LIBCPP_HIDE_FROM_ABI const_iterator
1408 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
13561409 __upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
13571410
13581411public:
13591412 template <class _Key>
1360 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k);
1413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> __equal_range_unique(const _Key& __k);
13611414 template <class _Key>
1362 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_unique(const _Key& __k) const;
1415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1416 __equal_range_unique(const _Key& __k) const;
13631417
13641418 template <class _Key>
1365 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_multi(const _Key& __k);
1419 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> __equal_range_multi(const _Key& __k);
13661420 template <class _Key>
1367 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;
1421 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1422 __equal_range_multi(const _Key& __k) const;
13681423
13691424 using _Dp _LIBCPP_NODEBUG = __tree_node_destructor<__node_allocator>;
13701425 using __node_holder _LIBCPP_NODEBUG = unique_ptr<__node, _Dp>;
13711426
1372 _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;
1427 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_holder remove(const_iterator __p) _NOEXCEPT;
13731428
13741429 // FIXME: Make this function const qualified. Unfortunately doing so
13751430 // breaks existing code which uses non-const callable comparators.
13761431 template <class _Key>
1377 _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v);
1432 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
1433 __find_equal(const _Key& __v);
13781434
13791435 template <class _Key>
1380 _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v) const {
1436 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
1437 __find_equal(const _Key& __v) const {
13811438 return const_cast<__tree*>(this)->__find_equal(__v);
13821439 }
13831440
13841441 template <class _Key>
1385 _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&>
1442 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
13861443 __find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v);
13871444
1388 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {
1445 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree& __t) {
13891446 __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());
13901447 }
13911448
1392 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t, true_type) {
1449 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree& __t, true_type) {
13931450 if (__node_alloc() != __t.__node_alloc())
13941451 clear();
13951452 __node_alloc() = __t.__node_alloc();
13961453 }
1397 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}
1454 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree&, false_type) {}
13981455
13991456private:
1400 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__end_node_pointer& __parent, const value_type& __v);
1457 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
1458 __find_leaf_low(__end_node_pointer& __parent, const value_type& __v);
14011459
1402 _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__end_node_pointer& __parent, const value_type& __v);
1460 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
1461 __find_leaf_high(__end_node_pointer& __parent, const value_type& __v);
14031462
1404 _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
1463 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
14051464 __find_leaf(const_iterator __hint, __end_node_pointer& __parent, const value_type& __v);
14061465
14071466 template <class... _Args>
1408 _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
1467 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_holder __construct_node(_Args&&... __args);
14091468
14101469 // TODO: Make this _LIBCPP_HIDE_FROM_ABI
1411 _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT { (__tree_deleter(__node_alloc_))(__nd); }
1470 _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX26 void destroy(__node_pointer __nd) _NOEXCEPT {
1471 (__tree_deleter(__node_alloc_))(__nd);
1472 }
14121473
1413 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
1414 _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
1474 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign(__tree& __t, false_type);
1475 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
14151476 is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);
14161477
1417 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t)
1478 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree& __t)
14181479 _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
14191480 is_nothrow_move_assignable<__node_allocator>::value) {
14201481 __move_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
14211482 }
14221483
1423 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t, true_type)
1484 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree& __t, true_type)
14241485 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
14251486 __node_alloc() = std::move(__t.__node_alloc());
14261487 }
1427 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
1488 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
14281489
14291490 template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
1430 _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
1491 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
1492 __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
14311493 using __key_type = __remove_const_t<typename value_type::first_type>;
14321494
1495#if _LIBCPP_STD_VER >= 26
1496 if constexpr (std::is_copy_constructible_v<decltype(__rhs.first)>) {
1497 // We need to replace the `const key_type` subobject by reconstruction during constant evaluation to avoid
1498 // undefined behavior. Currently, there is no constexpr-friend way to replacing a move-only key subobject.
1499 if consteval {
1500 std::destroy_at(std::addressof(__lhs));
1501 std::construct_at(std::addressof(__lhs), __rhs.first, std::forward<_From>(__rhs).second);
1502 return;
1503 }
1504 }
1505#endif
1506
14331507 // This is technically UB, since the object was constructed as `const`.
14341508 // Clang doesn't optimize on this currently though.
14351509 const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
......@@ -1437,7 +1511,7 @@ private:
14371511 }
14381512
14391513 template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
1440 _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
1514 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void __assign_value(_To& __lhs, _From&& __rhs) {
14411515 __lhs = std::forward<_From>(__rhs);
14421516 }
14431517
......@@ -1447,24 +1521,23 @@ private:
14471521 public:
14481522 using pointer = __node_pointer;
14491523
1450 _LIBCPP_HIDE_FROM_ABI __tree_deleter(__node_allocator& __alloc) : __alloc_(__alloc) {}
1524 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_deleter(__node_allocator& __alloc) : __alloc_(__alloc) {}
14511525
14521526#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
14531527 _LIBCPP_HIDE_FROM_ABI
14541528#endif
1455 void
1456 operator()(__node_pointer __ptr) {
1529 _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(__node_pointer __ptr) {
14571530 if (!__ptr)
14581531 return;
14591532
1460 (*this)(static_cast<__node_pointer>(__ptr->__left_));
1533 (*this)(std::__static_fancy_pointer_cast<__node_pointer>(__ptr->__left_));
14611534
14621535 auto __right = __ptr->__right_;
14631536
14641537 __node_traits::destroy(__alloc_, std::addressof(__ptr->__get_value()));
14651538 __node_traits::deallocate(__alloc_, __ptr, 1);
14661539
1467 (*this)(static_cast<__node_pointer>(__right));
1540 (*this)(std::__static_fancy_pointer_cast<__node_pointer>(__right));
14681541 }
14691542 };
14701543
......@@ -1476,41 +1549,54 @@ private:
14761549#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
14771550 _LIBCPP_HIDE_FROM_ABI
14781551#endif
1479 __node_pointer __construct_from_tree(__node_pointer __src, _NodeConstructor __construct) {
1552 _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer
1553 __construct_from_tree(__node_pointer __src, _NodeConstructor __construct) {
14801554 if (!__src)
14811555 return nullptr;
14821556
14831557 __node_holder __new_node = __construct(__src->__get_value());
14841558
14851559 unique_ptr<__node, __tree_deleter> __left(
1486 __construct_from_tree(static_cast<__node_pointer>(__src->__left_), __construct), __node_alloc_);
1487 __node_pointer __right = __construct_from_tree(static_cast<__node_pointer>(__src->__right_), __construct);
1560 __construct_from_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_), __construct),
1561 __node_alloc_);
1562 __node_pointer __right =
1563 __construct_from_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_), __construct);
14881564
14891565 __node_pointer __new_node_ptr = __new_node.release();
14901566
14911567 __new_node_ptr->__is_black_ = __src->__is_black_;
1492 __new_node_ptr->__left_ = static_cast<__node_base_pointer>(__left.release());
1493 __new_node_ptr->__right_ = static_cast<__node_base_pointer>(__right);
1568 __new_node_ptr->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__left.release());
1569 __new_node_ptr->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__right);
14941570 if (__new_node_ptr->__left_)
1495 __new_node_ptr->__left_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr);
1571 __new_node_ptr->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__new_node_ptr);
14961572 if (__new_node_ptr->__right_)
1497 __new_node_ptr->__right_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr);
1573 __new_node_ptr->__right_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__new_node_ptr);
14981574 return __new_node_ptr;
14991575 }
15001576
1501 _LIBCPP_HIDE_FROM_ABI __node_pointer __copy_construct_tree(__node_pointer __src) {
1577 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __copy_construct_tree(__node_pointer __src) {
15021578 return __construct_from_tree(__src, [this](const value_type& __val) { return __construct_node(__val); });
15031579 }
15041580
15051581 template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
1506 _LIBCPP_HIDE_FROM_ABI __node_pointer __move_construct_tree(__node_pointer __src) {
1582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __move_construct_tree(__node_pointer __src) {
15071583 return __construct_from_tree(__src, [this](value_type& __val) {
1584
1585#if _LIBCPP_STD_VER >= 26
1586 // We need to replace the `const key_type` subobject by reconstruction during constant evaluation to avoid
1587 // undefined behavior. Currently, there is no constexpr-friend way to replacing a move-only key subobject.
1588 if constexpr (std::is_copy_constructible_v<decltype(__val.first)>) {
1589 if consteval {
1590 return __construct_node(__val.first, std::move(__val.second));
1591 }
1592 }
1593#endif
15081594 return __construct_node(const_cast<key_type&&>(__val.first), std::move(__val.second));
15091595 });
15101596 }
15111597
15121598 template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
1513 _LIBCPP_HIDE_FROM_ABI __node_pointer __move_construct_tree(__node_pointer __src) {
1599 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __move_construct_tree(__node_pointer __src) {
15141600 return __construct_from_tree(__src, [this](value_type& __val) { return __construct_node(std::move(__val)); });
15151601 }
15161602
......@@ -1521,7 +1607,7 @@ private:
15211607#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
15221608 _LIBCPP_HIDE_FROM_ABI
15231609#endif
1524 __node_pointer __assign_from_tree(
1610 _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __assign_from_tree(
15251611 __node_pointer __dest, __node_pointer __src, _Assignment __assign, _ConstructionAlg __construct_subtree) {
15261612 if (!__src) {
15271613 destroy(__dest);
......@@ -1533,36 +1619,37 @@ private:
15331619
15341620 // If we already have a left node in the destination tree, reuse it and copy-assign recursively
15351621 if (__dest->__left_) {
1536 __dest->__left_ = static_cast<__node_base_pointer>(__assign_from_tree(
1537 static_cast<__node_pointer>(__dest->__left_),
1538 static_cast<__node_pointer>(__src->__left_),
1622 __dest->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__assign_from_tree(
1623 std::__static_fancy_pointer_cast<__node_pointer>(__dest->__left_),
1624 std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_),
15391625 __assign,
15401626 __construct_subtree));
15411627
15421628 // Otherwise, we must create new nodes; copy-construct from here on
15431629 } else if (__src->__left_) {
1544 auto __new_left = __construct_subtree(static_cast<__node_pointer>(__src->__left_));
1545 __dest->__left_ = static_cast<__node_base_pointer>(__new_left);
1546 __new_left->__parent_ = static_cast<__end_node_pointer>(__dest);
1630 auto __new_left = __construct_subtree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_));
1631 __dest->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__new_left);
1632 __new_left->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__dest);
15471633 }
15481634
15491635 // Identical to the left case above, just for the right nodes
15501636 if (__dest->__right_) {
1551 __dest->__right_ = static_cast<__node_base_pointer>(__assign_from_tree(
1552 static_cast<__node_pointer>(__dest->__right_),
1553 static_cast<__node_pointer>(__src->__right_),
1637 __dest->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__assign_from_tree(
1638 std::__static_fancy_pointer_cast<__node_pointer>(__dest->__right_),
1639 std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_),
15541640 __assign,
15551641 __construct_subtree));
15561642 } else if (__src->__right_) {
1557 auto __new_right = __construct_subtree(static_cast<__node_pointer>(__src->__right_));
1558 __dest->__right_ = static_cast<__node_base_pointer>(__new_right);
1559 __new_right->__parent_ = static_cast<__end_node_pointer>(__dest);
1643 auto __new_right = __construct_subtree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_));
1644 __dest->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__new_right);
1645 __new_right->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__dest);
15601646 }
15611647
15621648 return __dest;
15631649 }
15641650
1565 _LIBCPP_HIDE_FROM_ABI __node_pointer __copy_assign_tree(__node_pointer __dest, __node_pointer __src) {
1651 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer
1652 __copy_assign_tree(__node_pointer __dest, __node_pointer __src) {
15661653 return __assign_from_tree(
15671654 __dest,
15681655 __src,
......@@ -1570,7 +1657,8 @@ private:
15701657 [this](__node_pointer __nd) { return __copy_construct_tree(__nd); });
15711658 }
15721659
1573 _LIBCPP_HIDE_FROM_ABI __node_pointer __move_assign_tree(__node_pointer __dest, __node_pointer __src) {
1660 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer
1661 __move_assign_tree(__node_pointer __dest, __node_pointer __src) {
15741662 return __assign_from_tree(
15751663 __dest,
15761664 __src,
......@@ -1589,7 +1677,8 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<__tree<_Tp
15891677 using __node_pointer _LIBCPP_NODEBUG = typename __tree<_Tp, _Compare, _Allocator>::__node_pointer;
15901678
15911679 template <class _Tree, class _Func, class _Proj>
1592 _LIBCPP_HIDE_FROM_ABI static auto operator()(_Tree&& __range, _Func __func, _Proj __proj) {
1680 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto
1681 operator()(_Tree&& __range, _Func __func, _Proj __proj) {
15931682 if (__range.size() != 0)
15941683 std::__tree_iterate_from_root<__copy_cvref_t<_Tree, typename __remove_cvref_t<_Tree>::value_type>>(
15951684 [](__node_pointer) { return false; }, __range.__root(), __func, __proj);
......@@ -1599,7 +1688,8 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<__tree<_Tp
15991688#endif
16001689
16011690template <class _Tp, class _Compare, class _Allocator>
1602__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) {
1691_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>&
1692__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) {
16031693 if (this == std::addressof(__t))
16041694 return *this;
16051695
......@@ -1607,21 +1697,22 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
16071697 __copy_assign_alloc(__t);
16081698
16091699 if (__size_ != 0) {
1610 *__root_ptr() = static_cast<__node_base_pointer>(__copy_assign_tree(__root(), __t.__root()));
1700 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_assign_tree(__root(), __t.__root()));
16111701 } else {
1612 *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
1702 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
16131703 if (__root())
16141704 __root()->__parent_ = __end_node();
16151705 }
1616 __begin_node_ =
1617 __end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node();
1706 __begin_node_ = __end_node()->__left_
1707 ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_))
1708 : __end_node();
16181709 __size_ = __t.size();
16191710
16201711 return *this;
16211712}
16221713
16231714template <class _Tp, class _Compare, class _Allocator>
1624__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
1715_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
16251716 : __begin_node_(__end_node()),
16261717 __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
16271718 __size_(0),
......@@ -1629,14 +1720,14 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
16291720 if (__t.size() == 0)
16301721 return;
16311722
1632 *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
1723 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
16331724 __root()->__parent_ = __end_node();
1634 __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
1725 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
16351726 __size_ = __t.size();
16361727}
16371728
16381729template <class _Tp, class _Compare, class _Allocator>
1639__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
1730_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
16401731 is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value)
16411732 : __begin_node_(std::move(__t.__begin_node_)),
16421733 __end_node_(std::move(__t.__end_node_)),
......@@ -1646,7 +1737,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
16461737 if (__size_ == 0)
16471738 __begin_node_ = __end_node();
16481739 else {
1649 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1740 __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
16501741 __t.__begin_node_ = __t.__end_node();
16511742 __t.__end_node()->__left_ = nullptr;
16521743 __t.__size_ = 0;
......@@ -1654,7 +1745,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
16541745}
16551746
16561747template <class _Tp, class _Compare, class _Allocator>
1657__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
1748_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
16581749 : __begin_node_(__end_node()),
16591750 __node_alloc_(__node_allocator(__a)),
16601751 __size_(0),
......@@ -1664,24 +1755,24 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __
16641755 if (__a == __t.__alloc()) {
16651756 __begin_node_ = __t.__begin_node_;
16661757 __end_node()->__left_ = __t.__end_node()->__left_;
1667 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1758 __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
16681759 __size_ = __t.__size_;
16691760 __t.__begin_node_ = __t.__end_node();
16701761 __t.__end_node()->__left_ = nullptr;
16711762 __t.__size_ = 0;
16721763 } else {
1673 *__root_ptr() = static_cast<__node_base_pointer>(__move_construct_tree(__t.__root()));
1764 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__move_construct_tree(__t.__root()));
16741765 __root()->__parent_ = __end_node();
1675 __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
1766 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
16761767 __size_ = __t.size();
16771768 __t.clear(); // Ensure that __t is in a valid state after moving out the keys
16781769 }
16791770}
16801771
16811772template <class _Tp, class _Compare, class _Allocator>
1682void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
1773_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
16831774 _NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) {
1684 destroy(static_cast<__node_pointer>(__end_node()->__left_));
1775 destroy(std::__static_fancy_pointer_cast<__node_pointer>(__end_node()->__left_));
16851776 __begin_node_ = __t.__begin_node_;
16861777 __end_node_ = __t.__end_node_;
16871778 __move_assign_alloc(__t);
......@@ -1690,7 +1781,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
16901781 if (__size_ == 0)
16911782 __begin_node_ = __end_node();
16921783 else {
1693 __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
1784 __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
16941785 __t.__begin_node_ = __t.__end_node();
16951786 __t.__end_node()->__left_ = nullptr;
16961787 __t.__size_ = 0;
......@@ -1698,27 +1789,28 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
16981789}
16991790
17001791template <class _Tp, class _Compare, class _Allocator>
1701void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
1792_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
17021793 if (__node_alloc() == __t.__node_alloc()) {
17031794 __move_assign(__t, true_type());
17041795 } else {
17051796 value_comp() = std::move(__t.value_comp());
17061797 if (__size_ != 0) {
1707 *__root_ptr() = static_cast<__node_base_pointer>(__move_assign_tree(__root(), __t.__root()));
1798 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__move_assign_tree(__root(), __t.__root()));
17081799 } else {
1709 *__root_ptr() = static_cast<__node_base_pointer>(__move_construct_tree(__t.__root()));
1800 *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__move_construct_tree(__t.__root()));
17101801 if (__root())
17111802 __root()->__parent_ = __end_node();
17121803 }
1713 __begin_node_ =
1714 __end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node();
1804 __begin_node_ = __end_node()->__left_
1805 ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_))
1806 : __end_node();
17151807 __size_ = __t.size();
17161808 __t.clear(); // Ensure that __t is in a valid state after moving out the keys
17171809 }
17181810}
17191811
17201812template <class _Tp, class _Compare, class _Allocator>
1721void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
1813_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
17221814#if _LIBCPP_STD_VER <= 11
17231815 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
17241816 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
......@@ -1743,7 +1835,7 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
17431835}
17441836
17451837template <class _Tp, class _Compare, class _Allocator>
1746void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
1838_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
17471839 destroy(__root());
17481840 __size_ = 0;
17491841 __begin_node_ = __end_node();
......@@ -1754,23 +1846,23 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
17541846// Set __parent to parent of null leaf
17551847// Return reference to null leaf
17561848template <class _Tp, class _Compare, class _Allocator>
1757typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1849_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
17581850__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, const value_type& __v) {
17591851 __node_pointer __nd = __root();
17601852 if (__nd != nullptr) {
17611853 while (true) {
17621854 if (value_comp()(__nd->__get_value(), __v)) {
17631855 if (__nd->__right_ != nullptr)
1764 __nd = static_cast<__node_pointer>(__nd->__right_);
1856 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
17651857 else {
1766 __parent = static_cast<__end_node_pointer>(__nd);
1858 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
17671859 return __nd->__right_;
17681860 }
17691861 } else {
17701862 if (__nd->__left_ != nullptr)
1771 __nd = static_cast<__node_pointer>(__nd->__left_);
1863 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
17721864 else {
1773 __parent = static_cast<__end_node_pointer>(__nd);
1865 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
17741866 return __parent->__left_;
17751867 }
17761868 }
......@@ -1784,23 +1876,23 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent,
17841876// Set __parent to parent of null leaf
17851877// Return reference to null leaf
17861878template <class _Tp, class _Compare, class _Allocator>
1787typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1879_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
17881880__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent, const value_type& __v) {
17891881 __node_pointer __nd = __root();
17901882 if (__nd != nullptr) {
17911883 while (true) {
17921884 if (value_comp()(__v, __nd->__get_value())) {
17931885 if (__nd->__left_ != nullptr)
1794 __nd = static_cast<__node_pointer>(__nd->__left_);
1886 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
17951887 else {
1796 __parent = static_cast<__end_node_pointer>(__nd);
1888 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
17971889 return __parent->__left_;
17981890 }
17991891 } else {
18001892 if (__nd->__right_ != nullptr)
1801 __nd = static_cast<__node_pointer>(__nd->__right_);
1893 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
18021894 else {
1803 __parent = static_cast<__end_node_pointer>(__nd);
1895 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
18041896 return __nd->__right_;
18051897 }
18061898 }
......@@ -1817,7 +1909,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent
18171909// Set __parent to parent of null leaf
18181910// Return reference to null leaf
18191911template <class _Tp, class _Compare, class _Allocator>
1820typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf(
1912_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
1913__tree<_Tp, _Compare, _Allocator>::__find_leaf(
18211914 const_iterator __hint, __end_node_pointer& __parent, const value_type& __v) {
18221915 if (__hint == end() || !value_comp()(*__hint, __v)) // check before
18231916 {
......@@ -1826,11 +1919,11 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
18261919 if (__prior == begin() || !value_comp()(__v, *--__prior)) {
18271920 // *prev(__hint) <= __v <= *__hint
18281921 if (__hint.__ptr_->__left_ == nullptr) {
1829 __parent = static_cast<__end_node_pointer>(__hint.__ptr_);
1922 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__hint.__ptr_);
18301923 return __parent->__left_;
18311924 } else {
1832 __parent = static_cast<__end_node_pointer>(__prior.__ptr_);
1833 return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
1925 __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__prior.__ptr_);
1926 return std::__static_fancy_pointer_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
18341927 }
18351928 }
18361929 // __v < *prev(__hint)
......@@ -1845,8 +1938,9 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
18451938// If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf.
18461939template <class _Tp, class _Compare, class _Allocator>
18471940template <class _Key>
1848_LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
1849 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
1941_LIBCPP_HIDE_FROM_ABI
1942_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
1943 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
18501944__tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
18511945 using _Pair = pair<__end_node_pointer, __node_base_pointer&>;
18521946
......@@ -1858,27 +1952,27 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
18581952 }
18591953
18601954 __node_base_pointer* __node_ptr = __root_ptr();
1861 auto&& __transparent = std::__as_transparent<_Key>(value_comp());
1955 auto&& __transparent = std::__as_transparent<key_type>(value_comp());
18621956 auto __comp =
1863 __lazy_synth_three_way_comparator<__make_transparent_t<_Key, _Compare>, _Key, value_type>(__transparent);
1957 __lazy_synth_three_way_comparator<__make_transparent_t<key_type, _Compare>, _Key, value_type>(__transparent);
18641958
18651959 while (true) {
18661960 auto __comp_res = __comp(__v, __nd->__get_value());
18671961
18681962 if (__comp_res.__less()) {
18691963 if (__nd->__left_ == nullptr)
1870 return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__left_);
1964 return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), __nd->__left_);
18711965
18721966 __node_ptr = std::addressof(__nd->__left_);
1873 __nd = static_cast<__node_pointer>(__nd->__left_);
1967 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
18741968 } else if (__comp_res.__greater()) {
18751969 if (__nd->__right_ == nullptr)
1876 return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__right_);
1970 return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), __nd->__right_);
18771971
18781972 __node_ptr = std::addressof(__nd->__right_);
1879 __nd = static_cast<__node_pointer>(__nd->__right_);
1973 __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
18801974 } else {
1881 return _Pair(static_cast<__end_node_pointer>(__nd), *__node_ptr);
1975 return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), *__node_ptr);
18821976 }
18831977 }
18841978}
......@@ -1891,8 +1985,9 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
18911985// If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf.
18921986template <class _Tp, class _Compare, class _Allocator>
18931987template <class _Key>
1894_LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
1895 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
1988_LIBCPP_HIDE_FROM_ABI
1989_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
1990 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
18961991__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v) {
18971992 using _Pair = pair<__end_node_pointer, __node_base_pointer&>;
18981993
......@@ -1903,7 +1998,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
19031998 // *prev(__hint) < __v < *__hint
19041999 if (__hint.__ptr_->__left_ == nullptr)
19052000 return _Pair(__hint.__ptr_, __hint.__ptr_->__left_);
1906 return _Pair(__prior.__ptr_, static_cast<__node_pointer>(__prior.__ptr_)->__right_);
2001 return _Pair(__prior.__ptr_, std::__static_fancy_pointer_cast<__node_pointer>(__prior.__ptr_)->__right_);
19072002 }
19082003 // __v <= *prev(__hint)
19092004 return __find_equal(__v);
......@@ -1915,7 +2010,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
19152010 if (__next == end() || value_comp()(__v, *__next)) {
19162011 // *__hint < __v < *std::next(__hint)
19172012 if (__hint.__get_np()->__right_ == nullptr)
1918 return _Pair(__hint.__ptr_, static_cast<__node_pointer>(__hint.__ptr_)->__right_);
2013 return _Pair(__hint.__ptr_, std::__static_fancy_pointer_cast<__node_pointer>(__hint.__ptr_)->__right_);
19192014 return _Pair(__next.__ptr_, __next.__ptr_->__left_);
19202015 }
19212016 // *next(__hint) <= __v
......@@ -1923,12 +2018,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
19232018 }
19242019
19252020 // else __v == *__hint
1926 __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);
2021 __dummy = std::__static_fancy_pointer_cast<__node_base_pointer>(__hint.__ptr_);
19272022 return _Pair(__hint.__ptr_, __dummy);
19282023}
19292024
19302025template <class _Tp, class _Compare, class _Allocator>
1931void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
2026_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
19322027 __end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {
19332028 __new_node->__left_ = nullptr;
19342029 __new_node->__right_ = nullptr;
......@@ -1936,14 +2031,14 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
19362031 // __new_node->__is_black_ is initialized in __tree_balance_after_insert
19372032 __child = __new_node;
19382033 if (__begin_node_->__left_ != nullptr)
1939 __begin_node_ = static_cast<__end_node_pointer>(__begin_node_->__left_);
2034 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__begin_node_->__left_);
19402035 std::__tree_balance_after_insert(__end_node()->__left_, __child);
19412036 ++__size_;
19422037}
19432038
19442039template <class _Tp, class _Compare, class _Allocator>
19452040template <class... _Args>
1946typename __tree<_Tp, _Compare, _Allocator>::__node_holder
2041_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
19472042__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
19482043 __node_allocator& __na = __node_alloc();
19492044 __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
......@@ -1954,42 +2049,42 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
19542049
19552050template <class _Tp, class _Compare, class _Allocator>
19562051template <class... _Args>
1957typename __tree<_Tp, _Compare, _Allocator>::iterator
2052typename __tree<_Tp, _Compare, _Allocator>::iterator _LIBCPP_CONSTEXPR_SINCE_CXX26
19582053__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {
19592054 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
19602055 __end_node_pointer __parent;
19612056 __node_base_pointer& __child = __find_leaf_high(__parent, __h->__get_value());
1962 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1963 return iterator(static_cast<__node_pointer>(__h.release()));
2057 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
2058 return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__h.release()));
19642059}
19652060
19662061template <class _Tp, class _Compare, class _Allocator>
19672062template <class... _Args>
1968typename __tree<_Tp, _Compare, _Allocator>::iterator
2063typename __tree<_Tp, _Compare, _Allocator>::iterator _LIBCPP_CONSTEXPR_SINCE_CXX26
19692064__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) {
19702065 __node_holder __h = __construct_node(std::forward<_Args>(__args)...);
19712066 __end_node_pointer __parent;
19722067 __node_base_pointer& __child = __find_leaf(__p, __parent, __h->__get_value());
1973 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
1974 return iterator(static_cast<__node_pointer>(__h.release()));
2068 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
2069 return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__h.release()));
19752070}
19762071
19772072template <class _Tp, class _Compare, class _Allocator>
1978typename __tree<_Tp, _Compare, _Allocator>::iterator
2073typename __tree<_Tp, _Compare, _Allocator>::iterator _LIBCPP_CONSTEXPR_SINCE_CXX26
19792074__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT {
19802075 iterator __r(__ptr);
19812076 ++__r;
19822077 if (__begin_node_ == __ptr)
19832078 __begin_node_ = __r.__ptr_;
19842079 --__size_;
1985 std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__ptr));
2080 std::__tree_remove(__end_node()->__left_, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
19862081 return __r;
19872082}
19882083
19892084#if _LIBCPP_STD_VER >= 17
19902085template <class _Tp, class _Compare, class _Allocator>
19912086template <class _NodeHandle, class _InsertReturnType>
1992_LIBCPP_HIDE_FROM_ABI _InsertReturnType
2087_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _InsertReturnType
19932088__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __nh) {
19942089 if (__nh.empty())
19952090 return _InsertReturnType{end(), false, _NodeHandle()};
......@@ -1997,16 +2092,17 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n
19972092 __node_pointer __ptr = __nh.__ptr_;
19982093 auto [__parent, __child] = __find_equal(__ptr->__get_value());
19992094 if (__child != nullptr)
2000 return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)};
2095 return _InsertReturnType{
2096 iterator(std::__static_fancy_pointer_cast<__node_pointer>(__child)), false, std::move(__nh)};
20012097
2002 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2098 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
20032099 __nh.__release_ptr();
20042100 return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};
20052101}
20062102
20072103template <class _Tp, class _Compare, class _Allocator>
20082104template <class _NodeHandle>
2009_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
2105_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
20102106__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __hint, _NodeHandle&& __nh) {
20112107 if (__nh.empty())
20122108 return end();
......@@ -2014,9 +2110,9 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
20142110 __node_pointer __ptr = __nh.__ptr_;
20152111 __node_base_pointer __dummy;
20162112 auto [__parent, __child] = __find_equal(__hint, __dummy, __ptr->__get_value());
2017 __node_pointer __r = static_cast<__node_pointer>(__child);
2113 __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
20182114 if (__child == nullptr) {
2019 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2115 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
20202116 __r = __ptr;
20212117 __nh.__release_ptr();
20222118 }
......@@ -2025,7 +2121,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
20252121
20262122template <class _Tp, class _Compare, class _Allocator>
20272123template <class _NodeHandle>
2028_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) {
2124_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle
2125__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) {
20292126 iterator __it = __lower_bound_multi(__key);
20302127 if (__it == end() || __value_comp_(__key, *__it))
20312128 return _NodeHandle();
......@@ -2034,7 +2131,8 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand
20342131
20352132template <class _Tp, class _Compare, class _Allocator>
20362133template <class _NodeHandle>
2037_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) {
2134_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle
2135__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) {
20382136 __node_pointer __np = __p.__get_np();
20392137 __remove_node_pointer(__np);
20402138 return _NodeHandle(__np, __alloc());
......@@ -2042,7 +2140,7 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand
20422140
20432141template <class _Tp, class _Compare, class _Allocator>
20442142template <class _Comp2>
2045_LIBCPP_HIDE_FROM_ABI void
2143_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
20462144__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source) {
20472145 for (iterator __i = __source.begin(); __i != __source.end();) {
20482146 __node_pointer __src_ptr = __i.__get_np();
......@@ -2051,27 +2149,27 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2
20512149 if (__child != nullptr)
20522150 continue;
20532151 __source.__remove_node_pointer(__src_ptr);
2054 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));
2152 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__src_ptr));
20552153 }
20562154}
20572155
20582156template <class _Tp, class _Compare, class _Allocator>
20592157template <class _NodeHandle>
2060_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
2158_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
20612159__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh) {
20622160 if (__nh.empty())
20632161 return end();
20642162 __node_pointer __ptr = __nh.__ptr_;
20652163 __end_node_pointer __parent;
20662164 __node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__get_value());
2067 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2165 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
20682166 __nh.__release_ptr();
20692167 return iterator(__ptr);
20702168}
20712169
20722170template <class _Tp, class _Compare, class _Allocator>
20732171template <class _NodeHandle>
2074_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
2172_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
20752173__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh) {
20762174 if (__nh.empty())
20772175 return end();
......@@ -2079,14 +2177,14 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h
20792177 __node_pointer __ptr = __nh.__ptr_;
20802178 __end_node_pointer __parent;
20812179 __node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__get_value());
2082 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
2180 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
20832181 __nh.__release_ptr();
20842182 return iterator(__ptr);
20852183}
20862184
20872185template <class _Tp, class _Compare, class _Allocator>
20882186template <class _Comp2>
2089_LIBCPP_HIDE_FROM_ABI void
2187_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
20902188__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source) {
20912189 for (iterator __i = __source.begin(); __i != __source.end();) {
20922190 __node_pointer __src_ptr = __i.__get_np();
......@@ -2094,14 +2192,14 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2,
20942192 __node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__get_value());
20952193 ++__i;
20962194 __source.__remove_node_pointer(__src_ptr);
2097 __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));
2195 __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__src_ptr));
20982196 }
20992197}
2100
21012198#endif // _LIBCPP_STD_VER >= 17
21022199
21032200template <class _Tp, class _Compare, class _Allocator>
2104typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) {
2201_LIBCPP_CONSTEXPR_SINCE_CXX26
2202 typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) {
21052203 __node_pointer __np = __p.__get_np();
21062204 iterator __r = __remove_node_pointer(__np);
21072205 __node_allocator& __na = __node_alloc();
......@@ -2111,7 +2209,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo
21112209}
21122210
21132211template <class _Tp, class _Compare, class _Allocator>
2114typename __tree<_Tp, _Compare, _Allocator>::iterator
2212_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
21152213__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) {
21162214 while (__f != __l)
21172215 __f = erase(__f);
......@@ -2120,7 +2218,7 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l)
21202218
21212219template <class _Tp, class _Compare, class _Allocator>
21222220template <class _Key>
2123typename __tree<_Tp, _Compare, _Allocator>::size_type
2221_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
21242222__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {
21252223 iterator __i = find(__k);
21262224 if (__i == end())
......@@ -2131,7 +2229,7 @@ __tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {
21312229
21322230template <class _Tp, class _Compare, class _Allocator>
21332231template <class _Key>
2134typename __tree<_Tp, _Compare, _Allocator>::size_type
2232_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
21352233__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {
21362234 pair<iterator, iterator> __p = __equal_range_multi(__k);
21372235 size_type __r = 0;
......@@ -2142,16 +2240,16 @@ __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {
21422240
21432241template <class _Tp, class _Compare, class _Allocator>
21442242template <class _Key>
2145typename __tree<_Tp, _Compare, _Allocator>::size_type
2243_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
21462244__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {
21472245 __node_pointer __rt = __root();
21482246 auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp());
21492247 while (__rt != nullptr) {
21502248 auto __comp_res = __comp(__k, __rt->__get_value());
21512249 if (__comp_res.__less()) {
2152 __rt = static_cast<__node_pointer>(__rt->__left_);
2250 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
21532251 } else if (__comp_res.__greater())
2154 __rt = static_cast<__node_pointer>(__rt->__right_);
2252 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
21552253 else
21562254 return 1;
21572255 }
......@@ -2160,7 +2258,7 @@ __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {
21602258
21612259template <class _Tp, class _Compare, class _Allocator>
21622260template <class _Key>
2163typename __tree<_Tp, _Compare, _Allocator>::size_type
2261_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
21642262__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
21652263 __end_node_pointer __result = __end_node();
21662264 __node_pointer __rt = __root();
......@@ -2168,78 +2266,85 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
21682266 while (__rt != nullptr) {
21692267 auto __comp_res = __comp(__k, __rt->__get_value());
21702268 if (__comp_res.__less()) {
2171 __result = static_cast<__end_node_pointer>(__rt);
2172 __rt = static_cast<__node_pointer>(__rt->__left_);
2269 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
2270 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
21732271 } else if (__comp_res.__greater())
2174 __rt = static_cast<__node_pointer>(__rt->__right_);
2272 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
21752273 else
21762274 return std::distance(
2177 __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2178 __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2275 __lower_bound_multi(__k,
2276 std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
2277 std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
2278 __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
21792279 }
21802280 return 0;
21812281}
21822282
21832283template <class _Tp, class _Compare, class _Allocator>
21842284template <class _Key>
2185typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
2285_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
2286__tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
21862287 const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
21872288 while (__root != nullptr) {
21882289 if (!value_comp()(__root->__get_value(), __v)) {
2189 __result = static_cast<__end_node_pointer>(__root);
2190 __root = static_cast<__node_pointer>(__root->__left_);
2290 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
2291 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
21912292 } else
2192 __root = static_cast<__node_pointer>(__root->__right_);
2293 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
21932294 }
21942295 return iterator(__result);
21952296}
21962297
21972298template <class _Tp, class _Compare, class _Allocator>
21982299template <class _Key>
2199typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
2300_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
2301__tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
22002302 const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
22012303 while (__root != nullptr) {
22022304 if (!value_comp()(__root->__get_value(), __v)) {
2203 __result = static_cast<__end_node_pointer>(__root);
2204 __root = static_cast<__node_pointer>(__root->__left_);
2305 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
2306 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
22052307 } else
2206 __root = static_cast<__node_pointer>(__root->__right_);
2308 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
22072309 }
22082310 return const_iterator(__result);
22092311}
22102312
22112313template <class _Tp, class _Compare, class _Allocator>
22122314template <class _Key>
2213typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
2315_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
2316__tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
22142317 const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
22152318 while (__root != nullptr) {
22162319 if (value_comp()(__v, __root->__get_value())) {
2217 __result = static_cast<__end_node_pointer>(__root);
2218 __root = static_cast<__node_pointer>(__root->__left_);
2320 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
2321 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
22192322 } else
2220 __root = static_cast<__node_pointer>(__root->__right_);
2323 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
22212324 }
22222325 return iterator(__result);
22232326}
22242327
22252328template <class _Tp, class _Compare, class _Allocator>
22262329template <class _Key>
2227typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
2330_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
2331__tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
22282332 const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
22292333 while (__root != nullptr) {
22302334 if (value_comp()(__v, __root->__get_value())) {
2231 __result = static_cast<__end_node_pointer>(__root);
2232 __root = static_cast<__node_pointer>(__root->__left_);
2335 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
2336 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
22332337 } else
2234 __root = static_cast<__node_pointer>(__root->__right_);
2338 __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
22352339 }
22362340 return const_iterator(__result);
22372341}
22382342
22392343template <class _Tp, class _Compare, class _Allocator>
22402344template <class _Key>
2241pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2242__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
2345_LIBCPP_CONSTEXPR_SINCE_CXX26
2346 pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2347 __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
22432348 using _Pp = pair<iterator, iterator>;
22442349 __end_node_pointer __result = __end_node();
22452350 __node_pointer __rt = __root();
......@@ -2247,22 +2352,23 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
22472352 while (__rt != nullptr) {
22482353 auto __comp_res = __comp(__k, __rt->__get_value());
22492354 if (__comp_res.__less()) {
2250 __result = static_cast<__end_node_pointer>(__rt);
2251 __rt = static_cast<__node_pointer>(__rt->__left_);
2355 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
2356 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
22522357 } else if (__comp_res.__greater())
2253 __rt = static_cast<__node_pointer>(__rt->__right_);
2358 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
22542359 else
22552360 return _Pp(iterator(__rt),
2256 iterator(__rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
2257 : __result));
2361 iterator(__rt->__right_ != nullptr
2362 ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
2363 : __result));
22582364 }
22592365 return _Pp(iterator(__result), iterator(__result));
22602366}
22612367
22622368template <class _Tp, class _Compare, class _Allocator>
22632369template <class _Key>
2264pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2265 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
2370_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2371 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
22662372__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
22672373 using _Pp = pair<const_iterator, const_iterator>;
22682374 __end_node_pointer __result = __end_node();
......@@ -2271,23 +2377,25 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
22712377 while (__rt != nullptr) {
22722378 auto __comp_res = __comp(__k, __rt->__get_value());
22732379 if (__comp_res.__less()) {
2274 __result = static_cast<__end_node_pointer>(__rt);
2275 __rt = static_cast<__node_pointer>(__rt->__left_);
2380 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
2381 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
22762382 } else if (__comp_res.__greater())
2277 __rt = static_cast<__node_pointer>(__rt->__right_);
2383 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
22782384 else
22792385 return _Pp(
22802386 const_iterator(__rt),
2281 const_iterator(
2282 __rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result));
2387 const_iterator(__rt->__right_ != nullptr
2388 ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
2389 : __result));
22832390 }
22842391 return _Pp(const_iterator(__result), const_iterator(__result));
22852392}
22862393
22872394template <class _Tp, class _Compare, class _Allocator>
22882395template <class _Key>
2289pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2290__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
2396_LIBCPP_CONSTEXPR_SINCE_CXX26
2397 pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
2398 __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
22912399 using _Pp = pair<iterator, iterator>;
22922400 __end_node_pointer __result = __end_node();
22932401 __node_pointer __rt = __root();
......@@ -2295,22 +2403,23 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
22952403 while (__rt != nullptr) {
22962404 auto __comp_res = __comp(__k, __rt->__get_value());
22972405 if (__comp_res.__less()) {
2298 __result = static_cast<__end_node_pointer>(__rt);
2299 __rt = static_cast<__node_pointer>(__rt->__left_);
2406 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
2407 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
23002408 } else if (__comp_res.__greater())
2301 __rt = static_cast<__node_pointer>(__rt->__right_);
2409 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
23022410 else
2303 return _Pp(
2304 __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2305 __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2411 return _Pp(__lower_bound_multi(__k,
2412 std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
2413 std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
2414 __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
23062415 }
23072416 return _Pp(iterator(__result), iterator(__result));
23082417}
23092418
23102419template <class _Tp, class _Compare, class _Allocator>
23112420template <class _Key>
2312pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2313 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
2421_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2422 typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
23142423__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
23152424 using _Pp = pair<const_iterator, const_iterator>;
23162425 __end_node_pointer __result = __end_node();
......@@ -2319,35 +2428,37 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
23192428 while (__rt != nullptr) {
23202429 auto __comp_res = __comp(__k, __rt->__get_value());
23212430 if (__comp_res.__less()) {
2322 __result = static_cast<__end_node_pointer>(__rt);
2323 __rt = static_cast<__node_pointer>(__rt->__left_);
2431 __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
2432 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
23242433 } else if (__comp_res.__greater())
2325 __rt = static_cast<__node_pointer>(__rt->__right_);
2434 __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
23262435 else
2327 return _Pp(
2328 __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
2329 __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
2436 return _Pp(__lower_bound_multi(__k,
2437 std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
2438 std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
2439 __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
23302440 }
23312441 return _Pp(const_iterator(__result), const_iterator(__result));
23322442}
23332443
23342444template <class _Tp, class _Compare, class _Allocator>
2335typename __tree<_Tp, _Compare, _Allocator>::__node_holder
2445_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
23362446__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT {
23372447 __node_pointer __np = __p.__get_np();
23382448 if (__begin_node_ == __p.__ptr_) {
23392449 if (__np->__right_ != nullptr)
2340 __begin_node_ = static_cast<__end_node_pointer>(__np->__right_);
2450 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__np->__right_);
23412451 else
2342 __begin_node_ = static_cast<__end_node_pointer>(__np->__parent_);
2452 __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__np->__parent_);
23432453 }
23442454 --__size_;
2345 std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np));
2455 std::__tree_remove(__end_node()->__left_, std::__static_fancy_pointer_cast<__node_base_pointer>(__np));
23462456 return __node_holder(__np, _Dp(__node_alloc(), true));
23472457}
23482458
23492459template <class _Tp, class _Compare, class _Allocator>
2350inline _LIBCPP_HIDE_FROM_ABI void swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y)
2460inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
2461swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y)
23512462 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
23522463 __x.swap(__y);
23532464}
lib/libcxx/include/__tuple/make_tuple_types.h deleted-80
......@@ -1,80 +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___TUPLE_MAKE_TUPLE_TYPES_H
10#define _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__fwd/array.h>
15#include <__fwd/tuple.h>
16#include <__tuple/tuple_element.h>
17#include <__tuple/tuple_indices.h>
18#include <__tuple/tuple_size.h>
19#include <__tuple/tuple_types.h>
20#include <__type_traits/copy_cvref.h>
21#include <__type_traits/remove_cvref.h>
22#include <__type_traits/remove_reference.h>
23
24#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
25# pragma GCC system_header
26#endif
27
28#ifndef _LIBCPP_CXX03_LANG
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32// __make_tuple_types<_Tuple<_Types...>, _Ep, _Sp>::type is a
33// __tuple_types<_Types...> using only those _Types in the range [_Sp, _Ep).
34// _Sp defaults to 0 and _Ep defaults to tuple_size<_Tuple>. If _Tuple is a
35// lvalue_reference type, then __tuple_types<_Types&...> is the result.
36
37template <class _TupleTypes, class _TupleIndices>
38struct __make_tuple_types_flat;
39
40template <template <class...> class _Tuple, class... _Types, size_t... _Idx>
41struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
42 // Specialization for pair, tuple, and __tuple_types
43 template <class _Tp>
44 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __type_pack_element<_Idx, _Types...>>...>;
45};
46
47template <class _Vt, size_t _Np, size_t... _Idx>
48struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
49 template <size_t>
50 using __value_type _LIBCPP_NODEBUG = _Vt;
51 template <class _Tp>
52 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>;
53};
54
55template <class _Tp,
56 size_t _Ep = tuple_size<__libcpp_remove_reference_t<_Tp> >::value,
57 size_t _Sp = 0,
58 bool _SameSize = (_Ep == tuple_size<__libcpp_remove_reference_t<_Tp> >::value)>
59struct __make_tuple_types {
60 static_assert(_Sp <= _Ep, "__make_tuple_types input error");
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>;
63 using type _LIBCPP_NODEBUG = typename _Maker::template __apply_quals<_Tp>;
64};
65
66template <class... _Types, size_t _Ep>
67struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
68 using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
69};
70
71template <class... _Types, size_t _Ep>
72struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
73 using type _LIBCPP_NODEBUG = __tuple_types<_Types...>;
74};
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP_CXX03_LANG
79
80#endif // _LIBCPP___TUPLE_MAKE_TUPLE_TYPES_H
lib/libcxx/include/__tuple/sfinae_helpers.h+6-5
......@@ -15,10 +15,10 @@
1515# pragma GCC system_header
1616#endif
1717
18_LIBCPP_BEGIN_NAMESPACE_STD
19
2018#ifndef _LIBCPP_CXX03_LANG
2119
20_LIBCPP_BEGIN_NAMESPACE_STD
21
2222struct __check_tuple_constructor_fail {
2323 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() { return false; }
2424 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() { return false; }
......@@ -35,9 +35,8 @@ struct __check_tuple_constructor_fail {
3535 return false;
3636 }
3737};
38#endif // !defined(_LIBCPP_CXX03_LANG)
3938
40#if _LIBCPP_STD_VER >= 17
39# if _LIBCPP_STD_VER >= 17
4140
4241template <bool _CanCopy, bool _CanMove>
4342struct __sfinae_ctor_base {};
......@@ -92,8 +91,10 @@ struct __sfinae_assign_base<false, true> {
9291 __sfinae_assign_base& operator=(__sfinae_assign_base const&) = delete;
9392 __sfinae_assign_base& operator=(__sfinae_assign_base&&) = default;
9493};
95#endif // _LIBCPP_STD_VER >= 17
94# endif // _LIBCPP_STD_VER >= 17
9695
9796_LIBCPP_END_NAMESPACE_STD
9897
98#endif // !defined(_LIBCPP_CXX03_LANG)
99
99100#endif // _LIBCPP___TUPLE_SFINAE_HELPERS_H
lib/libcxx/include/__tuple/tuple_indices.h deleted-37
......@@ -1,37 +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___TUPLE_MAKE_TUPLE_INDICES_H
10#define _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__utility/integer_sequence.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#ifndef _LIBCPP_CXX03_LANG
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <size_t...>
25struct __tuple_indices {};
26
27template <size_t _Ep, size_t _Sp = 0>
28struct __make_tuple_indices {
29 static_assert(_Sp <= _Ep, "__make_tuple_indices input error");
30 typedef __make_indices_imp<_Ep, _Sp> type;
31};
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP_CXX03_LANG
36
37#endif // _LIBCPP___TUPLE_MAKE_TUPLE_INDICES_H
lib/libcxx/include/__tuple/tuple_like.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 20
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626template <class _Tp>
2727inline constexpr bool __is_ranges_subrange_v = false;
2828
......@@ -35,8 +35,8 @@ concept __tuple_like = __tuple_like_no_subrange<_Tp> || __is_ranges_subrange_v<r
3535// As of writing this comment every use of `pair-like` in the standard excludes `ranges::subrange`, so
3636// you most likely want to use `__pair_like_no_subrange` if you're looking for `pair-like`.
3737
38#endif // _LIBCPP_STD_VER >= 20
39
4038_LIBCPP_END_NAMESPACE_STD
4139
40#endif // _LIBCPP_STD_VER >= 20
41
4242#endif // _LIBCPP___TUPLE_TUPLE_LIKE_H
lib/libcxx/include/__tuple/tuple_like_ext.h deleted-52
......@@ -1,52 +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___TUPLE_TUPLE_LIKE_EXT_H
10#define _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__fwd/array.h>
15#include <__fwd/pair.h>
16#include <__fwd/tuple.h>
17#include <__tuple/tuple_types.h>
18#include <__type_traits/integral_constant.h>
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 _Tp>
27struct __tuple_like_ext : false_type {};
28
29template <class _Tp>
30struct __tuple_like_ext<const _Tp> : public __tuple_like_ext<_Tp> {};
31template <class _Tp>
32struct __tuple_like_ext<volatile _Tp> : public __tuple_like_ext<_Tp> {};
33template <class _Tp>
34struct __tuple_like_ext<const volatile _Tp> : public __tuple_like_ext<_Tp> {};
35
36#ifndef _LIBCPP_CXX03_LANG
37template <class... _Tp>
38struct __tuple_like_ext<tuple<_Tp...> > : true_type {};
39#endif
40
41template <class _T1, class _T2>
42struct __tuple_like_ext<pair<_T1, _T2> > : true_type {};
43
44template <class _Tp, size_t _Size>
45struct __tuple_like_ext<array<_Tp, _Size> > : true_type {};
46
47template <class... _Tp>
48struct __tuple_like_ext<__tuple_types<_Tp...> > : true_type {};
49
50_LIBCPP_END_NAMESPACE_STD
51
52#endif // _LIBCPP___TUPLE_TUPLE_LIKE_EXT_H
lib/libcxx/include/__tuple/tuple_like_no_subrange.h+4-4
......@@ -22,10 +22,10 @@
2222# pragma GCC system_header
2323#endif
2424
25_LIBCPP_BEGIN_NAMESPACE_STD
26
2725#if _LIBCPP_STD_VER >= 20
2826
27_LIBCPP_BEGIN_NAMESPACE_STD
28
2929template <class _Tp>
3030inline constexpr bool __tuple_like_no_subrange_impl = false;
3131
......@@ -54,8 +54,8 @@ concept __tuple_like_no_subrange = __tuple_like_no_subrange_impl<remove_cvref_t<
5454template <class _Tp>
5555concept __pair_like_no_subrange = __tuple_like_no_subrange<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
5656
57#endif // _LIBCPP_STD_VER >= 20
58
5957_LIBCPP_END_NAMESPACE_STD
6058
59#endif // _LIBCPP_STD_VER >= 20
60
6161#endif // _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
lib/libcxx/include/__tuple/tuple_types.h deleted-25
......@@ -1,25 +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___TUPLE_TUPLE_TYPES_H
10#define _LIBCPP___TUPLE_TUPLE_TYPES_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 __tuple_types {};
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___TUPLE_TUPLE_TYPES_H
lib/libcxx/include/__type_traits/add_pointer.h+3-28
......@@ -10,9 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H
1111
1212#include <__config>
13#include <__type_traits/is_referenceable.h>
14#include <__type_traits/is_void.h>
15#include <__type_traits/remove_reference.h>
1613
1714#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1815# pragma GCC system_header
......@@ -20,40 +17,18 @@
2017
2118_LIBCPP_BEGIN_NAMESPACE_STD
2219
23#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS)
24
2520template <class _Tp>
2621struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
2722 using type _LIBCPP_NODEBUG = __add_pointer(_Tp);
2823};
2924
30# ifdef _LIBCPP_COMPILER_GCC
25#ifdef _LIBCPP_COMPILER_GCC
3126template <class _Tp>
3227using __add_pointer_t _LIBCPP_NODEBUG = typename add_pointer<_Tp>::type;
33# else
34template <class _Tp>
35using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
36# endif
37
3828#else
39template <class _Tp, bool = __is_referenceable_v<_Tp> || is_void<_Tp>::value>
40struct __add_pointer_impl {
41 using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*;
42};
43template <class _Tp>
44struct __add_pointer_impl<_Tp, false> {
45 using type _LIBCPP_NODEBUG = _Tp;
46};
47
4829template <class _Tp>
49using __add_pointer_t = typename __add_pointer_impl<_Tp>::type;
50
51template <class _Tp>
52struct _LIBCPP_NO_SPECIALIZATIONS add_pointer {
53 using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>;
54};
55
56#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS)
30using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp);
31#endif
5732
5833#if _LIBCPP_STD_VER >= 14
5934template <class _Tp>
lib/libcxx/include/__type_traits/aligned_union.h+10-13
......@@ -19,25 +19,22 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22template <size_t _I0, size_t... _In>
23struct __static_max;
24
25template <size_t _I0>
26struct __static_max<_I0> {
27 static const size_t value = _I0;
22template <class _Arg0, class... _Args>
23union __union {
24 _ALIGNAS(_LIBCPP_PREFERRED_ALIGNOF(_Arg0)) _Arg0 __arg;
25 __union<_Args...> __u;
2826};
2927
30template <size_t _I0, size_t _I1, size_t... _In>
31struct __static_max<_I0, _I1, _In...> {
32 static const size_t value = _I0 >= _I1 ? __static_max<_I0, _In...>::value : __static_max<_I1, _In...>::value;
28template <class _Arg>
29union __union<_Arg> {
30 _ALIGNAS(_LIBCPP_PREFERRED_ALIGNOF(_Arg)) _Arg __arg;
3331};
3432
3533template <size_t _Len, class _Type0, class... _Types>
3634struct _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_NO_SPECIALIZATIONS aligned_union {
37 static const size_t alignment_value =
38 __static_max<_LIBCPP_PREFERRED_ALIGNOF(_Type0), _LIBCPP_PREFERRED_ALIGNOF(_Types)...>::value;
39 static const size_t __len = __static_max<_Len, sizeof(_Type0), sizeof(_Types)...>::value;
40 typedef typename aligned_storage<__len, alignment_value>::type type;
35 using _Union _LIBCPP_NODEBUG = __union<char[_Len], _Type0, _Types...>;
36 static const size_t alignment_value = _LIBCPP_ALIGNOF(_Union);
37 using type _LIBCPP_NODEBUG = typename aligned_storage<sizeof(_Union), alignment_value>::type;
4138};
4239
4340#if _LIBCPP_STD_VER >= 14
lib/libcxx/include/__type_traits/can_extract_key.h deleted-53
......@@ -1,53 +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_CAN_EXTRACT_KEY_H
10#define _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
11
12#include <__config>
13#include <__fwd/pair.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_same.h>
17#include <__type_traits/remove_const.h>
18#include <__type_traits/remove_const_ref.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26// These traits are used in __tree and __hash_table
27struct __extract_key_fail_tag {};
28struct __extract_key_self_tag {};
29struct __extract_key_first_tag {};
30
31template <class _ValTy, class _Key, class _RawValTy = __remove_const_ref_t<_ValTy> >
32struct __can_extract_key
33 : __conditional_t<_IsSame<_RawValTy, _Key>::value, __extract_key_self_tag, __extract_key_fail_tag> {};
34
35template <class _Pair, class _Key, class _First, class _Second>
36struct __can_extract_key<_Pair, _Key, pair<_First, _Second> >
37 : __conditional_t<_IsSame<__remove_const_t<_First>, _Key>::value, __extract_key_first_tag, __extract_key_fail_tag> {
38};
39
40// __can_extract_map_key uses true_type/false_type instead of the tags.
41// It returns true if _Key != _ContainerValueTy (the container is a map not a set)
42// and _ValTy == _Key.
43template <class _ValTy, class _Key, class _ContainerValueTy, class _RawValTy = __remove_const_ref_t<_ValTy> >
44struct __can_extract_map_key : integral_constant<bool, _IsSame<_RawValTy, _Key>::value> {};
45
46// This specialization returns __extract_key_fail_tag for non-map containers
47// because _Key == _ContainerValueTy
48template <class _ValTy, class _Key, class _RawValTy>
49struct __can_extract_map_key<_ValTy, _Key, _Key, _RawValTy> : false_type {};
50
51_LIBCPP_END_NAMESPACE_STD
52
53#endif // _LIBCPP___TYPE_TRAITS_CAN_EXTRACT_KEY_H
lib/libcxx/include/__type_traits/common_reference.h+5-3
......@@ -24,10 +24,12 @@
2424# pragma GCC system_header
2525#endif
2626
27#if _LIBCPP_STD_VER >= 20
28
2729_LIBCPP_BEGIN_NAMESPACE_STD
2830
2931// common_reference
30#if _LIBCPP_STD_VER >= 20
32
3133// Let COND_RES(X, Y) be:
3234template <class _Xp, class _Yp>
3335using __cond_res _LIBCPP_NODEBUG = decltype(false ? std::declval<_Xp (&)()>()() : std::declval<_Yp (&)()>()());
......@@ -195,8 +197,8 @@ _LIBCPP_DIAGNOSTIC_POP
195197template <class...>
196198struct _LIBCPP_NO_SPECIALIZATIONS common_reference {};
197199
198#endif // _LIBCPP_STD_VER >= 20
199
200200_LIBCPP_END_NAMESPACE_STD
201201
202#endif // _LIBCPP_STD_VER >= 20
203
202204#endif // _LIBCPP___TYPE_TRAITS_COMMON_REFERENCE_H
lib/libcxx/include/__type_traits/conditional.h+2-12
......@@ -35,20 +35,10 @@ struct _IfImpl<false> {
3535template <bool _Cond, class _IfRes, class _ElseRes>
3636using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>;
3737
38template <bool _Bp, class _If, class _Then>
38template <bool _Bp, class _IfRes, class _ElseRes>
3939struct _LIBCPP_NO_SPECIALIZATIONS conditional {
40 using type _LIBCPP_NODEBUG = _If;
41};
42
43_LIBCPP_DIAGNOSTIC_PUSH
44#if __has_warning("-Winvalid-specialization")
45_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
46#endif
47template <class _If, class _Then>
48struct conditional<false, _If, _Then> {
49 using type _LIBCPP_NODEBUG = _Then;
40 using type _LIBCPP_NODEBUG = _If<_Bp, _IfRes, _ElseRes>;
5041};
51_LIBCPP_DIAGNOSTIC_POP
5242
5343#if _LIBCPP_STD_VER >= 14
5444template <bool _Bp, class _IfRes, class _ElseRes>
lib/libcxx/include/__type_traits/conjunction.h+1-1
......@@ -34,7 +34,7 @@ false_type __and_helper(...);
3434//
3535// However, `_And<_Pred...>` itself will evaluate its result immediately (without having to
3636// be instantiated) since it is an alias, unlike `conjunction<_Pred...>`, which is a struct.
37// If you want to defer the evaluation of `_And<_Pred...>` itself, use `_Lazy<_And, _Pred...>`.
37// If you want to defer the evaluation, use `conjunction{,_v}<_Pred...>`.
3838template <class... _Pred>
3939using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
4040
lib/libcxx/include/__type_traits/dependent_type.h deleted-25
......@@ -1,25 +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_DEPENDENT_TYPE_H
10#define _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_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, bool>
21struct __dependent_type : public _Tp {};
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___TYPE_TRAITS_DEPENDENT_TYPE_H
lib/libcxx/include/__type_traits/disjunction.h+1-2
......@@ -38,8 +38,7 @@ struct _OrImpl<false> {
3838//
3939// However, `_Or<_Pred...>` itself will evaluate its result immediately (without having to
4040// be instantiated) since it is an alias, unlike `disjunction<_Pred...>`, which is a struct.
41// If you want to defer the evaluation of `_Or<_Pred...>` itself, use `_Lazy<_Or, _Pred...>`
42// or `disjunction<_Pred...>` directly.
41// If you want to defer the evaluation , use `disjunction{,_v}<_Pred...>`.
4342template <class... _Args>
4443using _Or _LIBCPP_NODEBUG = typename _OrImpl<sizeof...(_Args) != 0>::template _Result<false_type, _Args...>;
4544
lib/libcxx/include/__type_traits/has_unique_object_representation.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 17
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323template <class _Tp>
2424struct _LIBCPP_NO_SPECIALIZATIONS has_unique_object_representations
2525 : integral_constant<bool, __has_unique_object_representations(_Tp)> {};
......@@ -28,8 +28,8 @@ template <class _Tp>
2828_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool has_unique_object_representations_v =
2929 __has_unique_object_representations(_Tp);
3030
31#endif
32
3331_LIBCPP_END_NAMESPACE_STD
3432
33#endif // _LIBCPP_STD_VER >= 17
34
3535#endif // _LIBCPP___TYPE_TRAITS_HAS_UNIQUE_OBJECT_REPRESENTATION_H
lib/libcxx/include/__type_traits/integer_traits.h+26-29
......@@ -10,6 +10,11 @@
1010#define _LIBCPP___TYPE_TRAITS_INTEGER_TRAITS_H
1111
1212#include <__config>
13#include <__type_traits/is_integral.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/is_signed.h>
16#include <__type_traits/is_unqualified.h>
17#include <__type_traits/is_unsigned.h>
1318
1419#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1520# pragma GCC system_header
......@@ -17,43 +22,35 @@
1722
1823_LIBCPP_BEGIN_NAMESPACE_STD
1924
20// This trait is to determine whether a type is a /signed integer type/
21// See [basic.fundamental]/p1
25// /signed integer type/ and /unsigned integer type/ per [basic.fundamental]
26// /p1-2: specific unqualified types plus extended integer types. bool and
27// character types are integral but excluded. cv-qualified versions are
28// distinct types ([basic.type.qualifier]) and so excluded.
29
2230template <class _Tp>
23inline const bool __is_signed_integer_v = false;
24template <>
25inline const bool __is_signed_integer_v<signed char> = true;
31inline const bool __is_character_v = false;
2632template <>
27inline const bool __is_signed_integer_v<signed short> = true;
33inline const bool __is_character_v<char> = true;
2834template <>
29inline const bool __is_signed_integer_v<signed int> = true;
35inline const bool __is_character_v<wchar_t> = true;
36#if _LIBCPP_HAS_CHAR8_T
3037template <>
31inline const bool __is_signed_integer_v<signed long> = true;
38inline const bool __is_character_v<char8_t> = true;
39#endif
3240template <>
33inline const bool __is_signed_integer_v<signed long long> = true;
34#if _LIBCPP_HAS_INT128
41inline const bool __is_character_v<char16_t> = true;
3542template <>
36inline const bool __is_signed_integer_v<__int128_t> = true;
37#endif
43inline const bool __is_character_v<char32_t> = true;
3844
39// This trait is to determine whether a type is an /unsigned integer type/
40// See [basic.fundamental]/p2
4145template <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
46inline const bool __is_signed_integer_v =
47 is_integral<_Tp>::value && is_signed<_Tp>::value && !__is_character_v<_Tp> && !is_same<_Tp, bool>::value &&
48 __is_unqualified_v<_Tp>;
49
50template <class _Tp>
51inline const bool __is_unsigned_integer_v =
52 is_integral<_Tp>::value && is_unsigned<_Tp>::value && !__is_character_v<_Tp> && !is_same<_Tp, bool>::value &&
53 __is_unqualified_v<_Tp>;
5754
5855#if _LIBCPP_STD_VER >= 20
5956template <class _Tp>
lib/libcxx/include/__type_traits/integral_constant.h+1-1
......@@ -24,7 +24,7 @@ struct _LIBCPP_NO_SPECIALIZATIONS integral_constant {
2424 typedef integral_constant type;
2525 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; }
2626#if _LIBCPP_STD_VER >= 14
27 _LIBCPP_HIDE_FROM_ABI constexpr value_type operator()() const _NOEXCEPT { return value; }
27 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr value_type operator()() const _NOEXCEPT { return value; }
2828#endif
2929};
3030
lib/libcxx/include/__type_traits/is_bounded_array.h deleted-36
......@@ -1,36 +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_BOUNDED_ARRAY_H
10#define _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_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
21template <class _Tp>
22inline const bool __is_bounded_array_v = __is_bounded_array(_Tp);
23
24#if _LIBCPP_STD_VER >= 20
25
26template <class _Tp>
27struct _LIBCPP_NO_SPECIALIZATIONS is_bounded_array : bool_constant<__is_bounded_array(_Tp)> {};
28
29template <class _Tp>
30_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_bounded_array_v = __is_bounded_array(_Tp);
31
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_BOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_constant_evaluated.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020#if _LIBCPP_STD_VER >= 20
21_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_constant_evaluated() noexcept {
21[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline constexpr bool is_constant_evaluated() noexcept {
2222 return __builtin_is_constant_evaluated();
2323}
2424#endif
lib/libcxx/include/__type_traits/is_implicit_lifetime.h+4-2
......@@ -16,9 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER >= 23
20
1921_LIBCPP_BEGIN_NAMESPACE_STD
2022
21#if _LIBCPP_STD_VER >= 23
2223# if __has_builtin(__builtin_is_implicit_lifetime)
2324
2425template <class _Tp>
......@@ -28,8 +29,9 @@ template <class _Tp>
2829_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);
2930
3031# endif
31#endif
3232
3333_LIBCPP_END_NAMESPACE_STD
3434
35#endif // _LIBCPP_STD_VER >= 23
36
3537#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H
lib/libcxx/include/__type_traits/is_implicitly_default_constructible.h+4-2
......@@ -17,9 +17,10 @@
1717# pragma GCC system_header
1818#endif
1919
20#ifndef _LIBCPP_CXX03_LANG
21
2022_LIBCPP_BEGIN_NAMESPACE_STD
2123
22#ifndef _LIBCPP_CXX03_LANG
2324// First of all, we can't implement this check in C++03 mode because the {}
2425// default initialization syntax isn't valid.
2526// Second, we implement the trait in a funny manner with two defaulted template
......@@ -39,8 +40,9 @@ template <class _Tp>
3940struct __is_implicitly_default_constructible<_Tp,
4041 decltype(std::__test_implicit_default_constructible<_Tp const&>({})),
4142 false_type> : false_type {};
42#endif // !C++03
4343
4444_LIBCPP_END_NAMESPACE_STD
4545
46#endif // _LIBCPP_CXX03_LANG
47
4648#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICITLY_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_literal_type.h+4-2
......@@ -16,9 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
20
1921_LIBCPP_BEGIN_NAMESPACE_STD
2022
21#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2223template <class _Tp>
2324struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type
2425 : integral_constant<bool, __is_literal_type(_Tp)> {};
......@@ -27,8 +28,9 @@ struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS is_literal_type
2728template <class _Tp>
2829_LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_literal_type_v = __is_literal_type(_Tp);
2930# endif // _LIBCPP_STD_VER >= 17
30#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
3131
3232_LIBCPP_END_NAMESPACE_STD
3333
34#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
35
3436#endif // _LIBCPP___TYPE_TRAITS_IS_LITERAL_TYPE
lib/libcxx/include/__type_traits/is_primary_template.h deleted-32
......@@ -1,32 +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_PRIMARY_TEMPLATE_H
10#define _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
11
12#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/is_valid_expansion.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 _Tp>
24using __test_for_primary_template _LIBCPP_NODEBUG =
25 __enable_if_t<_IsSame<_Tp, typename _Tp::__primary_template>::value>;
26
27template <class _Tp>
28using __is_primary_template _LIBCPP_NODEBUG = _IsValidExpansion<__test_for_primary_template, _Tp>;
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_PRIMARY_TEMPLATE_H
lib/libcxx/include/__type_traits/is_referenceable.h deleted-34
......@@ -1,34 +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_REFERENCEABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
11
12#include <__config>
13#include <__type_traits/void_t.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
21template <class _Tp, class = void>
22inline const bool __is_referenceable_v = false;
23
24template <class _Tp>
25inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&> > = true;
26
27#if _LIBCPP_STD_VER >= 20
28template <class _Tp>
29concept __referenceable = __is_referenceable_v<_Tp>;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
lib/libcxx/include/__type_traits/is_replaceable.h deleted-61
......@@ -1,61 +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_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_trivially_relocatable.h+4
......@@ -34,10 +34,14 @@ template <class _Tp, class = void>
3434struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {};
3535#endif
3636
37// __trivially_relocatable on libc++'s builtin types does not currently return the right answer with PFP
38// in tagged mode, in which the address of the pointer is used as part of the pointer encoding.
39#if !defined(__POINTER_FIELD_PROTECTION_TAGGED__)
3740template <class _Tp>
3841struct __libcpp_is_trivially_relocatable<_Tp,
3942 __enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> >
4043 : true_type {};
44#endif
4145
4246_LIBCPP_END_NAMESPACE_STD
4347
lib/libcxx/include/__type_traits/is_unbounded_array.h deleted-38
......@@ -1,38 +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_UNBOUNDED_ARRAY_H
10#define _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_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
21template <class>
22inline const bool __is_unbounded_array_v = false;
23template <class _Tp>
24inline const bool __is_unbounded_array_v<_Tp[]> = true;
25
26#if _LIBCPP_STD_VER >= 20
27
28template <class _Tp>
29struct _LIBCPP_NO_SPECIALIZATIONS is_unbounded_array : bool_constant<__is_unbounded_array_v<_Tp>> {};
30
31template <class _Tp>
32_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool is_unbounded_array_v = __is_unbounded_array_v<_Tp>;
33
34#endif
35
36_LIBCPP_END_NAMESPACE_STD
37
38#endif // _LIBCPP___TYPE_TRAITS_IS_UNBOUNDED_ARRAY_H
lib/libcxx/include/__type_traits/is_valid_expansion.h deleted-31
......@@ -1,31 +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_VALID_EXPANSION_H
10#define _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_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
21template <template <class...> class _Templ, class... _Args, class = _Templ<_Args...> >
22true_type __sfinae_test_impl(int);
23template <template <class...> class, class...>
24false_type __sfinae_test_impl(...);
25
26template <template <class...> class _Templ, class... _Args>
27using _IsValidExpansion _LIBCPP_NODEBUG = decltype(std::__sfinae_test_impl<_Templ, _Args...>(0));
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_IS_VALID_EXPANSION_H
lib/libcxx/include/__type_traits/is_within_lifetime.h+1-1
......@@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919
2020#if _LIBCPP_STD_VER >= 26 && __has_builtin(__builtin_is_within_lifetime)
2121template <class _Tp>
22_LIBCPP_HIDE_FROM_ABI consteval bool is_within_lifetime(const _Tp* __p) noexcept {
22[[nodiscard]] _LIBCPP_HIDE_FROM_ABI consteval bool is_within_lifetime(const _Tp* __p) noexcept {
2323 return __builtin_is_within_lifetime(__p);
2424}
2525#endif
lib/libcxx/include/__type_traits/lazy.h deleted-25
......@@ -1,25 +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_LAZY_H
10#define _LIBCPP___TYPE_TRAITS_LAZY_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 <template <class...> class _Func, class... _Args>
21struct _Lazy : _Func<_Args...> {};
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___TYPE_TRAITS_LAZY_H
lib/libcxx/include/__type_traits/make_transparent.h+13-11
......@@ -22,29 +22,31 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323// __make_transparent tries to create a transparent comparator from its non-transparent counterpart, e.g. obtain
2424// `less<>` from `less<T>`. This is useful in cases where conversions can be avoided (e.g. a string literal to a
25// std::string).
25// std::string). This depends on the argument type provided to the comparator, because a comparator might be
26// transparent for some argument types but not for others.
2627
27template <class _Tp, class _Comparator>
28template <class _ArgumentType, class _Comparator>
2829struct __make_transparent {
2930 using type _LIBCPP_NODEBUG = _Comparator;
3031};
3132
32template <class _Tp, class _Comparator>
33using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_Tp, _Comparator>::type;
33template <class _ArgumentType, class _Comparator>
34using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_ArgumentType, _Comparator>::type;
3435
35template <class _Tp,
36template <class _ArgumentType,
3637 class _Comparator,
37 __enable_if_t<is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0>
38_LIBCPP_HIDE_FROM_ABI _Comparator& __as_transparent(_Comparator& __comp) {
38 __enable_if_t<is_same<_Comparator, __make_transparent_t<_ArgumentType, _Comparator> >::value, int> = 0>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Comparator& __as_transparent(_Comparator& __comp) {
3940 return __comp;
4041}
4142
42template <class _Tp,
43template <class _ArgumentType,
4344 class _Comparator,
44 __enable_if_t<!is_same<_Comparator, __make_transparent_t<_Tp, _Comparator> >::value, int> = 0>
45_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_Tp, _Comparator> __as_transparent(_Comparator&) {
45 __enable_if_t<!is_same<_Comparator, __make_transparent_t<_ArgumentType, _Comparator> >::value, int> = 0>
46_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __make_transparent_t<_ArgumentType, _Comparator>
47__as_transparent(_Comparator&) {
4648 static_assert(is_empty<_Comparator>::value);
47 return __make_transparent_t<_Tp, _Comparator>();
49 return __make_transparent_t<_ArgumentType, _Comparator>();
4850}
4951
5052_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/rank.h+1-21
......@@ -19,32 +19,12 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#if __has_builtin(__array_rank) && !defined(_LIBCPP_COMPILER_CLANG_BASED) || \
23 (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2001)
24
2522template <class _Tp>
2623struct _LIBCPP_NO_SPECIALIZATIONS rank : integral_constant<size_t, __array_rank(_Tp)> {};
2724
28#else
29
30template <class _Tp>
31struct _LIBCPP_NO_SPECIALIZATIONS rank : public integral_constant<size_t, 0> {};
32
33_LIBCPP_DIAGNOSTIC_PUSH
34# if __has_warning("-Winvalid-specialization")
35_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
36# endif
37template <class _Tp>
38struct rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
39template <class _Tp, size_t _Np>
40struct rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {};
41_LIBCPP_DIAGNOSTIC_POP
42
43#endif // __has_builtin(__array_rank)
44
4525#if _LIBCPP_STD_VER >= 17
4626template <class _Tp>
47_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = rank<_Tp>::value;
27_LIBCPP_NO_SPECIALIZATIONS inline constexpr size_t rank_v = __array_rank(_Tp);
4828#endif
4929
5030_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/reference_converts_from_temporary.h+4-4
......@@ -16,10 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#if _LIBCPP_STD_VER >= 23
2220
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2323template <class _Tp, class _Up>
2424struct _LIBCPP_NO_SPECIALIZATIONS reference_converts_from_temporary
2525 : public bool_constant<__reference_converts_from_temporary(_Tp, _Up)> {};
......@@ -28,8 +28,8 @@ template <class _Tp, class _Up>
2828_LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_converts_from_temporary_v =
2929 __reference_converts_from_temporary(_Tp, _Up);
3030
31#endif
32
3331_LIBCPP_END_NAMESPACE_STD
3432
33#endif // _LIBCPP_STD_VER >= 23
34
3535#endif // _LIBCPP___TYPE_TRAITS_REFERENCE_CONVERTS_FROM_TEMPORARY_H
lib/libcxx/include/__type_traits/remove_pointer.h+3-16
......@@ -17,31 +17,18 @@
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
20#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)
2120template <class _Tp>
2221struct _LIBCPP_NO_SPECIALIZATIONS remove_pointer {
2322 using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
2423};
2524
26# ifdef _LIBCPP_COMPILER_GCC
25#ifdef _LIBCPP_COMPILER_GCC
2726template <class _Tp>
2827using __remove_pointer_t _LIBCPP_NODEBUG = typename remove_pointer<_Tp>::type;
29# else
30template <class _Tp>
31using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp);
32# endif
3328#else
34// clang-format off
35template <class _Tp> struct remove_pointer {using type _LIBCPP_NODEBUG = _Tp;};
36template <class _Tp> struct remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;};
37template <class _Tp> struct remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;};
38template <class _Tp> struct remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;};
39template <class _Tp> struct remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;};
40// clang-format on
41
4229template <class _Tp>
43using __remove_pointer_t = typename remove_pointer<_Tp>::type;
44#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer)
30using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp);
31#endif
4532
4633#if _LIBCPP_STD_VER >= 14
4734template <class _Tp>
lib/libcxx/include/__type_traits/result_of.h+6-4
......@@ -16,18 +16,19 @@
1616# pragma GCC system_header
1717#endif
1818
19#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
20
1921_LIBCPP_BEGIN_NAMESPACE_STD
2022
2123// result_of
2224
23#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2425template <class _Callable>
2526struct _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_NO_SPECIALIZATIONS result_of;
2627
2728_LIBCPP_DIAGNOSTIC_PUSH
28#if __has_warning("-Winvalid-specialization")
29# if __has_warning("-Winvalid-specialization")
2930_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-specialization")
30#endif
31# endif
3132template <class _Fp, class... _Args>
3233struct result_of<_Fp(_Args...)> : __invoke_result<_Fp, _Args...> {};
3334_LIBCPP_DIAGNOSTIC_POP
......@@ -36,8 +37,9 @@ _LIBCPP_DIAGNOSTIC_POP
3637template <class _Tp>
3738using result_of_t _LIBCPP_DEPRECATED_IN_CXX17 = typename result_of<_Tp>::type;
3839# endif // _LIBCPP_STD_VER >= 14
39#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
4040
4141_LIBCPP_END_NAMESPACE_STD
4242
43#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
44
4345#endif // _LIBCPP___TYPE_TRAITS_RESULT_OF_H
lib/libcxx/include/__type_traits/strip_signature.h+3
......@@ -74,6 +74,9 @@ template<class _Rp, class _Gp, class ..._Ap>
7474struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type _LIBCPP_NODEBUG = _Rp(_Ap...); };
7575// clang-format on
7676
77template <class _Fp>
78using __strip_signature_t _LIBCPP_NODEBUG = typename __strip_signature<_Fp>::type;
79
7780_LIBCPP_END_NAMESPACE_STD
7881
7982#endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/__utility/as_const.h+4-2
......@@ -15,9 +15,10 @@
1515# pragma GCC system_header
1616#endif
1717
18#if _LIBCPP_STD_VER >= 17
19
1820_LIBCPP_BEGIN_NAMESPACE_STD
1921
20#if _LIBCPP_STD_VER >= 17
2122template <class _Tp>
2223[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& as_const(_Tp& __t) noexcept {
2324 return __t;
......@@ -25,8 +26,9 @@ template <class _Tp>
2526
2627template <class _Tp>
2728void as_const(const _Tp&&) = delete;
28#endif
2929
3030_LIBCPP_END_NAMESPACE_STD
3131
32#endif // _LIBCPP_STD_VER >= 17
33
3234#endif // _LIBCPP___UTILITY_AS_CONST_H
lib/libcxx/include/__utility/constant_wrapper.h created+326
......@@ -0,0 +1,326 @@
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___UTILITY_CONSTANT_WRAPPER_H
10#define _LIBCPP___UTILITY_CONSTANT_WRAPPER_H
11
12#include <__config>
13#include <__cstddef/size_t.h>
14#include <__functional/invoke.h>
15#include <__type_traits/invoke.h>
16#include <__type_traits/is_constructible.h>
17#include <__type_traits/is_same.h>
18#include <__type_traits/remove_cvref.h>
19#include <__utility/declval.h>
20#include <__utility/forward.h>
21#include <__utility/integer_sequence.h>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29#if _LIBCPP_STD_VER >= 26
30
31template <auto _Xp, class = remove_cvref_t<decltype(_Xp)>>
32struct constant_wrapper;
33
34template <class _Tp>
35concept __constexpr_param = requires { typename constant_wrapper<_Tp::value>; };
36
37template <auto _Xp>
38constexpr auto cw = constant_wrapper<_Xp>{};
39
40struct __cw_operators {
41 // unary operators
42 template <__constexpr_param _Tp>
43 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator+(_Tp) noexcept -> constant_wrapper<(+_Tp::value)> {
44 return {};
45 }
46 template <__constexpr_param _Tp>
47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator-(_Tp) noexcept -> constant_wrapper<(-_Tp::value)> {
48 return {};
49 }
50 template <__constexpr_param _Tp>
51 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator~(_Tp) noexcept -> constant_wrapper<(~_Tp::value)> {
52 return {};
53 }
54 template <__constexpr_param _Tp>
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator!(_Tp) noexcept -> constant_wrapper<(!_Tp::value)> {
56 return {};
57 }
58 template <__constexpr_param _Tp>
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator&(_Tp) noexcept -> constant_wrapper<(&_Tp::value)> {
60 return {};
61 }
62 template <__constexpr_param _Tp>
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator*(_Tp) noexcept -> constant_wrapper<(*_Tp::value)> {
64 return {};
65 }
66
67 // binary operators
68 template <__constexpr_param _Lp, __constexpr_param _Rp>
69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator+(_Lp, _Rp) noexcept
70 -> constant_wrapper<(_Lp::value + _Rp::value)> {
71 return {};
72 }
73 template <__constexpr_param _Lp, __constexpr_param _Rp>
74 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator-(_Lp, _Rp) noexcept
75 -> constant_wrapper<(_Lp::value - _Rp::value)> {
76 return {};
77 }
78 template <__constexpr_param _Lp, __constexpr_param _Rp>
79 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator*(_Lp, _Rp) noexcept
80 -> constant_wrapper<(_Lp::value * _Rp::value)> {
81 return {};
82 }
83 template <__constexpr_param _Lp, __constexpr_param _Rp>
84 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator/(_Lp, _Rp) noexcept
85 -> constant_wrapper<(_Lp::value / _Rp::value)> {
86 return {};
87 }
88 template <__constexpr_param _Lp, __constexpr_param _Rp>
89 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator%(_Lp, _Rp) noexcept
90 -> constant_wrapper<(_Lp::value % _Rp::value)> {
91 return {};
92 }
93
94 template <__constexpr_param _Lp, __constexpr_param _Rp>
95 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<<(_Lp, _Rp) noexcept
96 -> constant_wrapper<(_Lp::value << _Rp::value)> {
97 return {};
98 }
99 template <__constexpr_param _Lp, __constexpr_param _Rp>
100 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator>>(_Lp, _Rp) noexcept
101 -> constant_wrapper<(_Lp::value >> _Rp::value)> {
102 return {};
103 }
104 template <__constexpr_param _Lp, __constexpr_param _Rp>
105 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator&(_Lp, _Rp) noexcept
106 -> constant_wrapper<(_Lp::value & _Rp::value)> {
107 return {};
108 }
109 template <__constexpr_param _Lp, __constexpr_param _Rp>
110 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator|(_Lp, _Rp) noexcept
111 -> constant_wrapper<(_Lp::value | _Rp::value)> {
112 return {};
113 }
114 template <__constexpr_param _Lp, __constexpr_param _Rp>
115 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator^(_Lp, _Rp) noexcept
116 -> constant_wrapper<(_Lp::value ^ _Rp::value)> {
117 return {};
118 }
119
120 template <__constexpr_param _Lp, __constexpr_param _Rp>
121 requires(!is_constructible_v<bool, decltype(_Lp::value)> || !is_constructible_v<bool, decltype(_Rp::value)>)
122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator&&(_Lp, _Rp) noexcept
123 -> constant_wrapper<(_Lp::value && _Rp::value)> {
124 return {};
125 }
126 template <__constexpr_param _Lp, __constexpr_param _Rp>
127 requires(!is_constructible_v<bool, decltype(_Lp::value)> || !is_constructible_v<bool, decltype(_Rp::value)>)
128 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator||(_Lp, _Rp) noexcept
129 -> constant_wrapper<(_Lp::value || _Rp::value)> {
130 return {};
131 }
132
133 // comparisons
134 template <__constexpr_param _Lp, __constexpr_param _Rp>
135 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(_Lp, _Rp) noexcept
136 -> constant_wrapper<(_Lp::value <=> _Rp::value)> {
137 return {};
138 }
139 template <__constexpr_param _Lp, __constexpr_param _Rp>
140 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<(_Lp, _Rp) noexcept
141 -> constant_wrapper<(_Lp::value < _Rp::value)> {
142 return {};
143 }
144 template <__constexpr_param _Lp, __constexpr_param _Rp>
145 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=(_Lp, _Rp) noexcept
146 -> constant_wrapper<(_Lp::value <= _Rp::value)> {
147 return {};
148 }
149 template <__constexpr_param _Lp, __constexpr_param _Rp>
150 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator==(_Lp, _Rp) noexcept
151 -> constant_wrapper<(_Lp::value == _Rp::value)> {
152 return {};
153 }
154 template <__constexpr_param _Lp, __constexpr_param _Rp>
155 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator!=(_Lp, _Rp) noexcept
156 -> constant_wrapper<(_Lp::value != _Rp::value)> {
157 return {};
158 }
159 template <__constexpr_param _Lp, __constexpr_param _Rp>
160 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator>(_Lp, _Rp) noexcept
161 -> constant_wrapper<(_Lp::value > _Rp::value)> {
162 return {};
163 }
164 template <__constexpr_param _Lp, __constexpr_param _Rp>
165 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator>=(_Lp, _Rp) noexcept
166 -> constant_wrapper<(_Lp::value >= _Rp::value)> {
167 return {};
168 }
169
170 template <__constexpr_param _Lp, __constexpr_param _Rp>
171 friend auto operator,(_Lp, _Rp) = delete;
172
173 template <__constexpr_param _Lp, __constexpr_param _Rp>
174 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator->*(_Lp, _Rp) noexcept
175 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
176 -> constant_wrapper<auto(_Lp::value->*_Rp::value)> {
177 return {};
178 }
179
180 // pseudo-mutators
181 template <__constexpr_param _Tp>
182 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator++(this _Tp) noexcept -> constant_wrapper<(++_Tp::value)> {
183 return {};
184 }
185 template <__constexpr_param _Tp>
186 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator++(this _Tp, int) noexcept
187 -> constant_wrapper<(_Tp::value++)> {
188 return {};
189 }
190 template <__constexpr_param _Tp>
191 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator--(this _Tp) noexcept -> constant_wrapper<(--_Tp::value)> {
192 return {};
193 }
194 template <__constexpr_param _Tp>
195 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator--(this _Tp, int) noexcept
196 -> constant_wrapper<(_Tp::value--)> {
197 return {};
198 }
199
200 template <__constexpr_param _Tp, __constexpr_param _Rp>
201 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator+=(this _Tp, _Rp) noexcept
202 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
203 -> constant_wrapper<auto(_Tp::value += _Rp::value)> {
204 return {};
205 }
206 template <__constexpr_param _Tp, __constexpr_param _Rp>
207 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator-=(this _Tp, _Rp) noexcept
208 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
209 -> constant_wrapper<auto(_Tp::value -= _Rp::value)> {
210 return {};
211 }
212 template <__constexpr_param _Tp, __constexpr_param _Rp>
213 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator*=(this _Tp, _Rp) noexcept
214 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
215 -> constant_wrapper<auto(_Tp::value *= _Rp::value)> {
216 return {};
217 }
218 template <__constexpr_param _Tp, __constexpr_param _Rp>
219 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator/=(this _Tp, _Rp) noexcept
220 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
221 -> constant_wrapper<auto(_Tp::value /= _Rp::value)> {
222 return {};
223 }
224 template <__constexpr_param _Tp, __constexpr_param _Rp>
225 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator%=(this _Tp, _Rp) noexcept
226 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
227 -> constant_wrapper<auto(_Tp::value %= _Rp::value)> {
228 return {};
229 }
230 template <__constexpr_param _Tp, __constexpr_param _Rp>
231 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator&=(this _Tp, _Rp) noexcept
232 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
233 -> constant_wrapper<auto(_Tp::value &= _Rp::value)> {
234 return {};
235 }
236 template <__constexpr_param _Tp, __constexpr_param _Rp>
237 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|=(this _Tp, _Rp) noexcept
238 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
239 -> constant_wrapper<auto(_Tp::value |= _Rp::value)> {
240 return {};
241 }
242 template <__constexpr_param _Tp, __constexpr_param _Rp>
243 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator^=(this _Tp, _Rp) noexcept
244 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
245 -> constant_wrapper<auto(_Tp::value ^= _Rp::value)> {
246 return {};
247 }
248 template <__constexpr_param _Tp, __constexpr_param _Rp>
249 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator<<=(this _Tp, _Rp) noexcept
250 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
251 -> constant_wrapper<auto(_Tp::value <<= _Rp::value)> {
252 return {};
253 }
254 template <__constexpr_param _Tp, __constexpr_param _Rp>
255 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator>>=(this _Tp, _Rp) noexcept
256 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
257 -> constant_wrapper<auto(_Tp::value >>= _Rp::value)> {
258 return {};
259 }
260};
261
262template <const auto& _Callable, class... _Args>
263concept __constexpr_callable = (__constexpr_param<remove_cvref_t<_Args>> && ...) && requires {
264 typename constant_wrapper<std::invoke(_Callable, remove_cvref_t<_Args>::value...)>;
265};
266
267template <const auto& _Obj, class... _Args>
268concept __constexpr_indexable = (__constexpr_param<remove_cvref_t<_Args>> && ...) && requires {
269 typename constant_wrapper<auto(_Obj[remove_cvref_t<_Args>::value...])>;
270};
271
272template <auto _Xp, class _Tp>
273struct constant_wrapper : __cw_operators {
274 static constexpr decltype((_Xp)) value = (_Xp);
275
276 using type = constant_wrapper;
277 using value_type = decltype(_Xp);
278
279 static_assert(is_same_v<_Tp, value_type>,
280 "the second template parameter of std::constant_wrapper must be its value_type");
281
282 template <__constexpr_param _Rp>
283 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator=(_Rp) const noexcept
284 // TODO: Remove `auto` when all support versions of Clang have https://llvm.org/PR202693 fixed.
285 -> constant_wrapper<auto(value = _Rp::value)> {
286 return {};
287 }
288
289 _LIBCPP_HIDE_FROM_ABI constexpr operator decltype(value)() const noexcept { return value; }
290
291 template <class... _Args>
292 requires __constexpr_callable<value, _Args...>
293 [[nodiscard]]
294 _LIBCPP_HIDE_FROM_ABI static constexpr constant_wrapper<std::invoke(value, remove_cvref_t<_Args>::value...)>
295 operator()(_Args&&...) noexcept {
296 return {};
297 }
298
299 template <class... _Args>
300 requires(!__constexpr_callable<value, _Args...> && is_invocable_v<const value_type&, _Args && ...>)
301 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
302 operator()(_Args&&... __args) noexcept(noexcept(std::invoke(value, std::forward<_Args>(__args)...))) {
303 return std::invoke(value, std::forward<_Args>(__args)...);
304 }
305
306 template <class... _Args>
307 requires __constexpr_indexable<value, _Args...>
308 [[nodiscard]]
309 _LIBCPP_HIDE_FROM_ABI static constexpr constant_wrapper<auto(value[remove_cvref_t<_Args>::value...])>
310 operator[](_Args&&...) noexcept {
311 return {};
312 }
313
314 template <class... _Args>
315 requires(!__constexpr_indexable<value, _Args...> && requires { value[std::declval<_Args>()...]; })
316 _LIBCPP_HIDE_FROM_ABI static constexpr decltype(auto)
317 operator[](_Args&&... __args) noexcept(noexcept(value[std::forward<_Args>(__args)...])) {
318 return value[std::forward<_Args>(__args)...];
319 }
320};
321
322#endif // _LIBCPP_STD_VER >= 26
323
324_LIBCPP_END_NAMESPACE_STD
325
326#endif // _LIBCPP___UTILITY_CONSTANT_WRAPPER_H
lib/libcxx/include/__utility/default_three_way_comparator.h+2-2
......@@ -31,7 +31,7 @@ template <class _LHS, class _RHS>
3131struct __default_three_way_comparator<_LHS,
3232 _RHS,
3333 __enable_if_t<is_arithmetic<_LHS>::value && is_arithmetic<_RHS>::value> > {
34 _LIBCPP_HIDE_FROM_ABI static int operator()(_LHS __lhs, _RHS __rhs) {
34 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static int operator()(_LHS __lhs, _RHS __rhs) {
3535 if (__lhs < __rhs)
3636 return -1;
3737 if (__lhs > __rhs)
......@@ -47,7 +47,7 @@ struct __default_three_way_comparator<
4747 _RHS,
4848 __enable_if_t<!(is_arithmetic<_LHS>::value && is_arithmetic<_RHS>::value) &&
4949 __builtin_lt_synthesizes_from_spaceship(const _LHS&, const _RHS&)>> {
50 _LIBCPP_HIDE_FROM_ABI static int operator()(const _LHS& __lhs, const _RHS& __rhs) {
50 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static int operator()(const _LHS& __lhs, const _RHS& __rhs) {
5151 auto __res = __lhs <=> __rhs;
5252 if (__res < 0)
5353 return -1;
lib/libcxx/include/__utility/exchange.h+14-3
......@@ -10,6 +10,9 @@
1010#define _LIBCPP___UTILITY_EXCHANGE_H
1111
1212#include <__config>
13#include <__type_traits/enable_if.h>
14#include <__type_traits/is_assignable.h>
15#include <__type_traits/is_constructible.h>
1316#include <__type_traits/is_nothrow_assignable.h>
1417#include <__type_traits/is_nothrow_constructible.h>
1518#include <__utility/forward.h>
......@@ -24,14 +27,22 @@ _LIBCPP_PUSH_MACROS
2427
2528_LIBCPP_BEGIN_NAMESPACE_STD
2629
27#if _LIBCPP_STD_VER >= 14
2830template <class _T1, class _T2 = _T1>
29inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _T1 exchange(_T1& __obj, _T2&& __new_value) noexcept(
30 is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value) {
31[[__nodiscard__]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1
32__exchange(_T1& __obj, _T2&& __new_value)
33 _NOEXCEPT_(is_nothrow_move_constructible<_T1>::value&& is_nothrow_assignable<_T1&, _T2>::value) {
3134 _T1 __old_value = std::move(__obj);
3235 __obj = std::forward<_T2>(__new_value);
3336 return __old_value;
3437}
38
39#if _LIBCPP_STD_VER >= 14
40template <class _T1, class _T2 = _T1>
41[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
42_LIBCPP_CONSTEXPR_SINCE_CXX20 _T1 exchange(_T1& __obj, _T2&& __new_value) noexcept(
43 is_nothrow_move_constructible<_T1>::value && is_nothrow_assignable<_T1&, _T2>::value) {
44 return std::__exchange(__obj, std::forward<_T2>(__new_value));
45}
3546#endif // _LIBCPP_STD_VER >= 14
3647
3748_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/forward_like.h+4-4
......@@ -21,10 +21,10 @@
2121# pragma GCC system_header
2222#endif
2323
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2624#if _LIBCPP_STD_VER >= 23
2725
26_LIBCPP_BEGIN_NAMESPACE_STD
27
2828template <class _Ap, class _Bp>
2929using _CopyConst _LIBCPP_NODEBUG = _If<is_const_v<_Ap>, const _Bp, _Bp>;
3030
......@@ -56,8 +56,8 @@ __forward_as(_LIBCPP_LIFETIMEBOUND _Up&& __val) noexcept {
5656 return static_cast<_ForwardLike<_Tp, _As>>(__val);
5757}
5858
59#endif // _LIBCPP_STD_VER >= 23
60
6159_LIBCPP_END_NAMESPACE_STD
6260
61#endif // _LIBCPP_STD_VER >= 23
62
6363#endif // _LIBCPP___UTILITY_FORWARD_LIKE_H
lib/libcxx/include/__utility/in_place.h+4-4
......@@ -18,10 +18,10 @@
1818# pragma GCC system_header
1919#endif
2020
21_LIBCPP_BEGIN_NAMESPACE_STD
22
2321#if _LIBCPP_STD_VER >= 17
2422
23_LIBCPP_BEGIN_NAMESPACE_STD
24
2525struct in_place_t {
2626 explicit in_place_t() = default;
2727};
......@@ -57,8 +57,8 @@ struct __is_inplace_index_imp<in_place_index_t<_Idx>> : true_type {};
5757template <class _Tp>
5858using __is_inplace_index _LIBCPP_NODEBUG = __is_inplace_index_imp<__remove_cvref_t<_Tp>>;
5959
60#endif // _LIBCPP_STD_VER >= 17
61
6260_LIBCPP_END_NAMESPACE_STD
6361
62#endif // _LIBCPP_STD_VER >= 17
63
6464#endif // _LIBCPP___UTILITY_IN_PLACE_H
lib/libcxx/include/__utility/is_pointer_in_range.h+6-6
......@@ -12,12 +12,12 @@
1212#include <__algorithm/comp.h>
1313#include <__assert>
1414#include <__config>
15#include <__memory/valid_range.h>
1516#include <__type_traits/enable_if.h>
1617#include <__type_traits/integral_constant.h>
1718#include <__type_traits/is_constant_evaluated.h>
1819#include <__type_traits/void_t.h>
1920#include <__utility/declval.h>
20#include <__utility/is_valid_range.h>
2121
2222#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2323# pragma GCC system_header
......@@ -26,13 +26,13 @@
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
2828template <class _Tp, class _Up, class = void>
29struct __is_less_than_comparable : false_type {};
29inline const bool __is_less_than_comparable_v = false;
3030
3131template <class _Tp, class _Up>
32struct __is_less_than_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() < std::declval<_Up>())> > : true_type {
33};
32inline const bool
33 __is_less_than_comparable_v<_Tp, _Up, __void_t<decltype(std::declval<_Tp>() < std::declval<_Up>())> > = true;
3434
35template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0>
35template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable_v<const _Tp*, const _Up*>, int> = 0>
3636_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
3737__is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
3838 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__begin, __end), "[__begin, __end) is not a valid range");
......@@ -47,7 +47,7 @@ __is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
4747 return !__less<>()(__ptr, __begin) && __less<>()(__ptr, __end);
4848}
4949
50template <class _Tp, class _Up, __enable_if_t<!__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0>
50template <class _Tp, class _Up, __enable_if_t<!__is_less_than_comparable_v<const _Tp*, const _Up*>, int> = 0>
5151_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
5252__is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
5353 if (__libcpp_is_constant_evaluated())
lib/libcxx/include/__utility/is_valid_range.h deleted-37
......@@ -1,37 +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___UTILITY_IS_VALID_RANGE_H
10#define _LIBCPP___UTILITY_IS_VALID_RANGE_H
11
12#include <__algorithm/comp.h>
13#include <__config>
14#include <__type_traits/is_constant_evaluated.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 _Tp>
23_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
24__is_valid_range(const _Tp* __first, const _Tp* __last) {
25 if (__libcpp_is_constant_evaluated()) {
26 // If this is not a constant during constant evaluation, that is because __first and __last are not
27 // part of the same allocation. If they are part of the same allocation, we must still make sure they
28 // are ordered properly.
29 return __builtin_constant_p(__first <= __last) && __first <= __last;
30 }
31
32 return !__less<>()(__last, __first);
33}
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP___UTILITY_IS_VALID_RANGE_H
lib/libcxx/include/__utility/lazy_synth_three_way_comparator.h+18-15
......@@ -35,20 +35,20 @@ struct __lazy_compare_result {
3535 const _LHS& __lhs_;
3636 const _RHS& __rhs_;
3737
38 _LIBCPP_HIDE_FROM_ABI
39 __lazy_compare_result(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp,
40 _LIBCPP_CTOR_LIFETIMEBOUND const _LHS& __lhs,
41 _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs)
38 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_compare_result(
39 _LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp,
40 _LIBCPP_CTOR_LIFETIMEBOUND const _LHS& __lhs,
41 _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs)
4242 : __comp_(__comp), __lhs_(__lhs), __rhs_(__rhs) {}
4343
44 _LIBCPP_HIDE_FROM_ABI bool __less() const {
44 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __less() const {
4545 bool __result = __comp_(__lhs_, __rhs_);
4646 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__result ? !static_cast<bool>(__comp_(__rhs_, __lhs_)) : true,
4747 "Comparator does not induce a strict weak ordering");
4848 return __result;
4949 }
5050
51 _LIBCPP_HIDE_FROM_ABI bool __greater() const {
51 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __greater() const {
5252 bool __result = __comp_(__rhs_, __lhs_);
5353 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(__result ? !static_cast<bool>(__comp_(__lhs_, __rhs_)) : true,
5454 "Comparator does not induce a strict weak ordering");
......@@ -63,10 +63,11 @@ template <class _Comparator, class _LHS, class _RHS, class = void>
6363struct __lazy_synth_three_way_comparator {
6464 const _Comparator& __comp_;
6565
66 _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp)
66 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
67 __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp)
6768 : __comp_(__comp) {}
6869
69 _LIBCPP_HIDE_FROM_ABI __lazy_compare_result<_Comparator, _LHS, _RHS>
70 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_compare_result<_Comparator, _LHS, _RHS>
7071 operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) const {
7172 return __lazy_compare_result<_Comparator, _LHS, _RHS>(__comp_, __lhs, __rhs);
7273 }
......@@ -75,10 +76,10 @@ struct __lazy_synth_three_way_comparator {
7576struct __eager_compare_result {
7677 int __res_;
7778
78 _LIBCPP_HIDE_FROM_ABI explicit __eager_compare_result(int __res) : __res_(__res) {}
79 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __eager_compare_result(int __res) : __res_(__res) {}
7980
80 _LIBCPP_HIDE_FROM_ABI bool __less() const { return __res_ < 0; }
81 _LIBCPP_HIDE_FROM_ABI bool __greater() const { return __res_ > 0; }
81 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __less() const { return __res_ < 0; }
82 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __greater() const { return __res_ > 0; }
8283};
8384
8485template <class _Comparator, class _LHS, class _RHS>
......@@ -89,10 +90,11 @@ struct __lazy_synth_three_way_comparator<_Comparator,
8990 __has_default_three_way_comparator<_LHS, _RHS> >::value> > {
9091 // This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of
9192 // the comparator.
92 _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
93 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
94 __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
9395
9496 // Same comment as above.
95 _LIBCPP_HIDE_FROM_ABI static __eager_compare_result
97 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __eager_compare_result
9698 operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) {
9799 return __eager_compare_result(__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs));
98100 }
......@@ -106,10 +108,11 @@ struct __lazy_synth_three_way_comparator<_Comparator,
106108 __has_default_three_way_comparator<_LHS, _RHS> >::value> > {
107109 // This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of
108110 // the comparator.
109 _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
111 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
112 __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
110113
111114 // Same comment as above.
112 _LIBCPP_HIDE_FROM_ABI static __eager_compare_result
115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __eager_compare_result
113116 operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) {
114117 return __eager_compare_result(-__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs));
115118 }
lib/libcxx/include/__utility/pair.h+77-97
......@@ -55,22 +55,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5555template <class _T1, class _T2>
5656struct __check_pair_construction {
5757 template <int&...>
58 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {
58 static constexpr bool __enable_implicit_default() {
5959 return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
6060 }
6161
6262 template <int&...>
63 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() {
63 static constexpr bool __enable_default() {
6464 return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
6565 }
6666
6767 template <class _U1, class _U2>
68 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_pair_constructible() {
68 static constexpr bool __is_pair_constructible() {
6969 return is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value;
7070 }
7171
7272 template <class _U1, class _U2>
73 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() {
73 static constexpr bool __is_implicit() {
7474 return is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value;
7575 }
7676};
......@@ -79,9 +79,8 @@ struct __check_pair_construction {
7979
8080template <class, class>
8181struct __non_trivially_copyable_base {
82 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __non_trivially_copyable_base() _NOEXCEPT {}
83 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
84 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
82 _LIBCPP_CONSTEXPR __non_trivially_copyable_base() _NOEXCEPT {}
83 _LIBCPP_CONSTEXPR_SINCE_CXX14 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
8584};
8685
8786template <class _T1, class _T2>
......@@ -101,18 +100,18 @@ struct pair
101100 pair,
102101 void>;
103102
104 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
105 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;
103 pair(pair const&) = default;
104 pair(pair&&) = default;
106105
107106#ifdef _LIBCPP_CXX03_LANG
108 _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}
107 pair() : first(), second() {}
109108
110 _LIBCPP_HIDE_FROM_ABI pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}
109 pair(_T1 const& __t1, _T2 const& __t2) : first(__t1), second(__t2) {}
111110
112111 template <class _U1, class _U2>
113 _LIBCPP_HIDE_FROM_ABI pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
112 pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
114113
115 _LIBCPP_HIDE_FROM_ABI pair& operator=(pair const& __p) {
114 pair& operator=(pair const& __p) {
116115 first = __p.first;
117116 second = __p.second;
118117 return *this;
......@@ -126,7 +125,7 @@ struct pair
126125 class _U2,
127126 __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,
128127 int> = 0>
129 _LIBCPP_HIDE_FROM_ABI pair& operator=(pair<_U1, _U2> const& __p) {
128 pair& operator=(pair<_U1, _U2> const& __p) {
130129 first = __p.first;
131130 second = __p.second;
132131 return *this;
......@@ -134,13 +133,12 @@ struct pair
134133#else
135134 template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>,
136135 __enable_if_t<_CheckArgsDep::__enable_default(), int> = 0>
137 explicit(!_CheckArgsDep::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(
136 explicit(!_CheckArgsDep::__enable_implicit_default()) constexpr pair() noexcept(
138137 is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)
139138 : first(), second() {}
140139
141140 template <class _CheckArgsDep = __check_pair_construction<_T1, _T2>,
142141 __enable_if_t<_CheckArgsDep::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0>
143 _LIBCPP_HIDE_FROM_ABI
144142 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep::template __is_implicit<_T1 const&, _T2 const&>())
145143 pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value &&
146144 is_nothrow_copy_constructible<second_type>::value)
......@@ -155,7 +153,6 @@ struct pair
155153 class _U2,
156154# endif
157155 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0 >
158 _LIBCPP_HIDE_FROM_ABI
159156 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
160157 pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value &&
161158 is_nothrow_constructible<second_type, _U2>::value)
......@@ -166,7 +163,7 @@ struct pair
166163 template <class _U1,
167164 class _U2,
168165 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1&, _U2&>(), int> = 0>
169 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1&, _U2&>())
166 constexpr explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1&, _U2&>())
170167 pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
171168 is_nothrow_constructible<second_type, _U2&>::value))
172169 : first(__p.first), second(__p.second) {}
......@@ -177,7 +174,7 @@ struct pair
177174 class _U2,
178175 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1 const&, _U2 const&>(),
179176 int> = 0>
180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
177 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
181178 !__check_pair_construction<_T1, _T2>::template __is_implicit<_U1 const&, _U2 const&>())
182179 pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value &&
183180 is_nothrow_constructible<second_type, _U2 const&>::value)
......@@ -186,7 +183,6 @@ struct pair
186183 template <class _U1,
187184 class _U2,
188185 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<_U1, _U2>(), int> = 0>
189 _LIBCPP_HIDE_FROM_ABI
190186 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<_U1, _U2>())
191187 pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value &&
192188 is_nothrow_constructible<second_type, _U2&&>::value)
......@@ -198,8 +194,7 @@ struct pair
198194 class _U2,
199195 __enable_if_t<__check_pair_construction<_T1, _T2>::template __is_pair_constructible<const _U1&&, const _U2&&>(),
200196 int> = 0>
201 _LIBCPP_HIDE_FROM_ABI constexpr explicit(
202 !__check_pair_construction<_T1, _T2>::template __is_implicit<const _U1&&, const _U2&&>())
197 constexpr explicit(!__check_pair_construction<_T1, _T2>::template __is_implicit<const _U1&&, const _U2&&>())
203198 pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&
204199 is_nothrow_constructible<second_type, const _U2&&>::value)
205200 : first(std::move(__p.first)), second(std::move(__p.second)) {}
......@@ -209,19 +204,19 @@ struct pair
209204 template <__pair_like_no_subrange _PairLike>
210205 requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&
211206 is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>)
212 _LIBCPP_HIDE_FROM_ABI constexpr explicit(
213 !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||
214 !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>) pair(_PairLike&& __p)
207 constexpr explicit(!is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||
208 !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>)
209 pair(_PairLike&& __p)
215210 : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {}
216211# endif
217212
218213 template <class... _Args1, class... _Args2>
219 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
214 _LIBCPP_CONSTEXPR_SINCE_CXX20
220215 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept(
221216 is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value)
222217 : pair(__pc, __first_args, __second_args, __index_sequence_for<_Args1...>(), __index_sequence_for<_Args2...>()) {}
223218
224 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
219 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
225220 operator=(__conditional_t<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
226221 pair,
227222 __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&
......@@ -231,7 +226,7 @@ struct pair
231226 return *this;
232227 }
233228
234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(
229 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(
235230 __conditional_t<is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&&
236231 __p) noexcept(is_nothrow_move_assignable<first_type>::value &&
237232 is_nothrow_move_assignable<second_type>::value) {
......@@ -245,7 +240,7 @@ struct pair
245240 class _U2,
246241 __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,
247242 int> = 0>
248 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) {
243 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) {
249244 first = __p.first;
250245 second = __p.second;
251246 return *this;
......@@ -254,7 +249,7 @@ struct pair
254249 template <class _U1,
255250 class _U2,
256251 __enable_if_t<is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value, int> = 0>
257 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) {
252 _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) {
258253 first = std::forward<_U1>(__p.first);
259254 second = std::forward<_U2>(__p.second);
260255 return *this;
......@@ -262,7 +257,7 @@ struct pair
262257
263258# if _LIBCPP_STD_VER >= 23
264259 template <class = void>
265 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair const& __p) const
260 constexpr const pair& operator=(pair const& __p) const
266261 noexcept(is_nothrow_copy_assignable_v<const first_type> && is_nothrow_copy_assignable_v<const second_type>)
267262 requires(is_copy_assignable_v<const first_type> && is_copy_assignable_v<const second_type>)
268263 {
......@@ -272,7 +267,7 @@ struct pair
272267 }
273268
274269 template <class = void>
275 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair&& __p) const
270 constexpr const pair& operator=(pair&& __p) const
276271 noexcept(is_nothrow_assignable_v<const first_type&, first_type> &&
277272 is_nothrow_assignable_v<const second_type&, second_type>)
278273 requires(is_assignable_v<const first_type&, first_type> && is_assignable_v<const second_type&, second_type>)
......@@ -283,7 +278,7 @@ struct pair
283278 }
284279
285280 template <class _U1, class _U2>
286 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(const pair<_U1, _U2>& __p) const
281 constexpr const pair& operator=(const pair<_U1, _U2>& __p) const
287282 requires(is_assignable_v<const first_type&, const _U1&> && is_assignable_v<const second_type&, const _U2&>)
288283 {
289284 first = __p.first;
......@@ -292,7 +287,7 @@ struct pair
292287 }
293288
294289 template <class _U1, class _U2>
295 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair<_U1, _U2>&& __p) const
290 constexpr const pair& operator=(pair<_U1, _U2>&& __p) const
296291 requires(is_assignable_v<const first_type&, _U1> && is_assignable_v<const second_type&, _U2>)
297292 {
298293 first = std::forward<_U1>(__p.first);
......@@ -304,7 +299,7 @@ struct pair
304299 requires(__different_from<_PairLike, pair> &&
305300 is_assignable_v<first_type&, decltype(std::get<0>(std::declval<_PairLike>()))> &&
306301 is_assignable_v<second_type&, decltype(std::get<1>(std::declval<_PairLike>()))>)
307 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(_PairLike&& __p) {
302 constexpr pair& operator=(_PairLike&& __p) {
308303 first = std::get<0>(std::forward<_PairLike>(__p));
309304 second = std::get<1>(std::forward<_PairLike>(__p));
310305 return *this;
......@@ -314,7 +309,7 @@ struct pair
314309 requires(__different_from<_PairLike, pair> &&
315310 is_assignable_v<first_type const&, decltype(std::get<0>(std::declval<_PairLike>()))> &&
316311 is_assignable_v<second_type const&, decltype(std::get<1>(std::declval<_PairLike>()))>)
317 _LIBCPP_HIDE_FROM_ABI constexpr pair const& operator=(_PairLike&& __p) const {
312 constexpr pair const& operator=(_PairLike&& __p) const {
318313 first = std::get<0>(std::forward<_PairLike>(__p));
319314 second = std::get<1>(std::forward<_PairLike>(__p));
320315 return *this;
......@@ -328,34 +323,33 @@ struct pair
328323 template <class _U1,
329324 class _U2,
330325 __enable_if_t<is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value, int> = 0>
331 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p)
332 : first(std::get<0>(__p)), second(std::get<1>(__p)) {}
326 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p) : first(std::get<0>(__p)), second(std::get<1>(__p)) {}
333327
334328 template < class _U1,
335329 class _U2,
336330 __enable_if_t<is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value &&
337331 !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value),
338332 int> = 0>
339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p)
333 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p)
340334 : first(std::get<0>(__p)), second(std::get<1>(__p)) {}
341335
342336 template <class _U1,
343337 class _U2,
344338 __enable_if_t<is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value, int> = 0>
345 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p)
339 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p)
346340 : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}
347341
348342 template <class _U1,
349343 class _U2,
350344 __enable_if_t<is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value &&
351345 !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) > = 0>
352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p)
346 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p)
353347 : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}
354348
355349 template <class _U1,
356350 class _U2,
357351 __enable_if_t<is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value, int> = 0>
358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) {
352 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) {
359353 first = std::get<0>(__p);
360354 second = std::get<1>(__p);
361355 return *this;
......@@ -364,7 +358,7 @@ struct pair
364358 template <class _U1,
365359 class _U2,
366360 __enable_if_t<is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value, int> = 0>
367 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) {
361 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) {
368362 first = std::get<0>(std::move(__p));
369363 second = std::get<1>(std::move(__p));
370364 return *this;
......@@ -373,36 +367,34 @@ struct pair
373367 // from std::array
374368 template <class _Up,
375369 __enable_if_t<is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value, int> = 0>
376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {}
370 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {}
377371
378372 template <class _Up,
379373 __enable_if_t<is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value &&
380374 !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value),
381375 int> = 0>
382 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p)
383 : first(__p[0]), second(__p[1]) {}
376 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {}
384377
385378 template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value, int> = 0>
386 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p)
387 : first(std::move(__p)[0]), second(std::move(__p)[1]) {}
379 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p) : first(std::move(__p)[0]), second(std::move(__p)[1]) {}
388380
389381 template <class _Up,
390382 __enable_if_t<is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value &&
391383 !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value),
392384 int> = 0>
393 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p)
385 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p)
394386 : first(std::move(__p)[0]), second(std::move(__p)[1]) {}
395387
396388 template <class _Up,
397389 __enable_if_t<is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value, int> = 0>
398 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) {
390 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) {
399391 first = std::get<0>(__p);
400392 second = std::get<1>(__p);
401393 return *this;
402394 }
403395
404396 template <class _Up, __enable_if_t<is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value, int> = 0>
405 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) {
397 _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) {
406398 first = std::get<0>(std::move(__p));
407399 second = std::get<1>(std::move(__p));
408400 return *this;
......@@ -410,7 +402,7 @@ struct pair
410402# endif // _LIBCPP_STD_VER < 23
411403#endif // _LIBCPP_CXX03_LANG
412404
413 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p)
405 _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p)
414406 _NOEXCEPT_(__is_nothrow_swappable_v<first_type>&& __is_nothrow_swappable_v<second_type>) {
415407 using std::swap;
416408 swap(first, __p.first);
......@@ -418,7 +410,7 @@ struct pair
418410 }
419411
420412#if _LIBCPP_STD_VER >= 23
421 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const
413 constexpr void swap(const pair& __p) const
422414 noexcept(__is_nothrow_swappable_v<const first_type> && __is_nothrow_swappable_v<const second_type>) {
423415 using std::swap;
424416 swap(first, __p.first);
......@@ -429,7 +421,7 @@ struct pair
429421private:
430422#ifndef _LIBCPP_CXX03_LANG
431423 template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
432 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
424 _LIBCPP_CONSTEXPR_SINCE_CXX20
433425 pair(piecewise_construct_t,
434426 tuple<_Args1...>& __first_args,
435427 tuple<_Args2...>& __second_args,
......@@ -448,8 +440,7 @@ pair(_T1, _T2) -> pair<_T1, _T2>;
448440// [pairs.spec], specialized algorithms
449441
450442template <class _T1, class _T2, class _U1, class _U2>
451inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
452operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
443inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
453444#if _LIBCPP_STD_VER >= 26
454445 requires requires {
455446 { __x.first == __y.first } -> __boolean_testable;
......@@ -463,8 +454,7 @@ operator==(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y)
463454#if _LIBCPP_STD_VER >= 20
464455
465456template <class _T1, class _T2, class _U1, class _U2>
466_LIBCPP_HIDE_FROM_ABI constexpr common_comparison_category_t< __synth_three_way_result<_T1, _U1>,
467 __synth_three_way_result<_T2, _U2> >
457constexpr common_comparison_category_t< __synth_three_way_result<_T1, _U1>, __synth_three_way_result<_T2, _U2> >
468458operator<=>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
469459 if (auto __c = std::__synth_three_way(__x.first, __y.first); __c != 0) {
470460 return __c;
......@@ -475,32 +465,27 @@ operator<=>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
475465#else // _LIBCPP_STD_VER >= 20
476466
477467template <class _T1, class _T2, class _U1, class _U2>
478inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
479operator!=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
468inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator!=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
480469 return !(__x == __y);
481470}
482471
483472template <class _T1, class _T2, class _U1, class _U2>
484inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
485operator<(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
473inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator<(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
486474 return __x.first < __y.first || (!(__y.first < __x.first) && __x.second < __y.second);
487475}
488476
489477template <class _T1, class _T2, class _U1, class _U2>
490inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
491operator>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
478inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator>(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
492479 return __y < __x;
493480}
494481
495482template <class _T1, class _T2, class _U1, class _U2>
496inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
497operator>=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
483inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator>=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
498484 return !(__x < __y);
499485}
500486
501487template <class _T1, class _T2, class _U1, class _U2>
502inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool
503operator<=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
488inline _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator<=(const pair<_T1, _T2>& __x, const pair<_U1, _U2>& __y) {
504489 return !(__y < __x);
505490}
506491
......@@ -524,7 +509,7 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
524509#endif // _LIBCPP_STD_VER >= 23
525510
526511template <class _T1, class _T2, __enable_if_t<__is_swappable_v<_T1> && __is_swappable_v<_T2>, int> = 0>
527inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
512inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
528513 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
529514 __x.swap(__y);
530515}
......@@ -532,15 +517,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _
532517#if _LIBCPP_STD_VER >= 23
533518template <class _T1, class _T2>
534519 requires(__is_swappable_v<const _T1> && __is_swappable_v<const _T2>)
535_LIBCPP_HIDE_FROM_ABI constexpr void
536swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) {
520constexpr void swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) {
537521 __x.swap(__y);
538522}
539523#endif
540524
541525template <class _T1, class _T2>
542[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
543pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> > make_pair(_T1&& __t1, _T2&& __t2) {
526[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >
527make_pair(_T1&& __t1, _T2&& __t2) {
544528 return pair<__unwrap_ref_decay_t<_T1>, __unwrap_ref_decay_t<_T2> >(std::forward<_T1>(__t1), std::forward<_T2>(__t2));
545529}
546530
......@@ -568,22 +552,22 @@ struct __get_pair;
568552template <>
569553struct __get_pair<0> {
570554 template <class _T1, class _T2>
571 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
555 static _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
572556 return __p.first;
573557 }
574558
575559 template <class _T1, class _T2>
576 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1& get(const pair<_T1, _T2>& __p) _NOEXCEPT {
560 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1& get(const pair<_T1, _T2>& __p) _NOEXCEPT {
577561 return __p.first;
578562 }
579563
580564 template <class _T1, class _T2>
581 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
565 static _LIBCPP_CONSTEXPR_SINCE_CXX14 _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
582566 return std::forward<_T1>(__p.first);
583567 }
584568
585569 template <class _T1, class _T2>
586 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
570 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T1&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
587571 return std::forward<const _T1>(__p.first);
588572 }
589573};
......@@ -591,92 +575,88 @@ struct __get_pair<0> {
591575template <>
592576struct __get_pair<1> {
593577 template <class _T1, class _T2>
594 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {
578 static _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {
595579 return __p.second;
596580 }
597581
598582 template <class _T1, class _T2>
599 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2& get(const pair<_T1, _T2>& __p) _NOEXCEPT {
583 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2& get(const pair<_T1, _T2>& __p) _NOEXCEPT {
600584 return __p.second;
601585 }
602586
603587 template <class _T1, class _T2>
604 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
588 static _LIBCPP_CONSTEXPR_SINCE_CXX14 _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
605589 return std::forward<_T2>(__p.second);
606590 }
607591
608592 template <class _T1, class _T2>
609 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
593 static _LIBCPP_CONSTEXPR_SINCE_CXX14 const _T2&& get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
610594 return std::forward<const _T2>(__p.second);
611595 }
612596};
613597
614598template <size_t _Ip, class _T1, class _T2>
615[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
616typename tuple_element<_Ip, pair<_T1, _T2> >::type&
599[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
617600get(pair<_T1, _T2>& __p) _NOEXCEPT {
618601 return __get_pair<_Ip>::get(__p);
619602}
620603
621604template <size_t _Ip, class _T1, class _T2>
622[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
623_LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
605[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
624606get(const pair<_T1, _T2>& __p) _NOEXCEPT {
625607 return __get_pair<_Ip>::get(__p);
626608}
627609
628610template <size_t _Ip, class _T1, class _T2>
629[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
630typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
611[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
631612get(pair<_T1, _T2>&& __p) _NOEXCEPT {
632613 return __get_pair<_Ip>::get(std::move(__p));
633614}
634615
635616template <size_t _Ip, class _T1, class _T2>
636[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
637_LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
617[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
638618get(const pair<_T1, _T2>&& __p) _NOEXCEPT {
639619 return __get_pair<_Ip>::get(std::move(__p));
640620}
641621
642622#if _LIBCPP_STD_VER >= 14
643623template <class _T1, class _T2>
644[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
624[[__nodiscard__]] inline constexpr _T1& get(pair<_T1, _T2>& __p) _NOEXCEPT {
645625 return __p.first;
646626}
647627
648628template <class _T1, class _T2>
649[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
629[[__nodiscard__]] inline constexpr _T1 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
650630 return __p.first;
651631}
652632
653633template <class _T1, class _T2>
654[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
634[[__nodiscard__]] inline constexpr _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
655635 return std::forward<_T1&&>(__p.first);
656636}
657637
658638template <class _T1, class _T2>
659[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
639[[__nodiscard__]] inline constexpr _T1 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
660640 return std::forward<_T1 const&&>(__p.first);
661641}
662642
663643template <class _T2, class _T1>
664[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {
644[[__nodiscard__]] inline constexpr _T2& get(pair<_T1, _T2>& __p) _NOEXCEPT {
665645 return __p.second;
666646}
667647
668648template <class _T2, class _T1>
669[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
649[[__nodiscard__]] inline constexpr _T2 const& get(pair<_T1, _T2> const& __p) _NOEXCEPT {
670650 return __p.second;
671651}
672652
673653template <class _T2, class _T1>
674[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
654[[__nodiscard__]] inline constexpr _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {
675655 return std::forward<_T2&&>(__p.second);
676656}
677657
678658template <class _T2, class _T1>
679[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
659[[__nodiscard__]] inline constexpr _T2 const&& get(pair<_T1, _T2> const&& __p) _NOEXCEPT {
680660 return std::forward<_T2 const&&>(__p.second);
681661}
682662
lib/libcxx/include/__utility/try_key_extraction.h+6-6
......@@ -28,7 +28,7 @@
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
3030template <class _KeyT, class _Ret, class _WithKey, class _WithoutKey, class... _Args>
31_LIBCPP_HIDE_FROM_ABI _Ret
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
3232__try_key_extraction_impl(__priority_tag<0>, _WithKey, _WithoutKey __without_key, _Args&&... __args) {
3333 return __without_key(std::forward<_Args>(__args)...);
3434}
......@@ -39,7 +39,7 @@ template <class _KeyT,
3939 class _WithoutKey,
4040 class _Arg,
4141 __enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg> >::value, int> = 0>
42_LIBCPP_HIDE_FROM_ABI _Ret
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
4343__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) {
4444 return __with_key(__arg, std::forward<_Arg>(__arg));
4545}
......@@ -52,7 +52,7 @@ template <class _KeyT,
5252 __enable_if_t<__is_pair_v<__remove_const_ref_t<_Arg> > &&
5353 is_same<__remove_const_t<typename __remove_const_ref_t<_Arg>::first_type>, _KeyT>::value,
5454 int> = 0>
55_LIBCPP_HIDE_FROM_ABI _Ret
55_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
5656__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) {
5757 return __with_key(__arg.first, std::forward<_Arg>(__arg));
5858}
......@@ -64,7 +64,7 @@ template <class _KeyT,
6464 class _Arg1,
6565 class _Arg2,
6666 __enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg1> >::value, int> = 0>
67_LIBCPP_HIDE_FROM_ABI _Ret
67_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
6868__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg1&& __arg1, _Arg2&& __arg2) {
6969 return __with_key(__arg1, std::forward<_Arg1>(__arg1), std::forward<_Arg2>(__arg2));
7070}
......@@ -81,7 +81,7 @@ template <class _KeyT,
8181 __is_tuple_v<_Tuple1> && tuple_size<_Tuple1>::value == 1 &&
8282 is_same<__remove_const_ref_t<typename tuple_element<0, _Tuple1>::type>, _KeyT>::value,
8383 int> = 0>
84_LIBCPP_HIDE_FROM_ABI _Ret __try_key_extraction_impl(
84_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret __try_key_extraction_impl(
8585 __priority_tag<1>,
8686 _WithKey __with_key,
8787 _WithoutKey,
......@@ -102,7 +102,7 @@ _LIBCPP_HIDE_FROM_ABI _Ret __try_key_extraction_impl(
102102//
103103// Both `__with_key` and `__without_key` must take all arguments by reference.
104104template <class _KeyT, class _WithKey, class _WithoutKey, class... _Args>
105_LIBCPP_HIDE_FROM_ABI decltype(std::declval<_WithoutKey>()(std::declval<_Args>()...))
105_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 decltype(std::declval<_WithoutKey>()(std::declval<_Args>()...))
106106__try_key_extraction(_WithKey __with_key, _WithoutKey __without_key, _Args&&... __args) {
107107 using _Ret = decltype(__without_key(std::forward<_Args>(__args)...));
108108 return std::__try_key_extraction_impl<_KeyT, _Ret>(
lib/libcxx/include/__variant/monostate.h+4-4
......@@ -19,10 +19,10 @@
1919# pragma GCC system_header
2020#endif
2121
22_LIBCPP_BEGIN_NAMESPACE_STD
23
2422#if _LIBCPP_STD_VER >= 17
2523
24_LIBCPP_BEGIN_NAMESPACE_STD
25
2626struct monostate {};
2727
2828_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }
......@@ -59,8 +59,8 @@ struct hash<monostate> {
5959 }
6060};
6161
62#endif // _LIBCPP_STD_VER >= 17
63
6462_LIBCPP_END_NAMESPACE_STD
6563
64#endif // _LIBCPP_STD_VER >= 17
65
6666#endif // _LIBCPP___VARIANT_MONOSTATE_H
lib/libcxx/include/__vector/layout.h created+479
......@@ -0,0 +1,479 @@
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___VECTOR_LAYOUT_H
10#define _LIBCPP___VECTOR_LAYOUT_H
11
12#include <__assert>
13#include <__config>
14#include <__debug_utils/sanitizers.h>
15#include <__memory/allocator_traits.h>
16#include <__memory/compressed_pair.h>
17#include <__memory/pointer_traits.h>
18#include <__memory/swap_allocator.h>
19#include <__memory/uninitialized_algorithms.h>
20#include <__split_buffer>
21#include <__type_traits/is_nothrow_constructible.h>
22#include <__utility/exchange.h>
23#include <__utility/move.h>
24#include <__utility/swap.h>
25
26#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
27# pragma GCC system_header
28#endif
29
30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35/// Defines `std::vector`'s storage layout and any operations that are affected by a change in the
36/// layout.
37///
38/// `std::vector` can be represented in a variety of ways. Each representation strongly influences
39/// the codegen when calling vector operations, which can significantly impact runtime performance
40/// and memory utilisation. libc++ provides two alternative layouts for `std::vector`, although only
41/// one can be active for an entire binary:
42///
43/// * pointer-based layout (stable ABI default)
44/// * size-based layout (unstable ABI alternative)
45//
46/// We describe these layouts below. All vector representations have a pointer that points to where
47/// the memory is allocated (called `__begin_`).
48///
49/// **Pointer-based layout**
50///
51/// The pointer-based layout uses two more pointers in addition to `__begin_`. The second pointer
52/// (called `__end_`) points past the end of the part of the buffer that holds valid elements.
53/// Another pointer (called `__capacity_`) points past the end of the allocated buffer. The original
54/// libc++ `std::vector` implementation only provided the pointer-based layout. libc++ continues to
55/// use the pointer-based layout, by default, in order to maintain binary compatibility with
56/// existing software.
57///
58/// The `__end_` pointer has three primary use-cases:
59/// * to compute the size of the vector; and
60/// * to construct the past-the-end iterator; and
61/// * to indicate where the next element should be appended.
62///
63/// The `__capacity_` is used to compute the capacity of the vector, which lets the vector know how
64/// many elements can be added to the vector before a reallocation is necessary.
65///
66/// __begin_ = 0xE4FD0, __end_ = 0xE4FF0, __capacity_ = 0xE5000
67/// 0xE4FD0 0xE4FF0 0xE5000
68/// v v v
69/// +---------------+--------+--------+--------+--------+--------+--------+---------------------+
70/// | ????????????? | 3174 | 5656 | 648 | 489 | ------ | ------ | ??????????????????? |
71/// +---------------+--------+--------+--------+--------+--------+--------+---------------------+
72/// ^ ^ ^
73/// __begin_ __end_ __capacity_
74///
75/// Figure 1: A visual representation of a pointer-based `std::vector<short>`. This vector has
76/// four elements, with the capacity to store six. Boxes with numbers are valid elements within
77/// the vector, and boxes with `xx` have been allocated, but aren't being used as elements right
78/// now.
79///
80/// This is the default layout for libc++.
81///
82/// **Size-based layout**
83///
84/// The size-based layout uses integers to track its size and capacity, and computes pointers to
85/// past-the-end of the valid range and the whole buffer only when it's necessary. Programs using
86/// the size-based layout have been measured to yield improved compute and memory performance over
87/// the pointer-based layout. Despite these promising measurements, the size-based layout is opt-in,
88/// to preserve ABI compatibility with prebuilt binaries. Given the improved performance, we
89/// recommend preferring the size-based layout in the absence of such ABI constraints.
90///
91/// __begin_ = 0xE4FD0, __size_ = 4, __capacity_ = 6
92/// 0xE4FD0
93/// v
94/// +---------------+--------+--------+--------+--------+--------+--------+---------------------+
95/// | ????????????? | 3174 | 5656 | 648 | 489 | ------ | ------ | ??????????????????? |
96/// +---------------+--------+--------+--------+--------+--------+--------+---------------------+
97/// ^
98/// __begin_
99///
100/// Figure 2: A visual representation of this a size-based layout. Blank boxes are not a part
101/// of the vector's allocated buffer.
102///
103/// **Class design**
104///
105/// __vector_layout was designed with the following goals:
106/// 1. to abstractly represent the buffer's boundaries; and
107/// 2. to limit the number of `#ifdef` blocks that a reader needs to pass through; and
108/// 3. given (1) and (2), to have no logically identical components in multiple `#ifdef` clauses.
109///
110/// To facilitate these goals, there is a single `__vector_layout` definition. Users must choose
111/// their vector's layout when libc++ is being configured, so there is no need to manage multiple
112/// vector layout types (e.g. `__vector_size_layout`, `__vector_pointer_layout`, etc.). In doing so,
113/// we reduce a significant portion of duplicate code.
114template <class _Tp, class _Allocator>
115class __vector_layout {
116public:
117 using value_type _LIBCPP_NODEBUG = _Tp;
118 using allocator_type _LIBCPP_NODEBUG = _Allocator;
119 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
120 using size_type _LIBCPP_NODEBUG = typename __alloc_traits::size_type;
121 using pointer _LIBCPP_NODEBUG = typename __alloc_traits::pointer;
122 using const_pointer _LIBCPP_NODEBUG = typename __alloc_traits::const_pointer;
123#ifdef _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
124 using _SplitBuffer _LIBCPP_NODEBUG = __split_buffer<_Tp, _Allocator, __split_buffer_size_layout>;
125 using __bound_type _LIBCPP_NODEBUG = size_type;
126#else
127 using _SplitBuffer _LIBCPP_NODEBUG = __split_buffer<_Tp, _Allocator, __split_buffer_pointer_layout>;
128 using __bound_type _LIBCPP_NODEBUG = pointer;
129#endif
130
131 // Cannot be defaulted, since `_LIBCPP_COMPRESSED_PAIR` isn't an aggregate before C++14.
132 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __vector_layout()
133 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
134 : __capacity_() {}
135
136 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __vector_layout(allocator_type const& __a)
137 _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
138 : __capacity_(), __alloc_(__a) {}
139
140 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __vector_layout(allocator_type&& __a)
141 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
142 : __capacity_(), __alloc_(std::move(__a)) {}
143
144 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __vector_layout(__vector_layout&& __other)
145 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
146
147 /// Returns a reference to the stored allocator.
148 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT {
149 return __alloc_;
150 }
151
152 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type const&
153 __alloc() const _NOEXCEPT {
154 return __alloc_;
155 }
156
157 /// Returns a pointer to the beginning of the buffer.
158 ///
159 /// `__begin_ptr()` is not called `data()` because `vector::data()` returns `T*`, but `__begin_`
160 /// is allowed to be a fancy pointer.
161 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __begin_ptr() _NOEXCEPT {
162 return __begin_;
163 }
164
165 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer __begin_ptr() const _NOEXCEPT {
166 return __begin_;
167 }
168
169 /// Returns a built-in pointer to the beginning of the buffer.
170 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _Tp* __data() _NOEXCEPT {
171 return std::__to_address(__begin_);
172 }
173
174 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _Tp const* __data() const _NOEXCEPT {
175 return std::__to_address(__begin_);
176 }
177
178 /// Returns how many elements can be added before a reallocation occurs.
179 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type
180 __remaining_capacity() const _NOEXCEPT;
181
182 /// Sets the member pointing to the first element in the vector to `__new_begin`, the member used
183 /// to obtain the vector's bound to the equivalent of `__new_size`, and the member that represents
184 /// the vector's capacity to the equivalent to `__new_capacity`.
185 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
186 __set_layout(pointer __new_begin, size_type __new_size, size_type __new_capacity) _NOEXCEPT;
187
188 /// Sets the member used to obtain the vector's bound to the equivalent of `__ptr`.
189 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __set_bound_using_pointer(pointer __ptr) _NOEXCEPT;
190
191 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __reset_without_allocator() _NOEXCEPT;
192 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap(__vector_layout& __other) _NOEXCEPT;
193 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
194 __move_assign_without_allocator(__vector_layout& __other) _NOEXCEPT;
195
196 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __relocate(_SplitBuffer& __buffer);
197 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
198 __relocate_with_pivot(_SplitBuffer& __buffer, pointer __pivot);
199
200 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __size() const _NOEXCEPT;
201 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type __capacity() const _NOEXCEPT;
202 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __empty() const _NOEXCEPT;
203 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __end_ptr() _NOEXCEPT;
204 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer __end_ptr() const _NOEXCEPT;
205 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer __capacity_ptr() _NOEXCEPT;
206 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer __capacity_ptr() const _NOEXCEPT;
207 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const _NOEXCEPT;
208
209private:
210 pointer __begin_ = nullptr;
211
212#ifdef _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
213 size_type __size_ = 0;
214 size_type __capacity_ = 0;
215 _LIBCPP_NO_UNIQUE_ADDRESS allocator_type __alloc_;
216#else
217 pointer __end_ = nullptr;
218 _LIBCPP_COMPRESSED_PAIR(pointer, __capacity_ = nullptr, allocator_type, __alloc_);
219#endif
220
221 _LIBCPP_CONSTEXPR_SINCE_CXX20
222 _LIBCPP_HIDE_FROM_ABI void __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
223 std::__annotate_contiguous_container<_Allocator>(__data(), __data() + __capacity(), __old_mid, __new_mid);
224 }
225
226 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
227 __annotate_contiguous_container(__data() + __capacity(), __data() + __current_size);
228 }
229
230 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
231 __annotate_contiguous_container(__data() + __size(), __data() + __capacity());
232 }
233};
234
235#ifdef _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
236template <class _Tp, class _Alloc>
237_LIBCPP_CONSTEXPR_SINCE_CXX20 __vector_layout<_Tp, _Alloc>::__vector_layout(__vector_layout&& __other)
238 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
239 : __begin_(std::__exchange(__other.__begin_, nullptr)),
240 __size_(std::__exchange(__other.__size_, 0)),
241 __capacity_(std::__exchange(__other.__capacity_, 0)),
242 __alloc_(std::move(__other.__alloc_)) {}
243
244template <class _Tp, class _Alloc>
245_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
246__vector_layout<_Tp, _Alloc>::__remaining_capacity() const _NOEXCEPT {
247 return __capacity_ - __size_;
248}
249
250template <class _Tp, class _Alloc>
251_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__set_layout(
252 pointer __new_begin, size_type __new_size, size_type __new_capacity) _NOEXCEPT {
253 __begin_ = __new_begin;
254 __size_ = __new_size;
255 __capacity_ = __new_capacity;
256}
257
258template <class _Tp, class _Alloc>
259_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__set_bound_using_pointer(pointer __ptr) _NOEXCEPT {
260 __size_ = static_cast<size_type>(__ptr - __begin_);
261}
262
263template <class _Tp, class _Alloc>
264_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__reset_without_allocator() _NOEXCEPT {
265 __begin_ = nullptr;
266 __size_ = 0;
267 __capacity_ = 0;
268}
269
270template <class _Tp, class _Alloc>
271_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__swap(__vector_layout& __other) _NOEXCEPT {
272 using std::swap;
273 swap(__begin_, __other.__begin_);
274 swap(__size_, __other.__size_);
275 swap(__capacity_, __other.__capacity_);
276 std::__swap_allocator(__alloc_, __other.__alloc_);
277}
278
279template <class _Tp, class _Alloc>
280_LIBCPP_CONSTEXPR_SINCE_CXX20 void
281__vector_layout<_Tp, _Alloc>::__move_assign_without_allocator(__vector_layout& __other) _NOEXCEPT {
282 __begin_ = __other.__begin_;
283 __size_ = __other.__size_;
284 __capacity_ = __other.__capacity_;
285
286 __other.__reset_without_allocator();
287}
288
289template <class _Tp, class _Alloc>
290_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__relocate(_SplitBuffer& __buffer) {
291 __annotate_delete();
292 __buffer.__relocate(__begin_, __size_, __capacity_);
293 __annotate_new(__size_);
294}
295
296template <class _Tp, class _Alloc>
297_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
298__vector_layout<_Tp, _Alloc>::__relocate_with_pivot(_SplitBuffer& __buffer, pointer __pivot) {
299 __annotate_delete();
300 auto __result = __buffer.__relocate_with_pivot(__pivot, __begin_, __size_, __capacity_);
301 __annotate_new(__size_);
302 return __result;
303}
304
305template <class _Tp, class _Alloc>
306_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
307__vector_layout<_Tp, _Alloc>::__size() const _NOEXCEPT {
308 return __size_;
309}
310
311template <class _Tp, class _Alloc>
312_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
313__vector_layout<_Tp, _Alloc>::__capacity() const _NOEXCEPT {
314 return __capacity_;
315}
316
317template <class _Tp, class _Alloc>
318_LIBCPP_CONSTEXPR_SINCE_CXX20 bool __vector_layout<_Tp, _Alloc>::__empty() const _NOEXCEPT {
319 return __size_ == 0;
320}
321
322template <class _Tp, class _Alloc>
323_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
324__vector_layout<_Tp, _Alloc>::__end_ptr() _NOEXCEPT {
325 return __begin_ + __size_;
326}
327
328template <class _Tp, class _Alloc>
329_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::const_pointer
330__vector_layout<_Tp, _Alloc>::__end_ptr() const _NOEXCEPT {
331 return __begin_ + __size_;
332}
333
334template <class _Tp, class _Alloc>
335_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
336__vector_layout<_Tp, _Alloc>::__capacity_ptr() _NOEXCEPT {
337 return __begin_ + __capacity_;
338}
339
340template <class _Tp, class _Alloc>
341_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::const_pointer
342__vector_layout<_Tp, _Alloc>::__capacity_ptr() const _NOEXCEPT {
343 return __begin_ + __capacity_;
344}
345
346template <class _Tp, class _Alloc>
347_LIBCPP_CONSTEXPR_SINCE_CXX20 bool __vector_layout<_Tp, _Alloc>::__invariants() const _NOEXCEPT {
348 if (__begin_ == nullptr)
349 return __size_ == 0 && __capacity_ == 0;
350 return __size_ <= __capacity_;
351}
352#else // !defined(_LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED)
353template <class _Tp, class _Alloc>
354_LIBCPP_CONSTEXPR_SINCE_CXX20 __vector_layout<_Tp, _Alloc>::__vector_layout(__vector_layout&& __other)
355 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
356 : __begin_(std::__exchange(__other.__begin_, nullptr)),
357 __end_(std::__exchange(__other.__end_, nullptr)),
358 __capacity_(std::__exchange(__other.__capacity_, nullptr)),
359 __alloc_(std::move(__other.__alloc_)) {}
360
361template <class _Tp, class _Alloc>
362_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
363__vector_layout<_Tp, _Alloc>::__remaining_capacity() const _NOEXCEPT {
364 return __capacity_ - __end_;
365}
366
367template <class _Tp, class _Alloc>
368_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__set_layout(
369 pointer __new_begin, size_type __new_size, size_type __new_capacity) _NOEXCEPT {
370 __begin_ = __new_begin;
371 __end_ = __new_begin + __new_size;
372 __capacity_ = __new_begin + __new_capacity;
373}
374
375template <class _Tp, class _Alloc>
376_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__set_bound_using_pointer(pointer __ptr) _NOEXCEPT {
377 __end_ = __ptr;
378}
379
380template <class _Tp, class _Alloc>
381_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__reset_without_allocator() _NOEXCEPT {
382 __begin_ = nullptr;
383 __end_ = nullptr;
384 __capacity_ = nullptr;
385}
386
387template <class _Tp, class _Alloc>
388_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__swap(__vector_layout& __other) _NOEXCEPT {
389 using std::swap;
390 swap(__begin_, __other.__begin_);
391 swap(__end_, __other.__end_);
392 swap(__capacity_, __other.__capacity_);
393 std::__swap_allocator(__alloc_, __other.__alloc_);
394}
395
396template <class _Tp, class _Alloc>
397_LIBCPP_CONSTEXPR_SINCE_CXX20 void
398__vector_layout<_Tp, _Alloc>::__move_assign_without_allocator(__vector_layout& __other) _NOEXCEPT {
399 __begin_ = __other.__begin_;
400 __end_ = __other.__end_;
401 __capacity_ = __other.__capacity_;
402
403 __other.__reset_without_allocator();
404}
405
406template <class _Tp, class _Alloc>
407_LIBCPP_CONSTEXPR_SINCE_CXX20 void __vector_layout<_Tp, _Alloc>::__relocate(_SplitBuffer& __buffer) {
408 __annotate_delete();
409 __buffer.__relocate(__begin_, __end_, __capacity_);
410 __annotate_new(__size());
411}
412
413template <class _Tp, class _Alloc>
414_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
415__vector_layout<_Tp, _Alloc>::__relocate_with_pivot(_SplitBuffer& __buffer, pointer __pivot) {
416 __annotate_delete();
417 auto __result = __buffer.__relocate_with_pivot(__pivot, __begin_, __end_, __capacity_);
418 __annotate_new(__size());
419 return __result;
420}
421
422template <class _Tp, class _Alloc>
423_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
424__vector_layout<_Tp, _Alloc>::__size() const _NOEXCEPT {
425 return static_cast<size_type>(__end_ - __begin_);
426}
427
428template <class _Tp, class _Alloc>
429_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::size_type
430__vector_layout<_Tp, _Alloc>::__capacity() const _NOEXCEPT {
431 return static_cast<size_type>(__capacity_ - __begin_);
432}
433
434template <class _Tp, class _Alloc>
435_LIBCPP_CONSTEXPR_SINCE_CXX20 bool __vector_layout<_Tp, _Alloc>::__empty() const _NOEXCEPT {
436 return __begin_ == __end_;
437}
438
439template <class _Tp, class _Alloc>
440_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
441__vector_layout<_Tp, _Alloc>::__end_ptr() _NOEXCEPT {
442 return __end_;
443}
444
445template <class _Tp, class _Alloc>
446_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::const_pointer
447__vector_layout<_Tp, _Alloc>::__end_ptr() const _NOEXCEPT {
448 return __end_;
449}
450
451template <class _Tp, class _Alloc>
452_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::pointer
453__vector_layout<_Tp, _Alloc>::__capacity_ptr() _NOEXCEPT {
454 return __capacity_;
455}
456
457template <class _Tp, class _Alloc>
458_LIBCPP_CONSTEXPR_SINCE_CXX20 typename __vector_layout<_Tp, _Alloc>::const_pointer
459__vector_layout<_Tp, _Alloc>::__capacity_ptr() const _NOEXCEPT {
460 return __capacity_;
461}
462
463template <class _Tp, class _Alloc>
464_LIBCPP_CONSTEXPR_SINCE_CXX20 bool __vector_layout<_Tp, _Alloc>::__invariants() const _NOEXCEPT {
465 if (__begin_ == nullptr)
466 return __end_ == nullptr && __capacity_ == nullptr;
467 if (__begin_ > __end_)
468 return false;
469 if (__begin_ == __capacity_)
470 return false;
471 return __end_ <= __capacity_;
472}
473#endif // _LIBCPP_ABI_VECTOR_LAYOUT_SIZE_BASED
474
475_LIBCPP_END_NAMESPACE_STD
476
477_LIBCPP_POP_MACROS
478
479#endif // _LIBCPP___VECTOR_LAYOUT_H
lib/libcxx/include/__vector/vector.h+218-301
......@@ -56,6 +56,7 @@
5656#include <__type_traits/is_nothrow_constructible.h>
5757#include <__type_traits/is_pointer.h>
5858#include <__type_traits/is_same.h>
59#include <__type_traits/is_swappable.h>
5960#include <__type_traits/is_trivially_relocatable.h>
6061#include <__type_traits/type_identity.h>
6162#include <__utility/declval.h>
......@@ -72,6 +73,7 @@
7273// These headers define parts of vectors definition, since they define ADL functions or class specializations.
7374#include <__vector/comparison.h>
7475#include <__vector/container_traits.h>
76#include <__vector/layout.h>
7577#include <__vector/swap.h>
7678
7779#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -85,19 +87,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
8587
8688template <class _Tp, class _Allocator /* = allocator<_Tp> */>
8789class vector {
88 template <class _Up, class _Alloc>
89 using __split_buffer _LIBCPP_NODEBUG = std::__split_buffer<_Up, _Alloc, __split_buffer_pointer_layout>;
90 using __base_type _LIBCPP_NODEBUG = __vector_layout<_Tp, _Allocator>;
91 using __bound_type _LIBCPP_NODEBUG = typename __base_type::__bound_type;
92 using _SplitBuffer _LIBCPP_NODEBUG = typename __base_type::_SplitBuffer;
9093
9194public:
9295 //
9396 // Types
9497 //
95 using __self _LIBCPP_NODEBUG = vector;
9698 using value_type = _Tp;
9799 using allocator_type = _Allocator;
98 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<allocator_type>;
99 using reference = value_type&;
100 using const_reference = const value_type&;
100 using __alloc_traits _LIBCPP_NODEBUG = allocator_traits<_Allocator>;
101 using reference = _Tp&;
102 using const_reference = const _Tp&;
101103 using size_type = typename __alloc_traits::size_type;
102104 using difference_type = typename __alloc_traits::difference_type;
103105 using pointer = typename __alloc_traits::pointer;
......@@ -106,8 +108,8 @@ public:
106108 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
107109 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
108110 // considered contiguous.
109 using iterator = __bounded_iter<__wrap_iter<pointer> >;
110 using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >;
111 using iterator = __bounded_iter<pointer>;
112 using const_iterator = __bounded_iter<const_pointer>;
111113#else
112114 using iterator = __wrap_iter<pointer>;
113115 using const_iterator = __wrap_iter<const_pointer>;
......@@ -139,7 +141,7 @@ public:
139141#else
140142 noexcept
141143#endif
142 : __alloc_(__a) {
144 : __layout_(__a) {
143145 }
144146
145147 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {
......@@ -151,9 +153,8 @@ public:
151153 __guard.__complete();
152154 }
153155
154#if _LIBCPP_STD_VER >= 14
155156 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
156 : __alloc_(__a) {
157 : __layout_(__a) {
157158 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
158159 if (__n > 0) {
159160 __vallocate(__n);
......@@ -161,7 +162,6 @@ public:
161162 }
162163 __guard.__complete();
163164 }
164#endif
165165
166166 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
167167 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
......@@ -175,7 +175,7 @@ public:
175175 template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
176176 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
177177 vector(size_type __n, const value_type& __x, const allocator_type& __a)
178 : __alloc_(__a) {
178 : __layout_(__a) {
179179 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
180180 if (__n > 0) {
181181 __vallocate(__n);
......@@ -198,7 +198,7 @@ public:
198198 int> = 0>
199199 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
200200 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
201 : __alloc_(__a) {
201 : __layout_(__a) {
202202 __init_with_sentinel(__first, __last);
203203 }
204204
......@@ -219,16 +219,15 @@ public:
219219 int> = 0>
220220 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
221221 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a)
222 : __alloc_(__a) {
222 : __layout_(__a) {
223223 size_type __n = static_cast<size_type>(std::distance(__first, __last));
224224 __init_with_size(__first, __last, __n);
225225 }
226226
227227#if _LIBCPP_STD_VER >= 23
228228 template <_ContainerCompatibleRange<_Tp> _Range>
229 _LIBCPP_HIDE_FROM_ABI constexpr vector(
230 from_range_t, _Range&& __range, const allocator_type& __alloc = allocator_type())
231 : __alloc_(__alloc) {
229 _LIBCPP_HIDE_FROM_ABI constexpr vector(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
230 : __layout_(__a) {
232231 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
233232 auto __n = static_cast<size_type>(ranges::distance(__range));
234233 __init_with_size(ranges::begin(__range), ranges::end(__range), __n);
......@@ -245,10 +244,10 @@ private:
245244 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI __destroy_vector(vector& __vec) : __vec_(__vec) {}
246245
247246 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void operator()() {
248 if (__vec_.__begin_ != nullptr) {
247 if (__vec_.__layout_.__begin_ptr() != nullptr) {
249248 __vec_.clear();
250249 __vec_.__annotate_delete();
251 __alloc_traits::deallocate(__vec_.__alloc_, __vec_.__begin_, __vec_.capacity());
250 __alloc_traits::deallocate(__vec_.__layout_.__alloc(), __vec_.__layout_.__begin_ptr(), __vec_.capacity());
252251 }
253252 }
254253
......@@ -256,17 +255,19 @@ private:
256255 vector& __vec_;
257256 };
258257
258 using __emplace_back_result_t _LIBCPP_NODEBUG = _If<(_LIBCPP_STD_VER < 17), void, reference>;
259
259260public:
260261 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~vector() { __destroy_vector (*this)(); }
261262
262263 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(const vector& __x)
263 : __alloc_(__alloc_traits::select_on_container_copy_construction(__x.__alloc_)) {
264 __init_with_size(__x.__begin_, __x.__end_, __x.size());
264 : __layout_(__alloc_traits::select_on_container_copy_construction(__x.__layout_.__alloc())) {
265 __init_with_size(__x.__layout_.__begin_ptr(), __x.__layout_.__end_ptr(), __x.size());
265266 }
266267 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
267268 vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
268 : __alloc_(__a) {
269 __init_with_size(__x.__begin_, __x.__end_, __x.size());
269 : __layout_(__a) {
270 __init_with_size(__x.__layout_.__begin_ptr(), __x.__layout_.__end_ptr(), __x.size());
270271 }
271272 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(const vector& __x);
272273
......@@ -277,7 +278,7 @@ public:
277278
278279 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
279280 vector(initializer_list<value_type> __il, const allocator_type& __a)
280 : __alloc_(__a) {
281 : __layout_(__a) {
281282 __init_with_size(__il.begin(), __il.end(), __il.size());
282283 }
283284
......@@ -294,8 +295,8 @@ public:
294295 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
295296#endif
296297
297 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
298 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
298 _LIBCPP_CONSTEXPR_SINCE_CXX20
299 _LIBCPP_HIDE_FROM_ABI vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
299300 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)
300301 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
301302 __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
......@@ -340,23 +341,23 @@ public:
340341#endif
341342
342343 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
343 return this->__alloc_;
344 return this->__layout_.__alloc();
344345 }
345346
346347 //
347348 // Iterators
348349 //
349350 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
350 return __make_iter(__add_alignment_assumption(this->__begin_));
351 return __make_iter(__add_alignment_assumption(this->__layout_.__begin_ptr()));
351352 }
352353 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
353 return __make_iter(__add_alignment_assumption(this->__begin_));
354 return __make_iter(__add_alignment_assumption(this->__layout_.__begin_ptr()));
354355 }
355356 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {
356 return __make_iter(__add_alignment_assumption(this->__end_));
357 return __make_iter(__add_alignment_assumption(__layout_.__end_ptr()));
357358 }
358359 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
359 return __make_iter(__add_alignment_assumption(this->__end_));
360 return __make_iter(__add_alignment_assumption(__layout_.__end_ptr()));
360361 }
361362
362363 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {
......@@ -391,16 +392,17 @@ public:
391392 // [vector.capacity], capacity
392393 //
393394 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT {
394 return static_cast<size_type>(this->__end_ - this->__begin_);
395 return __layout_.__size();
395396 }
396397 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {
397 return static_cast<size_type>(this->__cap_ - this->__begin_);
398 return __layout_.__capacity();
398399 }
399400 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
400 return this->__begin_ == this->__end_;
401 return __layout_.__empty();
401402 }
403
402404 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
403 return std::min<size_type>(__alloc_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());
405 return std::min<size_type>(__alloc_traits::max_size(__layout_.__alloc()), numeric_limits<difference_type>::max());
404406 }
405407 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void reserve(size_type __n);
406408 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
......@@ -410,50 +412,50 @@ public:
410412 //
411413 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT {
412414 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
413 return this->__begin_[__n];
415 return this->__layout_.__begin_ptr()[__n];
414416 }
415417 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference
416418 operator[](size_type __n) const _NOEXCEPT {
417419 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
418 return this->__begin_[__n];
420 return this->__layout_.__begin_ptr()[__n];
419421 }
420422 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) {
421423 if (__n >= size())
422424 this->__throw_out_of_range();
423 return this->__begin_[__n];
425 return this->__layout_.__begin_ptr()[__n];
424426 }
425427 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const {
426428 if (__n >= size())
427429 this->__throw_out_of_range();
428 return this->__begin_[__n];
430 return this->__layout_.__begin_ptr()[__n];
429431 }
430432
431433 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT {
432434 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
433 return *this->__begin_;
435 return *this->__layout_.__begin_ptr();
434436 }
435437 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT {
436438 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "front() called on an empty vector");
437 return *this->__begin_;
439 return *this->__layout_.__begin_ptr();
438440 }
439441 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT {
440442 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
441 return *(this->__end_ - 1);
443 return end()[-1];
442444 }
443445 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT {
444446 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "back() called on an empty vector");
445 return *(this->__end_ - 1);
447 return end()[-1];
446448 }
447449
448450 //
449451 // [vector.data], data access
450452 //
451453 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT {
452 return std::__to_address(this->__begin_);
454 return __layout_.__data();
453455 }
454456
455457 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT {
456 return std::__to_address(this->__begin_);
458 return __layout_.__data();
457459 }
458460
459461 //
......@@ -464,21 +466,15 @@ public:
464466 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x) { emplace_back(std::move(__x)); }
465467
466468 template <class... _Args>
467 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
468#if _LIBCPP_STD_VER >= 17
469 reference
470 emplace_back(_Args&&... __args);
471#else
472 void
473 emplace_back(_Args&&... __args);
474#endif
469 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __emplace_back_result_t emplace_back(_Args&&... __args);
475470
476471 template <class... _Args>
477472 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __emplace_back_assume_capacity(_Args&&... __args) {
478473 _LIBCPP_ASSERT_INTERNAL(
479474 size() < capacity(), "We assume that we have enough space to insert an element at the end of the vector");
480475 _ConstructTransaction __tx(*this, 1);
481 __alloc_traits::construct(this->__alloc_, std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
476 __alloc_traits::construct(
477 this->__layout_.__alloc(), std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);
482478 ++__tx.__pos_;
483479 }
484480
......@@ -487,15 +483,15 @@ public:
487483 _LIBCPP_HIDE_FROM_ABI constexpr void append_range(_Range&& __range) {
488484 if constexpr (ranges::forward_range<_Range> || ranges::sized_range<_Range>) {
489485 auto __len = ranges::distance(__range);
490 if (__len <= __cap_ - __end_) {
486 if (__len <= static_cast<difference_type>(__layout_.__remaining_capacity())) {
491487 __construct_at_end(ranges::begin(__range), ranges::end(__range), __len);
492488 } else {
493 __split_buffer<value_type, allocator_type> __buffer(__recommend(size() + __len), size(), __alloc_);
489 _SplitBuffer __buffer(__recommend(size() + __len), size(), __layout_.__alloc());
494490 __buffer.__construct_at_end_with_size(ranges::begin(__range), __len);
495 __swap_out_circular_buffer(__buffer);
491 __layout_.__relocate(__buffer);
496492 }
497493 } else {
498 vector __buffer(__alloc_);
494 vector __buffer(__layout_.__alloc());
499495 for (auto&& __val : __range)
500496 __buffer.emplace_back(std::forward<decltype(__val)>(__val));
501497 append_range(ranges::as_rvalue_view(__buffer));
......@@ -505,7 +501,7 @@ public:
505501
506502 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void pop_back() {
507503 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "vector::pop_back called on an empty vector");
508 this->__destruct_at_end(this->__end_ - 1);
504 this->__destruct_at_end(__layout_.__end_ptr() - 1);
509505 }
510506
511507 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, const_reference __x);
......@@ -550,8 +546,8 @@ public:
550546#endif
551547
552548#ifndef _LIBCPP_CXX03_LANG
553 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator
554 insert(const_iterator __position, initializer_list<value_type> __il) {
549 _LIBCPP_CONSTEXPR_SINCE_CXX20
550 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __position, initializer_list<value_type> __il) {
555551 return insert(__position, __il.begin(), __il.end());
556552 }
557553#endif
......@@ -561,7 +557,7 @@ public:
561557
562558 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT {
563559 size_type __old_size = size();
564 __base_destruct_at_end(this->__begin_);
560 __base_destruct_at_end(this->__layout_.__begin_ptr());
565561 __annotate_shrink(__old_size);
566562 }
567563
......@@ -575,27 +571,41 @@ public:
575571 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
576572#endif
577573
578 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
574 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const _NOEXCEPT {
575 return __layout_.__invariants();
576 }
579577
580578private:
581 pointer __begin_ = nullptr;
582 pointer __end_ = nullptr;
583 _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_);
579 __base_type __layout_;
584580
585581 // Allocate space for __n objects
586582 // throws length_error if __n > max_size()
587583 // throws (probably bad_alloc) if memory run out
588 // Precondition: __begin_ == __end_ == __cap_ == nullptr
584 // Precondition: begin() == nullptr
585 // Precondition: size() == 0
586 // Precondition: capacity() == 0
589587 // Precondition: __n > 0
590588 // Postcondition: capacity() >= __n
591589 // Postcondition: size() == 0
592590 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
591 _LIBCPP_ASSERT_INTERNAL(
592 __layout_.__begin_ptr() == nullptr,
593 "vector::__vallocate can only be called on a vector that hasn't allocated memory. This vector either already "
594 "owns a buffer, or a deallocation function didn't reset the layout's begin pointer.");
595 _LIBCPP_ASSERT_INTERNAL(
596 size() == 0,
597 "vector::__vallocate can only be called on a vector that hasn't allocated memory. This vector either already "
598 "owns a buffer, or a deallocation function didn't reset the layout's size.");
599 _LIBCPP_ASSERT_INTERNAL(
600 __layout_.__capacity() == 0,
601 "vector::__vallocate can only be called on a vector that hasn't allocated memory. This vector either already "
602 "owns a buffer, or a deallocation function didn't reset the layout's capacity.");
603 _LIBCPP_ASSERT_INTERNAL(__n > 0, "vector::__vallocate cannot allocate 0 bytes");
604
593605 if (__n > max_size())
594606 this->__throw_length_error();
595 auto __allocation = std::__allocate_at_least(this->__alloc_, __n);
596 __begin_ = __allocation.ptr;
597 __end_ = __allocation.ptr;
598 __cap_ = __begin_ + __allocation.count;
607 auto __allocation = std::__allocate_at_least(this->__layout_.__alloc(), __n);
608 __layout_.__set_layout(__allocation.ptr, 0, __allocation.count);
599609 __annotate_new(0);
600610 }
601611
......@@ -644,7 +654,7 @@ private:
644654 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
645655 __insert_assign_n_unchecked(_Iterator __first, difference_type __n, pointer __position) {
646656 for (pointer __end_position = __position + __n; __position != __end_position; ++__position, (void)++__first) {
647 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, *__first);
657 __temp_value<value_type, _Allocator> __tmp(this->__layout_.__alloc(), *__first);
648658 *__position = std::move(__tmp.get());
649659 }
650660 }
......@@ -680,10 +690,7 @@ private:
680690 // current implementation, there is no connection between a bounded iterator and its associated container, so we
681691 // don't have a way to update existing valid iterators when the container is resized and thus have to go with
682692 // a laxer approach.
683 return std::__make_bounded_iter(
684 std::__wrap_iter<pointer>(__p),
685 std::__wrap_iter<pointer>(this->__begin_),
686 std::__wrap_iter<pointer>(this->__cap_));
693 return std::__make_bounded_iter(__p, __layout_.__begin_ptr(), __layout_.__capacity_ptr());
687694#else
688695 return iterator(__p);
689696#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
......@@ -692,19 +699,12 @@ private:
692699 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {
693700#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
694701 // Bound the iterator according to the capacity, rather than the size.
695 return std::__make_bounded_iter(
696 std::__wrap_iter<const_pointer>(__p),
697 std::__wrap_iter<const_pointer>(this->__begin_),
698 std::__wrap_iter<const_pointer>(this->__cap_));
702 return std::__make_bounded_iter(__p, __layout_.__begin_ptr(), __layout_.__capacity_ptr());
699703#else
700704 return const_iterator(__p);
701705#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
702706 }
703707
704 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
705 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v);
706 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
707 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p);
708708 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
709709 __move_range(pointer __from_s, pointer __from_e, pointer __to);
710710 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
......@@ -751,14 +751,14 @@ private:
751751
752752 struct _ConstructTransaction {
753753 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n)
754 : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
754 : __v_(__v), __pos_(__v.__layout_.__end_ptr()), __new_end_(__pos_ + __n) {
755755 __v_.__annotate_increase(__n);
756756 }
757757
758758 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
759 __v_.__end_ = __pos_;
759 __v_.__layout_.__set_bound_using_pointer(__pos_);
760760 if (__pos_ != __new_end_) {
761 __v_.__annotate_shrink(__new_end_ - __v_.__begin_);
761 __v_.__annotate_shrink(__new_end_ - __v_.__layout_.__begin_ptr());
762762 }
763763 }
764764
......@@ -771,10 +771,10 @@ private:
771771 };
772772
773773 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
774 pointer __soon_to_be_end = this->__end_;
774 pointer __soon_to_be_end = __layout_.__end_ptr();
775775 while (__new_last != __soon_to_be_end)
776 __alloc_traits::destroy(this->__alloc_, std::__to_address(--__soon_to_be_end));
777 this->__end_ = __new_last;
776 __alloc_traits::destroy(this->__layout_.__alloc(), std::__to_address(--__soon_to_be_end));
777 __layout_.__set_bound_using_pointer(__new_last);
778778 }
779779
780780 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c) {
......@@ -792,56 +792,38 @@ private:
792792 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI static void __throw_out_of_range() { std::__throw_out_of_range("vector"); }
793793
794794 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector& __c, true_type) {
795 if (this->__alloc_ != __c.__alloc_) {
795 if (this->__layout_.__alloc() != __c.__layout_.__alloc()) {
796796 clear();
797797 __annotate_delete();
798 __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());
799 this->__begin_ = this->__end_ = this->__cap_ = nullptr;
798 __alloc_traits::deallocate(this->__layout_.__alloc(), this->__layout_.__begin_ptr(), capacity());
799 __layout_.__reset_without_allocator();
800800 }
801 this->__alloc_ = __c.__alloc_;
801 this->__layout_.__alloc() = __c.__layout_.__alloc();
802802 }
803803
804804 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const vector&, false_type) {}
805805
806806 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector& __c, true_type)
807807 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
808 this->__alloc_ = std::move(__c.__alloc_);
808 this->__layout_.__alloc() = std::move(__c.__layout_.__alloc());
809809 }
810810
811811 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(vector&, false_type) _NOEXCEPT {}
812812
813813 template <class _Ptr = pointer, __enable_if_t<is_pointer<_Ptr>::value, int> = 0>
814 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer
814 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Ptr
815815 __add_alignment_assumption(_Ptr __p) _NOEXCEPT {
816816 if (!__libcpp_is_constant_evaluated()) {
817 return static_cast<pointer>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));
817 return static_cast<_Ptr>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));
818818 }
819819 return __p;
820820 }
821821
822822 template <class _Ptr = pointer, __enable_if_t<!is_pointer<_Ptr>::value, int> = 0>
823 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI pointer
823 static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Ptr
824824 __add_alignment_assumption(_Ptr __p) _NOEXCEPT {
825825 return __p;
826826 }
827
828 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_layouts(__split_buffer<_Tp, allocator_type>& __sb) {
829 auto __vector_begin = __begin_;
830 auto __vector_sentinel = __end_;
831 auto __vector_cap = __cap_;
832
833 auto __sb_begin = __sb.begin();
834 auto __sb_sentinel = __sb.__raw_sentinel();
835 auto __sb_cap = __sb.__raw_capacity();
836
837 // TODO: replace with __set_valid_range and __set_capacity when vector supports it.
838 __begin_ = __sb_begin;
839 __end_ = __sb_sentinel;
840 __cap_ = __sb_cap;
841
842 __sb.__set_valid_range(__vector_begin, __vector_sentinel);
843 __sb.__set_capacity(__vector_cap);
844 }
845827};
846828
847829#if _LIBCPP_STD_VER >= 17
......@@ -865,60 +847,13 @@ template <ranges::input_range _Range,
865847vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;
866848#endif
867849
868// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
869// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
870// function has a strong exception guarantee.
871template <class _Tp, class _Allocator>
872_LIBCPP_CONSTEXPR_SINCE_CXX20 void
873vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v) {
874 __annotate_delete();
875 auto __new_begin = __v.begin() - size();
876 std::__uninitialized_allocator_relocate(
877 this->__alloc_, std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));
878 __v.__set_valid_range(__new_begin, __v.end());
879 __end_ = __begin_; // All the objects have been destroyed by relocating them.
880
881 __swap_layouts(__v);
882 __v.__set_data(__v.begin());
883 __annotate_new(size());
884}
885
886// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in
887// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for
888// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This
889// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
890template <class _Tp, class _Allocator>
891_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
892vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p) {
893 __annotate_delete();
894 pointer __ret = __v.begin();
895
896 // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)
897 // in case something in [__begin_, __p) throws.
898 std::__uninitialized_allocator_relocate(
899 this->__alloc_, std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.end()));
900 auto __relocated_so_far = __end_ - __p;
901 __v.__set_sentinel(__v.end() + __relocated_so_far);
902 __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.
903 auto __new_begin = __v.begin() - (__p - __begin_);
904
905 std::__uninitialized_allocator_relocate(
906 this->__alloc_, std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));
907 __v.__set_valid_range(__new_begin, __v.end());
908 __end_ = __begin_; // All the objects have been destroyed by relocating them.
909 __swap_layouts(__v);
910 __v.__set_data(__v.begin());
911 __annotate_new(size());
912 return __ret;
913}
914
915850template <class _Tp, class _Allocator>
916851_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT {
917 if (this->__begin_ != nullptr) {
852 if (this->__layout_.__begin_ptr() != nullptr) {
918853 clear();
919854 __annotate_delete();
920 __alloc_traits::deallocate(this->__alloc_, this->__begin_, capacity());
921 this->__begin_ = this->__end_ = this->__cap_ = nullptr;
855 __alloc_traits::deallocate(this->__layout_.__alloc(), this->__layout_.__begin_ptr(), capacity());
856 __layout_.__reset_without_allocator();
922857 }
923858}
924859
......@@ -935,7 +870,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const {
935870 return std::max<size_type>(2 * __cap, __new_size);
936871}
937872
938// Default constructs __n objects starting at __end_
873// Default constructs __n objects starting at __layout_.__end_ptr()
939874// throws if construction throws
940875// Precondition: __n > 0
941876// Precondition: size() + __n <= capacity()
......@@ -945,11 +880,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__construct_at_end(s
945880 _ConstructTransaction __tx(*this, __n);
946881 const_pointer __new_end = __tx.__new_end_;
947882 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
948 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos));
883 __alloc_traits::construct(this->__layout_.__alloc(), std::__to_address(__pos));
949884 }
950885}
951886
952// Copy constructs __n objects starting at __end_ from __x
887// Copy constructs __n objects starting at __layout_.__end_ptr() from __x
953888// throws if construction throws
954889// Precondition: __n > 0
955890// Precondition: size() + __n <= capacity()
......@@ -961,7 +896,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
961896 _ConstructTransaction __tx(*this, __n);
962897 const_pointer __new_end = __tx.__new_end_;
963898 for (pointer __pos = __tx.__pos_; __pos != __new_end; __tx.__pos_ = ++__pos) {
964 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), __x);
899 __alloc_traits::construct(this->__layout_.__alloc(), std::__to_address(__pos), __x);
965900 }
966901}
967902
......@@ -970,7 +905,8 @@ template <class _InputIterator, class _Sentinel>
970905_LIBCPP_CONSTEXPR_SINCE_CXX20 void
971906vector<_Tp, _Allocator>::__construct_at_end(_InputIterator __first, _Sentinel __last, size_type __n) {
972907 _ConstructTransaction __tx(*this, __n);
973 __tx.__pos_ = std::__uninitialized_allocator_copy(this->__alloc_, std::move(__first), std::move(__last), __tx.__pos_);
908 __tx.__pos_ = std::__uninitialized_allocator_copy(
909 this->__layout_.__alloc(), std::move(__first), std::move(__last), __tx.__pos_);
974910}
975911
976912template <class _Tp, class _Allocator>
......@@ -980,22 +916,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocato
980916#else
981917 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
982918#endif
983 : __alloc_(std::move(__x.__alloc_)) {
984 this->__begin_ = __x.__begin_;
985 this->__end_ = __x.__end_;
986 this->__cap_ = __x.__cap_;
987 __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;
919 : __layout_(std::move(__x.__layout_)) {
988920}
989921
990922template <class _Tp, class _Allocator>
991923_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI
992924vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
993 : __alloc_(__a) {
994 if (__a == __x.__alloc_) {
995 this->__begin_ = __x.__begin_;
996 this->__end_ = __x.__end_;
997 this->__cap_ = __x.__cap_;
998 __x.__begin_ = __x.__end_ = __x.__cap_ = nullptr;
925 : __layout_(__a) {
926 if (__a == __x.__layout_.__alloc()) {
927 __layout_.__move_assign_without_allocator(__x.__layout_);
999928 } else {
1000929 typedef move_iterator<iterator> _Ip;
1001930 __init_with_size(_Ip(__x.begin()), _Ip(__x.end()), __x.size());
......@@ -1005,7 +934,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
1005934template <class _Tp, class _Allocator>
1006935_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
1007936 _NOEXCEPT_(__alloc_traits::is_always_equal::value) {
1008 if (this->__alloc_ != __c.__alloc_) {
937 if (this->__layout_.__alloc() != __c.__layout_.__alloc()) {
1009938 typedef move_iterator<iterator> _Ip;
1010939 assign(_Ip(__c.begin()), _Ip(__c.end()));
1011940 } else
......@@ -1017,10 +946,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__move_assign(vector
1017946 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
1018947 __vdeallocate();
1019948 __move_assign_alloc(__c); // this can throw
1020 this->__begin_ = __c.__begin_;
1021 this->__end_ = __c.__end_;
1022 this->__cap_ = __c.__cap_;
1023 __c.__begin_ = __c.__end_ = __c.__cap_ = nullptr;
949 __layout_.__move_assign_without_allocator(__c.__layout_);
1024950}
1025951
1026952template <class _Tp, class _Allocator>
......@@ -1028,7 +954,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocato
1028954vector<_Tp, _Allocator>::operator=(const vector& __x) {
1029955 if (this != std::addressof(__x)) {
1030956 __copy_assign_alloc(__x);
1031 assign(__x.__begin_, __x.__end_);
957 assign(__x.__layout_.__begin_ptr(), __x.__layout_.__end_ptr());
1032958 }
1033959 return *this;
1034960}
......@@ -1037,10 +963,11 @@ template <class _Tp, class _Allocator>
1037963template <class _Iterator, class _Sentinel>
1038964_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1039965vector<_Tp, _Allocator>::__assign_with_sentinel(_Iterator __first, _Sentinel __last) {
1040 pointer __cur = __begin_;
1041 for (; __first != __last && __cur != __end_; ++__first, (void)++__cur)
966 pointer __cur = __layout_.__begin_ptr();
967 pointer __end = __layout_.__end_ptr();
968 for (; __first != __last && __cur != __end; ++__first, (void)++__cur)
1042969 *__cur = *__first;
1043 if (__cur != __end_) {
970 if (__cur != __end) {
1044971 __destruct_at_end(__cur);
1045972 } else {
1046973 for (; __first != __last; ++__first)
......@@ -1054,11 +981,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
1054981vector<_Tp, _Allocator>::__assign_with_size(_Iterator __first, _Sentinel __last, difference_type __n) {
1055982 size_type __new_size = static_cast<size_type>(__n);
1056983 if (__new_size <= capacity()) {
1057 if (__new_size > size()) {
1058 auto __mid = std::__copy_n<_AlgPolicy>(std::move(__first), size(), this->__begin_).first;
1059 __construct_at_end(std::move(__mid), std::move(__last), __new_size - size());
984 auto const __size = size();
985 if (__new_size > __size) {
986 auto __mid = std::__copy_n<_AlgPolicy>(std::move(__first), __size, this->__layout_.__begin_ptr()).__in_;
987 __construct_at_end(std::move(__mid), std::move(__last), __new_size - __size);
1060988 } else {
1061 pointer __m = std::__copy(std::move(__first), __last, this->__begin_).second;
989 pointer __m = std::__copy(std::move(__first), __last, this->__layout_.__begin_ptr()).__out_;
1062990 this->__destruct_at_end(__m);
1063991 }
1064992 } else {
......@@ -1072,11 +1000,11 @@ template <class _Tp, class _Allocator>
10721000_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) {
10731001 if (__n <= capacity()) {
10741002 size_type __s = size();
1075 std::fill_n(this->__begin_, std::min(__n, __s), __u);
1003 std::fill_n(this->__layout_.__begin_ptr(), std::min(__n, __s), __u);
10761004 if (__n > __s)
10771005 __construct_at_end(__n - __s, __u);
10781006 else
1079 this->__destruct_at_end(this->__begin_ + __n);
1007 this->__destruct_at_end(this->__layout_.__begin_ptr() + __n);
10801008 } else {
10811009 __vdeallocate();
10821010 __vallocate(__recommend(static_cast<size_type>(__n)));
......@@ -1089,8 +1017,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __
10891017 if (__n > capacity()) {
10901018 if (__n > max_size())
10911019 this->__throw_length_error();
1092 __split_buffer<value_type, allocator_type> __v(__n, size(), this->__alloc_);
1093 __swap_out_circular_buffer(__v);
1020 _SplitBuffer __v(__n, size(), this->__layout_.__alloc());
1021 __layout_.__relocate(__v);
10941022 }
10951023}
10961024
......@@ -1100,12 +1028,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE
11001028#if _LIBCPP_HAS_EXCEPTIONS
11011029 try {
11021030#endif // _LIBCPP_HAS_EXCEPTIONS
1103 __split_buffer<value_type, allocator_type> __v(size(), size(), this->__alloc_);
1031 _SplitBuffer __v(size(), size(), this->__layout_.__alloc());
11041032 // The Standard mandates shrink_to_fit() does not increase the capacity.
11051033 // With equal capacity keep the existing buffer. This avoids extra work
11061034 // due to swapping the elements.
11071035 if (__v.capacity() < capacity())
1108 __swap_out_circular_buffer(__v);
1036 __layout_.__relocate(__v);
11091037#if _LIBCPP_HAS_EXCEPTIONS
11101038 } catch (...) {
11111039 }
......@@ -1117,13 +1045,13 @@ template <class _Tp, class _Allocator>
11171045template <class... _Args>
11181046_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
11191047vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {
1120 __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), size(), this->__alloc_);
1048 _SplitBuffer __v(__recommend(size() + 1), size(), this->__layout_.__alloc());
11211049 // __v.emplace_back(std::forward<_Args>(__args)...);
11221050 pointer __end = __v.end();
1123 __alloc_traits::construct(this->__alloc_, std::__to_address(__end), std::forward<_Args>(__args)...);
1051 __alloc_traits::construct(this->__layout_.__alloc(), std::__to_address(__end), std::forward<_Args>(__args)...);
11241052 __v.__set_sentinel(++__end);
1125 __swap_out_circular_buffer(__v);
1126 return this->__end_;
1053 __layout_.__relocate(__v);
1054 return __end;
11271055}
11281056
11291057// This makes the compiler inline `__else()` if `__cond` is known to be false. Currently LLVM doesn't do that without
......@@ -1144,27 +1072,22 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __if_likely_else(bool _
11441072 }
11451073}
11461074
1147template <class _Tp, class _Allocator>
1075template <class _Tp, class _Alloc>
11481076template <class... _Args>
1149_LIBCPP_CONSTEXPR_SINCE_CXX20 inline
1150#if _LIBCPP_STD_VER >= 17
1151 typename vector<_Tp, _Allocator>::reference
1152#else
1153 void
1154#endif
1155 vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) {
1156 pointer __end = this->__end_;
1077_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Alloc>::__emplace_back_result_t
1078vector<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
1079 pointer __end = __layout_.__end_ptr();
11571080 std::__if_likely_else(
1158 __end < this->__cap_,
1081 size() != capacity(),
11591082 [&] {
11601083 __emplace_back_assume_capacity(std::forward<_Args>(__args)...);
11611084 ++__end;
11621085 },
11631086 [&] { __end = __emplace_back_slow_path(std::forward<_Args>(__args)...); });
11641087
1165 this->__end_ = __end;
1088 __layout_.__set_bound_using_pointer(__end);
11661089#if _LIBCPP_STD_VER >= 17
1167 return *(__end - 1);
1090 return back();
11681091#endif
11691092}
11701093
......@@ -1174,8 +1097,8 @@ vector<_Tp, _Allocator>::erase(const_iterator __position) {
11741097 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
11751098 __position != end(), "vector::erase(iterator) called with a non-dereferenceable iterator");
11761099 difference_type __ps = __position - cbegin();
1177 pointer __p = this->__begin_ + __ps;
1178 this->__destruct_at_end(std::move(__p + 1, this->__end_, __p));
1100 pointer __p = this->__layout_.__begin_ptr() + __ps;
1101 this->__destruct_at_end(std::move(__p + 1, __layout_.__end_ptr(), __p));
11791102 return __make_iter(__p);
11801103}
11811104
......@@ -1183,9 +1106,9 @@ template <class _Tp, class _Allocator>
11831106_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
11841107vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {
11851108 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__first <= __last, "vector::erase(first, last) called with invalid range");
1186 pointer __p = this->__begin_ + (__first - begin());
1109 pointer __p = this->__layout_.__begin_ptr() + (__first - begin());
11871110 if (__first != __last) {
1188 this->__destruct_at_end(std::move(__p + (__last - __first), this->__end_, __p));
1111 this->__destruct_at_end(std::move(__p + (__last - __first), __layout_.__end_ptr(), __p));
11891112 }
11901113 return __make_iter(__p);
11911114}
......@@ -1193,13 +1116,13 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last) {
11931116template <class _Tp, class _Allocator>
11941117_LIBCPP_CONSTEXPR_SINCE_CXX20 void
11951118vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to) {
1196 pointer __old_last = this->__end_;
1119 pointer __old_last = __layout_.__end_ptr();
11971120 difference_type __n = __old_last - __to;
11981121 {
11991122 pointer __i = __from_s + __n;
12001123 _ConstructTransaction __tx(*this, __from_e - __i);
12011124 for (pointer __pos = __tx.__pos_; __i < __from_e; ++__i, (void)++__pos, __tx.__pos_ = __pos) {
1202 __alloc_traits::construct(this->__alloc_, std::__to_address(__pos), std::move(*__i));
1125 __alloc_traits::construct(this->__layout_.__alloc(), std::__to_address(__pos), std::move(*__i));
12031126 }
12041127 }
12051128 std::move_backward(__from_s, __from_s + __n, __old_last);
......@@ -1208,21 +1131,22 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
12081131template <class _Tp, class _Allocator>
12091132_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
12101133vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {
1211 pointer __p = this->__begin_ + (__position - begin());
1212 if (this->__end_ < this->__cap_) {
1213 if (__p == this->__end_) {
1134 pointer __p = this->__layout_.__begin_ptr() + (__position - begin());
1135 if (size() != capacity()) {
1136 pointer __end = __layout_.__end_ptr();
1137 if (__p == __end) {
12141138 __emplace_back_assume_capacity(__x);
12151139 } else {
1216 __move_range(__p, this->__end_, __p + 1);
1140 __move_range(__p, __end, __p + 1);
12171141 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1218 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
1142 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end), std::addressof(__x)))
12191143 ++__xr;
12201144 *__p = *__xr;
12211145 }
12221146 } else {
1223 __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1147 _SplitBuffer __v(__recommend(size() + 1), __p - this->__layout_.__begin_ptr(), this->__layout_.__alloc());
12241148 __v.emplace_back(__x);
1225 __p = __swap_out_circular_buffer(__v, __p);
1149 __p = __layout_.__relocate_with_pivot(__v, __p);
12261150 }
12271151 return __make_iter(__p);
12281152}
......@@ -1230,18 +1154,19 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
12301154template <class _Tp, class _Allocator>
12311155_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
12321156vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
1233 pointer __p = this->__begin_ + (__position - begin());
1234 if (this->__end_ < this->__cap_) {
1235 if (__p == this->__end_) {
1157 pointer __p = this->__layout_.__begin_ptr() + (__position - begin());
1158 if (size() != capacity()) {
1159 pointer __end = __layout_.__end_ptr();
1160 if (__p == __end) {
12361161 __emplace_back_assume_capacity(std::move(__x));
12371162 } else {
1238 __move_range(__p, this->__end_, __p + 1);
1163 __move_range(__p, __end, __p + 1);
12391164 *__p = std::move(__x);
12401165 }
12411166 } else {
1242 __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1167 _SplitBuffer __v(__recommend(size() + 1), __p - this->__layout_.__begin_ptr(), this->__layout_.__alloc());
12431168 __v.emplace_back(std::move(__x));
1244 __p = __swap_out_circular_buffer(__v, __p);
1169 __p = __layout_.__relocate_with_pivot(__v, __p);
12451170 }
12461171 return __make_iter(__p);
12471172}
......@@ -1250,19 +1175,20 @@ template <class _Tp, class _Allocator>
12501175template <class... _Args>
12511176_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
12521177vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
1253 pointer __p = this->__begin_ + (__position - begin());
1254 if (this->__end_ < this->__cap_) {
1255 if (__p == this->__end_) {
1178 pointer __p = this->__layout_.__begin_ptr() + (__position - begin());
1179 if (size() != capacity()) {
1180 pointer __end = __layout_.__end_ptr();
1181 if (__p == __end) {
12561182 __emplace_back_assume_capacity(std::forward<_Args>(__args)...);
12571183 } else {
1258 __temp_value<value_type, _Allocator> __tmp(this->__alloc_, std::forward<_Args>(__args)...);
1259 __move_range(__p, this->__end_, __p + 1);
1184 __temp_value<value_type, _Allocator> __tmp(this->__layout_.__alloc(), std::forward<_Args>(__args)...);
1185 __move_range(__p, __end, __p + 1);
12601186 *__p = std::move(__tmp.get());
12611187 }
12621188 } else {
1263 __split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1189 _SplitBuffer __v(__recommend(size() + 1), __p - this->__layout_.__begin_ptr(), this->__layout_.__alloc());
12641190 __v.emplace_back(std::forward<_Args>(__args)...);
1265 __p = __swap_out_circular_buffer(__v, __p);
1191 __p = __layout_.__relocate_with_pivot(__v, __p);
12661192 }
12671193 return __make_iter(__p);
12681194}
......@@ -1270,27 +1196,28 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
12701196template <class _Tp, class _Allocator>
12711197_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
12721198vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x) {
1273 pointer __p = this->__begin_ + (__position - begin());
1199 pointer __p = this->__layout_.__begin_ptr() + (__position - begin());
12741200 if (__n > 0) {
1275 if (__n <= static_cast<size_type>(this->__cap_ - this->__end_)) {
1201 if (__n <= __layout_.__remaining_capacity()) {
12761202 size_type __old_n = __n;
1277 pointer __old_last = this->__end_;
1278 if (__n > static_cast<size_type>(this->__end_ - __p)) {
1279 size_type __cx = __n - (this->__end_ - __p);
1203 pointer __end = __layout_.__end_ptr();
1204 pointer __old_last = __end;
1205 if (__n > static_cast<size_type>(__end - __p)) {
1206 size_type __cx = __n - (__end - __p);
12801207 __construct_at_end(__cx, __x);
12811208 __n -= __cx;
12821209 }
12831210 if (__n > 0) {
12841211 __move_range(__p, __old_last, __p + __old_n);
12851212 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1286 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
1213 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end), std::addressof(__x)))
12871214 __xr += __old_n;
12881215 std::fill_n(__p, __n, *__xr);
12891216 }
12901217 } else {
1291 __split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1218 _SplitBuffer __v(__recommend(size() + __n), __p - this->__layout_.__begin_ptr(), this->__layout_.__alloc());
12921219 __v.__construct_at_end(__n, __x);
1293 __p = __swap_out_circular_buffer(__v, __p);
1220 __p = __layout_.__relocate_with_pivot(__v, __p);
12941221 }
12951222 }
12961223 return __make_iter(__p);
......@@ -1301,30 +1228,38 @@ template <class _InputIterator, class _Sentinel>
13011228_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
13021229vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _InputIterator __first, _Sentinel __last) {
13031230 difference_type __off = __position - begin();
1304 pointer __p = this->__begin_ + __off;
1305 pointer __old_last = this->__end_;
1306 for (; this->__end_ != this->__cap_ && __first != __last; ++__first)
1231 pointer __p = this->__layout_.__begin_ptr() + __off;
1232 pointer __old_last = __layout_.__end_ptr();
1233 for (; size() != capacity() && __first != __last; ++__first)
13071234 __emplace_back_assume_capacity(*__first);
13081235
13091236 if (__first == __last)
1310 (void)std::rotate(__p, __old_last, this->__end_);
1237 (void)std::rotate(__p, __old_last, __layout_.__end_ptr());
13111238 else {
1312 __split_buffer<value_type, allocator_type> __v(__alloc_);
1313 auto __guard = std::__make_exception_guard(
1314 _AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_));
1239 _SplitBuffer __v(__layout_.__alloc());
1240 pointer __end = __layout_.__end_ptr();
1241 auto __guard = std::__make_exception_guard(
1242 _AllocatorDestroyRangeReverse<allocator_type, pointer>(__layout_.__alloc(), __old_last, __end));
13151243 __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));
1316 __split_buffer<value_type, allocator_type> __merged(
1317 __recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front
1244 _SplitBuffer __merged(
1245 __recommend(size() + __v.size()), __off, __layout_.__alloc()); // has `__off` positions available at the front
13181246 std::__uninitialized_allocator_relocate(
1319 __alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.end()));
1320 __guard.__complete(); // Release the guard once objects in [__old_last_, __end_) have been successfully relocated.
1321 __merged.__set_sentinel(__merged.end() + (this->__end_ - __old_last));
1322 this->__end_ = __old_last;
1247 __layout_.__alloc(),
1248 std::__to_address(__old_last),
1249 std::__to_address(__layout_.__end_ptr()),
1250 std::__to_address(__merged.end()));
1251 __guard.__complete(); // Release the guard once objects in [__old_last_, __layout_.__end_ptr()) have been
1252 // successfully relocated.
1253 __merged.__set_sentinel(__merged.end() + (__layout_.__end_ptr() - __old_last));
1254 __layout_.__set_bound_using_pointer(__old_last);
13231255 std::__uninitialized_allocator_relocate(
1324 __alloc_, std::__to_address(__v.begin()), std::__to_address(__v.end()), std::__to_address(__merged.end()));
1256 __layout_.__alloc(),
1257 std::__to_address(__v.begin()),
1258 std::__to_address(__v.end()),
1259 std::__to_address(__merged.end()));
13251260 __merged.__set_sentinel(__merged.size() + __v.size());
13261261 __v.__set_sentinel(__v.begin());
1327 __p = __swap_out_circular_buffer(__merged, __p);
1262 __p = __layout_.__relocate_with_pivot(__merged, __p);
13281263 }
13291264 return __make_iter(__p);
13301265}
......@@ -1334,16 +1269,17 @@ template <class _AlgPolicy, class _Iterator, class _Sentinel>
13341269_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI typename vector<_Tp, _Allocator>::iterator
13351270vector<_Tp, _Allocator>::__insert_with_size(
13361271 const_iterator __position, _Iterator __first, _Sentinel __last, difference_type __n) {
1337 pointer __p = this->__begin_ + (__position - begin());
1272 pointer __p = this->__layout_.__begin_ptr() + (__position - begin());
13381273 if (__n > 0) {
1339 if (__n <= this->__cap_ - this->__end_) {
1340 pointer __old_last = this->__end_;
1341 difference_type __dx = this->__end_ - __p;
1274 if (__n <= static_cast<difference_type>(__layout_.__remaining_capacity())) {
1275 pointer __end = __layout_.__end_ptr();
1276 pointer __old_last = __end;
1277 difference_type __dx = __end - __p;
13421278 if (__n > __dx) {
13431279#if _LIBCPP_STD_VER >= 23
13441280 if constexpr (!forward_iterator<_Iterator>) {
13451281 __construct_at_end(std::move(__first), std::move(__last), __n);
1346 std::rotate(__p, __old_last, this->__end_);
1282 std::rotate(__p, __old_last, __end);
13471283 } else
13481284#endif
13491285 {
......@@ -1359,9 +1295,9 @@ vector<_Tp, _Allocator>::__insert_with_size(
13591295 __insert_assign_n_unchecked<_AlgPolicy>(std::move(__first), __n, __p);
13601296 }
13611297 } else {
1362 __split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1298 _SplitBuffer __v(__recommend(size() + __n), __p - this->__layout_.__begin_ptr(), this->__layout_.__alloc());
13631299 __v.__construct_at_end_with_size(std::move(__first), __n);
1364 __p = __swap_out_circular_buffer(__v, __p);
1300 __p = __layout_.__relocate_with_pivot(__v, __p);
13651301 }
13661302 }
13671303 return __make_iter(__p);
......@@ -1374,12 +1310,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __n
13741310 if (__new_size <= capacity()) {
13751311 __construct_at_end(__new_size - __current_size);
13761312 } else {
1377 __split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_);
1313 _SplitBuffer __v(__recommend(__new_size), __current_size, __layout_.__alloc());
13781314 __v.__construct_at_end(__new_size - __current_size);
1379 __swap_out_circular_buffer(__v);
1315 __layout_.__relocate(__v);
13801316 }
13811317 } else if (__current_size > __new_size) {
1382 this->__destruct_at_end(this->__begin_ + __new_size);
1318 this->__destruct_at_end(this->__layout_.__begin_ptr() + __new_size);
13831319 }
13841320}
13851321
......@@ -1390,12 +1326,12 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __n
13901326 if (__new_size <= capacity())
13911327 __construct_at_end(__new_size - __current_size, __x);
13921328 else {
1393 __split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_);
1329 _SplitBuffer __v(__recommend(__new_size), __current_size, __layout_.__alloc());
13941330 __v.__construct_at_end(__new_size - __current_size, __x);
1395 __swap_out_circular_buffer(__v);
1331 __layout_.__relocate(__v);
13961332 }
13971333 } else if (__current_size > __new_size) {
1398 this->__destruct_at_end(this->__begin_ + __new_size);
1334 this->__destruct_at_end(this->__layout_.__begin_ptr() + __new_size);
13991335 }
14001336}
14011337
......@@ -1408,29 +1344,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)
14081344#endif
14091345{
14101346 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
1411 __alloc_traits::propagate_on_container_swap::value || this->__alloc_ == __x.__alloc_,
1347 __alloc_traits::propagate_on_container_swap::value || __layout_.__alloc() == __x.__layout_.__alloc(),
14121348 "vector::swap: Either propagate_on_container_swap must be true"
14131349 " or the allocators must compare equal");
1414 std::swap(this->__begin_, __x.__begin_);
1415 std::swap(this->__end_, __x.__end_);
1416 std::swap(this->__cap_, __x.__cap_);
1417 std::__swap_allocator(this->__alloc_, __x.__alloc_);
1418}
1419
1420template <class _Tp, class _Allocator>
1421_LIBCPP_CONSTEXPR_SINCE_CXX20 bool vector<_Tp, _Allocator>::__invariants() const {
1422 if (this->__begin_ == nullptr) {
1423 if (this->__end_ != nullptr || this->__cap_ != nullptr)
1424 return false;
1425 } else {
1426 if (this->__begin_ > this->__end_)
1427 return false;
1428 if (this->__begin_ == this->__cap_)
1429 return false;
1430 if (this->__end_ > this->__cap_)
1431 return false;
1432 }
1433 return true;
1350 __layout_.__swap(__x.__layout_);
14341351}
14351352
14361353#if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__vector/vector_bool.h+10-20
......@@ -45,6 +45,7 @@
4545#include <__type_traits/is_nothrow_constructible.h>
4646#include <__type_traits/type_identity.h>
4747#include <__utility/exception_guard.h>
48#include <__utility/exchange.h>
4849#include <__utility/forward.h>
4950#include <__utility/move.h>
5051#include <__utility/swap.h>
......@@ -151,9 +152,7 @@ public:
151152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~vector() { __destroy_vector (*this)(); }
152153
153154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n);
154#if _LIBCPP_STD_VER >= 14
155155 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit vector(size_type __n, const allocator_type& __a);
156#endif
157156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector(size_type __n, const value_type& __v);
158157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
159158 vector(size_type __n, const value_type& __v, const allocator_type& __a);
......@@ -604,7 +603,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n)
604603 }
605604}
606605
607#if _LIBCPP_STD_VER >= 14
608606template <class _Allocator>
609607_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
610608 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(static_cast<__storage_allocator>(__a)) {
......@@ -614,7 +612,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, co
614612 __size_ = __n;
615613 }
616614}
617#endif
618615
619616template <class _Allocator>
620617_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
......@@ -740,13 +737,10 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocat
740737#else
741738 _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
742739#endif
743 : __begin_(__v.__begin_),
744 __size_(__v.__size_),
745 __cap_(__v.__cap_),
740 : __begin_(std::__exchange(__v.__begin_, nullptr)),
741 __size_(std::__exchange(__v.__size_, 0)),
742 __cap_(std::__exchange(__v.__cap_, 0)),
746743 __alloc_(std::move(__v.__alloc_)) {
747 __v.__begin_ = nullptr;
748 __v.__size_ = 0;
749 __v.__cap_ = 0;
750744}
751745
752746template <class _Allocator>
......@@ -754,11 +748,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20
754748vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
755749 : __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) {
756750 if (__a == allocator_type(__v.__alloc_)) {
757 this->__begin_ = __v.__begin_;
758 this->__size_ = __v.__size_;
759 this->__cap_ = __v.__cap_;
760 __v.__begin_ = nullptr;
761 __v.__cap_ = __v.__size_ = 0;
751 __begin_ = std::__exchange(__v.__begin_, nullptr);
752 __size_ = std::__exchange(__v.__size_, 0);
753 __cap_ = std::__exchange(__v.__cap_, 0);
762754 } else if (__v.size() > 0) {
763755 __vallocate(__v.size());
764756 __size_ = __v.__size_;
......@@ -787,11 +779,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::__move_assign(vecto
787779 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
788780 __vdeallocate();
789781 __move_assign_alloc(__c);
790 this->__begin_ = __c.__begin_;
791 this->__size_ = __c.__size_;
792 this->__cap_ = __c.__cap_;
793 __c.__begin_ = nullptr;
794 __c.__cap_ = __c.__size_ = 0;
782 __begin_ = std::__exchange(__c.__begin_, nullptr);
783 __size_ = std::__exchange(__c.__size_, 0);
784 __cap_ = std::__exchange(__c.__cap_, 0);
795785}
796786
797787template <class _Allocator>
lib/libcxx/include/__verbose_abort+2
......@@ -20,8 +20,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
2121// This function should never be called directly from the code -- it should only be called through
2222// the _LIBCPP_VERBOSE_ABORT macro.
23_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2324[[__noreturn__]] _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_ATTRIBUTE_FORMAT(
2425 __printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...) _NOEXCEPT;
26_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2527
2628// _LIBCPP_VERBOSE_ABORT(format, args...)
2729//
lib/libcxx/include/__verbose_trap+1-12
......@@ -16,21 +16,10 @@
1616# pragma GCC system_header
1717#endif
1818
19_LIBCPP_BEGIN_NAMESPACE_STD
20
2119#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
20# define _LIBCPP_VERBOSE_TRAP(message) __builtin_verbose_trap("libc++", message)
3021#else
3122# define _LIBCPP_VERBOSE_TRAP(message) ((void)message, __builtin_trap())
3223#endif
3324
34_LIBCPP_END_NAMESPACE_STD
35
3625#endif // _LIBCPP___VERBOSE_TRAP
lib/libcxx/include/algorithm+57-2
......@@ -883,6 +883,13 @@ namespace ranges {
883883 uniform_random_bit_generator<remove_reference_t<Gen>>
884884 O sample(R&& r, O out, range_difference_t<R> n, Gen&& g); // since C++20
885885
886 template<permutable I, sentinel_for<I> S>
887 constexpr subrange<I> ranges::shift_left(I first, S last, iter_difference_t<I> n); // since C++23
888
889 template<forward_range R>
890 requires permutable<iterator_t<R>>
891 constexpr borrowed_subrange_t<R> ranges::shift_left(R&& r, range_difference_t<R> n) // since C++23
892
886893 template<random_access_iterator I, sentinel_for<I> S, class Gen>
887894 requires permutable<I> &&
888895 uniform_random_bit_generator<remove_reference_t<Gen>>
......@@ -944,6 +951,33 @@ namespace ranges {
944951 template<input_range R, class T, indirectly-binary-left-foldable<T, iterator_t<R>> F>
945952 constexpr auto fold_left(R&& r, T init, F f); // since C++23
946953
954 template<input_iterator I, sentinel_for<I> S,
955 indirectly-binary-left-foldable<iter_value_t<I>, I> F>
956 requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
957 constexpr auto ranges::fold_left_first(I first, S last, F f); // since C++23
958
959 template<input_range R, indirectly-binary-left-foldable<range_value_t<R>, iterator_t<R>> F>
960 requires constructible_from<range_value_t<R>, range_reference_t<R>>
961 constexpr auto ranges::fold_left_first(R&& r, F f); // since C++23
962
963 template<bidirectional_iterator I, sentinel_for<I> S, class T = iter_value_t<I>,
964 indirectly-binary-right-foldable<T, I> F>
965 constexpr auto ranges::fold_right(I first, S last, T init, F f); // since C++23
966
967 template<bidirectional_range R, class T = range_value_t<R>,
968 indirectly-binary-right-foldable<T, iterator_t<R>> F>
969 constexpr auto ranges::fold_right(R&& r, T init, F f); // since C++23
970
971 template<bidirectional_iterator I, sentinel_for<I> S,
972 indirectly-binary-right-foldable<iter_value_t<I>, I> F>
973 requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
974 constexpr auto ranges::fold_right_last(I first, S last, F f); // since C++23
975
976 template<bidirectional_range R,
977 indirectly-binary-right-foldable<range_value_t<R>, iterator_t<R>> F>
978 requires constructible_from<range_value_t<R>, range_reference_t<R>>
979 constexpr auto ranges::fold_right_last(R&& r, F f); // since C++23
980
947981 template<class I, class T>
948982 using fold_left_with_iter_result = in_value_result<I, T>; // since C++23
949983
......@@ -954,6 +988,18 @@ namespace ranges {
954988 template<input_range R, class T, indirectly-binary-left-foldable<T, iterator_t<R>> F>
955989 constexpr see below fold_left_with_iter(R&& r, T init, F f); // since C++23
956990
991 template<class I, class T>
992 using fold_left_first_with_iter_result = in_value_result<I, T>; // since C++23
993
994 template<input_iterator I, sentinel_for<I> S,
995 indirectly-binary-left-foldable<iter_value_t<I>, I> F>
996 requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
997 constexpr see below ranges::fold_left_first_with_iter(I first, S last, F f); // since C++23
998
999 template<input_range R, indirectly-binary-left-foldable<range_value_t<R>, iterator_t<R>> F>
1000 requires constructible_from<range_value_t<R>, range_reference_t<R>>
1001 constexpr see below ranges::fold_left_first_with_iter(R&& r, F f); // since C++23
1002
9571003 template<forward_iterator I1, sentinel_for<I1> S1, forward_iterator I2, sentinel_for<I2> S2,
9581004 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
9591005 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
......@@ -1489,6 +1535,13 @@ template<class ForwardIterator>
14891535 shift_right(ForwardIterator first, ForwardIterator last,
14901536 typename iterator_traits<ForwardIterator>::difference_type n); // C++20
14911537
1538 template<permutable I, sentinel_for<I> S>
1539 constexpr subrange<I> ranges::shift_right(I first, S last, iter_difference_t<I> n); // since C++23
1540
1541 template<forward_range R>
1542 requires permutable<iterator_t<R>>
1543 constexpr borrowed_subrange_t<R> ranges::shift_right(R&& r, range_difference_t<R> n) // since C++23
1544
14921545template <class InputIterator, class Predicate>
14931546 constexpr bool // constexpr since C++20
14941547 is_partitioned(InputIterator first, InputIterator last, Predicate pred);
......@@ -2035,6 +2088,8 @@ template <class BidirectionalIterator, class Compare>
20352088# include <__algorithm/ranges_ends_with.h>
20362089# include <__algorithm/ranges_find_last.h>
20372090# include <__algorithm/ranges_fold.h>
2091# include <__algorithm/ranges_shift_left.h>
2092# include <__algorithm/ranges_shift_right.h>
20382093# include <__algorithm/ranges_starts_with.h>
20392094# endif // _LIBCPP_STD_VER >= 23
20402095
......@@ -2049,11 +2104,11 @@ template <class BidirectionalIterator, class Compare>
20492104# pragma GCC system_header
20502105# endif
20512106
2052# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
2107# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER == 14
20532108# include <execution>
20542109# endif
20552110
2056# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2111# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
20572112# include <atomic>
20582113# include <bit>
20592114# include <concepts>
lib/libcxx/include/any+11-9
......@@ -120,16 +120,20 @@ _LIBCPP_PUSH_MACROS
120120# include <__undef_macros>
121121
122122_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
123_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
124
123125class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
124126public:
125127 const char* what() const _NOEXCEPT override;
126128};
127_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
128129
129_LIBCPP_BEGIN_NAMESPACE_STD
130_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
131_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
130132
131133# if _LIBCPP_STD_VER >= 17
132134
135_LIBCPP_BEGIN_NAMESPACE_STD
136
133137[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_any_cast() {
134138# if _LIBCPP_HAS_EXCEPTIONS
135139 throw bad_any_cast();
......@@ -522,8 +526,6 @@ template <class _ValueType>
522526
523527template <class _ValueType>
524528[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI add_pointer_t<add_const_t<_ValueType>> any_cast(any const* __any) noexcept {
525 static_assert(!is_void_v<_ValueType>, "_ValueType may not be void.");
526 static_assert(!is_reference_v<_ValueType>, "_ValueType may not be a reference.");
527529 return std::any_cast<_ValueType>(const_cast<any*>(__any));
528530}
529531
......@@ -550,17 +552,17 @@ template <class _ValueType>
550552 return nullptr;
551553}
552554
553# endif // _LIBCPP_STD_VER >= 17
554
555555_LIBCPP_END_NAMESPACE_STD
556556
557# endif // _LIBCPP_STD_VER >= 17
558
557559_LIBCPP_POP_MACROS
558560
559# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
561# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 17
560562# include <chrono>
561563# endif
562564
563# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
565# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
564566# include <atomic>
565567# include <concepts>
566568# include <cstdlib>
......@@ -572,7 +574,7 @@ _LIBCPP_POP_MACROS
572574# include <variant>
573575# endif
574576
575# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
577# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
576578# include <cstring>
577579# include <limits>
578580# endif
lib/libcxx/include/array+1-1
......@@ -594,7 +594,7 @@ _LIBCPP_END_NAMESPACE_STD
594594
595595_LIBCPP_POP_MACROS
596596
597# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
597# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
598598# include <algorithm>
599599# include <concepts>
600600# include <cstdlib>
lib/libcxx/include/atomic+1-5
......@@ -626,11 +626,7 @@ template <class T>
626626# pragma GCC system_header
627627# endif
628628
629# if !_LIBCPP_HAS_ATOMIC_HEADER
630# error <atomic> is not implemented
631# endif
632
633# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
629# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
634630# include <cmath>
635631# include <compare>
636632# include <cstddef>
lib/libcxx/include/barrier+3-1
......@@ -95,6 +95,7 @@ using __barrier_phase_t _LIBCPP_NODEBUG = uint8_t;
9595
9696class __barrier_algorithm_base;
9797
98_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
9899[[__gnu__::__returns_nonnull__, __gnu__::__malloc__]]
99100_LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected);
100101
......@@ -104,6 +105,7 @@ __arrive_barrier_algorithm_base([[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barr
104105
105106_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(
106107 [[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE __barrier_algorithm_base* __barrier) noexcept;
108_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
107109
108110template <class _CompletionF>
109111class __barrier_base {
......@@ -190,7 +192,7 @@ _LIBCPP_POP_MACROS
190192
191193# endif // _LIBCPP_HAS_THREADS
192194
193# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
195# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
194196# include <atomic>
195197# include <concepts>
196198# include <iterator>
lib/libcxx/include/bit+1-1
......@@ -90,7 +90,7 @@ namespace std {
9090# pragma GCC system_header
9191# endif
9292
93# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
93# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
9494# include <cstdlib>
9595# include <iosfwd>
9696# include <limits>
lib/libcxx/include/bitset+1-1
......@@ -971,7 +971,7 @@ _LIBCPP_END_NAMESPACE_STD
971971
972972_LIBCPP_POP_MACROS
973973
974# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
974# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
975975# include <concepts>
976976# include <cstdlib>
977977# include <optional>
lib/libcxx/include/cctype+5-63
......@@ -39,13 +39,11 @@ int toupper(int c);
3939#else
4040# include <__config>
4141
42# include <ctype.h>
43
44# ifndef _LIBCPP_CTYPE_H
45# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
46 This usually means that your header search paths are not configured properly. \
47 The header search paths should contain the C++ Standard Library headers before \
48 any C Standard Library.
42# if __has_include(<ctype.h>)
43# include <ctype.h>
44# ifdef _LIBCPP_CTYPE_H
45# error "If libc++ starts defining <ctype.h>, the __has_include check should move to libc++'s <ctype.h>"
46# endif
4947# endif
5048
5149# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -54,62 +52,6 @@ int toupper(int c);
5452
5553_LIBCPP_BEGIN_NAMESPACE_STD
5654
57# ifdef isalnum
58# undef isalnum
59# endif
60
61# ifdef isalpha
62# undef isalpha
63# endif
64
65# ifdef isblank
66# undef isblank
67# endif
68
69# ifdef iscntrl
70# undef iscntrl
71# endif
72
73# ifdef isdigit
74# undef isdigit
75# endif
76
77# ifdef isgraph
78# undef isgraph
79# endif
80
81# ifdef islower
82# undef islower
83# endif
84
85# ifdef isprint
86# undef isprint
87# endif
88
89# ifdef ispunct
90# undef ispunct
91# endif
92
93# ifdef isspace
94# undef isspace
95# endif
96
97# ifdef isupper
98# undef isupper
99# endif
100
101# ifdef isxdigit
102# undef isxdigit
103# endif
104
105# ifdef tolower
106# undef tolower
107# endif
108
109# ifdef toupper
110# undef toupper
111# endif
112
11355using ::isalnum _LIBCPP_USING_IF_EXISTS;
11456using ::isalpha _LIBCPP_USING_IF_EXISTS;
11557using ::isblank _LIBCPP_USING_IF_EXISTS;
lib/libcxx/include/cfenv+5-8
......@@ -57,14 +57,11 @@ int feupdateenv(const fenv_t* envp);
5757#else
5858# include <__config>
5959
60# include <fenv.h>
61
62# ifndef _LIBCPP_FENV_H
63# error <cfenv> tried including <fenv.h> but didn't find libc++'s <fenv.h> header. \
64 This usually means that your header search paths are not configured properly. \
65 The header search paths should contain the C++ Standard Library headers before \
66 any C Standard Library, and you are probably using compiler flags that make that \
67 not be the case.
60# if __has_include(<fenv.h>)
61# include <fenv.h>
62# ifdef _LIBCPP_FENV_H
63# error "If libc++ starts defining <fenv.h>, the __has_include check should move to libc++'s <fenv.h>"
64# endif
6865# endif
6966
7067# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cfloat+6-8
......@@ -74,14 +74,12 @@ Macros:
7474#else
7575# include <__config>
7676
77# include <float.h>
78
79# ifndef _LIBCPP_FLOAT_H
80# error <cfloat> tried including <float.h> but didn't find libc++'s <float.h> header. \
81 This usually means that your header search paths are not configured properly. \
82 The header search paths should contain the C++ Standard Library headers before \
83 any C Standard Library, and you are probably using compiler flags that make that \
84 not be the case.
77// <float.h> is not provided by libc++
78# if __has_include(<float.h>)
79# include <float.h>
80# ifdef _LIBCPP_FLOAT_H
81# error "If libc++ starts defining <float.h>, the __has_include check should move to libc++'s <float.h>"
82# endif
8583# endif
8684
8785# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/charconv+1-5
......@@ -100,11 +100,7 @@ namespace std {
100100# pragma GCC system_header
101101# endif
102102
103_LIBCPP_BEGIN_NAMESPACE_STD
104
105_LIBCPP_END_NAMESPACE_STD
106
107# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
103# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
108104# include <cmath>
109105# include <concepts>
110106# include <cstddef>
lib/libcxx/include/chrono+4-3
......@@ -46,6 +46,7 @@ public:
4646template <class Rep, class Period = ratio<1>>
4747class duration
4848{
49 static_assert(__is_unqualified_v<Rep>, "A duration representation cannot be qualified");
4950 static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
5051 static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
5152 static_assert(Period::num > 0, "duration period must be positive");
......@@ -1148,13 +1149,13 @@ namespace std {
11481149# pragma GCC system_header
11491150# endif
11501151
1151# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
1152# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 17
11521153# include <cstdint>
11531154# include <stdexcept>
11541155# include <string_view>
11551156# endif
11561157
1157# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1158# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
11581159# include <bit>
11591160# include <concepts>
11601161# include <cstring>
......@@ -1164,7 +1165,7 @@ namespace std {
11641165# include <vector>
11651166# endif
11661167
1167# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
1168# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER == 20
11681169# include <charconv>
11691170# if _LIBCPP_HAS_LOCALIZATION
11701171# include <locale>
lib/libcxx/include/cinttypes+5-8
......@@ -244,14 +244,11 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
244244// [cinttypes.syn]
245245# include <cstdint>
246246
247# include <inttypes.h>
248
249# ifndef _LIBCPP_INTTYPES_H
250# error <cinttypes> tried including <inttypes.h> but didn't find libc++'s <inttypes.h> header. \
251 This usually means that your header search paths are not configured properly. \
252 The header search paths should contain the C++ Standard Library headers before \
253 any C Standard Library, and you are probably using compiler flags that make that \
254 not be the case.
247# if __has_include(<inttypes.h>)
248# include <inttypes.h>
249# ifdef _LIBCPP_INTTYPES_H
250# error "If libc++ starts defining <inttypes.h>, the __has_include check should move to libc++'s <float.h>"
251# endif
255252# endif
256253
257254# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cmath+1-1
......@@ -612,7 +612,7 @@ _LIBCPP_END_NAMESPACE_STD
612612
613613_LIBCPP_POP_MACROS
614614
615# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
615# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
616616# include <type_traits>
617617# endif
618618#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/codecvt+3-1
......@@ -71,6 +71,7 @@ class codecvt_utf8_utf16
7171# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
7272
7373_LIBCPP_BEGIN_NAMESPACE_STD
74_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
7475
7576enum _LIBCPP_DEPRECATED_IN_CXX17 codecvt_mode { consume_header = 4, generate_header = 2, little_endian = 1 };
7677
......@@ -579,13 +580,14 @@ public:
579580};
580581_LIBCPP_SUPPRESS_DEPRECATED_POP
581582
583_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
582584_LIBCPP_END_NAMESPACE_STD
583585
584586# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCPP_ENABLE_CXX26_REMOVED_CODECVT)
585587
586588# endif // _LIBCPP_HAS_LOCALIZATION
587589
588# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
590# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
589591# include <atomic>
590592# include <concepts>
591593# include <cstddef>
lib/libcxx/include/compare+1-1
......@@ -167,7 +167,7 @@ namespace std {
167167# pragma GCC system_header
168168# endif
169169
170# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
170# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
171171# include <cmath>
172172# include <cstddef>
173173# include <type_traits>
lib/libcxx/include/complex+1-1
......@@ -1484,7 +1484,7 @@ _LIBCPP_END_NAMESPACE_STD
14841484
14851485_LIBCPP_POP_MACROS
14861486
1487# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1487# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
14881488# include <iosfwd>
14891489# include <stdexcept>
14901490# include <type_traits>
lib/libcxx/include/concepts+1-1
......@@ -161,7 +161,7 @@ namespace std {
161161
162162# include <version>
163163
164# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
164# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
165165# include <cstddef>
166166# include <type_traits>
167167# endif
lib/libcxx/include/condition_variable+6-1
......@@ -146,6 +146,7 @@ _LIBCPP_PUSH_MACROS
146146# if _LIBCPP_HAS_THREADS
147147
148148_LIBCPP_BEGIN_NAMESPACE_STD
149_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
149150
150151template <class _Lock>
151152struct __unlock_guard {
......@@ -342,14 +343,18 @@ bool condition_variable_any::wait_for(
342343
343344_LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);
344345
346_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
345347_LIBCPP_END_NAMESPACE_STD
346348
347349# endif // _LIBCPP_HAS_THREADS
348350
349351_LIBCPP_POP_MACROS
350352
351# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
353# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
352354# include <atomic>
355# endif
356
357# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
353358# include <concepts>
354359# include <cstdint>
355360# include <cstdlib>
lib/libcxx/include/coroutine+1-1
......@@ -61,7 +61,7 @@ struct suspend_always;
6161# pragma GCC system_header
6262# endif
6363
64# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
64# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
6565# include <cstddef>
6666# include <iosfwd>
6767# include <limits>
lib/libcxx/include/ctype.h deleted-65
......@@ -1,65 +0,0 @@
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_CTYPE_H
11#define _LIBCPP_CTYPE_H
12
13/*
14 ctype.h synopsis
15
16int isalnum(int c);
17int isalpha(int c);
18int isblank(int c); // C99
19int iscntrl(int c);
20int isdigit(int c);
21int isgraph(int c);
22int islower(int c);
23int isprint(int c);
24int ispunct(int c);
25int isspace(int c);
26int isupper(int c);
27int isxdigit(int c);
28int tolower(int c);
29int toupper(int c);
30*/
31
32#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
33# include <__cxx03/__config>
34#else
35# include <__config>
36#endif
37
38#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
39# pragma GCC system_header
40#endif
41
42#if __has_include_next(<ctype.h>)
43# include_next <ctype.h>
44#endif
45
46#ifdef __cplusplus
47
48# undef isalnum
49# undef isalpha
50# undef isblank
51# undef iscntrl
52# undef isdigit
53# undef isgraph
54# undef islower
55# undef isprint
56# undef ispunct
57# undef isspace
58# undef isupper
59# undef isxdigit
60# undef tolower
61# undef toupper
62
63#endif
64
65#endif // _LIBCPP_CTYPE_H
lib/libcxx/include/cuchar+4-4
......@@ -56,10 +56,10 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
5656# pragma GCC system_header
5757# endif
5858
59_LIBCPP_BEGIN_NAMESPACE_STD
60
6159# if !defined(_LIBCPP_CXX03_LANG)
6260
61_LIBCPP_BEGIN_NAMESPACE_STD
62
6363using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
6464
6565# if _LIBCPP_HAS_C8RTOMB_MBRTOC8
......@@ -71,10 +71,10 @@ using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
7171using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
7272using ::c32rtomb _LIBCPP_USING_IF_EXISTS;
7373
74# endif // _LIBCPP_CXX03_LANG
75
7674_LIBCPP_END_NAMESPACE_STD
7775
76# endif // _LIBCPP_CXX03_LANG
77
7878#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
7979
8080#endif // _LIBCPP_CUCHAR
lib/libcxx/include/cwchar+1-1
......@@ -258,7 +258,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
258258
259259_LIBCPP_END_NAMESPACE_STD
260260
261# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
261# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
262262# include <cstddef>
263263# endif
264264#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/deque+45-31
......@@ -40,7 +40,7 @@ public:
4040 deque() noexcept(is_nothrow_default_constructible<allocator_type>::value);
4141 explicit deque(const allocator_type& a);
4242 explicit deque(size_type n);
43 explicit deque(size_type n, const allocator_type& a); // C++14
43 explicit deque(size_type n, const allocator_type& a);
4444 deque(size_type n, const value_type& v);
4545 deque(size_type n, const value_type& v, const allocator_type& a);
4646 template <class InputIterator>
......@@ -263,10 +263,17 @@ _LIBCPP_PUSH_MACROS
263263
264264_LIBCPP_BEGIN_NAMESPACE_STD
265265
266# ifndef _LIBCPP_ABI_USE_SMALL_DEQUE_BLOCK_SIZE
266267template <class _ValueType, class _DiffType>
267268struct __deque_block_size {
268269 static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
269270};
271# else
272template <class _ValueType, class _DiffType>
273struct __deque_block_size {
274 static const _DiffType value = sizeof(_ValueType) < 128 ? 512 / sizeof(_ValueType) : 4;
275};
276# endif
270277
271278template <class _ValueType,
272279 class _Pointer,
......@@ -283,7 +290,18 @@ template <class _ValueType,
283290# endif
284291 >
285292class __deque_iterator {
286 typedef _MapPointer __map_iterator;
293 using __map_iterator _LIBCPP_NODEBUG = __rebind_pointer_t<_Pointer, const __rebind_pointer_t<_Pointer, _ValueType> >;
294
295// TODO(LLVM 25): Remove this check
296# ifndef _LIBCPP_ABI_DEQUE_ITERATORS
297 static_assert(
298 sizeof(__map_iterator) == sizeof(_MapPointer) && _LIBCPP_ALIGNOF(__map_iterator) == _LIBCPP_ALIGNOF(_MapPointer),
299 "It looks like you are using fancy pointers such that FancyPtr<const FancyPtr<const value_type>> is not "
300 "layout-compatible with FancyPtr<FancyPtr<value_type>> or FancyPtr<const FancyPtr<value_type>>. "
301 "This means that your ABI is being broken between LLVM 22 and LLVM 23 if deque::iterator or "
302 "deque::const_iterator is used. If you don't care about your ABI being broken, define the "
303 "_LIBCPP_ABI_DEQUE_ITERATORS macro to silence this diagnostic.");
304# endif
287305
288306public:
289307 typedef _Pointer pointer;
......@@ -459,7 +477,7 @@ private:
459477 __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, _DiffType, _BlockSize>;
460478
461479public:
462 using __segment_iterator _LIBCPP_NODEBUG = _MapPointer;
480 using __segment_iterator _LIBCPP_NODEBUG = typename _Iterator::__map_iterator;
463481 using __local_iterator _LIBCPP_NODEBUG = _Pointer;
464482
465483 static _LIBCPP_HIDE_FROM_ABI __segment_iterator __segment(_Iterator __iter) { return __iter.__m_iter_; }
......@@ -626,9 +644,7 @@ public:
626644 }
627645
628646 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n);
629# if _LIBCPP_STD_VER >= 14
630647 explicit _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const _Allocator& __a);
631# endif
632648 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
633649
634650 template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
......@@ -725,24 +741,24 @@ public:
725741 // iterators:
726742
727743 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT {
728 __map_pointer __mp = __map_.begin() + __start_ / __block_size;
744 auto __mp = __map_.begin() + __start_ / __block_size;
729745 return iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
730746 }
731747
732748 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
733 __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __start_ / __block_size);
749 auto __mp = __map_.begin() + __start_ / __block_size;
734750 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __start_ % __block_size);
735751 }
736752
737753 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT {
738 size_type __p = size() + __start_;
739 __map_pointer __mp = __map_.begin() + __p / __block_size;
754 size_type __p = size() + __start_;
755 auto __mp = __map_.begin() + __p / __block_size;
740756 return iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
741757 }
742758
743759 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
744 size_type __p = size() + __start_;
745 __map_const_pointer __mp = static_cast<__map_const_pointer>(__map_.begin() + __p / __block_size);
760 size_type __p = size() + __start_;
761 auto __mp = __map_.begin() + __p / __block_size;
746762 return const_iterator(__mp, __map_.empty() ? 0 : *__mp + __p % __block_size);
747763 }
748764
......@@ -953,7 +969,7 @@ private:
953969 (void)__end;
954970 (void)__annotation_type;
955971 (void)__place;
956# if __has_feature(address_sanitizer)
972# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
957973 // __beg - index of the first item to annotate
958974 // __end - index behind the last item to annotate (so last item + 1)
959975 // __annotation_type - __asan_unposion or __asan_poison
......@@ -1046,23 +1062,23 @@ private:
10461062 std::__annotate_double_ended_contiguous_container<_Allocator>(
10471063 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);
10481064 }
1049# endif // __has_feature(address_sanitizer)
1065# endif // _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10501066 }
10511067
10521068 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
10531069 (void)__current_size;
1054# if __has_feature(address_sanitizer)
1070# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10551071 if (__current_size == 0)
10561072 __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
10571073 else {
10581074 __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved);
10591075 __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved);
10601076 }
1061# endif // __has_feature(address_sanitizer)
1077# endif // _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10621078 }
10631079
10641080 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT {
1065# if __has_feature(address_sanitizer)
1081# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10661082 if (empty()) {
10671083 for (size_t __i = 0; __i < __map_.size(); ++__i) {
10681084 __annotate_whole_block(__i, __asan_unposion);
......@@ -1071,19 +1087,19 @@ private:
10711087 __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved);
10721088 __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved);
10731089 }
1074# endif // __has_feature(address_sanitizer)
1090# endif // _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10751091 }
10761092
10771093 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT {
10781094 (void)__n;
1079# if __has_feature(address_sanitizer)
1095# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10801096 __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved);
10811097# endif
10821098 }
10831099
10841100 _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT {
10851101 (void)__n;
1086# if __has_feature(address_sanitizer)
1102# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10871103 __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved);
10881104# endif
10891105 }
......@@ -1091,7 +1107,7 @@ private:
10911107 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT {
10921108 (void)__old_size;
10931109 (void)__old_start;
1094# if __has_feature(address_sanitizer)
1110# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
10951111 __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved);
10961112# endif
10971113 }
......@@ -1099,7 +1115,7 @@ private:
10991115 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT {
11001116 (void)__old_size;
11011117 (void)__old_start;
1102# if __has_feature(address_sanitizer)
1118# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
11031119 __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved);
11041120# endif
11051121 }
......@@ -1112,7 +1128,7 @@ private:
11121128 __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT {
11131129 (void)__block_index;
11141130 (void)__annotation_type;
1115# if __has_feature(address_sanitizer)
1131# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
11161132 __map_const_iterator __block_it = __map_.begin() + __block_index;
11171133 const void* __block_start = std::__to_address(*__block_it);
11181134 const void* __block_end = std::__to_address(*__block_it + __block_size);
......@@ -1125,7 +1141,7 @@ private:
11251141 }
11261142# endif
11271143 }
1128# if __has_feature(address_sanitizer)
1144# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
11291145
11301146public:
11311147 _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {
......@@ -1187,7 +1203,7 @@ public:
11871203 }
11881204
11891205private:
1190# endif // __has_feature(address_sanitizer)
1206# endif // _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS
11911207 _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) {
11921208 if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) {
11931209 __annotate_whole_block(0, __asan_unposion);
......@@ -1305,7 +1321,6 @@ deque<_Tp, _Allocator>::deque(size_type __n) : __start_(0), __size_(0) {
13051321 __append(__n);
13061322}
13071323
1308# if _LIBCPP_STD_VER >= 14
13091324template <class _Tp, class _Allocator>
13101325deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
13111326 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0), __alloc_(__a) {
......@@ -1313,7 +1328,6 @@ deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a)
13131328 if (__n > 0)
13141329 __append(__n);
13151330}
1316# endif
13171331
13181332template <class _Tp, class _Allocator>
13191333deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) : __start_(0), __size_(0) {
......@@ -2220,7 +2234,7 @@ deque<_Tp, _Allocator>::__move_and_check(iterator __f, iterator __l, iterator __
22202234 __fe = __fb + __bs;
22212235 }
22222236 if (__fb <= __vt && __vt < __fe)
2223 __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) -= __f - __r).__ptr_;
2237 __vt = (const_iterator(__f.__m_iter_, __vt) -= __f - __r).__ptr_;
22242238 __r = std::move(__fb, __fe, __r);
22252239 __n -= __bs;
22262240 __f += __bs;
......@@ -2247,7 +2261,7 @@ deque<_Tp, _Allocator>::__move_backward_and_check(iterator __f, iterator __l, it
22472261 __lb = __le - __bs;
22482262 }
22492263 if (__lb <= __vt && __vt < __le)
2250 __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) += __r - __l - 1).__ptr_;
2264 __vt = (const_iterator(__l.__m_iter_, __vt) += __r - __l - 1).__ptr_;
22512265 __r = std::move_backward(__lb, __le, __r);
22522266 __n -= __bs;
22532267 __l -= __bs - 1;
......@@ -2273,7 +2287,7 @@ void deque<_Tp, _Allocator>::__move_construct_and_check(iterator __f, iterator _
22732287 __fe = __fb + __bs;
22742288 }
22752289 if (__fb <= __vt && __vt < __fe)
2276 __vt = (const_iterator(static_cast<__map_const_pointer>(__f.__m_iter_), __vt) += __r - __f).__ptr_;
2290 __vt = (const_iterator(__f.__m_iter_, __vt) += __r - __f).__ptr_;
22772291 for (; __fb != __fe; ++__fb, ++__r, ++__size())
22782292 __alloc_traits::construct(__a, std::addressof(*__r), std::move(*__fb));
22792293 __n -= __bs;
......@@ -2305,7 +2319,7 @@ void deque<_Tp, _Allocator>::__move_construct_backward_and_check(
23052319 __lb = __le - __bs;
23062320 }
23072321 if (__lb <= __vt && __vt < __le)
2308 __vt = (const_iterator(static_cast<__map_const_pointer>(__l.__m_iter_), __vt) -= __l - __r + 1).__ptr_;
2322 __vt = (const_iterator(__l.__m_iter_, __vt) -= __l - __r + 1).__ptr_;
23092323 while (__le != __lb) {
23102324 __alloc_traits::construct(__a, std::addressof(*--__r), std::move(*--__le));
23112325 --__start_;
......@@ -2532,7 +2546,7 @@ _LIBCPP_END_NAMESPACE_STD
25322546
25332547_LIBCPP_POP_MACROS
25342548
2535# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2549# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
25362550# include <algorithm>
25372551# include <atomic>
25382552# include <concepts>
lib/libcxx/include/exception+2-2
......@@ -91,13 +91,13 @@ template <class E> void rethrow_if_nested(const E& e);
9191# pragma GCC system_header
9292# endif
9393
94# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
94# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
9595# include <cstddef>
9696# include <new>
9797# include <type_traits>
9898# endif
9999
100# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
100# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
101101# include <cstdlib>
102102# endif
103103#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/execution+1-1
......@@ -155,7 +155,7 @@ _LIBCPP_END_NAMESPACE_STD
155155
156156# endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
157157
158# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
158# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
159159# include <cstddef>
160160# endif
161161#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/experimental/iterator+2-2
......@@ -124,14 +124,14 @@ _LIBCPP_END_NAMESPACE_LFTS
124124
125125_LIBCPP_POP_MACROS
126126
127# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
127# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
128128# include <cstddef>
129129# include <iosfwd>
130130# include <optional>
131131# include <type_traits>
132132# endif
133133
134# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
134# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
135135# include <locale>
136136# endif
137137
lib/libcxx/include/experimental/memory+5-7
......@@ -70,10 +70,10 @@ public:
7070
7171# ifdef _LIBCPP_ENABLE_EXPERIMENTAL
7272
73_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
74
7573# if _LIBCPP_STD_VER >= 17
7674
75_LIBCPP_BEGIN_NAMESPACE_LFTS_V2
76
7777template <class _Wp>
7878class observer_ptr {
7979public:
......@@ -175,28 +175,26 @@ _LIBCPP_HIDE_FROM_ABI bool operator>=(observer_ptr<_W1> __a, observer_ptr<_W2> _
175175 return !(__a < __b);
176176}
177177
178# endif // _LIBCPP_STD_VER >= 17
179
180178_LIBCPP_END_NAMESPACE_LFTS_V2
181179
182180_LIBCPP_BEGIN_NAMESPACE_STD
183181
184182// hash
185183
186# if _LIBCPP_STD_VER >= 17
187184template <class _Tp>
188185struct hash<experimental::observer_ptr<_Tp>> {
189186 _LIBCPP_HIDE_FROM_ABI size_t operator()(const experimental::observer_ptr<_Tp>& __ptr) const noexcept {
190187 return hash<_Tp*>()(__ptr.get());
191188 }
192189};
193# endif // _LIBCPP_STD_VER >= 17
194190
195191_LIBCPP_END_NAMESPACE_STD
196192
193# endif // _LIBCPP_STD_VER >= 17
194
197195# endif // _LIBCPP_ENABLE_EXPERIMENTAL
198196
199# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
197# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
200198# include <cstddef>
201199# include <limits>
202200# endif
lib/libcxx/include/experimental/propagate_const+1-1
......@@ -488,7 +488,7 @@ _LIBCPP_END_NAMESPACE_STD
488488
489489_LIBCPP_POP_MACROS
490490
491# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
491# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
492492# include <cstddef>
493493# include <type_traits>
494494# endif
lib/libcxx/include/experimental/simd+1-1
......@@ -88,7 +88,7 @@ inline namespace parallelism_v2 {
8888# include <experimental/__simd/traits.h>
8989# include <experimental/__simd/vec_ext.h>
9090
91# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
91# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
9292# include <cstddef>
9393# endif
9494#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/experimental/type_traits+1-1
......@@ -151,7 +151,7 @@ constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Ar
151151
152152_LIBCPP_END_NAMESPACE_LFTS
153153
154# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
154# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
155155# include <cstddef>
156156# endif
157157
lib/libcxx/include/experimental/utility+1-1
......@@ -46,7 +46,7 @@ struct erased_type {};
4646
4747_LIBCPP_END_NAMESPACE_LFTS
4848
49# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
49# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
5050# include <cstddef>
5151# endif
5252#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/ext/hash_map+1-1
......@@ -825,7 +825,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multimap<_Key, _Tp, _Has
825825
826826} // namespace __gnu_cxx
827827
828# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
828# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
829829# include <concepts>
830830# include <iterator>
831831# include <type_traits>
lib/libcxx/include/ext/hash_set+1-1
......@@ -572,7 +572,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const hash_multiset<_Value, _Hash,
572572
573573} // namespace __gnu_cxx
574574
575# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
575# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
576576# include <concepts>
577577# include <iterator>
578578# include <type_traits>
lib/libcxx/include/fenv.h deleted-118
......@@ -1,118 +0,0 @@
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_FENV_H
11#define _LIBCPP_FENV_H
12
13/*
14 fenv.h synopsis
15
16This entire header is C99 / C++0X
17
18Macros:
19
20 FE_DIVBYZERO
21 FE_INEXACT
22 FE_INVALID
23 FE_OVERFLOW
24 FE_UNDERFLOW
25 FE_ALL_EXCEPT
26 FE_DOWNWARD
27 FE_TONEAREST
28 FE_TOWARDZERO
29 FE_UPWARD
30 FE_DFL_ENV
31
32Types:
33
34 fenv_t
35 fexcept_t
36
37int feclearexcept(int excepts);
38int fegetexceptflag(fexcept_t* flagp, int excepts);
39int feraiseexcept(int excepts);
40int fesetexceptflag(const fexcept_t* flagp, int excepts);
41int fetestexcept(int excepts);
42int fegetround();
43int fesetround(int round);
44int fegetenv(fenv_t* envp);
45int feholdexcept(fenv_t* envp);
46int fesetenv(const fenv_t* envp);
47int feupdateenv(const fenv_t* envp);
48
49
50*/
51
52#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
53# include <__cxx03/__config>
54#else
55# include <__config>
56#endif
57
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header
60#endif
61
62#if __has_include_next(<fenv.h>)
63# include_next <fenv.h>
64#endif
65
66#ifdef __cplusplus
67
68extern "C++" {
69
70# ifdef feclearexcept
71# undef feclearexcept
72# endif
73
74# ifdef fegetexceptflag
75# undef fegetexceptflag
76# endif
77
78# ifdef feraiseexcept
79# undef feraiseexcept
80# endif
81
82# ifdef fesetexceptflag
83# undef fesetexceptflag
84# endif
85
86# ifdef fetestexcept
87# undef fetestexcept
88# endif
89
90# ifdef fegetround
91# undef fegetround
92# endif
93
94# ifdef fesetround
95# undef fesetround
96# endif
97
98# ifdef fegetenv
99# undef fegetenv
100# endif
101
102# ifdef feholdexcept
103# undef feholdexcept
104# endif
105
106# ifdef fesetenv
107# undef fesetenv
108# endif
109
110# ifdef feupdateenv
111# undef feupdateenv
112# endif
113
114} // extern "C++"
115
116#endif // defined(__cplusplus)
117
118#endif // _LIBCPP_FENV_H
lib/libcxx/include/filesystem+1-1
......@@ -568,7 +568,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
568568# pragma GCC system_header
569569# endif
570570
571# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
571# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
572572# include <concepts>
573573# include <cstdlib>
574574# include <cstring>
lib/libcxx/include/float.h deleted-99
......@@ -1,99 +0,0 @@
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_FLOAT_H
11#define _LIBCPP_FLOAT_H
12
13/*
14 float.h synopsis
15
16Macros:
17
18 FLT_ROUNDS
19 FLT_EVAL_METHOD // C99
20 FLT_RADIX
21
22 FLT_MANT_DIG
23 DBL_MANT_DIG
24 LDBL_MANT_DIG
25
26 FLT_HAS_SUBNORM // C11
27 DBL_HAS_SUBNORM // C11
28 LDBL_HAS_SUBNORM // C11
29
30 DECIMAL_DIG // C99
31 FLT_DECIMAL_DIG // C11
32 DBL_DECIMAL_DIG // C11
33 LDBL_DECIMAL_DIG // C11
34
35 FLT_DIG
36 DBL_DIG
37 LDBL_DIG
38
39 FLT_MIN_EXP
40 DBL_MIN_EXP
41 LDBL_MIN_EXP
42
43 FLT_MIN_10_EXP
44 DBL_MIN_10_EXP
45 LDBL_MIN_10_EXP
46
47 FLT_MAX_EXP
48 DBL_MAX_EXP
49 LDBL_MAX_EXP
50
51 FLT_MAX_10_EXP
52 DBL_MAX_10_EXP
53 LDBL_MAX_10_EXP
54
55 FLT_MAX
56 DBL_MAX
57 LDBL_MAX
58
59 FLT_EPSILON
60 DBL_EPSILON
61 LDBL_EPSILON
62
63 FLT_MIN
64 DBL_MIN
65 LDBL_MIN
66
67 FLT_TRUE_MIN // C11
68 DBL_TRUE_MIN // C11
69 LDBL_TRUE_MIN // C11
70
71*/
72
73#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
74# include <__cxx03/__config>
75#else
76# include <__config>
77#endif
78
79#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
80# pragma GCC system_header
81#endif
82
83#if __has_include_next(<float.h>)
84# include_next <float.h>
85#endif
86
87#ifdef __cplusplus
88
89# ifndef FLT_EVAL_METHOD
90# define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
91# endif
92
93# ifndef DECIMAL_DIG
94# define DECIMAL_DIG __DECIMAL_DIG__
95# endif
96
97#endif // __cplusplus
98
99#endif // _LIBCPP_FLOAT_H
lib/libcxx/include/format+13-10
......@@ -31,7 +31,7 @@ namespace std {
3131
3232 public:
3333 template<class T> consteval basic_format_string(const T& s);
34 basic_format_string(runtime-format-string<charT> s) noexcept : str(s.str) {} // since C++26
34 basic_format_string(dynamic-format-string<charT> s) noexcept : str(s.str) {} // since C++26
3535
3636 constexpr basic_string_view<charT> get() const noexcept { return str; }
3737 };
......@@ -42,21 +42,21 @@ namespace std {
4242 using wformat_string = // since C++23, exposition only before C++23
4343 basic_format_string<wchar_t, type_identity_t<Args>...>;
4444
45 template<class charT> struct runtime-format-string { // since C++26, exposition-only
45 template<class charT> struct dynamic-format-string { // since C++26, exposition-only
4646 private:
4747 basic_string_view<charT> str; // exposition-only
4848
4949 public:
50 runtime-format-string(basic_string_view<charT> s) noexcept : str(s) {}
50 dynamic-format-string(basic_string_view<charT> s) noexcept : str(s) {}
5151
52 runtime-format-string(const runtime-format-string&) = delete;
53 runtime-format-string& operator=(const runtime-format-string&) = delete;
52 dynamic-format-string(const dynamic-format-string&) = delete;
53 dynamic-format-string& operator=(const dynamic-format-string&) = delete;
5454 };
5555
56 runtime-format-string<char> runtime_format(string_view fmt) noexcept {
56 dynamic-format-string<char> dynamic_format(string_view fmt) noexcept {
5757 return fmt;
5858 }
59 runtime-format-string<wchar_t> runtime_format(wstring_view fmt) noexcept {
59 dynamic-format-string<wchar_t> dynamic_format(wstring_view fmt) noexcept {
6060 return fmt;
6161 }
6262
......@@ -213,7 +213,7 @@ namespace std {
213213# include <__format/format_string.h>
214214# include <__format/format_to_n_result.h>
215215# include <__format/formatter.h>
216# include <__format/formatter_bool.h>
216# include <__format/formatter_bool_impl.h>
217217# include <__format/formatter_char.h>
218218# include <__format/formatter_floating_point.h>
219219# include <__format/formatter_integer.h>
......@@ -233,12 +233,15 @@ namespace std {
233233# pragma GCC system_header
234234# endif
235235
236# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
236# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
237# include <cmath>
238# endif
239
240# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
237241# include <array>
238242# include <cctype>
239243# include <cerrno>
240244# include <clocale>
241# include <cmath>
242245# include <cstddef>
243246# include <cstdint>
244247# include <cstdlib>
lib/libcxx/include/forward_list+4-8
......@@ -37,7 +37,7 @@ public:
3737 noexcept(is_nothrow_default_constructible<allocator_type>::value);
3838 explicit forward_list(const allocator_type& a);
3939 explicit forward_list(size_type n);
40 explicit forward_list(size_type n, const allocator_type& a); // C++14
40 explicit forward_list(size_type n, const allocator_type& a);
4141 forward_list(size_type n, const value_type& v);
4242 forward_list(size_type n, const value_type& v, const allocator_type& a);
4343 template <class InputIterator>
......@@ -234,6 +234,7 @@ template <class T, class Allocator, class Predicate>
234234# include <__type_traits/remove_cv.h>
235235# include <__type_traits/type_identity.h>
236236# include <__utility/exception_guard.h>
237# include <__utility/exchange.h>
237238# include <__utility/forward.h>
238239# include <__utility/move.h>
239240# include <__utility/swap.h>
......@@ -663,9 +664,7 @@ public:
663664 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {} // = default;
664665 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(const allocator_type& __a);
665666 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n);
666# if _LIBCPP_STD_VER >= 14
667667 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit forward_list(size_type __n, const allocator_type& __a);
668# endif
669668 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
670669
671670 template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0>
......@@ -940,7 +939,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type
940939 }
941940}
942941
943# if _LIBCPP_STD_VER >= 14
944942template <class _Tp, class _Alloc>
945943_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __base_alloc)
946944 : __base(__base_alloc) {
......@@ -951,7 +949,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type
951949 }
952950 }
953951}
954# endif
955952
956953template <class _Tp, class _Alloc>
957954_LIBCPP_CONSTEXPR_SINCE_CXX26 forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {
......@@ -1022,8 +1019,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void forward_list<_Tp, _Alloc>::__move_assign(forw
10221019 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
10231020 clear();
10241021 __base::__move_assign_alloc(__x);
1025 __base::__before_begin()->__next_ = __x.__before_begin()->__next_;
1026 __x.__before_begin()->__next_ = nullptr;
1022 __base::__before_begin()->__next_ = std::__exchange(__x.__before_begin()->__next_, nullptr);
10271023}
10281024
10291025template <class _Tp, class _Alloc>
......@@ -1603,7 +1599,7 @@ _LIBCPP_END_NAMESPACE_STD
16031599
16041600_LIBCPP_POP_MACROS
16051601
1606# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1602# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
16071603# include <algorithm>
16081604# include <atomic>
16091605# include <concepts>
lib/libcxx/include/fstream+90-31
......@@ -220,6 +220,7 @@ _LIBCPP_PUSH_MACROS
220220# include <__undef_macros>
221221
222222_LIBCPP_BEGIN_NAMESPACE_STD
223_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
223224
224225# if _LIBCPP_STD_VER >= 23 && defined(_LIBCPP_WIN32API)
225226_LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) noexcept;
......@@ -308,6 +309,34 @@ protected:
308309 return basic_streambuf<_CharT, _Traits>::xsputn(__str, __len);
309310 }
310311
312 _LIBCPP_HIDE_FROM_ABI_VIRTUAL streamsize xsgetn(char_type* __str, streamsize __len) override {
313 if (__file_ && __always_noconv_) {
314 char_type __1buf;
315 __read_guard __guard(__1buf, *this);
316 const streamsize __n = std::min(this->egptr() - this->gptr(), __len);
317 if (__n != 0) {
318 traits_type::copy(__str, this->gptr(), __n);
319 this->__gbump_ptrdiff(__n);
320 }
321 const streamsize __remainder = __len - __n;
322 const streamsize __buffer_space = this->egptr() - this->eback();
323
324 if (__remainder >= __buffer_space) {
325 auto __res = std::fread(__str + __n, sizeof(char_type), __remainder, __file_) + __n;
326
327 // Copy the buffer-sized tail into the buffer so that `unget`ting works correctly
328 auto __buf_size = std::min<size_t>(__res, this->egptr() - this->eback());
329 traits_type::copy(this->eback(), __str + __res - __buf_size, __buf_size);
330 this->setg(this->eback(), this->eback() + __buf_size, this->eback() + __buf_size);
331
332 return __res;
333 } else if (__remainder > 0)
334 return basic_streambuf<_CharT, _Traits>::xsgetn(__str + __n, __remainder) + __n;
335 return __n;
336 }
337 return basic_streambuf<_CharT, _Traits>::xsgetn(__str, __len);
338 }
339
311340private:
312341 char* __extbuf_;
313342 const char* __extbufnext_;
......@@ -364,6 +393,40 @@ private:
364393 bool __always_noconv_;
365394
366395 bool __read_mode();
396
397 struct [[__nodiscard__]] __read_guard {
398 basic_filebuf& __self_;
399 size_t __unget_size_;
400 char_type& __1buf_;
401
402 _LIBCPP_HIDE_FROM_ABI __read_guard(char_type& __1buf, basic_filebuf& __self) : __self_(__self), __1buf_(__1buf) {
403 if (__self.__cm_ & ios_base::in) {
404 __unget_size_ = std::min<size_t>((__self.egptr() - __self.eback()) / 2, 4);
405 } else {
406 __self.setp(nullptr, nullptr);
407 if (__self.__always_noconv_) {
408 __self.setg(reinterpret_cast<char_type*>(__self.__extbuf_),
409 reinterpret_cast<char_type*>(__self.__extbuf_) + __self.__ebs_,
410 reinterpret_cast<char_type*>(__self.__extbuf_) + __self.__ebs_);
411 } else {
412 __self.setg(__self.__intbuf_, __self.__intbuf_ + __self.__ibs_, __self.__intbuf_ + __self.__ibs_);
413 }
414 __self.__cm_ = ios_base::in;
415 __unget_size_ = 0;
416 }
417
418 if (__self.gptr() == nullptr)
419 __self.setg(std::addressof(__1buf_), std::addressof(__1buf_) + 1, std::addressof(__1buf_) + 1);
420 }
421
422 _LIBCPP_HIDE_FROM_ABI size_t __unget_size() { return __unget_size_; }
423
424 _LIBCPP_HIDE_FROM_ABI ~__read_guard() {
425 if (__self_.eback() == std::addressof(__1buf_))
426 __self_.setg(nullptr, nullptr, nullptr);
427 }
428 };
429
367430 void __write_mode();
368431
369432 _LIBCPP_HIDE_FROM_ABI static int __fseek(FILE* __file, pos_type __offset, int __whence);
......@@ -400,14 +463,12 @@ private:
400463 // If the file is already open, switch to unbuffered mode. Otherwise, record
401464 // the request to use unbuffered mode so that we use that mode when we
402465 // eventually open the file.
403 _LIBCPP_HIDE_FROM_ABI void __request_unbuffered_mode(char_type* __s, streamsize __n) {
404 if (__cm_ == __no_io_operations && __s == nullptr && __n == 0) {
405 if (__file_) {
406 std::setbuf(__file_, nullptr);
407 __cm_ = 0;
408 } else {
409 __cm_ = __no_io_operations | __use_unbuffered_io;
410 }
466 _LIBCPP_HIDE_FROM_ABI void __request_unbuffered_mode() {
467 if (__file_) {
468 std::setbuf(__file_, nullptr);
469 __cm_ = 0;
470 } else {
471 __cm_ = __no_io_operations | __use_unbuffered_io;
411472 }
412473 }
413474
......@@ -601,6 +662,17 @@ inline bool basic_filebuf<_CharT, _Traits>::is_open() const {
601662 return __file_ != nullptr;
602663}
603664
665// Configures the fopen close-on-exec mode character, if any. This string will
666// be appended to any mode string used by fstream for fopen/fdopen.
667//
668// Not all platforms support this, but it helps avoid fd-leaks on platforms that
669// do.
670# if defined(__BIONIC__)
671# define _LIBCPP_FOPEN_CLOEXEC_MODE "e"
672# else
673# define _LIBCPP_FOPEN_CLOEXEC_MODE
674# endif
675
604676template <class _CharT, class _Traits>
605677const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode __mode) _NOEXCEPT {
606678 switch (__mode & ~ios_base::ate) {
......@@ -773,11 +845,11 @@ template <class _CharT, class _Traits>
773845typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>::underflow() {
774846 if (__file_ == nullptr)
775847 return traits_type::eof();
776 bool __initial = __read_mode();
848
777849 char_type __1buf;
778 if (this->gptr() == nullptr)
779 this->setg(std::addressof(__1buf), std::addressof(__1buf) + 1, std::addressof(__1buf) + 1);
780 const size_t __unget_sz = __initial ? 0 : std::min<size_t>((this->egptr() - this->eback()) / 2, 4);
850 __read_guard __guard(__1buf, *this);
851
852 const size_t __unget_sz = __guard.__unget_size();
781853 int_type __c = traits_type::eof();
782854 if (this->gptr() == this->egptr()) {
783855 std::memmove(this->eback(), this->egptr() - __unget_sz, __unget_sz * sizeof(char_type));
......@@ -820,8 +892,6 @@ typename basic_filebuf<_CharT, _Traits>::int_type basic_filebuf<_CharT, _Traits>
820892 }
821893 } else
822894 __c = traits_type::to_int_type(*this->gptr());
823 if (this->eback() == std::addressof(__1buf))
824 this->setg(nullptr, nullptr, nullptr);
825895 return __c;
826896}
827897
......@@ -920,7 +990,9 @@ template <class _CharT, class _Traits>
920990basic_streambuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n) {
921991 this->setg(nullptr, nullptr, nullptr);
922992 this->setp(nullptr, nullptr);
923 __request_unbuffered_mode(__s, __n);
993 // Calling setbuf(nullptr, 0) before any i/o operation switches the stream to unbuffered mode
994 if (__cm_ == __no_io_operations && __s == nullptr && __n == 0)
995 __request_unbuffered_mode();
924996 if (__owns_eb_)
925997 delete[] __extbuf_;
926998 if (__owns_ib_)
......@@ -1110,20 +1182,6 @@ void basic_filebuf<_CharT, _Traits>::imbue(const locale& __loc) {
11101182 }
11111183}
11121184
1113template <class _CharT, class _Traits>
1114bool basic_filebuf<_CharT, _Traits>::__read_mode() {
1115 if (!(__cm_ & ios_base::in)) {
1116 this->setp(nullptr, nullptr);
1117 if (__always_noconv_)
1118 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_);
1119 else
1120 this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
1121 __cm_ = ios_base::in;
1122 return true;
1123 }
1124 return false;
1125}
1126
11271185template <class _CharT, class _Traits>
11281186void basic_filebuf<_CharT, _Traits>::__write_mode() {
11291187 if (!(__cm_ & ios_base::out)) {
......@@ -1616,13 +1674,14 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ofstream<char>;
16161674extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_filebuf<char>;
16171675# endif
16181676
1677_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
16191678_LIBCPP_END_NAMESPACE_STD
16201679
16211680_LIBCPP_POP_MACROS
16221681
16231682# endif // _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
16241683
1625# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1684# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
16261685# include <atomic>
16271686# include <concepts>
16281687# include <cstdlib>
......@@ -1634,7 +1693,7 @@ _LIBCPP_POP_MACROS
16341693# include <type_traits>
16351694# endif
16361695
1637# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
1696# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
16381697# include <filesystem>
16391698# endif
16401699#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/functional+7-5
......@@ -221,6 +221,8 @@ template <auto f>
221221// [func.bind.partial], function templates bind_front and bind_back
222222template<class F, class... Args>
223223 constexpr unspecified bind_front(F&&, Args&&...); // C++20
224template<auto f, class... Args>
225 constexpr unspecified bind_front(Args&&...); // C++26
224226template<class F, class... Args>
225227 constexpr unspecified bind_back(F&&, Args&&...); // C++23
226228
......@@ -540,7 +542,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
540542# include <__functional/binder1st.h>
541543# include <__functional/binder2nd.h>
542544# include <__functional/hash.h>
543# include <__functional/mem_fn.h> // TODO: deprecate
545# include <__functional/mem_fn.h>
544546# include <__functional/mem_fun_ref.h>
545547# include <__functional/operations.h>
546548# include <__functional/pointer_to_binary_function.h>
......@@ -575,18 +577,18 @@ POLICY: For non-variadic implementations, the number of arguments is limited
575577# pragma GCC system_header
576578# endif
577579
578# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG)
580# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && defined(_LIBCPP_CXX03_LANG)
579581# include <limits>
580582# include <new>
581583# endif
582584
583# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
585# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 14
584586# include <array>
585587# include <initializer_list>
586588# include <unordered_map>
587589# endif
588590
589# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
591# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
590592# include <atomic>
591593# include <concepts>
592594# include <cstdlib>
......@@ -601,7 +603,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited
601603# include <vector>
602604# endif
603605
604# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 23
606# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER == 23
605607# include <__vector/vector.h>
606608# endif
607609#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/future+23-10
......@@ -379,7 +379,6 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
379379# include <__memory/allocator_arg_t.h>
380380# include <__memory/allocator_destructor.h>
381381# include <__memory/allocator_traits.h>
382# include <__memory/compressed_pair.h>
383382# include <__memory/pointer_traits.h>
384383# include <__memory/shared_count.h>
385384# include <__memory/unique_ptr.h>
......@@ -420,6 +419,7 @@ _LIBCPP_PUSH_MACROS
420419# include <__undef_macros>
421420
422421_LIBCPP_BEGIN_NAMESPACE_STD
422_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
423423
424424// enum class future_errc
425425_LIBCPP_DECLARE_STRONG_ENUM(future_errc){
......@@ -435,7 +435,12 @@ struct is_error_code_enum<future_errc::__lx> : public true_type {};
435435# endif
436436
437437// enum class launch
438_LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred};
438_LIBCPP_DECLARE_STRONG_ENUM(launch){
439 async = 1,
440 deferred = 2,
441 any _LIBCPP_DEPRECATED_("std::launch::any is a deprecated extension. "
442 "Use std::launch::async | std::launch::deferred instead. "
443 "It will be removed in LLVM 25.") = async | deferred};
439444_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
440445
441446# ifndef _LIBCPP_CXX03_LANG
......@@ -1407,8 +1412,10 @@ template <class _FD, class _Alloc, class _FB>
14071412class __packaged_task_func;
14081413
14091414template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
1410class __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> {
1411 _LIBCPP_COMPRESSED_PAIR(_Fp, __func_, _Alloc, __alloc_);
1415class _LIBCPP_HIDE_STRUCT_FROM_ABI
1416 __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __packaged_task_base<_Rp(_ArgTypes...)> {
1417 _LIBCPP_NO_UNIQUE_ADDRESS _Fp __func_;
1418 _LIBCPP_NO_UNIQUE_ADDRESS _Alloc __alloc_;
14121419
14131420public:
14141421 _LIBCPP_HIDE_FROM_ABI explicit __packaged_task_func(const _Fp& __f) : __func_(__f) {}
......@@ -1429,8 +1436,8 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__move_to(
14291436
14301437template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
14311438void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() {
1432 __func_.~_Fp();
14331439 __alloc_.~_Alloc();
1440 __func_.~_Fp();
14341441}
14351442
14361443template <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
......@@ -1439,8 +1446,8 @@ void __packaged_task_func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate()
14391446 typedef allocator_traits<_Ap> _ATraits;
14401447 typedef pointer_traits<typename _ATraits::pointer> _PTraits;
14411448 _Ap __a(__alloc_);
1442 __func_.~_Fp();
14431449 __alloc_.~_Alloc();
1450 __func_.~_Fp();
14441451 __a.deallocate(_PTraits::pointer_to(*this), 1);
14451452}
14461453
......@@ -1744,7 +1751,7 @@ public:
17441751template <class _Rp, class... _Args>
17451752packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
17461753
1747template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
1754template <class _Fp, class _Stripped = __strip_signature_t<decltype(&_Fp::operator())>>
17481755packaged_task(_Fp) -> packaged_task<_Stripped>;
17491756
17501757# endif
......@@ -1876,7 +1883,7 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) {
18761883template <class _Fp, class... _Args>
18771884[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI future<__invoke_result_t<__decay_t<_Fp>, __decay_t<_Args>...> >
18781885async(_Fp&& __f, _Args&&... __args) {
1879 return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
1886 return std::async(launch::async | launch::deferred, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
18801887}
18811888
18821889# endif // C++03
......@@ -2052,17 +2059,18 @@ inline shared_future<_Rp&> future<_Rp&>::share() _NOEXCEPT {
20522059
20532060inline shared_future<void> future<void>::share() _NOEXCEPT { return shared_future<void>(std::move(*this)); }
20542061
2062_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
20552063_LIBCPP_END_NAMESPACE_STD
20562064
20572065_LIBCPP_POP_MACROS
20582066
20592067# endif // _LIBCPP_HAS_THREADS
20602068
2061# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
2069# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 17
20622070# include <chrono>
20632071# endif
20642072
2065# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2073# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
20662074# include <atomic>
20672075# include <cstdlib>
20682076# include <exception>
......@@ -2070,6 +2078,11 @@ _LIBCPP_POP_MACROS
20702078# include <system_error>
20712079# include <thread>
20722080# endif
2081
2082# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
2083# include <sstream>
2084# endif
2085
20732086#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
20742087
20752088#endif // _LIBCPP_FUTURE
lib/libcxx/include/initializer_list+5-5
......@@ -53,11 +53,11 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
5353# pragma GCC system_header
5454# endif
5555
56# ifndef _LIBCPP_CXX03_LANG
57
5658namespace std // purposefully not versioned
5759{
5860
59# ifndef _LIBCPP_CXX03_LANG
60
6161template <class _Ep>
6262class _LIBCPP_NO_SPECIALIZATIONS initializer_list {
6363 const _Ep* __begin_;
......@@ -101,11 +101,11 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Ep* end(initia
101101 return __il.end();
102102}
103103
104# endif // !defined(_LIBCPP_CXX03_LANG)
105
106104} // namespace std
107105
108# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
106# endif // _LIBCPP_CXX03_LANG
107
108# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
109109# include <cstddef>
110110# endif
111111#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/inttypes.h deleted-268
......@@ -1,268 +0,0 @@
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_INTTYPES_H
11// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
12// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
13// case the header guard macro is defined.
14#if !defined(_AIX) || !defined(_STD_TYPES_T)
15# define _LIBCPP_INTTYPES_H
16#endif // _STD_TYPES_T
17
18/*
19 inttypes.h synopsis
20
21This entire header is C99 / C++0X
22
23#include <stdint.h> // <cinttypes> includes <cstdint>
24
25Macros:
26
27 PRId8
28 PRId16
29 PRId32
30 PRId64
31
32 PRIdLEAST8
33 PRIdLEAST16
34 PRIdLEAST32
35 PRIdLEAST64
36
37 PRIdFAST8
38 PRIdFAST16
39 PRIdFAST32
40 PRIdFAST64
41
42 PRIdMAX
43 PRIdPTR
44
45 PRIi8
46 PRIi16
47 PRIi32
48 PRIi64
49
50 PRIiLEAST8
51 PRIiLEAST16
52 PRIiLEAST32
53 PRIiLEAST64
54
55 PRIiFAST8
56 PRIiFAST16
57 PRIiFAST32
58 PRIiFAST64
59
60 PRIiMAX
61 PRIiPTR
62
63 PRIo8
64 PRIo16
65 PRIo32
66 PRIo64
67
68 PRIoLEAST8
69 PRIoLEAST16
70 PRIoLEAST32
71 PRIoLEAST64
72
73 PRIoFAST8
74 PRIoFAST16
75 PRIoFAST32
76 PRIoFAST64
77
78 PRIoMAX
79 PRIoPTR
80
81 PRIu8
82 PRIu16
83 PRIu32
84 PRIu64
85
86 PRIuLEAST8
87 PRIuLEAST16
88 PRIuLEAST32
89 PRIuLEAST64
90
91 PRIuFAST8
92 PRIuFAST16
93 PRIuFAST32
94 PRIuFAST64
95
96 PRIuMAX
97 PRIuPTR
98
99 PRIx8
100 PRIx16
101 PRIx32
102 PRIx64
103
104 PRIxLEAST8
105 PRIxLEAST16
106 PRIxLEAST32
107 PRIxLEAST64
108
109 PRIxFAST8
110 PRIxFAST16
111 PRIxFAST32
112 PRIxFAST64
113
114 PRIxMAX
115 PRIxPTR
116
117 PRIX8
118 PRIX16
119 PRIX32
120 PRIX64
121
122 PRIXLEAST8
123 PRIXLEAST16
124 PRIXLEAST32
125 PRIXLEAST64
126
127 PRIXFAST8
128 PRIXFAST16
129 PRIXFAST32
130 PRIXFAST64
131
132 PRIXMAX
133 PRIXPTR
134
135 SCNd8
136 SCNd16
137 SCNd32
138 SCNd64
139
140 SCNdLEAST8
141 SCNdLEAST16
142 SCNdLEAST32
143 SCNdLEAST64
144
145 SCNdFAST8
146 SCNdFAST16
147 SCNdFAST32
148 SCNdFAST64
149
150 SCNdMAX
151 SCNdPTR
152
153 SCNi8
154 SCNi16
155 SCNi32
156 SCNi64
157
158 SCNiLEAST8
159 SCNiLEAST16
160 SCNiLEAST32
161 SCNiLEAST64
162
163 SCNiFAST8
164 SCNiFAST16
165 SCNiFAST32
166 SCNiFAST64
167
168 SCNiMAX
169 SCNiPTR
170
171 SCNo8
172 SCNo16
173 SCNo32
174 SCNo64
175
176 SCNoLEAST8
177 SCNoLEAST16
178 SCNoLEAST32
179 SCNoLEAST64
180
181 SCNoFAST8
182 SCNoFAST16
183 SCNoFAST32
184 SCNoFAST64
185
186 SCNoMAX
187 SCNoPTR
188
189 SCNu8
190 SCNu16
191 SCNu32
192 SCNu64
193
194 SCNuLEAST8
195 SCNuLEAST16
196 SCNuLEAST32
197 SCNuLEAST64
198
199 SCNuFAST8
200 SCNuFAST16
201 SCNuFAST32
202 SCNuFAST64
203
204 SCNuMAX
205 SCNuPTR
206
207 SCNx8
208 SCNx16
209 SCNx32
210 SCNx64
211
212 SCNxLEAST8
213 SCNxLEAST16
214 SCNxLEAST32
215 SCNxLEAST64
216
217 SCNxFAST8
218 SCNxFAST16
219 SCNxFAST32
220 SCNxFAST64
221
222 SCNxMAX
223 SCNxPTR
224
225Types:
226
227 imaxdiv_t
228
229intmax_t imaxabs(intmax_t j);
230imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
231intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base);
232uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base);
233intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
234uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base);
235
236*/
237
238#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
239# include <__cxx03/__config>
240#else
241# include <__config>
242#endif
243
244#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
245# pragma GCC system_header
246#endif
247
248/* C99 stdlib (e.g. glibc < 2.18) does not provide format macros needed
249 for C++11 unless __STDC_FORMAT_MACROS is defined
250*/
251#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS)
252# define __STDC_FORMAT_MACROS
253#endif
254
255#if __has_include_next(<inttypes.h>)
256# include_next <inttypes.h>
257#endif
258
259#ifdef __cplusplus
260
261# include <stdint.h>
262
263# undef imaxabs
264# undef imaxdiv
265
266#endif // __cplusplus
267
268#endif // _LIBCPP_INTTYPES_H
lib/libcxx/include/iomanip+4-18
......@@ -413,6 +413,8 @@ inline _LIBCPP_HIDE_FROM_ABI __iom_t10<_CharT> put_time(const tm* __tm, const _C
413413 return __iom_t10<_CharT>(__tm, __fmt);
414414}
415415
416# if _LIBCPP_STD_VER >= 14
417
416418template <class _CharT, class _Traits>
417419_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& __quoted_output(
418420 basic_ostream<_CharT, _Traits>& __os,
......@@ -502,22 +504,6 @@ struct _LIBCPP_HIDDEN __quoted_proxy {
502504 }
503505};
504506
505template <class _CharT, class _Traits, class _Allocator>
506_LIBCPP_HIDE_FROM_ABI __quoted_output_proxy<_CharT, _Traits>
507__quoted(const basic_string<_CharT, _Traits, _Allocator>& __s,
508 _CharT __delim = _CharT('"'),
509 _CharT __escape = _CharT('\\')) {
510 return __quoted_output_proxy<_CharT, _Traits>(__s.data(), __s.data() + __s.size(), __delim, __escape);
511}
512
513template <class _CharT, class _Traits, class _Allocator>
514_LIBCPP_HIDE_FROM_ABI __quoted_proxy<_CharT, _Traits, _Allocator>
515__quoted(basic_string<_CharT, _Traits, _Allocator>& __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
516 return __quoted_proxy<_CharT, _Traits, _Allocator>(__s, __delim, __escape);
517}
518
519# if _LIBCPP_STD_VER >= 14
520
521507template <class _CharT>
522508_LIBCPP_HIDE_FROM_ABI auto quoted(const _CharT* __s, _CharT __delim = _CharT('"'), _CharT __escape = _CharT('\\')) {
523509 const _CharT* __end = __s;
......@@ -552,7 +538,7 @@ _LIBCPP_END_NAMESPACE_STD
552538
553539# endif // _LIBCPP_HAS_LOCALIZATION
554540
555# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
541# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
556542# include <array>
557543# include <bitset>
558544# include <deque>
......@@ -567,7 +553,7 @@ _LIBCPP_END_NAMESPACE_STD
567553# include <vector>
568554# endif
569555
570# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
556# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
571557# include <locale>
572558# endif
573559
lib/libcxx/include/ios+18-15
......@@ -235,10 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept;
235235# include <__verbose_abort>
236236# include <version>
237237
238# if _LIBCPP_HAS_ATOMIC_HEADER
239# include <__atomic/atomic.h> // for __xindex_
240# endif
241
242238# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
243239# pragma GCC system_header
244240# endif
......@@ -247,6 +243,7 @@ _LIBCPP_PUSH_MACROS
247243# include <__undef_macros>
248244
249245_LIBCPP_BEGIN_NAMESPACE_STD
246_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
250247
251248typedef ptrdiff_t streamsize;
252249
......@@ -361,7 +358,7 @@ public:
361358 }
362359
363360protected:
364 _LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(nullptr) {
361 _LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(__private_constructor_tag(), nullptr) {
365362 // Purposefully does no initialization
366363 //
367364 // Except for the locale, this is a sentinel to avoid destroying
......@@ -386,25 +383,25 @@ protected:
386383 _LIBCPP_HIDE_FROM_ABI void set_rdbuf(void* __sb) { __rdbuf_ = __sb; }
387384
388385private:
389 // All data members must be scalars
390386 fmtflags __fmtflags_;
391387 streamsize __precision_;
392388 streamsize __width_;
393389 iostate __rdstate_;
394390 iostate __exceptions_;
395391 void* __rdbuf_;
396 void* __loc_;
392# ifndef _LIBCPP_CXX03_LANG
393 union {
394 locale __loc_;
395 };
396# else
397 // We only care about the union above to implement the destructor correctly, which we do in C++26 anyways. No need to
398 // handle C++03 shenanigans.
399 locale __loc_;
400# endif
397401 event_callback* __fn_;
398402 int* __index_;
399403 size_t __event_size_;
400404 size_t __event_cap_;
401// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
402// enabled with clang.
403# if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS
404 static atomic<int> __xindex_;
405# else
406 static int __xindex_;
407# endif
408405 long* __iarray_;
409406 size_t __iarray_size_;
410407 size_t __iarray_cap_;
......@@ -871,13 +868,19 @@ _LIBCPP_HIDE_FROM_ABI inline ios_base& defaultfloat(ios_base& __str) {
871868 return __str;
872869}
873870
871_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
874872_LIBCPP_END_NAMESPACE_STD
875873
876874_LIBCPP_POP_MACROS
877875
878876# endif // _LIBCPP_HAS_LOCALIZATION
879877
880# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
878# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
879# include <ctime>
880# include <ratio>
881# endif
882
883# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
881884# include <atomic>
882885# include <concepts>
883886# include <cstddef>
lib/libcxx/include/istream+4-2
......@@ -190,6 +190,7 @@ _LIBCPP_PUSH_MACROS
190190# include <__undef_macros>
191191
192192_LIBCPP_BEGIN_NAMESPACE_STD
193_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
193194
194195template <class _CharT, class _Traits>
195196class basic_istream : virtual public basic_ios<_CharT, _Traits> {
......@@ -1405,20 +1406,21 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istream<wchar_t>;
14051406# endif
14061407extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_iostream<char>;
14071408
1409_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
14081410_LIBCPP_END_NAMESPACE_STD
14091411
14101412_LIBCPP_POP_MACROS
14111413
14121414# endif // _LIBCPP_HAS_LOCALIZATION
14131415
1414# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1416# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
14151417# include <concepts>
14161418# include <iosfwd>
14171419# include <ostream>
14181420# include <type_traits>
14191421# endif
14201422
1421# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
1423# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
14221424# include <locale>
14231425# endif
14241426
lib/libcxx/include/iterator+2-2
......@@ -751,11 +751,11 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
751751# pragma GCC system_header
752752# endif
753753
754# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
754# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 17
755755# include <variant>
756756# endif
757757
758# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
758# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
759759# include <cstddef>
760760# include <cstdlib>
761761# include <exception>
lib/libcxx/include/latch+1-1
......@@ -128,7 +128,7 @@ _LIBCPP_POP_MACROS
128128
129129# endif // _LIBCPP_HAS_THREADS
130130
131# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
131# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
132132# include <atomic>
133133# include <cstddef>
134134# endif
lib/libcxx/include/limits+12-4
......@@ -108,6 +108,7 @@ template<> class numeric_limits<cv long double>;
108108# include <__config>
109109# include <__type_traits/is_arithmetic.h>
110110# include <__type_traits/is_same.h>
111# include <__type_traits/make_unsigned.h>
111112
112113# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
113114# pragma GCC system_header
......@@ -184,9 +185,16 @@ protected:
184185
185186 static _LIBCPP_CONSTEXPR const bool is_specialized = true;
186187
187 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
188 static _LIBCPP_CONSTEXPR const int digits = static_cast<int>(sizeof(type) * __CHAR_BIT__ - is_signed);
189 static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10;
188 static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0);
189 // Number of value bits in type. Works for any integer type, including
190 // _BitInt(N), whose sizeof(type) * CHAR_BIT may include padding.
191 static _LIBCPP_CONSTEXPR const int digits =
192 __builtin_popcountg(static_cast<__make_unsigned_t<type> >(~__make_unsigned_t<type>(0))) - is_signed;
193 // digits10 = floor(digits * log10(2)). 1936274/6432163 is a continued-fraction
194 // convergent of log10(2) and matches floor(digits * log10(2)) exactly for every
195 // digits in [1, 8388608], i.e. up to __BITINT_MAXWIDTH__ on x86.
196 // TODO: switch to __builtin_log10 once it becomes constexpr.
197 static _LIBCPP_CONSTEXPR const int digits10 = static_cast<int>((digits * 1936274LL) / 6432163);
190198 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
191199 static _LIBCPP_CONSTEXPR const type __min = is_signed ? _Tp(_Tp(1) << digits) : 0;
192200 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
......@@ -520,7 +528,7 @@ _LIBCPP_END_NAMESPACE_STD
520528
521529_LIBCPP_POP_MACROS
522530
523# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
531# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
524532# include <type_traits>
525533# endif
526534#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/list+6-6
......@@ -39,7 +39,7 @@ public:
3939 noexcept(is_nothrow_default_constructible<allocator_type>::value);
4040 explicit list(const allocator_type& a);
4141 explicit list(size_type n);
42 explicit list(size_type n, const allocator_type& a); // C++14
42 explicit list(size_type n, const allocator_type& a);
4343 list(size_type n, const value_type& value);
4444 list(size_type n, const value_type& value, const allocator_type& a);
4545 template <class Iter>
......@@ -708,9 +708,7 @@ public:
708708 _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
709709 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
710710 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
711# if _LIBCPP_STD_VER >= 14
712711 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
713# endif
714712 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
715713 template <__enable_if_t<__is_allocator_v<_Alloc>, int> = 0>
716714 _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
......@@ -1066,13 +1064,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n) {
10661064# endif
10671065}
10681066
1069# if _LIBCPP_STD_VER >= 14
10701067template <class _Tp, class _Alloc>
10711068_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
10721069 for (; __n > 0; --__n)
1070# ifndef _LIBCPP_CXX03_LANG
10731071 emplace_back();
1074}
1072# else
1073 push_back(value_type());
10751074# endif
1075}
10761076
10771077template <class _Tp, class _Alloc>
10781078_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
......@@ -1815,7 +1815,7 @@ _LIBCPP_END_NAMESPACE_STD
18151815
18161816_LIBCPP_POP_MACROS
18171817
1818# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1818# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
18191819# include <algorithm>
18201820# include <atomic>
18211821# include <concepts>
lib/libcxx/include/locale+1-1
......@@ -210,7 +210,7 @@ template <class charT> class messages_byname;
210210
211211# endif // _LIBCPP_HAS_LOCALIZATION
212212
213# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
213# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
214214# include <atomic>
215215# include <concepts>
216216# include <cstdarg>
lib/libcxx/include/map+565-397
......@@ -57,177 +57,175 @@ public:
5757 };
5858
5959 // construct/copy/destroy:
60 map()
60 constexpr map()
6161 noexcept(
6262 is_nothrow_default_constructible<allocator_type>::value &&
6363 is_nothrow_default_constructible<key_compare>::value &&
6464 is_nothrow_copy_constructible<key_compare>::value);
65 explicit map(const key_compare& comp);
66 map(const key_compare& comp, const allocator_type& a);
65 constexpr explicit map(const key_compare& comp);
66 constexpr map(const key_compare& comp, const allocator_type& a);
6767 template <class InputIterator>
68 map(InputIterator first, InputIterator last,
68 constexpr map(InputIterator first, InputIterator last,
6969 const key_compare& comp = key_compare());
7070 template <class InputIterator>
71 map(InputIterator first, InputIterator last,
71 constexpr map(InputIterator first, InputIterator last,
7272 const key_compare& comp, const allocator_type& a);
7373 template<container-compatible-range<value_type> R>
74 map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23
75 map(const map& m);
76 map(map&& m)
74 constexpr map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23
75 constexpr map(const map& m);
76 constexpr map(map&& m)
7777 noexcept(
7878 is_nothrow_move_constructible<allocator_type>::value &&
7979 is_nothrow_move_constructible<key_compare>::value);
80 explicit map(const allocator_type& a);
81 map(const map& m, const allocator_type& a);
82 map(map&& m, const allocator_type& a);
83 map(initializer_list<value_type> il, const key_compare& comp = key_compare());
84 map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
80 constexpr explicit map(const allocator_type& a);
81 constexpr map(const map& m, const allocator_type& a);
82 constexpr map(map&& m, const allocator_type& a);
83 constexpr map(initializer_list<value_type> il, const key_compare& comp = key_compare());
84 constexpr map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
8585 template <class InputIterator>
86 map(InputIterator first, InputIterator last, const allocator_type& a)
87 : map(first, last, Compare(), a) {} // C++14
86 constexpr map(InputIterator first, InputIterator last, const allocator_type& a)
87 : map(first, last, Compare(), a) {}
8888 template<container-compatible-range<value_type> R>
89 map(from_range_t, R&& rg, const Allocator& a))
90 : map(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
91 map(initializer_list<value_type> il, const allocator_type& a)
92 : map(il, Compare(), a) {} // C++14
93 ~map();
94
95 map& operator=(const map& m);
96 map& operator=(map&& m)
89 constexpr map(from_range_t, R&& rg, const Allocator& a))
90 : map(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
91 constexpr map(initializer_list<value_type> il, const allocator_type& a)
92 : map(il, Compare(), a) {}
93 constexpr ~map();
94
95 constexpr map& operator=(const map& m);
96 constexpr map& operator=(map&& m)
9797 noexcept(
9898 allocator_type::propagate_on_container_move_assignment::value &&
9999 is_nothrow_move_assignable<allocator_type>::value &&
100100 is_nothrow_move_assignable<key_compare>::value);
101 map& operator=(initializer_list<value_type> il);
101 constexpr map& operator=(initializer_list<value_type> il);
102102
103103 // iterators:
104 iterator begin() noexcept;
105 const_iterator begin() const noexcept;
106 iterator end() noexcept;
107 const_iterator end() const noexcept;
104 constexpr iterator begin() noexcept;
105 constexpr const_iterator begin() const noexcept;
106 constexpr iterator end() noexcept;
107 constexpr const_iterator end() const noexcept;
108108
109 reverse_iterator rbegin() noexcept;
110 const_reverse_iterator rbegin() const noexcept;
111 reverse_iterator rend() noexcept;
112 const_reverse_iterator rend() const noexcept;
109 constexpr reverse_iterator rbegin() noexcept;
110 constexpr const_reverse_iterator rbegin() const noexcept;
111 constexpr reverse_iterator rend() noexcept;
112 constexpr const_reverse_iterator rend() const noexcept;
113113
114 const_iterator cbegin() const noexcept;
115 const_iterator cend() const noexcept;
116 const_reverse_iterator crbegin() const noexcept;
117 const_reverse_iterator crend() const noexcept;
114 constexpr const_iterator cbegin() const noexcept;
115 constexpr const_iterator cend() const noexcept;
116 constexpr const_reverse_iterator crbegin() const noexcept;
117 constexpr const_reverse_iterator crend() const noexcept;
118118
119119 // capacity:
120 bool empty() const noexcept;
121 size_type size() const noexcept;
122 size_type max_size() const noexcept;
120 constexpr bool empty() const noexcept;
121 constexpr size_type size() const noexcept;
122 constexpr size_type max_size() const noexcept;
123123
124124 // element access:
125 mapped_type& operator[](const key_type& k);
126 mapped_type& operator[](key_type&& k);
125 constexpr mapped_type& operator[](const key_type& k);
126 constexpr mapped_type& operator[](key_type&& k);
127127
128 mapped_type& at(const key_type& k);
129 const mapped_type& at(const key_type& k) const;
128 constexpr mapped_type& at(const key_type& k);
129 constexpr const mapped_type& at(const key_type& k) const;
130130
131131 // modifiers:
132132 template <class... Args>
133 pair<iterator, bool> emplace(Args&&... args);
133 constexpr pair<iterator, bool> emplace(Args&&... args);
134134 template <class... Args>
135 iterator emplace_hint(const_iterator position, Args&&... args);
136 pair<iterator, bool> insert(const value_type& v);
137 pair<iterator, bool> insert( value_type&& v); // C++17
138 template <class P>
139 pair<iterator, bool> insert(P&& p);
140 iterator insert(const_iterator position, const value_type& v);
141 iterator insert(const_iterator position, value_type&& v); // C++17
142 template <class P>
143 iterator insert(const_iterator position, P&& p);
144 template <class InputIterator>
145 void insert(InputIterator first, InputIterator last);
135 constexpr iterator emplace_hint(const_iterator position, Args&&... args);
136 constexpr pair<iterator, bool> insert(const value_type& v);
137 constexpr pair<iterator, bool> insert( value_type&& v); // C++17
138 template <class P> constexpr pair<iterator, bool> insert(P&& p);
139 constexpr iterator insert(const_iterator position, const value_type& v);
140 constexpr iterator insert(const_iterator position, value_type&& v); // C++17
141 template <class P> constexpr iterator insert(const_iterator position, P&& p);
142 template <class InputIterator> constexpr void insert(InputIterator first, InputIterator last);
143
146144 template<container-compatible-range<value_type> R>
147 void insert_range(R&& rg); // C++23
148 void insert(initializer_list<value_type> il);
145 constexpr void insert_range(R&& rg); // C++23
146 constexpr void insert(initializer_list<value_type> il);
149147
150 node_type extract(const_iterator position); // C++17
151 node_type extract(const key_type& x); // C++17
152 insert_return_type insert(node_type&& nh); // C++17
153 iterator insert(const_iterator hint, node_type&& nh); // C++17
148 constexpr node_type extract(const_iterator position); // C++17
149 constexpr node_type extract(const key_type& x); // C++17
150 constexpr insert_return_type insert(node_type&& nh); // C++17
151 constexpr iterator insert(const_iterator hint, node_type&& nh); // C++17
154152
155153 template <class... Args>
156 pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
154 constexpr pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); // C++17
157155 template <class... Args>
158 pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
156 constexpr pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); // C++17
159157 template <class... Args>
160 iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
158 constexpr iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17
161159 template <class... Args>
162 iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
160 constexpr iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17
163161 template <class M>
164 pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
162 constexpr pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); // C++17
165163 template <class M>
166 pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
164 constexpr pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj); // C++17
167165 template <class M>
168 iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
166 constexpr iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17
169167 template <class M>
170 iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
168 constexpr iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17
171169
172 iterator erase(const_iterator position);
173 iterator erase(iterator position); // C++14
174 size_type erase(const key_type& k);
175 iterator erase(const_iterator first, const_iterator last);
176 void clear() noexcept;
170 constexpr iterator erase(const_iterator position);
171 constexpr iterator erase(iterator position); // C++14
172 constexpr size_type erase(const key_type& k);
173 constexpr iterator erase(const_iterator first, const_iterator last);
174 constexpr void clear() noexcept;
177175
178176 template<class C2>
179 void merge(map<Key, T, C2, Allocator>& source); // C++17
177 constexpr void merge(map<Key, T, C2, Allocator>& source); // C++17
180178 template<class C2>
181 void merge(map<Key, T, C2, Allocator>&& source); // C++17
179 constexpr void merge(map<Key, T, C2, Allocator>&& source); // C++17
182180 template<class C2>
183 void merge(multimap<Key, T, C2, Allocator>& source); // C++17
181 constexpr void merge(multimap<Key, T, C2, Allocator>& source); // C++17
184182 template<class C2>
185 void merge(multimap<Key, T, C2, Allocator>&& source); // C++17
183 constexpr void merge(multimap<Key, T, C2, Allocator>&& source); // C++17
186184
187 void swap(map& m)
185 constexpr void swap(map& m)
188186 noexcept(allocator_traits<allocator_type>::is_always_equal::value &&
189 is_nothrow_swappable<key_compare>::value); // C++17
187 is_nothrow_swappable<key_compare>::value); // C++17
190188
191189 // observers:
192 allocator_type get_allocator() const noexcept;
193 key_compare key_comp() const;
194 value_compare value_comp() const;
190 constexpr allocator_type get_allocator() const noexcept;
191 constexpr key_compare key_comp() const;
192 constexpr value_compare value_comp() const;
195193
196194 // map operations:
197 iterator find(const key_type& k);
198 const_iterator find(const key_type& k) const;
195 constexpr iterator find(const key_type& k);
196 constexpr const_iterator find(const key_type& k) const;
199197 template<typename K>
200 iterator find(const K& x); // C++14
198 constexpr iterator find(const K& x); // C++14
201199 template<typename K>
202 const_iterator find(const K& x) const; // C++14
200 constexpr const_iterator find(const K& x) const; // C++14
203201
204202 template<typename K>
205 size_type count(const K& x) const; // C++14
206 size_type count(const key_type& k) const;
203 constexpr size_type count(const K& x) const; // C++14
204 constexpr size_type count(const key_type& k) const;
207205
208 bool contains(const key_type& x) const; // C++20
209 template<class K> bool contains(const K& x) const; // C++20
206 constexpr bool contains(const key_type& x) const; // C++20
207 template<class K> constexpr bool contains(const K& x) const; // C++20
210208
211 iterator lower_bound(const key_type& k);
212 const_iterator lower_bound(const key_type& k) const;
209 constexpr iterator lower_bound(const key_type& k);
210 constexpr const_iterator lower_bound(const key_type& k) const;
213211 template<typename K>
214 iterator lower_bound(const K& x); // C++14
212 constexpr iterator lower_bound(const K& x); // C++14
215213 template<typename K>
216 const_iterator lower_bound(const K& x) const; // C++14
214 constexpr const_iterator lower_bound(const K& x) const; // C++14
217215
218 iterator upper_bound(const key_type& k);
219 const_iterator upper_bound(const key_type& k) const;
216 constexpr iterator upper_bound(const key_type& k);
217 constexpr const_iterator upper_bound(const key_type& k) const;
220218 template<typename K>
221 iterator upper_bound(const K& x); // C++14
219 constexpr iterator upper_bound(const K& x); // C++14
222220 template<typename K>
223 const_iterator upper_bound(const K& x) const; // C++14
221 constexpr const_iterator upper_bound(const K& x) const; // C++14
224222
225 pair<iterator,iterator> equal_range(const key_type& k);
226 pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
223 constexpr pair<iterator,iterator> equal_range(const key_type& k);
224 constexpr pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
227225 template<typename K>
228 pair<iterator,iterator> equal_range(const K& x); // C++14
226 constexpr pair<iterator,iterator> equal_range(const K& x); // C++14
229227 template<typename K>
230 pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
228 constexpr pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14
231229};
232230
233231template <class InputIterator,
......@@ -370,12 +368,12 @@ public:
370368 const allocator_type& a);
371369 template <class InputIterator>
372370 multimap(InputIterator first, InputIterator last, const allocator_type& a)
373 : multimap(first, last, Compare(), a) {} // C++14
371 : multimap(first, last, Compare(), a) {}
374372 template<container-compatible-range<value_type> R>
375373 multimap(from_range_t, R&& rg, const Allocator& a))
376374 : multimap(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
377375 multimap(initializer_list<value_type> il, const allocator_type& a)
378 : multimap(il, Compare(), a) {} // C++14
376 : multimap(il, Compare(), a) {}
379377 ~multimap();
380378
381379 multimap& operator=(const multimap& m);
......@@ -411,7 +409,7 @@ public:
411409 template <class... Args>
412410 iterator emplace(Args&&... args);
413411 template <class... Args>
414 iterator emplace_hint(const_iterator position, Args&&... args);
412 iterator emplace_hint(const_iterator position, Args&&... args);
415413 iterator insert(const value_type& v);
416414 iterator insert( value_type&& v); // C++17
417415 template <class P>
......@@ -641,28 +639,37 @@ class __map_value_compare {
641639 _LIBCPP_COMPRESSED_ELEMENT(_Compare, __comp_);
642640
643641public:
644 _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
642 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare()
643 _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value)
645644 : __comp_() {}
646 _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
645 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare(_Compare __c)
646 _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value)
647647 : __comp_(__c) {}
648 _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; }
648 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const _Compare& key_comp() const _NOEXCEPT { return __comp_; }
649649
650 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.first, __y.first); }
651 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.first, __y); }
652 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.first); }
653 _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
650 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _CP& __y) const {
651 return __comp_(__x.first, __y.first);
652 }
653 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _Key& __y) const {
654 return __comp_(__x.first, __y);
655 }
656 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _Key& __x, const _CP& __y) const {
657 return __comp_(__x, __y.first);
658 }
659 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__map_value_compare& __y)
660 _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
654661 using std::swap;
655662 swap(__comp_, __y.__comp_);
656663 }
657664
658665# if _LIBCPP_STD_VER >= 14
659666 template <typename _K2>
660 _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const {
667 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _K2& __x, const _CP& __y) const {
661668 return __comp_(__x, __y.first);
662669 }
663670
664671 template <typename _K2>
665 _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const {
672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _K2& __y) const {
666673 return __comp_(__x.first, __y);
667674 }
668675# endif
......@@ -678,11 +685,11 @@ template <class _MapValueT, class _Key, class _Compare>
678685struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _MapValueT, _MapValueT> {
679686 __lazy_synth_three_way_comparator<_Compare, _Key, _Key> __comp_;
680687
681 __lazy_synth_three_way_comparator(
688 _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_synth_three_way_comparator(
682689 _LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp)
683690 : __comp_(__comp.key_comp()) {}
684691
685 _LIBCPP_HIDE_FROM_ABI auto
692 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
686693 operator()(_LIBCPP_LIFETIMEBOUND const _MapValueT& __lhs, _LIBCPP_LIFETIMEBOUND const _MapValueT& __rhs) const {
687694 return __comp_(__lhs.first, __rhs.first);
688695 }
......@@ -692,11 +699,11 @@ template <class _MapValueT, class _Key, class _TransparentKey, class _Compare>
692699struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _Compare>, _TransparentKey, _MapValueT> {
693700 __lazy_synth_three_way_comparator<_Compare, _TransparentKey, _Key> __comp_;
694701
695 __lazy_synth_three_way_comparator(
702 _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_synth_three_way_comparator(
696703 _LIBCPP_CTOR_LIFETIMEBOUND const __map_value_compare<_Key, _MapValueT, _Compare>& __comp)
697704 : __comp_(__comp.key_comp()) {}
698705
699 _LIBCPP_HIDE_FROM_ABI auto
706 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 auto
700707 operator()(_LIBCPP_LIFETIMEBOUND const _TransparentKey& __lhs, _LIBCPP_LIFETIMEBOUND const _MapValueT& __rhs) const {
701708 return __comp_(__lhs, __rhs.first);
702709 }
......@@ -718,7 +725,7 @@ struct __lazy_synth_three_way_comparator<__map_value_compare<_Key, _MapValueT, _
718725# endif // _LIBCPP_STD_VER >= 14
719726
720727template <class _Key, class _CP, class _Compare>
721inline _LIBCPP_HIDE_FROM_ABI void
728inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
722729swap(__map_value_compare<_Key, _CP, _Compare>& __x, __map_value_compare<_Key, _CP, _Compare>& __y)
723730 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
724731 __x.swap(__y);
......@@ -779,37 +786,41 @@ public:
779786 using reference = value_type&;
780787 using pointer = typename _TreeIterator::pointer;
781788
782 _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {}
789 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator() _NOEXCEPT {}
783790
784 _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
791 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
785792
786 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
787 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
793 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return *__i_; }
794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
795 return pointer_traits<pointer>::pointer_to(*__i_);
796 }
788797
789 _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() {
798 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator& operator++() {
790799 ++__i_;
791800 return *this;
792801 }
793 _LIBCPP_HIDE_FROM_ABI __map_iterator operator++(int) {
802 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator operator++(int) {
794803 __map_iterator __t(*this);
795804 ++(*this);
796805 return __t;
797806 }
798807
799 _LIBCPP_HIDE_FROM_ABI __map_iterator& operator--() {
808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator& operator--() {
800809 --__i_;
801810 return *this;
802811 }
803 _LIBCPP_HIDE_FROM_ABI __map_iterator operator--(int) {
812 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator operator--(int) {
804813 __map_iterator __t(*this);
805814 --(*this);
806815 return __t;
807816 }
808817
809 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_iterator& __x, const __map_iterator& __y) {
818 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
819 operator==(const __map_iterator& __x, const __map_iterator& __y) {
810820 return __x.__i_ == __y.__i_;
811821 }
812 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {
822 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
823 operator!=(const __map_iterator& __x, const __map_iterator& __y) {
813824 return __x.__i_ != __y.__i_;
814825 }
815826
......@@ -834,7 +845,8 @@ struct __specialized_algorithm<_Alg, __iterator_pair<__map_iterator<_TreeIterato
834845 using __iterator _LIBCPP_NODEBUG = __map_iterator<_TreeIterator>;
835846
836847 template <class... _Args>
837 _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Args&&... __args) {
848 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
849 operator()(__iterator __first, __iterator __last, _Args&&... __args) {
838850 __base()(__first.__i_, __last.__i_, std::forward<_Args>(__args)...);
839851 }
840852};
......@@ -851,39 +863,43 @@ public:
851863 using reference = const value_type&;
852864 using pointer = typename _TreeIterator::pointer;
853865
854 _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {}
866 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator() _NOEXCEPT {}
855867
856 _LIBCPP_HIDE_FROM_ABI __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
857 _LIBCPP_HIDE_FROM_ABI
868 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
858870 __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {}
859871
860 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return *__i_; }
861 _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(*__i_); }
872 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return *__i_; }
873 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
874 return pointer_traits<pointer>::pointer_to(*__i_);
875 }
862876
863 _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() {
877 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator& operator++() {
864878 ++__i_;
865879 return *this;
866880 }
867 _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator++(int) {
881 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator operator++(int) {
868882 __map_const_iterator __t(*this);
869883 ++(*this);
870884 return __t;
871885 }
872886
873 _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator--() {
887 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator& operator--() {
874888 --__i_;
875889 return *this;
876890 }
877 _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator--(int) {
891 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator operator--(int) {
878892 __map_const_iterator __t(*this);
879893 --(*this);
880894 return __t;
881895 }
882896
883 friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) {
897 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
898 operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) {
884899 return __x.__i_ == __y.__i_;
885900 }
886 friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {
901 friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
902 operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {
887903 return __x.__i_ != __y.__i_;
888904 }
889905
......@@ -910,7 +926,8 @@ struct __specialized_algorithm<
910926 using __iterator _LIBCPP_NODEBUG = __map_const_iterator<_TreeIterator>;
911927
912928 template <class... _Args>
913 _LIBCPP_HIDE_FROM_ABI static void operator()(__iterator __first, __iterator __last, _Args&&... __args) {
929 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void
930 operator()(__iterator __first, __iterator __last, _Args&&... __args) {
914931 __base()(__first.__i_, __last.__i_, std::forward<_Args>(__args)...);
915932 }
916933};
......@@ -940,10 +957,11 @@ public:
940957 protected:
941958 key_compare comp;
942959
943 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {}
960 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : comp(__c) {}
944961
945962 public:
946 _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const {
963 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
964 operator()(const value_type& __x, const value_type& __y) const {
947965 return comp(__x.first, __y.first);
948966 }
949967 };
......@@ -979,26 +997,27 @@ public:
979997 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
980998 friend class multimap;
981999
982 _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_(
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map() _NOEXCEPT_(
9831001 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
9841002 is_nothrow_copy_constructible<key_compare>::value)
9851003 : __tree_(__vc(key_compare())) {}
9861004
987 _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp) _NOEXCEPT_(
1005 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const key_compare& __comp) _NOEXCEPT_(
9881006 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)
9891007 : __tree_(__vc(__comp)) {}
9901008
991 _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp, const allocator_type& __a)
1009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const key_compare& __comp, const allocator_type& __a)
9921010 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
9931011
9941012 template <class _InputIterator>
995 _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())
1013 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1014 map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())
9961015 : __tree_(__vc(__comp)) {
9971016 insert(__f, __l);
9981017 }
9991018
10001019 template <class _InputIterator>
1001 _LIBCPP_HIDE_FROM_ABI
1020 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
10021021 map(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a)
10031022 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
10041023 insert(__f, __l);
......@@ -1006,7 +1025,7 @@ public:
10061025
10071026# if _LIBCPP_STD_VER >= 23
10081027 template <_ContainerCompatibleRange<value_type> _Range>
1009 _LIBCPP_HIDE_FROM_ABI
1028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
10101029 map(from_range_t,
10111030 _Range&& __range,
10121031 const key_compare& __comp = key_compare(),
......@@ -1016,46 +1035,46 @@ public:
10161035 }
10171036# endif
10181037
1019# if _LIBCPP_STD_VER >= 14
10201038 template <class _InputIterator>
1021 _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1039 _LIBCPP_HIDE_FROM_ABI
1040 _LIBCPP_CONSTEXPR_SINCE_CXX26 map(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
10221041 : map(__f, __l, key_compare(), __a) {}
1023# endif
10241042
10251043# if _LIBCPP_STD_VER >= 23
10261044 template <_ContainerCompatibleRange<value_type> _Range>
1027 _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a)
1045 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(from_range_t, _Range&& __range, const allocator_type& __a)
10281046 : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
10291047# endif
10301048
1031 _LIBCPP_HIDE_FROM_ABI map(const map& __m) = default;
1049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(const map& __m) = default;
10321050
1033 _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) = default;
1051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(const map& __m) = default;
10341052
10351053# ifndef _LIBCPP_CXX03_LANG
10361054
1037 _LIBCPP_HIDE_FROM_ABI map(map&& __m) = default;
1055 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(map&& __m) = default;
10381056
1039 _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), __a) {}
1057 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(map&& __m, const allocator_type& __a)
1058 : __tree_(std::move(__m.__tree_), __a) {}
10401059
1041 _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) = default;
1060 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(map&& __m) = default;
10421061
1043 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
1062 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1063 map(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
10441064 : __tree_(__vc(__comp)) {
10451065 insert(__il.begin(), __il.end());
10461066 }
10471067
1048 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
1068 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1069 map(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
10491070 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
10501071 insert(__il.begin(), __il.end());
10511072 }
10521073
1053# if _LIBCPP_STD_VER >= 14
1054 _LIBCPP_HIDE_FROM_ABI map(initializer_list<value_type> __il, const allocator_type& __a)
1074 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(initializer_list<value_type> __il, const allocator_type& __a)
10551075 : map(__il, key_compare(), __a) {}
1056# endif
10571076
1058 _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list<value_type> __il) {
1077 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(initializer_list<value_type> __il) {
10591078 clear();
10601079 insert(__il.begin(), __il.end());
10611080 return *this;
......@@ -1063,118 +1082,157 @@ public:
10631082
10641083# endif // _LIBCPP_CXX03_LANG
10651084
1066 _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}
1085 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const allocator_type& __a)
1086 : __tree_(typename __base::allocator_type(__a)) {}
10671087
1068 _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __alloc) : __tree_(__m.__tree_, __alloc) {}
1088 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(const map& __m, const allocator_type& __alloc)
1089 : __tree_(__m.__tree_, __alloc) {}
10691090
1070 _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
1091 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~map() {
1092 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
1093 }
10711094
1072 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1073 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
1074 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
1075 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
1095 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT {
1096 return __tree_.begin();
1097 }
1098 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
1099 return __tree_.begin();
1100 }
1101 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT {
1102 return __tree_.end();
1103 }
1104 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
1105 return __tree_.end();
1106 }
10761107
1077 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
1078 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
1108 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() _NOEXCEPT {
1109 return reverse_iterator(end());
1110 }
1111 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1112 rbegin() const _NOEXCEPT {
10791113 return const_reverse_iterator(end());
10801114 }
1081 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
1082 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
1115 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() _NOEXCEPT {
1116 return reverse_iterator(begin());
1117 }
1118 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const _NOEXCEPT {
10831119 return const_reverse_iterator(begin());
10841120 }
10851121
1086 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
1087 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
1088 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1089 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
1122 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const _NOEXCEPT {
1123 return begin();
1124 }
1125 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const _NOEXCEPT {
1126 return end();
1127 }
1128 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1129 crbegin() const _NOEXCEPT {
1130 return rbegin();
1131 }
1132 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const _NOEXCEPT {
1133 return rend();
1134 }
10901135
1091 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1092 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1093 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
1136 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const _NOEXCEPT {
1137 return __tree_.size() == 0;
1138 }
1139 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT {
1140 return __tree_.size();
1141 }
1142 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
1143 return __tree_.max_size();
1144 }
10941145
1095 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k);
1146 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __k);
10961147# ifndef _LIBCPP_CXX03_LANG
1097 _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k);
1148 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](key_type&& __k);
10981149# endif
10991150
11001151 template <class _Arg,
11011152 __enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
1102 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mapped_type& at(_Arg&& __arg) {
1103 auto [_, __child] = __tree_.__find_equal(__arg);
1153 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(_Arg&& __arg) {
1154 auto [__dummy, __child] = __tree_.__find_equal(__arg);
11041155 if (__child == nullptr)
11051156 std::__throw_out_of_range("map::at: key not found");
1106 return static_cast<__node_pointer>(__child)->__get_value().second;
1157 return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
11071158 }
11081159
11091160 template <class _Arg,
11101161 __enable_if_t<__is_transparently_comparable_v<_Compare, key_type, __remove_cvref_t<_Arg> >, int> = 0>
1111 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mapped_type& at(_Arg&& __arg) const {
1112 auto [_, __child] = __tree_.__find_equal(__arg);
1162 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(_Arg&& __arg) const {
1163 auto [__dummy, __child] = __tree_.__find_equal(__arg);
11131164 if (__child == nullptr)
11141165 std::__throw_out_of_range("map::at: key not found");
1115 return static_cast<__node_pointer>(__child)->__get_value().second;
1166 return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
11161167 }
11171168
1118 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k);
1119 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const;
1169 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __k);
1170 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type&
1171 at(const key_type& __k) const;
11201172
1121 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1173 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT {
11221174 return allocator_type(__tree_.__alloc());
11231175 }
1124 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }
1125 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const {
1176 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const {
1177 return __tree_.value_comp().key_comp();
1178 }
1179 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const {
11261180 return value_compare(__tree_.value_comp().key_comp());
11271181 }
11281182
11291183# ifndef _LIBCPP_CXX03_LANG
11301184 template <class... _Args>
1131 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
1185 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
11321186 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);
11331187 }
11341188
11351189 template <class... _Args>
1136 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1190 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
11371191 return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...).first;
11381192 }
11391193
11401194 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1141 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) {
1195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(_Pp&& __p) {
11421196 return __tree_.__emplace_unique(std::forward<_Pp>(__p));
11431197 }
11441198
11451199 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1146 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
1200 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __pos, _Pp&& __p) {
11471201 return __tree_.__emplace_hint_unique(__pos.__i_, std::forward<_Pp>(__p)).first;
11481202 }
11491203
11501204# endif // _LIBCPP_CXX03_LANG
11511205
1152 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); }
1206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __v) {
1207 return __tree_.__emplace_unique(__v);
1208 }
11531209
1154 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1210 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) {
11551211 return __tree_.__emplace_hint_unique(__p.__i_, __v).first;
11561212 }
11571213
11581214# ifndef _LIBCPP_CXX03_LANG
1159 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
1215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __v) {
11601216 return __tree_.__emplace_unique(std::move(__v));
11611217 }
11621218
1163 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1219 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, value_type&& __v) {
11641220 return __tree_.__emplace_hint_unique(__p.__i_, std::move(__v)).first;
11651221 }
11661222
1167 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
1224 insert(__il.begin(), __il.end());
1225 }
11681226# endif
11691227
11701228 template <class _InputIterator>
1171 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
1229 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
11721230 __tree_.__insert_range_unique(__first, __last);
11731231 }
11741232
11751233# if _LIBCPP_STD_VER >= 23
11761234 template <_ContainerCompatibleRange<value_type> _Range>
1177 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
11781236 __tree_.__insert_range_unique(ranges::begin(__range), ranges::end(__range));
11791237 }
11801238# endif
......@@ -1182,13 +1240,15 @@ public:
11821240# if _LIBCPP_STD_VER >= 17
11831241
11841242 template <class... _Args>
1185 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(const key_type& __k, _Args&&... __args) {
1243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1244 try_emplace(const key_type& __k, _Args&&... __args) {
11861245 return __tree_.__emplace_unique(
11871246 std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple(std::forward<_Args>(__args)...));
11881247 }
11891248
11901249 template <class... _Args>
1191 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> try_emplace(key_type&& __k, _Args&&... __args) {
1250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1251 try_emplace(key_type&& __k, _Args&&... __args) {
11921252 return __tree_.__emplace_unique(
11931253 std::piecewise_construct,
11941254 std::forward_as_tuple(std::move(__k)),
......@@ -1196,7 +1256,8 @@ public:
11961256 }
11971257
11981258 template <class... _Args>
1199 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) {
1259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1260 try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) {
12001261 return __tree_
12011262 .__emplace_hint_unique(
12021263 __h.__i_,
......@@ -1207,7 +1268,8 @@ public:
12071268 }
12081269
12091270 template <class... _Args>
1210 _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) {
1271 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1272 try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) {
12111273 return __tree_
12121274 .__emplace_hint_unique(
12131275 __h.__i_,
......@@ -1218,7 +1280,8 @@ public:
12181280 }
12191281
12201282 template <class _Vp>
1221 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(const key_type& __k, _Vp&& __v) {
1283 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
1284 insert_or_assign(const key_type& __k, _Vp&& __v) {
12221285 auto __result = __tree_.__emplace_unique(__k, std::forward<_Vp>(__v));
12231286 auto& [__iter, __inserted] = __result;
12241287 if (!__inserted)
......@@ -1227,7 +1290,7 @@ public:
12271290 }
12281291
12291292 template <class _Vp>
1230 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) {
1293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert_or_assign(key_type&& __k, _Vp&& __v) {
12311294 auto __result = __tree_.__emplace_unique(std::move(__k), std::forward<_Vp>(__v));
12321295 auto& [__iter, __inserted] = __result;
12331296 if (!__inserted)
......@@ -1236,7 +1299,8 @@ public:
12361299 }
12371300
12381301 template <class _Vp>
1239 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) {
1302 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1303 insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) {
12401304 auto [__r, __inserted] = __tree_.__emplace_hint_unique(__h.__i_, __k, std::forward<_Vp>(__v));
12411305
12421306 if (!__inserted)
......@@ -1246,7 +1310,8 @@ public:
12461310 }
12471311
12481312 template <class _Vp>
1249 _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) {
1313 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
1314 insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) {
12501315 auto [__r, __inserted] = __tree_.__emplace_hint_unique(__h.__i_, std::move(__k), std::forward<_Vp>(__v));
12511316
12521317 if (!__inserted)
......@@ -1257,101 +1322,118 @@ public:
12571322
12581323# endif // _LIBCPP_STD_VER >= 17
12591324
1260 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }
1261 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
1262 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }
1263 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) {
1325 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) {
1326 return __tree_.erase(__p.__i_);
1327 }
1328 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
1329 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) {
1330 return __tree_.__erase_unique(__k);
1331 }
1332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) {
12641333 return __tree_.erase(__f.__i_, __l.__i_);
12651334 }
1266 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
1335 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); }
12671336
12681337# if _LIBCPP_STD_VER >= 17
1269 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
1338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 insert_return_type insert(node_type&& __nh) {
12701339 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
12711340 "node_type with incompatible allocator passed to map::insert()");
12721341 return __tree_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
12731342 }
1274 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
1343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, node_type&& __nh) {
12751344 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
12761345 "node_type with incompatible allocator passed to map::insert()");
12771346 return __tree_.template __node_handle_insert_unique<node_type>(__hint.__i_, std::move(__nh));
12781347 }
1279 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
1348 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(key_type const& __key) {
12801349 return __tree_.template __node_handle_extract<node_type>(__key);
12811350 }
1282 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
1351 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(const_iterator __it) {
12831352 return __tree_.template __node_handle_extract<node_type>(__it.__i_);
12841353 }
12851354 template <class _Compare2>
1286 _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {
1355 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1356 merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {
12871357 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12881358 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12891359 __tree_.__node_handle_merge_unique(__source.__tree_);
12901360 }
12911361 template <class _Compare2>
1292 _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
1362 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1363 merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
12931364 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12941365 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12951366 __tree_.__node_handle_merge_unique(__source.__tree_);
12961367 }
12971368 template <class _Compare2>
1298 _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {
1369 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1370 merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {
12991371 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
13001372 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13011373 __tree_.__node_handle_merge_unique(__source.__tree_);
13021374 }
13031375 template <class _Compare2>
1304 _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
1376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1377 merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
13051378 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
13061379 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
13071380 __tree_.__node_handle_merge_unique(__source.__tree_);
13081381 }
13091382# endif
13101383
1311 _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); }
1384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
1385 __tree_.swap(__m.__tree_);
1386 }
13121387
1313 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1314 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
1388 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __k) {
1389 return __tree_.find(__k);
1390 }
1391 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __k) const {
1392 return __tree_.find(__k);
1393 }
13151394# if _LIBCPP_STD_VER >= 14
13161395 template <typename _K2,
1317 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1318 int> = 0>
1319 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1396 class _Comp = _Compare,
1397 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1398 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _K2& __k) {
13201399 return __tree_.find(__k);
13211400 }
13221401 template <typename _K2,
1323 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1324 int> = 0>
1325 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1402 class _Comp = _Compare,
1403 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1404 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _K2& __k) const {
13261405 return __tree_.find(__k);
13271406 }
13281407# endif
13291408
1330 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
1409 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const {
13311410 return __tree_.__count_unique(__k);
13321411 }
13331412# if _LIBCPP_STD_VER >= 14
1334 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1335 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1413 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1414 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _K2& __k) const {
13361415 return __tree_.__count_multi(__k);
13371416 }
13381417# endif
13391418
13401419# if _LIBCPP_STD_VER >= 20
1341 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1420 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __k) const {
1421 return find(__k) != end();
1422 }
13421423 template <typename _K2,
1343 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1344 int> = 0>
1345 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1424 class _Comp = _Compare,
1425 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1426 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _K2& __k) const {
13461427 return find(__k) != end();
13471428 }
13481429# endif // _LIBCPP_STD_VER >= 20
13491430
1350 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) {
1431 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) {
13511432 return __tree_.__lower_bound_unique(__k);
13521433 }
13531434
1354 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
1435 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1436 lower_bound(const key_type& __k) const {
13551437 return __tree_.__lower_bound_unique(__k);
13561438 }
13571439
......@@ -1359,56 +1441,63 @@ public:
13591441 // match multiple elements.
13601442# if _LIBCPP_STD_VER >= 14
13611443 template <typename _K2,
1362 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1363 int> = 0>
1364 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
1444 class _Comp = _Compare,
1445 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1446 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _K2& __k) {
13651447 return __tree_.__lower_bound_multi(__k);
13661448 }
13671449
13681450 template <typename _K2,
1369 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1370 int> = 0>
1371 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
1451 class _Comp = _Compare,
1452 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1453 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1454 lower_bound(const _K2& __k) const {
13721455 return __tree_.__lower_bound_multi(__k);
13731456 }
13741457# endif
13751458
1376 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) {
1459 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) {
13771460 return __tree_.__upper_bound_unique(__k);
13781461 }
13791462
1380 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const {
1463 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1464 upper_bound(const key_type& __k) const {
13811465 return __tree_.__upper_bound_unique(__k);
13821466 }
13831467
13841468# if _LIBCPP_STD_VER >= 14
13851469 template <typename _K2,
1386 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1387 int> = 0>
1388 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
1470 class _Comp = _Compare,
1471 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1472 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _K2& __k) {
13891473 return __tree_.__upper_bound_multi(__k);
13901474 }
13911475 template <typename _K2,
1392 enable_if_t<__is_transparent_v<_Compare, _K2> || __is_transparently_comparable_v<_Compare, key_type, _K2>,
1393 int> = 0>
1394 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
1476 class _Comp = _Compare,
1477 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1478 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1479 upper_bound(const _K2& __k) const {
13951480 return __tree_.__upper_bound_multi(__k);
13961481 }
13971482# endif
13981483
1399 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1484 [[__nodiscard__]]
1485 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __k) {
14001486 return __tree_.__equal_range_unique(__k);
14011487 }
1402 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1488 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1489 equal_range(const key_type& __k) const {
14031490 return __tree_.__equal_range_unique(__k);
14041491 }
14051492# if _LIBCPP_STD_VER >= 14
1406 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1407 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1493 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1494 [[__nodiscard__]]
1495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _K2& __k) {
14081496 return __tree_.__equal_range_multi(__k);
14091497 }
1410 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1411 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1498 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1499 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1500 equal_range(const _K2& __k) const {
14121501 return __tree_.__equal_range_multi(__k);
14131502 }
14141503# endif
......@@ -1487,8 +1576,8 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<map<_Key,
14871576 static const bool __has_algorithm = true;
14881577
14891578 template <class _Map, class _Func, class _Proj>
1490 _LIBCPP_HIDE_FROM_ABI static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
1491 auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
1579 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
1580 auto [__dummy, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
14921581 __map.__tree_, std::move(__func), std::move(__proj));
14931582 return std::make_pair(__map.end(), std::move(__func2));
14941583 }
......@@ -1497,13 +1586,13 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<map<_Key,
14971586
14981587# ifndef _LIBCPP_CXX03_LANG
14991588template <class _Key, class _Tp, class _Compare, class _Allocator>
1500_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
1589_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
15011590 return __tree_.__emplace_unique(std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple())
15021591 .first->second;
15031592}
15041593
15051594template <class _Key, class _Tp, class _Compare, class _Allocator>
1506_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {
1595_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) {
15071596 return __tree_
15081597 .__emplace_unique(std::piecewise_construct, std::forward_as_tuple(std::move(__k)), std::forward_as_tuple())
15091598 .first->second;
......@@ -1538,23 +1627,23 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) {
15381627# endif // _LIBCPP_CXX03_LANG
15391628
15401629template <class _Key, class _Tp, class _Compare, class _Allocator>
1541_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {
1542 auto [_, __child] = __tree_.__find_equal(__k);
1630_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) {
1631 auto [__dummy, __child] = __tree_.__find_equal(__k);
15431632 if (__child == nullptr)
15441633 std::__throw_out_of_range("map::at: key not found");
1545 return static_cast<__node_pointer>(__child)->__get_value().second;
1634 return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
15461635}
15471636
15481637template <class _Key, class _Tp, class _Compare, class _Allocator>
1549const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {
1550 auto [_, __child] = __tree_.__find_equal(__k);
1638_LIBCPP_CONSTEXPR_SINCE_CXX26 const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const {
1639 auto [__dummy, __child] = __tree_.__find_equal(__k);
15511640 if (__child == nullptr)
15521641 std::__throw_out_of_range("map::at: key not found");
1553 return static_cast<__node_pointer>(__child)->__get_value().second;
1642 return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__get_value().second;
15541643}
15551644
15561645template <class _Key, class _Tp, class _Compare, class _Allocator>
1557inline _LIBCPP_HIDE_FROM_ABI bool
1646inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15581647operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15591648 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
15601649}
......@@ -1562,31 +1651,31 @@ operator==(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
15621651# if _LIBCPP_STD_VER <= 17
15631652
15641653template <class _Key, class _Tp, class _Compare, class _Allocator>
1565inline _LIBCPP_HIDE_FROM_ABI bool
1654inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15661655operator<(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15671656 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
15681657}
15691658
15701659template <class _Key, class _Tp, class _Compare, class _Allocator>
1571inline _LIBCPP_HIDE_FROM_ABI bool
1660inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15721661operator!=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15731662 return !(__x == __y);
15741663}
15751664
15761665template <class _Key, class _Tp, class _Compare, class _Allocator>
1577inline _LIBCPP_HIDE_FROM_ABI bool
1666inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15781667operator>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15791668 return __y < __x;
15801669}
15811670
15821671template <class _Key, class _Tp, class _Compare, class _Allocator>
1583inline _LIBCPP_HIDE_FROM_ABI bool
1672inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15841673operator>=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15851674 return !(__x < __y);
15861675}
15871676
15881677template <class _Key, class _Tp, class _Compare, class _Allocator>
1589inline _LIBCPP_HIDE_FROM_ABI bool
1678inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
15901679operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15911680 return !(__y < __x);
15921681}
......@@ -1594,7 +1683,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
15941683# else // #if _LIBCPP_STD_VER <= 17
15951684
15961685template <class _Key, class _Tp, class _Compare, class _Allocator>
1597_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
1686_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<pair<const _Key, _Tp>>
15981687operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
15991688 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
16001689}
......@@ -1602,7 +1691,7 @@ operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp
16021691# endif // #if _LIBCPP_STD_VER <= 17
16031692
16041693template <class _Key, class _Tp, class _Compare, class _Allocator>
1605inline _LIBCPP_HIDE_FROM_ABI void
1694inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
16061695swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Allocator>& __y)
16071696 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
16081697 __x.swap(__y);
......@@ -1610,7 +1699,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, map<_Key, _Tp, _Compare, _Alloca
16101699
16111700# if _LIBCPP_STD_VER >= 20
16121701template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
1613inline _LIBCPP_HIDE_FROM_ABI typename map<_Key, _Tp, _Compare, _Allocator>::size_type
1702inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename map<_Key, _Tp, _Compare, _Allocator>::size_type
16141703erase_if(map<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
16151704 return std::__libcpp_erase_if_container(__c, __pred);
16161705}
......@@ -1648,10 +1737,11 @@ public:
16481737 protected:
16491738 key_compare comp;
16501739
1651 _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {}
1740 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : comp(__c) {}
16521741
16531742 public:
1654 _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const {
1743 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
1744 operator()(const value_type& __x, const value_type& __y) const {
16551745 return comp(__x.first, __y.first);
16561746 }
16571747 };
......@@ -1684,26 +1774,28 @@ public:
16841774 template <class _Key2, class _Value2, class _Comp2, class _Alloc2>
16851775 friend class multimap;
16861776
1687 _LIBCPP_HIDE_FROM_ABI multimap() _NOEXCEPT_(
1777 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap() _NOEXCEPT_(
16881778 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
16891779 is_nothrow_copy_constructible<key_compare>::value)
16901780 : __tree_(__vc(key_compare())) {}
16911781
1692 _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp) _NOEXCEPT_(
1782 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multimap(const key_compare& __comp) _NOEXCEPT_(
16931783 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)
16941784 : __tree_(__vc(__comp)) {}
16951785
1696 _LIBCPP_HIDE_FROM_ABI explicit multimap(const key_compare& __comp, const allocator_type& __a)
1786 _LIBCPP_HIDE_FROM_ABI
1787 _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multimap(const key_compare& __comp, const allocator_type& __a)
16971788 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {}
16981789
16991790 template <class _InputIterator>
1700 _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())
1791 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1792 multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare())
17011793 : __tree_(__vc(__comp)) {
17021794 insert(__f, __l);
17031795 }
17041796
17051797 template <class _InputIterator>
1706 _LIBCPP_HIDE_FROM_ABI
1798 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
17071799 multimap(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a)
17081800 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
17091801 insert(__f, __l);
......@@ -1711,7 +1803,7 @@ public:
17111803
17121804# if _LIBCPP_STD_VER >= 23
17131805 template <_ContainerCompatibleRange<value_type> _Range>
1714 _LIBCPP_HIDE_FROM_ABI
1806 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
17151807 multimap(from_range_t,
17161808 _Range&& __range,
17171809 const key_compare& __comp = key_compare(),
......@@ -1721,47 +1813,48 @@ public:
17211813 }
17221814# endif
17231815
1724# if _LIBCPP_STD_VER >= 14
17251816 template <class _InputIterator>
1726 _LIBCPP_HIDE_FROM_ABI multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1817 _LIBCPP_HIDE_FROM_ABI
1818 _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
17271819 : multimap(__f, __l, key_compare(), __a) {}
1728# endif
17291820
17301821# if _LIBCPP_STD_VER >= 23
17311822 template <_ContainerCompatibleRange<value_type> _Range>
1732 _LIBCPP_HIDE_FROM_ABI multimap(from_range_t, _Range&& __range, const allocator_type& __a)
1823 _LIBCPP_HIDE_FROM_ABI
1824 _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(from_range_t, _Range&& __range, const allocator_type& __a)
17331825 : multimap(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
17341826# endif
17351827
1736 _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m) = default;
1828 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(const multimap& __m) = default;
17371829
1738 _LIBCPP_HIDE_FROM_ABI multimap& operator=(const multimap& __m) = default;
1830 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap& operator=(const multimap& __m) = default;
17391831
17401832# ifndef _LIBCPP_CXX03_LANG
17411833
1742 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) = default;
1834 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(multimap&& __m) = default;
17431835
1744 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), __a) {}
1836 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(multimap&& __m, const allocator_type& __a)
1837 : __tree_(std::move(__m.__tree_), __a) {}
17451838
1746 _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) = default;
1839 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap& operator=(multimap&& __m) = default;
17471840
1748 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
1841 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1842 multimap(initializer_list<value_type> __il, const key_compare& __comp = key_compare())
17491843 : __tree_(__vc(__comp)) {
17501844 insert(__il.begin(), __il.end());
17511845 }
17521846
1753 _LIBCPP_HIDE_FROM_ABI
1847 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
17541848 multimap(initializer_list<value_type> __il, const key_compare& __comp, const allocator_type& __a)
17551849 : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {
17561850 insert(__il.begin(), __il.end());
17571851 }
17581852
1759# if _LIBCPP_STD_VER >= 14
1760 _LIBCPP_HIDE_FROM_ABI multimap(initializer_list<value_type> __il, const allocator_type& __a)
1853 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1854 multimap(initializer_list<value_type> __il, const allocator_type& __a)
17611855 : multimap(__il, key_compare(), __a) {}
1762# endif
17631856
1764 _LIBCPP_HIDE_FROM_ABI multimap& operator=(initializer_list<value_type> __il) {
1857 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap& operator=(initializer_list<value_type> __il) {
17651858 clear();
17661859 insert(__il.begin(), __il.end());
17671860 return *this;
......@@ -1769,234 +1862,309 @@ public:
17691862
17701863# endif // _LIBCPP_CXX03_LANG
17711864
1772 _LIBCPP_HIDE_FROM_ABI explicit multimap(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {}
1865 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multimap(const allocator_type& __a)
1866 : __tree_(typename __base::allocator_type(__a)) {}
17731867
1774 _LIBCPP_HIDE_FROM_ABI multimap(const multimap& __m, const allocator_type& __a) : __tree_(__m.__tree_, __a) {}
1868 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multimap(const multimap& __m, const allocator_type& __a)
1869 : __tree_(__m.__tree_, __a) {}
17751870
1776 _LIBCPP_HIDE_FROM_ABI ~multimap() {
1871 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~multimap() {
17771872 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
17781873 }
17791874
1780 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1781 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
1782 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
1783 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
1875 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT {
1876 return __tree_.begin();
1877 }
1878 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
1879 return __tree_.begin();
1880 }
1881 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT {
1882 return __tree_.end();
1883 }
1884 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
1885 return __tree_.end();
1886 }
17841887
1785 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
1786 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
1888 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() _NOEXCEPT {
1889 return reverse_iterator(end());
1890 }
1891 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1892 rbegin() const _NOEXCEPT {
17871893 return const_reverse_iterator(end());
17881894 }
1789 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
1790 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
1895 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() _NOEXCEPT {
1896 return reverse_iterator(begin());
1897 }
1898 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const _NOEXCEPT {
17911899 return const_reverse_iterator(begin());
17921900 }
17931901
1794 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
1795 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
1796 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1797 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
1902 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const _NOEXCEPT {
1903 return begin();
1904 }
1905 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const _NOEXCEPT {
1906 return end();
1907 }
1908 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1909 crbegin() const _NOEXCEPT {
1910 return rbegin();
1911 }
1912 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const _NOEXCEPT {
1913 return rend();
1914 }
17981915
1799 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1800 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1801 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
1916 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const _NOEXCEPT {
1917 return __tree_.size() == 0;
1918 }
1919 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT {
1920 return __tree_.size();
1921 }
1922 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
1923 return __tree_.max_size();
1924 }
18021925
1803 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT {
1926 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT {
18041927 return allocator_type(__tree_.__alloc());
18051928 }
1806 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); }
1807 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const {
1929 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const {
1930 return __tree_.value_comp().key_comp();
1931 }
1932 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const {
18081933 return value_compare(__tree_.value_comp().key_comp());
18091934 }
18101935
18111936# ifndef _LIBCPP_CXX03_LANG
18121937
18131938 template <class... _Args>
1814 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1939 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace(_Args&&... __args) {
18151940 return __tree_.__emplace_multi(std::forward<_Args>(__args)...);
18161941 }
18171942
18181943 template <class... _Args>
1819 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1944 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
18201945 return __tree_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);
18211946 }
18221947
18231948 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1824 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) {
1949 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(_Pp&& __p) {
18251950 return __tree_.__emplace_multi(std::forward<_Pp>(__p));
18261951 }
18271952
18281953 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
1829 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
1954 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __pos, _Pp&& __p) {
18301955 return __tree_.__emplace_hint_multi(__pos.__i_, std::forward<_Pp>(__p));
18311956 }
18321957
1833 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); }
1958 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(value_type&& __v) {
1959 return __tree_.__emplace_multi(std::move(__v));
1960 }
18341961
1835 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1962 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, value_type&& __v) {
18361963 return __tree_.__emplace_hint_multi(__p.__i_, std::move(__v));
18371964 }
18381965
1839 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1966 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
1967 insert(__il.begin(), __il.end());
1968 }
18401969
18411970# endif // _LIBCPP_CXX03_LANG
18421971
1843 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); }
1972 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const value_type& __v) {
1973 return __tree_.__emplace_multi(__v);
1974 }
18441975
1845 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) {
18461977 return __tree_.__emplace_hint_multi(__p.__i_, __v);
18471978 }
18481979
18491980 template <class _InputIterator>
1850 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) {
1981 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __f, _InputIterator __l) {
18511982 __tree_.__insert_range_multi(__f, __l);
18521983 }
18531984
18541985# if _LIBCPP_STD_VER >= 23
18551986 template <_ContainerCompatibleRange<value_type> _Range>
1856 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1987 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
18571988 __tree_.__insert_range_multi(ranges::begin(__range), ranges::end(__range));
18581989 }
18591990# endif
18601991
1861 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); }
1862 _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
1863 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }
1864 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) {
1992 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) {
1993 return __tree_.erase(__p.__i_);
1994 }
1995 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __p) { return __tree_.erase(__p.__i_); }
1996 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) {
1997 return __tree_.__erase_multi(__k);
1998 }
1999 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) {
18652000 return __tree_.erase(__f.__i_, __l.__i_);
18662001 }
18672002
18682003# if _LIBCPP_STD_VER >= 17
1869 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
2004 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(node_type&& __nh) {
18702005 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
18712006 "node_type with incompatible allocator passed to multimap::insert()");
18722007 return __tree_.template __node_handle_insert_multi<node_type>(std::move(__nh));
18732008 }
1874 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
2009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, node_type&& __nh) {
18752010 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
18762011 "node_type with incompatible allocator passed to multimap::insert()");
18772012 return __tree_.template __node_handle_insert_multi<node_type>(__hint.__i_, std::move(__nh));
18782013 }
1879 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
2014 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(key_type const& __key) {
18802015 return __tree_.template __node_handle_extract<node_type>(__key);
18812016 }
1882 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
2017 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(const_iterator __it) {
18832018 return __tree_.template __node_handle_extract<node_type>(__it.__i_);
18842019 }
18852020 template <class _Compare2>
1886 _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {
2021 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
2022 merge(multimap<key_type, mapped_type, _Compare2, allocator_type>& __source) {
18872023 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
18882024 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
18892025 return __tree_.__node_handle_merge_multi(__source.__tree_);
18902026 }
18912027 template <class _Compare2>
1892 _LIBCPP_HIDE_FROM_ABI void merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
2028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
2029 merge(multimap<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
18932030 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
18942031 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
18952032 return __tree_.__node_handle_merge_multi(__source.__tree_);
18962033 }
18972034 template <class _Compare2>
1898 _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {
2035 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
2036 merge(map<key_type, mapped_type, _Compare2, allocator_type>& __source) {
18992037 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
19002038 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
19012039 return __tree_.__node_handle_merge_multi(__source.__tree_);
19022040 }
19032041 template <class _Compare2>
1904 _LIBCPP_HIDE_FROM_ABI void merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
2042 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
2043 merge(map<key_type, mapped_type, _Compare2, allocator_type>&& __source) {
19052044 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
19062045 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
19072046 return __tree_.__node_handle_merge_multi(__source.__tree_);
19082047 }
19092048# endif
19102049
1911 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
2050 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); }
19122051
1913 _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
2052 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(multimap& __m)
2053 _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
19142054 __tree_.swap(__m.__tree_);
19152055 }
19162056
1917 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1918 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
2057 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __k) {
2058 return __tree_.find(__k);
2059 }
2060 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __k) const {
2061 return __tree_.find(__k);
2062 }
19192063# if _LIBCPP_STD_VER >= 14
1920 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1921 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
2064 template <typename _K2,
2065 class _Comp = _Compare,
2066 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2067 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _K2& __k) {
19222068 return __tree_.find(__k);
19232069 }
1924 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1925 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
2070 template <typename _K2,
2071 class _Comp = _Compare,
2072 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2073 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _K2& __k) const {
19262074 return __tree_.find(__k);
19272075 }
19282076# endif
19292077
1930 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
2078 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const {
19312079 return __tree_.__count_multi(__k);
19322080 }
19332081# if _LIBCPP_STD_VER >= 14
1934 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1935 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
2082 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
2083 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _K2& __k) const {
19362084 return __tree_.__count_multi(__k);
19372085 }
19382086# endif
19392087
19402088# if _LIBCPP_STD_VER >= 20
1941 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1942 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1943 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
2089 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __k) const {
2090 return find(__k) != end();
2091 }
2092 template <typename _K2,
2093 class _Comp = _Compare,
2094 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2095 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _K2& __k) const {
19442096 return find(__k) != end();
19452097 }
19462098# endif // _LIBCPP_STD_VER >= 20
19472099
1948 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) {
2100 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) {
19492101 return __tree_.__lower_bound_multi(__k);
19502102 }
19512103
1952 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
2104 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
2105 lower_bound(const key_type& __k) const {
19532106 return __tree_.__lower_bound_multi(__k);
19542107 }
19552108
19562109# if _LIBCPP_STD_VER >= 14
1957 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1958 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
2110 template <typename _K2,
2111 class _Comp = _Compare,
2112 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2113 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _K2& __k) {
19592114 return __tree_.__lower_bound_multi(__k);
19602115 }
19612116
1962 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1963 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
2117 template <typename _K2,
2118 class _Comp = _Compare,
2119 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2120 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
2121 lower_bound(const _K2& __k) const {
19642122 return __tree_.__lower_bound_multi(__k);
19652123 }
19662124# endif
19672125
1968 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) {
2126 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) {
19692127 return __tree_.__upper_bound_multi(__k);
19702128 }
19712129
1972 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const {
2130 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
2131 upper_bound(const key_type& __k) const {
19732132 return __tree_.__upper_bound_multi(__k);
19742133 }
19752134
19762135# if _LIBCPP_STD_VER >= 14
1977 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1978 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
2136 template <typename _K2,
2137 class _Comp = _Compare,
2138 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2139 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _K2& __k) {
19792140 return __tree_.__upper_bound_multi(__k);
19802141 }
1981 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1982 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
2142 template <typename _K2,
2143 class _Comp = _Compare,
2144 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
2145 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
2146 upper_bound(const _K2& __k) const {
19832147 return __tree_.__upper_bound_multi(__k);
19842148 }
19852149# endif
19862150
1987 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
2151 [[__nodiscard__]]
2152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __k) {
19882153 return __tree_.__equal_range_multi(__k);
19892154 }
1990 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
2155 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
2156 equal_range(const key_type& __k) const {
19912157 return __tree_.__equal_range_multi(__k);
19922158 }
19932159# if _LIBCPP_STD_VER >= 14
1994 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1995 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
2160 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
2161 [[__nodiscard__]]
2162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _K2& __k) {
19962163 return __tree_.__equal_range_multi(__k);
19972164 }
1998 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1999 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
2165 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
2166 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
2167 equal_range(const _K2& __k) const {
20002168 return __tree_.__equal_range_multi(__k);
20012169 }
20022170# endif
......@@ -2070,8 +2238,8 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<multimap<_
20702238 static const bool __has_algorithm = true;
20712239
20722240 template <class _Map, class _Func, class _Proj>
2073 _LIBCPP_HIDE_FROM_ABI static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
2074 auto [_, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
2241 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(_Map&& __map, _Func __func, _Proj __proj) {
2242 auto [__dummy, __func2] = __specialized_algorithm<_Algorithm::__for_each, __single_range<typename __map::__base>>()(
20752243 __map.__tree_, std::move(__func), std::move(__proj));
20762244 return std::make_pair(__map.end(), std::move(__func2));
20772245 }
......@@ -2079,7 +2247,7 @@ struct __specialized_algorithm<_Algorithm::__for_each, __single_range<multimap<_
20792247# endif
20802248
20812249template <class _Key, class _Tp, class _Compare, class _Allocator>
2082inline _LIBCPP_HIDE_FROM_ABI bool
2250inline _LIBCPP_HIDE_FROM_ABI bool _LIBCPP_CONSTEXPR_SINCE_CXX26
20832251operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
20842252 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
20852253}
......@@ -2087,31 +2255,31 @@ operator==(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<
20872255# if _LIBCPP_STD_VER <= 17
20882256
20892257template <class _Key, class _Tp, class _Compare, class _Allocator>
2090inline _LIBCPP_HIDE_FROM_ABI bool
2258inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
20912259operator<(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
20922260 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
20932261}
20942262
20952263template <class _Key, class _Tp, class _Compare, class _Allocator>
2096inline _LIBCPP_HIDE_FROM_ABI bool
2264inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
20972265operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
20982266 return !(__x == __y);
20992267}
21002268
21012269template <class _Key, class _Tp, class _Compare, class _Allocator>
2102inline _LIBCPP_HIDE_FROM_ABI bool
2270inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
21032271operator>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
21042272 return __y < __x;
21052273}
21062274
21072275template <class _Key, class _Tp, class _Compare, class _Allocator>
2108inline _LIBCPP_HIDE_FROM_ABI bool
2276inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
21092277operator>=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
21102278 return !(__x < __y);
21112279}
21122280
21132281template <class _Key, class _Tp, class _Compare, class _Allocator>
2114inline _LIBCPP_HIDE_FROM_ABI bool
2282inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
21152283operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
21162284 return !(__y < __x);
21172285}
......@@ -2119,7 +2287,7 @@ operator<=(const multimap<_Key, _Tp, _Compare, _Allocator>& __x, const multimap<
21192287# else // #if _LIBCPP_STD_VER <= 17
21202288
21212289template <class _Key, class _Tp, class _Compare, class _Allocator>
2122_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
2290_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<pair<const _Key, _Tp>>
21232291operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
21242292 const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
21252293 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
......@@ -2128,7 +2296,7 @@ operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
21282296# endif // #if _LIBCPP_STD_VER <= 17
21292297
21302298template <class _Key, class _Tp, class _Compare, class _Allocator>
2131inline _LIBCPP_HIDE_FROM_ABI void
2299inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
21322300swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compare, _Allocator>& __y)
21332301 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
21342302 __x.swap(__y);
......@@ -2136,7 +2304,7 @@ swap(multimap<_Key, _Tp, _Compare, _Allocator>& __x, multimap<_Key, _Tp, _Compar
21362304
21372305# if _LIBCPP_STD_VER >= 20
21382306template <class _Key, class _Tp, class _Compare, class _Allocator, class _Predicate>
2139inline _LIBCPP_HIDE_FROM_ABI typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
2307inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename multimap<_Key, _Tp, _Compare, _Allocator>::size_type
21402308erase_if(multimap<_Key, _Tp, _Compare, _Allocator>& __c, _Predicate __pred) {
21412309 return std::__libcpp_erase_if_container(__c, __pred);
21422310}
......@@ -2170,7 +2338,7 @@ _LIBCPP_END_NAMESPACE_STD
21702338
21712339_LIBCPP_POP_MACROS
21722340
2173# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2341# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
21742342# include <concepts>
21752343# include <cstdlib>
21762344# include <functional>
lib/libcxx/include/mdspan+46-46
......@@ -46,15 +46,15 @@ namespace std {
4646// extents synopsis
4747
4848namespace std {
49 template<class _IndexType, size_t... _Extents>
49 template<class IndexType, size_t... Extents>
5050 class extents {
5151 public:
52 using index_type = _IndexType;
52 using index_type = IndexType;
5353 using size_type = make_unsigned_t<index_type>;
5454 using rank_type = size_t;
5555
5656 // [mdspan.extents.obs], observers of the multidimensional index space
57 static constexpr rank_type rank() noexcept { return sizeof...(_Extents); }
57 static constexpr rank_type rank() noexcept { return sizeof...(Extents); }
5858 static constexpr rank_type rank_dynamic() noexcept { return dynamic-index(rank()); }
5959 static constexpr size_t static_extent(rank_type) noexcept;
6060 constexpr index_type extent(rank_type) const noexcept;
......@@ -62,20 +62,20 @@ namespace std {
6262 // [mdspan.extents.cons], constructors
6363 constexpr extents() noexcept = default;
6464
65 template<class _OtherIndexType, size_t... _OtherExtents>
65 template<class OtherIndexType, size_t... OtherExtents>
6666 constexpr explicit(see below)
67 extents(const extents<_OtherIndexType, _OtherExtents...>&) noexcept;
68 template<class... _OtherIndexTypes>
69 constexpr explicit extents(_OtherIndexTypes...) noexcept;
70 template<class _OtherIndexType, size_t N>
67 extents(const extents<OtherIndexType, OtherExtents...>&) noexcept;
68 template<class... OtherIndexTypes>
69 constexpr explicit extents(OtherIndexTypes...) noexcept;
70 template<class OtherIndexType, size_t N>
7171 constexpr explicit(N != rank_dynamic())
72 extents(span<_OtherIndexType, N>) noexcept;
73 template<class _OtherIndexType, size_t N>
72 extents(span<OtherIndexType, N>) noexcept;
73 template<class OtherIndexType, size_t N>
7474 constexpr explicit(N != rank_dynamic())
75 extents(const array<_OtherIndexType, N>&) noexcept;
75 extents(const array<OtherIndexType, N>&) noexcept;
7676
7777 // [mdspan.extents.cmp], comparison operators
78 template<class _OtherIndexType, size_t... _OtherExtents>
78 template<class OtherIndexType, size_t... OtherExtents>
7979 friend constexpr bool operator==(const extents&,
8080 const extents<_OtherIndexType, _OtherExtents...>&) noexcept;
8181
......@@ -97,12 +97,12 @@ namespace std {
9797 class layout_left::mapping {
9898 public:
9999 using extents_type = Extents;
100 using index_type = typename extents_type::index_type;
101 using size_type = typename extents_type::size_type;
102 using rank_type = typename extents_type::rank_type;
100 using index_type = extents_type::index_type;
101 using size_type = extents_type::size_type;
102 using rank_type = extents_type::rank_type;
103103 using layout_type = layout_left;
104104
105 // [mdspan.layout.right.cons], constructors
105 // [mdspan.layout.left.cons], constructors
106106 constexpr mapping() noexcept = default;
107107 constexpr mapping(const mapping&) noexcept = default;
108108 constexpr mapping(const extents_type&) noexcept;
......@@ -118,7 +118,7 @@ namespace std {
118118
119119 constexpr mapping& operator=(const mapping&) noexcept = default;
120120
121 // [mdspan.layout.right.obs], observers
121 // [mdspan.layout.left.obs], observers
122122 constexpr const extents_type& extents() const noexcept { return extents_; }
123123
124124 constexpr index_type required_span_size() const noexcept;
......@@ -151,9 +151,9 @@ namespace std {
151151 class layout_right::mapping {
152152 public:
153153 using extents_type = Extents;
154 using index_type = typename extents_type::index_type;
155 using size_type = typename extents_type::size_type;
156 using rank_type = typename extents_type::rank_type;
154 using index_type = extents_type::index_type;
155 using size_type = extents_type::size_type;
156 using rank_type = extents_type::rank_type;
157157 using layout_type = layout_right;
158158
159159 // [mdspan.layout.right.cons], constructors
......@@ -205,9 +205,9 @@ namespace std {
205205 class layout_stride::mapping {
206206 public:
207207 using extents_type = Extents;
208 using index_type = typename extents_type::index_type;
209 using size_type = typename extents_type::size_type;
210 using rank_type = typename extents_type::rank_type;
208 using index_type = extents_type::index_type;
209 using size_type = extents_type::size_type;
210 using rank_type = extents_type::rank_type;
211211 using layout_type = layout_stride;
212212
213213 private:
......@@ -237,7 +237,7 @@ namespace std {
237237 constexpr index_type operator()(Indices...) const noexcept;
238238
239239 static constexpr bool is_always_unique() noexcept { return true; }
240 static constexpr bool is_always_exhaustive() noexcept { return false; }
240 static constexpr bool is_always_exhaustive() noexcept;
241241 static constexpr bool is_always_strided() noexcept { return true; }
242242
243243 static constexpr bool is_unique() noexcept { return true; }
......@@ -286,22 +286,19 @@ namespace std {
286286 static constexpr size_t byte_alignment = ByteAlignment;
287287
288288 constexpr aligned_accessor() noexcept = default;
289
290289 template<class OtherElementType, size_t OtherByteAlignment>
291290 constexpr aligned_accessor(
292291 aligned_accessor<OtherElementType, OtherByteAlignment>) noexcept;
293
294292 template<class OtherElementType>
295 explicit constexpr aligned_accessor(
296 default_accessor<OtherElementType>) noexcept;
293 constexpr explicit aligned_accessor(default_accessor<OtherElementType>) noexcept;
297294
298295 template<class OtherElementType>
299 constexpr operator default_accessor<OtherElementType>() const noexcept;
296 constexpr operator default_accessor<OtherElementType>() const noexcept;
300297
301298 constexpr reference access(data_handle_type p, size_t i) const noexcept;
302299
303 constexpr typename offset_policy::data_handle_type
304 offset(data_handle_type p, size_t i) const noexcept;
300 constexpr typename offset_policy::data_handle_type offset(
301 data_handle_type p, size_t i) const noexcept;
305302 };
306303}
307304
......@@ -315,14 +312,14 @@ namespace std {
315312 using extents_type = Extents;
316313 using layout_type = LayoutPolicy;
317314 using accessor_type = AccessorPolicy;
318 using mapping_type = typename layout_type::template mapping<extents_type>;
315 using mapping_type = layout_type::template mapping<extents_type>;
319316 using element_type = ElementType;
320317 using value_type = remove_cv_t<element_type>;
321 using index_type = typename extents_type::index_type;
322 using size_type = typename extents_type::size_type;
323 using rank_type = typename extents_type::rank_type;
324 using data_handle_type = typename accessor_type::data_handle_type;
325 using reference = typename accessor_type::reference;
318 using index_type = extents_type::index_type;
319 using size_type = extents_type::size_type;
320 using rank_type = extents_type::rank_type;
321 using data_handle_type = accessor_type::data_handle_type;
322 using reference = accessor_type::reference;
326323
327324 static constexpr rank_type rank() noexcept { return extents_type::rank(); }
328325 static constexpr rank_type rank_dynamic() noexcept { return extents_type::rank_dynamic(); }
......@@ -364,8 +361,15 @@ namespace std {
364361 template<class OtherIndexType>
365362 constexpr reference operator[](const array<OtherIndexType, rank()>& indices) const;
366363
364 template<class... OtherIndexTypes>
365 constexpr reference at(OtherIndexTypes... indices) const;
366 template<class OtherIndexType>
367 constexpr reference at(span<OtherIndexType, rank()> indices) const;
368 template<class OtherIndexType>
369 constexpr reference at(const array<OtherIndexType, rank()>& indices) const;
370
367371 constexpr size_type size() const noexcept;
368 [[nodiscard]] constexpr bool empty() const noexcept;
372 constexpr bool empty() const noexcept;
369373
370374 friend constexpr void swap(mdspan& x, mdspan& y) noexcept;
371375
......@@ -398,23 +402,19 @@ namespace std {
398402 };
399403
400404 template<class CArray>
401 requires(is_array_v<CArray> && rank_v<CArray> == 1)
405 requires (is_array_v<CArray> && rank_v<CArray> == 1)
402406 mdspan(CArray&)
403407 -> mdspan<remove_all_extents_t<CArray>, extents<size_t, extent_v<CArray, 0>>>;
404408
405409 template<class Pointer>
406 requires(is_pointer_v<remove_reference_t<Pointer>>)
410 requires (is_pointer_v<remove_reference_t<Pointer>>)
407411 mdspan(Pointer&&)
408412 -> mdspan<remove_pointer_t<remove_reference_t<Pointer>>, extents<size_t>>;
409413
410414 template<class ElementType, class... Integrals>
411415 requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
412416 explicit mdspan(ElementType*, Integrals...)
413 -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>; // until C++26
414 template<class ElementType, class... Integrals>
415 requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
416 explicit mdspan(ElementType*, Integrals...)
417 -> mdspan<ElementType, extents<size_t, maybe-static-ext<Integrals>...>>; // since C++26
417 -> mdspan<ElementType, extents<size_t, maybe-static-ext<Integrals>...>>;
418418
419419 template<class ElementType, class OtherIndexType, size_t N>
420420 mdspan(ElementType*, span<OtherIndexType, N>)
......@@ -434,7 +434,7 @@ namespace std {
434434 typename MappingType::layout_type>;
435435
436436 template<class MappingType, class AccessorType>
437 mdspan(const typename AccessorType::data_handle_type&, const MappingType&,
437 mdspan(typename AccessorType::data_handle_type, const MappingType&,
438438 const AccessorType&)
439439 -> mdspan<typename AccessorType::element_type, typename MappingType::extents_type,
440440 typename MappingType::layout_type, AccessorType>;
lib/libcxx/include/memory+1-1
......@@ -987,7 +987,7 @@ template<class Pointer = void, class Smart, class... Args>
987987# pragma GCC system_header
988988# endif
989989
990# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
990# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
991991# include <atomic>
992992# include <concepts>
993993# include <cstddef>
lib/libcxx/include/memory_resource+2-2
......@@ -69,11 +69,11 @@ namespace std::pmr {
6969# pragma GCC system_header
7070# endif
7171
72# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER >= 17 && _LIBCPP_STD_VER <= 20
72# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER >= 17 && _LIBCPP_STD_VER <= 20
7373# include <mutex>
7474# endif
7575
76# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
76# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
7777# include <stdexcept>
7878# endif
7979#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/mutex+20-11
......@@ -214,10 +214,11 @@ template<class Callable, class ...Args>
214214_LIBCPP_PUSH_MACROS
215215# include <__undef_macros>
216216
217_LIBCPP_BEGIN_NAMESPACE_STD
218
219217# if _LIBCPP_HAS_THREADS
220218
219_LIBCPP_BEGIN_NAMESPACE_STD
220_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
221
221222class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex {
222223 __libcpp_recursive_mutex_t __m_;
223224
......@@ -457,7 +458,7 @@ public:
457458 __m_.lock();
458459 }
459460
460 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __m_.unlock(); }
461 _LIBCPP_RELEASE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __m_.unlock(); }
461462
462463 [[nodiscard]]
463464 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m) _LIBCPP_REQUIRES_CAPABILITY(__m)
......@@ -468,25 +469,31 @@ public:
468469};
469470
470471template <class... _MArgs>
471class scoped_lock {
472class _LIBCPP_SCOPED_LOCKABLE scoped_lock {
472473 static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
473474 typedef tuple<_MArgs&...> _MutexTuple;
474475
475476public:
476 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) {
477 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) _LIBCPP_ACQUIRE_CAPABILITY(__margs...)
478 : __t_(__margs...) {
477479 std::lock(__margs...);
478480 }
479481
480 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {}
482 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs)
483 _LIBCPP_REQUIRES_CAPABILITY(__margs...)
484 : __t_(__margs...) {}
481485
482 _LIBCPP_HIDE_FROM_ABI ~scoped_lock() { __unlock_unpack(make_index_sequence<sizeof...(_MArgs)>(), __t_); }
486 _LIBCPP_RELEASE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI ~scoped_lock() {
487 __unlock_unpack(make_index_sequence<sizeof...(_MArgs)>(), __t_);
488 }
483489
484490 scoped_lock(scoped_lock const&) = delete;
485491 scoped_lock& operator=(scoped_lock const&) = delete;
486492
487493private:
488494 template <size_t... _Indx>
489 _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(index_sequence<_Indx...>, _MutexTuple& __mt) {
495 _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(index_sequence<_Indx...>, _MutexTuple& __mt)
496 _LIBCPP_RELEASE_CAPABILITY(std::get<_Indx>(__mt)...) {
490497 (std::get<_Indx>(__mt).unlock(), ...);
491498 }
492499
......@@ -495,17 +502,19 @@ private:
495502_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
496503
497504# endif // _LIBCPP_STD_VER >= 17
498# endif // _LIBCPP_HAS_THREADS
499505
506_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
500507_LIBCPP_END_NAMESPACE_STD
501508
509# endif // _LIBCPP_HAS_THREADS
510
502511_LIBCPP_POP_MACROS
503512
504# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
513# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
505514# include <typeinfo>
506515# endif
507516
508# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
517# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
509518# include <atomic>
510519# include <concepts>
511520# include <cstdlib>
lib/libcxx/include/new+3-3
......@@ -81,8 +81,8 @@ void operator delete[](void* ptr, std::align_val_t alignment,
8181
8282void* operator new (std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26
8383void* operator new[](std::size_t size, void* ptr) noexcept; // nodiscard in C++20, constexpr since C++26
84void operator delete (void* ptr, void*) noexcept;
85void operator delete[](void* ptr, void*) noexcept;
84void operator delete (void* ptr, void*) noexcept; // constexpr since C++26
85void operator delete[](void* ptr, void*) noexcept; // constexpr since C++26
8686
8787*/
8888
......@@ -114,7 +114,7 @@ void operator delete[](void* ptr, void*) noexcept;
114114# pragma GCC system_header
115115# endif
116116
117# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
117# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
118118# include <cstddef>
119119# include <cstdlib>
120120# include <type_traits>
lib/libcxx/include/numbers+1-1
......@@ -159,7 +159,7 @@ _LIBCPP_END_NAMESPACE_STD
159159
160160# endif // _LIBCPP_STD_VER >= 20
161161
162# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
162# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
163163# include <concepts>
164164# include <cstddef>
165165# include <type_traits>
lib/libcxx/include/numeric+7-7
......@@ -142,15 +142,15 @@ template<class T>
142142
143143// [numeric.sat], saturation arithmetic
144144template<class T>
145constexpr T add_sat(T x, T y) noexcept; // freestanding, Since C++26
145constexpr T saturating_add(T x, T y) noexcept; // freestanding, Since C++26
146146template<class T>
147constexpr T sub_sat(T x, T y) noexcept; // freestanding, Since C++26
147constexpr T saturating_sub(T x, T y) noexcept; // freestanding, Since C++26
148148template<class T>
149constexpr T mul_sat(T x, T y) noexcept; // freestanding, Since C++26
149constexpr T saturating_mul(T x, T y) noexcept; // freestanding, Since C++26
150150template<class T>
151constexpr T div_sat(T x, T y) noexcept; // freestanding, Since C++26
151constexpr T saturating_div(T x, T y) noexcept; // freestanding, Since C++26
152152template<class T, class U>
153constexpr T saturate_cast(U x) noexcept; // freestanding, Since C++26
153constexpr T saturating_cast(U x) noexcept; // freestanding, Since C++26
154154
155155} // std
156156
......@@ -190,12 +190,12 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin
190190# pragma GCC system_header
191191# endif
192192
193# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
193# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 14
194194# include <initializer_list>
195195# include <limits>
196196# endif
197197
198# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
198# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
199199# include <climits>
200200# include <cmath>
201201# include <concepts>
lib/libcxx/include/optional+341-383
......@@ -264,15 +264,14 @@ namespace std {
264264# include <__compare/three_way_comparable.h>
265265# include <__concepts/invocable.h>
266266# include <__config>
267# include <__cstddef/ptrdiff_t.h>
268267# include <__exception/exception.h>
269# include <__format/range_format.h>
270268# include <__functional/hash.h>
271269# include <__functional/invoke.h>
272270# include <__functional/unary_function.h>
271# include <__fwd/format.h>
273272# include <__fwd/functional.h>
274273# include <__iterator/bounded_iter.h>
275# include <__iterator/wrap_iter.h>
274# include <__iterator/capacity_aware_iterator.h>
276275# include <__memory/addressof.h>
277276# include <__memory/construct_at.h>
278277# include <__ranges/enable_borrowed_range.h>
......@@ -493,6 +492,61 @@ struct __optional_storage_base : __optional_destruct_base<_Tp> {
493492 }
494493 }
495494 }
495
496 // [optional.observe]
497 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp const> operator->() const noexcept {
498 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
499 return std::addressof(this->__get());
500 }
501
502 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() noexcept {
503 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
504 return std::addressof(this->__get());
505 }
506
507 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept {
508 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
509 return this->__get();
510 }
511
512 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept {
513 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
514 return this->__get();
515 }
516
517 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept {
518 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
519 return std::move(this->__get());
520 }
521
522 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept {
523 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
524 return std::move(this->__get());
525 }
526
527 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& value() const& {
528 if (!this->has_value())
529 std::__throw_bad_optional_access();
530 return this->__get();
531 }
532
533 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() & {
534 if (!this->has_value())
535 std::__throw_bad_optional_access();
536 return this->__get();
537 }
538
539 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() && {
540 if (!this->has_value())
541 std::__throw_bad_optional_access();
542 return std::move(this->__get());
543 }
544
545 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const&& value() const&& {
546 if (!this->has_value())
547 std::__throw_bad_optional_access();
548 return std::move(this->__get());
549 }
496550};
497551
498552template <class _Tp>
......@@ -504,7 +558,7 @@ struct __optional_storage_base<_Tp, true> {
504558 _LIBCPP_HIDE_FROM_ABI constexpr __optional_storage_base() noexcept : __value_(nullptr) {}
505559
506560 template <class _Up>
507 _LIBCPP_HIDE_FROM_ABI constexpr void __convert_init_ref_val(_Up&& __val) noexcept {
561 _LIBCPP_HIDE_FROM_ABI constexpr void __convert_init_ref_val(_Up&& __val) {
508562 _Tp& __r(std::forward<_Up>(__val));
509563 __value_ = std::addressof(__r);
510564 }
......@@ -517,6 +571,14 @@ struct __optional_storage_base<_Tp, true> {
517571 __convert_init_ref_val(std::forward<_UArg>(__uarg));
518572 }
519573
574# if _LIBCPP_STD_VER >= 23
575 template <class _Fp, class... _Args>
576 constexpr __optional_storage_base(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args) {
577 __convert_init_ref_val(std::forward<invoke_result_t<_Fp, _Args...>>(
578 std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)));
579 }
580# endif
581
520582 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reset() noexcept { __value_ = nullptr; }
521583
522584 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_value() const noexcept { return __value_ != nullptr; }
......@@ -525,7 +587,6 @@ struct __optional_storage_base<_Tp, true> {
525587
526588 template <class _UArg>
527589 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __construct(_UArg&& __val) {
528 _LIBCPP_ASSERT_INTERNAL(!has_value(), "__construct called for engaged __optional_storage");
529590 static_assert(!__reference_constructs_from_temporary_v<_Tp, _UArg>,
530591 "Attempted to construct a reference element in tuple from a "
531592 "possible temporary");
......@@ -554,9 +615,26 @@ struct __optional_storage_base<_Tp, true> {
554615 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __swap(__optional_storage_base& __rhs) noexcept {
555616 std::swap(__value_, __rhs.__value_);
556617 }
618
619 // [optional.ref.observe]
620 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() const noexcept {
621 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
622 return std::addressof(this->__get());
623 }
624
625 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() const noexcept {
626 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
627 return this->__get();
628 }
629
630 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() const {
631 if (!this->has_value())
632 std::__throw_bad_optional_access();
633 return this->__get();
634 }
557635};
558636
559template <class _Tp, bool = is_trivially_copy_constructible_v<_Tp> || is_lvalue_reference_v<_Tp>>
637template <class _Tp, bool = is_trivially_copy_constructible_v<_Tp>>
560638struct __optional_copy_base : __optional_storage_base<_Tp> {
561639 using __optional_storage_base<_Tp>::__optional_storage_base;
562640};
......@@ -576,7 +654,7 @@ struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp> {
576654 _LIBCPP_HIDE_FROM_ABI __optional_copy_base& operator=(__optional_copy_base&&) = default;
577655};
578656
579template <class _Tp, bool = is_trivially_move_constructible_v<_Tp> || is_lvalue_reference_v<_Tp>>
657template <class _Tp, bool = is_trivially_move_constructible_v<_Tp>>
580658struct __optional_move_base : __optional_copy_base<_Tp> {
581659 using __optional_copy_base<_Tp>::__optional_copy_base;
582660};
......@@ -600,8 +678,7 @@ struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp> {
600678
601679template <class _Tp,
602680 bool = (is_trivially_destructible_v<_Tp> && is_trivially_copy_constructible_v<_Tp> &&
603 is_trivially_copy_assignable_v<_Tp>) ||
604 is_lvalue_reference_v<_Tp>>
681 is_trivially_copy_assignable_v<_Tp>)>
605682struct __optional_copy_assign_base : __optional_move_base<_Tp> {
606683 using __optional_move_base<_Tp>::__optional_move_base;
607684};
......@@ -625,8 +702,7 @@ struct __optional_copy_assign_base<_Tp, false> : __optional_move_base<_Tp> {
625702
626703template <class _Tp,
627704 bool = (is_trivially_destructible_v<_Tp> && is_trivially_move_constructible_v<_Tp> &&
628 is_trivially_move_assignable_v<_Tp>) ||
629 is_lvalue_reference_v<_Tp>>
705 is_trivially_move_assignable_v<_Tp>)>
630706struct __optional_move_assign_base : __optional_copy_assign_base<_Tp> {
631707 using __optional_copy_assign_base<_Tp>::__optional_copy_assign_base;
632708};
......@@ -655,8 +731,8 @@ using __optional_sfinae_ctor_base_t _LIBCPP_NODEBUG =
655731
656732template <class _Tp>
657733using __optional_sfinae_assign_base_t _LIBCPP_NODEBUG =
658 __sfinae_assign_base< (is_copy_constructible_v<_Tp> && is_copy_assignable_v<_Tp>) || is_lvalue_reference_v<_Tp>,
659 (is_move_constructible_v<_Tp> && is_move_assignable_v<_Tp>) || is_lvalue_reference_v<_Tp>>;
734 __sfinae_assign_base< (is_copy_constructible_v<_Tp> && is_copy_assignable_v<_Tp>),
735 (is_move_constructible_v<_Tp> && is_move_assignable_v<_Tp>)>;
660736
661737template <class _Tp>
662738class optional;
......@@ -685,126 +761,115 @@ struct __is_std_optional : false_type {};
685761template <class _Tp>
686762struct __is_std_optional<optional<_Tp>> : true_type {};
687763
688template <class _Tp, class... _Args>
689inline constexpr bool __is_constructible_for_optional_v = is_constructible_v<_Tp, _Args...>;
690
691template <class _Tp, class... _Args>
692struct __is_constructible_for_optional : bool_constant<__is_constructible_for_optional_v<_Tp, _Args...>> {};
764# if _LIBCPP_STD_VER < 26
765template <class _Tp>
766inline constexpr bool __is_valid_optional_contained_type = is_object_v<_Tp>;
767# else
768template <class _Tp>
769inline constexpr bool __is_valid_optional_contained_type = is_object_v<_Tp> || is_lvalue_reference_v<_Tp>;
770# endif
693771
694template <class _Tp, class _Up, class... _Args>
695inline constexpr bool __is_constructible_for_optional_initializer_list_v =
696 is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>;
772template <class _Tp>
773struct __optional_iterator_base : __optional_move_assign_base<_Tp> {
774 using __optional_move_assign_base<_Tp>::__optional_move_assign_base;
775};
697776
698777# if _LIBCPP_STD_VER >= 26
699template <class _Tp, class... _Args>
700inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Args...> = false;
701template <class _Tp, class _Arg>
702inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Arg> =
703 is_constructible_v<_Tp&, _Arg> && !reference_constructs_from_temporary_v<_Tp&, _Arg>;
704
705template <class _Tp, class _Up, class... _Args>
706inline constexpr bool __is_constructible_for_optional_initializer_list_v<_Tp&, _Up, _Args...> = false;
707# endif
778template <class _Tp>
779struct __optional_iterator_base<_Tp&> : __optional_storage_base<_Tp&> {
780 using __optional_storage_base<_Tp&>::__optional_storage_base;
781};
708782
709template <class _Tp, class = void>
710struct __optional_iterator {};
711
712# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
783# if _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
713784
714785template <class _Tp>
715struct __optional_iterator<_Tp, enable_if_t<is_object_v<_Tp>>> {
786 requires is_object_v<_Tp>
787struct __optional_iterator_base<_Tp> : __optional_move_assign_base<_Tp> {
716788private:
717789 using __pointer _LIBCPP_NODEBUG = add_pointer_t<_Tp>;
718790 using __const_pointer _LIBCPP_NODEBUG = add_pointer_t<const _Tp>;
719791
720792public:
721# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
722 using iterator = __bounded_iter<__wrap_iter<__pointer>>;
723 using const_iterator = __bounded_iter<__wrap_iter<__const_pointer>>;
724# else
725 using iterator = __wrap_iter<__pointer>;
726 using const_iterator = __wrap_iter<__const_pointer>;
727# endif
793 using __optional_move_assign_base<_Tp>::__optional_move_assign_base;
794
795# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
796 using iterator = __bounded_iter<__pointer>;
797 using const_iterator = __bounded_iter<__const_pointer>;
798# else
799 using iterator = __capacity_aware_iterator<__pointer, optional<_Tp>, 1>;
800 using const_iterator = __capacity_aware_iterator<__const_pointer, optional<_Tp>, 1>;
801# endif
728802
729803 // [optional.iterators], iterator support
730804 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator begin() noexcept {
731 auto& __derived_self = static_cast<optional<_Tp>&>(*this);
732 auto* __ptr = std::addressof(__derived_self.__get());
805 auto* __ptr = std::addressof(this->__get());
733806
734# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
735 return std::__make_bounded_iter(
736 __wrap_iter<__pointer>(__ptr),
737 __wrap_iter<__pointer>(__ptr),
738 __wrap_iter<__pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0));
739# else
740 return iterator(__ptr);
741# endif
807# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
808 return std::__make_bounded_iter(__ptr, __ptr, __ptr + (this->has_value() ? 1 : 0));
809# else
810 return std::__make_capacity_aware_iterator<__pointer, optional<_Tp>, 1>(__ptr);
811# endif
742812 }
743813
744814 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept {
745 auto& __derived_self = static_cast<const optional<_Tp>&>(*this);
746 auto* __ptr = std::addressof(__derived_self.__get());
815 auto* __ptr = std::addressof(this->__get());
747816
748# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
749 return std::__make_bounded_iter(
750 __wrap_iter<__const_pointer>(__ptr),
751 __wrap_iter<__const_pointer>(__ptr),
752 __wrap_iter<__const_pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0));
753# else
754 return const_iterator(__ptr);
755# endif
817# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
818 return std::__make_bounded_iter(__ptr, __ptr, __ptr + (this->has_value() ? 1 : 0));
819# else
820 return std::__make_capacity_aware_iterator<__const_pointer, optional<_Tp>, 1>(__ptr);
821# endif
756822 }
757823
758824 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iterator end() noexcept {
759 return begin() + (static_cast<optional<_Tp>&>(*this).has_value() ? 1 : 0);
825 return begin() + (this->has_value() ? 1 : 0);
760826 }
761827 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept {
762 return begin() + (static_cast<const optional<_Tp>&>(*this).has_value() ? 1 : 0);
828 return begin() + (this->has_value() ? 1 : 0);
763829 }
764830};
765831
766832template <class _Tp>
767struct __optional_iterator<_Tp&, enable_if_t<is_object_v<_Tp> && !__is_unbounded_array_v<_Tp> >> {
833 requires(is_object_v<_Tp> && !__is_unbounded_array_v<_Tp>)
834struct __optional_iterator_base<_Tp&> : __optional_storage_base<_Tp&> {
768835private:
769836 using __pointer _LIBCPP_NODEBUG = add_pointer_t<_Tp>;
770837
771838public:
772# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
773 using iterator = __bounded_iter<__wrap_iter<__pointer>>;
774# else
775 using iterator = __wrap_iter<__pointer>;
776# endif
839 using __optional_storage_base<_Tp&>::__optional_storage_base;
840
841# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
842 using iterator = __bounded_iter<__pointer>;
843# else
844 using iterator = __capacity_aware_iterator<__pointer, optional<_Tp&>, 1>;
845# endif
777846
778847 // [optional.ref.iterators], iterator support
779848
780849 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto begin() const noexcept {
781 auto& __derived_self = static_cast<const optional<_Tp&>&>(*this);
782 auto* __ptr = __derived_self.has_value() ? std::addressof(__derived_self.__get()) : nullptr;
850 auto* __ptr = this->has_value() ? std::addressof(this->__get()) : nullptr;
783851
784# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
785 return std::__make_bounded_iter(
786 __wrap_iter<__pointer>(__ptr),
787 __wrap_iter<__pointer>(__ptr),
788 __wrap_iter<__pointer>(__ptr) + (__derived_self.has_value() ? 1 : 0));
789# else
790 return iterator(__ptr);
791# endif
852# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_OPTIONAL
853 return std::__make_bounded_iter(__ptr, __ptr, __ptr + (this->has_value() ? 1 : 0));
854# else
855 return std::__make_capacity_aware_iterator<__pointer, optional<_Tp&>, 1>(__ptr);
856# endif
792857 }
793858
794859 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto end() const noexcept {
795 return begin() + (static_cast<const optional<_Tp&>&>(*this).has_value() ? 1 : 0);
860 return begin() + (this->has_value() ? 1 : 0);
796861 }
797862};
798863
799# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
864# endif // _LIBCPP_HAS_EXPERIMENTAL_OPTIONAL_ITERATOR
865# endif // _LIBCPP_STD_VER >= 26
800866
801867template <class _Tp>
802868class _LIBCPP_DECLSPEC_EMPTY_BASES optional
803 : private __optional_move_assign_base<_Tp>,
869 : public __optional_iterator_base<_Tp>,
804870 private __optional_sfinae_ctor_base_t<_Tp>,
805 private __optional_sfinae_assign_base_t<_Tp>,
806 public __optional_iterator<_Tp> {
807 using __base _LIBCPP_NODEBUG = __optional_move_assign_base<_Tp>;
871 private __optional_sfinae_assign_base_t<_Tp> {
872 using __base _LIBCPP_NODEBUG = __optional_iterator_base<_Tp>;
808873
809874public:
810875 using value_type = __libcpp_remove_reference_t<_Tp>;
......@@ -813,9 +878,8 @@ public:
813878 conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;
814879
815880private:
816 static_assert(!is_same_v<__remove_cvref_t<_Tp>, in_place_t>,
817 "instantiation of optional with in_place_t is ill-formed");
818 static_assert(!is_same_v<__remove_cvref_t<_Tp>, nullopt_t>, "instantiation of optional with nullopt_t is ill-formed");
881 static_assert(!is_same_v<remove_cv_t<_Tp>, in_place_t>, "instantiation of optional with in_place_t is ill-formed");
882 static_assert(!is_same_v<remove_cv_t<_Tp>, nullopt_t>, "instantiation of optional with nullopt_t is ill-formed");
819883# if _LIBCPP_STD_VER >= 26
820884 static_assert(!is_rvalue_reference_v<_Tp>, "instantiation of optional with an rvalue reference type is ill-formed");
821885# else
......@@ -824,16 +888,6 @@ private:
824888 static_assert(is_destructible_v<_Tp>, "instantiation of optional with a non-destructible type is ill-formed");
825889 static_assert(!is_array_v<_Tp>, "instantiation of optional with an array type is ill-formed");
826890
827# if _LIBCPP_STD_VER >= 26
828 template <class _Up>
829 constexpr static bool __libcpp_opt_ref_ctor_deleted =
830 is_lvalue_reference_v<_Tp> && reference_constructs_from_temporary_v<_Tp, _Up>;
831
832 template <class _Up>
833 constexpr static bool __ref_ctor_enabled =
834 is_lvalue_reference_v<_Tp> && !reference_constructs_from_temporary_v<_Tp, _Up>;
835# endif
836
837891 // LWG2756: conditionally explicit conversion from _Up
838892 struct _CheckOptionalArgsConstructor {
839893 template <class _Up>
......@@ -905,131 +959,48 @@ public:
905959 _LIBCPP_HIDE_FROM_ABI constexpr optional(optional&&) = default;
906960 _LIBCPP_HIDE_FROM_ABI constexpr optional(nullopt_t) noexcept {}
907961
908 template <
909 class _InPlaceT,
910 class... _Args,
911 enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, __is_constructible_for_optional<_Tp, _Args...>>::value, int> = 0>
962 template <class _InPlaceT,
963 class... _Args,
964 enable_if_t<_And<_IsSame<_InPlaceT, in_place_t>, is_constructible<_Tp, _Args...>>::value, int> = 0>
912965 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_InPlaceT, _Args&&... __args)
913966 : __base(in_place, std::forward<_Args>(__args)...) {}
914967
915 template <class _Up,
916 class... _Args,
917 enable_if_t<__is_constructible_for_optional_initializer_list_v<_Tp, _Up, _Args...>, int> = 0>
968 template <class _Up, class... _Args, enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0>
918969 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
919970 : __base(in_place, __il, std::forward<_Args>(__args)...) {}
920971
921972 template <class _Up = _Tp, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0>
922 _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v)
923# if _LIBCPP_STD_VER >= 26
924 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>)
925# endif
926 : __base(in_place, std::forward<_Up>(__v)) {
927 }
973 _LIBCPP_HIDE_FROM_ABI constexpr optional(_Up&& __v) noexcept(is_nothrow_constructible_v<_Tp, _Up>) // strengthened
974 : __base(in_place, std::forward<_Up>(__v)) {}
928975
929976 template <class _Up = remove_cv_t<_Tp>,
930977 enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0>
931 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v)
932# if _LIBCPP_STD_VER >= 26
933 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>)
934# endif
935 : __base(in_place, std::forward<_Up>(__v)) {
936 }
978 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Up&& __v) noexcept(
979 is_nothrow_constructible_v<_Tp, _Up>) // strengthened
980 : __base(in_place, std::forward<_Up>(__v)) {}
937981
938982 // LWG2756: conditionally explicit conversion from const optional<_Up>&
939983 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
940 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v)
941# if _LIBCPP_STD_VER >= 26
942 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>)
943# endif
944 {
984 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>& __v) {
945985 this->__construct_from(__v);
946986 }
987
947988 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
948 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v)
949# if _LIBCPP_STD_VER >= 26
950 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, const _Up&>)
951# endif
952 {
989 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(const optional<_Up>& __v) {
953990 this->__construct_from(__v);
954991 }
955992
956993 // LWG2756: conditionally explicit conversion from optional<_Up>&&
957994 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0>
958 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v)
959# if _LIBCPP_STD_VER >= 26
960 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>)
961# endif
962 {
963 this->__construct_from(std::move(__v));
964 }
965 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0>
966 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v)
967# if _LIBCPP_STD_VER >= 26
968 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp&, _Up>)
969# endif
970 {
995 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(optional<_Up>&& __v) {
971996 this->__construct_from(std::move(__v));
972997 }
973998
974 // deleted optional<T&> constructors and additional optional<T&> constructors
975# if _LIBCPP_STD_VER >= 26
976 // optional(U&&)
977 template <class _Up = _Tp, enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>(), int> = 0>
978 requires __libcpp_opt_ref_ctor_deleted<_Up>
979 optional(_Up&&) = delete;
980
981 template <class _Up = remove_cv_t<_Tp>,
982 enable_if_t<_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>(), int> = 0>
983 requires __libcpp_opt_ref_ctor_deleted<_Up>
984 explicit optional(_Up&&) = delete;
985
986 // optional(optional<U>& rhs)
987 template <class _Up>
988 requires __ref_ctor_enabled<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) && (!is_same_v<_Tp&, _Up>) &&
989 is_constructible_v<_Tp&, _Up&>
990 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!is_convertible_v<_Up&, _Tp&>)
991 optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) {
992 this->__construct_from(__rhs);
993 }
994
995 template <class _Up>
996 requires __libcpp_opt_ref_ctor_deleted<_Up&> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
997 (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, _Up&>
998 constexpr explicit optional(optional<_Up>& __rhs) noexcept = delete;
999
1000 // optional(const optional<U>&)
1001 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>(), int> = 0>
1002 requires __libcpp_opt_ref_ctor_deleted<const _Up&>
1003 optional(const optional<_Up>&) = delete;
1004
1005 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>(), int> = 0>
1006 requires __libcpp_opt_ref_ctor_deleted<const _Up&>
1007 explicit optional(const optional<_Up>&) = delete;
1008
1009 // optional(optional<U>&&)
1010 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_implicit<_Up>(), int> = 0>
1011 requires __libcpp_opt_ref_ctor_deleted<_Up>
1012 optional(optional<_Up>&&) = delete;
1013
1014999 template <class _Up, enable_if_t<_CheckOptionalLikeCtor<_Up, _Up&&>::template __enable_explicit<_Up>(), int> = 0>
1015 requires __libcpp_opt_ref_ctor_deleted<_Up>
1016 explicit optional(optional<_Up>&&) = delete;
1017
1018 // optional(const optional<U>&&)
1019 template <class _Up>
1020 requires __ref_ctor_enabled<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1021 (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up>
1022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!is_convertible_v<const _Up, _Tp&>)
1023 optional(const optional<_Up>&& __v) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) {
1000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit optional(optional<_Up>&& __v) {
10241001 this->__construct_from(std::move(__v));
10251002 }
10261003
1027 template <class _Up>
1028 requires __libcpp_opt_ref_ctor_deleted<const _Up> && (!is_same_v<remove_cvref_t<_Tp>, optional<_Up>>) &&
1029 (!is_same_v<_Tp&, _Up>) && is_constructible_v<_Tp&, const _Up>
1030 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional(const optional<_Up>&& __v) noexcept = delete;
1031# endif
1032
10331004# if _LIBCPP_STD_VER >= 23
10341005 template <class _Tag,
10351006 class _Fp,
......@@ -1052,8 +1023,7 @@ public:
10521023 enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Up>, optional>,
10531024 _Or<_IsNotSame<__remove_cvref_t<_Up>, _Tp>, _Not<is_scalar<_Tp>>>,
10541025 is_constructible<_Tp, _Up>,
1055 is_assignable<_Tp&, _Up>,
1056 is_object<_Tp>>::value,
1026 is_assignable<_Tp&, _Up>>::value,
10571027 int> = 0>
10581028 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) {
10591029 if (this->has_value())
......@@ -1077,138 +1047,35 @@ public:
10771047 return *this;
10781048 }
10791049
1080 template <class... _Args, enable_if_t<__is_constructible_for_optional_v<_Tp, _Args...>, int> = 0>
1081 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args)
1082# if _LIBCPP_STD_VER >= 26
1083 noexcept(is_lvalue_reference_v<_Tp> && is_nothrow_constructible_v<_Tp, _Args...>)
1084# endif
1085 {
1050 template <class... _Args, enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {
10861052 reset();
10871053 this->__construct(std::forward<_Args>(__args)...);
10881054 return this->__get();
10891055 }
10901056
1091 template <class _Up,
1092 class... _Args,
1093 enable_if_t<__is_constructible_for_optional_initializer_list_v<_Tp, _Up, _Args...>, int> = 0>
1057 template <class _Up, class... _Args, enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0>
10941058 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
10951059 reset();
10961060 this->__construct(__il, std::forward<_Args>(__args)...);
10971061 return this->__get();
10981062 }
10991063
1100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional& __opt) noexcept(
1101 (is_nothrow_move_constructible_v<_Tp> && is_nothrow_swappable_v<_Tp>)
1102# if _LIBCPP_STD_VER >= 26
1103 || is_lvalue_reference_v<_Tp>
1104# endif
1105 ) {
1064 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
1065 swap(optional& __opt) noexcept((is_nothrow_move_constructible_v<_Tp> && is_nothrow_swappable_v<_Tp>)) {
11061066 this->__swap(__opt);
11071067 }
11081068
1109 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp const> operator->() const noexcept
1110# if _LIBCPP_STD_VER >= 26
1111 requires(is_object_v<_Tp>)
1112# endif
1113 {
1114 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
1115 return std::addressof(this->__get());
1116 }
1117
1118 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() noexcept
1119# if _LIBCPP_STD_VER >= 26
1120 requires(is_object_v<_Tp>)
1121# endif
1122 {
1123 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
1124 return std::addressof(this->__get());
1125 }
1126
1127 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator*() const& noexcept
1128# if _LIBCPP_STD_VER >= 26
1129 requires(is_object_v<_Tp>)
1130# endif
1131 {
1132 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
1133 return this->__get();
1134 }
1135
1136 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() & noexcept
1137# if _LIBCPP_STD_VER >= 26
1138 requires(is_object_v<_Tp>)
1139# endif
1140 {
1141 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
1142 return this->__get();
1143 }
1144
1145 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator*() && noexcept
1146# if _LIBCPP_STD_VER >= 26
1147 requires(is_object_v<_Tp>)
1148# endif
1149 {
1150 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
1151 return std::move(this->__get());
1152 }
1153
1154 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& operator*() const&& noexcept
1155# if _LIBCPP_STD_VER >= 26
1156 requires(is_object_v<_Tp>)
1157# endif
1158 {
1159 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
1160 return std::move(this->__get());
1161 }
1069 using __base::operator*;
1070 using __base::operator->;
11621071
11631072 _LIBCPP_HIDE_FROM_ABI constexpr explicit operator bool() const noexcept { return has_value(); }
11641073
11651074 using __base::__get;
11661075 using __base::has_value;
1167
1168 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const& value() const&
1169# if _LIBCPP_STD_VER >= 26
1170 requires(is_object_v<_Tp>)
1171# endif
1172 {
1173 if (!this->has_value())
1174 std::__throw_bad_optional_access();
1175 return this->__get();
1176 }
1177
1178 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() &
1179# if _LIBCPP_STD_VER >= 26
1180 requires(is_object_v<_Tp>)
1181# endif
1182 {
1183 if (!this->has_value())
1184 std::__throw_bad_optional_access();
1185 return this->__get();
1186 }
1187
1188 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& value() &&
1189# if _LIBCPP_STD_VER >= 26
1190 requires(is_object_v<_Tp>)
1191# endif
1192 {
1193 if (!this->has_value())
1194 std::__throw_bad_optional_access();
1195 return std::move(this->__get());
1196 }
1197
1198 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp const&& value() const&&
1199# if _LIBCPP_STD_VER >= 26
1200 requires(is_object_v<_Tp>)
1201# endif
1202 {
1203 if (!this->has_value())
1204 std::__throw_bad_optional_access();
1205 return std::move(this->__get());
1206 }
1076 using __base::value;
12071077
12081078 template <class _Up = remove_cv_t<_Tp>>
1209# if _LIBCPP_STD_VER >= 26
1210 requires(is_object_v<_Tp>)
1211# endif
12121079 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) const& {
12131080 static_assert(is_copy_constructible_v<_Tp>, "optional<T>::value_or: T must be copy constructible");
12141081 static_assert(is_convertible_v<_Up, _Tp>, "optional<T>::value_or: U must be convertible to T");
......@@ -1216,9 +1083,6 @@ public:
12161083 }
12171084
12181085 template <class _Up = remove_cv_t<_Tp>>
1219# if _LIBCPP_STD_VER >= 26
1220 requires(is_object_v<_Tp>)
1221# endif
12221086 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp value_or(_Up&& __v) && {
12231087 static_assert(is_move_constructible_v<_Tp>, "optional<T>::value_or: T must be move constructible");
12241088 static_assert(is_convertible_v<_Up, _Tp>, "optional<T>::value_or: U must be convertible to T");
......@@ -1227,9 +1091,6 @@ public:
12271091
12281092# if _LIBCPP_STD_VER >= 23
12291093 template <class _Func>
1230# if _LIBCPP_STD_VER >= 26
1231 requires(is_object_v<_Tp>)
1232# endif
12331094 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
12341095 using _Up = invoke_result_t<_Func, _Tp&>;
12351096 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
......@@ -1240,9 +1101,6 @@ public:
12401101 }
12411102
12421103 template <class _Func>
1243# if _LIBCPP_STD_VER >= 26
1244 requires(is_object_v<_Tp>)
1245# endif
12461104 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {
12471105 using _Up = invoke_result_t<_Func, const _Tp&>;
12481106 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
......@@ -1253,9 +1111,6 @@ public:
12531111 }
12541112
12551113 template <class _Func>
1256# if _LIBCPP_STD_VER >= 26
1257 requires(is_object_v<_Tp>)
1258# endif
12591114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && {
12601115 using _Up = invoke_result_t<_Func, _Tp&&>;
12611116 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
......@@ -1266,9 +1121,6 @@ public:
12661121 }
12671122
12681123 template <class _Func>
1269# if _LIBCPP_STD_VER >= 26
1270 requires(is_object_v<_Tp>)
1271# endif
12721124 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const&& {
12731125 using _Up = invoke_result_t<_Func, const _Tp&&>;
12741126 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
......@@ -1279,60 +1131,52 @@ public:
12791131 }
12801132
12811133 template <class _Func>
1282# if _LIBCPP_STD_VER >= 26
1283 requires(is_object_v<_Tp>)
1284# endif
12851134 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & {
12861135 using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>;
12871136 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
12881137 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
12891138 static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t");
1290 static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
1139 static_assert(
1140 __is_valid_optional_contained_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
12911141 if (*this)
12921142 return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value());
12931143 return optional<_Up>();
12941144 }
12951145
12961146 template <class _Func>
1297# if _LIBCPP_STD_VER >= 26
1298 requires(is_object_v<_Tp>)
1299# endif
13001147 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& {
13011148 using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&>>;
13021149 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
13031150 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
13041151 static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t");
1305 static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
1152 static_assert(
1153 __is_valid_optional_contained_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
13061154 if (*this)
13071155 return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value());
13081156 return optional<_Up>();
13091157 }
13101158
13111159 template <class _Func>
1312# if _LIBCPP_STD_VER >= 26
1313 requires(is_object_v<_Tp>)
1314# endif
13151160 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && {
13161161 using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&&>>;
13171162 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
13181163 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
13191164 static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t");
1320 static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type");
1165 static_assert(
1166 __is_valid_optional_contained_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
13211167 if (*this)
13221168 return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), std::move(value()));
13231169 return optional<_Up>();
13241170 }
13251171
13261172 template <class _Func>
1327# if _LIBCPP_STD_VER >= 26
1328 requires(is_object_v<_Tp>)
1329# endif
13301173 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& {
13311174 using _Up = remove_cv_t<invoke_result_t<_Func, const _Tp&&>>;
13321175 static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
13331176 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
13341177 static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(std::move(value())) should not be std::nullopt_t");
1335 static_assert(is_object_v<_Up>, "Result of f(std::move(value())) should be an object type");
1178 static_assert(
1179 __is_valid_optional_contained_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
13361180 if (*this)
13371181 return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), std::move(value()));
13381182 return optional<_Up>();
......@@ -1341,9 +1185,6 @@ public:
13411185 template <invocable _Func>
13421186 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const&
13431187 requires is_copy_constructible_v<_Tp>
1344# if _LIBCPP_STD_VER >= 26
1345 && (is_object_v<_Tp>)
1346# endif
13471188 {
13481189 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
13491190 "Result of f() should be the same type as this optional");
......@@ -1355,9 +1196,6 @@ public:
13551196 template <invocable _Func>
13561197 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) &&
13571198 requires is_move_constructible_v<_Tp>
1358# if _LIBCPP_STD_VER >= 26
1359 && (is_object_v<_Tp>)
1360# endif
13611199 {
13621200 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
13631201 "Result of f() should be the same type as this optional");
......@@ -1368,46 +1206,137 @@ public:
13681206# endif // _LIBCPP_STD_VER >= 23
13691207
13701208 using __base::reset;
1209};
13711210
1372// optional<T&> overloads
13731211# if _LIBCPP_STD_VER >= 26
1212template <class _Tp>
1213class optional<_Tp&> : public __optional_iterator_base<_Tp&> {
1214 using __base _LIBCPP_NODEBUG = __optional_iterator_base<_Tp&>;
13741215
1375 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<_Tp> operator->() const noexcept
1376 requires(is_lvalue_reference_v<_Tp>)
1377 {
1378 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
1379 return std::addressof(this->__get());
1216 template <class _Up, class _QualUp>
1217 static constexpr bool __check_optionalU_ctor =
1218 !is_same_v<remove_cv_t<_Tp>, optional<_Up>> && !is_same_v<_Tp&, _Up> && is_constructible_v<_Tp&, _QualUp>;
1219 static_assert(!is_same_v<remove_cv_t<_Tp>, in_place_t>, "instantiation of optional with in_place_t is ill-formed");
1220 static_assert(!is_same_v<remove_cv_t<_Tp>, nullopt_t>, "instantiation of optional with nullopt_t is ill-formed");
1221
1222public:
1223 using value_type = _Tp;
1224
1225 constexpr optional() noexcept = default;
1226 constexpr optional(nullopt_t) noexcept {}
1227 constexpr optional(const optional&) noexcept = default;
1228
1229 template <class _Arg>
1230 requires(is_constructible_v<_Tp&, _Arg> && !reference_constructs_from_temporary_v<_Tp&, _Arg>)
1231 constexpr explicit optional(in_place_t, _Arg&& __arg) : __base(in_place, std::forward<_Arg>(__arg)) {}
1232
1233 template <class _Up>
1234 requires(!is_same_v<remove_cvref_t<_Up>, optional> && !is_same_v<remove_cvref_t<_Up>, in_place_t> &&
1235 is_constructible_v<_Tp&, _Up> && !reference_constructs_from_temporary_v<_Tp&, _Up>)
1236 constexpr explicit(!is_convertible_v<_Up, _Tp&>) optional(_Up&& __v) noexcept(is_nothrow_constructible_v<_Tp&, _Up>)
1237 : __base(in_place, std::forward<_Up>(__v)) {}
1238
1239 template <class _Up>
1240 requires(__check_optionalU_ctor<_Up, _Up&> && !reference_constructs_from_temporary_v<_Tp&, _Up&>)
1241 constexpr explicit(!is_convertible_v<_Up&, _Tp&>)
1242 optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) {
1243 this->__construct_from(__rhs);
13801244 }
13811245
1382 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& operator*() const noexcept
1383 requires(is_lvalue_reference_v<_Tp>)
1384 {
1385 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator* called on a disengaged value");
1386 return this->__get();
1246 template <class _Up>
1247 requires(__check_optionalU_ctor<_Up, const _Up&> && !reference_constructs_from_temporary_v<_Tp&, const _Up&>)
1248 constexpr explicit(!is_convertible_v<const _Up&, _Tp&>)
1249 optional(const optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, const _Up&>) {
1250 this->__construct_from(__rhs);
13871251 }
13881252
1389 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp& value() const
1390 requires(is_lvalue_reference_v<_Tp>)
1391 {
1392 if (!this->has_value())
1393 std::__throw_bad_optional_access();
1253 template <class _Up>
1254 requires(__check_optionalU_ctor<_Up, _Up> && !reference_constructs_from_temporary_v<_Tp&, _Up>)
1255 constexpr explicit(!is_convertible_v<_Up, _Tp&>)
1256 optional(optional<_Up>&& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up>) {
1257 this->__construct_from(std::move(__rhs));
1258 }
1259
1260 template <class _Up>
1261 requires(__check_optionalU_ctor<_Up, const _Up> && !reference_constructs_from_temporary_v<_Tp&, const _Up>)
1262 constexpr explicit(!is_convertible_v<const _Up, _Tp&>)
1263 optional(const optional<_Up>&& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) {
1264 this->__construct_from(std::move(__rhs));
1265 }
1266
1267 template <class _Tag, class _Fp, class... _Args>
1268 requires(is_same_v<_Tag, __optional_construct_from_invoke_tag>)
1269 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)
1270 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}
1271
1272 // deleted overloads
1273
1274 template <class _Up>
1275 requires(!is_same_v<remove_cvref_t<_Up>, optional> && !is_same_v<remove_cvref_t<_Up>, in_place_t> &&
1276 is_constructible_v<_Tp&, _Up> && reference_constructs_from_temporary_v<_Tp&, _Up>)
1277 constexpr explicit(!is_convertible_v<_Up, _Tp&>)
1278 optional(_Up&& __v) noexcept(is_nothrow_constructible_v<_Tp&, _Up>) = delete;
1279
1280 template <class _Up>
1281 requires(__check_optionalU_ctor<_Up, _Up&> && reference_constructs_from_temporary_v<_Tp&, _Up&>)
1282 constexpr explicit(!is_convertible_v<_Up&, _Tp&>)
1283 optional(optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up&>) = delete;
1284
1285 template <class _Up>
1286 requires(__check_optionalU_ctor<_Up, const _Up&> && reference_constructs_from_temporary_v<_Tp&, const _Up&>)
1287 constexpr explicit(!is_convertible_v<const _Up&, _Tp&>)
1288 optional(const optional<_Up>& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, const _Up&>) = delete;
1289
1290 template <class _Up>
1291 requires(__check_optionalU_ctor<_Up, _Up> && reference_constructs_from_temporary_v<_Tp&, _Up>)
1292 constexpr explicit(!is_convertible_v<_Up, _Tp&>)
1293 optional(optional<_Up>&& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, _Up>) = delete;
1294
1295 template <class _Up>
1296 requires(__check_optionalU_ctor<_Up, const _Up> && reference_constructs_from_temporary_v<_Tp&, const _Up>)
1297 constexpr explicit(!is_convertible_v<const _Up, _Tp&>)
1298 optional(const optional<_Up>&& __rhs) noexcept(is_nothrow_constructible_v<_Tp&, const _Up>) = delete;
1299
1300 constexpr ~optional() = default;
1301
1302 using __base::__get;
1303
1304 _LIBCPP_HIDE_FROM_ABI constexpr optional& operator=(nullopt_t) noexcept {
1305 reset();
1306 return *this;
1307 }
1308
1309 constexpr optional& operator=(const optional&) noexcept = default;
1310
1311 template <class _Up>
1312 requires(is_constructible_v<_Tp&, _Up> && !reference_constructs_from_temporary_v<_Tp&, _Up>)
1313 constexpr _Tp& emplace(_Up&& __u) noexcept(is_nothrow_constructible_v<_Tp&, _Up>) {
1314 this->__construct(std::forward<_Up>(__u));
1315
13941316 return this->__get();
13951317 }
13961318
1397 template <class _Up = remove_cvref_t<_Tp>>
1398 requires(is_lvalue_reference_v<_Tp> && is_object_v<__libcpp_remove_reference_t<_Tp>> &&
1399 !is_array_v<__libcpp_remove_reference_t<_Tp>>)
1400 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decay_t<_Tp> value_or(_Up&& __v) const {
1401 static_assert(
1402 is_constructible_v<remove_cvref_t<_Tp>, _Tp&>, "optional<T&>::value_or: remove_cv_t<T> must be constructible");
1403 static_assert(
1404 is_convertible_v<_Up, remove_cvref_t<_Tp>>, "optional<T&>::value_or: U must be convertible to remove_cv_t<T>");
1405 return this->has_value() ? this->__get() : static_cast<remove_cvref_t<_Tp>>(std::forward<_Up>(__v));
1319 constexpr void swap(optional& __rhs) noexcept { this->__swap(__rhs); }
1320
1321 using __base::operator->;
1322 using __base::operator*;
1323
1324 constexpr explicit operator bool() const noexcept { return has_value(); }
1325
1326 using __base::has_value;
1327 using __base::value;
1328
1329 template <class _Up = remove_cv_t<_Tp>>
1330 requires(!is_array_v<_Tp> && is_object_v<_Tp>)
1331 [[nodiscard]] constexpr decay_t<_Tp> value_or(_Up&& __v) const {
1332 using _XTp = remove_cv_t<_Tp>;
1333 static_assert(is_constructible_v<_XTp, _Tp&>, "optional<T&>::value_or: remove_cv_t<T> must be constructible");
1334 static_assert(is_convertible_v<_Up, _XTp>, "optional<T&>::value_or: U must be convertible to remove_cv_t<T>");
1335 return this->has_value() ? this->__get() : static_cast<_XTp>(std::forward<_Up>(__v));
14061336 }
14071337
14081338 template <class _Func>
1409 requires(is_lvalue_reference_v<_Tp>)
1410 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const {
1339 [[nodiscard]] constexpr auto and_then(_Func&& __f) const {
14111340 using _Up = invoke_result_t<_Func, _Tp&>;
14121341 static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
14131342 "Result of f(value()) must be a specialization of std::optional");
......@@ -1417,30 +1346,31 @@ public:
14171346 }
14181347
14191348 template <class _Func>
1420 requires(is_lvalue_reference_v<_Tp>)
1421 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional<remove_cv_t<invoke_result_t<_Func, _Tp&>>>
1422 transform(_Func&& __f) const {
1423 using _Up = remove_cvref_t<invoke_result_t<_Func, _Tp&>>;
1349 [[nodiscard]] constexpr optional<remove_cv_t<invoke_result_t<_Func, _Tp&>>> transform(_Func&& __f) const {
1350 using _Up = remove_cv_t<invoke_result_t<_Func, _Tp&>>;
14241351 static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
14251352 static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
14261353 static_assert(!is_same_v<_Up, nullopt_t>, "Result of f(value()) should not be std::nullopt_t");
1427 static_assert(is_object_v<_Up>, "Result of f(value()) should be an object type");
1354 static_assert(
1355 __is_valid_optional_contained_type<_Up>, "Result of f(value()) should be a valid contained type for optional");
1356
14281357 if (*this)
14291358 return optional<_Up>(__optional_construct_from_invoke_tag{}, std::forward<_Func>(__f), value());
14301359 return optional<_Up>();
14311360 }
14321361
14331362 template <invocable _Func>
1434 requires(is_lvalue_reference_v<_Tp>)
1435 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr optional or_else(_Func&& __f) const {
1363 [[nodiscard]] constexpr optional or_else(_Func&& __f) const {
14361364 static_assert(is_same_v<remove_cvref_t<invoke_result_t<_Func>>, optional>,
14371365 "Result of f() should be the same type as this optional");
14381366 if (*this)
14391367 return *this;
14401368 return std::forward<_Func>(__f)();
14411369 }
1442# endif
1370
1371 using __base::reset;
14431372};
1373# endif
14441374
14451375template <class _Tp>
14461376optional(_Tp) -> optional<_Tp>;
......@@ -1749,7 +1679,13 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {
17491679
17501680# endif // _LIBCPP_STD_VER >= 20
17511681
1752template <class _Tp, enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, int> = 0>
1682template <class _Tp,
1683 enable_if_t<(is_move_constructible_v<_Tp> && is_swappable_v<_Tp>)
1684# if _LIBCPP_STD_VER >= 26
1685 || is_reference_v<_Tp>
1686# endif
1687 ,
1688 int> = 0>
17531689inline _LIBCPP_HIDE_FROM_ABI
17541690_LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {
17551691 __x.swap(__y);
......@@ -1759,6 +1695,28 @@ struct __make_optional_barrier_tag {
17591695 explicit __make_optional_barrier_tag() = default;
17601696};
17611697
1698template <class _Tp, class... _Args>
1699inline constexpr bool __is_constructible_for_optional_v = is_constructible_v<_Tp, _Args...>;
1700
1701template <class _Tp, class... _Args>
1702struct __is_constructible_for_optional : bool_constant<__is_constructible_for_optional_v<_Tp, _Args...>> {};
1703
1704template <class _Tp, class _Up, class... _Args>
1705inline constexpr bool __is_constructible_for_optional_initializer_list_v =
1706 is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>;
1707
1708# if _LIBCPP_STD_VER >= 26
1709template <class _Tp, class... _Args>
1710inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Args...> = false;
1711
1712template <class _Tp, class _Arg>
1713inline constexpr bool __is_constructible_for_optional_v<_Tp&, _Arg> =
1714 is_constructible_v<_Tp&, _Arg> && !reference_constructs_from_temporary_v<_Tp&, _Arg>;
1715
1716template <class _Tp, class _Up, class... _Args>
1717inline constexpr bool __is_constructible_for_optional_initializer_list_v<_Tp&, _Up, _Args...> = false;
1718# endif
1719
17621720template <
17631721# if _LIBCPP_STD_VER >= 26
17641722 __make_optional_barrier_tag = __make_optional_barrier_tag{},
......@@ -1801,7 +1759,7 @@ _LIBCPP_END_NAMESPACE_STD
18011759
18021760_LIBCPP_POP_MACROS
18031761
1804# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1762# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
18051763# include <atomic>
18061764# include <climits>
18071765# include <concepts>
lib/libcxx/include/ostream+2-2
......@@ -193,7 +193,7 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
193193
194194# endif // _LIBCPP_HAS_LOCALIZATION
195195
196# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
196# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
197197# include <atomic>
198198# include <concepts>
199199# include <cstdio>
......@@ -206,7 +206,7 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
206206# include <type_traits>
207207# endif
208208
209# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23
209# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
210210# include <locale>
211211# endif
212212
lib/libcxx/include/print+56-80
......@@ -52,12 +52,15 @@ namespace std {
5252# pragma GCC system_header
5353# endif
5454
55# if _LIBCPP_STD_VER >= 23
56
5557_LIBCPP_BEGIN_NAMESPACE_STD
5658
57# ifdef _LIBCPP_WIN32API
59# ifdef _LIBCPP_WIN32API
60_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
5861_LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
5962
60# if _LIBCPP_HAS_WIDE_CHARACTERS
63# if _LIBCPP_HAS_WIDE_CHARACTERS
6164// A wrapper for WriteConsoleW which is used to write to the Windows
6265// console. This function is in the dylib to avoid pulling in windows.h
6366// in the library headers. The function itself uses some private parts
......@@ -68,12 +71,9 @@ _LIBCPP_EXPORTED_FROM_ABI bool __is_windows_terminal(FILE* __stream);
6871//
6972// Note the function is only implemented on the Windows platform.
7073_LIBCPP_EXPORTED_FROM_ABI void __write_to_windows_console(FILE* __stream, wstring_view __view);
71# endif // _LIBCPP_HAS_WIDE_CHARACTERS
72# elif __has_include(<unistd.h>)
73_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream);
74# endif // _LIBCPP_WIN32API
75
76# if _LIBCPP_STD_VER >= 23
74# endif // _LIBCPP_HAS_WIDE_CHARACTERS
75_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
76# endif // _LIBCPP_WIN32API
7777
7878# if _LIBCPP_HAS_UNICODE
7979// This is the code to transcode UTF-8 to UTF-16. This is used on
......@@ -197,36 +197,30 @@ inline constexpr bool __use_unicode_execution_charset = _MSVC_EXECUTION_CHARACTE
197197inline constexpr bool __use_unicode_execution_charset = true;
198198# endif
199199
200# ifdef _LIBCPP_WIN32API
200201_LIBCPP_HIDE_FROM_ABI inline bool __is_terminal([[maybe_unused]] FILE* __stream) {
201202 // The macro _LIBCPP_TESTING_PRINT_IS_TERMINAL is used to change
202203 // the behavior in the test. This is not part of the public API.
203# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
204# ifdef _LIBCPP_TESTING_PRINT_IS_TERMINAL
204205 return _LIBCPP_TESTING_PRINT_IS_TERMINAL(__stream);
205# elif _LIBCPP_AVAILABILITY_HAS_PRINT == 0 || !_LIBCPP_HAS_TERMINAL
206 return false;
207# elif defined(_LIBCPP_WIN32API)
206# else
208207 return std::__is_windows_terminal(__stream);
209# elif __has_include(<unistd.h>)
210 return std::__is_posix_terminal(__stream);
211# else
212# error "Provide a way to determine whether a FILE* is a terminal"
213# endif
208# endif
209}
210# endif // _LIBCPP_WIN32API
211
212[[noreturn]] _LIBCPP_HIDE_FROM_ABI inline void __handle_output_error(FILE* __stream) {
213 if (std::feof(__stream))
214 std::__throw_system_error(EIO, "EOF while writing the formatted output");
215 std::__throw_system_error(std::ferror(__stream), "failed to write formatted output");
214216}
215217
216218template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
217_LIBCPP_HIDE_FROM_ABI inline void
218__vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl) {
219_LIBCPP_HIDE_FROM_ABI inline void __output_nonunicode(FILE* __stream, string_view __text) {
219220 _LIBCPP_ASSERT_NON_NULL(__stream, "__stream must be a valid pointer to an output C stream");
220 string __str = std::vformat(__fmt, __args);
221 if (__write_nl)
222 __str.push_back('\n');
223
224 size_t __size = fwrite(__str.data(), 1, __str.size(), __stream);
225 if (__size < __str.size()) {
226 if (std::feof(__stream))
227 std::__throw_system_error(EIO, "EOF while writing the formatted output");
228 std::__throw_system_error(std::ferror(__stream), "failed to write formatted output");
229 }
221 size_t __size = std::fwrite(__text.data(), 1, __text.size(), __stream);
222 if (__size < __text.size())
223 __print::__handle_output_error(__stream);
230224}
231225
232226# if _LIBCPP_HAS_UNICODE
......@@ -236,27 +230,10 @@ __vprint_nonunicode(FILE* __stream, string_view __fmt, format_args __args, bool
236230// terminal when the output is redirected. Typically during testing the
237231// output is redirected to be able to capture it. This makes it hard to
238232// test this code path.
239template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
240_LIBCPP_HIDE_FROM_ABI inline void
241__vprint_unicode_posix(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {
242 // TODO PRINT Should flush errors throw too?
243 if (__is_terminal)
244 std::fflush(__stream);
245
246 __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);
247}
248233
249234# if _LIBCPP_HAS_WIDE_CHARACTERS
250235template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
251_LIBCPP_HIDE_FROM_ABI inline void
252__vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args, bool __write_nl, bool __is_terminal) {
253 if (!__is_terminal)
254 return __print::__vprint_nonunicode(__stream, __fmt, __args, __write_nl);
255
256 // TODO PRINT Should flush errors throw too?
257 std::fflush(__stream);
258
259 string __str = std::vformat(__fmt, __args);
236_LIBCPP_HIDE_FROM_ABI inline void __output_unicode_windows([[maybe_unused]] FILE* __stream, string_view __text) {
260237 // UTF-16 uses the same number or less code units than UTF-8.
261238 // However the size of the code unit is 16 bits instead of 8 bits.
262239 //
......@@ -266,11 +243,8 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args,
266243 // the final size might be larger when the estimate is wrong.
267244 //
268245 // TODO PRINT profile and improve the speed of this code.
269 __format::__retarget_buffer<wchar_t> __buffer{__str.size()};
270 __unicode::__transcode(__str.begin(), __str.end(), __buffer.__make_output_iterator());
271 if (__write_nl)
272 __buffer.push_back(L'\n');
273
246 __format::__retarget_buffer<wchar_t> __buffer{__text.size()};
247 __unicode::__transcode(__text.begin(), __text.end(), __buffer.__make_output_iterator());
274248 [[maybe_unused]] wstring_view __view = __buffer.__view();
275249
276250 // The macro _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION is used to change
......@@ -287,11 +261,7 @@ __vprint_unicode_windows(FILE* __stream, string_view __fmt, format_args __args,
287261# endif // _LIBCPP_HAS_WIDE_CHARACTERS
288262
289263template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
290_LIBCPP_HIDE_FROM_ABI inline void
291__vprint_unicode([[maybe_unused]] FILE* __stream,
292 [[maybe_unused]] string_view __fmt,
293 [[maybe_unused]] format_args __args,
294 [[maybe_unused]] bool __write_nl) {
264_LIBCPP_HIDE_FROM_ABI inline void __output_unicode([[maybe_unused]] FILE* __stream, string_view __text) {
295265 _LIBCPP_ASSERT_NON_NULL(__stream, "__stream must be a valid pointer to an output C stream");
296266
297267 // [print.fun]
......@@ -302,9 +272,6 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
302272 // Otherwise writes out to stream unchanged. If the native
303273 // Unicode API is used, the function flushes stream before
304274 // writing out.
305 // 8 - Throws: Any exception thrown by the call to vformat
306 // ([format.err.report]). system_error if writing to the terminal
307 // or stream fails. May throw bad_alloc.
308275 // 9 - Recommended practice: If invoking the native Unicode API
309276 // requires transcoding, implementations should substitute
310277 // invalid code units with U+FFFD replacement character per the
......@@ -316,9 +283,15 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
316283 // Windows there is a different API. This API requires transcoding.
317284
318285# ifndef _LIBCPP_WIN32API
319 __print::__vprint_unicode_posix(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));
286 __print::__output_nonunicode(__stream, __text);
320287# elif _LIBCPP_HAS_WIDE_CHARACTERS
321 __print::__vprint_unicode_windows(__stream, __fmt, __args, __write_nl, __print::__is_terminal(__stream));
288 if (__print::__is_terminal(__stream)) {
289 // TODO PRINT Should flush errors throw too?
290 std::fflush(__stream);
291 __print::__output_unicode_windows(__stream, __text);
292 } else {
293 __print::__output_nonunicode(__stream, __text);
294 }
322295# else
323296# error "Windows builds with wchar_t disabled are not supported."
324297# endif
......@@ -329,51 +302,54 @@ __vprint_unicode([[maybe_unused]] FILE* __stream,
329302} // namespace __print
330303
331304template <class... _Args>
332_LIBCPP_HIDE_FROM_ABI void
305_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE void
333306print(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, format_string<_Args...> __fmt, _Args&&... __args) {
307 auto __result = std::vformat(__fmt.get(), std::make_format_args(__args...));
334308# if _LIBCPP_HAS_UNICODE
335309 if constexpr (__print::__use_unicode_execution_charset)
336 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
310 __print::__output_unicode(__stream, __result);
337311 else
338 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
312 __print::__output_nonunicode(__stream, __result);
339313# else // _LIBCPP_HAS_UNICODE
340 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), false);
314 __print::__output_nonunicode(__stream, __result);
341315# endif // _LIBCPP_HAS_UNICODE
342316}
343317
344318template <class... _Args>
345_LIBCPP_HIDE_FROM_ABI void print(format_string<_Args...> __fmt, _Args&&... __args) {
319_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE void print(format_string<_Args...> __fmt, _Args&&... __args) {
346320 std::print(stdout, __fmt, std::forward<_Args>(__args)...);
347321}
348322
349323template <class... _Args>
350_LIBCPP_HIDE_FROM_ABI void
324_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE void
351325println(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, format_string<_Args...> __fmt, _Args&&... __args) {
326 auto __result = std::vformat(__fmt.get(), std::make_format_args(__args...));
327 __result.push_back('\n');
352328# if _LIBCPP_HAS_UNICODE
353329 // Note the wording in the Standard is inefficient. The output of
354330 // std::format is a std::string which is then copied. This solution
355331 // just appends a newline at the end of the output.
356332 if constexpr (__print::__use_unicode_execution_charset)
357 __print::__vprint_unicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
333 __print::__output_unicode(__stream, __result);
358334 else
359 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
335 __print::__output_nonunicode(__stream, __result);
360336# else // _LIBCPP_HAS_UNICODE
361 __print::__vprint_nonunicode(__stream, __fmt.get(), std::make_format_args(__args...), true);
337 __print::__output_nonunicode(__stream, __result);
362338# endif // _LIBCPP_HAS_UNICODE
363339}
364340
365template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
366_LIBCPP_HIDE_FROM_ABI inline void println(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream) {
367 std::print(__stream, "\n");
341template <class _Void = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
342_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE inline void println(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream) {
343 std::print(__stream, (_Void(), "\n"));
368344}
369345
370346template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
371_LIBCPP_HIDE_FROM_ABI inline void println() {
347_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE inline void println() {
372348 println(stdout);
373349}
374350
375351template <class... _Args>
376_LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __args) {
352_LIBCPP_HIDE_FROM_ABI _LIBCPP_ALWAYS_INLINE void println(format_string<_Args...> __fmt, _Args&&... __args) {
377353 std::println(stdout, __fmt, std::forward<_Args>(__args)...);
378354}
379355
......@@ -381,7 +357,7 @@ _LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __a
381357template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
382358_LIBCPP_HIDE_FROM_ABI inline void
383359vprint_unicode(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, string_view __fmt, format_args __args) {
384 __print::__vprint_unicode(__stream, __fmt, __args, false);
360 __print::__output_unicode(__stream, std::vformat(__fmt, __args));
385361}
386362
387363template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
......@@ -394,7 +370,7 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(string_view __fmt, format_args
394370template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
395371_LIBCPP_HIDE_FROM_ABI inline void
396372vprint_nonunicode(FILE* _LIBCPP_DIAGNOSE_NULLPTR __stream, string_view __fmt, format_args __args) {
397 __print::__vprint_nonunicode(__stream, __fmt, __args, false);
373 __print::__output_nonunicode(__stream, std::vformat(__fmt, __args));
398374}
399375
400376template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
......@@ -402,10 +378,10 @@ _LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(string_view __fmt, format_ar
402378 std::vprint_nonunicode(stdout, __fmt, __args);
403379}
404380
405# endif // _LIBCPP_STD_VER >= 23
406
407381_LIBCPP_END_NAMESPACE_STD
408382
383# endif // _LIBCPP_STD_VER >= 23
384
409385#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
410386
411387#endif // _LIBCPP_PRINT
lib/libcxx/include/queue+1-1
......@@ -970,7 +970,7 @@ _LIBCPP_END_NAMESPACE_STD
970970
971971_LIBCPP_POP_MACROS
972972
973# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
973# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
974974# include <concepts>
975975# include <cstdlib>
976976# include <functional>
lib/libcxx/include/random+1-1
......@@ -1726,7 +1726,7 @@ class piecewise_linear_distribution
17261726# pragma GCC system_header
17271727# endif
17281728
1729# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1729# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
17301730# include <algorithm>
17311731# include <climits>
17321732# include <cmath>
lib/libcxx/include/ranges+39-1
......@@ -201,6 +201,16 @@ namespace std::ranges {
201201 inline constexpr unspecified filter = unspecified;
202202 }
203203
204 // [range.concat], concat view
205 template <input_range... Views>
206 requires (view<Views> && ...) && (sizeof...(Views) > 0) &&
207 concatable<Views...>
208 class concat_view;
209
210 namespace views {
211 inline constexpr unspecified concat = unspecified;
212 }
213
204214 // [range.drop], drop view
205215 template<view V>
206216 class drop_view;
......@@ -337,6 +347,17 @@ namespace std::ranges {
337347
338348 namespace views { template<class T> inline constexpr unspecified istream = unspecified; }
339349
350 // [range.enumerate], enumerate view
351 template<view View>
352 requires see below
353 class enumerate_view; // since C++23
354
355 template<class View>
356 constexpr bool enable_borrowed_range<enumerate_view<View>> = // since C++23
357 enable_borrowed_range<View>;
358
359 namespace views { inline constexpr unspecified enumerate = unspecified; } // since C++23
360
340361 // [range.zip], zip view
341362 template<input_range... Views>
342363 requires (view<Views> && ...) && (sizeof...(Views) > 0)
......@@ -396,6 +417,17 @@ namespace std::ranges {
396417 class chunk_by_view; // C++23
397418
398419 namespace views { inline constexpr unspecified chunk_by = unspecified; } // C++23
420
421 // [range.stride.view], stride view
422 template<input_range V>
423 requires view<V>
424 class stride_view; // C++23
425
426 template<class V>
427 constexpr bool enable_borrowed_range<stride_view<V>> =
428 enable_borrowed_range<V>; // C++23
429
430 namespace views { inline constexpr unspecified stride = unspecified; } // C++23
399431}
400432
401433namespace std {
......@@ -482,14 +514,20 @@ namespace std {
482514# include <__ranges/adjacent_view.h>
483515# include <__ranges/as_rvalue_view.h>
484516# include <__ranges/chunk_by_view.h>
517# include <__ranges/enumerate_view.h>
485518# include <__ranges/from_range.h>
486519# include <__ranges/join_with_view.h>
487520# include <__ranges/repeat_view.h>
521# include <__ranges/stride_view.h>
488522# include <__ranges/to.h>
489523# include <__ranges/zip_transform_view.h>
490524# include <__ranges/zip_view.h>
491525# endif
492526
527# if _LIBCPP_STD_VER >= 26
528# include <__ranges/concat_view.h>
529# endif
530
493531# include <version>
494532
495533// standard-mandated includes
......@@ -507,7 +545,7 @@ namespace std {
507545# pragma GCC system_header
508546# endif
509547
510# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
548# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
511549# include <cstdlib>
512550# include <iosfwd>
513551# include <type_traits>
lib/libcxx/include/ratio+1-1
......@@ -491,7 +491,7 @@ _LIBCPP_END_NAMESPACE_STD
491491
492492_LIBCPP_POP_MACROS
493493
494# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
494# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
495495# include <type_traits>
496496# endif
497497#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/regex+5-2
......@@ -817,6 +817,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
817817# include <__iterator/wrap_iter.h>
818818# include <__locale>
819819# include <__memory/addressof.h>
820# include <__memory/pointer_traits.h>
820821# include <__memory/shared_ptr.h>
821822# include <__memory_resource/polymorphic_allocator.h>
822823# include <__type_traits/is_swappable.h>
......@@ -840,6 +841,7 @@ _LIBCPP_PUSH_MACROS
840841# define _LIBCPP_REGEX_COMPLEXITY_FACTOR 4096
841842
842843_LIBCPP_BEGIN_NAMESPACE_STD
844_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
843845
844846namespace regex_constants {
845847
......@@ -5167,7 +5169,7 @@ regex_search(__wrap_iter<_Iter> __first,
51675169 const basic_regex<_CharT, _Traits>& __e,
51685170 regex_constants::match_flag_type __flags = regex_constants::match_default) {
51695171 match_results<const _CharT*> __mc;
5170 bool __r = __e.__search(__first.base(), __last.base(), __mc, __flags);
5172 bool __r = __e.__search(std::__to_address(__first), std::__to_address(__last), __mc, __flags);
51715173 __m.__assign(__first, __last, __mc, __flags & regex_constants::__no_update_pos);
51725174 return __r;
51735175}
......@@ -5807,6 +5809,7 @@ regex_replace(const _CharT* __s,
58075809 return __r;
58085810}
58095811
5812_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
58105813_LIBCPP_END_NAMESPACE_STD
58115814
58125815# if _LIBCPP_STD_VER >= 17
......@@ -5831,7 +5834,7 @@ _LIBCPP_POP_MACROS
58315834
58325835# endif // _LIBCPP_HAS_LOCALIZATION
58335836
5834# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
5837# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
58355838# include <atomic>
58365839# include <concepts>
58375840# include <cstdlib>
lib/libcxx/include/scoped_allocator+5-5
......@@ -135,10 +135,10 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
135135_LIBCPP_PUSH_MACROS
136136# include <__undef_macros>
137137
138_LIBCPP_BEGIN_NAMESPACE_STD
139
140138# if !defined(_LIBCPP_CXX03_LANG)
141139
140_LIBCPP_BEGIN_NAMESPACE_STD
141
142142// scoped_allocator_adaptor
143143
144144template <class... _Allocs>
......@@ -558,13 +558,13 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const scoped_allocator_adaptor<_Out
558558
559559# endif // _LIBCPP_STD_VER <= 17
560560
561# endif // !defined(_LIBCPP_CXX03_LANG)
562
563561_LIBCPP_END_NAMESPACE_STD
564562
563# endif // !defined(_LIBCPP_CXX03_LANG)
564
565565_LIBCPP_POP_MACROS
566566
567# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
567# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
568568# include <atomic>
569569# include <climits>
570570# include <concepts>
lib/libcxx/include/semaphore+1-1
......@@ -180,7 +180,7 @@ _LIBCPP_POP_MACROS
180180
181181# endif // _LIBCPP_HAS_THREADS
182182
183# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
183# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
184184# include <atomic>
185185# include <cstddef>
186186# endif
lib/libcxx/include/set+373-214
......@@ -71,12 +71,12 @@ public:
7171 const allocator_type& a);
7272 template <class InputIterator>
7373 set(InputIterator first, InputIterator last, const allocator_type& a)
74 : set(first, last, Compare(), a) {} // C++14
74 : set(first, last, Compare(), a) {}
7575 template<container-compatible-range<value_type> R>
7676 set(from_range_t, R&& rg, const Allocator& a))
7777 : set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
7878 set(initializer_list<value_type> il, const allocator_type& a)
79 : set(il, Compare(), a) {} // C++14
79 : set(il, Compare(), a) {}
8080 ~set();
8181
8282 set& operator=(const set& s);
......@@ -316,12 +316,12 @@ public:
316316 const allocator_type& a);
317317 template <class InputIterator>
318318 multiset(InputIterator first, InputIterator last, const allocator_type& a)
319 : set(first, last, Compare(), a) {} // C++14
319 : set(first, last, Compare(), a) {}
320320 template<container-compatible-range<value_type> R>
321321 multiset(from_range_t, R&& rg, const Allocator& a))
322322 : multiset(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
323323 multiset(initializer_list<value_type> il, const allocator_type& a)
324 : set(il, Compare(), a) {} // C++14
324 : set(il, Compare(), a) {}
325325 ~multiset();
326326
327327 multiset& operator=(const multiset& s);
......@@ -615,24 +615,27 @@ public:
615615 template <class _Key2, class _Compare2, class _Alloc2>
616616 friend class multiset;
617617
618 _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_(
618 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set() _NOEXCEPT_(
619619 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
620620 is_nothrow_copy_constructible<key_compare>::value)
621621 : __tree_(value_compare()) {}
622622
623 _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp) _NOEXCEPT_(
623 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const value_compare& __comp) _NOEXCEPT_(
624624 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)
625625 : __tree_(__comp) {}
626626
627 _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {}
627 _LIBCPP_HIDE_FROM_ABI
628 _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const value_compare& __comp, const allocator_type& __a)
629 : __tree_(__comp, __a) {}
628630 template <class _InputIterator>
629 _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
631 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
632 set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
630633 : __tree_(__comp) {
631634 insert(__f, __l);
632635 }
633636
634637 template <class _InputIterator>
635 _LIBCPP_HIDE_FROM_ABI
638 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
636639 set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)
637640 : __tree_(__comp, __a) {
638641 insert(__f, __l);
......@@ -640,7 +643,7 @@ public:
640643
641644# if _LIBCPP_STD_VER >= 23
642645 template <_ContainerCompatibleRange<value_type> _Range>
643 _LIBCPP_HIDE_FROM_ABI
646 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
644647 set(from_range_t,
645648 _Range&& __range,
646649 const key_compare& __comp = key_compare(),
......@@ -650,263 +653,340 @@ public:
650653 }
651654# endif
652655
653# if _LIBCPP_STD_VER >= 14
654656 template <class _InputIterator>
655 _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
657 _LIBCPP_HIDE_FROM_ABI
658 _LIBCPP_CONSTEXPR_SINCE_CXX26 set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
656659 : set(__f, __l, key_compare(), __a) {}
657# endif
658660
659661# if _LIBCPP_STD_VER >= 23
660662 template <_ContainerCompatibleRange<value_type> _Range>
661 _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a)
663 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(from_range_t, _Range&& __range, const allocator_type& __a)
662664 : set(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
663665# endif
664666
665 _LIBCPP_HIDE_FROM_ABI set(const set& __s) = default;
667 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(const set& __s) = default;
666668
667 _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default;
669 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(const set& __s) = default;
668670
669671# ifndef _LIBCPP_CXX03_LANG
670 _LIBCPP_HIDE_FROM_ABI set(set&& __s) = default;
672 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(set&& __s) = default;
671673# endif // _LIBCPP_CXX03_LANG
672674
673 _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}
675 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const allocator_type& __a) : __tree_(__a) {}
674676
675 _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __alloc) : __tree_(__s.__tree_, __alloc) {}
677 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(const set& __s, const allocator_type& __alloc)
678 : __tree_(__s.__tree_, __alloc) {}
676679
677680# ifndef _LIBCPP_CXX03_LANG
678 _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __alloc) : __tree_(std::move(__s.__tree_), __alloc) {}
681 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(set&& __s, const allocator_type& __alloc)
682 : __tree_(std::move(__s.__tree_), __alloc) {}
679683
680 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
684 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
685 set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
681686 : __tree_(__comp) {
682687 insert(__il.begin(), __il.end());
683688 }
684689
685 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)
690 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
691 set(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)
686692 : __tree_(__comp, __a) {
687693 insert(__il.begin(), __il.end());
688694 }
689695
690# if _LIBCPP_STD_VER >= 14
691 _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a)
696 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(initializer_list<value_type> __il, const allocator_type& __a)
692697 : set(__il, key_compare(), __a) {}
693# endif
694698
695 _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) {
699 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(initializer_list<value_type> __il) {
696700 clear();
697701 insert(__il.begin(), __il.end());
698702 return *this;
699703 }
700704
701 _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) = default;
705 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(set&& __s) = default;
702706# endif // _LIBCPP_CXX03_LANG
703707
704 _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
708 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~set() {
709 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
710 }
705711
706 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
707 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
708 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
709 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
712 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT {
713 return __tree_.begin();
714 }
715 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
716 return __tree_.begin();
717 }
718 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT {
719 return __tree_.end();
720 }
721 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
722 return __tree_.end();
723 }
710724
711 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
712 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
725 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() _NOEXCEPT {
726 return reverse_iterator(end());
727 }
728 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
729 rbegin() const _NOEXCEPT {
713730 return const_reverse_iterator(end());
714731 }
715 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
716 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
732 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() _NOEXCEPT {
733 return reverse_iterator(begin());
734 }
735 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const _NOEXCEPT {
717736 return const_reverse_iterator(begin());
718737 }
719738
720 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
721 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
722 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
723 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
739 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const _NOEXCEPT {
740 return begin();
741 }
742 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const _NOEXCEPT {
743 return end();
744 }
745 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
746 crbegin() const _NOEXCEPT {
747 return rbegin();
748 }
749 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const _NOEXCEPT {
750 return rend();
751 }
724752
725 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
726 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
727 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
753 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const _NOEXCEPT {
754 return __tree_.size() == 0;
755 }
756 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT {
757 return __tree_.size();
758 }
759 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
760 return __tree_.max_size();
761 }
728762
729763 // modifiers:
730764# ifndef _LIBCPP_CXX03_LANG
731765 template <class... _Args>
732 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
766 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
733767 return __tree_.__emplace_unique(std::forward<_Args>(__args)...);
734768 }
735769 template <class... _Args>
736 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
770 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
737771 return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...).first;
738772 }
739773# endif // _LIBCPP_CXX03_LANG
740774
741 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); }
742 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
775 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __v) {
776 return __tree_.__emplace_unique(__v);
777 }
778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) {
743779 return __tree_.__emplace_hint_unique(__p, __v).first;
744780 }
745781
746782 template <class _InputIterator>
747 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
748784 __tree_.__insert_range_unique(__first, __last);
749785 }
750786
751787# if _LIBCPP_STD_VER >= 23
752788 template <_ContainerCompatibleRange<value_type> _Range>
753 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
789 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
754790 __tree_.__insert_range_unique(ranges::begin(__range), ranges::end(__range));
755791 }
756792# endif
757793
758794# ifndef _LIBCPP_CXX03_LANG
759 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
795 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __v) {
760796 return __tree_.__emplace_unique(std::move(__v));
761797 }
762798
763 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
799 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, value_type&& __v) {
764800 return __tree_.__emplace_hint_unique(__p, std::move(__v)).first;
765801 }
766802
767 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
803 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
804 insert(__il.begin(), __il.end());
805 }
768806# endif // _LIBCPP_CXX03_LANG
769807
770 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
771 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }
772 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
773 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
808 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) { return __tree_.erase(__p); }
809 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) {
810 return __tree_.__erase_unique(__k);
811 }
812 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) {
813 return __tree_.erase(__f, __l);
814 }
815 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); }
774816
775817# if _LIBCPP_STD_VER >= 17
776 _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
818 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 insert_return_type insert(node_type&& __nh) {
777819 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
778820 "node_type with incompatible allocator passed to set::insert()");
779821 return __tree_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
780822 }
781 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
823 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, node_type&& __nh) {
782824 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
783825 "node_type with incompatible allocator passed to set::insert()");
784826 return __tree_.template __node_handle_insert_unique<node_type>(__hint, std::move(__nh));
785827 }
786 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
828 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(key_type const& __key) {
787829 return __tree_.template __node_handle_extract<node_type>(__key);
788830 }
789 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
831 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(const_iterator __it) {
790832 return __tree_.template __node_handle_extract<node_type>(__it);
791833 }
792834 template <class _Compare2>
793 _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>& __source) {
835 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>& __source) {
794836 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
795837 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
796838 __tree_.__node_handle_merge_unique(__source.__tree_);
797839 }
798840 template <class _Compare2>
799 _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>&& __source) {
841 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>&& __source) {
800842 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
801843 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
802844 __tree_.__node_handle_merge_unique(__source.__tree_);
803845 }
804846 template <class _Compare2>
805 _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>& __source) {
847 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
848 merge(multiset<key_type, _Compare2, allocator_type>& __source) {
806849 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
807850 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
808851 __tree_.__node_handle_merge_unique(__source.__tree_);
809852 }
810853 template <class _Compare2>
811 _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
854 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
855 merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
812856 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
813857 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
814858 __tree_.__node_handle_merge_unique(__source.__tree_);
815859 }
816860# endif
817861
818 _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }
862 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
863 __tree_.swap(__s.__tree_);
864 }
819865
820 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
821 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
822 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }
866 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT {
867 return __tree_.__alloc();
868 }
869 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const {
870 return __tree_.value_comp();
871 }
872 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const {
873 return __tree_.value_comp();
874 }
823875
824876 // set operations:
825 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
826 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
877 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __k) {
878 return __tree_.find(__k);
879 }
880 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __k) const {
881 return __tree_.find(__k);
882 }
827883# if _LIBCPP_STD_VER >= 14
828 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
829 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
884 template <typename _K2,
885 class _Comp = _Compare,
886 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
887 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _K2& __k) {
830888 return __tree_.find(__k);
831889 }
832 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
833 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
890 template <typename _K2,
891 class _Comp = _Compare,
892 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
893 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _K2& __k) const {
834894 return __tree_.find(__k);
835895 }
836896# endif
837897
838 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
898 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const {
839899 return __tree_.__count_unique(__k);
840900 }
841901# if _LIBCPP_STD_VER >= 14
842 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
843 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
902 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
903 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _K2& __k) const {
844904 return __tree_.__count_multi(__k);
845905 }
846906# endif
847907
848908# if _LIBCPP_STD_VER >= 20
849 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
850 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
851 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
909 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __k) const {
910 return find(__k) != end();
911 }
912 template <typename _K2,
913 class _Comp = _Compare,
914 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
915 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _K2& __k) const {
852916 return find(__k) != end();
853917 }
854918# endif // _LIBCPP_STD_VER >= 20
855919
856 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) {
920 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) {
857921 return __tree_.__lower_bound_unique(__k);
858922 }
859923
860 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
924 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
925 lower_bound(const key_type& __k) const {
861926 return __tree_.__lower_bound_unique(__k);
862927 }
863928
864929 // The transparent versions of the lookup functions use the _multi version, since a non-element key is allowed to
865930 // match multiple elements.
866931# if _LIBCPP_STD_VER >= 14
867 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
868 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
932 template <typename _K2,
933 class _Comp = _Compare,
934 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
935 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _K2& __k) {
869936 return __tree_.__lower_bound_multi(__k);
870937 }
871938
872 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
873 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
939 template <typename _K2,
940 class _Comp = _Compare,
941 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
942 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
943 lower_bound(const _K2& __k) const {
874944 return __tree_.__lower_bound_multi(__k);
875945 }
876946# endif
877947
878 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) {
948 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) {
879949 return __tree_.__upper_bound_unique(__k);
880950 }
881951
882 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const {
952 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
953 upper_bound(const key_type& __k) const {
883954 return __tree_.__upper_bound_unique(__k);
884955 }
885956
886957# if _LIBCPP_STD_VER >= 14
887 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
888 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
958 template <typename _K2,
959 class _Comp = _Compare,
960 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
961 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _K2& __k) {
889962 return __tree_.__upper_bound_multi(__k);
890963 }
891 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
892 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
964 template <typename _K2,
965 class _Comp = _Compare,
966 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
967 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
968 upper_bound(const _K2& __k) const {
893969 return __tree_.__upper_bound_multi(__k);
894970 }
895971# endif
896972
897 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
973 [[__nodiscard__]]
974 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __k) {
898975 return __tree_.__equal_range_unique(__k);
899976 }
900 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
977 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
978 equal_range(const key_type& __k) const {
901979 return __tree_.__equal_range_unique(__k);
902980 }
903981# if _LIBCPP_STD_VER >= 14
904 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
905 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
982 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
983 [[__nodiscard__]]
984 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _K2& __k) {
906985 return __tree_.__equal_range_multi(__k);
907986 }
908 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
909 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
987 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
988 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
989 equal_range(const _K2& __k) const {
910990 return __tree_.__equal_range_multi(__k);
911991 }
912992# endif
......@@ -969,7 +1049,7 @@ struct __specialized_algorithm<_Alg, __single_range<set<_Key, _Compare, _Allocat
9691049
9701050 // set's begin() and end() are identical with and without const qualification
9711051 template <class... _Args>
972 _LIBCPP_HIDE_FROM_ABI static auto operator()(const __set& __set, _Args&&... __args) {
1052 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(const __set& __set, _Args&&... __args) {
9731053 return __specialized_algorithm<_Alg, __single_range<typename __set::__base>>()(
9741054 __set.__tree_, std::forward<_Args>(__args)...);
9751055 }
......@@ -977,7 +1057,7 @@ struct __specialized_algorithm<_Alg, __single_range<set<_Key, _Compare, _Allocat
9771057# endif
9781058
9791059template <class _Key, class _Compare, class _Allocator>
980inline _LIBCPP_HIDE_FROM_ABI bool
1060inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
9811061operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
9821062 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
9831063}
......@@ -985,31 +1065,31 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
9851065# if _LIBCPP_STD_VER <= 17
9861066
9871067template <class _Key, class _Compare, class _Allocator>
988inline _LIBCPP_HIDE_FROM_ABI bool
1068inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
9891069operator<(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
9901070 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
9911071}
9921072
9931073template <class _Key, class _Compare, class _Allocator>
994inline _LIBCPP_HIDE_FROM_ABI bool
1074inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
9951075operator!=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
9961076 return !(__x == __y);
9971077}
9981078
9991079template <class _Key, class _Compare, class _Allocator>
1000inline _LIBCPP_HIDE_FROM_ABI bool
1080inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
10011081operator>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
10021082 return __y < __x;
10031083}
10041084
10051085template <class _Key, class _Compare, class _Allocator>
1006inline _LIBCPP_HIDE_FROM_ABI bool
1086inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
10071087operator>=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
10081088 return !(__x < __y);
10091089}
10101090
10111091template <class _Key, class _Compare, class _Allocator>
1012inline _LIBCPP_HIDE_FROM_ABI bool
1092inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
10131093operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
10141094 return !(__y < __x);
10151095}
......@@ -1017,7 +1097,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
10171097# else // _LIBCPP_STD_VER <= 17
10181098
10191099template <class _Key, class _Compare, class _Allocator>
1020_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
1100_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<_Key>
10211101operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
10221102 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
10231103}
......@@ -1026,14 +1106,14 @@ operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare
10261106
10271107// specialized algorithms:
10281108template <class _Key, class _Compare, class _Allocator>
1029inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y)
1030 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
1109inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1110swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
10311111 __x.swap(__y);
10321112}
10331113
10341114# if _LIBCPP_STD_VER >= 20
10351115template <class _Key, class _Compare, class _Allocator, class _Predicate>
1036inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type
1116inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename set<_Key, _Compare, _Allocator>::size_type
10371117erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
10381118 return std::__libcpp_erase_if_container(__c, __pred);
10391119}
......@@ -1092,31 +1172,32 @@ public:
10921172 friend class multiset;
10931173
10941174 // construct/copy/destroy:
1095 _LIBCPP_HIDE_FROM_ABI multiset() _NOEXCEPT_(
1175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset() _NOEXCEPT_(
10961176 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
10971177 is_nothrow_copy_constructible<key_compare>::value)
10981178 : __tree_(value_compare()) {}
10991179
1100 _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp) _NOEXCEPT_(
1180 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multiset(const value_compare& __comp) _NOEXCEPT_(
11011181 is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)
11021182 : __tree_(__comp) {}
11031183
1104 _LIBCPP_HIDE_FROM_ABI explicit multiset(const value_compare& __comp, const allocator_type& __a)
1184 _LIBCPP_HIDE_FROM_ABI
1185 _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multiset(const value_compare& __comp, const allocator_type& __a)
11051186 : __tree_(__comp, __a) {}
11061187 template <class _InputIterator>
1107 _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
1188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1189 multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
11081190 : __tree_(__comp) {
11091191 insert(__f, __l);
11101192 }
11111193
1112# if _LIBCPP_STD_VER >= 14
11131194 template <class _InputIterator>
1114 _LIBCPP_HIDE_FROM_ABI multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
1195 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1196 multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
11151197 : multiset(__f, __l, key_compare(), __a) {}
1116# endif
11171198
11181199 template <class _InputIterator>
1119 _LIBCPP_HIDE_FROM_ABI
1200 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
11201201 multiset(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)
11211202 : __tree_(__comp, __a) {
11221203 insert(__f, __l);
......@@ -1124,7 +1205,7 @@ public:
11241205
11251206# if _LIBCPP_STD_VER >= 23
11261207 template <_ContainerCompatibleRange<value_type> _Range>
1127 _LIBCPP_HIDE_FROM_ABI
1208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
11281209 multiset(from_range_t,
11291210 _Range&& __range,
11301211 const key_compare& __comp = key_compare(),
......@@ -1134,254 +1215,332 @@ public:
11341215 }
11351216
11361217 template <_ContainerCompatibleRange<value_type> _Range>
1137 _LIBCPP_HIDE_FROM_ABI multiset(from_range_t, _Range&& __range, const allocator_type& __a)
1218 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1219 multiset(from_range_t, _Range&& __range, const allocator_type& __a)
11381220 : multiset(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
11391221# endif
11401222
1141 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s) = default;
1223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(const multiset& __s) = default;
11421224
1143 _LIBCPP_HIDE_FROM_ABI multiset& operator=(const multiset& __s) = default;
1225 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset& operator=(const multiset& __s) = default;
11441226
11451227# ifndef _LIBCPP_CXX03_LANG
1146 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) = default;
1228 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(multiset&& __s) = default;
11471229
1148 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {}
1230 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(multiset&& __s, const allocator_type& __a)
1231 : __tree_(std::move(__s.__tree_), __a) {}
11491232# endif // _LIBCPP_CXX03_LANG
1150 _LIBCPP_HIDE_FROM_ABI explicit multiset(const allocator_type& __a) : __tree_(__a) {}
1151 _LIBCPP_HIDE_FROM_ABI multiset(const multiset& __s, const allocator_type& __a) : __tree_(__s.__tree_, __a) {}
1233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit multiset(const allocator_type& __a) : __tree_(__a) {}
1234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset(const multiset& __s, const allocator_type& __a)
1235 : __tree_(__s.__tree_, __a) {}
11521236
11531237# ifndef _LIBCPP_CXX03_LANG
1154 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
1238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1239 multiset(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
11551240 : __tree_(__comp) {
11561241 insert(__il.begin(), __il.end());
11571242 }
11581243
1159 _LIBCPP_HIDE_FROM_ABI
1244 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
11601245 multiset(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)
11611246 : __tree_(__comp, __a) {
11621247 insert(__il.begin(), __il.end());
11631248 }
11641249
1165# if _LIBCPP_STD_VER >= 14
1166 _LIBCPP_HIDE_FROM_ABI multiset(initializer_list<value_type> __il, const allocator_type& __a)
1250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
1251 multiset(initializer_list<value_type> __il, const allocator_type& __a)
11671252 : multiset(__il, key_compare(), __a) {}
1168# endif
11691253
1170 _LIBCPP_HIDE_FROM_ABI multiset& operator=(initializer_list<value_type> __il) {
1254 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset& operator=(initializer_list<value_type> __il) {
11711255 clear();
11721256 insert(__il.begin(), __il.end());
11731257 return *this;
11741258 }
11751259
1176 _LIBCPP_HIDE_FROM_ABI multiset& operator=(multiset&& __s) = default;
1260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 multiset& operator=(multiset&& __s) = default;
11771261# endif // _LIBCPP_CXX03_LANG
11781262
1179 _LIBCPP_HIDE_FROM_ABI ~multiset() {
1263 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~multiset() {
11801264 static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
11811265 }
11821266
1183 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
1184 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
1185 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
1186 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
1267 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT {
1268 return __tree_.begin();
1269 }
1270 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
1271 return __tree_.begin();
1272 }
1273 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT {
1274 return __tree_.end();
1275 }
1276 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
1277 return __tree_.end();
1278 }
11871279
1188 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
1189 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
1280 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() _NOEXCEPT {
1281 return reverse_iterator(end());
1282 }
1283 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1284 rbegin() const _NOEXCEPT {
11901285 return const_reverse_iterator(end());
11911286 }
1192 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
1193 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
1287 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() _NOEXCEPT {
1288 return reverse_iterator(begin());
1289 }
1290 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const _NOEXCEPT {
11941291 return const_reverse_iterator(begin());
11951292 }
11961293
1197 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
1198 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
1199 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
1200 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
1294 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const _NOEXCEPT {
1295 return begin();
1296 }
1297 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const _NOEXCEPT {
1298 return end();
1299 }
1300 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator
1301 crbegin() const _NOEXCEPT {
1302 return rbegin();
1303 }
1304 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const _NOEXCEPT {
1305 return rend();
1306 }
12011307
1202 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1203 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
1204 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
1308 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const _NOEXCEPT {
1309 return __tree_.size() == 0;
1310 }
1311 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT {
1312 return __tree_.size();
1313 }
1314 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
1315 return __tree_.max_size();
1316 }
12051317
12061318 // modifiers:
12071319# ifndef _LIBCPP_CXX03_LANG
12081320 template <class... _Args>
1209 _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) {
1321 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace(_Args&&... __args) {
12101322 return __tree_.__emplace_multi(std::forward<_Args>(__args)...);
12111323 }
12121324 template <class... _Args>
1213 _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
1325 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
12141326 return __tree_.__emplace_hint_multi(__p, std::forward<_Args>(__args)...);
12151327 }
12161328# endif // _LIBCPP_CXX03_LANG
12171329
1218 _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__emplace_multi(__v); }
1219 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
1330 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const value_type& __v) {
1331 return __tree_.__emplace_multi(__v);
1332 }
1333 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) {
12201334 return __tree_.__emplace_hint_multi(__p, __v);
12211335 }
12221336
12231337 template <class _InputIterator>
1224 _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
1338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
12251339 __tree_.__insert_range_multi(__first, __last);
12261340 }
12271341
12281342# if _LIBCPP_STD_VER >= 23
12291343 template <_ContainerCompatibleRange<value_type> _Range>
1230 _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
1344 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
12311345 __tree_.__insert_range_multi(ranges::begin(__range), ranges::end(__range));
12321346 }
12331347# endif
12341348
12351349# ifndef _LIBCPP_CXX03_LANG
1236 _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__emplace_multi(std::move(__v)); }
1350 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(value_type&& __v) {
1351 return __tree_.__emplace_multi(std::move(__v));
1352 }
12371353
1238 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
1354 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, value_type&& __v) {
12391355 return __tree_.__emplace_hint_multi(__p, std::move(__v));
12401356 }
12411357
1242 _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
1358 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
1359 insert(__il.begin(), __il.end());
1360 }
12431361# endif // _LIBCPP_CXX03_LANG
12441362
1245 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
1246 _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); }
1247 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
1248 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
1363 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) { return __tree_.erase(__p); }
1364 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) {
1365 return __tree_.__erase_multi(__k);
1366 }
1367 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) {
1368 return __tree_.erase(__f, __l);
1369 }
1370 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); }
12491371
12501372# if _LIBCPP_STD_VER >= 17
1251 _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) {
1373 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(node_type&& __nh) {
12521374 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
12531375 "node_type with incompatible allocator passed to multiset::insert()");
12541376 return __tree_.template __node_handle_insert_multi<node_type>(std::move(__nh));
12551377 }
1256 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
1378 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, node_type&& __nh) {
12571379 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
12581380 "node_type with incompatible allocator passed to multiset::insert()");
12591381 return __tree_.template __node_handle_insert_multi<node_type>(__hint, std::move(__nh));
12601382 }
1261 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
1383 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(key_type const& __key) {
12621384 return __tree_.template __node_handle_extract<node_type>(__key);
12631385 }
1264 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
1386 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(const_iterator __it) {
12651387 return __tree_.template __node_handle_extract<node_type>(__it);
12661388 }
12671389 template <class _Compare2>
1268 _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>& __source) {
1390 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1391 merge(multiset<key_type, _Compare2, allocator_type>& __source) {
12691392 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12701393 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12711394 __tree_.__node_handle_merge_multi(__source.__tree_);
12721395 }
12731396 template <class _Compare2>
1274 _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
1397 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
1398 merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
12751399 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12761400 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12771401 __tree_.__node_handle_merge_multi(__source.__tree_);
12781402 }
12791403 template <class _Compare2>
1280 _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>& __source) {
1404 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>& __source) {
12811405 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12821406 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12831407 __tree_.__node_handle_merge_multi(__source.__tree_);
12841408 }
12851409 template <class _Compare2>
1286 _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>&& __source) {
1410 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>&& __source) {
12871411 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
12881412 __source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
12891413 __tree_.__node_handle_merge_multi(__source.__tree_);
12901414 }
12911415# endif
12921416
1293 _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
1417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(multiset& __s)
1418 _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
12941419 __tree_.swap(__s.__tree_);
12951420 }
12961421
1297 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
1298 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
1299 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }
1422 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT {
1423 return __tree_.__alloc();
1424 }
1425 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const {
1426 return __tree_.value_comp();
1427 }
1428 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const {
1429 return __tree_.value_comp();
1430 }
13001431
13011432 // set operations:
1302 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
1303 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
1433 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __k) {
1434 return __tree_.find(__k);
1435 }
1436 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __k) const {
1437 return __tree_.find(__k);
1438 }
13041439# if _LIBCPP_STD_VER >= 14
1305 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1306 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
1440 template <typename _K2,
1441 class _Comp = _Compare,
1442 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1443 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _K2& __k) {
13071444 return __tree_.find(__k);
13081445 }
1309 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1310 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
1446 template <typename _K2,
1447 class _Comp = _Compare,
1448 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1449 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _K2& __k) const {
13111450 return __tree_.find(__k);
13121451 }
13131452# endif
13141453
1315 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const {
1454 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const {
13161455 return __tree_.__count_multi(__k);
13171456 }
13181457# if _LIBCPP_STD_VER >= 14
1319 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1320 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
1458 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1459 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _K2& __k) const {
13211460 return __tree_.__count_multi(__k);
13221461 }
13231462# endif
13241463
13251464# if _LIBCPP_STD_VER >= 20
1326 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1327 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1328 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
1465 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __k) const {
1466 return find(__k) != end();
1467 }
1468 template <typename _K2,
1469 class _Comp = _Compare,
1470 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1471 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _K2& __k) const {
13291472 return find(__k) != end();
13301473 }
13311474# endif // _LIBCPP_STD_VER >= 20
13321475
1333 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) {
1476 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) {
13341477 return __tree_.__lower_bound_multi(__k);
13351478 }
13361479
1337 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
1480 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1481 lower_bound(const key_type& __k) const {
13381482 return __tree_.__lower_bound_multi(__k);
13391483 }
13401484
13411485# if _LIBCPP_STD_VER >= 14
1342 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1343 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
1486 template <typename _K2,
1487 class _Comp = _Compare,
1488 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1489 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _K2& __k) {
13441490 return __tree_.__lower_bound_multi(__k);
13451491 }
13461492
1347 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1348 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
1493 template <typename _K2,
1494 class _Comp = _Compare,
1495 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1496 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1497 lower_bound(const _K2& __k) const {
13491498 return __tree_.__lower_bound_multi(__k);
13501499 }
13511500# endif
13521501
1353 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) {
1502 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) {
13541503 return __tree_.__upper_bound_multi(__k);
13551504 }
13561505
1357 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const {
1506 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1507 upper_bound(const key_type& __k) const {
13581508 return __tree_.__upper_bound_multi(__k);
13591509 }
13601510
13611511# if _LIBCPP_STD_VER >= 14
1362 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1363 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
1512 template <typename _K2,
1513 class _Comp = _Compare,
1514 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1515 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _K2& __k) {
13641516 return __tree_.__upper_bound_multi(__k);
13651517 }
1366 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1367 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
1518 template <typename _K2,
1519 class _Comp = _Compare,
1520 enable_if_t<__is_transparent_v<_Comp> || __is_transparently_comparable_v<_Comp, key_type, _K2>, int> = 0>
1521 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
1522 upper_bound(const _K2& __k) const {
13681523 return __tree_.__upper_bound_multi(__k);
13691524 }
13701525# endif
13711526
1372 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
1527 [[__nodiscard__]]
1528 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __k) {
13731529 return __tree_.__equal_range_multi(__k);
13741530 }
1375 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
1531 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1532 equal_range(const key_type& __k) const {
13761533 return __tree_.__equal_range_multi(__k);
13771534 }
13781535# if _LIBCPP_STD_VER >= 14
1379 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1380 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
1536 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1537 [[__nodiscard__]]
1538 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _K2& __k) {
13811539 return __tree_.__equal_range_multi(__k);
13821540 }
1383 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
1384 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
1541 template <typename _K2, class _Comp = _Compare, enable_if_t<__is_transparent_v<_Comp>, int> = 0>
1542 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
1543 equal_range(const _K2& __k) const {
13851544 return __tree_.__equal_range_multi(__k);
13861545 }
13871546# endif
......@@ -1445,7 +1604,7 @@ struct __specialized_algorithm<_Alg, __single_range<multiset<_Key, _Compare, _Al
14451604
14461605 // set's begin() and end() are identical with and without const qualification
14471606 template <class... _Args>
1448 _LIBCPP_HIDE_FROM_ABI static auto operator()(const __set& __set, _Args&&... __args) {
1607 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static auto operator()(const __set& __set, _Args&&... __args) {
14491608 return __specialized_algorithm<_Alg, __single_range<typename __set::__base>>()(
14501609 __set.__tree_, std::forward<_Args>(__args)...);
14511610 }
......@@ -1453,7 +1612,7 @@ struct __specialized_algorithm<_Alg, __single_range<multiset<_Key, _Compare, _Al
14531612# endif
14541613
14551614template <class _Key, class _Compare, class _Allocator>
1456inline _LIBCPP_HIDE_FROM_ABI bool
1615inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14571616operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14581617 return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
14591618}
......@@ -1461,31 +1620,31 @@ operator==(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,
14611620# if _LIBCPP_STD_VER <= 17
14621621
14631622template <class _Key, class _Compare, class _Allocator>
1464inline _LIBCPP_HIDE_FROM_ABI bool
1623inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14651624operator<(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14661625 return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
14671626}
14681627
14691628template <class _Key, class _Compare, class _Allocator>
1470inline _LIBCPP_HIDE_FROM_ABI bool
1629inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14711630operator!=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14721631 return !(__x == __y);
14731632}
14741633
14751634template <class _Key, class _Compare, class _Allocator>
1476inline _LIBCPP_HIDE_FROM_ABI bool
1635inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14771636operator>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14781637 return __y < __x;
14791638}
14801639
14811640template <class _Key, class _Compare, class _Allocator>
1482inline _LIBCPP_HIDE_FROM_ABI bool
1641inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14831642operator>=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14841643 return !(__x < __y);
14851644}
14861645
14871646template <class _Key, class _Compare, class _Allocator>
1488inline _LIBCPP_HIDE_FROM_ABI bool
1647inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
14891648operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14901649 return !(__y < __x);
14911650}
......@@ -1493,7 +1652,7 @@ operator<=(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key,
14931652# else // _LIBCPP_STD_VER <= 17
14941653
14951654template <class _Key, class _Compare, class _Allocator>
1496_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
1655_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<_Key>
14971656operator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key, _Compare, _Allocator>& __y) {
14981657 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
14991658}
......@@ -1501,7 +1660,7 @@ operator<=>(const multiset<_Key, _Compare, _Allocator>& __x, const multiset<_Key
15011660# endif // _LIBCPP_STD_VER <= 17
15021661
15031662template <class _Key, class _Compare, class _Allocator>
1504inline _LIBCPP_HIDE_FROM_ABI void
1663inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
15051664swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Allocator>& __y)
15061665 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
15071666 __x.swap(__y);
......@@ -1509,7 +1668,7 @@ swap(multiset<_Key, _Compare, _Allocator>& __x, multiset<_Key, _Compare, _Alloca
15091668
15101669# if _LIBCPP_STD_VER >= 20
15111670template <class _Key, class _Compare, class _Allocator, class _Predicate>
1512inline _LIBCPP_HIDE_FROM_ABI typename multiset<_Key, _Compare, _Allocator>::size_type
1671inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename multiset<_Key, _Compare, _Allocator>::size_type
15131672erase_if(multiset<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
15141673 return std::__libcpp_erase_if_container(__c, __pred);
15151674}
......@@ -1541,7 +1700,7 @@ _LIBCPP_END_NAMESPACE_STD
15411700
15421701_LIBCPP_POP_MACROS
15431702
1544# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1703# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
15451704# include <concepts>
15461705# include <cstdlib>
15471706# include <functional>
lib/libcxx/include/shared_mutex+34-24
......@@ -153,6 +153,7 @@ _LIBCPP_PUSH_MACROS
153153# endif
154154
155155_LIBCPP_BEGIN_NAMESPACE_STD
156_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
156157
157158struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {
158159 mutex __mut_;
......@@ -196,12 +197,14 @@ public:
196197
197198 // Exclusive ownership
198199 _LIBCPP_ACQUIRE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI void lock() { return __base_.lock(); }
199 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock() { return __base_.try_lock(); }
200 _LIBCPP_RELEASE_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock() { return __base_.unlock(); }
200 [[nodiscard]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock() {
201 return __base_.try_lock();
202 }
203 _LIBCPP_RELEASE_CAPABILITY() _LIBCPP_HIDE_FROM_ABI void unlock() { return __base_.unlock(); }
201204
202205 // Shared ownership
203206 _LIBCPP_ACQUIRE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void lock_shared() { return __base_.lock_shared(); }
204 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock_shared() {
207 [[nodiscard]] _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool try_lock_shared() {
205208 return __base_.try_lock_shared();
206209 }
207210 _LIBCPP_RELEASE_SHARED_CAPABILITY _LIBCPP_HIDE_FROM_ABI void unlock_shared() { return __base_.unlock_shared(); }
......@@ -223,15 +226,15 @@ public:
223226
224227 // Exclusive ownership
225228 void lock() _LIBCPP_ACQUIRE_CAPABILITY();
226 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock();
229 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) bool try_lock();
227230 template <class _Rep, class _Period>
228 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
231 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
229232 try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) {
230233 return try_lock_until(chrono::steady_clock::now() + __rel_time);
231234 }
232235
233236 template <class _Clock, class _Duration>
234 _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
237 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
235238 try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {
236239 unique_lock<mutex> __lk(__base_.__mut_);
237240 if (__base_.__state_ & __base_.__write_entered_) {
......@@ -259,19 +262,19 @@ public:
259262 return true;
260263 }
261264
262 _LIBCPP_RELEASE_CAPABILITY void unlock();
265 _LIBCPP_RELEASE_CAPABILITY() void unlock();
263266
264267 // Shared ownership
265268 _LIBCPP_ACQUIRE_SHARED_CAPABILITY void lock_shared();
266 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) bool try_lock_shared();
269 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) bool try_lock_shared();
267270 template <class _Rep, class _Period>
268 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
271 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
269272 try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) {
270273 return try_lock_shared_until(chrono::steady_clock::now() + __rel_time);
271274 }
272275
273276 template <class _Clock, class _Duration>
274 _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
277 [[__nodiscard__]] _LIBCPP_TRY_ACQUIRE_SHARED_CAPABILITY(true) _LIBCPP_HIDE_FROM_ABI bool
275278 try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time) {
276279 unique_lock<mutex> __lk(__base_.__mut_);
277280 if ((__base_.__state_ & __base_.__write_entered_) ||
......@@ -304,27 +307,31 @@ private:
304307 bool __owns_;
305308
306309public:
307 _LIBCPP_HIDE_FROM_ABI shared_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
310 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
308311
309 _LIBCPP_HIDE_FROM_ABI explicit shared_lock(mutex_type& __m) : __m_(std::addressof(__m)), __owns_(true) {
312 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI explicit shared_lock(mutex_type& __m)
313 : __m_(std::addressof(__m)), __owns_(true) {
310314 __m_->lock_shared();
311315 }
312316
313 _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
317 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
314318 : __m_(std::addressof(__m)),
315319 __owns_(false) {}
316320
317 _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, try_to_lock_t)
321 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, try_to_lock_t)
318322 : __m_(std::addressof(__m)), __owns_(__m.try_lock_shared()) {}
319323
320 _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, adopt_lock_t) : __m_(std::addressof(__m)), __owns_(true) {}
324 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, adopt_lock_t)
325 : __m_(std::addressof(__m)), __owns_(true) {}
321326
322327 template <class _Clock, class _Duration>
323 _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __abs_time)
328 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
329 shared_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __abs_time)
324330 : __m_(std::addressof(__m)), __owns_(__m.try_lock_shared_until(__abs_time)) {}
325331
326332 template <class _Rep, class _Period>
327 _LIBCPP_HIDE_FROM_ABI shared_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __rel_time)
333 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI
334 shared_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __rel_time)
328335 : __m_(std::addressof(__m)), __owns_(__m.try_lock_shared_for(__rel_time)) {}
329336
330337 _LIBCPP_HIDE_FROM_ABI ~shared_lock() {
......@@ -335,7 +342,9 @@ public:
335342 shared_lock(shared_lock const&) = delete;
336343 shared_lock& operator=(shared_lock const&) = delete;
337344
338 _LIBCPP_HIDE_FROM_ABI shared_lock(shared_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) {
345 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI shared_lock(shared_lock&& __u) _NOEXCEPT
346 : __m_(__u.__m_),
347 __owns_(__u.__owns_) {
339348 __u.__m_ = nullptr;
340349 __u.__owns_ = false;
341350 }
......@@ -347,11 +356,11 @@ public:
347356 }
348357
349358 _LIBCPP_HIDE_FROM_ABI void lock();
350 _LIBCPP_HIDE_FROM_ABI bool try_lock();
359 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock();
351360 template <class _Rep, class _Period>
352 _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time);
361 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time);
353362 template <class _Clock, class _Duration>
354 _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
363 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time);
355364 _LIBCPP_HIDE_FROM_ABI void unlock();
356365
357366 // Setters
......@@ -368,11 +377,11 @@ public:
368377 }
369378
370379 // Getters
371 _LIBCPP_HIDE_FROM_ABI bool owns_lock() const _NOEXCEPT { return __owns_; }
380 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool owns_lock() const _NOEXCEPT { return __owns_; }
372381
373382 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __owns_; }
374383
375 _LIBCPP_HIDE_FROM_ABI mutex_type* mutex() const _NOEXCEPT { return __m_; }
384 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI mutex_type* mutex() const _NOEXCEPT { return __m_; }
376385};
377386_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(shared_lock);
378387
......@@ -431,6 +440,7 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu
431440 __x.swap(__y);
432441}
433442
443_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
434444_LIBCPP_END_NAMESPACE_STD
435445
436446# endif // _LIBCPP_STD_VER >= 14
......@@ -439,7 +449,7 @@ _LIBCPP_POP_MACROS
439449
440450# endif // _LIBCPP_HAS_THREADS
441451
442# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
452# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
443453# include <optional>
444454# include <system_error>
445455# endif
lib/libcxx/include/source_location+4-4
......@@ -36,10 +36,10 @@ namespace std {
3636# pragma GCC system_header
3737# endif
3838
39_LIBCPP_BEGIN_NAMESPACE_STD
40
4139# if _LIBCPP_STD_VER >= 20
4240
41_LIBCPP_BEGIN_NAMESPACE_STD
42
4343class source_location {
4444 // The names source_location::__impl, _M_file_name, _M_function_name, _M_line, and _M_column
4545 // are hard-coded in the compiler and must not be changed here.
......@@ -81,10 +81,10 @@ public:
8181 }
8282};
8383
84# endif // _LIBCPP_STD_VER >= 20
85
8684_LIBCPP_END_NAMESPACE_STD
8785
86# endif // _LIBCPP_STD_VER >= 20
87
8888#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
8989
9090#endif // _LIBCPP_SOURCE_LOCATION
lib/libcxx/include/span+15-36
......@@ -19,16 +19,16 @@ namespace std {
1919inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
2020
2121template<class T>
22 concept integral-constant-like = // exposition only, since C++26
23 is_integral_v<decltype(T::value)> &&
24 !is_same_v<bool, remove_const_t<decltype(T::value)>> &&
22 concept integral-constant-like = // exposition only
23 is_integral_v<remove_cvref_t<decltype(T::value)>> &&
24 !is_same_v<bool, remove_cvref_t<decltype(T::value)>> &&
2525 convertible_to<T, decltype(T::value)> &&
2626 equality_comparable_with<T, decltype(T::value)> &&
2727 bool_constant<T() == T::value>::value &&
2828 bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value;
2929
3030template<class T>
31 constexpr size_t maybe-static-ext = dynamic_extent; // exposition only, since C++26
31 constexpr size_t maybe-static-ext = dynamic_extent; // exposition only
3232template<integral-constant-like T>
3333 constexpr size_t maybe-static-ext<T> = {T::value};
3434
......@@ -82,7 +82,6 @@ public:
8282 constexpr span(const array<value_type, N>& arr) noexcept;
8383 template<class R>
8484 constexpr explicit(Extent != dynamic_extent) span(R&& r);
85 constexpr explicit(extent != dynamic_extent) span(std::initializer_list<value_type> il); // Since C++26
8685 constexpr span(const span& other) noexcept = default;
8786 template <class OtherElementType, size_t OtherExtent>
8887 constexpr explicit(Extent != dynamic_extent) span(const span<OtherElementType, OtherExtent>& s) noexcept;
......@@ -124,9 +123,7 @@ private:
124123};
125124
126125template<class It, class EndOrSize>
127 span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>; // until C++26
128template<class It, class EndOrSize>
129 span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>, maybe-static-ext<EndOrSize>>; // since C++26
126 span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<It>>, maybe-static-ext<EndOrSize>>;
130127
131128template<class T, size_t N>
132129 span(T (&)[N]) -> span<T, N>;
......@@ -153,6 +150,7 @@ template<class R>
153150# include <__config>
154151# include <__cstddef/byte.h>
155152# include <__cstddef/ptrdiff_t.h>
153# include <__cstddef/size_t.h>
156154# include <__fwd/array.h>
157155# include <__fwd/span.h>
158156# include <__iterator/bounded_iter.h>
......@@ -172,13 +170,13 @@ template<class R>
172170# include <__type_traits/is_convertible.h>
173171# include <__type_traits/is_integral.h>
174172# include <__type_traits/is_same.h>
173# include <__type_traits/is_volatile.h>
175174# include <__type_traits/remove_const.h>
176175# include <__type_traits/remove_cv.h>
177176# include <__type_traits/remove_cvref.h>
178177# include <__type_traits/remove_reference.h>
179178# include <__type_traits/type_identity.h>
180179# include <__utility/forward.h>
181# include <initializer_list>
182180# include <stdexcept>
183181# include <version>
184182
......@@ -198,10 +196,10 @@ template<class R>
198196_LIBCPP_PUSH_MACROS
199197# include <__undef_macros>
200198
201_LIBCPP_BEGIN_NAMESPACE_STD
202
203199# if _LIBCPP_STD_VER >= 20
204200
201_LIBCPP_BEGIN_NAMESPACE_STD
202
205203template <class _Tp>
206204struct __is_std_span : false_type {};
207205
......@@ -254,15 +252,6 @@ public:
254252 requires(_Sz == 0)
255253 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr} {}
256254
257# if _LIBCPP_STD_VER >= 26
258 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(std::initializer_list<value_type> __il)
259 requires is_const_v<element_type>
260 : __data_{__il.begin()} {
261 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
262 _Extent == __il.size(), "Size mismatch in span's constructor _Extent != __il.size().");
263 }
264# endif
265
266255 constexpr span(const span&) noexcept = default;
267256 constexpr span& operator=(const span&) noexcept = default;
268257
......@@ -443,12 +432,6 @@ public:
443432 // [span.cons], span constructors, copy, assignment, and destructor
444433 _LIBCPP_HIDE_FROM_ABI constexpr span() noexcept : __data_{nullptr}, __size_{0} {}
445434
446# if _LIBCPP_STD_VER >= 26
447 _LIBCPP_HIDE_FROM_ABI constexpr span(std::initializer_list<value_type> __il)
448 requires is_const_v<element_type>
449 : __data_{__il.begin()}, __size_{__il.size()} {}
450# endif
451
452435 constexpr span(const span&) noexcept = default;
453436 constexpr span& operator=(const span&) noexcept = default;
454437
......@@ -601,20 +584,20 @@ inline constexpr bool ranges::enable_view<span<_ElementType, _Extent>> = true;
601584
602585// as_bytes & as_writable_bytes
603586template <class _Tp, size_t _Extent>
587 requires(!is_volatile_v<_Tp>)
604588[[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto as_bytes(span<_Tp, _Extent> __s) noexcept {
605589 return __s.__as_bytes();
606590}
607591
608592template <class _Tp, size_t _Extent>
609 requires(!is_const_v<_Tp>)
593 requires(!is_const_v<_Tp> && !is_volatile_v<_Tp>)
610594[[nodiscard]] _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept {
611595 return __s.__as_writable_bytes();
612596}
613597
614# if _LIBCPP_STD_VER >= 26
615598template <class _Tp>
616599concept __integral_constant_like =
617 is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> &&
600 is_integral_v<remove_cvref_t<decltype(_Tp::value)>> && !is_same_v<bool, remove_cvref_t<decltype(_Tp::value)>> &&
618601 convertible_to<_Tp, decltype(_Tp::value)> && equality_comparable_with<_Tp, decltype(_Tp::value)> &&
619602 bool_constant<_Tp() == _Tp::value>::value &&
620603 bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>::value;
......@@ -627,10 +610,6 @@ inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value};
627610
628611template <contiguous_iterator _It, class _EndOrSize>
629612span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>;
630# else
631template <contiguous_iterator _It, class _EndOrSize>
632span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
633# endif
634613
635614template <class _Tp, size_t _Sz>
636615span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
......@@ -644,13 +623,13 @@ span(const array<_Tp, _Sz>&) -> span<const _Tp, _Sz>;
644623template <ranges::contiguous_range _Range>
645624span(_Range&&) -> span<remove_reference_t<ranges::range_reference_t<_Range>>>;
646625
647# endif // _LIBCPP_STD_VER >= 20
648
649626_LIBCPP_END_NAMESPACE_STD
650627
628# endif // _LIBCPP_STD_VER >= 20
629
651630_LIBCPP_POP_MACROS
652631
653# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
632# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
654633# include <array>
655634# include <concepts>
656635# include <functional>
lib/libcxx/include/sstream+3-1
......@@ -338,6 +338,7 @@ _LIBCPP_PUSH_MACROS
338338# include <__undef_macros>
339339
340340_LIBCPP_BEGIN_NAMESPACE_STD
341_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
341342
342343// Class template basic_stringbuf [stringbuf]
343344
......@@ -1288,13 +1289,14 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostringstream<char>
12881289extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_istringstream<char>;
12891290# endif
12901291
1292_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
12911293_LIBCPP_END_NAMESPACE_STD
12921294
12931295_LIBCPP_POP_MACROS
12941296
12951297# endif // _LIBCPP_HAS_LOCALIZATION
12961298
1297# if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
1299# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
12981300# include <ostream>
12991301# include <type_traits>
13001302# endif
lib/libcxx/include/stack+1-1
......@@ -377,7 +377,7 @@ _LIBCPP_END_NAMESPACE_STD
377377
378378_LIBCPP_POP_MACROS
379379
380# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
380# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
381381# include <concepts>
382382# include <functional>
383383# include <type_traits>
lib/libcxx/include/stdatomic.h+1-1
......@@ -231,7 +231,7 @@ using std::atomic_store_explicit _LIBCPP_USING_IF_EXISTS;
231231using std::atomic_signal_fence _LIBCPP_USING_IF_EXISTS;
232232using std::atomic_thread_fence _LIBCPP_USING_IF_EXISTS;
233233
234# elif defined(_LIBCPP_COMPILER_CLANG_BASED)
234# elif !defined(__cplusplus) || defined(_LIBCPP_COMPILER_CLANG_BASED)
235235
236236// Before C++23, we include the next <stdatomic.h> on the path to avoid hijacking
237237// the header. We do this because Clang has historically shipped a <stdatomic.h>
lib/libcxx/include/stdbool.h deleted-44
......@@ -1,44 +0,0 @@
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_STDBOOL_H
11#define _LIBCPP_STDBOOL_H
12
13/*
14 stdbool.h synopsis
15
16Macros:
17
18 __bool_true_false_are_defined
19
20*/
21
22#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
23# include <__cxx03/stdbool.h>
24#else
25# include <__config>
26
27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29# endif
30
31# if __has_include_next(<stdbool.h>)
32# include_next <stdbool.h>
33# endif
34
35# ifdef __cplusplus
36# undef bool
37# undef true
38# undef false
39# undef __bool_true_false_are_defined
40# define __bool_true_false_are_defined 1
41# endif
42#endif // defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
43
44#endif // _LIBCPP_STDBOOL_H
lib/libcxx/include/stdexcept+3-1
......@@ -212,7 +212,9 @@ public:
212212_LIBCPP_BEGIN_NAMESPACE_STD
213213
214214// in the dylib
215_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
215216[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*);
217_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
216218
217219[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) {
218220# if _LIBCPP_HAS_EXCEPTIONS
......@@ -280,7 +282,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
280282
281283_LIBCPP_END_NAMESPACE_STD
282284
283# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
285# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
284286# include <cstddef>
285287# include <cstdlib>
286288# include <exception>
lib/libcxx/include/stop_token+5-1
......@@ -52,7 +52,11 @@ namespace std {
5252
5353# endif // _LIBCPP_HAS_THREADS
5454
55# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
55# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
56# include <atomic>
57# endif
58
59# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
5660# include <cstddef>
5761# include <iosfwd>
5862# endif
lib/libcxx/include/streambuf+4-2
......@@ -117,8 +117,8 @@ protected:
117117# include <__assert>
118118# include <__fwd/streambuf.h>
119119# include <__locale>
120# include <__memory/valid_range.h>
120121# include <__type_traits/is_same.h>
121# include <__utility/is_valid_range.h>
122122# include <__utility/scope_guard.h>
123123# include <climits>
124124# include <ios>
......@@ -133,6 +133,7 @@ _LIBCPP_PUSH_MACROS
133133# include <__undef_macros>
134134
135135_LIBCPP_BEGIN_NAMESPACE_STD
136_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
136137
137138template <class _CharT, class _Traits>
138139class basic_streambuf {
......@@ -430,13 +431,14 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
430431extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
431432# endif
432433
434_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
433435_LIBCPP_END_NAMESPACE_STD
434436
435437_LIBCPP_POP_MACROS
436438
437439# endif // _LIBCPP_HAS_LOCALIZATION
438440
439# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
441# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
440442# include <cstdint>
441443# include <optional>
442444# endif
lib/libcxx/include/string+164-224
......@@ -201,6 +201,7 @@ public:
201201 basic_string& append(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
202202 basic_string& append(const value_type* s, size_type n); // constexpr since C++20
203203 basic_string& append(const value_type* s); // constexpr since C++20
204 basic_string& append(const value_type* s, size_type pos, size_type n); // constexpr since C++20
204205 basic_string& append(size_type n, value_type c); // constexpr since C++20
205206 template<class InputIterator>
206207 basic_string& append(InputIterator first, InputIterator last); // constexpr since C++20
......@@ -224,6 +225,7 @@ public:
224225 basic_string& assign(const T& t, size_type pos, size_type n=npos); // C++17, constexpr since C++20
225226 basic_string& assign(const value_type* s, size_type n); // constexpr since C++20
226227 basic_string& assign(const value_type* s); // constexpr since C++20
228 basic_string& assign(const value_type* s, size_type pos, size_type n); // constexpr since C++20
227229 basic_string& assign(size_type n, value_type c); // constexpr since C++20
228230 template<class InputIterator>
229231 basic_string& assign(InputIterator first, InputIterator last); // constexpr since C++20
......@@ -597,6 +599,7 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
597599# include <__algorithm/remove_if.h>
598600# include <__assert>
599601# include <__config>
602# include <__cstddef/size_t.h>
600603# include <__debug_utils/sanitizers.h>
601604# include <__format/enable_insertable.h>
602605# include <__functional/hash.h>
......@@ -625,9 +628,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
625628# include <__string/char_traits.h>
626629# include <__string/extern_template_lists.h>
627630# include <__type_traits/conditional.h>
631# include <__type_traits/desugars_to.h>
628632# include <__type_traits/enable_if.h>
629633# include <__type_traits/is_allocator.h>
630634# include <__type_traits/is_array.h>
635# include <__type_traits/is_constant_evaluated.h>
631636# include <__type_traits/is_convertible.h>
632637# include <__type_traits/is_generic_transparent_comparator.h>
633638# include <__type_traits/is_nothrow_assignable.h>
......@@ -637,9 +642,11 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
637642# include <__type_traits/is_trivially_constructible.h>
638643# include <__type_traits/is_trivially_copyable.h>
639644# include <__type_traits/is_trivially_relocatable.h>
645# include <__type_traits/remove_cv.h>
640646# include <__type_traits/remove_cvref.h>
641647# include <__utility/default_three_way_comparator.h>
642648# include <__utility/exception_guard.h>
649# include <__utility/exchange.h>
643650# include <__utility/forward.h>
644651# include <__utility/is_pointer_in_range.h>
645652# include <__utility/move.h>
......@@ -678,18 +685,18 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
678685_LIBCPP_PUSH_MACROS
679686# include <__undef_macros>
680687
681# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
682# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address")))
683// This macro disables AddressSanitizer (ASan) instrumentation for a specific function,
684// allowing memory accesses that would normally trigger ASan errors to proceed without crashing.
685// This is useful for accessing parts of objects memory, which should not be accessed,
686// such as unused bytes in short strings, that should never be accessed
687// by other parts of the program.
688// Since std::string is partially instantiated in the built library, we require that the library
689// has been built with ASAN support in order to enable the container checks in std::string.
690// Within the <string> implementation, use `_LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS_FOR_STRING`
691// to determine whether ASAN container checks should be provided.
692# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS && _LIBCPP_INSTRUMENTED_WITH_ASAN
693# define _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS_FOR_STRING 1
688694# else
689# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
695# define _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS_FOR_STRING 0
690696# endif
691697
692698_LIBCPP_BEGIN_NAMESPACE_STD
699_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
693700
694701// basic_string
695702
......@@ -749,44 +756,10 @@ public:
749756 //
750757 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether
751758 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
752# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
753 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
754 // relocatable. Because the object's memory might be poisoned when its content
755 // is kept inside objects memory (short string optimization), instead of in allocated
756 // external memory. In such cases, the destructor is responsible for unpoisoning
757 // the memory to avoid triggering false positives.
758 // Therefore it's crucial to ensure the destructor is called.
759 using __trivially_relocatable _LIBCPP_NODEBUG = void;
760# else
761759 using __trivially_relocatable _LIBCPP_NODEBUG = __conditional_t<
762760 __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,
763761 basic_string,
764762 void>;
765# endif
766
767# if __has_feature(address_sanitizer) && _LIBCPP_INSTRUMENTED_WITH_ASAN
768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
769 if (__libcpp_is_constant_evaluated())
770 return __ptr;
771
772 pointer volatile __copy_ptr = __ptr;
773
774 return const_cast<pointer&>(__copy_ptr);
775 }
776
777 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer
778 __asan_volatile_wrapper(const_pointer const& __ptr) const {
779 if (__libcpp_is_constant_evaluated())
780 return __ptr;
781
782 const_pointer volatile __copy_ptr = __ptr;
783
784 return const_cast<const_pointer&>(__copy_ptr);
785 }
786# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)
787# else
788# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR
789# endif
790763
791764 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
792765 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
......@@ -803,8 +776,8 @@ public:
803776 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
804777 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
805778 // considered contiguous.
806 using iterator = __bounded_iter<__wrap_iter<pointer> >;
807 using const_iterator = __bounded_iter<__wrap_iter<const_pointer> >;
779 using iterator = __bounded_iter<pointer>;
780 using const_iterator = __bounded_iter<const_pointer>;
808781# else
809782 using iterator = __wrap_iter<pointer>;
810783 using const_iterator = __wrap_iter<const_pointer>;
......@@ -949,10 +922,7 @@ private:
949922 // regardless of whether reallocation occurs. This allows us to check for out-of-bounds accesses using logical size,
950923 // a stricter check, since correct code can never rely on being able to access newly-added elements via an existing
951924 // iterator.
952 return std::__make_bounded_iter(
953 std::__wrap_iter<pointer>(__p),
954 std::__wrap_iter<pointer>(__get_pointer()),
955 std::__wrap_iter<pointer>(__get_pointer() + size()));
925 return std::__make_bounded_iter(__p, __get_pointer(), __get_pointer() + size());
956926# else
957927 return iterator(__p);
958928# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
......@@ -961,10 +931,7 @@ private:
961931 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {
962932# ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
963933 // Bound the iterator according to the size (and not the capacity, unlike vector).
964 return std::__make_bounded_iter(
965 std::__wrap_iter<const_pointer>(__p),
966 std::__wrap_iter<const_pointer>(__get_pointer()),
967 std::__wrap_iter<const_pointer>(__get_pointer() + size()));
934 return std::__make_bounded_iter(__p, __get_pointer(), __get_pointer() + size());
968935# else
969936 return const_iterator(__p);
970937# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
......@@ -975,12 +942,7 @@ public:
975942
976943 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string()
977944 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
978# if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567
979 : __rep_(__short())
980# else
981 : __rep_()
982# endif
983 {
945 : __rep_() {
984946 __annotate_new(0);
985947 }
986948
......@@ -990,16 +952,11 @@ public:
990952# else
991953 _NOEXCEPT
992954# endif
993# if _LIBCPP_STD_VER >= 20 // TODO(LLVM 23): Remove this condition; this is a workaround for https://llvm.org/PR154567
994 : __rep_(__short()),
995# else
996 : __rep_(),
997# endif
998 __alloc_(__a) {
955 : __rep_(), __alloc_(__a) {
999956 __annotate_new(0);
1000957 }
1001958
1002 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string(const basic_string& __str)
959 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str)
1003960 : __alloc_(__alloc_traits::select_on_container_copy_construction(__str.__alloc_)) {
1004961 if (!__str.__is_long()) {
1005962 __rep_ = __str.__rep_;
......@@ -1008,9 +965,7 @@ public:
1008965 __init_copy_ctor_external(std::__to_address(__str.__get_long_pointer()), __str.__get_long_size());
1009966 }
1010967
1011 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
1012 basic_string(const basic_string& __str, const allocator_type& __a)
1013 : __alloc_(__a) {
968 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const basic_string& __str, const allocator_type& __a) : __alloc_(__a) {
1014969 if (!__str.__is_long()) {
1015970 __rep_ = __str.__rep_;
1016971 __annotate_new(__get_short_size());
......@@ -1025,15 +980,7 @@ public:
1025980# else
1026981 _NOEXCEPT
1027982# endif
1028 // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
1029 // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.
1030 // __str's memory needs to be unpoisoned only in the case where it's a short string.
1031 : __rep_([](basic_string& __s) -> decltype(__s.__rep_)&& {
1032 if (!__s.__is_long())
1033 __s.__annotate_delete();
1034 return std::move(__s.__rep_);
1035 }(__str)),
1036 __alloc_(std::move(__str.__alloc_)) {
983 : __rep_(std::move(__str.__rep_)), __alloc_(std::move(__str.__alloc_)) {
1037984 __str.__rep_ = __rep();
1038985 __str.__annotate_new(0);
1039986 if (!__is_long())
......@@ -1058,15 +1005,9 @@ public:
10581005 }
10591006# endif // _LIBCPP_CXX03_LANG
10601007
1061 template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
1062 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s) {
1063 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*) detected nullptr");
1064 __init(__s, traits_type::length(__s));
1065 }
1066
10671008 template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
10681009 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1069 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a)
1010 basic_string(const _CharT* _LIBCPP_DIAGNOSE_NULLPTR __s, const _Allocator& __a = _Allocator())
10701011 : __alloc_(__a) {
10711012 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
10721013 __init(__s, traits_type::length(__s));
......@@ -1076,22 +1017,14 @@ public:
10761017 basic_string(nullptr_t) = delete;
10771018# endif
10781019
1079 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n)
1080 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero") {
1081 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr");
1082 __init(__s, __n);
1083 }
1084
1085 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1086 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
1020 _LIBCPP_HIDE_FROM_ABI
1021 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(const _CharT* __s, size_type __n, const _Allocator& __a = _Allocator())
10871022 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero")
10881023 : __alloc_(__a) {
10891024 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr");
10901025 __init(__s, __n);
10911026 }
10921027
1093 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c) { __init(__n, __c); }
1094
10951028# if _LIBCPP_STD_VER >= 23
10961029 _LIBCPP_HIDE_FROM_ABI constexpr basic_string(
10971030 basic_string&& __str, size_type __pos, const _Allocator& __alloc = _Allocator())
......@@ -1114,7 +1047,8 @@ public:
11141047# endif
11151048
11161049 template <__enable_if_t<__is_allocator_v<_Allocator>, int> = 0>
1117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a)
1050 _LIBCPP_HIDE_FROM_ABI
1051 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(size_type __n, _CharT __c, const _Allocator& __a = _Allocator())
11181052 : __alloc_(__a) {
11191053 __init(__n, __c);
11201054 }
......@@ -1153,29 +1087,16 @@ public:
11531087 __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> &&
11541088 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
11551089 int> = 0>
1156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t) {
1157 __self_view __sv = __t;
1158 __init(__sv.data(), __sv.size());
1159 }
1160
1161 template <class _Tp,
1162 __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> &&
1163 !is_same<__remove_cvref_t<_Tp>, basic_string>::value,
1164 int> = 0>
1165 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
1090 _LIBCPP_HIDE_FROM_ABI
1091 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a = allocator_type())
11661092 : __alloc_(__a) {
11671093 __self_view __sv = __t;
11681094 __init(__sv.data(), __sv.size());
11691095 }
11701096
1171 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
1172 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(_InputIterator __first, _InputIterator __last) {
1173 __init(__first, __last);
1174 }
1175
11761097 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
11771098 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1178 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a)
1099 basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type())
11791100 : __alloc_(__a) {
11801101 __init(__first, __last);
11811102 }
......@@ -1194,11 +1115,8 @@ public:
11941115# endif
11951116
11961117# ifndef _LIBCPP_CXX03_LANG
1197 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il) {
1198 __init(__il.begin(), __il.end());
1199 }
1200
1201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a)
1118 _LIBCPP_HIDE_FROM_ABI
1119 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string(initializer_list<_CharT> __il, const _Allocator& __a = _Allocator())
12021120 : __alloc_(__a) {
12031121 __init(__il.begin(), __il.end());
12041122 }
......@@ -1213,8 +1131,7 @@ public:
12131131 return __self_view(typename __self_view::__assume_valid(), data(), size());
12141132 }
12151133
1216 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string&
1217 operator=(const basic_string& __str);
1134 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(const basic_string& __str);
12181135
12191136 template <class _Tp,
12201137 __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp> &&
......@@ -1427,6 +1344,8 @@ public:
14271344 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n)
14281345 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero");
14291346 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1347 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __pos, size_type __n)
1348 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero");
14301349 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(size_type __n, value_type __c);
14311350
14321351 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
......@@ -1450,7 +1369,7 @@ public:
14501369 if (__cap - __sz < __n)
14511370 __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
14521371 __annotate_increase(__n);
1453 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz));
1372 auto __end = __copy_non_overlapping_range(__first, __last, __data() + __sz);
14541373 traits_type::assign(*__end, value_type());
14551374 __set_size(__sz + __n);
14561375 return *this;
......@@ -1510,8 +1429,7 @@ public:
15101429 size_type __old_sz = __str.size();
15111430 if (!__str.__is_long())
15121431 __str.__annotate_delete();
1513 __rep_ = __str.__rep_;
1514 __str.__rep_ = __rep();
1432 __rep_ = std::__exchange(__str.__rep_, __rep());
15151433 __str.__annotate_new(0);
15161434
15171435 _Traits::move(data(), data() + __pos, __len);
......@@ -1554,6 +1472,8 @@ public:
15541472 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __n)
15551473 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero");
15561474 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s);
1475 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(const value_type* __s, size_type __pos, size_type __n)
1476 _LIBCPP_DIAGNOSE_NULLPTR_IF(__n != 0 && __s == nullptr, " if n is not zero");
15571477 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(size_type __n, value_type __c);
15581478
15591479 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
......@@ -1807,6 +1727,13 @@ public:
18071727 }
18081728# endif
18091729
1730 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* __data() const _NOEXCEPT {
1731 return std::__to_address(__get_pointer());
1732 }
1733 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 value_type* __data() _NOEXCEPT {
1734 return std::__to_address(__get_pointer());
1735 }
1736
18101737 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator_type get_allocator() const _NOEXCEPT {
18111738 return __alloc_;
18121739 }
......@@ -1815,14 +1742,14 @@ public:
18151742
18161743 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18171744 find(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1818 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __str.data(), __pos, __str.size());
1745 return find(__str.data(), __pos, __str.size());
18191746 }
18201747
18211748 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
18221749 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18231750 find(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
18241751 __self_view __sv = __t;
1825 return std::__str_find<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
1752 return find(__sv.data(), __pos, __sv.size());
18261753 }
18271754
18281755 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1835,8 +1762,7 @@ public:
18351762 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18361763 find(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
18371764 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find(): received nullptr");
1838 return std::__str_find<value_type, size_type, traits_type, npos>(
1839 data(), size(), __s, __pos, traits_type::length(__s));
1765 return find(__s, __pos, traits_type::length(__s));
18401766 }
18411767
18421768 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type find(value_type __c, size_type __pos = 0) const _NOEXCEPT {
......@@ -1847,15 +1773,14 @@ public:
18471773
18481774 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18491775 rfind(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1850 return std::__str_rfind<value_type, size_type, traits_type, npos>(
1851 data(), size(), __str.data(), __pos, __str.size());
1776 return rfind(__str.data(), __pos, __str.size());
18521777 }
18531778
18541779 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
18551780 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18561781 rfind(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
18571782 __self_view __sv = __t;
1858 return std::__str_rfind<value_type, size_type, traits_type, npos>(data(), size(), __sv.data(), __pos, __sv.size());
1783 return rfind(__sv.data(), __pos, __sv.size());
18591784 }
18601785
18611786 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1868,8 +1793,7 @@ public:
18681793 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18691794 rfind(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
18701795 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::rfind(): received nullptr");
1871 return std::__str_rfind<value_type, size_type, traits_type, npos>(
1872 data(), size(), __s, __pos, traits_type::length(__s));
1796 return rfind(__s, __pos, traits_type::length(__s));
18731797 }
18741798
18751799 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1881,16 +1805,14 @@ public:
18811805
18821806 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18831807 find_first_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1884 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1885 data(), size(), __str.data(), __pos, __str.size());
1808 return find_first_of(__str.data(), __pos, __str.size());
18861809 }
18871810
18881811 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
18891812 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
18901813 find_first_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
18911814 __self_view __sv = __t;
1892 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1893 data(), size(), __sv.data(), __pos, __sv.size());
1815 return find_first_of(__sv.data(), __pos, __sv.size());
18941816 }
18951817
18961818 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1903,8 +1825,7 @@ public:
19031825 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19041826 find_first_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
19051827 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_of(): received nullptr");
1906 return std::__str_find_first_of<value_type, size_type, traits_type, npos>(
1907 data(), size(), __s, __pos, traits_type::length(__s));
1828 return find_first_of(__s, __pos, traits_type::length(__s));
19081829 }
19091830
19101831 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1916,16 +1837,14 @@ public:
19161837
19171838 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19181839 find_last_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1919 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1920 data(), size(), __str.data(), __pos, __str.size());
1840 return find_last_of(__str.data(), __pos, __str.size());
19211841 }
19221842
19231843 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
19241844 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19251845 find_last_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
19261846 __self_view __sv = __t;
1927 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1928 data(), size(), __sv.data(), __pos, __sv.size());
1847 return find_last_of(__sv.data(), __pos, __sv.size());
19291848 }
19301849
19311850 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1938,8 +1857,7 @@ public:
19381857 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19391858 find_last_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
19401859 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_of(): received nullptr");
1941 return std::__str_find_last_of<value_type, size_type, traits_type, npos>(
1942 data(), size(), __s, __pos, traits_type::length(__s));
1860 return find_last_of(__s, __pos, traits_type::length(__s));
19431861 }
19441862
19451863 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1951,16 +1869,14 @@ public:
19511869
19521870 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19531871 find_first_not_of(const basic_string& __str, size_type __pos = 0) const _NOEXCEPT {
1954 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1955 data(), size(), __str.data(), __pos, __str.size());
1872 return find_first_not_of(__str.data(), __pos, __str.size());
19561873 }
19571874
19581875 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
19591876 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19601877 find_first_not_of(const _Tp& __t, size_type __pos = 0) const _NOEXCEPT {
19611878 __self_view __sv = __t;
1962 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1963 data(), size(), __sv.data(), __pos, __sv.size());
1879 return find_first_not_of(__sv.data(), __pos, __sv.size());
19641880 }
19651881
19661882 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1973,8 +1889,7 @@ public:
19731889 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19741890 find_first_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = 0) const _NOEXCEPT {
19751891 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_first_not_of(): received nullptr");
1976 return std::__str_find_first_not_of<value_type, size_type, traits_type, npos>(
1977 data(), size(), __s, __pos, traits_type::length(__s));
1892 return find_first_not_of(__s, __pos, traits_type::length(__s));
19781893 }
19791894
19801895 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -1986,16 +1901,14 @@ public:
19861901
19871902 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19881903 find_last_not_of(const basic_string& __str, size_type __pos = npos) const _NOEXCEPT {
1989 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
1990 data(), size(), __str.data(), __pos, __str.size());
1904 return find_last_not_of(__str.data(), __pos, __str.size());
19911905 }
19921906
19931907 template <class _Tp, __enable_if_t<__can_be_converted_to_string_view_v<_CharT, _Traits, _Tp>, int> = 0>
19941908 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
19951909 find_last_not_of(const _Tp& __t, size_type __pos = npos) const _NOEXCEPT {
19961910 __self_view __sv = __t;
1997 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
1998 data(), size(), __sv.data(), __pos, __sv.size());
1911 return find_last_not_of(__sv.data(), __pos, __sv.size());
19991912 }
20001913
20011914 [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -2008,8 +1921,7 @@ public:
20081921 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
20091922 find_last_not_of(const value_type* _LIBCPP_DIAGNOSE_NULLPTR __s, size_type __pos = npos) const _NOEXCEPT {
20101923 _LIBCPP_ASSERT_NON_NULL(__s != nullptr, "string::find_last_not_of(): received nullptr");
2011 return std::__str_find_last_not_of<value_type, size_type, traits_type, npos>(
2012 data(), size(), __s, __pos, traits_type::length(__s));
1924 return find_last_not_of(__s, __pos, traits_type::length(__s));
20131925 }
20141926
20151927 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type
......@@ -2134,8 +2046,7 @@ public:
21342046 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __invariants() const;
21352047
21362048private:
2137 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS bool
2138 __is_long() const _NOEXCEPT {
2049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_long() const _NOEXCEPT {
21392050 if (__libcpp_is_constant_evaluated() && __builtin_constant_p(__rep_.__l.__is_long_)) {
21402051 return __rep_.__l.__is_long_;
21412052 }
......@@ -2180,7 +2091,7 @@ private:
21802091 value_type* __p;
21812092 if (__cap - __sz >= __n) {
21822093 __annotate_increase(__n);
2183 __p = std::__to_address(__get_pointer());
2094 __p = __data();
21842095 size_type __n_move = __sz - __ip;
21852096 if (__n_move != 0)
21862097 traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
......@@ -2203,15 +2114,13 @@ private:
22032114 // internal buffer accessors
22042115 // -------------------------
22052116
2206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
2207 __set_short_size(size_type __s) _NOEXCEPT {
2117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_short_size(size_type __s) _NOEXCEPT {
22082118 _LIBCPP_ASSERT_INTERNAL(__s < __min_cap, "__s should never be greater than or equal to the short string capacity");
22092119 __rep_.__s.__size_ = __s;
22102120 __rep_.__s.__is_long_ = false;
22112121 }
22122122
2213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS size_type
2214 __get_short_size() const _NOEXCEPT {
2123 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __get_short_size() const _NOEXCEPT {
22152124 _LIBCPP_ASSERT_INTERNAL(!__rep_.__s.__is_long_, "String has to be short when trying to get the short size");
22162125 return __rep_.__s.__size_;
22172126 }
......@@ -2239,22 +2148,20 @@ private:
22392148
22402149 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {
22412150 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer");
2242 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);
2151 return __rep_.__l.__data_;
22432152 }
22442153
22452154 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {
22462155 _LIBCPP_ASSERT_INTERNAL(__rep_.__l.__is_long_, "String has to be long when trying to get the long pointer");
2247 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__rep_.__l.__data_);
2156 return __rep_.__l.__data_;
22482157 }
22492158
2250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer
2251 __get_short_pointer() _NOEXCEPT {
2252 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0]));
2159 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_short_pointer() _NOEXCEPT {
2160 return pointer_traits<pointer>::pointer_to(__rep_.__s.__data_[0]);
22532161 }
22542162
2255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer
2256 __get_short_pointer() const _NOEXCEPT {
2257 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0]));
2163 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_short_pointer() const _NOEXCEPT {
2164 return pointer_traits<const_pointer>::pointer_to(__rep_.__s.__data_[0]);
22582165 }
22592166
22602167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {
......@@ -2272,17 +2179,24 @@ private:
22722179
22732180 // Allocate a buffer of __capacity size with __alloc and return it
22742181 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __long
2275 __allocate_long_buffer(_Allocator& __alloc, size_type __capacity) {
2276 _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__capacity),
2182 __allocate_long_buffer(_Allocator& __alloc, size_type __size, size_type __min_capacity) {
2183 _LIBCPP_ASSERT_INTERNAL(
2184 __size <= __min_capacity, "Trying to allocate a long buffer with a smaller capacity than size");
2185 _LIBCPP_ASSERT_INTERNAL(!__fits_in_sso(__min_capacity),
22772186 "Trying to allocate long buffer for a capacity what would fit into the small buffer");
2278 auto __buffer = std::__allocate_at_least(__alloc, __align_allocation_size(__capacity));
2187 auto __buffer = std::__allocate_at_least(__alloc, __align_allocation_size(__min_capacity));
22792188
22802189 if (__libcpp_is_constant_evaluated()) {
22812190 for (size_type __i = 0; __i != __buffer.count; ++__i)
22822191 std::__construct_at(std::addressof(__buffer.ptr[__i]));
22832192 }
22842193
2285 return __long(__buffer, __capacity);
2194 return __long(__buffer, __size);
2195 }
2196
2197 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 __long
2198 __allocate_long_buffer(_Allocator& __alloc, size_type __size) {
2199 return __allocate_long_buffer(__alloc, __size, __size);
22862200 }
22872201
22882202 // Replace the current buffer with __new_rep. Deallocate the old long buffer if it exists.
......@@ -2321,13 +2235,9 @@ private:
23212235 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
23222236 (void)__old_mid;
23232237 (void)__new_mid;
2324# if _LIBCPP_INSTRUMENTED_WITH_ASAN
2325# if defined(__APPLE__)
2326 // TODO: remove after addressing issue #96099 (https://llvm.org/PR96099)
2327 if (!__is_long())
2328 return;
2329# endif
2330 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
2238# if _LIBCPP_ENABLE_ASAN_CONTAINER_CHECKS_FOR_STRING
2239 if (__is_long())
2240 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
23312241# endif
23322242 }
23332243
......@@ -2366,7 +2276,17 @@ private:
23662276 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {
23672277 return (__s + (__a - 1)) & ~(__a - 1);
23682278 }
2369 enum { __alignment = 8 };
2279
2280 // GCC currently doesn't define __STDCPP_DEFAULT_NEW_ALIGNMENT__ unconditionally
2281 // See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123872
2282# ifdef __STDCPP_DEFAULT_NEW_ALIGNMENT__
2283 static inline const size_t
2284 __alignment = __is_std_allocator_v<allocator_type> && __STDCPP_DEFAULT_NEW_ALIGNMENT__ > sizeof(void*)
2285 ? __STDCPP_DEFAULT_NEW_ALIGNMENT__
2286 : sizeof(void*);
2287# else
2288 static inline const size_t __alignment = sizeof(void*);
2289# endif
23702290
23712291 // This makes sure that we're using a capacity with some extra alignment, since allocators almost always over-align
23722292 // the allocations anyways, improving memory usage. More importantly, this ensures that the lowest bit is never set
......@@ -2458,7 +2378,7 @@ private:
24582378
24592379 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __erase_to_end(size_type __pos) {
24602380 _LIBCPP_ASSERT_INTERNAL(__pos <= capacity(), "Trying to erase at position outside the strings capacity!");
2461 __null_terminate_at(std::__to_address(__get_pointer()), __pos);
2381 __null_terminate_at(__data(), __pos);
24622382 }
24632383
24642384 // __erase_external_with_move is invoked for erase() invocations where
......@@ -2494,8 +2414,7 @@ private:
24942414# ifndef _LIBCPP_CXX03_LANG
24952415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
24962416 __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);
2497 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
2498 __move_assign(basic_string& __str, true_type)
2417 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(basic_string& __str, true_type)
24992418# if _LIBCPP_STD_VER >= 17
25002419 noexcept;
25012420# else
......@@ -2610,19 +2529,29 @@ struct __default_three_way_comparator<basic_string<_CharT, _Traits, _Alloc>, bas
26102529};
26112530# endif
26122531
2613template <class _Comparator, class _CharT, class _Traits, class _Alloc>
2614inline const bool __is_transparently_comparable_v<_Comparator,
2615 basic_string<_CharT, _Traits, _Alloc>,
2616 const _CharT*,
2617 __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > =
2618 true;
2532template <class _Comparator, class _CharT2, class _CharT, class _Traits, class _Alloc>
2533inline const bool __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT2*> =
2534 is_same<_CharT, __remove_cv_t<_CharT2> >::value &&
2535 (__desugars_to_v<__less_tag,
2536 _Comparator,
2537 basic_string<_CharT, _Traits, _Alloc>,
2538 basic_string<_CharT, _Traits, _Alloc> > ||
2539 __desugars_to_v<__greater_tag,
2540 _Comparator,
2541 basic_string<_CharT, _Traits, _Alloc>,
2542 basic_string<_CharT, _Traits, _Alloc> >);
2543
2544template <class _Comparator, class _CharT2, class _CharT, class _Traits, class _Alloc>
2545inline const bool __is_transparently_comparable_v<_Comparator, _CharT2*, basic_string<_CharT, _Traits, _Alloc> > =
2546 __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT2*>;
26192547
26202548template <class _Comparator, class _CharT, class _Traits, class _Alloc, size_t _Np>
2621inline const bool __is_transparently_comparable_v<_Comparator,
2622 basic_string<_CharT, _Traits, _Alloc>,
2623 _CharT[_Np],
2624 __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > =
2625 true;
2549inline const bool __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT[_Np]> =
2550 __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, const _CharT*>;
2551
2552template <class _Comparator, class _CharT, class _Traits, class _Alloc, size_t _Np>
2553inline const bool __is_transparently_comparable_v<_Comparator, _CharT[_Np], basic_string<_CharT, _Traits, _Alloc> > =
2554 __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, const _CharT*>;
26262555
26272556# if _LIBCPP_STD_VER >= 17
26282557template <class _InputIterator,
......@@ -2728,19 +2657,18 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
27282657 size_type __n_del,
27292658 size_type __n_add,
27302659 const value_type* __p_new_stuff) {
2731 __long __buffer = __allocate_long_buffer(__alloc_, __get_amortized_growth_capacity(__old_cap + __delta_cap));
2732 pointer __old_p = __get_pointer();
2660 __long __buffer = __allocate_long_buffer(__alloc_, 0, __get_amortized_growth_capacity(__old_cap + __delta_cap));
2661 value_type* __old_p = __data();
27332662 __annotate_delete();
27342663 auto __guard = std::__make_scope_guard(__annotate_new_size(*this));
27352664 if (__n_copy != 0)
2736 traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__old_p), __n_copy);
2665 traits_type::copy(std::__to_address(__buffer.__data_), __old_p, __n_copy);
27372666 if (__n_add != 0)
27382667 traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy, __p_new_stuff, __n_add);
27392668 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
27402669 if (__sec_cp_sz != 0)
2741 traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy + __n_add,
2742 std::__to_address(__old_p) + __n_copy + __n_del,
2743 __sec_cp_sz);
2670 traits_type::copy(
2671 std::__to_address(__buffer.__data_) + __n_copy + __n_add, __old_p + __n_copy + __n_del, __sec_cp_sz);
27442672 __buffer.__size_ = __n_copy + __n_add + __sec_cp_sz;
27452673 traits_type::assign(__buffer.__data_[__buffer.__size_], value_type());
27462674 __reset_internal_buffer(__buffer);
......@@ -2761,16 +2689,14 @@ _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Trait
27612689 size_type __n_copy,
27622690 size_type __n_del,
27632691 size_type __n_add) {
2764 __long __buffer = __allocate_long_buffer(__alloc_, __get_amortized_growth_capacity(__old_cap + __delta_cap));
2765 pointer __old_p = __get_pointer();
2692 __long __buffer = __allocate_long_buffer(__alloc_, 0, __get_amortized_growth_capacity(__old_cap + __delta_cap));
2693 value_type* __old_p = __data();
27662694 if (__n_copy != 0)
2767 traits_type::copy(std::__to_address(__buffer.__data_), std::__to_address(__old_p), __n_copy);
2695 traits_type::copy(std::__to_address(__buffer.__data_), __old_p, __n_copy);
27682696 size_type __sec_cp_sz = __old_sz - __n_del - __n_copy;
27692697 if (__sec_cp_sz != 0)
2770 traits_type::copy(std::__to_address(__buffer.__data_) + __n_copy + __n_add,
2771 std::__to_address(__old_p) + __n_copy + __n_del,
2772 __sec_cp_sz);
2773
2698 traits_type::copy(
2699 std::__to_address(__buffer.__data_) + __n_copy + __n_add, __old_p + __n_copy + __n_del, __sec_cp_sz);
27742700 // This is -1 to make sure the caller sets the size properly, since old versions of this function didn't set the size
27752701 // at all.
27762702 __buffer.__size_ = -1;
......@@ -2831,7 +2757,7 @@ basic_string<_CharT, _Traits, _Allocator>::__assign_external(const value_type* _
28312757 if (__cap >= __n) {
28322758 if (__n > __size)
28332759 __annotate_increase(__n - __size);
2834 value_type* __p = std::__to_address(__get_pointer());
2760 value_type* __p = __data();
28352761 traits_type::move(__p, __s, __n);
28362762 return __null_terminate_at(__p, __n);
28372763 } else {
......@@ -2847,6 +2773,13 @@ basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_ty
28472773 return (__builtin_constant_p(__n) && __fits_in_sso(__n)) ? __assign_short(__s, __n) : __assign_external(__s, __n);
28482774}
28492775
2776template <class _CharT, class _Traits, class _Allocator>
2777_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
2778basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __pos, size_type __n) {
2779 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::assign received nullptr");
2780 return assign(__self_view(__s).substr(__pos, __n));
2781}
2782
28502783template <class _CharT, class _Traits, class _Allocator>
28512784_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
28522785basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c) {
......@@ -2857,7 +2790,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(size_type __n, value_type __c)
28572790 __annotate_increase(__n);
28582791 } else if (__n > __old_size)
28592792 __annotate_increase(__n - __old_size);
2860 value_type* __p = std::__to_address(__get_pointer());
2793 value_type* __p = __data();
28612794 traits_type::assign(__p, __n, __c);
28622795 return __null_terminate_at(__p, __n);
28632796}
......@@ -2884,7 +2817,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(value_type __c) {
28842817}
28852818
28862819template <class _CharT, class _Traits, class _Allocator>
2887_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string<_CharT, _Traits, _Allocator>&
2820_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
28882821basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) {
28892822 if (this == std::addressof(__str))
28902823 return *this;
......@@ -2916,7 +2849,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
29162849}
29172850
29182851template <class _CharT, class _Traits, class _Allocator>
2919inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
2852inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
29202853basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
29212854# if _LIBCPP_STD_VER >= 17
29222855 noexcept
......@@ -3042,7 +2975,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_ty
30422975 return *this;
30432976
30442977 __annotate_increase(__n);
3045 value_type* __p = std::__to_address(__get_pointer());
2978 value_type* __p = __data();
30462979 traits_type::copy(__p + __sz, __s, __n);
30472980 __sz += __n;
30482981 __set_size(__sz);
......@@ -3061,7 +2994,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c)
30612994 if (__cap - __sz < __n)
30622995 __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
30632996 __annotate_increase(__n);
3064 pointer __p = __get_pointer();
2997 value_type* __p = __data();
30652998 traits_type::assign(std::__to_address(__p) + __sz, __n, __c);
30662999 __sz += __n;
30673000 __set_size(__sz);
......@@ -3114,6 +3047,13 @@ basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) {
31143047 return append(__s, traits_type::length(__s));
31153048}
31163049
3050template <class _CharT, class _Traits, class _Allocator>
3051_LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>&
3052basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __pos, size_type __n) {
3053 _LIBCPP_ASSERT_NON_NULL(__n == 0 || __s != nullptr, "string::append received nullptr");
3054 return append(__self_view(__s).substr(__pos, __n));
3055}
3056
31173057// insert
31183058
31193059template <class _CharT, class _Traits, class _Allocator>
......@@ -3134,7 +3074,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_t
31343074 return *this;
31353075
31363076 __annotate_increase(__n);
3137 value_type* __p = std::__to_address(__get_pointer());
3077 value_type* __p = __data();
31383078 size_type __n_move = __sz - __pos;
31393079 if (__n_move != 0) {
31403080 if (std::__is_pointer_in_range(__p + __pos, __p + __sz, __s))
......@@ -3162,7 +3102,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, size_type __n
31623102 value_type* __p;
31633103 if (__cap - __sz >= __n) {
31643104 __annotate_increase(__n);
3165 __p = std::__to_address(__get_pointer());
3105 __p = __data();
31663106 size_type __n_move = __sz - __pos;
31673107 if (__n_move != 0)
31683108 traits_type::move(__p + __pos + __n, __p + __pos, __n_move);
......@@ -3223,7 +3163,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty
32233163 __p = std::__to_address(__get_long_pointer());
32243164 } else {
32253165 __annotate_increase(1);
3226 __p = std::__to_address(__get_pointer());
3166 __p = __data();
32273167 size_type __n_move = __sz - __ip;
32283168 if (__n_move != 0)
32293169 traits_type::move(__p + __ip + 1, __p + __ip, __n_move);
......@@ -3252,7 +3192,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(
32523192 return *this;
32533193 }
32543194
3255 value_type* __p = std::__to_address(__get_pointer());
3195 value_type* __p = __data();
32563196 if (__n1 != __n2) {
32573197 if (__n2 > __n1)
32583198 __annotate_increase(__n2 - __n1);
......@@ -3291,7 +3231,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __
32913231 size_type __cap = capacity();
32923232 value_type* __p;
32933233 if (__cap - __sz + __n1 >= __n2) {
3294 __p = std::__to_address(__get_pointer());
3234 __p = __data();
32953235 if (__n1 != __n2) {
32963236 if (__n2 > __n1)
32973237 __annotate_increase(__n2 - __n1);
......@@ -3335,7 +3275,7 @@ basic_string<_CharT, _Traits, _Allocator>::__erase_external_with_move(size_type
33353275 return;
33363276
33373277 size_type __sz = size();
3338 value_type* __p = std::__to_address(__get_pointer());
3278 value_type* __p = __data();
33393279 __n = std::min(__n, __sz - __pos);
33403280 size_type __n_move = __sz - __pos - __n;
33413281 if (__n_move != 0)
......@@ -3419,8 +3359,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::re
34193359 return;
34203360
34213361 __annotation_guard __g(*this);
3422 __long __buffer = __allocate_long_buffer(__alloc_, __requested_capacity);
3423 __buffer.__size_ = size();
3362 __long __buffer = __allocate_long_buffer(__alloc_, size(), __requested_capacity);
34243363 traits_type::copy(std::__to_address(__buffer.__data_), data(), __buffer.__size_ + 1);
34253364 __reset_internal_buffer(__buffer);
34263365}
......@@ -3717,7 +3656,7 @@ __concatenate_strings(const _Allocator& __alloc,
37173656 _String __r(__uninitialized_size_tag(),
37183657 __str1.size() + __str2.size(),
37193658 _String::__alloc_traits::select_on_container_copy_construction(__alloc));
3720 auto __ptr = std::__to_address(__r.__get_pointer());
3659 auto __ptr = __r.__data();
37213660 _Traits::copy(__ptr, __str1.data(), __str1.size());
37223661 _Traits::copy(__ptr + __str1.size(), __str2.data(), __str2.size());
37233662 _Traits::assign(__ptr[__str1.size() + __str2.size()], _CharT());
......@@ -4019,11 +3958,12 @@ inline constexpr bool __format::__enable_insertable<std::basic_string<wchar_t>>
40193958
40203959# endif
40213960
3961_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
40223962_LIBCPP_END_NAMESPACE_STD
40233963
40243964_LIBCPP_POP_MACROS
40253965
4026# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3966# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
40273967# include <algorithm>
40283968# include <concepts>
40293969# include <cstdlib>
lib/libcxx/include/string.h+2
......@@ -64,6 +64,8 @@ size_t strlen(const char* s);
6464# include_next <string.h>
6565# endif
6666
67# include <stddef.h>
68
6769// MSVCRT, GNU libc and its derivates may already have the correct prototype in
6870// <string.h>. This macro can be defined by users if their C library provides
6971// the right signature.
lib/libcxx/include/string_view+1-1
......@@ -971,7 +971,7 @@ _LIBCPP_END_NAMESPACE_STD
971971
972972_LIBCPP_POP_MACROS
973973
974# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
974# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
975975# include <algorithm>
976976# include <concepts>
977977# include <cstdlib>
lib/libcxx/include/strstream+2
......@@ -151,6 +151,7 @@ _LIBCPP_PUSH_MACROS
151151# include <__undef_macros>
152152
153153_LIBCPP_BEGIN_NAMESPACE_STD
154_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
154155
155156class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {
156157public:
......@@ -349,6 +350,7 @@ private:
349350 strstreambuf __sb_; // exposition only
350351};
351352
353_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
352354_LIBCPP_END_NAMESPACE_STD
353355
354356_LIBCPP_POP_MACROS
lib/libcxx/include/syncstream+6-5
......@@ -147,10 +147,10 @@ namespace std {
147147_LIBCPP_PUSH_MACROS
148148# include <__undef_macros>
149149
150_LIBCPP_BEGIN_NAMESPACE_STD
151
152150# if _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
153151
152_LIBCPP_BEGIN_NAMESPACE_STD
153
154154// [syncstream.syncbuf.overview]/1
155155// Class template basic_syncbuf stores character data written to it,
156156// known as the associated output, into internal buffers allocated
......@@ -196,7 +196,8 @@ public:
196196 // calling __inc_reference.
197197 //
198198 // pre: __ptr is in __lut_
199 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI lock_guard<mutex> __get_lock([[maybe_unused]] void* __ptr) noexcept {
199 _LIBCPP_NO_THREAD_SAFETY_ANALYSIS [[nodiscard]] _LIBCPP_HIDE_FROM_ABI lock_guard<mutex>
200 __get_lock([[maybe_unused]] void* __ptr) noexcept {
200201 shared_lock __lock{__mutex_};
201202 return lock_guard{__get_it(__ptr)->second.__mutex};
202203 }
......@@ -511,10 +512,10 @@ using std::osyncstream;
511512using std::wosyncstream;
512513# endif
513514
514# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
515
516515_LIBCPP_END_NAMESPACE_STD
517516
517# endif // _LIBCPP_STD_VER >= 20 && _LIBCPP_HAS_EXPERIMENTAL_SYNCSTREAM
518
518519_LIBCPP_POP_MACROS
519520
520521# endif // _LIBCPP_HAS_LOCALIZATION
lib/libcxx/include/system_error+1-1
......@@ -164,7 +164,7 @@ template <> struct hash<std::error_condition>;
164164# pragma GCC system_header
165165# endif
166166
167# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
167# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
168168# include <cstdint>
169169# include <cstring>
170170# include <limits>
lib/libcxx/include/text_encoding created+835
......@@ -0,0 +1,835 @@
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_TEXT_ENCODING
11#define _LIBCPP_TEXT_ENCODING
12
13/* text_encoding synopsis
14namespace std {
15
16struct text_encoding;
17
18// [text.encoding.hash], hash support
19template<class T> struct hash;
20template<> struct hash<text_encoding>;
21
22struct text_encoding
23{
24 static constexpr size_t max_name_length = 63;
25
26 // [text.encoding.id], enumeration text_encoding::id
27 enum class id : int_least32_t {
28 see below
29 };
30 using enum id;
31
32 constexpr text_encoding() = default;
33 constexpr explicit text_encoding(string_view enc) noexcept;
34 constexpr text_encoding(id i) noexcept;
35
36 constexpr id mib() const noexcept;
37 constexpr const char* name() const noexcept;
38
39 // [text.encoding.aliases], class text_encoding::aliases_view
40 // struct aliases_view;
41 constexpr aliases_view aliases() const noexcept;
42
43 friend constexpr bool operator==(const text_encoding& a,
44 const text_encoding& b) noexcept;
45 friend constexpr bool operator==(const text_encoding& encoding, id i) noexcept;
46
47 static consteval text_encoding literal() noexcept;
48 static text_encoding environment();
49 template<id i> static bool environment_is();
50
51 private:
52 id mib_ = id::unknown; // exposition only
53 char name_[max_name_length + 1] = {0}; // exposition only
54 static constexpr bool comp-name(string_view a, string_view b); // exposition only
55};
56}
57
58*/
59
60#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
61# include <__cxx03/__config>
62#else
63# include <__config>
64
65# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
66# pragma GCC system_header
67# endif
68
69# if _LIBCPP_STD_VER >= 26
70
71# include <__algorithm/count.h>
72# include <__algorithm/find_if.h>
73# include <__algorithm/lower_bound.h>
74# include <__cstddef/ptrdiff_t.h>
75# include <__functional/hash.h>
76# include <__iterator/iterator_traits.h>
77# include <__ranges/enable_borrowed_range.h>
78# include <__ranges/view_interface.h>
79# include <climits>
80# include <cstdint>
81# include <string_view>
82# include <version>
83
84_LIBCPP_BEGIN_NAMESPACE_STD
85struct text_encoding;
86
87_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
88
89_LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT _LIBCPP_EXPORTED_FROM_ABI text_encoding
90__get_locale_encoding(const char* __name);
91
92_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
93
94struct text_encoding {
95 static_assert(CHAR_BIT == 8, "libc++ only supports platforms where CHAR_BIT == 8");
96 enum class id : int_least32_t {
97 other = 1,
98 unknown = 2,
99 ASCII = 3,
100 ISOLatin1 = 4,
101 ISOLatin2 = 5,
102 ISOLatin3 = 6,
103 ISOLatin4 = 7,
104 ISOLatinCyrillic = 8,
105 ISOLatinArabic = 9,
106 ISOLatinGreek = 10,
107 ISOLatinHebrew = 11,
108 ISOLatin5 = 12,
109 ISOLatin6 = 13,
110 ISOTextComm = 14,
111 HalfWidthKatakana = 15,
112 JISEncoding = 16,
113 ShiftJIS = 17,
114 EUCPkdFmtJapanese = 18,
115 EUCFixWidJapanese = 19,
116 ISO4UnitedKingdom = 20,
117 ISO11SwedishForNames = 21,
118 ISO15Italian = 22,
119 ISO17Spanish = 23,
120 ISO21German = 24,
121 ISO60DanishNorwegian = 25,
122 ISO69French = 26,
123 ISO10646UTF1 = 27,
124 ISO646basic1983 = 28,
125 INVARIANT = 29,
126 ISO2IntlRefVersion = 30,
127 NATSSEFI = 31,
128 NATSSEFIADD = 32, // NATS-DANO (33) and NATS-DANO-ADD (34) are omitted by the standard.
129 ISO10Swedish = 35,
130 KSC56011987 = 36,
131 ISO2022KR = 37,
132 EUCKR = 38,
133 ISO2022JP = 39,
134 ISO2022JP2 = 40,
135 ISO13JISC6220jp = 41,
136 ISO14JISC6220ro = 42,
137 ISO16Portuguese = 43,
138 ISO18Greek7Old = 44,
139 ISO19LatinGreek = 45,
140 ISO25French = 46,
141 ISO27LatinGreek1 = 47,
142 ISO5427Cyrillic = 48,
143 ISO42JISC62261978 = 49,
144 ISO47BSViewdata = 50,
145 ISO49INIS = 51,
146 ISO50INIS8 = 52,
147 ISO51INISCyrillic = 53,
148 ISO54271981 = 54,
149 ISO5428Greek = 55,
150 ISO57GB1988 = 56,
151 ISO58GB231280 = 57,
152 ISO61Norwegian2 = 58,
153 ISO70VideotexSupp1 = 59,
154 ISO84Portuguese2 = 60,
155 ISO85Spanish2 = 61,
156 ISO86Hungarian = 62,
157 ISO87JISX0208 = 63,
158 ISO88Greek7 = 64,
159 ISO89ASMO449 = 65,
160 ISO90 = 66,
161 ISO91JISC62291984a = 67,
162 ISO92JISC62991984b = 68,
163 ISO93JIS62291984badd = 69,
164 ISO94JIS62291984hand = 70,
165 ISO95JIS62291984handadd = 71,
166 ISO96JISC62291984kana = 72,
167 ISO2033 = 73,
168 ISO99NAPLPS = 74,
169 ISO102T617bit = 75,
170 ISO103T618bit = 76,
171 ISO111ECMACyrillic = 77,
172 ISO121Canadian1 = 78,
173 ISO122Canadian2 = 79,
174 ISO123CSAZ24341985gr = 80,
175 ISO88596E = 81,
176 ISO88596I = 82,
177 ISO128T101G2 = 83,
178 ISO88598E = 84,
179 ISO88598I = 85,
180 ISO139CSN369103 = 86,
181 ISO141JUSIB1002 = 87,
182 ISO143IECP271 = 88,
183 ISO146Serbian = 89,
184 ISO147Macedonian = 90,
185 ISO150 = 91,
186 ISO151Cuba = 92,
187 ISO6937Add = 93,
188 ISO153GOST1976874 = 94,
189 ISO8859Supp = 95,
190 ISO10367Box = 96,
191 ISO158Lap = 97,
192 ISO159JISX02121990 = 98,
193 ISO646Danish = 99,
194 USDK = 100,
195 DKUS = 101,
196 KSC5636 = 102,
197 Unicode11UTF7 = 103,
198 ISO2022CN = 104,
199 ISO2022CNEXT = 105,
200 UTF8 = 106,
201 ISO885913 = 109,
202 ISO885914 = 110,
203 ISO885915 = 111,
204 ISO885916 = 112,
205 GBK = 113,
206 GB18030 = 114,
207 OSDEBCDICDF0415 = 115,
208 OSDEBCDICDF03IRV = 116,
209 OSDEBCDICDF041 = 117,
210 ISO115481 = 118,
211 KZ1048 = 119,
212 UCS2 = 1000,
213 UCS4 = 1001,
214 UnicodeASCII = 1002,
215 UnicodeLatin1 = 1003,
216 UnicodeJapanese = 1004,
217 UnicodeIBM1261 = 1005,
218 UnicodeIBM1268 = 1006,
219 UnicodeIBM1276 = 1007,
220 UnicodeIBM1264 = 1008,
221 UnicodeIBM1265 = 1009,
222 Unicode11 = 1010,
223 SCSU = 1011,
224 UTF7 = 1012,
225 UTF16BE = 1013,
226 UTF16LE = 1014,
227 UTF16 = 1015,
228 CESU8 = 1016,
229 UTF32 = 1017,
230 UTF32BE = 1018,
231 UTF32LE = 1019,
232 BOCU1 = 1020,
233 UTF7IMAP = 1021,
234 Windows30Latin1 = 2000,
235 Windows31Latin1 = 2001,
236 Windows31Latin2 = 2002,
237 Windows31Latin5 = 2003,
238 HPRoman8 = 2004,
239 AdobeStandardEncoding = 2005,
240 VenturaUS = 2006,
241 VenturaInternational = 2007,
242 DECMCS = 2008,
243 PC850Multilingual = 2009,
244 PC8DanishNorwegian = 2012,
245 PC862LatinHebrew = 2013,
246 PC8Turkish = 2014,
247 IBMSymbols = 2015,
248 IBMThai = 2016,
249 HPLegal = 2017,
250 HPPiFont = 2018,
251 HPMath8 = 2019,
252 HPPSMath = 2020,
253 HPDesktop = 2021,
254 VenturaMath = 2022,
255 MicrosoftPublishing = 2023,
256 Windows31J = 2024,
257 GB2312 = 2025,
258 Big5 = 2026,
259 Macintosh = 2027,
260 IBM037 = 2028,
261 IBM038 = 2029,
262 IBM273 = 2030,
263 IBM274 = 2031,
264 IBM275 = 2032,
265 IBM277 = 2033,
266 IBM278 = 2034,
267 IBM280 = 2035,
268 IBM281 = 2036,
269 IBM284 = 2037,
270 IBM285 = 2038,
271 IBM290 = 2039,
272 IBM297 = 2040,
273 IBM420 = 2041,
274 IBM423 = 2042,
275 IBM424 = 2043,
276 PC8CodePage437 = 2011,
277 IBM500 = 2044,
278 IBM851 = 2045,
279 PCp852 = 2010,
280 IBM855 = 2046,
281 IBM857 = 2047,
282 IBM860 = 2048,
283 IBM861 = 2049,
284 IBM863 = 2050,
285 IBM864 = 2051,
286 IBM865 = 2052,
287 IBM868 = 2053,
288 IBM869 = 2054,
289 IBM870 = 2055,
290 IBM871 = 2056,
291 IBM880 = 2057,
292 IBM891 = 2058,
293 IBM903 = 2059,
294 IBM904 = 2060,
295 IBM905 = 2061,
296 IBM918 = 2062,
297 IBM1026 = 2063,
298 IBMEBCDICATDE = 2064,
299 EBCDICATDEA = 2065,
300 EBCDICCAFR = 2066,
301 EBCDICDKNO = 2067,
302 EBCDICDKNOA = 2068,
303 EBCDICFISE = 2069,
304 EBCDICFISEA = 2070,
305 EBCDICFR = 2071,
306 EBCDICIT = 2072,
307 EBCDICPT = 2073,
308 EBCDICES = 2074,
309 EBCDICESA = 2075,
310 EBCDICESS = 2076,
311 EBCDICUK = 2077,
312 EBCDICUS = 2078,
313 Unknown8BiT = 2079,
314 Mnemonic = 2080,
315 Mnem = 2081,
316 VISCII = 2082,
317 VIQR = 2083,
318 KOI8R = 2084,
319 HZGB2312 = 2085,
320 IBM866 = 2086,
321 PC775Baltic = 2087,
322 KOI8U = 2088,
323 IBM00858 = 2089,
324 IBM00924 = 2090,
325 IBM01140 = 2091,
326 IBM01141 = 2092,
327 IBM01142 = 2093,
328 IBM01143 = 2094,
329 IBM01144 = 2095,
330 IBM01145 = 2096,
331 IBM01146 = 2097,
332 IBM01147 = 2098,
333 IBM01148 = 2099,
334 IBM01149 = 2100,
335 Big5HKSCS = 2101,
336 IBM1047 = 2102,
337 PTCP154 = 2103,
338 Amiga1251 = 2104,
339 KOI7switched = 2105,
340 BRF = 2106,
341 TSCII = 2107,
342 CP51932 = 2108,
343 windows874 = 2109,
344 windows1250 = 2250,
345 windows1251 = 2251,
346 windows1252 = 2252,
347 windows1253 = 2253,
348 windows1254 = 2254,
349 windows1255 = 2255,
350 windows1256 = 2256,
351 windows1257 = 2257,
352 windows1258 = 2258,
353 TIS620 = 2259,
354 CP50220 = 2260
355 };
356
357private:
358 static constexpr int __nats_dano_ = 33;
359 static constexpr int __nats_dano_add_ = 34;
360
361 // A __te_data structure stores:
362 // Index into a table of offsets in the giant aliases string
363 // The MIB of that text encoding
364 // Number of aliases the current MIB holds
365 // We only need 6 bytes of information to store this information.
366
367 // The data is structured in three different locations:
368 // The mib table (array of __te_data)
369 // Aliases string
370 // Table of offsets into the aliases string
371
372 // All of the alias strings were transformed from an array of char* into one giant string split by '\0'.
373 // This allows us to reduce runtime memory footprint by not only removing the need to store ~884 pointers, it also
374 // significantly reduces the disk space taken by removing the need for relocation data for those pointers.
375 // We also know ahead of time that the total number of characters of all of these aliases combined can fit into 2
376 // bytes, so we can also save even more memory by using 2 byte offsets rather than a full pointer into the aliases
377 // string.
378
379 struct __te_data {
380 unsigned short __first_alias_index_;
381 unsigned short __mib_rep_;
382 unsigned char __num_aliases_;
383
384 friend constexpr bool operator<(const __te_data& __enc, id __i) noexcept {
385 return __enc.__mib_rep_ < static_cast<unsigned short>(__i);
386 }
387 };
388
389 static constexpr bool __comp_name(string_view __a, string_view __b) noexcept {
390 if (__a.empty() || __b.empty()) {
391 return false;
392 }
393
394 // Map any non-alphanumeric character to 255, skip prefix 0s, else get tolower(__n).
395 auto __map_char = [](char __n, bool& __in_number) -> unsigned char {
396 if (__n == '0') {
397 return __in_number ? '0' : 255;
398 }
399 __in_number = __n >= '1' && __n <= '9';
400
401 if ((__n >= '1' && __n <= '9') || (__n >= 'a' && __n <= 'z')) {
402 return __n;
403 }
404 if (__n >= 'A' && __n <= 'Z') {
405 return __n + ('a' - 'A'); // tolower
406 }
407
408 return 255;
409 };
410
411 auto __a_ptr = __a.begin(), __b_ptr = __b.begin();
412 bool __a_in_number = false, __b_in_number = false;
413
414 unsigned char __a_val = 255, __b_val = 255;
415 for (;; __a_ptr++, __b_ptr++) {
416 while (__a_ptr != __a.end() && (__a_val = __map_char(*__a_ptr, __a_in_number)) == 255)
417 __a_ptr++;
418 while (__b_ptr != __b.end() && (__b_val = __map_char(*__b_ptr, __b_in_number)) == 255)
419 __b_ptr++;
420
421 if (__a_ptr == __a.end())
422 return __b_ptr == __b.end();
423 if (__b_ptr == __b.end())
424 return false;
425 if (__a_val != __b_val)
426 return false;
427 }
428 return true;
429 }
430
431 static constexpr unsigned short __find_data_idx(string_view __a) noexcept {
432 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__a.size() <= max_name_length, "input string_view must have size <= 63");
433 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__a.contains('\0'), "input string_view must not contain '\\0'");
434
435 auto __pred = [&__a](const __te_data& __entry) -> bool {
436 // Search aliases of text encoding for string
437 aliases_view __aliases(__entry);
438 return std::find_if(__aliases.begin(), __aliases.end(), [&__a](auto __alias) {
439 return __comp_name(__a, __alias);
440 }) != __aliases.end();
441 };
442
443 const __te_data* __found = std::find_if(__entries + 2, std::end(__entries), __pred);
444 if (__found == std::end(__entries)) {
445 return __other_idx_; // other
446 }
447
448 return __found - __entries;
449 }
450
451 static constexpr unsigned short __find_data_idx_by_id(id __i) noexcept {
452 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i >= id::other, "invalid text_encoding::id passed");
453 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__i <= id::CP50220, "invalid text_encoding::id passed");
454 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_, "Mib for NATS-DANO used");
455 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(int_least32_t(__i) != __nats_dano_add_, "Mib for NATS-DANO-ADD used");
456 auto __found = std::lower_bound(std::begin(__entries), std::end(__entries), __i);
457
458 if (__found == std::end(__entries)) {
459 return __unknown_idx_; // unknown
460 }
461
462 return __found - __entries;
463 }
464
465public:
466 using enum id;
467 static constexpr size_t max_name_length = 63;
468
469 // [text.encoding.aliases], class text_encoding::aliases_view
470 struct aliases_view : ranges::view_interface<aliases_view> {
471 struct __iterator {
472 using iterator_concept = random_access_iterator_tag;
473 using iterator_category = random_access_iterator_tag;
474 using value_type = const char*;
475 using reference = const char*;
476 using difference_type = int;
477
478 constexpr __iterator() noexcept = default;
479
480 [[nodiscard]] constexpr reference operator*() const noexcept {
481 return __get_alias_from_offset_table(__current_idx_);
482 }
483
484 [[nodiscard]] constexpr reference operator[](difference_type __n) const noexcept {
485 auto __it = *this;
486 return *(__it + __n);
487 }
488
489 [[nodiscard]] friend constexpr __iterator operator+(__iterator __it, difference_type __n) noexcept {
490 __it += __n;
491 return __it;
492 }
493
494 [[nodiscard]] friend constexpr __iterator operator+(difference_type __n, __iterator __it) noexcept {
495 __it += __n;
496 return __it;
497 }
498
499 [[nodiscard]] friend constexpr __iterator operator-(__iterator __it, difference_type __n) noexcept {
500 __it -= __n;
501 return __it;
502 }
503
504 [[nodiscard]] constexpr difference_type operator-(const __iterator& __other) const noexcept {
505 return __current_idx_ - __other.__current_idx_;
506 }
507
508 constexpr __iterator& operator++() noexcept {
509 __current_idx_++;
510 return *this;
511 }
512
513 constexpr __iterator operator++(int) noexcept {
514 auto __old = *this;
515 __current_idx_++;
516 return __old;
517 }
518
519 constexpr __iterator& operator--() noexcept {
520 __current_idx_--;
521 return *this;
522 }
523
524 constexpr __iterator operator--(int) noexcept {
525 auto __old = *this;
526 __current_idx_--;
527 return __old;
528 }
529
530 constexpr __iterator& operator+=(difference_type __n) noexcept {
531 __current_idx_ += __n;
532 return *this;
533 }
534
535 constexpr __iterator& operator-=(difference_type __n) noexcept { return (*this += -__n); }
536
537 friend constexpr auto operator<=>(const __iterator& __it, const __iterator& __it2) noexcept = default;
538
539 private:
540 friend struct aliases_view;
541
542 constexpr __iterator(unsigned short __enc_d) noexcept : __current_idx_(__enc_d) {}
543
544 unsigned short __current_idx_;
545 }; // __iterator
546
547 [[nodiscard]] constexpr __iterator begin() const noexcept { return __iterator(__first_idx_); }
548
549 [[nodiscard]] constexpr __iterator end() const noexcept { return __iterator(__last_idx_); }
550
551 private:
552 friend struct text_encoding;
553
554 constexpr aliases_view(const __te_data& __d)
555 : __first_idx_(__d.__first_alias_index_), __last_idx_(__d.__first_alias_index_ + __d.__num_aliases_) {}
556
557 unsigned short __first_idx_;
558 unsigned short __last_idx_;
559 }; // aliases_view
560
561 constexpr text_encoding() = default;
562
563 constexpr explicit text_encoding(string_view __enc) noexcept : __encoding_idx_(__find_data_idx(__enc)) {
564 __enc.copy(__name_, max_name_length, 0);
565 }
566
567 constexpr text_encoding(id __i) noexcept : __encoding_idx_(__find_data_idx_by_id(__i)) {
568 const char* __alias = __get_alias_from_offset_table(__get().__first_alias_index_);
569 if (__alias[0] != '\0') {
570 string_view(__alias).copy(__name_, max_name_length);
571 }
572 }
573
574 [[nodiscard]] constexpr id mib() const noexcept { return id(__get().__mib_rep_); }
575
576 [[nodiscard]] constexpr const char* name() const noexcept { return __name_; }
577
578 [[nodiscard]] constexpr aliases_view aliases() const noexcept { return aliases_view(__get()); }
579
580 friend constexpr bool operator==(const text_encoding& __a, const text_encoding& __b) noexcept {
581 return __a.mib() == id::other && __b.mib() == id::other
582 ? __comp_name(__a.__name_, __b.__name_)
583 : __a.mib() == __b.mib();
584 }
585
586 friend constexpr bool operator==(const text_encoding& __encoding, id __i) noexcept { return __encoding.mib() == __i; }
587
588 [[nodiscard]] static consteval text_encoding literal() noexcept {
589 // TODO: Remove this branch once we have __GNUC_EXECUTION_CHARSET_NAME or __clang_literal_encoding__ unconditionally
590# ifdef __GNUC_EXECUTION_CHARSET_NAME
591 return text_encoding(__GNUC_EXECUTION_CHARSET_NAME);
592# elif defined(__clang_literal_encoding__)
593 return text_encoding(__clang_literal_encoding__);
594# else
595 return text_encoding();
596# endif
597 }
598
599# if _LIBCPP_HAS_LOCALIZATION
600 [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static text_encoding environment() {
601# if defined(_LIBCPP_WIN32API)
602 return __get_locale_encoding(nullptr);
603# else
604 return __get_locale_encoding("");
605# endif
606 }
607
608 template <id _Id>
609 [[nodiscard]] _LIBCPP_AVAILABILITY_TEXT_ENCODING_ENVIRONMENT static bool environment_is() {
610 // TODO: It may be worthwhile to implement an optimization for popular encodings, e.g. UTF-8,
611 // to allow checking the environment text encoding without needing to use the data tables.
612
613# if defined(__ANDROID__)
614 return _Id == std::text_encoding::id::UTF8;
615# else
616 return environment() == _Id;
617# endif
618 }
619# else
620 static text_encoding environment() = delete;
621
622 template <id>
623 static bool environment_is() = delete;
624# endif
625
626private:
627 constexpr const __te_data& __get() const { return __entries[__encoding_idx_]; }
628
629 static constexpr char const* __get_alias_from_offset_table(unsigned short __idx) {
630 return __aliases_string + __alias_offsets.__table[__idx];
631 }
632
633 static constexpr auto __other_idx_ = 0u;
634 static constexpr auto __unknown_idx_ = 1u;
635
636 char __name_[max_name_length + 1]{};
637 unsigned short __encoding_idx_{1u};
638
639 static constexpr __te_data __entries[] = {
640 {0, 1, 0}, {1, 2, 0}, {2, 3, 11}, {13, 4, 9}, {22, 5, 7}, {29, 6, 7}, {36, 7, 7},
641 {43, 8, 6}, {49, 9, 8}, {57, 10, 9}, {66, 11, 6}, {72, 12, 7}, {79, 13, 6}, {85, 14, 3},
642 {88, 15, 3}, {91, 16, 2}, {93, 17, 3}, {96, 18, 3}, {99, 19, 2}, {101, 20, 6}, {107, 21, 5},
643 {112, 22, 4}, {116, 23, 4}, {120, 24, 5}, {125, 25, 6}, {131, 26, 5}, {136, 27, 2}, {138, 28, 3},
644 {141, 29, 2}, {143, 30, 4}, {147, 31, 3}, {150, 32, 3}, {153, 35, 7}, {160, 36, 6}, {166, 37, 2},
645 {168, 38, 2}, {170, 39, 2}, {172, 40, 2}, {174, 41, 6}, {180, 42, 5}, {185, 43, 4}, {189, 44, 3},
646 {192, 45, 3}, {195, 46, 4}, {199, 47, 3}, {202, 48, 3}, {205, 49, 3}, {208, 50, 3}, {211, 51, 3},
647 {214, 52, 3}, {217, 53, 3}, {220, 54, 4}, {224, 55, 3}, {227, 56, 5}, {232, 57, 4}, {236, 58, 5},
648 {241, 59, 3}, {244, 60, 4}, {248, 61, 4}, {252, 62, 5}, {257, 63, 5}, {262, 64, 3}, {265, 65, 5},
649 {270, 66, 2}, {272, 67, 4}, {276, 68, 5}, {281, 69, 4}, {285, 70, 4}, {289, 71, 4}, {293, 72, 3},
650 {296, 73, 4}, {300, 74, 5}, {305, 75, 3}, {308, 76, 4}, {312, 77, 4}, {316, 78, 7}, {323, 79, 6},
651 {329, 80, 3}, {332, 81, 3}, {335, 82, 3}, {338, 83, 3}, {341, 84, 3}, {344, 85, 3}, {347, 86, 3},
652 {350, 87, 6}, {356, 88, 3}, {359, 89, 4}, {363, 90, 4}, {367, 91, 4}, {371, 92, 5}, {376, 93, 3},
653 {379, 94, 4}, {383, 95, 4}, {387, 96, 3}, {390, 97, 4}, {394, 98, 4}, {398, 99, 5}, {403, 100, 2},
654 {405, 101, 2}, {407, 102, 3}, {410, 103, 2}, {412, 104, 2}, {414, 105, 2}, {416, 106, 2}, {418, 109, 2},
655 {420, 110, 8}, {428, 111, 4}, {432, 112, 7}, {439, 113, 5}, {444, 114, 2}, {446, 115, 2}, {448, 116, 2},
656 {450, 117, 2}, {452, 118, 4}, {456, 119, 4}, {460, 1000, 2}, {462, 1001, 2}, {464, 1002, 2}, {466, 1003, 3},
657 {469, 1004, 2}, {471, 1005, 2}, {473, 1006, 2}, {475, 1007, 2}, {477, 1008, 2}, {479, 1009, 2}, {481, 1010, 2},
658 {483, 1011, 2}, {485, 1012, 2}, {487, 1013, 2}, {489, 1014, 2}, {491, 1015, 2}, {493, 1016, 3}, {496, 1017, 2},
659 {498, 1018, 2}, {500, 1019, 2}, {502, 1020, 3}, {505, 1021, 2}, {507, 2000, 2}, {509, 2001, 2}, {511, 2002, 2},
660 {513, 2003, 2}, {515, 2004, 4}, {519, 2005, 2}, {521, 2006, 2}, {523, 2007, 2}, {525, 2008, 3}, {528, 2009, 4},
661 {532, 2010, 4}, {536, 2011, 4}, {540, 2012, 2}, {542, 2013, 4}, {546, 2014, 2}, {548, 2015, 2}, {550, 2016, 2},
662 {552, 2017, 2}, {554, 2018, 2}, {556, 2019, 2}, {558, 2020, 2}, {560, 2021, 2}, {562, 2022, 2}, {564, 2023, 2},
663 {566, 2024, 2}, {568, 2025, 2}, {570, 2026, 2}, {572, 2027, 3}, {575, 2028, 7}, {582, 2029, 4}, {586, 2030, 3},
664 {589, 2031, 4}, {593, 2032, 4}, {597, 2033, 4}, {601, 2034, 5}, {606, 2035, 4}, {610, 2036, 4}, {614, 2037, 4},
665 {618, 2038, 4}, {622, 2039, 4}, {626, 2040, 4}, {630, 2041, 4}, {634, 2042, 4}, {638, 2043, 4}, {642, 2044, 5},
666 {647, 2045, 4}, {651, 2046, 4}, {655, 2047, 4}, {659, 2048, 4}, {663, 2049, 5}, {668, 2050, 4}, {672, 2051, 3},
667 {675, 2052, 4}, {679, 2053, 4}, {683, 2054, 5}, {688, 2055, 5}, {693, 2056, 4}, {697, 2057, 4}, {701, 2058, 3},
668 {704, 2059, 3}, {707, 2060, 4}, {711, 2061, 4}, {715, 2062, 4}, {719, 2063, 3}, {722, 2064, 2}, {724, 2065, 2},
669 {726, 2066, 2}, {728, 2067, 2}, {730, 2068, 2}, {732, 2069, 2}, {734, 2070, 2}, {736, 2071, 2}, {738, 2072, 2},
670 {740, 2073, 2}, {742, 2074, 2}, {744, 2075, 2}, {746, 2076, 2}, {748, 2077, 2}, {750, 2078, 2}, {752, 2079, 2},
671 {754, 2080, 2}, {756, 2081, 2}, {758, 2082, 2}, {760, 2083, 2}, {762, 2084, 2}, {764, 2085, 1}, {765, 2086, 4},
672 {769, 2087, 3}, {772, 2088, 2}, {774, 2089, 5}, {779, 2090, 5}, {784, 2091, 5}, {789, 2092, 5}, {794, 2093, 6},
673 {800, 2094, 6}, {806, 2095, 5}, {811, 2096, 5}, {816, 2097, 5}, {821, 2098, 5}, {826, 2099, 5}, {831, 2100, 5},
674 {836, 2101, 2}, {838, 2102, 3}, {841, 2103, 5}, {846, 2104, 5}, {851, 2105, 2}, {853, 2106, 2}, {855, 2107, 2},
675 {857, 2108, 2}, {859, 2109, 2}, {861, 2250, 2}, {863, 2251, 2}, {865, 2252, 2}, {867, 2253, 2}, {869, 2254, 2},
676 {871, 2255, 2}, {873, 2256, 2}, {875, 2257, 2}, {877, 2258, 2}, {879, 2259, 3}, {882, 2260, 2}};
677
678 static constexpr char __aliases_string[] =
679 "US-ASCII\0iso-ir-6\0ANSI_X3.4-1968\0ANSI_X3.4-1986\0ISO_646.irv:1991\0ISO646-"
680 "US\0us\0IBM367\0cp367\0csASCII\0ASCII\0ISO_8859-1:1987\0iso-ir-100\0ISO_8859-1\0ISO-8859-"
681 "1\0latin1\0l1\0IBM819\0CP819\0csISOLatin1\0ISO_8859-2:1987\0iso-ir-101\0ISO_8859-2\0ISO-8859-"
682 "2\0latin2\0l2\0csISOLatin2\0ISO_8859-3:1988\0iso-ir-109\0ISO_8859-3\0ISO-8859-3\0latin3\0l3\0csISOLatin3\0ISO_"
683 "8859-4:1988\0iso-ir-110\0ISO_8859-4\0ISO-8859-4\0latin4\0l4\0csISOLatin4\0ISO_8859-5:1988\0iso-ir-144\0ISO_8859-"
684 "5\0ISO-8859-5\0cyrillic\0csISOLatinCyrillic\0ISO_8859-6:1987\0iso-ir-127\0ISO_8859-6\0ISO-8859-6\0ECMA-"
685 "114\0ASMO-708\0arabic\0csISOLatinArabic\0ISO_8859-7:1987\0iso-ir-126\0ISO_8859-7\0ISO-8859-7\0ELOT_928\0ECMA-"
686 "118\0greek\0greek8\0csISOLatinGreek\0ISO_8859-8:1988\0iso-ir-138\0ISO_8859-8\0ISO-8859-"
687 "8\0hebrew\0csISOLatinHebrew\0ISO_8859-9:1989\0iso-ir-148\0ISO_8859-9\0ISO-8859-9\0latin5\0l5\0csISOLatin5\0ISO-"
688 "8859-10\0iso-ir-157\0l6\0ISO_8859-10:1992\0csISOLatin6\0latin6\0ISO_6937-2-add\0iso-ir-142\0csISOTextComm\0JIS_"
689 "X0201\0X0201\0csHalfWidthKatakana\0JIS_Encoding\0csJISEncoding\0Shift_JIS\0MS_Kanji\0csShiftJIS\0Extended_UNIX_"
690 "Code_Packed_Format_for_Japanese\0csEUCPkdFmtJapanese\0EUC-JP\0Extended_UNIX_Code_Fixed_Width_for_"
691 "Japanese\0csEUCFixWidJapanese\0BS_4730\0iso-ir-4\0ISO646-GB\0gb\0uk\0csISO4UnitedKingdom\0SEN_850200_C\0iso-ir-"
692 "11\0ISO646-SE2\0se2\0csISO11SwedishForNames\0IT\0iso-ir-15\0ISO646-IT\0csISO15Italian\0ES\0iso-ir-17\0ISO646-"
693 "ES\0csISO17Spanish\0DIN_66003\0iso-ir-21\0de\0ISO646-DE\0csISO21German\0NS_4551-1\0iso-ir-60\0ISO646-"
694 "NO\0no\0csISO60DanishNorwegian\0csISO60Norwegian1\0NF_Z_62-010\0iso-ir-69\0ISO646-FR\0fr\0csISO69French\0ISO-"
695 "10646-UTF-1\0csISO10646UTF1\0ISO_646.basic:1983\0ref\0csISO646basic1983\0INVARIANT\0csINVARIANT\0ISO_646.irv:"
696 "1983\0iso-ir-2\0irv\0csISO2IntlRefVersion\0NATS-SEFI\0iso-ir-8-1\0csNATSSEFI\0NATS-SEFI-ADD\0iso-ir-8-"
697 "2\0csNATSSEFIADD\0SEN_850200_B\0iso-ir-10\0FI\0ISO646-FI\0ISO646-SE\0se\0csISO10Swedish\0KS_C_5601-1987\0iso-ir-"
698 "149\0KS_C_5601-1989\0KSC_5601\0korean\0csKSC56011987\0ISO-2022-KR\0csISO2022KR\0EUC-KR\0csEUCKR\0ISO-2022-"
699 "JP\0csISO2022JP\0ISO-2022-JP-2\0csISO2022JP2\0JIS_C6220-1969-jp\0JIS_C6220-1969\0iso-ir-13\0katakana\0x0201-"
700 "7\0csISO13JISC6220jp\0JIS_C6220-1969-ro\0iso-ir-14\0jp\0ISO646-JP\0csISO14JISC6220ro\0PT\0iso-ir-16\0ISO646-"
701 "PT\0csISO16Portuguese\0greek7-old\0iso-ir-18\0csISO18Greek7Old\0latin-greek\0iso-ir-19\0csISO19LatinGreek\0NF_Z_"
702 "62-010_(1973)\0iso-ir-25\0ISO646-FR1\0csISO25French\0Latin-greek-1\0iso-ir-27\0csISO27LatinGreek1\0ISO_"
703 "5427\0iso-ir-37\0csISO5427Cyrillic\0JIS_C6226-1978\0iso-ir-42\0csISO42JISC62261978\0BS_viewdata\0iso-ir-"
704 "47\0csISO47BSViewdata\0INIS\0iso-ir-49\0csISO49INIS\0INIS-8\0iso-ir-50\0csISO50INIS8\0INIS-cyrillic\0iso-ir-"
705 "51\0csISO51INISCyrillic\0ISO_5427:1981\0iso-ir-54\0ISO5427Cyrillic1981\0csISO54271981\0ISO_5428:1980\0iso-ir-"
706 "55\0csISO5428Greek\0GB_1988-80\0iso-ir-57\0cn\0ISO646-CN\0csISO57GB1988\0GB_2312-80\0iso-ir-"
707 "58\0chinese\0csISO58GB231280\0NS_4551-2\0ISO646-NO2\0iso-ir-61\0no2\0csISO61Norwegian2\0videotex-suppl\0iso-ir-"
708 "70\0csISO70VideotexSupp1\0PT2\0iso-ir-84\0ISO646-PT2\0csISO84Portuguese2\0ES2\0iso-ir-85\0ISO646-"
709 "ES2\0csISO85Spanish2\0MSZ_7795.3\0iso-ir-86\0ISO646-HU\0hu\0csISO86Hungarian\0JIS_C6226-1983\0iso-ir-"
710 "87\0x0208\0JIS_X0208-1983\0csISO87JISX0208\0greek7\0iso-ir-88\0csISO88Greek7\0ASMO_449\0ISO_9036\0arabic7\0iso-"
711 "ir-89\0csISO89ASMO449\0iso-ir-90\0csISO90\0JIS_C6229-1984-a\0iso-ir-91\0jp-ocr-a\0csISO91JISC62291984a\0JIS_"
712 "C6229-1984-b\0iso-ir-92\0ISO646-JP-OCR-B\0jp-ocr-b\0csISO92JISC62991984b\0JIS_C6229-1984-b-add\0iso-ir-93\0jp-"
713 "ocr-b-add\0csISO93JIS62291984badd\0JIS_C6229-1984-hand\0iso-ir-94\0jp-ocr-hand\0csISO94JIS62291984hand\0JIS_"
714 "C6229-1984-hand-add\0iso-ir-95\0jp-ocr-hand-add\0csISO95JIS62291984handadd\0JIS_C6229-1984-kana\0iso-ir-"
715 "96\0csISO96JISC62291984kana\0ISO_2033-1983\0iso-ir-98\0e13b\0csISO2033\0ANSI_X3.110-1983\0iso-ir-99\0CSA_T500-"
716 "1983\0NAPLPS\0csISO99NAPLPS\0T.61-7bit\0iso-ir-102\0csISO102T617bit\0T.61-8bit\0T.61\0iso-ir-"
717 "103\0csISO103T618bit\0ECMA-cyrillic\0iso-ir-111\0KOI8-E\0csISO111ECMACyrillic\0CSA_Z243.4-1985-1\0iso-ir-"
718 "121\0ISO646-CA\0csa7-1\0csa71\0ca\0csISO121Canadian1\0CSA_Z243.4-1985-2\0iso-ir-122\0ISO646-CA2\0csa7-"
719 "2\0csa72\0csISO122Canadian2\0CSA_Z243.4-1985-gr\0iso-ir-123\0csISO123CSAZ24341985gr\0ISO_8859-6-"
720 "E\0csISO88596E\0ISO-8859-6-E\0ISO_8859-6-I\0csISO88596I\0ISO-8859-6-I\0T.101-G2\0iso-ir-"
721 "128\0csISO128T101G2\0ISO_8859-8-E\0csISO88598E\0ISO-8859-8-E\0ISO_8859-8-I\0csISO88598I\0ISO-8859-8-I\0CSN_"
722 "369103\0iso-ir-139\0csISO139CSN369103\0JUS_I.B1.002\0iso-ir-141\0ISO646-YU\0js\0yu\0csISO141JUSIB1002\0IEC_P27-"
723 "1\0iso-ir-143\0csISO143IECP271\0JUS_I.B1.003-serb\0iso-ir-146\0serbian\0csISO146Serbian\0JUS_I.B1.003-"
724 "mac\0macedonian\0iso-ir-147\0csISO147Macedonian\0greek-ccitt\0iso-ir-150\0csISO150\0csISO150GreekCCITT\0NC_NC00-"
725 "10:81\0cuba\0iso-ir-151\0ISO646-CU\0csISO151Cuba\0ISO_6937-2-25\0iso-ir-152\0csISO6937Add\0GOST_19768-74\0ST_"
726 "SEV_358-88\0iso-ir-153\0csISO153GOST1976874\0ISO_8859-supp\0iso-ir-154\0latin1-2-5\0csISO8859Supp\0ISO_10367-"
727 "box\0iso-ir-155\0csISO10367Box\0latin-lap\0lap\0iso-ir-158\0csISO158Lap\0JIS_X0212-1990\0x0212\0iso-ir-"
728 "159\0csISO159JISX02121990\0DS_2089\0DS2089\0ISO646-DK\0dk\0csISO646Danish\0us-dk\0csUSDK\0dk-"
729 "us\0csDKUS\0KSC5636\0ISO646-KR\0csKSC5636\0UNICODE-1-1-UTF-7\0csUnicode11UTF7\0ISO-2022-CN\0csISO2022CN\0ISO-"
730 "2022-CN-EXT\0csISO2022CNEXT\0UTF-8\0csUTF8\0ISO-8859-13\0csISO885913\0ISO-8859-14\0iso-ir-199\0ISO_8859-14:"
731 "1998\0ISO_8859-14\0latin8\0iso-celtic\0l8\0csISO885914\0ISO-8859-15\0ISO_8859-15\0Latin-9\0csISO885915\0ISO-"
732 "8859-16\0iso-ir-226\0ISO_8859-16:2001\0ISO_8859-16\0latin10\0l10\0csISO885916\0GBK\0CP936\0MS936\0windows-"
733 "936\0csGBK\0GB18030\0csGB18030\0OSD_EBCDIC_DF04_15\0csOSDEBCDICDF0415\0OSD_EBCDIC_DF03_"
734 "IRV\0csOSDEBCDICDF03IRV\0OSD_EBCDIC_DF04_1\0csOSDEBCDICDF041\0ISO-11548-1\0ISO_11548-1\0ISO_TR_11548-"
735 "1\0csISO115481\0KZ-1048\0STRK1048-2002\0RK1048\0csKZ1048\0ISO-10646-UCS-2\0csUnicode\0ISO-10646-UCS-"
736 "4\0csUCS4\0ISO-10646-UCS-Basic\0csUnicodeASCII\0ISO-10646-Unicode-Latin1\0csUnicodeLatin1\0ISO-10646\0ISO-10646-"
737 "J-1\0csUnicodeJapanese\0ISO-Unicode-IBM-1261\0csUnicodeIBM1261\0ISO-Unicode-IBM-1268\0csUnicodeIBM1268\0ISO-"
738 "Unicode-IBM-1276\0csUnicodeIBM1276\0ISO-Unicode-IBM-1264\0csUnicodeIBM1264\0ISO-Unicode-IBM-"
739 "1265\0csUnicodeIBM1265\0UNICODE-1-1\0csUnicode11\0SCSU\0csSCSU\0UTF-7\0csUTF7\0UTF-16BE\0csUTF16BE\0UTF-"
740 "16LE\0csUTF16LE\0UTF-16\0csUTF16\0CESU-8\0csCESU8\0csCESU-8\0UTF-32\0csUTF32\0UTF-32BE\0csUTF32BE\0UTF-"
741 "32LE\0csUTF32LE\0BOCU-1\0csBOCU1\0csBOCU-1\0UTF-7-IMAP\0csUTF7IMAP\0ISO-8859-1-Windows-3.0-Latin-"
742 "1\0csWindows30Latin1\0ISO-8859-1-Windows-3.1-Latin-1\0csWindows31Latin1\0ISO-8859-2-Windows-Latin-"
743 "2\0csWindows31Latin2\0ISO-8859-9-Windows-Latin-5\0csWindows31Latin5\0hp-roman8\0roman8\0r8\0csHPRoman8\0Adobe-"
744 "Standard-Encoding\0csAdobeStandardEncoding\0Ventura-US\0csVenturaUS\0Ventura-"
745 "International\0csVenturaInternational\0DEC-"
746 "MCS\0dec\0csDECMCS\0IBM850\0cp850\0850\0csPC850Multilingual\0IBM852\0cp852\0852\0csPCp852\0IBM437\0cp437\0"
747 "437\0csPC8CodePage437\0PC8-Danish-Norwegian\0csPC8DanishNorwegian\0IBM862\0cp862\0862\0csPC862LatinHebrew\0PC8-"
748 "Turkish\0csPC8Turkish\0IBM-Symbols\0csIBMSymbols\0IBM-Thai\0csIBMThai\0HP-Legal\0csHPLegal\0HP-Pi-"
749 "font\0csHPPiFont\0HP-Math8\0csHPMath8\0Adobe-Symbol-Encoding\0csHPPSMath\0HP-DeskTop\0csHPDesktop\0Ventura-"
750 "Math\0csVenturaMath\0Microsoft-Publishing\0csMicrosoftPublishing\0Windows-"
751 "31J\0csWindows31J\0GB2312\0csGB2312\0Big5\0csBig5\0macintosh\0mac\0csMacintosh\0IBM037\0cp037\0ebcdic-cp-"
752 "us\0ebcdic-cp-ca\0ebcdic-cp-wt\0ebcdic-cp-nl\0csIBM037\0IBM038\0EBCDIC-"
753 "INT\0cp038\0csIBM038\0IBM273\0CP273\0csIBM273\0IBM274\0EBCDIC-BE\0CP274\0csIBM274\0IBM275\0EBCDIC-"
754 "BR\0cp275\0csIBM275\0IBM277\0EBCDIC-CP-DK\0EBCDIC-CP-NO\0csIBM277\0IBM278\0CP278\0ebcdic-cp-fi\0ebcdic-cp-"
755 "se\0csIBM278\0IBM280\0CP280\0ebcdic-cp-it\0csIBM280\0IBM281\0EBCDIC-JP-"
756 "E\0cp281\0csIBM281\0IBM284\0CP284\0ebcdic-cp-es\0csIBM284\0IBM285\0CP285\0ebcdic-cp-"
757 "gb\0csIBM285\0IBM290\0cp290\0EBCDIC-JP-kana\0csIBM290\0IBM297\0cp297\0ebcdic-cp-"
758 "fr\0csIBM297\0IBM420\0cp420\0ebcdic-cp-ar1\0csIBM420\0IBM423\0cp423\0ebcdic-cp-"
759 "gr\0csIBM423\0IBM424\0cp424\0ebcdic-cp-he\0csIBM424\0IBM500\0CP500\0ebcdic-cp-be\0ebcdic-cp-"
760 "ch\0csIBM500\0IBM851\0cp851\0851\0csIBM851\0IBM855\0cp855\0855\0csIBM855\0IBM857\0cp857\0857\0csIBM857\0IBM860\0"
761 "cp860\0860\0csIBM860\0IBM861\0cp861\0861\0cp-"
762 "is\0csIBM861\0IBM863\0cp863\0863\0csIBM863\0IBM864\0cp864\0csIBM864\0IBM865\0cp865\0865\0csIBM865\0IBM868\0CP868"
763 "\0cp-ar\0csIBM868\0IBM869\0cp869\0869\0cp-gr\0csIBM869\0IBM870\0CP870\0ebcdic-cp-roece\0ebcdic-cp-"
764 "yu\0csIBM870\0IBM871\0CP871\0ebcdic-cp-is\0csIBM871\0IBM880\0cp880\0EBCDIC-"
765 "Cyrillic\0csIBM880\0IBM891\0cp891\0csIBM891\0IBM903\0cp903\0csIBM903\0IBM904\0cp904\0904\0csIBBM904\0IBM905\0CP9"
766 "05\0ebcdic-cp-tr\0csIBM905\0IBM918\0CP918\0ebcdic-cp-ar2\0csIBM918\0IBM1026\0CP1026\0csIBM1026\0EBCDIC-AT-"
767 "DE\0csIBMEBCDICATDE\0EBCDIC-AT-DE-A\0csEBCDICATDEA\0EBCDIC-CA-FR\0csEBCDICCAFR\0EBCDIC-DK-"
768 "NO\0csEBCDICDKNO\0EBCDIC-DK-NO-A\0csEBCDICDKNOA\0EBCDIC-FI-SE\0csEBCDICFISE\0EBCDIC-FI-SE-"
769 "A\0csEBCDICFISEA\0EBCDIC-FR\0csEBCDICFR\0EBCDIC-IT\0csEBCDICIT\0EBCDIC-PT\0csEBCDICPT\0EBCDIC-"
770 "ES\0csEBCDICES\0EBCDIC-ES-A\0csEBCDICESA\0EBCDIC-ES-S\0csEBCDICESS\0EBCDIC-UK\0csEBCDICUK\0EBCDIC-"
771 "US\0csEBCDICUS\0UNKNOWN-"
772 "8BIT\0csUnknown8BiT\0MNEMONIC\0csMnemonic\0MNEM\0csMnem\0VISCII\0csVISCII\0VIQR\0csVIQR\0KOI8-R\0csKOI8R\0HZ-GB-"
773 "2312\0IBM866\0cp866\0866\0csIBM866\0IBM775\0cp775\0csPC775Baltic\0KOI8-"
774 "U\0csKOI8U\0IBM00858\0CCSID00858\0CP00858\0PC-Multilingual-850+"
775 "euro\0csIBM00858\0IBM00924\0CCSID00924\0CP00924\0ebcdic-Latin9--"
776 "euro\0csIBM00924\0IBM01140\0CCSID01140\0CP01140\0ebcdic-us-37+"
777 "euro\0csIBM01140\0IBM01141\0CCSID01141\0CP01141\0ebcdic-de-273+"
778 "euro\0csIBM01141\0IBM01142\0CCSID01142\0CP01142\0ebcdic-dk-277+euro\0ebcdic-no-277+"
779 "euro\0csIBM01142\0IBM01143\0CCSID01143\0CP01143\0ebcdic-fi-278+euro\0ebcdic-se-278+"
780 "euro\0csIBM01143\0IBM01144\0CCSID01144\0CP01144\0ebcdic-it-280+"
781 "euro\0csIBM01144\0IBM01145\0CCSID01145\0CP01145\0ebcdic-es-284+"
782 "euro\0csIBM01145\0IBM01146\0CCSID01146\0CP01146\0ebcdic-gb-285+"
783 "euro\0csIBM01146\0IBM01147\0CCSID01147\0CP01147\0ebcdic-fr-297+"
784 "euro\0csIBM01147\0IBM01148\0CCSID01148\0CP01148\0ebcdic-international-500+"
785 "euro\0csIBM01148\0IBM01149\0CCSID01149\0CP01149\0ebcdic-is-871+euro\0csIBM01149\0Big5-"
786 "HKSCS\0csBig5HKSCS\0IBM1047\0IBM-1047\0csIBM1047\0PTCP154\0csPTCP154\0PT154\0CP154\0Cyrillic-Asian\0Amiga-"
787 "1251\0Ami1251\0Amiga1251\0Ami-1251\0csAmiga1251\0KOI7-"
788 "switched\0csKOI7switched\0BRF\0csBRF\0TSCII\0csTSCII\0CP51932\0csCP51932\0windows-874\0cswindows874\0windows-"
789 "1250\0cswindows1250\0windows-1251\0cswindows1251\0windows-1252\0cswindows1252\0windows-"
790 "1253\0cswindows1253\0windows-1254\0cswindows1254\0windows-1255\0cswindows1255\0windows-"
791 "1256\0cswindows1256\0windows-1257\0cswindows1257\0windows-1258\0cswindows1258\0TIS-620\0csTIS620\0ISO-8859-"
792 "11\0CP50220\0csCP50220\0";
793
794 struct __offset_table {
795 constexpr static unsigned long long __num_aliases =
796 std::count(__aliases_string, __aliases_string + sizeof(__aliases_string), '\0') + 1;
797 unsigned short __table[__num_aliases];
798 };
799
800 static constexpr __offset_table __alias_offsets = [] {
801 __offset_table __aliases{};
802 __aliases.__table[0] = sizeof(__aliases_string) - 1;
803 __aliases.__table[1] = sizeof(__aliases_string) - 1;
804 __aliases.__table[2] = 0;
805
806 unsigned long long __idx = 3;
807
808 for (unsigned short __pos = 0; __pos < sizeof(__aliases_string) - 1 && __idx < __offset_table::__num_aliases;
809 __pos++) {
810 if (__aliases_string[__pos] == '\0') {
811 __aliases.__table[__idx++] = __pos + 1;
812 }
813 }
814
815 return __aliases;
816 }();
817};
818
819template <>
820struct hash<text_encoding> {
821 [[nodiscard]] static size_t operator()(const text_encoding& __enc) noexcept {
822 return std::hash<std::text_encoding::id>()(__enc.mib());
823 }
824};
825
826template <>
827inline constexpr bool ranges::enable_borrowed_range<text_encoding::aliases_view> = true;
828
829_LIBCPP_END_NAMESPACE_STD
830
831# endif // _LIBCPP_STD_VER >= 26
832
833#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
834
835#endif // _LIBCPP_TEXT_ENCODING
lib/libcxx/include/thread+13-7
......@@ -91,6 +91,11 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
9191#else
9292# include <__config>
9393
94// standard-mandated includes
95
96// [thread.syn]
97# include <compare>
98
9499# if _LIBCPP_HAS_THREADS
95100
96101# include <__thread/this_thread.h>
......@@ -106,28 +111,29 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
106111
107112# include <version>
108113
109// standard-mandated includes
110
111// [thread.syn]
112# include <compare>
113
114114# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
115115# pragma GCC system_header
116116# endif
117117
118118# endif // _LIBCPP_HAS_THREADS
119119
120# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
120# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 17
121121# include <chrono>
122122# endif
123123
124# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
124# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
125125# include <cstring>
126126# include <functional>
127127# include <new>
128128# include <system_error>
129129# include <type_traits>
130130# endif
131
132# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
133# include <atomic>
134# include <sstream>
135# endif
136
131137#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
132138
133139#endif // _LIBCPP_THREAD
lib/libcxx/include/tuple+53-65
......@@ -255,7 +255,6 @@ template <class... Types>
255255# include <__type_traits/is_same.h>
256256# include <__type_traits/is_swappable.h>
257257# include <__type_traits/is_trivially_relocatable.h>
258# include <__type_traits/lazy.h>
259258# include <__type_traits/maybe_const.h>
260259# include <__type_traits/nat.h>
261260# include <__type_traits/negation.h>
......@@ -284,10 +283,10 @@ template <class... Types>
284283_LIBCPP_PUSH_MACROS
285284# include <__undef_macros>
286285
287_LIBCPP_BEGIN_NAMESPACE_STD
288
289286# ifndef _LIBCPP_CXX03_LANG
290287
288_LIBCPP_BEGIN_NAMESPACE_STD
289
291290template <size_t _Ip, class _Tp, class _Up>
292291_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(const _Tp& __x, const _Up& __y) {
293292 if constexpr (_Ip == 0)
......@@ -296,20 +295,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(c
296295 return std::__tuple_compare_equal<_Ip - 1>(__x, __y) && std::get<_Ip - 1>(__x) == std::get<_Ip - 1>(__y);
297296}
298297
299# if _LIBCPP_STD_VER >= 26
300template <class _Tp, class _Up, class _IndexSeq = make_index_sequence<tuple_size_v<_Tp>>>
301inline constexpr bool __can_tuple_compare_equal = false;
302
303// TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends
304// because the resolution of CWG2369 landed in LLVM-21.
305template <class _Tp, class _Up, size_t... _Is>
306 requires(tuple_size_v<_Tp> == tuple_size_v<_Up>)
307inline constexpr bool __can_tuple_compare_equal<_Tp, _Up, index_sequence<_Is...>> =
308 __all<requires(const tuple_element_t<_Is, _Tp>& __t, const tuple_element_t<_Is, _Up>& __u) {
309 { __t == __u } -> __boolean_testable;
310 }...>::value;
311# endif // _LIBCPP_STD_VER >= 26
312
313298# if _LIBCPP_STD_VER >= 20
314299template <class _Ret, class _Tp, class _Up, size_t... _Is>
315300_LIBCPP_HIDE_FROM_ABI constexpr _Ret __tuple_compare_three_way(const _Tp& __x, const _Up& __y, index_sequence<_Is...>) {
......@@ -324,24 +309,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Ret __tuple_compare_three_way(const _Tp& __x, c
324309template <class _Tp>
325310concept __tuple_like_no_tuple = __tuple_like<_Tp> && !__is_tuple_v<_Tp>;
326311
327template <class _Tp, class _Up, class _IndexSeq>
328struct __tuple_common_comparison_category_impl {};
312template <__tuple_like _Tp, class _IndexSequence = make_index_sequence<tuple_size_v<_Tp>>>
313struct __to_tuple;
329314
330// TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends
331// because the resolution of CWG2369 landed in LLVM-21.
332template <class _Tp, class _Up, size_t... _Is>
333 requires(tuple_size_v<_Tp> == tuple_size_v<_Up>) && requires {
334 typename common_comparison_category_t<
335 __synth_three_way_result<tuple_element_t<_Is, _Tp>, tuple_element_t<_Is, _Up>>...>;
336 }
337struct __tuple_common_comparison_category_impl<_Tp, _Up, index_sequence<_Is...>> {
338 using type _LIBCPP_NODEBUG =
339 common_comparison_category_t<__synth_three_way_result<tuple_element_t<_Is, _Tp>, tuple_element_t<_Is, _Up>>...>;
315template <__tuple_like _Tp, size_t... _Index>
316struct __to_tuple<_Tp, index_sequence<_Index...>> {
317 using type _LIBCPP_NODEBUG = tuple<tuple_element_t<_Index, _Tp>...>;
340318};
341319
342template <__tuple_like _Tp, __tuple_like _Up>
343using __tuple_common_comparison_category _LIBCPP_NODEBUG =
344 __tuple_common_comparison_category_impl<_Tp, _Up, make_index_sequence<tuple_size_v<_Tp>>>::type;
320template <__tuple_like _Tp>
321using __to_tuple_t _LIBCPP_NODEBUG = typename __to_tuple<_Tp>::type;
345322# endif // _LIBCPP_STD_VER >= 23
346323
347324// __tuple_leaf
......@@ -602,30 +579,28 @@ public:
602579 template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
603580 template <class...> class _IsDefault = is_default_constructible,
604581 __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
605 _LIBCPP_HIDE_FROM_ABI constexpr explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
582 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_And<_IsImpDefault<_Tp>...>::value)
606583 tuple() noexcept(_And<is_nothrow_default_constructible<_Tp>...>::value) {}
607584
608585 template <class _Alloc,
609586 template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
610587 template <class...> class _IsDefault = is_default_constructible,
611588 __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
612 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
613 tuple(allocator_arg_t, _Alloc const& __a)
589 _LIBCPP_HIDE_FROM_ABI
590 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<_IsImpDefault<_Tp>...>::value) tuple(allocator_arg_t, _Alloc const& __a)
614591 : __base_(allocator_arg_t(), __a, __value_init{}) {}
615592
616593 // tuple(const T&...) constructors (including allocator_arg_t variants)
617594 template <template <class...> class _And = _And,
618595 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
619 _LIBCPP_HIDE_FROM_ABI
620 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
596 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_And<is_convertible<const _Tp&, _Tp>...>::value)
621597 tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value)
622598 : __base_(__forward_args{}, __t...) {}
623599
624600 template <class _Alloc,
625601 template <class...> class _And = _And,
626602 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
627 _LIBCPP_HIDE_FROM_ABI
628 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
603 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<is_convertible<const _Tp&, _Tp>...>::value)
629604 tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t)
630605 : __base_(allocator_arg_t(), __a, __forward_args{}, __t...) {}
631606
......@@ -644,7 +619,7 @@ public:
644619 template <class... _Up,
645620 __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
646621 int> = 0>
647 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_And<is_convertible<_Up, _Tp>...>::value)
648623 tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
649624 : __base_(__forward_args{}, std::forward<_Up>(__u)...) {}
650625
......@@ -652,7 +627,7 @@ public:
652627 class... _Up,
653628 __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
654629 int> = 0>
655 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
630 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<is_convertible<_Up, _Tp>...>::value)
656631 tuple(allocator_arg_t, const _Alloc& __a, _Up&&... __u)
657632 : __base_(allocator_arg_t(), __a, __forward_args{}, std::forward<_Up>(__u)...) {}
658633
......@@ -690,26 +665,22 @@ public:
690665 _Not<is_same<_OtherTuple, const tuple&> >,
691666 _Not<is_same<_OtherTuple, tuple&&> >,
692667 is_constructible<_Tp, __copy_cvref_t<_OtherTuple, _Up> >...,
693 _Lazy<_Or,
694 _BoolConstant<sizeof...(_Tp) != 1>,
695 // _Tp and _Up are 1-element packs - the pack expansions look
696 // weird to avoid tripping up the type traits in degenerate cases
697 _Lazy<_And,
698 _Not<is_same<_Tp, _Up> >...,
699 _Not<is_convertible<_OtherTuple, _Tp> >...,
700 _Not<is_constructible<_Tp, _OtherTuple> >... > > > {};
668 _Or<_BoolConstant<sizeof...(_Tp) != 1>,
669 // _Tp and _Up are 1-element packs - the pack expansions look
670 // weird to avoid tripping up the type traits in degenerate cases
671 _And<_Not<is_same<_Tp, _Up> >...,
672 _Not<is_convertible<_OtherTuple, _Tp> >...,
673 _Not<is_constructible<_Tp, _OtherTuple> >... > > > {};
701674
702675 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
703 _LIBCPP_HIDE_FROM_ABI
704 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
676 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_And<is_convertible<const _Up&, _Tp>...>::value)
705677 tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)
706678 : __base_(__from_tuple(), __t) {}
707679
708680 template <class... _Up,
709681 class _Alloc,
710682 __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
711 _LIBCPP_HIDE_FROM_ABI
712 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
683 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<is_convertible<const _Up&, _Tp>...>::value)
713684 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
714685 : __base_(allocator_arg_t(), __a, __from_tuple(), __t) {}
715686
......@@ -717,25 +688,25 @@ public:
717688 // tuple(tuple<U...>&) constructors (including allocator_arg_t variants)
718689
719690 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
720 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t)
691 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_And<is_convertible<_Up&, _Tp>...>::value) tuple(tuple<_Up...>& __t)
721692 : __base_(__from_tuple(), __t) {}
722693
723694 template <class _Alloc, class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<tuple<_Up...>&>::value>* = nullptr>
724 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<_Up&, _Tp>...>::value)
695 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_And<is_convertible<_Up&, _Tp>...>::value)
725696 tuple(allocator_arg_t, const _Alloc& __alloc, tuple<_Up...>& __t)
726697 : __base_(allocator_arg_t(), __alloc, __from_tuple(), __t) {}
727698# endif // _LIBCPP_STD_VER >= 23
728699
729700 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
730701 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
731 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_And<is_convertible<_Up, _Tp>...>::value)
732703 tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
733704 : __base_(__from_tuple(), std::move(__t)) {}
734705
735706 template <class _Alloc,
736707 class... _Up,
737708 __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
738 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
709 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(!_And<is_convertible<_Up, _Tp>...>::value)
739710 tuple(allocator_arg_t, const _Alloc& __a, tuple<_Up...>&& __t)
740711 : __base_(allocator_arg_t(), __a, __from_tuple(), std::move(__t)) {}
741712
......@@ -743,14 +714,14 @@ public:
743714 // tuple(const tuple<U...>&&) constructors (including allocator_arg_t variants)
744715
745716 template <class... _Up, enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
746 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
717 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_And<is_convertible<const _Up&&, _Tp>...>::value)
747718 tuple(const tuple<_Up...>&& __t)
748719 : __base_(__from_tuple(), std::move(__t)) {}
749720
750721 template <class _Alloc,
751722 class... _Up,
752723 enable_if_t< _EnableCtorFromUTypesTuple<const tuple<_Up...>&&>::value>* = nullptr>
753 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_Lazy<_And, is_convertible<const _Up&&, _Tp>...>::value)
724 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_And<is_convertible<const _Up&&, _Tp>...>::value)
754725 tuple(allocator_arg_t, const _Alloc& __alloc, const tuple<_Up...>&& __t)
755726 : __base_(allocator_arg_t(), __alloc, __from_tuple(), std::move(__t)) {}
756727# endif // _LIBCPP_STD_VER >= 23
......@@ -1011,20 +982,37 @@ public:
1011982 __base_.swap(__t.__base_);
1012983 }
1013984
985 template <class _Tuple>
986 static constexpr bool __can_compare_equal = false;
987
988 template <class... _Up>
989 static constexpr bool __can_compare_equal<tuple<_Up...>> = __all<requires(const _Tp& __t, const _Up& __u) {
990 { __t == __u } -> __boolean_testable;
991 }...>::value;
992
1014993 template <__tuple_like_no_tuple _UTuple>
1015994# if _LIBCPP_STD_VER >= 26
1016 requires __can_tuple_compare_equal<tuple, _UTuple> && (sizeof...(_Tp) == tuple_size_v<_UTuple>)
995 requires(sizeof...(_Tp) == tuple_size_v<_UTuple>) && __can_compare_equal<__to_tuple_t<_UTuple>>
1017996# endif // _LIBCPP_STD_VER >= 26
1018997 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(const tuple& __x, const _UTuple& __y) {
1019998 static_assert(sizeof...(_Tp) == tuple_size_v<_UTuple>, "Can't compare tuple-like values of different sizes");
1020999 return std::__tuple_compare_equal<sizeof...(_Tp)>(__x, __y);
10211000 }
10221001
1002 template <class _Tuple>
1003 struct __common_comparison_category_with;
1004
1005 template <class... _Up>
1006 requires requires { typename common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>; }
1007 struct __common_comparison_category_with<tuple<_Up...>> {
1008 using type _LIBCPP_NODEBUG = common_comparison_category_t<__synth_three_way_result<_Tp, _Up>...>;
1009 };
1010
10231011 template <__tuple_like_no_tuple _UTuple>
10241012 requires(sizeof...(_Tp) == tuple_size_v<_UTuple>)
1025 _LIBCPP_HIDE_FROM_ABI friend constexpr __tuple_common_comparison_category<tuple, _UTuple>
1013 _LIBCPP_HIDE_FROM_ABI friend constexpr typename __common_comparison_category_with<__to_tuple_t<_UTuple>>::type
10261014 operator<=>(const tuple& __x, const _UTuple& __y) {
1027 return std::__tuple_compare_three_way<__tuple_common_comparison_category<tuple, _UTuple>>(
1015 return std::__tuple_compare_three_way<typename __common_comparison_category_with<__to_tuple_t<_UTuple>>::type>(
10281016 __x, __y, index_sequence_for<_Tp...>{});
10291017 }
10301018# endif // _LIBCPP_STD_VER >= 23
......@@ -1455,15 +1443,15 @@ template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp
14551443
14561444# endif // _LIBCPP_STD_VER >= 17
14571445
1458#endif // !defined(_LIBCPP_CXX03_LANG)
1459
14601446_LIBCPP_END_NAMESPACE_STD
14611447
1448#endif // !defined(_LIBCPP_CXX03_LANG)
1449
14621450_LIBCPP_POP_MACROS
14631451
14641452// clang-format on
14651453
1466# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1454# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
14671455# include <cstddef>
14681456# include <exception>
14691457# include <iosfwd>
lib/libcxx/include/typeindex+1-1
......@@ -102,7 +102,7 @@ struct hash<type_index> : public __unary_function<type_index, size_t> {
102102
103103_LIBCPP_END_NAMESPACE_STD
104104
105# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
105# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
106106# include <cstddef>
107107# include <iosfwd>
108108# include <new>
lib/libcxx/include/typeinfo+2-2
......@@ -302,7 +302,7 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info
302302protected:
303303 typedef __type_info_implementations::__impl __impl;
304304
305 __impl::__type_name_t __type_name;
305 _LIBCPP_DISABLE_POINTER_FIELD_PROTECTION __impl::__type_name_t __type_name;
306306
307307 _LIBCPP_HIDE_FROM_ABI explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {}
308308
......@@ -389,7 +389,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
389389}
390390_LIBCPP_END_NAMESPACE_STD
391391
392# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
392# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
393393# include <cstddef>
394394# include <cstdlib>
395395# include <type_traits>
lib/libcxx/include/unordered_map+67-31
......@@ -77,16 +77,16 @@ public:
7777 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
7878 const allocator_type& a = allocator_type());
7979 unordered_map(size_type n, const allocator_type& a)
80 : unordered_map(n, hasher(), key_equal(), a) {} // C++14
80 : unordered_map(n, hasher(), key_equal(), a) {}
8181 unordered_map(size_type n, const hasher& hf, const allocator_type& a)
82 : unordered_map(n, hf, key_equal(), a) {} // C++14
82 : unordered_map(n, hf, key_equal(), a) {}
8383 template <class InputIterator>
8484 unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
85 : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14
85 : unordered_map(f, l, n, hasher(), key_equal(), a) {}
8686 template <class InputIterator>
8787 unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf,
8888 const allocator_type& a)
89 : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14
89 : unordered_map(f, l, n, hf, key_equal(), a) {}
9090 template<container-compatible-range<value_type> R>
9191 unordered_map(from_range_t, R&& rg, size_type n, const allocator_type& a)
9292 : unordered_map(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
......@@ -94,10 +94,10 @@ public:
9494 unordered_map(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
9595 : unordered_map(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
9696 unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a)
97 : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14
97 : unordered_map(il, n, hasher(), key_equal(), a) {}
9898 unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf,
9999 const allocator_type& a)
100 : unordered_map(il, n, hf, key_equal(), a) {} // C++14
100 : unordered_map(il, n, hf, key_equal(), a) {}
101101 ~unordered_map();
102102 unordered_map& operator=(const unordered_map&);
103103 unordered_map& operator=(unordered_map&&)
......@@ -363,16 +363,16 @@ public:
363363 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
364364 const allocator_type& a = allocator_type());
365365 unordered_multimap(size_type n, const allocator_type& a)
366 : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14
366 : unordered_multimap(n, hasher(), key_equal(), a) {}
367367 unordered_multimap(size_type n, const hasher& hf, const allocator_type& a)
368 : unordered_multimap(n, hf, key_equal(), a) {} // C++14
368 : unordered_multimap(n, hf, key_equal(), a) {}
369369 template <class InputIterator>
370370 unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a)
371 : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14
371 : unordered_multimap(f, l, n, hasher(), key_equal(), a) {}
372372 template <class InputIterator>
373373 unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf,
374374 const allocator_type& a)
375 : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14
375 : unordered_multimap(f, l, n, hf, key_equal(), a) {}
376376 template<container-compatible-range<value_type> R>
377377 unordered_multimap(from_range_t, R&& rg, size_type n, const allocator_type& a)
378378 : unordered_multimap(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
......@@ -380,10 +380,10 @@ public:
380380 unordered_multimap(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
381381 : unordered_multimap(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
382382 unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a)
383 : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14
383 : unordered_multimap(il, n, hasher(), key_equal(), a) {}
384384 unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf,
385385 const allocator_type& a)
386 : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14
386 : unordered_multimap(il, n, hf, key_equal(), a) {}
387387 ~unordered_multimap();
388388 unordered_multimap& operator=(const unordered_multimap&);
389389 unordered_multimap& operator=(unordered_multimap&&)
......@@ -993,7 +993,6 @@ public:
993993 const key_equal& __eql,
994994 const allocator_type& __a);
995995# endif // _LIBCPP_CXX03_LANG
996# if _LIBCPP_STD_VER >= 14
997996 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const allocator_type& __a)
998997 : unordered_map(__n, hasher(), key_equal(), __a) {}
999998 _LIBCPP_HIDE_FROM_ABI unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a)
......@@ -1007,7 +1006,7 @@ public:
10071006 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
10081007 : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {}
10091008
1010# if _LIBCPP_STD_VER >= 23
1009# if _LIBCPP_STD_VER >= 23
10111010 template <_ContainerCompatibleRange<value_type> _Range>
10121011 _LIBCPP_HIDE_FROM_ABI unordered_map(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
10131012 : unordered_map(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
......@@ -1016,8 +1015,9 @@ public:
10161015 _LIBCPP_HIDE_FROM_ABI
10171016 unordered_map(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
10181017 : unordered_map(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1019# endif
1018# endif
10201019
1020# ifndef _LIBCPP_CXX03_LANG
10211021 _LIBCPP_HIDE_FROM_ABI unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
10221022 : unordered_map(__il, __n, hasher(), key_equal(), __a) {}
10231023 _LIBCPP_HIDE_FROM_ABI
......@@ -1216,11 +1216,17 @@ public:
12161216 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
12171217 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
12181218# if _LIBCPP_STD_VER >= 20
1219 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1219 template <class _K2,
1220 class _Hasher = hasher,
1221 class _Comp = key_equal,
1222 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12201223 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
12211224 return __table_.find(__k);
12221225 }
1223 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1226 template <class _K2,
1227 class _Hasher = hasher,
1228 class _Comp = key_equal,
1229 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12241230 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
12251231 return __table_.find(__k);
12261232 }
......@@ -1230,7 +1236,10 @@ public:
12301236 return __table_.__count_unique(__k);
12311237 }
12321238# if _LIBCPP_STD_VER >= 20
1233 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1239 template <class _K2,
1240 class _Hasher = hasher,
1241 class _Comp = key_equal,
1242 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12341243 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
12351244 return __table_.__count_unique(__k);
12361245 }
......@@ -1239,7 +1248,10 @@ public:
12391248# if _LIBCPP_STD_VER >= 20
12401249 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
12411250
1242 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1251 template <class _K2,
1252 class _Hasher = hasher,
1253 class _Comp = key_equal,
1254 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12431255 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
12441256 return find(__k) != end();
12451257 }
......@@ -1252,11 +1264,17 @@ public:
12521264 return __table_.__equal_range_unique(__k);
12531265 }
12541266# if _LIBCPP_STD_VER >= 20
1255 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1267 template <class _K2,
1268 class _Hasher = hasher,
1269 class _Comp = key_equal,
1270 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12561271 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
12571272 return __table_.__equal_range_unique(__k);
12581273 }
1259 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1274 template <class _K2,
1275 class _Hasher = hasher,
1276 class _Comp = key_equal,
1277 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
12601278 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
12611279 return __table_.__equal_range_unique(__k);
12621280 }
......@@ -1769,7 +1787,6 @@ public:
17691787 const key_equal& __eql,
17701788 const allocator_type& __a);
17711789# endif // _LIBCPP_CXX03_LANG
1772# if _LIBCPP_STD_VER >= 14
17731790 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const allocator_type& __a)
17741791 : unordered_multimap(__n, hasher(), key_equal(), __a) {}
17751792 _LIBCPP_HIDE_FROM_ABI unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a)
......@@ -1783,7 +1800,7 @@ public:
17831800 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
17841801 : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {}
17851802
1786# if _LIBCPP_STD_VER >= 23
1803# if _LIBCPP_STD_VER >= 23
17871804 template <_ContainerCompatibleRange<value_type> _Range>
17881805 _LIBCPP_HIDE_FROM_ABI unordered_multimap(from_range_t, _Range&& __range, size_type __n, const allocator_type& __a)
17891806 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, hasher(), key_equal(), __a) {}
......@@ -1792,8 +1809,9 @@ public:
17921809 _LIBCPP_HIDE_FROM_ABI
17931810 unordered_multimap(from_range_t, _Range&& __range, size_type __n, const hasher& __hf, const allocator_type& __a)
17941811 : unordered_multimap(from_range, std::forward<_Range>(__range), __n, __hf, key_equal(), __a) {}
1795# endif
1812# endif
17961813
1814# ifndef _LIBCPP_CXX03_LANG
17971815 _LIBCPP_HIDE_FROM_ABI unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
17981816 : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {}
17991817 _LIBCPP_HIDE_FROM_ABI
......@@ -1936,11 +1954,17 @@ public:
19361954 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
19371955 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
19381956# if _LIBCPP_STD_VER >= 20
1939 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1957 template <class _K2,
1958 class _Hasher = hasher,
1959 class _Comp = key_equal,
1960 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19401961 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
19411962 return __table_.find(__k);
19421963 }
1943 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1964 template <class _K2,
1965 class _Hasher = hasher,
1966 class _Comp = key_equal,
1967 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19441968 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
19451969 return __table_.find(__k);
19461970 }
......@@ -1950,7 +1974,10 @@ public:
19501974 return __table_.__count_multi(__k);
19511975 }
19521976# if _LIBCPP_STD_VER >= 20
1953 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1977 template <class _K2,
1978 class _Hasher = hasher,
1979 class _Comp = key_equal,
1980 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19541981 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
19551982 return __table_.__count_multi(__k);
19561983 }
......@@ -1959,7 +1986,10 @@ public:
19591986# if _LIBCPP_STD_VER >= 20
19601987 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
19611988
1962 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1989 template <class _K2,
1990 class _Hasher = hasher,
1991 class _Comp = key_equal,
1992 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19631993 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
19641994 return find(__k) != end();
19651995 }
......@@ -1972,11 +2002,17 @@ public:
19722002 return __table_.__equal_range_multi(__k);
19732003 }
19742004# if _LIBCPP_STD_VER >= 20
1975 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2005 template <class _K2,
2006 class _Hasher = hasher,
2007 class _Comp = key_equal,
2008 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19762009 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
19772010 return __table_.__equal_range_multi(__k);
19782011 }
1979 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
2012 template <class _K2,
2013 class _Hasher = hasher,
2014 class _Comp = key_equal,
2015 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
19802016 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
19812017 return __table_.__equal_range_multi(__k);
19822018 }
......@@ -2345,7 +2381,7 @@ _LIBCPP_END_NAMESPACE_STD
23452381
23462382_LIBCPP_POP_MACROS
23472383
2348# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
2384# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
23492385# include <algorithm>
23502386# include <bit>
23512387# include <cmath>
lib/libcxx/include/unordered_set+61-37
......@@ -76,22 +76,22 @@ public:
7676 unordered_set(initializer_list<value_type>, size_type n = 0,
7777 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
7878 const allocator_type& a = allocator_type());
79 unordered_set(size_type n, const allocator_type& a); // C++14
80 unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14
79 unordered_set(size_type n, const allocator_type& a);
80 unordered_set(size_type n, const hasher& hf, const allocator_type& a);
8181 template <class InputIterator>
82 unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
82 unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
8383 template <class InputIterator>
8484 unordered_set(InputIterator f, InputIterator l, size_type n,
85 const hasher& hf, const allocator_type& a); // C++14
85 const hasher& hf, const allocator_type& a);
8686 template<container-compatible-range<value_type> R>
8787 unordered_set(from_range_t, R&& rg, size_type n, const allocator_type& a)
8888 : unordered_set(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
8989 template<container-compatible-range<value_type> R>
9090 unordered_set(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
9191 : unordered_set(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
92 unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
92 unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a);
9393 unordered_set(initializer_list<value_type> il, size_type n,
94 const hasher& hf, const allocator_type& a); // C++14
94 const hasher& hf, const allocator_type& a);
9595 ~unordered_set();
9696 unordered_set& operator=(const unordered_set&);
9797 unordered_set& operator=(unordered_set&&)
......@@ -324,22 +324,22 @@ public:
324324 unordered_multiset(initializer_list<value_type>, size_type n = /see below/,
325325 const hasher& hf = hasher(), const key_equal& eql = key_equal(),
326326 const allocator_type& a = allocator_type());
327 unordered_multiset(size_type n, const allocator_type& a); // C++14
328 unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14
327 unordered_multiset(size_type n, const allocator_type& a);
328 unordered_multiset(size_type n, const hasher& hf, const allocator_type& a);
329329 template <class InputIterator>
330 unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14
330 unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a);
331331 template <class InputIterator>
332332 unordered_multiset(InputIterator f, InputIterator l, size_type n,
333 const hasher& hf, const allocator_type& a); // C++14
333 const hasher& hf, const allocator_type& a);
334334 template<container-compatible-range<value_type> R>
335335 unordered_multiset(from_range_t, R&& rg, size_type n, const allocator_type& a)
336336 : unordered_multiset(from_range, std::forward<R>(rg), n, hasher(), key_equal(), a) { } // C++23
337337 template<container-compatible-range<value_type> R>
338338 unordered_multiset(from_range_t, R&& rg, size_type n, const hasher& hf, const allocator_type& a)
339339 : unordered_multiset(from_range, std::forward<R>(rg), n, hf, key_equal(), a) { } // C++23
340 unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14
340 unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a);
341341 unordered_multiset(initializer_list<value_type> il, size_type n,
342 const hasher& hf, const allocator_type& a); // C++14
342 const hasher& hf, const allocator_type& a);
343343 ~unordered_multiset();
344344 unordered_multiset& operator=(const unordered_multiset&);
345345 unordered_multiset& operator=(unordered_multiset&&)
......@@ -634,12 +634,10 @@ public:
634634 _LIBCPP_HIDE_FROM_ABI unordered_set() _NOEXCEPT_(is_nothrow_default_constructible<__table>::value) {}
635635 explicit _LIBCPP_HIDE_FROM_ABI
636636 unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
637# if _LIBCPP_STD_VER >= 14
638637 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const allocator_type& __a)
639638 : unordered_set(__n, hasher(), key_equal(), __a) {}
640639 inline _LIBCPP_HIDE_FROM_ABI unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a)
641640 : unordered_set(__n, __hf, key_equal(), __a) {}
642# endif
643641 _LIBCPP_HIDE_FROM_ABI
644642 unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
645643 template <class _InputIterator>
......@@ -677,7 +675,6 @@ public:
677675 }
678676# endif
679677
680# if _LIBCPP_STD_VER >= 14
681678 template <class _InputIterator>
682679 inline _LIBCPP_HIDE_FROM_ABI
683680 unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
......@@ -686,7 +683,6 @@ public:
686683 _LIBCPP_HIDE_FROM_ABI unordered_set(
687684 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
688685 : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {}
689# endif
690686
691687# if _LIBCPP_STD_VER >= 23
692688 template <_ContainerCompatibleRange<value_type> _Range>
......@@ -717,14 +713,12 @@ public:
717713 const hasher& __hf,
718714 const key_equal& __eql,
719715 const allocator_type& __a);
720# if _LIBCPP_STD_VER >= 14
721716 inline _LIBCPP_HIDE_FROM_ABI
722717 unordered_set(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
723718 : unordered_set(__il, __n, hasher(), key_equal(), __a) {}
724719 inline _LIBCPP_HIDE_FROM_ABI
725720 unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
726721 : unordered_set(__il, __n, __hf, key_equal(), __a) {}
727# endif
728722# endif // _LIBCPP_CXX03_LANG
729723 _LIBCPP_HIDE_FROM_ABI ~unordered_set() {
730724 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
......@@ -844,11 +838,17 @@ public:
844838 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
845839 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
846840# if _LIBCPP_STD_VER >= 20
847 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
841 template <class _K2,
842 class _Hasher = hasher,
843 class _Comp = key_equal,
844 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
848845 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
849846 return __table_.find(__k);
850847 }
851 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
848 template <class _K2,
849 class _Hasher = hasher,
850 class _Comp = key_equal,
851 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
852852 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
853853 return __table_.find(__k);
854854 }
......@@ -858,7 +858,10 @@ public:
858858 return __table_.__count_unique(__k);
859859 }
860860# if _LIBCPP_STD_VER >= 20
861 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
861 template <class _K2,
862 class _Hasher = hasher,
863 class _Comp = key_equal,
864 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
862865 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
863866 return __table_.__count_unique(__k);
864867 }
......@@ -867,7 +870,10 @@ public:
867870# if _LIBCPP_STD_VER >= 20
868871 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
869872
870 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
873 template <class _K2,
874 class _Hasher = hasher,
875 class _Comp = key_equal,
876 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
871877 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
872878 return find(__k) != end();
873879 }
......@@ -880,11 +886,17 @@ public:
880886 return __table_.__equal_range_unique(__k);
881887 }
882888# if _LIBCPP_STD_VER >= 20
883 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
889 template <class _K2,
890 class _Hasher = hasher,
891 class _Comp = key_equal,
892 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
884893 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
885894 return __table_.__equal_range_unique(__k);
886895 }
887 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
896 template <class _K2,
897 class _Hasher = hasher,
898 class _Comp = key_equal,
899 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
888900 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
889901 return __table_.__equal_range_unique(__k);
890902 }
......@@ -1232,12 +1244,10 @@ public:
12321244 unordered_multiset(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal());
12331245 _LIBCPP_HIDE_FROM_ABI
12341246 unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a);
1235# if _LIBCPP_STD_VER >= 14
12361247 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const allocator_type& __a)
12371248 : unordered_multiset(__n, hasher(), key_equal(), __a) {}
12381249 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a)
12391250 : unordered_multiset(__n, __hf, key_equal(), __a) {}
1240# endif
12411251 template <class _InputIterator>
12421252 _LIBCPP_HIDE_FROM_ABI unordered_multiset(_InputIterator __first, _InputIterator __last);
12431253 template <class _InputIterator>
......@@ -1273,7 +1283,6 @@ public:
12731283 }
12741284# endif
12751285
1276# if _LIBCPP_STD_VER >= 14
12771286 template <class _InputIterator>
12781287 inline _LIBCPP_HIDE_FROM_ABI
12791288 unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a)
......@@ -1282,7 +1291,6 @@ public:
12821291 inline _LIBCPP_HIDE_FROM_ABI unordered_multiset(
12831292 _InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const allocator_type& __a)
12841293 : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {}
1285# endif
12861294
12871295# if _LIBCPP_STD_VER >= 23
12881296 template <_ContainerCompatibleRange<value_type> _Range>
......@@ -1313,14 +1321,12 @@ public:
13131321 const hasher& __hf,
13141322 const key_equal& __eql,
13151323 const allocator_type& __a);
1316# if _LIBCPP_STD_VER >= 14
13171324 inline _LIBCPP_HIDE_FROM_ABI
13181325 unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a)
13191326 : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {}
13201327 inline _LIBCPP_HIDE_FROM_ABI
13211328 unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a)
13221329 : unordered_multiset(__il, __n, __hf, key_equal(), __a) {}
1323# endif
13241330# endif // _LIBCPP_CXX03_LANG
13251331 _LIBCPP_HIDE_FROM_ABI ~unordered_multiset() {
13261332 static_assert(sizeof(std::__diagnose_unordered_container_requirements<_Value, _Hash, _Pred>(0)), "");
......@@ -1443,11 +1449,17 @@ public:
14431449 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
14441450 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
14451451# if _LIBCPP_STD_VER >= 20
1446 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1452 template <class _K2,
1453 class _Hasher = hasher,
1454 class _Comp = key_equal,
1455 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14471456 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
14481457 return __table_.find(__k);
14491458 }
1450 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1459 template <class _K2,
1460 class _Hasher = hasher,
1461 class _Comp = key_equal,
1462 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14511463 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
14521464 return __table_.find(__k);
14531465 }
......@@ -1457,7 +1469,10 @@ public:
14571469 return __table_.__count_multi(__k);
14581470 }
14591471# if _LIBCPP_STD_VER >= 20
1460 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1472 template <class _K2,
1473 class _Hasher = hasher,
1474 class _Comp = key_equal,
1475 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14611476 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
14621477 return __table_.__count_multi(__k);
14631478 }
......@@ -1466,7 +1481,10 @@ public:
14661481# if _LIBCPP_STD_VER >= 20
14671482 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
14681483
1469 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1484 template <class _K2,
1485 class _Hasher = hasher,
1486 class _Comp = key_equal,
1487 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14701488 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
14711489 return find(__k) != end();
14721490 }
......@@ -1479,11 +1497,17 @@ public:
14791497 return __table_.__equal_range_multi(__k);
14801498 }
14811499# if _LIBCPP_STD_VER >= 20
1482 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1500 template <class _K2,
1501 class _Hasher = hasher,
1502 class _Comp = key_equal,
1503 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14831504 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
14841505 return __table_.__equal_range_multi(__k);
14851506 }
1486 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
1507 template <class _K2,
1508 class _Hasher = hasher,
1509 class _Comp = key_equal,
1510 enable_if_t<__is_transparent_v<_Hasher> && __is_transparent_v<_Comp>>* = nullptr>
14871511 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
14881512 return __table_.__equal_range_multi(__k);
14891513 }
......@@ -1812,7 +1836,7 @@ _LIBCPP_END_NAMESPACE_STD
18121836
18131837_LIBCPP_POP_MACROS
18141838
1815# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1839# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
18161840# include <cmath>
18171841# include <concepts>
18181842# include <cstdlib>
lib/libcxx/include/utility+16-5
......@@ -195,6 +195,19 @@ template<class T1, class T2>
195195template<class T1, class T2>
196196 constexpr const T1&& get(const pair<T2, T1>&&) noexcept; // C++14
197197
198// [const.wrap.class], class template constant_wrapper
199template<auto X, class = decltype(X)>
200 struct constant_wrapper; // since C++26
201
202template<class T>
203 concept constexpr-param = // exposition only, since C++26
204 requires { typename constant_wrapper<T::value>; };
205
206struct cw-operators; // exposition only, since C++26
207
208template<auto X>
209 constexpr auto cw = constant_wrapper<X>{}; // since C++26
210
198211// C++14
199212
200213template<class T, T... I>
......@@ -292,6 +305,7 @@ template <class T>
292305# endif
293306
294307# if _LIBCPP_STD_VER >= 26
308# include <__utility/constant_wrapper.h>
295309# include <__variant/monostate.h>
296310# endif
297311
......@@ -315,14 +329,11 @@ template <class T>
315329# pragma GCC system_header
316330# endif
317331
318# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
319# include <limits>
320# endif
321
322# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
332# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
323333# include <cstddef>
324334# include <cstdlib>
325335# include <iosfwd>
336# include <limits>
326337# include <type_traits>
327338# endif
328339#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/valarray+3-1
......@@ -381,6 +381,7 @@ _LIBCPP_PUSH_MACROS
381381# include <__undef_macros>
382382
383383_LIBCPP_BEGIN_NAMESPACE_STD
384_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
384385
385386template <class _Tp>
386387class valarray;
......@@ -3300,11 +3301,12 @@ template <class _Tp>
33003301 return __v.__end_;
33013302}
33023303
3304_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
33033305_LIBCPP_END_NAMESPACE_STD
33043306
33053307_LIBCPP_POP_MACROS
33063308
3307# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
3309# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
33083310# include <algorithm>
33093311# include <concepts>
33103312# include <cstdlib>
lib/libcxx/include/variant+39-19
......@@ -235,7 +235,6 @@ namespace std {
235235# include <__type_traits/conditional.h>
236236# include <__type_traits/conjunction.h>
237237# include <__type_traits/decay.h>
238# include <__type_traits/dependent_type.h>
239238# include <__type_traits/enable_if.h>
240239# include <__type_traits/invoke.h>
241240# include <__type_traits/is_array.h>
......@@ -285,18 +284,33 @@ _LIBCPP_PUSH_MACROS
285284# include <__undef_macros>
286285
287286_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
287_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
288288
289289class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception {
290290public:
291291 [[__nodiscard__]] const char* what() const _NOEXCEPT override;
292292};
293293
294_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
294class _LIBCPP_EXPORTED_FROM_ABI __bad_variant_access_with_msg : public bad_variant_access {
295public:
296 _LIBCPP_HIDE_FROM_ABI explicit __bad_variant_access_with_msg(const char* __msg) _NOEXCEPT : __msg_(__msg) {}
297# if _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS_WITH_MSG_KEY_FUNCTION
298 [[__nodiscard__]] const char* what() const _NOEXCEPT override;
299# else
300 [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const _NOEXCEPT override { return __msg_; }
301# endif
295302
296_LIBCPP_BEGIN_NAMESPACE_STD
303private:
304 const char* __msg_;
305};
306
307_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
308_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
297309
298310# if _LIBCPP_STD_VER >= 17
299311
312_LIBCPP_BEGIN_NAMESPACE_STD
313
300314// Light N-dimensional array of function pointers. Used in place of std::array to avoid
301315// adding a dependency.
302316template <class _Tp, size_t _Size>
......@@ -307,11 +321,11 @@ struct __farray {
307321 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }
308322};
309323
310[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access() {
324[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access(const char* __msg) {
311325# if _LIBCPP_HAS_EXCEPTIONS
312 throw bad_variant_access();
326 throw __bad_variant_access_with_msg(__msg);
313327# else
314 _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode");
328 _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode: %s", __msg);
315329# endif
316330}
317331
......@@ -539,9 +553,12 @@ private:
539553 return __dispatcher<_Is...>::template __dispatch<_Fp, _Vs...>;
540554 }
541555
556 template <class, class _Tp>
557 using __expander _LIBCPP_NODEBUG = _Tp;
558
542559 template <size_t _Ip, class _Fp, class... _Vs>
543560 _LIBCPP_HIDE_FROM_ABI static constexpr auto __make_fdiagonal_impl() {
544 return __make_dispatch<_Fp, _Vs...>(index_sequence<((void)__type_identity<_Vs>{}, _Ip)...>{});
561 return __make_dispatch<_Fp, _Vs...>(index_sequence<static_cast<__expander<_Vs, size_t>>(_Ip)...>{});
545562 }
546563
547564 template <class _Fp, class... _Vs, size_t... _Is>
......@@ -614,7 +631,8 @@ private:
614631 template <class _Visitor>
615632 struct __value_visitor {
616633 template <class... _Alts>
617 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Alts&&... __alts) const {
634 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Alts&&... __alts) const
635 -> invoke_result_t<_Visitor&&, decltype((std::forward<_Alts>(__alts).__value))...> {
618636 __std_visit_exhaustive_visitor_check< _Visitor, decltype((std::forward<_Alts>(__alts).__value))...>();
619637 return std::__invoke(std::forward<_Visitor>(__visitor), std::forward<_Alts>(__alts).__value...);
620638 }
......@@ -1164,8 +1182,7 @@ public:
11641182 using __trivially_relocatable _LIBCPP_NODEBUG =
11651183 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;
11661184
1167 template <bool _Dummy = true,
1168 enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0>
1185 template <class _FirstType = __first_type, enable_if_t<is_default_constructible_v<_FirstType>, int> = 0>
11691186 _LIBCPP_HIDE_FROM_ABI constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
11701187 : __impl_(in_place_index<0>) {}
11711188
......@@ -1280,10 +1297,10 @@ public:
12801297
12811298 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_t index() const noexcept { return __impl_.index(); }
12821299
1283 template < bool _Dummy = true,
1284 enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
1285 __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
1286 int> = 0>
1300 template <
1301 bool _Dummy = true,
1302 enable_if_t<_And<_And<bool_constant<_Dummy>, is_move_constructible<_Types>, is_swappable<_Types>>...>::value,
1303 int> = 0>
12871304 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(variant& __that) noexcept(
12881305 __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) {
12891306 __impl_.__swap(__that.__impl_);
......@@ -1329,7 +1346,9 @@ template <size_t _Ip, class _Vp>
13291346_LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) {
13301347 using __variant_detail::__access::__variant;
13311348 if (!std::__holds_alternative<_Ip>(__v)) {
1332 std::__throw_bad_variant_access();
1349 if (__v.valueless_by_exception())
1350 std::__throw_bad_variant_access("std::get: variant is valueless");
1351 std::__throw_bad_variant_access("std::get: wrong alternative for variant");
13331352 }
13341353 return __variant::__get_alt<_Ip>(std::forward<_Vp>(__v)).__value;
13351354}
......@@ -1566,7 +1585,7 @@ template <class... _Vs>
15661585_LIBCPP_HIDE_FROM_ABI constexpr void __throw_if_valueless(_Vs&&... __vs) {
15671586 const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception());
15681587 if (__valueless) {
1569 std::__throw_bad_variant_access();
1588 std::__throw_bad_variant_access("std::visit: variant is valueless");
15701589 }
15711590}
15721591
......@@ -1574,6 +1593,7 @@ template < class _Visitor, class... _Vs, typename>
15741593_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
15751594 using __variant_detail::__visitation::__variant;
15761595 std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
1596 // NOLINTNEXTLINE(bugprone-use-after-move) __throw_if_valueless doesn't actually forward the variants
15771597 return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
15781598}
15791599
......@@ -1635,13 +1655,13 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto&& __unchecked_get(variant<_Types...>& __v)
16351655 return std::__unchecked_get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
16361656}
16371657
1638# endif // _LIBCPP_STD_VER >= 17
1639
16401658_LIBCPP_END_NAMESPACE_STD
16411659
1660# endif // _LIBCPP_STD_VER >= 17
1661
16421662_LIBCPP_POP_MACROS
16431663
1644# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1664# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
16451665# include <cstddef>
16461666# include <exception>
16471667# include <tuple>
lib/libcxx/include/vector+12-8
......@@ -39,7 +39,7 @@ public:
3939 noexcept(is_nothrow_default_constructible<allocator_type>::value);
4040 explicit vector(const allocator_type&);
4141 explicit vector(size_type n);
42 explicit vector(size_type n, const allocator_type&); // C++14
42 explicit vector(size_type n, const allocator_type&);
4343 vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
4444 template <class InputIterator>
4545 vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
......@@ -171,7 +171,7 @@ public:
171171 vector()
172172 noexcept(is_nothrow_default_constructible<allocator_type>::value);
173173 explicit vector(const allocator_type&) noexcept;
174 explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14
174 explicit vector(size_type n, const allocator_type& a = allocator_type());
175175 vector(size_type n, const value_type& value, const allocator_type& = allocator_type());
176176 template <class InputIterator>
177177 vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type());
......@@ -348,16 +348,21 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
348348# pragma GCC system_header
349349# endif
350350
351# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
352# include <algorithm>
351# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 23
353352# include <array>
354# include <atomic>
355# include <cctype>
356353# include <cerrno>
357354# include <clocale>
355# include <cstddef>
356# include <cstdlib>
357# include <typeinfo>
358# endif
359
360# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
361# include <algorithm>
362# include <atomic>
363# include <cctype>
358364# include <concepts>
359365# include <cstdint>
360# include <cstdlib>
361366# include <iosfwd>
362367# if _LIBCPP_HAS_LOCALIZATION
363368# include <locale>
......@@ -367,7 +372,6 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
367372# include <string_view>
368373# include <tuple>
369374# include <type_traits>
370# include <typeinfo>
371375# include <utility>
372376# endif
373377#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
lib/libcxx/include/version+27-11
......@@ -37,7 +37,7 @@ __cpp_lib_atomic_float 201711L <atomic>
3737__cpp_lib_atomic_is_always_lock_free 201603L <atomic>
3838__cpp_lib_atomic_lock_free_type_aliases 201907L <atomic>
3939__cpp_lib_atomic_min_max 202403L <atomic>
40__cpp_lib_atomic_ref 202411L <atomic>
40__cpp_lib_atomic_ref 202603L <atomic>
4141 201806L // C++20
4242__cpp_lib_atomic_shared_ptr 201711L <atomic>
4343__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
......@@ -64,6 +64,7 @@ __cpp_lib_common_reference 202302L <type_traits>
6464__cpp_lib_common_reference_wrapper 202302L <functional>
6565__cpp_lib_complex_udls 201309L <complex>
6666__cpp_lib_concepts 202207L <concepts>
67__cpp_lib_constant_wrapper 202606L <utility>
6768__cpp_lib_constexpr_algorithms 202306L <algorithm> <utility>
6869 201806L // C++20
6970__cpp_lib_constexpr_bitset 202207L <bitset>
......@@ -77,11 +78,13 @@ __cpp_lib_constexpr_forward_list 202502L <forward_list>
7778__cpp_lib_constexpr_functional 201907L <functional>
7879__cpp_lib_constexpr_iterator 201811L <iterator>
7980__cpp_lib_constexpr_list 202502L <list>
81__cpp_lib_constexpr_map 202502L <map>
8082__cpp_lib_constexpr_memory 202202L <memory>
8183 201811L // C++20
8284__cpp_lib_constexpr_new 202406L <new>
8385__cpp_lib_constexpr_numeric 201911L <numeric>
8486__cpp_lib_constexpr_queue 202502L <queue>
87__cpp_lib_constexpr_set 202502L <set>
8588__cpp_lib_constexpr_string 201907L <string>
8689__cpp_lib_constexpr_string_view 201811L <string_view>
8790__cpp_lib_constexpr_tuple 201811L <tuple>
......@@ -209,17 +212,21 @@ __cpp_lib_ranges_chunk 202202L <ranges>
209212__cpp_lib_ranges_chunk_by 202202L <ranges>
210213__cpp_lib_ranges_concat 202403L <ranges>
211214__cpp_lib_ranges_contains 202207L <algorithm>
215__cpp_lib_ranges_enumerate 202302L <ranges>
212216__cpp_lib_ranges_find_last 202207L <algorithm>
217__cpp_lib_ranges_fold 202207L <algorithm>
213218__cpp_lib_ranges_indices 202506L <ranges>
214219__cpp_lib_ranges_iota 202202L <numeric>
215220__cpp_lib_ranges_join_with 202202L <ranges>
216221__cpp_lib_ranges_repeat 202207L <ranges>
217222__cpp_lib_ranges_slide 202202L <ranges>
218223__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
224__cpp_lib_ranges_stride 202207L <ranges>
219225__cpp_lib_ranges_to_container 202202L <ranges>
220226__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
221227__cpp_lib_ratio 202306L <ratio>
222__cpp_lib_raw_memory_algorithms 201606L <memory>
228__cpp_lib_raw_memory_algorithms 202411L <memory>
229 201606L // C++17
223230__cpp_lib_rcu 202306L <rcu>
224231__cpp_lib_reference_from_temporary 202202L <type_traits>
225232__cpp_lib_reference_wrapper 202403L <functional>
......@@ -227,7 +234,7 @@ __cpp_lib_remove_cvref 201711L <type_traits>
227234__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
228235__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
229236__cpp_lib_sample 201603L <algorithm>
230__cpp_lib_saturation_arithmetic 202311L <numeric>
237__cpp_lib_saturation_arithmetic 202603L <numeric>
231238__cpp_lib_scoped_lock 201703L <mutex>
232239__cpp_lib_semaphore 201907L <semaphore>
233240__cpp_lib_senders 202406L <execution>
......@@ -236,13 +243,13 @@ __cpp_lib_shared_ptr_arrays 201707L <memory>
236243 201611L // C++17
237244__cpp_lib_shared_ptr_weak_type 201606L <memory>
238245__cpp_lib_shared_timed_mutex 201402L <shared_mutex>
239__cpp_lib_shift 201806L <algorithm>
246__cpp_lib_shift 202202L <algorithm>
247 201806L // C++20
240248__cpp_lib_smart_ptr_for_overwrite 202002L <memory>
241249__cpp_lib_smart_ptr_owner_equality 202306L <memory>
242250__cpp_lib_source_location 201907L <source_location>
243251__cpp_lib_span 202002L <span>
244252__cpp_lib_span_at 202311L <span>
245__cpp_lib_span_initializer_list 202311L <span>
246253__cpp_lib_spanstream 202106L <spanstream>
247254__cpp_lib_ssize 201902L <iterator>
248255__cpp_lib_sstream_from_string_view 202306L <sstream>
......@@ -423,7 +430,7 @@ __cpp_lib_void_t 201411L <type_traits>
423430# define __cpp_lib_constexpr_utility 201811L
424431# define __cpp_lib_constexpr_vector 201907L
425432# define __cpp_lib_coroutine 201902L
426# if _LIBCPP_STD_VER >= 20 && defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
433# if defined(__cpp_impl_destroying_delete) && __cpp_impl_destroying_delete >= 201806L
427434# define __cpp_lib_destroying_delete 201806L
428435# endif
429436# define __cpp_lib_endian 201907L
......@@ -524,15 +531,20 @@ __cpp_lib_void_t 201411L <type_traits>
524531// # define __cpp_lib_ranges_chunk 202202L
525532# define __cpp_lib_ranges_chunk_by 202202L
526533# define __cpp_lib_ranges_contains 202207L
534# define __cpp_lib_ranges_enumerate 202302L
527535# define __cpp_lib_ranges_find_last 202207L
536# define __cpp_lib_ranges_fold 202207L
528537# define __cpp_lib_ranges_iota 202202L
529538# define __cpp_lib_ranges_join_with 202202L
530539# define __cpp_lib_ranges_repeat 202207L
531540// # define __cpp_lib_ranges_slide 202202L
532541# define __cpp_lib_ranges_starts_ends_with 202106L
542# define __cpp_lib_ranges_stride 202207L
533543# define __cpp_lib_ranges_to_container 202202L
534544# define __cpp_lib_ranges_zip 202110L
535545// # define __cpp_lib_reference_from_temporary 202202L
546# undef __cpp_lib_shift
547# define __cpp_lib_shift 202202L
536548// # define __cpp_lib_spanstream 202106L
537549// # define __cpp_lib_stacktrace 202011L
538550# define __cpp_lib_stdatomic_h 202011L
......@@ -548,20 +560,23 @@ __cpp_lib_void_t 201411L <type_traits>
548560// # define __cpp_lib_associative_heterogeneous_insertion 202306L
549561// # define __cpp_lib_atomic_min_max 202403L
550562# undef __cpp_lib_atomic_ref
551# define __cpp_lib_atomic_ref 202411L
563# define __cpp_lib_atomic_ref 202603L
552564# undef __cpp_lib_bind_front
553565# define __cpp_lib_bind_front 202306L
554566# define __cpp_lib_bitset 202306L
567# define __cpp_lib_constant_wrapper 202606L
555568# undef __cpp_lib_constexpr_algorithms
556569# define __cpp_lib_constexpr_algorithms 202306L
557570# define __cpp_lib_constexpr_flat_map 202502L
558571# define __cpp_lib_constexpr_flat_set 202502L
559572# define __cpp_lib_constexpr_forward_list 202502L
560573# define __cpp_lib_constexpr_list 202502L
574# define __cpp_lib_constexpr_map 202502L
561575# if !defined(_LIBCPP_ABI_VCRUNTIME)
562576# define __cpp_lib_constexpr_new 202406L
563577# endif
564578# define __cpp_lib_constexpr_queue 202502L
579# define __cpp_lib_constexpr_set 202502L
565580# define __cpp_lib_constrained_equality 202411L
566581// # define __cpp_lib_copyable_function 202306L
567582// # define __cpp_lib_debugging 202311L
......@@ -604,22 +619,23 @@ __cpp_lib_void_t 201411L <type_traits>
604619# undef __cpp_lib_out_ptr
605620# define __cpp_lib_out_ptr 202311L
606621// # define __cpp_lib_philox_engine 202406L
607// # define __cpp_lib_ranges_concat 202403L
622# define __cpp_lib_ranges_concat 202403L
608623# define __cpp_lib_ranges_indices 202506L
609624# define __cpp_lib_ratio 202306L
625# undef __cpp_lib_raw_memory_algorithms
626# define __cpp_lib_raw_memory_algorithms 202411L
610627// # define __cpp_lib_rcu 202306L
611628# define __cpp_lib_reference_wrapper 202403L
612# define __cpp_lib_saturation_arithmetic 202311L
629# define __cpp_lib_saturation_arithmetic 202603L
613630// # define __cpp_lib_senders 202406L
614631// # define __cpp_lib_smart_ptr_owner_equality 202306L
615632# define __cpp_lib_span_at 202311L
616# define __cpp_lib_span_initializer_list 202311L
617633# define __cpp_lib_sstream_from_string_view 202306L
618634# define __cpp_lib_string_subview 202506L
619635# undef __cpp_lib_string_view
620636# define __cpp_lib_string_view 202403L
621637// # define __cpp_lib_submdspan 202306L
622// # define __cpp_lib_text_encoding 202306L
638# define __cpp_lib_text_encoding 202306L
623639# undef __cpp_lib_to_chars
624640// # define __cpp_lib_to_chars 202306L
625641// # define __cpp_lib_to_string 202306L
lib/libcxx/include/wchar.h+2
......@@ -133,6 +133,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
133133# if defined(_CRT_CONST_CORRECT_OVERLOADS)
134134# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
135135# endif
136# elif _LIBCPP_LIBC_LLVM_LIBC
137# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1
136138# endif
137139
138140# if _LIBCPP_HAS_WIDE_CHARACTERS
lib/libcxx/src/algorithm.cpp+2
......@@ -10,6 +10,7 @@
1010#include <bit>
1111
1212_LIBCPP_BEGIN_NAMESPACE_STD
13_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1314
1415template <class Comp, class RandomAccessIterator>
1516void __sort(RandomAccessIterator first, RandomAccessIterator last, Comp comp) {
......@@ -47,4 +48,5 @@ template void __sort<__less<double>&, double*>(double*, double*, __less<double>&
4748template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
4849// clang-format on
4950
51_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5052_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/any.cpp+4-2
......@@ -19,6 +19,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
1919// Preserve std::experimental::any_bad_cast for ABI compatibility
2020// Even though it no longer exists in a header file
2121_LIBCPP_BEGIN_NAMESPACE_LFTS
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
2425public:
......@@ -27,6 +28,7 @@ public:
2728
2829const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
2930
30#endif
31
31_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3232_LIBCPP_END_NAMESPACE_LFTS
33
34#endif
lib/libcxx/src/atomic.cpp+163-58
......@@ -17,7 +17,19 @@
1717#include <thread>
1818#include <type_traits>
1919
20#include "include/apple_availability.h"
20// Determine whether to use the public os_sync API on Apple platforms based on the deployment target.
21// Otherwise we fall back to the private __ulock API.
22#if defined(__APPLE__)
23# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
24 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 140400) || \
25 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \
26 __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 170400) || \
27 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 170400) || \
28 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && \
29 __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 100400)
30# define _LIBCPP_USE_OS_SYNC
31# endif
32#endif
2133
2234#ifdef __linux__
2335
......@@ -51,6 +63,16 @@
5163# include <memory>
5264# include <windows.h>
5365
66#elif defined(__APPLE__)
67
68# if defined(_LIBCPP_USE_OS_SYNC)
69# include <os/os_sync_wait_on_address.h>
70# endif
71
72#elif defined(__Fuchsia__)
73
74# include <zircon/syscalls.h>
75
5476#else // <- Add other operating systems here
5577
5678// Baseline needs no new headers
......@@ -63,6 +85,7 @@ _LIBCPP_PUSH_MACROS
6385#include <__undef_macros>
6486
6587_LIBCPP_BEGIN_NAMESPACE_STD
88_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
6689
6790struct NoTimeout {};
6891
......@@ -90,20 +113,64 @@ static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
90113 _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
91114}
92115
93#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
116#elif defined(__APPLE__)
117
118# if defined(_LIBCPP_USE_OS_SYNC)
119
120template <std::size_t _Size, class MaybeTimeout>
121static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) {
122 std::uint64_t __value = [__val]() -> std::uint64_t {
123 if constexpr (_Size == 4) {
124 std::uint32_t __result;
125 std::memcpy(&__result, __val, _Size);
126 return __result;
127 } else if constexpr (_Size == 8) {
128 std::uint64_t __result;
129 std::memcpy(&__result, __val, _Size);
130 return __result;
131 } else {
132 static_assert(false, "Can only wait on 8 bytes or 4 bytes value");
133 }
134 }();
135
136 if constexpr (is_same_v<MaybeTimeout, NoTimeout>) {
137 os_sync_wait_on_address(const_cast<void*>(__ptr), __value, _Size, OS_SYNC_WAIT_ON_ADDRESS_NONE);
138 } else {
139 // os_sync_wait_on_address_with_timeout returns EINVAL on a 0-ns timeout, so clamp to 1ns
140 // when an already-expired deadline produced a zero-duration timeout.
141 uint64_t __timeout_ns = std::max<uint64_t>(maybe_timeout_ns, 1);
142 os_sync_wait_on_address_with_timeout(
143 const_cast<void*>(__ptr),
144 __value,
145 _Size,
146 OS_SYNC_WAIT_ON_ADDRESS_NONE,
147 OS_CLOCK_MACH_ABSOLUTE_TIME,
148 __timeout_ns);
149 }
150}
151
152template <std::size_t _Size>
153static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
154 static_assert(_Size == 8 || _Size == 4, "Can only wake up on 8 bytes or 4 bytes value");
155 if (__notify_one)
156 os_sync_wake_by_address_any(const_cast<void*>(__ptr), _Size, OS_SYNC_WAKE_BY_ADDRESS_NONE);
157 else
158 os_sync_wake_by_address_all(const_cast<void*>(__ptr), _Size, OS_SYNC_WAKE_BY_ADDRESS_NONE);
159}
160
161# else // !_LIBCPP_USE_OS_SYNC -- fall back to the private __ulock API
94162
95163extern "C" int __ulock_wait(
96164 uint32_t operation, void* addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */
97165extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value);
98166
99167// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ulock.h#L82
100# define UL_COMPARE_AND_WAIT 1
101# define UL_COMPARE_AND_WAIT64 5
102# define ULF_WAKE_ALL 0x00000100
168# define UL_COMPARE_AND_WAIT 1
169# define UL_COMPARE_AND_WAIT64 5
170# define ULF_WAKE_ALL 0x00000100
103171
104172template <std::size_t _Size, class MaybeTimeout>
105173static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) {
106 static_assert(_Size == 8 || _Size == 4, "Can only wait on 8 bytes or 4 bytes value");
107174 auto __timeout_us = [&] {
108175 if constexpr (is_same_v<MaybeTimeout, NoTimeout>) {
109176 return uint32_t(0);
......@@ -111,17 +178,23 @@ static void __platform_wait_on_address(void const* __ptr, void const* __val, May
111178 return std::max(static_cast<uint32_t>(maybe_timeout_ns / 1000), uint32_t(1));
112179 }
113180 }();
114 if constexpr (_Size == 4) {
115 alignas(uint32_t) char buffer[_Size];
116 std::memcpy(&buffer, const_cast<const void*>(__val), _Size);
117 __ulock_wait(
118 UL_COMPARE_AND_WAIT, const_cast<void*>(__ptr), *reinterpret_cast<uint32_t const*>(&buffer), __timeout_us);
119 } else {
120 alignas(uint64_t) char buffer[_Size];
121 std::memcpy(&buffer, const_cast<const void*>(__val), _Size);
122 __ulock_wait(
123 UL_COMPARE_AND_WAIT64, const_cast<void*>(__ptr), *reinterpret_cast<uint64_t const*>(&buffer), __timeout_us);
124 }
181
182 std::uint64_t __value = [__val]() -> std::uint64_t {
183 if constexpr (_Size == 4) {
184 std::uint32_t __result;
185 std::memcpy(&__result, __val, _Size);
186 return __result;
187 } else if constexpr (_Size == 8) {
188 std::uint64_t __result;
189 std::memcpy(&__result, __val, _Size);
190 return __result;
191 } else {
192 static_assert(false, "Can only wait on 8 bytes or 4 bytes value");
193 }
194 }();
195
196 __ulock_wait(
197 _Size == 4 ? UL_COMPARE_AND_WAIT : UL_COMPARE_AND_WAIT64, const_cast<void*>(__ptr), __value, __timeout_us);
125198}
126199
127200template <std::size_t _Size>
......@@ -134,6 +207,8 @@ static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
134207 __ulock_wake(UL_COMPARE_AND_WAIT64 | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<void*>(__ptr), 0);
135208}
136209
210# endif // _LIBCPP_USE_OS_SYNC
211
137212#elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8
138213/*
139214 * Since __cxx_contention_t is int64_t even on 32bit FreeBSD
......@@ -254,6 +329,37 @@ static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
254329 }
255330}
256331
332#elif defined(__Fuchsia__)
333
334template <std::size_t _Size>
335static inline zx_futex_t const* __get_zx_futex(void const* __ptr) {
336 static_assert(_Size == sizeof(zx_futex_t), "Can only wait/wake on zx_futex_t-compatible value");
337
338 // Implicitly link against the vDSO system call ABI without requiring the
339 // final link to specify -lzircon explicitly when statically linking libc++.
340# pragma comment(lib, "zircon")
341
342 return reinterpret_cast<zx_futex_t const*>(__ptr);
343}
344
345template <std::size_t _Size, class MaybeTimeout>
346static void __platform_wait_on_address(void const* __ptr, void const* __val, MaybeTimeout maybe_timeout_ns) {
347 zx_futex_t val;
348 std::memcpy(&val, __val, _Size);
349 zx_instant_mono_t deadline;
350 if constexpr (is_same_v<MaybeTimeout, NoTimeout>) {
351 deadline = ZX_TIME_INFINITE;
352 } else {
353 deadline = _zx_deadline_after(maybe_timeout_ns);
354 }
355 _zx_futex_wait(__get_zx_futex<_Size>(__ptr), val, ZX_HANDLE_INVALID, deadline);
356}
357
358template <std::size_t _Size>
359static void __platform_wake_by_address(void const* __ptr, bool __notify_one) {
360 _zx_futex_wake(__get_zx_futex<_Size>(__ptr), __notify_one ? 1 : UINT32_MAX);
361}
362
257363#else // <- Add other operating systems here
258364
259365// Baseline is just a timed backoff
......@@ -308,45 +414,41 @@ static constexpr size_t __contention_table_size = (1 << 8); /* < there's no magi
308414
309415static constexpr hash<void const*> __contention_hasher;
310416
311// Waiter count table for all atomics with the correct size that use itself as the wait/notify address.
312
313struct alignas(
314 std::hardware_constructive_interference_size) /* aim to avoid false sharing */ __contention_state_native {
315 __cxx_atomic_contention_t __waiter_count;
316 constexpr __contention_state_native() : __waiter_count(0) {}
317};
318
319static __contention_state_native __contention_table_native[__contention_table_size];
320
321static __cxx_atomic_contention_t* __get_native_waiter_count(void const* p) {
322 return &__contention_table_native[__contention_hasher(p) & (__contention_table_size - 1)].__waiter_count;
323}
324
325// Global contention table for all atomics with the wrong size that use the global table's atomic as wait/notify
326// address.
327
328struct alignas(
329 std::hardware_constructive_interference_size) /* aim to avoid false sharing */ __contention_state_global {
330 __cxx_atomic_contention_t __waiter_count;
417// Unified contention table shared by both the native path (atomics whose size matches the platform
418// wait size and are waited on directly) and the global path (atomics with the wrong size, which use
419// the global table's atomic as the wait/notify address). The native path only reads/writes the native
420// waiter count, and the global path uses the global waiter count and the platform state.
421//
422// We use a single table for both the native and non-native states to minimize the size impact, since
423// we would have plenty of unused padding otherwise. This technically means that if both a native and
424// a non-native atomic fall into the same bucket and are reading/writing waiter counts on the same
425// cache line, we would end up in a "false-sharing" situation. However, in practice, it would require
426// both native and non-native atomics to be used concurrently, and to fall in the same bucket, which
427// is expected to be unlikely.
428struct alignas(std::hardware_destructive_interference_size) /* aim to avoid false sharing */ __contention_state {
429 __cxx_atomic_contention_t __waiter_count_native;
430 __cxx_atomic_contention_t __waiter_count_global;
331431 __cxx_atomic_contention_t __platform_state;
332 constexpr __contention_state_global() : __waiter_count(0), __platform_state(0) {}
432 constexpr __contention_state() : __waiter_count_native(0), __waiter_count_global(0), __platform_state(0) {}
333433};
334434
335static __contention_state_global __contention_table_global[__contention_table_size];
435static constinit __contention_state __contention_table[__contention_table_size];
336436
337static __contention_state_global* __get_global_contention_state(void const* p) {
338 return &__contention_table_global[__contention_hasher(p) & (__contention_table_size - 1)];
437static __contention_state* __get_contention_state(void const* p) {
438 return &__contention_table[__contention_hasher(p) & (__contention_table_size - 1)];
339439}
340440
341441/* When the incoming atomic is the wrong size for the platform wait size, need to
342442 launder the value sequence through an atomic from our table. */
343443
344444static void __atomic_notify_global_table(void const* __location) {
345 auto const __entry = __get_global_contention_state(__location);
445 auto const __entry = __get_contention_state(__location);
346446 // The value sequence laundering happens on the next line below.
347447 __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_seq_cst);
348448 __contention_notify<sizeof(__cxx_atomic_contention_t)>(
349 &__entry->__waiter_count, &__entry->__platform_state, false /* when laundering, we can't handle notify_one */);
449 &__entry->__waiter_count_global,
450 &__entry->__platform_state,
451 false /* when laundering, we can't handle notify_one */);
350452}
351453
352454// =============================
......@@ -355,22 +457,22 @@ static void __atomic_notify_global_table(void const* __location) {
355457
356458// global
357459_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __atomic_monitor_global(void const* __location) noexcept {
358 auto const __entry = __get_global_contention_state(__location);
460 auto const __entry = __get_contention_state(__location);
359461 return __cxx_atomic_load(&__entry->__platform_state, memory_order_acquire);
360462}
361463
362464_LIBCPP_EXPORTED_FROM_ABI void
363465__atomic_wait_global_table(void const* __location, __cxx_contention_t __old_value) noexcept {
364 auto const __entry = __get_global_contention_state(__location);
466 auto const __entry = __get_contention_state(__location);
365467 __contention_wait<sizeof(__cxx_atomic_contention_t)>(
366 &__entry->__waiter_count, &__entry->__platform_state, &__old_value, NoTimeout{});
468 &__entry->__waiter_count_global, &__entry->__platform_state, &__old_value, NoTimeout{});
367469}
368470
369471_LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_global_table_with_timeout(
370472 void const* __location, __cxx_contention_t __old_value, uint64_t __timeout_ns) _NOEXCEPT {
371 auto const __entry = __get_global_contention_state(__location);
473 auto const __entry = __get_contention_state(__location);
372474 __contention_wait<sizeof(__cxx_atomic_contention_t)>(
373 &__entry->__waiter_count, &__entry->__platform_state, &__old_value, __timeout_ns);
475 &__entry->__waiter_count_global, &__entry->__platform_state, &__old_value, __timeout_ns);
374476}
375477
376478_LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_global_table(void const* __location) noexcept {
......@@ -385,23 +487,25 @@ _LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_global_table(void const* __lo
385487
386488template <std::size_t _Size>
387489_LIBCPP_EXPORTED_FROM_ABI void __atomic_wait_native(void const* __address, void const* __old_value) noexcept {
388 __contention_wait<_Size>(__get_native_waiter_count(__address), __address, __old_value, NoTimeout{});
490 __contention_wait<_Size>(
491 &__get_contention_state(__address)->__waiter_count_native, __address, __old_value, NoTimeout{});
389492}
390493
391494template <std::size_t _Size>
392495_LIBCPP_EXPORTED_FROM_ABI void
393496__atomic_wait_native_with_timeout(void const* __address, void const* __old_value, uint64_t __timeout_ns) noexcept {
394 __contention_wait<_Size>(__get_native_waiter_count(__address), __address, __old_value, __timeout_ns);
497 __contention_wait<_Size>(
498 &__get_contention_state(__address)->__waiter_count_native, __address, __old_value, __timeout_ns);
395499}
396500
397501template <std::size_t _Size>
398502_LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_one_native(void const* __location) noexcept {
399 __contention_notify<_Size>(__get_native_waiter_count(__location), __location, true);
503 __contention_notify<_Size>(&__get_contention_state(__location)->__waiter_count_native, __location, true);
400504}
401505
402506template <std::size_t _Size>
403507_LIBCPP_EXPORTED_FROM_ABI void __atomic_notify_all_native(void const* __location) noexcept {
404 __contention_notify<_Size>(__get_native_waiter_count(__location), __location, false);
508 __contention_notify<_Size>(&__get_contention_state(__location)->__waiter_count_native, __location, false);
405509}
406510
407511// ==================================================
......@@ -452,34 +556,34 @@ _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __lo
452556}
453557
454558_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept {
455 auto const __entry = __get_global_contention_state(const_cast<void const*>(__location));
559 auto const __entry = __get_contention_state(const_cast<void const*>(__location));
456560 return __cxx_atomic_load(&__entry->__platform_state, memory_order_acquire);
457561}
458562
459563_LIBCPP_EXPORTED_FROM_ABI void
460564__libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept {
461 auto const __entry = __get_global_contention_state(const_cast<void const*>(__location));
565 auto const __entry = __get_contention_state(const_cast<void const*>(__location));
462566 __contention_wait<sizeof(__cxx_atomic_contention_t)>(
463 &__entry->__waiter_count, &__entry->__platform_state, &__old_value, NoTimeout{});
567 &__entry->__waiter_count_global, &__entry->__platform_state, &__old_value, NoTimeout{});
464568}
465569
466570_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept {
467571 auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location));
468572 __contention_notify<sizeof(__cxx_atomic_contention_t)>(
469 __get_native_waiter_count(__location_cast), __location_cast, true);
573 &__get_contention_state(__location_cast)->__waiter_count_native, __location_cast, true);
470574}
471575
472576_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept {
473577 auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location));
474578 __contention_notify<sizeof(__cxx_atomic_contention_t)>(
475 __get_native_waiter_count(__location_cast), __location_cast, false);
579 &__get_contention_state(__location_cast)->__waiter_count_native, __location_cast, false);
476580}
477581
478582_LIBCPP_EXPORTED_FROM_ABI void
479583__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept {
480584 auto __location_cast = const_cast<const void*>(static_cast<const volatile void*>(__location));
481585 __contention_wait<sizeof(__cxx_atomic_contention_t)>(
482 __get_native_waiter_count(__location_cast), __location_cast, &__old_value, NoTimeout{});
586 &__get_contention_state(__location_cast)->__waiter_count_native, __location_cast, &__old_value, NoTimeout{});
483587}
484588
485589// this function is even unused in the old ABI
......@@ -490,6 +594,7 @@ __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) no
490594
491595_LIBCPP_DIAGNOSTIC_POP
492596
597_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
493598_LIBCPP_END_NAMESPACE_STD
494599
495600_LIBCPP_POP_MACROS
lib/libcxx/src/barrier.cpp+2
......@@ -10,6 +10,7 @@
1010#include <thread>
1111
1212_LIBCPP_BEGIN_NAMESPACE_STD
13_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1314
1415class __barrier_algorithm_base {
1516public:
......@@ -69,4 +70,5 @@ __destroy_barrier_algorithm_base(_LIBCPP_NOESCAPE __barrier_algorithm_base* __ba
6970 delete __barrier;
7071}
7172
73_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7274_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/call_once.cpp+2
......@@ -17,6 +17,7 @@
1717#include "include/atomic_support.h"
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
20_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2021
2122// If dispatch_once_f ever handles C++ exceptions, and if one can get to it
2223// without illegal macros (unexpected macros not beginning with _UpperCase or
......@@ -68,4 +69,5 @@ void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(
6869#endif // !_LIBCPP_HAS_THREADS
6970}
7071
72_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7173_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/charconv.cpp+3
......@@ -13,6 +13,7 @@
1313#include "include/to_chars_floating_point.h"
1414
1515_LIBCPP_BEGIN_NAMESPACE_STD
16_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1617
1718#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15
1819
......@@ -89,4 +90,6 @@ template __from_chars_result<float> __from_chars_floating_point(
8990
9091template __from_chars_result<double> __from_chars_floating_point(
9192 _LIBCPP_NOESCAPE const char* __first, _LIBCPP_NOESCAPE const char* __last, chars_format __fmt);
93
94_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
9295_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/chrono.cpp+3-2
......@@ -20,7 +20,6 @@
2020# include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
2121#endif
2222
23#include "include/apple_availability.h"
2423#include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW}
2524
2625#if __has_include(<unistd.h>)
......@@ -31,7 +30,7 @@
3130# include <sys/time.h> // for gettimeofday and timeval
3231#endif
3332
34#if defined(__LLVM_LIBC__)
33#if _LIBCPP_LIBC_LLVM_LIBC
3534# define _LIBCPP_HAS_TIMESPEC_GET
3635#endif
3736
......@@ -64,6 +63,7 @@
6463#endif
6564
6665_LIBCPP_BEGIN_NAMESPACE_STD
66_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
6767
6868namespace chrono {
6969
......@@ -262,4 +262,5 @@ steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_c
262262
263263} // namespace chrono
264264
265_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
265266_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/condition_variable.cpp+2
......@@ -23,6 +23,7 @@ _LIBCPP_PUSH_MACROS
2323#include <__undef_macros>
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2627
2728// ~condition_variable is defined elsewhere.
2829
......@@ -72,6 +73,7 @@ void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
7273 __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
7374}
7475
76_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7577_LIBCPP_END_NAMESPACE_STD
7678
7779_LIBCPP_POP_MACROS
lib/libcxx/src/condition_variable_destructor.cpp+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324#ifdef NEEDS_CONDVAR_DESTRUCTOR
2425
......@@ -37,4 +38,5 @@ public:
3738condition_variable::~condition_variable() { __libcpp_condvar_destroy(&__cv_); }
3839#endif
3940
41_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4042_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/error_category.cpp+2
......@@ -17,6 +17,7 @@
1717#include <system_error>
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
20_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2021
2122// class error_category
2223
......@@ -36,4 +37,5 @@ bool error_category::equivalent(const error_code& code, int condition) const noe
3637 return *this == code.category() && code.value() == condition;
3738}
3839
40_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3941_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/expected.cpp+4
......@@ -9,5 +9,9 @@
99#include <expected>
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
12_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
13
1214const char* bad_expected_access<void>::what() const noexcept { return "bad access to std::expected"; }
15
16_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
1317_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/chrono_exception.cpp+2
......@@ -9,6 +9,7 @@
99#include <chrono>
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
12_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1213
1314namespace chrono {
1415
......@@ -19,4 +20,5 @@ _LIBCPP_EXPORTED_FROM_ABI ambiguous_local_time::~ambiguous_local_time() = defaul
1920
2021} // namespace chrono
2122
23_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2224_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/include/tzdb/tzdb_private.h+2
......@@ -16,6 +16,7 @@
1616#include "types_private.h"
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
19_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1920
2021namespace chrono {
2122
......@@ -23,6 +24,7 @@ void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules);
2324
2425} // namespace chrono
2526
27_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2628_LIBCPP_END_NAMESPACE_STD
2729
2830#endif // _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H
lib/libcxx/src/experimental/log_hardening_failure.cpp+2
......@@ -15,6 +15,7 @@
1515#endif // __BIONIC__
1616
1717_LIBCPP_BEGIN_NAMESPACE_STD
18_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1819
1920void __log_hardening_failure(const char* message) noexcept {
2021 // Always log the message to `stderr` in case the platform-specific system calls fail.
......@@ -28,4 +29,5 @@ void __log_hardening_failure(const char* message) noexcept {
2829#endif
2930}
3031
32_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3133_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/time_zone.cpp+2-6
......@@ -55,6 +55,7 @@
5555#endif
5656
5757_LIBCPP_BEGIN_NAMESPACE_STD
58_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
5859
5960#ifdef PRINT
6061template <>
......@@ -209,8 +210,6 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se
209210 return chrono::seconds{0};
210211 else
211212 static_assert(false);
212
213 std::__libcpp_unreachable();
214213 },
215214 __continuation.__rules);
216215
......@@ -235,8 +234,6 @@ __format(const __tz::__continuation& __continuation, const string& __letters, se
235234 return __value(__year, __month);
236235 else
237236 static_assert(false);
238
239 std::__libcpp_unreachable();
240237 },
241238 __on);
242239}
......@@ -698,8 +695,6 @@ __get_sys_info(sys_seconds __time,
698695 return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time);
699696 else
700697 static_assert(false);
701
702 std::__libcpp_unreachable();
703698 },
704699 __continuation.__rules);
705700}
......@@ -1061,4 +1056,5 @@ time_zone::__get_info(local_seconds __local_time) const {
10611056
10621057} // namespace chrono
10631058
1059_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
10641060_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/tzdb.cpp+3-1
......@@ -46,6 +46,7 @@
4646// TODO TZDB Implement the Windows mapping in tzdb::current_zone
4747
4848_LIBCPP_BEGIN_NAMESPACE_STD
49_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4950
5051namespace chrono {
5152
......@@ -53,7 +54,7 @@ _LIBCPP_DIAGNOSTIC_PUSH
5354_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
5455// This function is weak so it can be overriden in the tests. The
5556// declaration is in the test header test/support/test_tzdb.h
56_LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
57[[gnu::weak]] string_view __libcpp_tzdb_directory() {
5758#if defined(__linux__)
5859 return "/usr/share/zoneinfo/";
5960#else
......@@ -825,4 +826,5 @@ _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() {
825826
826827} // namespace chrono
827828
829_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
828830_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/tzdb_list.cpp+2
......@@ -13,6 +13,7 @@
1313#include "include/tzdb/tzdb_list_private.h"
1414
1515_LIBCPP_BEGIN_NAMESPACE_STD
16_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1617
1718namespace chrono {
1819
......@@ -40,4 +41,5 @@ _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__erase_after(con
4041
4142} // namespace chrono
4243
44_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4345_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/filesystem/directory_entry.cpp+2
......@@ -16,6 +16,7 @@
1616#include "time_utils.h"
1717
1818_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
19_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1920
2021error_code directory_entry::__do_refresh() noexcept {
2122 __data_.__reset();
......@@ -70,4 +71,5 @@ error_code directory_entry::__do_refresh() noexcept {
7071 return failure_ec;
7172}
7273
74_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7375_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/filesystem/directory_iterator.cpp+2
......@@ -26,6 +26,7 @@
2626#endif
2727
2828_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
29_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2930
3031using detail::ErrorHandler;
3132
......@@ -320,4 +321,5 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
320321 return false;
321322}
322323
324_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
323325_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/filesystem/filesystem_clock.cpp+3-1
......@@ -32,7 +32,7 @@
3232# include <sys/time.h> // for gettimeofday and timeval
3333#endif
3434
35#if defined(__LLVM_LIBC__)
35#if _LIBCPP_LIBC_LLVM_LIBC
3636# define _LIBCPP_HAS_TIMESPEC_GET
3737#endif
3838
......@@ -42,6 +42,7 @@
4242#endif
4343
4444_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
45_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4546
4647_LIBCPP_DIAGNOSTIC_PUSH
4748_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
......@@ -76,4 +77,5 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {
7677#endif
7778}
7879
80_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7981_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/filesystem/filesystem_error.cpp+2
......@@ -15,6 +15,7 @@
1515#include "format_string.h"
1616
1717_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
18_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1819
1920filesystem_error::~filesystem_error() {}
2021
......@@ -37,4 +38,5 @@ void filesystem_error::__create_what(int __num_paths) {
3738 }();
3839}
3940
41_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4042_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/filesystem/operations.cpp+5
......@@ -69,6 +69,7 @@
6969#endif
7070
7171_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
72_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
7273
7374using detail::capture_errno;
7475using detail::ErrorHandler;
......@@ -904,6 +905,9 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
904905 break; // we're done iterating through the directory
905906 } else {
906907 count += remove_all_impl(fd, str, ec);
908 // If there's an error removing the child, return immediately to preserve the error code.
909 if (ec)
910 return count;
907911 }
908912 }
909913
......@@ -1077,4 +1081,5 @@ path __weakly_canonical(const path& p, error_code* ec) {
10771081 return result.lexically_normal();
10781082}
10791083
1084_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
10801085_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/filesystem/path.cpp+12-11
......@@ -14,6 +14,7 @@
1414#include "path_parser.h"
1515
1616_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
17_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1718
1819using detail::ErrorHandler;
1920using parser::createView;
......@@ -139,21 +140,20 @@ string_view_t path::__extension() const { return parser::separate_filename(__fil
139140////////////////////////////////////////////////////////////////////////////
140141// path.gen
141142
142enum PathPartKind : unsigned char { PK_None, PK_RootSep, PK_Filename, PK_Dot, PK_DotDot, PK_TrailingSep };
143enum PathPartKind : unsigned char { PK_None, PK_RootName, PK_RootSep, PK_Filename, PK_Dot, PK_DotDot, PK_TrailingSep };
143144
144static PathPartKind ClassifyPathPart(string_view_t Part) {
145static PathPartKind ClassifyPathPart(const PathParser& PP) {
146 if (PP.inRootName())
147 return PK_RootName;
148 if (PP.inRootDir())
149 return PK_RootSep;
150 string_view_t Part = *PP;
145151 if (Part.empty())
146152 return PK_TrailingSep;
147153 if (Part == PATHSTR("."))
148154 return PK_Dot;
149155 if (Part == PATHSTR(".."))
150156 return PK_DotDot;
151 if (Part == PATHSTR("/"))
152 return PK_RootSep;
153#if defined(_LIBCPP_WIN32API)
154 if (Part == PATHSTR("\\"))
155 return PK_RootSep;
156#endif
157157 return PK_Filename;
158158}
159159
......@@ -183,13 +183,13 @@ path path::lexically_normal() const {
183183 // Build a stack containing the remaining elements of the path, popping off
184184 // elements which occur before a '..' entry.
185185 for (auto PP = PathParser::CreateBegin(__pn_); PP; ++PP) {
186 auto Part = *PP;
187 PathPartKind Kind = ClassifyPathPart(Part);
186 PathPartKind Kind = ClassifyPathPart(PP);
188187 switch (Kind) {
189188 case PK_Filename:
189 case PK_RootName:
190190 case PK_RootSep: {
191191 // Add all non-dot and non-dot-dot elements to the stack of elements.
192 AddPart(Kind, Part);
192 AddPart(Kind, *PP);
193193 MaybeNeedTrailingSep = false;
194194 break;
195195 }
......@@ -444,4 +444,5 @@ size_t __char_to_wide(const string& str, wchar_t* out, size_t outlen) {
444444}
445445#endif
446446
447_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
447448_LIBCPP_END_NAMESPACE_FILESYSTEM
lib/libcxx/src/fstream.cpp+2
......@@ -18,6 +18,7 @@
1818#endif
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
21_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2122
2223#if defined(_LIBCPP_WIN32API)
2324
......@@ -34,4 +35,5 @@ _LIBCPP_EXPORTED_FROM_ABI void* __filebuf_windows_native_handle(FILE* __file) no
3435
3536#endif
3637
38_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3739_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/functional.cpp+2
......@@ -9,6 +9,7 @@
99#include <functional>
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
12_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1213
1314bad_function_call::~bad_function_call() noexcept {}
1415
......@@ -18,4 +19,5 @@ size_t __hash_memory(_LIBCPP_NOESCAPE const void* ptr, size_t size) noexcept {
1819 return __murmur2_or_cityhash<size_t>()(ptr, size);
1920}
2021
22_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
2123_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/future.cpp+2
......@@ -10,6 +10,7 @@
1010#include <string>
1111
1212_LIBCPP_BEGIN_NAMESPACE_STD
13_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1314
1415class _LIBCPP_HIDDEN __future_error_category : public __do_message {
1516public:
......@@ -194,4 +195,5 @@ shared_future<void>& shared_future<void>::operator=(const shared_future& __rhs)
194195 return *this;
195196}
196197
198_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
197199_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/hash.cpp+17-334
......@@ -13,6 +13,7 @@
1313_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wtautological-constant-out-of-range-compare")
1414
1515_LIBCPP_BEGIN_NAMESPACE_STD
16_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1617
1718namespace {
1819
......@@ -30,6 +31,13 @@ const unsigned indices[] = {
3031 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139,
3132 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209};
3233
34// These are the amount we increment by when checking for potential
35// primes in the loop in __next_prime.
36const uint8_t increments[] = {
37 0, 10, 2, 4, 2, 4, 6, 2, 6, 4, 2, 4, 6, 6, 2, 6, 4, 2, 6, 4, 6, 8, 4, 2,
38 4, 2, 4, 8, 6, 4, 6, 2, 4, 6, 2, 6, 6, 4, 2, 4, 6, 2, 6, 4, 2, 4, 2, 10,
39};
40
3341} // namespace
3442
3543// Returns: If n == 0, returns 0. Else returns the lowest prime number that
......@@ -97,340 +105,14 @@ size_t __next_prime(size_t n) {
97105 {
98106 size_t i = 211;
99107 while (true) {
100 std::size_t q = n / i;
101 if (q < i)
102 return n;
103 if (n == q * i)
104 break;
105
106 i += 10;
107 q = n / i;
108 if (q < i)
109 return n;
110 if (n == q * i)
111 break;
112
113 i += 2;
114 q = n / i;
115 if (q < i)
116 return n;
117 if (n == q * i)
118 break;
119
120 i += 4;
121 q = n / i;
122 if (q < i)
123 return n;
124 if (n == q * i)
125 break;
126
127 i += 2;
128 q = n / i;
129 if (q < i)
130 return n;
131 if (n == q * i)
132 break;
133
134 i += 4;
135 q = n / i;
136 if (q < i)
137 return n;
138 if (n == q * i)
139 break;
140
141 i += 6;
142 q = n / i;
143 if (q < i)
144 return n;
145 if (n == q * i)
146 break;
147
148 i += 2;
149 q = n / i;
150 if (q < i)
151 return n;
152 if (n == q * i)
153 break;
154
155 i += 6;
156 q = n / i;
157 if (q < i)
158 return n;
159 if (n == q * i)
160 break;
161
162 i += 4;
163 q = n / i;
164 if (q < i)
165 return n;
166 if (n == q * i)
167 break;
168
169 i += 2;
170 q = n / i;
171 if (q < i)
172 return n;
173 if (n == q * i)
174 break;
175
176 i += 4;
177 q = n / i;
178 if (q < i)
179 return n;
180 if (n == q * i)
181 break;
182
183 i += 6;
184 q = n / i;
185 if (q < i)
186 return n;
187 if (n == q * i)
188 break;
189
190 i += 6;
191 q = n / i;
192 if (q < i)
193 return n;
194 if (n == q * i)
195 break;
196
197 i += 2;
198 q = n / i;
199 if (q < i)
200 return n;
201 if (n == q * i)
202 break;
203
204 i += 6;
205 q = n / i;
206 if (q < i)
207 return n;
208 if (n == q * i)
209 break;
210
211 i += 4;
212 q = n / i;
213 if (q < i)
214 return n;
215 if (n == q * i)
216 break;
217
218 i += 2;
219 q = n / i;
220 if (q < i)
221 return n;
222 if (n == q * i)
223 break;
224
225 i += 6;
226 q = n / i;
227 if (q < i)
228 return n;
229 if (n == q * i)
230 break;
231
232 i += 4;
233 q = n / i;
234 if (q < i)
235 return n;
236 if (n == q * i)
237 break;
238
239 i += 6;
240 q = n / i;
241 if (q < i)
242 return n;
243 if (n == q * i)
244 break;
245
246 i += 8;
247 q = n / i;
248 if (q < i)
249 return n;
250 if (n == q * i)
251 break;
252
253 i += 4;
254 q = n / i;
255 if (q < i)
256 return n;
257 if (n == q * i)
258 break;
259
260 i += 2;
261 q = n / i;
262 if (q < i)
263 return n;
264 if (n == q * i)
265 break;
266
267 i += 4;
268 q = n / i;
269 if (q < i)
270 return n;
271 if (n == q * i)
272 break;
273
274 i += 2;
275 q = n / i;
276 if (q < i)
277 return n;
278 if (n == q * i)
279 break;
280
281 i += 4;
282 q = n / i;
283 if (q < i)
284 return n;
285 if (n == q * i)
286 break;
287
288 i += 8;
289 q = n / i;
290 if (q < i)
291 return n;
292 if (n == q * i)
293 break;
294
295 i += 6;
296 q = n / i;
297 if (q < i)
298 return n;
299 if (n == q * i)
300 break;
301
302 i += 4;
303 q = n / i;
304 if (q < i)
305 return n;
306 if (n == q * i)
307 break;
308
309 i += 6;
310 q = n / i;
311 if (q < i)
312 return n;
313 if (n == q * i)
314 break;
315
316 i += 2;
317 q = n / i;
318 if (q < i)
319 return n;
320 if (n == q * i)
321 break;
322
323 i += 4;
324 q = n / i;
325 if (q < i)
326 return n;
327 if (n == q * i)
328 break;
329
330 i += 6;
331 q = n / i;
332 if (q < i)
333 return n;
334 if (n == q * i)
335 break;
336
337 i += 2;
338 q = n / i;
339 if (q < i)
340 return n;
341 if (n == q * i)
342 break;
343
344 i += 6;
345 q = n / i;
346 if (q < i)
347 return n;
348 if (n == q * i)
349 break;
350
351 i += 6;
352 q = n / i;
353 if (q < i)
354 return n;
355 if (n == q * i)
356 break;
357
358 i += 4;
359 q = n / i;
360 if (q < i)
361 return n;
362 if (n == q * i)
363 break;
364
365 i += 2;
366 q = n / i;
367 if (q < i)
368 return n;
369 if (n == q * i)
370 break;
371
372 i += 4;
373 q = n / i;
374 if (q < i)
375 return n;
376 if (n == q * i)
377 break;
378
379 i += 6;
380 q = n / i;
381 if (q < i)
382 return n;
383 if (n == q * i)
384 break;
385
386 i += 2;
387 q = n / i;
388 if (q < i)
389 return n;
390 if (n == q * i)
391 break;
392
393 i += 6;
394 q = n / i;
395 if (q < i)
396 return n;
397 if (n == q * i)
398 break;
399
400 i += 4;
401 q = n / i;
402 if (q < i)
403 return n;
404 if (n == q * i)
405 break;
406
407 i += 2;
408 q = n / i;
409 if (q < i)
410 return n;
411 if (n == q * i)
412 break;
413
414 i += 4;
415 q = n / i;
416 if (q < i)
417 return n;
418 if (n == q * i)
419 break;
420
421 i += 2;
422 q = n / i;
423 if (q < i)
424 return n;
425 if (n == q * i)
426 break;
427
428 i += 10;
429 q = n / i;
430 if (q < i)
431 return n;
432 if (n == q * i)
433 break;
108 for (auto inc : increments) {
109 i += inc;
110 std::size_t q = n / i;
111 if (q < i)
112 return n;
113 if (n == q * i)
114 goto next;
115 }
434116
435117 // This will loop i to the next "plane" of potential primes
436118 i += 2;
......@@ -446,4 +128,5 @@ size_t __next_prime(size_t n) {
446128 }
447129}
448130
131_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
449132_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/include/apple_availability.h deleted-34
......@@ -1,34 +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_SRC_INCLUDE_APPLE_AVAILABILITY_H
10#define _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
11
12#if defined(__APPLE__)
13
14# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
15# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
16# define _LIBCPP_USE_ULOCK
17# endif
18# elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
19# if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000
20# define _LIBCPP_USE_ULOCK
21# endif
22# elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
23# if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000
24# define _LIBCPP_USE_ULOCK
25# endif
26# elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
27# if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000
28# define _LIBCPP_USE_ULOCK
29# endif
30# endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
31
32#endif // __APPLE__
33
34#endif // _LIBCPP_SRC_INCLUDE_APPLE_AVAILABILITY_H
lib/libcxx/src/include/config_elast.h+1-1
......@@ -21,7 +21,7 @@
2121// where strerror/strerror_r can't handle out-of-range errno values.
2222#if defined(ELAST)
2323# define _LIBCPP_ELAST ELAST
24#elif defined(__LLVM_LIBC__)
24#elif _LIBCPP_LIBC_LLVM_LIBC
2525// No _LIBCPP_ELAST needed for LLVM libc
2626#elif _LIBCPP_LIBC_NEWLIB
2727# define _LIBCPP_ELAST __ELASTERROR
lib/libcxx/src/include/overridable_function.h+80-50
......@@ -11,11 +11,6 @@
1111#define _LIBCPP_SRC_INCLUDE_OVERRIDABLE_FUNCTION_H
1212
1313#include <__config>
14#include <cstdint>
15
16#if __has_feature(ptrauth_calls)
17# include <ptrauth.h>
18#endif
1914
2015#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2116# pragma GCC system_header
......@@ -42,18 +37,19 @@
4237// -------------------
4338//
4439// 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)
46// inside a special section, which we do using the `__section__` attribute via the
47// OVERRIDABLE_FUNCTION macro.
40// The general mechanism works by defining a local symbol `__impl_ref<f>::__impl_` with
41// the same address as `f` as a constant expression using direct PC-relative
42// materialization thus pointing at the symbol defined in the same TU. At runtime, it
43// compares the address of `__impl_ref<f>::__impl_` with the address of `f` loaded from
44// GOT: if `f` was overridden by the user in another TU, the addresses will be different.
4845//
49// 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 function
51// we created. This can be done by finding pointers to the start and the end of the section
52// (which is done differently for ELF and Mach-O), and then checking whether `f` falls
53// within those bounds. If it falls within those bounds, then `f` is still inside the
54// special section and so it is the version we defined in the libc++ built library, i.e.
55// it was not overridden. Otherwise, it was overridden by the user because it falls
56// outside of the section.
46// When pointer authentication is used, the above mechanism doesn't work (yet) so we use
47// a different strategy placing `f`'s definition (in the libc++ built library) inside
48// a special section, which we do using the `__section__` attribute via the
49// OVERRIDABLE_FUNCTION macro. Then, when comes the time to check whether the function has
50// been overridden, we take the address of the function and we check whether it falls inside
51// the special section we created. This can be done by finding pointers to the start and
52// the end of the section, and then checking whether `f` falls within those bounds.
5753//
5854// Important note
5955// --------------
......@@ -63,50 +59,80 @@
6359// want to be defining special sections inside user's executables which use our headers.
6460//
6561
66#if defined(_LIBCPP_OBJECT_FORMAT_MACHO)
62#if defined(_LIBCPP_OBJECT_FORMAT_MACHO) || (defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__))
6763
6864# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
69# define OVERRIDABLE_FUNCTION \
70 __attribute__((__section__("__TEXT,__lcxx_override,regular,pure_instructions"))) _LIBCPP_WEAK
7165
72_LIBCPP_BEGIN_NAMESPACE_STD template <typename T, T* _Func>
73_LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
74 // Declare two dummy bytes and give them these special `__asm` values. These values are
75 // defined by the linker, which means that referring to `&__lcxx_override_start` will
76 // effectively refer to the address where the section starts (and same for the end).
77 extern char __lcxx_override_start __asm("section$start$__TEXT$__lcxx_override");
78 extern char __lcxx_override_end __asm("section$end$__TEXT$__lcxx_override");
79
80 // Now get a uintptr_t out of these locations, and out of the function pointer.
81 uintptr_t __start = reinterpret_cast<uintptr_t>(&__lcxx_override_start);
82 uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end);
83 uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
66# if !__has_feature(ptrauth_calls)
8467
85# if __has_feature(ptrauth_calls)
86 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
87 // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
88 // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
89 // stripped the function pointer. See rdar://122927845.
90 __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
91# endif
68# define OVERRIDABLE_FUNCTION [[gnu::weak]]
9269
93 // Finally, the function was overridden if it falls outside of the section's bounds.
94 return __ptr < __start || __ptr > __end;
70_LIBCPP_BEGIN_NAMESPACE_STD
71
72namespace {
73
74// This is used to prevent TBAA from optimizing away the function pointer comparison.
75template <typename T>
76[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI T* __launder_function_pointer(T* __ptr) noexcept {
77 __asm__ volatile("" : "+r"(__ptr));
78 return __ptr;
9579}
80
81} // namespace
82
83template <auto* _Func>
84struct __impl_ref;
85
86// __impl_ref<...>::__impl_ is expected to be defined elsewhere, so the compiler emits
87// assembly references to the mangled symbol with no definition. This template saves us
88// the trouble of providing manual declarations for overloads with some other local name
89// for each function name being overloaded (operator new, operator new[], etc.).
90template <typename _Ret, typename... _Args, _Ret (*_Func)(_Args...)>
91struct __impl_ref<_Func> {
92 [[gnu::visibility("hidden")]] static _Ret __impl_(_Args...);
93};
94
95// This takes a function type template argument first so that the second non-type template
96// argument (pointer to the public function) gets the benefit of type-aware overload
97// resolution, rather than having to use a static_cast.
98template <typename T, T* _Func>
99_LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
100# if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 2101
101 __asm__("%cc0 = %cc1" : : "X"(__impl_ref<_Func>::__impl_), "X"(_Func));
102# else
103 __asm__("%c0 = %c1" : : "X"(__impl_ref<_Func>::__impl_), "X"(_Func));
104# endif
105 // This just has the compiler compare the two symbols. For PIC mode, this will do a
106 // direct PC-relative materialization for __impl_ref<...>::__impl_ and a GOT load for
107 // the _Func symbol. The compiler thinks __impl_ref<...>::__impl_ is defined elsewhere
108 // at link time and will be an undefined symbol. It doesn't know that the __asm__ tells
109 // the assembler to define it as a local symbol.
110 return __launder_function_pointer(_Func) != __impl_ref<_Func>::__impl_;
111}
112
96113_LIBCPP_END_NAMESPACE_STD
97114
98// The NVPTX linker cannot create '__start/__stop' sections.
99#elif defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__)
115# else // __has_feature(ptrauth_calls)
100116
101# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 1
102# define OVERRIDABLE_FUNCTION __attribute__((__section__("__lcxx_override"))) _LIBCPP_WEAK
117# include <cstdint>
118# include <ptrauth.h>
103119
120# if defined(_LIBCPP_OBJECT_FORMAT_MACHO)
121# define OVERRIDABLE_FUNCTION [[gnu::weak, gnu::section("__TEXT,__lcxx_override,regular,pure_instructions")]]
122// Declare two dummy bytes and give them these special `__asm` values. These values are
123// defined by the linker, which means that referring to `&__lcxx_override_start` will
124// effectively refer to the address where the section starts (and same for the end).
125extern char __start___lcxx_override __asm("section$start$__TEXT$__lcxx_override");
126extern char __stop___lcxx_override __asm("section$end$__TEXT$__lcxx_override");
127# elif defined(_LIBCPP_OBJECT_FORMAT_ELF)
104128// This is very similar to what we do for Mach-O above. The ELF linker will implicitly define
105129// variables with those names corresponding to the start and the end of the section.
106130//
107131// See https://stackoverflow.com/questions/16552710/how-do-you-get-the-start-and-end-addresses-of-a-custom-elf-section
132# define OVERRIDABLE_FUNCTION [[gnu::weak, gnu::section("__lcxx_override")]]
108133extern char __start___lcxx_override;
109134extern char __stop___lcxx_override;
135# endif
110136
111137_LIBCPP_BEGIN_NAMESPACE_STD
112138template <typename T, T* _Func>
......@@ -115,20 +141,24 @@ _LIBCPP_HIDE_FROM_ABI inline bool __is_function_overridden() noexcept {
115141 uintptr_t __end = reinterpret_cast<uintptr_t>(&__stop___lcxx_override);
116142 uintptr_t __ptr = reinterpret_cast<uintptr_t>(_Func);
117143
118# if __has_feature(ptrauth_calls)
119 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. See full explanation above.
144 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
145 // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
146 // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
147 // stripped the function pointer. See rdar://122927845.
120148 __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
121# endif
122149
150 // Finally, the function was overridden if it falls outside of the section's bounds.
123151 return __ptr < __start || __ptr > __end;
124152}
125153_LIBCPP_END_NAMESPACE_STD
126154
127#else
155# endif // __has_feature(ptrauth_calls)
156
157#else // defined(_LIBCPP_OBJECT_FORMAT_MACHO) || (defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__))
128158
129159# define _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION 0
130# define OVERRIDABLE_FUNCTION _LIBCPP_WEAK
160# define OVERRIDABLE_FUNCTION [[gnu::weak]]
131161
132#endif
162#endif // defined(_LIBCPP_OBJECT_FORMAT_MACHO) || (defined(_LIBCPP_OBJECT_FORMAT_ELF) && !defined(__NVPTX__))
133163
134164#endif // _LIBCPP_SRC_INCLUDE_OVERRIDABLE_FUNCTION_H
lib/libcxx/src/include/refstring.h+1-1
......@@ -15,7 +15,7 @@
1515#include <cstring>
1616#include <stdexcept>
1717
18// MacOS and iOS used to ship with libstdc++, and still support old applications
18// macOS and iOS used to ship with libstdc++, and still support old applications
1919// linking against libstdc++. The libc++ and libstdc++ exceptions are supposed
2020// to be ABI compatible, such that they can be thrown from one library and caught
2121// in the other.
lib/libcxx/src/include/ryu/ryu.h-18
......@@ -67,24 +67,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
6767
6868// https://github.com/ulfjack/ryu/tree/59661c3/ryu
6969
70#if !defined(_MSC_VER)
71_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward64(unsigned long* __index, unsigned long long __mask) {
72 if (__mask == 0) {
73 return false;
74 }
75 *__index = __builtin_ctzll(__mask);
76 return true;
77}
78
79_LIBCPP_HIDE_FROM_ABI inline unsigned char _BitScanForward(unsigned long* __index, unsigned int __mask) {
80 if (__mask == 0) {
81 return false;
82 }
83 *__index = __builtin_ctz(__mask);
84 return true;
85}
86#endif // !_MSC_VER
87
8870template <class _Floating>
8971[[nodiscard]] to_chars_result _Floating_to_chars_ryu(
9072 char* const _First, char* const _Last, const _Floating _Value, const chars_format _Fmt) noexcept {
lib/libcxx/src/include/to_chars_floating_point.h+1-1
......@@ -38,7 +38,7 @@ namespace __itoa {
3838inline constexpr char _Charconv_digits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e',
3939 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
4040static_assert(std::size(_Charconv_digits) == 36);
41} // __itoa
41} // namespace __itoa
4242
4343// vvvvvvvvvv DERIVED FROM corecrt_internal_fltintrn.h vvvvvvvvvv
4444
lib/libcxx/src/ios.cpp+38-39
......@@ -9,6 +9,7 @@
99#include <__config>
1010#include <__locale>
1111#include <algorithm>
12#include <atomic>
1213#include <ios>
1314#include <limits>
1415#include <memory>
......@@ -22,6 +23,7 @@ _LIBCPP_PUSH_MACROS
2223#include <__undef_macros>
2324
2425_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2527
2628class _LIBCPP_HIDDEN __iostream_category : public __do_message {
2729public:
......@@ -102,25 +104,13 @@ void ios_base::__call_callbacks(event ev) {
102104// locale
103105
104106locale ios_base::imbue(const locale& newloc) {
105 static_assert(sizeof(locale) == sizeof(__loc_), "");
106 locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
107 locale oldloc = loc_storage;
108 loc_storage = newloc;
107 locale loc = newloc;
108 std::swap(__loc_, loc);
109109 __call_callbacks(imbue_event);
110 return oldloc;
110 return loc;
111111}
112112
113locale ios_base::getloc() const {
114 const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
115 return loc_storage;
116}
117
118// xalloc
119#if _LIBCPP_HAS_C_ATOMIC_IMP && _LIBCPP_HAS_THREADS
120atomic<int> ios_base::__xindex_{0};
121#else
122int ios_base::__xindex_ = 0;
123#endif
113locale ios_base::getloc() const { return __loc_; }
124114
125115template <typename _Tp>
126116static size_t __ios_new_cap(size_t __req_size, size_t __current_cap) { // Precondition: __req_size > __current_cap
......@@ -131,7 +121,17 @@ static size_t __ios_new_cap(size_t __req_size, size_t __current_cap) { // Precon
131121 return mx;
132122}
133123
134int ios_base::xalloc() { return __xindex_++; }
124int ios_base::xalloc() {
125#if _LIBCPP_HAS_THREADS
126 constinit static atomic<int> xindex = 0;
127#else
128 // If we don't have atomics, fall back to single-threaded implementation.
129 // FIXME: Should "single-threaded" be a separate option from
130 // _LIBCPP_HAS_THREADS?
131 static int xindex = 0;
132#endif // _LIBCPP_HAS_THREADS
133 return xindex++;
134}
135135
136136long& ios_base::iword(int index) {
137137 size_t req_size = static_cast<size_t>(index) + 1;
......@@ -180,12 +180,16 @@ void ios_base::register_callback(event_callback fn, int index) {
180180 if (req_size > __event_cap_) {
181181 size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
182182 event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
183 if (fns == 0)
183 if (fns == 0) {
184184 setstate(badbit);
185 return;
186 }
185187 __fn_ = fns;
186188 int* indxs = static_cast<int*>(realloc(__index_, newcap * sizeof(int)));
187 if (indxs == 0)
189 if (indxs == 0) {
188190 setstate(badbit);
191 return;
192 }
189193 __index_ = indxs;
190194 __event_cap_ = newcap;
191195 }
......@@ -197,11 +201,10 @@ void ios_base::register_callback(event_callback fn, int index) {
197201ios_base::~ios_base() {
198202 // Avoid UB when not properly initialized. See ios_base::ios_base for
199203 // more information.
200 if (!__loc_)
204 if (!__loc_.__locale_)
201205 return;
202206 __call_callbacks(erase_event);
203 locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
204 loc_storage.~locale();
207 __loc_.~locale();
205208 free(__fn_);
206209 free(__index_);
207210 free(__iarray_);
......@@ -273,12 +276,10 @@ void ios_base::copyfmt(const ios_base& rhs) {
273276 std::__throw_bad_alloc();
274277 }
275278 // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
276 __fmtflags_ = rhs.__fmtflags_;
277 __precision_ = rhs.__precision_;
278 __width_ = rhs.__width_;
279 locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
280 const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
281 lhs_loc = rhs_loc;
279 __fmtflags_ = rhs.__fmtflags_;
280 __precision_ = rhs.__precision_;
281 __width_ = rhs.__width_;
282 __loc_ = rhs.__loc_;
282283 if (__event_cap_ < rhs.__event_size_) {
283284 free(__fn_);
284285 __fn_ = new_callbacks.release();
......@@ -308,14 +309,13 @@ void ios_base::copyfmt(const ios_base& rhs) {
308309
309310void ios_base::move(ios_base& rhs) {
310311 // *this is uninitialized
311 __fmtflags_ = rhs.__fmtflags_;
312 __precision_ = rhs.__precision_;
313 __width_ = rhs.__width_;
314 __rdstate_ = rhs.__rdstate_;
315 __exceptions_ = rhs.__exceptions_;
316 __rdbuf_ = 0;
317 locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
318 ::new (&__loc_) locale(rhs_loc);
312 __fmtflags_ = rhs.__fmtflags_;
313 __precision_ = rhs.__precision_;
314 __width_ = rhs.__width_;
315 __rdstate_ = rhs.__rdstate_;
316 __exceptions_ = rhs.__exceptions_;
317 __rdbuf_ = 0;
318 ::new (&__loc_) locale(rhs.__loc_);
319319 __fn_ = rhs.__fn_;
320320 rhs.__fn_ = 0;
321321 __index_ = rhs.__index_;
......@@ -344,9 +344,7 @@ void ios_base::swap(ios_base& rhs) noexcept {
344344 std::swap(__width_, rhs.__width_);
345345 std::swap(__rdstate_, rhs.__rdstate_);
346346 std::swap(__exceptions_, rhs.__exceptions_);
347 locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
348 locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
349 std::swap(lhs_loc, rhs_loc);
347 std::swap(__loc_, rhs.__loc_);
350348 std::swap(__fn_, rhs.__fn_);
351349 std::swap(__index_, rhs.__index_);
352350 std::swap(__event_size_, rhs.__event_size_);
......@@ -382,6 +380,7 @@ bool ios_base::sync_with_stdio(bool sync) {
382380 return r;
383381}
384382
383_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
385384_LIBCPP_END_NAMESPACE_STD
386385
387386_LIBCPP_POP_MACROS
lib/libcxx/src/ios.instantiations.cpp+21
......@@ -15,6 +15,26 @@
1515#include <streambuf>
1616
1717_LIBCPP_BEGIN_NAMESPACE_STD
18_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
19
20#if _LIBCPP_HAS_FILESYSTEM
21// This is provided for ABI compatiblity with programs compiled against old headers.
22// TODO: Is this actually required? If so, this should be guarded with
23// `_LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 24`. Otherwise this should be removed.
24template <class _CharT, class _Traits>
25bool basic_filebuf<_CharT, _Traits>::__read_mode() {
26 if (!(__cm_ & ios_base::in)) {
27 this->setp(nullptr, nullptr);
28 if (__always_noconv_)
29 this->setg((char_type*)__extbuf_, (char_type*)__extbuf_ + __ebs_, (char_type*)__extbuf_ + __ebs_);
30 else
31 this->setg(__intbuf_, __intbuf_ + __ibs_, __intbuf_ + __ibs_);
32 __cm_ = ios_base::in;
33 return true;
34 }
35 return false;
36}
37#endif
1838
1939// Original explicit instantiations provided in the library
2040template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_ios<char>;
......@@ -45,4 +65,5 @@ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS basic_filebuf<char>;
4565
4666// Add more here if needed...
4767
68_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4869_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/iostream.cpp+2
......@@ -15,6 +15,7 @@
1515#define ABI_NAMESPACE_STR _LIBCPP_TOSTRING(_LIBCPP_ABI_NAMESPACE)
1616
1717_LIBCPP_BEGIN_NAMESPACE_STD
18_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1819
1920// This file implements the various stream objects provided inside <iostream>. We're doing some ODR violations in here,
2021// so this quite fragile. Specifically, the size of the stream objects (i.e. cout, cin etc.) needs to stay the same.
......@@ -154,4 +155,5 @@ ios_base::Init::Init() {
154155
155156ios_base::Init::~Init() {}
156157
158_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
157159_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/locale.cpp+22-18
......@@ -45,6 +45,7 @@ _LIBCPP_PUSH_MACROS
4545#include <__undef_macros>
4646
4747_LIBCPP_BEGIN_NAMESPACE_STD
48_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
4849
4950struct __libcpp_unique_locale {
5051 __libcpp_unique_locale(const char* nm) : __loc_(__locale::__newlocale(_LIBCPP_ALL_MASK, nm, 0)) {}
......@@ -158,11 +159,11 @@ locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") {
158159 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
159160 install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
160161 install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
161 _LIBCPP_SUPPRESS_DEPRECATED_POP
162162#if _LIBCPP_HAS_CHAR8_T
163163 install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
164164 install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
165165#endif
166 _LIBCPP_SUPPRESS_DEPRECATED_POP
166167 install(&make<numpunct<char> >(1u));
167168#if _LIBCPP_HAS_WIDE_CHARACTERS
168169 install(&make<numpunct<wchar_t> >(1u));
......@@ -228,11 +229,11 @@ locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N),
228229 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
229230 install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
230231 install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
231 _LIBCPP_SUPPRESS_DEPRECATED_POP
232232#if _LIBCPP_HAS_CHAR8_T
233233 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
234234 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
235235#endif
236 _LIBCPP_SUPPRESS_DEPRECATED_POP
236237 install(new numpunct_byname<char>(name_));
237238#if _LIBCPP_HAS_WIDE_CHARACTERS
238239 install(new numpunct_byname<wchar_t>(name_));
......@@ -294,11 +295,11 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
294295 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
295296 install(new codecvt_byname<char16_t, char, mbstate_t>(name));
296297 install(new codecvt_byname<char32_t, char, mbstate_t>(name));
297 _LIBCPP_SUPPRESS_DEPRECATED_POP
298298#if _LIBCPP_HAS_CHAR8_T
299299 install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
300300 install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
301301#endif
302 _LIBCPP_SUPPRESS_DEPRECATED_POP
302303 }
303304 if (c & locale::monetary) {
304305 install(new moneypunct_byname<char, false>(name));
......@@ -366,11 +367,11 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
366367 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
367368 install_from<std::codecvt<char16_t, char, mbstate_t> >(one);
368369 install_from<std::codecvt<char32_t, char, mbstate_t> >(one);
369 _LIBCPP_SUPPRESS_DEPRECATED_POP
370370#if _LIBCPP_HAS_CHAR8_T
371371 install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);
372372 install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);
373373#endif
374 _LIBCPP_SUPPRESS_DEPRECATED_POP
374375#if _LIBCPP_HAS_WIDE_CHARACTERS
375376 install_from<std::codecvt<wchar_t, char, mbstate_t> >(one);
376377#endif
......@@ -2318,7 +2319,7 @@ static codecvt_base::result utf16be_to_ucs4(
23182319 frm_nxt += 2;
23192320 }
23202321 for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
2321 uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
2322 uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
23222323 if ((c1 & 0xFC00) == 0xDC00)
23232324 return codecvt_base::error;
23242325 if ((c1 & 0xFC00) != 0xD800) {
......@@ -2329,7 +2330,7 @@ static codecvt_base::result utf16be_to_ucs4(
23292330 } else {
23302331 if (frm_end - frm_nxt < 4)
23312332 return codecvt_base::partial;
2332 uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
2333 uint16_t c2 = static_cast<uint16_t>((frm_nxt[2] << 8) | frm_nxt[3]);
23332334 if ((c2 & 0xFC00) != 0xDC00)
23342335 return codecvt_base::error;
23352336 uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
......@@ -2354,7 +2355,7 @@ static int utf16be_to_ucs4_length(
23542355 frm_nxt += 2;
23552356 }
23562357 for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t) {
2357 uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
2358 uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
23582359 if ((c1 & 0xFC00) == 0xDC00)
23592360 break;
23602361 if ((c1 & 0xFC00) != 0xD800) {
......@@ -2364,7 +2365,7 @@ static int utf16be_to_ucs4_length(
23642365 } else {
23652366 if (frm_end - frm_nxt < 4)
23662367 break;
2367 uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
2368 uint16_t c2 = static_cast<uint16_t>((frm_nxt[2] << 8) | frm_nxt[3]);
23682369 if ((c2 & 0xFC00) != 0xDC00)
23692370 break;
23702371 uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
......@@ -2432,7 +2433,7 @@ static codecvt_base::result utf16le_to_ucs4(
24322433 frm_nxt += 2;
24332434 }
24342435 for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
2435 uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
2436 uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
24362437 if ((c1 & 0xFC00) == 0xDC00)
24372438 return codecvt_base::error;
24382439 if ((c1 & 0xFC00) != 0xD800) {
......@@ -2443,7 +2444,7 @@ static codecvt_base::result utf16le_to_ucs4(
24432444 } else {
24442445 if (frm_end - frm_nxt < 4)
24452446 return codecvt_base::partial;
2446 uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
2447 uint16_t c2 = static_cast<uint16_t>((frm_nxt[3] << 8) | frm_nxt[2]);
24472448 if ((c2 & 0xFC00) != 0xDC00)
24482449 return codecvt_base::error;
24492450 uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
......@@ -2468,7 +2469,7 @@ static int utf16le_to_ucs4_length(
24682469 frm_nxt += 2;
24692470 }
24702471 for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t) {
2471 uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
2472 uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
24722473 if ((c1 & 0xFC00) == 0xDC00)
24732474 break;
24742475 if ((c1 & 0xFC00) != 0xD800) {
......@@ -2478,7 +2479,7 @@ static int utf16le_to_ucs4_length(
24782479 } else {
24792480 if (frm_end - frm_nxt < 4)
24802481 break;
2481 uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
2482 uint16_t c2 = static_cast<uint16_t>((frm_nxt[3] << 8) | frm_nxt[2]);
24822483 if ((c2 & 0xFC00) != 0xDC00)
24832484 break;
24842485 uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
......@@ -2535,7 +2536,7 @@ static codecvt_base::result utf16be_to_ucs2(
25352536 frm_nxt += 2;
25362537 }
25372538 for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
2538 uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
2539 uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
25392540 if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
25402541 return codecvt_base::error;
25412542 *to_nxt = c1;
......@@ -2556,7 +2557,7 @@ static int utf16be_to_ucs2_length(
25562557 frm_nxt += 2;
25572558 }
25582559 for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t) {
2559 uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
2560 uint16_t c1 = static_cast<uint16_t>((frm_nxt[0] << 8) | frm_nxt[1]);
25602561 if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
25612562 break;
25622563 frm_nxt += 2;
......@@ -2609,7 +2610,7 @@ static codecvt_base::result utf16le_to_ucs2(
26092610 frm_nxt += 2;
26102611 }
26112612 for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
2612 uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
2613 uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
26132614 if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
26142615 return codecvt_base::error;
26152616 *to_nxt = c1;
......@@ -2631,7 +2632,7 @@ static int utf16le_to_ucs2_length(
26312632 frm_nxt += 2;
26322633 }
26332634 for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t) {
2634 uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
2635 uint16_t c1 = static_cast<uint16_t>((frm_nxt[1] << 8) | frm_nxt[0]);
26352636 if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
26362637 break;
26372638 frm_nxt += 2;
......@@ -5651,10 +5652,13 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_
56515652template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
56525653 codecvt_byname<char32_t, char, mbstate_t>;
56535654#if _LIBCPP_HAS_CHAR8_T
5654template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
5655template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
5655template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
5656 codecvt_byname<char16_t, char8_t, mbstate_t>;
5657template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
5658 codecvt_byname<char32_t, char8_t, mbstate_t>;
56565659#endif
56575660
5661_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
56585662_LIBCPP_END_NAMESPACE_STD
56595663
56605664_LIBCPP_POP_MACROS
lib/libcxx/src/memory.cpp+3-2
......@@ -7,8 +7,7 @@
77//===----------------------------------------------------------------------===//
88
99#include <__config>
10#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) && !defined(_LIBCPP_OBJECT_FORMAT_XCOFF) && \
11 _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 5
10#if !defined(_LIBCPP_OBJECT_FORMAT_COFF) && _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 5
1211# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
1312#endif
1413
......@@ -27,6 +26,7 @@
2726#include "include/atomic_support.h"
2827
2928_LIBCPP_BEGIN_NAMESPACE_STD
29_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3030
3131bad_weak_ptr::~bad_weak_ptr() noexcept {}
3232
......@@ -145,4 +145,5 @@ _LIBCPP_DIAGNOSTIC_POP
145145
146146#endif
147147
148_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
148149_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/memory_resource.cpp+3-34
......@@ -6,20 +6,13 @@
66//
77//===----------------------------------------------------------------------===//
88
9#include <atomic>
910#include <cstddef>
1011#include <memory>
1112#include <memory_resource>
1213
13#if _LIBCPP_HAS_ATOMIC_HEADER
14# include <atomic>
15#elif _LIBCPP_HAS_THREADS
16# include <mutex>
17# if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
18# pragma comment(lib, "pthread")
19# endif
20#endif
21
2214_LIBCPP_BEGIN_NAMESPACE_STD
15_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2316
2417namespace pmr {
2518
......@@ -94,7 +87,6 @@ memory_resource* null_memory_resource() noexcept { return &res_init.resources.nu
9487// default_memory_resource()
9588
9689static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept {
97#if _LIBCPP_HAS_ATOMIC_HEADER
9890 static constinit atomic<memory_resource*> __res{&res_init.resources.new_delete_res};
9991 if (set) {
10092 new_res = new_res ? new_res : new_delete_resource();
......@@ -103,30 +95,6 @@ static memory_resource* __default_memory_resource(bool set = false, memory_resou
10395 } else {
10496 return std::atomic_load_explicit(&__res, memory_order_acquire);
10597 }
106#elif _LIBCPP_HAS_THREADS
107 static constinit memory_resource* res = &res_init.resources.new_delete_res;
108 static mutex res_lock;
109 if (set) {
110 new_res = new_res ? new_res : new_delete_resource();
111 lock_guard<mutex> guard(res_lock);
112 memory_resource* old_res = res;
113 res = new_res;
114 return old_res;
115 } else {
116 lock_guard<mutex> guard(res_lock);
117 return res;
118 }
119#else
120 static constinit memory_resource* res = &res_init.resources.new_delete_res;
121 if (set) {
122 new_res = new_res ? new_res : new_delete_resource();
123 memory_resource* old_res = res;
124 res = new_res;
125 return old_res;
126 } else {
127 return res;
128 }
129#endif
13098}
13199
132100memory_resource* get_default_resource() noexcept { return __default_memory_resource(); }
......@@ -497,4 +465,5 @@ void* monotonic_buffer_resource::do_allocate(size_t bytes, size_t align) {
497465
498466} // namespace pmr
499467
468_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
500469_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/mutex.cpp+2
......@@ -23,6 +23,7 @@ _LIBCPP_PUSH_MACROS
2323#include <__undef_macros>
2424
2525_LIBCPP_BEGIN_NAMESPACE_STD
26_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2627
2728// ~mutex is defined elsewhere
2829
......@@ -141,6 +142,7 @@ void recursive_timed_mutex::unlock() noexcept {
141142 }
142143}
143144
145_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
144146_LIBCPP_END_NAMESPACE_STD
145147
146148_LIBCPP_POP_MACROS
lib/libcxx/src/mutex_destructor.cpp+2
......@@ -24,6 +24,7 @@
2424#endif
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728
2829#ifdef NEEDS_MUTEX_DESTRUCTOR
2930class _LIBCPP_EXPORTED_FROM_ABI mutex {
......@@ -39,4 +40,5 @@ public:
3940mutex::~mutex() noexcept { __libcpp_mutex_destroy(&__m_); }
4041#endif // !NEEDS_MUTEX_DESTRUCTOR
4142
43_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4244_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/new.cpp+16-16
......@@ -50,7 +50,7 @@ OVERRIDABLE_FUNCTION void* operator new(std::size_t size) _THROW_BAD_ALLOC {
5050 return p;
5151}
5252
53_LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
53[[gnu::weak]] void* operator new(size_t size, const std::nothrow_t&) noexcept {
5454# if !_LIBCPP_HAS_EXCEPTIONS
5555# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
5656 _LIBCPP_ASSERT_SHIM(
......@@ -76,7 +76,7 @@ _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept {
7676
7777OVERRIDABLE_FUNCTION void* operator new[](size_t size) _THROW_BAD_ALLOC { return ::operator new(size); }
7878
79_LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
79[[gnu::weak]] void* operator new[](size_t size, const std::nothrow_t&) noexcept {
8080# if !_LIBCPP_HAS_EXCEPTIONS
8181# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
8282 _LIBCPP_ASSERT_SHIM(
......@@ -100,17 +100,17 @@ _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept {
100100# endif
101101}
102102
103_LIBCPP_WEAK void operator delete(void* ptr) noexcept { std::free(ptr); }
103[[gnu::weak]] void operator delete(void* ptr) noexcept { std::free(ptr); }
104104
105_LIBCPP_WEAK void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); }
105[[gnu::weak]] void operator delete(void* ptr, const std::nothrow_t&) noexcept { ::operator delete(ptr); }
106106
107_LIBCPP_WEAK void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); }
107[[gnu::weak]] void operator delete(void* ptr, size_t) noexcept { ::operator delete(ptr); }
108108
109_LIBCPP_WEAK void operator delete[](void* ptr) noexcept { ::operator delete(ptr); }
109[[gnu::weak]] void operator delete[](void* ptr) noexcept { ::operator delete(ptr); }
110110
111_LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); }
111[[gnu::weak]] void operator delete[](void* ptr, const std::nothrow_t&) noexcept { ::operator delete[](ptr); }
112112
113_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }
113[[gnu::weak]] void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }
114114
115115# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
116116
......@@ -141,7 +141,7 @@ OVERRIDABLE_FUNCTION void* operator new(std::size_t size, std::align_val_t align
141141 return p;
142142}
143143
144_LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
144[[gnu::weak]] void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
145145# if !_LIBCPP_HAS_EXCEPTIONS
146146# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
147147 _LIBCPP_ASSERT_SHIM(
......@@ -169,7 +169,7 @@ OVERRIDABLE_FUNCTION void* operator new[](size_t size, std::align_val_t alignmen
169169 return ::operator new(size, alignment);
170170}
171171
172_LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
172[[gnu::weak]] void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept {
173173# if !_LIBCPP_HAS_EXCEPTIONS
174174# if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION
175175 _LIBCPP_ASSERT_SHIM(
......@@ -193,25 +193,25 @@ _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const
193193# endif
194194}
195195
196_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); }
196[[gnu::weak]] void operator delete(void* ptr, std::align_val_t) noexcept { std::__libcpp_aligned_free(ptr); }
197197
198_LIBCPP_WEAK void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {
198[[gnu::weak]] void operator delete(void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {
199199 ::operator delete(ptr, alignment);
200200}
201201
202_LIBCPP_WEAK void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept {
202[[gnu::weak]] void operator delete(void* ptr, size_t, std::align_val_t alignment) noexcept {
203203 ::operator delete(ptr, alignment);
204204}
205205
206_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment) noexcept {
206[[gnu::weak]] void operator delete[](void* ptr, std::align_val_t alignment) noexcept {
207207 ::operator delete(ptr, alignment);
208208}
209209
210_LIBCPP_WEAK void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {
210[[gnu::weak]] void operator delete[](void* ptr, std::align_val_t alignment, const std::nothrow_t&) noexcept {
211211 ::operator delete[](ptr, alignment);
212212}
213213
214_LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept {
214[[gnu::weak]] void operator delete[](void* ptr, size_t, std::align_val_t alignment) noexcept {
215215 ::operator delete[](ptr, alignment);
216216}
217217
lib/libcxx/src/optional.cpp+2
......@@ -24,6 +24,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac
2424// Preserve std::experimental::bad_optional_access for ABI compatibility
2525// Even though it no longer exists in a header file
2626_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728
2829class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public std::logic_error {
2930public:
......@@ -35,6 +36,7 @@ public:
3536
3637bad_optional_access::~bad_optional_access() noexcept = default;
3738
39_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3840_LIBCPP_END_NAMESPACE_EXPERIMENTAL
3941
4042#endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 7
lib/libcxx/src/ostream.cpp+2
......@@ -15,6 +15,7 @@
1515#include "std_stream.h"
1616
1717_LIBCPP_BEGIN_NAMESPACE_STD
18_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1819
1920_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
2021 // dynamic_cast requires RTTI, this only affects users whose vendor builds
......@@ -38,4 +39,5 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
3839 return nullptr;
3940}
4041
42_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4143_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/print.cpp+6-1
......@@ -33,6 +33,7 @@
3333#endif
3434
3535_LIBCPP_BEGIN_NAMESPACE_STD
36_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3637
3738#if defined(_LIBCPP_WIN32API)
3839
......@@ -64,9 +65,13 @@ __write_to_windows_console([[maybe_unused]] FILE* __stream, [[maybe_unused]] wst
6465}
6566# endif // _LIBCPP_HAS_WIDE_CHARACTERS
6667
67#elif defined(HAS_FILENO_AND_ISATTY) // !_LIBCPP_WIN32API
68#elif defined(HAS_FILENO_AND_ISATTY) && _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 23 // !_LIBCPP_WIN32API
6869
70_LIBCPP_DIAGNOSTIC_PUSH
71_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-prototypes")
6972_LIBCPP_EXPORTED_FROM_ABI bool __is_posix_terminal(FILE* __stream) { return isatty(fileno(__stream)); }
73_LIBCPP_DIAGNOSTIC_POP
7074#endif
7175
76_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
7277_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/pstl/libdispatch.cpp+2
......@@ -12,6 +12,7 @@
1212#include <dispatch/dispatch.h>
1313
1414_LIBCPP_BEGIN_NAMESPACE_STD
15_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1516namespace __pstl::__libdispatch {
1617
1718void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept {
......@@ -29,4 +30,5 @@ __chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept {
2930}
3031
3132} // namespace __pstl::__libdispatch
33_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3234_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/random.cpp+2
......@@ -36,6 +36,7 @@
3636#endif
3737
3838_LIBCPP_BEGIN_NAMESPACE_STD
39_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3940
4041#if defined(_LIBCPP_USING_GETENTROPY)
4142
......@@ -153,4 +154,5 @@ double random_device::entropy() const noexcept {
153154#endif
154155}
155156
157_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
156158_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/random_shuffle.cpp+2
......@@ -17,6 +17,7 @@
1717#endif
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
20_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2021
2122#if _LIBCPP_HAS_THREADS
2223static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
......@@ -48,4 +49,5 @@ __rs_default::result_type __rs_default::operator()() {
4849
4950__rs_default __rs_get() { return __rs_default(); }
5051
52_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
5153_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/regex.cpp+2
......@@ -11,6 +11,7 @@
1111#include <regex>
1212
1313_LIBCPP_BEGIN_NAMESPACE_STD
14_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1415
1516static const char* make_error_type_string(regex_constants::error_type ecode) {
1617 switch (ecode) {
......@@ -396,4 +397,5 @@ void __match_any_but_newline<wchar_t>::__exec(__state& __s) const {
396397 }
397398}
398399
400_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
399401_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/ryu/d2s.cpp+2-13
......@@ -41,6 +41,7 @@
4141
4242#include <__assert>
4343#include <__config>
44#include <bit>
4445#include <charconv>
4546#include <cstddef>
4647
......@@ -478,19 +479,7 @@ struct __floating_decimal_64 {
478479 2882303761517u, 576460752303u, 115292150460u, 23058430092u, 4611686018u, 922337203u, 184467440u,
479480 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u };
480481
481 unsigned long _Trailing_zero_bits;
482#if _LIBCPP_HAS_BITSCAN64
483 (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
484#else // ^^^ 64-bit ^^^ / vvv 32-bit vvv
485 const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa);
486 if (_Low_mantissa != 0) {
487 (void) _BitScanForward(&_Trailing_zero_bits, _Low_mantissa);
488 } else {
489 const uint32_t _High_mantissa = static_cast<uint32_t>(__v.__mantissa >> 32); // nonzero here
490 (void) _BitScanForward(&_Trailing_zero_bits, _High_mantissa);
491 _Trailing_zero_bits += 32;
492 }
493#endif // ^^^ 32-bit ^^^
482 unsigned long _Trailing_zero_bits = std::countr_zero(__v.__mantissa);
494483 const uint64_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits;
495484 _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent];
496485 }
lib/libcxx/src/ryu/f2s.cpp+2-2
......@@ -41,6 +41,7 @@
4141
4242#include <__assert>
4343#include <__config>
44#include <bit>
4445#include <charconv>
4546#include <cstdint>
4647#include <cstddef>
......@@ -535,8 +536,7 @@ struct __floating_decimal_32 {
535536 static constexpr uint32_t _Max_shifted_mantissa[11] = {
536537 16777215, 3355443, 671088, 134217, 26843, 5368, 1073, 214, 42, 8, 1 };
537538
538 unsigned long _Trailing_zero_bits;
539 (void) _BitScanForward(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero
539 unsigned long _Trailing_zero_bits = std::countr_zero(__v.__mantissa); // __v.__mantissa is guaranteed nonzero
540540 const uint32_t _Shifted_mantissa = __v.__mantissa >> _Trailing_zero_bits;
541541 _Can_use_ryu = _Shifted_mantissa <= _Max_shifted_mantissa[_Ryu_exponent];
542542 }
lib/libcxx/src/shared_mutex.cpp+2
......@@ -13,6 +13,7 @@
1313#endif
1414
1515_LIBCPP_BEGIN_NAMESPACE_STD
16_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1617
1718// Shared Mutex Base
1819__shared_mutex_base::__shared_mutex_base() : __state_(0) {}
......@@ -96,4 +97,5 @@ void shared_timed_mutex::lock_shared() { return __base_.lock_shared(); }
9697bool shared_timed_mutex::try_lock_shared() { return __base_.try_lock_shared(); }
9798void shared_timed_mutex::unlock_shared() { return __base_.unlock_shared(); }
9899
100_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
99101_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/std_stream.h+2
......@@ -24,6 +24,7 @@ _LIBCPP_PUSH_MACROS
2424#include <__undef_macros>
2525
2626_LIBCPP_BEGIN_NAMESPACE_STD
27_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2728
2829static const int __limit = 8;
2930
......@@ -380,6 +381,7 @@ void __stdoutbuf<_CharT>::imbue(const locale& __loc) {
380381 __always_noconv_ = __cv_->always_noconv();
381382}
382383
384_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
383385_LIBCPP_END_NAMESPACE_STD
384386
385387_LIBCPP_POP_MACROS
lib/libcxx/src/stdexcept.cpp+2
......@@ -18,6 +18,7 @@
1818#endif
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
21_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2122
2223void __throw_runtime_error(const char* msg) {
2324#if _LIBCPP_HAS_EXCEPTIONS
......@@ -27,4 +28,5 @@ void __throw_runtime_error(const char* msg) {
2728#endif
2829}
2930
31_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3032_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/string.cpp+2
......@@ -19,6 +19,7 @@
1919#endif
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
22_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2223
2324#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 14
2425
......@@ -367,4 +368,5 @@ wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string
367368wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }
368369#endif
369370
371_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
370372_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/strstream.cpp+2
......@@ -18,6 +18,7 @@ _LIBCPP_PUSH_MACROS
1818#include <__undef_macros>
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
21_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2122
2223strstreambuf::strstreambuf(streamsize __alsize)
2324 : __strmode_(__dynamic), __alsize_(__alsize), __palloc_(nullptr), __pfree_(nullptr) {}
......@@ -253,6 +254,7 @@ ostrstream::~ostrstream() {}
253254
254255strstream::~strstream() {}
255256
257_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
256258_LIBCPP_END_NAMESPACE_STD
257259
258260_LIBCPP_POP_MACROS
lib/libcxx/src/support/runtime/exception_pointer_msvc.ipp+425-34
......@@ -7,62 +7,453 @@
77//
88//===----------------------------------------------------------------------===//
99
10#include <exception>
11#include <stdio.h>
12#include <stdlib.h>
13
14_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCreate(void*);
15_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrDestroy(void*);
16_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCopy(void*, const void*);
17_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrAssign(void*, const void*);
18_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrCompare(const void*, const void*);
19_LIBCPP_CRT_FUNC bool __cdecl __ExceptionPtrToBool(const void*);
20_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrSwap(void*, void*);
21_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCurrentException(void*);
22[[noreturn]] _LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrRethrow(const void*);
23_LIBCPP_CRT_FUNC void __cdecl __ExceptionPtrCopyException(void*, const void*, const void*);
10_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmultichar")
2411
25namespace std {
12#include <__exception/exception_ptr.h>
13#include <__memory/shared_count.h>
14#include <cstdlib>
15#include <cstring>
2616
27exception_ptr::exception_ptr() noexcept { __ExceptionPtrCreate(this); }
28exception_ptr::exception_ptr(nullptr_t) noexcept { __ExceptionPtrCreate(this); }
17#include <unknwn.h>
18#include <windows.h>
19struct _ThrowInfo;
20#include <eh.h>
21#include <ehdata.h>
22#include <malloc.h> // alloca
2923
30exception_ptr::exception_ptr(const exception_ptr& __other) noexcept { __ExceptionPtrCopy(this, &__other); }
31exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept {
32 __ExceptionPtrAssign(this, &__other);
33 return *this;
24// Pre-V4 managed exception code
25#define MANAGED_EXCEPTION_CODE 0XE0434F4D
26
27// V4 and later managed exception code
28#define MANAGED_EXCEPTION_CODE_V4 0XE0434352
29
30extern "C" _LIBCPP_CRT_FUNC void* __cdecl __AdjustPointer(void*, const PMD&);
31extern "C" _LIBCPP_CRT_FUNC void** __cdecl __current_exception();
32
33namespace {
34
35typedef void(__stdcall* __prepare_for_throw_t)(void*);
36
37struct __winrt_exception_info {
38 void* __description;
39 void* __restricted_error_string;
40 void* __restricted_error_reference;
41 void* __capability_sid;
42 long __hr;
43 void* __restricted_info;
44 ThrowInfo* __throw_info;
45 unsigned int __size;
46 __prepare_for_throw_t __prepare_throw;
47};
48
49inline EHExceptionRecord* __get_current_exception() noexcept {
50 return *reinterpret_cast<EHExceptionRecord**>(__current_exception());
3451}
3552
36exception_ptr& exception_ptr::operator=(nullptr_t) noexcept {
37 exception_ptr dummy;
38 __ExceptionPtrAssign(this, &dummy);
39 return *this;
53inline void __call_member_function_0(void* __this, void* __mfn) {
54 auto __fn = reinterpret_cast<void(__thiscall*)(void*)>(__mfn);
55 __fn(__this);
56}
57
58inline void __call_member_function_1(void* __this, void* __mfn, void* __arg) {
59 auto __fn = reinterpret_cast<void(__thiscall*)(void*, void*)>(__mfn);
60 __fn(__this, __arg);
61}
62
63inline void __call_member_function_2(void* __this, void* __mfn, void* __arg1, int __arg2) {
64 auto __fn = reinterpret_cast<void(__thiscall*)(void*, void*, int)>(__mfn);
65 __fn(__this, __arg1, __arg2);
4066}
4167
42exception_ptr::~exception_ptr() noexcept { __ExceptionPtrDestroy(this); }
68void __populate_cpp_exception_record(
69 _EXCEPTION_RECORD& __record, const void* const __except_obj, ThrowInfo* __throw_info) noexcept {
70 __record.ExceptionCode = EH_EXCEPTION_NUMBER;
71 __record.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
72 __record.ExceptionRecord = nullptr; // No SEH to chain.
73 __record.ExceptionAddress = nullptr; // Address of exception. This will be overwritten by OS.
74 __record.NumberParameters = EH_EXCEPTION_PARAMETERS;
75 __record.ExceptionInformation[0] = EH_MAGIC_NUMBER1;
76 __record.ExceptionInformation[1] = reinterpret_cast<ULONG_PTR>(__except_obj);
77
78 if (__throw_info && (__throw_info->attributes & TI_IsWinRT)) {
79 // The pointer to the ExceptionInfo structure is stored sizeof(void*) in front of each WinRT Exception Info.
80 const auto __wei = (*static_cast<__winrt_exception_info** const*>(const_cast<void*>(__except_obj)))[-1];
81 __throw_info = __wei->__throw_info;
82 }
83
84 __record.ExceptionInformation[2] = reinterpret_cast<ULONG_PTR>(__throw_info);
85
86#if _EH_RELATIVE_TYPEINFO
87 void* __throw_image_base =
88 __throw_info ? RtlPcToFileHeader(const_cast<void*>(static_cast<const void*>(__throw_info)), &__throw_image_base)
89 : nullptr;
90 __record.ExceptionInformation[3] = reinterpret_cast<ULONG_PTR>(__throw_image_base);
91#endif // _EH_RELATIVE_TYPEINFO
92
93 // If the throw info indicates this throw is from a pure region, set the magic number to the Pure one, so only a
94 // pure-region catch will see it.
95 //
96 // Also use the Pure magic number on 64-bit platforms if we were unable to determine an image base, since that was the
97 // old way to determine a pure throw, before the TI_IsPure bit was added to the FuncInfo attributes field.
98 if (__throw_info && ((__throw_info->attributes & TI_IsPure)
99#if _EH_RELATIVE_TYPEINFO
100 || !__throw_image_base
101#endif // _EH_RELATIVE_TYPEINFO
102 ))
103 __record.ExceptionInformation[0] = EH_PURE_MAGIC_NUMBER1;
104}
105
106void __copy_exception_record(_EXCEPTION_RECORD& __dest, const _EXCEPTION_RECORD& __src) noexcept {
107 __dest.ExceptionCode = __src.ExceptionCode;
108 // We force EXCEPTION_NONCONTINUABLE because rethrow_exception is [[noreturn]].
109 __dest.ExceptionFlags = __src.ExceptionFlags | EXCEPTION_NONCONTINUABLE;
110 __dest.ExceptionRecord = nullptr; // We don't chain SEH exceptions.
111 __dest.ExceptionAddress = nullptr; // Useless field to copy. It will be overwritten by RaiseException().
112 const auto __parameters = __src.NumberParameters;
113 __dest.NumberParameters = __parameters;
114
115 // Copy the number of parameters in use.
116 constexpr auto __max_parameters = static_cast<DWORD>(EXCEPTION_MAXIMUM_PARAMETERS);
117 const auto __in_use = (__parameters < __max_parameters) ? __parameters : __max_parameters;
118 std::memcpy(__dest.ExceptionInformation, __src.ExceptionInformation, __in_use * sizeof(ULONG_PTR));
119 std::memset(&__dest.ExceptionInformation[__in_use], 0, (__max_parameters - __in_use) * sizeof(ULONG_PTR));
120}
121
122void __copy_exception_object(void* __dest, const void* __src, const CatchableType* const __type
123#if _EH_RELATIVE_TYPEINFO
124 ,
125 uintptr_t __throw_image_base
126#endif // _EH_RELATIVE_TYPEINFO
127) {
128 // Copy an object of type denoted by *_PType from __src to __dDest; throws whatever the copy ctor of the type denoted
129 // by *_PType throws.
130 if ((__type->properties & CT_IsSimpleType) || __type->copyFunction == 0) {
131 std::memcpy(__dest, __src, __type->sizeOrOffset);
132
133 if (__type->properties & CT_IsWinRTHandle) {
134 const auto __unknown = *static_cast<IUnknown* const*>(const_cast<void*>(__src));
135 if (__unknown)
136 __unknown->AddRef();
137 }
138 return;
139 }
140
141#if _EH_RELATIVE_TYPEINFO
142 const auto __copy_func = reinterpret_cast<void*>(__throw_image_base + __type->copyFunction);
143#else // _EH_RELATIVE_TYPEINFO
144 const auto __copy_func = reinterpret_cast<void*>(__type->copyFunction);
145#endif // _EH_RELATIVE_TYPEINFO
146
147 const auto __adjusted = __AdjustPointer(const_cast<void*>(__src), __type->thisDisplacement);
148 if (__type->properties & CT_HasVirtualBase)
149 __call_member_function_2(__dest, __copy_func, __adjusted, 1);
150 else
151 __call_member_function_1(__dest, __copy_func, __adjusted);
152}
153
154struct __exception_ptr_storage : public std::__shared_count {
155 _EXCEPTION_RECORD __record_;
156 explicit __exception_ptr_storage(long __refs = 0) noexcept : std::__shared_count(__refs) {}
157};
158
159template <class _StaticEx>
160struct __exception_ptr_static final : public __exception_ptr_storage {
161 _StaticEx __ex_;
162
163 __exception_ptr_static() noexcept : __exception_ptr_storage(0) {
164 __populate_cpp_exception_record(__record_, &__ex_, static_cast<ThrowInfo*>(__GetExceptionInfo(__ex_)));
165 }
166
167 void __on_zero_shared() noexcept override {}
168
169 static __exception_ptr_storage* __get() noexcept {
170 struct __container {
171 union {
172 __exception_ptr_static __instance_;
173 };
174 __container() noexcept : __instance_() {}
175 ~__container() {}
176 };
177 static __container __storage;
178 return &__storage.__instance_;
179 }
180};
181
182struct alignas(__STDCPP_DEFAULT_NEW_ALIGNMENT__) __exception_ptr_normal final : public __exception_ptr_storage {
183 explicit __exception_ptr_normal(const _EXCEPTION_RECORD& __record) noexcept : __exception_ptr_storage(0) {
184 __copy_exception_record(__record_, __record);
185 }
186
187 void __on_zero_shared() noexcept override {
188 const auto& __cpp_eh_record = reinterpret_cast<EHExceptionRecord&>(__record_);
189 if (PER_IS_MSVC_PURE_OR_NATIVE_EH(&__cpp_eh_record)) {
190 const auto* __throw_info = __cpp_eh_record.params.pThrowInfo;
191 if (__throw_info && __cpp_eh_record.params.pExceptionObject) {
192#if _EH_RELATIVE_TYPEINFO
193 const auto __throw_image_base = reinterpret_cast<uintptr_t>(__cpp_eh_record.params.pThrowImageBase);
194 const auto* __catchable_type_array = reinterpret_cast<const CatchableTypeArray*>(
195 static_cast<uintptr_t>(__throw_info->pCatchableTypeArray) + __throw_image_base);
196 const auto* __type = reinterpret_cast<CatchableType*>(
197 static_cast<uintptr_t>(__catchable_type_array->arrayOfCatchableTypes[0]) + __throw_image_base);
198#else // _EH_RELATIVE_TYPEINFO
199 const auto* __type = __throw_info->pCatchableTypeArray->arrayOfCatchableTypes[0];
200#endif // _EH_RELATIVE_TYPEINFO
201 if (__throw_info->pmfnUnwind) {
202 // The exception was a user defined type with a nontrivial destructor, call it.
203#if _EH_RELATIVE_TYPEINFO
204 __call_member_function_0(__cpp_eh_record.params.pExceptionObject,
205 reinterpret_cast<void*>(__throw_info->pmfnUnwind + __throw_image_base));
206#else // _EH_RELATIVE_TYPEINFO
207 __call_member_function_0(__cpp_eh_record.params.pExceptionObject,
208 reinterpret_cast<void*>(__throw_info->pmfnUnwind));
209#endif // _EH_RELATIVE_TYPEINFO
210 } else if (__type->properties & CT_IsWinRTHandle) {
211 const auto* __unknown = *static_cast<IUnknown* const*>(__cpp_eh_record.params.pExceptionObject);
212 if (__unknown)
213 const_cast<IUnknown*>(__unknown)->Release();
214 }
215 }
216 }
217 std::free(this);
218 }
219};
220
221static_assert(sizeof(__exception_ptr_normal) % __STDCPP_DEFAULT_NEW_ALIGNMENT__ == 0,
222 "Exception in exception_ptr would be constructed with the wrong alignment");
43223
44exception_ptr::operator bool() const noexcept { return __ExceptionPtrToBool(this); }
224void __assign_seh_exception_ptr_from_record(
225 void*& __dest, const _EXCEPTION_RECORD& __record, void* const __rx_raw) noexcept {
226 if (!__rx_raw) {
227 __dest = __exception_ptr_static<std::bad_alloc>::__get();
228 return;
229 }
45230
46bool operator==(const exception_ptr& __x, const exception_ptr& __y) noexcept {
47 return __ExceptionPtrCompare(&__x, &__y);
231 __dest = ::new (__rx_raw) __exception_ptr_normal(__record);
48232}
49233
50void swap(exception_ptr& lhs, exception_ptr& rhs) noexcept { __ExceptionPtrSwap(&rhs, &lhs); }
234void __assign_cpp_exception_ptr_from_record(void*& __dest, const EHExceptionRecord& __record) noexcept {
235 // Construct a reference count control block for the C++ exception recorded by __record, and bind it to __dest.
236 //
237 // * If allocating memory for the reference count control block fails, sets __dest to bad_alloc.
238 // * If copying the exception object referred to __record throws, constructs a reference count control block for that
239 // exception instead.
240 // * If copying the exception object thrown by copying the original exception object throws, sets __dest to
241 // bad_exception.
242 const auto* __throw_info = __record.params.pThrowInfo;
243#if _EH_RELATIVE_TYPEINFO
244 const auto __throw_image_base = reinterpret_cast<uintptr_t>(__record.params.pThrowImageBase);
245 const auto* __catchable_type_array = reinterpret_cast<const CatchableTypeArray*>(
246 static_cast<uintptr_t>(__throw_info->pCatchableTypeArray) + __throw_image_base);
247 const auto* __type = reinterpret_cast<CatchableType*>(
248 static_cast<uintptr_t>(__catchable_type_array->arrayOfCatchableTypes[0]) + __throw_image_base);
249#else // _EH_RELATIVE_TYPEINFO
250 const auto* __type = __throw_info->pCatchableTypeArray->arrayOfCatchableTypes[0];
251#endif // _EH_RELATIVE_TYPEINFO
252
253 const auto __except_obj_size = static_cast<size_t>(__type->sizeOrOffset);
254 const auto __alloc_size = sizeof(__exception_ptr_normal) + __except_obj_size;
255 auto* __rx_raw = std::malloc(__alloc_size);
256 if (!__rx_raw) {
257 __dest = __exception_ptr_static<std::bad_alloc>::__get();
258 return;
259 }
260
261 try {
262 __copy_exception_object(static_cast<__exception_ptr_normal*>(__rx_raw) + 1,
263 __record.params.pExceptionObject,
264 __type
265#if _EH_RELATIVE_TYPEINFO
266 ,
267 __throw_image_base
268#endif // _EH_RELATIVE_TYPEINFO
269 );
270
271 const auto* __rx = ::new (__rx_raw) __exception_ptr_normal(reinterpret_cast<const _EXCEPTION_RECORD&>(__record));
272 reinterpret_cast<EHExceptionRecord&>(const_cast<__exception_ptr_normal*>(__rx)->__record_).params.pExceptionObject =
273 static_cast<__exception_ptr_normal*>(__rx_raw) + 1;
274 __dest = const_cast<__exception_ptr_normal*>(__rx);
275 } catch (...) { // Copying the exception object threw an exception.
276 // Exception thrown by the original exception's copy ctor.
277 const auto* __inner_record_ptr = __get_current_exception();
278 if (!__inner_record_ptr) {
279 std::free(__rx_raw);
280 __dest = __exception_ptr_static<std::bad_exception>::__get();
281 return;
282 }
283 const auto& __inner_record = *__inner_record_ptr;
284 if (__inner_record.ExceptionCode == MANAGED_EXCEPTION_CODE ||
285 __inner_record.ExceptionCode == MANAGED_EXCEPTION_CODE_V4) {
286 // We don't support managed exceptions and don't want to say there's no active exception, so give up and say
287 // bad_exception.
288 std::free(__rx_raw);
289 __dest = __exception_ptr_static<std::bad_exception>::__get();
290 return;
291 }
292
293 if (!PER_IS_MSVC_PURE_OR_NATIVE_EH(&__inner_record)) { // Catching a non-C++ exception depends on /EHa.
294 __assign_seh_exception_ptr_from_record(
295 __dest, reinterpret_cast<const _EXCEPTION_RECORD&>(__inner_record), __rx_raw);
296 return;
297 }
298
299 const auto* __inner_throw = __inner_record.params.pThrowInfo;
300#if _EH_RELATIVE_TYPEINFO
301 const auto __inner_throw_image_base = reinterpret_cast<uintptr_t>(__inner_record.params.pThrowImageBase);
302 const auto* __inner_catchable_type_array = reinterpret_cast<const CatchableTypeArray*>(
303 static_cast<uintptr_t>(__inner_throw->pCatchableTypeArray) + __inner_throw_image_base);
304 const auto* __inner_type = reinterpret_cast<CatchableType*>(
305 static_cast<uintptr_t>(__inner_catchable_type_array->arrayOfCatchableTypes[0]) + __inner_throw_image_base);
306#else // _EH_RELATIVE_TYPEINFO
307 const auto* __inner_type = __inner_throw->pCatchableTypeArray->arrayOfCatchableTypes[0];
308#endif // _EH_RELATIVE_TYPEINFO
309
310 const auto __inner_except_size = static_cast<size_t>(__inner_type->sizeOrOffset);
311 const auto __inner_alloc_size = sizeof(__exception_ptr_normal) + __inner_except_size;
312 if (__inner_alloc_size > __alloc_size) {
313 std::free(__rx_raw);
314 __rx_raw = std::malloc(__inner_alloc_size);
315 if (!__rx_raw) {
316 __dest = __exception_ptr_static<std::bad_alloc>::__get();
317 return;
318 }
319 }
320
321 try {
322 __copy_exception_object(static_cast<__exception_ptr_normal*>(__rx_raw) + 1,
323 __inner_record.params.pExceptionObject,
324 __inner_type
325#if _EH_RELATIVE_TYPEINFO
326 ,
327 __inner_throw_image_base
328#endif // _EH_RELATIVE_TYPEINFO
329 );
330 } catch (...) { // Copying the exception emitted while copying the original exception also threw, give up.
331 std::free(__rx_raw);
332 __dest = __exception_ptr_static<std::bad_exception>::__get();
333 return;
334 }
335
336 // This next block must be duplicated inside the catch (even though it looks identical to the block in the try) so
337 // that __inner_record is held alive; exiting the catch will destroy it.
338 const auto* __rx =
339 ::new (__rx_raw) __exception_ptr_normal(reinterpret_cast<const _EXCEPTION_RECORD&>(__inner_record));
340 reinterpret_cast<EHExceptionRecord&>(const_cast<__exception_ptr_normal*>(__rx)->__record_).params.pExceptionObject =
341 static_cast<__exception_ptr_normal*>(__rx_raw) + 1;
342 __dest = const_cast<__exception_ptr_normal*>(__rx);
343 }
344}
345
346} // namespace
347
348namespace std {
349
350exception_ptr::~exception_ptr() noexcept {
351 if (__ptr_)
352 static_cast<__shared_count*>(__ptr_)->__release_shared();
353}
354
355exception_ptr::exception_ptr(const exception_ptr& __other) noexcept : __ptr_(__other.__ptr_) {
356 if (__ptr_)
357 static_cast<__shared_count*>(__ptr_)->__add_shared();
358}
359
360exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept {
361 if (__ptr_ != __other.__ptr_) {
362 if (__other.__ptr_)
363 static_cast<__shared_count*>(__other.__ptr_)->__add_shared();
364 if (__ptr_)
365 static_cast<__shared_count*>(__ptr_)->__release_shared();
366 __ptr_ = __other.__ptr_;
367 }
368 return *this;
369}
370
371exception_ptr exception_ptr::__from_native_exception_pointer(void* __p) noexcept {
372 exception_ptr __ret;
373 __ret.__ptr_ = __p;
374 if (__ret.__ptr_)
375 static_cast<__shared_count*>(__ret.__ptr_)->__add_shared();
376 return __ret;
377}
51378
52379exception_ptr __copy_exception_ptr(void* __except, const void* __ptr) {
53380 exception_ptr __ret = nullptr;
54 if (__ptr)
55 __ExceptionPtrCopyException(&__ret, __except, __ptr);
381 if (!__ptr)
382 return __ret;
383
384 _EXCEPTION_RECORD __record;
385 __populate_cpp_exception_record(__record, __except, static_cast<ThrowInfo*>(const_cast<void*>(__ptr)));
386 __assign_cpp_exception_ptr_from_record(__ret.__ptr_, reinterpret_cast<const EHExceptionRecord&>(__record));
56387 return __ret;
57388}
58389
59390exception_ptr current_exception() noexcept {
60391 exception_ptr __ret;
61 __ExceptionPtrCurrentException(&__ret);
392 const auto* __record = __get_current_exception();
393 if (!__record || __record->ExceptionCode == MANAGED_EXCEPTION_CODE ||
394 __record->ExceptionCode == MANAGED_EXCEPTION_CODE_V4)
395 return __ret;
396
397 if (PER_IS_MSVC_PURE_OR_NATIVE_EH(__record))
398 __assign_cpp_exception_ptr_from_record(__ret.__ptr_, *__record);
399 else
400 __assign_seh_exception_ptr_from_record(
401 __ret.__ptr_, reinterpret_cast<const _EXCEPTION_RECORD&>(*__record), std::malloc(sizeof(__exception_ptr_normal)));
62402 return __ret;
63403}
64404
65[[noreturn]] void rethrow_exception(exception_ptr p) { __ExceptionPtrRethrow(&p); }
405[[noreturn]] void rethrow_exception(exception_ptr __p) {
406 if (!__p)
407 throw bad_exception();
408
409 auto* __rep = static_cast<__exception_ptr_storage*>(__p.__ptr_);
410 auto __record_copy = __rep->__record_;
411 auto& __cpp_record = reinterpret_cast<EHExceptionRecord&>(__record_copy);
412 if (PER_IS_MSVC_PURE_OR_NATIVE_EH(&__cpp_record)) {
413 const auto* __throw_info = __cpp_record.params.pThrowInfo;
414 if (!__cpp_record.params.pExceptionObject || !__throw_info || !__throw_info->pCatchableTypeArray)
415 terminate();
416
417#if _EH_RELATIVE_TYPEINFO
418 const auto __throw_image_base = reinterpret_cast<uintptr_t>(__cpp_record.params.pThrowImageBase);
419 const auto* __catchable_type_array =
420 reinterpret_cast<const CatchableTypeArray*>(__throw_image_base + __throw_info->pCatchableTypeArray);
421#else // _EH_RELATIVE_TYPEINFO
422 const auto* __catchable_type_array = __throw_info->pCatchableTypeArray;
423#endif // _EH_RELATIVE_TYPEINFO
424
425 if (__catchable_type_array->nCatchableTypes <= 0)
426 terminate();
427
428#if _EH_RELATIVE_TYPEINFO
429 const auto* __type = reinterpret_cast<CatchableType*>(
430 static_cast<uintptr_t>(__catchable_type_array->arrayOfCatchableTypes[0]) + __throw_image_base);
431#else // _EH_RELATIVE_TYPEINFO
432 const auto* __type = __throw_info->pCatchableTypeArray->arrayOfCatchableTypes[0];
433#endif // _EH_RELATIVE_TYPEINFO
434
435#pragma warning(suppress : 6255)
436 void* __exception_buffer = alloca(__type->sizeOrOffset);
437 __copy_exception_object(__exception_buffer, __cpp_record.params.pExceptionObject, __type
438#if _EH_RELATIVE_TYPEINFO
439 ,
440 __throw_image_base
441#endif // _EH_RELATIVE_TYPEINFO
442 );
443
444 __cpp_record.params.pExceptionObject = __exception_buffer;
445 }
446
447 // Under MSVC C++ exception handling (/EHsc), C Win32 API functions like RaiseException
448 // are assumed not to throw synchronous C++ exceptions. As a result, stack unwinding
449 // initiated by RaiseException does not execute local destructors in this frame.
450 // We must explicitly reset __p here so that the reference count on the stored
451 // exception record is properly decremented before unwinding begins.
452 __p = nullptr;
453 RaiseException(__record_copy.ExceptionCode, __record_copy.ExceptionFlags, __record_copy.NumberParameters,
454 __record_copy.ExceptionInformation);
455 terminate();
456}
66457
67458nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
68459
lib/libcxx/src/support/win32/locale_win32.cpp+262
......@@ -7,6 +7,8 @@
77//===----------------------------------------------------------------------===//
88
99#include <__locale_dir/support/windows.h>
10#include <cctype>
11#include <charconv>
1012#include <clocale> // std::localeconv() & friends
1113#include <cstdarg> // va_start & friends
1214#include <cstddef>
......@@ -14,8 +16,11 @@
1416#include <cstdlib> // std::strtof & friends
1517#include <ctime> // std::strftime
1618#include <cwchar> // wide char manipulation
19#include <string_view>
20#include <windows.h>
1721
1822_LIBCPP_BEGIN_NAMESPACE_STD
23_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1924namespace __locale {
2025
2126//
......@@ -34,6 +39,262 @@ __lconv_t* __localeconv(__locale_t& loc) {
3439 return loc.__store_lconv(lc);
3540}
3641
42namespace {
43const char* __codepage_name(unsigned int __codepage) {
44 switch (__codepage) {
45 case 0:
46 // If no ANSI code page is available, only Unicode can be used for the locale.
47 // In this case, the value is CP_ACP (0).
48 // Such a locale cannot be set as the system locale.
49 // Applications that do not support Unicode do not work correctly with locales
50 // marked as "Unicode only".
51 return nullptr;
52 case 037:
53 return "IBM037";
54 case 437:
55 return "IBM437";
56 case 500:
57 return "IBM500";
58 case 708:
59 return "ASMO-708";
60 case 709:
61 return "ASMO_449";
62 case 775:
63 return "IBM775";
64 case 850:
65 return "IBM850";
66 case 852:
67 return "IBM852";
68 case 855:
69 return "IBM855";
70 case 857:
71 return "IBM857";
72 case 858:
73 return "IBM00858";
74 case 860:
75 return "IBM860";
76 case 861:
77 return "IBM861";
78 case 862:
79 return "IBM862";
80 case 863:
81 return "IBM863";
82 case 864:
83 return "IBM864";
84 case 865:
85 return "IBM865";
86 case 866:
87 return "IBM866";
88 case 869:
89 return "IBM869";
90 case 870:
91 return "IBM870";
92 case 874:
93 return "windows-874";
94 case 932:
95 return "Shift_JIS";
96 case 936:
97 return "GB2312";
98 case 949:
99 return "KS_C_5601-1989";
100 case 950:
101 return "Big5";
102 case 1026:
103 return "IBM1026";
104 case 1047:
105 return "IBM1047";
106 case 1140:
107 return "IBM01140";
108 case 1141:
109 return "IBM01141";
110 case 1142:
111 return "IBM01142";
112 case 1143:
113 return "IBM01143";
114 case 1144:
115 return "IBM01144";
116 case 1145:
117 return "IBM01145";
118 case 1146:
119 return "IBM01146";
120 case 1147:
121 return "IBM01147";
122 case 1148:
123 return "IBM01148";
124 case 1149:
125 return "IBM01149";
126 case 1200:
127 return "UTF-16LE";
128 case 1201:
129 return "UTF-16BE";
130 case 1250:
131 return "windows-1250";
132 case 1251:
133 return "windows-1251";
134 case 1252:
135 return "windows-1252";
136 case 1253:
137 return "windows-1253";
138 case 1254:
139 return "windows-1254";
140 case 1255:
141 return "windows-1255";
142 case 1256:
143 return "windows-1256";
144 case 1257:
145 return "windows-1257";
146 case 1258:
147 return "windows-1258";
148 case 10000:
149 return "macintosh";
150 case 12000:
151 return "UTF-32LE";
152 case 12001:
153 return "UTF-32BE";
154 case 20127:
155 return "US-ASCII";
156 case 20273:
157 return "IBM273";
158 case 20277:
159 return "IBM277";
160 case 20278:
161 return "IBM278";
162 case 20280:
163 return "IBM280";
164 case 20284:
165 return "IBM284";
166 case 20285:
167 return "IBM285";
168 case 20290:
169 return "IBM290";
170 case 20297:
171 return "IBM297";
172 case 20420:
173 return "IBM420";
174 case 20423:
175 return "IBM423";
176 case 20424:
177 return "IBM424";
178 case 20838:
179 return "IBM-Thai";
180 case 20866:
181 return "KOI8-R";
182 case 20871:
183 return "IBM871";
184 case 20880:
185 return "IBM880";
186 case 20905:
187 return "IBM905";
188 case 20924:
189 return "IBM00924";
190 case 20932:
191 return "EUC-JP";
192 case 21866:
193 return "KOI8-U";
194 case 28591:
195 return "ISO-8859-1";
196 case 28592:
197 return "ISO-8859-2";
198 case 28593:
199 return "ISO-8859-3";
200 case 28594:
201 return "ISO-8859-4";
202 case 28595:
203 return "ISO-8859-9";
204 case 28596:
205 return "ISO-8859-10";
206 case 28597:
207 return "ISO-8859-7";
208 case 28598:
209 return "ISO-8859-8";
210 case 28599:
211 return "ISO-8859-9-Windows-Latin-5";
212 case 28603:
213 return "ISO-8859-13";
214 case 28605:
215 return "ISO-8859-15";
216 case 38598:
217 return "ISO-8859-8-I";
218 case 50220:
219 case 50221:
220 case 50222:
221 return "ISO-2022-JP";
222 case 51932:
223 return "EUC-JP";
224 case 51936:
225 return "GB2312";
226 case 51949:
227 return "EUC-KR";
228 case 52936:
229 return "HZ-GB-2312";
230 case 54936:
231 return "GB18030";
232 case 65000:
233 return "UTF-7";
234 case 65001:
235 return "UTF-8";
236 default:
237 return nullptr;
238 }
239}
240} // namespace
241
242const char* __get_locale_encoding(__locale_t loc) {
243 const char* locale_name = loc.__get_locale();
244 if (locale_name == nullptr) {
245 return __codepage_name(::GetACP());
246 }
247
248 std::string_view __sv(locale_name);
249
250 // locale :: "locale-name"
251 // | "language"[_country-region[.code-page]]
252 // | ".code-page"
253 // GetLocaleInfoEx doesn't accept anything other than BCP-47 locale names, e.g. "en_US",
254 // so do a best-attempt to derive the text encoding from the name.
255 if (__sv == "C" || __sv == "") {
256 // "A locale argument value of C specifies the minimal ANSI conforming environment for C translation."
257 // TODO: Figure out what to do for an empty string:
258 // "If locale points to an empty string, the locale is the implementation-defined native environment."
259 return __codepage_name(::GetACP());
260 } else if (auto dot = __sv.find('.'); dot != std::string_view::npos) {
261 std::string_view __code_page(locale_name + dot + 1);
262
263 // Windows allows the codepage number as part of the name,
264 // e.g. "en_US.1252" for English US, Windows-1252.
265 if (std::isdigit(__code_page[0])) {
266 unsigned int __cpage{};
267 auto __res = std::from_chars(__code_page.data(), __code_page.data() + __code_page.size(), __cpage);
268 if (__res) {
269 return __codepage_name(__cpage);
270 }
271 } else { // POSIX-style name
272 return locale_name + dot + 1;
273 }
274 }
275
276 wchar_t locale_wbuffer[LOCALE_NAME_MAX_LENGTH + 1]{};
277 wchar_t number_buffer[11]{};
278
279 bool is_ansi = ::AreFileApisANSI();
280 auto codepage = is_ansi ? CP_ACP : CP_OEMCP;
281 int ret = ::MultiByteToWideChar(
282 codepage, MB_ERR_INVALID_CHARS, locale_name, __sv.size(), locale_wbuffer, LOCALE_NAME_MAX_LENGTH);
283
284 if (ret <= 0)
285 return nullptr;
286
287 // The below function fills the string with the number in text.
288 auto lctype = is_ansi ? LOCALE_IDEFAULTANSICODEPAGE : LOCALE_IDEFAULTCODEPAGE;
289 int result = ::GetLocaleInfoEx(locale_wbuffer, lctype, number_buffer, 10);
290
291 if (result <= 0)
292 return nullptr;
293
294 unsigned int acp = std::wcstoul(number_buffer, nullptr, 10);
295 return __codepage_name(acp);
296}
297
37298//
38299// Strtonum functions
39300//
......@@ -182,4 +443,5 @@ int __asprintf(char** ret, __locale_t loc, const char* format, ...) {
182443}
183444
184445} // namespace __locale
446_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
185447_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/support/win32/thread_win32.cpp+2
......@@ -16,6 +16,7 @@
1616#include <fibersapi.h>
1717
1818_LIBCPP_BEGIN_NAMESPACE_STD
19_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1920
2021static_assert(sizeof(__libcpp_mutex_t) == sizeof(SRWLOCK), "");
2122static_assert(alignof(__libcpp_mutex_t) == alignof(SRWLOCK), "");
......@@ -211,4 +212,5 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) {
211212 return 0;
212213}
213214
215_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
214216_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/system_error.cpp+2
......@@ -27,6 +27,7 @@
2727#endif
2828
2929_LIBCPP_BEGIN_NAMESPACE_STD
30_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3031
3132#if defined(_LIBCPP_WIN32API)
3233
......@@ -368,4 +369,5 @@ void __throw_system_error(int ev, const char* what_arg) {
368369#endif
369370}
370371
372_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
371373_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/text_encoding.cpp created+54
......@@ -0,0 +1,54 @@
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 <__locale_dir/locale_base_api.h>
11#include <__utility/scope_guard.h>
12#include <text_encoding>
13
14_LIBCPP_BEGIN_NAMESPACE_STD
15_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
16
17#if defined(__ANDROID__)
18// UTF-8 is the always the environment encoding on Android.
19std::text_encoding __get_locale_encoding([[maybe_unused]] const char* __name) { return std::text_encoding::id::UTF8; }
20#else
21static text_encoding __make_text_encoding(const char* __name) {
22 if (__name == nullptr)
23 return text_encoding{};
24
25 string_view __name_view(__name);
26 if (__name_view.size() > text_encoding::max_name_length)
27 return text_encoding{};
28
29 return text_encoding(__name_view);
30}
31
32std::text_encoding __get_locale_encoding(const char* __name) {
33 if (__name == nullptr)
34 return __make_text_encoding(__locale::__get_locale_encoding(static_cast<__locale::__locale_t>(0)));
35
36 __locale::__locale_t __l = __locale::__newlocale(_LIBCPP_CTYPE_MASK, __name, static_cast<__locale::__locale_t>(0));
37
38 __scope_guard __locale_guard([&__l] {
39 if (__l) {
40 __locale::__freelocale(__l);
41 }
42 });
43
44 if (!__l) {
45 return text_encoding{};
46 }
47
48 return __make_text_encoding(__locale::__get_locale_encoding(__l));
49}
50
51#endif // __ANDROID__
52
53_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
54_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/thread.cpp+2
......@@ -33,6 +33,7 @@
3333#endif
3434
3535_LIBCPP_BEGIN_NAMESPACE_STD
36_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
3637
3738thread::~thread() {
3839 if (!__libcpp_thread_isnull(&__t_))
......@@ -170,4 +171,5 @@ void __thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m
170171
171172void __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s) { __p_->__make_ready_at_thread_exit(__s); }
172173
174_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
173175_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/valarray.cpp+2
......@@ -9,6 +9,7 @@
99#include <valarray>
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
12_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1213
1314#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 9
1415template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::valarray(size_t);
......@@ -45,4 +46,5 @@ void gslice::__init(size_t __start) {
4546 }
4647}
4748
49_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
4850_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/variant.cpp+2
......@@ -12,4 +12,6 @@ namespace std {
1212
1313const char* bad_variant_access::what() const noexcept { return "bad_variant_access"; }
1414
15const char* __bad_variant_access_with_msg::what() const noexcept { return __msg_; }
16
1517} // namespace std
lib/libcxx/src/vector.cpp+2
......@@ -9,6 +9,7 @@
99#include <vector>
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
12_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
1213
1314#if _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15
1415
......@@ -27,4 +28,5 @@ void __vector_base_common<true>::__throw_out_of_range() const { std::__throw_out
2728
2829#endif // _LIBCPP_AVAILABILITY_MINIMUM_HEADER_VERSION < 15
2930
31_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
3032_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/verbose_abort.cpp+3-1
......@@ -22,8 +22,9 @@ extern "C" void android_set_abort_message(const char* msg);
2222#endif
2323
2424_LIBCPP_BEGIN_NAMESPACE_STD
25_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
2526
26_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
27[[gnu::weak]] void __libcpp_verbose_abort(char const* format, ...) noexcept {
2728 // Write message to stderr. We do this before formatting into a
2829 // buffer so that we still get some information out if that fails.
2930 {
......@@ -62,4 +63,5 @@ _LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) noexcept {
6263 std::abort();
6364}
6465
66_LIBCPP_END_EXPLICIT_ABI_ANNOTATIONS
6567_LIBCPP_END_NAMESPACE_STD
src/libs/libcxx.zig+3-2
......@@ -82,6 +82,7 @@ const libcxx_base_files = [_][]const u8{
8282 "src/support/win32/locale_win32.cpp",
8383 "src/support/win32/support.cpp",
8484 "src/system_error.cpp",
85 "src/text_encoding.cpp",
8586 "src/typeinfo.cpp",
8687 "src/valarray.cpp",
8788 "src/variant.cpp",
......@@ -222,7 +223,7 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
222223 try cflags.append("-faligned-allocation");
223224
224225 try cflags.append("-nostdinc++");
225 try cflags.append("-std=c++23");
226 try cflags.append("-std=c++26");
226227
227228 // These depend on only the zig lib directory file path, which is
228229 // purposefully either in the cache or not in the cache. The decision
......@@ -417,7 +418,7 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
417418
418419 try cflags.append("-nostdinc++");
419420 try cflags.append("-fstrict-aliasing");
420 try cflags.append("-std=c++23");
421 try cflags.append("-std=c++26");
421422
422423 // These depend on only the zig lib directory file path, which is
423424 // purposefully either in the cache or not in the cache. The decision