authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-23 02:59:46+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-09-19 18:20:21-07:00
log1c8f0b8909f342201f84def1efb8c6fb4386cc2c
treeb58a1488ff85440a65565474627add3fdc66b32e
parentd13bc04cb4c4c2f0806b9d9c676cb013ea888828

libcxx: Update to LLVM 19.

* Moved the tz.cpp patch to experimental/tzdb.cpp. * Extended the __config_site patch to a few more files.

677 files changed, 21356 insertions(+), 16160 deletions(-)

lib/libcxx/include/__algorithm/adjacent_find.h+3-3
......@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
2828template <class _Iter, class _Sent, class _BinaryPredicate>
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
29_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
3030__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
3131 if (__first == __last)
3232 return __first;
......@@ -40,13 +40,13 @@ __adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
4040}
4141
4242template <class _ForwardIterator, class _BinaryPredicate>
43_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
43_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4444adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
4545 return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
4646}
4747
4848template <class _ForwardIterator>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5050adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
5151 return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
5252}
lib/libcxx/include/__algorithm/all_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (!__pred(*__first))
lib/libcxx/include/__algorithm/any_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/binary_search.h+2-2
......@@ -22,14 +22,14 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _ForwardIterator, class _Tp, class _Compare>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2626binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
2727 __first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
2828 return __first != __last && !__comp(__value, *__first);
2929}
3030
3131template <class _ForwardIterator, class _Tp>
32_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3333binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
3434 return std::binary_search(__first, __last, __value, __less<>());
3535}
lib/libcxx/include/__algorithm/clamp.h+2-2
......@@ -21,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121
2222#if _LIBCPP_STD_VER >= 17
2323template <class _Tp, class _Compare>
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
24[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
2525clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
2626 _LIBCPP_LIFETIMEBOUND const _Tp& __lo,
2727 _LIBCPP_LIFETIMEBOUND const _Tp& __hi,
......@@ -31,7 +31,7 @@ clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
3131}
3232
3333template <class _Tp>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
34[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
3535clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
3636 _LIBCPP_LIFETIMEBOUND const _Tp& __lo,
3737 _LIBCPP_LIFETIMEBOUND const _Tp& __hi) {
lib/libcxx/include/__algorithm/comp.h+5-3
......@@ -10,8 +10,7 @@
1010#define _LIBCPP___ALGORITHM_COMP_H
1111
1212#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/operation_traits.h>
13#include <__type_traits/desugars_to.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
......@@ -27,7 +26,7 @@ struct __equal_to {
2726};
2827
2928template <class _Tp, class _Up>
30struct __desugars_to<__equal_tag, __equal_to, _Tp, _Up> : true_type {};
29inline const bool __desugars_to_v<__equal_tag, __equal_to, _Tp, _Up> = true;
3130
3231// The definition is required because __less is part of the ABI, but it's empty
3332// because all comparisons should be transparent.
......@@ -42,6 +41,9 @@ struct __less<void, void> {
4241 }
4342};
4443
44template <class _Tp>
45inline const bool __desugars_to_v<__less_tag, __less<>, _Tp, _Tp> = true;
46
4547_LIBCPP_END_NAMESPACE_STD
4648
4749#endif // _LIBCPP___ALGORITHM_COMP_H
lib/libcxx/include/__algorithm/comp_ref_type.h+3-3
......@@ -41,9 +41,9 @@ struct __debug_less {
4141 }
4242
4343 template <class _LHS, class _RHS>
44 _LIBCPP_CONSTEXPR_SINCE_CXX14 inline _LIBCPP_HIDE_FROM_ABI decltype((void)std::declval<_Compare&>()(
45 std::declval<_LHS&>(), std::declval<_RHS&>()))
46 __do_compare_assert(int, _LHS& __l, _RHS& __r) {
44 _LIBCPP_CONSTEXPR_SINCE_CXX14 inline
45 _LIBCPP_HIDE_FROM_ABI decltype((void)std::declval<_Compare&>()(std::declval<_LHS&>(), std::declval<_RHS&>()))
46 __do_compare_assert(int, _LHS& __l, _RHS& __r) {
4747 _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(!__comp_(__l, __r), "Comparator does not induce a strict weak ordering");
4848 (void)__l;
4949 (void)__r;
lib/libcxx/include/__algorithm/copy.h+2-4
......@@ -32,7 +32,7 @@ template <class, class _InIter, class _Sent, class _OutIter>
3232inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter);
3333
3434template <class _AlgPolicy>
35struct __copy_loop {
35struct __copy_impl {
3636 template <class _InIter, class _Sent, class _OutIter>
3737 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
3838 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
......@@ -94,9 +94,7 @@ struct __copy_loop {
9494 __local_first = _Traits::__begin(++__segment_iterator);
9595 }
9696 }
97};
9897
99struct __copy_trivial {
10098 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
10199 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
102100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
......@@ -108,7 +106,7 @@ struct __copy_trivial {
108106template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
109107pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
110108__copy(_InIter __first, _Sent __last, _OutIter __result) {
111 return std::__dispatch_copy_or_move<_AlgPolicy, __copy_loop<_AlgPolicy>, __copy_trivial>(
109 return std::__copy_move_unwrap_iters<__copy_impl<_AlgPolicy> >(
112110 std::move(__first), std::move(__last), std::move(__result));
113111}
114112
lib/libcxx/include/__algorithm/copy_backward.h+3-5
......@@ -15,7 +15,7 @@
1515#include <__config>
1616#include <__iterator/segmented_iterator.h>
1717#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
18#include <__type_traits/is_constructible.h>
1919#include <__utility/move.h>
2020#include <__utility/pair.h>
2121
......@@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter>
3333__copy_backward(_InIter __first, _Sent __last, _OutIter __result);
3434
3535template <class _AlgPolicy>
36struct __copy_backward_loop {
36struct __copy_backward_impl {
3737 template <class _InIter, class _Sent, class _OutIter>
3838 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
3939 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
......@@ -104,9 +104,7 @@ struct __copy_backward_loop {
104104 __local_last = _Traits::__end(__segment_iterator);
105105 }
106106 }
107};
108107
109struct __copy_backward_trivial {
110108 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111109 template <class _In, class _Out, __enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0>
112110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
......@@ -118,7 +116,7 @@ struct __copy_backward_trivial {
118116template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2>
119117_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2>
120118__copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) {
121 return std::__dispatch_copy_or_move<_AlgPolicy, __copy_backward_loop<_AlgPolicy>, __copy_backward_trivial>(
119 return std::__copy_move_unwrap_iters<__copy_backward_impl<_AlgPolicy> >(
122120 std::move(__first), std::move(__last), std::move(__result));
123121}
124122
lib/libcxx/include/__algorithm/copy_move_common.h+8-34
......@@ -19,9 +19,8 @@
1919#include <__type_traits/enable_if.h>
2020#include <__type_traits/is_always_bitcastable.h>
2121#include <__type_traits/is_constant_evaluated.h>
22#include <__type_traits/is_copy_constructible.h>
22#include <__type_traits/is_constructible.h>
2323#include <__type_traits/is_trivially_assignable.h>
24#include <__type_traits/is_trivially_copyable.h>
2524#include <__type_traits/is_volatile.h>
2625#include <__utility/move.h>
2726#include <__utility/pair.h>
......@@ -81,30 +80,17 @@ __copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) {
8180
8281// Iterator unwrapping and dispatching to the correct overload.
8382
84template <class _F1, class _F2>
85struct __overload : _F1, _F2 {
86 using _F1::operator();
87 using _F2::operator();
88};
89
90template <class _InIter, class _Sent, class _OutIter, class = void>
91struct __can_rewrap : false_type {};
92
93template <class _InIter, class _Sent, class _OutIter>
94struct __can_rewrap<_InIter,
95 _Sent,
96 _OutIter,
97 // Note that sentinels are always copy-constructible.
98 __enable_if_t< is_copy_constructible<_InIter>::value && is_copy_constructible<_OutIter>::value > >
99 : true_type {};
83template <class _InIter, class _OutIter>
84struct __can_rewrap
85 : integral_constant<bool, is_copy_constructible<_InIter>::value && is_copy_constructible<_OutIter>::value> {};
10086
10187template <class _Algorithm,
10288 class _InIter,
10389 class _Sent,
10490 class _OutIter,
105 __enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
91 __enable_if_t<__can_rewrap<_InIter, _OutIter>::value, int> = 0>
10692_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
107__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
93__copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) {
10894 auto __range = std::__unwrap_range(__first, std::move(__last));
10995 auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first));
11096 return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)),
......@@ -115,24 +101,12 @@ template <class _Algorithm,
115101 class _InIter,
116102 class _Sent,
117103 class _OutIter,
118 __enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0>
104 __enable_if_t<!__can_rewrap<_InIter, _OutIter>::value, int> = 0>
119105_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
120__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) {
106__copy_move_unwrap_iters(_InIter __first, _Sent __last, _OutIter __out_first) {
121107 return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first));
122108}
123109
124template <class _AlgPolicy,
125 class _NaiveAlgorithm,
126 class _OptimizedAlgorithm,
127 class _InIter,
128 class _Sent,
129 class _OutIter>
130_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter>
131__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) {
132 using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>;
133 return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first));
134}
135
136110_LIBCPP_END_NAMESPACE_STD
137111
138112_LIBCPP_POP_MACROS
lib/libcxx/include/__algorithm/count.h+1-1
......@@ -79,7 +79,7 @@ __count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __l
7979}
8080
8181template <class _InputIterator, class _Tp>
82_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
82_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __iter_diff_t<_InputIterator>
8383count(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
8484 __identity __proj;
8585 return std::__count<_ClassicAlgPolicy>(__first, __last, __value, __proj);
lib/libcxx/include/__algorithm/count_if.h+3-3
......@@ -20,9 +20,9 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222template <class _InputIterator, class _Predicate>
23_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24 typename iterator_traits<_InputIterator>::difference_type
25 count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
23_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
24typename iterator_traits<_InputIterator>::difference_type
25count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2626 typename iterator_traits<_InputIterator>::difference_type __r(0);
2727 for (; __first != __last; ++__first)
2828 if (__pred(*__first))
lib/libcxx/include/__algorithm/equal.h+21-58
......@@ -18,12 +18,11 @@
1818#include <__iterator/distance.h>
1919#include <__iterator/iterator_traits.h>
2020#include <__string/constexpr_c_functions.h>
21#include <__type_traits/desugars_to.h>
2122#include <__type_traits/enable_if.h>
22#include <__type_traits/integral_constant.h>
2323#include <__type_traits/is_constant_evaluated.h>
2424#include <__type_traits/is_equality_comparable.h>
2525#include <__type_traits/is_volatile.h>
26#include <__type_traits/operation_traits.h>
2726#include <__utility/move.h>
2827
2928#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -47,7 +46,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 boo
4746template <class _Tp,
4847 class _Up,
4948 class _BinaryPredicate,
50 __enable_if_t<__desugars_to<__equal_tag, _BinaryPredicate, _Tp, _Up>::value && !is_volatile<_Tp>::value &&
49 __enable_if_t<__desugars_to_v<__equal_tag, _BinaryPredicate, _Tp, _Up> && !is_volatile<_Tp>::value &&
5150 !is_volatile<_Up>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
5251 int> = 0>
5352_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
......@@ -56,33 +55,19 @@ __equal_iter_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _BinaryPredicate&)
5655}
5756
5857template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
58_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
6059equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
6160 return std::__equal_iter_impl(
6261 std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred);
6362}
6463
6564template <class _InputIterator1, class _InputIterator2>
66_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
65_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
6766equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
6867 return std::equal(__first1, __last1, __first2, __equal_to());
6968}
7069
7170#if _LIBCPP_STD_VER >= 14
72template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2>
73inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
74__equal(_InputIterator1 __first1,
75 _InputIterator1 __last1,
76 _InputIterator2 __first2,
77 _InputIterator2 __last2,
78 _BinaryPredicate __pred,
79 input_iterator_tag,
80 input_iterator_tag) {
81 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
82 if (!__pred(*__first1, *__first2))
83 return false;
84 return __first1 == __last1 && __first2 == __last2;
85}
8671
8772template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
8873_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __equal_impl(
......@@ -101,7 +86,7 @@ template <class _Tp,
10186 class _Pred,
10287 class _Proj1,
10388 class _Proj2,
104 __enable_if_t<__desugars_to<__equal_tag, _Pred, _Tp, _Up>::value && __is_identity<_Proj1>::value &&
89 __enable_if_t<__desugars_to_v<__equal_tag, _Pred, _Tp, _Up> && __is_identity<_Proj1>::value &&
10590 __is_identity<_Proj2>::value && !is_volatile<_Tp>::value && !is_volatile<_Up>::value &&
10691 __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value,
10792 int> = 0>
......@@ -110,17 +95,18 @@ __equal_impl(_Tp* __first1, _Tp* __last1, _Up* __first2, _Up*, _Pred&, _Proj1&,
11095 return std::__constexpr_memcmp_equal(__first1, __first2, __element_count(__last1 - __first1));
11196}
11297
113template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2>
114inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
115__equal(_RandomAccessIterator1 __first1,
116 _RandomAccessIterator1 __last1,
117 _RandomAccessIterator2 __first2,
118 _RandomAccessIterator2 __last2,
119 _BinaryPredicate __pred,
120 random_access_iterator_tag,
121 random_access_iterator_tag) {
122 if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
123 return false;
98template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
99_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
100equal(_InputIterator1 __first1,
101 _InputIterator1 __last1,
102 _InputIterator2 __first2,
103 _InputIterator2 __last2,
104 _BinaryPredicate __pred) {
105 if constexpr (__has_random_access_iterator_category<_InputIterator1>::value &&
106 __has_random_access_iterator_category<_InputIterator2>::value) {
107 if (std::distance(__first1, __last1) != std::distance(__first2, __last2))
108 return false;
109 }
124110 __identity __proj;
125111 return std::__equal_impl(
126112 std::__unwrap_iter(__first1),
......@@ -132,36 +118,13 @@ __equal(_RandomAccessIterator1 __first1,
132118 __proj);
133119}
134120
135template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
136_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
137equal(_InputIterator1 __first1,
138 _InputIterator1 __last1,
139 _InputIterator2 __first2,
140 _InputIterator2 __last2,
141 _BinaryPredicate __pred) {
142 return std::__equal<_BinaryPredicate&>(
143 __first1,
144 __last1,
145 __first2,
146 __last2,
147 __pred,
148 typename iterator_traits<_InputIterator1>::iterator_category(),
149 typename iterator_traits<_InputIterator2>::iterator_category());
150}
151
152121template <class _InputIterator1, class _InputIterator2>
153_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
122_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
154123equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
155 return std::__equal(
156 __first1,
157 __last1,
158 __first2,
159 __last2,
160 __equal_to(),
161 typename iterator_traits<_InputIterator1>::iterator_category(),
162 typename iterator_traits<_InputIterator2>::iterator_category());
124 return std::equal(__first1, __last1, __first2, __last2, __equal_to());
163125}
164#endif
126
127#endif // _LIBCPP_STD_VER >= 14
165128
166129_LIBCPP_END_NAMESPACE_STD
167130
lib/libcxx/include/__algorithm/equal_range.h+3-3
......@@ -23,7 +23,7 @@
2323#include <__iterator/iterator_traits.h>
2424#include <__iterator/next.h>
2525#include <__type_traits/is_callable.h>
26#include <__type_traits/is_copy_constructible.h>
26#include <__type_traits/is_constructible.h>
2727#include <__utility/move.h>
2828#include <__utility/pair.h>
2929
......@@ -60,7 +60,7 @@ __equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
6060}
6161
6262template <class _ForwardIterator, class _Tp, class _Compare>
63_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
63_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
6464equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
6565 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
6666 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");
......@@ -73,7 +73,7 @@ equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
7373}
7474
7575template <class _ForwardIterator, class _Tp>
76_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
76_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator>
7777equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
7878 return std::equal_range(std::move(__first), std::move(__last), __value, __less<>());
7979}
lib/libcxx/include/__algorithm/fill_n.h+58
......@@ -9,18 +9,74 @@
99#ifndef _LIBCPP___ALGORITHM_FILL_N_H
1010#define _LIBCPP___ALGORITHM_FILL_N_H
1111
12#include <__algorithm/min.h>
1213#include <__config>
14#include <__fwd/bit_reference.h>
1315#include <__iterator/iterator_traits.h>
16#include <__memory/pointer_traits.h>
1417#include <__utility/convert_to_integral.h>
1518
1619#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1720# pragma GCC system_header
1821#endif
1922
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
2026_LIBCPP_BEGIN_NAMESPACE_STD
2127
2228// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
2329
30template <class _OutputIterator, class _Size, class _Tp>
31inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
32__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value);
33
34template <bool _FillVal, class _Cp>
35_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
36__fill_n_bool(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {
37 using _It = __bit_iterator<_Cp, false>;
38 using __storage_type = typename _It::__storage_type;
39
40 const int __bits_per_word = _It::__bits_per_word;
41 // do first partial word
42 if (__first.__ctz_ != 0) {
43 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
44 __storage_type __dn = std::min(__clz_f, __n);
45 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
46 if (_FillVal)
47 *__first.__seg_ |= __m;
48 else
49 *__first.__seg_ &= ~__m;
50 __n -= __dn;
51 ++__first.__seg_;
52 }
53 // do middle whole words
54 __storage_type __nw = __n / __bits_per_word;
55 std::__fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0);
56 __n -= __nw * __bits_per_word;
57 // do last partial word
58 if (__n > 0) {
59 __first.__seg_ += __nw;
60 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
61 if (_FillVal)
62 *__first.__seg_ |= __m;
63 else
64 *__first.__seg_ &= ~__m;
65 }
66}
67
68template <class _Cp, class _Size>
69inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, false>
70__fill_n(__bit_iterator<_Cp, false> __first, _Size __n, const bool& __value) {
71 if (__n > 0) {
72 if (__value)
73 std::__fill_n_bool<true>(__first, __n);
74 else
75 std::__fill_n_bool<false>(__first, __n);
76 }
77 return __first + __n;
78}
79
2480template <class _OutputIterator, class _Size, class _Tp>
2581inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator
2682__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) {
......@@ -37,4 +93,6 @@ fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) {
3793
3894_LIBCPP_END_NAMESPACE_STD
3995
96_LIBCPP_POP_MACROS
97
4098#endif // _LIBCPP___ALGORITHM_FILL_N_H
lib/libcxx/include/__algorithm/find.h+10-12
......@@ -43,7 +43,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4343// generic implementation
4444template <class _Iter, class _Sent, class _Tp, class _Proj>
4545_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter
46__find_impl(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
46__find(_Iter __first, _Sent __last, const _Tp& __value, _Proj& __proj) {
4747 for (; __first != __last; ++__first)
4848 if (std::__invoke(__proj, *__first) == __value)
4949 break;
......@@ -57,8 +57,7 @@ template <class _Tp,
5757 __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
5858 sizeof(_Tp) == 1,
5959 int> = 0>
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*
61__find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
60_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
6261 if (auto __ret = std::__constexpr_memchr(__first, __value, __last - __first))
6362 return __ret;
6463 return __last;
......@@ -71,8 +70,7 @@ template <class _Tp,
7170 __enable_if_t<__is_identity<_Proj>::value && __libcpp_is_trivially_equality_comparable<_Tp, _Up>::value &&
7271 sizeof(_Tp) == sizeof(wchar_t) && _LIBCPP_ALIGNOF(_Tp) >= _LIBCPP_ALIGNOF(wchar_t),
7372 int> = 0>
74_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*
75__find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
73_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj&) {
7674 if (auto __ret = std::__constexpr_wmemchr(__first, __value, __last - __first))
7775 return __ret;
7876 return __last;
......@@ -89,10 +87,10 @@ template <class _Tp,
8987 is_signed<_Tp>::value == is_signed<_Up>::value,
9088 int> = 0>
9189_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp*
92__find_impl(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) {
90__find(_Tp* __first, _Tp* __last, const _Up& __value, _Proj& __proj) {
9391 if (__value < numeric_limits<_Tp>::min() || __value > numeric_limits<_Tp>::max())
9492 return __last;
95 return std::__find_impl(__first, __last, _Tp(__value), __proj);
93 return std::__find(__first, __last, _Tp(__value), __proj);
9694}
9795
9896// __bit_iterator implementation
......@@ -134,7 +132,7 @@ __find_bool(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
134132
135133template <class _Cp, bool _IsConst, class _Tp, class _Proj, __enable_if_t<__is_identity<_Proj>::value, int> = 0>
136134inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_iterator<_Cp, _IsConst>
137__find_impl(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
135__find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value, _Proj&) {
138136 if (static_cast<bool>(__value))
139137 return std::__find_bool<true>(__first, static_cast<typename _Cp::size_type>(__last - __first));
140138 return std::__find_bool<false>(__first, static_cast<typename _Cp::size_type>(__last - __first));
......@@ -150,7 +148,7 @@ template <class _SegmentedIterator,
150148 class _Proj,
151149 __enable_if_t<__is_segmented_iterator<_SegmentedIterator>::value, int> = 0>
152150_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _SegmentedIterator
153__find_impl(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) {
151__find(_SegmentedIterator __first, _SegmentedIterator __last, const _Tp& __value, _Proj& __proj) {
154152 return std::__find_segment_if(std::move(__first), std::move(__last), __find_segment<_Tp>(__value), __proj);
155153}
156154
......@@ -163,17 +161,17 @@ struct __find_segment {
163161 template <class _InputIterator, class _Proj>
164162 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _InputIterator
165163 operator()(_InputIterator __first, _InputIterator __last, _Proj& __proj) const {
166 return std::__find_impl(__first, __last, __value_, __proj);
164 return std::__find(__first, __last, __value_, __proj);
167165 }
168166};
169167
170168// public API
171169template <class _InputIterator, class _Tp>
172_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
170_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
173171find(_InputIterator __first, _InputIterator __last, const _Tp& __value) {
174172 __identity __proj;
175173 return std::__rewrap_iter(
176 __first, std::__find_impl(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __value, __proj));
174 __first, std::__find(std::__unwrap_iter(__first), std::__unwrap_iter(__last), __value, __proj));
177175}
178176
179177_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/find_end.h+2-2
......@@ -205,7 +205,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Fo
205205}
206206
207207template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
208_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end(
208_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_end(
209209 _ForwardIterator1 __first1,
210210 _ForwardIterator1 __last1,
211211 _ForwardIterator2 __first2,
......@@ -215,7 +215,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
215215}
216216
217217template <class _ForwardIterator1, class _ForwardIterator2>
218_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
218_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
219219find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
220220 return std::find_end(__first1, __last1, __first2, __last2, __equal_to());
221221}
lib/libcxx/include/__algorithm/find_first_of.h+2-2
......@@ -35,7 +35,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_fir
3535}
3636
3737template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
3939 _ForwardIterator1 __first1,
4040 _ForwardIterator1 __last1,
4141 _ForwardIterator2 __first2,
......@@ -45,7 +45,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4545}
4646
4747template <class _ForwardIterator1, class _ForwardIterator2>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of(
4949 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
5050 return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to());
5151}
lib/libcxx/include/__algorithm/find_if.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2323find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/find_if_not.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator
2323find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (!__pred(*__first))
lib/libcxx/include/__algorithm/fold.h+4-6
......@@ -78,8 +78,7 @@ concept __indirectly_binary_left_foldable =
7878
7979struct __fold_left_with_iter {
8080 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
81 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
82 operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
8382 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, iter_reference_t<_Ip>>>;
8483
8584 if (__first == __last) {
......@@ -95,7 +94,7 @@ struct __fold_left_with_iter {
9594 }
9695
9796 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
98 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
9998 auto __result = operator()(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f));
10099
101100 using _Up = decay_t<invoke_result_t<_Fp&, _Tp, range_reference_t<_Rp>>>;
......@@ -107,13 +106,12 @@ inline constexpr auto fold_left_with_iter = __fold_left_with_iter();
107106
108107struct __fold_left {
109108 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
110 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto
111 operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
109 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Ip __first, _Sp __last, _Tp __init, _Fp __f) {
112110 return fold_left_with_iter(std::move(__first), std::move(__last), std::move(__init), std::ref(__f)).value;
113111 }
114112
115113 template <input_range _Rp, class _Tp, __indirectly_binary_left_foldable<_Tp, iterator_t<_Rp>> _Fp>
116 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Rp&& __r, _Tp __init, _Fp __f) {
117115 return fold_left_with_iter(ranges::begin(__r), ranges::end(__r), std::move(__init), std::ref(__f)).value;
118116 }
119117};
lib/libcxx/include/__algorithm/includes.h+2-2
......@@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __includes(
4747}
4848
4949template <class _InputIterator1, class _InputIterator2, class _Compare>
50_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
5151includes(_InputIterator1 __first1,
5252 _InputIterator1 __last1,
5353 _InputIterator2 __first2,
......@@ -67,7 +67,7 @@ includes(_InputIterator1 __first1,
6767}
6868
6969template <class _InputIterator1, class _InputIterator2>
70_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
70_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
7171includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
7272 return std::includes(std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __less<>());
7373}
lib/libcxx/include/__algorithm/inplace_merge.h+2-2
......@@ -114,8 +114,8 @@ _LIBCPP_HIDE_FROM_ABI void __buffered_inplace_merge(
114114 for (_BidirectionalIterator __i = __middle; __i != __last;
115115 __d.template __incr<value_type>(), (void)++__i, (void)++__p)
116116 ::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i));
117 typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi;
118 typedef __unconstrained_reverse_iterator<value_type*> _Rv;
117 typedef reverse_iterator<_BidirectionalIterator> _RBi;
118 typedef reverse_iterator<value_type*> _Rv;
119119 typedef __invert<_Compare> _Inverted;
120120 std::__half_inplace_merge<_AlgPolicy>(
121121 _Rv(__p), _Rv(__buff), _RBi(__middle), _RBi(__first), _RBi(__last), _Inverted(__comp));
lib/libcxx/include/__algorithm/is_heap.h+2-2
......@@ -22,13 +22,13 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _RandomAccessIterator, class _Compare>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2626is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
2727 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last;
2828}
2929
3030template <class _RandomAccessIterator>
31_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
31_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3232is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) {
3333 return std::is_heap(__first, __last, __less<>());
3434}
lib/libcxx/include/__algorithm/is_heap_until.h+2-2
......@@ -46,13 +46,13 @@ __is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Co
4646}
4747
4848template <class _RandomAccessIterator, class _Compare>
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
5050is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) {
5151 return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp));
5252}
5353
5454template <class _RandomAccessIterator>
55_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
55_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator
5656is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) {
5757 return std::__is_heap_until(__first, __last, __less<>());
5858}
lib/libcxx/include/__algorithm/is_partitioned.h+1-1
......@@ -18,7 +18,7 @@
1818_LIBCPP_BEGIN_NAMESPACE_STD
1919
2020template <class _InputIterator, class _Predicate>
21_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
21_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2222is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2323 for (; __first != __last; ++__first)
2424 if (!__pred(*__first))
lib/libcxx/include/__algorithm/is_permutation.h+5-5
......@@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation_impl(
113113
114114// 2+1 iterators, predicate. Not used by range algorithms.
115115template <class _AlgPolicy, class _ForwardIterator1, class _Sentinel1, class _ForwardIterator2, class _BinaryPredicate>
116_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
116_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
117117 _ForwardIterator1 __first1, _Sentinel1 __last1, _ForwardIterator2 __first2, _BinaryPredicate&& __pred) {
118118 // Shorten sequences as much as possible by lopping of any equal prefix.
119119 for (; __first1 != __last1; ++__first1, (void)++__first2) {
......@@ -247,7 +247,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __is_permutation(
247247
248248// 2+1 iterators, predicate
249249template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
250_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
250_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
251251 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _BinaryPredicate __pred) {
252252 static_assert(__is_callable<_BinaryPredicate, decltype(*__first1), decltype(*__first2)>::value,
253253 "The predicate has to be callable");
......@@ -257,7 +257,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool i
257257
258258// 2+1 iterators
259259template <class _ForwardIterator1, class _ForwardIterator2>
260_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
260_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
261261is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
262262 return std::is_permutation(__first1, __last1, __first2, __equal_to());
263263}
......@@ -266,7 +266,7 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIt
266266
267267// 2+2 iterators
268268template <class _ForwardIterator1, class _ForwardIterator2>
269_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
269_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
270270 _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
271271 return std::__is_permutation<_ClassicAlgPolicy>(
272272 std::move(__first1),
......@@ -280,7 +280,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
280280
281281// 2+2 iterators, predicate
282282template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
283_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
283_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool is_permutation(
284284 _ForwardIterator1 __first1,
285285 _ForwardIterator1 __last1,
286286 _ForwardIterator2 __first2,
lib/libcxx/include/__algorithm/is_sorted.h+2-2
......@@ -22,13 +22,13 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <class _ForwardIterator, class _Compare>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
25_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2626is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
2727 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp) == __last;
2828}
2929
3030template <class _ForwardIterator>
31_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
31_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
3232is_sorted(_ForwardIterator __first, _ForwardIterator __last) {
3333 return std::is_sorted(__first, __last, __less<>());
3434}
lib/libcxx/include/__algorithm/is_sorted_until.h+2-2
......@@ -35,13 +35,13 @@ __is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __
3535}
3636
3737template <class _ForwardIterator, class _Compare>
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
3939is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
4040 return std::__is_sorted_until<__comp_ref_type<_Compare> >(__first, __last, __comp);
4141}
4242
4343template <class _ForwardIterator>
44_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
44_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
4545is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) {
4646 return std::is_sorted_until(__first, __last, __less<>());
4747}
lib/libcxx/include/__algorithm/iterator_operations.h+54
......@@ -11,6 +11,7 @@
1111
1212#include <__algorithm/iter_swap.h>
1313#include <__algorithm/ranges_iterator_concept.h>
14#include <__assert>
1415#include <__config>
1516#include <__iterator/advance.h>
1617#include <__iterator/distance.h>
......@@ -160,6 +161,59 @@ struct _IterOps<_ClassicAlgPolicy> {
160161 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX14 void __advance_to(_Iter& __first, _Iter __last) {
161162 __first = __last;
162163 }
164
165 // advance with sentinel, a la std::ranges::advance
166 template <class _Iter>
167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_Iter>
168 __advance_to(_Iter& __iter, __difference_type<_Iter> __count, const _Iter& __sentinel) {
169 return _IterOps::__advance_to(__iter, __count, __sentinel, typename iterator_traits<_Iter>::iterator_category());
170 }
171
172private:
173 // advance with sentinel, a la std::ranges::advance -- InputIterator specialization
174 template <class _InputIter>
175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_InputIter> __advance_to(
176 _InputIter& __iter, __difference_type<_InputIter> __count, const _InputIter& __sentinel, input_iterator_tag) {
177 __difference_type<_InputIter> __dist = 0;
178 for (; __dist < __count && __iter != __sentinel; ++__dist)
179 ++__iter;
180 return __count - __dist;
181 }
182
183 // advance with sentinel, a la std::ranges::advance -- BidirectionalIterator specialization
184 template <class _BiDirIter>
185 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_BiDirIter>
186 __advance_to(_BiDirIter& __iter,
187 __difference_type<_BiDirIter> __count,
188 const _BiDirIter& __sentinel,
189 bidirectional_iterator_tag) {
190 __difference_type<_BiDirIter> __dist = 0;
191 if (__count >= 0)
192 for (; __dist < __count && __iter != __sentinel; ++__dist)
193 ++__iter;
194 else
195 for (__count = -__count; __dist < __count && __iter != __sentinel; ++__dist)
196 --__iter;
197 return __count - __dist;
198 }
199
200 // advance with sentinel, a la std::ranges::advance -- RandomIterator specialization
201 template <class _RandIter>
202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static __difference_type<_RandIter>
203 __advance_to(_RandIter& __iter,
204 __difference_type<_RandIter> __count,
205 const _RandIter& __sentinel,
206 random_access_iterator_tag) {
207 auto __dist = _IterOps::distance(__iter, __sentinel);
208 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
209 __count == 0 || (__dist < 0) == (__count < 0), "__sentinel must precede __iter when __count < 0");
210 if (__count < 0)
211 __dist = __dist > __count ? __dist : __count;
212 else
213 __dist = __dist < __count ? __dist : __count;
214 __iter += __dist;
215 return __count - __dist;
216 }
163217};
164218
165219_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__algorithm/lexicographical_compare.h+2-2
......@@ -37,7 +37,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __lexicographical_compa
3737}
3838
3939template <class _InputIterator1, class _InputIterator2, class _Compare>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
40_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
4141 _InputIterator1 __first1,
4242 _InputIterator1 __last1,
4343 _InputIterator2 __first2,
......@@ -47,7 +47,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4747}
4848
4949template <class _InputIterator1, class _InputIterator2>
50_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool lexicographical_compare(
5151 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
5252 return std::lexicographical_compare(__first1, __last1, __first2, __last2, __less<>());
5353}
lib/libcxx/include/__algorithm/lexicographical_compare_three_way.h+3-3
......@@ -17,7 +17,7 @@
1717#include <__config>
1818#include <__iterator/iterator_traits.h>
1919#include <__type_traits/common_type.h>
20#include <__type_traits/is_copy_constructible.h>
20#include <__type_traits/is_constructible.h>
2121#include <__utility/move.h>
2222
2323#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -90,7 +90,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __lexicographical_compare_three_way_slow_pa
9090}
9191
9292template <class _InputIterator1, class _InputIterator2, class _Cmp>
93_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way(
93[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way(
9494 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Cmp __comp)
9595 -> decltype(__comp(*__first1, *__first2)) {
9696 static_assert(__comparison_category<decltype(__comp(*__first1, *__first2))>,
......@@ -110,7 +110,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compa
110110}
111111
112112template <class _InputIterator1, class _InputIterator2>
113_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way(
113[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto lexicographical_compare_three_way(
114114 _InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
115115 return std::lexicographical_compare_three_way(
116116 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::compare_three_way());
lib/libcxx/include/__algorithm/lower_bound.h+51-7
......@@ -27,11 +27,13 @@
2727
2828_LIBCPP_BEGIN_NAMESPACE_STD
2929
30template <class _AlgPolicy, class _Iter, class _Sent, class _Type, class _Proj, class _Comp>
31_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
32__lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
33 auto __len = _IterOps<_AlgPolicy>::distance(__first, __last);
34
30template <class _AlgPolicy, class _Iter, class _Type, class _Proj, class _Comp>
31_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter __lower_bound_bisecting(
32 _Iter __first,
33 const _Type& __value,
34 typename iterator_traits<_Iter>::difference_type __len,
35 _Comp& __comp,
36 _Proj& __proj) {
3537 while (__len != 0) {
3638 auto __l2 = std::__half_positive(__len);
3739 _Iter __m = __first;
......@@ -46,8 +48,50 @@ __lower_bound(_Iter __first, _Sent __last, const _Type& __value, _Comp& __comp,
4648 return __first;
4749}
4850
51// One-sided binary search, aka meta binary search, has been in the public domain for decades, and has the general
52// advantage of being \Omega(1) rather than the classic algorithm's \Omega(log(n)), with the downside of executing at
53// most 2*log(n) comparisons vs the classic algorithm's exact log(n). There are two scenarios in which it really shines:
54// the first one is when operating over non-random-access iterators, because the classic algorithm requires knowing the
55// container's size upfront, which adds \Omega(n) iterator increments to the complexity. The second one is when you're
56// traversing the container in order, trying to fast-forward to the next value: in that case, the classic algorithm
57// would yield \Omega(n*log(n)) comparisons and, for non-random-access iterators, \Omega(n^2) iterator increments,
58// whereas the one-sided version will yield O(n) operations on both counts, with a \Omega(log(n)) bound on the number of
59// comparisons.
60template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>
61_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
62__lower_bound_onesided(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
63 // step = 0, ensuring we can always short-circuit when distance is 1 later on
64 if (__first == __last || !std::__invoke(__comp, std::__invoke(__proj, *__first), __value))
65 return __first;
66
67 using _Distance = typename iterator_traits<_ForwardIterator>::difference_type;
68 for (_Distance __step = 1; __first != __last; __step <<= 1) {
69 auto __it = __first;
70 auto __dist = __step - _IterOps<_AlgPolicy>::__advance_to(__it, __step, __last);
71 // once we reach the last range where needle can be we must start
72 // looking inwards, bisecting that range
73 if (__it == __last || !std::__invoke(__comp, std::__invoke(__proj, *__it), __value)) {
74 // we've already checked the previous value and it was less, we can save
75 // one comparison by skipping bisection
76 if (__dist == 1)
77 return __it;
78 return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);
79 }
80 // range not found, move forward!
81 __first = __it;
82 }
83 return __first;
84}
85
86template <class _AlgPolicy, class _ForwardIterator, class _Sent, class _Type, class _Proj, class _Comp>
87_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
88__lower_bound(_ForwardIterator __first, _Sent __last, const _Type& __value, _Comp& __comp, _Proj& __proj) {
89 const auto __dist = _IterOps<_AlgPolicy>::distance(__first, __last);
90 return std::__lower_bound_bisecting<_AlgPolicy>(__first, __value, __dist, __comp, __proj);
91}
92
4993template <class _ForwardIterator, class _Tp, class _Compare>
50_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
94_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5195lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
5296 static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, "The comparator has to be callable");
5397 auto __proj = std::__identity();
......@@ -55,7 +99,7 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
5599}
56100
57101template <class _ForwardIterator, class _Tp>
58_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
102_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
59103lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
60104 return std::lower_bound(__first, __last, __value, __less<>());
61105}
lib/libcxx/include/__algorithm/make_projected.h+4-4
......@@ -36,8 +36,8 @@ struct _ProjectedPred {
3636 : __pred(__pred_arg), __proj(__proj_arg) {}
3737
3838 template <class _Tp>
39 typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>())) >::
40 type _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
39 typename __invoke_of<_Pred&, decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_Tp>()))>::type
40 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
4141 operator()(_Tp&& __v) const {
4242 return std::__invoke(__pred, std::__invoke(__proj, std::forward<_Tp>(__v)));
4343 }
......@@ -45,8 +45,8 @@ struct _ProjectedPred {
4545 template <class _T1, class _T2>
4646 typename __invoke_of<_Pred&,
4747 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T1>())),
48 decltype(std::__invoke(std::declval<_Proj&>(),
49 std::declval<_T2>())) >::type _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI
48 decltype(std::__invoke(std::declval<_Proj&>(), std::declval<_T2>()))>::type _LIBCPP_CONSTEXPR
49 _LIBCPP_HIDE_FROM_ABI
5050 operator()(_T1&& __lhs, _T2&& __rhs) const {
5151 return std::__invoke(
5252 __pred, std::__invoke(__proj, std::forward<_T1>(__lhs)), std::__invoke(__proj, std::forward<_T2>(__rhs)));
lib/libcxx/include/__algorithm/max.h+4-4
......@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
2929max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
3030 return __comp(__a, __b) ? __b : __a;
3131}
3232
3333template <class _Tp>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
34_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
3535max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
3636 return std::max(__a, __b, __less<>());
3737}
......@@ -39,13 +39,13 @@ max(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
3939#ifndef _LIBCPP_CXX03_LANG
4040
4141template <class _Tp, class _Compare>
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
4343max(initializer_list<_Tp> __t, _Compare __comp) {
4444 return *std::__max_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
4545}
4646
4747template <class _Tp>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp max(initializer_list<_Tp> __t) {
4949 return *std::max_element(__t.begin(), __t.end(), __less<>());
5050}
5151
lib/libcxx/include/__algorithm/max_element.h+2-2
......@@ -35,13 +35,13 @@ __max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp
3535}
3636
3737template <class _ForwardIterator, class _Compare>
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
3939max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
4040 return std::__max_element<__comp_ref_type<_Compare> >(__first, __last, __comp);
4141}
4242
4343template <class _ForwardIterator>
44_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
44_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
4545max_element(_ForwardIterator __first, _ForwardIterator __last) {
4646 return std::max_element(__first, __last, __less<>());
4747}
lib/libcxx/include/__algorithm/min.h+4-4
......@@ -25,13 +25,13 @@ _LIBCPP_PUSH_MACROS
2525_LIBCPP_BEGIN_NAMESPACE_STD
2626
2727template <class _Tp, class _Compare>
28_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
2929min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
3030 return __comp(__b, __a) ? __b : __a;
3131}
3232
3333template <class _Tp>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
34_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&
3535min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
3636 return std::min(__a, __b, __less<>());
3737}
......@@ -39,13 +39,13 @@ min(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b)
3939#ifndef _LIBCPP_CXX03_LANG
4040
4141template <class _Tp, class _Compare>
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp
4343min(initializer_list<_Tp> __t, _Compare __comp) {
4444 return *std::__min_element<__comp_ref_type<_Compare> >(__t.begin(), __t.end(), __comp);
4545}
4646
4747template <class _Tp>
48_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {
48_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp min(initializer_list<_Tp> __t) {
4949 return *std::min_element(__t.begin(), __t.end(), __less<>());
5050}
5151
lib/libcxx/include/__algorithm/min_element.h+2-2
......@@ -48,7 +48,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter __min_element(_Iter __
4848}
4949
5050template <class _ForwardIterator, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
51_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
5252min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
5353 static_assert(
5454 __has_forward_iterator_category<_ForwardIterator>::value, "std::min_element requires a ForwardIterator");
......@@ -59,7 +59,7 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
5959}
6060
6161template <class _ForwardIterator>
62_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
62_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator
6363min_element(_ForwardIterator __first, _ForwardIterator __last) {
6464 return std::min_element(__first, __last, __less<>());
6565}
lib/libcxx/include/__algorithm/minmax.h+4-4
......@@ -24,13 +24,13 @@
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template <class _Tp, class _Compare>
27_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
27_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
2828minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b, _Compare __comp) {
2929 return __comp(__b, __a) ? pair<const _Tp&, const _Tp&>(__b, __a) : pair<const _Tp&, const _Tp&>(__a, __b);
3030}
3131
3232template <class _Tp>
33_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
33_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<const _Tp&, const _Tp&>
3434minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __b) {
3535 return std::minmax(__a, __b, __less<>());
3636}
......@@ -38,7 +38,7 @@ minmax(_LIBCPP_LIFETIMEBOUND const _Tp& __a, _LIBCPP_LIFETIMEBOUND const _Tp& __
3838#ifndef _LIBCPP_CXX03_LANG
3939
4040template <class _Tp, class _Compare>
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
41_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
4242minmax(initializer_list<_Tp> __t, _Compare __comp) {
4343 static_assert(__is_callable<_Compare, _Tp, _Tp>::value, "The comparator has to be callable");
4444 __identity __proj;
......@@ -47,7 +47,7 @@ minmax(initializer_list<_Tp> __t, _Compare __comp) {
4747}
4848
4949template <class _Tp>
50_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Tp, _Tp>
5151minmax(initializer_list<_Tp> __t) {
5252 return std::minmax(__t, __less<>());
5353}
lib/libcxx/include/__algorithm/minmax_element.h+3-4
......@@ -79,7 +79,7 @@ __minmax_element_impl(_Iter __first, _Sent __last, _Comp& __comp, _Proj& __proj)
7979}
8080
8181template <class _ForwardIterator, class _Compare>
82_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>
82_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>
8383minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) {
8484 static_assert(
8585 __has_forward_iterator_category<_ForwardIterator>::value, "std::minmax_element requires a ForwardIterator");
......@@ -90,9 +90,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
9090}
9191
9292template <class _ForwardIterator>
93_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
94 pair<_ForwardIterator, _ForwardIterator>
95 minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
93_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_ForwardIterator, _ForwardIterator>
94minmax_element(_ForwardIterator __first, _ForwardIterator __last) {
9695 return std::minmax_element(__first, __last, __less<>());
9796}
9897
lib/libcxx/include/__algorithm/mismatch.h+168-13
......@@ -11,47 +11,200 @@
1111#define _LIBCPP___ALGORITHM_MISMATCH_H
1212
1313#include <__algorithm/comp.h>
14#include <__algorithm/min.h>
15#include <__algorithm/simd_utils.h>
16#include <__algorithm/unwrap_iter.h>
1417#include <__config>
15#include <__iterator/iterator_traits.h>
18#include <__functional/identity.h>
19#include <__iterator/aliasing_iterator.h>
20#include <__type_traits/desugars_to.h>
21#include <__type_traits/invoke.h>
22#include <__type_traits/is_constant_evaluated.h>
23#include <__type_traits/is_equality_comparable.h>
24#include <__type_traits/is_integral.h>
25#include <__utility/move.h>
1626#include <__utility/pair.h>
27#include <__utility/unreachable.h>
28#include <cstddef>
1729
1830#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1931# pragma GCC system_header
2032#endif
2133
34_LIBCPP_PUSH_MACROS
35#include <__undef_macros>
36
2237_LIBCPP_BEGIN_NAMESPACE_STD
2338
39template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>
40_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
41__mismatch_loop(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
42 while (__first1 != __last1) {
43 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
44 break;
45 ++__first1;
46 ++__first2;
47 }
48 return std::make_pair(std::move(__first1), std::move(__first2));
49}
50
51template <class _Iter1, class _Sent1, class _Iter2, class _Pred, class _Proj1, class _Proj2>
52_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2>
53__mismatch(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
54 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);
55}
56
57#if _LIBCPP_VECTORIZE_ALGORITHMS
58
59template <class _Iter>
60_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter>
61__mismatch_vectorized(_Iter __first1, _Iter __last1, _Iter __first2) {
62 using __value_type = __iter_value_type<_Iter>;
63 constexpr size_t __unroll_count = 4;
64 constexpr size_t __vec_size = __native_vector_size<__value_type>;
65 using __vec = __simd_vector<__value_type, __vec_size>;
66
67 if (!__libcpp_is_constant_evaluated()) {
68 auto __orig_first1 = __first1;
69 auto __last2 = __first2 + (__last1 - __first1);
70 while (static_cast<size_t>(__last1 - __first1) >= __unroll_count * __vec_size) [[__unlikely__]] {
71 __vec __lhs[__unroll_count];
72 __vec __rhs[__unroll_count];
73
74 for (size_t __i = 0; __i != __unroll_count; ++__i) {
75 __lhs[__i] = std::__load_vector<__vec>(__first1 + __i * __vec_size);
76 __rhs[__i] = std::__load_vector<__vec>(__first2 + __i * __vec_size);
77 }
78
79 for (size_t __i = 0; __i != __unroll_count; ++__i) {
80 if (auto __cmp_res = __lhs[__i] == __rhs[__i]; !std::__all_of(__cmp_res)) {
81 auto __offset = __i * __vec_size + std::__find_first_not_set(__cmp_res);
82 return {__first1 + __offset, __first2 + __offset};
83 }
84 }
85
86 __first1 += __unroll_count * __vec_size;
87 __first2 += __unroll_count * __vec_size;
88 }
89
90 // check the remaining 0-3 vectors
91 while (static_cast<size_t>(__last1 - __first1) >= __vec_size) {
92 if (auto __cmp_res = std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2);
93 !std::__all_of(__cmp_res)) {
94 auto __offset = std::__find_first_not_set(__cmp_res);
95 return {__first1 + __offset, __first2 + __offset};
96 }
97 __first1 += __vec_size;
98 __first2 += __vec_size;
99 }
100
101 if (__last1 - __first1 == 0)
102 return {__first1, __first2};
103
104 // Check if we can load elements in front of the current pointer. If that's the case load a vector at
105 // (last - vector_size) to check the remaining elements
106 if (static_cast<size_t>(__first1 - __orig_first1) >= __vec_size) {
107 __first1 = __last1 - __vec_size;
108 __first2 = __last2 - __vec_size;
109 auto __offset =
110 std::__find_first_not_set(std::__load_vector<__vec>(__first1) == std::__load_vector<__vec>(__first2));
111 return {__first1 + __offset, __first2 + __offset};
112 } // else loop over the elements individually
113 }
114
115 __equal_to __pred;
116 __identity __proj;
117 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj, __proj);
118}
119
120template <class _Tp,
121 class _Pred,
122 class _Proj1,
123 class _Proj2,
124 __enable_if_t<is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> &&
125 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value,
126 int> = 0>
127_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
128__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred&, _Proj1&, _Proj2&) {
129 return std::__mismatch_vectorized(__first1, __last1, __first2);
130}
131
132template <class _Tp,
133 class _Pred,
134 class _Proj1,
135 class _Proj2,
136 __enable_if_t<!is_integral<_Tp>::value && __desugars_to_v<__equal_tag, _Pred, _Tp, _Tp> &&
137 __is_identity<_Proj1>::value && __is_identity<_Proj2>::value &&
138 __can_map_to_integer_v<_Tp> && __libcpp_is_trivially_equality_comparable<_Tp, _Tp>::value,
139 int> = 0>
140_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
141__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
142 if (__libcpp_is_constant_evaluated()) {
143 return std::__mismatch_loop(__first1, __last1, __first2, __pred, __proj1, __proj2);
144 } else {
145 using _Iter = __aliasing_iterator<_Tp*, __get_as_integer_type_t<_Tp>>;
146 auto __ret = std::__mismatch_vectorized(_Iter(__first1), _Iter(__last1), _Iter(__first2));
147 return {__ret.first.__base(), __ret.second.__base()};
148 }
149}
150#endif // _LIBCPP_VECTORIZE_ALGORITHMS
151
24152template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
25_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
153_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
26154mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) {
27 for (; __first1 != __last1; ++__first1, (void)++__first2)
28 if (!__pred(*__first1, *__first2))
29 break;
30 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
155 __identity __proj;
156 auto __res = std::__mismatch(
157 std::__unwrap_iter(__first1), std::__unwrap_iter(__last1), std::__unwrap_iter(__first2), __pred, __proj, __proj);
158 return std::make_pair(std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second));
31159}
32160
33161template <class _InputIterator1, class _InputIterator2>
34_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
162_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
35163mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) {
36164 return std::mismatch(__first1, __last1, __first2, __equal_to());
37165}
38166
39167#if _LIBCPP_STD_VER >= 14
168template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
169_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter1, _Iter2> __mismatch(
170 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
171 while (__first1 != __last1 && __first2 != __last2) {
172 if (!std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2)))
173 break;
174 ++__first1;
175 ++__first2;
176 }
177 return {std::move(__first1), std::move(__first2)};
178}
179
180template <class _Tp, class _Pred, class _Proj1, class _Proj2>
181_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Tp*, _Tp*>
182__mismatch(_Tp* __first1, _Tp* __last1, _Tp* __first2, _Tp* __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
183 auto __len = std::min(__last1 - __first1, __last2 - __first2);
184 return std::__mismatch(__first1, __first1 + __len, __first2, __pred, __proj1, __proj2);
185}
186
40187template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
188_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
42189mismatch(_InputIterator1 __first1,
43190 _InputIterator1 __last1,
44191 _InputIterator2 __first2,
45192 _InputIterator2 __last2,
46193 _BinaryPredicate __pred) {
47 for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2)
48 if (!__pred(*__first1, *__first2))
49 break;
50 return pair<_InputIterator1, _InputIterator2>(__first1, __first2);
194 __identity __proj;
195 auto __res = std::__mismatch(
196 std::__unwrap_iter(__first1),
197 std::__unwrap_iter(__last1),
198 std::__unwrap_iter(__first2),
199 std::__unwrap_iter(__last2),
200 __pred,
201 __proj,
202 __proj);
203 return {std::__rewrap_iter(__first1, __res.first), std::__rewrap_iter(__first2, __res.second)};
51204}
52205
53206template <class _InputIterator1, class _InputIterator2>
54_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
207_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InputIterator1, _InputIterator2>
55208mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) {
56209 return std::mismatch(__first1, __last1, __first2, __last2, __equal_to());
57210}
......@@ -59,4 +212,6 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
59212
60213_LIBCPP_END_NAMESPACE_STD
61214
215_LIBCPP_POP_MACROS
216
62217#endif // _LIBCPP___ALGORITHM_MISMATCH_H
lib/libcxx/include/__algorithm/move.h+3-5
......@@ -16,7 +16,7 @@
1616#include <__config>
1717#include <__iterator/segmented_iterator.h>
1818#include <__type_traits/common_type.h>
19#include <__type_traits/is_copy_constructible.h>
19#include <__type_traits/is_constructible.h>
2020#include <__utility/move.h>
2121#include <__utility/pair.h>
2222
......@@ -34,7 +34,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIte
3434__move(_InIter __first, _Sent __last, _OutIter __result);
3535
3636template <class _AlgPolicy>
37struct __move_loop {
37struct __move_impl {
3838 template <class _InIter, class _Sent, class _OutIter>
3939 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
4040 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
......@@ -95,9 +95,7 @@ struct __move_loop {
9595 __local_first = _Traits::__begin(++__segment_iterator);
9696 }
9797 }
98};
9998
100struct __move_trivial {
10199 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
102100 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
103101 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
......@@ -109,7 +107,7 @@ struct __move_trivial {
109107template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter>
110108inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
111109__move(_InIter __first, _Sent __last, _OutIter __result) {
112 return std::__dispatch_copy_or_move<_AlgPolicy, __move_loop<_AlgPolicy>, __move_trivial>(
110 return std::__copy_move_unwrap_iters<__move_impl<_AlgPolicy> >(
113111 std::move(__first), std::move(__last), std::move(__result));
114112}
115113
lib/libcxx/include/__algorithm/move_backward.h+3-5
......@@ -15,7 +15,7 @@
1515#include <__config>
1616#include <__iterator/segmented_iterator.h>
1717#include <__type_traits/common_type.h>
18#include <__type_traits/is_copy_constructible.h>
18#include <__type_traits/is_constructible.h>
1919#include <__utility/move.h>
2020#include <__utility/pair.h>
2121
......@@ -33,7 +33,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1
3333__move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result);
3434
3535template <class _AlgPolicy>
36struct __move_backward_loop {
36struct __move_backward_impl {
3737 template <class _InIter, class _Sent, class _OutIter>
3838 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter>
3939 operator()(_InIter __first, _Sent __last, _OutIter __result) const {
......@@ -104,9 +104,7 @@ struct __move_backward_loop {
104104 __local_last = _Traits::__end(--__segment_iterator);
105105 }
106106 }
107};
108107
109struct __move_backward_trivial {
110108 // At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer.
111109 template <class _In, class _Out, __enable_if_t<__can_lower_move_assignment_to_memmove<_In, _Out>::value, int> = 0>
112110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*>
......@@ -122,7 +120,7 @@ __move_backward(_BidirectionalIterator1 __first, _Sentinel __last, _Bidirectiona
122120 std::is_copy_constructible<_BidirectionalIterator1>::value,
123121 "Iterators must be copy constructible.");
124122
125 return std::__dispatch_copy_or_move<_AlgPolicy, __move_backward_loop<_AlgPolicy>, __move_backward_trivial>(
123 return std::__copy_move_unwrap_iters<__move_backward_impl<_AlgPolicy> >(
126124 std::move(__first), std::move(__last), std::move(__result));
127125}
128126
lib/libcxx/include/__algorithm/none_of.h+1-1
......@@ -19,7 +19,7 @@
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
2121template <class _InputIterator, class _Predicate>
22_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
22_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
2323none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
2424 for (; __first != __last; ++__first)
2525 if (__pred(*__first))
lib/libcxx/include/__algorithm/partial_sort.h+2-2
......@@ -18,8 +18,8 @@
1818#include <__config>
1919#include <__debug_utils/randomize_range.h>
2020#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_copy_assignable.h>
22#include <__type_traits/is_copy_constructible.h>
21#include <__type_traits/is_assignable.h>
22#include <__type_traits/is_constructible.h>
2323#include <__utility/move.h>
2424
2525#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__algorithm/pop_heap.h+2-2
......@@ -17,8 +17,8 @@
1717#include <__assert>
1818#include <__config>
1919#include <__iterator/iterator_traits.h>
20#include <__type_traits/is_copy_assignable.h>
21#include <__type_traits/is_copy_constructible.h>
20#include <__type_traits/is_assignable.h>
21#include <__type_traits/is_constructible.h>
2222#include <__utility/move.h>
2323
2424#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__algorithm/pstl.h created+663
......@@ -0,0 +1,663 @@
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_PSTL_H
10#define _LIBCPP___ALGORITHM_PSTL_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_PUSH_MACROS
19#include <__undef_macros>
20
21#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
22
23# include <__functional/operations.h>
24# include <__iterator/cpp17_iterator_concepts.h>
25# include <__iterator/iterator_traits.h>
26# include <__pstl/backend.h>
27# include <__pstl/dispatch.h>
28# include <__pstl/handle_exception.h>
29# include <__type_traits/enable_if.h>
30# include <__type_traits/is_execution_policy.h>
31# include <__type_traits/remove_cvref.h>
32# include <__utility/forward.h>
33# include <__utility/move.h>
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37template <class _ExecutionPolicy,
38 class _ForwardIterator,
39 class _Predicate,
40 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
41 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
42[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
43any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
44 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "any_of requires a ForwardIterator");
45 using _Implementation = __pstl::__dispatch<__pstl::__any_of, __pstl::__current_configuration, _RawPolicy>;
46 return __pstl::__handle_exception<_Implementation>(
47 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
48}
49
50template <class _ExecutionPolicy,
51 class _ForwardIterator,
52 class _Pred,
53 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
54 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
55[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
56all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
57 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "all_of requires a ForwardIterator");
58 using _Implementation = __pstl::__dispatch<__pstl::__all_of, __pstl::__current_configuration, _RawPolicy>;
59 return __pstl::__handle_exception<_Implementation>(
60 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
61}
62
63template <class _ExecutionPolicy,
64 class _ForwardIterator,
65 class _Pred,
66 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
67 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
68[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
69none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
70 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "none_of requires a ForwardIterator");
71 using _Implementation = __pstl::__dispatch<__pstl::__none_of, __pstl::__current_configuration, _RawPolicy>;
72 return __pstl::__handle_exception<_Implementation>(
73 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
74}
75
76template <class _ExecutionPolicy,
77 class _ForwardIterator,
78 class _ForwardOutIterator,
79 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
80 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
81_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
82copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
83 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
84 _ForwardIterator, "copy(first, last, result) requires [first, last) to be ForwardIterators");
85 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
86 _ForwardOutIterator, "copy(first, last, result) requires result to be a ForwardIterator");
87 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
88 _ForwardOutIterator, decltype(*__first), "copy(first, last, result) requires result to be an OutputIterator");
89 using _Implementation = __pstl::__dispatch<__pstl::__copy, __pstl::__current_configuration, _RawPolicy>;
90 return __pstl::__handle_exception<_Implementation>(
91 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result));
92}
93
94template <class _ExecutionPolicy,
95 class _ForwardIterator,
96 class _ForwardOutIterator,
97 class _Size,
98 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
99 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
100_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
101copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) {
102 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
103 _ForwardIterator, "copy_n(first, n, result) requires first to be a ForwardIterator");
104 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
105 _ForwardOutIterator, "copy_n(first, n, result) requires result to be a ForwardIterator");
106 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
107 _ForwardOutIterator, decltype(*__first), "copy_n(first, n, result) requires result to be an OutputIterator");
108 using _Implementation = __pstl::__dispatch<__pstl::__copy_n, __pstl::__current_configuration, _RawPolicy>;
109 return __pstl::__handle_exception<_Implementation>(
110 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__result));
111}
112
113template <class _ExecutionPolicy,
114 class _ForwardIterator,
115 class _Predicate,
116 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
117 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
118_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
119count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
120 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
121 _ForwardIterator, "count_if(first, last, pred) requires [first, last) to be ForwardIterators");
122 using _Implementation = __pstl::__dispatch<__pstl::__count_if, __pstl::__current_configuration, _RawPolicy>;
123 return __pstl::__handle_exception<_Implementation>(
124 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
125}
126
127template <class _ExecutionPolicy,
128 class _ForwardIterator,
129 class _Tp,
130 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
131 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
132_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
133count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
134 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(
135 _ForwardIterator, "count(first, last, val) requires [first, last) to be ForwardIterators");
136 using _Implementation = __pstl::__dispatch<__pstl::__count, __pstl::__current_configuration, _RawPolicy>;
137 return __pstl::__handle_exception<_Implementation>(
138 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
139}
140
141template <class _ExecutionPolicy,
142 class _ForwardIterator1,
143 class _ForwardIterator2,
144 class _Pred,
145 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
146 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
147_LIBCPP_HIDE_FROM_ABI bool
148equal(_ExecutionPolicy&& __policy,
149 _ForwardIterator1 __first1,
150 _ForwardIterator1 __last1,
151 _ForwardIterator2 __first2,
152 _Pred __pred) {
153 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
154 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
155 using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>;
156 return __pstl::__handle_exception<_Implementation>(
157 std::forward<_ExecutionPolicy>(__policy),
158 std::move(__first1),
159 std::move(__last1),
160 std::move(__first2),
161 std::move(__pred));
162}
163
164template <class _ExecutionPolicy,
165 class _ForwardIterator1,
166 class _ForwardIterator2,
167 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
168 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
169_LIBCPP_HIDE_FROM_ABI bool
170equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
171 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
172 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
173 using _Implementation = __pstl::__dispatch<__pstl::__equal_3leg, __pstl::__current_configuration, _RawPolicy>;
174 return __pstl::__handle_exception<_Implementation>(
175 std::forward<_ExecutionPolicy>(__policy),
176 std::move(__first1),
177 std::move(__last1),
178 std::move(__first2),
179 equal_to{});
180}
181
182template <class _ExecutionPolicy,
183 class _ForwardIterator1,
184 class _ForwardIterator2,
185 class _Pred,
186 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
187 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
188_LIBCPP_HIDE_FROM_ABI bool
189equal(_ExecutionPolicy&& __policy,
190 _ForwardIterator1 __first1,
191 _ForwardIterator1 __last1,
192 _ForwardIterator2 __first2,
193 _ForwardIterator2 __last2,
194 _Pred __pred) {
195 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
196 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
197 using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>;
198 return __pstl::__handle_exception<_Implementation>(
199 std::forward<_ExecutionPolicy>(__policy),
200 std::move(__first1),
201 std::move(__last1),
202 std::move(__first2),
203 std::move(__last2),
204 std::move(__pred));
205}
206
207template <class _ExecutionPolicy,
208 class _ForwardIterator1,
209 class _ForwardIterator2,
210 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
211 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
212_LIBCPP_HIDE_FROM_ABI bool
213equal(_ExecutionPolicy&& __policy,
214 _ForwardIterator1 __first1,
215 _ForwardIterator1 __last1,
216 _ForwardIterator2 __first2,
217 _ForwardIterator2 __last2) {
218 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "equal requires ForwardIterators");
219 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "equal requires ForwardIterators");
220 using _Implementation = __pstl::__dispatch<__pstl::__equal, __pstl::__current_configuration, _RawPolicy>;
221 return __pstl::__handle_exception<_Implementation>(
222 std::forward<_ExecutionPolicy>(__policy),
223 std::move(__first1),
224 std::move(__last1),
225 std::move(__first2),
226 std::move(__last2),
227 equal_to{});
228}
229
230template <class _ExecutionPolicy,
231 class _ForwardIterator,
232 class _Tp,
233 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
234 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
235_LIBCPP_HIDE_FROM_ABI void
236fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
237 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill requires ForwardIterators");
238 using _Implementation = __pstl::__dispatch<__pstl::__fill, __pstl::__current_configuration, _RawPolicy>;
239 __pstl::__handle_exception<_Implementation>(
240 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
241}
242
243template <class _ExecutionPolicy,
244 class _ForwardIterator,
245 class _Size,
246 class _Tp,
247 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
248 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
249_LIBCPP_HIDE_FROM_ABI void
250fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, const _Tp& __value) {
251 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "fill_n requires a ForwardIterator");
252 using _Implementation = __pstl::__dispatch<__pstl::__fill_n, __pstl::__current_configuration, _RawPolicy>;
253 __pstl::__handle_exception<_Implementation>(
254 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), __value);
255}
256
257template <class _ExecutionPolicy,
258 class _ForwardIterator,
259 class _Predicate,
260 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
261 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
262_LIBCPP_HIDE_FROM_ABI _ForwardIterator
263find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
264 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if requires ForwardIterators");
265 using _Implementation = __pstl::__dispatch<__pstl::__find_if, __pstl::__current_configuration, _RawPolicy>;
266 return __pstl::__handle_exception<_Implementation>(
267 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
268}
269
270template <class _ExecutionPolicy,
271 class _ForwardIterator,
272 class _Predicate,
273 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
274 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
275_LIBCPP_HIDE_FROM_ABI _ForwardIterator
276find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
277 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find_if_not requires ForwardIterators");
278 using _Implementation = __pstl::__dispatch<__pstl::__find_if_not, __pstl::__current_configuration, _RawPolicy>;
279 return __pstl::__handle_exception<_Implementation>(
280 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
281}
282
283template <class _ExecutionPolicy,
284 class _ForwardIterator,
285 class _Tp,
286 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
287 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
288_LIBCPP_HIDE_FROM_ABI _ForwardIterator
289find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
290 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "find requires ForwardIterators");
291 using _Implementation = __pstl::__dispatch<__pstl::__find, __pstl::__current_configuration, _RawPolicy>;
292 return __pstl::__handle_exception<_Implementation>(
293 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __value);
294}
295
296template <class _ExecutionPolicy,
297 class _ForwardIterator,
298 class _Function,
299 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
300 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
301_LIBCPP_HIDE_FROM_ABI void
302for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) {
303 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each requires ForwardIterators");
304 using _Implementation = __pstl::__dispatch<__pstl::__for_each, __pstl::__current_configuration, _RawPolicy>;
305 __pstl::__handle_exception<_Implementation>(
306 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__func));
307}
308
309template <class _ExecutionPolicy,
310 class _ForwardIterator,
311 class _Size,
312 class _Function,
313 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
314 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
315_LIBCPP_HIDE_FROM_ABI void
316for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) {
317 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "for_each_n requires a ForwardIterator");
318 using _Implementation = __pstl::__dispatch<__pstl::__for_each_n, __pstl::__current_configuration, _RawPolicy>;
319 __pstl::__handle_exception<_Implementation>(
320 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__size), std::move(__func));
321}
322
323template <class _ExecutionPolicy,
324 class _ForwardIterator,
325 class _Generator,
326 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
327 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
328_LIBCPP_HIDE_FROM_ABI void
329generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
330 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate requires ForwardIterators");
331 using _Implementation = __pstl::__dispatch<__pstl::__generate, __pstl::__current_configuration, _RawPolicy>;
332 __pstl::__handle_exception<_Implementation>(
333 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__gen));
334}
335
336template <class _ExecutionPolicy,
337 class _ForwardIterator,
338 class _Size,
339 class _Generator,
340 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
341 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
342_LIBCPP_HIDE_FROM_ABI void
343generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) {
344 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "generate_n requires a ForwardIterator");
345 using _Implementation = __pstl::__dispatch<__pstl::__generate_n, __pstl::__current_configuration, _RawPolicy>;
346 __pstl::__handle_exception<_Implementation>(
347 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__n), std::move(__gen));
348}
349
350template <class _ExecutionPolicy,
351 class _ForwardIterator,
352 class _Predicate,
353 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
354 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
355_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool
356is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
357 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "is_partitioned requires ForwardIterators");
358 using _Implementation = __pstl::__dispatch<__pstl::__is_partitioned, __pstl::__current_configuration, _RawPolicy>;
359 return __pstl::__handle_exception<_Implementation>(
360 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred));
361}
362
363template <class _ExecutionPolicy,
364 class _ForwardIterator1,
365 class _ForwardIterator2,
366 class _ForwardOutIterator,
367 class _Comp,
368 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
369 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
370_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
371merge(_ExecutionPolicy&& __policy,
372 _ForwardIterator1 __first1,
373 _ForwardIterator1 __last1,
374 _ForwardIterator2 __first2,
375 _ForwardIterator2 __last2,
376 _ForwardOutIterator __result,
377 _Comp __comp) {
378 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators");
379 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators");
380 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator");
381 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator");
382 using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>;
383 return __pstl::__handle_exception<_Implementation>(
384 std::forward<_ExecutionPolicy>(__policy),
385 std::move(__first1),
386 std::move(__last1),
387 std::move(__first2),
388 std::move(__last2),
389 std::move(__result),
390 std::move(__comp));
391}
392
393template <class _ExecutionPolicy,
394 class _ForwardIterator1,
395 class _ForwardIterator2,
396 class _ForwardOutIterator,
397 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
398 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
399_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
400merge(_ExecutionPolicy&& __policy,
401 _ForwardIterator1 __first1,
402 _ForwardIterator1 __last1,
403 _ForwardIterator2 __first2,
404 _ForwardIterator2 __last2,
405 _ForwardOutIterator __result) {
406 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "merge requires ForwardIterators");
407 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "merge requires ForwardIterators");
408 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first1), "merge requires an OutputIterator");
409 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(*__first2), "merge requires an OutputIterator");
410 using _Implementation = __pstl::__dispatch<__pstl::__merge, __pstl::__current_configuration, _RawPolicy>;
411 return __pstl::__handle_exception<_Implementation>(
412 std::forward<_ExecutionPolicy>(__policy),
413 std::move(__first1),
414 std::move(__last1),
415 std::move(__first2),
416 std::move(__last2),
417 std::move(__result),
418 less{});
419}
420
421template <class _ExecutionPolicy,
422 class _ForwardIterator,
423 class _ForwardOutIterator,
424 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
425 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
426_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
427move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
428 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "move requires ForwardIterators");
429 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "move requires an OutputIterator");
430 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
431 _ForwardOutIterator, decltype(std::move(*__first)), "move requires an OutputIterator");
432 using _Implementation = __pstl::__dispatch<__pstl::__move, __pstl::__current_configuration, _RawPolicy>;
433 return __pstl::__handle_exception<_Implementation>(
434 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__result));
435}
436
437template <class _ExecutionPolicy,
438 class _ForwardIterator,
439 class _Pred,
440 class _Tp,
441 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
442 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
443_LIBCPP_HIDE_FROM_ABI void
444replace_if(_ExecutionPolicy&& __policy,
445 _ForwardIterator __first,
446 _ForwardIterator __last,
447 _Pred __pred,
448 const _Tp& __new_value) {
449 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_if requires ForwardIterators");
450 using _Implementation = __pstl::__dispatch<__pstl::__replace_if, __pstl::__current_configuration, _RawPolicy>;
451 __pstl::__handle_exception<_Implementation>(
452 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__pred), __new_value);
453}
454
455template <class _ExecutionPolicy,
456 class _ForwardIterator,
457 class _Tp,
458 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
459 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
460_LIBCPP_HIDE_FROM_ABI void
461replace(_ExecutionPolicy&& __policy,
462 _ForwardIterator __first,
463 _ForwardIterator __last,
464 const _Tp& __old_value,
465 const _Tp& __new_value) {
466 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace requires ForwardIterators");
467 using _Implementation = __pstl::__dispatch<__pstl::__replace, __pstl::__current_configuration, _RawPolicy>;
468 __pstl::__handle_exception<_Implementation>(
469 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), __old_value, __new_value);
470}
471
472template <class _ExecutionPolicy,
473 class _ForwardIterator,
474 class _ForwardOutIterator,
475 class _Pred,
476 class _Tp,
477 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
478 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
479_LIBCPP_HIDE_FROM_ABI void replace_copy_if(
480 _ExecutionPolicy&& __policy,
481 _ForwardIterator __first,
482 _ForwardIterator __last,
483 _ForwardOutIterator __result,
484 _Pred __pred,
485 const _Tp& __new_value) {
486 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy_if requires ForwardIterators");
487 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy_if requires ForwardIterators");
488 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
489 _ForwardOutIterator, decltype(*__first), "replace_copy_if requires an OutputIterator");
490 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator");
491 using _Implementation = __pstl::__dispatch<__pstl::__replace_copy_if, __pstl::__current_configuration, _RawPolicy>;
492 __pstl::__handle_exception<_Implementation>(
493 std::forward<_ExecutionPolicy>(__policy),
494 std::move(__first),
495 std::move(__last),
496 std::move(__result),
497 std::move(__pred),
498 __new_value);
499}
500
501template <class _ExecutionPolicy,
502 class _ForwardIterator,
503 class _ForwardOutIterator,
504 class _Tp,
505 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
506 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
507_LIBCPP_HIDE_FROM_ABI void replace_copy(
508 _ExecutionPolicy&& __policy,
509 _ForwardIterator __first,
510 _ForwardIterator __last,
511 _ForwardOutIterator __result,
512 const _Tp& __old_value,
513 const _Tp& __new_value) {
514 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "replace_copy requires ForwardIterators");
515 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "replace_copy requires ForwardIterators");
516 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
517 _ForwardOutIterator, decltype(*__first), "replace_copy requires an OutputIterator");
518 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, const _Tp&, "replace_copy requires an OutputIterator");
519 using _Implementation = __pstl::__dispatch<__pstl::__replace_copy, __pstl::__current_configuration, _RawPolicy>;
520 __pstl::__handle_exception<_Implementation>(
521 std::forward<_ExecutionPolicy>(__policy),
522 std::move(__first),
523 std::move(__last),
524 std::move(__result),
525 __old_value,
526 __new_value);
527}
528
529template <class _ExecutionPolicy,
530 class _ForwardIterator,
531 class _ForwardOutIterator,
532 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
533 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
534_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy(
535 _ExecutionPolicy&& __policy,
536 _ForwardIterator __first,
537 _ForwardIterator __middle,
538 _ForwardIterator __last,
539 _ForwardOutIterator __result) {
540 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "rotate_copy requires ForwardIterators");
541 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "rotate_copy requires ForwardIterators");
542 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
543 _ForwardOutIterator, decltype(*__first), "rotate_copy requires an OutputIterator");
544 using _Implementation = __pstl::__dispatch<__pstl::__rotate_copy, __pstl::__current_configuration, _RawPolicy>;
545 return __pstl::__handle_exception<_Implementation>(
546 std::forward<_ExecutionPolicy>(__policy),
547 std::move(__first),
548 std::move(__middle),
549 std::move(__last),
550 std::move(__result));
551}
552
553template <class _ExecutionPolicy,
554 class _RandomAccessIterator,
555 class _Comp,
556 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
557 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
558_LIBCPP_HIDE_FROM_ABI void
559sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
560 _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators");
561 using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>;
562 __pstl::__handle_exception<_Implementation>(
563 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp));
564}
565
566template <class _ExecutionPolicy,
567 class _RandomAccessIterator,
568 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
569 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
570_LIBCPP_HIDE_FROM_ABI void
571sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) {
572 _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "sort requires RandomAccessIterators");
573 using _Implementation = __pstl::__dispatch<__pstl::__sort, __pstl::__current_configuration, _RawPolicy>;
574 __pstl::__handle_exception<_Implementation>(
575 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
576}
577
578template <class _ExecutionPolicy,
579 class _RandomAccessIterator,
580 class _Comp,
581 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
582 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
583_LIBCPP_HIDE_FROM_ABI void
584stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
585 _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators");
586 using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>;
587 __pstl::__handle_exception<_Implementation>(
588 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__comp));
589}
590
591template <class _ExecutionPolicy,
592 class _RandomAccessIterator,
593 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
594 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
595_LIBCPP_HIDE_FROM_ABI void
596stable_sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) {
597 _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(_RandomAccessIterator, "stable_sort requires RandomAccessIterators");
598 using _Implementation = __pstl::__dispatch<__pstl::__stable_sort, __pstl::__current_configuration, _RawPolicy>;
599 __pstl::__handle_exception<_Implementation>(
600 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
601}
602
603template <class _ExecutionPolicy,
604 class _ForwardIterator,
605 class _ForwardOutIterator,
606 class _UnaryOperation,
607 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
608 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
609_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
610 _ExecutionPolicy&& __policy,
611 _ForwardIterator __first,
612 _ForwardIterator __last,
613 _ForwardOutIterator __result,
614 _UnaryOperation __op) {
615 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "transform requires ForwardIterators");
616 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator");
617 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
618 _ForwardOutIterator, decltype(__op(*__first)), "transform requires an OutputIterator");
619 using _Implementation = __pstl::__dispatch<__pstl::__transform, __pstl::__current_configuration, _RawPolicy>;
620 return __pstl::__handle_exception<_Implementation>(
621 std::forward<_ExecutionPolicy>(__policy),
622 std::move(__first),
623 std::move(__last),
624 std::move(__result),
625 std::move(__op));
626}
627
628template <class _ExecutionPolicy,
629 class _ForwardIterator1,
630 class _ForwardIterator2,
631 class _ForwardOutIterator,
632 class _BinaryOperation,
633 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
634 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
635_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
636 _ExecutionPolicy&& __policy,
637 _ForwardIterator1 __first1,
638 _ForwardIterator1 __last1,
639 _ForwardIterator2 __first2,
640 _ForwardOutIterator __result,
641 _BinaryOperation __op) {
642 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform requires ForwardIterators");
643 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform requires ForwardIterators");
644 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator, "transform requires an OutputIterator");
645 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(
646 _ForwardOutIterator, decltype(__op(*__first1, *__first2)), "transform requires an OutputIterator");
647 using _Implementation = __pstl::__dispatch<__pstl::__transform_binary, __pstl::__current_configuration, _RawPolicy>;
648 return __pstl::__handle_exception<_Implementation>(
649 std::forward<_ExecutionPolicy>(__policy),
650 std::move(__first1),
651 std::move(__last1),
652 std::move(__first2),
653 std::move(__result),
654 std::move(__op));
655}
656
657_LIBCPP_END_NAMESPACE_STD
658
659#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
660
661_LIBCPP_POP_MACROS
662
663#endif // _LIBCPP___ALGORITHM_PSTL_H
lib/libcxx/include/__algorithm/pstl_any_all_none_of.h deleted-152
......@@ -1,152 +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___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H
10#define _LIBCPP___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H
11
12#include <__algorithm/pstl_find.h>
13#include <__algorithm/pstl_frontend_dispatch.h>
14#include <__config>
15#include <__iterator/cpp17_iterator_concepts.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_execution_policy.h>
18#include <__type_traits/remove_cvref.h>
19#include <__utility/move.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33template <class>
34void __pstl_any_of(); // declaration needed for the frontend dispatch below
35
36template <class _ExecutionPolicy,
37 class _ForwardIterator,
38 class _Predicate,
39 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
40 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
41[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __any_of(
42 _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
43 return std::__pstl_frontend_dispatch(
44 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_any_of, _RawPolicy),
45 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<bool> {
46 auto __res = std::__find_if(__policy, __g_first, __g_last, __g_pred);
47 if (!__res)
48 return nullopt;
49 return *__res != __g_last;
50 },
51 std::move(__first),
52 std::move(__last),
53 std::move(__pred));
54}
55
56template <class _ExecutionPolicy,
57 class _ForwardIterator,
58 class _Predicate,
59 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
60 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
61_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
62any_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
63 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
64 auto __res = std::__any_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
65 if (!__res)
66 std::__throw_bad_alloc();
67 return *std::move(__res);
68}
69
70template <class>
71void __pstl_all_of(); // declaration needed for the frontend dispatch below
72
73template <class _ExecutionPolicy,
74 class _ForwardIterator,
75 class _Pred,
76 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
77 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
78[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
79__all_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept {
80 return std::__pstl_frontend_dispatch(
81 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_all_of, _RawPolicy),
82 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> {
83 auto __res = std::__any_of(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __value) {
84 return !__g_pred(__value);
85 });
86 if (!__res)
87 return nullopt;
88 return !*__res;
89 },
90 std::move(__first),
91 std::move(__last),
92 std::move(__pred));
93}
94
95template <class _ExecutionPolicy,
96 class _ForwardIterator,
97 class _Pred,
98 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
99 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
100_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
101all_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
102 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
103 auto __res = std::__all_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
104 if (!__res)
105 std::__throw_bad_alloc();
106 return *std::move(__res);
107}
108
109template <class>
110void __pstl_none_of(); // declaration needed for the frontend dispatch below
111
112template <class _ExecutionPolicy,
113 class _ForwardIterator,
114 class _Pred,
115 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
116 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
117[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
118__none_of(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Pred&& __pred) noexcept {
119 return std::__pstl_frontend_dispatch(
120 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_none_of, _RawPolicy),
121 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Pred __g_pred) -> optional<bool> {
122 auto __res = std::__any_of(__policy, __g_first, __g_last, __g_pred);
123 if (!__res)
124 return nullopt;
125 return !*__res;
126 },
127 std::move(__first),
128 std::move(__last),
129 std::move(__pred));
130}
131
132template <class _ExecutionPolicy,
133 class _ForwardIterator,
134 class _Pred,
135 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
136 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
137_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
138none_of(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred __pred) {
139 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
140 auto __res = std::__none_of(__policy, std::move(__first), std::move(__last), std::move(__pred));
141 if (!__res)
142 std::__throw_bad_alloc();
143 return *std::move(__res);
144}
145
146_LIBCPP_END_NAMESPACE_STD
147
148#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
149
150_LIBCPP_POP_MACROS
151
152#endif // _LIBCPP___ALGORITHM_PSTL_ANY_ALL_NONE_OF_H
lib/libcxx/include/__algorithm/pstl_backend.h deleted-232
......@@ -1,232 +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___ALGORITHM_PSTL_BACKEND_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKEND_H
11
12#include <__algorithm/pstl_backends/cpu_backend.h>
13#include <__config>
14#include <execution>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24/*
25TODO: Documentation of how backends work
26
27A PSTL parallel backend is a tag type to which the following functions are associated, at minimum:
28
29 template <class _ExecutionPolicy, class _Iterator, class _Func>
30 optional<__empty> __pstl_for_each(_Backend, _ExecutionPolicy&&, _Iterator __first, _Iterator __last, _Func __f);
31
32 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
33 optional<_Iterator> __pstl_find_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
34
35 template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
36 optional<__empty>
37 __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp);
38
39 template <class _ExecutionPolicy,
40 class _ForwardIterator1,
41 class _ForwardIterator2,
42 class _ForwardOutIterator,
43 class _Comp>
44 optional<_ForwardOutIterator> __pstl_merge(_Backend,
45 _ForwardIterator1 __first1,
46 _ForwardIterator1 __last1,
47 _ForwardIterator2 __first2,
48 _ForwardIterator2 __last2,
49 _ForwardOutIterator __result,
50 _Comp __comp);
51
52 template <class _ExecutionPolicy, class _InIterator, class _OutIterator, class _UnaryOperation>
53 optional<_OutIterator>
54 __pstl_transform(_Backend, _InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op);
55
56 template <class _ExecutionPolicy, class _InIterator1, class _InIterator2, class _OutIterator, class _BinaryOperation>
57 optional<_OutIterator> __pstl_transform(_InIterator1 __first1,
58 _InIterator2 __first2,
59 _InIterator1 __last1,
60 _OutIterator __result,
61 _BinaryOperation __op);
62
63 template <class _ExecutionPolicy,
64 class _Iterator1,
65 class _Iterator2,
66 class _Tp,
67 class _BinaryOperation1,
68 class _BinaryOperation2>
69 optional<_Tp> __pstl_transform_reduce(_Backend,
70 _Iterator1 __first1,
71 _Iterator1 __last1,
72 _Iterator2 __first2,
73 _Iterator2 __last2,
74 _Tp __init,
75 _BinaryOperation1 __reduce,
76 _BinaryOperation2 __transform);
77
78 template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
79 optional<_Tp> __pstl_transform_reduce(_Backend,
80 _Iterator __first,
81 _Iterator __last,
82 _Tp __init,
83 _BinaryOperation __reduce,
84 _UnaryOperation __transform);
85
86// TODO: Complete this list
87
88The following functions are optional but can be provided. If provided, they are used by the corresponding
89algorithms, otherwise they are implemented in terms of other algorithms. If none of the optional algorithms are
90implemented, all the algorithms will eventually forward to the basis algorithms listed above:
91
92 template <class _ExecutionPolicy, class _Iterator, class _Size, class _Func>
93 optional<__empty> __pstl_for_each_n(_Backend, _Iterator __first, _Size __n, _Func __f);
94
95 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
96 optional<bool> __pstl_any_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
97
98 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
99 optional<bool> __pstl_all_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
100
101 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
102 optional<bool> __pstl_none_of(_Backend, _Iterator __first, _iterator __last, _Predicate __pred);
103
104 template <class _ExecutionPolicy, class _Iterator, class _Tp>
105 optional<_Iterator> __pstl_find(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
106
107 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
108 optional<_Iterator> __pstl_find_if_not(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
109
110 template <class _ExecutionPolicy, class _Iterator, class _Tp>
111 optional<__empty> __pstl_fill(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
112
113 template <class _ExecutionPolicy, class _Iterator, class _SizeT, class _Tp>
114 optional<__empty> __pstl_fill_n(_Backend, _Iterator __first, _SizeT __n, const _Tp& __value);
115
116 template <class _ExecutionPolicy, class _Iterator, class _Generator>
117 optional<__empty> __pstl_generate(_Backend, _Iterator __first, _Iterator __last, _Generator __gen);
118
119 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
120 optional<__empty> __pstl_is_partitioned(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
121
122 template <class _ExecutionPolicy, class _Iterator, class _Size, class _Generator>
123 optional<__empty> __pstl_generator_n(_Backend, _Iterator __first, _Size __n, _Generator __gen);
124
125 template <class _ExecutionPolicy, class _terator1, class _Iterator2, class _OutIterator, class _Comp>
126 optional<_OutIterator> __pstl_merge(_Backend,
127 _Iterator1 __first1,
128 _Iterator1 __last1,
129 _Iterator2 __first2,
130 _Iterator2 __last2,
131 _OutIterator __result,
132 _Comp __comp);
133
134 template <class _ExecutionPolicy, class _Iterator, class _OutIterator>
135 optional<_OutIterator> __pstl_move(_Backend, _Iterator __first, _Iterator __last, _OutIterator __result);
136
137 template <class _ExecutionPolicy, class _Iterator, class _Tp, class _BinaryOperation>
138 optional<_Tp> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last, _Tp __init, _BinaryOperation __op);
139
140 temlate <class _ExecutionPolicy, class _Iterator>
141 optional<__iter_value_type<_Iterator>> __pstl_reduce(_Backend, _Iterator __first, _Iterator __last);
142
143 template <class _ExecutionPolicy, class _Iterator, class _Tp>
144 optional<__iter_diff_t<_Iterator>> __pstl_count(_Backend, _Iterator __first, _Iterator __last, const _Tp& __value);
145
146 template <class _ExecutionPolicy, class _Iterator, class _Predicate>
147 optional<__iter_diff_t<_Iterator>> __pstl_count_if(_Backend, _Iterator __first, _Iterator __last, _Predicate __pred);
148
149 template <class _ExecutionPolicy, class _Iterator, class _Tp>
150 optional<__empty>
151 __pstl_replace(_Backend, _Iterator __first, _Iterator __last, const _Tp& __old_value, const _Tp& __new_value);
152
153 template <class _ExecutionPolicy, class _Iterator, class _Pred, class _Tp>
154 optional<__empty>
155 __pstl_replace_if(_Backend, _Iterator __first, _Iterator __last, _Pred __pred, const _Tp& __new_value);
156
157 template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Tp>
158 optional<__empty> __pstl_replace_copy(_Backend,
159 _Iterator __first,
160 _Iterator __last,
161 _OutIterator __result,
162 const _Tp& __old_value,
163 const _Tp& __new_value);
164
165 template <class _ExecutionPolicy, class _Iterator, class _OutIterator, class _Pred, class _Tp>
166 optional<__empty> __pstl_replace_copy_if(_Backend,
167 _Iterator __first,
168 _Iterator __last,
169 _OutIterator __result,
170 _Pred __pred,
171 const _Tp& __new_value);
172
173 template <class _ExecutionPolicy, class _Iterator, class _OutIterator>
174 optional<_Iterator> __pstl_rotate_copy(
175 _Backend, _Iterator __first, _Iterator __middle, _Iterator __last, _OutIterator __result);
176
177 template <class _ExecutionPolicy, class _Iterator, class _Comp>
178 optional<__empty> __pstl_sort(_Backend, _Iterator __first, _Iterator __last, _Comp __comp);
179
180 template <class _ExecutionPolicy, class _Iterator1, class _Iterator2, class _Comp>
181 optional<bool> __pstl_equal(_Backend, _Iterator1 first1, _Iterator1 last1, _Iterator2 first2, _Comp __comp);
182
183// TODO: Complete this list
184
185Exception handling
186==================
187
188PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
189implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned
190into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the
191frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user.
192*/
193
194template <class _ExecutionPolicy>
195struct __select_backend;
196
197template <>
198struct __select_backend<std::execution::sequenced_policy> {
199 using type = __cpu_backend_tag;
200};
201
202# if _LIBCPP_STD_VER >= 20
203template <>
204struct __select_backend<std::execution::unsequenced_policy> {
205 using type = __cpu_backend_tag;
206};
207# endif
208
209# if defined(_LIBCPP_PSTL_CPU_BACKEND_SERIAL) || defined(_LIBCPP_PSTL_CPU_BACKEND_THREAD) || \
210 defined(_LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH)
211template <>
212struct __select_backend<std::execution::parallel_policy> {
213 using type = __cpu_backend_tag;
214};
215
216template <>
217struct __select_backend<std::execution::parallel_unsequenced_policy> {
218 using type = __cpu_backend_tag;
219};
220
221# else
222
223// ...New vendors can add parallel backends here...
224
225# error "Invalid choice of a PSTL parallel backend"
226# endif
227
228_LIBCPP_END_NAMESPACE_STD
229
230#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
231
232#endif // _LIBCPP___ALGORITHM_PSTL_BACKEND_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backend.h deleted-68
......@@ -1,68 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
11
12#include <__config>
13
14/*
15
16 // _Functor takes a subrange for [__first, __last) that should be executed in serial
17 template <class _RandomAccessIterator, class _Functor>
18 optional<__empty> __parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
19
20 template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction>
21 optional<_Tp>
22 __parallel_transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction);
23
24 // Cancel the execution of other jobs - they aren't needed anymore
25 void __cancel_execution();
26
27 template <class _RandomAccessIterator1,
28 class _RandomAccessIterator2,
29 class _RandomAccessIterator3,
30 class _Compare,
31 class _LeafMerge>
32 optional<void> __parallel_merge(
33 _RandomAccessIterator1 __first1,
34 _RandomAccessIterator1 __last1,
35 _RandomAccessIterator2 __first2,
36 _RandomAccessIterator2 __last2,
37 _RandomAccessIterator3 __outit,
38 _Compare __comp,
39 _LeafMerge __leaf_merge);
40
41 template <class _RandomAccessIterator, class _Comp, class _LeafSort>
42 void __parallel_stable_sort(_RandomAccessIterator __first,
43 _RandomAccessIterator __last,
44 _Comp __comp,
45 _LeafSort __leaf_sort);
46
47 TODO: Document the parallel backend
48
49Exception handling
50==================
51
52CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
53implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are turned
54into a program termination at the front-end level. When a backend returns a disengaged `optional` to the frontend, the
55frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to the user.
56*/
57
58#include <__algorithm/pstl_backends/cpu_backends/any_of.h>
59#include <__algorithm/pstl_backends/cpu_backends/backend.h>
60#include <__algorithm/pstl_backends/cpu_backends/fill.h>
61#include <__algorithm/pstl_backends/cpu_backends/find_if.h>
62#include <__algorithm/pstl_backends/cpu_backends/for_each.h>
63#include <__algorithm/pstl_backends/cpu_backends/merge.h>
64#include <__algorithm/pstl_backends/cpu_backends/stable_sort.h>
65#include <__algorithm/pstl_backends/cpu_backends/transform.h>
66#include <__algorithm/pstl_backends/cpu_backends/transform_reduce.h>
67
68#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/any_of.h deleted-98
......@@ -1,98 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
11
12#include <__algorithm/any_of.h>
13#include <__algorithm/find_if.h>
14#include <__algorithm/pstl_backends/cpu_backends/backend.h>
15#include <__atomic/atomic.h>
16#include <__atomic/memory_order.h>
17#include <__config>
18#include <__functional/operations.h>
19#include <__iterator/concepts.h>
20#include <__type_traits/is_execution_policy.h>
21#include <__utility/move.h>
22#include <__utility/pair.h>
23#include <cstdint>
24#include <optional>
25
26#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27
28_LIBCPP_PUSH_MACROS
29# include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33template <class _Index, class _Brick>
34_LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) {
35 std::atomic<bool> __found(false);
36 auto __ret = __par_backend::__parallel_for(__first, __last, [__f, &__found](_Index __i, _Index __j) {
37 if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) {
38 __found.store(true, std::memory_order_relaxed);
39 __par_backend::__cancel_execution();
40 }
41 });
42 if (!__ret)
43 return nullopt;
44 return static_cast<bool>(__found);
45}
46
47// TODO: check whether __simd_first() can be used here
48template <class _Index, class _DifferenceType, class _Pred>
49_LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept {
50 _DifferenceType __block_size = 4 < __n ? 4 : __n;
51 const _Index __last = __first + __n;
52 while (__last != __first) {
53 int32_t __flag = 1;
54 _PSTL_PRAGMA_SIMD_REDUCTION(& : __flag)
55 for (_DifferenceType __i = 0; __i < __block_size; ++__i)
56 if (__pred(*(__first + __i)))
57 __flag = 0;
58 if (!__flag)
59 return true;
60
61 __first += __block_size;
62 if (__last - __first >= __block_size << 1) {
63 // Double the block _Size. Any unnecessary iterations can be amortized against work done so far.
64 __block_size <<= 1;
65 } else {
66 __block_size = __last - __first;
67 }
68 }
69 return false;
70}
71
72template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate>
73_LIBCPP_HIDE_FROM_ABI optional<bool>
74__pstl_any_of(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
75 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
76 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
77 return std::__parallel_or(
78 __first, __last, [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
79 auto __res = std::__pstl_any_of<__remove_parallel_policy_t<_ExecutionPolicy>>(
80 __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
81 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
82 return *std::move(__res);
83 });
84 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
85 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
86 return std::__simd_or(__first, __last - __first, __pred);
87 } else {
88 return std::any_of(__first, __last, __pred);
89 }
90}
91
92_LIBCPP_END_NAMESPACE_STD
93
94_LIBCPP_POP_MACROS
95
96#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
97
98#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_ANY_OF_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h deleted-41
......@@ -1,41 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H
11
12#include <__config>
13#include <cstddef>
14
15#if defined(_LIBCPP_PSTL_CPU_BACKEND_SERIAL)
16# include <__algorithm/pstl_backends/cpu_backends/serial.h>
17#elif defined(_LIBCPP_PSTL_CPU_BACKEND_THREAD)
18# include <__algorithm/pstl_backends/cpu_backends/thread.h>
19#elif defined(_LIBCPP_PSTL_CPU_BACKEND_LIBDISPATCH)
20# include <__algorithm/pstl_backends/cpu_backends/libdispatch.h>
21#else
22# error "Invalid CPU backend choice"
23#endif
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if _LIBCPP_STD_VER >= 17
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33struct __cpu_backend_tag {};
34
35inline constexpr size_t __lane_size = 64;
36
37_LIBCPP_END_NAMESPACE_STD
38
39#endif // _LIBCPP_STD_VER >= 17
40
41#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKEND_BACKEND_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/fill.h deleted-62
......@@ -1,62 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
11
12#include <__algorithm/fill.h>
13#include <__algorithm/pstl_backends/cpu_backends/backend.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__utility/empty.h>
18#include <optional>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _Index, class _DifferenceType, class _Tp>
29_LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n, const _Tp& __value) noexcept {
30 _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
31 _PSTL_PRAGMA_SIMD
32 for (_DifferenceType __i = 0; __i < __n; ++__i)
33 __first[__i] = __value;
34 return __first + __n;
35}
36
37template <class _ExecutionPolicy, class _ForwardIterator, class _Tp>
38_LIBCPP_HIDE_FROM_ABI optional<__empty>
39__pstl_fill(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
40 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
41 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
42 return __par_backend::__parallel_for(
43 __first, __last, [&__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
44 [[maybe_unused]] auto __res = std::__pstl_fill<__remove_parallel_policy_t<_ExecutionPolicy>>(
45 __cpu_backend_tag{}, __brick_first, __brick_last, __value);
46 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
47 });
48 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
49 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
50 std::__simd_fill_n(__first, __last - __first, __value);
51 return __empty{};
52 } else {
53 std::fill(__first, __last, __value);
54 return __empty{};
55 }
56}
57
58_LIBCPP_END_NAMESPACE_STD
59
60#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
61
62#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FILL_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/find_if.h deleted-133
......@@ -1,133 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
11
12#include <__algorithm/find_if.h>
13#include <__algorithm/pstl_backends/cpu_backends/backend.h>
14#include <__atomic/atomic.h>
15#include <__config>
16#include <__functional/operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__type_traits/is_execution_policy.h>
20#include <__utility/move.h>
21#include <__utility/pair.h>
22#include <cstddef>
23#include <optional>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
30
31_LIBCPP_PUSH_MACROS
32# include <__undef_macros>
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36template <class _Index, class _Brick, class _Compare>
37_LIBCPP_HIDE_FROM_ABI optional<_Index>
38__parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) {
39 typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType;
40 const _DifferenceType __n = __last - __first;
41 _DifferenceType __initial_dist = __b_first ? __n : -1;
42 std::atomic<_DifferenceType> __extremum(__initial_dist);
43 // TODO: find out what is better here: parallel_for or parallel_reduce
44 auto __res =
45 __par_backend::__parallel_for(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
46 // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
47 // why using a shared variable scales fairly well in this situation.
48 if (__comp(__i - __first, __extremum)) {
49 _Index __result = __f(__i, __j);
50 // If not '__last' returned then we found what we want so put this to extremum
51 if (__result != __j) {
52 const _DifferenceType __k = __result - __first;
53 for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) {
54 __extremum.compare_exchange_weak(__old, __k);
55 }
56 }
57 }
58 });
59 if (!__res)
60 return nullopt;
61 return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last;
62}
63
64template <class _Index, class _DifferenceType, class _Compare>
65_LIBCPP_HIDE_FROM_ABI _Index
66__simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept {
67 // Experiments show good block sizes like this
68 const _DifferenceType __block_size = 8;
69 alignas(__lane_size) _DifferenceType __lane[__block_size] = {0};
70 while (__end - __begin >= __block_size) {
71 _DifferenceType __found = 0;
72 _PSTL_PRAGMA_SIMD_REDUCTION(| : __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size; ++__i) {
73 const _DifferenceType __t = __comp(__first, __i);
74 __lane[__i - __begin] = __t;
75 __found |= __t;
76 }
77 if (__found) {
78 _DifferenceType __i;
79 // This will vectorize
80 for (__i = 0; __i < __block_size; ++__i) {
81 if (__lane[__i]) {
82 break;
83 }
84 }
85 return __first + __begin + __i;
86 }
87 __begin += __block_size;
88 }
89
90 // Keep remainder scalar
91 while (__begin != __end) {
92 if (__comp(__first, __begin)) {
93 return __first + __begin;
94 }
95 ++__begin;
96 }
97 return __first + __end;
98}
99
100template <class _ExecutionPolicy, class _ForwardIterator, class _Predicate>
101_LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
102__pstl_find_if(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
103 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
104 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
105 return std::__parallel_find(
106 __first,
107 __last,
108 [&__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
109 auto __res = std::__pstl_find_if<__remove_parallel_policy_t<_ExecutionPolicy>>(
110 __cpu_backend_tag{}, __brick_first, __brick_last, __pred);
111 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
112 return *std::move(__res);
113 },
114 less<>{},
115 true);
116 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
117 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
118 using __diff_t = __iter_diff_t<_ForwardIterator>;
119 return std::__simd_first(__first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) {
120 return __pred(__iter[__i]);
121 });
122 } else {
123 return std::find_if(__first, __last, __pred);
124 }
125}
126
127_LIBCPP_END_NAMESPACE_STD
128
129_LIBCPP_POP_MACROS
130
131#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
132
133#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_FIND_IF_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/for_each.h deleted-62
......@@ -1,62 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
11
12#include <__algorithm/for_each.h>
13#include <__algorithm/pstl_backends/cpu_backends/backend.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__utility/empty.h>
18#include <optional>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28template <class _Iterator, class _DifferenceType, class _Function>
29_LIBCPP_HIDE_FROM_ABI _Iterator __simd_walk(_Iterator __first, _DifferenceType __n, _Function __f) noexcept {
30 _PSTL_PRAGMA_SIMD
31 for (_DifferenceType __i = 0; __i < __n; ++__i)
32 __f(__first[__i]);
33
34 return __first + __n;
35}
36
37template <class _ExecutionPolicy, class _ForwardIterator, class _Functor>
38_LIBCPP_HIDE_FROM_ABI optional<__empty>
39__pstl_for_each(__cpu_backend_tag, _ForwardIterator __first, _ForwardIterator __last, _Functor __func) {
40 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
41 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
42 return std::__par_backend::__parallel_for(
43 __first, __last, [__func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
44 [[maybe_unused]] auto __res = std::__pstl_for_each<__remove_parallel_policy_t<_ExecutionPolicy>>(
45 __cpu_backend_tag{}, __brick_first, __brick_last, __func);
46 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
47 });
48 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
49 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
50 std::__simd_walk(__first, __last - __first, __func);
51 return __empty{};
52 } else {
53 std::for_each(__first, __last, __func);
54 return __empty{};
55 }
56}
57
58_LIBCPP_END_NAMESPACE_STD
59
60#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
61
62#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKNEDS_FOR_EACH_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/libdispatch.h deleted-347
......@@ -1,347 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H
11
12#include <__algorithm/inplace_merge.h>
13#include <__algorithm/lower_bound.h>
14#include <__algorithm/max.h>
15#include <__algorithm/merge.h>
16#include <__algorithm/upper_bound.h>
17#include <__atomic/atomic.h>
18#include <__config>
19#include <__exception/terminate.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/move_iterator.h>
22#include <__memory/allocator.h>
23#include <__memory/construct_at.h>
24#include <__memory/unique_ptr.h>
25#include <__numeric/reduce.h>
26#include <__utility/empty.h>
27#include <__utility/exception_guard.h>
28#include <__utility/move.h>
29#include <__utility/pair.h>
30#include <cstddef>
31#include <new>
32#include <optional>
33
34_LIBCPP_PUSH_MACROS
35#include <__undef_macros>
36
37#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
38
39_LIBCPP_BEGIN_NAMESPACE_STD
40
41namespace __par_backend {
42inline namespace __libdispatch {
43
44// ::dispatch_apply is marked as __attribute__((nothrow)) because it doesn't let exceptions propagate, and neither do
45// we.
46// TODO: Do we want to add [[_Clang::__callback__(__func, __context, __)]]?
47_LIBCPP_EXPORTED_FROM_ABI void
48__dispatch_apply(size_t __chunk_count, void* __context, void (*__func)(void* __context, size_t __chunk)) noexcept;
49
50template <class _Func>
51_LIBCPP_HIDE_FROM_ABI void __dispatch_apply(size_t __chunk_count, _Func __func) noexcept {
52 __libdispatch::__dispatch_apply(__chunk_count, &__func, [](void* __context, size_t __chunk) {
53 (*static_cast<_Func*>(__context))(__chunk);
54 });
55}
56
57struct __chunk_partitions {
58 ptrdiff_t __chunk_count_; // includes the first chunk
59 ptrdiff_t __chunk_size_;
60 ptrdiff_t __first_chunk_size_;
61};
62
63[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept;
64
65template <class _RandomAccessIterator, class _Functor>
66_LIBCPP_HIDE_FROM_ABI optional<__empty>
67__dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) {
68 // Perform the chunked execution.
69 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) {
70 auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_;
71 auto __index =
72 __chunk == 0
73 ? 0
74 : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_);
75 __func(__first + __index, __first + __index + __this_chunk_size);
76 });
77
78 return __empty{};
79}
80
81template <class _RandomAccessIterator, class _Functor>
82_LIBCPP_HIDE_FROM_ABI optional<__empty>
83__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
84 return __libdispatch::__dispatch_parallel_for(
85 __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func));
86}
87
88template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut>
89struct __merge_range {
90 __merge_range(_RandomAccessIterator1 __mid1, _RandomAccessIterator2 __mid2, _RandomAccessIteratorOut __result)
91 : __mid1_(__mid1), __mid2_(__mid2), __result_(__result) {}
92
93 _RandomAccessIterator1 __mid1_;
94 _RandomAccessIterator2 __mid2_;
95 _RandomAccessIteratorOut __result_;
96};
97
98template <typename _RandomAccessIterator1,
99 typename _RandomAccessIterator2,
100 typename _RandomAccessIterator3,
101 typename _Compare,
102 typename _LeafMerge>
103_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
104 _RandomAccessIterator1 __first1,
105 _RandomAccessIterator1 __last1,
106 _RandomAccessIterator2 __first2,
107 _RandomAccessIterator2 __last2,
108 _RandomAccessIterator3 __result,
109 _Compare __comp,
110 _LeafMerge __leaf_merge) noexcept {
111 __chunk_partitions __partitions =
112 __libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2));
113
114 if (__partitions.__chunk_count_ == 0)
115 return __empty{};
116
117 if (__partitions.__chunk_count_ == 1) {
118 __leaf_merge(__first1, __last1, __first2, __last2, __result, __comp);
119 return __empty{};
120 }
121
122 using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>;
123 auto const __n_ranges = __partitions.__chunk_count_ + 1;
124
125 // TODO: use __uninitialized_buffer
126 auto __destroy = [=](__merge_range_t* __ptr) {
127 std::destroy_n(__ptr, __n_ranges);
128 std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges);
129 };
130
131 unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
132 [&]() -> __merge_range_t* {
133# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
134 try {
135# endif
136 return std::allocator<__merge_range_t>().allocate(__n_ranges);
137# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
138 } catch (const std::bad_alloc&) {
139 return nullptr;
140 }
141# endif
142 }(),
143 __destroy);
144
145 if (!__ranges)
146 return nullopt;
147
148 // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case
149 __merge_range_t* __r = __ranges.get();
150 std::__construct_at(__r++, __first1, __first2, __result);
151
152 bool __iterate_first_range = __last1 - __first1 > __last2 - __first2;
153
154 auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t {
155 auto [__mid1, __mid2] = [&] {
156 if (__iterate_first_range) {
157 auto __m1 = __first1 + __chunk_size;
158 auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp);
159 return std::make_pair(__m1, __m2);
160 } else {
161 auto __m2 = __first2 + __chunk_size;
162 auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp);
163 return std::make_pair(__m1, __m2);
164 }
165 }();
166
167 __result += (__mid1 - __first1) + (__mid2 - __first2);
168 __first1 = __mid1;
169 __first2 = __mid2;
170 return {std::move(__mid1), std::move(__mid2), __result};
171 };
172
173 // handle first chunk
174 std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_));
175
176 // handle 2 -> N - 1 chunks
177 for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i)
178 std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_));
179
180 // handle last chunk
181 std::__construct_at(__r, __last1, __last2, __result);
182
183 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) {
184 auto __first_iters = __ranges[__index];
185 auto __last_iters = __ranges[__index + 1];
186 __leaf_merge(
187 __first_iters.__mid1_,
188 __last_iters.__mid1_,
189 __first_iters.__mid2_,
190 __last_iters.__mid2_,
191 __first_iters.__result_,
192 __comp);
193 });
194
195 return __empty{};
196}
197
198template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction>
199_LIBCPP_HIDE_FROM_ABI optional<_Value> __parallel_transform_reduce(
200 _RandomAccessIterator __first,
201 _RandomAccessIterator __last,
202 _Transform __transform,
203 _Value __init,
204 _Combiner __combiner,
205 _Reduction __reduction) {
206 if (__first == __last)
207 return __init;
208
209 auto __partitions = __libdispatch::__partition_chunks(__last - __first);
210
211 auto __destroy = [__count = __partitions.__chunk_count_](_Value* __ptr) {
212 std::destroy_n(__ptr, __count);
213 std::allocator<_Value>().deallocate(__ptr, __count);
214 };
215
216 // TODO: use __uninitialized_buffer
217 // TODO: allocate one element per worker instead of one element per chunk
218 unique_ptr<_Value[], decltype(__destroy)> __values(
219 std::allocator<_Value>().allocate(__partitions.__chunk_count_), __destroy);
220
221 // __dispatch_apply is noexcept
222 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) {
223 auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_;
224 auto __index =
225 __chunk == 0
226 ? 0
227 : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_);
228 if (__this_chunk_size != 1) {
229 std::__construct_at(
230 __values.get() + __chunk,
231 __reduction(__first + __index + 2,
232 __first + __index + __this_chunk_size,
233 __combiner(__transform(__first + __index), __transform(__first + __index + 1))));
234 } else {
235 std::__construct_at(__values.get() + __chunk, __transform(__first + __index));
236 }
237 });
238
239 return std::reduce(
240 std::make_move_iterator(__values.get()),
241 std::make_move_iterator(__values.get() + __partitions.__chunk_count_),
242 std::move(__init),
243 __combiner);
244}
245
246template <class _RandomAccessIterator, class _Comp, class _LeafSort>
247_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
248 _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) {
249 const auto __size = __last - __first;
250 auto __partitions = __libdispatch::__partition_chunks(__size);
251
252 if (__partitions.__chunk_count_ == 0)
253 return __empty{};
254
255 if (__partitions.__chunk_count_ == 1) {
256 __leaf_sort(__first, __last, __comp);
257 return __empty{};
258 }
259
260 using _Value = __iter_value_type<_RandomAccessIterator>;
261
262 auto __destroy = [__size](_Value* __ptr) {
263 std::destroy_n(__ptr, __size);
264 std::allocator<_Value>().deallocate(__ptr, __size);
265 };
266
267 // TODO: use __uninitialized_buffer
268 unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy);
269
270 // Initialize all elements to a moved-from state
271 // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928
272 std::__construct_at(__values.get(), std::move(*__first));
273 for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) {
274 std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1]));
275 }
276 *__first = std::move(__values.get()[__size - 1]);
277
278 __libdispatch::__dispatch_parallel_for(
279 __partitions,
280 __first,
281 [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) {
282 __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp);
283 });
284
285 bool __objects_are_in_buffer = false;
286 do {
287 const auto __old_chunk_size = __partitions.__chunk_size_;
288 if (__partitions.__chunk_count_ % 2 == 1) {
289 auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) {
290 std::inplace_merge(
291 __first_chunk_begin,
292 __first_chunk_begin + __partitions.__first_chunk_size_,
293 __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_,
294 __comp);
295 };
296 if (__objects_are_in_buffer)
297 __inplace_merge_chunks(__values.get());
298 else
299 __inplace_merge_chunks(__first);
300 __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_;
301 } else {
302 __partitions.__first_chunk_size_ += __partitions.__chunk_size_;
303 }
304
305 __partitions.__chunk_size_ *= 2;
306 __partitions.__chunk_count_ /= 2;
307
308 auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) {
309 __libdispatch::__dispatch_parallel_for(
310 __partitions,
311 __from_first,
312 [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) {
313 std::merge(std::make_move_iterator(__chunk_first),
314 std::make_move_iterator(__chunk_last - __old_chunk_size),
315 std::make_move_iterator(__chunk_last - __old_chunk_size),
316 std::make_move_iterator(__chunk_last),
317 __to_first + (__chunk_first - __from_first),
318 __comp);
319 });
320 };
321
322 if (__objects_are_in_buffer)
323 __merge_chunks(__values.get(), __first);
324 else
325 __merge_chunks(__first, __values.get());
326 __objects_are_in_buffer = !__objects_are_in_buffer;
327 } while (__partitions.__chunk_count_ > 1);
328
329 if (__objects_are_in_buffer) {
330 std::move(__values.get(), __values.get() + __size, __first);
331 }
332
333 return __empty{};
334}
335
336_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
337
338} // namespace __libdispatch
339} // namespace __par_backend
340
341_LIBCPP_END_NAMESPACE_STD
342
343#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
344
345_LIBCPP_POP_MACROS
346
347#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_LIBDISPATCH_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/merge.h deleted-85
......@@ -1,85 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
11
12#include <__algorithm/merge.h>
13#include <__algorithm/pstl_backends/cpu_backends/backend.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__utility/move.h>
18#include <optional>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
25
26_LIBCPP_PUSH_MACROS
27# include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31template <class _ExecutionPolicy,
32 class _ForwardIterator1,
33 class _ForwardIterator2,
34 class _ForwardOutIterator,
35 class _Comp>
36_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_merge(
37 __cpu_backend_tag,
38 _ForwardIterator1 __first1,
39 _ForwardIterator1 __last1,
40 _ForwardIterator2 __first2,
41 _ForwardIterator2 __last2,
42 _ForwardOutIterator __result,
43 _Comp __comp) {
44 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
45 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
46 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
47 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
48 auto __res = __par_backend::__parallel_merge(
49 __first1,
50 __last1,
51 __first2,
52 __last2,
53 __result,
54 __comp,
55 [](_ForwardIterator1 __g_first1,
56 _ForwardIterator1 __g_last1,
57 _ForwardIterator2 __g_first2,
58 _ForwardIterator2 __g_last2,
59 _ForwardOutIterator __g_result,
60 _Comp __g_comp) {
61 [[maybe_unused]] auto __g_res = std::__pstl_merge<__remove_parallel_policy_t<_ExecutionPolicy>>(
62 __cpu_backend_tag{},
63 std::move(__g_first1),
64 std::move(__g_last1),
65 std::move(__g_first2),
66 std::move(__g_last2),
67 std::move(__g_result),
68 std::move(__g_comp));
69 _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!");
70 });
71 if (!__res)
72 return nullopt;
73 return __result + (__last1 - __first1) + (__last2 - __first2);
74 } else {
75 return std::merge(__first1, __last1, __first2, __last2, __result, __comp);
76 }
77}
78
79_LIBCPP_END_NAMESPACE_STD
80
81_LIBCPP_POP_MACROS
82
83#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
84
85#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_MERGE_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/serial.h deleted-83
......@@ -1,83 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
11#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
12
13#include <__config>
14#include <__utility/empty.h>
15#include <__utility/move.h>
16#include <cstddef>
17#include <optional>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
24
25_LIBCPP_PUSH_MACROS
26# include <__undef_macros>
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace __par_backend {
31inline namespace __serial_cpu_backend {
32
33template <class _RandomAccessIterator, class _Fp>
34_LIBCPP_HIDE_FROM_ABI optional<__empty>
35__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
36 __f(__first, __last);
37 return __empty{};
38}
39
40template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
41_LIBCPP_HIDE_FROM_ABI optional<_Tp>
42__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
43 return __reduce(std::move(__first), std::move(__last), std::move(__init));
44}
45
46template <class _RandomAccessIterator, class _Compare, class _LeafSort>
47_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
48 _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
49 __leaf_sort(__first, __last, __comp);
50 return __empty{};
51}
52
53_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
54
55template <class _RandomAccessIterator1,
56 class _RandomAccessIterator2,
57 class _RandomAccessIterator3,
58 class _Compare,
59 class _LeafMerge>
60_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
61 _RandomAccessIterator1 __first1,
62 _RandomAccessIterator1 __last1,
63 _RandomAccessIterator2 __first2,
64 _RandomAccessIterator2 __last2,
65 _RandomAccessIterator3 __outit,
66 _Compare __comp,
67 _LeafMerge __leaf_merge) {
68 __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
69 return __empty{};
70}
71
72// TODO: Complete this list
73
74} // namespace __serial_cpu_backend
75} // namespace __par_backend
76
77_LIBCPP_END_NAMESPACE_STD
78
79_LIBCPP_POP_MACROS
80
81#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
82
83#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_SERIAL_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/stable_sort.h deleted-45
......@@ -1,45 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
11
12#include <__algorithm/pstl_backends/cpu_backends/backend.h>
13#include <__algorithm/stable_sort.h>
14#include <__config>
15#include <__type_traits/is_execution_policy.h>
16#include <__utility/empty.h>
17#include <optional>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
28_LIBCPP_HIDE_FROM_ABI optional<__empty>
29__pstl_stable_sort(__cpu_backend_tag, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
30 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy>) {
31 return __par_backend::__parallel_stable_sort(
32 __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
33 std::stable_sort(__g_first, __g_last, __g_comp);
34 });
35 } else {
36 std::stable_sort(__first, __last, __comp);
37 return __empty{};
38 }
39}
40
41_LIBCPP_END_NAMESPACE_STD
42
43#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
44
45#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_STABLE_SORT_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/thread.h deleted-84
......@@ -1,84 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H
11
12#include <__assert>
13#include <__config>
14#include <__utility/empty.h>
15#include <__utility/move.h>
16#include <cstddef>
17#include <optional>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
26#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27
28// This backend implementation is for testing purposes only and not meant for production use. This will be replaced
29// by a proper implementation once the PSTL implementation is somewhat stable.
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33namespace __par_backend {
34inline namespace __thread_cpu_backend {
35
36template <class _RandomAccessIterator, class _Fp>
37_LIBCPP_HIDE_FROM_ABI optional<__empty>
38__parallel_for(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
39 __f(__first, __last);
40 return __empty{};
41}
42
43template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
44_LIBCPP_HIDE_FROM_ABI optional<_Tp>
45__parallel_transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
46 return __reduce(std::move(__first), std::move(__last), std::move(__init));
47}
48
49template <class _RandomAccessIterator, class _Compare, class _LeafSort>
50_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_stable_sort(
51 _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
52 __leaf_sort(__first, __last, __comp);
53 return __empty{};
54}
55
56_LIBCPP_HIDE_FROM_ABI inline void __cancel_execution() {}
57
58template <class _RandomAccessIterator1,
59 class _RandomAccessIterator2,
60 class _RandomAccessIterator3,
61 class _Compare,
62 class _LeafMerge>
63_LIBCPP_HIDE_FROM_ABI optional<__empty> __parallel_merge(
64 _RandomAccessIterator1 __first1,
65 _RandomAccessIterator1 __last1,
66 _RandomAccessIterator2 __first2,
67 _RandomAccessIterator2 __last2,
68 _RandomAccessIterator3 __outit,
69 _Compare __comp,
70 _LeafMerge __leaf_merge) {
71 __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
72 return __empty{};
73}
74
75} // namespace __thread_cpu_backend
76} // namespace __par_backend
77
78_LIBCPP_END_NAMESPACE_STD
79
80#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && && _LIBCPP_STD_VER >= 17
81
82_LIBCPP_POP_MACROS
83
84#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_THREAD_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform.h deleted-138
......@@ -1,138 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
11
12#include <__algorithm/pstl_backends/cpu_backends/backend.h>
13#include <__algorithm/transform.h>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/iterator_traits.h>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__type_traits/remove_cvref.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27
28_LIBCPP_PUSH_MACROS
29# include <__undef_macros>
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function>
34_LIBCPP_HIDE_FROM_ABI _Iterator2
35__simd_walk(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept {
36 _PSTL_PRAGMA_SIMD
37 for (_DifferenceType __i = 0; __i < __n; ++__i)
38 __f(__first1[__i], __first2[__i]);
39 return __first2 + __n;
40}
41
42template <class _ExecutionPolicy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
43_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
44 __cpu_backend_tag,
45 _ForwardIterator __first,
46 _ForwardIterator __last,
47 _ForwardOutIterator __result,
48 _UnaryOperation __op) {
49 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
50 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
51 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
52 std::__par_backend::__parallel_for(
53 __first, __last, [__op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
54 auto __res = std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
55 __cpu_backend_tag{}, __brick_first, __brick_last, __result + (__brick_first - __first), __op);
56 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
57 return *std::move(__res);
58 });
59 return __result + (__last - __first);
60 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
61 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
62 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
63 return std::__simd_walk(
64 __first,
65 __last - __first,
66 __result,
67 [&](__iter_reference<_ForwardIterator> __in_value, __iter_reference<_ForwardOutIterator> __out_value) {
68 __out_value = __op(__in_value);
69 });
70 } else {
71 return std::transform(__first, __last, __result, __op);
72 }
73}
74
75template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function>
76_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_walk(
77 _Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept {
78 _PSTL_PRAGMA_SIMD
79 for (_DifferenceType __i = 0; __i < __n; ++__i)
80 __f(__first1[__i], __first2[__i], __first3[__i]);
81 return __first3 + __n;
82}
83template <class _ExecutionPolicy,
84 class _ForwardIterator1,
85 class _ForwardIterator2,
86 class _ForwardOutIterator,
87 class _BinaryOperation,
88 enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
89_LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __pstl_transform(
90 __cpu_backend_tag,
91 _ForwardIterator1 __first1,
92 _ForwardIterator1 __last1,
93 _ForwardIterator2 __first2,
94 _ForwardOutIterator __result,
95 _BinaryOperation __op) {
96 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
97 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
98 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
99 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
100 auto __res = std::__par_backend::__parallel_for(
101 __first1,
102 __last1,
103 [__op, __first1, __first2, __result](_ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) {
104 return std::__pstl_transform<__remove_parallel_policy_t<_ExecutionPolicy>>(
105 __cpu_backend_tag{},
106 __brick_first,
107 __brick_last,
108 __first2 + (__brick_first - __first1),
109 __result + (__brick_first - __first1),
110 __op);
111 });
112 if (!__res)
113 return nullopt;
114 return __result + (__last1 - __first1);
115 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
116 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
117 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
118 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
119 return std::__simd_walk(
120 __first1,
121 __last1 - __first1,
122 __first2,
123 __result,
124 [&](__iter_reference<_ForwardIterator1> __in1,
125 __iter_reference<_ForwardIterator2> __in2,
126 __iter_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); });
127 } else {
128 return std::transform(__first1, __last1, __first2, __result, __op);
129 }
130}
131
132_LIBCPP_END_NAMESPACE_STD
133
134_LIBCPP_POP_MACROS
135
136#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
137
138#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_H
lib/libcxx/include/__algorithm/pstl_backends/cpu_backends/transform_reduce.h deleted-202
......@@ -1,202 +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___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
10#define _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
11
12#include <__algorithm/pstl_backends/cpu_backends/backend.h>
13#include <__config>
14#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>
16#include <__numeric/transform_reduce.h>
17#include <__type_traits/is_arithmetic.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__type_traits/operation_traits.h>
20#include <__utility/move.h>
21#include <new>
22#include <optional>
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 !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35template <typename _DifferenceType,
36 typename _Tp,
37 typename _BinaryOperation,
38 typename _UnaryOperation,
39 typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>,
40 __enable_if_t<__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value && is_arithmetic_v<_Tp> &&
41 is_arithmetic_v<_UnaryResult>,
42 int> = 0>
43_LIBCPP_HIDE_FROM_ABI _Tp
44__simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept {
45 _PSTL_PRAGMA_SIMD_REDUCTION(+ : __init)
46 for (_DifferenceType __i = 0; __i < __n; ++__i)
47 __init += __f(__i);
48 return __init;
49}
50
51template <typename _Size,
52 typename _Tp,
53 typename _BinaryOperation,
54 typename _UnaryOperation,
55 typename _UnaryResult = invoke_result_t<_UnaryOperation, _Size>,
56 __enable_if_t<!(__desugars_to<__plus_tag, _BinaryOperation, _Tp, _UnaryResult>::value &&
57 is_arithmetic_v<_Tp> && is_arithmetic_v<_UnaryResult>),
58 int> = 0>
59_LIBCPP_HIDE_FROM_ABI _Tp
60__simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _UnaryOperation __f) noexcept {
61 const _Size __block_size = __lane_size / sizeof(_Tp);
62 if (__n > 2 * __block_size && __block_size > 1) {
63 alignas(__lane_size) char __lane_buffer[__lane_size];
64 _Tp* __lane = reinterpret_cast<_Tp*>(__lane_buffer);
65
66 // initializer
67 _PSTL_PRAGMA_SIMD
68 for (_Size __i = 0; __i < __block_size; ++__i) {
69 ::new (__lane + __i) _Tp(__binary_op(__f(__i), __f(__block_size + __i)));
70 }
71 // main loop
72 _Size __i = 2 * __block_size;
73 const _Size __last_iteration = __block_size * (__n / __block_size);
74 for (; __i < __last_iteration; __i += __block_size) {
75 _PSTL_PRAGMA_SIMD
76 for (_Size __j = 0; __j < __block_size; ++__j) {
77 __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__i + __j));
78 }
79 }
80 // remainder
81 _PSTL_PRAGMA_SIMD
82 for (_Size __j = 0; __j < __n - __last_iteration; ++__j) {
83 __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__last_iteration + __j));
84 }
85 // combiner
86 for (_Size __j = 0; __j < __block_size; ++__j) {
87 __init = __binary_op(std::move(__init), std::move(__lane[__j]));
88 }
89 // destroyer
90 _PSTL_PRAGMA_SIMD
91 for (_Size __j = 0; __j < __block_size; ++__j) {
92 __lane[__j].~_Tp();
93 }
94 } else {
95 for (_Size __i = 0; __i < __n; ++__i) {
96 __init = __binary_op(std::move(__init), __f(__i));
97 }
98 }
99 return __init;
100}
101
102template <class _ExecutionPolicy,
103 class _ForwardIterator1,
104 class _ForwardIterator2,
105 class _Tp,
106 class _BinaryOperation1,
107 class _BinaryOperation2>
108_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce(
109 __cpu_backend_tag,
110 _ForwardIterator1 __first1,
111 _ForwardIterator1 __last1,
112 _ForwardIterator2 __first2,
113 _Tp __init,
114 _BinaryOperation1 __reduce,
115 _BinaryOperation2 __transform) {
116 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
117 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
118 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
119 return __par_backend::__parallel_transform_reduce(
120 __first1,
121 std::move(__last1),
122 [__first1, __first2, __transform](_ForwardIterator1 __iter) {
123 return __transform(*__iter, *(__first2 + (__iter - __first1)));
124 },
125 std::move(__init),
126 std::move(__reduce),
127 [__first1, __first2, __reduce, __transform](
128 _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) {
129 return *std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
130 __cpu_backend_tag{},
131 __brick_first,
132 std::move(__brick_last),
133 __first2 + (__brick_first - __first1),
134 std::move(__brick_init),
135 std::move(__reduce),
136 std::move(__transform));
137 });
138 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
139 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
140 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
141 return std::__simd_transform_reduce(
142 __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) {
143 return __transform(__first1[__i], __first2[__i]);
144 });
145 } else {
146 return std::transform_reduce(
147 std::move(__first1),
148 std::move(__last1),
149 std::move(__first2),
150 std::move(__init),
151 std::move(__reduce),
152 std::move(__transform));
153 }
154}
155
156template <class _ExecutionPolicy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
157_LIBCPP_HIDE_FROM_ABI optional<_Tp> __pstl_transform_reduce(
158 __cpu_backend_tag,
159 _ForwardIterator __first,
160 _ForwardIterator __last,
161 _Tp __init,
162 _BinaryOperation __reduce,
163 _UnaryOperation __transform) {
164 if constexpr (__is_parallel_execution_policy_v<_ExecutionPolicy> &&
165 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
166 return __par_backend::__parallel_transform_reduce(
167 std::move(__first),
168 std::move(__last),
169 [__transform](_ForwardIterator __iter) { return __transform(*__iter); },
170 std::move(__init),
171 __reduce,
172 [__transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) {
173 auto __res = std::__pstl_transform_reduce<__remove_parallel_policy_t<_ExecutionPolicy>>(
174 __cpu_backend_tag{},
175 std::move(__brick_first),
176 std::move(__brick_last),
177 std::move(__brick_init),
178 std::move(__reduce),
179 std::move(__transform));
180 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
181 return *std::move(__res);
182 });
183 } else if constexpr (__is_unsequenced_execution_policy_v<_ExecutionPolicy> &&
184 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
185 return std::__simd_transform_reduce(
186 __last - __first,
187 std::move(__init),
188 std::move(__reduce),
189 [=, &__transform](__iter_diff_t<_ForwardIterator> __i) { return __transform(__first[__i]); });
190 } else {
191 return std::transform_reduce(
192 std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform));
193 }
194}
195
196_LIBCPP_END_NAMESPACE_STD
197
198#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
199
200_LIBCPP_POP_MACROS
201
202#endif // _LIBCPP___ALGORITHM_PSTL_BACKENDS_CPU_BACKENDS_TRANSFORM_REDUCE_H
lib/libcxx/include/__algorithm/pstl_copy.h deleted-121
......@@ -1,121 +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___ALGORITHM_PSTL_COPY_H
10#define _LIBCPP___ALGORITHM_PSTL_COPY_H
11
12#include <__algorithm/copy_n.h>
13#include <__algorithm/pstl_backend.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__algorithm/pstl_transform.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__iterator/concepts.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/is_constant_evaluated.h>
21#include <__type_traits/is_execution_policy.h>
22#include <__type_traits/is_trivially_copyable.h>
23#include <__type_traits/remove_cvref.h>
24#include <__utility/move.h>
25#include <optional>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>
33
34#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38// TODO: Use the std::copy/move shenanigans to forward to std::memmove
39
40template <class>
41void __pstl_copy();
42
43template <class _ExecutionPolicy,
44 class _ForwardIterator,
45 class _ForwardOutIterator,
46 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
47 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
48[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
49__copy(_ExecutionPolicy&& __policy,
50 _ForwardIterator&& __first,
51 _ForwardIterator&& __last,
52 _ForwardOutIterator&& __result) noexcept {
53 return std::__pstl_frontend_dispatch(
54 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy, _RawPolicy),
55 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) {
56 return std::__transform(__policy, __g_first, __g_last, __g_result, __identity());
57 },
58 std::move(__first),
59 std::move(__last),
60 std::move(__result));
61}
62
63template <class _ExecutionPolicy,
64 class _ForwardIterator,
65 class _ForwardOutIterator,
66 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
67 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
68_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
69copy(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
70 auto __res = std::__copy(__policy, std::move(__first), std::move(__last), std::move(__result));
71 if (!__res)
72 std::__throw_bad_alloc();
73 return *std::move(__res);
74}
75
76template <class>
77void __pstl_copy_n();
78
79template <class _ExecutionPolicy,
80 class _ForwardIterator,
81 class _ForwardOutIterator,
82 class _Size,
83 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
84 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
85[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> __copy_n(
86 _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _ForwardOutIterator&& __result) noexcept {
87 return std::__pstl_frontend_dispatch(
88 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_copy_n, _RawPolicy),
89 [&__policy](
90 _ForwardIterator __g_first, _Size __g_n, _ForwardOutIterator __g_result) -> optional<_ForwardIterator> {
91 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value)
92 return std::__copy(__policy, std::move(__g_first), std::move(__g_first + __g_n), std::move(__g_result));
93 else
94 return std::copy_n(__g_first, __g_n, __g_result);
95 },
96 std::move(__first),
97 std::move(__n),
98 std::move(__result));
99}
100
101template <class _ExecutionPolicy,
102 class _ForwardIterator,
103 class _ForwardOutIterator,
104 class _Size,
105 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
106 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
107_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
108copy_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __result) {
109 auto __res = std::__copy_n(__policy, std::move(__first), std::move(__n), std::move(__result));
110 if (!__res)
111 std::__throw_bad_alloc();
112 return *std::move(__res);
113}
114
115_LIBCPP_END_NAMESPACE_STD
116
117#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
118
119_LIBCPP_POP_MACROS
120
121#endif // _LIBCPP___ALGORITHM_PSTL_COPY_H
lib/libcxx/include/__algorithm/pstl_count.h deleted-121
......@@ -1,121 +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___ALGORITHM_PSTL_COUNT_H
10#define _LIBCPP___ALGORITHM_PSTL_COUNT_H
11
12#include <__algorithm/count.h>
13#include <__algorithm/for_each.h>
14#include <__algorithm/pstl_backend.h>
15#include <__algorithm/pstl_for_each.h>
16#include <__algorithm/pstl_frontend_dispatch.h>
17#include <__atomic/atomic.h>
18#include <__config>
19#include <__functional/operations.h>
20#include <__iterator/iterator_traits.h>
21#include <__numeric/pstl_transform_reduce.h>
22#include <__type_traits/enable_if.h>
23#include <__type_traits/is_execution_policy.h>
24#include <__type_traits/remove_cvref.h>
25#include <__utility/move.h>
26#include <optional>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32_LIBCPP_PUSH_MACROS
33#include <__undef_macros>
34
35#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39template <class>
40void __pstl_count_if(); // declaration needed for the frontend dispatch below
41
42template <class _ExecutionPolicy,
43 class _ForwardIterator,
44 class _Predicate,
45 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
46 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
47[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> __count_if(
48 _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
49 using __diff_t = __iter_diff_t<_ForwardIterator>;
50 return std::__pstl_frontend_dispatch(
51 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count_if, _RawPolicy),
52 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) -> optional<__diff_t> {
53 return std::__transform_reduce(
54 __policy,
55 std::move(__g_first),
56 std::move(__g_last),
57 __diff_t(),
58 std::plus{},
59 [&](__iter_reference<_ForwardIterator> __element) -> bool { return __g_pred(__element); });
60 },
61 std::move(__first),
62 std::move(__last),
63 std::move(__pred));
64}
65
66template <class _ExecutionPolicy,
67 class _ForwardIterator,
68 class _Predicate,
69 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
70 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
71_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
72count_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
73 auto __res = std::__count_if(__policy, std::move(__first), std::move(__last), std::move(__pred));
74 if (!__res)
75 std::__throw_bad_alloc();
76 return *std::move(__res);
77}
78
79template <class>
80void __pstl_count(); // declaration needed for the frontend dispatch below
81
82template <class _ExecutionPolicy,
83 class _ForwardIterator,
84 class _Tp,
85 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
86 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
87[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>>
88__count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
89 return std::__pstl_frontend_dispatch(
90 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_count, _RawPolicy),
91 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value)
92 -> optional<__iter_diff_t<_ForwardIterator>> {
93 return std::count_if(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __v) {
94 return __v == __g_value;
95 });
96 },
97 std::move(__first),
98 std::move(__last),
99 __value);
100}
101
102template <class _ExecutionPolicy,
103 class _ForwardIterator,
104 class _Tp,
105 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
106 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
107_LIBCPP_HIDE_FROM_ABI __iter_diff_t<_ForwardIterator>
108count(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
109 auto __res = std::__count(__policy, std::move(__first), std::move(__last), __value);
110 if (!__res)
111 std::__throw_bad_alloc();
112 return *__res;
113}
114
115_LIBCPP_END_NAMESPACE_STD
116
117#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
118
119_LIBCPP_POP_MACROS
120
121#endif // _LIBCPP___ALGORITHM_PSTL_COUNT_H
lib/libcxx/include/__algorithm/pstl_equal.h deleted-175
......@@ -1,175 +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___ALGORITHM_PSTL_EQUAL_H
10#define _LIBCPP___ALGORITHM_PSTL_EQUAL_H
11
12#include <__algorithm/equal.h>
13#include <__algorithm/pstl_frontend_dispatch.h>
14#include <__config>
15#include <__functional/operations.h>
16#include <__iterator/iterator_traits.h>
17#include <__numeric/pstl_transform_reduce.h>
18#include <__utility/move.h>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_PUSH_MACROS
25#include <__undef_macros>
26
27#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31template <class>
32void __pstl_equal();
33
34template <class _ExecutionPolicy,
35 class _ForwardIterator1,
36 class _ForwardIterator2,
37 class _Pred,
38 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
39 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
40[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
41__equal(_ExecutionPolicy&& __policy,
42 _ForwardIterator1&& __first1,
43 _ForwardIterator1&& __last1,
44 _ForwardIterator2&& __first2,
45 _Pred&& __pred) noexcept {
46 return std::__pstl_frontend_dispatch(
47 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy),
48 [&__policy](
49 _ForwardIterator1 __g_first1, _ForwardIterator1 __g_last1, _ForwardIterator2 __g_first2, _Pred __g_pred) {
50 return std::__transform_reduce(
51 __policy,
52 std::move(__g_first1),
53 std::move(__g_last1),
54 std::move(__g_first2),
55 true,
56 std::logical_and{},
57 std::move(__g_pred));
58 },
59 std::move(__first1),
60 std::move(__last1),
61 std::move(__first2),
62 std::move(__pred));
63}
64
65template <class _ExecutionPolicy,
66 class _ForwardIterator1,
67 class _ForwardIterator2,
68 class _Pred,
69 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
70 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
71_LIBCPP_HIDE_FROM_ABI bool
72equal(_ExecutionPolicy&& __policy,
73 _ForwardIterator1 __first1,
74 _ForwardIterator1 __last1,
75 _ForwardIterator2 __first2,
76 _Pred __pred) {
77 auto __res = std::__equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__pred));
78 if (!__res)
79 std::__throw_bad_alloc();
80 return *__res;
81}
82
83template <class _ExecutionPolicy,
84 class _ForwardIterator1,
85 class _ForwardIterator2,
86 enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
87_LIBCPP_HIDE_FROM_ABI bool
88equal(_ExecutionPolicy&& __policy, _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) {
89 return std::equal(__policy, std::move(__first1), std::move(__last1), std::move(__first2), std::equal_to{});
90}
91
92template <class _ExecutionPolicy,
93 class _ForwardIterator1,
94 class _ForwardIterator2,
95 class _Pred,
96 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
97 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
98[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
99__equal(_ExecutionPolicy&& __policy,
100 _ForwardIterator1&& __first1,
101 _ForwardIterator1&& __last1,
102 _ForwardIterator2&& __first2,
103 _ForwardIterator2&& __last2,
104 _Pred&& __pred) noexcept {
105 return std::__pstl_frontend_dispatch(
106 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_equal, _RawPolicy),
107 [&__policy](_ForwardIterator1 __g_first1,
108 _ForwardIterator1 __g_last1,
109 _ForwardIterator2 __g_first2,
110 _ForwardIterator2 __g_last2,
111 _Pred __g_pred) -> optional<bool> {
112 if constexpr (__has_random_access_iterator_category<_ForwardIterator1>::value &&
113 __has_random_access_iterator_category<_ForwardIterator2>::value) {
114 if (__g_last1 - __g_first1 != __g_last2 - __g_first2)
115 return false;
116 return std::__equal(
117 __policy, std::move(__g_first1), std::move(__g_last1), std::move(__g_first2), std::move(__g_pred));
118 } else {
119 (void)__policy; // Avoid unused lambda capture warning
120 return std::equal(
121 std::move(__g_first1),
122 std::move(__g_last1),
123 std::move(__g_first2),
124 std::move(__g_last2),
125 std::move(__g_pred));
126 }
127 },
128 std::move(__first1),
129 std::move(__last1),
130 std::move(__first2),
131 std::move(__last2),
132 std::move(__pred));
133}
134
135template <class _ExecutionPolicy,
136 class _ForwardIterator1,
137 class _ForwardIterator2,
138 class _Pred,
139 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
140 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
141_LIBCPP_HIDE_FROM_ABI bool
142equal(_ExecutionPolicy&& __policy,
143 _ForwardIterator1 __first1,
144 _ForwardIterator1 __last1,
145 _ForwardIterator2 __first2,
146 _ForwardIterator2 __last2,
147 _Pred __pred) {
148 auto __res = std::__equal(
149 __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::move(__pred));
150 if (!__res)
151 std::__throw_bad_alloc();
152 return *__res;
153}
154
155template <class _ExecutionPolicy,
156 class _ForwardIterator1,
157 class _ForwardIterator2,
158 enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
159_LIBCPP_HIDE_FROM_ABI bool
160equal(_ExecutionPolicy&& __policy,
161 _ForwardIterator1 __first1,
162 _ForwardIterator1 __last1,
163 _ForwardIterator2 __first2,
164 _ForwardIterator2 __last2) {
165 return std::equal(
166 __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), std::equal_to{});
167}
168
169_LIBCPP_END_NAMESPACE_STD
170
171#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
172
173_LIBCPP_POP_MACROS
174
175#endif // _LIBCPP___ALGORITHM_PSTL_EQUAL_H
lib/libcxx/include/__algorithm/pstl_fill.h deleted-116
......@@ -1,116 +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___ALGORITHM_PSTL_FILL_H
10#define _LIBCPP___ALGORITHM_PSTL_FILL_H
11
12#include <__algorithm/fill_n.h>
13#include <__algorithm/pstl_for_each.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__config>
16#include <__iterator/concepts.h>
17#include <__iterator/cpp17_iterator_concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/is_execution_policy.h>
21#include <__type_traits/remove_cvref.h>
22#include <__utility/move.h>
23#include <optional>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29_LIBCPP_PUSH_MACROS
30#include <__undef_macros>
31
32#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35
36template <class>
37void __pstl_fill(); // declaration needed for the frontend dispatch below
38
39template <class _ExecutionPolicy,
40 class _ForwardIterator,
41 class _Tp,
42 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
43 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
44_LIBCPP_HIDE_FROM_ABI optional<__empty>
45__fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept {
46 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
47 return std::__pstl_frontend_dispatch(
48 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill, _RawPolicy),
49 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) {
50 return std::__for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
51 __element = __g_value;
52 });
53 },
54 std::move(__first),
55 std::move(__last),
56 __value);
57}
58
59template <class _ExecutionPolicy,
60 class _ForwardIterator,
61 class _Tp,
62 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
63 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
64_LIBCPP_HIDE_FROM_ABI void
65fill(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
66 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
67 if (!std::__fill(__policy, std::move(__first), std::move(__last), __value))
68 std::__throw_bad_alloc();
69}
70
71template <class>
72void __pstl_fill_n(); // declaration needed for the frontend dispatch below
73
74template <class _ExecutionPolicy,
75 class _ForwardIterator,
76 class _SizeT,
77 class _Tp,
78 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
79 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
80[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
81__fill_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _SizeT&& __n, const _Tp& __value) noexcept {
82 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
83 return std::__pstl_frontend_dispatch(
84 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_fill_n, _RawPolicy),
85 [&](_ForwardIterator __g_first, _SizeT __g_n, const _Tp& __g_value) {
86 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value)
87 std::fill(__policy, __g_first, __g_first + __g_n, __g_value);
88 else
89 std::fill_n(__g_first, __g_n, __g_value);
90 return optional<__empty>{__empty{}};
91 },
92 std::move(__first),
93 std::move(__n),
94 __value);
95}
96
97template <class _ExecutionPolicy,
98 class _ForwardIterator,
99 class _SizeT,
100 class _Tp,
101 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
102 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
103_LIBCPP_HIDE_FROM_ABI void
104fill_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _SizeT __n, const _Tp& __value) {
105 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
106 if (!std::__fill_n(__policy, std::move(__first), std::move(__n), __value))
107 std::__throw_bad_alloc();
108}
109
110_LIBCPP_END_NAMESPACE_STD
111
112#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
113
114_LIBCPP_POP_MACROS
115
116#endif // _LIBCPP___ALGORITHM_PSTL_FILL_H
lib/libcxx/include/__algorithm/pstl_find.h deleted-141
......@@ -1,141 +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___ALGORITHM_PSTL_FIND_H
10#define _LIBCPP___ALGORITHM_PSTL_FIND_H
11
12#include <__algorithm/comp.h>
13#include <__algorithm/find.h>
14#include <__algorithm/pstl_backend.h>
15#include <__algorithm/pstl_frontend_dispatch.h>
16#include <__config>
17#include <__iterator/cpp17_iterator_concepts.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_execution_policy.h>
20#include <__type_traits/remove_cvref.h>
21#include <__utility/move.h>
22#include <optional>
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 !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35template <class _ExecutionPolicy,
36 class _ForwardIterator,
37 class _Predicate,
38 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
39 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
40[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
41__find_if(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) noexcept {
42 using _Backend = typename __select_backend<_RawPolicy>::type;
43 return std::__pstl_find_if<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__pred));
44}
45
46template <class _ExecutionPolicy,
47 class _ForwardIterator,
48 class _Predicate,
49 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
50 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
51_LIBCPP_HIDE_FROM_ABI _ForwardIterator
52find_if(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
53 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
54 auto __res = std::__find_if(__policy, std::move(__first), std::move(__last), std::move(__pred));
55 if (!__res)
56 std::__throw_bad_alloc();
57 return *std::move(__res);
58}
59
60template <class>
61void __pstl_find_if_not();
62
63template <class _ExecutionPolicy,
64 class _ForwardIterator,
65 class _Predicate,
66 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
67 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
68[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
69__find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) {
70 return std::__pstl_frontend_dispatch(
71 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find_if_not, _RawPolicy),
72 [&](_ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Predicate&& __g_pred)
73 -> optional<__remove_cvref_t<_ForwardIterator>> {
74 return std::__find_if(
75 __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __value) {
76 return !__g_pred(__value);
77 });
78 },
79 std::move(__first),
80 std::move(__last),
81 std::move(__pred));
82}
83
84template <class _ExecutionPolicy,
85 class _ForwardIterator,
86 class _Predicate,
87 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
88 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
89_LIBCPP_HIDE_FROM_ABI _ForwardIterator
90find_if_not(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
91 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
92 auto __res = std::__find_if_not(__policy, std::move(__first), std::move(__last), std::move(__pred));
93 if (!__res)
94 std::__throw_bad_alloc();
95 return *std::move(__res);
96}
97
98template <class>
99void __pstl_find();
100
101template <class _ExecutionPolicy,
102 class _ForwardIterator,
103 class _Tp,
104 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
105 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
106[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardIterator>>
107__find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) noexcept {
108 return std::__pstl_frontend_dispatch(
109 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_find, _RawPolicy),
110 [&](_ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_value) -> optional<_ForwardIterator> {
111 return std::find_if(
112 __policy, __g_first, __g_last, [&](__iter_reference<__remove_cvref_t<_ForwardIterator>> __element) {
113 return __element == __g_value;
114 });
115 },
116 std::move(__first),
117 std::move(__last),
118 __value);
119}
120
121template <class _ExecutionPolicy,
122 class _ForwardIterator,
123 class _Tp,
124 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
125 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
126_LIBCPP_HIDE_FROM_ABI _ForwardIterator
127find(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
128 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
129 auto __res = std::__find(__policy, std::move(__first), std::move(__last), __value);
130 if (!__res)
131 std::__throw_bad_alloc();
132 return *std::move(__res);
133}
134
135_LIBCPP_END_NAMESPACE_STD
136
137#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
138
139_LIBCPP_POP_MACROS
140
141#endif // _LIBCPP___ALGORITHM_PSTL_FIND_H
lib/libcxx/include/__algorithm/pstl_for_each.h deleted-108
......@@ -1,108 +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___ALGORITHM_PSTL_FOR_EACH_H
10#define _LIBCPP___ALGORITHM_PSTL_FOR_EACH_H
11
12#include <__algorithm/for_each.h>
13#include <__algorithm/for_each_n.h>
14#include <__algorithm/pstl_backend.h>
15#include <__algorithm/pstl_frontend_dispatch.h>
16#include <__config>
17#include <__iterator/concepts.h>
18#include <__iterator/cpp17_iterator_concepts.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/is_execution_policy.h>
21#include <__type_traits/remove_cvref.h>
22#include <__type_traits/void_t.h>
23#include <__utility/empty.h>
24#include <__utility/move.h>
25#include <optional>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>
33
34#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38template <class _ExecutionPolicy,
39 class _ForwardIterator,
40 class _Function,
41 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
42 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
43[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
44__for_each(_ExecutionPolicy&&, _ForwardIterator&& __first, _ForwardIterator&& __last, _Function&& __func) noexcept {
45 using _Backend = typename __select_backend<_RawPolicy>::type;
46 return std::__pstl_for_each<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__func));
47}
48
49template <class _ExecutionPolicy,
50 class _ForwardIterator,
51 class _Function,
52 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
53 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
54_LIBCPP_HIDE_FROM_ABI void
55for_each(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) {
56 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
57 if (!std::__for_each(__policy, std::move(__first), std::move(__last), std::move(__func)))
58 std::__throw_bad_alloc();
59}
60
61template <class>
62void __pstl_for_each_n(); // declaration needed for the frontend dispatch below
63
64template <class _ExecutionPolicy,
65 class _ForwardIterator,
66 class _Size,
67 class _Function,
68 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
69 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
70[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
71__for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __size, _Function&& __func) noexcept {
72 return std::__pstl_frontend_dispatch(
73 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_for_each_n, _RawPolicy),
74 [&](_ForwardIterator __g_first, _Size __g_size, _Function __g_func) -> optional<__empty> {
75 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
76 std::for_each(__policy, std::move(__g_first), __g_first + __g_size, std::move(__g_func));
77 return __empty{};
78 } else {
79 std::for_each_n(std::move(__g_first), __g_size, std::move(__g_func));
80 return __empty{};
81 }
82 },
83 std::move(__first),
84 std::move(__size),
85 std::move(__func));
86}
87
88template <class _ExecutionPolicy,
89 class _ForwardIterator,
90 class _Size,
91 class _Function,
92 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
93 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
94_LIBCPP_HIDE_FROM_ABI void
95for_each_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) {
96 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
97 auto __res = std::__for_each_n(__policy, std::move(__first), std::move(__size), std::move(__func));
98 if (!__res)
99 std::__throw_bad_alloc();
100}
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
105
106_LIBCPP_POP_MACROS
107
108#endif // _LIBCPP___ALGORITHM_PSTL_FOR_EACH_H
lib/libcxx/include/__algorithm/pstl_frontend_dispatch.h deleted-44
......@@ -1,44 +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___ALGORITHM_PSTL_FRONTEND_DISPATCH
10#define _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
11
12#include <__config>
13#include <__type_traits/is_callable.h>
14#include <__utility/forward.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if _LIBCPP_STD_VER >= 17
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24# define _LIBCPP_PSTL_CUSTOMIZATION_POINT(name, policy) \
25 [](auto&&... __args) -> decltype(std::name<policy>( \
26 typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...)) { \
27 return std::name<policy>(typename __select_backend<policy>::type{}, std::forward<decltype(__args)>(__args)...); \
28 }
29
30template <class _SpecializedImpl, class _GenericImpl, class... _Args>
31_LIBCPP_HIDE_FROM_ABI decltype(auto)
32__pstl_frontend_dispatch(_SpecializedImpl __specialized_impl, _GenericImpl __generic_impl, _Args&&... __args) {
33 if constexpr (__is_callable<_SpecializedImpl, _Args...>::value) {
34 return __specialized_impl(std::forward<_Args>(__args)...);
35 } else {
36 return __generic_impl(std::forward<_Args>(__args)...);
37 }
38}
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP_STD_VER >= 17
43
44#endif // _LIBCPP___ALGORITHM_PSTL_FRONTEND_DISPATCH
lib/libcxx/include/__algorithm/pstl_generate.h deleted-114
......@@ -1,114 +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___ALGORITHM_PSTL_GENERATE_H
10#define _LIBCPP___ALGORITHM_PSTL_GENERATE_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__algorithm/pstl_for_each.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__config>
16#include <__iterator/cpp17_iterator_concepts.h>
17#include <__iterator/iterator_traits.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_execution_policy.h>
20#include <__type_traits/remove_cvref.h>
21#include <__utility/move.h>
22#include <optional>
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 !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35template <class>
36void __pstl_generate();
37
38template <class _ExecutionPolicy,
39 class _ForwardIterator,
40 class _Generator,
41 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
42 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
43[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
44__generate(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Generator&& __gen) {
45 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
46 return std::__pstl_frontend_dispatch(
47 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate, _RawPolicy),
48 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Generator __g_gen) {
49 return std::__for_each(
50 __policy, std::move(__g_first), std::move(__g_last), [&](__iter_reference<_ForwardIterator> __element) {
51 __element = __g_gen();
52 });
53 },
54 std::move(__first),
55 std::move(__last),
56 std::move(__gen));
57}
58
59template <class _ExecutionPolicy,
60 class _ForwardIterator,
61 class _Generator,
62 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
63 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
64_LIBCPP_HIDE_FROM_ABI void
65generate(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) {
66 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
67 if (!std::__generate(__policy, std::move(__first), std::move(__last), std::move(__gen)))
68 std::__throw_bad_alloc();
69}
70
71template <class>
72void __pstl_generate_n();
73
74template <class _ExecutionPolicy,
75 class _ForwardIterator,
76 class _Size,
77 class _Generator,
78 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
79 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
80[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
81__generate_n(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _Size&& __n, _Generator&& __gen) {
82 return std::__pstl_frontend_dispatch(
83 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_generate_n, _RawPolicy),
84 [&__policy](_ForwardIterator __g_first, _Size __g_n, _Generator __g_gen) {
85 return std::__for_each_n(
86 __policy, std::move(__g_first), std::move(__g_n), [&](__iter_reference<_ForwardIterator> __element) {
87 __element = __g_gen();
88 });
89 },
90 std::move(__first),
91 __n,
92 std::move(__gen));
93}
94
95template <class _ExecutionPolicy,
96 class _ForwardIterator,
97 class _Size,
98 class _Generator,
99 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
100 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
101_LIBCPP_HIDE_FROM_ABI void
102generate_n(_ExecutionPolicy&& __policy, _ForwardIterator __first, _Size __n, _Generator __gen) {
103 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
104 if (!std::__generate_n(__policy, std::move(__first), std::move(__n), std::move(__gen)))
105 std::__throw_bad_alloc();
106}
107
108_LIBCPP_END_NAMESPACE_STD
109
110#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
111
112_LIBCPP_POP_MACROS
113
114#endif // _LIBCPP___ALGORITHM_PSTL_GENERATE_H
lib/libcxx/include/__algorithm/pstl_is_partitioned.h deleted-77
......@@ -1,77 +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___ALGORITHM_PSTL_IS_PARITTIONED
10#define _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED
11
12#include <__algorithm/pstl_any_all_none_of.h>
13#include <__algorithm/pstl_backend.h>
14#include <__algorithm/pstl_find.h>
15#include <__algorithm/pstl_frontend_dispatch.h>
16#include <__config>
17#include <__type_traits/enable_if.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__type_traits/remove_cvref.h>
20#include <__utility/move.h>
21#include <optional>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>
29
30#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34template <class>
35void __pstl_is_partitioned();
36
37template <class _ExecutionPolicy,
38 class _ForwardIterator,
39 class _Predicate,
40 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
41 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
42[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool> __is_partitioned(
43 _ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last, _Predicate&& __pred) {
44 return std::__pstl_frontend_dispatch(
45 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_is_partitioned, _RawPolicy),
46 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Predicate __g_pred) {
47 __g_first = std::find_if_not(__policy, __g_first, __g_last, __g_pred);
48 if (__g_first == __g_last)
49 return true;
50 ++__g_first;
51 return std::none_of(__policy, __g_first, __g_last, __g_pred);
52 },
53 std::move(__first),
54 std::move(__last),
55 std::move(__pred));
56}
57
58template <class _ExecutionPolicy,
59 class _ForwardIterator,
60 class _Predicate,
61 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
62 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
63_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI bool
64is_partitioned(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
65 auto __res = std::__is_partitioned(__policy, std::move(__first), std::move(__last), std::move(__pred));
66 if (!__res)
67 std::__throw_bad_alloc();
68 return *std::move(__res);
69}
70
71_LIBCPP_END_NAMESPACE_STD
72
73#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
74
75_LIBCPP_POP_MACROS
76
77#endif // _LIBCPP___ALGORITHM_PSTL_IS_PARITTIONED
lib/libcxx/include/__algorithm/pstl_merge.h deleted-92
......@@ -1,92 +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___ALGORITHM_PSTL_MERGE_H
10#define _LIBCPP___ALGORITHM_PSTL_MERGE_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__config>
14#include <__functional/operations.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__type_traits/remove_cvref.h>
18#include <__utility/move.h>
19#include <optional>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32template <class _ExecutionPolicy,
33 class _ForwardIterator1,
34 class _ForwardIterator2,
35 class _ForwardOutIterator,
36 class _Comp = std::less<>,
37 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
38 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
39[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
40__merge(_ExecutionPolicy&&,
41 _ForwardIterator1 __first1,
42 _ForwardIterator1 __last1,
43 _ForwardIterator2 __first2,
44 _ForwardIterator2 __last2,
45 _ForwardOutIterator __result,
46 _Comp __comp = {}) noexcept {
47 using _Backend = typename __select_backend<_RawPolicy>::type;
48 return std::__pstl_merge<_RawPolicy>(
49 _Backend{},
50 std::move(__first1),
51 std::move(__last1),
52 std::move(__first2),
53 std::move(__last2),
54 std::move(__result),
55 std::move(__comp));
56}
57
58template <class _ExecutionPolicy,
59 class _ForwardIterator1,
60 class _ForwardIterator2,
61 class _ForwardOutIterator,
62 class _Comp = std::less<>,
63 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
64 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
65_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
66merge(_ExecutionPolicy&& __policy,
67 _ForwardIterator1 __first1,
68 _ForwardIterator1 __last1,
69 _ForwardIterator2 __first2,
70 _ForwardIterator2 __last2,
71 _ForwardOutIterator __result,
72 _Comp __comp = {}) {
73 auto __res = std::__merge(
74 __policy,
75 std::move(__first1),
76 std::move(__last1),
77 std::move(__first2),
78 std::move(__last2),
79 std::move(__result),
80 std::move(__comp));
81 if (!__res)
82 std::__throw_bad_alloc();
83 return *std::move(__res);
84}
85
86_LIBCPP_END_NAMESPACE_STD
87
88#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
89
90_LIBCPP_POP_MACROS
91
92#endif // _LIBCPP___ALGORITHM_PSTL_MERGE_H
lib/libcxx/include/__algorithm/pstl_move.h deleted-84
......@@ -1,84 +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___ALGORITHM_PSTL_MOVE_H
10#define _LIBCPP___ALGORITHM_PSTL_MOVE_H
11
12#include <__algorithm/copy_n.h>
13#include <__algorithm/pstl_backend.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__algorithm/pstl_transform.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__iterator/iterator_traits.h>
19#include <__type_traits/enable_if.h>
20#include <__type_traits/is_constant_evaluated.h>
21#include <__type_traits/is_execution_policy.h>
22#include <__type_traits/is_trivially_copyable.h>
23#include <__type_traits/remove_cvref.h>
24#include <optional>
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 !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37// TODO: Use the std::copy/move shenanigans to forward to std::memmove
38// Investigate whether we want to still forward to std::transform(policy)
39// in that case for the execution::par part, or whether we actually want
40// to run everything serially in that case.
41
42template <class>
43void __pstl_move();
44
45template <class _ExecutionPolicy,
46 class _ForwardIterator,
47 class _ForwardOutIterator,
48 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
49 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
50[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
51__move(_ExecutionPolicy&& __policy,
52 _ForwardIterator&& __first,
53 _ForwardIterator&& __last,
54 _ForwardOutIterator&& __result) noexcept {
55 return std::__pstl_frontend_dispatch(
56 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_move, _RawPolicy),
57 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _ForwardOutIterator __g_result) {
58 return std::__transform(__policy, __g_first, __g_last, __g_result, [](auto&& __v) { return std::move(__v); });
59 },
60 std::move(__first),
61 std::move(__last),
62 std::move(__result));
63}
64
65template <class _ExecutionPolicy,
66 class _ForwardIterator,
67 class _ForwardOutIterator,
68 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
69 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
70_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator
71move(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __result) {
72 auto __res = std::__move(__policy, std::move(__first), std::move(__last), std::move(__result));
73 if (!__res)
74 std::__throw_bad_alloc();
75 return *__res;
76}
77
78_LIBCPP_END_NAMESPACE_STD
79
80#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
81
82_LIBCPP_POP_MACROS
83
84#endif // _LIBCPP___ALGORITHM_PSTL_MOVE_H
lib/libcxx/include/__algorithm/pstl_replace.h deleted-247
......@@ -1,247 +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___ALGORITHM_PSTL_REPLACE_H
10#define _LIBCPP___ALGORITHM_PSTL_REPLACE_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__algorithm/pstl_for_each.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__algorithm/pstl_transform.h>
16#include <__config>
17#include <__iterator/iterator_traits.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/remove_cvref.h>
20#include <__utility/move.h>
21#include <optional>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>
29
30#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34template <class>
35void __pstl_replace_if();
36
37template <class _ExecutionPolicy,
38 class _ForwardIterator,
39 class _Pred,
40 class _Tp,
41 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
42 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
43[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
44__replace_if(_ExecutionPolicy&& __policy,
45 _ForwardIterator&& __first,
46 _ForwardIterator&& __last,
47 _Pred&& __pred,
48 const _Tp& __new_value) noexcept {
49 return std::__pstl_frontend_dispatch(
50 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_if, _RawPolicy),
51 [&__policy](
52 _ForwardIterator&& __g_first, _ForwardIterator&& __g_last, _Pred&& __g_pred, const _Tp& __g_new_value) {
53 std::for_each(__policy, __g_first, __g_last, [&](__iter_reference<_ForwardIterator> __element) {
54 if (__g_pred(__element))
55 __element = __g_new_value;
56 });
57 return optional<__empty>{__empty{}};
58 },
59 std::move(__first),
60 std::move(__last),
61 std::move(__pred),
62 __new_value);
63}
64
65template <class _ExecutionPolicy,
66 class _ForwardIterator,
67 class _Pred,
68 class _Tp,
69 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
70 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
71_LIBCPP_HIDE_FROM_ABI void
72replace_if(_ExecutionPolicy&& __policy,
73 _ForwardIterator __first,
74 _ForwardIterator __last,
75 _Pred __pred,
76 const _Tp& __new_value) {
77 auto __res = std::__replace_if(__policy, std::move(__first), std::move(__last), std::move(__pred), __new_value);
78 if (!__res)
79 std::__throw_bad_alloc();
80}
81
82template <class>
83void __pstl_replace();
84
85template <class _ExecutionPolicy,
86 class _ForwardIterator,
87 class _Tp,
88 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
89 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
90[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
91__replace(_ExecutionPolicy&& __policy,
92 _ForwardIterator __first,
93 _ForwardIterator __last,
94 const _Tp& __old_value,
95 const _Tp& __new_value) noexcept {
96 return std::__pstl_frontend_dispatch(
97 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace, _RawPolicy),
98 [&__policy](
99 _ForwardIterator __g_first, _ForwardIterator __g_last, const _Tp& __g_old_value, const _Tp& __g_new_value) {
100 return std::__replace_if(
101 __policy,
102 std::move(__g_first),
103 std::move(__g_last),
104 [&](__iter_reference<_ForwardIterator> __element) { return __element == __g_old_value; },
105 __g_new_value);
106 },
107 std::move(__first),
108 std::move(__last),
109 __old_value,
110 __new_value);
111}
112
113template <class _ExecutionPolicy,
114 class _ForwardIterator,
115 class _Tp,
116 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
117 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
118_LIBCPP_HIDE_FROM_ABI void
119replace(_ExecutionPolicy&& __policy,
120 _ForwardIterator __first,
121 _ForwardIterator __last,
122 const _Tp& __old_value,
123 const _Tp& __new_value) {
124 if (!std::__replace(__policy, std::move(__first), std::move(__last), __old_value, __new_value))
125 std::__throw_bad_alloc();
126}
127
128template <class>
129void __pstl_replace_copy_if();
130
131template <class _ExecutionPolicy,
132 class _ForwardIterator,
133 class _ForwardOutIterator,
134 class _Pred,
135 class _Tp,
136 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
137 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
138[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy_if(
139 _ExecutionPolicy&& __policy,
140 _ForwardIterator&& __first,
141 _ForwardIterator&& __last,
142 _ForwardOutIterator&& __result,
143 _Pred&& __pred,
144 const _Tp& __new_value) {
145 return std::__pstl_frontend_dispatch(
146 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy_if, _RawPolicy),
147 [&__policy](_ForwardIterator __g_first,
148 _ForwardIterator __g_last,
149 _ForwardOutIterator __g_result,
150 _Pred __g_pred,
151 const _Tp& __g_new_value) -> optional<__empty> {
152 if (!std::__transform(
153 __policy, __g_first, __g_last, __g_result, [&](__iter_reference<_ForwardIterator> __element) {
154 return __g_pred(__element) ? __g_new_value : __element;
155 }))
156 return nullopt;
157 return __empty{};
158 },
159 std::move(__first),
160 std::move(__last),
161 std::move(__result),
162 std::move(__pred),
163 __new_value);
164}
165
166template <class _ExecutionPolicy,
167 class _ForwardIterator,
168 class _ForwardOutIterator,
169 class _Pred,
170 class _Tp,
171 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
172 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
173_LIBCPP_HIDE_FROM_ABI void replace_copy_if(
174 _ExecutionPolicy&& __policy,
175 _ForwardIterator __first,
176 _ForwardIterator __last,
177 _ForwardOutIterator __result,
178 _Pred __pred,
179 const _Tp& __new_value) {
180 if (!std::__replace_copy_if(
181 __policy, std::move(__first), std::move(__last), std::move(__result), std::move(__pred), __new_value))
182 std::__throw_bad_alloc();
183}
184
185template <class>
186void __pstl_replace_copy();
187
188template <class _ExecutionPolicy,
189 class _ForwardIterator,
190 class _ForwardOutIterator,
191 class _Tp,
192 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
193 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
194[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __replace_copy(
195 _ExecutionPolicy&& __policy,
196 _ForwardIterator&& __first,
197 _ForwardIterator&& __last,
198 _ForwardOutIterator&& __result,
199 const _Tp& __old_value,
200 const _Tp& __new_value) noexcept {
201 return std::__pstl_frontend_dispatch(
202 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_replace_copy, _RawPolicy),
203 [&__policy](_ForwardIterator __g_first,
204 _ForwardIterator __g_last,
205 _ForwardOutIterator __g_result,
206 const _Tp& __g_old_value,
207 const _Tp& __g_new_value) {
208 return std::__replace_copy_if(
209 __policy,
210 std::move(__g_first),
211 std::move(__g_last),
212 std::move(__g_result),
213 [&](__iter_reference<_ForwardIterator> __element) { return __element == __g_old_value; },
214 __g_new_value);
215 },
216 std::move(__first),
217 std::move(__last),
218 std::move(__result),
219 __old_value,
220 __new_value);
221}
222
223template <class _ExecutionPolicy,
224 class _ForwardIterator,
225 class _ForwardOutIterator,
226 class _Tp,
227 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
228 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
229_LIBCPP_HIDE_FROM_ABI void replace_copy(
230 _ExecutionPolicy&& __policy,
231 _ForwardIterator __first,
232 _ForwardIterator __last,
233 _ForwardOutIterator __result,
234 const _Tp& __old_value,
235 const _Tp& __new_value) {
236 if (!std::__replace_copy(
237 __policy, std::move(__first), std::move(__last), std::move(__result), __old_value, __new_value))
238 std::__throw_bad_alloc();
239}
240
241_LIBCPP_END_NAMESPACE_STD
242
243#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
244
245_LIBCPP_POP_MACROS
246
247#endif // _LIBCPP___ALGORITHM_PSTL_REPLACE_H
lib/libcxx/include/__algorithm/pstl_rotate_copy.h deleted-85
......@@ -1,85 +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___ALGORITHM_PSTL_ROTATE_COPY_H
10#define _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__algorithm/pstl_copy.h>
14#include <__algorithm/pstl_frontend_dispatch.h>
15#include <__type_traits/is_execution_policy.h>
16#include <optional>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29template <class>
30void __pstl_rotate_copy();
31
32template <class _ExecutionPolicy,
33 class _ForwardIterator,
34 class _ForwardOutIterator,
35 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
36 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
38__rotate_copy(_ExecutionPolicy&& __policy,
39 _ForwardIterator&& __first,
40 _ForwardIterator&& __middle,
41 _ForwardIterator&& __last,
42 _ForwardOutIterator&& __result) noexcept {
43 return std::__pstl_frontend_dispatch(
44 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_rotate_copy, _RawPolicy),
45 [&__policy](_ForwardIterator __g_first,
46 _ForwardIterator __g_middle,
47 _ForwardIterator __g_last,
48 _ForwardOutIterator __g_result) -> optional<_ForwardOutIterator> {
49 auto __result_mid =
50 std::__copy(__policy, _ForwardIterator(__g_middle), std::move(__g_last), std::move(__g_result));
51 if (!__result_mid)
52 return nullopt;
53 return std::__copy(__policy, std::move(__g_first), std::move(__g_middle), *std::move(__result_mid));
54 },
55 std::move(__first),
56 std::move(__middle),
57 std::move(__last),
58 std::move(__result));
59}
60
61template <class _ExecutionPolicy,
62 class _ForwardIterator,
63 class _ForwardOutIterator,
64 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
65 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
66_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator rotate_copy(
67 _ExecutionPolicy&& __policy,
68 _ForwardIterator __first,
69 _ForwardIterator __middle,
70 _ForwardIterator __last,
71 _ForwardOutIterator __result) {
72 auto __res =
73 std::__rotate_copy(__policy, std::move(__first), std::move(__middle), std::move(__last), std::move(__result));
74 if (!__res)
75 std::__throw_bad_alloc();
76 return *__res;
77}
78
79_LIBCPP_END_NAMESPACE_STD
80
81#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
82
83_LIBCPP_POP_MACROS
84
85#endif // _LIBCPP___ALGORITHM_PSTL_ROTATE_COPY_H
lib/libcxx/include/__algorithm/pstl_sort.h deleted-82
......@@ -1,82 +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___ALGORITHM_PSTL_SORT_H
10#define _LIBCPP___ALGORITHM_PSTL_SORT_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__algorithm/pstl_frontend_dispatch.h>
14#include <__algorithm/pstl_stable_sort.h>
15#include <__config>
16#include <__functional/operations.h>
17#include <__type_traits/is_execution_policy.h>
18#include <__type_traits/remove_cvref.h>
19#include <__utility/empty.h>
20#include <__utility/forward.h>
21#include <__utility/move.h>
22#include <optional>
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 !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35template <class>
36void __pstl_sort();
37
38template <class _ExecutionPolicy,
39 class _RandomAccessIterator,
40 class _Comp,
41 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
42 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
43[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __sort(
44 _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) noexcept {
45 return std::__pstl_frontend_dispatch(
46 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_sort, _RawPolicy),
47 [&__policy](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
48 std::stable_sort(__policy, std::move(__g_first), std::move(__g_last), std::move(__g_comp));
49 return optional<__empty>{__empty{}};
50 },
51 std::move(__first),
52 std::move(__last),
53 std::move(__comp));
54}
55
56template <class _ExecutionPolicy,
57 class _RandomAccessIterator,
58 class _Comp,
59 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
60 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
61_LIBCPP_HIDE_FROM_ABI void
62sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) {
63 if (!std::__sort(__policy, std::move(__first), std::move(__last), std::move(__comp)))
64 std::__throw_bad_alloc();
65}
66
67template <class _ExecutionPolicy,
68 class _RandomAccessIterator,
69 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
70 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
71_LIBCPP_HIDE_FROM_ABI void
72sort(_ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last) {
73 std::sort(std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), less{});
74}
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
79
80_LIBCPP_POP_MACROS
81
82#endif // _LIBCPP___ALGORITHM_PSTL_SORT_H
lib/libcxx/include/__algorithm/pstl_stable_sort.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___ALGORITHM_PSTL_STABLE_SORT_H
10#define _LIBCPP___ALGORITHM_PSTL_STABLE_SORT_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__config>
14#include <__functional/operations.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__type_traits/remove_cvref.h>
18#include <__utility/empty.h>
19#include <__utility/move.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33template <class _ExecutionPolicy,
34 class _RandomAccessIterator,
35 class _Comp = less<>,
36 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
37 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
38[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> __stable_sort(
39 _ExecutionPolicy&&, _RandomAccessIterator&& __first, _RandomAccessIterator&& __last, _Comp&& __comp = {}) noexcept {
40 using _Backend = typename __select_backend<_RawPolicy>::type;
41 return std::__pstl_stable_sort<_RawPolicy>(_Backend{}, std::move(__first), std::move(__last), std::move(__comp));
42}
43
44template <class _ExecutionPolicy,
45 class _RandomAccessIterator,
46 class _Comp = less<>,
47 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
48 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
49_LIBCPP_HIDE_FROM_ABI void stable_sort(
50 _ExecutionPolicy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp = {}) {
51 if (!std::__stable_sort(__policy, std::move(__first), std::move(__last), std::move(__comp)))
52 std::__throw_bad_alloc();
53}
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
58
59_LIBCPP_POP_MACROS
60
61#endif // _LIBCPP___ALGORITHM_PSTL_STABLE_SORT_H
lib/libcxx/include/__algorithm/pstl_transform.h deleted-120
......@@ -1,120 +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___ALGORITHM_PSTL_TRANSFORM_H
10#define _LIBCPP___ALGORITHM_PSTL_TRANSFORM_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__config>
14#include <__iterator/cpp17_iterator_concepts.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__type_traits/remove_cvref.h>
18#include <__utility/move.h>
19#include <optional>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32template <class _ExecutionPolicy,
33 class _ForwardIterator,
34 class _ForwardOutIterator,
35 class _UnaryOperation,
36 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
37 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
38[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>>
39__transform(_ExecutionPolicy&&,
40 _ForwardIterator&& __first,
41 _ForwardIterator&& __last,
42 _ForwardOutIterator&& __result,
43 _UnaryOperation&& __op) noexcept {
44 using _Backend = typename __select_backend<_RawPolicy>::type;
45 return std::__pstl_transform<_RawPolicy>(
46 _Backend{}, std::move(__first), std::move(__last), std::move(__result), std::move(__op));
47}
48
49template <class _ExecutionPolicy,
50 class _ForwardIterator,
51 class _ForwardOutIterator,
52 class _UnaryOperation,
53 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
54 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
55_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
56 _ExecutionPolicy&& __policy,
57 _ForwardIterator __first,
58 _ForwardIterator __last,
59 _ForwardOutIterator __result,
60 _UnaryOperation __op) {
61 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator);
62 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator);
63 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first)));
64 auto __res = std::__transform(__policy, std::move(__first), std::move(__last), std::move(__result), std::move(__op));
65 if (!__res)
66 std::__throw_bad_alloc();
67 return *std::move(__res);
68}
69
70template <class _ExecutionPolicy,
71 class _ForwardIterator1,
72 class _ForwardIterator2,
73 class _ForwardOutIterator,
74 class _BinaryOperation,
75 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
76 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
77_LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_ForwardOutIterator>>
78__transform(_ExecutionPolicy&&,
79 _ForwardIterator1&& __first1,
80 _ForwardIterator1&& __last1,
81 _ForwardIterator2&& __first2,
82 _ForwardOutIterator&& __result,
83 _BinaryOperation&& __op) noexcept {
84 using _Backend = typename __select_backend<_RawPolicy>::type;
85 return std::__pstl_transform<_RawPolicy>(
86 _Backend{}, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op));
87}
88
89template <class _ExecutionPolicy,
90 class _ForwardIterator1,
91 class _ForwardIterator2,
92 class _ForwardOutIterator,
93 class _BinaryOperation,
94 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
95 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
96_LIBCPP_HIDE_FROM_ABI _ForwardOutIterator transform(
97 _ExecutionPolicy&& __policy,
98 _ForwardIterator1 __first1,
99 _ForwardIterator1 __last1,
100 _ForwardIterator2 __first2,
101 _ForwardOutIterator __result,
102 _BinaryOperation __op) {
103 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1);
104 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2);
105 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardOutIterator);
106 _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(_ForwardOutIterator, decltype(__op(*__first1, *__first2)));
107 auto __res = std::__transform(
108 __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::move(__result), std::move(__op));
109 if (!__res)
110 std::__throw_bad_alloc();
111 return *std::move(__res);
112}
113
114_LIBCPP_END_NAMESPACE_STD
115
116#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
117
118_LIBCPP_POP_MACROS
119
120#endif // _LIBCPP___ALGORITHM_PSTL_TRANSFORM_H
lib/libcxx/include/__algorithm/push_heap.h+2-2
......@@ -14,8 +14,8 @@
1414#include <__algorithm/iterator_operations.h>
1515#include <__config>
1616#include <__iterator/iterator_traits.h>
17#include <__type_traits/is_copy_assignable.h>
18#include <__type_traits/is_copy_constructible.h>
17#include <__type_traits/is_assignable.h>
18#include <__type_traits/is_constructible.h>
1919#include <__utility/move.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__algorithm/ranges_adjacent_find.h+2-2
......@@ -53,7 +53,7 @@ struct __fn {
5353 sentinel_for<_Iter> _Sent,
5454 class _Proj = identity,
5555 indirect_binary_predicate<projected<_Iter, _Proj>, projected<_Iter, _Proj>> _Pred = ranges::equal_to>
56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
5757 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
5858 return __adjacent_find_impl(std::move(__first), std::move(__last), __pred, __proj);
5959 }
......@@ -62,7 +62,7 @@ struct __fn {
6262 class _Proj = identity,
6363 indirect_binary_predicate<projected<iterator_t<_Range>, _Proj>, projected<iterator_t<_Range>, _Proj>>
6464 _Pred = ranges::equal_to>
65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
6666 operator()(_Range&& __range, _Pred __pred = {}, _Proj __proj = {}) const {
6767 return __adjacent_find_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
6868 }
lib/libcxx/include/__algorithm/ranges_all_of.h+2-2
......@@ -45,7 +45,7 @@ struct __fn {
4545 sentinel_for<_Iter> _Sent,
4646 class _Proj = identity,
4747 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
4949 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
5050 return __all_of_impl(std::move(__first), std::move(__last), __pred, __proj);
5151 }
......@@ -53,7 +53,7 @@ struct __fn {
5353 template <input_range _Range,
5454 class _Proj = identity,
5555 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5757 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5858 return __all_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5959 }
lib/libcxx/include/__algorithm/ranges_any_of.h+2-2
......@@ -45,7 +45,7 @@ struct __fn {
4545 sentinel_for<_Iter> _Sent,
4646 class _Proj = identity,
4747 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
4949 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
5050 return __any_of_impl(std::move(__first), std::move(__last), __pred, __proj);
5151 }
......@@ -53,7 +53,7 @@ struct __fn {
5353 template <input_range _Range,
5454 class _Proj = identity,
5555 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5757 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5858 return __any_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
5959 }
lib/libcxx/include/__algorithm/ranges_binary_search.h+2-2
......@@ -39,7 +39,7 @@ struct __fn {
3939 class _Type,
4040 class _Proj = identity,
4141 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
42 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
4343 operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4444 auto __ret = std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
4545 return __ret != __last && !std::invoke(__comp, __value, std::invoke(__proj, *__ret));
......@@ -49,7 +49,7 @@ struct __fn {
4949 class _Type,
5050 class _Proj = identity,
5151 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
52 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
52 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5353 operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
5454 auto __first = ranges::begin(__r);
5555 auto __last = ranges::end(__r);
lib/libcxx/include/__algorithm/ranges_clamp.h+1-1
......@@ -35,7 +35,7 @@ struct __fn {
3535 template <class _Type,
3636 class _Proj = identity,
3737 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Type& operator()(
38 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Type& operator()(
3939 const _Type& __value, const _Type& __low, const _Type& __high, _Comp __comp = {}, _Proj __proj = {}) const {
4040 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
4141 !bool(std::invoke(__comp, std::invoke(__proj, __high), std::invoke(__proj, __low))),
lib/libcxx/include/__algorithm/ranges_contains.h+2-2
......@@ -37,14 +37,14 @@ namespace __contains {
3737struct __fn {
3838 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3939 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool static
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static
4141 operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) {
4242 return ranges::find(std::move(__first), __last, __value, std::ref(__proj)) != __last;
4343 }
4444
4545 template <input_range _Range, class _Type, class _Proj = identity>
4646 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool static
47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static
4848 operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) {
4949 return ranges::find(ranges::begin(__range), ranges::end(__range), __value, std::ref(__proj)) !=
5050 ranges::end(__range);
lib/libcxx/include/__algorithm/ranges_contains_subrange.h created+97
......@@ -0,0 +1,97 @@
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_CONTAINS_SUBRANGE_H
10#define _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
11
12#include <__algorithm/ranges_search.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__functional/ranges_operations.h>
16#include <__functional/reference_wrapper.h>
17#include <__iterator/concepts.h>
18#include <__iterator/indirectly_comparable.h>
19#include <__iterator/projected.h>
20#include <__ranges/access.h>
21#include <__ranges/concepts.h>
22#include <__ranges/size.h>
23#include <__ranges/subrange.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 >= 23
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37namespace ranges {
38namespace __contains_subrange {
39struct __fn {
40 template <forward_iterator _Iter1,
41 sentinel_for<_Iter1> _Sent1,
42 forward_iterator _Iter2,
43 sentinel_for<_Iter2> _Sent2,
44 class _Pred = ranges::equal_to,
45 class _Proj1 = identity,
46 class _Proj2 = identity>
47 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static operator()(
49 _Iter1 __first1,
50 _Sent1 __last1,
51 _Iter2 __first2,
52 _Sent2 __last2,
53 _Pred __pred = {},
54 _Proj1 __proj1 = {},
55 _Proj2 __proj2 = {}) {
56 if (__first2 == __last2)
57 return true;
58
59 auto __ret = ranges::search(
60 std::move(__first1), __last1, std::move(__first2), __last2, __pred, std::ref(__proj1), std::ref(__proj2));
61 return __ret.empty() == false;
62 }
63
64 template <forward_range _Range1,
65 forward_range _Range2,
66 class _Pred = ranges::equal_to,
67 class _Proj1 = identity,
68 class _Proj2 = identity>
69 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool static
71 operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {
72 if constexpr (sized_range<_Range2>) {
73 if (ranges::size(__range2) == 0)
74 return true;
75 } else {
76 if (ranges::begin(__range2) == ranges::end(__range2))
77 return true;
78 }
79
80 auto __ret = ranges::search(__range1, __range2, __pred, std::ref(__proj1), std::ref(__proj2));
81 return __ret.empty() == false;
82 }
83};
84} // namespace __contains_subrange
85
86inline namespace __cpo {
87inline constexpr auto contains_subrange = __contains_subrange::__fn{};
88} // namespace __cpo
89} // namespace ranges
90
91_LIBCPP_END_NAMESPACE_STD
92
93#endif // _LIBCPP_STD_VER >= 23
94
95_LIBCPP_POP_MACROS
96
97#endif // _LIBCPP___ALGORITHM_RANGES_CONTAINS_SUBRANGE_H
lib/libcxx/include/__algorithm/ranges_count.h+2-2
......@@ -38,14 +38,14 @@ namespace __count {
3838struct __fn {
3939 template <input_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
4040 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
41 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
4242 operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
4343 return std::__count<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __proj);
4444 }
4545
4646 template <input_range _Range, class _Type, class _Proj = identity>
4747 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
4949 operator()(_Range&& __r, const _Type& __value, _Proj __proj = {}) const {
5050 return std::__count<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __proj);
5151 }
lib/libcxx/include/__algorithm/ranges_count_if.h+2-2
......@@ -50,7 +50,7 @@ struct __fn {
5050 sentinel_for<_Iter> _Sent,
5151 class _Proj = identity,
5252 indirect_unary_predicate<projected<_Iter, _Proj>> _Predicate>
53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr iter_difference_t<_Iter>
5454 operator()(_Iter __first, _Sent __last, _Predicate __pred, _Proj __proj = {}) const {
5555 return ranges::__count_if_impl(std::move(__first), std::move(__last), __pred, __proj);
5656 }
......@@ -58,7 +58,7 @@ struct __fn {
5858 template <input_range _Range,
5959 class _Proj = identity,
6060 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Predicate>
61 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_difference_t<_Range>
6262 operator()(_Range&& __r, _Predicate __pred, _Proj __proj = {}) const {
6363 return ranges::__count_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
6464 }
lib/libcxx/include/__algorithm/ranges_ends_with.h+5-5
......@@ -39,7 +39,7 @@ namespace ranges {
3939namespace __ends_with {
4040struct __fn {
4141 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
42 static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl_bidirectional(
42 _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl_bidirectional(
4343 _Iter1 __first1,
4444 _Sent1 __last1,
4545 _Iter2 __first2,
......@@ -56,7 +56,7 @@ struct __fn {
5656 }
5757
5858 template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
59 static _LIBCPP_HIDE_FROM_ABI constexpr bool __ends_with_fn_impl(
59 _LIBCPP_HIDE_FROM_ABI static constexpr bool __ends_with_fn_impl(
6060 _Iter1 __first1,
6161 _Sent1 __last1,
6262 _Iter2 __first2,
......@@ -65,7 +65,7 @@ struct __fn {
6565 _Proj1& __proj1,
6666 _Proj2& __proj2) {
6767 if constexpr (std::bidirectional_iterator<_Sent1> && std::bidirectional_iterator<_Sent2> &&
68 (!std::random_access_iterator<_Sent1>)&&(!std::random_access_iterator<_Sent2>)) {
68 (!std::random_access_iterator<_Sent1>) && (!std::random_access_iterator<_Sent2>)) {
6969 return __ends_with_fn_impl_bidirectional(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
7070
7171 } else {
......@@ -133,7 +133,7 @@ struct __fn {
133133 requires(forward_iterator<_Iter1> || sized_sentinel_for<_Sent1, _Iter1>) &&
134134 (forward_iterator<_Iter2> || sized_sentinel_for<_Sent2, _Iter2>) &&
135135 indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
136 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
136 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
137137 _Iter1 __first1,
138138 _Sent1 __last1,
139139 _Iter2 __first2,
......@@ -152,7 +152,7 @@ struct __fn {
152152 class _Proj2 = identity>
153153 requires(forward_range<_Range1> || sized_range<_Range1>) && (forward_range<_Range2> || sized_range<_Range2>) &&
154154 indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
155 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
155 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
156156 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
157157 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
158158 auto __n1 = ranges::size(__range1);
lib/libcxx/include/__algorithm/ranges_equal.h+2-2
......@@ -44,7 +44,7 @@ struct __fn {
4444 class _Proj1 = identity,
4545 class _Proj2 = identity>
4646 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
4848 _Iter1 __first1,
4949 _Sent1 __last1,
5050 _Iter2 __first2,
......@@ -74,7 +74,7 @@ struct __fn {
7474 class _Proj1 = identity,
7575 class _Proj2 = identity>
7676 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
77 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
77 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
7878 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7979 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
8080 if (ranges::distance(__range1) != ranges::distance(__range2))
lib/libcxx/include/__algorithm/ranges_equal_range.h+2-2
......@@ -46,7 +46,7 @@ struct __fn {
4646 class _Tp,
4747 class _Proj = identity,
4848 indirect_strict_weak_order<const _Tp*, projected<_Iter, _Proj>> _Comp = ranges::less>
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
5050 operator()(_Iter __first, _Sent __last, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
5151 auto __ret = std::__equal_range<_RangeAlgPolicy>(std::move(__first), std::move(__last), __value, __comp, __proj);
5252 return {std::move(__ret.first), std::move(__ret.second)};
......@@ -56,7 +56,7 @@ struct __fn {
5656 class _Tp,
5757 class _Proj = identity,
5858 indirect_strict_weak_order<const _Tp*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
59 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
6060 operator()(_Range&& __range, const _Tp& __value, _Comp __comp = {}, _Proj __proj = {}) const {
6161 auto __ret =
6262 std::__equal_range<_RangeAlgPolicy>(ranges::begin(__range), ranges::end(__range), __value, __comp, __proj);
lib/libcxx/include/__algorithm/ranges_find.h+4-4
......@@ -44,22 +44,22 @@ struct __fn {
4444 if constexpr (forward_iterator<_Iter>) {
4545 auto [__first_un, __last_un] = std::__unwrap_range(__first, std::move(__last));
4646 return std::__rewrap_range<_Sent>(
47 std::move(__first), std::__find_impl(std::move(__first_un), std::move(__last_un), __value, __proj));
47 std::move(__first), std::__find(std::move(__first_un), std::move(__last_un), __value, __proj));
4848 } else {
49 return std::__find_impl(std::move(__first), std::move(__last), __value, __proj);
49 return std::__find(std::move(__first), std::move(__last), __value, __proj);
5050 }
5151 }
5252
5353 template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, class _Proj = identity>
5454 requires indirect_binary_predicate<ranges::equal_to, projected<_Ip, _Proj>, const _Tp*>
55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
5656 operator()(_Ip __first, _Sp __last, const _Tp& __value, _Proj __proj = {}) const {
5757 return __find_unwrap(std::move(__first), std::move(__last), __value, __proj);
5858 }
5959
6060 template <input_range _Rp, class _Tp, class _Proj = identity>
6161 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Rp>, _Proj>, const _Tp*>
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
6363 operator()(_Rp&& __r, const _Tp& __value, _Proj __proj = {}) const {
6464 return __find_unwrap(ranges::begin(__r), ranges::end(__r), __value, __proj);
6565 }
lib/libcxx/include/__algorithm/ranges_find_end.h+2-2
......@@ -45,7 +45,7 @@ struct __fn {
4545 class _Proj1 = identity,
4646 class _Proj2 = identity>
4747 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(
4949 _Iter1 __first1,
5050 _Sent1 __last1,
5151 _Iter2 __first2,
......@@ -72,7 +72,7 @@ struct __fn {
7272 class _Proj1 = identity,
7373 class _Proj2 = identity>
7474 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
75 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(
75 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(
7676 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7777 auto __ret = std::__find_end_impl<_RangeAlgPolicy>(
7878 ranges::begin(__range1),
lib/libcxx/include/__algorithm/ranges_find_first_of.h+2-2
......@@ -60,7 +60,7 @@ struct __fn {
6060 class _Proj1 = identity,
6161 class _Proj2 = identity>
6262 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
63 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()(
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter1 operator()(
6464 _Iter1 __first1,
6565 _Sent1 __last1,
6666 _Iter2 __first2,
......@@ -78,7 +78,7 @@ struct __fn {
7878 class _Proj1 = identity,
7979 class _Proj2 = identity>
8080 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
81 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()(
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range1> operator()(
8282 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
8383 return __find_first_of_impl(
8484 ranges::begin(__range1),
lib/libcxx/include/__algorithm/ranges_find_if.h+2-2
......@@ -48,13 +48,13 @@ struct __fn {
4848 sentinel_for<_Ip> _Sp,
4949 class _Proj = identity,
5050 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
51 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
51 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
5252 operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
5353 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred, __proj);
5454 }
5555
5656 template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
5858 operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
5959 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred, __proj);
6060 }
lib/libcxx/include/__algorithm/ranges_find_if_not.h+2-2
......@@ -40,14 +40,14 @@ struct __fn {
4040 sentinel_for<_Ip> _Sp,
4141 class _Proj = identity,
4242 indirect_unary_predicate<projected<_Ip, _Proj>> _Pred>
43 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
43 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
4444 operator()(_Ip __first, _Sp __last, _Pred __pred, _Proj __proj = {}) const {
4545 auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
4646 return ranges::__find_if_impl(std::move(__first), std::move(__last), __pred2, __proj);
4747 }
4848
4949 template <input_range _Rp, class _Proj = identity, indirect_unary_predicate<projected<iterator_t<_Rp>, _Proj>> _Pred>
50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
5151 operator()(_Rp&& __r, _Pred __pred, _Proj __proj = {}) const {
5252 auto __pred2 = [&](auto&& __e) -> bool { return !std::invoke(__pred, std::forward<decltype(__e)>(__e)); };
5353 return ranges::__find_if_impl(ranges::begin(__r), ranges::end(__r), __pred2, __proj);
lib/libcxx/include/__algorithm/ranges_find_last.h created+175
......@@ -0,0 +1,175 @@
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_FIND_LAST_H
10#define _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H
11
12#include <__config>
13#include <__functional/identity.h>
14#include <__functional/invoke.h>
15#include <__functional/ranges_operations.h>
16#include <__iterator/concepts.h>
17#include <__iterator/indirectly_comparable.h>
18#include <__iterator/next.h>
19#include <__iterator/prev.h>
20#include <__iterator/projected.h>
21#include <__ranges/access.h>
22#include <__ranges/concepts.h>
23#include <__ranges/subrange.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 >= 23
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36
37namespace ranges {
38
39template <class _Iter, class _Sent, class _Pred, class _Proj>
40_LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
41__find_last_impl(_Iter __first, _Sent __last, _Pred __pred, _Proj& __proj) {
42 if (__first == __last) {
43 return subrange<_Iter>(__first, __first);
44 }
45
46 if constexpr (bidirectional_iterator<_Iter>) {
47 auto __last_it = ranges::next(__first, __last);
48 for (auto __it = ranges::prev(__last_it); __it != __first; --__it) {
49 if (__pred(std::invoke(__proj, *__it))) {
50 return subrange<_Iter>(std::move(__it), std::move(__last_it));
51 }
52 }
53 if (__pred(std::invoke(__proj, *__first))) {
54 return subrange<_Iter>(std::move(__first), std::move(__last_it));
55 }
56 return subrange<_Iter>(__last_it, __last_it);
57 } else {
58 bool __found = false;
59 _Iter __found_it;
60 for (; __first != __last; ++__first) {
61 if (__pred(std::invoke(__proj, *__first))) {
62 __found = true;
63 __found_it = __first;
64 }
65 }
66
67 if (__found) {
68 return subrange<_Iter>(std::move(__found_it), std::move(__first));
69 } else {
70 return subrange<_Iter>(__first, __first);
71 }
72 }
73}
74
75namespace __find_last {
76struct __fn {
77 template <class _Type>
78 struct __op {
79 const _Type& __value;
80 template <class _Elem>
81 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const {
82 return std::forward<_Elem>(__elem) == __value;
83 }
84 };
85
86 template <forward_iterator _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
87 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
88 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter>
89 operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) {
90 return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Type>{__value}, __proj);
91 }
92
93 template <forward_range _Range, class _Type, class _Proj = identity>
94 requires indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
95 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range>
96 operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) {
97 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Type>{__value}, __proj);
98 }
99};
100} // namespace __find_last
101
102namespace __find_last_if {
103struct __fn {
104 template <class _Pred>
105 struct __op {
106 _Pred& __pred;
107 template <class _Elem>
108 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const {
109 return std::invoke(__pred, std::forward<_Elem>(__elem));
110 }
111 };
112
113 template <forward_iterator _Iter,
114 sentinel_for<_Iter> _Sent,
115 class _Proj = identity,
116 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter>
118 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) {
119 return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj);
120 }
121
122 template <forward_range _Range,
123 class _Proj = identity,
124 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
125 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range>
126 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) {
127 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);
128 }
129};
130} // namespace __find_last_if
131
132namespace __find_last_if_not {
133struct __fn {
134 template <class _Pred>
135 struct __op {
136 _Pred& __pred;
137 template <class _Elem>
138 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Elem&& __elem) const {
139 return !std::invoke(__pred, std::forward<_Elem>(__elem));
140 }
141 };
142
143 template <forward_iterator _Iter,
144 sentinel_for<_Iter> _Sent,
145 class _Proj = identity,
146 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
147 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static subrange<_Iter>
148 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) {
149 return ranges::__find_last_impl(std::move(__first), std::move(__last), __op<_Pred>{__pred}, __proj);
150 }
151
152 template <forward_range _Range,
153 class _Proj = identity,
154 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
155 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr static borrowed_subrange_t<_Range>
156 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) {
157 return ranges::__find_last_impl(ranges::begin(__range), ranges::end(__range), __op<_Pred>{__pred}, __proj);
158 }
159};
160} // namespace __find_last_if_not
161
162inline namespace __cpo {
163inline constexpr auto find_last = __find_last::__fn{};
164inline constexpr auto find_last_if = __find_last_if::__fn{};
165inline constexpr auto find_last_if_not = __find_last_if_not::__fn{};
166} // namespace __cpo
167} // namespace ranges
168
169_LIBCPP_END_NAMESPACE_STD
170
171#endif // _LIBCPP_STD_VER >= 23
172
173_LIBCPP_POP_MACROS
174
175#endif // _LIBCPP___ALGORITHM_RANGES_FIND_LAST_H
lib/libcxx/include/__algorithm/ranges_includes.h+2-2
......@@ -45,7 +45,7 @@ struct __fn {
4545 class _Proj1 = identity,
4646 class _Proj2 = identity,
4747 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
4949 _Iter1 __first1,
5050 _Sent1 __last1,
5151 _Iter2 __first2,
......@@ -69,7 +69,7 @@ struct __fn {
6969 class _Proj2 = identity,
7070 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
7171 _Comp = ranges::less>
72 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
72 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
7373 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7474 return std::__includes(
7575 ranges::begin(__range1),
lib/libcxx/include/__algorithm/ranges_is_heap.h+2-2
......@@ -51,7 +51,7 @@ struct __fn {
5151 sentinel_for<_Iter> _Sent,
5252 class _Proj = identity,
5353 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
54 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5555 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5656 return __is_heap_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
5757 }
......@@ -59,7 +59,7 @@ struct __fn {
5959 template <random_access_range _Range,
6060 class _Proj = identity,
6161 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
6363 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6464 return __is_heap_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6565 }
lib/libcxx/include/__algorithm/ranges_is_heap_until.h+2-2
......@@ -51,7 +51,7 @@ struct __fn {
5151 sentinel_for<_Iter> _Sent,
5252 class _Proj = identity,
5353 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
54 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
5555 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5656 return __is_heap_until_fn_impl(std::move(__first), std::move(__last), __comp, __proj);
5757 }
......@@ -59,7 +59,7 @@ struct __fn {
5959 template <random_access_range _Range,
6060 class _Proj = identity,
6161 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
6363 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6464 return __is_heap_until_fn_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6565 }
lib/libcxx/include/__algorithm/ranges_is_partitioned.h+2-2
......@@ -57,7 +57,7 @@ struct __fn {
5757 sentinel_for<_Iter> _Sent,
5858 class _Proj = identity,
5959 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
60 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
6161 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
6262 return __is_partitioned_impl(std::move(__first), std::move(__last), __pred, __proj);
6363 }
......@@ -65,7 +65,7 @@ struct __fn {
6565 template <input_range _Range,
6666 class _Proj = identity,
6767 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
6969 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
7070 return __is_partitioned_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
7171 }
lib/libcxx/include/__algorithm/ranges_is_permutation.h+2-2
......@@ -56,7 +56,7 @@ struct __fn {
5656 class _Proj1 = identity,
5757 class _Proj2 = identity,
5858 indirect_equivalence_relation<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Pred = ranges::equal_to>
59 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
6060 _Iter1 __first1,
6161 _Sent1 __last1,
6262 _Iter2 __first2,
......@@ -74,7 +74,7 @@ struct __fn {
7474 class _Proj2 = identity,
7575 indirect_equivalence_relation<projected<iterator_t<_Range1>, _Proj1>,
7676 projected<iterator_t<_Range2>, _Proj2>> _Pred = ranges::equal_to>
77 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
77 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
7878 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7979 if constexpr (sized_range<_Range1> && sized_range<_Range2>) {
8080 if (ranges::distance(__range1) != ranges::distance(__range2))
lib/libcxx/include/__algorithm/ranges_is_sorted.h+2-2
......@@ -37,7 +37,7 @@ struct __fn {
3737 sentinel_for<_Iter> _Sent,
3838 class _Proj = identity,
3939 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
4141 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
4242 return ranges::__is_sorted_until_impl(std::move(__first), __last, __comp, __proj) == __last;
4343 }
......@@ -45,7 +45,7 @@ struct __fn {
4545 template <forward_range _Range,
4646 class _Proj = identity,
4747 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
48 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
4949 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
5050 auto __last = ranges::end(__range);
5151 return ranges::__is_sorted_until_impl(ranges::begin(__range), __last, __comp, __proj) == __last;
lib/libcxx/include/__algorithm/ranges_is_sorted_until.h+2-2
......@@ -53,7 +53,7 @@ struct __fn {
5353 sentinel_for<_Iter> _Sent,
5454 class _Proj = identity,
5555 indirect_strict_weak_order<projected<_Iter, _Proj>> _Comp = ranges::less>
56 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
56 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
5757 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5858 return ranges::__is_sorted_until_impl(std::move(__first), std::move(__last), __comp, __proj);
5959 }
......@@ -61,7 +61,7 @@ struct __fn {
6161 template <forward_range _Range,
6262 class _Proj = identity,
6363 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
64 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
64 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
6565 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6666 return ranges::__is_sorted_until_impl(ranges::begin(__range), ranges::end(__range), __comp, __proj);
6767 }
lib/libcxx/include/__algorithm/ranges_lexicographical_compare.h+2-2
......@@ -60,7 +60,7 @@ struct __fn {
6060 class _Proj1 = identity,
6161 class _Proj2 = identity,
6262 indirect_strict_weak_order<projected<_Iter1, _Proj1>, projected<_Iter2, _Proj2>> _Comp = ranges::less>
63 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
6464 _Iter1 __first1,
6565 _Sent1 __last1,
6666 _Iter2 __first2,
......@@ -78,7 +78,7 @@ struct __fn {
7878 class _Proj2 = identity,
7979 indirect_strict_weak_order<projected<iterator_t<_Range1>, _Proj1>, projected<iterator_t<_Range2>, _Proj2>>
8080 _Comp = ranges::less>
81 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
81 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
8282 _Range1&& __range1, _Range2&& __range2, _Comp __comp = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
8383 return __lexicographical_compare_impl(
8484 ranges::begin(__range1),
lib/libcxx/include/__algorithm/ranges_lower_bound.h+2-2
......@@ -43,7 +43,7 @@ struct __fn {
4343 class _Type,
4444 class _Proj = identity,
4545 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
46 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
46 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
4747 operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4848 return std::__lower_bound<_RangeAlgPolicy>(__first, __last, __value, __comp, __proj);
4949 }
......@@ -52,7 +52,7 @@ struct __fn {
5252 class _Type,
5353 class _Proj = identity,
5454 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
5656 operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
5757 return std::__lower_bound<_RangeAlgPolicy>(ranges::begin(__r), ranges::end(__r), __value, __comp, __proj);
5858 }
lib/libcxx/include/__algorithm/ranges_max.h+4-4
......@@ -41,7 +41,7 @@ struct __fn {
4141 template <class _Tp,
4242 class _Proj = identity,
4343 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
44 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
44 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
4545 operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a,
4646 _LIBCPP_LIFETIMEBOUND const _Tp& __b,
4747 _Comp __comp = {},
......@@ -52,7 +52,7 @@ struct __fn {
5252 template <copyable _Tp,
5353 class _Proj = identity,
5454 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp
5656 operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
5757 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
5858 __il.begin() != __il.end(), "initializer_list must contain at least one element");
......@@ -65,7 +65,7 @@ struct __fn {
6565 class _Proj = identity,
6666 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
6767 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
68 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp>
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp>
6969 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
7070 auto __first = ranges::begin(__r);
7171 auto __last = ranges::end(__r);
......@@ -98,6 +98,6 @@ _LIBCPP_END_NAMESPACE_STD
9898
9999_LIBCPP_POP_MACROS
100100
101#endif // _LIBCPP_STD_VER >= 20 &&
101#endif // _LIBCPP_STD_VER >= 20
102102
103103#endif // _LIBCPP___ALGORITHM_RANGES_MAX_H
lib/libcxx/include/__algorithm/ranges_max_element.h+2-2
......@@ -38,7 +38,7 @@ struct __fn {
3838 sentinel_for<_Ip> _Sp,
3939 class _Proj = identity,
4040 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
41 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
41 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
4242 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
4343 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
4444 return ranges::__min_element_impl(__first, __last, __comp_lhs_rhs_swapped, __proj);
......@@ -47,7 +47,7 @@ struct __fn {
4747 template <forward_range _Rp,
4848 class _Proj = identity,
4949 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
5151 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
5252 auto __comp_lhs_rhs_swapped = [&](auto&& __lhs, auto&& __rhs) -> bool { return std::invoke(__comp, __rhs, __lhs); };
5353 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp_lhs_rhs_swapped, __proj);
lib/libcxx/include/__algorithm/ranges_min.h+4-4
......@@ -40,7 +40,7 @@ struct __fn {
4040 template <class _Tp,
4141 class _Proj = identity,
4242 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
43 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
43 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
4444 operator()(_LIBCPP_LIFETIMEBOUND const _Tp& __a,
4545 _LIBCPP_LIFETIMEBOUND const _Tp& __b,
4646 _Comp __comp = {},
......@@ -51,7 +51,7 @@ struct __fn {
5151 template <copyable _Tp,
5252 class _Proj = identity,
5353 indirect_strict_weak_order<projected<const _Tp*, _Proj>> _Comp = ranges::less>
54 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp
54 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp
5555 operator()(initializer_list<_Tp> __il, _Comp __comp = {}, _Proj __proj = {}) const {
5656 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
5757 __il.begin() != __il.end(), "initializer_list must contain at least one element");
......@@ -62,7 +62,7 @@ struct __fn {
6262 class _Proj = identity,
6363 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
6464 requires indirectly_copyable_storable<iterator_t<_Rp>, range_value_t<_Rp>*>
65 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp>
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr range_value_t<_Rp>
6666 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6767 auto __first = ranges::begin(__r);
6868 auto __last = ranges::end(__r);
......@@ -90,6 +90,6 @@ _LIBCPP_END_NAMESPACE_STD
9090
9191_LIBCPP_POP_MACROS
9292
93#endif // _LIBCPP_STD_VER >= 20 &&
93#endif // _LIBCPP_STD_VER >= 20
9494
9595#endif // _LIBCPP___ALGORITHM_RANGES_MIN_H
lib/libcxx/include/__algorithm/ranges_min_element.h+2-2
......@@ -52,7 +52,7 @@ struct __fn {
5252 sentinel_for<_Ip> _Sp,
5353 class _Proj = identity,
5454 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
55 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Ip
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Ip
5656 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
5757 return ranges::__min_element_impl(__first, __last, __comp, __proj);
5858 }
......@@ -60,7 +60,7 @@ struct __fn {
6060 template <forward_range _Rp,
6161 class _Proj = identity,
6262 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
63 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Rp>
6464 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6565 return ranges::__min_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
6666 }
lib/libcxx/include/__algorithm/ranges_minmax.h+19-4
......@@ -23,7 +23,9 @@
2323#include <__iterator/projected.h>
2424#include <__ranges/access.h>
2525#include <__ranges/concepts.h>
26#include <__type_traits/desugars_to.h>
2627#include <__type_traits/is_reference.h>
28#include <__type_traits/is_trivially_copyable.h>
2729#include <__type_traits/remove_cvref.h>
2830#include <__utility/forward.h>
2931#include <__utility/move.h>
......@@ -50,7 +52,7 @@ struct __fn {
5052 template <class _Type,
5153 class _Proj = identity,
5254 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<const _Type&>
5456 operator()(_LIBCPP_LIFETIMEBOUND const _Type& __a,
5557 _LIBCPP_LIFETIMEBOUND const _Type& __b,
5658 _Comp __comp = {},
......@@ -63,7 +65,7 @@ struct __fn {
6365 template <copyable _Type,
6466 class _Proj = identity,
6567 indirect_strict_weak_order<projected<const _Type*, _Proj>> _Comp = ranges::less>
66 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type>
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<_Type>
6769 operator()(initializer_list<_Type> __il, _Comp __comp = {}, _Proj __proj = {}) const {
6870 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
6971 __il.begin() != __il.end(), "initializer_list has to contain at least one element");
......@@ -75,7 +77,7 @@ struct __fn {
7577 class _Proj = identity,
7678 indirect_strict_weak_order<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
7779 requires indirectly_copyable_storable<iterator_t<_Range>, range_value_t<_Range>*>
78 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<range_value_t<_Range>>
80 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_result<range_value_t<_Range>>
7981 operator()(_Range&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
8082 auto __first = ranges::begin(__r);
8183 auto __last = ranges::end(__r);
......@@ -83,7 +85,20 @@ struct __fn {
8385
8486 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__first != __last, "range has to contain at least one element");
8587
86 if constexpr (forward_range<_Range>) {
88 // This optimiation is not in minmax_element because clang doesn't see through the pointers and as a result doesn't
89 // vectorize the code.
90 if constexpr (contiguous_range<_Range> && is_integral_v<_ValueT> &&
91 __is_cheap_to_copy<_ValueT> & __is_identity<_Proj>::value &&
92 __desugars_to_v<__less_tag, _Comp, _ValueT, _ValueT>) {
93 minmax_result<_ValueT> __result = {__r[0], __r[0]};
94 for (auto __e : __r) {
95 if (__e < __result.min)
96 __result.min = __e;
97 if (__result.max < __e)
98 __result.max = __e;
99 }
100 return __result;
101 } else if constexpr (forward_range<_Range>) {
87102 // Special-case the one element case. Avoid repeatedly initializing objects from the result of an iterator
88103 // dereference when doing so might not be idempotent. The `if constexpr` avoids the extra branch in cases where
89104 // it's not needed.
lib/libcxx/include/__algorithm/ranges_minmax_element.h+2-2
......@@ -46,7 +46,7 @@ struct __fn {
4646 sentinel_for<_Ip> _Sp,
4747 class _Proj = identity,
4848 indirect_strict_weak_order<projected<_Ip, _Proj>> _Comp = ranges::less>
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<_Ip>
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<_Ip>
5050 operator()(_Ip __first, _Sp __last, _Comp __comp = {}, _Proj __proj = {}) const {
5151 auto __ret = std::__minmax_element_impl(std::move(__first), std::move(__last), __comp, __proj);
5252 return {__ret.first, __ret.second};
......@@ -55,7 +55,7 @@ struct __fn {
5555 template <forward_range _Rp,
5656 class _Proj = identity,
5757 indirect_strict_weak_order<projected<iterator_t<_Rp>, _Proj>> _Comp = ranges::less>
58 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
58 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr ranges::minmax_element_result<borrowed_iterator_t<_Rp>>
5959 operator()(_Rp&& __r, _Comp __comp = {}, _Proj __proj = {}) const {
6060 auto __ret = std::__minmax_element_impl(ranges::begin(__r), ranges::end(__r), __comp, __proj);
6161 return {__ret.first, __ret.second};
lib/libcxx/include/__algorithm/ranges_mismatch.h+15-9
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___ALGORITHM_RANGES_MISMATCH_H
1111
1212#include <__algorithm/in_in_result.h>
13#include <__algorithm/mismatch.h>
14#include <__algorithm/unwrap_range.h>
1315#include <__config>
1416#include <__functional/identity.h>
1517#include <__functional/invoke.h>
......@@ -42,13 +44,17 @@ struct __fn {
4244 template <class _I1, class _S1, class _I2, class _S2, class _Pred, class _Proj1, class _Proj2>
4345 static _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2>
4446 __go(_I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
45 while (__first1 != __last1 && __first2 != __last2) {
46 if (!std::invoke(__pred, std::invoke(__proj1, *__first1), std::invoke(__proj2, *__first2)))
47 break;
48 ++__first1;
49 ++__first2;
47 if constexpr (forward_iterator<_I1> && forward_iterator<_I2>) {
48 auto __range1 = std::__unwrap_range(__first1, __last1);
49 auto __range2 = std::__unwrap_range(__first2, __last2);
50 auto __res =
51 std::__mismatch(__range1.first, __range1.second, __range2.first, __range2.second, __pred, __proj1, __proj2);
52 return {std::__rewrap_range<_S1>(__first1, __res.first), std::__rewrap_range<_S2>(__first2, __res.second)};
53 } else {
54 auto __res = std::__mismatch(
55 std::move(__first1), std::move(__last1), std::move(__first2), std::move(__last2), __pred, __proj1, __proj2);
56 return {std::move(__res.first), std::move(__res.second)};
5057 }
51 return {std::move(__first1), std::move(__first2)};
5258 }
5359
5460 template <input_iterator _I1,
......@@ -59,7 +65,7 @@ struct __fn {
5965 class _Proj1 = identity,
6066 class _Proj2 = identity>
6167 requires indirectly_comparable<_I1, _I2, _Pred, _Proj1, _Proj2>
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()(
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<_I1, _I2> operator()(
6369 _I1 __first1, _S1 __last1, _I2 __first2, _S2 __last2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {})
6470 const {
6571 return __go(std::move(__first1), __last1, std::move(__first2), __last2, __pred, __proj1, __proj2);
......@@ -71,8 +77,8 @@ struct __fn {
7177 class _Proj1 = identity,
7278 class _Proj2 = identity>
7379 requires indirectly_comparable<iterator_t<_R1>, iterator_t<_R2>, _Pred, _Proj1, _Proj2>
74 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<borrowed_iterator_t<_R1>,
75 borrowed_iterator_t<_R2>>
80 [[nodiscard]]
81 _LIBCPP_HIDE_FROM_ABI constexpr mismatch_result<borrowed_iterator_t<_R1>, borrowed_iterator_t<_R2>>
7682 operator()(_R1&& __r1, _R2&& __r2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
7783 return __go(
7884 ranges::begin(__r1), ranges::end(__r1), ranges::begin(__r2), ranges::end(__r2), __pred, __proj1, __proj2);
lib/libcxx/include/__algorithm/ranges_none_of.h+2-2
......@@ -46,7 +46,7 @@ struct __fn {
4646 sentinel_for<_Iter> _Sent,
4747 class _Proj = identity,
4848 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5050 operator()(_Iter __first, _Sent __last, _Pred __pred = {}, _Proj __proj = {}) const {
5151 return __none_of_impl(std::move(__first), std::move(__last), __pred, __proj);
5252 }
......@@ -54,7 +54,7 @@ struct __fn {
5454 template <input_range _Range,
5555 class _Proj = identity,
5656 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
57 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool
57 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
5858 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
5959 return __none_of_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
6060 }
lib/libcxx/include/__algorithm/ranges_remove.h+2-2
......@@ -37,7 +37,7 @@ namespace __remove {
3737struct __fn {
3838 template <permutable _Iter, sentinel_for<_Iter> _Sent, class _Type, class _Proj = identity>
3939 requires indirect_binary_predicate<ranges::equal_to, projected<_Iter, _Proj>, const _Type*>
40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
4141 operator()(_Iter __first, _Sent __last, const _Type& __value, _Proj __proj = {}) const {
4242 auto __pred = [&](auto&& __other) -> bool { return __value == __other; };
4343 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
......@@ -46,7 +46,7 @@ struct __fn {
4646 template <forward_range _Range, class _Type, class _Proj = identity>
4747 requires permutable<iterator_t<_Range>> &&
4848 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<_Range>, _Proj>, const _Type*>
49 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
5050 operator()(_Range&& __range, const _Type& __value, _Proj __proj = {}) const {
5151 auto __pred = [&](auto&& __other) -> bool { return __value == __other; };
5252 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
lib/libcxx/include/__algorithm/ranges_remove_if.h+2-2
......@@ -59,7 +59,7 @@ struct __fn {
5959 sentinel_for<_Iter> _Sent,
6060 class _Proj = identity,
6161 indirect_unary_predicate<projected<_Iter, _Proj>> _Pred>
62 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
6363 operator()(_Iter __first, _Sent __last, _Pred __pred, _Proj __proj = {}) const {
6464 return ranges::__remove_if_impl(std::move(__first), std::move(__last), __pred, __proj);
6565 }
......@@ -68,7 +68,7 @@ struct __fn {
6868 class _Proj = identity,
6969 indirect_unary_predicate<projected<iterator_t<_Range>, _Proj>> _Pred>
7070 requires permutable<iterator_t<_Range>>
71 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
71 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
7272 operator()(_Range&& __range, _Pred __pred, _Proj __proj = {}) const {
7373 return ranges::__remove_if_impl(ranges::begin(__range), ranges::end(__range), __pred, __proj);
7474 }
lib/libcxx/include/__algorithm/ranges_search.h+2-2
......@@ -77,7 +77,7 @@ struct __fn {
7777 class _Proj1 = identity,
7878 class _Proj2 = identity>
7979 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
80 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(
80 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter1> operator()(
8181 _Iter1 __first1,
8282 _Sent1 __last1,
8383 _Iter2 __first2,
......@@ -94,7 +94,7 @@ struct __fn {
9494 class _Proj1 = identity,
9595 class _Proj2 = identity>
9696 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
97 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(
97 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range1> operator()(
9898 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
9999 auto __first1 = ranges::begin(__range1);
100100 if constexpr (sized_range<_Range2>) {
lib/libcxx/include/__algorithm/ranges_search_n.h+2-2
......@@ -71,7 +71,7 @@ struct __fn {
7171 class _Pred = ranges::equal_to,
7272 class _Proj = identity>
7373 requires indirectly_comparable<_Iter, const _Type*, _Pred, _Proj>
74 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
74 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
7575 operator()(_Iter __first,
7676 _Sent __last,
7777 iter_difference_t<_Iter> __count,
......@@ -83,7 +83,7 @@ struct __fn {
8383
8484 template <forward_range _Range, class _Type, class _Pred = ranges::equal_to, class _Proj = identity>
8585 requires indirectly_comparable<iterator_t<_Range>, const _Type*, _Pred, _Proj>
86 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range> operator()(
8787 _Range&& __range, range_difference_t<_Range> __count, const _Type& __value, _Pred __pred = {}, _Proj __proj = {})
8888 const {
8989 auto __first = ranges::begin(__range);
lib/libcxx/include/__algorithm/ranges_starts_with.h+4-4
......@@ -42,14 +42,14 @@ struct __fn {
4242 class _Proj1 = identity,
4343 class _Proj2 = identity>
4444 requires indirectly_comparable<_Iter1, _Iter2, _Pred, _Proj1, _Proj2>
45 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
45 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool operator()(
4646 _Iter1 __first1,
4747 _Sent1 __last1,
4848 _Iter2 __first2,
4949 _Sent2 __last2,
5050 _Pred __pred = {},
5151 _Proj1 __proj1 = {},
52 _Proj2 __proj2 = {}) const {
52 _Proj2 __proj2 = {}) {
5353 return __mismatch::__fn::__go(
5454 std::move(__first1),
5555 std::move(__last1),
......@@ -67,8 +67,8 @@ struct __fn {
6767 class _Proj1 = identity,
6868 class _Proj2 = identity>
6969 requires indirectly_comparable<iterator_t<_Range1>, iterator_t<_Range2>, _Pred, _Proj1, _Proj2>
70 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(
71 _Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) const {
70 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr bool
71 operator()(_Range1&& __range1, _Range2&& __range2, _Pred __pred = {}, _Proj1 __proj1 = {}, _Proj2 __proj2 = {}) {
7272 return __mismatch::__fn::__go(
7373 ranges::begin(__range1),
7474 ranges::end(__range1),
lib/libcxx/include/__algorithm/ranges_unique.h+2-2
......@@ -47,7 +47,7 @@ struct __fn {
4747 sentinel_for<_Iter> _Sent,
4848 class _Proj = identity,
4949 indirect_equivalence_relation<projected<_Iter, _Proj>> _Comp = ranges::equal_to>
50 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
50 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr subrange<_Iter>
5151 operator()(_Iter __first, _Sent __last, _Comp __comp = {}, _Proj __proj = {}) const {
5252 auto __ret =
5353 std::__unique<_RangeAlgPolicy>(std::move(__first), std::move(__last), std::__make_projected(__comp, __proj));
......@@ -58,7 +58,7 @@ struct __fn {
5858 class _Proj = identity,
5959 indirect_equivalence_relation<projected<iterator_t<_Range>, _Proj>> _Comp = ranges::equal_to>
6060 requires permutable<iterator_t<_Range>>
61 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_subrange_t<_Range>
6262 operator()(_Range&& __range, _Comp __comp = {}, _Proj __proj = {}) const {
6363 auto __ret = std::__unique<_RangeAlgPolicy>(
6464 ranges::begin(__range), ranges::end(__range), std::__make_projected(__comp, __proj));
lib/libcxx/include/__algorithm/ranges_upper_bound.h+2-2
......@@ -37,7 +37,7 @@ struct __fn {
3737 class _Type,
3838 class _Proj = identity,
3939 indirect_strict_weak_order<const _Type*, projected<_Iter, _Proj>> _Comp = ranges::less>
40 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Iter
40 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Iter
4141 operator()(_Iter __first, _Sent __last, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
4242 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool {
4343 return !std::invoke(__comp, __rhs, __lhs);
......@@ -50,7 +50,7 @@ struct __fn {
5050 class _Type,
5151 class _Proj = identity,
5252 indirect_strict_weak_order<const _Type*, projected<iterator_t<_Range>, _Proj>> _Comp = ranges::less>
53 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
53 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr borrowed_iterator_t<_Range>
5454 operator()(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) const {
5555 auto __comp_lhs_rhs_swapped = [&](const auto& __lhs, const auto& __rhs) -> bool {
5656 return !std::invoke(__comp, __rhs, __lhs);
lib/libcxx/include/__algorithm/remove.h+1-1
......@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template <class _ForwardIterator, class _Tp>
27_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
27_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2828remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
2929 __first = std::find(__first, __last, __value);
3030 if (__first != __last) {
lib/libcxx/include/__algorithm/remove_if.h+1-1
......@@ -23,7 +23,7 @@ _LIBCPP_PUSH_MACROS
2323_LIBCPP_BEGIN_NAMESPACE_STD
2424
2525template <class _ForwardIterator, class _Predicate>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
26_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
2727remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) {
2828 __first = std::find_if<_ForwardIterator, _Predicate&>(__first, __last, __pred);
2929 if (__first != __last) {
lib/libcxx/include/__algorithm/rotate.h+1-1
......@@ -15,7 +15,7 @@
1515#include <__algorithm/swap_ranges.h>
1616#include <__config>
1717#include <__iterator/iterator_traits.h>
18#include <__type_traits/is_trivially_move_assignable.h>
18#include <__type_traits/is_trivially_assignable.h>
1919#include <__utility/move.h>
2020#include <__utility/pair.h>
2121
lib/libcxx/include/__algorithm/search.h+27-24
......@@ -117,17 +117,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc
117117 }
118118}
119119
120template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
120template <class _Iter1,
121 class _Sent1,
122 class _Iter2,
123 class _Sent2,
124 class _Pred,
125 class _Proj1,
126 class _Proj2,
127 __enable_if_t<__has_random_access_iterator_category<_Iter1>::value &&
128 __has_random_access_iterator_category<_Iter2>::value,
129 int> = 0>
121130_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl(
122 _Iter1 __first1,
123 _Sent1 __last1,
124 _Iter2 __first2,
125 _Sent2 __last2,
126 _Pred& __pred,
127 _Proj1& __proj1,
128 _Proj2& __proj2,
129 __enable_if_t<__has_random_access_iterator_category<_Iter1>::value &&
130 __has_random_access_iterator_category<_Iter2>::value>* = nullptr) {
131 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
131132 auto __size2 = __last2 - __first2;
132133 if (__size2 == 0)
133134 return std::make_pair(__first1, __first1);
......@@ -141,23 +142,25 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __searc
141142 __first1, __last1, __first2, __last2, __pred, __proj1, __proj2, __size1, __size2);
142143}
143144
144template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Pred, class _Proj1, class _Proj2>
145_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl(
146 _Iter1 __first1,
147 _Sent1 __last1,
148 _Iter2 __first2,
149 _Sent2 __last2,
150 _Pred& __pred,
151 _Proj1& __proj1,
152 _Proj2& __proj2,
145template <
146 class _Iter1,
147 class _Sent1,
148 class _Iter2,
149 class _Sent2,
150 class _Pred,
151 class _Proj1,
152 class _Proj2,
153153 __enable_if_t<__has_forward_iterator_category<_Iter1>::value && __has_forward_iterator_category<_Iter2>::value &&
154 !(__has_random_access_iterator_category<_Iter1>::value &&
155 __has_random_access_iterator_category<_Iter2>::value)>* = nullptr) {
154 !(__has_random_access_iterator_category<_Iter1>::value &&
155 __has_random_access_iterator_category<_Iter2>::value),
156 int> = 0>
157_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_impl(
158 _Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, _Pred& __pred, _Proj1& __proj1, _Proj2& __proj2) {
156159 return std::__search_forward_impl<_ClassicAlgPolicy>(__first1, __last1, __first2, __last2, __pred, __proj1, __proj2);
157160}
158161
159162template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
160_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
163_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
161164search(_ForwardIterator1 __first1,
162165 _ForwardIterator1 __last1,
163166 _ForwardIterator2 __first2,
......@@ -170,14 +173,14 @@ search(_ForwardIterator1 __first1,
170173}
171174
172175template <class _ForwardIterator1, class _ForwardIterator2>
173_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
176_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1
174177search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) {
175178 return std::search(__first1, __last1, __first2, __last2, __equal_to());
176179}
177180
178181#if _LIBCPP_STD_VER >= 17
179182template <class _ForwardIterator, class _Searcher>
180_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
183[[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
181184search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher& __s) {
182185 return __s(__f, __l).first;
183186}
lib/libcxx/include/__algorithm/search_n.h+22-21
......@@ -108,34 +108,35 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 std::pair<_Iter, _Iter> __se
108108 }
109109}
110110
111template <class _Iter, class _Sent, class _DiffT, class _Type, class _Pred, class _Proj>
112_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter> __search_n_impl(
113 _Iter __first,
114 _Sent __last,
115 _DiffT __count,
116 const _Type& __value,
117 _Pred& __pred,
118 _Proj& __proj,
119 __enable_if_t<__has_random_access_iterator_category<_Iter>::value>* = nullptr) {
111template <class _Iter,
112 class _Sent,
113 class _DiffT,
114 class _Type,
115 class _Pred,
116 class _Proj,
117 __enable_if_t<__has_random_access_iterator_category<_Iter>::value, int> = 0>
118_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter, _Iter>
119__search_n_impl(_Iter __first, _Sent __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
120120 return std::__search_n_random_access_impl<_ClassicAlgPolicy>(
121121 __first, __last, __count, __value, __pred, __proj, __last - __first);
122122}
123123
124template <class _Iter1, class _Sent1, class _DiffT, class _Type, class _Pred, class _Proj>
125_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __search_n_impl(
126 _Iter1 __first,
127 _Sent1 __last,
128 _DiffT __count,
129 const _Type& __value,
130 _Pred& __pred,
131 _Proj& __proj,
132 __enable_if_t<__has_forward_iterator_category<_Iter1>::value &&
133 !__has_random_access_iterator_category<_Iter1>::value>* = nullptr) {
124template <class _Iter1,
125 class _Sent1,
126 class _DiffT,
127 class _Type,
128 class _Pred,
129 class _Proj,
130 __enable_if_t<__has_forward_iterator_category<_Iter1>::value &&
131 !__has_random_access_iterator_category<_Iter1>::value,
132 int> = 0>
133_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1>
134__search_n_impl(_Iter1 __first, _Sent1 __last, _DiffT __count, const _Type& __value, _Pred& __pred, _Proj& __proj) {
134135 return std::__search_n_forward_impl<_ClassicAlgPolicy>(__first, __last, __count, __value, __pred, __proj);
135136}
136137
137138template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
138_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(
139_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator search_n(
139140 _ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value, _BinaryPredicate __pred) {
140141 static_assert(
141142 __is_callable<_BinaryPredicate, decltype(*__first), const _Tp&>::value, "BinaryPredicate has to be callable");
......@@ -144,7 +145,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
144145}
145146
146147template <class _ForwardIterator, class _Size, class _Tp>
147_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
148_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
148149search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value) {
149150 return std::search_n(__first, __last, std::__convert_to_integral(__count), __value, __equal_to());
150151}
lib/libcxx/include/__algorithm/set_intersection.h+118-4
......@@ -12,10 +12,15 @@
1212#include <__algorithm/comp.h>
1313#include <__algorithm/comp_ref_type.h>
1414#include <__algorithm/iterator_operations.h>
15#include <__algorithm/lower_bound.h>
1516#include <__config>
17#include <__functional/identity.h>
1618#include <__iterator/iterator_traits.h>
1719#include <__iterator/next.h>
20#include <__type_traits/is_same.h>
21#include <__utility/exchange.h>
1822#include <__utility/move.h>
23#include <__utility/swap.h>
1924
2025#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2126# pragma GCC system_header
......@@ -38,10 +43,103 @@ struct __set_intersection_result {
3843 : __in1_(std::move(__in_iter1)), __in2_(std::move(__in_iter2)), __out_(std::move(__out_iter)) {}
3944};
4045
41template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
46// Helper for __set_intersection() with one-sided binary search: populate result and advance input iterators if they
47// are found to potentially contain the same value in two consecutive calls. This function is very intimately related to
48// the way it is used and doesn't attempt to abstract that, it's not appropriate for general usage outside of its
49// context.
50template <class _InForwardIter1, class _InForwardIter2, class _OutIter>
51_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __set_intersection_add_output_if_equal(
52 bool __may_be_equal,
53 _InForwardIter1& __first1,
54 _InForwardIter2& __first2,
55 _OutIter& __result,
56 bool& __prev_may_be_equal) {
57 if (__may_be_equal && __prev_may_be_equal) {
58 *__result = *__first1;
59 ++__result;
60 ++__first1;
61 ++__first2;
62 __prev_may_be_equal = false;
63 } else {
64 __prev_may_be_equal = __may_be_equal;
65 }
66}
67
68// With forward iterators we can make multiple passes over the data, allowing the use of one-sided binary search to
69// reduce best-case complexity to log(N). Understanding how we can use binary search and still respect complexity
70// guarantees is _not_ straightforward: the guarantee is "at most 2*(N+M)-1 comparisons", and one-sided binary search
71// will necessarily overshoot depending on the position of the needle in the haystack -- for instance, if we're
72// searching for 3 in (1, 2, 3, 4), we'll check if 3<1, then 3<2, then 3<4, and, finally, 3<3, for a total of 4
73// comparisons, when linear search would have yielded 3. However, because we won't need to perform the intervening
74// reciprocal comparisons (ie 1<3, 2<3, 4<3), that extra comparison doesn't run afoul of the guarantee. Additionally,
75// this type of scenario can only happen for match distances of up to 5 elements, because 2*log2(8) is 6, and we'll
76// still be worse-off at position 5 of an 8-element set. From then onwards these scenarios can't happen. TL;DR: we'll be
77// 1 comparison worse-off compared to the classic linear-searching algorithm if matching position 3 of a set with 4
78// elements, or position 5 if the set has 7 or 8 elements, but we'll never exceed the complexity guarantees from the
79// standard.
80template <class _AlgPolicy,
81 class _Compare,
82 class _InForwardIter1,
83 class _Sent1,
84 class _InForwardIter2,
85 class _Sent2,
86 class _OutIter>
87_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI
88_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>
4389__set_intersection(
44 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
90 _InForwardIter1 __first1,
91 _Sent1 __last1,
92 _InForwardIter2 __first2,
93 _Sent2 __last2,
94 _OutIter __result,
95 _Compare&& __comp,
96 std::forward_iterator_tag,
97 std::forward_iterator_tag) {
98 _LIBCPP_CONSTEXPR std::__identity __proj;
99 bool __prev_may_be_equal = false;
100
101 while (__first2 != __last2) {
102 _InForwardIter1 __first1_next =
103 std::__lower_bound_onesided<_AlgPolicy>(__first1, __last1, *__first2, __comp, __proj);
104 std::swap(__first1_next, __first1);
105 // keeping in mind that a==b iff !(a<b) && !(b<a):
106 // if we can't advance __first1, that means !(*__first1 < *_first2), therefore __may_be_equal==true
107 std::__set_intersection_add_output_if_equal(
108 __first1 == __first1_next, __first1, __first2, __result, __prev_may_be_equal);
109 if (__first1 == __last1)
110 break;
111
112 _InForwardIter2 __first2_next =
113 std::__lower_bound_onesided<_AlgPolicy>(__first2, __last2, *__first1, __comp, __proj);
114 std::swap(__first2_next, __first2);
115 std::__set_intersection_add_output_if_equal(
116 __first2 == __first2_next, __first1, __first2, __result, __prev_may_be_equal);
117 }
118 return __set_intersection_result<_InForwardIter1, _InForwardIter2, _OutIter>(
119 _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)),
120 _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)),
121 std::move(__result));
122}
123
124// input iterators are not suitable for multipass algorithms, so we stick to the classic single-pass version
125template <class _AlgPolicy,
126 class _Compare,
127 class _InInputIter1,
128 class _Sent1,
129 class _InInputIter2,
130 class _Sent2,
131 class _OutIter>
132_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI
133_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>
134__set_intersection(
135 _InInputIter1 __first1,
136 _Sent1 __last1,
137 _InInputIter2 __first2,
138 _Sent2 __last2,
139 _OutIter __result,
140 _Compare&& __comp,
141 std::input_iterator_tag,
142 std::input_iterator_tag) {
45143 while (__first1 != __last1 && __first2 != __last2) {
46144 if (__comp(*__first1, *__first2))
47145 ++__first1;
......@@ -55,12 +153,28 @@ __set_intersection(
55153 }
56154 }
57155
58 return __set_intersection_result<_InIter1, _InIter2, _OutIter>(
156 return __set_intersection_result<_InInputIter1, _InInputIter2, _OutIter>(
59157 _IterOps<_AlgPolicy>::next(std::move(__first1), std::move(__last1)),
60158 _IterOps<_AlgPolicy>::next(std::move(__first2), std::move(__last2)),
61159 std::move(__result));
62160}
63161
162template <class _AlgPolicy, class _Compare, class _InIter1, class _Sent1, class _InIter2, class _Sent2, class _OutIter>
163_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI
164_LIBCPP_CONSTEXPR_SINCE_CXX20 __set_intersection_result<_InIter1, _InIter2, _OutIter>
165__set_intersection(
166 _InIter1 __first1, _Sent1 __last1, _InIter2 __first2, _Sent2 __last2, _OutIter __result, _Compare&& __comp) {
167 return std::__set_intersection<_AlgPolicy>(
168 std::move(__first1),
169 std::move(__last1),
170 std::move(__first2),
171 std::move(__last2),
172 std::move(__result),
173 std::forward<_Compare>(__comp),
174 typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter1>(),
175 typename std::_IterOps<_AlgPolicy>::template __iterator_category<_InIter2>());
176}
177
64178template <class _InputIterator1, class _InputIterator2, class _OutputIterator, class _Compare>
65179inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator set_intersection(
66180 _InputIterator1 __first1,
lib/libcxx/include/__algorithm/simd_utils.h created+164
......@@ -0,0 +1,164 @@
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_SIMD_UTILS_H
10#define _LIBCPP___ALGORITHM_SIMD_UTILS_H
11
12#include <__algorithm/min.h>
13#include <__bit/bit_cast.h>
14#include <__bit/countl.h>
15#include <__bit/countr.h>
16#include <__config>
17#include <__type_traits/is_arithmetic.h>
18#include <__type_traits/is_same.h>
19#include <__utility/integer_sequence.h>
20#include <cstddef>
21#include <cstdint>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>
29
30// TODO: Find out how altivec changes things and allow vectorizations there too.
31#if _LIBCPP_STD_VER >= 14 && defined(_LIBCPP_CLANG_VER) && !defined(__ALTIVEC__)
32# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 1
33#else
34# define _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS 0
35#endif
36
37#if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS && !defined(__OPTIMIZE_SIZE__)
38# define _LIBCPP_VECTORIZE_ALGORITHMS 1
39#else
40# define _LIBCPP_VECTORIZE_ALGORITHMS 0
41#endif
42
43#if _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS
44
45_LIBCPP_BEGIN_NAMESPACE_STD
46
47template <class _Tp>
48inline constexpr bool __can_map_to_integer_v =
49 sizeof(_Tp) == alignof(_Tp) && (sizeof(_Tp) == 1 || sizeof(_Tp) == 2 || sizeof(_Tp) == 4 || sizeof(_Tp) == 8);
50
51template <size_t _TypeSize>
52struct __get_as_integer_type_impl;
53
54template <>
55struct __get_as_integer_type_impl<1> {
56 using type = uint8_t;
57};
58
59template <>
60struct __get_as_integer_type_impl<2> {
61 using type = uint16_t;
62};
63template <>
64struct __get_as_integer_type_impl<4> {
65 using type = uint32_t;
66};
67template <>
68struct __get_as_integer_type_impl<8> {
69 using type = uint64_t;
70};
71
72template <class _Tp>
73using __get_as_integer_type_t = typename __get_as_integer_type_impl<sizeof(_Tp)>::type;
74
75// This isn't specialized for 64 byte vectors on purpose. They have the potential to significantly reduce performance
76// in mixed simd/non-simd workloads and don't provide any performance improvement for currently vectorized algorithms
77// as far as benchmarks are concerned.
78# if defined(__AVX__) || defined(__MVS__)
79template <class _Tp>
80inline constexpr size_t __native_vector_size = 32 / sizeof(_Tp);
81# elif defined(__SSE__) || defined(__ARM_NEON__)
82template <class _Tp>
83inline constexpr size_t __native_vector_size = 16 / sizeof(_Tp);
84# elif defined(__MMX__)
85template <class _Tp>
86inline constexpr size_t __native_vector_size = 8 / sizeof(_Tp);
87# else
88template <class _Tp>
89inline constexpr size_t __native_vector_size = 1;
90# endif
91
92template <class _ArithmeticT, size_t _Np>
93using __simd_vector __attribute__((__ext_vector_type__(_Np))) = _ArithmeticT;
94
95template <class _VecT>
96inline constexpr size_t __simd_vector_size_v = []<bool _False = false>() -> size_t {
97 static_assert(_False, "Not a vector!");
98}();
99
100template <class _Tp, size_t _Np>
101inline constexpr size_t __simd_vector_size_v<__simd_vector<_Tp, _Np>> = _Np;
102
103template <class _Tp, size_t _Np>
104_LIBCPP_HIDE_FROM_ABI _Tp __simd_vector_underlying_type_impl(__simd_vector<_Tp, _Np>) {
105 return _Tp{};
106}
107
108template <class _VecT>
109using __simd_vector_underlying_type_t = decltype(std::__simd_vector_underlying_type_impl(_VecT{}));
110
111// This isn't inlined without always_inline when loading chars.
112template <class _VecT, class _Iter>
113_LIBCPP_NODISCARD _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _VecT __load_vector(_Iter __iter) noexcept {
114 return [=]<size_t... _Indices>(index_sequence<_Indices...>) _LIBCPP_ALWAYS_INLINE noexcept {
115 return _VecT{__iter[_Indices]...};
116 }(make_index_sequence<__simd_vector_size_v<_VecT>>{});
117}
118
119template <class _Tp, size_t _Np>
120_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool __all_of(__simd_vector<_Tp, _Np> __vec) noexcept {
121 return __builtin_reduce_and(__builtin_convertvector(__vec, __simd_vector<bool, _Np>));
122}
123
124template <class _Tp, size_t _Np>
125_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_set(__simd_vector<_Tp, _Np> __vec) noexcept {
126 using __mask_vec = __simd_vector<bool, _Np>;
127
128 // This has MSan disabled du to https://github.com/llvm/llvm-project/issues/85876
129 auto __impl = [&]<class _MaskT>(_MaskT) _LIBCPP_NO_SANITIZE("memory") noexcept {
130# if defined(_LIBCPP_BIG_ENDIAN)
131 return std::min<size_t>(
132 _Np, std::__countl_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec))));
133# else
134 return std::min<size_t>(
135 _Np, std::__countr_zero(__builtin_bit_cast(_MaskT, __builtin_convertvector(__vec, __mask_vec))));
136# endif
137 };
138
139 if constexpr (sizeof(__mask_vec) == sizeof(uint8_t)) {
140 return __impl(uint8_t{});
141 } else if constexpr (sizeof(__mask_vec) == sizeof(uint16_t)) {
142 return __impl(uint16_t{});
143 } else if constexpr (sizeof(__mask_vec) == sizeof(uint32_t)) {
144 return __impl(uint32_t{});
145 } else if constexpr (sizeof(__mask_vec) == sizeof(uint64_t)) {
146 return __impl(uint64_t{});
147 } else {
148 static_assert(sizeof(__mask_vec) == 0, "unexpected required size for mask integer type");
149 return 0;
150 }
151}
152
153template <class _Tp, size_t _Np>
154_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI size_t __find_first_not_set(__simd_vector<_Tp, _Np> __vec) noexcept {
155 return std::__find_first_set(~__vec);
156}
157
158_LIBCPP_END_NAMESPACE_STD
159
160#endif // _LIBCPP_HAS_ALGORITHM_VECTOR_UTILS
161
162_LIBCPP_POP_MACROS
163
164#endif // _LIBCPP___ALGORITHM_SIMD_UTILS_H
lib/libcxx/include/__algorithm/sort.h+2-3
......@@ -696,9 +696,8 @@ __partition_with_equals_on_left(_RandomAccessIterator __first, _RandomAccessIter
696696 using _Ops = _IterOps<_AlgPolicy>;
697697 typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
698698 typedef typename std::iterator_traits<_RandomAccessIterator>::value_type value_type;
699 // TODO(LLVM18): Make __begin const, see https://reviews.llvm.org/D147089#4349748
700 _RandomAccessIterator __begin = __first; // used for bounds checking, those are not moved around
701 const _RandomAccessIterator __end = __last;
699 const _RandomAccessIterator __begin = __first; // used for bounds checking, those are not moved around
700 const _RandomAccessIterator __end = __last;
702701 (void)__end; //
703702 value_type __pivot(_Ops::__iter_move(__first));
704703 if (__comp(__pivot, *(__last - difference_type(1)))) {
lib/libcxx/include/__algorithm/sort_heap.h+2-2
......@@ -16,8 +16,8 @@
1616#include <__config>
1717#include <__debug_utils/strict_weak_ordering_check.h>
1818#include <__iterator/iterator_traits.h>
19#include <__type_traits/is_copy_assignable.h>
20#include <__type_traits/is_copy_constructible.h>
19#include <__type_traits/is_assignable.h>
20#include <__type_traits/is_constructible.h>
2121#include <__utility/move.h>
2222
2323#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__algorithm/stable_sort.h+1-1
......@@ -20,7 +20,7 @@
2020#include <__memory/destruct_n.h>
2121#include <__memory/temporary_buffer.h>
2222#include <__memory/unique_ptr.h>
23#include <__type_traits/is_trivially_copy_assignable.h>
23#include <__type_traits/is_trivially_assignable.h>
2424#include <__utility/move.h>
2525#include <__utility/pair.h>
2626#include <new>
lib/libcxx/include/__algorithm/unique.h+3-3
......@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929// unique
3030
3131template <class _AlgPolicy, class _Iter, class _Sent, class _BinaryPredicate>
32_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
32_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 std::pair<_Iter, _Iter>
3333__unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
3434 __first = std::__adjacent_find(__first, __last, __pred);
3535 if (__first != __last) {
......@@ -46,13 +46,13 @@ __unique(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
4646}
4747
4848template <class _ForwardIterator, class _BinaryPredicate>
49_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
49_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5050unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
5151 return std::__unique<_ClassicAlgPolicy>(std::move(__first), std::move(__last), __pred).first;
5252}
5353
5454template <class _ForwardIterator>
55_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
55_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5656unique(_ForwardIterator __first, _ForwardIterator __last) {
5757 return std::unique(__first, __last, __equal_to());
5858}
lib/libcxx/include/__algorithm/unwrap_iter.h+1-1
......@@ -13,7 +13,7 @@
1313#include <__iterator/iterator_traits.h>
1414#include <__memory/pointer_traits.h>
1515#include <__type_traits/enable_if.h>
16#include <__type_traits/is_copy_constructible.h>
16#include <__type_traits/is_constructible.h>
1717#include <__utility/declval.h>
1818#include <__utility/move.h>
1919
lib/libcxx/include/__algorithm/upper_bound.h+3-3
......@@ -18,7 +18,7 @@
1818#include <__iterator/advance.h>
1919#include <__iterator/distance.h>
2020#include <__iterator/iterator_traits.h>
21#include <__type_traits/is_copy_constructible.h>
21#include <__type_traits/is_constructible.h>
2222#include <__utility/move.h>
2323
2424#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -48,7 +48,7 @@ __upper_bound(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp
4848}
4949
5050template <class _ForwardIterator, class _Tp, class _Compare>
51_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
51_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
5252upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
5353 static_assert(is_copy_constructible<_ForwardIterator>::value, "Iterator has to be copy constructible");
5454 return std::__upper_bound<_ClassicAlgPolicy>(
......@@ -56,7 +56,7 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
5656}
5757
5858template <class _ForwardIterator, class _Tp>
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
6060upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
6161 return std::upper_bound(std::move(__first), std::move(__last), __value, __less<>());
6262}
lib/libcxx/include/__assert+81
......@@ -34,4 +34,85 @@
3434# define _LIBCPP_ASSUME(expression) ((void)0)
3535#endif
3636
37// clang-format off
38// Fast hardening mode checks.
39
40#if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
41
42// Enabled checks.
43# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
44# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
45// Disabled checks.
46// On most modern platforms, dereferencing a null pointer does not lead to an actual memory access.
47# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)
48// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
49// vulnerability.
50# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
51# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)
52# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)
53# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
54# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)
55# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)
56# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
57# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
58# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
59
60// Extensive hardening mode checks.
61
62#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
63
64// Enabled checks.
65# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
66# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
67# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message)
68# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
69# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message)
70# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message)
71# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
72# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message)
73# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)
74# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
75// Disabled checks.
76# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
77# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
78
79// Debug hardening mode checks.
80
81#elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
82
83// All checks enabled.
84# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
85# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
86# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message)
87# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
88# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message)
89# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message)
90# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
91# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message)
92# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)
93# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSERT(expression, message)
94# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
95# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
96
97// Disable all checks if hardening is not enabled.
98
99#else
100
101// All checks disabled.
102# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression)
103# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression)
104# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)
105# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
106# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)
107# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)
108# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
109# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)
110# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)
111# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
112# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
113# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
114
115#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
116// clang-format on
117
37118#endif // _LIBCPP___ASSERT
lib/libcxx/include/__assertion_handler+11-2
......@@ -23,8 +23,17 @@
2323
2424#else
2525
26// TODO(hardening): use `__builtin_verbose_trap(message)` once that becomes available.
27# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
26# if __has_builtin(__builtin_verbose_trap)
27// AppleClang shipped a slightly different version of __builtin_verbose_trap from the upstream
28// version before upstream Clang actually got the builtin.
29# if defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 17000
30# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap(message)
31# else
32# define _LIBCPP_ASSERTION_HANDLER(message) __builtin_verbose_trap("libc++", message)
33# endif
34# else
35# define _LIBCPP_ASSERTION_HANDLER(message) ((void)message, __builtin_trap())
36# endif
2837
2938#endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
3039
lib/libcxx/include/__atomic/aliases.h+1-2
......@@ -18,7 +18,6 @@
1818#include <__type_traits/make_unsigned.h>
1919#include <cstddef>
2020#include <cstdint>
21#include <cstdlib>
2221
2322#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2423# pragma GCC system_header
......@@ -92,7 +91,7 @@ using __largest_lock_free_type = short;
9291# elif ATOMIC_CHAR_LOCK_FREE == 2
9392using __largest_lock_free_type = char;
9493# else
95# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen in freestanding)
94# define _LIBCPP_NO_LOCK_FREE_TYPES // There are no lockfree types (this can happen on unusual platforms)
9695# endif
9796
9897# ifndef _LIBCPP_NO_LOCK_FREE_TYPES
lib/libcxx/include/__atomic/atomic.h+8-4
......@@ -462,22 +462,26 @@ atomic_wait_explicit(const atomic<_Tp>* __o, typename atomic<_Tp>::value_type __
462462// atomic_notify_one
463463
464464template <class _Tp>
465_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
465_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
466atomic_notify_one(volatile atomic<_Tp>* __o) _NOEXCEPT {
466467 __o->notify_one();
467468}
468469template <class _Tp>
469_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
470_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
471atomic_notify_one(atomic<_Tp>* __o) _NOEXCEPT {
470472 __o->notify_one();
471473}
472474
473475// atomic_notify_all
474476
475477template <class _Tp>
476_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
478_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
479atomic_notify_all(volatile atomic<_Tp>* __o) _NOEXCEPT {
477480 __o->notify_all();
478481}
479482template <class _Tp>
480_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
483_LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
484atomic_notify_all(atomic<_Tp>* __o) _NOEXCEPT {
481485 __o->notify_all();
482486}
483487
lib/libcxx/include/__atomic/atomic_base.h+34-18
......@@ -14,11 +14,10 @@
1414#include <__atomic/cxx_atomic_impl.h>
1515#include <__atomic/is_always_lock_free.h>
1616#include <__atomic/memory_order.h>
17#include <__availability>
1817#include <__config>
1918#include <__memory/addressof.h>
2019#include <__type_traits/is_integral.h>
21#include <__type_traits/is_nothrow_default_constructible.h>
20#include <__type_traits/is_nothrow_constructible.h>
2221#include <__type_traits/is_same.h>
2322#include <version>
2423
......@@ -34,7 +33,7 @@ struct __atomic_base // false
3433 mutable __cxx_atomic_impl<_Tp> __a_;
3534
3635#if _LIBCPP_STD_VER >= 17
37 static _LIBCPP_CONSTEXPR bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
36 static constexpr bool is_always_lock_free = __libcpp_is_always_lock_free<__cxx_atomic_impl<_Tp> >::__value;
3837#endif
3938
4039 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const volatile _NOEXCEPT {
......@@ -104,24 +103,20 @@ struct __atomic_base // false
104103
105104 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(_Tp __v, memory_order __m = memory_order_seq_cst) const
106105 volatile _NOEXCEPT {
107 std::__cxx_atomic_wait(std::addressof(__a_), __v, __m);
106 std::__atomic_wait(*this, __v, __m);
108107 }
109108 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
110109 wait(_Tp __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
111 std::__cxx_atomic_wait(std::addressof(__a_), __v, __m);
110 std::__atomic_wait(*this, __v, __m);
112111 }
113112 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
114 std::__cxx_atomic_notify_one(std::addressof(__a_));
115 }
116 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT {
117 std::__cxx_atomic_notify_one(std::addressof(__a_));
113 std::__atomic_notify_one(*this);
118114 }
115 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { std::__atomic_notify_one(*this); }
119116 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
120 std::__cxx_atomic_notify_all(std::addressof(__a_));
121 }
122 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT {
123 std::__cxx_atomic_notify_all(std::addressof(__a_));
117 std::__atomic_notify_all(*this);
124118 }
119 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { std::__atomic_notify_all(*this); }
125120
126121#if _LIBCPP_STD_VER >= 20
127122 _LIBCPP_HIDE_FROM_ABI constexpr __atomic_base() noexcept(is_nothrow_default_constructible_v<_Tp>) : __a_(_Tp()) {}
......@@ -134,11 +129,6 @@ struct __atomic_base // false
134129 __atomic_base(const __atomic_base&) = delete;
135130};
136131
137#if _LIBCPP_STD_VER >= 17
138template <class _Tp, bool __b>
139_LIBCPP_CONSTEXPR bool __atomic_base<_Tp, __b>::is_always_lock_free;
140#endif
141
142132// atomic<Integral>
143133
144134template <class _Tp>
......@@ -200,6 +190,32 @@ struct __atomic_base<_Tp, true> : public __atomic_base<_Tp, false> {
200190 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __op) _NOEXCEPT { return fetch_xor(__op) ^ __op; }
201191};
202192
193// Here we need _IsIntegral because the default template argument is not enough
194// e.g __atomic_base<int> is __atomic_base<int, true>, which inherits from
195// __atomic_base<int, false> and the caller of the wait function is
196// __atomic_base<int, false>. So specializing __atomic_base<_Tp> does not work
197template <class _Tp, bool _IsIntegral>
198struct __atomic_waitable_traits<__atomic_base<_Tp, _IsIntegral> > {
199 static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_base<_Tp, _IsIntegral>& __a, memory_order __order) {
200 return __a.load(__order);
201 }
202
203 static _LIBCPP_HIDE_FROM_ABI _Tp
204 __atomic_load(const volatile __atomic_base<_Tp, _IsIntegral>& __this, memory_order __order) {
205 return __this.load(__order);
206 }
207
208 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_Tp>*
209 __atomic_contention_address(const __atomic_base<_Tp, _IsIntegral>& __a) {
210 return std::addressof(__a.__a_);
211 }
212
213 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_Tp>*
214 __atomic_contention_address(const volatile __atomic_base<_Tp, _IsIntegral>& __this) {
215 return std::addressof(__this.__a_);
216 }
217};
218
203219_LIBCPP_END_NAMESPACE_STD
204220
205221#endif // _LIBCPP___ATOMIC_ATOMIC_BASE_H
lib/libcxx/include/__atomic/atomic_flag.h+48-19
......@@ -15,7 +15,8 @@
1515#include <__atomic/memory_order.h>
1616#include <__chrono/duration.h>
1717#include <__config>
18#include <__threading_support>
18#include <__memory/addressof.h>
19#include <__thread/support.h>
1920#include <cstdint>
2021
2122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -47,22 +48,26 @@ struct atomic_flag {
4748 __cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);
4849 }
4950
50 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait(bool __v, memory_order __m = memory_order_seq_cst) const
51 volatile _NOEXCEPT {
52 __cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
51 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
52 wait(bool __v, memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT {
53 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
5354 }
54 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
55 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
5556 wait(bool __v, memory_order __m = memory_order_seq_cst) const _NOEXCEPT {
56 __cxx_atomic_wait(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
57 std::__atomic_wait(*this, _LIBCPP_ATOMIC_FLAG_TYPE(__v), __m);
5758 }
58 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
59 __cxx_atomic_notify_one(&__a_);
59 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() volatile _NOEXCEPT {
60 std::__atomic_notify_one(*this);
61 }
62 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT {
63 std::__atomic_notify_one(*this);
6064 }
61 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_one() _NOEXCEPT { __cxx_atomic_notify_one(&__a_); }
6265 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() volatile _NOEXCEPT {
63 __cxx_atomic_notify_all(&__a_);
66 std::__atomic_notify_all(*this);
67 }
68 _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT {
69 std::__atomic_notify_all(*this);
6470 }
65 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void notify_all() _NOEXCEPT { __cxx_atomic_notify_all(&__a_); }
6671
6772#if _LIBCPP_STD_VER >= 20
6873 _LIBCPP_HIDE_FROM_ABI constexpr atomic_flag() _NOEXCEPT : __a_(false) {}
......@@ -77,6 +82,28 @@ struct atomic_flag {
7782 atomic_flag& operator=(const atomic_flag&) volatile = delete;
7883};
7984
85template <>
86struct __atomic_waitable_traits<atomic_flag> {
87 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE __atomic_load(const atomic_flag& __a, memory_order __order) {
88 return std::__cxx_atomic_load(&__a.__a_, __order);
89 }
90
91 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_ATOMIC_FLAG_TYPE
92 __atomic_load(const volatile atomic_flag& __a, memory_order __order) {
93 return std::__cxx_atomic_load(&__a.__a_, __order);
94 }
95
96 static _LIBCPP_HIDE_FROM_ABI const __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>*
97 __atomic_contention_address(const atomic_flag& __a) {
98 return std::addressof(__a.__a_);
99 }
100
101 static _LIBCPP_HIDE_FROM_ABI const volatile __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE>*
102 __atomic_contention_address(const volatile atomic_flag& __a) {
103 return std::addressof(__a.__a_);
104 }
105};
106
80107inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const volatile atomic_flag* __o) _NOEXCEPT { return __o->test(); }
81108
82109inline _LIBCPP_HIDE_FROM_ABI bool atomic_flag_test(const atomic_flag* __o) _NOEXCEPT { return __o->test(); }
......@@ -117,41 +144,43 @@ inline _LIBCPP_HIDE_FROM_ABI void atomic_flag_clear_explicit(atomic_flag* __o, m
117144 __o->clear(__m);
118145}
119146
120inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
147inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
121148atomic_flag_wait(const volatile atomic_flag* __o, bool __v) _NOEXCEPT {
122149 __o->wait(__v);
123150}
124151
125inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
152inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
126153atomic_flag_wait(const atomic_flag* __o, bool __v) _NOEXCEPT {
127154 __o->wait(__v);
128155}
129156
130inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
157inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
131158atomic_flag_wait_explicit(const volatile atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
132159 __o->wait(__v, __m);
133160}
134161
135inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
162inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
136163atomic_flag_wait_explicit(const atomic_flag* __o, bool __v, memory_order __m) _NOEXCEPT {
137164 __o->wait(__v, __m);
138165}
139166
140inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
167inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
141168atomic_flag_notify_one(volatile atomic_flag* __o) _NOEXCEPT {
142169 __o->notify_one();
143170}
144171
145inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
172inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
173atomic_flag_notify_one(atomic_flag* __o) _NOEXCEPT {
146174 __o->notify_one();
147175}
148176
149inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
177inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
150178atomic_flag_notify_all(volatile atomic_flag* __o) _NOEXCEPT {
151179 __o->notify_all();
152180}
153181
154inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
182inline _LIBCPP_DEPRECATED_ATOMIC_SYNC _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_SYNC void
183atomic_flag_notify_all(atomic_flag* __o) _NOEXCEPT {
155184 __o->notify_all();
156185}
157186
lib/libcxx/include/__atomic/atomic_init.h+3-5
......@@ -15,12 +15,10 @@
1515# pragma GCC system_header
1616#endif
1717
18#define ATOMIC_FLAG_INIT \
19 { false }
20#define ATOMIC_VAR_INIT(__v) \
21 { __v }
18#define ATOMIC_FLAG_INIT {false}
19#define ATOMIC_VAR_INIT(__v) {__v}
2220
23#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
21#if _LIBCPP_STD_VER >= 20 && defined(_LIBCPP_COMPILER_CLANG_BASED) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
2422# pragma clang deprecated(ATOMIC_VAR_INIT)
2523#endif
2624
lib/libcxx/include/__atomic/atomic_ref.h created+378
......@@ -0,0 +1,378 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8// Kokkos v. 4.0
9// Copyright (2022) National Technology & Engineering
10// Solutions of Sandia, LLC (NTESS).
11//
12// Under the terms of Contract DE-NA0003525 with NTESS,
13// the U.S. Government retains certain rights in this software.
14//
15//===---------------------------------------------------------------------===//
16
17#ifndef _LIBCPP___ATOMIC_ATOMIC_REF_H
18#define _LIBCPP___ATOMIC_ATOMIC_REF_H
19
20#include <__assert>
21#include <__atomic/atomic_sync.h>
22#include <__atomic/check_memory_order.h>
23#include <__atomic/to_gcc_order.h>
24#include <__concepts/arithmetic.h>
25#include <__concepts/same_as.h>
26#include <__config>
27#include <__memory/addressof.h>
28#include <__type_traits/has_unique_object_representation.h>
29#include <__type_traits/is_trivially_copyable.h>
30#include <cstddef>
31#include <cstdint>
32#include <cstring>
33
34#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
35# pragma GCC system_header
36#endif
37
38_LIBCPP_PUSH_MACROS
39#include <__undef_macros>
40
41_LIBCPP_BEGIN_NAMESPACE_STD
42
43#if _LIBCPP_STD_VER >= 20
44
45// These types are required to make __atomic_is_always_lock_free work across GCC and Clang.
46// The purpose of this trick is to make sure that we provide an object with the correct alignment
47// to __atomic_is_always_lock_free, since that answer depends on the alignment.
48template <size_t _Alignment>
49struct __alignment_checker_type {
50 alignas(_Alignment) char __data;
51};
52
53template <size_t _Alignment>
54struct __get_aligner_instance {
55 static constexpr __alignment_checker_type<_Alignment> __instance{};
56};
57
58template <class _Tp>
59struct __atomic_ref_base {
60private:
61 _LIBCPP_HIDE_FROM_ABI static _Tp* __clear_padding(_Tp& __val) noexcept {
62 _Tp* __ptr = std::addressof(__val);
63# if __has_builtin(__builtin_clear_padding)
64 __builtin_clear_padding(__ptr);
65# endif
66 return __ptr;
67 }
68
69 _LIBCPP_HIDE_FROM_ABI static bool __compare_exchange(
70 _Tp* __ptr, _Tp* __expected, _Tp* __desired, bool __is_weak, int __success, int __failure) noexcept {
71 if constexpr (
72# if __has_builtin(__builtin_clear_padding)
73 has_unique_object_representations_v<_Tp> || floating_point<_Tp>
74# else
75 true // NOLINT(readability-simplify-boolean-expr)
76# endif
77 ) {
78 return __atomic_compare_exchange(__ptr, __expected, __desired, __is_weak, __success, __failure);
79 } else { // _Tp has padding bits and __builtin_clear_padding is available
80 __clear_padding(*__desired);
81 _Tp __copy = *__expected;
82 __clear_padding(__copy);
83 // The algorithm we use here is basically to perform `__atomic_compare_exchange` on the
84 // values until it has either succeeded, or failed because the value representation of the
85 // objects involved was different. This is why we loop around __atomic_compare_exchange:
86 // we basically loop until its failure is caused by the value representation of the objects
87 // being different, not only their object representation.
88 while (true) {
89 _Tp __prev = __copy;
90 if (__atomic_compare_exchange(__ptr, std::addressof(__copy), __desired, __is_weak, __success, __failure)) {
91 return true;
92 }
93 _Tp __curr = __copy;
94 if (std::memcmp(__clear_padding(__prev), __clear_padding(__curr), sizeof(_Tp)) != 0) {
95 // Value representation without padding bits do not compare equal ->
96 // write the current content of *ptr into *expected
97 std::memcpy(__expected, std::addressof(__copy), sizeof(_Tp));
98 return false;
99 }
100 }
101 }
102 }
103
104 friend struct __atomic_waitable_traits<__atomic_ref_base<_Tp>>;
105
106 // require types that are 1, 2, 4, 8, or 16 bytes in length to be aligned to at least their size to be potentially
107 // used lock-free
108 static constexpr size_t __min_alignment = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || (sizeof(_Tp) > 16) ? 0 : sizeof(_Tp);
109
110public:
111 using value_type = _Tp;
112
113 static constexpr size_t required_alignment = alignof(_Tp) > __min_alignment ? alignof(_Tp) : __min_alignment;
114
115 // The __atomic_always_lock_free builtin takes into account the alignment of the pointer if provided,
116 // so we create a fake pointer with a suitable alignment when querying it. Note that we are guaranteed
117 // that the pointer is going to be aligned properly at runtime because that is a (checked) precondition
118 // of atomic_ref's constructor.
119 static constexpr bool is_always_lock_free =
120 __atomic_always_lock_free(sizeof(_Tp), &__get_aligner_instance<required_alignment>::__instance);
121
122 _LIBCPP_HIDE_FROM_ABI bool is_lock_free() const noexcept { return __atomic_is_lock_free(sizeof(_Tp), __ptr_); }
123
124 _LIBCPP_HIDE_FROM_ABI void store(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept
125 _LIBCPP_CHECK_STORE_MEMORY_ORDER(__order) {
126 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
127 __order == memory_order::relaxed || __order == memory_order::release || __order == memory_order::seq_cst,
128 "atomic_ref: memory order argument to atomic store operation is invalid");
129 __atomic_store(__ptr_, __clear_padding(__desired), std::__to_gcc_order(__order));
130 }
131
132 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept {
133 store(__desired);
134 return __desired;
135 }
136
137 _LIBCPP_HIDE_FROM_ABI _Tp load(memory_order __order = memory_order::seq_cst) const noexcept
138 _LIBCPP_CHECK_LOAD_MEMORY_ORDER(__order) {
139 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
140 __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire ||
141 __order == memory_order::seq_cst,
142 "atomic_ref: memory order argument to atomic load operation is invalid");
143 alignas(_Tp) byte __mem[sizeof(_Tp)];
144 auto* __ret = reinterpret_cast<_Tp*>(__mem);
145 __atomic_load(__ptr_, __ret, std::__to_gcc_order(__order));
146 return *__ret;
147 }
148
149 _LIBCPP_HIDE_FROM_ABI operator _Tp() const noexcept { return load(); }
150
151 _LIBCPP_HIDE_FROM_ABI _Tp exchange(_Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept {
152 alignas(_Tp) byte __mem[sizeof(_Tp)];
153 auto* __ret = reinterpret_cast<_Tp*>(__mem);
154 __atomic_exchange(__ptr_, __clear_padding(__desired), __ret, std::__to_gcc_order(__order));
155 return *__ret;
156 }
157
158 _LIBCPP_HIDE_FROM_ABI bool
159 compare_exchange_weak(_Tp& __expected, _Tp __desired, memory_order __success, memory_order __failure) const noexcept
160 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__success, __failure) {
161 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
162 __failure == memory_order::relaxed || __failure == memory_order::consume ||
163 __failure == memory_order::acquire || __failure == memory_order::seq_cst,
164 "atomic_ref: failure memory order argument to weak atomic compare-and-exchange operation is invalid");
165 return __compare_exchange(
166 __ptr_,
167 std::addressof(__expected),
168 std::addressof(__desired),
169 true,
170 std::__to_gcc_order(__success),
171 std::__to_gcc_order(__failure));
172 }
173 _LIBCPP_HIDE_FROM_ABI bool
174 compare_exchange_strong(_Tp& __expected, _Tp __desired, memory_order __success, memory_order __failure) const noexcept
175 _LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__success, __failure) {
176 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
177 __failure == memory_order::relaxed || __failure == memory_order::consume ||
178 __failure == memory_order::acquire || __failure == memory_order::seq_cst,
179 "atomic_ref: failure memory order argument to strong atomic compare-and-exchange operation is invalid");
180 return __compare_exchange(
181 __ptr_,
182 std::addressof(__expected),
183 std::addressof(__desired),
184 false,
185 std::__to_gcc_order(__success),
186 std::__to_gcc_order(__failure));
187 }
188
189 _LIBCPP_HIDE_FROM_ABI bool
190 compare_exchange_weak(_Tp& __expected, _Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept {
191 return __compare_exchange(
192 __ptr_,
193 std::addressof(__expected),
194 std::addressof(__desired),
195 true,
196 std::__to_gcc_order(__order),
197 std::__to_gcc_failure_order(__order));
198 }
199 _LIBCPP_HIDE_FROM_ABI bool
200 compare_exchange_strong(_Tp& __expected, _Tp __desired, memory_order __order = memory_order::seq_cst) const noexcept {
201 return __compare_exchange(
202 __ptr_,
203 std::addressof(__expected),
204 std::addressof(__desired),
205 false,
206 std::__to_gcc_order(__order),
207 std::__to_gcc_failure_order(__order));
208 }
209
210 _LIBCPP_HIDE_FROM_ABI void wait(_Tp __old, memory_order __order = memory_order::seq_cst) const noexcept
211 _LIBCPP_CHECK_WAIT_MEMORY_ORDER(__order) {
212 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
213 __order == memory_order::relaxed || __order == memory_order::consume || __order == memory_order::acquire ||
214 __order == memory_order::seq_cst,
215 "atomic_ref: memory order argument to atomic wait operation is invalid");
216 std::__atomic_wait(*this, __old, __order);
217 }
218 _LIBCPP_HIDE_FROM_ABI void notify_one() const noexcept { std::__atomic_notify_one(*this); }
219 _LIBCPP_HIDE_FROM_ABI void notify_all() const noexcept { std::__atomic_notify_all(*this); }
220
221protected:
222 typedef _Tp _Aligned_Tp __attribute__((aligned(required_alignment)));
223 _Aligned_Tp* __ptr_;
224
225 _LIBCPP_HIDE_FROM_ABI __atomic_ref_base(_Tp& __obj) : __ptr_(std::addressof(__obj)) {}
226};
227
228template <class _Tp>
229struct __atomic_waitable_traits<__atomic_ref_base<_Tp>> {
230 static _LIBCPP_HIDE_FROM_ABI _Tp __atomic_load(const __atomic_ref_base<_Tp>& __a, memory_order __order) {
231 return __a.load(__order);
232 }
233 static _LIBCPP_HIDE_FROM_ABI const _Tp* __atomic_contention_address(const __atomic_ref_base<_Tp>& __a) {
234 return __a.__ptr_;
235 }
236};
237
238template <class _Tp>
239struct atomic_ref : public __atomic_ref_base<_Tp> {
240 static_assert(is_trivially_copyable_v<_Tp>, "std::atomic_ref<T> requires that 'T' be a trivially copyable type");
241
242 using __base = __atomic_ref_base<_Tp>;
243
244 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
245 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
246 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
247 "atomic_ref ctor: referenced object must be aligned to required_alignment");
248 }
249
250 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
251
252 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
253
254 atomic_ref& operator=(const atomic_ref&) = delete;
255};
256
257template <class _Tp>
258 requires(std::integral<_Tp> && !std::same_as<bool, _Tp>)
259struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
260 using __base = __atomic_ref_base<_Tp>;
261
262 using difference_type = __base::value_type;
263
264 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
265 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
266 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
267 "atomic_ref ctor: referenced object must be aligned to required_alignment");
268 }
269
270 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
271
272 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
273
274 atomic_ref& operator=(const atomic_ref&) = delete;
275
276 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
277 return __atomic_fetch_add(this->__ptr_, __arg, std::__to_gcc_order(__order));
278 }
279 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
280 return __atomic_fetch_sub(this->__ptr_, __arg, std::__to_gcc_order(__order));
281 }
282 _LIBCPP_HIDE_FROM_ABI _Tp fetch_and(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
283 return __atomic_fetch_and(this->__ptr_, __arg, std::__to_gcc_order(__order));
284 }
285 _LIBCPP_HIDE_FROM_ABI _Tp fetch_or(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
286 return __atomic_fetch_or(this->__ptr_, __arg, std::__to_gcc_order(__order));
287 }
288 _LIBCPP_HIDE_FROM_ABI _Tp fetch_xor(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
289 return __atomic_fetch_xor(this->__ptr_, __arg, std::__to_gcc_order(__order));
290 }
291
292 _LIBCPP_HIDE_FROM_ABI _Tp operator++(int) const noexcept { return fetch_add(_Tp(1)); }
293 _LIBCPP_HIDE_FROM_ABI _Tp operator--(int) const noexcept { return fetch_sub(_Tp(1)); }
294 _LIBCPP_HIDE_FROM_ABI _Tp operator++() const noexcept { return fetch_add(_Tp(1)) + _Tp(1); }
295 _LIBCPP_HIDE_FROM_ABI _Tp operator--() const noexcept { return fetch_sub(_Tp(1)) - _Tp(1); }
296 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; }
297 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __arg) const noexcept { return fetch_sub(__arg) - __arg; }
298 _LIBCPP_HIDE_FROM_ABI _Tp operator&=(_Tp __arg) const noexcept { return fetch_and(__arg) & __arg; }
299 _LIBCPP_HIDE_FROM_ABI _Tp operator|=(_Tp __arg) const noexcept { return fetch_or(__arg) | __arg; }
300 _LIBCPP_HIDE_FROM_ABI _Tp operator^=(_Tp __arg) const noexcept { return fetch_xor(__arg) ^ __arg; }
301};
302
303template <class _Tp>
304 requires std::floating_point<_Tp>
305struct atomic_ref<_Tp> : public __atomic_ref_base<_Tp> {
306 using __base = __atomic_ref_base<_Tp>;
307
308 using difference_type = __base::value_type;
309
310 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp& __obj) : __base(__obj) {
311 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
312 reinterpret_cast<uintptr_t>(std::addressof(__obj)) % __base::required_alignment == 0,
313 "atomic_ref ctor: referenced object must be aligned to required_alignment");
314 }
315
316 _LIBCPP_HIDE_FROM_ABI atomic_ref(const atomic_ref&) noexcept = default;
317
318 _LIBCPP_HIDE_FROM_ABI _Tp operator=(_Tp __desired) const noexcept { return __base::operator=(__desired); }
319
320 atomic_ref& operator=(const atomic_ref&) = delete;
321
322 _LIBCPP_HIDE_FROM_ABI _Tp fetch_add(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
323 _Tp __old = this->load(memory_order_relaxed);
324 _Tp __new = __old + __arg;
325 while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) {
326 __new = __old + __arg;
327 }
328 return __old;
329 }
330 _LIBCPP_HIDE_FROM_ABI _Tp fetch_sub(_Tp __arg, memory_order __order = memory_order_seq_cst) const noexcept {
331 _Tp __old = this->load(memory_order_relaxed);
332 _Tp __new = __old - __arg;
333 while (!this->compare_exchange_weak(__old, __new, __order, memory_order_relaxed)) {
334 __new = __old - __arg;
335 }
336 return __old;
337 }
338
339 _LIBCPP_HIDE_FROM_ABI _Tp operator+=(_Tp __arg) const noexcept { return fetch_add(__arg) + __arg; }
340 _LIBCPP_HIDE_FROM_ABI _Tp operator-=(_Tp __arg) const noexcept { return fetch_sub(__arg) - __arg; }
341};
342
343template <class _Tp>
344struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {
345 using __base = __atomic_ref_base<_Tp*>;
346
347 using difference_type = ptrdiff_t;
348
349 _LIBCPP_HIDE_FROM_ABI explicit atomic_ref(_Tp*& __ptr) : __base(__ptr) {}
350
351 _LIBCPP_HIDE_FROM_ABI _Tp* operator=(_Tp* __desired) const noexcept { return __base::operator=(__desired); }
352
353 atomic_ref& operator=(const atomic_ref&) = delete;
354
355 _LIBCPP_HIDE_FROM_ABI _Tp* fetch_add(ptrdiff_t __arg, memory_order __order = memory_order_seq_cst) const noexcept {
356 return __atomic_fetch_add(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order));
357 }
358 _LIBCPP_HIDE_FROM_ABI _Tp* fetch_sub(ptrdiff_t __arg, memory_order __order = memory_order_seq_cst) const noexcept {
359 return __atomic_fetch_sub(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order));
360 }
361
362 _LIBCPP_HIDE_FROM_ABI _Tp* operator++(int) const noexcept { return fetch_add(1); }
363 _LIBCPP_HIDE_FROM_ABI _Tp* operator--(int) const noexcept { return fetch_sub(1); }
364 _LIBCPP_HIDE_FROM_ABI _Tp* operator++() const noexcept { return fetch_add(1) + 1; }
365 _LIBCPP_HIDE_FROM_ABI _Tp* operator--() const noexcept { return fetch_sub(1) - 1; }
366 _LIBCPP_HIDE_FROM_ABI _Tp* operator+=(ptrdiff_t __arg) const noexcept { return fetch_add(__arg) + __arg; }
367 _LIBCPP_HIDE_FROM_ABI _Tp* operator-=(ptrdiff_t __arg) const noexcept { return fetch_sub(__arg) - __arg; }
368};
369
370_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(atomic_ref);
371
372#endif // _LIBCPP_STD_VER >= 20
373
374_LIBCPP_END_NAMESPACE_STD
375
376_LIBCPP_POP_MACROS
377
378#endif // _LIBCPP__ATOMIC_ATOMIC_REF_H
lib/libcxx/include/__atomic/atomic_sync.h+137-40
......@@ -12,13 +12,17 @@
1212#include <__atomic/contention_t.h>
1313#include <__atomic/cxx_atomic_impl.h>
1414#include <__atomic/memory_order.h>
15#include <__availability>
15#include <__atomic/to_gcc_order.h>
1616#include <__chrono/duration.h>
1717#include <__config>
1818#include <__memory/addressof.h>
1919#include <__thread/poll_with_backoff.h>
20#include <__threading_support>
20#include <__thread/support.h>
21#include <__type_traits/conjunction.h>
2122#include <__type_traits/decay.h>
23#include <__type_traits/invoke.h>
24#include <__type_traits/void_t.h>
25#include <__utility/declval.h>
2226#include <cstring>
2327
2428#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -27,33 +31,101 @@
2731
2832_LIBCPP_BEGIN_NAMESPACE_STD
2933
34// The customisation points to enable the following functions:
35// - __atomic_wait
36// - __atomic_wait_unless
37// - __atomic_notify_one
38// - __atomic_notify_all
39// Note that std::atomic<T>::wait was back-ported to C++03
40// The below implementations look ugly to support C++03
41template <class _Tp, class = void>
42struct __atomic_waitable_traits {
43 template <class _AtomicWaitable>
44 static void __atomic_load(_AtomicWaitable&&, memory_order) = delete;
45
46 template <class _AtomicWaitable>
47 static void __atomic_contention_address(_AtomicWaitable&&) = delete;
48};
49
50template <class _Tp, class = void>
51struct __atomic_waitable : false_type {};
52
53template <class _Tp>
54struct __atomic_waitable< _Tp,
55 __void_t<decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_load(
56 std::declval<const _Tp&>(), std::declval<memory_order>())),
57 decltype(__atomic_waitable_traits<__decay_t<_Tp> >::__atomic_contention_address(
58 std::declval<const _Tp&>()))> > : true_type {};
59
60template <class _AtomicWaitable, class _Poll>
61struct __atomic_wait_poll_impl {
62 const _AtomicWaitable& __a_;
63 _Poll __poll_;
64 memory_order __order_;
65
66 _LIBCPP_HIDE_FROM_ABI bool operator()() const {
67 auto __current_val = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_load(__a_, __order_);
68 return __poll_(__current_val);
69 }
70};
71
3072#ifndef _LIBCPP_HAS_NO_THREADS
3173
32_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*);
33_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*);
34_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile*);
35_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile*, __cxx_contention_t);
74_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile*) _NOEXCEPT;
75_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile*) _NOEXCEPT;
76_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
77__libcpp_atomic_monitor(void const volatile*) _NOEXCEPT;
78_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
79__libcpp_atomic_wait(void const volatile*, __cxx_contention_t) _NOEXCEPT;
3680
3781_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
38__cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*);
82__cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
3983_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
40__cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*);
84__cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
4185_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
42__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*);
86__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile*) _NOEXCEPT;
4387_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
44__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t);
88__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile*, __cxx_contention_t) _NOEXCEPT;
89
90template <class _AtomicWaitable, class _Poll>
91struct __atomic_wait_backoff_impl {
92 const _AtomicWaitable& __a_;
93 _Poll __poll_;
94 memory_order __order_;
95
96 using __waitable_traits = __atomic_waitable_traits<__decay_t<_AtomicWaitable> >;
97
98 _LIBCPP_AVAILABILITY_SYNC
99 _LIBCPP_HIDE_FROM_ABI bool
100 __update_monitor_val_and_poll(__cxx_atomic_contention_t const volatile*, __cxx_contention_t& __monitor_val) const {
101 // In case the contention type happens to be __cxx_atomic_contention_t, i.e. __cxx_atomic_impl<int64_t>,
102 // the platform wait is directly monitoring the atomic value itself.
103 // `__poll_` takes the current value of the atomic as an in-out argument
104 // to potentially modify it. After it returns, `__monitor` has a value
105 // which can be safely waited on by `std::__libcpp_atomic_wait` without any
106 // ABA style issues.
107 __monitor_val = __waitable_traits::__atomic_load(__a_, __order_);
108 return __poll_(__monitor_val);
109 }
110
111 _LIBCPP_AVAILABILITY_SYNC
112 _LIBCPP_HIDE_FROM_ABI bool
113 __update_monitor_val_and_poll(void const volatile* __contention_address, __cxx_contention_t& __monitor_val) const {
114 // In case the contention type is anything else, platform wait is monitoring a __cxx_atomic_contention_t
115 // from the global pool, the monitor comes from __libcpp_atomic_monitor
116 __monitor_val = std::__libcpp_atomic_monitor(__contention_address);
117 auto __current_val = __waitable_traits::__atomic_load(__a_, __order_);
118 return __poll_(__current_val);
119 }
45120
46template <class _Atp, class _Fn>
47struct __libcpp_atomic_wait_backoff_impl {
48 _Atp* __a;
49 _Fn __test_fn;
50121 _LIBCPP_AVAILABILITY_SYNC
51122 _LIBCPP_HIDE_FROM_ABI bool operator()(chrono::nanoseconds __elapsed) const {
52123 if (__elapsed > chrono::microseconds(64)) {
53 auto const __monitor = std::__libcpp_atomic_monitor(__a);
54 if (__test_fn())
124 auto __contention_address = __waitable_traits::__atomic_contention_address(__a_);
125 __cxx_contention_t __monitor_val;
126 if (__update_monitor_val_and_poll(__contention_address, __monitor_val))
55127 return true;
56 std::__libcpp_atomic_wait(__a, __monitor);
128 std::__libcpp_atomic_wait(__contention_address, __monitor_val);
57129 } else if (__elapsed > chrono::microseconds(4))
58130 __libcpp_thread_yield();
59131 else {
......@@ -62,23 +134,49 @@ struct __libcpp_atomic_wait_backoff_impl {
62134 }
63135};
64136
65template <class _Atp, class _Fn>
66_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_wait(_Atp* __a, _Fn&& __test_fn) {
67 __libcpp_atomic_wait_backoff_impl<_Atp, __decay_t<_Fn> > __backoff_fn = {__a, __test_fn};
68 return std::__libcpp_thread_poll_with_backoff(__test_fn, __backoff_fn);
137// The semantics of this function are similar to `atomic`'s
138// `.wait(T old, std::memory_order order)`, but instead of having a hardcoded
139// predicate (is the loaded value unequal to `old`?), the predicate function is
140// specified as an argument. The loaded value is given as an in-out argument to
141// the predicate. If the predicate function returns `true`,
142// `__atomic_wait_unless` will return. If the predicate function returns
143// `false`, it must set the argument to its current understanding of the atomic
144// value. The predicate function must not return `false` spuriously.
145template <class _AtomicWaitable, class _Poll>
146_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
147__atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) {
148 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
149 __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_impl = {__a, __poll, __order};
150 __atomic_wait_backoff_impl<_AtomicWaitable, __decay_t<_Poll> > __backoff_fn = {__a, __poll, __order};
151 std::__libcpp_thread_poll_with_backoff(__poll_impl, __backoff_fn);
152}
153
154template <class _AtomicWaitable>
155_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable& __a) {
156 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
157 std::__cxx_atomic_notify_one(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a));
158}
159
160template <class _AtomicWaitable>
161_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable& __a) {
162 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
163 std::__cxx_atomic_notify_all(__atomic_waitable_traits<__decay_t<_AtomicWaitable> >::__atomic_contention_address(__a));
69164}
70165
71166#else // _LIBCPP_HAS_NO_THREADS
72167
73template <class _Tp>
74_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_impl<_Tp> const volatile*) {}
75template <class _Tp>
76_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_impl<_Tp> const volatile*) {}
77template <class _Atp, class _Fn>
78_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_wait(_Atp*, _Fn&& __test_fn) {
79 return std::__libcpp_thread_poll_with_backoff(__test_fn, __spinning_backoff_policy());
168template <class _AtomicWaitable, class _Poll>
169_LIBCPP_HIDE_FROM_ABI void __atomic_wait_unless(const _AtomicWaitable& __a, _Poll&& __poll, memory_order __order) {
170 __atomic_wait_poll_impl<_AtomicWaitable, __decay_t<_Poll> > __poll_fn = {__a, __poll, __order};
171 std::__libcpp_thread_poll_with_backoff(__poll_fn, __spinning_backoff_policy());
80172}
81173
174template <class _AtomicWaitable>
175_LIBCPP_HIDE_FROM_ABI void __atomic_notify_one(const _AtomicWaitable&) {}
176
177template <class _AtomicWaitable>
178_LIBCPP_HIDE_FROM_ABI void __atomic_notify_all(const _AtomicWaitable&) {}
179
82180#endif // _LIBCPP_HAS_NO_THREADS
83181
84182template <typename _Tp>
......@@ -86,21 +184,20 @@ _LIBCPP_HIDE_FROM_ABI bool __cxx_nonatomic_compare_equal(_Tp const& __lhs, _Tp c
86184 return std::memcmp(std::addressof(__lhs), std::addressof(__rhs), sizeof(_Tp)) == 0;
87185}
88186
89template <class _Atp, class _Tp>
90struct __cxx_atomic_wait_test_fn_impl {
91 _Atp* __a;
92 _Tp __val;
93 memory_order __order;
94 _LIBCPP_HIDE_FROM_ABI bool operator()() const {
95 return !std::__cxx_nonatomic_compare_equal(std::__cxx_atomic_load(__a, __order), __val);
187template <class _Tp>
188struct __atomic_compare_unequal_to {
189 _Tp __val_;
190 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __arg) const {
191 return !std::__cxx_nonatomic_compare_equal(__arg, __val_);
96192 }
97193};
98194
99template <class _Atp, class _Tp>
100_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool
101__cxx_atomic_wait(_Atp* __a, _Tp const __val, memory_order __order) {
102 __cxx_atomic_wait_test_fn_impl<_Atp, _Tp> __test_fn = {__a, __val, __order};
103 return std::__cxx_atomic_wait(__a, __test_fn);
195template <class _AtomicWaitable, class _Up>
196_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void
197__atomic_wait(_AtomicWaitable& __a, _Up __val, memory_order __order) {
198 static_assert(__atomic_waitable<_AtomicWaitable>::value, "");
199 __atomic_compare_unequal_to<_Up> __nonatomic_equal = {__val};
200 std::__atomic_wait_unless(__a, __nonatomic_equal, __order);
104201}
105202
106203_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__atomic/check_memory_order.h+4
......@@ -27,4 +27,8 @@
2727 _LIBCPP_DIAGNOSE_WARNING(__f == memory_order_release || __f == memory_order_acq_rel, \
2828 "memory order argument to atomic operation is invalid")
2929
30#define _LIBCPP_CHECK_WAIT_MEMORY_ORDER(__m) \
31 _LIBCPP_DIAGNOSE_WARNING(__m == memory_order_release || __m == memory_order_acq_rel, \
32 "memory order argument to atomic operation is invalid")
33
3034#endif // _LIBCPP___ATOMIC_CHECK_MEMORY_ORDER_H
lib/libcxx/include/__atomic/cxx_atomic_impl.h+2-316
......@@ -9,16 +9,14 @@
99#ifndef _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H
1010#define _LIBCPP___ATOMIC_CXX_ATOMIC_IMPL_H
1111
12#include <__atomic/is_always_lock_free.h>
1312#include <__atomic/memory_order.h>
13#include <__atomic/to_gcc_order.h>
1414#include <__config>
1515#include <__memory/addressof.h>
16#include <__type_traits/conditional.h>
1716#include <__type_traits/is_assignable.h>
1817#include <__type_traits/is_trivially_copyable.h>
1918#include <__type_traits/remove_const.h>
2019#include <cstddef>
21#include <cstring>
2220
2321#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2422# pragma GCC system_header
......@@ -26,7 +24,7 @@
2624
2725_LIBCPP_BEGIN_NAMESPACE_STD
2826
29#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
27#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
3028
3129// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
3230// the default operator= in an object is not volatile, a byte-by-byte copy
......@@ -44,10 +42,6 @@ _LIBCPP_HIDE_FROM_ABI void __cxx_atomic_assign_volatile(_Tp volatile& __a_value,
4442 *__to++ = *__from++;
4543}
4644
47#endif
48
49#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
50
5145template <typename _Tp>
5246struct __cxx_atomic_base_impl {
5347 _LIBCPP_HIDE_FROM_ABI
......@@ -61,32 +55,6 @@ struct __cxx_atomic_base_impl {
6155 _Tp __a_value;
6256};
6357
64_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
65 // Avoid switch statement to make this a constexpr.
66 return __order == memory_order_relaxed
67 ? __ATOMIC_RELAXED
68 : (__order == memory_order_acquire
69 ? __ATOMIC_ACQUIRE
70 : (__order == memory_order_release
71 ? __ATOMIC_RELEASE
72 : (__order == memory_order_seq_cst
73 ? __ATOMIC_SEQ_CST
74 : (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME))));
75}
76
77_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
78 // Avoid switch statement to make this a constexpr.
79 return __order == memory_order_relaxed
80 ? __ATOMIC_RELAXED
81 : (__order == memory_order_acquire
82 ? __ATOMIC_ACQUIRE
83 : (__order == memory_order_release
84 ? __ATOMIC_RELAXED
85 : (__order == memory_order_seq_cst
86 ? __ATOMIC_SEQ_CST
87 : (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE : __ATOMIC_CONSUME))));
88}
89
9058template <typename _Tp>
9159_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
9260 __cxx_atomic_assign_volatile(__a->__a_value, __val);
......@@ -529,289 +497,7 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o
529497
530498#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP
531499
532#ifdef _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
533
534template <typename _Tp>
535struct __cxx_atomic_lock_impl {
536 _LIBCPP_HIDE_FROM_ABI __cxx_atomic_lock_impl() _NOEXCEPT : __a_value(), __a_lock(0) {}
537 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __cxx_atomic_lock_impl(_Tp value) _NOEXCEPT
538 : __a_value(value),
539 __a_lock(0) {}
540
541 _Tp __a_value;
542 mutable __cxx_atomic_base_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_lock;
543
544 _LIBCPP_HIDE_FROM_ABI void __lock() const volatile {
545 while (1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
546 /*spin*/;
547 }
548 _LIBCPP_HIDE_FROM_ABI void __lock() const {
549 while (1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
550 /*spin*/;
551 }
552 _LIBCPP_HIDE_FROM_ABI void __unlock() const volatile {
553 __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
554 }
555 _LIBCPP_HIDE_FROM_ABI void __unlock() const {
556 __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
557 }
558 _LIBCPP_HIDE_FROM_ABI _Tp __read() const volatile {
559 __lock();
560 _Tp __old;
561 __cxx_atomic_assign_volatile(__old, __a_value);
562 __unlock();
563 return __old;
564 }
565 _LIBCPP_HIDE_FROM_ABI _Tp __read() const {
566 __lock();
567 _Tp __old = __a_value;
568 __unlock();
569 return __old;
570 }
571 _LIBCPP_HIDE_FROM_ABI void __read_inplace(_Tp* __dst) const volatile {
572 __lock();
573 __cxx_atomic_assign_volatile(*__dst, __a_value);
574 __unlock();
575 }
576 _LIBCPP_HIDE_FROM_ABI void __read_inplace(_Tp* __dst) const {
577 __lock();
578 *__dst = __a_value;
579 __unlock();
580 }
581};
582
583template <typename _Tp>
584_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
585 __cxx_atomic_assign_volatile(__a->__a_value, __val);
586}
587template <typename _Tp>
588_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_init(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
589 __a->__a_value = __val;
590}
591
592template <typename _Tp>
593_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
594 __a->__lock();
595 __cxx_atomic_assign_volatile(__a->__a_value, __val);
596 __a->__unlock();
597}
598template <typename _Tp>
599_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_store(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
600 __a->__lock();
601 __a->__a_value = __val;
602 __a->__unlock();
603}
604
605template <typename _Tp>
606_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
607 return __a->__read();
608}
609template <typename _Tp>
610_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
611 return __a->__read();
612}
613
614template <typename _Tp>
615_LIBCPP_HIDE_FROM_ABI void
616__cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __dst, memory_order) {
617 __a->__read_inplace(__dst);
618}
619template <typename _Tp>
620_LIBCPP_HIDE_FROM_ABI void __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __dst, memory_order) {
621 __a->__read_inplace(__dst);
622}
623
624template <typename _Tp>
625_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
626 __a->__lock();
627 _Tp __old;
628 __cxx_atomic_assign_volatile(__old, __a->__a_value);
629 __cxx_atomic_assign_volatile(__a->__a_value, __value);
630 __a->__unlock();
631 return __old;
632}
633template <typename _Tp>
634_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_exchange(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
635 __a->__lock();
636 _Tp __old = __a->__a_value;
637 __a->__a_value = __value;
638 __a->__unlock();
639 return __old;
640}
641
642template <typename _Tp>
643_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
644 volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) {
645 _Tp __temp;
646 __a->__lock();
647 __cxx_atomic_assign_volatile(__temp, __a->__a_value);
648 bool __ret = (std::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
649 if (__ret)
650 __cxx_atomic_assign_volatile(__a->__a_value, __value);
651 else
652 __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
653 __a->__unlock();
654 return __ret;
655}
656template <typename _Tp>
657_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_strong(
658 __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) {
659 __a->__lock();
660 bool __ret = (std::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
661 if (__ret)
662 std::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
663 else
664 std::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
665 __a->__unlock();
666 return __ret;
667}
668
669template <typename _Tp>
670_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
671 volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) {
672 _Tp __temp;
673 __a->__lock();
674 __cxx_atomic_assign_volatile(__temp, __a->__a_value);
675 bool __ret = (std::memcmp(&__temp, __expected, sizeof(_Tp)) == 0);
676 if (__ret)
677 __cxx_atomic_assign_volatile(__a->__a_value, __value);
678 else
679 __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
680 __a->__unlock();
681 return __ret;
682}
683template <typename _Tp>
684_LIBCPP_HIDE_FROM_ABI bool __cxx_atomic_compare_exchange_weak(
685 __cxx_atomic_lock_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order, memory_order) {
686 __a->__lock();
687 bool __ret = (std::memcmp(&__a->__a_value, __expected, sizeof(_Tp)) == 0);
688 if (__ret)
689 std::memcpy(&__a->__a_value, &__value, sizeof(_Tp));
690 else
691 std::memcpy(__expected, &__a->__a_value, sizeof(_Tp));
692 __a->__unlock();
693 return __ret;
694}
695
696template <typename _Tp, typename _Td>
697_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) {
698 __a->__lock();
699 _Tp __old;
700 __cxx_atomic_assign_volatile(__old, __a->__a_value);
701 __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old + __delta));
702 __a->__unlock();
703 return __old;
704}
705template <typename _Tp, typename _Td>
706_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) {
707 __a->__lock();
708 _Tp __old = __a->__a_value;
709 __a->__a_value += __delta;
710 __a->__unlock();
711 return __old;
712}
713
714template <typename _Tp, typename _Td>
715_LIBCPP_HIDE_FROM_ABI _Tp*
716__cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order) {
717 __a->__lock();
718 _Tp* __old;
719 __cxx_atomic_assign_volatile(__old, __a->__a_value);
720 __cxx_atomic_assign_volatile(__a->__a_value, __old + __delta);
721 __a->__unlock();
722 return __old;
723}
724template <typename _Tp, typename _Td>
725_LIBCPP_HIDE_FROM_ABI _Tp* __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp*>* __a, ptrdiff_t __delta, memory_order) {
726 __a->__lock();
727 _Tp* __old = __a->__a_value;
728 __a->__a_value += __delta;
729 __a->__unlock();
730 return __old;
731}
732
733template <typename _Tp, typename _Td>
734_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) {
735 __a->__lock();
736 _Tp __old;
737 __cxx_atomic_assign_volatile(__old, __a->__a_value);
738 __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old - __delta));
739 __a->__unlock();
740 return __old;
741}
742template <typename _Tp, typename _Td>
743_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_sub(__cxx_atomic_lock_impl<_Tp>* __a, _Td __delta, memory_order) {
744 __a->__lock();
745 _Tp __old = __a->__a_value;
746 __a->__a_value -= __delta;
747 __a->__unlock();
748 return __old;
749}
750
751template <typename _Tp>
752_LIBCPP_HIDE_FROM_ABI _Tp
753__cxx_atomic_fetch_and(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
754 __a->__lock();
755 _Tp __old;
756 __cxx_atomic_assign_volatile(__old, __a->__a_value);
757 __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old & __pattern));
758 __a->__unlock();
759 return __old;
760}
761template <typename _Tp>
762_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_and(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
763 __a->__lock();
764 _Tp __old = __a->__a_value;
765 __a->__a_value &= __pattern;
766 __a->__unlock();
767 return __old;
768}
769
770template <typename _Tp>
771_LIBCPP_HIDE_FROM_ABI _Tp
772__cxx_atomic_fetch_or(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
773 __a->__lock();
774 _Tp __old;
775 __cxx_atomic_assign_volatile(__old, __a->__a_value);
776 __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old | __pattern));
777 __a->__unlock();
778 return __old;
779}
780template <typename _Tp>
781_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_or(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
782 __a->__lock();
783 _Tp __old = __a->__a_value;
784 __a->__a_value |= __pattern;
785 __a->__unlock();
786 return __old;
787}
788
789template <typename _Tp>
790_LIBCPP_HIDE_FROM_ABI _Tp
791__cxx_atomic_fetch_xor(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
792 __a->__lock();
793 _Tp __old;
794 __cxx_atomic_assign_volatile(__old, __a->__a_value);
795 __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old ^ __pattern));
796 __a->__unlock();
797 return __old;
798}
799template <typename _Tp>
800_LIBCPP_HIDE_FROM_ABI _Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __pattern, memory_order) {
801 __a->__lock();
802 _Tp __old = __a->__a_value;
803 __a->__a_value ^= __pattern;
804 __a->__unlock();
805 return __old;
806}
807
808template <typename _Tp,
809 typename _Base = typename conditional<__libcpp_is_always_lock_free<_Tp>::__value,
810 __cxx_atomic_base_impl<_Tp>,
811 __cxx_atomic_lock_impl<_Tp> >::type>
812#else
813500template <typename _Tp, typename _Base = __cxx_atomic_base_impl<_Tp> >
814#endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS
815501struct __cxx_atomic_impl : public _Base {
816502 static_assert(is_trivially_copyable<_Tp>::value, "std::atomic<T> requires that 'T' be a trivially copyable type");
817503
lib/libcxx/include/__atomic/memory_order.h+1-1
......@@ -37,7 +37,7 @@ enum class memory_order : __memory_order_underlying_t {
3737 seq_cst = __mo_seq_cst
3838};
3939
40static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),
40static_assert(is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value,
4141 "unexpected underlying type for std::memory_order");
4242
4343inline constexpr auto memory_order_relaxed = memory_order::relaxed;
lib/libcxx/include/__atomic/to_gcc_order.h 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#ifndef _LIBCPP___ATOMIC_TO_GCC_ORDER_H
10#define _LIBCPP___ATOMIC_TO_GCC_ORDER_H
11
12#include <__atomic/memory_order.h>
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && defined(__ATOMIC_ACQUIRE) && \
22 defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST)
23
24_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
25 // Avoid switch statement to make this a constexpr.
26 return __order == memory_order_relaxed
27 ? __ATOMIC_RELAXED
28 : (__order == memory_order_acquire
29 ? __ATOMIC_ACQUIRE
30 : (__order == memory_order_release
31 ? __ATOMIC_RELEASE
32 : (__order == memory_order_seq_cst
33 ? __ATOMIC_SEQ_CST
34 : (__order == memory_order_acq_rel ? __ATOMIC_ACQ_REL : __ATOMIC_CONSUME))));
35}
36
37_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
38 // Avoid switch statement to make this a constexpr.
39 return __order == memory_order_relaxed
40 ? __ATOMIC_RELAXED
41 : (__order == memory_order_acquire
42 ? __ATOMIC_ACQUIRE
43 : (__order == memory_order_release
44 ? __ATOMIC_RELAXED
45 : (__order == memory_order_seq_cst
46 ? __ATOMIC_SEQ_CST
47 : (__order == memory_order_acq_rel ? __ATOMIC_ACQUIRE : __ATOMIC_CONSUME))));
48}
49
50#endif
51
52_LIBCPP_END_NAMESPACE_STD
53
54#endif // _LIBCPP___ATOMIC_TO_GCC_ORDER_H
lib/libcxx/include/__availability deleted-324
......@@ -1,324 +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___AVAILABILITY
11#define _LIBCPP___AVAILABILITY
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19// Libc++ is shipped by various vendors. In particular, it is used as a system
20// library on macOS, iOS and other Apple platforms. In order for users to be
21// able to compile a binary that is intended to be deployed to an older version
22// of a platform, Clang provides availability attributes [1]. These attributes
23// can be placed on declarations and are used to describe the life cycle of a
24// symbol in the library.
25//
26// The main goal is to ensure a compile-time error if a symbol that hasn't been
27// introduced in a previously released library is used in a program that targets
28// that previously released library. Normally, this would be a load-time error
29// when one tries to launch the program against the older library.
30//
31// For example, the filesystem library was introduced in the dylib in macOS 10.15.
32// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their
33// program, the compiler would normally not complain (because the required
34// declarations are in the headers), but the dynamic loader would fail to find
35// the symbols when actually trying to launch the program on macOS 10.13. To
36// turn this into a compile-time issue instead, declarations are annotated with
37// when they were introduced, and the compiler can produce a diagnostic if the
38// program references something that isn't available on the deployment target.
39//
40// This mechanism is general in nature, and any vendor can add their markup to
41// the library (see below). Whenever a new feature is added that requires support
42// in the shared library, two macros are added below to allow marking the feature
43// as unavailable:
44// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` which must be defined
45// exactly when compiling for a target that doesn't support the feature.
46// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must always be defined
47// and must expand to the proper availability attribute for the platform.
48//
49// When vendors decide to ship the feature as part of their shared library, they
50// can update these macros appropriately for their platform, and the library will
51// use those to provide an optimal user experience.
52//
53// Furthermore, many features in the standard library have corresponding
54// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_NO_<feature>` macros
55// are checked by the corresponding feature-test macros generated by
56// generate_feature_test_macro_components.py to ensure that the library
57// doesn't announce a feature as being implemented if it is unavailable on
58// the deployment target.
59//
60// Note that this mechanism is disabled by default in the "upstream" libc++.
61// Availability annotations are only meaningful when shipping libc++ inside
62// a platform (i.e. as a system library), and so vendors that want them should
63// turn those annotations on at CMake configuration time.
64//
65// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
66
67// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
68// for a while.
69#if defined(_LIBCPP_DISABLE_AVAILABILITY)
70# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
71# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
72# endif
73#endif
74
75// Availability markup is disabled when building the library, or when a non-Clang
76// compiler is used because only Clang supports the necessary attributes.
77// doesn't support the proper attributes.
78#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
79# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
80# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
81# endif
82#endif
83
84#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
85
86// These macros control the availability of std::bad_optional_access and
87// other exception types. These were put in the shared library to prevent
88// code bloat from every user program defining the vtable for these exception
89// types.
90//
91// Note that when exceptions are disabled, the methods that normally throw
92// these exceptions can be used even on older deployment targets, but those
93// methods will abort instead of throwing.
94# define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS 1
95# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
96
97# define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS 1
98# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
99
100# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST 1
101# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST
102
103// These macros controls the availability of __cxa_init_primary_exception
104// in the built library, which std::make_exception_ptr might use
105// (see libcxx/include/__exception/exception_ptr.h).
106# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1
107# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
108
109// These macros control the availability of all parts of <filesystem> that
110// depend on something in the dylib.
111# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1
112# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
113# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
114# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP
115
116// This controls the availability of floating-point std::to_chars functions.
117// These overloads were added later than the integer overloads.
118# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1
119# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
120
121// This controls the availability of the C++20 synchronization library,
122// which requires shared library support for various operations
123// (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
124// <semaphore>, and notification functions on std::atomic.
125# define _LIBCPP_AVAILABILITY_HAS_SYNC 1
126# define _LIBCPP_AVAILABILITY_SYNC
127
128// This controls whether the library claims to provide a default verbose
129// termination function, and consequently whether the headers will try
130// to use it when the mechanism isn't overriden at compile-time.
131# define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 1
132# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT
133
134// This controls the availability of the C++17 std::pmr library,
135// which is implemented in large part in the built library.
136# define _LIBCPP_AVAILABILITY_HAS_PMR 1
137# define _LIBCPP_AVAILABILITY_PMR
138
139// This controls the availability of the C++20 time zone database.
140// The parser code is built in the library.
141# define _LIBCPP_AVAILABILITY_HAS_TZDB 1
142# define _LIBCPP_AVAILABILITY_TZDB
143
144// This controls the availability of C++23 <print>, which
145// has a dependency on the built library (it needs access to
146// the underlying buffer types of std::cout, std::cerr, and std::clog.
147# define _LIBCPP_AVAILABILITY_HAS_PRINT 1
148# define _LIBCPP_AVAILABILITY_PRINT
149
150// Enable additional explicit instantiations of iostreams components. This
151// reduces the number of weak definitions generated in programs that use
152// iostreams by providing a single strong definition in the shared library.
153//
154// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
155// or once libc++ doesn't use the attribute anymore.
156// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
157# if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
158# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1
159# else
160# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
161# endif
162
163#elif defined(__APPLE__)
164
165# define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS \
166 (!defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) || __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 50000)
167
168# define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS
169# define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS
170
171# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS __attribute__((availability(watchos, strict, introduced = 5.0)))
172# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
173# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
174
175// TODO: Update once this is released
176# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
177# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION __attribute__((unavailable))
178
179// <filesystem>
180// clang-format off
181# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
182 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
183 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
184 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
185// clang-format on
186# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 0
187# else
188# define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY 1
189# endif
190# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY \
191 __attribute__((availability(macos, strict, introduced = 10.15))) \
192 __attribute__((availability(ios, strict, introduced = 13.0))) \
193 __attribute__((availability(tvos, strict, introduced = 13.0))) \
194 __attribute__((availability(watchos, strict, introduced = 6.0)))
195// clang-format off
196# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH \
197 _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
198 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
199 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
200 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
201# define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP \
202 _Pragma("clang attribute pop") \
203 _Pragma("clang attribute pop") \
204 _Pragma("clang attribute pop") \
205 _Pragma("clang attribute pop")
206// clang-format on
207
208// std::to_chars(floating-point)
209// clang-format off
210# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130300) || \
211 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160300) || \
212 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160300) || \
213 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90300)
214// clang-format on
215# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 0
216# else
217# define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT 1
218# endif
219# define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT \
220 __attribute__((availability(macos, strict, introduced = 13.3))) \
221 __attribute__((availability(ios, strict, introduced = 16.3))) \
222 __attribute__((availability(tvos, strict, introduced = 16.3))) \
223 __attribute__((availability(watchos, strict, introduced = 9.3)))
224
225// c++20 synchronization library
226// clang-format off
227# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
228 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
229 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
230 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
231// clang-format on
232# define _LIBCPP_AVAILABILITY_HAS_SYNC 0
233# else
234# define _LIBCPP_AVAILABILITY_HAS_SYNC 1
235# endif
236# define _LIBCPP_AVAILABILITY_SYNC \
237 __attribute__((availability(macos, strict, introduced = 11.0))) \
238 __attribute__((availability(ios, strict, introduced = 14.0))) \
239 __attribute__((availability(tvos, strict, introduced = 14.0))) \
240 __attribute__((availability(watchos, strict, introduced = 7.0)))
241
242// __libcpp_verbose_abort
243// TODO: Update once this is released
244# define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT 0
245
246# define _LIBCPP_AVAILABILITY_VERBOSE_ABORT __attribute__((unavailable))
247
248// std::pmr
249// clang-format off
250# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
251 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
252 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
253 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
254// clang-format on
255# define _LIBCPP_AVAILABILITY_HAS_PMR 0
256# else
257# define _LIBCPP_AVAILABILITY_HAS_PMR 1
258# endif
259// TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed
260// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
261// 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
262// use availability annotations until that bug has been fixed.
263# if 0
264# define _LIBCPP_AVAILABILITY_PMR \
265 __attribute__((availability(macos, strict, introduced = 14.0))) \
266 __attribute__((availability(ios, strict, introduced = 17.0))) \
267 __attribute__((availability(tvos, strict, introduced = 17.0))) \
268 __attribute__((availability(watchos, strict, introduced = 10.0)))
269# else
270# define _LIBCPP_AVAILABILITY_PMR
271# endif
272
273# define _LIBCPP_AVAILABILITY_HAS_TZDB 0
274# define _LIBCPP_AVAILABILITY_TZDB __attribute__((unavailable))
275
276// Warning: This availability macro works differently than the other macros.
277// The dylib part of print is not needed on Apple platforms. Therefore when
278// the macro is not available the code calling the dylib is commented out.
279// The macro _LIBCPP_AVAILABILITY_PRINT is not used.
280# define _LIBCPP_AVAILABILITY_HAS_PRINT 0
281# define _LIBCPP_AVAILABILITY_PRINT __attribute__((unavailable))
282
283// clang-format off
284# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120000) || \
285 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150000) || \
286 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150000) || \
287 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80000)
288// clang-format on
289# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
290# else
291# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 1
292# endif
293#else
294
295// ...New vendors can add availability markup here...
296
297# error \
298 "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
299
300#endif
301
302// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS.
303// Those are defined in terms of the availability attributes above, and
304// should not be vendor-specific.
305#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)
306# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
307# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
308# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
309#else
310# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
311# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
312# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
313#endif
314
315// Define availability attributes that depend on both
316// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.
317#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)
318# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
319# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
320# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
321# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
322#endif
323
324#endif // _LIBCPP___AVAILABILITY
lib/libcxx/include/__bit/bit_cast.h+10-1
......@@ -19,12 +19,21 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22#ifndef _LIBCPP_CXX03_LANG
23
24template <class _ToType, class _FromType>
25_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr _ToType __bit_cast(const _FromType& __from) noexcept {
26 return __builtin_bit_cast(_ToType, __from);
27}
28
29#endif // _LIBCPP_CXX03_LANG
30
2231#if _LIBCPP_STD_VER >= 20
2332
2433template <class _ToType, class _FromType>
2534 requires(sizeof(_ToType) == sizeof(_FromType) && is_trivially_copyable_v<_ToType> &&
2635 is_trivially_copyable_v<_FromType>)
27_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept {
36[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ToType bit_cast(const _FromType& __from) noexcept {
2837 return __builtin_bit_cast(_ToType, __from);
2938}
3039
lib/libcxx/include/__bit/bit_ceil.h+2-2
......@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424#if _LIBCPP_STD_VER >= 17
2525
2626template <class _Tp>
27_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept {
27[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) noexcept {
2828 if (__t < 2)
2929 return 1;
3030 const unsigned __n = numeric_limits<_Tp>::digits - std::__countl_zero((_Tp)(__t - 1u));
......@@ -42,7 +42,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp __bit_ceil(_Tp __t) no
4242# if _LIBCPP_STD_VER >= 20
4343
4444template <__libcpp_unsigned_integer _Tp>
45_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
45[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_ceil(_Tp __t) noexcept {
4646 return std::__bit_ceil(__t);
4747}
4848
lib/libcxx/include/__bit/bit_floor.h+1-1
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323#if _LIBCPP_STD_VER >= 20
2424
2525template <__libcpp_unsigned_integer _Tp>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
26[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp bit_floor(_Tp __t) noexcept {
2727 return __t == 0 ? 0 : _Tp{1} << std::__bit_log2(__t);
2828}
2929
lib/libcxx/include/__bit/bit_width.h+1-1
......@@ -22,7 +22,7 @@
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
2424template <__libcpp_unsigned_integer _Tp>
25_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int bit_width(_Tp __t) noexcept {
2626 return __t == 0 ? 0 : std::__bit_log2(__t) + 1;
2727}
2828
lib/libcxx/include/__bit/byteswap.h+1-1
......@@ -23,7 +23,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323#if _LIBCPP_STD_VER >= 23
2424
2525template <integral _Tp>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
26[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp byteswap(_Tp __val) noexcept {
2727 if constexpr (sizeof(_Tp) == 1) {
2828 return __val;
2929 } else if constexpr (sizeof(_Tp) == 2) {
lib/libcxx/include/__bit/countl.h+13-2
......@@ -6,6 +6,9 @@
66//
77//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_clzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_clzg.
11
912#ifndef _LIBCPP___BIT_COUNTL_H
1013#define _LIBCPP___BIT_COUNTL_H
1114
......@@ -38,6 +41,9 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_cl
3841
3942#ifndef _LIBCPP_HAS_NO_INT128
4043inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT {
44# if __has_builtin(__builtin_clzg)
45 return __builtin_clzg(__x);
46# else
4147 // The function is written in this form due to C++ constexpr limitations.
4248 // The algorithm:
4349 // - Test whether any bit in the high 64-bits is set
......@@ -49,12 +55,16 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
4955 // zeros in the high 64-bits.
5056 return ((__x >> 64) == 0) ? (64 + __builtin_clzll(static_cast<unsigned long long>(__x)))
5157 : __builtin_clzll(static_cast<unsigned long long>(__x >> 64));
58# endif
5259}
5360#endif // _LIBCPP_HAS_NO_INT128
5461
5562template <class _Tp>
5663_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
5764 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
65#if __has_builtin(__builtin_clzg)
66 return __builtin_clzg(__t, numeric_limits<_Tp>::digits);
67#else // __has_builtin(__builtin_clzg)
5868 if (__t == 0)
5969 return numeric_limits<_Tp>::digits;
6070
......@@ -79,17 +89,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
7989 }
8090 return __ret + __iter;
8191 }
92#endif // __has_builtin(__builtin_clzg)
8293}
8394
8495#if _LIBCPP_STD_VER >= 20
8596
8697template <__libcpp_unsigned_integer _Tp>
87_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
98[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_zero(_Tp __t) noexcept {
8899 return std::__countl_zero(__t);
89100}
90101
91102template <__libcpp_unsigned_integer _Tp>
92_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
103[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countl_one(_Tp __t) noexcept {
93104 return __t != numeric_limits<_Tp>::max() ? std::countl_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
94105}
95106
lib/libcxx/include/__bit/countr.h+17-6
......@@ -6,6 +6,9 @@
66//
77//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_ctzg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_ctzg.
11
912#ifndef _LIBCPP___BIT_COUNTR_H
1013#define _LIBCPP___BIT_COUNTR_H
1114
......@@ -35,13 +38,13 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ct
3538 return __builtin_ctzll(__x);
3639}
3740
38#if _LIBCPP_STD_VER >= 20
39
40template <__libcpp_unsigned_integer _Tp>
41_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
41template <class _Tp>
42_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {
43#if __has_builtin(__builtin_ctzg)
44 return __builtin_ctzg(__t, numeric_limits<_Tp>::digits);
45#else // __has_builtin(__builtin_ctzg)
4246 if (__t == 0)
4347 return numeric_limits<_Tp>::digits;
44
4548 if (sizeof(_Tp) <= sizeof(unsigned int))
4649 return std::__libcpp_ctz(static_cast<unsigned int>(__t));
4750 else if (sizeof(_Tp) <= sizeof(unsigned long))
......@@ -57,10 +60,18 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) n
5760 }
5861 return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
5962 }
63#endif // __has_builtin(__builtin_ctzg)
64}
65
66#if _LIBCPP_STD_VER >= 20
67
68template <__libcpp_unsigned_integer _Tp>
69[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_zero(_Tp __t) noexcept {
70 return std::__countr_zero(__t);
6071}
6172
6273template <__libcpp_unsigned_integer _Tp>
63_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
74[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int countr_one(_Tp __t) noexcept {
6475 return __t != numeric_limits<_Tp>::max() ? std::countr_zero(static_cast<_Tp>(~__t)) : numeric_limits<_Tp>::digits;
6576}
6677
lib/libcxx/include/__bit/has_single_bit.h+1-1
......@@ -24,7 +24,7 @@ _LIBCPP_PUSH_MACROS
2424_LIBCPP_BEGIN_NAMESPACE_STD
2525
2626template <__libcpp_unsigned_integer _Tp>
27_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
27[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool has_single_bit(_Tp __t) noexcept {
2828 return __t != 0 && (((__t & (__t - 1)) == 0));
2929}
3030
lib/libcxx/include/__bit/popcount.h+8-1
......@@ -6,6 +6,9 @@
66//
77//===----------------------------------------------------------------------===//
88
9// TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
10// refactor this code to exclusively use __builtin_popcountg.
11
912#ifndef _LIBCPP___BIT_POPCOUNT_H
1013#define _LIBCPP___BIT_POPCOUNT_H
1114
......@@ -38,7 +41,10 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo
3841#if _LIBCPP_STD_VER >= 20
3942
4043template <__libcpp_unsigned_integer _Tp>
41_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
44[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
45# if __has_builtin(__builtin_popcountg)
46 return __builtin_popcountg(__t);
47# else // __has_builtin(__builtin_popcountg)
4248 if (sizeof(_Tp) <= sizeof(unsigned int))
4349 return std::__libcpp_popcount(static_cast<unsigned int>(__t));
4450 else if (sizeof(_Tp) <= sizeof(unsigned long))
......@@ -53,6 +59,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex
5359 }
5460 return __ret;
5561 }
62# endif // __has_builtin(__builtin_popcountg)
5663}
5764
5865#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__bit/rotate.h+25-12
......@@ -20,24 +20,37 @@
2020
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
23// Writing two full functions for rotl and rotr makes it easier for the compiler
24// to optimize the code. On x86 this function becomes the ROL instruction and
25// the rotr function becomes the ROR instruction.
2326template <class _Tp>
24_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __t, int __cnt) _NOEXCEPT {
25 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
26 const unsigned int __dig = numeric_limits<_Tp>::digits;
27 if ((__cnt % __dig) == 0)
28 return __t;
27_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __x, int __s) _NOEXCEPT {
28 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotl requires an unsigned integer type");
29 const int __N = numeric_limits<_Tp>::digits;
30 int __r = __s % __N;
31
32 if (__r == 0)
33 return __x;
2934
30 if (__cnt < 0) {
31 __cnt *= -1;
32 return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig))); // rotr with negative __cnt is similar to rotl
33 }
35 if (__r > 0)
36 return (__x << __r) | (__x >> (__N - __r));
3437
35 return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
38 return (__x >> -__r) | (__x << (__N + __r));
3639}
3740
3841template <class _Tp>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotl(_Tp __t, int __cnt) _NOEXCEPT {
40 return std::__rotr(__t, -__cnt);
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __rotr(_Tp __x, int __s) _NOEXCEPT {
43 static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__rotr requires an unsigned integer type");
44 const int __N = numeric_limits<_Tp>::digits;
45 int __r = __s % __N;
46
47 if (__r == 0)
48 return __x;
49
50 if (__r > 0)
51 return (__x >> __r) | (__x << (__N - __r));
52
53 return (__x << -__r) | (__x >> (__N + __r));
4154}
4255
4356#if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__bit_reference+26-66
......@@ -16,6 +16,7 @@
1616#include <__bit/countr.h>
1717#include <__bit/invert_if.h>
1818#include <__bit/popcount.h>
19#include <__compare/ordering.h>
1920#include <__config>
2021#include <__fwd/bit_reference.h>
2122#include <__iterator/iterator_traits.h>
......@@ -95,8 +96,8 @@ public:
9596 }
9697
9798private:
98 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_reference(
99 __storage_pointer __s, __storage_type __m) _NOEXCEPT
99 _LIBCPP_HIDE_FROM_ABI
100 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
100101 : __seg_(__s),
101102 __mask_(__m) {}
102103};
......@@ -149,6 +150,7 @@ public:
149150 using __container = typename _Cp::__self;
150151
151152 _LIBCPP_HIDE_FROM_ABI __bit_const_reference(const __bit_const_reference&) = default;
153 __bit_const_reference& operator=(const __bit_const_reference&) = delete;
152154
153155 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
154156 : __seg_(__x.__seg_),
......@@ -163,69 +165,12 @@ public:
163165 }
164166
165167private:
166 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __bit_const_reference(
167 __storage_pointer __s, __storage_type __m) _NOEXCEPT
168 _LIBCPP_HIDE_FROM_ABI
169 _LIBCPP_CONSTEXPR explicit __bit_const_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
168170 : __seg_(__s),
169171 __mask_(__m) {}
170
171 __bit_const_reference& operator=(const __bit_const_reference&) = delete;
172172};
173173
174// fill_n
175
176template <bool _FillVal, class _Cp>
177_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
178__fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) {
179 using _It = __bit_iterator<_Cp, false>;
180 using __storage_type = typename _It::__storage_type;
181
182 const int __bits_per_word = _It::__bits_per_word;
183 // do first partial word
184 if (__first.__ctz_ != 0) {
185 __storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
186 __storage_type __dn = std::min(__clz_f, __n);
187 __storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
188 if (_FillVal)
189 *__first.__seg_ |= __m;
190 else
191 *__first.__seg_ &= ~__m;
192 __n -= __dn;
193 ++__first.__seg_;
194 }
195 // do middle whole words
196 __storage_type __nw = __n / __bits_per_word;
197 std::fill_n(std::__to_address(__first.__seg_), __nw, _FillVal ? static_cast<__storage_type>(-1) : 0);
198 __n -= __nw * __bits_per_word;
199 // do last partial word
200 if (__n > 0) {
201 __first.__seg_ += __nw;
202 __storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
203 if (_FillVal)
204 *__first.__seg_ |= __m;
205 else
206 *__first.__seg_ &= ~__m;
207 }
208}
209
210template <class _Cp>
211inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
212fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value) {
213 if (__n > 0) {
214 if (__value)
215 std::__fill_n<true>(__first, __n);
216 else
217 std::__fill_n<false>(__first, __n);
218 }
219}
220
221// fill
222
223template <class _Cp>
224inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
225fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value) {
226 std::fill_n(__first, static_cast<typename _Cp::size_type>(__last - __first), __value);
227}
228
229174// copy
230175
231176template <class _Cp, bool _IsConst>
......@@ -969,6 +914,7 @@ public:
969914 return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;
970915 }
971916
917#if _LIBCPP_STD_VER <= 17
972918 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 friend bool
973919 operator!=(const __bit_iterator& __x, const __bit_iterator& __y) {
974920 return !(__x == __y);
......@@ -993,10 +939,22 @@ public:
993939 operator>=(const __bit_iterator& __x, const __bit_iterator& __y) {
994940 return !(__x < __y);
995941 }
942#else // _LIBCPP_STD_VER <= 17
943 _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
944 operator<=>(const __bit_iterator& __x, const __bit_iterator& __y) {
945 if (__x.__seg_ < __y.__seg_)
946 return strong_ordering::less;
947
948 if (__x.__seg_ == __y.__seg_)
949 return __x.__ctz_ <=> __y.__ctz_;
950
951 return strong_ordering::greater;
952 }
953#endif // _LIBCPP_STD_VER <= 17
996954
997955private:
998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(
999 __storage_pointer __s, unsigned __ctz) _NOEXCEPT
956 _LIBCPP_HIDE_FROM_ABI
957 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
1000958 : __seg_(__s),
1001959 __ctz_(__ctz) {}
1002960
......@@ -1007,8 +965,10 @@ private:
1007965 friend class __bit_iterator<_Cp, true>;
1008966 template <class _Dp>
1009967 friend struct __bit_array;
968
1010969 template <bool _FillVal, class _Dp>
1011 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void __fill_n(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
970 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend void
971 __fill_n_bool(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
1012972
1013973 template <class _Dp, bool _IC>
1014974 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, false> __copy_aligned(
......@@ -1053,8 +1013,8 @@ private:
10531013 _LIBCPP_CONSTEXPR_SINCE_CXX20 friend __bit_iterator<_Dp, _IC>
10541014 __find_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
10551015 template <bool _ToCount, class _Dp, bool _IC>
1056 friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1057 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
1016 friend typename __bit_iterator<_Dp, _IC>::difference_type _LIBCPP_HIDE_FROM_ABI
1017 _LIBCPP_CONSTEXPR_SINCE_CXX20 __count_bool(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
10581018};
10591019
10601020_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__charconv/chars_format.h+3-6
......@@ -39,20 +39,17 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator^(chars_format __x,
3939 return chars_format(std::__to_underlying(__x) ^ std::__to_underlying(__y));
4040}
4141
42inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
43operator&=(chars_format& __x, chars_format __y) {
42inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator&=(chars_format& __x, chars_format __y) {
4443 __x = __x & __y;
4544 return __x;
4645}
4746
48inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
49operator|=(chars_format& __x, chars_format __y) {
47inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator|=(chars_format& __x, chars_format __y) {
5048 __x = __x | __y;
5149 return __x;
5250}
5351
54inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 chars_format&
55operator^=(chars_format& __x, chars_format __y) {
52inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format& operator^=(chars_format& __x, chars_format __y) {
5653 __x = __x ^ __y;
5754 return __x;
5855}
lib/libcxx/include/__charconv/from_chars_integral.h+1
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___CHARCONV_FROM_CHARS_INTEGRAL_H
1212
1313#include <__algorithm/copy_n.h>
14#include <__assert>
1415#include <__charconv/from_chars_result.h>
1516#include <__charconv/traits.h>
1617#include <__config>
lib/libcxx/include/__charconv/to_chars_base_10.h+1
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___CHARCONV_TO_CHARS_BASE_10_H
1212
1313#include <__algorithm/copy_n.h>
14#include <__assert>
1415#include <__charconv/tables.h>
1516#include <__config>
1617#include <cstdint>
lib/libcxx/include/__charconv/to_chars_floating_point.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
1111#define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
1212
13#include <__availability>
1413#include <__charconv/chars_format.h>
1514#include <__charconv/to_chars_result.h>
1615#include <__config>
lib/libcxx/include/__charconv/to_chars_integral.h+1
......@@ -11,6 +11,7 @@
1111#define _LIBCPP___CHARCONV_TO_CHARS_INTEGRAL_H
1212
1313#include <__algorithm/copy_n.h>
14#include <__assert>
1415#include <__bit/countl.h>
1516#include <__charconv/tables.h>
1617#include <__charconv/to_chars_base_10.h>
lib/libcxx/include/__charconv/traits.h+1
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___CHARCONV_TRAITS
1111#define _LIBCPP___CHARCONV_TRAITS
1212
13#include <__assert>
1314#include <__bit/countl.h>
1415#include <__charconv/tables.h>
1516#include <__charconv/to_chars_base_10.h>
lib/libcxx/include/__chrono/convert_to_tm.h+16
......@@ -16,10 +16,12 @@
1616#include <__chrono/duration.h>
1717#include <__chrono/file_clock.h>
1818#include <__chrono/hh_mm_ss.h>
19#include <__chrono/local_info.h>
1920#include <__chrono/month.h>
2021#include <__chrono/month_weekday.h>
2122#include <__chrono/monthday.h>
2223#include <__chrono/statically_widen.h>
24#include <__chrono/sys_info.h>
2325#include <__chrono/system_clock.h>
2426#include <__chrono/time_point.h>
2527#include <__chrono/weekday.h>
......@@ -27,11 +29,13 @@
2729#include <__chrono/year_month.h>
2830#include <__chrono/year_month_day.h>
2931#include <__chrono/year_month_weekday.h>
32#include <__chrono/zoned_time.h>
3033#include <__concepts/same_as.h>
3134#include <__config>
3235#include <__format/format_error.h>
3336#include <__memory/addressof.h>
3437#include <__type_traits/is_convertible.h>
38#include <__type_traits/is_specialization.h>
3539#include <cstdint>
3640#include <ctime>
3741#include <limits>
......@@ -171,6 +175,18 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
171175 if (__value.hours().count() > std::numeric_limits<decltype(__result.tm_hour)>::max())
172176 std::__throw_format_error("Formatting hh_mm_ss, encountered an hour overflow");
173177 __result.tm_hour = __value.hours().count();
178# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
179 } else if constexpr (same_as<_ChronoT, chrono::sys_info>) {
180 // Has no time information.
181 } else if constexpr (same_as<_ChronoT, chrono::local_info>) {
182 // Has no time information.
183# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
184 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
185 } else if constexpr (__is_specialization_v<_ChronoT, chrono::zoned_time>) {
186 return std::__convert_to_tm<_Tm>(
187 chrono::sys_time<typename _ChronoT::duration>{__value.get_local_time().time_since_epoch()});
188# endif
189# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
174190 } else
175191 static_assert(sizeof(_ChronoT) == 0, "Add the missing type specialization");
176192
lib/libcxx/include/__chrono/duration.h+10-10
......@@ -391,8 +391,8 @@ operator<=>(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Perio
391391
392392template <class _Rep1, class _Period1, class _Rep2, class _Period2>
393393inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
394 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
395 operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
394typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
395operator+(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
396396 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
397397 return _Cd(_Cd(__lhs).count() + _Cd(__rhs).count());
398398}
......@@ -401,8 +401,8 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
401401
402402template <class _Rep1, class _Period1, class _Rep2, class _Period2>
403403inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
404 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
405 operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
404typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
405operator-(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
406406 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
407407 return _Cd(_Cd(__lhs).count() - _Cd(__rhs).count());
408408}
......@@ -412,7 +412,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
412412template <class _Rep1,
413413 class _Period,
414414 class _Rep2,
415 __enable_if_t<is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
415 __enable_if_t<is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
416416inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
417417operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
418418 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
......@@ -423,7 +423,7 @@ operator*(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
423423template <class _Rep1,
424424 class _Period,
425425 class _Rep2,
426 __enable_if_t<is_convertible<_Rep1, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
426 __enable_if_t<is_convertible<const _Rep1&, typename common_type<_Rep1, _Rep2>::type>::value, int> = 0>
427427inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
428428operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d) {
429429 return __d * __s;
......@@ -435,7 +435,7 @@ template <class _Rep1,
435435 class _Period,
436436 class _Rep2,
437437 __enable_if_t<!__is_duration<_Rep2>::value &&
438 is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
438 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
439439 int> = 0>
440440inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
441441operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
......@@ -457,7 +457,7 @@ template <class _Rep1,
457457 class _Period,
458458 class _Rep2,
459459 __enable_if_t<!__is_duration<_Rep2>::value &&
460 is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
460 is_convertible<const _Rep2&, typename common_type<_Rep1, _Rep2>::type>::value,
461461 int> = 0>
462462inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<typename common_type<_Rep1, _Rep2>::type, _Period>
463463operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
......@@ -468,8 +468,8 @@ operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s) {
468468
469469template <class _Rep1, class _Period1, class _Rep2, class _Period2>
470470inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
471 typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
472 operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
471typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type
472operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
473473 typedef typename common_type<_Rep1, _Rep2>::type _Cr;
474474 typedef typename common_type<duration<_Rep1, _Period1>, duration<_Rep2, _Period2> >::type _Cd;
475475 return _Cd(static_cast<_Cr>(_Cd(__lhs).count()) % static_cast<_Cr>(_Cd(__rhs).count()));
lib/libcxx/include/__chrono/exception.h created+135
......@@ -0,0 +1,135 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_EXCEPTION_H
13#define _LIBCPP___CHRONO_EXCEPTION_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/calendar.h>
20# include <__chrono/local_info.h>
21# include <__chrono/time_point.h>
22# include <__config>
23# include <__configuration/availability.h>
24# include <__verbose_abort>
25# include <format>
26# include <stdexcept>
27# include <string>
28
29# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31# endif
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35# if _LIBCPP_STD_VER >= 20
36
37namespace chrono {
38
39class nonexistent_local_time : public runtime_error {
40public:
41 template <class _Duration>
42 _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const local_time<_Duration>& __time, const local_info& __info)
43 : runtime_error{__create_message(__time, __info)} {
44 // [time.zone.exception.nonexist]/2
45 // Preconditions: i.result == local_info::nonexistent is true.
46 // The value of __info.result is not used.
47 _LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::nonexistent,
48 "creating an nonexistent_local_time from a local_info that is not non-existent");
49 }
50
51 _LIBCPP_HIDE_FROM_ABI nonexistent_local_time(const nonexistent_local_time&) = default;
52 _LIBCPP_HIDE_FROM_ABI nonexistent_local_time& operator=(const nonexistent_local_time&) = default;
53
54 _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI ~nonexistent_local_time() override; // exported as key function
55
56private:
57 template <class _Duration>
58 _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& __time, const local_info& __info) {
59 return std::format(
60 R"({} is in a gap between
61{} {} and
62{} {} which are both equivalent to
63{} UTC)",
64 __time,
65 local_seconds{__info.first.end.time_since_epoch()} + __info.first.offset,
66 __info.first.abbrev,
67 local_seconds{__info.second.begin.time_since_epoch()} + __info.second.offset,
68 __info.second.abbrev,
69 __info.first.end);
70 }
71};
72
73template <class _Duration>
74_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time(
75 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
76# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
77 throw nonexistent_local_time(__time, __info);
78# else
79 _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode");
80# endif
81}
82
83class ambiguous_local_time : public runtime_error {
84public:
85 template <class _Duration>
86 _LIBCPP_HIDE_FROM_ABI ambiguous_local_time(const local_time<_Duration>& __time, const local_info& __info)
87 : runtime_error{__create_message(__time, __info)} {
88 // [time.zone.exception.ambig]/2
89 // Preconditions: i.result == local_info::ambiguous is true.
90 // The value of __info.result is not used.
91 _LIBCPP_ASSERT_PEDANTIC(__info.result == local_info::ambiguous,
92 "creating an ambiguous_local_time from a local_info that is not ambiguous");
93 }
94
95 _LIBCPP_HIDE_FROM_ABI ambiguous_local_time(const ambiguous_local_time&) = default;
96 _LIBCPP_HIDE_FROM_ABI ambiguous_local_time& operator=(const ambiguous_local_time&) = default;
97
98 _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI ~ambiguous_local_time() override; // exported as key function
99
100private:
101 template <class _Duration>
102 _LIBCPP_HIDE_FROM_ABI string __create_message(const local_time<_Duration>& __time, const local_info& __info) {
103 return std::format(
104 // There are two spaces after the full-stop; this has been verified
105 // in the sources of the Standard.
106 R"({0} is ambiguous. It could be
107{0} {1} == {2} UTC or
108{0} {3} == {4} UTC)",
109 __time,
110 __info.first.abbrev,
111 __time - __info.first.offset,
112 __info.second.abbrev,
113 __time - __info.second.offset);
114 }
115};
116
117template <class _Duration>
118_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time(
119 [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) {
120# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
121 throw ambiguous_local_time(__time, __info);
122# else
123 _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode");
124# endif
125}
126
127} // namespace chrono
128
129# endif // _LIBCPP_STD_VER >= 20
130
131_LIBCPP_END_NAMESPACE_STD
132
133#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
134
135#endif // _LIBCPP___CHRONO_EXCEPTION_H
lib/libcxx/include/__chrono/file_clock.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___CHRONO_FILE_CLOCK_H
1111#define _LIBCPP___CHRONO_FILE_CLOCK_H
1212
13#include <__availability>
1413#include <__chrono/duration.h>
1514#include <__chrono/system_clock.h>
1615#include <__chrono/time_point.h>
lib/libcxx/include/__chrono/formatter.h+195-26
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___CHRONO_FORMATTER_H
1111#define _LIBCPP___CHRONO_FORMATTER_H
1212
13#include <__algorithm/ranges_copy.h>
1314#include <__chrono/calendar.h>
1415#include <__chrono/concepts.h>
1516#include <__chrono/convert_to_tm.h>
......@@ -17,12 +18,14 @@
1718#include <__chrono/duration.h>
1819#include <__chrono/file_clock.h>
1920#include <__chrono/hh_mm_ss.h>
21#include <__chrono/local_info.h>
2022#include <__chrono/month.h>
2123#include <__chrono/month_weekday.h>
2224#include <__chrono/monthday.h>
2325#include <__chrono/ostream.h>
2426#include <__chrono/parser_std_format_spec.h>
2527#include <__chrono/statically_widen.h>
28#include <__chrono/sys_info.h>
2629#include <__chrono/system_clock.h>
2730#include <__chrono/time_point.h>
2831#include <__chrono/weekday.h>
......@@ -30,6 +33,7 @@
3033#include <__chrono/year_month.h>
3134#include <__chrono/year_month_day.h>
3235#include <__chrono/year_month_weekday.h>
36#include <__chrono/zoned_time.h>
3337#include <__concepts/arithmetic.h>
3438#include <__concepts/same_as.h>
3539#include <__config>
......@@ -41,8 +45,10 @@
4145#include <__format/parser_std_format_spec.h>
4246#include <__format/write_escaped.h>
4347#include <__memory/addressof.h>
48#include <__type_traits/is_specialization.h>
4449#include <cmath>
4550#include <ctime>
51#include <limits>
4652#include <sstream>
4753#include <string_view>
4854
......@@ -79,12 +85,15 @@ namespace __formatter {
7985// small). Therefore a duration uses its own conversion.
8086template <class _CharT, class _Rep, class _Period>
8187_LIBCPP_HIDE_FROM_ABI void
82__format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_stringstream<_CharT>& __sstr) {
88__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::duration<_Rep, _Period>& __value) {
8389 __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
8490
8591 using __duration = chrono::duration<_Rep, _Period>;
8692
8793 auto __fraction = __value - chrono::duration_cast<chrono::seconds>(__value);
94 // Converts a negative fraction to its positive value.
95 if (__value < chrono::seconds{0} && __fraction != __duration{0})
96 __fraction += chrono::seconds{1};
8897 if constexpr (chrono::treat_as_floating_point_v<_Rep>)
8998 // When the floating-point value has digits itself they are ignored based
9099 // on the wording in [tab:time.format.spec]
......@@ -110,13 +119,13 @@ __format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_strin
110119}
111120
112121template <class _CharT, __is_time_point _Tp>
113_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, basic_stringstream<_CharT>& __sstr) {
114 __formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr);
122_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const _Tp& __value) {
123 __formatter::__format_sub_seconds(__sstr, __value.time_since_epoch());
115124}
116125
117126template <class _CharT, class _Duration>
118127_LIBCPP_HIDE_FROM_ABI void
119__format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstream<_CharT>& __sstr) {
128__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<_Duration>& __value) {
120129 __sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
121130 if constexpr (chrono::treat_as_floating_point_v<typename _Duration::rep>)
122131 std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
......@@ -130,10 +139,24 @@ __format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstr
130139 __value.fractional_width);
131140}
132141
142# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
143 !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
144template <class _CharT, class _Duration, class _TimeZonePtr>
145_LIBCPP_HIDE_FROM_ABI void
146__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
147 __formatter::__format_sub_seconds(__sstr, __value.get_local_time().time_since_epoch());
148}
149# endif
150
133151template <class _Tp>
134152consteval bool __use_fraction() {
135153 if constexpr (__is_time_point<_Tp>)
136154 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
155# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
156 !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
157 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
158 return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
159# endif
137160 else if constexpr (chrono::__is_duration<_Tp>::value)
138161 return chrono::hh_mm_ss<_Tp>::fractional_width;
139162 else if constexpr (__is_hh_mm_ss<_Tp>)
......@@ -143,7 +166,7 @@ consteval bool __use_fraction() {
143166}
144167
145168template <class _CharT>
146_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& __sstr) {
169_LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, int __year) {
147170 if (__year < 0) {
148171 __sstr << _CharT('-');
149172 __year = -__year;
......@@ -159,7 +182,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>&
159182}
160183
161184template <class _CharT>
162_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_CharT>& __sstr) {
185_LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& __sstr, int __year) {
163186 // TODO FMT Write an issue
164187 // [tab:time.format.spec]
165188 // %C The year divided by 100 using floored division. If the result is a
......@@ -170,10 +193,56 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_Char
170193 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __century);
171194}
172195
196// Implements the %z format specifier according to [tab:time.format.spec], where
197// '__modifier' signals %Oz or %Ez were used. (Both modifiers behave the same,
198// so there is no need to distinguish between them.)
199template <class _CharT>
200_LIBCPP_HIDE_FROM_ABI void
201__format_zone_offset(basic_stringstream<_CharT>& __sstr, chrono::seconds __offset, bool __modifier) {
202 if (__offset < 0s) {
203 __sstr << _CharT('-');
204 __offset = -__offset;
205 } else {
206 __sstr << _CharT('+');
207 }
208
209 chrono::hh_mm_ss __hms{__offset};
210 std::ostreambuf_iterator<_CharT> __out_it{__sstr};
211 // Note HMS does not allow formatting hours > 23, but the offset is not limited to 24H.
212 std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __hms.hours().count());
213 if (__modifier)
214 __sstr << _CharT(':');
215 std::format_to(__out_it, _LIBCPP_STATICALLY_WIDEN(_CharT, "{:02}"), __hms.minutes().count());
216}
217
218// Helper to store the time zone information needed for formatting.
219struct _LIBCPP_HIDE_FROM_ABI __time_zone {
220 // Typically these abbreviations are short and fit in the string's internal
221 // buffer.
222 string __abbrev;
223 chrono::seconds __offset;
224};
225
226template <class _Tp>
227_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone([[maybe_unused]] const _Tp& __value) {
228# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
229 if constexpr (same_as<_Tp, chrono::sys_info>)
230 return {__value.abbrev, __value.offset};
231# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
232 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
233 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
234 return __formatter::__convert_to_time_zone(__value.get_info());
235# endif
236 else
237# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
238 return {"UTC", chrono::seconds{0}};
239}
240
173241template <class _CharT, class _Tp>
174242_LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
175 const _Tp& __value, basic_stringstream<_CharT>& __sstr, basic_string_view<_CharT> __chrono_specs) {
243 basic_stringstream<_CharT>& __sstr, const _Tp& __value, basic_string_view<_CharT> __chrono_specs) {
176244 tm __t = std::__convert_to_tm<tm>(__value);
245 __time_zone __z = __formatter::__convert_to_time_zone(__value);
177246 const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc());
178247 for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) {
179248 if (*__it == _CharT('%')) {
......@@ -196,7 +265,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
196265 // strftime's output is only defined in the range [00, 99].
197266 int __year = __t.tm_year + 1900;
198267 if (__year < 1000 || __year > 9999)
199 __formatter::__format_century(__year, __sstr);
268 __formatter::__format_century(__sstr, __year);
200269 else
201270 __facet.put(
202271 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
......@@ -242,7 +311,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
242311 __facet.put(
243312 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
244313 if constexpr (__use_fraction<_Tp>())
245 __formatter::__format_sub_seconds(__value, __sstr);
314 __formatter::__format_sub_seconds(__sstr, __value);
246315 break;
247316
248317 // Unlike time_put and strftime the formatting library requires %Y
......@@ -283,22 +352,24 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
283352 // Depending on the platform's libc the range of supported years is
284353 // limited. Intead of of testing all conditions use the internal
285354 // implementation unconditionally.
286 __formatter::__format_year(__t.tm_year + 1900, __sstr);
355 __formatter::__format_year(__sstr, __t.tm_year + 1900);
287356 break;
288357
289 case _CharT('F'): {
290 int __year = __t.tm_year + 1900;
291 if (__year < 1000) {
292 __formatter::__format_year(__year, __sstr);
293 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
294 } else
295 __facet.put(
296 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
297 } break;
358 case _CharT('F'):
359 // Depending on the platform's libc the range of supported years is
360 // limited. Instead of testing all conditions use the internal
361 // implementation unconditionally.
362 __formatter::__format_year(__sstr, __t.tm_year + 1900);
363 __sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
364 break;
365
366 case _CharT('z'):
367 __formatter::__format_zone_offset(__sstr, __z.__offset, false);
368 break;
298369
299370 case _CharT('Z'):
300 // TODO FMT Add proper timezone support.
301 __sstr << _LIBCPP_STATICALLY_WIDEN(_CharT, "UTC");
371 // __abbrev is always a char so the copy may convert.
372 ranges::copy(__z.__abbrev, std::ostreambuf_iterator<_CharT>{__sstr});
302373 break;
303374
304375 case _CharT('O'):
......@@ -310,13 +381,19 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
310381 ++__it;
311382 __facet.put(
312383 {__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
313 __formatter::__format_sub_seconds(__value, __sstr);
384 __formatter::__format_sub_seconds(__sstr, __value);
314385 break;
315386 }
316387 }
388
389 // Oz produces the same output as Ez below.
317390 [[fallthrough]];
318391 case _CharT('E'):
319392 ++__it;
393 if (*__it == 'z') {
394 __formatter::__format_zone_offset(__sstr, __z.__offset, true);
395 break;
396 }
320397 [[fallthrough]];
321398 default:
322399 __facet.put(
......@@ -365,6 +442,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
365442 return __value.weekday().ok();
366443 else if constexpr (__is_hh_mm_ss<_Tp>)
367444 return true;
445# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
446 else if constexpr (same_as<_Tp, chrono::sys_info>)
447 return true;
448 else if constexpr (same_as<_Tp, chrono::local_info>)
449 return true;
450# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
451 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
452 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
453 return true;
454# endif
455# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
368456 else
369457 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
370458}
......@@ -405,6 +493,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
405493 return __value.weekday().ok();
406494 else if constexpr (__is_hh_mm_ss<_Tp>)
407495 return true;
496# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
497 else if constexpr (same_as<_Tp, chrono::sys_info>)
498 return true;
499 else if constexpr (same_as<_Tp, chrono::local_info>)
500 return true;
501# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
502 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
503 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
504 return true;
505# endif
506# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
408507 else
409508 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
410509}
......@@ -445,6 +544,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
445544 return __value.ok();
446545 else if constexpr (__is_hh_mm_ss<_Tp>)
447546 return true;
547# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
548 else if constexpr (same_as<_Tp, chrono::sys_info>)
549 return true;
550 else if constexpr (same_as<_Tp, chrono::local_info>)
551 return true;
552# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
553 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
554 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
555 return true;
556# endif
557# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
448558 else
449559 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
450560}
......@@ -485,6 +595,17 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
485595 return __value.month().ok();
486596 else if constexpr (__is_hh_mm_ss<_Tp>)
487597 return true;
598# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
599 else if constexpr (same_as<_Tp, chrono::sys_info>)
600 return true;
601 else if constexpr (same_as<_Tp, chrono::local_info>)
602 return true;
603# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
604 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
605 else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
606 return true;
607# endif
608# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
488609 else
489610 static_assert(sizeof(_Tp) == 0, "Add the missing type specialization");
490611}
......@@ -510,9 +631,16 @@ __format_chrono(const _Tp& __value,
510631 __sstr << __value;
511632 else {
512633 if constexpr (chrono::__is_duration<_Tp>::value) {
513 if (__value < __value.zero())
514 __sstr << _CharT('-');
515 __formatter::__format_chrono_using_chrono_specs(chrono::abs(__value), __sstr, __chrono_specs);
634 // A duration can be a user defined arithmetic type. Users may specialize
635 // numeric_limits, but they may not specialize is_signed.
636 if constexpr (numeric_limits<typename _Tp::rep>::is_signed) {
637 if (__value < __value.zero()) {
638 __sstr << _CharT('-');
639 __formatter::__format_chrono_using_chrono_specs(__sstr, -__value, __chrono_specs);
640 } else
641 __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs);
642 } else
643 __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs);
516644 // TODO FMT When keeping the precision it will truncate the string.
517645 // Note that the behaviour what the precision does isn't specified.
518646 __specs.__precision_ = -1;
......@@ -556,7 +684,7 @@ __format_chrono(const _Tp& __value,
556684 __sstr << _CharT('-');
557685 }
558686
559 __formatter::__format_chrono_using_chrono_specs(__value, __sstr, __chrono_specs);
687 __formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs);
560688 }
561689 }
562690
......@@ -814,6 +942,47 @@ public:
814942 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time);
815943 }
816944};
945
946# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
947template <__fmt_char_type _CharT>
948struct formatter<chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {
949public:
950 using _Base = __formatter_chrono<_CharT>;
951
952 template <class _ParseContext>
953 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
954 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__time_zone);
955 }
956};
957
958template <__fmt_char_type _CharT>
959struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT> {
960public:
961 using _Base = __formatter_chrono<_CharT>;
962
963 template <class _ParseContext>
964 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
965 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
966 }
967};
968# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
969 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
970// Note due to how libc++'s formatters are implemented there is no need to add
971// the exposition only local-time-format-t abstraction.
972template <class _Duration, class _TimeZonePtr, __fmt_char_type _CharT>
973struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public __formatter_chrono<_CharT> {
974public:
975 using _Base = __formatter_chrono<_CharT>;
976
977 template <class _ParseContext>
978 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __ctx) {
979 return _Base::__parse(__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
980 }
981};
982# endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
983 // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
984# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
985
817986#endif // if _LIBCPP_STD_VER >= 20
818987
819988_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__chrono/leap_second.h created+126
......@@ -0,0 +1,126 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_LEAP_SECOND_H
13#define _LIBCPP___CHRONO_LEAP_SECOND_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/duration.h>
20# include <__chrono/system_clock.h>
21# include <__chrono/time_point.h>
22# include <__compare/ordering.h>
23# include <__compare/three_way_comparable.h>
24# include <__config>
25# include <__utility/private_constructor_tag.h>
26
27# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29# endif
30
31_LIBCPP_BEGIN_NAMESPACE_STD
32
33# if _LIBCPP_STD_VER >= 20
34
35namespace chrono {
36
37class leap_second {
38public:
39 [[nodiscard]]
40 _LIBCPP_HIDE_FROM_ABI explicit constexpr leap_second(__private_constructor_tag, sys_seconds __date, seconds __value)
41 : __date_(__date), __value_(__value) {}
42
43 _LIBCPP_HIDE_FROM_ABI leap_second(const leap_second&) = default;
44 _LIBCPP_HIDE_FROM_ABI leap_second& operator=(const leap_second&) = default;
45
46 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr sys_seconds date() const noexcept { return __date_; }
47
48 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI constexpr seconds value() const noexcept { return __value_; }
49
50private:
51 sys_seconds __date_;
52 seconds __value_;
53};
54
55_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const leap_second& __x, const leap_second& __y) {
56 return __x.date() == __y.date();
57}
58
59_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const leap_second& __x, const leap_second& __y) {
60 return __x.date() <=> __y.date();
61}
62
63template <class _Duration>
64_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const leap_second& __x, const sys_time<_Duration>& __y) {
65 return __x.date() == __y;
66}
67
68template <class _Duration>
69_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const leap_second& __x, const sys_time<_Duration>& __y) {
70 return __x.date() < __y;
71}
72
73template <class _Duration>
74_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const sys_time<_Duration>& __x, const leap_second& __y) {
75 return __x < __y.date();
76}
77
78template <class _Duration>
79_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const leap_second& __x, const sys_time<_Duration>& __y) {
80 return __y < __x;
81}
82
83template <class _Duration>
84_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const sys_time<_Duration>& __x, const leap_second& __y) {
85 return __y < __x;
86}
87
88template <class _Duration>
89_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const leap_second& __x, const sys_time<_Duration>& __y) {
90 return !(__y < __x);
91}
92
93template <class _Duration>
94_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const sys_time<_Duration>& __x, const leap_second& __y) {
95 return !(__y < __x);
96}
97
98template <class _Duration>
99_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const leap_second& __x, const sys_time<_Duration>& __y) {
100 return !(__x < __y);
101}
102
103template <class _Duration>
104_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const sys_time<_Duration>& __x, const leap_second& __y) {
105 return !(__x < __y);
106}
107
108# ifndef _LIBCPP_COMPILER_GCC
109// This requirement cause a compilation loop in GCC-13 and running out of memory.
110// TODO TZDB Test whether GCC-14 fixes this.
111template <class _Duration>
112 requires three_way_comparable_with<sys_seconds, sys_time<_Duration>>
113_LIBCPP_HIDE_FROM_ABI constexpr auto operator<=>(const leap_second& __x, const sys_time<_Duration>& __y) {
114 return __x.date() <=> __y;
115}
116# endif
117
118} // namespace chrono
119
120# endif //_LIBCPP_STD_VER >= 20
121
122_LIBCPP_END_NAMESPACE_STD
123
124#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
125
126#endif // _LIBCPP___CHRONO_LEAP_SECOND_H
lib/libcxx/include/__chrono/local_info.h created+50
......@@ -0,0 +1,50 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_LOCAL_INFO_H
13#define _LIBCPP___CHRONO_LOCAL_INFO_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/sys_info.h>
20# include <__config>
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# if _LIBCPP_STD_VER >= 20
29
30namespace chrono {
31
32struct local_info {
33 static constexpr int unique = 0;
34 static constexpr int nonexistent = 1;
35 static constexpr int ambiguous = 2;
36
37 int result;
38 sys_info first;
39 sys_info second;
40};
41
42} // namespace chrono
43
44# endif // _LIBCPP_STD_VER >= 20
45
46_LIBCPP_END_NAMESPACE_STD
47
48#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
49
50#endif // _LIBCPP___CHRONO_LOCAL_INFO_H
lib/libcxx/include/__chrono/ostream.h+52-1
......@@ -15,20 +15,23 @@
1515#include <__chrono/duration.h>
1616#include <__chrono/file_clock.h>
1717#include <__chrono/hh_mm_ss.h>
18#include <__chrono/local_info.h>
1819#include <__chrono/month.h>
1920#include <__chrono/month_weekday.h>
2021#include <__chrono/monthday.h>
2122#include <__chrono/statically_widen.h>
23#include <__chrono/sys_info.h>
2224#include <__chrono/system_clock.h>
2325#include <__chrono/weekday.h>
2426#include <__chrono/year.h>
2527#include <__chrono/year_month.h>
2628#include <__chrono/year_month_day.h>
2729#include <__chrono/year_month_weekday.h>
30#include <__chrono/zoned_time.h>
2831#include <__concepts/same_as.h>
2932#include <__config>
3033#include <__format/format_functions.h>
31#include <ostream>
34#include <__fwd/ostream.h>
3235#include <ratio>
3336
3437#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -262,6 +265,54 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const hh_mm_ss<_Duration> __hms
262265 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%T}"), __hms);
263266}
264267
268# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
269
270template <class _CharT, class _Traits>
271_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
272operator<<(basic_ostream<_CharT, _Traits>& __os, const sys_info& __info) {
273 // __info.abbrev is always std::basic_string<char>.
274 // Since these strings typically are short the conversion should be cheap.
275 std::basic_string<_CharT> __abbrev{__info.abbrev.begin(), __info.abbrev.end()};
276 return __os << std::format(
277 _LIBCPP_STATICALLY_WIDEN(_CharT, "[{:%F %T}, {:%F %T}) {:%T} {:%Q%q} \"{}\""),
278 __info.begin,
279 __info.end,
280 hh_mm_ss{__info.offset},
281 __info.save,
282 __abbrev);
283}
284
285template <class _CharT, class _Traits>
286_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
287operator<<(basic_ostream<_CharT, _Traits>& __os, const local_info& __info) {
288 auto __result = [&]() -> basic_string<_CharT> {
289 switch (__info.result) {
290 case local_info::unique:
291 return _LIBCPP_STATICALLY_WIDEN(_CharT, "unique");
292 case local_info::nonexistent:
293 return _LIBCPP_STATICALLY_WIDEN(_CharT, "non-existent");
294 case local_info::ambiguous:
295 return _LIBCPP_STATICALLY_WIDEN(_CharT, "ambiguous");
296
297 default:
298 return std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "unspecified result ({})"), __info.result);
299 };
300 };
301
302 return __os << std::format(
303 _LIBCPP_STATICALLY_WIDEN(_CharT, "{}: {{{}, {}}}"), __result(), __info.first, __info.second);
304}
305
306# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
307 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
308template <class _CharT, class _Traits, class _Duration, class _TimeZonePtr>
309_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
310operator<<(basic_ostream<_CharT, _Traits>& __os, const zoned_time<_Duration, _TimeZonePtr>& __tp) {
311 return __os << std::format(__os.getloc(), _LIBCPP_STATICALLY_WIDEN(_CharT, "{:L%F %T %Z}"), __tp);
312}
313# endif
314# endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
315
265316} // namespace chrono
266317
267318#endif // if _LIBCPP_STD_VER >= 20
lib/libcxx/include/__chrono/sys_info.h created+51
......@@ -0,0 +1,51 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_SYS_INFO_H
13#define _LIBCPP___CHRONO_SYS_INFO_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/duration.h>
20# include <__chrono/system_clock.h>
21# include <__chrono/time_point.h>
22# include <__config>
23# include <string>
24
25# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27# endif
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30
31# if _LIBCPP_STD_VER >= 20
32
33namespace chrono {
34
35struct sys_info {
36 sys_seconds begin;
37 sys_seconds end;
38 seconds offset;
39 minutes save;
40 string abbrev;
41};
42
43} // namespace chrono
44
45# endif // _LIBCPP_STD_VER >= 20
46
47_LIBCPP_END_NAMESPACE_STD
48
49#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
50
51#endif // _LIBCPP___CHRONO_SYS_INFO_H
lib/libcxx/include/__chrono/time_point.h+14-17
......@@ -78,7 +78,7 @@ public:
7878
7979template <class _Clock, class _Duration1, class _Duration2>
8080struct _LIBCPP_TEMPLATE_VIS
81 common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
81common_type<chrono::time_point<_Clock, _Duration1>, chrono::time_point<_Clock, _Duration2> > {
8282 typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type;
8383};
8484
......@@ -92,25 +92,22 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) {
9292
9393#if _LIBCPP_STD_VER >= 17
9494template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
95inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration>
96floor(const time_point<_Clock, _Duration>& __t) {
95inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> floor(const time_point<_Clock, _Duration>& __t) {
9796 return time_point<_Clock, _ToDuration>{chrono::floor<_ToDuration>(__t.time_since_epoch())};
9897}
9998
10099template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
101inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration>
102ceil(const time_point<_Clock, _Duration>& __t) {
100inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> ceil(const time_point<_Clock, _Duration>& __t) {
103101 return time_point<_Clock, _ToDuration>{chrono::ceil<_ToDuration>(__t.time_since_epoch())};
104102}
105103
106104template <class _ToDuration, class _Clock, class _Duration, enable_if_t<__is_duration<_ToDuration>::value, int> = 0>
107inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR time_point<_Clock, _ToDuration>
108round(const time_point<_Clock, _Duration>& __t) {
105inline _LIBCPP_HIDE_FROM_ABI constexpr time_point<_Clock, _ToDuration> round(const time_point<_Clock, _Duration>& __t) {
109106 return time_point<_Clock, _ToDuration>{chrono::round<_ToDuration>(__t.time_since_epoch())};
110107}
111108
112109template <class _Rep, class _Period, enable_if_t<numeric_limits<_Rep>::is_signed, int> = 0>
113inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
110inline _LIBCPP_HIDE_FROM_ABI constexpr duration<_Rep, _Period> abs(duration<_Rep, _Period> __d) {
114111 return __d >= __d.zero() ? +__d : -__d;
115112}
116113#endif // _LIBCPP_STD_VER >= 17
......@@ -180,9 +177,9 @@ operator<=>(const time_point<_Clock, _Duration1>& __lhs, const time_point<_Clock
180177// time_point operator+(time_point x, duration y);
181178
182179template <class _Clock, class _Duration1, class _Rep2, class _Period2>
183inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
184 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
185 operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
180inline _LIBCPP_HIDE_FROM_ABI
181_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
182operator+(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
186183 typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Tr;
187184 return _Tr(__lhs.time_since_epoch() + __rhs);
188185}
......@@ -190,18 +187,18 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
190187// time_point operator+(duration x, time_point y);
191188
192189template <class _Rep1, class _Period1, class _Clock, class _Duration2>
193inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
194 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
195 operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
190inline _LIBCPP_HIDE_FROM_ABI
191_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<duration<_Rep1, _Period1>, _Duration2>::type>
192operator+(const duration<_Rep1, _Period1>& __lhs, const time_point<_Clock, _Duration2>& __rhs) {
196193 return __rhs + __lhs;
197194}
198195
199196// time_point operator-(time_point x, duration y);
200197
201198template <class _Clock, class _Duration1, class _Rep2, class _Period2>
202inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
203 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
204 operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
199inline _LIBCPP_HIDE_FROM_ABI
200_LIBCPP_CONSTEXPR_SINCE_CXX14 time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type>
201operator-(const time_point<_Clock, _Duration1>& __lhs, const duration<_Rep2, _Period2>& __rhs) {
205202 typedef time_point<_Clock, typename common_type<_Duration1, duration<_Rep2, _Period2> >::type> _Ret;
206203 return _Ret(__lhs.time_since_epoch() - __rhs);
207204}
lib/libcxx/include/__chrono/time_zone.h created+182
......@@ -0,0 +1,182 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_TIME_ZONE_H
13#define _LIBCPP___CHRONO_TIME_ZONE_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/calendar.h>
20# include <__chrono/duration.h>
21# include <__chrono/exception.h>
22# include <__chrono/local_info.h>
23# include <__chrono/sys_info.h>
24# include <__chrono/system_clock.h>
25# include <__compare/strong_order.h>
26# include <__config>
27# include <__memory/unique_ptr.h>
28# include <__type_traits/common_type.h>
29# include <string_view>
30
31# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
32# pragma GCC system_header
33# endif
34
35_LIBCPP_PUSH_MACROS
36# include <__undef_macros>
37
38_LIBCPP_BEGIN_NAMESPACE_STD
39
40# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
41 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
42
43namespace chrono {
44
45enum class choose { earliest, latest };
46
47class _LIBCPP_AVAILABILITY_TZDB time_zone {
48 _LIBCPP_HIDE_FROM_ABI time_zone() = default;
49
50public:
51 class __impl; // public so it can be used by make_unique.
52
53 // The "constructor".
54 //
55 // The default constructor is private to avoid the constructor from being
56 // part of the ABI. Instead use an __ugly_named function as an ABI interface,
57 // since that gives us the ability to change it in the future.
58 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI static time_zone __create(unique_ptr<__impl>&& __p);
59
60 _LIBCPP_EXPORTED_FROM_ABI ~time_zone();
61
62 _LIBCPP_HIDE_FROM_ABI time_zone(time_zone&&) = default;
63 _LIBCPP_HIDE_FROM_ABI time_zone& operator=(time_zone&&) = default;
64
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name(); }
66
67 template <class _Duration>
68 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info(const sys_time<_Duration>& __time) const {
69 return __get_info(chrono::time_point_cast<seconds>(__time));
70 }
71
72 template <class _Duration>
73 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_info get_info(const local_time<_Duration>& __time) const {
74 return __get_info(chrono::time_point_cast<seconds>(__time));
75 }
76
77 // We don't apply nodiscard here since this function throws on many inputs,
78 // so it could be used as a validation.
79 template <class _Duration>
80 _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>> to_sys(const local_time<_Duration>& __time) const {
81 local_info __info = get_info(__time);
82 switch (__info.result) {
83 case local_info::unique:
84 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};
85
86 case local_info::nonexistent:
87 chrono::__throw_nonexistent_local_time(__time, __info);
88
89 case local_info::ambiguous:
90 chrono::__throw_ambiguous_local_time(__time, __info);
91 }
92
93 // TODO TZDB The Standard does not specify anything in these cases.
94 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
95 __info.result != -1, "cannot convert the local time; it would be before the minimum system clock value");
96 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
97 __info.result != -2, "cannot convert the local time; it would be after the maximum system clock value");
98
99 return {};
100 }
101
102 template <class _Duration>
103 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<common_type_t<_Duration, seconds>>
104 to_sys(const local_time<_Duration>& __time, choose __z) const {
105 local_info __info = get_info(__time);
106 switch (__info.result) {
107 case local_info::unique:
108 case local_info::nonexistent: // first and second are the same
109 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};
110
111 case local_info::ambiguous:
112 switch (__z) {
113 case choose::earliest:
114 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.first.offset};
115
116 case choose::latest:
117 return sys_time<common_type_t<_Duration, seconds>>{__time.time_since_epoch() - __info.second.offset};
118
119 // Note a value out of bounds is not specified.
120 }
121 }
122
123 // TODO TZDB The standard does not specify anything in these cases.
124 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
125 __info.result != -1, "cannot convert the local time; it would be before the minimum system clock value");
126 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
127 __info.result != -2, "cannot convert the local time; it would be after the maximum system clock value");
128
129 return {};
130 }
131
132 template <class _Duration>
133 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<common_type_t<_Duration, seconds>>
134 to_local(const sys_time<_Duration>& __time) const {
135 using _Dp = common_type_t<_Duration, seconds>;
136
137 sys_info __info = get_info(__time);
138
139 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
140 __info.offset >= chrono::seconds{0} || __time.time_since_epoch() >= _Dp::min() - __info.offset,
141 "cannot convert the system time; it would be before the minimum local clock value");
142
143 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
144 __info.offset <= chrono::seconds{0} || __time.time_since_epoch() <= _Dp::max() - __info.offset,
145 "cannot convert the system time; it would be after the maximum local clock value");
146
147 return local_time<_Dp>{__time.time_since_epoch() + __info.offset};
148 }
149
150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __impl& __implementation() const noexcept { return *__impl_; }
151
152private:
153 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view __name() const noexcept;
154
155 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info __get_info(sys_seconds __time) const;
156 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info __get_info(local_seconds __time) const;
157
158 unique_ptr<__impl> __impl_;
159};
160
161[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool
162operator==(const time_zone& __x, const time_zone& __y) noexcept {
163 return __x.name() == __y.name();
164}
165
166[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering
167operator<=>(const time_zone& __x, const time_zone& __y) noexcept {
168 return __x.name() <=> __y.name();
169}
170
171} // namespace chrono
172
173# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
174 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
175
176_LIBCPP_END_NAMESPACE_STD
177
178_LIBCPP_POP_MACROS
179
180#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
181
182#endif // _LIBCPP___CHRONO_TIME_ZONE_H
lib/libcxx/include/__chrono/time_zone_link.h created+79
......@@ -0,0 +1,79 @@
1// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_TIME_ZONE_LINK_H
13#define _LIBCPP___CHRONO_TIME_ZONE_LINK_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__compare/strong_order.h>
20# include <__config>
21# include <__utility/private_constructor_tag.h>
22# include <string>
23# include <string_view>
24
25# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27# endif
28
29_LIBCPP_PUSH_MACROS
30# include <__undef_macros>
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
35 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
36
37namespace chrono {
38
39class time_zone_link {
40public:
41 [[nodiscard]]
42 _LIBCPP_HIDE_FROM_ABI explicit time_zone_link(__private_constructor_tag, string_view __name, string_view __target)
43 : __name_{__name}, __target_{__target} {}
44
45 _LIBCPP_HIDE_FROM_ABI time_zone_link(time_zone_link&&) = default;
46 _LIBCPP_HIDE_FROM_ABI time_zone_link& operator=(time_zone_link&&) = default;
47
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view name() const noexcept { return __name_; }
49 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view target() const noexcept { return __target_; }
50
51private:
52 string __name_;
53 // TODO TZDB instead of the name we can store the pointer to a zone. These
54 // pointers are immutable. This makes it possible to directly return a
55 // pointer in the time_zone in the 'locate_zone' function.
56 string __target_;
57};
58
59[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline bool
60operator==(const time_zone_link& __x, const time_zone_link& __y) noexcept {
61 return __x.name() == __y.name();
62}
63
64[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline strong_ordering
65operator<=>(const time_zone_link& __x, const time_zone_link& __y) noexcept {
66 return __x.name() <=> __y.name();
67}
68
69} // namespace chrono
70
71# endif //_LIBCPP_STD_VER >= 20
72
73_LIBCPP_END_NAMESPACE_STD
74
75_LIBCPP_POP_MACROS
76
77#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
78
79#endif // _LIBCPP___CHRONO_TIME_ZONE_LINK_H
lib/libcxx/include/__chrono/tzdb.h+52-3
......@@ -14,14 +14,23 @@
1414
1515#include <version>
1616// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
1818
19# include <__algorithm/ranges_lower_bound.h>
20# include <__chrono/leap_second.h>
21# include <__chrono/time_zone.h>
22# include <__chrono/time_zone_link.h>
23# include <__config>
1924# include <string>
25# include <vector>
2026
2127# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2228# pragma GCC system_header
2329# endif
2430
31_LIBCPP_PUSH_MACROS
32# include <__undef_macros>
33
2534_LIBCPP_BEGIN_NAMESPACE_STD
2635
2736# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
......@@ -29,8 +38,46 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2938
3039namespace chrono {
3140
32struct _LIBCPP_AVAILABILITY_TZDB tzdb {
41struct tzdb {
3342 string version;
43 vector<time_zone> zones;
44 vector<time_zone_link> links;
45
46 vector<leap_second> leap_seconds;
47
48 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* __locate_zone(string_view __name) const {
49 if (const time_zone* __result = __find_in_zone(__name))
50 return __result;
51
52 if (auto __it = ranges::lower_bound(links, __name, {}, &time_zone_link::name);
53 __it != links.end() && __it->name() == __name)
54 if (const time_zone* __result = __find_in_zone(__it->target()))
55 return __result;
56
57 return nullptr;
58 }
59
60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const time_zone* locate_zone(string_view __name) const {
61 if (const time_zone* __result = __locate_zone(__name))
62 return __result;
63
64 std::__throw_runtime_error("tzdb: requested time zone not found");
65 }
66
67 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI const time_zone* current_zone() const {
68 return __current_zone();
69 }
70
71private:
72 _LIBCPP_HIDE_FROM_ABI const time_zone* __find_in_zone(string_view __name) const noexcept {
73 if (auto __it = ranges::lower_bound(zones, __name, {}, &time_zone::name);
74 __it != zones.end() && __it->name() == __name)
75 return std::addressof(*__it);
76
77 return nullptr;
78 }
79
80 [[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* __current_zone() const;
3481};
3582
3683} // namespace chrono
......@@ -40,6 +87,8 @@ struct _LIBCPP_AVAILABILITY_TZDB tzdb {
4087
4188_LIBCPP_END_NAMESPACE_STD
4289
43#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
90_LIBCPP_POP_MACROS
91
92#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
4493
4594#endif // _LIBCPP___CHRONO_TZDB_H
lib/libcxx/include/__chrono/tzdb_list.h+43-16
......@@ -14,12 +14,13 @@
1414
1515#include <version>
1616// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
1818
19# include <__availability>
19# include <__chrono/time_zone.h>
2020# include <__chrono/tzdb.h>
21# include <__config>
22# include <__fwd/string.h>
2123# include <forward_list>
22# include <string_view>
2324
2425# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2526# pragma GCC system_header
......@@ -32,9 +33,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3233
3334namespace chrono {
3435
36// TODO TZDB
37// Libc++ recently switched to only export __ugly_names from the dylib.
38// Since the library is still experimental the functions in this header
39// should be adapted to this new style. The other tzdb headers should be
40// evaluated too.
41
3542class _LIBCPP_AVAILABILITY_TZDB tzdb_list {
3643public:
37 _LIBCPP_EXPORTED_FROM_ABI explicit tzdb_list(tzdb&& __tzdb);
44 class __impl; // public to allow construction in dylib
45 _LIBCPP_HIDE_FROM_ABI explicit tzdb_list(__impl* __p) : __impl_(__p) {
46 _LIBCPP_ASSERT_NON_NULL(__impl_ != nullptr, "initialized time_zone without a valid pimpl object");
47 }
3848 _LIBCPP_EXPORTED_FROM_ABI ~tzdb_list();
3949
4050 tzdb_list(const tzdb_list&) = delete;
......@@ -42,32 +52,49 @@ public:
4252
4353 using const_iterator = forward_list<tzdb>::const_iterator;
4454
45 _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& front() const noexcept;
55 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const tzdb& front() const noexcept { return __front(); }
4656
47 _LIBCPP_EXPORTED_FROM_ABI const_iterator erase_after(const_iterator __p);
57 _LIBCPP_HIDE_FROM_ABI const_iterator erase_after(const_iterator __p) { return __erase_after(__p); }
4858
49 _LIBCPP_EXPORTED_FROM_ABI tzdb& __emplace_front(tzdb&& __tzdb);
59 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator begin() const noexcept { return __begin(); }
60 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator end() const noexcept { return __end(); }
5061
51 _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator begin() const noexcept;
52 _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator end() const noexcept;
62 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const noexcept { return __cbegin(); }
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const_iterator cend() const noexcept { return __cend(); }
5364
54 _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cbegin() const noexcept;
55 _LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const_iterator cend() const noexcept;
65 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI __impl& __implementation() { return *__impl_; }
5666
5767private:
58 class __impl;
68 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const tzdb& __front() const noexcept;
69
70 _LIBCPP_EXPORTED_FROM_ABI const_iterator __erase_after(const_iterator __p);
71
72 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __begin() const noexcept;
73 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __end() const noexcept;
74
75 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cbegin() const noexcept;
76 [[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const_iterator __cend() const noexcept;
77
5978 __impl* __impl_;
6079};
6180
62_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list();
81[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list();
6382
64_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() {
83[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const tzdb& get_tzdb() {
6584 return get_tzdb_list().front();
6685}
6786
87[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const time_zone* locate_zone(string_view __name) {
88 return get_tzdb().locate_zone(__name);
89}
90
91[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI inline const time_zone* current_zone() {
92 return get_tzdb().current_zone();
93}
94
6895_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb();
6996
70_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version();
97[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version();
7198
7299} // namespace chrono
73100
......@@ -76,6 +103,6 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string
76103
77104_LIBCPP_END_NAMESPACE_STD
78105
79#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_TZDB)
106#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
80107
81108#endif // _LIBCPP___CHRONO_TZDB_LIST_H
lib/libcxx/include/__chrono/weekday.h+3
......@@ -79,6 +79,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const weekday& __lhs, con
7979 return __lhs.c_encoding() == __rhs.c_encoding();
8080}
8181
82// TODO(LLVM 20): Remove the escape hatch
83# ifdef _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS
8284_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(const weekday& __lhs, const weekday& __rhs) noexcept {
8385 return __lhs.c_encoding() < __rhs.c_encoding();
8486}
......@@ -94,6 +96,7 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(const weekday& __lhs, con
9496_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(const weekday& __lhs, const weekday& __rhs) noexcept {
9597 return !(__lhs < __rhs);
9698}
99# endif // _LIBCPP_ENABLE_REMOVED_WEEKDAY_RELATIONAL_OPERATORS
97100
98101_LIBCPP_HIDE_FROM_ABI inline constexpr weekday operator+(const weekday& __lhs, const days& __rhs) noexcept {
99102 auto const __mu = static_cast<long long>(__lhs.c_encoding()) + __rhs.count();
lib/libcxx/include/__chrono/year_month_day.h+5-27
......@@ -239,33 +239,11 @@ operator==(const year_month_day_last& __lhs, const year_month_day_last& __rhs) n
239239 return __lhs.year() == __rhs.year() && __lhs.month_day_last() == __rhs.month_day_last();
240240}
241241
242_LIBCPP_HIDE_FROM_ABI inline constexpr bool
243operator!=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
244 return !(__lhs == __rhs);
245}
246
247_LIBCPP_HIDE_FROM_ABI inline constexpr bool
248operator<(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
249 if (__lhs.year() < __rhs.year())
250 return true;
251 if (__lhs.year() > __rhs.year())
252 return false;
253 return __lhs.month_day_last() < __rhs.month_day_last();
254}
255
256_LIBCPP_HIDE_FROM_ABI inline constexpr bool
257operator>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
258 return __rhs < __lhs;
259}
260
261_LIBCPP_HIDE_FROM_ABI inline constexpr bool
262operator<=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
263 return !(__rhs < __lhs);
264}
265
266_LIBCPP_HIDE_FROM_ABI inline constexpr bool
267operator>=(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
268 return !(__lhs < __rhs);
242_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering
243operator<=>(const year_month_day_last& __lhs, const year_month_day_last& __rhs) noexcept {
244 if (auto __c = __lhs.year() <=> __rhs.year(); __c != 0)
245 return __c;
246 return __lhs.month_day_last() <=> __rhs.month_day_last();
269247}
270248
271249_LIBCPP_HIDE_FROM_ABI inline constexpr year_month_day_last operator/(const year_month& __lhs, last_spec) noexcept {
lib/libcxx/include/__chrono/zoned_time.h created+227
......@@ -0,0 +1,227 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP___CHRONO_ZONED_TIME_H
13#define _LIBCPP___CHRONO_ZONED_TIME_H
14
15#include <version>
16// Enable the contents of the header only when libc++ was built with experimental features enabled.
17#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
18
19# include <__chrono/calendar.h>
20# include <__chrono/duration.h>
21# include <__chrono/sys_info.h>
22# include <__chrono/system_clock.h>
23# include <__chrono/time_zone.h>
24# include <__chrono/tzdb_list.h>
25# include <__config>
26# include <__fwd/string_view.h>
27# include <__type_traits/common_type.h>
28# include <__type_traits/conditional.h>
29# include <__type_traits/remove_cvref.h>
30# include <__utility/move.h>
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 >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
42 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
43
44namespace chrono {
45
46template <class>
47struct zoned_traits {};
48
49template <>
50struct zoned_traits<const time_zone*> {
51 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* default_zone() { return chrono::locate_zone("UTC"); }
52 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static const time_zone* locate_zone(string_view __name) {
53 return chrono::locate_zone(__name);
54 }
55};
56
57template <class _Duration, class _TimeZonePtr = const time_zone*>
58class zoned_time {
59 // [time.zone.zonedtime.ctor]/2
60 static_assert(__is_duration<_Duration>::value,
61 "the program is ill-formed since _Duration is not a specialization of std::chrono::duration");
62
63 // The wording uses the constraints like
64 // constructible_from<zoned_time, decltype(__traits::locate_zone(string_view{}))>
65 // Using these constraints in the code causes the compiler to give an
66 // error that the constraint depends on itself. To avoid that issue use
67 // the fact it is possible to create this object from a _TimeZonePtr.
68 using __traits = zoned_traits<_TimeZonePtr>;
69
70public:
71 using duration = common_type_t<_Duration, seconds>;
72
73 _LIBCPP_HIDE_FROM_ABI zoned_time()
74 requires requires { __traits::default_zone(); }
75 : __zone_{__traits::default_zone()}, __tp_{} {}
76
77 _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time&) = default;
78 _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const zoned_time&) = default;
79
80 _LIBCPP_HIDE_FROM_ABI zoned_time(const sys_time<_Duration>& __tp)
81 requires requires { __traits::default_zone(); }
82 : __zone_{__traits::default_zone()}, __tp_{__tp} {}
83
84 _LIBCPP_HIDE_FROM_ABI explicit zoned_time(_TimeZonePtr __zone) : __zone_{std::move(__zone)}, __tp_{} {}
85
86 _LIBCPP_HIDE_FROM_ABI explicit zoned_time(string_view __name)
87 requires(requires { __traits::locate_zone(string_view{}); } &&
88 constructible_from<_TimeZonePtr, decltype(__traits::locate_zone(string_view{}))>)
89 : __zone_{__traits::locate_zone(__name)}, __tp_{} {}
90
91 template <class _Duration2>
92 _LIBCPP_HIDE_FROM_ABI zoned_time(const zoned_time<_Duration2, _TimeZonePtr>& __zt)
93 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
94 : __zone_{__zt.get_time_zone()}, __tp_{__zt.get_sys_time()} {}
95
96 _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const sys_time<_Duration>& __tp)
97 : __zone_{std::move(__zone)}, __tp_{__tp} {}
98
99 _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const sys_time<_Duration>& __tp)
100 requires requires { _TimeZonePtr{__traits::locate_zone(string_view{})}; }
101 : zoned_time{__traits::locate_zone(__name), __tp} {}
102
103 _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp)
104 requires(is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})),
105 sys_time<duration>>)
106 : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp)} {}
107
108 _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp)
109 requires(requires {
110 _TimeZonePtr{__traits::locate_zone(string_view{})};
111 } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{})),
112 sys_time<duration>>)
113 : zoned_time{__traits::locate_zone(__name), __tp} {}
114
115 _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const local_time<_Duration>& __tp, choose __c)
116 requires(is_convertible_v<
117 decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)),
118 sys_time<duration>>)
119 : __zone_{std::move(__zone)}, __tp_{__zone_->to_sys(__tp, __c)} {}
120
121 _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const local_time<_Duration>& __tp, choose __c)
122 requires(requires {
123 _TimeZonePtr{__traits::locate_zone(string_view{})};
124 } && is_convertible_v<decltype(std::declval<_TimeZonePtr&>() -> to_sys(local_time<_Duration>{}, choose::earliest)),
125 sys_time<duration>>)
126 : zoned_time{__traits::locate_zone(__name), __tp, __c} {}
127
128 template <class _Duration2, class _TimeZonePtr2>
129 _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt)
130 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
131 : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {}
132
133 // per wording choose has no effect
134 template <class _Duration2, class _TimeZonePtr2>
135 _LIBCPP_HIDE_FROM_ABI zoned_time(_TimeZonePtr __zone, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose)
136 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
137 : __zone_{std::move(__zone)}, __tp_{__zt.get_sys_time()} {}
138
139 template <class _Duration2, class _TimeZonePtr2>
140 _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt)
141 requires(requires {
142 _TimeZonePtr{__traits::locate_zone(string_view{})};
143 } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>)
144 : zoned_time{__traits::locate_zone(__name), __zt} {}
145
146 template <class _Duration2, class _TimeZonePtr2>
147 _LIBCPP_HIDE_FROM_ABI zoned_time(string_view __name, const zoned_time<_Duration2, _TimeZonePtr2>& __zt, choose __c)
148 requires(requires {
149 _TimeZonePtr{__traits::locate_zone(string_view{})};
150 } && is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>)
151 : zoned_time{__traits::locate_zone(__name), __zt, __c} {}
152
153 _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const sys_time<_Duration>& __tp) {
154 __tp_ = __tp;
155 return *this;
156 }
157
158 _LIBCPP_HIDE_FROM_ABI zoned_time& operator=(const local_time<_Duration>& __tp) {
159 // TODO TZDB This seems wrong.
160 // Assigning a non-existent or ambiguous time will throw and not satisfy
161 // the post condition. This seems quite odd; I constructed an object with
162 // choose::earliest and that choice is not respected.
163 // what did LEWG do with this.
164 // MSVC STL and libstdc++ behave the same
165 __tp_ = __zone_->to_sys(__tp);
166 return *this;
167 }
168
169 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI operator sys_time<duration>() const { return get_sys_time(); }
170 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit operator local_time<duration>() const { return get_local_time(); }
171
172 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _TimeZonePtr get_time_zone() const { return __zone_; }
173 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI local_time<duration> get_local_time() const { return __zone_->to_local(__tp_); }
174 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_time<duration> get_sys_time() const { return __tp_; }
175 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI sys_info get_info() const { return __zone_->get_info(__tp_); }
176
177private:
178 _TimeZonePtr __zone_;
179 sys_time<duration> __tp_;
180};
181
182zoned_time() -> zoned_time<seconds>;
183
184template <class _Duration>
185zoned_time(sys_time<_Duration>) -> zoned_time<common_type_t<_Duration, seconds>>;
186
187template <class _TimeZonePtrOrName>
188using __time_zone_representation =
189 conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>,
190 const time_zone*,
191 remove_cvref_t<_TimeZonePtrOrName>>;
192
193template <class _TimeZonePtrOrName>
194zoned_time(_TimeZonePtrOrName&&) -> zoned_time<seconds, __time_zone_representation<_TimeZonePtrOrName>>;
195
196template <class _TimeZonePtrOrName, class _Duration>
197zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>)
198 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
199
200template <class _TimeZonePtrOrName, class _Duration>
201zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>, choose = choose::earliest)
202 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
203
204template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2>
205zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest)
206 -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
207
208using zoned_seconds = zoned_time<seconds>;
209
210template <class _Duration1, class _Duration2, class _TimeZonePtr>
211_LIBCPP_HIDE_FROM_ABI bool
212operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
213 return __lhs.get_time_zone() == __rhs.get_time_zone() && __lhs.get_sys_time() == __rhs.get_sys_time();
214}
215
216} // namespace chrono
217
218# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
219 // && !defined(_LIBCPP_HAS_NO_LOCALIZATION)
220
221_LIBCPP_END_NAMESPACE_STD
222
223_LIBCPP_POP_MACROS
224
225#endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
226
227#endif // _LIBCPP___CHRONO_ZONED_TIME_H
lib/libcxx/include/__compare/partial_order.h+2
......@@ -28,6 +28,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828
2929// [cmp.alg]
3030namespace __partial_order {
31void partial_order() = delete;
32
3133struct __fn {
3234 // NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
3335 template <class _Tp, class _Up>
lib/libcxx/include/__compare/strong_order.h+15-10
......@@ -13,11 +13,14 @@
1313#include <__compare/compare_three_way.h>
1414#include <__compare/ordering.h>
1515#include <__config>
16#include <__math/exponential_functions.h>
17#include <__math/traits.h>
1618#include <__type_traits/conditional.h>
1719#include <__type_traits/decay.h>
20#include <__type_traits/is_floating_point.h>
21#include <__type_traits/is_same.h>
1822#include <__utility/forward.h>
1923#include <__utility/priority_tag.h>
20#include <cmath>
2124#include <cstdint>
2225#include <limits>
2326
......@@ -34,6 +37,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3437
3538// [cmp.alg]
3639namespace __strong_order {
40void strong_order() = delete;
41
3742struct __fn {
3843 // NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
3944 template <class _Tp, class _Up>
......@@ -66,27 +71,27 @@ struct __fn {
6671 return strong_ordering::greater;
6772 } else if (__t == __u) {
6873 if constexpr (numeric_limits<_Dp>::radix == 2) {
69 return std::signbit(__u) <=> std::signbit(__t);
74 return __math::signbit(__u) <=> __math::signbit(__t);
7075 } else {
7176 // This is bullet 3 of the IEEE754 algorithm, relevant
7277 // only for decimal floating-point;
7378 // see https://stackoverflow.com/questions/69068075/
74 if (__t == 0 || std::isinf(__t)) {
75 return std::signbit(__u) <=> std::signbit(__t);
79 if (__t == 0 || __math::isinf(__t)) {
80 return __math::signbit(__u) <=> __math::signbit(__t);
7681 } else {
7782 int __texp, __uexp;
78 (void)std::frexp(__t, &__texp);
79 (void)std::frexp(__u, &__uexp);
83 (void)__math::frexp(__t, &__texp);
84 (void)__math::frexp(__u, &__uexp);
8085 return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp);
8186 }
8287 }
8388 } else {
8489 // They're unordered, so one of them must be a NAN.
8590 // The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN.
86 bool __t_is_nan = std::isnan(__t);
87 bool __u_is_nan = std::isnan(__u);
88 bool __t_is_negative = std::signbit(__t);
89 bool __u_is_negative = std::signbit(__u);
91 bool __t_is_nan = __math::isnan(__t);
92 bool __u_is_nan = __math::isnan(__u);
93 bool __t_is_negative = __math::signbit(__t);
94 bool __u_is_negative = __math::signbit(__u);
9095 using _IntType =
9196 conditional_t< sizeof(__t) == sizeof(int32_t),
9297 int32_t,
lib/libcxx/include/__compare/synth_three_way.h+2-7
......@@ -25,12 +25,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2525
2626// [expos.only.func]
2727
28// TODO MODULES restore the lamba to match the Standard.
29// See https://github.com/llvm/llvm-project/issues/57222
30//_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
31// []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
32template <class _Tp, class _Up>
33_LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u)
28_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
3429 requires requires {
3530 { __t < __u } -> __boolean_testable;
3631 { __u < __t } -> __boolean_testable;
......@@ -45,7 +40,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up
4540 return weak_ordering::greater;
4641 return weak_ordering::equivalent;
4742 }
48}
43};
4944
5045template <class _Tp, class _Up = _Tp>
5146using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
lib/libcxx/include/__compare/weak_order.h+9-5
......@@ -13,10 +13,12 @@
1313#include <__compare/ordering.h>
1414#include <__compare/strong_order.h>
1515#include <__config>
16#include <__math/traits.h>
1617#include <__type_traits/decay.h>
18#include <__type_traits/is_floating_point.h>
19#include <__type_traits/is_same.h>
1720#include <__utility/forward.h>
1821#include <__utility/priority_tag.h>
19#include <cmath>
2022
2123#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
2224# pragma GCC system_header
......@@ -28,6 +30,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2830
2931// [cmp.alg]
3032namespace __weak_order {
33void weak_order() = delete;
34
3135struct __fn {
3236 // NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
3337 template <class _Tp, class _Up>
......@@ -51,10 +55,10 @@ struct __fn {
5155 return weak_ordering::greater;
5256 } else {
5357 // Otherwise, at least one of them is a NaN.
54 bool __t_is_nan = std::isnan(__t);
55 bool __u_is_nan = std::isnan(__u);
56 bool __t_is_negative = std::signbit(__t);
57 bool __u_is_negative = std::signbit(__u);
58 bool __t_is_nan = __math::isnan(__t);
59 bool __u_is_nan = __math::isnan(__u);
60 bool __t_is_negative = __math::signbit(__t);
61 bool __u_is_negative = __math::signbit(__u);
5862 if (__t_is_nan && __u_is_nan) {
5963 return (__u_is_negative <=> __t_is_negative);
6064 } else if (__t_is_nan) {
lib/libcxx/include/__concepts/class_or_enum.h-5
......@@ -28,11 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2828template <class _Tp>
2929concept __class_or_enum = is_class_v<_Tp> || is_union_v<_Tp> || is_enum_v<_Tp>;
3030
31// Work around Clang bug https://llvm.org/PR52970
32// TODO: remove this workaround once libc++ no longer has to support Clang 13 (it was fixed in Clang 14).
33template <class _Tp>
34concept __workaround_52970 = is_class_v<__remove_cvref_t<_Tp>> || is_union_v<__remove_cvref_t<_Tp>>;
35
3631#endif // _LIBCPP_STD_VER >= 20
3732
3833_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__concepts/swappable.h+2-2
......@@ -15,8 +15,8 @@
1515#include <__concepts/constructible.h>
1616#include <__config>
1717#include <__type_traits/extent.h>
18#include <__type_traits/is_nothrow_move_assignable.h>
19#include <__type_traits/is_nothrow_move_constructible.h>
18#include <__type_traits/is_nothrow_assignable.h>
19#include <__type_traits/is_nothrow_constructible.h>
2020#include <__type_traits/remove_cvref.h>
2121#include <__utility/exchange.h>
2222#include <__utility/forward.h>
lib/libcxx/include/__condition_variable/condition_variable.h+2-1
......@@ -9,6 +9,7 @@
99#ifndef _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H
1010#define _LIBCPP___CONDITION_VARIABLE_CONDITION_VARIABLE_H
1111
12#include <__chrono/duration.h>
1213#include <__chrono/steady_clock.h>
1314#include <__chrono/system_clock.h>
1415#include <__chrono/time_point.h>
......@@ -16,7 +17,7 @@
1617#include <__mutex/mutex.h>
1718#include <__mutex/unique_lock.h>
1819#include <__system_error/system_error.h>
19#include <__threading_support>
20#include <__thread/support.h>
2021#include <__type_traits/enable_if.h>
2122#include <__type_traits/is_floating_point.h>
2223#include <__utility/move.h>
lib/libcxx/include/__config+117-454
......@@ -11,58 +11,23 @@
1111#define _LIBCPP___CONFIG
1212
1313/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14#include <__configuration/abi.h>
15#include <__configuration/availability.h>
16#include <__configuration/compiler.h>
17#include <__configuration/platform.h>
1418
1519#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
1620# pragma GCC system_header
1721#endif
1822
19#if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
20# pragma clang deprecated( \
21 _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES, \
22 "_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
23#endif
24#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
25# pragma clang deprecated( \
26 _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES, \
27 "_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES is deprecated in LLVM 18 and will be removed in LLVM 19")
28#endif
29
30#if defined(__apple_build_version__)
31// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
32# define _LIBCPP_COMPILER_CLANG_BASED
33# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
34#elif defined(__clang__)
35# define _LIBCPP_COMPILER_CLANG_BASED
36# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
37#elif defined(__GNUC__)
38# define _LIBCPP_COMPILER_GCC
39# define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
40#endif
41
4223#ifdef __cplusplus
4324
44// Warn if a compiler version is used that is not supported anymore
45// LLVM RELEASE Update the minimum compiler versions
46# if defined(_LIBCPP_CLANG_VER)
47# if _LIBCPP_CLANG_VER < 1600
48# warning "Libc++ only supports Clang 16 and later"
49# endif
50# elif defined(_LIBCPP_APPLE_CLANG_VER)
51# if _LIBCPP_APPLE_CLANG_VER < 1500
52# warning "Libc++ only supports AppleClang 15 and later"
53# endif
54# elif defined(_LIBCPP_GCC_VER)
55# if _LIBCPP_GCC_VER < 1300
56# warning "Libc++ only supports GCC 13 and later"
57# endif
58# endif
59
6025// The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
6126
6227// _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.
6328// Given a LLVM release LLVM XX.YY.ZZ (e.g. LLVM 17.0.1 == 17.00.01), _LIBCPP_VERSION is
6429// defined to XXYYZZ.
65# define _LIBCPP_VERSION 180100
30# define _LIBCPP_VERSION 190100
6631
6732# define _LIBCPP_CONCAT_IMPL(_X, _Y) _X##_Y
6833# define _LIBCPP_CONCAT(_X, _Y) _LIBCPP_CONCAT_IMPL(_X, _Y)
......@@ -71,170 +36,12 @@
7136# define _LIBCPP_FREESTANDING
7237# endif
7338
74// NOLINTBEGIN(libcpp-cpp-version-check)
75# ifndef _LIBCPP_STD_VER
76# if __cplusplus <= 201103L
77# define _LIBCPP_STD_VER 11
78# elif __cplusplus <= 201402L
79# define _LIBCPP_STD_VER 14
80# elif __cplusplus <= 201703L
81# define _LIBCPP_STD_VER 17
82# elif __cplusplus <= 202002L
83# define _LIBCPP_STD_VER 20
84# elif __cplusplus <= 202302L
85# define _LIBCPP_STD_VER 23
86# else
87// Expected release year of the next C++ standard
88# define _LIBCPP_STD_VER 26
89# endif
90# endif // _LIBCPP_STD_VER
91// NOLINTEND(libcpp-cpp-version-check)
92
93# if defined(__ELF__)
94# define _LIBCPP_OBJECT_FORMAT_ELF 1
95# elif defined(__MACH__)
96# define _LIBCPP_OBJECT_FORMAT_MACHO 1
97# elif defined(_WIN32)
98# define _LIBCPP_OBJECT_FORMAT_COFF 1
99# elif defined(__wasm__)
100# define _LIBCPP_OBJECT_FORMAT_WASM 1
101# elif defined(_AIX)
102# define _LIBCPP_OBJECT_FORMAT_XCOFF 1
103# else
104// ... add new file formats here ...
105# endif
106
107// ABI {
108
109# if _LIBCPP_ABI_VERSION >= 2
110// Change short string representation so that string data starts at offset 0,
111// improving its alignment in some cases.
112# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
113// Fix deque iterator type in order to support incomplete types.
114# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
115// Fix undefined behavior in how std::list stores its linked nodes.
116# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
117// Fix undefined behavior in how __tree stores its end and parent nodes.
118# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
119// Fix undefined behavior in how __hash_table stores its pointer types.
120# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
121# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
122# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
123// Define a key function for `bad_function_call` in the library, to centralize
124// its vtable and typeinfo to libc++ rather than having all other libraries
125// using that class define their own copies.
126# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
127// Override the default return value of exception::what() for
128// bad_function_call::what() with a string that is specific to
129// bad_function_call (see http://wg21.link/LWG2233). This is an ABI break
130// because it changes the vtable layout of bad_function_call.
131# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
132// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
133# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
134// Give reverse_iterator<T> one data member of type T, not two.
135// Also, in C++17 and later, don't derive iterator types from std::iterator.
136# define _LIBCPP_ABI_NO_ITERATOR_BASES
137// Use the smallest possible integer type to represent the index of the variant.
138// Previously libc++ used "unsigned int" exclusively.
139# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
140// Unstable attempt to provide a more optimized std::function
141# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
142// All the regex constants must be distinct and nonzero.
143# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
144// Re-worked external template instantiations for std::string with a focus on
145// performance and fast-path inlining.
146# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
147// Enable clang::trivial_abi on std::unique_ptr.
148# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
149// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
150# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
151// std::random_device holds some state when it uses an implementation that gets
152// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
153// implementation to another one on a platform that has already shipped
154// std::random_device, one needs to retain the same object layout to remain ABI
155// compatible. This switch removes these workarounds for platforms that don't care
156// about ABI compatibility.
157# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
158// Don't export the legacy __basic_string_common class and its methods from the built library.
159# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
160// Don't export the legacy __vector_base_common class and its methods from the built library.
161# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
162// According to the Standard, `bitset::operator[] const` returns bool
163# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
164// Fix the implementation of CityHash used for std::hash<fundamental-type>.
165// This is an ABI break because `std::hash` will return a different result,
166// which means that hashing the same object in translation units built against
167// different versions of libc++ can return inconsistent results. This is especially
168// tricky since std::hash is used in the implementation of unordered containers.
169//
170// The incorrect implementation of CityHash has the problem that it drops some
171// bits on the floor.
172# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
173// Remove the base 10 implementation of std::to_chars from the dylib.
174// The implementation moved to the header, but we still export the symbols from
175// the dylib for backwards compatibility.
176# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
177# elif _LIBCPP_ABI_VERSION == 1
178# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
179// Enable compiling copies of now inline methods into the dylib to support
180// applications compiled against older libraries. This is unnecessary with
181// COFF dllexport semantics, since dllexport forces a non-inline definition
182// of inline functions to be emitted anyway. Our own non-inline copy would
183// conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
184// the linker will take issue with the symbols in the shared object if the
185// weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
186// so disable it.
187# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
188# endif
189// Feature macros for disabling pre ABI v1 features. All of these options
190// are deprecated.
191# if defined(__FreeBSD__) && __FreeBSD__ < 14
192# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
193# endif
194// For XCOFF linkers, we have problems if we see a weak hidden version of a symbol
195// in user code (like you get with -fvisibility-inlines-hidden) and then a strong def
196// in the library, so we need to always rely on the library version.
197# if defined(_AIX)
198# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
199# endif
200# endif
201
202# if defined(_LIBCPP_BUILDING_LIBRARY) || _LIBCPP_ABI_VERSION >= 2
203// Define a key function for `bad_function_call` in the library, to centralize
204// its vtable and typeinfo to libc++ rather than having all other libraries
205// using that class define their own copies.
206# define _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
207# endif
208
209// We had some bugs where we use [[no_unique_address]] together with construct_at,
210// which causes UB as the call on construct_at could write to overlapping subobjects
211//
212// https://github.com/llvm/llvm-project/issues/70506
213// https://github.com/llvm/llvm-project/issues/70494
214//
215// To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions.
216// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.
217# define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))
218
219// Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
220// within the bounds of the original container and asserts it on every dereference.
221//
222// ABI impact: changes the iterator type of the relevant containers.
223//
224// Supported containers:
225// - `span`;
226// - `string_view`;
227// - `array`.
228// #define _LIBCPP_ABI_BOUNDED_ITERATORS
229
230// } ABI
231
23239// HARDENING {
23340
234// TODO(hardening): deprecate this in LLVM 19.
23541// This is for backward compatibility -- make enabling `_LIBCPP_ENABLE_ASSERTIONS` (which predates hardening modes)
236// equivalent to setting the extensive mode.
42// equivalent to setting the extensive mode. This is deprecated and will be removed in LLVM 20.
23743# ifdef _LIBCPP_ENABLE_ASSERTIONS
44# warning "_LIBCPP_ENABLE_ASSERTIONS is deprecated, please use _LIBCPP_HARDENING_MODE instead"
23845# if _LIBCPP_ENABLE_ASSERTIONS != 0 && _LIBCPP_ENABLE_ASSERTIONS != 1
23946# error "_LIBCPP_ENABLE_ASSERTIONS must be set to 0 or 1"
24047# endif
......@@ -325,6 +132,12 @@
325132// clang-format on
326133
327134# ifndef _LIBCPP_HARDENING_MODE
135
136# ifndef _LIBCPP_HARDENING_MODE_DEFAULT
137# error _LIBCPP_HARDENING_MODE_DEFAULT is not defined. This definition should be set at configuration time in the \
138`__config_site` header, please make sure your installation of libc++ is not broken.
139# endif
140
328141# define _LIBCPP_HARDENING_MODE _LIBCPP_HARDENING_MODE_DEFAULT
329142# endif
330143
......@@ -339,87 +152,6 @@ _LIBCPP_HARDENING_MODE_EXTENSIVE, \
339152_LIBCPP_HARDENING_MODE_DEBUG
340153# endif
341154
342// clang-format off
343// Fast hardening mode checks.
344
345# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
346
347// Enabled checks.
348# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
349# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
350// Disabled checks.
351// On most modern platforms, dereferencing a null pointer does not lead to an actual memory access.
352# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)
353// Overlapping ranges will make algorithms produce incorrect results but don't directly lead to a security
354// vulnerability.
355# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
356# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)
357# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)
358# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
359# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)
360# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)
361# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
362# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
363# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
364
365// Extensive hardening mode checks.
366
367# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
368
369// Enabled checks.
370# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
371# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
372# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message)
373# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
374# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message)
375# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message)
376# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
377# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message)
378# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)
379# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
380// Disabled checks.
381# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
382# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
383
384// Debug hardening mode checks.
385
386# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_DEBUG
387
388// All checks enabled.
389# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSERT(expression, message)
390# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSERT(expression, message)
391# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSERT(expression, message)
392# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSERT(expression, message)
393# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSERT(expression, message)
394# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSERT(expression, message)
395# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSERT(expression, message)
396# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSERT(expression, message)
397# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSERT(expression, message)
398# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSERT(expression, message)
399# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSERT(expression, message)
400# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSERT(expression, message)
401
402// Disable all checks if hardening is not enabled.
403
404# else
405
406// All checks disabled.
407# define _LIBCPP_ASSERT_VALID_INPUT_RANGE(expression, message) _LIBCPP_ASSUME(expression)
408# define _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(expression, message) _LIBCPP_ASSUME(expression)
409# define _LIBCPP_ASSERT_NON_NULL(expression, message) _LIBCPP_ASSUME(expression)
410# define _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(expression, message) _LIBCPP_ASSUME(expression)
411# define _LIBCPP_ASSERT_VALID_DEALLOCATION(expression, message) _LIBCPP_ASSUME(expression)
412# define _LIBCPP_ASSERT_VALID_EXTERNAL_API_CALL(expression, message) _LIBCPP_ASSUME(expression)
413# define _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(expression, message) _LIBCPP_ASSUME(expression)
414# define _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(expression, message) _LIBCPP_ASSUME(expression)
415# define _LIBCPP_ASSERT_PEDANTIC(expression, message) _LIBCPP_ASSUME(expression)
416# define _LIBCPP_ASSERT_SEMANTIC_REQUIREMENT(expression, message) _LIBCPP_ASSUME(expression)
417# define _LIBCPP_ASSERT_INTERNAL(expression, message) _LIBCPP_ASSUME(expression)
418# define _LIBCPP_ASSERT_UNCATEGORIZED(expression, message) _LIBCPP_ASSUME(expression)
419
420# endif // _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
421// clang-format on
422
423155// } HARDENING
424156
425157# define _LIBCPP_TOSTRING2(x) #x
......@@ -430,30 +162,15 @@ _LIBCPP_HARDENING_MODE_DEBUG
430162# define _LIBCPP_CXX03_LANG
431163# endif
432164
433# ifndef __has_attribute
434# define __has_attribute(__x) 0
435# endif
436
437# ifndef __has_builtin
438# define __has_builtin(__x) 0
439# endif
440
441# ifndef __has_extension
442# define __has_extension(__x) 0
443# endif
444
445# ifndef __has_feature
446# define __has_feature(__x) 0
447# endif
448
449# ifndef __has_cpp_attribute
450# define __has_cpp_attribute(__x) 0
451# endif
452
453165# ifndef __has_constexpr_builtin
454166# define __has_constexpr_builtin(x) 0
455167# endif
456168
169// This checks wheter a Clang module is built
170# ifndef __building_module
171# define __building_module(...) 0
172# endif
173
457174// '__is_identifier' returns '0' if '__x' is a reserved identifier provided by
458175// the compiler and '1' otherwise.
459176# ifndef __is_identifier
......@@ -466,8 +183,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
466183
467184# define __has_keyword(__x) !(__is_identifier(__x))
468185
469# ifndef __has_include
470# define __has_include(...) 0
186# ifndef __has_warning
187# define __has_warning(...) 0
471188# endif
472189
473190# if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
......@@ -508,35 +225,14 @@ _LIBCPP_HARDENING_MODE_DEBUG
508225# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
509226# define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
510227# define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
511# define _LIBCPP_HAS_NO_INCOMPLETE_TZDB
228# define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB
512229# define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
513230# endif
514231
515// Need to detect which libc we're using if we're on Linux.
516# if defined(__linux__)
517# include <features.h>
518# if defined(__GLIBC_PREREQ)
519# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
520# else
521# define _LIBCPP_GLIBC_PREREQ(a, b) 0
522# endif // defined(__GLIBC_PREREQ)
523# endif // defined(__linux__)
524
525232# if defined(__MVS__)
526233# include <features.h> // for __NATIVE_ASCII_F
527234# endif
528235
529# ifndef __BYTE_ORDER__
530# error \
531 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
532# endif
533
534# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
535# define _LIBCPP_LITTLE_ENDIAN
536# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
537# define _LIBCPP_BIG_ENDIAN
538# endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
539
540236# if defined(_WIN32)
541237# define _LIBCPP_WIN32API
542238# define _LIBCPP_SHORT_WCHAR 1
......@@ -618,7 +314,7 @@ _LIBCPP_HARDENING_MODE_DEBUG
618314# define _ALIGNAS(x) alignas(x)
619315# define _LIBCPP_NORETURN [[noreturn]]
620316# define _NOEXCEPT noexcept
621# define _NOEXCEPT_(x) noexcept(x)
317# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
622318# define _LIBCPP_CONSTEXPR constexpr
623319
624320# else
......@@ -630,7 +326,7 @@ _LIBCPP_HARDENING_MODE_DEBUG
630326# define _LIBCPP_HAS_NO_NOEXCEPT
631327# define nullptr __nullptr
632328# define _NOEXCEPT throw()
633# define _NOEXCEPT_(x)
329# define _NOEXCEPT_(...)
634330# define static_assert(...) _Static_assert(__VA_ARGS__)
635331# define decltype(...) __decltype(__VA_ARGS__)
636332# define _LIBCPP_CONSTEXPR
......@@ -640,63 +336,32 @@ typedef __char32_t char32_t;
640336
641337# endif
642338
643# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
644# define _LIBCPP_HAS_NO_EXCEPTIONS
645# endif
646
647339# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
648340
649# if defined(_LIBCPP_COMPILER_CLANG_BASED)
650
651# if defined(__APPLE__)
652# if defined(__i386__) || defined(__x86_64__)
653// use old string layout on x86_64 and i386
654# elif defined(__arm__)
655// use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs
656# if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2
657# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
658# endif
659# else
660# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
661# endif
662# endif
663
664341// Objective-C++ features (opt-in)
665# if __has_feature(objc_arc)
666# define _LIBCPP_HAS_OBJC_ARC
667# endif
668
669# if __has_feature(objc_arc_weak)
670# define _LIBCPP_HAS_OBJC_ARC_WEAK
671# endif
672
673# if __has_extension(blocks)
674# define _LIBCPP_HAS_EXTENSION_BLOCKS
675# endif
676
677# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
678# define _LIBCPP_HAS_BLOCKS_RUNTIME
679# endif
680
681# if !__has_feature(address_sanitizer)
682# define _LIBCPP_HAS_NO_ASAN
683# endif
684
685# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
342# if __has_feature(objc_arc)
343# define _LIBCPP_HAS_OBJC_ARC
344# endif
686345
687# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
346# if __has_feature(objc_arc_weak)
347# define _LIBCPP_HAS_OBJC_ARC_WEAK
348# endif
688349
689# elif defined(_LIBCPP_COMPILER_GCC)
350# if __has_extension(blocks)
351# define _LIBCPP_HAS_EXTENSION_BLOCKS
352# endif
690353
691# if !defined(__SANITIZE_ADDRESS__)
692# define _LIBCPP_HAS_NO_ASAN
693# endif
354# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__)
355# define _LIBCPP_HAS_BLOCKS_RUNTIME
356# endif
694357
695# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
358# if !__has_feature(address_sanitizer)
359# define _LIBCPP_HAS_NO_ASAN
360# endif
696361
697# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
362# define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__))
698363
699# endif // _LIBCPP_COMPILER_[CLANG|GCC]
364# define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
700365
701366# if defined(_LIBCPP_OBJECT_FORMAT_COFF)
702367
......@@ -787,6 +452,23 @@ typedef __char32_t char32_t;
787452# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
788453# endif
789454
455# ifdef _LIBCPP_COMPILER_CLANG_BASED
456# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
457# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
458# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
459# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
460# elif defined(_LIBCPP_COMPILER_GCC)
461# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
462# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
463# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
464# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
465# else
466# define _LIBCPP_DIAGNOSTIC_PUSH
467# define _LIBCPP_DIAGNOSTIC_POP
468# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
469# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
470# endif
471
790472# if _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_FAST
791473# define _LIBCPP_HARDENING_SIG f
792474# elif _LIBCPP_HARDENING_MODE == _LIBCPP_HARDENING_MODE_EXTENSIVE
......@@ -848,22 +530,24 @@ typedef __char32_t char32_t;
848530// the implementation of a virtual function in an ABI-incompatible way in the first place,
849531// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
850532//
533// The macro can be applied to record and enum types. When the tagged type is nested in
534// a record this "parent" record needs to have the macro too. Another use case for applying
535// this macro to records and unions is to apply an ABI tag to inline constexpr variables.
536// This can be useful for inline variables that are implementation details which are expected
537// to change in the future.
538//
851539// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
852540// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
853541// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
854542# ifndef _LIBCPP_NO_ABI_TAG
855543# define _LIBCPP_HIDE_FROM_ABI \
856544 _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION \
857 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
545 __attribute__((__abi_tag__(_LIBCPP_TOSTRING(_LIBCPP_ODR_SIGNATURE))))
858546# else
859547# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
860548# endif
861549# define _LIBCPP_HIDE_FROM_ABI_VIRTUAL _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
862550
863// This macro provides a HIDE_FROM_ABI equivalent that can be applied to extern
864// "C" function, as those lack mangling.
865# define _LIBCPP_HIDE_FROM_ABI_C _LIBCPP_HIDDEN _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION
866
867551# ifdef _LIBCPP_BUILDING_LIBRARY
868552# if _LIBCPP_ABI_VERSION > 1
869553# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
......@@ -874,21 +558,51 @@ typedef __char32_t char32_t;
874558# define _LIBCPP_HIDE_FROM_ABI_AFTER_V1 _LIBCPP_HIDE_FROM_ABI
875559# endif
876560
877// TODO(LLVM-19): Remove _LIBCPP_INLINE_VISIBILITY and _VSTD, which we're keeping around
878// only to ease the renaming for downstreams.
879# define _LIBCPP_INLINE_VISIBILITY _LIBCPP_HIDE_FROM_ABI
880# define _VSTD std
561// TODO: Remove this workaround once we drop support for Clang 16
562# if __has_warning("-Wc++23-extensions")
563# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
564# else
565# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++2b-extensions")
566# endif
567
568// Clang modules take a significant compile time hit when pushing and popping diagnostics.
569// Since all the headers are marked as system headers in the modulemap, we can simply disable this
570// pushing and popping when building with clang modules.
571# if !__has_feature(modules)
572# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
573 _LIBCPP_DIAGNOSTIC_PUSH \
574 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++11-extensions") \
575 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
576 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
577 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
578 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED_CXX23_EXTENSION \
579 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++14-extensions") \
580 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++17-extensions") \
581 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions") \
582 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++23-extensions")
583# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS _LIBCPP_DIAGNOSTIC_POP
584# else
585# define _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS
586# define _LIBCPP_POP_EXTENSION_DIAGNOSTICS
587# endif
881588
882589// Inline namespaces are available in Clang/GCC/MSVC regardless of C++ dialect.
883590// clang-format off
884# define _LIBCPP_BEGIN_NAMESPACE_STD namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
591# define _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_PUSH_EXTENSION_DIAGNOSTICS \
592 namespace _LIBCPP_TYPE_VISIBILITY_DEFAULT std { \
885593 inline namespace _LIBCPP_ABI_NAMESPACE {
886# define _LIBCPP_END_NAMESPACE_STD }}
594# define _LIBCPP_END_NAMESPACE_STD }} _LIBCPP_POP_EXTENSION_DIAGNOSTICS
887595
596#ifdef _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
597# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD namespace filesystem {
598# define _LIBCPP_END_NAMESPACE_FILESYSTEM } _LIBCPP_END_NAMESPACE_STD
599#else
888600# define _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM _LIBCPP_BEGIN_NAMESPACE_STD \
889601 inline namespace __fs { namespace filesystem {
890602
891# define _LIBCPP_END_NAMESPACE_FILESYSTEM _LIBCPP_END_NAMESPACE_STD }}
603# define _LIBCPP_END_NAMESPACE_FILESYSTEM }} _LIBCPP_END_NAMESPACE_STD
604#endif
605
892606// clang-format on
893607
894608# if __has_attribute(__enable_if__)
......@@ -985,6 +699,14 @@ typedef __char32_t char32_t;
985699# define _LIBCPP_DEPRECATED_(m)
986700# endif
987701
702# if _LIBCPP_STD_VER < 20
703# define _LIBCPP_DEPRECATED_ATOMIC_SYNC \
704 _LIBCPP_DEPRECATED_("The C++20 synchronization library has been deprecated prior to C++20. Please update to " \
705 "using -std=c++20 if you need to use these facilities.")
706# else
707# define _LIBCPP_DEPRECATED_ATOMIC_SYNC /* nothing */
708# endif
709
988710# if !defined(_LIBCPP_CXX03_LANG)
989711# define _LIBCPP_DEPRECATED_IN_CXX11 _LIBCPP_DEPRECATED
990712# else
......@@ -1015,6 +737,12 @@ typedef __char32_t char32_t;
1015737# define _LIBCPP_DEPRECATED_IN_CXX23
1016738# endif
1017739
740# if _LIBCPP_STD_VER >= 26
741# define _LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_DEPRECATED
742# else
743# define _LIBCPP_DEPRECATED_IN_CXX26
744# endif
745
1018746# if !defined(_LIBCPP_HAS_NO_CHAR8_T)
1019747# define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
1020748# else
......@@ -1068,20 +796,6 @@ typedef __char32_t char32_t;
1068796# define _LIBCPP_CONSTEXPR_SINCE_CXX23
1069797# endif
1070798
1071# ifndef _LIBCPP_HAS_NO_ASAN
1072extern "C" _LIBCPP_EXPORTED_FROM_ABI void
1073__sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
1074extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
1075 const void*, const void*, const void*, const void*, const void*, const void*);
1076extern "C" _LIBCPP_EXPORTED_FROM_ABI int
1077__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
1078# endif
1079
1080// Try to find out if RTTI is disabled.
1081# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
1082# define _LIBCPP_HAS_NO_RTTI
1083# endif
1084
1085799# ifndef _LIBCPP_WEAK
1086800# define _LIBCPP_WEAK __attribute__((__weak__))
1087801# endif
......@@ -1193,9 +907,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
1193907# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
1194908# define _LIBCPP_ATOMIC_FLAG_TYPE bool
1195909# endif
1196# ifdef _LIBCPP_FREESTANDING
1197# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
1198# endif
1199910# endif
1200911
1201912# if defined(__FreeBSD__) && defined(__clang__) && __has_attribute(__no_thread_safety_analysis__)
......@@ -1257,23 +968,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
1257968# define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
1258969# endif
1259970
1260# if defined(_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES)
1261# define _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR
1262# define _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS
1263# define _LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE
1264# define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
1265# define _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
1266# endif // _LIBCPP_ENABLE_CXX17_REMOVED_FEATURES
1267
1268# if defined(_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES)
1269# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS
1270# define _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION
1271# define _LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS
1272# define _LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS
1273# define _LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR
1274# define _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS
1275# endif // _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES
1276
1277971// clang-format off
1278972# define _LIBCPP_PUSH_MACROS _Pragma("push_macro(\"min\")") _Pragma("push_macro(\"max\")") _Pragma("push_macro(\"refresh\")") _Pragma("push_macro(\"move\")") _Pragma("push_macro(\"erase\")")
1279973# define _LIBCPP_POP_MACROS _Pragma("pop_macro(\"min\")") _Pragma("pop_macro(\"max\")") _Pragma("pop_macro(\"refresh\")") _Pragma("pop_macro(\"move\")") _Pragma("pop_macro(\"erase\")")
......@@ -1322,23 +1016,6 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
13221016// the ABI inconsistent.
13231017# endif
13241018
1325# ifdef _LIBCPP_COMPILER_CLANG_BASED
1326# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push")
1327# define _LIBCPP_DIAGNOSTIC_POP _Pragma("clang diagnostic pop")
1328# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(clang diagnostic ignored str))
1329# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1330# elif defined(_LIBCPP_COMPILER_GCC)
1331# define _LIBCPP_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push")
1332# define _LIBCPP_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop")
1333# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1334# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(_LIBCPP_TOSTRING(GCC diagnostic ignored str))
1335# else
1336# define _LIBCPP_DIAGNOSTIC_PUSH
1337# define _LIBCPP_DIAGNOSTIC_POP
1338# define _LIBCPP_CLANG_DIAGNOSTIC_IGNORED(str)
1339# define _LIBCPP_GCC_DIAGNOSTIC_IGNORED(str)
1340# endif
1341
13421019// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
13431020// functions is gradually being added to existing C libraries. The conditions
13441021// below check for known C library versions and conditions under which these
......@@ -1447,7 +1124,7 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
14471124# define _LIBCPP_USING_IF_EXISTS
14481125# endif
14491126
1450# if __has_cpp_attribute(nodiscard)
1127# if __has_cpp_attribute(__nodiscard__)
14511128# define _LIBCPP_NODISCARD [[__nodiscard__]]
14521129# else
14531130// We can't use GCC's [[gnu::warn_unused_result]] and
......@@ -1456,27 +1133,13 @@ __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, c
14561133# define _LIBCPP_NODISCARD
14571134# endif
14581135
1459// _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not
1460// specified as such as an extension.
1461# if !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1462# define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD
1463# else
1464# define _LIBCPP_NODISCARD_EXT
1465# endif
1466
1467# if _LIBCPP_STD_VER >= 20 || !defined(_LIBCPP_DISABLE_NODISCARD_EXT)
1468# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
1469# else
1470# define _LIBCPP_NODISCARD_AFTER_CXX17
1471# endif
1472
14731136# if __has_attribute(__no_destroy__)
14741137# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
14751138# else
14761139# define _LIBCPP_NO_DESTROY
14771140# endif
14781141
1479# if __has_attribute(__diagnose_if__) && !defined(_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS)
1142# if __has_attribute(__diagnose_if__)
14801143# define _LIBCPP_DIAGNOSE_WARNING(...) __attribute__((__diagnose_if__(__VA_ARGS__, "warning")))
14811144# else
14821145# define _LIBCPP_DIAGNOSE_WARNING(...)
lib/libcxx/include/__configuration/abi.h created+172
......@@ -0,0 +1,172 @@
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_ABI_H
11#define _LIBCPP___CONFIGURATION_ABI_H
12
13/* zig patch: instead of including __config_site, zig adds -D flags when compiling */
14#include <__configuration/compiler.h>
15#include <__configuration/platform.h>
16
17#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
18# pragma GCC system_header
19#endif
20
21#if _LIBCPP_ABI_VERSION >= 2
22// Change short string representation so that string data starts at offset 0,
23// improving its alignment in some cases.
24# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
25// Fix deque iterator type in order to support incomplete types.
26# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
27// Fix undefined behavior in how std::list stores its linked nodes.
28# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
29// Fix undefined behavior in how __tree stores its end and parent nodes.
30# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
31// Fix undefined behavior in how __hash_table stores its pointer types.
32# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
33# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
34# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
35// Override the default return value of exception::what() for bad_function_call::what()
36// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).
37// This is an ABI break on platforms that sign and authenticate vtable function pointers
38// because it changes the mangling of the virtual function located in the vtable, which
39// changes how it gets signed.
40# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
41// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
42# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
43// Give reverse_iterator<T> one data member of type T, not two.
44// Also, in C++17 and later, don't derive iterator types from std::iterator.
45# define _LIBCPP_ABI_NO_ITERATOR_BASES
46// Use the smallest possible integer type to represent the index of the variant.
47// Previously libc++ used "unsigned int" exclusively.
48# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
49// Unstable attempt to provide a more optimized std::function
50# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
51// All the regex constants must be distinct and nonzero.
52# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
53// Re-worked external template instantiations for std::string with a focus on
54// performance and fast-path inlining.
55# define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
56// Enable clang::trivial_abi on std::unique_ptr.
57# define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI
58// Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr
59# define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI
60// std::random_device holds some state when it uses an implementation that gets
61// entropy from a file (see _LIBCPP_USING_DEV_RANDOM). When switching from this
62// implementation to another one on a platform that has already shipped
63// std::random_device, one needs to retain the same object layout to remain ABI
64// compatible. This switch removes these workarounds for platforms that don't care
65// about ABI compatibility.
66# define _LIBCPP_ABI_NO_RANDOM_DEVICE_COMPATIBILITY_LAYOUT
67// Don't export the legacy __basic_string_common class and its methods from the built library.
68# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
69// Don't export the legacy __vector_base_common class and its methods from the built library.
70# define _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
71// According to the Standard, `bitset::operator[] const` returns bool
72# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
73// Fix the implementation of CityHash used for std::hash<fundamental-type>.
74// This is an ABI break because `std::hash` will return a different result,
75// which means that hashing the same object in translation units built against
76// different versions of libc++ can return inconsistent results. This is especially
77// tricky since std::hash is used in the implementation of unordered containers.
78//
79// The incorrect implementation of CityHash has the problem that it drops some
80// bits on the floor.
81# define _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
82// Remove the base 10 implementation of std::to_chars from the dylib.
83// The implementation moved to the header, but we still export the symbols from
84// the dylib for backwards compatibility.
85# define _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
86// Define std::array/std::string_view iterators to be __wrap_iters instead of raw
87// pointers, which prevents people from relying on a non-portable implementation
88// detail. This is especially useful because enabling bounded iterators hardening
89// requires code not to make these assumptions.
90# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
91# define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
92// Dont' add an inline namespace for `std::filesystem`
93# define _LIBCPP_ABI_NO_FILESYSTEM_INLINE_NAMESPACE
94// std::basic_ios uses WEOF to indicate that the fill value is
95// uninitialized. However, on platforms where the size of char_type is
96// equal to or greater than the size of int_type and char_type is unsigned,
97// std::char_traits<char_type>::eq_int_type() cannot distinguish between WEOF
98// and WCHAR_MAX. This ABI setting determines whether we should instead track whether the fill
99// value has been initialized using a separate boolean, which changes the ABI.
100# define _LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE
101// Make a std::pair of trivially copyable types trivially copyable.
102// While this technically doesn't change the layout of pair itself, other types may decide to programatically change
103// their representation based on whether something is trivially copyable.
104# define _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
105#elif _LIBCPP_ABI_VERSION == 1
106# if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF))
107// Enable compiling copies of now inline methods into the dylib to support
108// applications compiled against older libraries. This is unnecessary with
109// COFF dllexport semantics, since dllexport forces a non-inline definition
110// of inline functions to be emitted anyway. Our own non-inline copy would
111// conflict with the dllexport-emitted copy, so we disable it. For XCOFF,
112// the linker will take issue with the symbols in the shared object if the
113// weak inline methods get visibility (such as from -fvisibility-inlines-hidden),
114// so disable it.
115# define _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
116# endif
117// Feature macros for disabling pre ABI v1 features. All of these options
118// are deprecated.
119# if defined(__FreeBSD__) && __FreeBSD__ < 14
120# define _LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR
121# endif
122#endif
123
124// We had some bugs where we use [[no_unique_address]] together with construct_at,
125// which causes UB as the call on construct_at could write to overlapping subobjects
126//
127// https://github.com/llvm/llvm-project/issues/70506
128// https://github.com/llvm/llvm-project/issues/70494
129//
130// To fix the bug we had to change the ABI of some classes to remove [[no_unique_address]] under certain conditions.
131// The macro below is used for all classes whose ABI have changed as part of fixing these bugs.
132#define _LIBCPP_ABI_LLVM18_NO_UNIQUE_ADDRESS __attribute__((__abi_tag__("llvm18_nua")))
133
134// Changes the iterator type of select containers (see below) to a bounded iterator that keeps track of whether it's
135// within the bounds of the original container and asserts it on every dereference.
136//
137// ABI impact: changes the iterator type of the relevant containers.
138//
139// Supported containers:
140// - `span`;
141// - `string_view`.
142// #define _LIBCPP_ABI_BOUNDED_ITERATORS
143
144// Changes the iterator type of `basic_string` to a bounded iterator that keeps track of whether it's within the bounds
145// of the original container and asserts it on every dereference and when performing iterator arithmetics.
146//
147// ABI impact: changes the iterator type of `basic_string` and its specializations, such as `string` and `wstring`.
148// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
149
150// Changes the iterator type of `vector` to a bounded iterator that keeps track of whether it's within the bounds of the
151// original container and asserts it on every dereference and when performing iterator arithmetics. Note: this doesn't
152// yet affect `vector<bool>`.
153//
154// ABI impact: changes the iterator type of `vector` (except `vector<bool>`).
155// #define _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
156
157#if defined(_LIBCPP_COMPILER_CLANG_BASED)
158# if defined(__APPLE__)
159# if defined(__i386__) || defined(__x86_64__)
160// use old string layout on x86_64 and i386
161# elif defined(__arm__)
162// use old string layout on arm (which does not include aarch64/arm64), except on watch ABIs
163# if defined(__ARM_ARCH_7K__) && __ARM_ARCH_7K__ >= 2
164# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
165# endif
166# else
167# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
168# endif
169# endif
170#endif
171
172#endif // _LIBCPP___CONFIGURATION_ABI_H
lib/libcxx/include/__configuration/availability.h created+400
......@@ -0,0 +1,400 @@
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_AVAILABILITY_H
11#define _LIBCPP___CONFIGURATION_AVAILABILITY_H
12
13#include <__configuration/compiler.h>
14#include <__configuration/language.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20// Libc++ is shipped by various vendors. In particular, it is used as a system
21// library on macOS, iOS and other Apple platforms. In order for users to be
22// able to compile a binary that is intended to be deployed to an older version
23// of a platform, Clang provides availability attributes [1]. These attributes
24// can be placed on declarations and are used to describe the life cycle of a
25// symbol in the library.
26//
27// The main goal is to ensure a compile-time error if a symbol that hasn't been
28// introduced in a previously released library is used in a program that targets
29// that previously released library. Normally, this would be a load-time error
30// when one tries to launch the program against the older library.
31//
32// For example, the filesystem library was introduced in the dylib in LLVM 9.
33// On Apple platforms, this corresponds to macOS 10.15. If a user compiles on
34// a macOS 10.15 host but targets macOS 10.13 with their program, the compiler
35// would normally not complain (because the required declarations are in the
36// headers), but the dynamic loader would fail to find the symbols when actually
37// trying to launch the program on macOS 10.13. To turn this into a compile-time
38// issue instead, declarations are annotated with when they were introduced, and
39// the compiler can produce a diagnostic if the program references something that
40// isn't available on the deployment target.
41//
42// This mechanism is general in nature, and any vendor can add their markup to
43// the library (see below). Whenever a new feature is added that requires support
44// in the shared library, two macros are added below to allow marking the feature
45// as unavailable:
46// 1. A macro named `_LIBCPP_AVAILABILITY_HAS_<feature>` which must be defined
47// to `_LIBCPP_INTRODUCED_IN_<version>` for the appropriate LLVM version.
48// 2. A macro named `_LIBCPP_AVAILABILITY_<feature>`, which must be defined to
49// `_LIBCPP_INTRODUCED_IN_<version>_MARKUP` for the appropriate LLVM version.
50//
51// When vendors decide to ship the feature as part of their shared library, they
52// can update the `_LIBCPP_INTRODUCED_IN_<version>` macro (and the markup counterpart)
53// based on the platform version they shipped that version of LLVM in. The library
54// will then use this markup to provide an optimal user experience on these platforms.
55//
56// Furthermore, many features in the standard library have corresponding
57// feature-test macros. The `_LIBCPP_AVAILABILITY_HAS_<feature>` macros
58// are checked by the corresponding feature-test macros generated by
59// generate_feature_test_macro_components.py to ensure that the library
60// doesn't announce a feature as being implemented if it is unavailable on
61// the deployment target.
62//
63// Note that this mechanism is disabled by default in the "upstream" libc++.
64// Availability annotations are only meaningful when shipping libc++ inside
65// a platform (i.e. as a system library), and so vendors that want them should
66// turn those annotations on at CMake configuration time.
67//
68// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability
69
70// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY
71// for a while.
72#if defined(_LIBCPP_DISABLE_AVAILABILITY)
73# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
74# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
75# endif
76#endif
77
78// Availability markup is disabled when building the library, or when a non-Clang
79// compiler is used because only Clang supports the necessary attributes.
80#if defined(_LIBCPP_BUILDING_LIBRARY) || defined(_LIBCXXABI_BUILDING_LIBRARY) || !defined(_LIBCPP_COMPILER_CLANG_BASED)
81# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
82# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
83# endif
84#endif
85
86// When availability annotations are disabled, we take for granted that features introduced
87// in all versions of the library are available.
88#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS)
89
90# define _LIBCPP_INTRODUCED_IN_LLVM_19 1
91# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE /* nothing */
92
93# define _LIBCPP_INTRODUCED_IN_LLVM_18 1
94# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE /* nothing */
95
96# define _LIBCPP_INTRODUCED_IN_LLVM_17 1
97# define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE /* nothing */
98
99# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
100# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE /* nothing */
101
102# define _LIBCPP_INTRODUCED_IN_LLVM_15 1
103# define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE /* nothing */
104
105# define _LIBCPP_INTRODUCED_IN_LLVM_14 1
106# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE /* nothing */
107
108# define _LIBCPP_INTRODUCED_IN_LLVM_13 1
109# define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE /* nothing */
110
111# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
112# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE /* nothing */
113
114# define _LIBCPP_INTRODUCED_IN_LLVM_11 1
115# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE /* nothing */
116
117# define _LIBCPP_INTRODUCED_IN_LLVM_10 1
118# define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE /* nothing */
119
120# define _LIBCPP_INTRODUCED_IN_LLVM_9 1
121# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE /* nothing */
122# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
123# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */
124
125# define _LIBCPP_INTRODUCED_IN_LLVM_8 1
126# define _LIBCPP_INTRODUCED_IN_LLVM_8_ATTRIBUTE /* nothing */
127
128# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
129# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
130
131#elif defined(__APPLE__)
132
133// clang-format off
134
135// LLVM 19
136// TODO: Fill this in
137# define _LIBCPP_INTRODUCED_IN_LLVM_19 0
138# define _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE __attribute__((unavailable))
139
140// LLVM 18
141// TODO: Fill this in
142# define _LIBCPP_INTRODUCED_IN_LLVM_18 0
143# define _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE __attribute__((unavailable))
144
145// LLVM 17
146# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140400) || \
147 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170400) || \
148 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170400) || \
149 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100400)
150# define _LIBCPP_INTRODUCED_IN_LLVM_17 0
151# else
152# define _LIBCPP_INTRODUCED_IN_LLVM_17 1
153# endif
154# define _LIBCPP_INTRODUCED_IN_LLVM_17_ATTRIBUTE \
155 __attribute__((availability(macos, strict, introduced = 14.4))) \
156 __attribute__((availability(ios, strict, introduced = 17.4))) \
157 __attribute__((availability(tvos, strict, introduced = 17.4))) \
158 __attribute__((availability(watchos, strict, introduced = 10.4)))
159
160// LLVM 16
161# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 140000) || \
162 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 170000) || \
163 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 170000) || \
164 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 100000)
165# define _LIBCPP_INTRODUCED_IN_LLVM_16 0
166# else
167# define _LIBCPP_INTRODUCED_IN_LLVM_16 1
168# endif
169# define _LIBCPP_INTRODUCED_IN_LLVM_16_ATTRIBUTE \
170 __attribute__((availability(macos, strict, introduced = 14.0))) \
171 __attribute__((availability(ios, strict, introduced = 17.0))) \
172 __attribute__((availability(tvos, strict, introduced = 17.0))) \
173 __attribute__((availability(watchos, strict, introduced = 10.0)))
174
175// LLVM 15
176# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130400) || \
177 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160500) || \
178 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160500) || \
179 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90500)
180# define _LIBCPP_INTRODUCED_IN_LLVM_15 0
181# else
182# define _LIBCPP_INTRODUCED_IN_LLVM_15 1
183# endif
184# define _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE \
185 __attribute__((availability(macos, strict, introduced = 13.4))) \
186 __attribute__((availability(ios, strict, introduced = 16.5))) \
187 __attribute__((availability(tvos, strict, introduced = 16.5))) \
188 __attribute__((availability(watchos, strict, introduced = 9.5)))
189
190// LLVM 14
191# define _LIBCPP_INTRODUCED_IN_LLVM_14 _LIBCPP_INTRODUCED_IN_LLVM_15
192# define _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
193
194// LLVM 13
195# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 130000) || \
196 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 160000) || \
197 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 160000) || \
198 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 90000)
199# define _LIBCPP_INTRODUCED_IN_LLVM_13 0
200# else
201# define _LIBCPP_INTRODUCED_IN_LLVM_13 1
202# endif
203# define _LIBCPP_INTRODUCED_IN_LLVM_13_ATTRIBUTE \
204 __attribute__((availability(macos, strict, introduced = 13.0))) \
205 __attribute__((availability(ios, strict, introduced = 16.0))) \
206 __attribute__((availability(tvos, strict, introduced = 16.0))) \
207 __attribute__((availability(watchos, strict, introduced = 9.0)))
208
209// LLVM 12
210# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 120300) || \
211 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 150300) || \
212 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 150300) || \
213 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 80300)
214# define _LIBCPP_INTRODUCED_IN_LLVM_12 0
215# else
216# define _LIBCPP_INTRODUCED_IN_LLVM_12 1
217# endif
218# define _LIBCPP_INTRODUCED_IN_LLVM_12_ATTRIBUTE \
219 __attribute__((availability(macos, strict, introduced = 12.3))) \
220 __attribute__((availability(ios, strict, introduced = 15.3))) \
221 __attribute__((availability(tvos, strict, introduced = 15.3))) \
222 __attribute__((availability(watchos, strict, introduced = 8.3)))
223
224// LLVM 11
225# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \
226 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \
227 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \
228 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000)
229# define _LIBCPP_INTRODUCED_IN_LLVM_11 0
230# else
231# define _LIBCPP_INTRODUCED_IN_LLVM_11 1
232# endif
233# define _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE \
234 __attribute__((availability(macos, strict, introduced = 11.0))) \
235 __attribute__((availability(ios, strict, introduced = 14.0))) \
236 __attribute__((availability(tvos, strict, introduced = 14.0))) \
237 __attribute__((availability(watchos, strict, introduced = 7.0)))
238
239// LLVM 10
240# define _LIBCPP_INTRODUCED_IN_LLVM_10 _LIBCPP_INTRODUCED_IN_LLVM_11
241# define _LIBCPP_INTRODUCED_IN_LLVM_10_ATTRIBUTE _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE
242
243// LLVM 9
244# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \
245 (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \
246 (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \
247 (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000)
248# define _LIBCPP_INTRODUCED_IN_LLVM_9 0
249# else
250# define _LIBCPP_INTRODUCED_IN_LLVM_9 1
251# endif
252# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE \
253 __attribute__((availability(macos, strict, introduced = 10.15))) \
254 __attribute__((availability(ios, strict, introduced = 13.0))) \
255 __attribute__((availability(tvos, strict, introduced = 13.0))) \
256 __attribute__((availability(watchos, strict, introduced = 6.0)))
257# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH \
258 _Pragma("clang attribute push(__attribute__((availability(macos,strict,introduced=10.15))), apply_to=any(function,record))") \
259 _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
260 _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
261 _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
262# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP \
263 _Pragma("clang attribute pop") \
264 _Pragma("clang attribute pop") \
265 _Pragma("clang attribute pop") \
266 _Pragma("clang attribute pop")
267
268// LLVM 4
269# if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000
270# define _LIBCPP_INTRODUCED_IN_LLVM_4 0
271# else
272# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
273# endif
274# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0)))
275
276// clang-format on
277
278#else
279
280// ...New vendors can add availability markup here...
281
282# error \
283 "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!"
284
285#endif
286
287// These macros control the availability of std::bad_optional_access and
288// other exception types. These were put in the shared library to prevent
289// code bloat from every user program defining the vtable for these exception
290// types.
291//
292// Note that when exceptions are disabled, the methods that normally throw
293// these exceptions can be used even on older deployment targets, but those
294// methods will abort instead of throwing.
295#define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
296#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
297
298#define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
299#define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
300
301#define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4
302#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
303
304// These macros control the availability of all parts of <filesystem> that
305// depend on something in the dylib.
306#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9
307#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE
308#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH
309#define _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_POP _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP
310
311// This controls the availability of the C++20 synchronization library,
312// which requires shared library support for various operations
313// (see libcxx/src/atomic.cpp). This includes <barier>, <latch>,
314// <semaphore>, and notification functions on std::atomic.
315#define _LIBCPP_AVAILABILITY_HAS_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11
316#define _LIBCPP_AVAILABILITY_SYNC _LIBCPP_INTRODUCED_IN_LLVM_11_ATTRIBUTE
317
318// Enable additional explicit instantiations of iostreams components. This
319// reduces the number of weak definitions generated in programs that use
320// iostreams by providing a single strong definition in the shared library.
321//
322// TODO: Enable additional explicit instantiations on GCC once it supports exclude_from_explicit_instantiation,
323// or once libc++ doesn't use the attribute anymore.
324// TODO: Enable them on Windows once https://llvm.org/PR41018 has been fixed.
325#if !defined(_LIBCPP_COMPILER_GCC) && !defined(_WIN32)
326# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 _LIBCPP_INTRODUCED_IN_LLVM_12
327#else
328# define _LIBCPP_AVAILABILITY_HAS_ADDITIONAL_IOSTREAM_EXPLICIT_INSTANTIATIONS_1 0
329#endif
330
331// This controls the availability of floating-point std::to_chars functions.
332// These overloads were added later than the integer overloads.
333#define _LIBCPP_AVAILABILITY_HAS_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14
334#define _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_14_ATTRIBUTE
335
336// This controls whether the library claims to provide a default verbose
337// termination function, and consequently whether the headers will try
338// to use it when the mechanism isn't overriden at compile-time.
339#define _LIBCPP_AVAILABILITY_HAS_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15
340#define _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_INTRODUCED_IN_LLVM_15_ATTRIBUTE
341
342// This controls the availability of the C++17 std::pmr library,
343// which is implemented in large part in the built library.
344//
345// TODO: Enable std::pmr markup once https://github.com/llvm/llvm-project/issues/40340 has been fixed
346// Until then, it is possible for folks to try to use `std::pmr` when back-deploying to targets that don't support
347// 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
348// use availability annotations until that bug has been fixed.
349#define _LIBCPP_AVAILABILITY_HAS_PMR _LIBCPP_INTRODUCED_IN_LLVM_16
350#define _LIBCPP_AVAILABILITY_PMR
351
352// These macros controls the availability of __cxa_init_primary_exception
353// in the built library, which std::make_exception_ptr might use
354// (see libcxx/include/__exception/exception_ptr.h).
355#define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18
356#define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
357
358// This controls the availability of C++23 <print>, which
359// has a dependency on the built library (it needs access to
360// the underlying buffer types of std::cout, std::cerr, and std::clog.
361#define _LIBCPP_AVAILABILITY_HAS_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18
362#define _LIBCPP_AVAILABILITY_PRINT _LIBCPP_INTRODUCED_IN_LLVM_18_ATTRIBUTE
363
364// This controls the availability of the C++20 time zone database.
365// The parser code is built in the library.
366#define _LIBCPP_AVAILABILITY_HAS_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19
367#define _LIBCPP_AVAILABILITY_TZDB _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
368
369// These macros determine whether we assume that std::bad_function_call and
370// std::bad_expected_access provide a key function in the dylib. This allows
371// centralizing their vtable and typeinfo instead of having all TUs provide
372// a weak definition that then gets deduplicated.
373#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
374#define _LIBCPP_AVAILABILITY_BAD_FUNCTION_CALL_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
375#define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19
376#define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE
377
378// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS.
379// Those are defined in terms of the availability attributes above, and
380// should not be vendor-specific.
381#if defined(_LIBCPP_HAS_NO_EXCEPTIONS)
382# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
383# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
384# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
385#else
386# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
387# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
388# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
389#endif
390
391// Define availability attributes that depend on both
392// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI.
393#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI)
394# undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
395# undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
396# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
397# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
398#endif
399
400#endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H
lib/libcxx/include/__configuration/compiler.h created+51
......@@ -0,0 +1,51 @@
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_COMPILER_H
11#define _LIBCPP___CONFIGURATION_COMPILER_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#if defined(__apple_build_version__)
20// Given AppleClang XX.Y.Z, _LIBCPP_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403)
21# define _LIBCPP_COMPILER_CLANG_BASED
22# define _LIBCPP_APPLE_CLANG_VER (__apple_build_version__ / 10000)
23#elif defined(__clang__)
24# define _LIBCPP_COMPILER_CLANG_BASED
25# define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
26#elif defined(__GNUC__)
27# define _LIBCPP_COMPILER_GCC
28# define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
29#endif
30
31#ifdef __cplusplus
32
33// Warn if a compiler version is used that is not supported anymore
34// LLVM RELEASE Update the minimum compiler versions
35# if defined(_LIBCPP_CLANG_VER)
36# if _LIBCPP_CLANG_VER < 1700
37# warning "Libc++ only supports Clang 17 and later"
38# endif
39# elif defined(_LIBCPP_APPLE_CLANG_VER)
40# if _LIBCPP_APPLE_CLANG_VER < 1500
41# warning "Libc++ only supports AppleClang 15 and later"
42# endif
43# elif defined(_LIBCPP_GCC_VER)
44# if _LIBCPP_GCC_VER < 1400
45# warning "Libc++ only supports GCC 14 and later"
46# endif
47# endif
48
49#endif
50
51#endif // _LIBCPP___CONFIGURATION_COMPILER_H
lib/libcxx/include/__configuration/language.h created+46
......@@ -0,0 +1,46 @@
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_LANGUAGE_H
11#define _LIBCPP___CONFIGURATION_LANGUAGE_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// NOLINTBEGIN(libcpp-cpp-version-check)
20#ifdef __cplusplus
21# if __cplusplus <= 201103L
22# define _LIBCPP_STD_VER 11
23# elif __cplusplus <= 201402L
24# define _LIBCPP_STD_VER 14
25# elif __cplusplus <= 201703L
26# define _LIBCPP_STD_VER 17
27# elif __cplusplus <= 202002L
28# define _LIBCPP_STD_VER 20
29# elif __cplusplus <= 202302L
30# define _LIBCPP_STD_VER 23
31# else
32// Expected release year of the next C++ standard
33# define _LIBCPP_STD_VER 26
34# endif
35#endif // __cplusplus
36// NOLINTEND(libcpp-cpp-version-check)
37
38#if !defined(__cpp_rtti) || __cpp_rtti < 199711L
39# define _LIBCPP_HAS_NO_RTTI
40#endif
41
42#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
43# define _LIBCPP_HAS_NO_EXCEPTIONS
44#endif
45
46#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H
lib/libcxx/include/__configuration/platform.h created+54
......@@ -0,0 +1,54 @@
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_PLATFORM_H
11#define _LIBCPP___CONFIGURATION_PLATFORM_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#if defined(__ELF__)
20# define _LIBCPP_OBJECT_FORMAT_ELF 1
21#elif defined(__MACH__)
22# define _LIBCPP_OBJECT_FORMAT_MACHO 1
23#elif defined(_WIN32)
24# define _LIBCPP_OBJECT_FORMAT_COFF 1
25#elif defined(__wasm__)
26# define _LIBCPP_OBJECT_FORMAT_WASM 1
27#elif defined(_AIX)
28# define _LIBCPP_OBJECT_FORMAT_XCOFF 1
29#else
30// ... add new file formats here ...
31#endif
32
33// Need to detect which libc we're using if we're on Linux.
34#if defined(__linux__)
35# include <features.h>
36# if defined(__GLIBC_PREREQ)
37# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
38# else
39# define _LIBCPP_GLIBC_PREREQ(a, b) 0
40# endif // defined(__GLIBC_PREREQ)
41#endif // defined(__linux__)
42
43#ifndef __BYTE_ORDER__
44# error \
45 "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"
46#endif
47
48#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
49# define _LIBCPP_LITTLE_ENDIAN
50#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
51# define _LIBCPP_BIG_ENDIAN
52#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
53
54#endif // _LIBCPP___CONFIGURATION_PLATFORM_H
lib/libcxx/include/__debug_utils/sanitizers.h created+104
......@@ -0,0 +1,104 @@
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___LIBCXX_DEBUG_UTILS_SANITIZERS_H
10#define _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
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#ifndef _LIBCPP_HAS_NO_ASAN
21
22extern "C" {
23_LIBCPP_EXPORTED_FROM_ABI void
24__sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
25_LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
26 const void*, const void*, const void*, const void*, const void*, const void*);
27_LIBCPP_EXPORTED_FROM_ABI int
28__sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
29}
30
31#endif // _LIBCPP_HAS_NO_ASAN
32
33_LIBCPP_BEGIN_NAMESPACE_STD
34
35// ASan choices
36#ifndef _LIBCPP_HAS_NO_ASAN
37# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1
38#endif
39
40#ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS
41// __asan_annotate_container_with_allocator determines whether containers with custom allocators are annotated. This is
42// a public customization point to disable annotations if the custom allocator assumes that the memory isn't poisoned.
43// See the https://libcxx.llvm.org/UsingLibcxx.html#turning-off-asan-annotation-in-containers for more information.
44template <class _Alloc>
45struct __asan_annotate_container_with_allocator : true_type {};
46#endif
47
48// Annotate a double-ended contiguous range.
49// - [__first_storage, __last_storage) is the allocated memory region,
50// - [__first_old_contained, __last_old_contained) is the previously allowed (unpoisoned) range, and
51// - [__first_new_contained, __last_new_contained) is the new allowed (unpoisoned) range.
52template <class _Allocator>
53_LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
54 const void* __first_storage,
55 const void* __last_storage,
56 const void* __first_old_contained,
57 const void* __last_old_contained,
58 const void* __first_new_contained,
59 const void* __last_new_contained) {
60#ifdef _LIBCPP_HAS_NO_ASAN
61 (void)__first_storage;
62 (void)__last_storage;
63 (void)__first_old_contained;
64 (void)__last_old_contained;
65 (void)__first_new_contained;
66 (void)__last_new_contained;
67#else
68 if (__asan_annotate_container_with_allocator<_Allocator>::value && __first_storage != nullptr)
69 __sanitizer_annotate_double_ended_contiguous_container(
70 __first_storage,
71 __last_storage,
72 __first_old_contained,
73 __last_old_contained,
74 __first_new_contained,
75 __last_new_contained);
76#endif
77}
78
79// Annotate a contiguous range.
80// [__first_storage, __last_storage) is the allocated memory region,
81// __old_last_contained is the previously last allowed (unpoisoned) element, and
82// __new_last_contained is the new last allowed (unpoisoned) element.
83template <class _Allocator>
84_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_container(
85 const void* __first_storage,
86 const void* __last_storage,
87 const void* __old_last_contained,
88 const void* __new_last_contained) {
89#ifdef _LIBCPP_HAS_NO_ASAN
90 (void)__first_storage;
91 (void)__last_storage;
92 (void)__old_last_contained;
93 (void)__new_last_contained;
94#else
95 if (!__libcpp_is_constant_evaluated() && __asan_annotate_container_with_allocator<_Allocator>::value &&
96 __first_storage != nullptr)
97 __sanitizer_annotate_contiguous_container(
98 __first_storage, __last_storage, __old_last_contained, __new_last_contained);
99#endif
100}
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // _LIBCPP___LIBCXX_DEBUG_UTILS_SANITIZERS_H
lib/libcxx/include/__exception/exception_ptr.h+26-8
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1010#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1111
12#include <__availability>
1312#include <__config>
1413#include <__exception/operations.h>
1514#include <__memory/addressof.h>
......@@ -26,6 +25,8 @@
2625
2726#ifndef _LIBCPP_ABI_MICROSOFT
2827
28# if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION
29
2930namespace __cxxabiv1 {
3031
3132extern "C" {
......@@ -36,15 +37,20 @@ struct __cxa_exception;
3637_LIBCPP_OVERRIDABLE_FUNC_VIS __cxa_exception* __cxa_init_primary_exception(
3738 void*,
3839 std::type_info*,
39 void(
40# if defined(_WIN32)
41 __thiscall
42# endif
43 *)(void*)) throw();
40# if defined(_WIN32)
41 void(__thiscall*)(void*)) throw();
42# elif defined(__wasm__)
43 // In Wasm, a destructor returns its argument
44 void* (*)(void*)) throw();
45# else
46 void (*)(void*)) throw();
47# endif
4448}
4549
4650} // namespace __cxxabiv1
4751
52# endif
53
4854#endif
4955
5056namespace std { // purposefully not using versioning namespace
......@@ -60,6 +66,9 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
6066 friend _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep) _NOEXCEPT;
6167
6268public:
69 // exception_ptr is basically a COW string.
70 using __trivially_relocatable = exception_ptr;
71
6372 _LIBCPP_HIDE_FROM_ABI exception_ptr() _NOEXCEPT : __ptr_() {}
6473 _LIBCPP_HIDE_FROM_ABI exception_ptr(nullptr_t) _NOEXCEPT : __ptr_() {}
6574
......@@ -88,9 +97,18 @@ _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT {
8897 using _Ep2 = __decay_t<_Ep>;
8998
9099 void* __ex = __cxxabiv1::__cxa_allocate_exception(sizeof(_Ep));
100# ifdef __wasm__
101 // In Wasm, a destructor returns its argument
102 (void)__cxxabiv1::__cxa_init_primary_exception(
103 __ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) -> void* {
104# else
91105 (void)__cxxabiv1::__cxa_init_primary_exception(__ex, const_cast<std::type_info*>(&typeid(_Ep)), [](void* __p) {
92 std::__destroy_at(static_cast<_Ep2*>(__p));
93 });
106# endif
107 std::__destroy_at(static_cast<_Ep2*>(__p));
108# ifdef __wasm__
109 return __p;
110# endif
111 });
94112
95113 try {
96114 ::new (__ex) _Ep2(__e);
lib/libcxx/include/__exception/nested_exception.h+5-7
......@@ -15,8 +15,8 @@
1515#include <__type_traits/decay.h>
1616#include <__type_traits/is_base_of.h>
1717#include <__type_traits/is_class.h>
18#include <__type_traits/is_constructible.h>
1819#include <__type_traits/is_convertible.h>
19#include <__type_traits/is_copy_constructible.h>
2020#include <__type_traits/is_final.h>
2121#include <__type_traits/is_polymorphic.h>
2222#include <__utility/forward.h>
......@@ -84,17 +84,15 @@ struct __can_dynamic_cast
8484 : _BoolConstant< is_polymorphic<_From>::value &&
8585 (!is_base_of<_To, _From>::value || is_convertible<const _From*, const _To*>::value)> {};
8686
87template <class _Ep>
88inline _LIBCPP_HIDE_FROM_ABI void
89rethrow_if_nested(const _Ep& __e, __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value>* = 0) {
87template <class _Ep, __enable_if_t< __can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>
88inline _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>
96inline _LIBCPP_HIDE_FROM_ABI void
97rethrow_if_nested(const _Ep&, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value>* = 0) {}
94template <class _Ep, __enable_if_t<!__can_dynamic_cast<_Ep, nested_exception>::value, int> = 0>
95inline _LIBCPP_HIDE_FROM_ABI void rethrow_if_nested(const _Ep&) {}
9896
9997} // namespace std
10098
lib/libcxx/include/__exception/operations.h-1
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___EXCEPTION_OPERATIONS_H
1010#define _LIBCPP___EXCEPTION_OPERATIONS_H
1111
12#include <__availability>
1312#include <__config>
1413#include <cstddef>
1514
lib/libcxx/include/__expected/bad_expected_access.h+16-11
......@@ -27,23 +27,28 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2727template <class _Err>
2828class bad_expected_access;
2929
30_LIBCPP_DIAGNOSTIC_PUSH
31# if !_LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION
32_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
33# endif
3034template <>
31class bad_expected_access<void> : public exception {
35class _LIBCPP_EXPORTED_FROM_ABI bad_expected_access<void> : public exception {
3236protected:
33 _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default;
34 _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) = default;
35 _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) = default;
36 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) = default;
37 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) = default;
38 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_expected_access() override = default;
37 _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default;
38 _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) noexcept = default;
39 _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) noexcept = default;
40 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
41 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
42 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_expected_access() override = default;
3943
4044public:
41 // The way this has been designed (by using a class template below) means that we'll already
42 // have a profusion of these vtables in TUs, and the dynamic linker will already have a bunch
43 // of work to do. So it is not worth hiding the <void> specialization in the dylib, given that
44 // it adds deployment target restrictions.
45# if _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION
46 const char* what() const noexcept override;
47# else
4548 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { return "bad access to std::expected"; }
49# endif
4650};
51_LIBCPP_DIAGNOSTIC_POP
4752
4853template <class _Err>
4954class bad_expected_access : public bad_expected_access<void> {
lib/libcxx/include/__expected/expected.h+11-13
......@@ -23,24 +23,15 @@
2323#include <__type_traits/is_assignable.h>
2424#include <__type_traits/is_constructible.h>
2525#include <__type_traits/is_convertible.h>
26#include <__type_traits/is_copy_assignable.h>
27#include <__type_traits/is_copy_constructible.h>
28#include <__type_traits/is_default_constructible.h>
2926#include <__type_traits/is_function.h>
30#include <__type_traits/is_move_assignable.h>
31#include <__type_traits/is_move_constructible.h>
27#include <__type_traits/is_nothrow_assignable.h>
3228#include <__type_traits/is_nothrow_constructible.h>
33#include <__type_traits/is_nothrow_copy_assignable.h>
34#include <__type_traits/is_nothrow_copy_constructible.h>
35#include <__type_traits/is_nothrow_default_constructible.h>
36#include <__type_traits/is_nothrow_move_assignable.h>
37#include <__type_traits/is_nothrow_move_constructible.h>
3829#include <__type_traits/is_reference.h>
3930#include <__type_traits/is_same.h>
4031#include <__type_traits/is_swappable.h>
41#include <__type_traits/is_trivially_copy_constructible.h>
32#include <__type_traits/is_trivially_constructible.h>
4233#include <__type_traits/is_trivially_destructible.h>
43#include <__type_traits/is_trivially_move_constructible.h>
34#include <__type_traits/is_trivially_relocatable.h>
4435#include <__type_traits/is_void.h>
4536#include <__type_traits/lazy.h>
4637#include <__type_traits/negation.h>
......@@ -473,6 +464,11 @@ public:
473464 using error_type = _Err;
474465 using unexpected_type = unexpected<_Err>;
475466
467 using __trivially_relocatable =
468 __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value && __libcpp_is_trivially_relocatable<_Err>::value,
469 expected,
470 void>;
471
476472 template <class _Up>
477473 using rebind = expected<_Up, error_type>;
478474
......@@ -511,7 +507,9 @@ private:
511507 _And< is_constructible<_Tp, _UfQual>,
512508 is_constructible<_Err, _OtherErrQual>,
513509 _If<_Not<is_same<remove_cv_t<_Tp>, bool>>::value,
514 _And< _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
510 _And<
511 _Not<_And<is_same<_Tp, _Up>, is_same<_Err, _OtherErr>>>, // use the copy constructor instead, see #92676
512 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>&>>,
515513 _Not<is_constructible<_Tp, expected<_Up, _OtherErr>>>,
516514 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>&>>,
517515 _Not<is_constructible<_Tp, const expected<_Up, _OtherErr>>>,
lib/libcxx/include/__filesystem/copy_options.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_COPY_OPTIONS_H
1111#define _LIBCPP___FILESYSTEM_COPY_OPTIONS_H
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__filesystem/directory_entry.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1111#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1212
13#include <__availability>
1413#include <__chrono/time_point.h>
1514#include <__compare/ordering.h>
1615#include <__config>
lib/libcxx/include/__filesystem/directory_iterator.h-1
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
1212
1313#include <__assert>
14#include <__availability>
1514#include <__config>
1615#include <__filesystem/directory_entry.h>
1716#include <__filesystem/directory_options.h>
lib/libcxx/include/__filesystem/directory_options.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H
1111#define _LIBCPP___FILESYSTEM_DIRECTORY_OPTIONS_H
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__filesystem/file_status.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_FILE_STATUS_H
1111#define _LIBCPP___FILESYSTEM_FILE_STATUS_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__filesystem/file_type.h>
1615#include <__filesystem/perms.h>
lib/libcxx/include/__filesystem/file_time_type.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
1111#define _LIBCPP___FILESYSTEM_FILE_TIME_TYPE_H
1212
13#include <__availability>
1413#include <__chrono/file_clock.h>
1514#include <__chrono/time_point.h>
1615#include <__config>
lib/libcxx/include/__filesystem/file_type.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_FILE_TYPE_H
1111#define _LIBCPP___FILESYSTEM_FILE_TYPE_H
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__filesystem/filesystem_error.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
1111#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__filesystem/path.h>
1615#include <__memory/shared_ptr.h>
lib/libcxx/include/__filesystem/operations.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H
1111#define _LIBCPP___FILESYSTEM_OPERATIONS_H
1212
13#include <__availability>
1413#include <__chrono/time_point.h>
1514#include <__config>
1615#include <__filesystem/copy_options.h>
lib/libcxx/include/__filesystem/path.h+2-4
......@@ -12,11 +12,9 @@
1212
1313#include <__algorithm/replace.h>
1414#include <__algorithm/replace_copy.h>
15#include <__availability>
1615#include <__config>
17#include <__functional/hash.h>
1816#include <__functional/unary_function.h>
19#include <__fwd/hash.h>
17#include <__fwd/functional.h>
2018#include <__iterator/back_insert_iterator.h>
2119#include <__iterator/iterator_traits.h>
2220#include <__type_traits/decay.h>
......@@ -813,7 +811,7 @@ public:
813811 _LIBCPP_HIDE_FROM_ABI path extension() const { return string_type(__extension()); }
814812
815813 // query
816 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); }
814 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const noexcept { return __pn_.empty(); }
817815
818816 _LIBCPP_HIDE_FROM_ABI bool has_root_name() const { return !__root_name().empty(); }
819817 _LIBCPP_HIDE_FROM_ABI bool has_root_directory() const { return !__root_directory().empty(); }
lib/libcxx/include/__filesystem/path_iterator.h-1
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
1212
1313#include <__assert>
14#include <__availability>
1514#include <__config>
1615#include <__filesystem/path.h>
1716#include <__iterator/iterator_traits.h>
lib/libcxx/include/__filesystem/perm_options.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
1111#define _LIBCPP___FILESYSTEM_PERM_OPTIONS_H
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__filesystem/perms.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_PERMS_H
1111#define _LIBCPP___FILESYSTEM_PERMS_H
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__filesystem/recursive_directory_iterator.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
1111#define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__filesystem/directory_entry.h>
1615#include <__filesystem/directory_options.h>
lib/libcxx/include/__filesystem/space_info.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FILESYSTEM_SPACE_INFO_H
1111#define _LIBCPP___FILESYSTEM_SPACE_INFO_H
1212
13#include <__availability>
1413#include <__config>
1514#include <cstdint>
1615
lib/libcxx/include/__filesystem/u8path.h-1
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___FILESYSTEM_U8PATH_H
1212
1313#include <__algorithm/unwrap_iter.h>
14#include <__availability>
1514#include <__config>
1615#include <__filesystem/path.h>
1716#include <string>
lib/libcxx/include/__format/concepts.h+4-2
......@@ -13,12 +13,14 @@
1313#include <__concepts/same_as.h>
1414#include <__concepts/semiregular.h>
1515#include <__config>
16#include <__format/format_fwd.h>
1716#include <__format/format_parse_context.h>
17#include <__fwd/format.h>
18#include <__fwd/tuple.h>
19#include <__tuple/tuple_size.h>
1820#include <__type_traits/is_specialization.h>
1921#include <__type_traits/remove_const.h>
22#include <__type_traits/remove_reference.h>
2023#include <__utility/pair.h>
21#include <tuple>
2224
2325#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2426# pragma GCC system_header
lib/libcxx/include/__format/container_adaptor.h+2-2
......@@ -18,11 +18,11 @@
1818#include <__format/concepts.h>
1919#include <__format/formatter.h>
2020#include <__format/range_default_formatter.h>
21#include <__fwd/queue.h>
22#include <__fwd/stack.h>
2123#include <__ranges/ref_view.h>
2224#include <__type_traits/is_const.h>
2325#include <__type_traits/maybe_const.h>
24#include <queue>
25#include <stack>
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
lib/libcxx/include/__format/escaped_output_table.h+736-913
......@@ -80,10 +80,9 @@ namespace __escaped_output_table {
8080/// The entries of the characters to escape in format's debug string.
8181///
8282/// Contains the entries for [format.string.escaped]/2.2.1.2.1
83/// CE is a Unicode encoding and C corresponds to either a UCS scalar value
84/// whose Unicode property General_Category has a value in the groups
85/// Separator (Z) or Other (C) or to a UCS scalar value which has the Unicode
86/// property Grapheme_Extend=Yes, as described by table 12 of UAX #44
83/// CE is a Unicode encoding and C corresponds to a UCS scalar value whose
84/// Unicode property General_Category has a value in the groups Separator (Z)
85/// or Other (C), as described by table 12 of UAX #44
8786///
8887/// Separator (Z) consists of General_Category
8988/// - Space_Separator,
......@@ -98,7 +97,6 @@ namespace __escaped_output_table {
9897/// - Unassigned.
9998///
10099/// The data is generated from
101/// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
102100/// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt
103101///
104102/// The table is similar to the table
......@@ -107,926 +105,751 @@ namespace __escaped_output_table {
107105/// table lacks a property, thus having more bits available for the size.
108106///
109107/// The data has 2 values:
110/// - bits [0, 10] The size of the range, allowing 2048 elements.
111/// - bits [11, 31] The lower bound code point of the range. The upper bound of
112/// the range is lower bound + size.
113inline constexpr uint32_t __entries[893] = {
114 0x00000020,
115 0x0003f821,
116 0x00056800,
117 0x0018006f,
118 0x001bc001,
119 0x001c0003,
120 0x001c5800,
121 0x001c6800,
122 0x001d1000,
123 0x00241806,
124 0x00298000,
125 0x002ab801,
126 0x002c5801,
127 0x002c802d,
128 0x002df800,
129 0x002e0801,
130 0x002e2001,
131 0x002e3808,
132 0x002f5803,
133 0x002fa810,
134 0x0030800a,
135 0x0030e000,
136 0x00325814,
137 0x00338000,
138 0x0036b007,
139 0x0036f805,
140 0x00373801,
141 0x00375003,
142 0x00387001,
143 0x00388800,
144 0x0039801c,
145 0x003d300a,
146 0x003d900d,
147 0x003f5808,
148 0x003fd802,
149 0x0040b003,
150 0x0040d808,
151 0x00412802,
152 0x00414806,
153 0x0041f800,
154 0x0042c804,
155 0x0042f800,
156 0x00435804,
157 0x00447810,
158 0x00465038,
159 0x0049d000,
160 0x0049e000,
161 0x004a0807,
162 0x004a6800,
163 0x004a8806,
164 0x004b1001,
165 0x004c0800,
166 0x004c2000,
167 0x004c6801,
168 0x004c8801,
169 0x004d4800,
170 0x004d8800,
171 0x004d9802,
172 0x004dd002,
173 0x004df000,
174 0x004e0805,
175 0x004e4801,
176 0x004e6800,
177 0x004e780c,
178 0x004ef000,
179 0x004f1003,
180 0x004ff004,
181 0x00502000,
182 0x00505803,
183 0x00508801,
184 0x00514800,
185 0x00518800,
186 0x0051a000,
187 0x0051b800,
188 0x0051d003,
189 0x00520817,
190 0x0052e800,
191 0x0052f806,
192 0x00538001,
193 0x0053a800,
194 0x0053b80b,
195 0x00542000,
196 0x00547000,
197 0x00549000,
198 0x00554800,
199 0x00558800,
200 0x0055a000,
201 0x0055d002,
202 0x00560807,
203 0x00565000,
204 0x00566802,
205 0x0056880e,
206 0x00571003,
207 0x00579006,
208 0x0057d007,
209 0x00582000,
210 0x00586801,
211 0x00588801,
212 0x00594800,
213 0x00598800,
214 0x0059a000,
215 0x0059d002,
216 0x0059f001,
217 0x005a0805,
218 0x005a4801,
219 0x005a680e,
220 0x005af000,
221 0x005b1003,
222 0x005bc00a,
223 0x005c2000,
224 0x005c5802,
225 0x005c8800,
226 0x005cb002,
227 0x005cd800,
228 0x005ce800,
229 0x005d0002,
230 0x005d2802,
231 0x005d5802,
232 0x005dd004,
233 0x005e0000,
234 0x005e1802,
235 0x005e4800,
236 0x005e6802,
237 0x005e8814,
238 0x005fd805,
239 0x00602000,
240 0x00606800,
241 0x00608800,
242 0x00614800,
243 0x0061d002,
244 0x0061f002,
245 0x00622812,
246 0x0062d801,
247 0x0062f001,
248 0x00631003,
249 0x00638006,
250 0x00640800,
251 0x00646800,
252 0x00648800,
253 0x00654800,
254 0x0065a000,
255 0x0065d002,
256 0x0065f800,
257 0x00661000,
258 0x00662801,
259 0x00664800,
260 0x00666010,
261 0x0066f800,
262 0x00671003,
263 0x00678000,
264 0x0067a00d,
265 0x00686800,
266 0x00688800,
267 0x0069d801,
268 0x0069f000,
269 0x006a0804,
270 0x006a4800,
271 0x006a6800,
272 0x006a8003,
273 0x006ab800,
274 0x006b1003,
275 0x006c0001,
276 0x006c2000,
277 0x006cb802,
278 0x006d9000,
279 0x006de000,
280 0x006df001,
281 0x006e3808,
282 0x006e9005,
283 0x006ef806,
284 0x006f8001,
285 0x006fa80b,
286 0x00718800,
287 0x0071a00a,
288 0x00723807,
289 0x0072e024,
290 0x00741800,
291 0x00742800,
292 0x00745800,
293 0x00752000,
294 0x00753000,
295 0x00758800,
296 0x0075a008,
297 0x0075f001,
298 0x00762800,
299 0x00763808,
300 0x0076d001,
301 0x0077001f,
302 0x0078c001,
303 0x0079a800,
304 0x0079b800,
305 0x0079c800,
306 0x007a4000,
307 0x007b6811,
308 0x007c0004,
309 0x007c3001,
310 0x007c6830,
311 0x007e3000,
312 0x007e6800,
313 0x007ed824,
314 0x00816803,
315 0x00819005,
316 0x0081c801,
317 0x0081e801,
318 0x0082c001,
319 0x0082f002,
320 0x00838803,
321 0x00841000,
322 0x00842801,
323 0x00846800,
324 0x0084e800,
325 0x00863000,
326 0x00864004,
327 0x00867001,
328 0x00924800,
329 0x00927001,
330 0x0092b800,
331 0x0092c800,
332 0x0092f001,
333 0x00944800,
334 0x00947001,
335 0x00958800,
336 0x0095b001,
337 0x0095f800,
338 0x00960800,
339 0x00963001,
340 0x0096b800,
341 0x00988800,
342 0x0098b001,
343 0x009ad804,
344 0x009be802,
345 0x009cd005,
346 0x009fb001,
347 0x009ff001,
348 0x00b40000,
349 0x00b4e802,
350 0x00b7c806,
351 0x00b89002,
352 0x00b8b008,
353 0x00b99001,
354 0x00b9b808,
355 0x00ba900d,
356 0x00bb6800,
357 0x00bb880e,
358 0x00bda001,
359 0x00bdb806,
360 0x00be3000,
361 0x00be480a,
362 0x00bee802,
363 0x00bf5005,
364 0x00bfd005,
365 0x00c05804,
366 0x00c0d005,
367 0x00c3c806,
368 0x00c42801,
369 0x00c54800,
370 0x00c55804,
371 0x00c7b009,
372 0x00c8f803,
373 0x00c93801,
374 0x00c96003,
375 0x00c99000,
376 0x00c9c806,
377 0x00ca0802,
378 0x00cb7001,
379 0x00cba80a,
380 0x00cd6003,
381 0x00ce5005,
382 0x00ced802,
383 0x00d0b801,
384 0x00d0d802,
385 0x00d2b000,
386 0x00d2c008,
387 0x00d31000,
388 0x00d32807,
389 0x00d3980c,
390 0x00d45005,
391 0x00d4d005,
392 0x00d57055,
393 0x00d9a006,
394 0x00d9e000,
395 0x00da1000,
396 0x00da6802,
397 0x00db5808,
398 0x00dbf802,
399 0x00dd1003,
400 0x00dd4001,
401 0x00dd5802,
402 0x00df3000,
403 0x00df4001,
404 0x00df6800,
405 0x00df7802,
406 0x00dfa007,
407 0x00e16007,
408 0x00e1b004,
409 0x00e25002,
410 0x00e44806,
411 0x00e5d801,
412 0x00e6400a,
413 0x00e6a00c,
414 0x00e71006,
415 0x00e76800,
416 0x00e7a000,
417 0x00e7c001,
418 0x00e7d804,
419 0x00ee003f,
420 0x00f8b001,
421 0x00f8f001,
422 0x00fa3001,
423 0x00fa7001,
424 0x00fac000,
425 0x00fad000,
426 0x00fae000,
427 0x00faf000,
428 0x00fbf001,
429 0x00fda800,
430 0x00fe2800,
431 0x00fea001,
432 0x00fee000,
433 0x00ff8001,
434 0x00ffa800,
435 0x00fff810,
436 0x01014007,
437 0x0102f810,
438 0x01039001,
439 0x01047800,
440 0x0104e802,
441 0x0106083e,
442 0x010c6003,
443 0x01213818,
444 0x01225814,
445 0x015ba001,
446 0x015cb000,
447 0x01677802,
448 0x0167a004,
449 0x01693000,
450 0x01694004,
451 0x01697001,
452 0x016b4006,
453 0x016b880e,
454 0x016cb808,
455 0x016d3800,
456 0x016d7800,
457 0x016db800,
458 0x016df800,
459 0x016e3800,
460 0x016e7800,
461 0x016eb800,
462 0x016ef820,
463 0x0172f021,
464 0x0174d000,
465 0x0177a00b,
466 0x017eb019,
467 0x017fe004,
468 0x01815005,
469 0x01820000,
470 0x0184b803,
471 0x01880004,
472 0x01898000,
473 0x018c7800,
474 0x018f200b,
475 0x0190f800,
476 0x05246802,
477 0x05263808,
478 0x05316013,
479 0x05337803,
480 0x0533a009,
481 0x0534f001,
482 0x05378001,
483 0x0537c007,
484 0x053e5804,
485 0x053e9000,
486 0x053ea000,
487 0x053ed017,
488 0x05401000,
489 0x05403000,
490 0x05405800,
491 0x05412801,
492 0x05416003,
493 0x0541d005,
494 0x0543c007,
495 0x05462009,
496 0x0546d017,
497 0x0547f800,
498 0x05493007,
499 0x054a380a,
500 0x054aa00a,
501 0x054be805,
502 0x054d9800,
503 0x054db003,
504 0x054de001,
505 0x054e7000,
506 0x054ed003,
507 0x054f2800,
508 0x054ff800,
509 0x05514805,
510 0x05518801,
511 0x0551a80a,
512 0x05521800,
513 0x05526000,
514 0x05527001,
515 0x0552d001,
516 0x0553e000,
517 0x05558000,
518 0x05559002,
519 0x0555b801,
520 0x0555f001,
521 0x05560800,
522 0x05561817,
523 0x05576001,
524 0x0557b00a,
525 0x05583801,
526 0x05587801,
527 0x0558b808,
528 0x05593800,
529 0x05597800,
530 0x055b6003,
531 0x055f2800,
532 0x055f4000,
533 0x055f6802,
534 0x055fd005,
535 0x06bd200b,
536 0x06be3803,
537 0x06bfe7ff,
538 0x06ffe7ff,
539 0x073fe7ff,
540 0x077fe7ff,
541 0x07bfe103,
542 0x07d37001,
543 0x07d6d025,
544 0x07d8380b,
545 0x07d8c004,
546 0x07d8f000,
547 0x07d9b800,
548 0x07d9e800,
549 0x07d9f800,
550 0x07da1000,
551 0x07da2800,
552 0x07de180f,
553 0x07ec8001,
554 0x07ee4006,
555 0x07ee801f,
556 0x07f0000f,
557 0x07f0d015,
558 0x07f29800,
559 0x07f33800,
560 0x07f36003,
561 0x07f3a800,
562 0x07f7e803,
563 0x07fcf001,
564 0x07fdf802,
565 0x07fe4001,
566 0x07fe8001,
567 0x07fec001,
568 0x07fee802,
569 0x07ff3800,
570 0x07ff780c,
571 0x07fff001,
572 0x08006000,
573 0x08013800,
574 0x0801d800,
575 0x0801f000,
576 0x08027001,
577 0x0802f021,
578 0x0807d804,
579 0x08081803,
580 0x0809a002,
581 0x080c7800,
582 0x080ce802,
583 0x080d082e,
584 0x080fe882,
585 0x0814e802,
586 0x0816880f,
587 0x0817e003,
588 0x08192008,
589 0x081a5804,
590 0x081bb009,
591 0x081cf000,
592 0x081e2003,
593 0x081eb029,
594 0x0824f001,
595 0x08255005,
596 0x0826a003,
597 0x0827e003,
598 0x08294007,
599 0x082b200a,
600 0x082bd800,
601 0x082c5800,
602 0x082c9800,
603 0x082cb000,
604 0x082d1000,
605 0x082d9000,
606 0x082dd000,
607 0x082de842,
608 0x0839b808,
609 0x083ab009,
610 0x083b4017,
611 0x083c3000,
612 0x083d8800,
613 0x083dd844,
614 0x08403001,
615 0x08404800,
616 0x0841b000,
617 0x0841c802,
618 0x0841e801,
619 0x0842b000,
620 0x0844f807,
621 0x0845802f,
622 0x08479800,
623 0x0847b004,
624 0x0848e002,
625 0x0849d004,
626 0x084a003f,
627 0x084dc003,
628 0x084e8001,
629 0x0850080e,
630 0x0850a000,
631 0x0850c000,
632 0x0851b009,
633 0x08524806,
634 0x0852c806,
635 0x0855001f,
636 0x08572805,
637 0x0857b808,
638 0x0859b002,
639 0x085ab001,
640 0x085b9804,
641 0x085c9006,
642 0x085ce80b,
643 0x085d804f,
644 0x08624836,
645 0x0865980c,
646 0x08679806,
647 0x0869200b,
648 0x0869d125,
649 0x0873f800,
650 0x08755002,
651 0x08757001,
652 0x0875904d,
653 0x08794007,
654 0x087a300a,
655 0x087ad015,
656 0x087c1003,
657 0x087c5025,
658 0x087e6013,
659 0x087fb808,
660 0x08800800,
661 0x0881c00e,
662 0x08827003,
663 0x08838000,
664 0x08839801,
665 0x0883b00b,
666 0x08859803,
667 0x0885c801,
668 0x0885e800,
669 0x0886100d,
670 0x08874806,
671 0x0887d008,
672 0x08893804,
673 0x08896808,
674 0x088a4007,
675 0x088b9800,
676 0x088bb80a,
677 0x088db008,
678 0x088e4803,
679 0x088e7800,
680 0x088f0000,
681 0x088fa80a,
682 0x08909000,
683 0x08917802,
684 0x0891a000,
685 0x0891b001,
686 0x0891f000,
687 0x0892083e,
688 0x08943800,
689 0x08944800,
690 0x08947000,
691 0x0894f000,
692 0x08955005,
693 0x0896f800,
694 0x0897180c,
695 0x0897d007,
696 0x08982000,
697 0x08986801,
698 0x08988801,
699 0x08994800,
700 0x08998800,
701 0x0899a000,
702 0x0899d002,
703 0x0899f000,
704 0x089a0000,
705 0x089a2801,
706 0x089a4801,
707 0x089a7001,
708 0x089a880b,
709 0x089b209b,
710 0x08a1c007,
711 0x08a21002,
712 0x08a23000,
713 0x08a2e000,
714 0x08a2f000,
715 0x08a3101d,
716 0x08a58000,
717 0x08a59805,
718 0x08a5d000,
719 0x08a5e800,
720 0x08a5f801,
721 0x08a61001,
722 0x08a64007,
723 0x08a6d0a5,
724 0x08ad7800,
725 0x08ad9005,
726 0x08ade001,
727 0x08adf801,
728 0x08aee023,
729 0x08b19807,
730 0x08b1e800,
731 0x08b1f801,
732 0x08b2280a,
733 0x08b2d005,
734 0x08b36812,
735 0x08b55800,
736 0x08b56800,
737 0x08b58005,
738 0x08b5b800,
739 0x08b5d005,
740 0x08b65035,
741 0x08b8d804,
742 0x08b91003,
743 0x08b93808,
744 0x08ba38b8,
745 0x08c17808,
746 0x08c1c801,
747 0x08c1e063,
748 0x08c7980b,
749 0x08c83801,
750 0x08c85001,
751 0x08c8a000,
752 0x08c8b800,
753 0x08c98000,
754 0x08c9b000,
755 0x08c9c803,
756 0x08c9f000,
757 0x08ca1800,
758 0x08ca3808,
759 0x08cad045,
760 0x08cd4001,
761 0x08cea007,
762 0x08cf0000,
763 0x08cf281a,
764 0x08d00809,
765 0x08d19805,
766 0x08d1d803,
767 0x08d23808,
768 0x08d28805,
769 0x08d2c802,
770 0x08d4500c,
771 0x08d4c001,
772 0x08d5180c,
773 0x08d7c806,
774 0x08d850f5,
775 0x08e04800,
776 0x08e1800d,
777 0x08e1f800,
778 0x08e23009,
779 0x08e36802,
780 0x08e48018,
781 0x08e55006,
782 0x08e59001,
783 0x08e5a84a,
784 0x08e83800,
785 0x08e85000,
786 0x08e98814,
787 0x08ea3808,
788 0x08ead005,
789 0x08eb3000,
790 0x08eb4800,
791 0x08ec7803,
792 0x08eca800,
793 0x08ecb800,
794 0x08ecc806,
795 0x08ed5135,
796 0x08f79801,
797 0x08f7c808,
798 0x08f88800,
799 0x08f9b007,
800 0x08fa0000,
801 0x08fa1000,
802 0x08fad055,
803 0x08fd880e,
804 0x08ff900c,
805 0x091cd065,
806 0x09237800,
807 0x0923a80a,
808 0x092a27ff,
809 0x096a224b,
810 0x097f980c,
811 0x09a18010,
812 0x09a23fff,
813 0x09e23fb8,
814 0x0a323fff,
815 0x0a723fff,
816 0x0ab23fff,
817 0x0af23fff,
818 0x0b3239b8,
819 0x0b51c806,
820 0x0b52f800,
821 0x0b535003,
822 0x0b55f800,
823 0x0b565005,
824 0x0b577006,
825 0x0b57b009,
826 0x0b598006,
827 0x0b5a3009,
828 0x0b5ad000,
829 0x0b5b1000,
830 0x0b5bc004,
831 0x0b5c82af,
832 0x0b74d864,
833 0x0b7a5804,
834 0x0b7c400a,
835 0x0b7d003f,
836 0x0b7f200b,
837 0x0b7f900d,
838 0x0c3fc007,
839 0x0c66b029,
840 0x0c684fff,
841 0x0ca84fff,
842 0x0ce84fff,
843 0x0d284fff,
844 0x0d684ae6,
845 0x0d7fa000,
846 0x0d7fe000,
847 0x0d7ff800,
848 0x0d89180e,
849 0x0d89981c,
850 0x0d8a9801,
851 0x0d8ab00d,
852 0x0d8b4007,
853 0x0d97e7ff,
854 0x0dd7e103,
855 0x0de35804,
856 0x0de3e802,
857 0x0de44806,
858 0x0de4d001,
859 0x0de4e801,
860 0x0de507ff,
861 0x0e2507ff,
862 0x0e6502af,
863 0x0e7e203b,
864 0x0e87b009,
865 0x0e893801,
866 0x0e8b2800,
867 0x0e8b3802,
868 0x0e8b7014,
869 0x0e8c2806,
870 0x0e8d5003,
871 0x0e8f5814,
872 0x0e921002,
873 0x0e923079,
874 0x0e96a00b,
875 0x0e97a00b,
876 0x0e9ab808,
877 0x0e9bc886,
878 0x0ea2a800,
879 0x0ea4e800,
880 0x0ea50001,
881 0x0ea51801,
882 0x0ea53801,
883 0x0ea56800,
884 0x0ea5d000,
885 0x0ea5e000,
886 0x0ea62000,
887 0x0ea83000,
888 0x0ea85801,
889 0x0ea8a800,
890 0x0ea8e800,
891 0x0ea9d000,
892 0x0ea9f800,
893 0x0eaa2800,
894 0x0eaa3802,
895 0x0eaa8800,
896 0x0eb53001,
897 0x0ebe6001,
898 0x0ed00036,
899 0x0ed1d831,
900 0x0ed3a800,
901 0x0ed42000,
902 0x0ed46473,
903 0x0ef8f805,
904 0x0ef95904,
905 0x0f037091,
906 0x0f096809,
907 0x0f09f001,
908 0x0f0a5003,
909 0x0f0a813f,
910 0x0f157011,
911 0x0f176003,
912 0x0f17d004,
913 0x0f1801cf,
914 0x0f276003,
915 0x0f27d2e5,
916 0x0f3f3800,
917 0x0f3f6000,
918 0x0f3f7800,
919 0x0f3ff800,
920 0x0f462801,
921 0x0f46802f,
922 0x0f4a2006,
923 0x0f4a6003,
924 0x0f4ad003,
925 0x0f4b0310,
926 0x0f65a84b,
927 0x0f69f0c1,
928 0x0f702000,
929 0x0f710000,
930 0x0f711800,
931 0x0f712801,
932 0x0f714000,
933 0x0f719800,
934 0x0f71c000,
935 0x0f71d000,
936 0x0f71e005,
937 0x0f721803,
938 0x0f724000,
939 0x0f725000,
940 0x0f726000,
941 0x0f728000,
942 0x0f729800,
943 0x0f72a801,
944 0x0f72c000,
945 0x0f72d000,
946 0x0f72e000,
947 0x0f72f000,
948 0x0f730000,
949 0x0f731800,
950 0x0f732801,
951 0x0f735800,
952 0x0f739800,
953 0x0f73c000,
954 0x0f73e800,
955 0x0f73f800,
956 0x0f745000,
957 0x0f74e004,
958 0x0f752000,
959 0x0f755000,
960 0x0f75e033,
961 0x0f77910d,
962 0x0f816003,
963 0x0f84a00b,
964 0x0f857801,
965 0x0f860000,
966 0x0f868000,
967 0x0f87b009,
968 0x0f8d7037,
969 0x0f90180c,
970 0x0f91e003,
971 0x0f924806,
972 0x0f92900d,
973 0x0f933099,
974 0x0fb6c003,
975 0x0fb76802,
976 0x0fb7e802,
977 0x0fbbb803,
978 0x0fbed005,
979 0x0fbf6003,
980 0x0fbf880e,
981 0x0fc06003,
982 0x0fc24007,
983 0x0fc2d005,
984 0x0fc44007,
985 0x0fc57001,
986 0x0fc5904d,
987 0x0fd2a00b,
988 0x0fd37001,
989 0x0fd3e802,
990 0x0fd44806,
991 0x0fd5f000,
992 0x0fd63007,
993 0x0fd6e003,
994 0x0fd74806,
995 0x0fd7c806,
996 0x0fdc9800,
997 0x0fde5824,
998 0x0fdfd405,
999 0x1537001f,
1000 0x15b9d005,
1001 0x15c0f001,
1002 0x1675100d,
1003 0x175f0fff,
1004 0x179f0c1e,
1005 0x17d0f5e1,
1006 0x189a5804};
108/// - bits [0, 13] The size of the range, allowing 16384 elements.
109/// - bits [14, 31] The lower bound code point of the range. The upper bound of
110/// the range is lower bound + size. Note the code expects code units the fit
111/// into 18 bits, instead of the 21 bits needed for the full Unicode range.
112_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[711] = {
113 0x00000020 /* 00000000 - 00000020 [ 33] */,
114 0x001fc021 /* 0000007f - 000000a0 [ 34] */,
115 0x002b4000 /* 000000ad - 000000ad [ 1] */,
116 0x00de0001 /* 00000378 - 00000379 [ 2] */,
117 0x00e00003 /* 00000380 - 00000383 [ 4] */,
118 0x00e2c000 /* 0000038b - 0000038b [ 1] */,
119 0x00e34000 /* 0000038d - 0000038d [ 1] */,
120 0x00e88000 /* 000003a2 - 000003a2 [ 1] */,
121 0x014c0000 /* 00000530 - 00000530 [ 1] */,
122 0x0155c001 /* 00000557 - 00000558 [ 2] */,
123 0x0162c001 /* 0000058b - 0000058c [ 2] */,
124 0x01640000 /* 00000590 - 00000590 [ 1] */,
125 0x01720007 /* 000005c8 - 000005cf [ 8] */,
126 0x017ac003 /* 000005eb - 000005ee [ 4] */,
127 0x017d4010 /* 000005f5 - 00000605 [ 17] */,
128 0x01870000 /* 0000061c - 0000061c [ 1] */,
129 0x01b74000 /* 000006dd - 000006dd [ 1] */,
130 0x01c38001 /* 0000070e - 0000070f [ 2] */,
131 0x01d2c001 /* 0000074b - 0000074c [ 2] */,
132 0x01ec800d /* 000007b2 - 000007bf [ 14] */,
133 0x01fec001 /* 000007fb - 000007fc [ 2] */,
134 0x020b8001 /* 0000082e - 0000082f [ 2] */,
135 0x020fc000 /* 0000083f - 0000083f [ 1] */,
136 0x02170001 /* 0000085c - 0000085d [ 2] */,
137 0x0217c000 /* 0000085f - 0000085f [ 1] */,
138 0x021ac004 /* 0000086b - 0000086f [ 5] */,
139 0x0223c008 /* 0000088f - 00000897 [ 9] */,
140 0x02388000 /* 000008e2 - 000008e2 [ 1] */,
141 0x02610000 /* 00000984 - 00000984 [ 1] */,
142 0x02634001 /* 0000098d - 0000098e [ 2] */,
143 0x02644001 /* 00000991 - 00000992 [ 2] */,
144 0x026a4000 /* 000009a9 - 000009a9 [ 1] */,
145 0x026c4000 /* 000009b1 - 000009b1 [ 1] */,
146 0x026cc002 /* 000009b3 - 000009b5 [ 3] */,
147 0x026e8001 /* 000009ba - 000009bb [ 2] */,
148 0x02714001 /* 000009c5 - 000009c6 [ 2] */,
149 0x02724001 /* 000009c9 - 000009ca [ 2] */,
150 0x0273c007 /* 000009cf - 000009d6 [ 8] */,
151 0x02760003 /* 000009d8 - 000009db [ 4] */,
152 0x02778000 /* 000009de - 000009de [ 1] */,
153 0x02790001 /* 000009e4 - 000009e5 [ 2] */,
154 0x027fc001 /* 000009ff - 00000a00 [ 2] */,
155 0x02810000 /* 00000a04 - 00000a04 [ 1] */,
156 0x0282c003 /* 00000a0b - 00000a0e [ 4] */,
157 0x02844001 /* 00000a11 - 00000a12 [ 2] */,
158 0x028a4000 /* 00000a29 - 00000a29 [ 1] */,
159 0x028c4000 /* 00000a31 - 00000a31 [ 1] */,
160 0x028d0000 /* 00000a34 - 00000a34 [ 1] */,
161 0x028dc000 /* 00000a37 - 00000a37 [ 1] */,
162 0x028e8001 /* 00000a3a - 00000a3b [ 2] */,
163 0x028f4000 /* 00000a3d - 00000a3d [ 1] */,
164 0x0290c003 /* 00000a43 - 00000a46 [ 4] */,
165 0x02924001 /* 00000a49 - 00000a4a [ 2] */,
166 0x02938002 /* 00000a4e - 00000a50 [ 3] */,
167 0x02948006 /* 00000a52 - 00000a58 [ 7] */,
168 0x02974000 /* 00000a5d - 00000a5d [ 1] */,
169 0x0297c006 /* 00000a5f - 00000a65 [ 7] */,
170 0x029dc009 /* 00000a77 - 00000a80 [ 10] */,
171 0x02a10000 /* 00000a84 - 00000a84 [ 1] */,
172 0x02a38000 /* 00000a8e - 00000a8e [ 1] */,
173 0x02a48000 /* 00000a92 - 00000a92 [ 1] */,
174 0x02aa4000 /* 00000aa9 - 00000aa9 [ 1] */,
175 0x02ac4000 /* 00000ab1 - 00000ab1 [ 1] */,
176 0x02ad0000 /* 00000ab4 - 00000ab4 [ 1] */,
177 0x02ae8001 /* 00000aba - 00000abb [ 2] */,
178 0x02b18000 /* 00000ac6 - 00000ac6 [ 1] */,
179 0x02b28000 /* 00000aca - 00000aca [ 1] */,
180 0x02b38001 /* 00000ace - 00000acf [ 2] */,
181 0x02b4400e /* 00000ad1 - 00000adf [ 15] */,
182 0x02b90001 /* 00000ae4 - 00000ae5 [ 2] */,
183 0x02bc8006 /* 00000af2 - 00000af8 [ 7] */,
184 0x02c00000 /* 00000b00 - 00000b00 [ 1] */,
185 0x02c10000 /* 00000b04 - 00000b04 [ 1] */,
186 0x02c34001 /* 00000b0d - 00000b0e [ 2] */,
187 0x02c44001 /* 00000b11 - 00000b12 [ 2] */,
188 0x02ca4000 /* 00000b29 - 00000b29 [ 1] */,
189 0x02cc4000 /* 00000b31 - 00000b31 [ 1] */,
190 0x02cd0000 /* 00000b34 - 00000b34 [ 1] */,
191 0x02ce8001 /* 00000b3a - 00000b3b [ 2] */,
192 0x02d14001 /* 00000b45 - 00000b46 [ 2] */,
193 0x02d24001 /* 00000b49 - 00000b4a [ 2] */,
194 0x02d38006 /* 00000b4e - 00000b54 [ 7] */,
195 0x02d60003 /* 00000b58 - 00000b5b [ 4] */,
196 0x02d78000 /* 00000b5e - 00000b5e [ 1] */,
197 0x02d90001 /* 00000b64 - 00000b65 [ 2] */,
198 0x02de0009 /* 00000b78 - 00000b81 [ 10] */,
199 0x02e10000 /* 00000b84 - 00000b84 [ 1] */,
200 0x02e2c002 /* 00000b8b - 00000b8d [ 3] */,
201 0x02e44000 /* 00000b91 - 00000b91 [ 1] */,
202 0x02e58002 /* 00000b96 - 00000b98 [ 3] */,
203 0x02e6c000 /* 00000b9b - 00000b9b [ 1] */,
204 0x02e74000 /* 00000b9d - 00000b9d [ 1] */,
205 0x02e80002 /* 00000ba0 - 00000ba2 [ 3] */,
206 0x02e94002 /* 00000ba5 - 00000ba7 [ 3] */,
207 0x02eac002 /* 00000bab - 00000bad [ 3] */,
208 0x02ee8003 /* 00000bba - 00000bbd [ 4] */,
209 0x02f0c002 /* 00000bc3 - 00000bc5 [ 3] */,
210 0x02f24000 /* 00000bc9 - 00000bc9 [ 1] */,
211 0x02f38001 /* 00000bce - 00000bcf [ 2] */,
212 0x02f44005 /* 00000bd1 - 00000bd6 [ 6] */,
213 0x02f6000d /* 00000bd8 - 00000be5 [ 14] */,
214 0x02fec004 /* 00000bfb - 00000bff [ 5] */,
215 0x03034000 /* 00000c0d - 00000c0d [ 1] */,
216 0x03044000 /* 00000c11 - 00000c11 [ 1] */,
217 0x030a4000 /* 00000c29 - 00000c29 [ 1] */,
218 0x030e8001 /* 00000c3a - 00000c3b [ 2] */,
219 0x03114000 /* 00000c45 - 00000c45 [ 1] */,
220 0x03124000 /* 00000c49 - 00000c49 [ 1] */,
221 0x03138006 /* 00000c4e - 00000c54 [ 7] */,
222 0x0315c000 /* 00000c57 - 00000c57 [ 1] */,
223 0x0316c001 /* 00000c5b - 00000c5c [ 2] */,
224 0x03178001 /* 00000c5e - 00000c5f [ 2] */,
225 0x03190001 /* 00000c64 - 00000c65 [ 2] */,
226 0x031c0006 /* 00000c70 - 00000c76 [ 7] */,
227 0x03234000 /* 00000c8d - 00000c8d [ 1] */,
228 0x03244000 /* 00000c91 - 00000c91 [ 1] */,
229 0x032a4000 /* 00000ca9 - 00000ca9 [ 1] */,
230 0x032d0000 /* 00000cb4 - 00000cb4 [ 1] */,
231 0x032e8001 /* 00000cba - 00000cbb [ 2] */,
232 0x03314000 /* 00000cc5 - 00000cc5 [ 1] */,
233 0x03324000 /* 00000cc9 - 00000cc9 [ 1] */,
234 0x03338006 /* 00000cce - 00000cd4 [ 7] */,
235 0x0335c005 /* 00000cd7 - 00000cdc [ 6] */,
236 0x0337c000 /* 00000cdf - 00000cdf [ 1] */,
237 0x03390001 /* 00000ce4 - 00000ce5 [ 2] */,
238 0x033c0000 /* 00000cf0 - 00000cf0 [ 1] */,
239 0x033d000b /* 00000cf4 - 00000cff [ 12] */,
240 0x03434000 /* 00000d0d - 00000d0d [ 1] */,
241 0x03444000 /* 00000d11 - 00000d11 [ 1] */,
242 0x03514000 /* 00000d45 - 00000d45 [ 1] */,
243 0x03524000 /* 00000d49 - 00000d49 [ 1] */,
244 0x03540003 /* 00000d50 - 00000d53 [ 4] */,
245 0x03590001 /* 00000d64 - 00000d65 [ 2] */,
246 0x03600000 /* 00000d80 - 00000d80 [ 1] */,
247 0x03610000 /* 00000d84 - 00000d84 [ 1] */,
248 0x0365c002 /* 00000d97 - 00000d99 [ 3] */,
249 0x036c8000 /* 00000db2 - 00000db2 [ 1] */,
250 0x036f0000 /* 00000dbc - 00000dbc [ 1] */,
251 0x036f8001 /* 00000dbe - 00000dbf [ 2] */,
252 0x0371c002 /* 00000dc7 - 00000dc9 [ 3] */,
253 0x0372c003 /* 00000dcb - 00000dce [ 4] */,
254 0x03754000 /* 00000dd5 - 00000dd5 [ 1] */,
255 0x0375c000 /* 00000dd7 - 00000dd7 [ 1] */,
256 0x03780005 /* 00000de0 - 00000de5 [ 6] */,
257 0x037c0001 /* 00000df0 - 00000df1 [ 2] */,
258 0x037d400b /* 00000df5 - 00000e00 [ 12] */,
259 0x038ec003 /* 00000e3b - 00000e3e [ 4] */,
260 0x03970024 /* 00000e5c - 00000e80 [ 37] */,
261 0x03a0c000 /* 00000e83 - 00000e83 [ 1] */,
262 0x03a14000 /* 00000e85 - 00000e85 [ 1] */,
263 0x03a2c000 /* 00000e8b - 00000e8b [ 1] */,
264 0x03a90000 /* 00000ea4 - 00000ea4 [ 1] */,
265 0x03a98000 /* 00000ea6 - 00000ea6 [ 1] */,
266 0x03af8001 /* 00000ebe - 00000ebf [ 2] */,
267 0x03b14000 /* 00000ec5 - 00000ec5 [ 1] */,
268 0x03b1c000 /* 00000ec7 - 00000ec7 [ 1] */,
269 0x03b3c000 /* 00000ecf - 00000ecf [ 1] */,
270 0x03b68001 /* 00000eda - 00000edb [ 2] */,
271 0x03b8001f /* 00000ee0 - 00000eff [ 32] */,
272 0x03d20000 /* 00000f48 - 00000f48 [ 1] */,
273 0x03db4003 /* 00000f6d - 00000f70 [ 4] */,
274 0x03e60000 /* 00000f98 - 00000f98 [ 1] */,
275 0x03ef4000 /* 00000fbd - 00000fbd [ 1] */,
276 0x03f34000 /* 00000fcd - 00000fcd [ 1] */,
277 0x03f6c024 /* 00000fdb - 00000fff [ 37] */,
278 0x04318000 /* 000010c6 - 000010c6 [ 1] */,
279 0x04320004 /* 000010c8 - 000010cc [ 5] */,
280 0x04338001 /* 000010ce - 000010cf [ 2] */,
281 0x04924000 /* 00001249 - 00001249 [ 1] */,
282 0x04938001 /* 0000124e - 0000124f [ 2] */,
283 0x0495c000 /* 00001257 - 00001257 [ 1] */,
284 0x04964000 /* 00001259 - 00001259 [ 1] */,
285 0x04978001 /* 0000125e - 0000125f [ 2] */,
286 0x04a24000 /* 00001289 - 00001289 [ 1] */,
287 0x04a38001 /* 0000128e - 0000128f [ 2] */,
288 0x04ac4000 /* 000012b1 - 000012b1 [ 1] */,
289 0x04ad8001 /* 000012b6 - 000012b7 [ 2] */,
290 0x04afc000 /* 000012bf - 000012bf [ 1] */,
291 0x04b04000 /* 000012c1 - 000012c1 [ 1] */,
292 0x04b18001 /* 000012c6 - 000012c7 [ 2] */,
293 0x04b5c000 /* 000012d7 - 000012d7 [ 1] */,
294 0x04c44000 /* 00001311 - 00001311 [ 1] */,
295 0x04c58001 /* 00001316 - 00001317 [ 2] */,
296 0x04d6c001 /* 0000135b - 0000135c [ 2] */,
297 0x04df4002 /* 0000137d - 0000137f [ 3] */,
298 0x04e68005 /* 0000139a - 0000139f [ 6] */,
299 0x04fd8001 /* 000013f6 - 000013f7 [ 2] */,
300 0x04ff8001 /* 000013fe - 000013ff [ 2] */,
301 0x05a00000 /* 00001680 - 00001680 [ 1] */,
302 0x05a74002 /* 0000169d - 0000169f [ 3] */,
303 0x05be4006 /* 000016f9 - 000016ff [ 7] */,
304 0x05c58008 /* 00001716 - 0000171e [ 9] */,
305 0x05cdc008 /* 00001737 - 0000173f [ 9] */,
306 0x05d5000b /* 00001754 - 0000175f [ 12] */,
307 0x05db4000 /* 0000176d - 0000176d [ 1] */,
308 0x05dc4000 /* 00001771 - 00001771 [ 1] */,
309 0x05dd000b /* 00001774 - 0000177f [ 12] */,
310 0x05f78001 /* 000017de - 000017df [ 2] */,
311 0x05fa8005 /* 000017ea - 000017ef [ 6] */,
312 0x05fe8005 /* 000017fa - 000017ff [ 6] */,
313 0x06038000 /* 0000180e - 0000180e [ 1] */,
314 0x06068005 /* 0000181a - 0000181f [ 6] */,
315 0x061e4006 /* 00001879 - 0000187f [ 7] */,
316 0x062ac004 /* 000018ab - 000018af [ 5] */,
317 0x063d8009 /* 000018f6 - 000018ff [ 10] */,
318 0x0647c000 /* 0000191f - 0000191f [ 1] */,
319 0x064b0003 /* 0000192c - 0000192f [ 4] */,
320 0x064f0003 /* 0000193c - 0000193f [ 4] */,
321 0x06504002 /* 00001941 - 00001943 [ 3] */,
322 0x065b8001 /* 0000196e - 0000196f [ 2] */,
323 0x065d400a /* 00001975 - 0000197f [ 11] */,
324 0x066b0003 /* 000019ac - 000019af [ 4] */,
325 0x06728005 /* 000019ca - 000019cf [ 6] */,
326 0x0676c002 /* 000019db - 000019dd [ 3] */,
327 0x06870001 /* 00001a1c - 00001a1d [ 2] */,
328 0x0697c000 /* 00001a5f - 00001a5f [ 1] */,
329 0x069f4001 /* 00001a7d - 00001a7e [ 2] */,
330 0x06a28005 /* 00001a8a - 00001a8f [ 6] */,
331 0x06a68005 /* 00001a9a - 00001a9f [ 6] */,
332 0x06ab8001 /* 00001aae - 00001aaf [ 2] */,
333 0x06b3c030 /* 00001acf - 00001aff [ 49] */,
334 0x06d34002 /* 00001b4d - 00001b4f [ 3] */,
335 0x06dfc000 /* 00001b7f - 00001b7f [ 1] */,
336 0x06fd0007 /* 00001bf4 - 00001bfb [ 8] */,
337 0x070e0002 /* 00001c38 - 00001c3a [ 3] */,
338 0x07128002 /* 00001c4a - 00001c4c [ 3] */,
339 0x07224006 /* 00001c89 - 00001c8f [ 7] */,
340 0x072ec001 /* 00001cbb - 00001cbc [ 2] */,
341 0x07320007 /* 00001cc8 - 00001ccf [ 8] */,
342 0x073ec004 /* 00001cfb - 00001cff [ 5] */,
343 0x07c58001 /* 00001f16 - 00001f17 [ 2] */,
344 0x07c78001 /* 00001f1e - 00001f1f [ 2] */,
345 0x07d18001 /* 00001f46 - 00001f47 [ 2] */,
346 0x07d38001 /* 00001f4e - 00001f4f [ 2] */,
347 0x07d60000 /* 00001f58 - 00001f58 [ 1] */,
348 0x07d68000 /* 00001f5a - 00001f5a [ 1] */,
349 0x07d70000 /* 00001f5c - 00001f5c [ 1] */,
350 0x07d78000 /* 00001f5e - 00001f5e [ 1] */,
351 0x07df8001 /* 00001f7e - 00001f7f [ 2] */,
352 0x07ed4000 /* 00001fb5 - 00001fb5 [ 1] */,
353 0x07f14000 /* 00001fc5 - 00001fc5 [ 1] */,
354 0x07f50001 /* 00001fd4 - 00001fd5 [ 2] */,
355 0x07f70000 /* 00001fdc - 00001fdc [ 1] */,
356 0x07fc0001 /* 00001ff0 - 00001ff1 [ 2] */,
357 0x07fd4000 /* 00001ff5 - 00001ff5 [ 1] */,
358 0x07ffc010 /* 00001fff - 0000200f [ 17] */,
359 0x080a0007 /* 00002028 - 0000202f [ 8] */,
360 0x0817c010 /* 0000205f - 0000206f [ 17] */,
361 0x081c8001 /* 00002072 - 00002073 [ 2] */,
362 0x0823c000 /* 0000208f - 0000208f [ 1] */,
363 0x08274002 /* 0000209d - 0000209f [ 3] */,
364 0x0830400e /* 000020c1 - 000020cf [ 15] */,
365 0x083c400e /* 000020f1 - 000020ff [ 15] */,
366 0x08630003 /* 0000218c - 0000218f [ 4] */,
367 0x0909c018 /* 00002427 - 0000243f [ 25] */,
368 0x0912c014 /* 0000244b - 0000245f [ 21] */,
369 0x0add0001 /* 00002b74 - 00002b75 [ 2] */,
370 0x0ae58000 /* 00002b96 - 00002b96 [ 1] */,
371 0x0b3d0004 /* 00002cf4 - 00002cf8 [ 5] */,
372 0x0b498000 /* 00002d26 - 00002d26 [ 1] */,
373 0x0b4a0004 /* 00002d28 - 00002d2c [ 5] */,
374 0x0b4b8001 /* 00002d2e - 00002d2f [ 2] */,
375 0x0b5a0006 /* 00002d68 - 00002d6e [ 7] */,
376 0x0b5c400d /* 00002d71 - 00002d7e [ 14] */,
377 0x0b65c008 /* 00002d97 - 00002d9f [ 9] */,
378 0x0b69c000 /* 00002da7 - 00002da7 [ 1] */,
379 0x0b6bc000 /* 00002daf - 00002daf [ 1] */,
380 0x0b6dc000 /* 00002db7 - 00002db7 [ 1] */,
381 0x0b6fc000 /* 00002dbf - 00002dbf [ 1] */,
382 0x0b71c000 /* 00002dc7 - 00002dc7 [ 1] */,
383 0x0b73c000 /* 00002dcf - 00002dcf [ 1] */,
384 0x0b75c000 /* 00002dd7 - 00002dd7 [ 1] */,
385 0x0b77c000 /* 00002ddf - 00002ddf [ 1] */,
386 0x0b978021 /* 00002e5e - 00002e7f [ 34] */,
387 0x0ba68000 /* 00002e9a - 00002e9a [ 1] */,
388 0x0bbd000b /* 00002ef4 - 00002eff [ 12] */,
389 0x0bf58019 /* 00002fd6 - 00002fef [ 26] */,
390 0x0c000000 /* 00003000 - 00003000 [ 1] */,
391 0x0c100000 /* 00003040 - 00003040 [ 1] */,
392 0x0c25c001 /* 00003097 - 00003098 [ 2] */,
393 0x0c400004 /* 00003100 - 00003104 [ 5] */,
394 0x0c4c0000 /* 00003130 - 00003130 [ 1] */,
395 0x0c63c000 /* 0000318f - 0000318f [ 1] */,
396 0x0c79000a /* 000031e4 - 000031ee [ 11] */,
397 0x0c87c000 /* 0000321f - 0000321f [ 1] */,
398 0x29234002 /* 0000a48d - 0000a48f [ 3] */,
399 0x2931c008 /* 0000a4c7 - 0000a4cf [ 9] */,
400 0x298b0013 /* 0000a62c - 0000a63f [ 20] */,
401 0x29be0007 /* 0000a6f8 - 0000a6ff [ 8] */,
402 0x29f2c004 /* 0000a7cb - 0000a7cf [ 5] */,
403 0x29f48000 /* 0000a7d2 - 0000a7d2 [ 1] */,
404 0x29f50000 /* 0000a7d4 - 0000a7d4 [ 1] */,
405 0x29f68017 /* 0000a7da - 0000a7f1 [ 24] */,
406 0x2a0b4002 /* 0000a82d - 0000a82f [ 3] */,
407 0x2a0e8005 /* 0000a83a - 0000a83f [ 6] */,
408 0x2a1e0007 /* 0000a878 - 0000a87f [ 8] */,
409 0x2a318007 /* 0000a8c6 - 0000a8cd [ 8] */,
410 0x2a368005 /* 0000a8da - 0000a8df [ 6] */,
411 0x2a55000a /* 0000a954 - 0000a95e [ 11] */,
412 0x2a5f4002 /* 0000a97d - 0000a97f [ 3] */,
413 0x2a738000 /* 0000a9ce - 0000a9ce [ 1] */,
414 0x2a768003 /* 0000a9da - 0000a9dd [ 4] */,
415 0x2a7fc000 /* 0000a9ff - 0000a9ff [ 1] */,
416 0x2a8dc008 /* 0000aa37 - 0000aa3f [ 9] */,
417 0x2a938001 /* 0000aa4e - 0000aa4f [ 2] */,
418 0x2a968001 /* 0000aa5a - 0000aa5b [ 2] */,
419 0x2ab0c017 /* 0000aac3 - 0000aada [ 24] */,
420 0x2abdc009 /* 0000aaf7 - 0000ab00 [ 10] */,
421 0x2ac1c001 /* 0000ab07 - 0000ab08 [ 2] */,
422 0x2ac3c001 /* 0000ab0f - 0000ab10 [ 2] */,
423 0x2ac5c008 /* 0000ab17 - 0000ab1f [ 9] */,
424 0x2ac9c000 /* 0000ab27 - 0000ab27 [ 1] */,
425 0x2acbc000 /* 0000ab2f - 0000ab2f [ 1] */,
426 0x2adb0003 /* 0000ab6c - 0000ab6f [ 4] */,
427 0x2afb8001 /* 0000abee - 0000abef [ 2] */,
428 0x2afe8005 /* 0000abfa - 0000abff [ 6] */,
429 0x35e9000b /* 0000d7a4 - 0000d7af [ 12] */,
430 0x35f1c003 /* 0000d7c7 - 0000d7ca [ 4] */,
431 0x35ff2103 /* 0000d7fc - 0000f8ff [ 8452] */,
432 0x3e9b8001 /* 0000fa6e - 0000fa6f [ 2] */,
433 0x3eb68025 /* 0000fada - 0000faff [ 38] */,
434 0x3ec1c00b /* 0000fb07 - 0000fb12 [ 12] */,
435 0x3ec60004 /* 0000fb18 - 0000fb1c [ 5] */,
436 0x3ecdc000 /* 0000fb37 - 0000fb37 [ 1] */,
437 0x3ecf4000 /* 0000fb3d - 0000fb3d [ 1] */,
438 0x3ecfc000 /* 0000fb3f - 0000fb3f [ 1] */,
439 0x3ed08000 /* 0000fb42 - 0000fb42 [ 1] */,
440 0x3ed14000 /* 0000fb45 - 0000fb45 [ 1] */,
441 0x3ef0c00f /* 0000fbc3 - 0000fbd2 [ 16] */,
442 0x3f640001 /* 0000fd90 - 0000fd91 [ 2] */,
443 0x3f720006 /* 0000fdc8 - 0000fdce [ 7] */,
444 0x3f74001f /* 0000fdd0 - 0000fdef [ 32] */,
445 0x3f868005 /* 0000fe1a - 0000fe1f [ 6] */,
446 0x3f94c000 /* 0000fe53 - 0000fe53 [ 1] */,
447 0x3f99c000 /* 0000fe67 - 0000fe67 [ 1] */,
448 0x3f9b0003 /* 0000fe6c - 0000fe6f [ 4] */,
449 0x3f9d4000 /* 0000fe75 - 0000fe75 [ 1] */,
450 0x3fbf4003 /* 0000fefd - 0000ff00 [ 4] */,
451 0x3fefc002 /* 0000ffbf - 0000ffc1 [ 3] */,
452 0x3ff20001 /* 0000ffc8 - 0000ffc9 [ 2] */,
453 0x3ff40001 /* 0000ffd0 - 0000ffd1 [ 2] */,
454 0x3ff60001 /* 0000ffd8 - 0000ffd9 [ 2] */,
455 0x3ff74002 /* 0000ffdd - 0000ffdf [ 3] */,
456 0x3ff9c000 /* 0000ffe7 - 0000ffe7 [ 1] */,
457 0x3ffbc00c /* 0000ffef - 0000fffb [ 13] */,
458 0x3fff8001 /* 0000fffe - 0000ffff [ 2] */,
459 0x40030000 /* 0001000c - 0001000c [ 1] */,
460 0x4009c000 /* 00010027 - 00010027 [ 1] */,
461 0x400ec000 /* 0001003b - 0001003b [ 1] */,
462 0x400f8000 /* 0001003e - 0001003e [ 1] */,
463 0x40138001 /* 0001004e - 0001004f [ 2] */,
464 0x40178021 /* 0001005e - 0001007f [ 34] */,
465 0x403ec004 /* 000100fb - 000100ff [ 5] */,
466 0x4040c003 /* 00010103 - 00010106 [ 4] */,
467 0x404d0002 /* 00010134 - 00010136 [ 3] */,
468 0x4063c000 /* 0001018f - 0001018f [ 1] */,
469 0x40674002 /* 0001019d - 0001019f [ 3] */,
470 0x4068402e /* 000101a1 - 000101cf [ 47] */,
471 0x407f8081 /* 000101fe - 0001027f [ 130] */,
472 0x40a74002 /* 0001029d - 0001029f [ 3] */,
473 0x40b4400e /* 000102d1 - 000102df [ 15] */,
474 0x40bf0003 /* 000102fc - 000102ff [ 4] */,
475 0x40c90008 /* 00010324 - 0001032c [ 9] */,
476 0x40d2c004 /* 0001034b - 0001034f [ 5] */,
477 0x40dec004 /* 0001037b - 0001037f [ 5] */,
478 0x40e78000 /* 0001039e - 0001039e [ 1] */,
479 0x40f10003 /* 000103c4 - 000103c7 [ 4] */,
480 0x40f58029 /* 000103d6 - 000103ff [ 42] */,
481 0x41278001 /* 0001049e - 0001049f [ 2] */,
482 0x412a8005 /* 000104aa - 000104af [ 6] */,
483 0x41350003 /* 000104d4 - 000104d7 [ 4] */,
484 0x413f0003 /* 000104fc - 000104ff [ 4] */,
485 0x414a0007 /* 00010528 - 0001052f [ 8] */,
486 0x4159000a /* 00010564 - 0001056e [ 11] */,
487 0x415ec000 /* 0001057b - 0001057b [ 1] */,
488 0x4162c000 /* 0001058b - 0001058b [ 1] */,
489 0x4164c000 /* 00010593 - 00010593 [ 1] */,
490 0x41658000 /* 00010596 - 00010596 [ 1] */,
491 0x41688000 /* 000105a2 - 000105a2 [ 1] */,
492 0x416c8000 /* 000105b2 - 000105b2 [ 1] */,
493 0x416e8000 /* 000105ba - 000105ba [ 1] */,
494 0x416f4042 /* 000105bd - 000105ff [ 67] */,
495 0x41cdc008 /* 00010737 - 0001073f [ 9] */,
496 0x41d58009 /* 00010756 - 0001075f [ 10] */,
497 0x41da0017 /* 00010768 - 0001077f [ 24] */,
498 0x41e18000 /* 00010786 - 00010786 [ 1] */,
499 0x41ec4000 /* 000107b1 - 000107b1 [ 1] */,
500 0x41eec044 /* 000107bb - 000107ff [ 69] */,
501 0x42018001 /* 00010806 - 00010807 [ 2] */,
502 0x42024000 /* 00010809 - 00010809 [ 1] */,
503 0x420d8000 /* 00010836 - 00010836 [ 1] */,
504 0x420e4002 /* 00010839 - 0001083b [ 3] */,
505 0x420f4001 /* 0001083d - 0001083e [ 2] */,
506 0x42158000 /* 00010856 - 00010856 [ 1] */,
507 0x4227c007 /* 0001089f - 000108a6 [ 8] */,
508 0x422c002f /* 000108b0 - 000108df [ 48] */,
509 0x423cc000 /* 000108f3 - 000108f3 [ 1] */,
510 0x423d8004 /* 000108f6 - 000108fa [ 5] */,
511 0x42470002 /* 0001091c - 0001091e [ 3] */,
512 0x424e8004 /* 0001093a - 0001093e [ 5] */,
513 0x4250003f /* 00010940 - 0001097f [ 64] */,
514 0x426e0003 /* 000109b8 - 000109bb [ 4] */,
515 0x42740001 /* 000109d0 - 000109d1 [ 2] */,
516 0x42810000 /* 00010a04 - 00010a04 [ 1] */,
517 0x4281c004 /* 00010a07 - 00010a0b [ 5] */,
518 0x42850000 /* 00010a14 - 00010a14 [ 1] */,
519 0x42860000 /* 00010a18 - 00010a18 [ 1] */,
520 0x428d8001 /* 00010a36 - 00010a37 [ 2] */,
521 0x428ec003 /* 00010a3b - 00010a3e [ 4] */,
522 0x42924006 /* 00010a49 - 00010a4f [ 7] */,
523 0x42964006 /* 00010a59 - 00010a5f [ 7] */,
524 0x42a8001f /* 00010aa0 - 00010abf [ 32] */,
525 0x42b9c003 /* 00010ae7 - 00010aea [ 4] */,
526 0x42bdc008 /* 00010af7 - 00010aff [ 9] */,
527 0x42cd8002 /* 00010b36 - 00010b38 [ 3] */,
528 0x42d58001 /* 00010b56 - 00010b57 [ 2] */,
529 0x42dcc004 /* 00010b73 - 00010b77 [ 5] */,
530 0x42e48006 /* 00010b92 - 00010b98 [ 7] */,
531 0x42e7400b /* 00010b9d - 00010ba8 [ 12] */,
532 0x42ec004f /* 00010bb0 - 00010bff [ 80] */,
533 0x43124036 /* 00010c49 - 00010c7f [ 55] */,
534 0x432cc00c /* 00010cb3 - 00010cbf [ 13] */,
535 0x433cc006 /* 00010cf3 - 00010cf9 [ 7] */,
536 0x434a0007 /* 00010d28 - 00010d2f [ 8] */,
537 0x434e8125 /* 00010d3a - 00010e5f [ 294] */,
538 0x439fc000 /* 00010e7f - 00010e7f [ 1] */,
539 0x43aa8000 /* 00010eaa - 00010eaa [ 1] */,
540 0x43ab8001 /* 00010eae - 00010eaf [ 2] */,
541 0x43ac804a /* 00010eb2 - 00010efc [ 75] */,
542 0x43ca0007 /* 00010f28 - 00010f2f [ 8] */,
543 0x43d68015 /* 00010f5a - 00010f6f [ 22] */,
544 0x43e28025 /* 00010f8a - 00010faf [ 38] */,
545 0x43f30013 /* 00010fcc - 00010fdf [ 20] */,
546 0x43fdc008 /* 00010ff7 - 00010fff [ 9] */,
547 0x44138003 /* 0001104e - 00011051 [ 4] */,
548 0x441d8008 /* 00011076 - 0001107e [ 9] */,
549 0x442f4000 /* 000110bd - 000110bd [ 1] */,
550 0x4430c00c /* 000110c3 - 000110cf [ 13] */,
551 0x443a4006 /* 000110e9 - 000110ef [ 7] */,
552 0x443e8005 /* 000110fa - 000110ff [ 6] */,
553 0x444d4000 /* 00011135 - 00011135 [ 1] */,
554 0x44520007 /* 00011148 - 0001114f [ 8] */,
555 0x445dc008 /* 00011177 - 0001117f [ 9] */,
556 0x44780000 /* 000111e0 - 000111e0 [ 1] */,
557 0x447d400a /* 000111f5 - 000111ff [ 11] */,
558 0x44848000 /* 00011212 - 00011212 [ 1] */,
559 0x4490803d /* 00011242 - 0001127f [ 62] */,
560 0x44a1c000 /* 00011287 - 00011287 [ 1] */,
561 0x44a24000 /* 00011289 - 00011289 [ 1] */,
562 0x44a38000 /* 0001128e - 0001128e [ 1] */,
563 0x44a78000 /* 0001129e - 0001129e [ 1] */,
564 0x44aa8005 /* 000112aa - 000112af [ 6] */,
565 0x44bac004 /* 000112eb - 000112ef [ 5] */,
566 0x44be8005 /* 000112fa - 000112ff [ 6] */,
567 0x44c10000 /* 00011304 - 00011304 [ 1] */,
568 0x44c34001 /* 0001130d - 0001130e [ 2] */,
569 0x44c44001 /* 00011311 - 00011312 [ 2] */,
570 0x44ca4000 /* 00011329 - 00011329 [ 1] */,
571 0x44cc4000 /* 00011331 - 00011331 [ 1] */,
572 0x44cd0000 /* 00011334 - 00011334 [ 1] */,
573 0x44ce8000 /* 0001133a - 0001133a [ 1] */,
574 0x44d14001 /* 00011345 - 00011346 [ 2] */,
575 0x44d24001 /* 00011349 - 0001134a [ 2] */,
576 0x44d38001 /* 0001134e - 0001134f [ 2] */,
577 0x44d44005 /* 00011351 - 00011356 [ 6] */,
578 0x44d60004 /* 00011358 - 0001135c [ 5] */,
579 0x44d90001 /* 00011364 - 00011365 [ 2] */,
580 0x44db4002 /* 0001136d - 0001136f [ 3] */,
581 0x44dd408a /* 00011375 - 000113ff [ 139] */,
582 0x45170000 /* 0001145c - 0001145c [ 1] */,
583 0x4518801d /* 00011462 - 0001147f [ 30] */,
584 0x45320007 /* 000114c8 - 000114cf [ 8] */,
585 0x453680a5 /* 000114da - 0001157f [ 166] */,
586 0x456d8001 /* 000115b6 - 000115b7 [ 2] */,
587 0x45778021 /* 000115de - 000115ff [ 34] */,
588 0x4591400a /* 00011645 - 0001164f [ 11] */,
589 0x45968005 /* 0001165a - 0001165f [ 6] */,
590 0x459b4012 /* 0001166d - 0001167f [ 19] */,
591 0x45ae8005 /* 000116ba - 000116bf [ 6] */,
592 0x45b28035 /* 000116ca - 000116ff [ 54] */,
593 0x45c6c001 /* 0001171b - 0001171c [ 2] */,
594 0x45cb0003 /* 0001172c - 0001172f [ 4] */,
595 0x45d1c0b8 /* 00011747 - 000117ff [ 185] */,
596 0x460f0063 /* 0001183c - 0001189f [ 100] */,
597 0x463cc00b /* 000118f3 - 000118fe [ 12] */,
598 0x4641c001 /* 00011907 - 00011908 [ 2] */,
599 0x46428001 /* 0001190a - 0001190b [ 2] */,
600 0x46450000 /* 00011914 - 00011914 [ 1] */,
601 0x4645c000 /* 00011917 - 00011917 [ 1] */,
602 0x464d8000 /* 00011936 - 00011936 [ 1] */,
603 0x464e4001 /* 00011939 - 0001193a [ 2] */,
604 0x4651c008 /* 00011947 - 0001194f [ 9] */,
605 0x46568045 /* 0001195a - 0001199f [ 70] */,
606 0x466a0001 /* 000119a8 - 000119a9 [ 2] */,
607 0x46760001 /* 000119d8 - 000119d9 [ 2] */,
608 0x4679401a /* 000119e5 - 000119ff [ 27] */,
609 0x46920007 /* 00011a48 - 00011a4f [ 8] */,
610 0x46a8c00c /* 00011aa3 - 00011aaf [ 13] */,
611 0x46be4006 /* 00011af9 - 00011aff [ 7] */,
612 0x46c280f5 /* 00011b0a - 00011bff [ 246] */,
613 0x47024000 /* 00011c09 - 00011c09 [ 1] */,
614 0x470dc000 /* 00011c37 - 00011c37 [ 1] */,
615 0x47118009 /* 00011c46 - 00011c4f [ 10] */,
616 0x471b4002 /* 00011c6d - 00011c6f [ 3] */,
617 0x47240001 /* 00011c90 - 00011c91 [ 2] */,
618 0x472a0000 /* 00011ca8 - 00011ca8 [ 1] */,
619 0x472dc048 /* 00011cb7 - 00011cff [ 73] */,
620 0x4741c000 /* 00011d07 - 00011d07 [ 1] */,
621 0x47428000 /* 00011d0a - 00011d0a [ 1] */,
622 0x474dc002 /* 00011d37 - 00011d39 [ 3] */,
623 0x474ec000 /* 00011d3b - 00011d3b [ 1] */,
624 0x474f8000 /* 00011d3e - 00011d3e [ 1] */,
625 0x47520007 /* 00011d48 - 00011d4f [ 8] */,
626 0x47568005 /* 00011d5a - 00011d5f [ 6] */,
627 0x47598000 /* 00011d66 - 00011d66 [ 1] */,
628 0x475a4000 /* 00011d69 - 00011d69 [ 1] */,
629 0x4763c000 /* 00011d8f - 00011d8f [ 1] */,
630 0x47648000 /* 00011d92 - 00011d92 [ 1] */,
631 0x47664006 /* 00011d99 - 00011d9f [ 7] */,
632 0x476a8135 /* 00011daa - 00011edf [ 310] */,
633 0x47be4006 /* 00011ef9 - 00011eff [ 7] */,
634 0x47c44000 /* 00011f11 - 00011f11 [ 1] */,
635 0x47cec002 /* 00011f3b - 00011f3d [ 3] */,
636 0x47d68055 /* 00011f5a - 00011faf [ 86] */,
637 0x47ec400e /* 00011fb1 - 00011fbf [ 15] */,
638 0x47fc800c /* 00011ff2 - 00011ffe [ 13] */,
639 0x48e68065 /* 0001239a - 000123ff [ 102] */,
640 0x491bc000 /* 0001246f - 0001246f [ 1] */,
641 0x491d400a /* 00012475 - 0001247f [ 11] */,
642 0x49510a4b /* 00012544 - 00012f8f [ 2636] */,
643 0x4bfcc00c /* 00012ff3 - 00012fff [ 13] */,
644 0x4d0c000f /* 00013430 - 0001343f [ 16] */,
645 0x4d158fa9 /* 00013456 - 000143ff [ 4010] */,
646 0x5191e1b8 /* 00014647 - 000167ff [ 8633] */,
647 0x5a8e4006 /* 00016a39 - 00016a3f [ 7] */,
648 0x5a97c000 /* 00016a5f - 00016a5f [ 1] */,
649 0x5a9a8003 /* 00016a6a - 00016a6d [ 4] */,
650 0x5aafc000 /* 00016abf - 00016abf [ 1] */,
651 0x5ab28005 /* 00016aca - 00016acf [ 6] */,
652 0x5abb8001 /* 00016aee - 00016aef [ 2] */,
653 0x5abd8009 /* 00016af6 - 00016aff [ 10] */,
654 0x5ad18009 /* 00016b46 - 00016b4f [ 10] */,
655 0x5ad68000 /* 00016b5a - 00016b5a [ 1] */,
656 0x5ad88000 /* 00016b62 - 00016b62 [ 1] */,
657 0x5ade0004 /* 00016b78 - 00016b7c [ 5] */,
658 0x5ae402af /* 00016b90 - 00016e3f [ 688] */,
659 0x5ba6c064 /* 00016e9b - 00016eff [ 101] */,
660 0x5bd2c003 /* 00016f4b - 00016f4e [ 4] */,
661 0x5be20006 /* 00016f88 - 00016f8e [ 7] */,
662 0x5be8003f /* 00016fa0 - 00016fdf [ 64] */,
663 0x5bf9400a /* 00016fe5 - 00016fef [ 11] */,
664 0x5bfc800d /* 00016ff2 - 00016fff [ 14] */,
665 0x61fe0007 /* 000187f8 - 000187ff [ 8] */,
666 0x63358029 /* 00018cd6 - 00018cff [ 42] */,
667 0x634262e6 /* 00018d09 - 0001afef [ 8935] */,
668 0x6bfd0000 /* 0001aff4 - 0001aff4 [ 1] */,
669 0x6bff0000 /* 0001affc - 0001affc [ 1] */,
670 0x6bffc000 /* 0001afff - 0001afff [ 1] */,
671 0x6c48c00e /* 0001b123 - 0001b131 [ 15] */,
672 0x6c4cc01c /* 0001b133 - 0001b14f [ 29] */,
673 0x6c54c001 /* 0001b153 - 0001b154 [ 2] */,
674 0x6c55800d /* 0001b156 - 0001b163 [ 14] */,
675 0x6c5a0007 /* 0001b168 - 0001b16f [ 8] */,
676 0x6cbf0903 /* 0001b2fc - 0001bbff [ 2308] */,
677 0x6f1ac004 /* 0001bc6b - 0001bc6f [ 5] */,
678 0x6f1f4002 /* 0001bc7d - 0001bc7f [ 3] */,
679 0x6f224006 /* 0001bc89 - 0001bc8f [ 7] */,
680 0x6f268001 /* 0001bc9a - 0001bc9b [ 2] */,
681 0x6f28125f /* 0001bca0 - 0001ceff [ 4704] */,
682 0x73cb8001 /* 0001cf2e - 0001cf2f [ 2] */,
683 0x73d1c008 /* 0001cf47 - 0001cf4f [ 9] */,
684 0x73f1003b /* 0001cfc4 - 0001cfff [ 60] */,
685 0x743d8009 /* 0001d0f6 - 0001d0ff [ 10] */,
686 0x7449c001 /* 0001d127 - 0001d128 [ 2] */,
687 0x745cc007 /* 0001d173 - 0001d17a [ 8] */,
688 0x747ac014 /* 0001d1eb - 0001d1ff [ 21] */,
689 0x74918079 /* 0001d246 - 0001d2bf [ 122] */,
690 0x74b5000b /* 0001d2d4 - 0001d2df [ 12] */,
691 0x74bd000b /* 0001d2f4 - 0001d2ff [ 12] */,
692 0x74d5c008 /* 0001d357 - 0001d35f [ 9] */,
693 0x74de4086 /* 0001d379 - 0001d3ff [ 135] */,
694 0x75154000 /* 0001d455 - 0001d455 [ 1] */,
695 0x75274000 /* 0001d49d - 0001d49d [ 1] */,
696 0x75280001 /* 0001d4a0 - 0001d4a1 [ 2] */,
697 0x7528c001 /* 0001d4a3 - 0001d4a4 [ 2] */,
698 0x7529c001 /* 0001d4a7 - 0001d4a8 [ 2] */,
699 0x752b4000 /* 0001d4ad - 0001d4ad [ 1] */,
700 0x752e8000 /* 0001d4ba - 0001d4ba [ 1] */,
701 0x752f0000 /* 0001d4bc - 0001d4bc [ 1] */,
702 0x75310000 /* 0001d4c4 - 0001d4c4 [ 1] */,
703 0x75418000 /* 0001d506 - 0001d506 [ 1] */,
704 0x7542c001 /* 0001d50b - 0001d50c [ 2] */,
705 0x75454000 /* 0001d515 - 0001d515 [ 1] */,
706 0x75474000 /* 0001d51d - 0001d51d [ 1] */,
707 0x754e8000 /* 0001d53a - 0001d53a [ 1] */,
708 0x754fc000 /* 0001d53f - 0001d53f [ 1] */,
709 0x75514000 /* 0001d545 - 0001d545 [ 1] */,
710 0x7551c002 /* 0001d547 - 0001d549 [ 3] */,
711 0x75544000 /* 0001d551 - 0001d551 [ 1] */,
712 0x75a98001 /* 0001d6a6 - 0001d6a7 [ 2] */,
713 0x75f30001 /* 0001d7cc - 0001d7cd [ 2] */,
714 0x76a3000e /* 0001da8c - 0001da9a [ 15] */,
715 0x76a80000 /* 0001daa0 - 0001daa0 [ 1] */,
716 0x76ac044f /* 0001dab0 - 0001deff [ 1104] */,
717 0x77c7c005 /* 0001df1f - 0001df24 [ 6] */,
718 0x77cac0d4 /* 0001df2b - 0001dfff [ 213] */,
719 0x7801c000 /* 0001e007 - 0001e007 [ 1] */,
720 0x78064001 /* 0001e019 - 0001e01a [ 2] */,
721 0x78088000 /* 0001e022 - 0001e022 [ 1] */,
722 0x78094000 /* 0001e025 - 0001e025 [ 1] */,
723 0x780ac004 /* 0001e02b - 0001e02f [ 5] */,
724 0x781b8020 /* 0001e06e - 0001e08e [ 33] */,
725 0x7824006f /* 0001e090 - 0001e0ff [ 112] */,
726 0x784b4002 /* 0001e12d - 0001e12f [ 3] */,
727 0x784f8001 /* 0001e13e - 0001e13f [ 2] */,
728 0x78528003 /* 0001e14a - 0001e14d [ 4] */,
729 0x7854013f /* 0001e150 - 0001e28f [ 320] */,
730 0x78abc010 /* 0001e2af - 0001e2bf [ 17] */,
731 0x78be8004 /* 0001e2fa - 0001e2fe [ 5] */,
732 0x78c001cf /* 0001e300 - 0001e4cf [ 464] */,
733 0x793e82e5 /* 0001e4fa - 0001e7df [ 742] */,
734 0x79f9c000 /* 0001e7e7 - 0001e7e7 [ 1] */,
735 0x79fb0000 /* 0001e7ec - 0001e7ec [ 1] */,
736 0x79fbc000 /* 0001e7ef - 0001e7ef [ 1] */,
737 0x79ffc000 /* 0001e7ff - 0001e7ff [ 1] */,
738 0x7a314001 /* 0001e8c5 - 0001e8c6 [ 2] */,
739 0x7a35c028 /* 0001e8d7 - 0001e8ff [ 41] */,
740 0x7a530003 /* 0001e94c - 0001e94f [ 4] */,
741 0x7a568003 /* 0001e95a - 0001e95d [ 4] */,
742 0x7a580310 /* 0001e960 - 0001ec70 [ 785] */,
743 0x7b2d404b /* 0001ecb5 - 0001ed00 [ 76] */,
744 0x7b4f80c1 /* 0001ed3e - 0001edff [ 194] */,
745 0x7b810000 /* 0001ee04 - 0001ee04 [ 1] */,
746 0x7b880000 /* 0001ee20 - 0001ee20 [ 1] */,
747 0x7b88c000 /* 0001ee23 - 0001ee23 [ 1] */,
748 0x7b894001 /* 0001ee25 - 0001ee26 [ 2] */,
749 0x7b8a0000 /* 0001ee28 - 0001ee28 [ 1] */,
750 0x7b8cc000 /* 0001ee33 - 0001ee33 [ 1] */,
751 0x7b8e0000 /* 0001ee38 - 0001ee38 [ 1] */,
752 0x7b8e8000 /* 0001ee3a - 0001ee3a [ 1] */,
753 0x7b8f0005 /* 0001ee3c - 0001ee41 [ 6] */,
754 0x7b90c003 /* 0001ee43 - 0001ee46 [ 4] */,
755 0x7b920000 /* 0001ee48 - 0001ee48 [ 1] */,
756 0x7b928000 /* 0001ee4a - 0001ee4a [ 1] */,
757 0x7b930000 /* 0001ee4c - 0001ee4c [ 1] */,
758 0x7b940000 /* 0001ee50 - 0001ee50 [ 1] */,
759 0x7b94c000 /* 0001ee53 - 0001ee53 [ 1] */,
760 0x7b954001 /* 0001ee55 - 0001ee56 [ 2] */,
761 0x7b960000 /* 0001ee58 - 0001ee58 [ 1] */,
762 0x7b968000 /* 0001ee5a - 0001ee5a [ 1] */,
763 0x7b970000 /* 0001ee5c - 0001ee5c [ 1] */,
764 0x7b978000 /* 0001ee5e - 0001ee5e [ 1] */,
765 0x7b980000 /* 0001ee60 - 0001ee60 [ 1] */,
766 0x7b98c000 /* 0001ee63 - 0001ee63 [ 1] */,
767 0x7b994001 /* 0001ee65 - 0001ee66 [ 2] */,
768 0x7b9ac000 /* 0001ee6b - 0001ee6b [ 1] */,
769 0x7b9cc000 /* 0001ee73 - 0001ee73 [ 1] */,
770 0x7b9e0000 /* 0001ee78 - 0001ee78 [ 1] */,
771 0x7b9f4000 /* 0001ee7d - 0001ee7d [ 1] */,
772 0x7b9fc000 /* 0001ee7f - 0001ee7f [ 1] */,
773 0x7ba28000 /* 0001ee8a - 0001ee8a [ 1] */,
774 0x7ba70004 /* 0001ee9c - 0001eea0 [ 5] */,
775 0x7ba90000 /* 0001eea4 - 0001eea4 [ 1] */,
776 0x7baa8000 /* 0001eeaa - 0001eeaa [ 1] */,
777 0x7baf0033 /* 0001eebc - 0001eeef [ 52] */,
778 0x7bbc810d /* 0001eef2 - 0001efff [ 270] */,
779 0x7c0b0003 /* 0001f02c - 0001f02f [ 4] */,
780 0x7c25000b /* 0001f094 - 0001f09f [ 12] */,
781 0x7c2bc001 /* 0001f0af - 0001f0b0 [ 2] */,
782 0x7c300000 /* 0001f0c0 - 0001f0c0 [ 1] */,
783 0x7c340000 /* 0001f0d0 - 0001f0d0 [ 1] */,
784 0x7c3d8009 /* 0001f0f6 - 0001f0ff [ 10] */,
785 0x7c6b8037 /* 0001f1ae - 0001f1e5 [ 56] */,
786 0x7c80c00c /* 0001f203 - 0001f20f [ 13] */,
787 0x7c8f0003 /* 0001f23c - 0001f23f [ 4] */,
788 0x7c924006 /* 0001f249 - 0001f24f [ 7] */,
789 0x7c94800d /* 0001f252 - 0001f25f [ 14] */,
790 0x7c998099 /* 0001f266 - 0001f2ff [ 154] */,
791 0x7db60003 /* 0001f6d8 - 0001f6db [ 4] */,
792 0x7dbb4002 /* 0001f6ed - 0001f6ef [ 3] */,
793 0x7dbf4002 /* 0001f6fd - 0001f6ff [ 3] */,
794 0x7dddc003 /* 0001f777 - 0001f77a [ 4] */,
795 0x7df68005 /* 0001f7da - 0001f7df [ 6] */,
796 0x7dfb0003 /* 0001f7ec - 0001f7ef [ 4] */,
797 0x7dfc400e /* 0001f7f1 - 0001f7ff [ 15] */,
798 0x7e030003 /* 0001f80c - 0001f80f [ 4] */,
799 0x7e120007 /* 0001f848 - 0001f84f [ 8] */,
800 0x7e168005 /* 0001f85a - 0001f85f [ 6] */,
801 0x7e220007 /* 0001f888 - 0001f88f [ 8] */,
802 0x7e2b8001 /* 0001f8ae - 0001f8af [ 2] */,
803 0x7e2c804d /* 0001f8b2 - 0001f8ff [ 78] */,
804 0x7e95000b /* 0001fa54 - 0001fa5f [ 12] */,
805 0x7e9b8001 /* 0001fa6e - 0001fa6f [ 2] */,
806 0x7e9f4002 /* 0001fa7d - 0001fa7f [ 3] */,
807 0x7ea24006 /* 0001fa89 - 0001fa8f [ 7] */,
808 0x7eaf8000 /* 0001fabe - 0001fabe [ 1] */,
809 0x7eb18007 /* 0001fac6 - 0001facd [ 8] */,
810 0x7eb70003 /* 0001fadc - 0001fadf [ 4] */,
811 0x7eba4006 /* 0001fae9 - 0001faef [ 7] */,
812 0x7ebe4006 /* 0001faf9 - 0001faff [ 7] */,
813 0x7ee4c000 /* 0001fb93 - 0001fb93 [ 1] */,
814 0x7ef2c024 /* 0001fbcb - 0001fbef [ 37] */,
815 0x7efe8405 /* 0001fbfa - 0001ffff [ 1030] */,
816 0xa9b8001f /* 0002a6e0 - 0002a6ff [ 32] */,
817 0xadce8005 /* 0002b73a - 0002b73f [ 6] */,
818 0xae078001 /* 0002b81e - 0002b81f [ 2] */,
819 0xb3a8800d /* 0002cea2 - 0002ceaf [ 14] */,
820 0xbaf8400e /* 0002ebe1 - 0002ebef [ 15] */,
821 0xbb9789a1 /* 0002ee5e - 0002f7ff [ 2466] */,
822 0xbe8785e1 /* 0002fa1e - 0002ffff [ 1506] */,
823 0xc4d2c004 /* 0003134b - 0003134f [ 5] */};
1007824
825/// Returns whether the code unit needs to be escaped.
826///
1008827/// At the end of the valid Unicode code points space a lot of code points are
1009828/// either reserved or a noncharacter. Adding all these entries to the
1010/// lookup table would add 446 entries to the table (in Unicode 14).
1011/// Instead the only the start of the region is stored, every code point in
1012/// this region needs to be escaped.
1013inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0;
829/// lookup table would greatly increase the size of the table. Instead these
830/// entries are manually processed. In this large area of reserved code points,
831/// there is a small area of extended graphemes that should not be escaped
832/// unconditionally. This is also manually coded. See the generation script for
833/// more details.
1014834
1015/// Returns whether the code unit needs to be escaped.
1016835///
1017/// \pre The code point is a valid Unicode code point.
836/// \\pre The code point is a valid Unicode code point.
1018837[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept {
1019 // Since __unallocated_region_lower_bound contains the unshifted range do the
1020 // comparison without shifting.
1021 if (__code_point >= __unallocated_region_lower_bound)
838
839 // The entries in the gap at the end.
840 if(__code_point >= 0x000e0100 && __code_point <= 0x000e01ef)
841 return false;
842
843 // The entries at the end.
844 if (__code_point >= 0x000323b0)
1022845 return true;
1023846
1024 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
847 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 14) | 0x3fffu) - __entries;
1025848 if (__i == 0)
1026849 return false;
1027850
1028851 --__i;
1029 uint32_t __upper_bound = (__entries[__i] >> 11) + (__entries[__i] & 0x7ffu);
852 uint32_t __upper_bound = (__entries[__i] >> 14) + (__entries[__i] & 0x3fffu);
1030853 return __code_point <= __upper_bound;
1031854}
1032855
lib/libcxx/include/__format/extended_grapheme_cluster_table.h+1-1
......@@ -125,7 +125,7 @@ enum class __property : uint8_t {
125125/// following benchmark.
126126/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
127127// clang-format off
128inline constexpr uint32_t __entries[1496] = {
128_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
129129 0x00000091,
130130 0x00005005,
131131 0x00005811,
lib/libcxx/include/__format/format_arg.h+108-4
......@@ -14,11 +14,12 @@
1414#include <__concepts/arithmetic.h>
1515#include <__config>
1616#include <__format/concepts.h>
17#include <__format/format_fwd.h>
1817#include <__format/format_parse_context.h>
1918#include <__functional/invoke.h>
19#include <__fwd/format.h>
2020#include <__memory/addressof.h>
2121#include <__type_traits/conditional.h>
22#include <__type_traits/remove_const.h>
2223#include <__utility/forward.h>
2324#include <__utility/move.h>
2425#include <__utility/unreachable.h>
......@@ -96,7 +97,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t __get_packed_type(uint64_t __types, size
9697
9798} // namespace __format
9899
99// This function is not user obervable, so it can directly use the non-standard
100// This function is not user observable, so it can directly use the non-standard
100101// types of the "variant". See __arg_t for more details.
101102template <class _Visitor, class _Context>
102103_LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
......@@ -147,6 +148,59 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
147148 __libcpp_unreachable();
148149}
149150
151# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
152
153template <class _Rp, class _Visitor, class _Context>
154_LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
155 switch (__arg.__type_) {
156 case __format::__arg_t::__none:
157 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
158 case __format::__arg_t::__boolean:
159 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__boolean_);
160 case __format::__arg_t::__char_type:
161 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__char_type_);
162 case __format::__arg_t::__int:
163 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__int_);
164 case __format::__arg_t::__long_long:
165 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
166 case __format::__arg_t::__i128:
167# ifndef _LIBCPP_HAS_NO_INT128
168 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_);
169# else
170 __libcpp_unreachable();
171# endif
172 case __format::__arg_t::__unsigned:
173 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_);
174 case __format::__arg_t::__unsigned_long_long:
175 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
176 case __format::__arg_t::__u128:
177# ifndef _LIBCPP_HAS_NO_INT128
178 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_);
179# else
180 __libcpp_unreachable();
181# endif
182 case __format::__arg_t::__float:
183 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__float_);
184 case __format::__arg_t::__double:
185 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__double_);
186 case __format::__arg_t::__long_double:
187 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_double_);
188 case __format::__arg_t::__const_char_type_ptr:
189 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_);
190 case __format::__arg_t::__string_view:
191 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__string_view_);
192 case __format::__arg_t::__ptr:
193 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__ptr_);
194 case __format::__arg_t::__handle:
195 return std::invoke_r<_Rp>(
196 std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_});
197 }
198
199 __libcpp_unreachable();
200}
201
202# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
203
150204/// Contains the values used in basic_format_arg.
151205///
152206/// This is a separate type so it's possible to store the values and types in
......@@ -230,6 +284,52 @@ public:
230284
231285 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; }
232286
287# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
288
289 // This function is user facing, so it must wrap the non-standard types of
290 // the "variant" in a handle to stay conforming. See __arg_t for more details.
291 template <class _Visitor>
292 _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) {
293 switch (__arg.__type_) {
294# ifndef _LIBCPP_HAS_NO_INT128
295 case __format::__arg_t::__i128: {
296 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
297 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
298 }
299
300 case __format::__arg_t::__u128: {
301 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
302 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
303 }
304# endif
305 default:
306 return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg);
307 }
308 }
309
310 // This function is user facing, so it must wrap the non-standard types of
311 // the "variant" in a handle to stay conforming. See __arg_t for more details.
312 template <class _Rp, class _Visitor>
313 _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) {
314 switch (__arg.__type_) {
315# ifndef _LIBCPP_HAS_NO_INT128
316 case __format::__arg_t::__i128: {
317 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
318 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
319 }
320
321 case __format::__arg_t::__u128: {
322 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
323 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
324 }
325# endif
326 default:
327 return std::__visit_format_arg<_Rp>(std::forward<_Visitor>(__vis), __arg);
328 }
329 }
330
331# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
332
233333private:
234334 using char_type = typename _Context::char_type;
235335
......@@ -270,7 +370,11 @@ private:
270370// This function is user facing, so it must wrap the non-standard types of
271371// the "variant" in a handle to stay conforming. See __arg_t for more details.
272372template <class _Visitor, class _Context>
273_LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
373# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
374_LIBCPP_DEPRECATED_IN_CXX26
375# endif
376 _LIBCPP_HIDE_FROM_ABI decltype(auto)
377 visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
274378 switch (__arg.__type_) {
275379# ifndef _LIBCPP_HAS_NO_INT128
276380 case __format::__arg_t::__i128: {
......@@ -282,7 +386,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_fo
282386 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
283387 return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
284388 }
285# endif
389# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
286390 default:
287391 return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg);
288392 }
lib/libcxx/include/__format/format_arg_store.h+1-2
......@@ -151,7 +151,7 @@ consteval __arg_t __determine_arg_t() {
151151// The overload for not formattable types allows triggering the static
152152// assertion below.
153153template <class _Context, class _Tp>
154 requires(!__formattable<_Tp, typename _Context::char_type>)
154 requires(!__formattable_with<_Tp, _Context>)
155155consteval __arg_t __determine_arg_t() {
156156 return __arg_t::__none;
157157}
......@@ -165,7 +165,6 @@ _LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp& __valu
165165 using _Dp = remove_const_t<_Tp>;
166166 constexpr __arg_t __arg = __determine_arg_t<_Context, _Dp>();
167167 static_assert(__arg != __arg_t::__none, "the supplied type is not formattable");
168
169168 static_assert(__formattable_with<_Tp, _Context>);
170169
171170 // Not all types can be used to directly initialize the
lib/libcxx/include/__format/format_args.h+1-4
......@@ -10,11 +10,10 @@
1010#ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H
1111#define _LIBCPP___FORMAT_FORMAT_ARGS_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__format/format_arg.h>
1615#include <__format/format_arg_store.h>
17#include <__format/format_fwd.h>
16#include <__fwd/format.h>
1817#include <cstddef>
1918#include <cstdint>
2019
......@@ -29,8 +28,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2928template <class _Context>
3029class _LIBCPP_TEMPLATE_VIS basic_format_args {
3130public:
32 basic_format_args() noexcept = default;
33
3431 template <class... _Args>
3532 _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
3633 : __size_(sizeof...(_Args)) {
lib/libcxx/include/__format/format_context.h+24-17
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FORMAT_FORMAT_CONTEXT_H
1111#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
1212
13#include <__availability>
1413#include <__concepts/same_as.h>
1514#include <__config>
1615#include <__format/buffer.h>
......@@ -18,7 +17,7 @@
1817#include <__format/format_arg_store.h>
1918#include <__format/format_args.h>
2019#include <__format/format_error.h>
21#include <__format/format_fwd.h>
20#include <__fwd/format.h>
2221#include <__iterator/back_insert_iterator.h>
2322#include <__iterator/concepts.h>
2423#include <__memory/addressof.h>
......@@ -27,7 +26,7 @@
2726#include <cstddef>
2827
2928#ifndef _LIBCPP_HAS_NO_LOCALIZATION
30# include <locale>
29# include <__locale>
3130# include <optional>
3231#endif
3332
......@@ -132,6 +131,9 @@ private:
132131 _LIBCPP_HIDE_FROM_ABI explicit basic_format_context(_OutIt __out_it, basic_format_args<basic_format_context> __args)
133132 : __out_it_(std::move(__out_it)), __args_(__args) {}
134133# endif
134
135 basic_format_context(const basic_format_context&) = delete;
136 basic_format_context& operator=(const basic_format_context&) = delete;
135137};
136138
137139// A specialization for __retarget_buffer
......@@ -166,20 +168,25 @@ public:
166168# endif
167169 __ctx_(std::addressof(__ctx)),
168170 __arg_([](void* __c, size_t __id) {
169 return std::visit_format_arg(
170 [&](auto __arg) -> basic_format_arg<basic_format_context> {
171 if constexpr (same_as<decltype(__arg), monostate>)
172 return {};
173 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
174 // At the moment it's not possible for formatting to use a re-targeted handle.
175 // TODO FMT add this when support is needed.
176 std::__throw_format_error("Re-targeting handle not supported");
177 else
178 return basic_format_arg<basic_format_context>{
179 __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
180 __basic_format_arg_value<basic_format_context>(__arg)};
181 },
182 static_cast<_Context*>(__c)->arg(__id));
171 auto __visitor = [&](auto __arg) -> basic_format_arg<basic_format_context> {
172 if constexpr (same_as<decltype(__arg), monostate>)
173 return {};
174 else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Context>::handle>)
175 // At the moment it's not possible for formatting to use a re-targeted handle.
176 // TODO FMT add this when support is needed.
177 std::__throw_format_error("Re-targeting handle not supported");
178 else
179 return basic_format_arg<basic_format_context>{
180 __format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
181 __basic_format_arg_value<basic_format_context>(__arg)};
182 };
183# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
184 return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
185# else
186 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
187 return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id));
188 _LIBCPP_SUPPRESS_DEPRECATED_POP
189# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
183190 }) {
184191 }
185192
lib/libcxx/include/__format/format_functions.h+17-19
......@@ -41,7 +41,7 @@
4141#include <string_view>
4242
4343#ifndef _LIBCPP_HAS_NO_LOCALIZATION
44# include <locale>
44# include <__locale>
4545#endif
4646
4747#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -66,15 +66,14 @@ using wformat_args = basic_format_args<wformat_context>;
6666# endif
6767
6868template <class _Context = format_context, class... _Args>
69_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args) {
70 return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
69[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args) {
70 return std::__format_arg_store<_Context, _Args...>(__args...);
7171}
7272
7373# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
7474template <class... _Args>
75_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...>
76make_wformat_args(_Args&... __args) {
77 return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
75[[nodiscard]] _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&... __args) {
76 return std::__format_arg_store<wformat_context, _Args...>(__args...);
7877}
7978# endif
8079
......@@ -452,8 +451,7 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
452451// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
453452// fires too eagerly, see http://llvm.org/PR61563.
454453template <class = void>
455_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
456vformat(string_view __fmt, format_args __args) {
454[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string vformat(string_view __fmt, format_args __args) {
457455 string __res;
458456 std::vformat_to(std::back_inserter(__res), __fmt, __args);
459457 return __res;
......@@ -463,7 +461,7 @@ vformat(string_view __fmt, format_args __args) {
463461// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
464462// fires too eagerly, see http://llvm.org/PR61563.
465463template <class = void>
466_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
464[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
467465vformat(wstring_view __fmt, wformat_args __args) {
468466 wstring __res;
469467 std::vformat_to(std::back_inserter(__res), __fmt, __args);
......@@ -472,14 +470,14 @@ vformat(wstring_view __fmt, wformat_args __args) {
472470# endif
473471
474472template <class... _Args>
475_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
473[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
476474format(format_string<_Args...> __fmt, _Args&&... __args) {
477475 return std::vformat(__fmt.get(), std::make_format_args(__args...));
478476}
479477
480478# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
481479template <class... _Args>
482_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
480[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
483481format(wformat_string<_Args...> __fmt, _Args&&... __args) {
484482 return std::vformat(__fmt.get(), std::make_wformat_args(__args...));
485483}
......@@ -520,14 +518,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt,
520518}
521519
522520template <class... _Args>
523_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
521[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
524522formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
525523 return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_format_args(__args...)});
526524}
527525
528526# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
529527template <class... _Args>
530_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
528[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
531529formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
532530 return std::__vformatted_size(__fmt.get(), basic_format_args{std::make_wformat_args(__args...)});
533531}
......@@ -585,7 +583,7 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&
585583// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
586584// fires too eagerly, see http://llvm.org/PR61563.
587585template <class = void>
588_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
586[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
589587vformat(locale __loc, string_view __fmt, format_args __args) {
590588 string __res;
591589 std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args);
......@@ -596,7 +594,7 @@ vformat(locale __loc, string_view __fmt, format_args __args) {
596594// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
597595// fires too eagerly, see http://llvm.org/PR61563.
598596template <class = void>
599_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
597[[nodiscard]] _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
600598vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
601599 wstring __res;
602600 std::vformat_to(std::back_inserter(__res), std::move(__loc), __fmt, __args);
......@@ -605,14 +603,14 @@ vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
605603# endif
606604
607605template <class... _Args>
608_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
606[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
609607format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
610608 return std::vformat(std::move(__loc), __fmt.get(), std::make_format_args(__args...));
611609}
612610
613611# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
614612template <class... _Args>
615_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
613[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
616614format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
617615 return std::vformat(std::move(__loc), __fmt.get(), std::make_wformat_args(__args...));
618616}
......@@ -658,14 +656,14 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_
658656}
659657
660658template <class... _Args>
661_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
659[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
662660formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
663661 return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_format_args(__args...)});
664662}
665663
666664# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
667665template <class... _Args>
668_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
666[[nodiscard]] _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
669667formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
670668 return std::__vformatted_size(std::move(__loc), __fmt.get(), basic_format_args{std::make_wformat_args(__args...)});
671669}
lib/libcxx/include/__format/format_fwd.h deleted-39
......@@ -1,39 +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___FORMAT_FORMAT_FWD_H
11#define _LIBCPP___FORMAT_FORMAT_FWD_H
12
13#include <__availability>
14#include <__config>
15#include <__iterator/concepts.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
23#if _LIBCPP_STD_VER >= 20
24
25template <class _Context>
26class _LIBCPP_TEMPLATE_VIS basic_format_arg;
27
28template <class _OutIt, class _CharT>
29 requires output_iterator<_OutIt, const _CharT&>
30class _LIBCPP_TEMPLATE_VIS basic_format_context;
31
32template <class _Tp, class _CharT = char>
33struct _LIBCPP_TEMPLATE_VIS formatter;
34
35#endif //_LIBCPP_STD_VER >= 20
36
37_LIBCPP_END_NAMESPACE_STD
38
39#endif // _LIBCPP___FORMAT_FORMAT_FWD_H
lib/libcxx/include/__format/formatter.h+1-2
......@@ -10,9 +10,8 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_H
1111#define _LIBCPP___FORMAT_FORMATTER_H
1212
13#include <__availability>
1413#include <__config>
15#include <__format/format_fwd.h>
14#include <__fwd/format.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
lib/libcxx/include/__format/formatter_bool.h+1-2
......@@ -12,7 +12,6 @@
1212
1313#include <__algorithm/copy.h>
1414#include <__assert>
15#include <__availability>
1615#include <__config>
1716#include <__format/concepts.h>
1817#include <__format/format_parse_context.h>
......@@ -22,7 +21,7 @@
2221#include <__utility/unreachable.h>
2322
2423#ifndef _LIBCPP_HAS_NO_LOCALIZATION
25# include <locale>
24# include <__locale>
2625#endif
2726
2827#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__format/formatter_char.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_CHAR_H
1111#define _LIBCPP___FORMAT_FORMATTER_CHAR_H
1212
13#include <__availability>
1413#include <__concepts/same_as.h>
1514#include <__config>
1615#include <__format/concepts.h>
lib/libcxx/include/__format/formatter_floating_point.h+2-1
......@@ -16,6 +16,7 @@
1616#include <__algorithm/min.h>
1717#include <__algorithm/rotate.h>
1818#include <__algorithm/transform.h>
19#include <__assert>
1920#include <__charconv/chars_format.h>
2021#include <__charconv/to_chars_floating_point.h>
2122#include <__charconv/to_chars_result.h>
......@@ -38,7 +39,7 @@
3839#include <cstddef>
3940
4041#ifndef _LIBCPP_HAS_NO_LOCALIZATION
41# include <locale>
42# include <__locale>
4243#endif
4344
4445#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__format/formatter_integer.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGER_H
1111#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H
1212
13#include <__availability>
1413#include <__concepts/arithmetic.h>
1514#include <__config>
1615#include <__format/concepts.h>
lib/libcxx/include/__format/formatter_integral.h+1-1
......@@ -32,7 +32,7 @@
3232#include <string_view>
3333
3434#ifndef _LIBCPP_HAS_NO_LOCALIZATION
35# include <locale>
35# include <__locale>
3636#endif
3737
3838#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__format/formatter_output.h+11-9
......@@ -100,8 +100,8 @@ __padding_size(size_t __size, size_t __width, __format_spec::__alignment __align
100100///
101101/// This uses a "mass output function" of __format::__output_buffer when possible.
102102template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
103_LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it)
104 -> decltype(__out_it) {
103_LIBCPP_HIDE_FROM_ABI auto
104__copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) {
105105 if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
106106 __out_it.__get_container()->__copy(__str);
107107 return __out_it;
......@@ -116,16 +116,16 @@ _LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterat
116116template <contiguous_iterator _Iterator,
117117 __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type,
118118 __fmt_char_type _OutCharT = _CharT>
119_LIBCPP_HIDE_FROM_ABI auto __copy(_Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it)
120 -> decltype(__out_it) {
119_LIBCPP_HIDE_FROM_ABI auto
120__copy(_Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) {
121121 return __formatter::__copy(basic_string_view{__first, __last}, std::move(__out_it));
122122}
123123
124124template <contiguous_iterator _Iterator,
125125 __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type,
126126 __fmt_char_type _OutCharT = _CharT>
127_LIBCPP_HIDE_FROM_ABI auto __copy(_Iterator __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it)
128 -> decltype(__out_it) {
127_LIBCPP_HIDE_FROM_ABI auto
128__copy(_Iterator __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it) -> decltype(__out_it) {
129129 return __formatter::__copy(basic_string_view{std::to_address(__first), __n}, std::move(__out_it));
130130}
131131
......@@ -136,9 +136,11 @@ template <contiguous_iterator _Iterator,
136136 __fmt_char_type _CharT = typename iterator_traits<_Iterator>::value_type,
137137 __fmt_char_type _OutCharT = _CharT,
138138 class _UnaryOperation>
139_LIBCPP_HIDE_FROM_ABI auto __transform(
140 _Iterator __first, _Iterator __last, output_iterator<const _OutCharT&> auto __out_it, _UnaryOperation __operation)
141 -> decltype(__out_it) {
139_LIBCPP_HIDE_FROM_ABI auto
140__transform(_Iterator __first,
141 _Iterator __last,
142 output_iterator<const _OutCharT&> auto __out_it,
143 _UnaryOperation __operation) -> decltype(__out_it) {
142144 if constexpr (std::same_as<decltype(__out_it), std::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
143145 __out_it.__get_container()->__transform(__first, __last, std::move(__operation));
144146 return __out_it;
lib/libcxx/include/__format/formatter_pointer.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H
1111#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__format/concepts.h>
1615#include <__format/format_parse_context.h>
lib/libcxx/include/__format/formatter_string.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
1111#define _LIBCPP___FORMAT_FORMATTER_STRING_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__format/concepts.h>
1615#include <__format/format_parse_context.h>
lib/libcxx/include/__format/indic_conjunct_break_table.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// WARNING, this entire header is generated by
11// utils/generate_indic_conjunct_break_table.py
12// DO NOT MODIFY!
13
14// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
15//
16// See Terms of Use <https://www.unicode.org/copyright.html>
17// for definitions of Unicode Inc.'s Data Files and Software.
18//
19// NOTICE TO USER: Carefully read the following legal agreement.
20// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
21// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
22// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
23// TERMS AND CONDITIONS OF THIS AGREEMENT.
24// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
25// THE DATA FILES OR SOFTWARE.
26//
27// COPYRIGHT AND PERMISSION NOTICE
28//
29// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
30// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
31//
32// Permission is hereby granted, free of charge, to any person obtaining
33// a copy of the Unicode data files and any associated documentation
34// (the "Data Files") or Unicode software and any associated documentation
35// (the "Software") to deal in the Data Files or Software
36// without restriction, including without limitation the rights to use,
37// copy, modify, merge, publish, distribute, and/or sell copies of
38// the Data Files or Software, and to permit persons to whom the Data Files
39// or Software are furnished to do so, provided that either
40// (a) this copyright and permission notice appear with all copies
41// of the Data Files or Software, or
42// (b) this copyright and permission notice appear in associated
43// Documentation.
44//
45// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
46// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
47// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
49// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
50// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
51// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
52// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
53// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
54// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
55//
56// Except as contained in this notice, the name of a copyright holder
57// shall not be used in advertising or otherwise to promote the sale,
58// use or other dealings in these Data Files or Software without prior
59// written authorization of the copyright holder.
60
61#ifndef _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H
62#define _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H
63
64#include <__algorithm/ranges_upper_bound.h>
65#include <__config>
66#include <__iterator/access.h>
67#include <cstddef>
68#include <cstdint>
69
70#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
71# pragma GCC system_header
72#endif
73
74_LIBCPP_BEGIN_NAMESPACE_STD
75
76#if _LIBCPP_STD_VER >= 20
77
78namespace __indic_conjunct_break {
79
80enum class __property : uint8_t {
81 // Values generated from the data files.
82 __Consonant,
83 __Extend,
84 __Linker,
85
86 // The code unit has none of above properties.
87 __none
88};
89
90/// The entries of the indic conjunct break property table.
91///
92/// The data is generated from
93/// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
94///
95/// The data has 3 values
96/// - bits [0, 1] The property. One of the values generated from the datafiles
97/// of \ref __property
98/// - bits [2, 10] The size of the range.
99/// - bits [11, 31] The lower bound code point of the range. The upper bound of
100/// the range is lower bound + size.
101///
102/// The 9 bits for the size allow a maximum range of 512 elements. Some ranges
103/// in the Unicode tables are larger. They are stored in multiple consecutive
104/// ranges in the data table. An alternative would be to store the sizes in a
105/// separate 16-bit value. The original MSVC STL code had such an approach, but
106/// this approach uses less space for the data and is about 4% faster in the
107/// following benchmark.
108/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
109// clang-format off
110_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[201] = {
111 0x00180139,
112 0x001a807d,
113 0x00241811,
114 0x002c88b1,
115 0x002df801,
116 0x002e0805,
117 0x002e2005,
118 0x002e3801,
119 0x00308029,
120 0x00325851,
121 0x00338001,
122 0x0036b019,
123 0x0036f815,
124 0x00373805,
125 0x0037500d,
126 0x00388801,
127 0x00398069,
128 0x003f5821,
129 0x003fe801,
130 0x0040b00d,
131 0x0040d821,
132 0x00412809,
133 0x00414811,
134 0x0042c809,
135 0x0044c01d,
136 0x0046505d,
137 0x00471871,
138 0x0048a890,
139 0x0049e001,
140 0x004a6802,
141 0x004a880d,
142 0x004ac01c,
143 0x004bc01c,
144 0x004ca84c,
145 0x004d5018,
146 0x004d9000,
147 0x004db00c,
148 0x004de001,
149 0x004e6802,
150 0x004ee004,
151 0x004ef800,
152 0x004f8004,
153 0x004ff001,
154 0x0051e001,
155 0x0054a84c,
156 0x00555018,
157 0x00559004,
158 0x0055a810,
159 0x0055e001,
160 0x00566802,
161 0x0057c800,
162 0x0058a84c,
163 0x00595018,
164 0x00599004,
165 0x0059a810,
166 0x0059e001,
167 0x005a6802,
168 0x005ae004,
169 0x005af800,
170 0x005b8800,
171 0x0060a84c,
172 0x0061503c,
173 0x0061e001,
174 0x00626802,
175 0x0062a805,
176 0x0062c008,
177 0x0065e001,
178 0x0068a894,
179 0x0069d805,
180 0x006a6802,
181 0x0071c009,
182 0x0072400d,
183 0x0075c009,
184 0x0076400d,
185 0x0078c005,
186 0x0079a801,
187 0x0079b801,
188 0x0079c801,
189 0x007b8805,
190 0x007ba001,
191 0x007bd00d,
192 0x007c0001,
193 0x007c1009,
194 0x007c3005,
195 0x007e3001,
196 0x0081b801,
197 0x0081c805,
198 0x00846801,
199 0x009ae809,
200 0x00b8a001,
201 0x00be9001,
202 0x00bee801,
203 0x00c54801,
204 0x00c9c809,
205 0x00d0b805,
206 0x00d30001,
207 0x00d3a81d,
208 0x00d3f801,
209 0x00d58035,
210 0x00d5f83d,
211 0x00d9a001,
212 0x00db5821,
213 0x00dd5801,
214 0x00df3001,
215 0x00e1b801,
216 0x00e68009,
217 0x00e6a031,
218 0x00e71019,
219 0x00e76801,
220 0x00e7a001,
221 0x00e7c005,
222 0x00ee00fd,
223 0x01006801,
224 0x01068031,
225 0x01070801,
226 0x0107282d,
227 0x01677809,
228 0x016bf801,
229 0x016f007d,
230 0x01815015,
231 0x0184c805,
232 0x05337801,
233 0x0533a025,
234 0x0534f005,
235 0x05378005,
236 0x05416001,
237 0x05470045,
238 0x05495809,
239 0x054d9801,
240 0x05558001,
241 0x05559009,
242 0x0555b805,
243 0x0555f005,
244 0x05560801,
245 0x0557b001,
246 0x055f6801,
247 0x07d8f001,
248 0x07f1003d,
249 0x080fe801,
250 0x08170001,
251 0x081bb011,
252 0x08506801,
253 0x08507801,
254 0x0851c009,
255 0x0851f801,
256 0x08572805,
257 0x0869200d,
258 0x08755805,
259 0x0877e809,
260 0x087a3029,
261 0x087c100d,
262 0x08838001,
263 0x0883f801,
264 0x0885d001,
265 0x08880009,
266 0x08899805,
267 0x088b9801,
268 0x088e5001,
269 0x0891b001,
270 0x08974805,
271 0x0899d805,
272 0x089b3019,
273 0x089b8011,
274 0x08a23001,
275 0x08a2f001,
276 0x08a61801,
277 0x08ae0001,
278 0x08b5b801,
279 0x08b95801,
280 0x08c1d001,
281 0x08c9f001,
282 0x08ca1801,
283 0x08d1a001,
284 0x08d23801,
285 0x08d4c801,
286 0x08ea1001,
287 0x08ea2005,
288 0x08ecb801,
289 0x08fa1001,
290 0x0b578011,
291 0x0b598019,
292 0x0de4f001,
293 0x0e8b2801,
294 0x0e8b3809,
295 0x0e8b7011,
296 0x0e8bd81d,
297 0x0e8c2819,
298 0x0e8d500d,
299 0x0e921009,
300 0x0f000019,
301 0x0f004041,
302 0x0f00d819,
303 0x0f011805,
304 0x0f013011,
305 0x0f047801,
306 0x0f098019,
307 0x0f157001,
308 0x0f17600d,
309 0x0f27600d,
310 0x0f468019,
311 0x0f4a2019};
312// clang-format on
313
314/// Returns the indic conjuct break property of a code point.
315[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
316 // The algorithm searches for the upper bound of the range and, when found,
317 // steps back one entry. This algorithm is used since the code point can be
318 // anywhere in the range. After a lower bound is found the next step is to
319 // compare whether the code unit is indeed in the range.
320 //
321 // Since the entry contains a code unit, size, and property the code point
322 // being sought needs to be adjusted. Just shifting the code point to the
323 // proper position doesn't work; suppose an entry has property 0, size 1,
324 // and lower bound 3. This results in the entry 0x1810.
325 // When searching for code point 3 it will search for 0x1800, find 0x1810
326 // and moves to the previous entry. Thus the lower bound value will never
327 // be found.
328 // The simple solution is to set the bits belonging to the property and
329 // size. Then the upper bound for code point 3 will return the entry after
330 // 0x1810. After moving to the previous entry the algorithm arrives at the
331 // correct entry.
332 ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
333 if (__i == 0)
334 return __property::__none;
335
336 --__i;
337 uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 2) & 0b1'1111'1111);
338 if (__code_point <= __upper_bound)
339 return static_cast<__property>(__entries[__i] & 0b11);
340
341 return __property::__none;
342}
343
344} // namespace __indic_conjunct_break
345
346#endif //_LIBCPP_STD_VER >= 20
347
348_LIBCPP_END_NAMESPACE_STD
349
350#endif // _LIBCPP___FORMAT_INDIC_CONJUNCT_BREAK_TABLE_H
lib/libcxx/include/__format/parser_std_format_spec.h+13-16
......@@ -129,8 +129,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr uint32_t __substitute_arg_id(basic_format_arg<_C
129129///
130130/// They default to false so when a new field is added it needs to be opted in
131131/// explicitly.
132// TODO FMT Use an ABI tag for this struct.
133struct __fields {
132struct _LIBCPP_HIDE_FROM_ABI __fields {
134133 uint16_t __sign_ : 1 {false};
135134 uint16_t __alternate_form_ : 1 {false};
136135 uint16_t __zero_padding_ : 1 {false};
......@@ -355,10 +354,10 @@ public:
355354 _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator __parse(_ParseContext& __ctx, __fields __fields) {
356355 auto __begin = __ctx.begin();
357356 auto __end = __ctx.end();
358 if (__begin == __end)
357 if (__begin == __end || *__begin == _CharT('}') || (__fields.__use_range_fill_ && *__begin == _CharT(':')))
359358 return __begin;
360359
361 if (__parse_fill_align(__begin, __end, __fields.__use_range_fill_) && __begin == __end)
360 if (__parse_fill_align(__begin, __end) && __begin == __end)
362361 return __begin;
363362
364363 if (__fields.__sign_) {
......@@ -574,12 +573,10 @@ private:
574573 return false;
575574 }
576575
577 _LIBCPP_HIDE_FROM_ABI constexpr void __validate_fill_character(_CharT __fill, bool __use_range_fill) {
576 _LIBCPP_HIDE_FROM_ABI constexpr void __validate_fill_character(_CharT __fill) {
578577 // The forbidden fill characters all code points formed from a single code unit, thus the
579578 // check can be omitted when more code units are used.
580 if (__use_range_fill && (__fill == _CharT('{') || __fill == _CharT('}') || __fill == _CharT(':')))
581 std::__throw_format_error("The fill option contains an invalid value");
582 else if (__fill == _CharT('{') || __fill == _CharT('}'))
579 if (__fill == _CharT('{'))
583580 std::__throw_format_error("The fill option contains an invalid value");
584581 }
585582
......@@ -590,7 +587,7 @@ private:
590587# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
591588 || (same_as<_CharT, wchar_t> && sizeof(wchar_t) == 2)
592589# endif
593 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
590 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
594591 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
595592 __begin != __end,
596593 "when called with an empty input the function will cause "
......@@ -606,7 +603,7 @@ private:
606603 // The forbidden fill characters all are code points encoded
607604 // in one code unit, thus the check can be omitted when more
608605 // code units are used.
609 __validate_fill_character(*__begin, __use_range_fill);
606 __validate_fill_character(*__begin);
610607
611608 std::copy_n(__begin, __code_units, std::addressof(__fill_.__data[0]));
612609 __begin += __code_units + 1;
......@@ -623,7 +620,7 @@ private:
623620# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
624621 template <contiguous_iterator _Iterator>
625622 requires(same_as<_CharT, wchar_t> && sizeof(wchar_t) == 4)
626 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
623 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
627624 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
628625 __begin != __end,
629626 "when called with an empty input the function will cause "
......@@ -632,7 +629,7 @@ private:
632629 if (!__unicode::__is_scalar_value(*__begin))
633630 std::__throw_format_error("The fill option contains an invalid value");
634631
635 __validate_fill_character(*__begin, __use_range_fill);
632 __validate_fill_character(*__begin);
636633
637634 __fill_.__data[0] = *__begin;
638635 __begin += 2;
......@@ -651,14 +648,14 @@ private:
651648# else // _LIBCPP_HAS_NO_UNICODE
652649 // range-fill and tuple-fill are identical
653650 template <contiguous_iterator _Iterator>
654 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end, bool __use_range_fill) {
651 _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_fill_align(_Iterator& __begin, _Iterator __end) {
655652 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
656653 __begin != __end,
657654 "when called with an empty input the function will cause "
658655 "undefined behavior by evaluating data not in the input");
659656 if (__begin + 1 != __end) {
660657 if (__parse_alignment(*(__begin + 1))) {
661 __validate_fill_character(*__begin, __use_range_fill);
658 __validate_fill_character(*__begin);
662659
663660 __fill_.__data[0] = *__begin;
664661 __begin += 2;
......@@ -1158,8 +1155,8 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col
11581155 // When Unicode isn't supported assume ASCII and every code unit is one code
11591156 // point. In ASCII the estimated column width is always one. Thus there's no
11601157 // need for rounding.
1161 size_t __width_ = std::min(__str.size(), __maximum);
1162 return {__width_, __str.begin() + __width_};
1158 size_t __width = std::min(__str.size(), __maximum);
1159 return {__width, __str.begin() + __width};
11631160}
11641161
11651162# endif // !defined(_LIBCPP_HAS_NO_UNICODE)
lib/libcxx/include/__format/unicode.h+218-95
......@@ -15,8 +15,10 @@
1515#include <__concepts/same_as.h>
1616#include <__config>
1717#include <__format/extended_grapheme_cluster_table.h>
18#include <__format/indic_conjunct_break_table.h>
1819#include <__iterator/concepts.h>
1920#include <__iterator/readable_traits.h> // iter_value_t
21#include <__utility/unreachable.h>
2022#include <string_view>
2123
2224#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -292,84 +294,231 @@ private:
292294};
293295# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
294296
295_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
296 bool& __ri_break_allowed,
297 bool __has_extened_pictographic,
298 __extended_grapheme_custer_property_boundary::__property __prev,
299 __extended_grapheme_custer_property_boundary::__property __next) {
300 using __extended_grapheme_custer_property_boundary::__property;
297// State machine to implement the Extended Grapheme Cluster Boundary
298//
299// The exact rules may change between Unicode versions.
300// This implements the extended rules see
301// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries
302class __extended_grapheme_cluster_break {
303 using __EGC_property = __extended_grapheme_custer_property_boundary::__property;
304 using __inCB_property = __indic_conjunct_break::__property;
301305
302 __has_extened_pictographic |= __prev == __property::__Extended_Pictographic;
306public:
307 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_break(char32_t __first_code_point)
308 : __prev_code_point_(__first_code_point),
309 __prev_property_(__extended_grapheme_custer_property_boundary::__get_property(__first_code_point)) {
310 // Initializes the active rule.
311 if (__prev_property_ == __EGC_property::__Extended_Pictographic)
312 __active_rule_ = __rule::__GB11_emoji;
313 else if (__prev_property_ == __EGC_property::__Regional_Indicator)
314 __active_rule_ = __rule::__GB12_GB13_regional_indicator;
315 else if (__indic_conjunct_break::__get_property(__first_code_point) == __inCB_property::__Consonant)
316 __active_rule_ = __rule::__GB9c_indic_conjunct_break;
317 }
303318
304 // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules
319 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(char32_t __next_code_point) {
320 __EGC_property __next_property = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point);
321 bool __result = __evaluate(__next_code_point, __next_property);
322 __prev_code_point_ = __next_code_point;
323 __prev_property_ = __next_property;
324 return __result;
325 }
305326
306 // *** Break at the start and end of text, unless the text is empty. ***
327 // The code point whose break propery are considered during the next
328 // evaluation cyle.
329 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr char32_t __current_code_point() const { return __prev_code_point_; }
307330
308 _LIBCPP_ASSERT_INTERNAL(__prev != __property::__sot, "should be handled in the constructor"); // GB1
309 _LIBCPP_ASSERT_INTERNAL(__prev != __property::__eot, "should be handled by our caller"); // GB2
331private:
332 // The naming of the identifiers matches the Unicode standard.
333 // NOLINTBEGIN(readability-identifier-naming)
334
335 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
336 __evaluate(char32_t __next_code_point, __EGC_property __next_property) {
337 switch (__active_rule_) {
338 case __rule::__none:
339 return __evaluate_none(__next_code_point, __next_property);
340 case __rule::__GB9c_indic_conjunct_break:
341 return __evaluate_GB9c_indic_conjunct_break(__next_code_point, __next_property);
342 case __rule::__GB11_emoji:
343 return __evaluate_GB11_emoji(__next_code_point, __next_property);
344 case __rule::__GB12_GB13_regional_indicator:
345 return __evaluate_GB12_GB13_regional_indicator(__next_code_point, __next_property);
346 }
347 __libcpp_unreachable();
348 }
310349
311 // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
312 if (__prev == __property::__CR && __next == __property::__LF) // GB3
313 return false;
350 _LIBCPP_HIDE_FROM_ABI constexpr bool __evaluate_none(char32_t __next_code_point, __EGC_property __next_property) {
351 // *** Break at the start and end of text, unless the text is empty. ***
314352
315 if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4
316 return true;
353 _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__sot, "should be handled in the constructor"); // GB1
354 _LIBCPP_ASSERT_INTERNAL(__prev_property_ != __EGC_property::__eot, "should be handled by our caller"); // GB2
317355
318 if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5
319 return true;
356 // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
357 if (__prev_property_ == __EGC_property::__CR && __next_property == __EGC_property::__LF) // GB3
358 return false;
320359
321 // *** Do not break Hangul syllable sequences. ***
322 if (__prev == __property::__L && (__next == __property::__L || __next == __property::__V ||
323 __next == __property::__LV || __next == __property::__LVT)) // GB6
324 return false;
360 if (__prev_property_ == __EGC_property::__Control || __prev_property_ == __EGC_property::__CR ||
361 __prev_property_ == __EGC_property::__LF) // GB4
362 return true;
325363
326 if ((__prev == __property::__LV || __prev == __property::__V) &&
327 (__next == __property::__V || __next == __property::__T)) // GB7
328 return false;
364 if (__next_property == __EGC_property::__Control || __next_property == __EGC_property::__CR ||
365 __next_property == __EGC_property::__LF) // GB5
366 return true;
329367
330 if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8
331 return false;
368 // *** Do not break Hangul syllable sequences. ***
369 if (__prev_property_ == __EGC_property::__L &&
370 (__next_property == __EGC_property::__L || __next_property == __EGC_property::__V ||
371 __next_property == __EGC_property::__LV || __next_property == __EGC_property::__LVT)) // GB6
372 return false;
332373
333 // *** Do not break before extending characters or ZWJ. ***
334 if (__next == __property::__Extend || __next == __property::__ZWJ)
335 return false; // GB9
374 if ((__prev_property_ == __EGC_property::__LV || __prev_property_ == __EGC_property::__V) &&
375 (__next_property == __EGC_property::__V || __next_property == __EGC_property::__T)) // GB7
376 return false;
336377
337 // *** Do not break before SpacingMarks, or after Prepend characters. ***
338 if (__next == __property::__SpacingMark) // GB9a
339 return false;
378 if ((__prev_property_ == __EGC_property::__LVT || __prev_property_ == __EGC_property::__T) &&
379 __next_property == __EGC_property::__T) // GB8
380 return false;
340381
341 if (__prev == __property::__Prepend) // GB9b
342 return false;
382 // *** Do not break before extending characters or ZWJ. ***
383 if (__next_property == __EGC_property::__Extend || __next_property == __EGC_property::__ZWJ)
384 return false; // GB9
343385
344 // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
386 // *** Do not break before SpacingMarks, or after Prepend characters. ***
387 if (__next_property == __EGC_property::__SpacingMark) // GB9a
388 return false;
345389
346 // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic}
347 //
348 // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ)
349 // - \p{Extended_Pictographic} x Extend
350 // - Extend x Extend
351 // - \p{Extended_Pictographic} x ZWJ
352 // - Extend x ZWJ
353 //
354 // So the only case left to test is
355 // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic}
356 // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic
357 if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic)
358 return false;
390 if (__prev_property_ == __EGC_property::__Prepend) // GB9b
391 return false;
359392
360 // *** Do not break within emoji flag sequences ***
393 // *** Do not break within certain combinations with Indic_Conjunct_Break (InCB)=Linker. ***
394 if (__indic_conjunct_break::__get_property(__next_code_point) == __inCB_property::__Consonant) {
395 __active_rule_ = __rule::__GB9c_indic_conjunct_break;
396 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
397 return true;
398 }
399
400 // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
401 if (__next_property == __EGC_property::__Extended_Pictographic) {
402 __active_rule_ = __rule::__GB11_emoji;
403 __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
404 return true;
405 }
406
407 // *** Do not break within emoji flag sequences ***
361408
362 // That is, do not break between regional indicator (RI) symbols if there
363 // is an odd number of RI characters before the break point.
409 // That is, do not break between regional indicator (RI) symbols if there
410 // is an odd number of RI characters before the break point.
411 if (__next_property == __EGC_property::__Regional_Indicator) { // GB12 + GB13
412 __active_rule_ = __rule::__GB12_GB13_regional_indicator;
413 return true;
414 }
364415
365 if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
366 __ri_break_allowed = !__ri_break_allowed;
367 return __ri_break_allowed;
416 // *** Otherwise, break everywhere. ***
417 return true; // GB999
368418 }
369419
370 // *** Otherwise, break everywhere. ***
371 return true; // GB999
372}
420 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
421 __evaluate_GB9c_indic_conjunct_break(char32_t __next_code_point, __EGC_property __next_property) {
422 __inCB_property __break = __indic_conjunct_break::__get_property(__next_code_point);
423 if (__break == __inCB_property::__none) {
424 __active_rule_ = __rule::__none;
425 return __evaluate_none(__next_code_point, __next_property);
426 }
427
428 switch (__GB9c_indic_conjunct_break_state_) {
429 case __GB9c_indic_conjunct_break_state::__Consonant:
430 if (__break == __inCB_property::__Extend) {
431 return false;
432 }
433 if (__break == __inCB_property::__Linker) {
434 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Linker;
435 return false;
436 }
437 __active_rule_ = __rule::__none;
438 return __evaluate_none(__next_code_point, __next_property);
439
440 case __GB9c_indic_conjunct_break_state::__Linker:
441 if (__break == __inCB_property::__Extend) {
442 return false;
443 }
444 if (__break == __inCB_property::__Linker) {
445 return false;
446 }
447 if (__break == __inCB_property::__Consonant) {
448 __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
449 return false;
450 }
451 __active_rule_ = __rule::__none;
452 return __evaluate_none(__next_code_point, __next_property);
453 }
454 __libcpp_unreachable();
455 }
456
457 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
458 __evaluate_GB11_emoji(char32_t __next_code_point, __EGC_property __next_property) {
459 switch (__GB11_emoji_state_) {
460 case __GB11_emoji_state::__Extended_Pictographic:
461 if (__next_property == __EGC_property::__Extend) {
462 __GB11_emoji_state_ = __GB11_emoji_state::__Extend;
463 return false;
464 }
465 [[fallthrough]];
466 case __GB11_emoji_state::__Extend:
467 if (__next_property == __EGC_property::__ZWJ) {
468 __GB11_emoji_state_ = __GB11_emoji_state::__ZWJ;
469 return false;
470 }
471 if (__next_property == __EGC_property::__Extend)
472 return false;
473 __active_rule_ = __rule::__none;
474 return __evaluate_none(__next_code_point, __next_property);
475
476 case __GB11_emoji_state::__ZWJ:
477 if (__next_property == __EGC_property::__Extended_Pictographic) {
478 __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
479 return false;
480 }
481 __active_rule_ = __rule::__none;
482 return __evaluate_none(__next_code_point, __next_property);
483 }
484 __libcpp_unreachable();
485 }
486
487 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool
488 __evaluate_GB12_GB13_regional_indicator(char32_t __next_code_point, __EGC_property __next_property) {
489 __active_rule_ = __rule::__none;
490 if (__next_property == __EGC_property::__Regional_Indicator)
491 return false;
492 return __evaluate_none(__next_code_point, __next_property);
493 }
494
495 char32_t __prev_code_point_;
496 __EGC_property __prev_property_;
497
498 enum class __rule {
499 __none,
500 __GB9c_indic_conjunct_break,
501 __GB11_emoji,
502 __GB12_GB13_regional_indicator,
503 };
504 __rule __active_rule_ = __rule::__none;
505
506 enum class __GB11_emoji_state {
507 __Extended_Pictographic,
508 __Extend,
509 __ZWJ,
510 };
511 __GB11_emoji_state __GB11_emoji_state_ = __GB11_emoji_state::__Extended_Pictographic;
512
513 enum class __GB9c_indic_conjunct_break_state {
514 __Consonant,
515 __Linker,
516 };
517
518 __GB9c_indic_conjunct_break_state __GB9c_indic_conjunct_break_state_ = __GB9c_indic_conjunct_break_state::__Consonant;
519
520 // NOLINTEND(readability-identifier-naming)
521};
373522
374523/// Helper class to extract an extended grapheme cluster from a Unicode character range.
375524///
......@@ -382,9 +531,7 @@ class __extended_grapheme_cluster_view {
382531
383532public:
384533 _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(_Iterator __first, _Iterator __last)
385 : __code_point_view_(__first, __last),
386 __next_code_point_(__code_point_view_.__consume().__code_point),
387 __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {}
534 : __code_point_view_(__first, __last), __at_break_(__code_point_view_.__consume().__code_point) {}
388535
389536 struct __cluster {
390537 /// The first code point of the extended grapheme cluster.
......@@ -400,44 +547,20 @@ public:
400547 _Iterator __last_;
401548 };
402549
403 _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() {
404 _LIBCPP_ASSERT_INTERNAL(__next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot,
405 "can't move beyond the end of input");
406
407 char32_t __code_point = __next_code_point_;
408 if (!__code_point_view_.__at_end())
409 return {__code_point, __get_break()};
410
411 __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
412 return {__code_point, __code_point_view_.__position()};
550 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() {
551 char32_t __code_point = __at_break_.__current_code_point();
552 _Iterator __position = __code_point_view_.__position();
553 while (!__code_point_view_.__at_end()) {
554 if (__at_break_(__code_point_view_.__consume().__code_point))
555 break;
556 __position = __code_point_view_.__position();
557 }
558 return {__code_point, __position};
413559 }
414560
415561private:
416562 __code_point_view<_CharT> __code_point_view_;
417
418 char32_t __next_code_point_;
419 __extended_grapheme_custer_property_boundary::__property __next_prop_;
420
421 _LIBCPP_HIDE_FROM_ABI constexpr _Iterator __get_break() {
422 bool __ri_break_allowed = true;
423 bool __has_extened_pictographic = false;
424 while (true) {
425 _Iterator __result = __code_point_view_.__position();
426 __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_;
427 if (__code_point_view_.__at_end()) {
428 __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
429 return __result;
430 }
431 __next_code_point_ = __code_point_view_.__consume().__code_point;
432 __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_);
433
434 __has_extened_pictographic |=
435 __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic;
436
437 if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_))
438 return __result;
439 }
440 }
563 __extended_grapheme_cluster_break __at_break_;
441564};
442565
443566template <contiguous_iterator _Iterator>
lib/libcxx/include/__format/width_estimation_table.h+4-5
......@@ -119,7 +119,7 @@ namespace __width_estimation_table {
119119/// - bits [0, 13] The size of the range, allowing 16384 elements.
120120/// - bits [14, 31] The lower bound code point of the range. The upper bound of
121121/// the range is lower bound + size.
122inline constexpr uint32_t __entries[108] = {
122_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[107] = {
123123 0x0440005f /* 00001100 - 0000115f [ 96] */, //
124124 0x08c68001 /* 0000231a - 0000231b [ 2] */, //
125125 0x08ca4001 /* 00002329 - 0000232a [ 2] */, //
......@@ -158,14 +158,13 @@ inline constexpr uint32_t __entries[108] = {
158158 0x0ba00019 /* 00002e80 - 00002e99 [ 26] */, //
159159 0x0ba6c058 /* 00002e9b - 00002ef3 [ 89] */, //
160160 0x0bc000d5 /* 00002f00 - 00002fd5 [ 214] */, //
161 0x0bfc000b /* 00002ff0 - 00002ffb [ 12] */, //
162 0x0c00003e /* 00003000 - 0000303e [ 63] */, //
161 0x0bfc004e /* 00002ff0 - 0000303e [ 79] */, //
163162 0x0c104055 /* 00003041 - 00003096 [ 86] */, //
164163 0x0c264066 /* 00003099 - 000030ff [ 103] */, //
165164 0x0c41402a /* 00003105 - 0000312f [ 43] */, //
166165 0x0c4c405d /* 00003131 - 0000318e [ 94] */, //
167166 0x0c640053 /* 00003190 - 000031e3 [ 84] */, //
168 0x0c7c002e /* 000031f0 - 0000321e [ 47] */, //
167 0x0c7bc02f /* 000031ef - 0000321e [ 48] */, //
169168 0x0c880027 /* 00003220 - 00003247 [ 40] */, //
170169 0x0c943fff /* 00003250 - 0000724f [16384] */, //
171170 0x1c94323c /* 00007250 - 0000a48c [12861] */, //
......@@ -238,7 +237,7 @@ inline constexpr uint32_t __table_upper_bound = 0x0003fffd;
238237
239238/// Returns the estimated width of a Unicode code point.
240239///
241/// \pre The code point is a valid Unicode code point.
240/// \\pre The code point is a valid Unicode code point.
242241[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int __estimated_width(const char32_t __code_point) noexcept {
243242 // Since __table_upper_bound contains the unshifted range do the
244243 // comparison without shifting.
lib/libcxx/include/__format/write_escaped.h+22-6
......@@ -101,15 +101,27 @@ _LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_Cha
101101}
102102
103103template <class _CharT>
104[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value) {
104[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
105__is_escaped_sequence_written(basic_string<_CharT>& __str, bool __last_escaped, char32_t __value) {
105106# ifdef _LIBCPP_HAS_NO_UNICODE
106107 // For ASCII assume everything above 127 is printable.
107108 if (__value > 127)
108109 return false;
109110# endif
110111
112 // [format.string.escaped]/2.2.1.2.1
113 // CE is UTF-8, UTF-16, or UTF-32 and C corresponds to a Unicode scalar
114 // value whose Unicode property General_Category has a value in the groups
115 // Separator (Z) or Other (C), as described by UAX #44 of the Unicode Standard,
111116 if (!__escaped_output_table::__needs_escape(__value))
112 return false;
117 // [format.string.escaped]/2.2.1.2.2
118 // CE is UTF-8, UTF-16, or UTF-32 and C corresponds to a Unicode scalar
119 // value with the Unicode property Grapheme_Extend=Yes as described by UAX
120 // #44 of the Unicode Standard and C is not immediately preceded in S by a
121 // character P appended to E without translation to an escape sequence,
122 if (!__last_escaped || __extended_grapheme_custer_property_boundary::__get_property(__value) !=
123 __extended_grapheme_custer_property_boundary::__property::__Extend)
124 return false;
113125
114126 __formatter::__write_well_formed_escaped_code_unit(__str, __value);
115127 return true;
......@@ -124,8 +136,8 @@ enum class __escape_quotation_mark { __apostrophe, __double_quote };
124136
125137// [format.string.escaped]/2
126138template <class _CharT>
127[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
128__is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __escape_quotation_mark __mark) {
139[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(
140 basic_string<_CharT>& __str, char32_t __value, bool __last_escaped, __escape_quotation_mark __mark) {
129141 // 2.2.1.1 - Mapped character in [tab:format.escape.sequences]
130142 switch (__value) {
131143 case _CharT('\t'):
......@@ -167,7 +179,7 @@ __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __e
167179 // TODO FMT determine what to do with shift sequences.
168180
169181 // 2.2.1.2.1 and 2.2.1.2.2 - Escape
170 return __formatter::__is_escaped_sequence_written(__str, __formatter::__to_char32(__value));
182 return __formatter::__is_escaped_sequence_written(__str, __last_escaped, __formatter::__to_char32(__value));
171183}
172184
173185template <class _CharT>
......@@ -175,11 +187,15 @@ _LIBCPP_HIDE_FROM_ABI void
175187__escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) {
176188 __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()};
177189
190 // When the first code unit has the property Grapheme_Extend=Yes it needs to
191 // be escaped. This happens when the previous code unit was also escaped.
192 bool __escape = true;
178193 while (!__view.__at_end()) {
179194 auto __first = __view.__position();
180195 typename __unicode::__consume_result __result = __view.__consume();
181196 if (__result.__status == __unicode::__consume_result::__ok) {
182 if (!__formatter::__is_escaped_sequence_written(__str, __result.__code_point, __mark))
197 __escape = __formatter::__is_escaped_sequence_written(__str, __result.__code_point, __escape, __mark);
198 if (!__escape)
183199 // 2.2.1.3 - Add the character
184200 ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str));
185201 } else {
lib/libcxx/include/__functional/bind.h+7-6
......@@ -13,6 +13,7 @@
1313#include <__config>
1414#include <__functional/invoke.h>
1515#include <__functional/weak_result_type.h>
16#include <__fwd/functional.h>
1617#include <__type_traits/decay.h>
1718#include <__type_traits/is_reference_wrapper.h>
1819#include <__type_traits/is_void.h>
......@@ -94,7 +95,7 @@ __mu(_Ti& __ti, tuple<_Uj...>& __uj) {
9495 return std::__mu_expand(__ti, __uj, __indices());
9596}
9697
97template <bool IsPh, class _Ti, class _Uj>
98template <bool _IsPh, class _Ti, class _Uj>
9899struct __mu_return2 {};
99100
100101template <class _Ti, class _Uj>
......@@ -104,8 +105,8 @@ struct __mu_return2<true, _Ti, _Uj> {
104105
105106template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0>
106107inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
107 typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
108 __mu(_Ti&, _Uj& __uj) {
108typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
109__mu(_Ti&, _Uj& __uj) {
109110 const size_t __indx = is_placeholder<_Ti>::value - 1;
110111 return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj));
111112}
......@@ -119,7 +120,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti,
119120 return __ti;
120121}
121122
122template <class _Ti, bool IsReferenceWrapper, bool IsBindEx, bool IsPh, class _TupleUj>
123template <class _Ti, bool _IsReferenceWrapper, bool _IsBindEx, bool _IsPh, class _TupleUj>
123124struct __mu_return_impl;
124125
125126template <bool _Invokable, class _Ti, class... _Uj>
......@@ -224,8 +225,8 @@ public:
224225
225226 template <class... _Args>
226227 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
227 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
228 operator()(_Args&&... __args) const {
228 typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
229 operator()(_Args&&... __args) const {
229230 return std::__apply_functor(__f_, __bound_args_, __indices(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
230231 }
231232};
lib/libcxx/include/__functional/bind_back.h+15-1
......@@ -52,7 +52,7 @@ struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>
5252
5353template <class _Fn, class... _Args>
5454 requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
55 (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
55 (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
5656_LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept(
5757 noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
5858 std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...))))
......@@ -62,6 +62,20 @@ _LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) n
6262 std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...));
6363}
6464
65# if _LIBCPP_STD_VER >= 23
66template <class _Fn, class... _Args>
67_LIBCPP_HIDE_FROM_ABI constexpr auto bind_back(_Fn&& __f, _Args&&... __args) {
68 static_assert(is_constructible_v<decay_t<_Fn>, _Fn>, "bind_back requires decay_t<F> to be constructible from F");
69 static_assert(is_move_constructible_v<decay_t<_Fn>>, "bind_back requires decay_t<F> to be move constructible");
70 static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...),
71 "bind_back requires all decay_t<Args> to be constructible from respective Args");
72 static_assert((is_move_constructible_v<decay_t<_Args>> && ...),
73 "bind_back requires all decay_t<Args> to be move constructible");
74 return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
75 std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...));
76}
77# endif // _LIBCPP_STD_VER >= 23
78
6579#endif // _LIBCPP_STD_VER >= 20
6680
6781_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__functional/bind_front.h+2-4
......@@ -17,7 +17,6 @@
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_move_constructible.h>
2120#include <__utility/forward.h>
2221
2322#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -30,9 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3029
3130struct __bind_front_op {
3231 template <class... _Args>
33 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const
34 noexcept(noexcept(std::invoke(std::forward<_Args>(__args)...)))
35 -> decltype(std::invoke(std::forward<_Args>(__args)...)) {
32 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept(
33 noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) {
3634 return std::invoke(std::forward<_Args>(__args)...);
3735 }
3836};
lib/libcxx/include/__functional/function.h+23-15
......@@ -28,7 +28,7 @@
2828#include <__type_traits/decay.h>
2929#include <__type_traits/is_core_convertible.h>
3030#include <__type_traits/is_scalar.h>
31#include <__type_traits/is_trivially_copy_constructible.h>
31#include <__type_traits/is_trivially_constructible.h>
3232#include <__type_traits/is_trivially_destructible.h>
3333#include <__type_traits/is_void.h>
3434#include <__type_traits/strip_signature.h>
......@@ -55,7 +55,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
5555// bad_function_call
5656
5757_LIBCPP_DIAGNOSTIC_PUSH
58# if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
5859_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
60# endif
5961class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {
6062public:
6163 _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default;
......@@ -64,7 +66,7 @@ public:
6466// Note that when a key function is not used, every translation unit that uses
6567// bad_function_call will end up containing a weak definition of the vtable and
6668// typeinfo.
67# ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
69# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
6870 ~bad_function_call() _NOEXCEPT override;
6971# else
7072 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}
......@@ -230,10 +232,10 @@ class _LIBCPP_TEMPLATE_VIS __base;
230232
231233template <class _Rp, class... _ArgTypes>
232234class __base<_Rp(_ArgTypes...)> {
233 __base(const __base&);
234 __base& operator=(const __base&);
235
236235public:
236 __base(const __base&) = delete;
237 __base& operator=(const __base&) = delete;
238
237239 _LIBCPP_HIDE_FROM_ABI __base() {}
238240 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
239241 virtual __base* __clone() const = 0;
......@@ -514,7 +516,7 @@ struct __policy {
514516 }
515517
516518 _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() {
517 static const _LIBCPP_CONSTEXPR __policy __policy = {
519 static constexpr __policy __policy = {
518520 nullptr,
519521 nullptr,
520522 true,
......@@ -541,7 +543,7 @@ private:
541543
542544 template <typename _Fun>
543545 _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ false_type) {
544 static const _LIBCPP_CONSTEXPR __policy __policy = {
546 static constexpr __policy __policy = {
545547 &__large_clone<_Fun>,
546548 &__large_destroy<_Fun>,
547549 false,
......@@ -556,7 +558,7 @@ private:
556558
557559 template <typename _Fun>
558560 _LIBCPP_HIDE_FROM_ABI static const __policy* __choose_policy(/* is_small = */ true_type) {
559 static const _LIBCPP_CONSTEXPR __policy __policy = {
561 static constexpr __policy __policy = {
560562 nullptr,
561563 nullptr,
562564 false,
......@@ -768,7 +770,7 @@ public:
768770 {
769771 }
770772
771 virtual __base<_Rp(_ArgTypes...)>* __clone() const {
773 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const {
772774 _LIBCPP_ASSERT_INTERNAL(
773775 false,
774776 "Block pointers are just pointers, so they should always fit into "
......@@ -777,9 +779,11 @@ public:
777779 return nullptr;
778780 }
779781
780 virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { ::new ((void*)__p) __func(__f_); }
782 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
783 ::new ((void*)__p) __func(__f_);
784 }
781785
782 virtual void destroy() _NOEXCEPT {
786 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
783787# ifndef _LIBCPP_HAS_OBJC_ARC
784788 if (__f_)
785789 _Block_release(__f_);
......@@ -787,7 +791,7 @@ public:
787791 __f_ = 0;
788792 }
789793
790 virtual void destroy_deallocate() _NOEXCEPT {
794 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT {
791795 _LIBCPP_ASSERT_INTERNAL(
792796 false,
793797 "Block pointers are just pointers, so they should always fit into "
......@@ -795,16 +799,20 @@ public:
795799 "never be invoked.");
796800 }
797801
798 virtual _Rp operator()(_ArgTypes&&... __arg) { return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...); }
802 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg) {
803 return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...);
804 }
799805
800806# ifndef _LIBCPP_HAS_NO_RTTI
801 virtual const void* target(type_info const& __ti) const _NOEXCEPT {
807 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT {
802808 if (__ti == typeid(__func::__block_type))
803809 return &__f_;
804810 return (const void*)nullptr;
805811 }
806812
807 virtual const std::type_info& target_type() const _NOEXCEPT { return typeid(__func::__block_type); }
813 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT {
814 return typeid(__func::__block_type);
815 }
808816# endif // _LIBCPP_HAS_NO_RTTI
809817};
810818
lib/libcxx/include/__functional/hash.h+4-9
......@@ -10,23 +10,18 @@
1010#define _LIBCPP___FUNCTIONAL_HASH_H
1111
1212#include <__config>
13#include <__functional/invoke.h>
1413#include <__functional/unary_function.h>
15#include <__fwd/hash.h>
16#include <__tuple/sfinae_helpers.h>
17#include <__type_traits/is_copy_constructible.h>
18#include <__type_traits/is_default_constructible.h>
14#include <__fwd/functional.h>
15#include <__type_traits/conjunction.h>
16#include <__type_traits/invoke.h>
17#include <__type_traits/is_constructible.h>
1918#include <__type_traits/is_enum.h>
20#include <__type_traits/is_move_constructible.h>
2119#include <__type_traits/underlying_type.h>
22#include <__utility/forward.h>
23#include <__utility/move.h>
2420#include <__utility/pair.h>
2521#include <__utility/swap.h>
2622#include <cstddef>
2723#include <cstdint>
2824#include <cstring>
29#include <limits>
3025
3126#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3227# pragma GCC system_header
lib/libcxx/include/__functional/identity.h+2-2
......@@ -11,7 +11,7 @@
1111#define _LIBCPP___FUNCTIONAL_IDENTITY_H
1212
1313#include <__config>
14#include <__functional/reference_wrapper.h>
14#include <__fwd/functional.h>
1515#include <__type_traits/integral_constant.h>
1616#include <__utility/forward.h>
1717
......@@ -44,7 +44,7 @@ struct __is_identity<reference_wrapper<const __identity> > : true_type {};
4444
4545struct identity {
4646 template <class _Tp>
47 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept {
47 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept {
4848 return std::forward<_Tp>(__t);
4949 }
5050
lib/libcxx/include/__functional/is_transparent.h+2-3
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
1212
1313#include <__config>
14#include <__type_traits/integral_constant.h>
1514#include <__type_traits/void_t.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -23,10 +22,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2322#if _LIBCPP_STD_VER >= 14
2423
2524template <class _Tp, class, class = void>
26struct __is_transparent : false_type {};
25inline const bool __is_transparent_v = false;
2726
2827template <class _Tp, class _Up>
29struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> > : true_type {};
28inline const bool __is_transparent_v<_Tp, _Up, __void_t<typename _Tp::is_transparent> > = true;
3029
3130#endif
3231
lib/libcxx/include/__functional/mem_fn.h+2-2
......@@ -38,8 +38,8 @@ public:
3838 template <class... _ArgTypes>
3939 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
4040
41 typename __invoke_return<type, _ArgTypes...>::type
42 operator()(_ArgTypes&&... __args) const {
41 typename __invoke_return<type, _ArgTypes...>::type
42 operator()(_ArgTypes&&... __args) const {
4343 return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
4444 }
4545};
lib/libcxx/include/__functional/mem_fun_ref.h+2-2
......@@ -89,8 +89,8 @@ public:
8989};
9090
9191template <class _Sp, class _Tp, class _Ap>
92class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
93 : public __binary_function<const _Tp*, _Ap, _Sp> {
92class _LIBCPP_TEMPLATE_VIS
93_LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> {
9494 _Sp (_Tp::*__p_)(_Ap) const;
9595
9696public:
lib/libcxx/include/__functional/not_fn.h-1
......@@ -16,7 +16,6 @@
1616#include <__type_traits/decay.h>
1717#include <__type_traits/enable_if.h>
1818#include <__type_traits/is_constructible.h>
19#include <__type_traits/is_move_constructible.h>
2019#include <__utility/forward.h>
2120
2221#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__functional/operations.h+49-41
......@@ -13,8 +13,7 @@
1313#include <__config>
1414#include <__functional/binary_function.h>
1515#include <__functional/unary_function.h>
16#include <__type_traits/integral_constant.h>
17#include <__type_traits/operation_traits.h>
16#include <__type_traits/desugars_to.h>
1817#include <__utility/forward.h>
1918
2019#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -41,18 +40,18 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
4140// The non-transparent std::plus specialization is only equivalent to a raw plus
4241// operator when we don't perform an implicit conversion when calling it.
4342template <class _Tp>
44struct __desugars_to<__plus_tag, plus<_Tp>, _Tp, _Tp> : true_type {};
43inline const bool __desugars_to_v<__plus_tag, plus<_Tp>, _Tp, _Tp> = true;
4544
4645template <class _Tp, class _Up>
47struct __desugars_to<__plus_tag, plus<void>, _Tp, _Up> : true_type {};
46inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;
4847
4948#if _LIBCPP_STD_VER >= 14
5049template <>
5150struct _LIBCPP_TEMPLATE_VIS plus<void> {
5251 template <class _T1, class _T2>
5352 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
54 noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u)))
55 -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) {
53 noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //
54 -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) {
5655 return std::forward<_T1>(__t) + std::forward<_T2>(__u);
5756 }
5857 typedef void is_transparent;
......@@ -77,8 +76,8 @@ template <>
7776struct _LIBCPP_TEMPLATE_VIS minus<void> {
7877 template <class _T1, class _T2>
7978 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
80 noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u)))
81 -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) {
79 noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //
80 -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) {
8281 return std::forward<_T1>(__t) - std::forward<_T2>(__u);
8382 }
8483 typedef void is_transparent;
......@@ -103,8 +102,8 @@ template <>
103102struct _LIBCPP_TEMPLATE_VIS multiplies<void> {
104103 template <class _T1, class _T2>
105104 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
106 noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u)))
107 -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) {
105 noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //
106 -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) {
108107 return std::forward<_T1>(__t) * std::forward<_T2>(__u);
109108 }
110109 typedef void is_transparent;
......@@ -129,8 +128,8 @@ template <>
129128struct _LIBCPP_TEMPLATE_VIS divides<void> {
130129 template <class _T1, class _T2>
131130 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
132 noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u)))
133 -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) {
131 noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //
132 -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) {
134133 return std::forward<_T1>(__t) / std::forward<_T2>(__u);
135134 }
136135 typedef void is_transparent;
......@@ -155,8 +154,8 @@ template <>
155154struct _LIBCPP_TEMPLATE_VIS modulus<void> {
156155 template <class _T1, class _T2>
157156 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
158 noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u)))
159 -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) {
157 noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //
158 -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) {
160159 return std::forward<_T1>(__t) % std::forward<_T2>(__u);
161160 }
162161 typedef void is_transparent;
......@@ -179,7 +178,8 @@ template <>
179178struct _LIBCPP_TEMPLATE_VIS negate<void> {
180179 template <class _Tp>
181180 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
182 noexcept(noexcept(-std::forward<_Tp>(__x))) -> decltype(-std::forward<_Tp>(__x)) {
181 noexcept(noexcept(-std::forward<_Tp>(__x))) //
182 -> decltype(-std::forward<_Tp>(__x)) {
183183 return -std::forward<_Tp>(__x);
184184 }
185185 typedef void is_transparent;
......@@ -206,8 +206,8 @@ template <>
206206struct _LIBCPP_TEMPLATE_VIS bit_and<void> {
207207 template <class _T1, class _T2>
208208 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
209 noexcept(noexcept(std::forward<_T1>(__t) & std::forward<_T2>(__u)))
210 -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) {
209 noexcept(noexcept(std::forward<_T1>(__t) &
210 std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) {
211211 return std::forward<_T1>(__t) & std::forward<_T2>(__u);
212212 }
213213 typedef void is_transparent;
......@@ -225,7 +225,8 @@ template <>
225225struct _LIBCPP_TEMPLATE_VIS bit_not<void> {
226226 template <class _Tp>
227227 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
228 noexcept(noexcept(~std::forward<_Tp>(__x))) -> decltype(~std::forward<_Tp>(__x)) {
228 noexcept(noexcept(~std::forward<_Tp>(__x))) //
229 -> decltype(~std::forward<_Tp>(__x)) {
229230 return ~std::forward<_Tp>(__x);
230231 }
231232 typedef void is_transparent;
......@@ -250,8 +251,8 @@ template <>
250251struct _LIBCPP_TEMPLATE_VIS bit_or<void> {
251252 template <class _T1, class _T2>
252253 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
253 noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u)))
254 -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) {
254 noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //
255 -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) {
255256 return std::forward<_T1>(__t) | std::forward<_T2>(__u);
256257 }
257258 typedef void is_transparent;
......@@ -276,8 +277,8 @@ template <>
276277struct _LIBCPP_TEMPLATE_VIS bit_xor<void> {
277278 template <class _T1, class _T2>
278279 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
279 noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)))
280 -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) {
280 noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //
281 -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) {
281282 return std::forward<_T1>(__t) ^ std::forward<_T2>(__u);
282283 }
283284 typedef void is_transparent;
......@@ -304,8 +305,8 @@ template <>
304305struct _LIBCPP_TEMPLATE_VIS equal_to<void> {
305306 template <class _T1, class _T2>
306307 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
307 noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u)))
308 -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) {
308 noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //
309 -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) {
309310 return std::forward<_T1>(__t) == std::forward<_T2>(__u);
310311 }
311312 typedef void is_transparent;
......@@ -315,11 +316,11 @@ struct _LIBCPP_TEMPLATE_VIS equal_to<void> {
315316// The non-transparent std::equal_to specialization is only equivalent to a raw equality
316317// comparison when we don't perform an implicit conversion when calling it.
317318template <class _Tp>
318struct __desugars_to<__equal_tag, equal_to<_Tp>, _Tp, _Tp> : true_type {};
319inline const bool __desugars_to_v<__equal_tag, equal_to<_Tp>, _Tp, _Tp> = true;
319320
320321// In the transparent case, we do not enforce that
321322template <class _Tp, class _Up>
322struct __desugars_to<__equal_tag, equal_to<void>, _Tp, _Up> : true_type {};
323inline const bool __desugars_to_v<__equal_tag, equal_to<void>, _Tp, _Up> = true;
323324
324325#if _LIBCPP_STD_VER >= 14
325326template <class _Tp = void>
......@@ -339,8 +340,8 @@ template <>
339340struct _LIBCPP_TEMPLATE_VIS not_equal_to<void> {
340341 template <class _T1, class _T2>
341342 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
342 noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u)))
343 -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) {
343 noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //
344 -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) {
344345 return std::forward<_T1>(__t) != std::forward<_T2>(__u);
345346 }
346347 typedef void is_transparent;
......@@ -360,17 +361,23 @@ struct _LIBCPP_TEMPLATE_VIS less : __binary_function<_Tp, _Tp, bool> {
360361};
361362_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
362363
364template <class _Tp>
365inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true;
366
363367#if _LIBCPP_STD_VER >= 14
364368template <>
365369struct _LIBCPP_TEMPLATE_VIS less<void> {
366370 template <class _T1, class _T2>
367371 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
368 noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u)))
369 -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) {
372 noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //
373 -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) {
370374 return std::forward<_T1>(__t) < std::forward<_T2>(__u);
371375 }
372376 typedef void is_transparent;
373377};
378
379template <class _Tp>
380inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Tp> = true;
374381#endif
375382
376383#if _LIBCPP_STD_VER >= 14
......@@ -391,8 +398,8 @@ template <>
391398struct _LIBCPP_TEMPLATE_VIS less_equal<void> {
392399 template <class _T1, class _T2>
393400 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
394 noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u)))
395 -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) {
401 noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //
402 -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) {
396403 return std::forward<_T1>(__t) <= std::forward<_T2>(__u);
397404 }
398405 typedef void is_transparent;
......@@ -417,8 +424,8 @@ template <>
417424struct _LIBCPP_TEMPLATE_VIS greater_equal<void> {
418425 template <class _T1, class _T2>
419426 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
420 noexcept(noexcept(std::forward<_T1>(__t) >= std::forward<_T2>(__u)))
421 -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) {
427 noexcept(noexcept(std::forward<_T1>(__t) >=
428 std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) {
422429 return std::forward<_T1>(__t) >= std::forward<_T2>(__u);
423430 }
424431 typedef void is_transparent;
......@@ -443,8 +450,8 @@ template <>
443450struct _LIBCPP_TEMPLATE_VIS greater<void> {
444451 template <class _T1, class _T2>
445452 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
446 noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u)))
447 -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) {
453 noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //
454 -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) {
448455 return std::forward<_T1>(__t) > std::forward<_T2>(__u);
449456 }
450457 typedef void is_transparent;
......@@ -471,8 +478,8 @@ template <>
471478struct _LIBCPP_TEMPLATE_VIS logical_and<void> {
472479 template <class _T1, class _T2>
473480 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
474 noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u)))
475 -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) {
481 noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //
482 -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) {
476483 return std::forward<_T1>(__t) && std::forward<_T2>(__u);
477484 }
478485 typedef void is_transparent;
......@@ -495,7 +502,8 @@ template <>
495502struct _LIBCPP_TEMPLATE_VIS logical_not<void> {
496503 template <class _Tp>
497504 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
498 noexcept(noexcept(!std::forward<_Tp>(__x))) -> decltype(!std::forward<_Tp>(__x)) {
505 noexcept(noexcept(!std::forward<_Tp>(__x))) //
506 -> decltype(!std::forward<_Tp>(__x)) {
499507 return !std::forward<_Tp>(__x);
500508 }
501509 typedef void is_transparent;
......@@ -520,8 +528,8 @@ template <>
520528struct _LIBCPP_TEMPLATE_VIS logical_or<void> {
521529 template <class _T1, class _T2>
522530 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
523 noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u)))
524 -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) {
531 noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //
532 -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) {
525533 return std::forward<_T1>(__t) || std::forward<_T2>(__u);
526534 }
527535 typedef void is_transparent;
lib/libcxx/include/__functional/pointer_to_binary_function.h+2-2
......@@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
2424template <class _Arg1, class _Arg2, class _Result>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
26 : public __binary_function<_Arg1, _Arg2, _Result> {
25class _LIBCPP_TEMPLATE_VIS
26_LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> {
2727 _Result (*__f_)(_Arg1, _Arg2);
2828
2929public:
lib/libcxx/include/__functional/pointer_to_unary_function.h+2-2
......@@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
2323
2424template <class _Arg, class _Result>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
26 : public __unary_function<_Arg, _Result> {
25class _LIBCPP_TEMPLATE_VIS
26_LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
2727 _Result (*__f_)(_Arg);
2828
2929public:
lib/libcxx/include/__functional/ranges_operations.h+5-3
......@@ -13,8 +13,7 @@
1313#include <__concepts/equality_comparable.h>
1414#include <__concepts/totally_ordered.h>
1515#include <__config>
16#include <__type_traits/integral_constant.h>
17#include <__type_traits/operation_traits.h>
16#include <__type_traits/desugars_to.h>
1817#include <__utility/forward.h>
1918
2019#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -98,7 +97,10 @@ struct greater_equal {
9897// For ranges we do not require that the types on each side of the equality
9998// operator are of the same type
10099template <class _Tp, class _Up>
101struct __desugars_to<__equal_tag, ranges::equal_to, _Tp, _Up> : true_type {};
100inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;
101
102template <class _Tp, class _Up>
103inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;
102104
103105#endif // _LIBCPP_STD_VER >= 20
104106
lib/libcxx/include/__functional/reference_wrapper.h+56-4
......@@ -10,12 +10,16 @@
1010#ifndef _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1111#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
1212
13#include <__compare/synth_three_way.h>
14#include <__concepts/boolean_testable.h>
1315#include <__config>
1416#include <__functional/invoke.h>
1517#include <__functional/weak_result_type.h>
1618#include <__memory/addressof.h>
1719#include <__type_traits/enable_if.h>
20#include <__type_traits/is_const.h>
1821#include <__type_traits/remove_cvref.h>
22#include <__type_traits/void_t.h>
1923#include <__utility/declval.h>
2024#include <__utility/forward.h>
2125
......@@ -35,12 +39,12 @@ private:
3539 type* __f_;
3640
3741 static void __fun(_Tp&) _NOEXCEPT;
38 static void __fun(_Tp&&) = delete;
42 static void __fun(_Tp&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276
3943
4044public:
41 template <
42 class _Up,
43 class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
45 template <class _Up,
46 class = __void_t<decltype(__fun(std::declval<_Up>()))>,
47 __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, int> = 0>
4448 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u)
4549 _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
4650 type& __f = static_cast<_Up&&>(__u);
......@@ -63,6 +67,54 @@ public:
6367 {
6468 return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
6569 }
70
71#if _LIBCPP_STD_VER >= 26
72
73 // [refwrap.comparisons], comparisons
74
75 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
76 requires requires {
77 { __x.get() == __y.get() } -> __boolean_testable;
78 }
79 {
80 return __x.get() == __y.get();
81 }
82
83 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
84 requires requires {
85 { __x.get() == __y } -> __boolean_testable;
86 }
87 {
88 return __x.get() == __y;
89 }
90
91 _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
92 requires(!is_const_v<_Tp>) && requires {
93 { __x.get() == __y.get() } -> __boolean_testable;
94 }
95 {
96 return __x.get() == __y.get();
97 }
98
99 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y)
100 requires requires { std::__synth_three_way(__x.get(), __y.get()); }
101 {
102 return std::__synth_three_way(__x.get(), __y.get());
103 }
104
105 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y)
106 requires requires { std::__synth_three_way(__x.get(), __y); }
107 {
108 return std::__synth_three_way(__x.get(), __y);
109 }
110
111 _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y)
112 requires(!is_const_v<_Tp>) && requires { std::__synth_three_way(__x.get(), __y.get()); }
113 {
114 return std::__synth_three_way(__x.get(), __y.get());
115 }
116
117#endif // _LIBCPP_STD_VER >= 26
66118};
67119
68120#if _LIBCPP_STD_VER >= 17
lib/libcxx/include/__functional/unary_negate.h+2-2
......@@ -22,8 +22,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
2323
2424template <class _Predicate>
25class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
26 : public __unary_function<typename _Predicate::argument_type, bool> {
25class _LIBCPP_TEMPLATE_VIS
26_LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
2727 _Predicate __pred_;
2828
2929public:
lib/libcxx/include/__fwd/array.h+20
......@@ -21,6 +21,26 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2121template <class _Tp, size_t _Size>
2222struct _LIBCPP_TEMPLATE_VIS array;
2323
24template <size_t _Ip, class _Tp, size_t _Size>
25_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT;
26
27template <size_t _Ip, class _Tp, size_t _Size>
28_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT;
29
30#ifndef _LIBCPP_CXX03_LANG
31template <size_t _Ip, class _Tp, size_t _Size>
32_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT;
33
34template <size_t _Ip, class _Tp, size_t _Size>
35_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
36#endif
37
38template <class>
39struct __is_std_array : false_type {};
40
41template <class _Tp, size_t _Size>
42struct __is_std_array<array<_Tp, _Size> > : true_type {};
43
2444_LIBCPP_END_NAMESPACE_STD
2545
2646#endif // _LIBCPP___FWD_ARRAY_H
lib/libcxx/include/__fwd/complex.h created+42
......@@ -0,0 +1,42 @@
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_COMPLEX_H
10#define _LIBCPP___FWD_COMPLEX_H
11
12#include <__config>
13#include <cstddef>
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>
22class _LIBCPP_TEMPLATE_VIS complex;
23
24#if _LIBCPP_STD_VER >= 26
25
26template <size_t _Ip, class _Tp>
27_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(complex<_Tp>&) noexcept;
28
29template <size_t _Ip, class _Tp>
30_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(complex<_Tp>&&) noexcept;
31
32template <size_t _Ip, class _Tp>
33_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const complex<_Tp>&) noexcept;
34
35template <size_t _Ip, class _Tp>
36_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const complex<_Tp>&&) noexcept;
37
38#endif // _LIBCPP_STD_VER >= 26
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP___FWD_COMPLEX_H
lib/libcxx/include/__fwd/deque.h created+26
......@@ -0,0 +1,26 @@
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_DEQUE_H
10#define _LIBCPP___FWD_DEQUE_H
11
12#include <__config>
13#include <__fwd/memory.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 _Allocator = allocator<_Tp> >
22class _LIBCPP_TEMPLATE_VIS deque;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___FWD_DEQUE_H
lib/libcxx/include/__fwd/format.h created+38
......@@ -0,0 +1,38 @@
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___FWD_FORMAT_H
11#define _LIBCPP___FWD_FORMAT_H
12
13#include <__config>
14#include <__iterator/concepts.h>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22#if _LIBCPP_STD_VER >= 20
23
24template <class _Context>
25class _LIBCPP_TEMPLATE_VIS basic_format_arg;
26
27template <class _OutIt, class _CharT>
28 requires output_iterator<_OutIt, const _CharT&>
29class _LIBCPP_TEMPLATE_VIS basic_format_context;
30
31template <class _Tp, class _CharT = char>
32struct _LIBCPP_TEMPLATE_VIS formatter;
33
34#endif //_LIBCPP_STD_VER >= 20
35
36_LIBCPP_END_NAMESPACE_STD
37
38#endif // _LIBCPP___FWD_FORMAT_H
lib/libcxx/include/__fwd/functional.h created+28
......@@ -0,0 +1,28 @@
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_FUNCTIONAL_H
10#define _LIBCPP___FWD_FUNCTIONAL_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>
21struct _LIBCPP_TEMPLATE_VIS hash;
22
23template <class>
24class _LIBCPP_TEMPLATE_VIS reference_wrapper;
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP___FWD_FUNCTIONAL_H
lib/libcxx/include/__fwd/get.h deleted-99
......@@ -1,99 +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_GET_H
10#define _LIBCPP___FWD_GET_H
11
12#include <__concepts/copyable.h>
13#include <__config>
14#include <__fwd/array.h>
15#include <__fwd/pair.h>
16#include <__fwd/subrange.h>
17#include <__fwd/tuple.h>
18#include <__tuple/tuple_element.h>
19#include <cstddef>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#ifndef _LIBCPP_CXX03_LANG
28
29template <size_t _Ip, class... _Tp>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
31get(tuple<_Tp...>&) _NOEXCEPT;
32
33template <size_t _Ip, class... _Tp>
34_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
35get(const tuple<_Tp...>&) _NOEXCEPT;
36
37template <size_t _Ip, class... _Tp>
38_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
39get(tuple<_Tp...>&&) _NOEXCEPT;
40
41template <size_t _Ip, class... _Tp>
42_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
43get(const tuple<_Tp...>&&) _NOEXCEPT;
44
45#endif //_LIBCPP_CXX03_LANG
46
47template <size_t _Ip, class _T1, class _T2>
48_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
49get(pair<_T1, _T2>&) _NOEXCEPT;
50
51template <size_t _Ip, class _T1, class _T2>
52_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
53get(const pair<_T1, _T2>&) _NOEXCEPT;
54
55#ifndef _LIBCPP_CXX03_LANG
56template <size_t _Ip, class _T1, class _T2>
57_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
58get(pair<_T1, _T2>&&) _NOEXCEPT;
59
60template <size_t _Ip, class _T1, class _T2>
61_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
62get(const pair<_T1, _T2>&&) _NOEXCEPT;
63#endif
64
65template <size_t _Ip, class _Tp, size_t _Size>
66_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>&) _NOEXCEPT;
67
68template <size_t _Ip, class _Tp, size_t _Size>
69_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>&) _NOEXCEPT;
70
71#ifndef _LIBCPP_CXX03_LANG
72template <size_t _Ip, class _Tp, size_t _Size>
73_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT;
74
75template <size_t _Ip, class _Tp, size_t _Size>
76_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&&) _NOEXCEPT;
77#endif
78
79#if _LIBCPP_STD_VER >= 20
80
81namespace ranges {
82
83template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
84 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
85_LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>& __subrange);
86
87template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
88 requires(_Index < 2)
89_LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&& __subrange);
90
91} // namespace ranges
92
93using ranges::get;
94
95#endif // _LIBCPP_STD_VER >= 20
96
97_LIBCPP_END_NAMESPACE_STD
98
99#endif // _LIBCPP___FWD_GET_H
lib/libcxx/include/__fwd/hash.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___FWD_HASH_H
10#define _LIBCPP___FWD_HASH_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>
21struct _LIBCPP_TEMPLATE_VIS hash;
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___FWD_HASH_H
lib/libcxx/include/__fwd/ios.h+2
......@@ -18,6 +18,8 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21class _LIBCPP_EXPORTED_FROM_ABI ios_base;
22
2123template <class _CharT, class _Traits = char_traits<_CharT> >
2224class _LIBCPP_TEMPLATE_VIS basic_ios;
2325
lib/libcxx/include/__fwd/memory.h created+25
......@@ -0,0 +1,25 @@
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_MEMORY_H
10#define _LIBCPP___FWD_MEMORY_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>
21class _LIBCPP_TEMPLATE_VIS allocator;
22
23_LIBCPP_END_NAMESPACE_STD
24
25#endif // _LIBCPP___FWD_MEMORY_H
lib/libcxx/include/__fwd/memory_resource.h-1
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H
1010#define _LIBCPP___FWD_MEMORY_RESOURCE_H
1111
12#include <__availability>
1312#include <__config>
1413
1514#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__fwd/pair.h+20
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___FWD_PAIR_H
1111
1212#include <__config>
13#include <__fwd/tuple.h>
14#include <cstddef>
1315
1416#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1517# pragma GCC system_header
......@@ -20,6 +22,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2022template <class, class>
2123struct _LIBCPP_TEMPLATE_VIS pair;
2224
25template <size_t _Ip, class _T1, class _T2>
26_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&
27get(pair<_T1, _T2>&) _NOEXCEPT;
28
29template <size_t _Ip, class _T1, class _T2>
30_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&
31get(const pair<_T1, _T2>&) _NOEXCEPT;
32
33#ifndef _LIBCPP_CXX03_LANG
34template <size_t _Ip, class _T1, class _T2>
35_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
36get(pair<_T1, _T2>&&) _NOEXCEPT;
37
38template <size_t _Ip, class _T1, class _T2>
39_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, pair<_T1, _T2> >::type&&
40get(const pair<_T1, _T2>&&) _NOEXCEPT;
41#endif
42
2343_LIBCPP_END_NAMESPACE_STD
2444
2545#endif // _LIBCPP___FWD_PAIR_H
lib/libcxx/include/__fwd/queue.h created+31
......@@ -0,0 +1,31 @@
1//===---------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===---------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___FWD_QUEUE_H
10#define _LIBCPP___FWD_QUEUE_H
11
12#include <__config>
13#include <__functional/operations.h>
14#include <__fwd/deque.h>
15#include <__fwd/vector.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, class _Container = deque<_Tp> >
24class _LIBCPP_TEMPLATE_VIS queue;
25
26template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> >
27class _LIBCPP_TEMPLATE_VIS priority_queue;
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___FWD_QUEUE_H
lib/libcxx/include/__fwd/sstream.h+1
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___FWD_SSTREAM_H
1111
1212#include <__config>
13#include <__fwd/memory.h>
1314#include <__fwd/string.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__fwd/stack.h created+26
......@@ -0,0 +1,26 @@
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_STACK_H
10#define _LIBCPP___FWD_STACK_H
11
12#include <__config>
13#include <__fwd/deque.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 _Container = deque<_Tp> >
22class _LIBCPP_TEMPLATE_VIS stack;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___FWD_STACK_H
lib/libcxx/include/__fwd/string.h+1-4
......@@ -9,8 +9,8 @@
99#ifndef _LIBCPP___FWD_STRING_H
1010#define _LIBCPP___FWD_STRING_H
1111
12#include <__availability>
1312#include <__config>
13#include <__fwd/memory.h>
1414#include <__fwd/memory_resource.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -39,9 +39,6 @@ template <>
3939struct char_traits<wchar_t>;
4040#endif
4141
42template <class _Tp>
43class _LIBCPP_TEMPLATE_VIS allocator;
44
4542template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> >
4643class _LIBCPP_TEMPLATE_VIS basic_string;
4744
lib/libcxx/include/__fwd/subrange.h+13-2
......@@ -9,7 +9,10 @@
99#ifndef _LIBCPP___FWD_SUBRANGE_H
1010#define _LIBCPP___FWD_SUBRANGE_H
1111
12#include <__concepts/copyable.h>
1213#include <__config>
14#include <__iterator/concepts.h>
15#include <cstddef>
1316
1417#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1518# pragma GCC system_header
......@@ -17,8 +20,6 @@
1720
1821#if _LIBCPP_STD_VER >= 20
1922
20# include <__iterator/concepts.h>
21
2223_LIBCPP_BEGIN_NAMESPACE_STD
2324
2425namespace ranges {
......@@ -29,8 +30,18 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent, subrange_ki
2930 requires(_Kind == subrange_kind::sized || !sized_sentinel_for<_Sent, _Iter>)
3031class _LIBCPP_TEMPLATE_VIS subrange;
3132
33template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
34 requires((_Index == 0 && copyable<_Iter>) || _Index == 1)
35_LIBCPP_HIDE_FROM_ABI constexpr auto get(const subrange<_Iter, _Sent, _Kind>&);
36
37template <size_t _Index, class _Iter, class _Sent, subrange_kind _Kind>
38 requires(_Index < 2)
39_LIBCPP_HIDE_FROM_ABI constexpr auto get(subrange<_Iter, _Sent, _Kind>&&);
40
3241} // namespace ranges
3342
43using ranges::get;
44
3445_LIBCPP_END_NAMESPACE_STD
3546
3647#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__fwd/tuple.h+23
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___FWD_TUPLE_H
1111
1212#include <__config>
13#include <cstddef>
1314
1415#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1516# pragma GCC system_header
......@@ -17,11 +18,33 @@
1718
1819_LIBCPP_BEGIN_NAMESPACE_STD
1920
21template <size_t, class>
22struct _LIBCPP_TEMPLATE_VIS tuple_element;
23
2024#ifndef _LIBCPP_CXX03_LANG
2125
2226template <class...>
2327class _LIBCPP_TEMPLATE_VIS tuple;
2428
29template <class>
30struct _LIBCPP_TEMPLATE_VIS tuple_size;
31
32template <size_t _Ip, class... _Tp>
33_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&
34get(tuple<_Tp...>&) _NOEXCEPT;
35
36template <size_t _Ip, class... _Tp>
37_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&
38get(const tuple<_Tp...>&) _NOEXCEPT;
39
40template <size_t _Ip, class... _Tp>
41_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename tuple_element<_Ip, tuple<_Tp...> >::type&&
42get(tuple<_Tp...>&&) _NOEXCEPT;
43
44template <size_t _Ip, class... _Tp>
45_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const typename tuple_element<_Ip, tuple<_Tp...> >::type&&
46get(const tuple<_Tp...>&&) _NOEXCEPT;
47
2548#endif // _LIBCPP_CXX03_LANG
2649
2750_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__fwd/vector.h created+26
......@@ -0,0 +1,26 @@
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_VECTOR_H
10#define _LIBCPP___FWD_VECTOR_H
11
12#include <__config>
13#include <__fwd/memory.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 _Alloc = allocator<_Tp> >
22class _LIBCPP_TEMPLATE_VIS vector;
23
24_LIBCPP_END_NAMESPACE_STD
25
26#endif // _LIBCPP___FWD_VECTOR_H
lib/libcxx/include/__hash_table+54-26
......@@ -28,12 +28,9 @@
2828#include <__type_traits/can_extract_key.h>
2929#include <__type_traits/conditional.h>
3030#include <__type_traits/is_const.h>
31#include <__type_traits/is_copy_constructible.h>
31#include <__type_traits/is_constructible.h>
32#include <__type_traits/is_nothrow_assignable.h>
3233#include <__type_traits/is_nothrow_constructible.h>
33#include <__type_traits/is_nothrow_copy_constructible.h>
34#include <__type_traits/is_nothrow_default_constructible.h>
35#include <__type_traits/is_nothrow_move_assignable.h>
36#include <__type_traits/is_nothrow_move_constructible.h>
3734#include <__type_traits/is_pointer.h>
3835#include <__type_traits/is_reference.h>
3936#include <__type_traits/is_swappable.h>
......@@ -243,9 +240,9 @@ public:
243240
244241private:
245242 static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");
246 static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
243 static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value,
247244 "_VoidPtr does not point to unqualified void type");
248 static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value),
245 static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value,
249246 "_VoidPtr does not rebind to _NodePtr.");
250247};
251248
......@@ -284,13 +281,21 @@ public:
284281
285282 _LIBCPP_HIDE_FROM_ABI __hash_iterator() _NOEXCEPT : __node_(nullptr) {}
286283
287 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); }
284 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
285 _LIBCPP_ASSERT_NON_NULL(
286 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container iterator");
287 return __node_->__upcast()->__get_value();
288 }
288289
289290 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
291 _LIBCPP_ASSERT_NON_NULL(
292 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container iterator");
290293 return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value());
291294 }
292295
293296 _LIBCPP_HIDE_FROM_ABI __hash_iterator& operator++() {
297 _LIBCPP_ASSERT_NON_NULL(
298 __node_ != nullptr, "Attempted to increment a non-incrementable unordered container iterator");
294299 __node_ = __node_->__next_;
295300 return *this;
296301 }
......@@ -345,12 +350,20 @@ public:
345350
346351 _LIBCPP_HIDE_FROM_ABI __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) {}
347352
348 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); }
353 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
354 _LIBCPP_ASSERT_NON_NULL(
355 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_iterator");
356 return __node_->__upcast()->__get_value();
357 }
349358 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
359 _LIBCPP_ASSERT_NON_NULL(
360 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_iterator");
350361 return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value());
351362 }
352363
353364 _LIBCPP_HIDE_FROM_ABI __hash_const_iterator& operator++() {
365 _LIBCPP_ASSERT_NON_NULL(
366 __node_ != nullptr, "Attempted to increment a non-incrementable unordered container const_iterator");
354367 __node_ = __node_->__next_;
355368 return *this;
356369 }
......@@ -400,13 +413,21 @@ public:
400413
401414 _LIBCPP_HIDE_FROM_ABI __hash_local_iterator() _NOEXCEPT : __node_(nullptr) {}
402415
403 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); }
416 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
417 _LIBCPP_ASSERT_NON_NULL(
418 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
419 return __node_->__upcast()->__get_value();
420 }
404421
405422 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
423 _LIBCPP_ASSERT_NON_NULL(
424 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container local_iterator");
406425 return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value());
407426 }
408427
409428 _LIBCPP_HIDE_FROM_ABI __hash_local_iterator& operator++() {
429 _LIBCPP_ASSERT_NON_NULL(
430 __node_ != nullptr, "Attempted to increment a non-incrementable unordered container local_iterator");
410431 __node_ = __node_->__next_;
411432 if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
412433 __node_ = nullptr;
......@@ -475,13 +496,21 @@ public:
475496 __bucket_(__x.__bucket_),
476497 __bucket_count_(__x.__bucket_count_) {}
477498
478 _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __node_->__upcast()->__get_value(); }
499 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
500 _LIBCPP_ASSERT_NON_NULL(
501 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
502 return __node_->__upcast()->__get_value();
503 }
479504
480505 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
506 _LIBCPP_ASSERT_NON_NULL(
507 __node_ != nullptr, "Attempted to dereference a non-dereferenceable unordered container const_local_iterator");
481508 return pointer_traits<pointer>::pointer_to(__node_->__upcast()->__get_value());
482509 }
483510
484511 _LIBCPP_HIDE_FROM_ABI __hash_const_local_iterator& operator++() {
512 _LIBCPP_ASSERT_NON_NULL(
513 __node_ != nullptr, "Attempted to increment a non-incrementable unordered container const_local_iterator");
485514 __node_ = __node_->__next_;
486515 if (__node_ != nullptr && std::__constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_)
487516 __node_ = nullptr;
......@@ -671,11 +700,11 @@ private:
671700 // check for sane allocator pointer rebinding semantics. Rebinding the
672701 // allocator for a new pointer type should be exactly the same as rebinding
673702 // the pointer using 'pointer_traits'.
674 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
703 static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value,
675704 "Allocator does not rebind pointers in a sane manner.");
676705 typedef __rebind_alloc<__node_traits, __first_node> __node_base_allocator;
677706 typedef allocator_traits<__node_base_allocator> __node_base_traits;
678 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
707 static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value,
679708 "Allocator does not rebind pointers in a sane manner.");
680709
681710private:
......@@ -802,7 +831,7 @@ public:
802831 return __emplace_unique_key_args(_NodeTypes::__get_key(__x), std::move(__x));
803832 }
804833
805 template <class _Pp, class = __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value> >
834 template <class _Pp, __enable_if_t<!__is_same_uncvref<_Pp, __container_value_type>::value, int> = 0>
806835 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Pp&& __x) {
807836 return __emplace_unique(std::forward<_Pp>(__x));
808837 }
......@@ -899,13 +928,12 @@ public:
899928
900929 _LIBCPP_HIDE_FROM_ABI void swap(__hash_table& __u)
901930#if _LIBCPP_STD_VER <= 11
902 _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value &&
931 _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
903932 (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
904 __is_nothrow_swappable<__pointer_allocator>::value) &&
905 (!__node_traits::propagate_on_container_swap::value ||
906 __is_nothrow_swappable<__node_allocator>::value));
933 __is_nothrow_swappable_v<__pointer_allocator>) &&
934 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
907935#else
908 _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value);
936 _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>);
909937#endif
910938
911939 _LIBCPP_HIDE_FROM_ABI size_type max_bucket_count() const _NOEXCEPT { return max_size(); }
......@@ -1072,8 +1100,8 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, const
10721100template <class _Tp, class _Hash, class _Equal, class _Alloc>
10731101__hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() {
10741102#if defined(_LIBCPP_CXX03_LANG)
1075 static_assert((is_copy_constructible<key_equal>::value), "Predicate must be copy-constructible.");
1076 static_assert((is_copy_constructible<hasher>::value), "Hasher must be copy-constructible.");
1103 static_assert(is_copy_constructible<key_equal>::value, "Predicate must be copy-constructible.");
1104 static_assert(is_copy_constructible<hasher>::value, "Hasher must be copy-constructible.");
10771105#endif
10781106
10791107 __deallocate_node(__p1_.first().__next_);
......@@ -1199,7 +1227,7 @@ template <class _InputIterator>
11991227void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first, _InputIterator __last) {
12001228 typedef iterator_traits<_InputIterator> _ITraits;
12011229 typedef typename _ITraits::value_type _ItValueType;
1202 static_assert((is_same<_ItValueType, __container_value_type>::value),
1230 static_assert(is_same<_ItValueType, __container_value_type>::value,
12031231 "__assign_unique may only be called with the containers value type");
12041232
12051233 if (bucket_count() != 0) {
......@@ -1956,12 +1984,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi(const _Key& __k) c
19561984template <class _Tp, class _Hash, class _Equal, class _Alloc>
19571985void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
19581986#if _LIBCPP_STD_VER <= 11
1959 _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value &&
1987 _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal> &&
19601988 (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value ||
1961 __is_nothrow_swappable<__pointer_allocator>::value) &&
1962 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value))
1989 __is_nothrow_swappable_v<__pointer_allocator>) &&
1990 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
19631991#else
1964 _NOEXCEPT_(__is_nothrow_swappable<hasher>::value&& __is_nothrow_swappable<key_equal>::value)
1992 _NOEXCEPT_(__is_nothrow_swappable_v<hasher>&& __is_nothrow_swappable_v<key_equal>)
19651993#endif
19661994{
19671995 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
lib/libcxx/include/__iterator/access.h+2-2
......@@ -54,8 +54,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto end(const _Cp& __c) ->
5454# if _LIBCPP_STD_VER >= 14
5555
5656template <class _Cp>
57_LIBCPP_HIDE_FROM_ABI constexpr auto cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c)))
58 -> decltype(std::begin(__c)) {
57_LIBCPP_HIDE_FROM_ABI constexpr auto
58cbegin(const _Cp& __c) noexcept(noexcept(std::begin(__c))) -> decltype(std::begin(__c)) {
5959 return std::begin(__c);
6060}
6161
lib/libcxx/include/__iterator/advance.h+3-3
......@@ -61,7 +61,7 @@ __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type _
6161template < class _InputIter,
6262 class _Distance,
6363 class _IntegralDistance = decltype(std::__convert_to_integral(std::declval<_Distance>())),
64 class = __enable_if_t<is_integral<_IntegralDistance>::value> >
64 __enable_if_t<is_integral<_IntegralDistance>::value, int> = 0>
6565_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void advance(_InputIter& __i, _Distance __orig_n) {
6666 typedef typename iterator_traits<_InputIter>::difference_type _Difference;
6767 _Difference __n = static_cast<_Difference>(std::__convert_to_integral(__orig_n));
......@@ -170,14 +170,14 @@ public:
170170 } else {
171171 // Otherwise, if `n` is non-negative, while `bool(i != bound_sentinel)` is true, increments `i` but at
172172 // most `n` times.
173 while (__i != __bound_sentinel && __n > 0) {
173 while (__n > 0 && __i != __bound_sentinel) {
174174 ++__i;
175175 --__n;
176176 }
177177
178178 // Otherwise, while `bool(i != bound_sentinel)` is true, decrements `i` but at most `-n` times.
179179 if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) {
180 while (__i != __bound_sentinel && __n < 0) {
180 while (__n < 0 && __i != __bound_sentinel) {
181181 --__i;
182182 ++__n;
183183 }
lib/libcxx/include/__iterator/aliasing_iterator.h created+127
......@@ -0,0 +1,127 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___ITERATOR_ALIASING_ITERATOR_H
10#define _LIBCPP___ITERATOR_ALIASING_ITERATOR_H
11
12#include <__config>
13#include <__iterator/iterator_traits.h>
14#include <__memory/pointer_traits.h>
15#include <__type_traits/is_trivial.h>
16#include <cstddef>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22// This iterator wrapper is used to type-pun an iterator to return a different type. This is done without UB by not
23// actually punning the type, but instead inspecting the object representation of the base type and copying that into
24// an instance of the alias type. For that reason the alias type has to be trivial. The alias is returned as a prvalue
25// when derferencing the iterator, since it is temporary storage. This wrapper is used to vectorize some algorithms.
26
27_LIBCPP_BEGIN_NAMESPACE_STD
28
29template <class _BaseIter, class _Alias>
30struct __aliasing_iterator_wrapper {
31 class __iterator {
32 _BaseIter __base_ = nullptr;
33
34 using __iter_traits = iterator_traits<_BaseIter>;
35 using __base_value_type = typename __iter_traits::value_type;
36
37 static_assert(__has_random_access_iterator_category<_BaseIter>::value,
38 "The base iterator has to be a random access iterator!");
39
40 public:
41 using iterator_category = random_access_iterator_tag;
42 using value_type = _Alias;
43 using difference_type = ptrdiff_t;
44 using reference = value_type&;
45 using pointer = value_type*;
46
47 static_assert(is_trivial<value_type>::value);
48 static_assert(sizeof(__base_value_type) == sizeof(value_type));
49
50 _LIBCPP_HIDE_FROM_ABI __iterator() = default;
51 _LIBCPP_HIDE_FROM_ABI __iterator(_BaseIter __base) _NOEXCEPT : __base_(__base) {}
52
53 _LIBCPP_HIDE_FROM_ABI __iterator& operator++() _NOEXCEPT {
54 ++__base_;
55 return *this;
56 }
57
58 _LIBCPP_HIDE_FROM_ABI __iterator operator++(int) _NOEXCEPT {
59 __iterator __tmp(*this);
60 ++__base_;
61 return __tmp;
62 }
63
64 _LIBCPP_HIDE_FROM_ABI __iterator& operator--() _NOEXCEPT {
65 --__base_;
66 return *this;
67 }
68
69 _LIBCPP_HIDE_FROM_ABI __iterator operator--(int) _NOEXCEPT {
70 __iterator __tmp(*this);
71 --__base_;
72 return __tmp;
73 }
74
75 _LIBCPP_HIDE_FROM_ABI friend __iterator operator+(__iterator __iter, difference_type __n) _NOEXCEPT {
76 return __iterator(__iter.__base_ + __n);
77 }
78
79 _LIBCPP_HIDE_FROM_ABI friend __iterator operator+(difference_type __n, __iterator __iter) _NOEXCEPT {
80 return __iterator(__n + __iter.__base_);
81 }
82
83 _LIBCPP_HIDE_FROM_ABI __iterator& operator+=(difference_type __n) _NOEXCEPT {
84 __base_ += __n;
85 return *this;
86 }
87
88 _LIBCPP_HIDE_FROM_ABI friend __iterator operator-(__iterator __iter, difference_type __n) _NOEXCEPT {
89 return __iterator(__iter.__base_ - __n);
90 }
91
92 _LIBCPP_HIDE_FROM_ABI friend difference_type operator-(__iterator __lhs, __iterator __rhs) _NOEXCEPT {
93 return __lhs.__base_ - __rhs.__base_;
94 }
95
96 _LIBCPP_HIDE_FROM_ABI __iterator& operator-=(difference_type __n) _NOEXCEPT {
97 __base_ -= __n;
98 return *this;
99 }
100
101 _LIBCPP_HIDE_FROM_ABI _BaseIter __base() const _NOEXCEPT { return __base_; }
102
103 _LIBCPP_HIDE_FROM_ABI _Alias operator*() const _NOEXCEPT {
104 _Alias __val;
105 __builtin_memcpy(&__val, std::__to_address(__base_), sizeof(value_type));
106 return __val;
107 }
108
109 _LIBCPP_HIDE_FROM_ABI value_type operator[](difference_type __n) const _NOEXCEPT { return *(*this + __n); }
110
111 _LIBCPP_HIDE_FROM_ABI friend bool operator==(const __iterator& __lhs, const __iterator& __rhs) _NOEXCEPT {
112 return __lhs.__base_ == __rhs.__base_;
113 }
114
115 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __iterator& __lhs, const __iterator& __rhs) _NOEXCEPT {
116 return __lhs.__base_ != __rhs.__base_;
117 }
118 };
119};
120
121// This is required to avoid ADL instantiations on _BaseT
122template <class _BaseT, class _Alias>
123using __aliasing_iterator = typename __aliasing_iterator_wrapper<_BaseT, _Alias>::__iterator;
124
125_LIBCPP_END_NAMESPACE_STD
126
127#endif // _LIBCPP___ITERATOR_ALIASING_ITERATOR_H
lib/libcxx/include/__iterator/bounded_iter.h+74-27
......@@ -11,6 +11,8 @@
1111#define _LIBCPP___ITERATOR_BOUNDED_ITER_H
1212
1313#include <__assert>
14#include <__compare/ordering.h>
15#include <__compare/three_way_comparable.h>
1416#include <__config>
1517#include <__iterator/iterator_traits.h>
1618#include <__memory/pointer_traits.h>
......@@ -31,13 +33,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3133// Iterator wrapper that carries the valid range it is allowed to access.
3234//
3335// This is a simple iterator wrapper for contiguous iterators that points
34// within a [begin, end) range and carries these bounds with it. The iterator
35// ensures that it is pointing within that [begin, end) range when it is
36// dereferenced.
36// within a [begin, end] range and carries these bounds with it. The iterator
37// ensures that it is pointing within [begin, end) range when it is
38// dereferenced. It also ensures that it is never iterated outside of
39// [begin, end]. This is important for two reasons:
3740//
38// Arithmetic operations are allowed and the bounds of the resulting iterator
39// are not checked. Hence, it is possible to create an iterator pointing outside
40// its range, but it is not possible to dereference it.
41// 1. It allows `operator*` and `operator++` bounds checks to be `iter != end`.
42// This is both less for the optimizer to prove, and aligns with how callers
43// typically use iterators.
44//
45// 2. Advancing an iterator out of bounds is undefined behavior (see the table
46// in [input.iterators]). In particular, when the underlying iterator is a
47// pointer, it is undefined at the language level (see [expr.add]). If
48// bounded iterators exhibited this undefined behavior, we risk compiler
49// optimizations deleting non-redundant bounds checks.
4150template <class _Iterator, class = __enable_if_t< __libcpp_is_contiguous_iterator<_Iterator>::value > >
4251struct __bounded_iter {
4352 using value_type = typename iterator_traits<_Iterator>::value_type;
......@@ -51,14 +60,14 @@ struct __bounded_iter {
5160
5261 // Create a singular iterator.
5362 //
54 // Such an iterator does not point to any object and is conceptually out of bounds, so it is
55 // not dereferenceable. Observing operations like comparison and assignment are valid.
63 // Such an iterator points past the end of an empty span, so it is not dereferenceable.
64 // Observing operations like comparison and assignment are valid.
5665 _LIBCPP_HIDE_FROM_ABI __bounded_iter() = default;
5766
5867 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter const&) = default;
5968 _LIBCPP_HIDE_FROM_ABI __bounded_iter(__bounded_iter&&) = default;
6069
61 template <class _OtherIterator, class = __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value > >
70 template <class _OtherIterator, __enable_if_t< is_convertible<_OtherIterator, _Iterator>::value, int> = 0>
6271 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __bounded_iter(__bounded_iter<_OtherIterator> const& __other) _NOEXCEPT
6372 : __current_(__other.__current_),
6473 __begin_(__other.__begin_),
......@@ -70,18 +79,20 @@ struct __bounded_iter {
7079
7180private:
7281 // Create an iterator wrapping the given iterator, and whose bounds are described
73 // by the provided [begin, end) range.
82 // by the provided [begin, end] range.
7483 //
75 // This constructor does not check whether the resulting iterator is within its bounds.
76 // However, it does check that the provided [begin, end) range is a valid range (that
77 // is, begin <= end).
84 // The constructor does not check whether the resulting iterator is within its bounds. It is a
85 // responsibility of the container to ensure that the given bounds are valid.
7886 //
7987 // Since it is non-standard for iterators to have this constructor, __bounded_iter must
8088 // be created via `std::__make_bounded_iter`.
81 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter(
82 _Iterator __current, _Iterator __begin, _Iterator __end)
89 _LIBCPP_HIDE_FROM_ABI
90 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __bounded_iter(_Iterator __current, _Iterator __begin, _Iterator __end)
8391 : __current_(__current), __begin_(__begin), __end_(__end) {
84 _LIBCPP_ASSERT_INTERNAL(__begin <= __end, "__bounded_iter(current, begin, end): [begin, end) is not a valid range");
92 _LIBCPP_ASSERT_INTERNAL(
93 __begin <= __current, "__bounded_iter(current, begin, end): current and begin are inconsistent");
94 _LIBCPP_ASSERT_INTERNAL(
95 __current <= __end, "__bounded_iter(current, begin, end): current and end are inconsistent");
8596 }
8697
8798 template <class _It>
......@@ -90,30 +101,37 @@ private:
90101public:
91102 // Dereference and indexing operations.
92103 //
93 // These operations check that the iterator is dereferenceable, that is within [begin, end).
104 // These operations check that the iterator is dereferenceable. Since the class invariant is
105 // that the iterator is always within `[begin, end]`, we only need to check it's not pointing to
106 // `end`. This is easier for the optimizer because it aligns with the `iter != container.end()`
107 // checks that typical callers already use (see
108 // https://github.com/llvm/llvm-project/issues/78829).
94109 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator*() const _NOEXCEPT {
95110 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
96 __in_bounds(__current_), "__bounded_iter::operator*: Attempt to dereference an out-of-range iterator");
111 __current_ != __end_, "__bounded_iter::operator*: Attempt to dereference an iterator at the end");
97112 return *__current_;
98113 }
99114
100115 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pointer operator->() const _NOEXCEPT {
101116 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
102 __in_bounds(__current_), "__bounded_iter::operator->: Attempt to dereference an out-of-range iterator");
117 __current_ != __end_, "__bounded_iter::operator->: Attempt to dereference an iterator at the end");
103118 return std::__to_address(__current_);
104119 }
105120
106121 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 reference operator[](difference_type __n) const _NOEXCEPT {
107122 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
108 __in_bounds(__current_ + __n), "__bounded_iter::operator[]: Attempt to index an iterator out-of-range");
123 __n >= __begin_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator past the start");
124 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
125 __n < __end_ - __current_, "__bounded_iter::operator[]: Attempt to index an iterator at or past the end");
109126 return __current_[__n];
110127 }
111128
112129 // Arithmetic operations.
113130 //
114 // These operations do not check that the resulting iterator is within the bounds, since that
115 // would make it impossible to create a past-the-end iterator.
131 // These operations check that the iterator remains within `[begin, end]`.
116132 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator++() _NOEXCEPT {
133 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
134 __current_ != __end_, "__bounded_iter::operator++: Attempt to advance an iterator past the end");
117135 ++__current_;
118136 return *this;
119137 }
......@@ -124,6 +142,8 @@ public:
124142 }
125143
126144 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator--() _NOEXCEPT {
145 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
146 __current_ != __begin_, "__bounded_iter::operator--: Attempt to rewind an iterator past the start");
127147 --__current_;
128148 return *this;
129149 }
......@@ -134,6 +154,10 @@ public:
134154 }
135155
136156 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator+=(difference_type __n) _NOEXCEPT {
157 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
158 __n >= __begin_ - __current_, "__bounded_iter::operator+=: Attempt to rewind an iterator past the start");
159 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
160 __n <= __end_ - __current_, "__bounded_iter::operator+=: Attempt to advance an iterator past the end");
137161 __current_ += __n;
138162 return *this;
139163 }
......@@ -151,6 +175,10 @@ public:
151175 }
152176
153177 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __bounded_iter& operator-=(difference_type __n) _NOEXCEPT {
178 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
179 __n <= __current_ - __begin_, "__bounded_iter::operator-=: Attempt to rewind an iterator past the start");
180 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
181 __n >= __current_ - __end_, "__bounded_iter::operator-=: Attempt to advance an iterator past the end");
154182 __current_ -= __n;
155183 return *this;
156184 }
......@@ -175,10 +203,15 @@ public:
175203 operator==(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
176204 return __x.__current_ == __y.__current_;
177205 }
206
207#if _LIBCPP_STD_VER <= 17
178208 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
179209 operator!=(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
180210 return __x.__current_ != __y.__current_;
181211 }
212#endif
213
214 // TODO(mordante) disable these overloads in the LLVM 20 release.
182215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR friend bool
183216 operator<(__bounded_iter const& __x, __bounded_iter const& __y) _NOEXCEPT {
184217 return __x.__current_ < __y.__current_;
......@@ -196,16 +229,30 @@ public:
196229 return __x.__current_ >= __y.__current_;
197230 }
198231
199private:
200 // Return whether the given iterator is in the bounds of this __bounded_iter.
201 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __in_bounds(_Iterator const& __iter) const {
202 return __iter >= __begin_ && __iter < __end_;
232#if _LIBCPP_STD_VER >= 20
233 _LIBCPP_HIDE_FROM_ABI constexpr friend strong_ordering
234 operator<=>(__bounded_iter const& __x, __bounded_iter const& __y) noexcept {
235 if constexpr (three_way_comparable<_Iterator, strong_ordering>) {
236 return __x.__current_ <=> __y.__current_;
237 } else {
238 if (__x.__current_ < __y.__current_)
239 return strong_ordering::less;
240
241 if (__x.__current_ == __y.__current_)
242 return strong_ordering::equal;
243
244 return strong_ordering::greater;
245 }
203246 }
247#endif // _LIBCPP_STD_VER >= 20
204248
249private:
205250 template <class>
206251 friend struct pointer_traits;
252 template <class, class>
253 friend struct __bounded_iter;
207254 _Iterator __current_; // current iterator
208 _Iterator __begin_, __end_; // valid range represented as [begin, end)
255 _Iterator __begin_, __end_; // valid range represented as [begin, end]
209256};
210257
211258template <class _It>
lib/libcxx/include/__iterator/common_iterator.h+1-1
......@@ -124,7 +124,7 @@ public:
124124 }
125125
126126 template <class _I2 = _Iter>
127 _LIBCPP_HIDE_FROM_ABI decltype(auto) operator->() const
127 _LIBCPP_HIDE_FROM_ABI auto operator->() const
128128 requires indirectly_readable<const _I2> && (requires(const _I2& __i) {
129129 __i.operator->();
130130 } || is_reference_v<iter_reference_t<_I2>> || constructible_from<iter_value_t<_I2>, iter_reference_t<_I2>>)
lib/libcxx/include/__iterator/concepts.h+6-9
......@@ -177,19 +177,19 @@ concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip
177177template <class _Fp, class _It>
178178concept indirectly_unary_invocable =
179179 indirectly_readable<_It> && copy_constructible<_Fp> && invocable<_Fp&, iter_value_t<_It>&> &&
180 invocable<_Fp&, iter_reference_t<_It>> && invocable<_Fp&, iter_common_reference_t<_It>> &&
180 invocable<_Fp&, iter_reference_t<_It>> &&
181181 common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;
182182
183183template <class _Fp, class _It>
184184concept indirectly_regular_unary_invocable =
185185 indirectly_readable<_It> && copy_constructible<_Fp> && regular_invocable<_Fp&, iter_value_t<_It>&> &&
186 regular_invocable<_Fp&, iter_reference_t<_It>> && regular_invocable<_Fp&, iter_common_reference_t<_It>> &&
186 regular_invocable<_Fp&, iter_reference_t<_It>> &&
187187 common_reference_with< invoke_result_t<_Fp&, iter_value_t<_It>&>, invoke_result_t<_Fp&, iter_reference_t<_It>>>;
188188
189189template <class _Fp, class _It>
190190concept indirect_unary_predicate =
191191 indirectly_readable<_It> && copy_constructible<_Fp> && predicate<_Fp&, iter_value_t<_It>&> &&
192 predicate<_Fp&, iter_reference_t<_It>> && predicate<_Fp&, iter_common_reference_t<_It>>;
192 predicate<_Fp&, iter_reference_t<_It>>;
193193
194194template <class _Fp, class _It1, class _It2>
195195concept indirect_binary_predicate =
......@@ -197,8 +197,7 @@ concept indirect_binary_predicate =
197197 predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
198198 predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
199199 predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
200 predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
201 predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
200 predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
202201
203202template <class _Fp, class _It1, class _It2 = _It1>
204203concept indirect_equivalence_relation =
......@@ -206,8 +205,7 @@ concept indirect_equivalence_relation =
206205 equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
207206 equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
208207 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
209 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
210 equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
208 equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
211209
212210template <class _Fp, class _It1, class _It2 = _It1>
213211concept indirect_strict_weak_order =
......@@ -215,8 +213,7 @@ concept indirect_strict_weak_order =
215213 strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> &&
216214 strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> &&
217215 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> &&
218 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> &&
219 strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>;
216 strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>>;
220217
221218template <class _Fp, class... _Its>
222219 requires(indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...>
lib/libcxx/include/__iterator/counted_iterator.h+1-1
......@@ -129,7 +129,7 @@ public:
129129 return *this;
130130 }
131131
132 _LIBCPP_HIDE_FROM_ABI decltype(auto) operator++(int) {
132 _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) {
133133 _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end.");
134134 --__count_;
135135# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
lib/libcxx/include/__iterator/cpp17_iterator_concepts.h+22-22
......@@ -14,10 +14,8 @@
1414#include <__concepts/same_as.h>
1515#include <__config>
1616#include <__iterator/iterator_traits.h>
17#include <__type_traits/is_constructible.h>
1718#include <__type_traits/is_convertible.h>
18#include <__type_traits/is_copy_constructible.h>
19#include <__type_traits/is_default_constructible.h>
20#include <__type_traits/is_move_constructible.h>
2119#include <__type_traits/is_signed.h>
2220#include <__type_traits/is_void.h>
2321#include <__utility/as_const.h>
......@@ -70,7 +68,7 @@ concept __cpp17_default_constructible = is_default_constructible_v<_Tp>;
7068template <class _Iter>
7169concept __cpp17_iterator =
7270 __cpp17_copy_constructible<_Iter> && __cpp17_copy_assignable<_Iter> && __cpp17_destructible<_Iter> &&
73 (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>)&&requires(_Iter __iter) {
71 (is_signed_v<__iter_diff_t<_Iter>> || is_void_v<__iter_diff_t<_Iter>>) && requires(_Iter __iter) {
7472 { *__iter };
7573 { ++__iter } -> same_as<_Iter&>;
7674 };
......@@ -159,29 +157,31 @@ concept __cpp17_random_access_iterator =
159157_LIBCPP_END_NAMESPACE_STD
160158
161159# ifndef _LIBCPP_DISABLE_ITERATOR_CHECKS
162# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t) static_assert(::std::__cpp17_input_iterator<iter_t>);
163# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t) \
164 static_assert(::std::__cpp17_output_iterator<iter_t, write_t>);
165# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t) static_assert(::std::__cpp17_forward_iterator<iter_t>);
166# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t) \
167 static_assert(::std::__cpp17_bidirectional_iterator<iter_t>);
168# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t) \
169 static_assert(::std::__cpp17_random_access_iterator<iter_t>);
160# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) \
161 static_assert(::std::__cpp17_input_iterator<iter_t>, message)
162# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) \
163 static_assert(::std::__cpp17_output_iterator<iter_t, write_t>, message)
164# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) \
165 static_assert(::std::__cpp17_forward_iterator<iter_t>, message)
166# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) \
167 static_assert(::std::__cpp17_bidirectional_iterator<iter_t>, message)
168# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) \
169 static_assert(::std::__cpp17_random_access_iterator<iter_t>, message)
170170# else
171# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t)
172# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t)
173# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t)
174# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t)
175# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t)
171# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true)
172# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true)
173# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true)
174# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true)
175# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true)
176176# endif
177177
178178#else // _LIBCPP_STD_VER >= 20
179179
180# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t)
181# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t)
182# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t)
183# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t)
184# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t)
180# define _LIBCPP_REQUIRE_CPP17_INPUT_ITERATOR(iter_t, message) static_assert(true)
181# define _LIBCPP_REQUIRE_CPP17_OUTPUT_ITERATOR(iter_t, write_t, message) static_assert(true)
182# define _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(iter_t, message) static_assert(true)
183# define _LIBCPP_REQUIRE_CPP17_BIDIRECTIONAL_ITERATOR(iter_t, message) static_assert(true)
184# define _LIBCPP_REQUIRE_CPP17_RANDOM_ACCESS_ITERATOR(iter_t, message) static_assert(true)
185185
186186#endif // _LIBCPP_STD_VER >= 20
187187
lib/libcxx/include/__iterator/data.h+2-2
......@@ -23,12 +23,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323#if _LIBCPP_STD_VER >= 17
2424
2525template <class _Cont>
26constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) _NOEXCEPT_(noexcept(__c.data())) -> decltype(__c.data()) {
26constexpr _LIBCPP_HIDE_FROM_ABI auto data(_Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) {
2727 return __c.data();
2828}
2929
3030template <class _Cont>
31constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) _NOEXCEPT_(noexcept(__c.data())) -> decltype(__c.data()) {
31constexpr _LIBCPP_HIDE_FROM_ABI auto data(const _Cont& __c) noexcept(noexcept(__c.data())) -> decltype(__c.data()) {
3232 return __c.data();
3333}
3434
lib/libcxx/include/__iterator/empty.h+4-4
......@@ -23,18 +23,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2323#if _LIBCPP_STD_VER >= 17
2424
2525template <class _Cont>
26_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr auto empty(const _Cont& __c)
27 _NOEXCEPT_(noexcept(__c.empty())) -> decltype(__c.empty()) {
26[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
27empty(const _Cont& __c) noexcept(noexcept(__c.empty())) -> decltype(__c.empty()) {
2828 return __c.empty();
2929}
3030
3131template <class _Tp, size_t _Sz>
32_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr bool empty(const _Tp (&)[_Sz]) noexcept {
32[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(const _Tp (&)[_Sz]) noexcept {
3333 return false;
3434}
3535
3636template <class _Ep>
37_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI constexpr bool empty(initializer_list<_Ep> __il) noexcept {
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty(initializer_list<_Ep> __il) noexcept {
3838 return __il.size() == 0;
3939}
4040
lib/libcxx/include/__iterator/iter_move.h+1-1
......@@ -35,7 +35,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3535namespace ranges {
3636namespace __iter_move {
3737
38void iter_move();
38void iter_move() = delete;
3939
4040template <class _Tp>
4141concept __unqualified_iter_move = __class_or_enum<remove_cvref_t<_Tp>> && requires(_Tp&& __t) {
lib/libcxx/include/__iterator/iter_swap.h+1-1
......@@ -42,7 +42,7 @@ void iter_swap(_I1, _I2) = delete;
4242
4343template <class _T1, class _T2>
4444concept __unqualified_iter_swap =
45 (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>)&&requires(_T1&& __x, _T2&& __y) {
45 (__class_or_enum<remove_cvref_t<_T1>> || __class_or_enum<remove_cvref_t<_T2>>) && requires(_T1&& __x, _T2&& __y) {
4646 // NOLINTNEXTLINE(libcpp-robust-against-adl) iter_swap ADL calls should only be made through ranges::iter_swap
4747 iter_swap(std::forward<_T1>(__x), std::forward<_T2>(__y));
4848 };
lib/libcxx/include/__iterator/iterator_traits.h+2-3
......@@ -21,7 +21,6 @@
2121#include <__fwd/pair.h>
2222#include <__iterator/incrementable_traits.h>
2323#include <__iterator/readable_traits.h>
24#include <__type_traits/add_const.h>
2524#include <__type_traits/common_reference.h>
2625#include <__type_traits/conditional.h>
2726#include <__type_traits/disjunction.h>
......@@ -493,8 +492,8 @@ using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type:
493492
494493template <class _InputIterator>
495494using __iter_to_alloc_type =
496 pair< typename add_const<typename iterator_traits<_InputIterator>::value_type::first_type>::type,
497 typename iterator_traits<_InputIterator>::value_type::second_type>;
495 pair<const typename iterator_traits<_InputIterator>::value_type::first_type,
496 typename iterator_traits<_InputIterator>::value_type::second_type>;
498497
499498template <class _Iter>
500499using __iterator_category_type = typename iterator_traits<_Iter>::iterator_category;
lib/libcxx/include/__iterator/move_iterator.h+14-9
......@@ -105,9 +105,8 @@ public:
105105 typedef iterator_type pointer;
106106
107107 typedef typename iterator_traits<iterator_type>::reference __reference;
108 typedef typename conditional< is_reference<__reference>::value,
109 __libcpp_remove_reference_t<__reference>&&,
110 __reference >::type reference;
108 typedef __conditional_t<is_reference<__reference>::value, __libcpp_remove_reference_t<__reference>&&, __reference>
109 reference;
111110#endif // _LIBCPP_STD_VER >= 20
112111
113112 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit move_iterator(_Iter __i) : __current_(std::move(__i)) {}
......@@ -157,14 +156,14 @@ public:
157156#else
158157 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator() : __current_() {}
159158
160 template <class _Up,
161 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value > >
159 template <class _Up, __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value, int> = 0>
162160 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator(const move_iterator<_Up>& __u)
163161 : __current_(__u.base()) {}
164162
165163 template <class _Up,
166 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value &&
167 is_assignable<_Iter&, const _Up&>::value > >
164 __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<const _Up&, _Iter>::value &&
165 is_assignable<_Iter&, const _Up&>::value,
166 int> = 0>
168167 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator& operator=(const move_iterator<_Up>& __u) {
169168 __current_ = __u.base();
170169 return *this;
......@@ -292,8 +291,8 @@ operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) {
292291#if _LIBCPP_STD_VER >= 20
293292template <class _Iter1, three_way_comparable_with<_Iter1> _Iter2>
294293inline _LIBCPP_HIDE_FROM_ABI constexpr auto
295operator<=>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y)
296 -> compare_three_way_result_t<_Iter1, _Iter2> {
294operator<=>(const move_iterator<_Iter1>& __x,
295 const move_iterator<_Iter2>& __y) -> compare_three_way_result_t<_Iter1, _Iter2> {
297296 return __x.base() <=> __y.base();
298297}
299298#endif // _LIBCPP_STD_VER >= 20
......@@ -330,6 +329,12 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato
330329}
331330#endif // _LIBCPP_STD_VER >= 20
332331
332#if _LIBCPP_STD_VER >= 20
333template <class _Iter1, class _Iter2>
334 requires(!sized_sentinel_for<_Iter1, _Iter2>)
335inline constexpr bool disable_sized_sentinel_for<move_iterator<_Iter1>, move_iterator<_Iter2>> = true;
336#endif // _LIBCPP_STD_VER >= 20
337
333338template <class _Iter>
334339inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 move_iterator<_Iter> make_move_iterator(_Iter __i) {
335340 return move_iterator<_Iter>(std::move(__i));
lib/libcxx/include/__iterator/ranges_iterator_traits.h+1-3
......@@ -13,7 +13,6 @@
1313#include <__config>
1414#include <__fwd/pair.h>
1515#include <__ranges/concepts.h>
16#include <__type_traits/add_const.h>
1716#include <__type_traits/remove_const.h>
1817
1918#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -32,8 +31,7 @@ using __range_mapped_type = typename ranges::range_value_t<_Range>::second_type;
3231
3332template <ranges::input_range _Range>
3433using __range_to_alloc_type =
35 pair<add_const_t<typename ranges::range_value_t<_Range>::first_type>,
36 typename ranges::range_value_t<_Range>::second_type>;
34 pair<const typename ranges::range_value_t<_Range>::first_type, typename ranges::range_value_t<_Range>::second_type>;
3735
3836#endif
3937
lib/libcxx/include/__iterator/reverse_iterator.h+26-197
......@@ -34,7 +34,7 @@
3434#include <__type_traits/enable_if.h>
3535#include <__type_traits/is_assignable.h>
3636#include <__type_traits/is_convertible.h>
37#include <__type_traits/is_nothrow_copy_constructible.h>
37#include <__type_traits/is_nothrow_constructible.h>
3838#include <__type_traits/is_pointer.h>
3939#include <__type_traits/is_same.h>
4040#include <__utility/declval.h>
......@@ -96,14 +96,14 @@ public:
9696
9797 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : __t_(__x), current(__x) {}
9898
99 template <class _Up,
100 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value > >
99 template <class _Up, __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value, int> = 0>
101100 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u)
102101 : __t_(__u.base()), current(__u.base()) {}
103102
104103 template <class _Up,
105 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value &&
106 is_assignable<_Iter&, _Up const&>::value > >
104 __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value &&
105 is_assignable<_Iter&, _Up const&>::value,
106 int> = 0>
107107 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
108108 __t_ = current = __u.base();
109109 return *this;
......@@ -113,14 +113,14 @@ public:
113113
114114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 explicit reverse_iterator(_Iter __x) : current(__x) {}
115115
116 template <class _Up,
117 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value > >
116 template <class _Up, __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value, int> = 0>
118117 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator(const reverse_iterator<_Up>& __u)
119118 : current(__u.base()) {}
120119
121120 template <class _Up,
122 class = __enable_if_t< !is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value &&
123 is_assignable<_Iter&, _Up const&>::value > >
121 __enable_if_t<!is_same<_Up, _Iter>::value && is_convertible<_Up const&, _Iter>::value &&
122 is_assignable<_Iter&, _Up const&>::value,
123 int> = 0>
124124 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator& operator=(const reverse_iterator<_Up>& __u) {
125125 current = __u.base();
126126 return *this;
......@@ -184,7 +184,7 @@ public:
184184
185185#if _LIBCPP_STD_VER >= 20
186186 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const reverse_iterator& __i) noexcept(
187 is_nothrow_copy_constructible_v<_Iter>&& noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
187 is_nothrow_copy_constructible_v<_Iter> && noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
188188 auto __tmp = __i.base();
189189 return ranges::iter_move(--__tmp);
190190 }
......@@ -192,9 +192,8 @@ public:
192192 template <indirectly_swappable<_Iter> _Iter2>
193193 _LIBCPP_HIDE_FROM_ABI friend constexpr void
194194 iter_swap(const reverse_iterator& __x, const reverse_iterator<_Iter2>& __y) noexcept(
195 is_nothrow_copy_constructible_v<_Iter> &&
196 is_nothrow_copy_constructible_v<_Iter2>&& noexcept(
197 ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
195 is_nothrow_copy_constructible_v<_Iter> && is_nothrow_copy_constructible_v<_Iter2> &&
196 noexcept(ranges::iter_swap(--std::declval<_Iter&>(), --std::declval<_Iter2&>()))) {
198197 auto __xtmp = __x.base();
199198 auto __ytmp = __y.base();
200199 ranges::iter_swap(--__xtmp, --__ytmp);
......@@ -285,8 +284,8 @@ operator<=>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>&
285284#ifndef _LIBCPP_CXX03_LANG
286285template <class _Iter1, class _Iter2>
287286inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 auto
288operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
289 -> decltype(__y.base() - __x.base()) {
287operator-(const reverse_iterator<_Iter1>& __x,
288 const reverse_iterator<_Iter2>& __y) -> decltype(__y.base() - __x.base()) {
290289 return __y.base() - __x.base();
291290}
292291#else
......@@ -316,172 +315,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reverse_iterator<_Ite
316315}
317316#endif
318317
319#if _LIBCPP_STD_VER <= 17
320template <class _Iter>
321using __unconstrained_reverse_iterator = reverse_iterator<_Iter>;
322#else
323
324// __unconstrained_reverse_iterator allows us to use reverse iterators in the implementation of algorithms by working
325// around a language issue in C++20.
326// In C++20, when a reverse iterator wraps certain C++20-hostile iterators, calling comparison operators on it will
327// result in a compilation error. However, calling comparison operators on the pristine hostile iterator is not
328// an error. Thus, we cannot use reverse_iterators in the implementation of an algorithm that accepts a
329// C++20-hostile iterator. This class is an internal workaround -- it is a copy of reverse_iterator with
330// tweaks to make it support hostile iterators.
331//
332// A C++20-hostile iterator is one that defines a comparison operator where one of the arguments is an exact match
333// and the other requires an implicit conversion, for example:
334// friend bool operator==(const BaseIter&, const DerivedIter&);
335//
336// C++20 rules for rewriting equality operators create another overload of this function with parameters reversed:
337// friend bool operator==(const DerivedIter&, const BaseIter&);
338//
339// This creates an ambiguity in overload resolution.
340//
341// Clang treats this ambiguity differently in different contexts. When operator== is actually called in the function
342// body, the code is accepted with a warning. When a concept requires operator== to be a valid expression, however,
343// it evaluates to false. Thus, the implementation of reverse_iterator::operator== can actually call operator== on its
344// base iterators, but the constraints on reverse_iterator::operator== prevent it from being considered during overload
345// resolution. This class simply removes the problematic constraints from comparison functions.
346template <class _Iter>
347class __unconstrained_reverse_iterator {
348 _Iter __iter_;
349
350public:
351 static_assert(__has_bidirectional_iterator_category<_Iter>::value || bidirectional_iterator<_Iter>);
352
353 using iterator_type = _Iter;
354 using iterator_category =
355 _If<__has_random_access_iterator_category<_Iter>::value,
356 random_access_iterator_tag,
357 __iterator_category_type<_Iter>>;
358 using pointer = __iterator_pointer_type<_Iter>;
359 using value_type = iter_value_t<_Iter>;
360 using difference_type = iter_difference_t<_Iter>;
361 using reference = iter_reference_t<_Iter>;
362
363 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator() = default;
364 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator(const __unconstrained_reverse_iterator&) = default;
365 _LIBCPP_HIDE_FROM_ABI constexpr explicit __unconstrained_reverse_iterator(_Iter __iter) : __iter_(__iter) {}
366
367 _LIBCPP_HIDE_FROM_ABI constexpr _Iter base() const { return __iter_; }
368 _LIBCPP_HIDE_FROM_ABI constexpr reference operator*() const {
369 auto __tmp = __iter_;
370 return *--__tmp;
371 }
372
373 _LIBCPP_HIDE_FROM_ABI constexpr pointer operator->() const {
374 if constexpr (is_pointer_v<_Iter>) {
375 return std::prev(__iter_);
376 } else {
377 return std::prev(__iter_).operator->();
378 }
379 }
380
381 _LIBCPP_HIDE_FROM_ABI friend constexpr iter_rvalue_reference_t<_Iter>
382 iter_move(const __unconstrained_reverse_iterator& __i) noexcept(
383 is_nothrow_copy_constructible_v<_Iter>&& noexcept(ranges::iter_move(--std::declval<_Iter&>()))) {
384 auto __tmp = __i.base();
385 return ranges::iter_move(--__tmp);
386 }
387
388 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator++() {
389 --__iter_;
390 return *this;
391 }
392
393 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator++(int) {
394 auto __tmp = *this;
395 --__iter_;
396 return __tmp;
397 }
398
399 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator--() {
400 ++__iter_;
401 return *this;
402 }
403
404 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator--(int) {
405 auto __tmp = *this;
406 ++__iter_;
407 return __tmp;
408 }
409
410 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator+=(difference_type __n) {
411 __iter_ -= __n;
412 return *this;
413 }
414
415 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator& operator-=(difference_type __n) {
416 __iter_ += __n;
417 return *this;
418 }
419
420 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator+(difference_type __n) const {
421 return __unconstrained_reverse_iterator(__iter_ - __n);
422 }
423
424 _LIBCPP_HIDE_FROM_ABI constexpr __unconstrained_reverse_iterator operator-(difference_type __n) const {
425 return __unconstrained_reverse_iterator(__iter_ + __n);
426 }
427
428 _LIBCPP_HIDE_FROM_ABI constexpr difference_type operator-(const __unconstrained_reverse_iterator& __other) const {
429 return __other.__iter_ - __iter_;
430 }
431
432 _LIBCPP_HIDE_FROM_ABI constexpr auto operator[](difference_type __n) const { return *(*this + __n); }
433
434 // Deliberately unconstrained unlike the comparison functions in `reverse_iterator` -- see the class comment for the
435 // rationale.
436 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
437 operator==(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
438 return __lhs.base() == __rhs.base();
439 }
440
441 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
442 operator!=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
443 return __lhs.base() != __rhs.base();
444 }
445
446 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
447 operator<(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
448 return __lhs.base() > __rhs.base();
449 }
450
451 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
452 operator>(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
453 return __lhs.base() < __rhs.base();
454 }
455
456 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
457 operator<=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
458 return __lhs.base() >= __rhs.base();
459 }
460
461 _LIBCPP_HIDE_FROM_ABI friend constexpr bool
462 operator>=(const __unconstrained_reverse_iterator& __lhs, const __unconstrained_reverse_iterator& __rhs) {
463 return __lhs.base() <= __rhs.base();
464 }
465};
466
467#endif // _LIBCPP_STD_VER <= 17
468
469template <template <class> class _RevIter1, template <class> class _RevIter2, class _Iter>
470struct __unwrap_reverse_iter_impl {
471 using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
472 using _ReverseWrapper = _RevIter1<_RevIter2<_Iter> >;
473
474 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
475 __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {
476 return _ReverseWrapper(
477 _RevIter2<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter)));
478 }
479
480 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT {
481 return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base());
482 }
483};
484
485318#if _LIBCPP_STD_VER >= 20
486319template <ranges::bidirectional_range _Range>
487320_LIBCPP_HIDE_FROM_ABI constexpr ranges::subrange<reverse_iterator<ranges::iterator_t<_Range>>,
......@@ -493,24 +326,20 @@ __reverse_range(_Range&& __range) {
493326#endif
494327
495328template <class _Iter, bool __b>
496struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b>
497 : __unwrap_reverse_iter_impl<reverse_iterator, reverse_iterator, _Iter> {};
498
499#if _LIBCPP_STD_VER >= 20
500
501template <class _Iter, bool __b>
502struct __unwrap_iter_impl<reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
503 : __unwrap_reverse_iter_impl<reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
504
505template <class _Iter, bool __b>
506struct __unwrap_iter_impl<__unconstrained_reverse_iterator<reverse_iterator<_Iter>>, __b>
507 : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, reverse_iterator, _Iter> {};
329struct __unwrap_iter_impl<reverse_iterator<reverse_iterator<_Iter> >, __b> {
330 using _UnwrappedIter = decltype(__unwrap_iter_impl<_Iter>::__unwrap(std::declval<_Iter>()));
331 using _ReverseWrapper = reverse_iterator<reverse_iterator<_Iter> >;
508332
509template <class _Iter, bool __b>
510struct __unwrap_iter_impl<__unconstrained_reverse_iterator<__unconstrained_reverse_iterator<_Iter>>, __b>
511 : __unwrap_reverse_iter_impl<__unconstrained_reverse_iterator, __unconstrained_reverse_iterator, _Iter> {};
333 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _ReverseWrapper
334 __rewrap(_ReverseWrapper __orig_iter, _UnwrappedIter __unwrapped_iter) {
335 return _ReverseWrapper(
336 reverse_iterator<_Iter>(__unwrap_iter_impl<_Iter>::__rewrap(__orig_iter.base().base(), __unwrapped_iter)));
337 }
512338
513#endif // _LIBCPP_STD_VER >= 20
339 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _UnwrappedIter __unwrap(_ReverseWrapper __i) _NOEXCEPT {
340 return __unwrap_iter_impl<_Iter>::__unwrap(__i.base().base());
341 }
342};
514343
515344_LIBCPP_END_NAMESPACE_STD
516345
lib/libcxx/include/__iterator/size.h+4-4
......@@ -24,7 +24,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2424#if _LIBCPP_STD_VER >= 17
2525
2626template <class _Cont>
27_LIBCPP_HIDE_FROM_ABI constexpr auto size(const _Cont& __c) _NOEXCEPT_(noexcept(__c.size())) -> decltype(__c.size()) {
27_LIBCPP_HIDE_FROM_ABI constexpr auto size(const _Cont& __c) noexcept(noexcept(__c.size())) -> decltype(__c.size()) {
2828 return __c.size();
2929}
3030
......@@ -35,9 +35,9 @@ _LIBCPP_HIDE_FROM_ABI constexpr size_t size(const _Tp (&)[_Sz]) noexcept {
3535
3636# if _LIBCPP_STD_VER >= 20
3737template <class _Cont>
38_LIBCPP_HIDE_FROM_ABI constexpr auto ssize(const _Cont& __c)
39 _NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size())))
40 -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> {
38_LIBCPP_HIDE_FROM_ABI constexpr auto
39ssize(const _Cont& __c) noexcept(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(
40 __c.size()))) -> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>> {
4141 return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size());
4242}
4343
lib/libcxx/include/__iterator/wrap_iter.h+29-2
......@@ -10,6 +10,8 @@
1010#ifndef _LIBCPP___ITERATOR_WRAP_ITER_H
1111#define _LIBCPP___ITERATOR_WRAP_ITER_H
1212
13#include <__compare/ordering.h>
14#include <__compare/three_way_comparable.h>
1315#include <__config>
1416#include <__iterator/iterator_traits.h>
1517#include <__memory/addressof.h>
......@@ -97,10 +99,14 @@ private:
9799 friend class __wrap_iter;
98100 template <class _CharT, class _Traits, class _Alloc>
99101 friend class basic_string;
102 template <class _CharT, class _Traits>
103 friend class basic_string_view;
100104 template <class _Tp, class _Alloc>
101105 friend class _LIBCPP_TEMPLATE_VIS vector;
102106 template <class _Tp, size_t>
103107 friend class _LIBCPP_TEMPLATE_VIS span;
108 template <class _Tp, size_t _Size>
109 friend struct array;
104110};
105111
106112template <class _Iter1>
......@@ -127,6 +133,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
127133 return __x.base() < __y.base();
128134}
129135
136#if _LIBCPP_STD_VER <= 17
130137template <class _Iter1>
131138_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
132139operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
......@@ -138,7 +145,9 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
138145operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT {
139146 return !(__x == __y);
140147}
148#endif
141149
150// TODO(mordante) disable these overloads in the LLVM 20 release.
142151template <class _Iter1>
143152_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
144153operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT {
......@@ -175,6 +184,24 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
175184 return !(__y < __x);
176185}
177186
187#if _LIBCPP_STD_VER >= 20
188template <class _Iter1, class _Iter2>
189_LIBCPP_HIDE_FROM_ABI constexpr strong_ordering
190operator<=>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) noexcept {
191 if constexpr (three_way_comparable_with<_Iter1, _Iter2, strong_ordering>) {
192 return __x.base() <=> __y.base();
193 } else {
194 if (__x.base() < __y.base())
195 return strong_ordering::less;
196
197 if (__x.base() == __y.base())
198 return strong_ordering::equal;
199
200 return strong_ordering::greater;
201 }
202}
203#endif // _LIBCPP_STD_VER >= 20
204
178205template <class _Iter1, class _Iter2>
179206_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
180207#ifndef _LIBCPP_CXX03_LANG
......@@ -182,8 +209,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
182209 operator-(const __wrap_iter<_Iter1>& __x,
183210 const __wrap_iter<_Iter2>& __y) _NOEXCEPT->decltype(__x.base() - __y.base())
184211#else
185 typename __wrap_iter<_Iter1>::difference_type
186 operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
212typename __wrap_iter<_Iter1>::difference_type
213operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
187214#endif // C++03
188215{
189216 return __x.base() - __y.base();
lib/libcxx/include/__locale+12-30
......@@ -10,12 +10,13 @@
1010#ifndef _LIBCPP___LOCALE
1111#define _LIBCPP___LOCALE
1212
13#include <__availability>
1413#include <__config>
14#include <__locale_dir/locale_base_api.h>
1515#include <__memory/shared_ptr.h> // __shared_count
1616#include <__mutex/once_flag.h>
1717#include <__type_traits/make_unsigned.h>
1818#include <__utility/no_destroy.h>
19#include <__utility/private_constructor_tag.h>
1920#include <cctype>
2021#include <clocale>
2122#include <cstdint>
......@@ -32,27 +33,6 @@
3233# include <__std_mbstate_t.h>
3334#endif
3435
35#if defined(_LIBCPP_MSVCRT_LIKE)
36# include <__support/win32/locale_win32.h>
37#elif defined(_AIX) || defined(__MVS__)
38# include <__support/ibm/xlocale.h>
39#elif defined(__ANDROID__)
40# include <__support/android/locale_bionic.h>
41#elif defined(_NEWLIB_VERSION)
42# include <__support/newlib/xlocale.h>
43#elif defined(__OpenBSD__)
44# include <__support/openbsd/xlocale.h>
45#elif (defined(__APPLE__) || defined(__FreeBSD__))
46# include <xlocale.h>
47#elif defined(__Fuchsia__)
48# include <__support/fuchsia/xlocale.h>
49#elif defined(__wasi__)
50// WASI libc uses musl's locales support.
51# include <__support/musl/xlocale.h>
52#elif defined(_LIBCPP_HAS_MUSL_LIBC)
53# include <__support/musl/xlocale.h>
54#endif
55
5636#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5737# pragma GCC system_header
5838#endif
......@@ -69,6 +49,9 @@ _LIBCPP_HIDE_FROM_ABI const _Facet& use_facet(const locale&);
6949
7050class _LIBCPP_EXPORTED_FROM_ABI locale {
7151public:
52 // locale is essentially a shared_ptr that doesn't support weak_ptrs and never got a move constructor.
53 using __trivially_relocatable = locale;
54
7255 // types:
7356 class _LIBCPP_EXPORTED_FROM_ABI facet;
7457 class _LIBCPP_EXPORTED_FROM_ABI id;
......@@ -118,8 +101,7 @@ private:
118101
119102 template <class>
120103 friend struct __no_destroy;
121 struct __private_tag {};
122 _LIBCPP_HIDE_FROM_ABI explicit locale(__private_tag, __imp* __loc) : __locale_(__loc) {}
104 _LIBCPP_HIDE_FROM_ABI explicit locale(__private_constructor_tag, __imp* __loc) : __locale_(__loc) {}
123105
124106 void __install_ctor(const locale&, facet*, long);
125107 static locale& __global();
......@@ -364,12 +346,12 @@ public:
364346 static const mask __regex_word = 0x4000; // 0x8000 and 0x0100 and 0x00ff are used
365347# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
366348# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
367#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
349#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
368350# ifdef __APPLE__
369351 typedef __uint32_t mask;
370352# elif defined(__FreeBSD__)
371353 typedef unsigned long mask;
372# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__)
354# elif defined(__NetBSD__)
373355 typedef unsigned short mask;
374356# endif
375357 static const mask space = _CTYPE_S;
......@@ -1269,10 +1251,10 @@ extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char, char
12691251#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
12701252extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>;
12711253#endif
1272extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
1273 codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1274extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
1275 codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
1254extern template class _LIBCPP_DEPRECATED_IN_CXX20
1255_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
1256extern template class _LIBCPP_DEPRECATED_IN_CXX20
1257_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // deprecated in C++20
12761258#ifndef _LIBCPP_HAS_NO_CHAR8_T
12771259extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char8_t, mbstate_t>; // C++20
12781260extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
lib/libcxx/include/__locale_dir/locale_base_api.h created+98
......@@ -0,0 +1,98 @@
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_LOCALE_BASE_API_H
10#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
11
12#if defined(_LIBCPP_MSVCRT_LIKE)
13# include <__locale_dir/locale_base_api/win32.h>
14#elif defined(_AIX) || defined(__MVS__)
15# include <__locale_dir/locale_base_api/ibm.h>
16#elif defined(__ANDROID__)
17# include <__locale_dir/locale_base_api/android.h>
18#elif defined(__sun__)
19# include <__locale_dir/locale_base_api/solaris.h>
20#elif defined(_NEWLIB_VERSION)
21# include <__locale_dir/locale_base_api/newlib.h>
22#elif defined(__OpenBSD__)
23# include <__locale_dir/locale_base_api/openbsd.h>
24#elif defined(__Fuchsia__)
25# include <__locale_dir/locale_base_api/fuchsia.h>
26#elif defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
27# include <__locale_dir/locale_base_api/musl.h>
28#elif defined(__APPLE__) || defined(__FreeBSD__)
29# include <xlocale.h>
30#endif
31
32#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
33# pragma GCC system_header
34#endif
35
36/*
37The platform-specific headers have to provide the following interface:
38
39// TODO: rename this to __libcpp_locale_t
40using locale_t = implementation-defined;
41
42implementation-defined __libcpp_mb_cur_max_l(locale_t);
43wint_t __libcpp_btowc_l(int, locale_t);
44int __libcpp_wctob_l(wint_t, locale_t);
45size_t __libcpp_wcsnrtombs_l(char* dest, const wchar_t** src, size_t wide_char_count, size_t len, mbstate_t, locale_t);
46size_t __libcpp_wcrtomb_l(char* str, wchar_t wide_char, mbstate_t*, locale_t);
47size_t __libcpp_mbsnrtowcs_l(wchar_t* dest, const char** src, size_t max_out, size_t len, mbstate_t*, locale_t);
48size_t __libcpp_mbrtowc_l(wchar_t* dest, cosnt char* src, size_t count, mbstate_t*, locale_t);
49int __libcpp_mbtowc_l(wchar_t* dest, const char* src, size_t count, locale_t);
50size_t __libcpp_mbrlen_l(const char* str, size_t count, mbstate_t*, locale_t);
51lconv* __libcpp_localeconv_l(locale_t);
52size_t __libcpp_mbsrtowcs_l(wchar_t* dest, const char** src, size_t len, mbstate_t*, locale_t);
53int __libcpp_snprintf_l(char* dest, size_t buff_size, locale_t, const char* format, ...);
54int __libcpp_asprintf_l(char** dest, locale_t, const char* format, ...);
55int __libcpp_sscanf_l(const char* dest, locale_t, const char* format, ...);
56
57// TODO: change these to reserved names
58float strtof_l(const char* str, char** str_end, locale_t);
59double strtod_l(const char* str, char** str_end, locale_t);
60long double strtold_l(const char* str, char** str_end, locale_t);
61long long strtoll_l(const char* str, char** str_end, locale_t);
62unsigned long long strtoull_l(const char* str, char** str_end, locale_t);
63
64locale_t newlocale(int category_mask, const char* locale, locale_t base);
65void freelocale(locale_t);
66
67int islower_l(int ch, locale_t);
68int isupper_l(int ch, locale_t);
69int isdigit_l(int ch, locale_t);
70int isxdigit_l(int ch, locale_t);
71int strcoll_l(const char* lhs, const char* rhs, locale_t);
72size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t);
73int wcscoll_l(const char* lhs, const char* rhs, locale_t);
74size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t);
75int toupper_l(int ch, locale_t);
76int tolower_l(int ch, locale_t);
77int iswspace_l(wint_t ch, locale_t);
78int iswprint_l(wint_t ch, locale_t);
79int iswcntrl_l(wint_t ch, locale_t);
80int iswupper_l(wint_t ch, locale_t);
81int iswlower_l(wint_t ch, locale_t);
82int iswalpha_l(wint_t ch, locale_t);
83int iswblank_l(wint_t ch, locale_t);
84int iswdigit_l(wint_t ch, locale_t);
85int iswpunct_l(wint_t ch, locale_t);
86int iswxdigit_l(wint_t ch, locale_t);
87wint_t towupper_l(wint_t ch, locale_t);
88wint_t towlower_l(wint_t ch, locale_t);
89size_t strftime_l(char* str, size_t len, const char* format, const tm*, locale_t);
90
91
92These functions are equivalent to their C counterparts,
93except that locale_t is used instead of the current global locale.
94
95The variadic functions may be implemented as templates with a parameter pack instead of variadic functions.
96*/
97
98#endif // _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_H
lib/libcxx/include/__locale_dir/locale_base_api/android.h created+50
......@@ -0,0 +1,50 @@
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_LOCALE_BASE_API_ANDROID_H
11#define _LIBCPP___LOCALE_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#if __ANDROID_API__ < 21
22# include <__support/xlocale/__posix_l_fallback.h>
23#endif
24
25// If we do not have this header, we are in a platform build rather than an NDK
26// build, which will always be at least as new as the ToT NDK, in which case we
27// don't need any of the inlines below since libc provides them.
28#if __has_include(<android/ndk-version.h>)
29# include <android/ndk-version.h>
30// In NDK versions later than 16, locale-aware functions are provided by
31// legacy_stdlib_inlines.h
32# if __NDK_MAJOR__ <= 16
33# if __ANDROID_API__ < 21
34# include <__support/xlocale/__strtonum_fallback.h>
35# elif __ANDROID_API__ < 26
36
37inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
38 return ::strtof(__nptr, __endptr);
39}
40
41inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
42 return ::strtod(__nptr, __endptr);
43}
44
45# endif // __ANDROID_API__ < 26
46
47# endif // __NDK_MAJOR__ <= 16
48#endif // __has_include(<android/ndk-version.h>)
49
50#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_ANDROID_H
lib/libcxx/include/__locale_dir/locale_base_api/fuchsia.h created+18
......@@ -0,0 +1,18 @@
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_LOCALE_BASE_API_FUCHSIA_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
12
13#include <__support/xlocale/__posix_l_fallback.h>
14#include <__support/xlocale/__strtonum_fallback.h>
15#include <cstdlib>
16#include <cwchar>
17
18#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_FUCHSIA_H
lib/libcxx/include/__locale_dir/locale_base_api/ibm.h created+108
......@@ -0,0 +1,108 @@
1// -*- C++ -*-
2//===-----------------------------------------------------------------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H
11#define _LIBCPP___LOCALE_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 long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
57 __setAndRestore __newloc(locale);
58 return ::strtoll(__nptr, __endptr, __base);
59}
60
61inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
62 __setAndRestore __newloc(locale);
63 return ::strtod(__nptr, __endptr);
64}
65
66inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) {
67 __setAndRestore __newloc(locale);
68 return ::strtof(__nptr, __endptr);
69}
70
71inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) {
72 __setAndRestore __newloc(locale);
73 return ::strtold(__nptr, __endptr);
74}
75
76inline _LIBCPP_HIDE_FROM_ABI unsigned long long
77strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
78 __setAndRestore __newloc(locale);
79 return ::strtoull(__nptr, __endptr, __base);
80}
81
82inline _LIBCPP_HIDE_FROM_ABI
83_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
84 const size_t buff_size = 256;
85 if ((*strp = (char*)malloc(buff_size)) == NULL) {
86 return -1;
87 }
88
89 va_list ap_copy;
90 // va_copy may not be provided by the C library in C++03 mode.
91#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
92 __builtin_va_copy(ap_copy, ap);
93#else
94 va_copy(ap_copy, ap);
95#endif
96 int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
97 va_end(ap_copy);
98
99 if ((size_t)str_size >= buff_size) {
100 if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
101 return -1;
102 }
103 str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
104 }
105 return str_size;
106}
107
108#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_IBM_H
lib/libcxx/include/__locale_dir/locale_base_api/locale_guard.h+2-3
......@@ -30,9 +30,8 @@ struct __libcpp_locale_guard {
3030
3131 locale_t __old_loc_;
3232
33private:
34 __libcpp_locale_guard(__libcpp_locale_guard const&);
35 __libcpp_locale_guard& operator=(__libcpp_locale_guard const&);
33 __libcpp_locale_guard(__libcpp_locale_guard const&) = delete;
34 __libcpp_locale_guard& operator=(__libcpp_locale_guard const&) = delete;
3635};
3736#elif defined(_LIBCPP_MSVCRT_LIKE)
3837struct __libcpp_locale_guard {
lib/libcxx/include/__locale_dir/locale_base_api/musl.h created+31
......@@ -0,0 +1,31 @@
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_LOCALE_BASE_API_MUSL_H
18#define _LIBCPP___LOCALE_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_LOCALE_BASE_API_MUSL_H
lib/libcxx/include/__locale_dir/locale_base_api/newlib.h created+12
......@@ -0,0 +1,12 @@
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_LOCALE_BASE_API_NEWLIB_H
10#define _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
11
12#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_NEWLIB_H
lib/libcxx/include/__locale_dir/locale_base_api/openbsd.h created+19
......@@ -0,0 +1,19 @@
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_LOCALE_BASE_API_OPENBSD_H
11#define _LIBCPP___LOCALE_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_LOCALE_BASE_API_OPENBSD_H
lib/libcxx/include/__locale_dir/locale_base_api/win32.h created+235
......@@ -0,0 +1,235 @@
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_LOCALE_BASE_API_WIN32_H
11#define _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H
12
13#include <__config>
14#include <cstddef>
15#include <locale.h> // _locale_t
16#include <stdio.h>
17#include <string>
18
19#define _X_ALL LC_ALL
20#define _X_COLLATE LC_COLLATE
21#define _X_CTYPE LC_CTYPE
22#define _X_MONETARY LC_MONETARY
23#define _X_NUMERIC LC_NUMERIC
24#define _X_TIME LC_TIME
25#define _X_MAX LC_MAX
26#define _X_MESSAGES 6
27#define _NCAT (_X_MESSAGES + 1)
28
29#define _CATMASK(n) ((1 << (n)) >> 1)
30#define _M_COLLATE _CATMASK(_X_COLLATE)
31#define _M_CTYPE _CATMASK(_X_CTYPE)
32#define _M_MONETARY _CATMASK(_X_MONETARY)
33#define _M_NUMERIC _CATMASK(_X_NUMERIC)
34#define _M_TIME _CATMASK(_X_TIME)
35#define _M_MESSAGES _CATMASK(_X_MESSAGES)
36#define _M_ALL (_CATMASK(_NCAT) - 1)
37
38#define LC_COLLATE_MASK _M_COLLATE
39#define LC_CTYPE_MASK _M_CTYPE
40#define LC_MONETARY_MASK _M_MONETARY
41#define LC_NUMERIC_MASK _M_NUMERIC
42#define LC_TIME_MASK _M_TIME
43#define LC_MESSAGES_MASK _M_MESSAGES
44#define LC_ALL_MASK \
45 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
46
47class __lconv_storage {
48public:
49 __lconv_storage(const lconv* __lc_input) {
50 __lc_ = *__lc_input;
51
52 __decimal_point_ = __lc_input->decimal_point;
53 __thousands_sep_ = __lc_input->thousands_sep;
54 __grouping_ = __lc_input->grouping;
55 __int_curr_symbol_ = __lc_input->int_curr_symbol;
56 __currency_symbol_ = __lc_input->currency_symbol;
57 __mon_decimal_point_ = __lc_input->mon_decimal_point;
58 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
59 __mon_grouping_ = __lc_input->mon_grouping;
60 __positive_sign_ = __lc_input->positive_sign;
61 __negative_sign_ = __lc_input->negative_sign;
62
63 __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str());
64 __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str());
65 __lc_.grouping = const_cast<char*>(__grouping_.c_str());
66 __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str());
67 __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str());
68 __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str());
69 __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str());
70 __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str());
71 __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str());
72 __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str());
73 }
74
75 lconv* __get() { return &__lc_; }
76
77private:
78 lconv __lc_;
79 std::string __decimal_point_;
80 std::string __thousands_sep_;
81 std::string __grouping_;
82 std::string __int_curr_symbol_;
83 std::string __currency_symbol_;
84 std::string __mon_decimal_point_;
85 std::string __mon_thousands_sep_;
86 std::string __mon_grouping_;
87 std::string __positive_sign_;
88 std::string __negative_sign_;
89};
90
91class locale_t {
92public:
93 locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
94 locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
95 locale_t(_locale_t __xlocale, const char* __xlocale_str)
96 : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {}
97 locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
98
99 ~locale_t() { delete __lc_; }
100
101 locale_t& operator=(const locale_t& __l) {
102 __locale_ = __l.__locale_;
103 __locale_str_ = __l.__locale_str_;
104 // __lc_ not copied
105 return *this;
106 }
107
108 friend bool operator==(const locale_t& __left, const locale_t& __right) {
109 return __left.__locale_ == __right.__locale_;
110 }
111
112 friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; }
113
114 friend bool operator==(const locale_t& __left, long long __right) {
115 return __left.__locale_ == nullptr && __right == 0;
116 }
117
118 friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; }
119
120 friend bool operator==(int __left, const locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; }
121
122 friend bool operator==(std::nullptr_t, const locale_t& __right) { return nullptr == __right.__locale_; }
123
124 friend bool operator!=(const locale_t& __left, const locale_t& __right) { return !(__left == __right); }
125
126 friend bool operator!=(const locale_t& __left, int __right) { return !(__left == __right); }
127
128 friend bool operator!=(const locale_t& __left, long long __right) { return !(__left == __right); }
129
130 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) { return !(__left == __right); }
131
132 friend bool operator!=(int __left, const locale_t& __right) { return !(__left == __right); }
133
134 friend bool operator!=(std::nullptr_t __left, const locale_t& __right) { return !(__left == __right); }
135
136 operator bool() const { return __locale_ != nullptr; }
137
138 const char* __get_locale() const { return __locale_str_; }
139
140 operator _locale_t() const { return __locale_; }
141
142 lconv* __store_lconv(const lconv* __input_lc) {
143 delete __lc_;
144 __lc_ = new __lconv_storage(__input_lc);
145 return __lc_->__get();
146 }
147
148private:
149 _locale_t __locale_;
150 const char* __locale_str_;
151 __lconv_storage* __lc_ = nullptr;
152};
153
154// Locale management functions
155#define freelocale _free_locale
156// FIXME: base currently unused. Needs manual work to construct the new locale
157locale_t newlocale(int __mask, const char* __locale, locale_t __base);
158// uselocale can't be implemented on Windows because Windows allows partial modification
159// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
160// not create any copies.
161// We can still implement raii even without uselocale though.
162
163lconv* localeconv_l(locale_t& __loc);
164size_t mbrlen_l(const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
165size_t mbsrtowcs_l(
166 wchar_t* __restrict __dst, const char** __restrict __src, size_t __len, mbstate_t* __restrict __ps, locale_t __loc);
167size_t wcrtomb_l(char* __restrict __s, wchar_t __wc, mbstate_t* __restrict __ps, locale_t __loc);
168size_t mbrtowc_l(
169 wchar_t* __restrict __pwc, const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
170size_t mbsnrtowcs_l(wchar_t* __restrict __dst,
171 const char** __restrict __src,
172 size_t __nms,
173 size_t __len,
174 mbstate_t* __restrict __ps,
175 locale_t __loc);
176size_t wcsnrtombs_l(char* __restrict __dst,
177 const wchar_t** __restrict __src,
178 size_t __nwc,
179 size_t __len,
180 mbstate_t* __restrict __ps,
181 locale_t __loc);
182wint_t btowc_l(int __c, locale_t __loc);
183int wctob_l(wint_t __c, locale_t __loc);
184
185decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l);
186
187// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
188#define mbtowc_l _mbtowc_l
189#define strtoll_l _strtoi64_l
190#define strtoull_l _strtoui64_l
191#define strtod_l _strtod_l
192#if defined(_LIBCPP_MSVCRT)
193# define strtof_l _strtof_l
194# define strtold_l _strtold_l
195#else
196_LIBCPP_EXPORTED_FROM_ABI float strtof_l(const char*, char**, locale_t);
197_LIBCPP_EXPORTED_FROM_ABI long double strtold_l(const char*, char**, locale_t);
198#endif
199inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, _locale_t __loc) { return _islower_l((int)__c, __loc); }
200
201inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, _locale_t __loc) { return _isupper_l((int)__c, __loc); }
202
203#define isdigit_l _isdigit_l
204#define isxdigit_l _isxdigit_l
205#define strcoll_l _strcoll_l
206#define strxfrm_l _strxfrm_l
207#define wcscoll_l _wcscoll_l
208#define wcsxfrm_l _wcsxfrm_l
209#define toupper_l _toupper_l
210#define tolower_l _tolower_l
211#define iswspace_l _iswspace_l
212#define iswprint_l _iswprint_l
213#define iswcntrl_l _iswcntrl_l
214#define iswupper_l _iswupper_l
215#define iswlower_l _iswlower_l
216#define iswalpha_l _iswalpha_l
217#define iswdigit_l _iswdigit_l
218#define iswpunct_l _iswpunct_l
219#define iswxdigit_l _iswxdigit_l
220#define towupper_l _towupper_l
221#define towlower_l _towlower_l
222#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
223_LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc);
224#else
225# define strftime_l _strftime_l
226#endif
227#define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__)
228_LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...);
229_LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...);
230_LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap);
231
232// not-so-pressing FIXME: use locale to determine blank characters
233inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); }
234
235#endif // _LIBCPP___LOCALE_LOCALE_BASE_API_WIN32_H
lib/libcxx/include/__math/abs.h+4-4
......@@ -23,19 +23,19 @@ namespace __math {
2323
2424// fabs
2525
26_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }
26_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fabs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }
2727
2828template <class = int>
29_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
29_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fabs(double __x) _NOEXCEPT {
3030 return __builtin_fabs(__x);
3131}
3232
33_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {
33_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fabs(long double __x) _NOEXCEPT {
3434 return __builtin_fabsl(__x);
3535}
3636
3737template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
38_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT {
38_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double fabs(_A1 __x) _NOEXCEPT {
3939 return __builtin_fabs((double)__x);
4040}
4141
lib/libcxx/include/__math/copysign.h+3-4
......@@ -25,17 +25,16 @@ namespace __math {
2525
2626// copysign
2727
28_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float copysign(float __x, float __y) _NOEXCEPT {
2929 return ::__builtin_copysignf(__x, __y);
3030}
3131
32_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double copysign(long double __x, long double __y) _NOEXCEPT {
3333 return ::__builtin_copysignl(__x, __y);
3434}
3535
3636template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type
38copysign(_A1 __x, _A2 __y) _NOEXCEPT {
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type copysign(_A1 __x, _A2 __y) _NOEXCEPT {
3938 return ::__builtin_copysign(__x, __y);
4039}
4140
lib/libcxx/include/__math/exponential_functions.h+1-1
......@@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double pow(long double __x, long double __y) _
160160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
161161inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type pow(_A1 __x, _A2 __y) _NOEXCEPT {
162162 using __result_type = typename __promote<_A1, _A2>::type;
163 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
164164 return __math::pow((__result_type)__x, (__result_type)__y);
165165}
166166
lib/libcxx/include/__math/fdim.h+1-1
......@@ -37,7 +37,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fdim(long double __x, long double __y)
3737template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
3838inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fdim(_A1 __x, _A2 __y) _NOEXCEPT {
3939 using __result_type = typename __promote<_A1, _A2>::type;
40 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
40 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
4141 return __math::fdim((__result_type)__x, (__result_type)__y);
4242}
4343
lib/libcxx/include/__math/fma.h+3-3
......@@ -42,9 +42,9 @@ template <class _A1,
4242 __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value, int> = 0>
4343inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type fma(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
4444 using __result_type = typename __promote<_A1, _A2, _A3>::type;
45 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value &&
46 _IsSame<_A3, __result_type>::value)),
47 "");
45 static_assert(
46 !(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value && _IsSame<_A3, __result_type>::value),
47 "");
4848 return __builtin_fma((__result_type)__x, (__result_type)__y, (__result_type)__z);
4949}
5050
lib/libcxx/include/__math/hypot.h+62-1
......@@ -9,16 +9,25 @@
99#ifndef _LIBCPP___MATH_HYPOT_H
1010#define _LIBCPP___MATH_HYPOT_H
1111
12#include <__algorithm/max.h>
1213#include <__config>
14#include <__math/abs.h>
15#include <__math/exponential_functions.h>
16#include <__math/roots.h>
1317#include <__type_traits/enable_if.h>
1418#include <__type_traits/is_arithmetic.h>
1519#include <__type_traits/is_same.h>
1620#include <__type_traits/promote.h>
21#include <__utility/pair.h>
22#include <limits>
1723
1824#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1925# pragma GCC system_header
2026#endif
2127
28_LIBCPP_PUSH_MACROS
29#include <__undef_macros>
30
2231_LIBCPP_BEGIN_NAMESPACE_STD
2332
2433namespace __math {
......@@ -37,12 +46,64 @@ inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y)
3746template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
3847inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type hypot(_A1 __x, _A2 __y) _NOEXCEPT {
3948 using __result_type = typename __promote<_A1, _A2>::type;
40 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
49 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
4150 return __math::hypot((__result_type)__x, (__result_type)__y);
4251}
4352
53#if _LIBCPP_STD_VER >= 17
54// Computes the three-dimensional hypotenuse: `std::hypot(x,y,z)`.
55// The naive implementation might over-/underflow which is why this implementation is more involved:
56// If the square of an argument might run into issues, we scale the arguments appropriately.
57// See https://github.com/llvm/llvm-project/issues/92782 for a detailed discussion and summary.
58template <class _Real>
59_LIBCPP_HIDE_FROM_ABI _Real __hypot(_Real __x, _Real __y, _Real __z) {
60 // Factors needed to determine if over-/underflow might happen
61 constexpr int __exp = std::numeric_limits<_Real>::max_exponent / 2;
62 const _Real __overflow_threshold = __math::ldexp(_Real(1), __exp);
63 const _Real __overflow_scale = __math::ldexp(_Real(1), -(__exp + 20));
64
65 // Scale arguments depending on their size
66 const _Real __max_abs = std::max(__math::fabs(__x), std::max(__math::fabs(__y), __math::fabs(__z)));
67 _Real __scale;
68 if (__max_abs > __overflow_threshold) { // x*x + y*y + z*z might overflow
69 __scale = __overflow_scale;
70 } else if (__max_abs < 1 / __overflow_threshold) { // x*x + y*y + z*z might underflow
71 __scale = 1 / __overflow_scale;
72 } else {
73 __scale = 1;
74 }
75 __x *= __scale;
76 __y *= __scale;
77 __z *= __scale;
78
79 // Compute hypot of scaled arguments and undo scaling
80 return __math::sqrt(__x * __x + __y * __y + __z * __z) / __scale;
81}
82
83inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) { return __math::__hypot(__x, __y, __z); }
84
85inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) { return __math::__hypot(__x, __y, __z); }
86
87inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
88 return __math::__hypot(__x, __y, __z);
89}
90
91template <class _A1,
92 class _A2,
93 class _A3,
94 std::enable_if_t< is_arithmetic_v<_A1> && is_arithmetic_v<_A2> && is_arithmetic_v<_A3>, int> = 0 >
95_LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2, _A3>::type hypot(_A1 __x, _A2 __y, _A3 __z) _NOEXCEPT {
96 using __result_type = typename __promote<_A1, _A2, _A3>::type;
97 static_assert(!(
98 std::is_same_v<_A1, __result_type> && std::is_same_v<_A2, __result_type> && std::is_same_v<_A3, __result_type>));
99 return __math::__hypot(
100 static_cast<__result_type>(__x), static_cast<__result_type>(__y), static_cast<__result_type>(__z));
101}
102#endif
103
44104} // namespace __math
45105
46106_LIBCPP_END_NAMESPACE_STD
107_LIBCPP_POP_MACROS
47108
48109#endif // _LIBCPP___MATH_HYPOT_H
lib/libcxx/include/__math/inverse_trigonometric_functions.h+1-1
......@@ -88,7 +88,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double atan2(long double __y, long double __x)
8888template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
8989inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type atan2(_A1 __y, _A2 __x) _NOEXCEPT {
9090 using __result_type = typename __promote<_A1, _A2>::type;
91 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
91 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
9292 return __math::atan2((__result_type)__y, (__result_type)__x);
9393}
9494
lib/libcxx/include/__math/min_max.h+10-10
......@@ -25,45 +25,45 @@ namespace __math {
2525
2626// fmax
2727
28_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {
28_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmax(float __x, float __y) _NOEXCEPT {
2929 return __builtin_fmaxf(__x, __y);
3030}
3131
3232template <class = int>
33_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
33_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmax(double __x, double __y) _NOEXCEPT {
3434 return __builtin_fmax(__x, __y);
3535}
3636
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmax(long double __x, long double __y) _NOEXCEPT {
3838 return __builtin_fmaxl(__x, __y);
3939}
4040
4141template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT {
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmax(_A1 __x, _A2 __y) _NOEXCEPT {
4343 using __result_type = typename __promote<_A1, _A2>::type;
44 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
44 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
4545 return __math::fmax((__result_type)__x, (__result_type)__y);
4646}
4747
4848// fmin
4949
50_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {
50_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float fmin(float __x, float __y) _NOEXCEPT {
5151 return __builtin_fminf(__x, __y);
5252}
5353
5454template <class = int>
55_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
55_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double fmin(double __x, double __y) _NOEXCEPT {
5656 return __builtin_fmin(__x, __y);
5757}
5858
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double fmin(long double __x, long double __y) _NOEXCEPT {
6060 return __builtin_fminl(__x, __y);
6161}
6262
6363template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
64_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT {
64_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmin(_A1 __x, _A2 __y) _NOEXCEPT {
6565 using __result_type = typename __promote<_A1, _A2>::type;
66 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
66 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
6767 return __math::fmin((__result_type)__x, (__result_type)__y);
6868}
6969
lib/libcxx/include/__math/modulo.h+1-1
......@@ -39,7 +39,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double fmod(long double __x, long double __y)
3939template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
4040inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type fmod(_A1 __x, _A2 __y) _NOEXCEPT {
4141 using __result_type = typename __promote<_A1, _A2>::type;
42 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
42 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
4343 return __math::fmod((__result_type)__x, (__result_type)__y);
4444}
4545
lib/libcxx/include/__math/remainder.h+2-2
......@@ -40,7 +40,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remainder(long double __x, long double
4040template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
4141inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remainder(_A1 __x, _A2 __y) _NOEXCEPT {
4242 using __result_type = typename __promote<_A1, _A2>::type;
43 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
43 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
4444 return __math::remainder((__result_type)__x, (__result_type)__y);
4545}
4646
......@@ -62,7 +62,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double remquo(long double __x, long double __y
6262template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
6363inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type remquo(_A1 __x, _A2 __y, int* __z) _NOEXCEPT {
6464 using __result_type = typename __promote<_A1, _A2>::type;
65 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
65 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
6666 return __math::remquo((__result_type)__x, (__result_type)__y, __z);
6767}
6868
lib/libcxx/include/__math/roots.h+4-4
......@@ -39,19 +39,19 @@ inline _LIBCPP_HIDE_FROM_ABI double sqrt(_A1 __x) _NOEXCEPT {
3939
4040// cbrt
4141
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); }
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float cbrt(float __x) _NOEXCEPT { return __builtin_cbrtf(__x); }
4343
4444template <class = int>
45_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
45_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double cbrt(double __x) _NOEXCEPT {
4646 return __builtin_cbrt(__x);
4747}
4848
49_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {
49_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double cbrt(long double __x) _NOEXCEPT {
5050 return __builtin_cbrtl(__x);
5151}
5252
5353template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
54_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT {
54_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double cbrt(_A1 __x) _NOEXCEPT {
5555 return __builtin_cbrt((double)__x);
5656}
5757
lib/libcxx/include/__math/rounding_functions.h+25-25
......@@ -26,37 +26,37 @@ namespace __math {
2626
2727// ceil
2828
29_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); }
29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float ceil(float __x) _NOEXCEPT { return __builtin_ceilf(__x); }
3030
3131template <class = int>
32_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
32_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double ceil(double __x) _NOEXCEPT {
3333 return __builtin_ceil(__x);
3434}
3535
36_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {
36_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double ceil(long double __x) _NOEXCEPT {
3737 return __builtin_ceill(__x);
3838}
3939
4040template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
41_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT {
41_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double ceil(_A1 __x) _NOEXCEPT {
4242 return __builtin_ceil((double)__x);
4343}
4444
4545// floor
4646
47_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); }
47_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float floor(float __x) _NOEXCEPT { return __builtin_floorf(__x); }
4848
4949template <class = int>
50_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
50_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double floor(double __x) _NOEXCEPT {
5151 return __builtin_floor(__x);
5252}
5353
54_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {
54_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double floor(long double __x) _NOEXCEPT {
5555 return __builtin_floorl(__x);
5656}
5757
5858template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
59_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT {
59_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double floor(_A1 __x) _NOEXCEPT {
6060 return __builtin_floor((double)__x);
6161}
6262
......@@ -126,21 +126,21 @@ inline _LIBCPP_HIDE_FROM_ABI long lround(_A1 __x) _NOEXCEPT {
126126
127127// nearbyint
128128
129_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {
129_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float nearbyint(float __x) _NOEXCEPT {
130130 return __builtin_nearbyintf(__x);
131131}
132132
133133template <class = int>
134_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
134_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double nearbyint(double __x) _NOEXCEPT {
135135 return __builtin_nearbyint(__x);
136136}
137137
138_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {
138_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double nearbyint(long double __x) _NOEXCEPT {
139139 return __builtin_nearbyintl(__x);
140140}
141141
142142template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
143_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT {
143_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double nearbyint(_A1 __x) _NOEXCEPT {
144144 return __builtin_nearbyint((double)__x);
145145}
146146
......@@ -160,7 +160,7 @@ inline _LIBCPP_HIDE_FROM_ABI long double nextafter(long double __x, long double
160160template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
161161inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type nextafter(_A1 __x, _A2 __y) _NOEXCEPT {
162162 using __result_type = typename __promote<_A1, _A2>::type;
163 static_assert((!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value)), "");
163 static_assert(!(_IsSame<_A1, __result_type>::value && _IsSame<_A2, __result_type>::value), "");
164164 return __math::nextafter((__result_type)__x, (__result_type)__y);
165165}
166166
......@@ -186,55 +186,55 @@ inline _LIBCPP_HIDE_FROM_ABI double nexttoward(_A1 __x, long double __y) _NOEXCE
186186
187187// rint
188188
189_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); }
189_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float rint(float __x) _NOEXCEPT { return __builtin_rintf(__x); }
190190
191191template <class = int>
192_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
192_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double rint(double __x) _NOEXCEPT {
193193 return __builtin_rint(__x);
194194}
195195
196_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT {
196_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double rint(long double __x) _NOEXCEPT {
197197 return __builtin_rintl(__x);
198198}
199199
200200template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
201_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT {
201_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double rint(_A1 __x) _NOEXCEPT {
202202 return __builtin_rint((double)__x);
203203}
204204
205205// round
206206
207_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); }
207_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float round(float __x) _NOEXCEPT { return __builtin_round(__x); }
208208
209209template <class = int>
210_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
210_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double round(double __x) _NOEXCEPT {
211211 return __builtin_round(__x);
212212}
213213
214_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT {
214_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double round(long double __x) _NOEXCEPT {
215215 return __builtin_roundl(__x);
216216}
217217
218218template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
219_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT {
219_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double round(_A1 __x) _NOEXCEPT {
220220 return __builtin_round((double)__x);
221221}
222222
223223// trunc
224224
225_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); }
225_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float trunc(float __x) _NOEXCEPT { return __builtin_trunc(__x); }
226226
227227template <class = int>
228_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
228_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI double trunc(double __x) _NOEXCEPT {
229229 return __builtin_trunc(__x);
230230}
231231
232_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT {
232_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double trunc(long double __x) _NOEXCEPT {
233233 return __builtin_truncl(__x);
234234}
235235
236236template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
237_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT {
237_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double trunc(_A1 __x) _NOEXCEPT {
238238 return __builtin_trunc((double)__x);
239239}
240240
lib/libcxx/include/__math/special_functions.h created+84
......@@ -0,0 +1,84 @@
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___MATH_SPECIAL_FUNCTIONS_H
11#define _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
12
13#include <__config>
14#include <__math/copysign.h>
15#include <__math/traits.h>
16#include <__type_traits/enable_if.h>
17#include <__type_traits/is_integral.h>
18#include <limits>
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#if _LIBCPP_STD_VER >= 17
27
28template <class _Real>
29_LIBCPP_HIDE_FROM_ABI _Real __hermite(unsigned __n, _Real __x) {
30 // The Hermite polynomial H_n(x).
31 // The implementation is based on the recurrence formula: H_{n+1}(x) = 2x H_n(x) - 2n H_{n-1}.
32 // Press, William H., et al. Numerical recipes 3rd edition: The art of scientific computing.
33 // Cambridge university press, 2007, p. 183.
34
35 // NOLINTBEGIN(readability-identifier-naming)
36 if (__math::isnan(__x))
37 return __x;
38
39 _Real __H_0{1};
40 if (__n == 0)
41 return __H_0;
42
43 _Real __H_n_prev = __H_0;
44 _Real __H_n = 2 * __x;
45 for (unsigned __i = 1; __i < __n; ++__i) {
46 _Real __H_n_next = 2 * (__x * __H_n - __i * __H_n_prev);
47 __H_n_prev = __H_n;
48 __H_n = __H_n_next;
49 }
50
51 if (!__math::isfinite(__H_n)) {
52 // Overflow occured. Two possible cases:
53 // n is odd: return infinity of the same sign as x.
54 // n is even: return +Inf
55 _Real __inf = std::numeric_limits<_Real>::infinity();
56 return (__n & 1) ? __math::copysign(__inf, __x) : __inf;
57 }
58 return __H_n;
59 // NOLINTEND(readability-identifier-naming)
60}
61
62inline _LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, double __x) { return std::__hermite(__n, __x); }
63
64inline _LIBCPP_HIDE_FROM_ABI float hermite(unsigned __n, float __x) {
65 // use double internally -- float is too prone to overflow!
66 return static_cast<float>(std::hermite(__n, static_cast<double>(__x)));
67}
68
69inline _LIBCPP_HIDE_FROM_ABI long double hermite(unsigned __n, long double __x) { return std::__hermite(__n, __x); }
70
71inline _LIBCPP_HIDE_FROM_ABI float hermitef(unsigned __n, float __x) { return std::hermite(__n, __x); }
72
73inline _LIBCPP_HIDE_FROM_ABI long double hermitel(unsigned __n, long double __x) { return std::hermite(__n, __x); }
74
75template <class _Integer, std::enable_if_t<std::is_integral_v<_Integer>, int> = 0>
76_LIBCPP_HIDE_FROM_ABI double hermite(unsigned __n, _Integer __x) {
77 return std::hermite(__n, static_cast<double>(__x));
78}
79
80#endif // _LIBCPP_STD_VER >= 17
81
82_LIBCPP_END_NAMESPACE_STD
83
84#endif // _LIBCPP___MATH_SPECIAL_FUNCTIONS_H
lib/libcxx/include/__math/traits.h+35-23
......@@ -29,55 +29,67 @@ namespace __math {
2929// signbit
3030
3131template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
32_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
32_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
3333 return __builtin_signbit(__x);
3434}
3535
3636template <class _A1, __enable_if_t<is_integral<_A1>::value && is_signed<_A1>::value, int> = 0>
37_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
37_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT {
3838 return __x < 0;
3939}
4040
4141template <class _A1, __enable_if_t<is_integral<_A1>::value && !is_signed<_A1>::value, int> = 0>
42_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
42_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool signbit(_A1) _NOEXCEPT {
4343 return false;
4444}
4545
4646// isfinite
4747
4848template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0>
49_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
49_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1 __x) _NOEXCEPT {
5050 return __builtin_isfinite((typename __promote<_A1>::type)__x);
5151}
5252
5353template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0>
54_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
54_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(_A1) _NOEXCEPT {
5555 return true;
5656}
5757
58_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(float __x) _NOEXCEPT {
59 return __builtin_isfinite(__x);
60}
61
62_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(double __x) _NOEXCEPT {
63 return __builtin_isfinite(__x);
64}
65
66_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isfinite(long double __x) _NOEXCEPT {
67 return __builtin_isfinite(__x);
68}
69
5870// isinf
5971
6072template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && numeric_limits<_A1>::has_infinity, int> = 0>
61_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
73_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1 __x) _NOEXCEPT {
6274 return __builtin_isinf((typename __promote<_A1>::type)__x);
6375}
6476
6577template <class _A1, __enable_if_t<is_arithmetic<_A1>::value && !numeric_limits<_A1>::has_infinity, int> = 0>
66_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT {
78_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(_A1) _NOEXCEPT {
6779 return false;
6880}
6981
7082#ifdef _LIBCPP_PREFERRED_OVERLOAD
71_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
83_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(float __x) _NOEXCEPT {
7284 return __builtin_isinf(__x);
7385}
7486
75_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
87_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
7688isinf(double __x) _NOEXCEPT {
7789 return __builtin_isinf(__x);
7890}
7991
80_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
92_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(long double __x) _NOEXCEPT {
8193 return __builtin_isinf(__x);
8294}
8395#endif
......@@ -85,26 +97,26 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
8597// isnan
8698
8799template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
88_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
100_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1 __x) _NOEXCEPT {
89101 return __builtin_isnan(__x);
90102}
91103
92104template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
93_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
105_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(_A1) _NOEXCEPT {
94106 return false;
95107}
96108
97109#ifdef _LIBCPP_PREFERRED_OVERLOAD
98_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
110_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(float __x) _NOEXCEPT {
99111 return __builtin_isnan(__x);
100112}
101113
102_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
114_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI _LIBCPP_PREFERRED_OVERLOAD bool
103115isnan(double __x) _NOEXCEPT {
104116 return __builtin_isnan(__x);
105117}
106118
107_LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
119_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(long double __x) _NOEXCEPT {
108120 return __builtin_isnan(__x);
109121}
110122#endif
......@@ -112,19 +124,19 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
112124// isnormal
113125
114126template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
115_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
127_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
116128 return __builtin_isnormal(__x);
117129}
118130
119131template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
120_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
132_LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnormal(_A1 __x) _NOEXCEPT {
121133 return __x != 0;
122134}
123135
124136// isgreater
125137
126138template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
127_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
139_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 __y) _NOEXCEPT {
128140 using type = typename __promote<_A1, _A2>::type;
129141 return __builtin_isgreater((type)__x, (type)__y);
130142}
......@@ -132,7 +144,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreater(_A1 __x, _A2 _
132144// isgreaterequal
133145
134146template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
135_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
147_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x, _A2 __y) _NOEXCEPT {
136148 using type = typename __promote<_A1, _A2>::type;
137149 return __builtin_isgreaterequal((type)__x, (type)__y);
138150}
......@@ -140,7 +152,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isgreaterequal(_A1 __x,
140152// isless
141153
142154template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
143_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
155_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y) _NOEXCEPT {
144156 using type = typename __promote<_A1, _A2>::type;
145157 return __builtin_isless((type)__x, (type)__y);
146158}
......@@ -148,7 +160,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isless(_A1 __x, _A2 __y)
148160// islessequal
149161
150162template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
151_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
163_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2 __y) _NOEXCEPT {
152164 using type = typename __promote<_A1, _A2>::type;
153165 return __builtin_islessequal((type)__x, (type)__y);
154166}
......@@ -156,7 +168,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessequal(_A1 __x, _A2
156168// islessgreater
157169
158170template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
159_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
171_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _A2 __y) _NOEXCEPT {
160172 using type = typename __promote<_A1, _A2>::type;
161173 return __builtin_islessgreater((type)__x, (type)__y);
162174}
......@@ -164,7 +176,7 @@ _LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool islessgreater(_A1 __x, _
164176// isunordered
165177
166178template <class _A1, class _A2, __enable_if_t<is_arithmetic<_A1>::value && is_arithmetic<_A2>::value, int> = 0>
167_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
179_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI bool isunordered(_A1 __x, _A2 __y) _NOEXCEPT {
168180 using type = typename __promote<_A1, _A2>::type;
169181 return __builtin_isunordered((type)__x, (type)__y);
170182}
lib/libcxx/include/__mdspan/extents.h+19-6
......@@ -137,9 +137,9 @@ private:
137137 // static mapping of indices to the position in the dynamic values array
138138 using _DynamicIdxMap = __static_partial_sums<static_cast<size_t>(_Values == _DynTag)...>;
139139
140 template <size_t... Indices>
141 _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<Indices...>) noexcept {
142 return _DynamicValues{((void)Indices, 0)...};
140 template <size_t... _Indices>
141 _LIBCPP_HIDE_FROM_ABI static constexpr _DynamicValues __zeros(index_sequence<_Indices...>) noexcept {
142 return _DynamicValues{((void)_Indices, 0)...};
143143 }
144144
145145public:
......@@ -165,7 +165,7 @@ public:
165165 template <class... _DynVals>
166166 requires(sizeof...(_DynVals) != __size_dynamic_)
167167 _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(_DynVals... __vals) {
168 static_assert((sizeof...(_DynVals) == __size_), "Invalid number of values.");
168 static_assert(sizeof...(_DynVals) == __size_, "Invalid number of values.");
169169 _TDynamic __values[__size_] = {static_cast<_TDynamic>(__vals)...};
170170 for (size_t __i = 0; __i < __size_; __i++) {
171171 _TStatic __static_val = _StaticValues::__get(__i);
......@@ -185,7 +185,7 @@ public:
185185 template <class _Tp, size_t _Size>
186186 requires(_Size != __size_dynamic_)
187187 _LIBCPP_HIDE_FROM_ABI constexpr __maybe_static_array(const span<_Tp, _Size>& __vals) {
188 static_assert((_Size == __size_) || (__size_ == dynamic_extent));
188 static_assert(_Size == __size_ || __size_ == dynamic_extent);
189189 for (size_t __i = 0; __i < __size_; __i++) {
190190 _TStatic __static_val = _StaticValues::__get(__i);
191191 if (__static_val == _DynTag) {
......@@ -454,9 +454,22 @@ struct __make_dextents< _IndexType, 0, extents<_IndexType, _ExtentsPack...>> {
454454template <class _IndexType, size_t _Rank>
455455using dextents = typename __mdspan_detail::__make_dextents<_IndexType, _Rank>::type;
456456
457# if _LIBCPP_STD_VER >= 26
458// [mdspan.extents.dims], alias template `dims`
459template <size_t _Rank, class _IndexType = size_t>
460using dims = dextents<_IndexType, _Rank>;
461# endif
462
457463// Deduction guide for extents
464# if _LIBCPP_STD_VER >= 26
465template <class... _IndexTypes>
466 requires(is_convertible_v<_IndexTypes, size_t> && ...)
467explicit extents(_IndexTypes...) -> extents<size_t, __maybe_static_ext<_IndexTypes>...>;
468# else
458469template <class... _IndexTypes>
459extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>;
470 requires(is_convertible_v<_IndexTypes, size_t> && ...)
471explicit extents(_IndexTypes...) -> extents<size_t, size_t(((void)sizeof(_IndexTypes), dynamic_extent))...>;
472# endif
460473
461474namespace __mdspan_detail {
462475
lib/libcxx/include/__mdspan/layout_left.h+1-1
......@@ -67,7 +67,7 @@ private:
6767 return true;
6868 }
6969
70 static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()),
70 static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()),
7171 "layout_left::mapping product of static extents must be representable as index_type.");
7272
7373public:
lib/libcxx/include/__mdspan/layout_right.h+1-1
......@@ -66,7 +66,7 @@ private:
6666 return true;
6767 }
6868
69 static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()),
69 static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()),
7070 "layout_right::mapping product of static extents must be representable as index_type.");
7171
7272public:
lib/libcxx/include/__mdspan/layout_stride.h+1-1
......@@ -149,7 +149,7 @@ private:
149149 }
150150 }
151151
152 static_assert((extents_type::rank_dynamic() > 0) || __required_span_size_is_representable(extents_type()),
152 static_assert(extents_type::rank_dynamic() > 0 || __required_span_size_is_representable(extents_type()),
153153 "layout_stride::mapping product of static extents must be representable as index_type.");
154154
155155public:
lib/libcxx/include/__mdspan/mdspan.h+9-3
......@@ -27,7 +27,6 @@
2727#include <__type_traits/is_array.h>
2828#include <__type_traits/is_constructible.h>
2929#include <__type_traits/is_convertible.h>
30#include <__type_traits/is_default_constructible.h>
3130#include <__type_traits/is_nothrow_constructible.h>
3231#include <__type_traits/is_pointer.h>
3332#include <__type_traits/is_same.h>
......@@ -267,10 +266,17 @@ private:
267266 friend class mdspan;
268267};
269268
269# if _LIBCPP_STD_VER >= 26
270270template <class _ElementType, class... _OtherIndexTypes>
271271 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
272explicit mdspan(_ElementType*, _OtherIndexTypes...)
273 -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>;
272explicit mdspan(_ElementType*,
273 _OtherIndexTypes...) -> mdspan<_ElementType, extents<size_t, __maybe_static_ext<_OtherIndexTypes>...>>;
274# else
275template <class _ElementType, class... _OtherIndexTypes>
276 requires((is_convertible_v<_OtherIndexTypes, size_t> && ...) && (sizeof...(_OtherIndexTypes) > 0))
277explicit mdspan(_ElementType*,
278 _OtherIndexTypes...) -> mdspan<_ElementType, dextents<size_t, sizeof...(_OtherIndexTypes)>>;
279# endif
274280
275281template <class _Pointer>
276282 requires(is_pointer_v<remove_reference_t<_Pointer>>)
lib/libcxx/include/__memory/allocate_at_least.h+6-20
......@@ -20,28 +20,14 @@
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
2222#if _LIBCPP_STD_VER >= 23
23template <class _Pointer>
24struct allocation_result {
25 _Pointer ptr;
26 size_t count;
27};
28_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
29
30template <class _Alloc>
31[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<typename allocator_traits<_Alloc>::pointer>
32allocate_at_least(_Alloc& __alloc, size_t __n) {
33 if constexpr (requires { __alloc.allocate_at_least(__n); }) {
34 return __alloc.allocate_at_least(__n);
35 } else {
36 return {__alloc.allocate(__n), __n};
37 }
38}
3923
4024template <class _Alloc>
4125[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) {
42 return std::allocate_at_least(__alloc, __n);
26 return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n);
4327}
28
4429#else
30
4531template <class _Pointer>
4632struct __allocation_result {
4733 _Pointer ptr;
......@@ -49,9 +35,9 @@ struct __allocation_result {
4935};
5036
5137template <class _Alloc>
52_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
53 __allocation_result<typename allocator_traits<_Alloc>::pointer>
54 __allocate_at_least(_Alloc& __alloc, size_t __n) {
38_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI
39_LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer>
40__allocate_at_least(_Alloc& __alloc, size_t __n) {
5541 return {__alloc.allocate(__n), __n};
5642}
5743
lib/libcxx/include/__memory/allocator.h+21-27
......@@ -14,6 +14,7 @@
1414#include <__memory/addressof.h>
1515#include <__memory/allocate_at_least.h>
1616#include <__memory/allocator_traits.h>
17#include <__type_traits/is_const.h>
1718#include <__type_traits/is_constant_evaluated.h>
1819#include <__type_traits/is_same.h>
1920#include <__type_traits/is_void.h>
......@@ -31,19 +32,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3132template <class _Tp>
3233class allocator;
3334
34#if defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
35# pragma clang deprecated( \
36 _LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS, \
37 "_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS is deprecated in LLVM 18 and will be removed in LLVM 19")
38#endif
39
40#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION)
35#if _LIBCPP_STD_VER <= 17
4136// These specializations shouldn't be marked _LIBCPP_DEPRECATED_IN_CXX17.
4237// Specializing allocator<void> is deprecated, but not using it.
4338template <>
4439class _LIBCPP_TEMPLATE_VIS allocator<void> {
45# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
46
4740public:
4841 _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer;
4942 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
......@@ -53,13 +46,12 @@ public:
5346 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
5447 typedef allocator<_Up> other;
5548 };
56# endif
5749};
5850
51// TODO(LLVM 20): Remove the escape hatch
52# ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
5953template <>
6054class _LIBCPP_TEMPLATE_VIS allocator<const void> {
61# if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
62
6355public:
6456 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer;
6557 _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer;
......@@ -69,9 +61,9 @@ public:
6961 struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {
7062 typedef allocator<_Up> other;
7163 };
72# endif
7364};
74#endif
65# endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
66#endif // _LIBCPP_STD_VER <= 17
7567
7668// This class provides a non-trivial default constructor to the class that derives from it
7769// if the condition is satisfied.
......@@ -100,6 +92,7 @@ struct __non_trivial_if<true, _Unique> {
10092
10193template <class _Tp>
10294class _LIBCPP_TEMPLATE_VIS allocator : private __non_trivial_if<!is_void<_Tp>::value, allocator<_Tp> > {
95 static_assert(!is_const<_Tp>::value, "std::allocator does not support const types");
10396 static_assert(!is_volatile<_Tp>::value, "std::allocator does not support volatile types");
10497
10598public:
......@@ -116,7 +109,7 @@ public:
116109 template <class _Up>
117110 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}
118111
119 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {
112 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* allocate(size_t __n) {
120113 if (__n > allocator_traits<allocator>::max_size(*this))
121114 __throw_bad_array_new_length();
122115 if (__libcpp_is_constant_evaluated()) {
......@@ -141,7 +134,7 @@ public:
141134 }
142135
143136 // C++20 Removed members
144#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
137#if _LIBCPP_STD_VER <= 17
145138 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer;
146139 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
147140 _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference;
......@@ -159,8 +152,7 @@ public:
159152 return std::addressof(__x);
160153 }
161154
162 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp*
163 allocate(size_t __n, const void*) {
155 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 _Tp* allocate(size_t __n, const void*) {
164156 return allocate(__n);
165157 }
166158
......@@ -177,6 +169,8 @@ public:
177169#endif
178170};
179171
172// TODO(LLVM 20): Remove the escape hatch
173#ifdef _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
180174template <class _Tp>
181175class _LIBCPP_TEMPLATE_VIS allocator<const _Tp>
182176 : private __non_trivial_if<!is_void<_Tp>::value, allocator<const _Tp> > {
......@@ -187,16 +181,16 @@ public:
187181 typedef ptrdiff_t difference_type;
188182 typedef const _Tp value_type;
189183 typedef true_type propagate_on_container_move_assignment;
190#if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
184# if _LIBCPP_STD_VER <= 23 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_ALLOCATOR_MEMBERS)
191185 _LIBCPP_DEPRECATED_IN_CXX23 typedef true_type is_always_equal;
192#endif
186# endif
193187
194188 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator() _NOEXCEPT = default;
195189
196190 template <class _Up>
197191 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 allocator(const allocator<_Up>&) _NOEXCEPT {}
198192
199 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) {
193 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const _Tp* allocate(size_t __n) {
200194 if (__n > allocator_traits<allocator>::max_size(*this))
201195 __throw_bad_array_new_length();
202196 if (__libcpp_is_constant_evaluated()) {
......@@ -206,11 +200,11 @@ public:
206200 }
207201 }
208202
209#if _LIBCPP_STD_VER >= 23
203# if _LIBCPP_STD_VER >= 23
210204 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr allocation_result<const _Tp*> allocate_at_least(size_t __n) {
211205 return {allocate(__n), __n};
212206 }
213#endif
207# endif
214208
215209 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void deallocate(const _Tp* __p, size_t __n) {
216210 if (__libcpp_is_constant_evaluated()) {
......@@ -221,7 +215,7 @@ public:
221215 }
222216
223217 // C++20 Removed members
224#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS)
218# if _LIBCPP_STD_VER <= 17
225219 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer;
226220 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer;
227221 _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference;
......@@ -236,8 +230,7 @@ public:
236230 return std::addressof(__x);
237231 }
238232
239 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp*
240 allocate(size_t __n, const void*) {
233 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_IN_CXX17 const _Tp* allocate(size_t __n, const void*) {
241234 return allocate(__n);
242235 }
243236
......@@ -251,8 +244,9 @@ public:
251244 }
252245
253246 _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_HIDE_FROM_ABI void destroy(pointer __p) { __p->~_Tp(); }
254#endif
247# endif
255248};
249#endif // _LIBCPP_ENABLE_REMOVED_ALLOCATOR_CONST
256250
257251template <class _Tp, class _Up>
258252inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
lib/libcxx/include/__memory/allocator_traits.h+52-33
......@@ -14,14 +14,15 @@
1414#include <__memory/construct_at.h>
1515#include <__memory/pointer_traits.h>
1616#include <__type_traits/enable_if.h>
17#include <__type_traits/is_copy_constructible.h>
17#include <__type_traits/is_constructible.h>
1818#include <__type_traits/is_empty.h>
19#include <__type_traits/is_move_constructible.h>
19#include <__type_traits/is_same.h>
2020#include <__type_traits/make_unsigned.h>
2121#include <__type_traits/remove_reference.h>
2222#include <__type_traits/void_t.h>
2323#include <__utility/declval.h>
2424#include <__utility/forward.h>
25#include <cstddef>
2526#include <limits>
2627
2728#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -40,7 +41,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
4041 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY > > : true_type {}
4142
4243// __pointer
43_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer);
4444template <class _Tp,
4545 class _Alloc,
4646 class _RawAlloc = __libcpp_remove_reference_t<_Alloc>,
......@@ -231,6 +231,17 @@ struct __has_select_on_container_copy_construction<
231231
232232_LIBCPP_SUPPRESS_DEPRECATED_POP
233233
234#if _LIBCPP_STD_VER >= 23
235
236template <class _Pointer, class _SizeType = size_t>
237struct allocation_result {
238 _Pointer ptr;
239 _SizeType count;
240};
241_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(allocation_result);
242
243#endif // _LIBCPP_STD_VER
244
234245template <class _Alloc>
235246struct _LIBCPP_TEMPLATE_VIS allocator_traits {
236247 using allocator_type = _Alloc;
......@@ -264,32 +275,44 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
264275 };
265276#endif // _LIBCPP_CXX03_LANG
266277
267 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
278 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
268279 allocate(allocator_type& __a, size_type __n) {
269280 return __a.allocate(__n);
270281 }
271282
272 template <class _Ap = _Alloc, class = __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
273 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
283 template <class _Ap = _Alloc, __enable_if_t<__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>
284 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
274285 allocate(allocator_type& __a, size_type __n, const_void_pointer __hint) {
275286 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
276287 return __a.allocate(__n, __hint);
277288 _LIBCPP_SUPPRESS_DEPRECATED_POP
278289 }
279 template <class _Ap = _Alloc,
280 class = void,
281 class = __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value> >
282 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
290 template <class _Ap = _Alloc,
291 class = void,
292 __enable_if_t<!__has_allocate_hint<_Ap, size_type, const_void_pointer>::value, int> = 0>
293 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static pointer
283294 allocate(allocator_type& __a, size_type __n, const_void_pointer) {
284295 return __a.allocate(__n);
285296 }
286297
298#if _LIBCPP_STD_VER >= 23
299 template <class _Ap = _Alloc>
300 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr allocation_result<pointer, size_type>
301 allocate_at_least(_Ap& __alloc, size_type __n) {
302 if constexpr (requires { __alloc.allocate_at_least(__n); }) {
303 return __alloc.allocate_at_least(__n);
304 } else {
305 return {__alloc.allocate(__n), __n};
306 }
307 }
308#endif
309
287310 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
288311 deallocate(allocator_type& __a, pointer __p, size_type __n) _NOEXCEPT {
289312 __a.deallocate(__p, __n);
290313 }
291314
292 template <class _Tp, class... _Args, class = __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value> >
315 template <class _Tp, class... _Args, __enable_if_t<__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0>
293316 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
294317 construct(allocator_type& __a, _Tp* __p, _Args&&... __args) {
295318 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
......@@ -298,43 +321,43 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits {
298321 }
299322 template <class _Tp,
300323 class... _Args,
301 class = void,
302 class = __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value> >
324 class = void,
325 __enable_if_t<!__has_construct<allocator_type, _Tp*, _Args...>::value, int> = 0>
303326 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void
304327 construct(allocator_type&, _Tp* __p, _Args&&... __args) {
305328 std::__construct_at(__p, std::forward<_Args>(__args)...);
306329 }
307330
308 template <class _Tp, class = __enable_if_t<__has_destroy<allocator_type, _Tp*>::value> >
331 template <class _Tp, __enable_if_t<__has_destroy<allocator_type, _Tp*>::value, int> = 0>
309332 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type& __a, _Tp* __p) {
310333 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
311334 __a.destroy(__p);
312335 _LIBCPP_SUPPRESS_DEPRECATED_POP
313336 }
314 template <class _Tp, class = void, class = __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value> >
337 template <class _Tp, class = void, __enable_if_t<!__has_destroy<allocator_type, _Tp*>::value, int> = 0>
315338 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void destroy(allocator_type&, _Tp* __p) {
316339 std::__destroy_at(__p);
317340 }
318341
319 template <class _Ap = _Alloc, class = __enable_if_t<__has_max_size<const _Ap>::value> >
342 template <class _Ap = _Alloc, __enable_if_t<__has_max_size<const _Ap>::value, int> = 0>
320343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type& __a) _NOEXCEPT {
321344 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
322345 return __a.max_size();
323346 _LIBCPP_SUPPRESS_DEPRECATED_POP
324347 }
325 template <class _Ap = _Alloc, class = void, class = __enable_if_t<!__has_max_size<const _Ap>::value> >
348 template <class _Ap = _Alloc, class = void, __enable_if_t<!__has_max_size<const _Ap>::value, int> = 0>
326349 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type max_size(const allocator_type&) _NOEXCEPT {
327350 return numeric_limits<size_type>::max() / sizeof(value_type);
328351 }
329352
330 template <class _Ap = _Alloc, class = __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value> >
353 template <class _Ap = _Alloc, __enable_if_t<__has_select_on_container_copy_construction<const _Ap>::value, int> = 0>
331354 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
332355 select_on_container_copy_construction(const allocator_type& __a) {
333356 return __a.select_on_container_copy_construction();
334357 }
335 template <class _Ap = _Alloc,
336 class = void,
337 class = __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value> >
358 template <class _Ap = _Alloc,
359 class = void,
360 __enable_if_t<!__has_select_on_container_copy_construction<const _Ap>::value, int> = 0>
338361 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static allocator_type
339362 select_on_container_copy_construction(const allocator_type& __a) {
340363 return __a;
......@@ -349,6 +372,14 @@ template <class _Traits, class _Tp>
349372using __rebind_alloc = typename _Traits::template rebind_alloc<_Tp>::other;
350373#endif
351374
375template <class _Alloc>
376struct __check_valid_allocator : true_type {
377 using _Traits = std::allocator_traits<_Alloc>;
378 static_assert(is_same<_Alloc, __rebind_alloc<_Traits, typename _Traits::value_type> >::value,
379 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
380 "original allocator");
381};
382
352383// __is_default_allocator
353384template <class _Tp>
354385struct __is_default_allocator : false_type {};
......@@ -384,18 +415,6 @@ struct __is_cpp17_copy_insertable<
384415 __has_construct<_Alloc, typename _Alloc::value_type*, const typename _Alloc::value_type&>::value > >
385416 : __is_cpp17_move_insertable<_Alloc> {};
386417
387// ASan choices
388#ifndef _LIBCPP_HAS_NO_ASAN
389# define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1
390#endif
391
392#ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS
393template <class _Alloc>
394struct __asan_annotate_container_with_allocator : true_type {};
395template <class _Tp>
396struct __asan_annotate_container_with_allocator<allocator<_Tp> > : true_type {};
397#endif
398
399418#undef _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX
400419
401420_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__memory/compressed_pair.h+9-9
......@@ -11,13 +11,12 @@
1111#define _LIBCPP___MEMORY_COMPRESSED_PAIR_H
1212
1313#include <__config>
14#include <__fwd/get.h>
1514#include <__fwd/tuple.h>
1615#include <__tuple/tuple_indices.h>
1716#include <__type_traits/decay.h>
1817#include <__type_traits/dependent_type.h>
1918#include <__type_traits/enable_if.h>
20#include <__type_traits/is_default_constructible.h>
19#include <__type_traits/is_constructible.h>
2120#include <__type_traits/is_empty.h>
2221#include <__type_traits/is_final.h>
2322#include <__type_traits/is_same.h>
......@@ -49,7 +48,7 @@ struct __compressed_pair_elem {
4948 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
5049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_() {}
5150
52 template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> >
51 template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0>
5352 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u)
5453 : __value_(std::forward<_Up>(__u)) {}
5554
......@@ -78,7 +77,7 @@ struct __compressed_pair_elem<_Tp, _Idx, true> : private _Tp {
7877 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__default_init_tag) {}
7978 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(__value_init_tag) : __value_type() {}
8079
81 template <class _Up, class = __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value> >
80 template <class _Up, __enable_if_t<!is_same<__compressed_pair_elem, __decay_t<_Up> >::value, int> = 0>
8281 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair_elem(_Up&& __u)
8382 : __value_type(std::forward<_Up>(__u)) {}
8483
......@@ -108,9 +107,10 @@ public:
108107 using _Base1 _LIBCPP_NODEBUG = __compressed_pair_elem<_T1, 0>;
109108 using _Base2 _LIBCPP_NODEBUG = __compressed_pair_elem<_T2, 1>;
110109
111 template <bool _Dummy = true,
112 class = __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
113 __dependent_type<is_default_constructible<_T2>, _Dummy>::value > >
110 template <bool _Dummy = true,
111 __enable_if_t< __dependent_type<is_default_constructible<_T1>, _Dummy>::value &&
112 __dependent_type<is_default_constructible<_T2>, _Dummy>::value,
113 int> = 0>
114114 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __compressed_pair()
115115 : _Base1(__value_init_tag()), _Base2(__value_init_tag()) {}
116116
......@@ -150,7 +150,7 @@ public:
150150 }
151151
152152 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__compressed_pair& __x)
153 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) {
153 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
154154 using std::swap;
155155 swap(first(), __x.first());
156156 swap(second(), __x.second());
......@@ -160,7 +160,7 @@ public:
160160template <class _T1, class _T2>
161161inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
162162swap(__compressed_pair<_T1, _T2>& __x, __compressed_pair<_T1, _T2>& __y)
163 _NOEXCEPT_(__is_nothrow_swappable<_T1>::value&& __is_nothrow_swappable<_T2>::value) {
163 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
164164 __x.swap(__y);
165165}
166166
lib/libcxx/include/__memory/construct_at.h+1-1
......@@ -44,7 +44,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp* construct_at(_Tp* __location, _Args&&... __
4444#endif
4545
4646template <class _Tp, class... _Args, class = decltype(::new(std::declval<void*>()) _Tp(std::declval<_Args>()...))>
47_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
47_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp* __construct_at(_Tp* __location, _Args&&... __args) {
4848#if _LIBCPP_STD_VER >= 20
4949 return std::construct_at(__location, std::forward<_Args>(__args)...);
5050#else
lib/libcxx/include/__memory/inout_ptr.h created+109
......@@ -0,0 +1,109 @@
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___INOUT_PTR_H
11#define _LIBCPP___INOUT_PTR_H
12
13#include <__config>
14#include <__memory/addressof.h>
15#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>
18#include <__type_traits/is_same.h>
19#include <__type_traits/is_specialization.h>
20#include <__type_traits/is_void.h>
21#include <__utility/forward.h>
22#include <__utility/move.h>
23#include <tuple>
24
25#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
26# pragma GCC system_header
27#endif
28
29_LIBCPP_PUSH_MACROS
30#include <__undef_macros>
31
32_LIBCPP_BEGIN_NAMESPACE_STD
33
34#if _LIBCPP_STD_VER >= 23
35
36template <class _Smart, class _Pointer, class... _Args>
37class _LIBCPP_TEMPLATE_VIS inout_ptr_t {
38 static_assert(!__is_specialization_v<_Smart, shared_ptr>, "std::shared_ptr<> is not supported with std::inout_ptr.");
39
40public:
41 _LIBCPP_HIDE_FROM_ABI explicit inout_ptr_t(_Smart& __smart, _Args... __args)
42 : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_([&__smart] {
43 if constexpr (is_pointer_v<_Smart>) {
44 return __smart;
45 } else {
46 return __smart.get();
47 }
48 }()) {
49 if constexpr (requires { __s_.release(); }) {
50 __s_.release();
51 } else {
52 __s_ = _Smart();
53 }
54 }
55
56 _LIBCPP_HIDE_FROM_ABI inout_ptr_t(const inout_ptr_t&) = delete;
57
58 _LIBCPP_HIDE_FROM_ABI ~inout_ptr_t() {
59 // LWG-3897 inout_ptr will not update raw pointer to null
60 if constexpr (!is_pointer_v<_Smart>) {
61 if (!__p_) {
62 return;
63 }
64 }
65
66 using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
67 if constexpr (is_pointer_v<_Smart>) {
68 std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
69 std::move(__a_));
70 } else if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
71 std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
72 std::move(__a_));
73 } else {
74 static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
75 "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
76 std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
77 std::move(__a_));
78 }
79 }
80
81 _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); }
82
83 _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept
84 requires(!is_same_v<_Pointer, void*>)
85 {
86 static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer.");
87
88 return reinterpret_cast<void**>(static_cast<_Pointer*>(*this));
89 }
90
91private:
92 _Smart& __s_;
93 tuple<_Args...> __a_;
94 _Pointer __p_;
95};
96
97template <class _Pointer = void, class _Smart, class... _Args>
98_LIBCPP_HIDE_FROM_ABI auto inout_ptr(_Smart& __s, _Args&&... __args) {
99 using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>;
100 return std::inout_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
101}
102
103#endif // _LIBCPP_STD_VER >= 23
104
105_LIBCPP_END_NAMESPACE_STD
106
107_LIBCPP_POP_MACROS
108
109#endif // _LIBCPP___INOUT_PTR_H
lib/libcxx/include/__memory/out_ptr.h created+101
......@@ -0,0 +1,101 @@
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___OUT_PTR_H
11#define _LIBCPP___OUT_PTR_H
12
13#include <__config>
14#include <__memory/addressof.h>
15#include <__memory/pointer_traits.h>
16#include <__memory/shared_ptr.h>
17#include <__memory/unique_ptr.h>
18#include <__type_traits/is_specialization.h>
19#include <__type_traits/is_void.h>
20#include <__utility/forward.h>
21#include <__utility/move.h>
22#include <tuple>
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
35template <class _Smart, class _Pointer, class... _Args>
36class _LIBCPP_TEMPLATE_VIS out_ptr_t {
37 static_assert(!__is_specialization_v<_Smart, shared_ptr> || sizeof...(_Args) > 0,
38 "Using std::shared_ptr<> without a deleter in std::out_ptr is not supported.");
39
40public:
41 _LIBCPP_HIDE_FROM_ABI explicit out_ptr_t(_Smart& __smart, _Args... __args)
42 : __s_(__smart), __a_(std::forward<_Args>(__args)...), __p_() {
43 using _Ptr = decltype(__smart);
44 if constexpr (__resettable_smart_pointer<_Ptr>) {
45 __s_.reset();
46 } else if constexpr (is_constructible_v<_Smart>) {
47 __s_ = _Smart();
48 } else {
49 static_assert(__resettable_smart_pointer<_Ptr> || is_constructible_v<_Smart>,
50 "The adapted pointer type must have a reset() member function or be default constructible.");
51 }
52 }
53
54 _LIBCPP_HIDE_FROM_ABI out_ptr_t(const out_ptr_t&) = delete;
55
56 _LIBCPP_HIDE_FROM_ABI ~out_ptr_t() {
57 if (!__p_) {
58 return;
59 }
60
61 using _SmartPtr = __pointer_of_or_t<_Smart, _Pointer>;
62 if constexpr (__resettable_smart_pointer_with_args<_Smart, _Pointer, _Args...>) {
63 std::apply([&](auto&&... __args) { __s_.reset(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
64 std::move(__a_));
65 } else {
66 static_assert(is_constructible_v<_Smart, _SmartPtr, _Args...>,
67 "The smart pointer must be constructible from arguments of types _Smart, _Pointer, _Args...");
68 std::apply([&](auto&&... __args) { __s_ = _Smart(static_cast<_SmartPtr>(__p_), std::forward<_Args>(__args)...); },
69 std::move(__a_));
70 }
71 }
72
73 _LIBCPP_HIDE_FROM_ABI operator _Pointer*() const noexcept { return std::addressof(const_cast<_Pointer&>(__p_)); }
74
75 _LIBCPP_HIDE_FROM_ABI operator void**() const noexcept
76 requires(!is_same_v<_Pointer, void*>)
77 {
78 static_assert(is_pointer_v<_Pointer>, "The conversion to void** requires _Pointer to be a raw pointer.");
79
80 return reinterpret_cast<void**>(static_cast<_Pointer*>(*this));
81 }
82
83private:
84 _Smart& __s_;
85 tuple<_Args...> __a_;
86 _Pointer __p_ = _Pointer();
87};
88
89template <class _Pointer = void, class _Smart, class... _Args>
90_LIBCPP_HIDE_FROM_ABI auto out_ptr(_Smart& __s, _Args&&... __args) {
91 using _Ptr = conditional_t<is_void_v<_Pointer>, __pointer_of_t<_Smart>, _Pointer>;
92 return std::out_ptr_t<_Smart, _Ptr, _Args&&...>(__s, std::forward<_Args>(__args)...);
93}
94
95#endif // _LIBCPP_STD_VER >= 23
96
97_LIBCPP_END_NAMESPACE_STD
98
99_LIBCPP_POP_MACROS
100
101#endif // _LIBCPP___OUT_PTR_H
lib/libcxx/include/__memory/pointer_traits.h+76-14
......@@ -20,19 +20,28 @@
2020#include <__type_traits/is_void.h>
2121#include <__type_traits/void_t.h>
2222#include <__utility/declval.h>
23#include <__utility/forward.h>
2324#include <cstddef>
2425
2526#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2627# pragma GCC system_header
2728#endif
2829
30_LIBCPP_PUSH_MACROS
31#include <__undef_macros>
32
2933_LIBCPP_BEGIN_NAMESPACE_STD
3034
31template <class _Tp, class = void>
32struct __has_element_type : false_type {};
35// clang-format off
36#define _LIBCPP_CLASS_TRAITS_HAS_XXX(NAME, PROPERTY) \
37 template <class _Tp, class = void> \
38 struct NAME : false_type {}; \
39 template <class _Tp> \
40 struct NAME<_Tp, __void_t<typename _Tp::PROPERTY> > : true_type {}
41// clang-format on
3342
34template <class _Tp>
35struct __has_element_type<_Tp, __void_t<typename _Tp::element_type> > : true_type {};
43_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_pointer, pointer);
44_LIBCPP_CLASS_TRAITS_HAS_XXX(__has_element_type, element_type);
3645
3746template <class _Ptr, bool = __has_element_type<_Ptr>::value>
3847struct __pointer_traits_element_type {};
......@@ -201,17 +210,17 @@ struct _IsFancyPointer {
201210};
202211
203212// enable_if is needed here to avoid instantiating checks for fancy pointers on raw pointers
204template <class _Pointer, class = __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value > >
205_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR
206 __decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>
207 __to_address(const _Pointer& __p) _NOEXCEPT {
213template <class _Pointer, __enable_if_t< _And<is_class<_Pointer>, _IsFancyPointer<_Pointer> >::value, int> = 0>
214_LIBCPP_HIDE_FROM_ABI
215_LIBCPP_CONSTEXPR __decay_t<decltype(__to_address_helper<_Pointer>::__call(std::declval<const _Pointer&>()))>
216__to_address(const _Pointer& __p) _NOEXCEPT {
208217 return __to_address_helper<_Pointer>::__call(__p);
209218}
210219
211220template <class _Pointer, class>
212221struct __to_address_helper {
213 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static decltype(std::__to_address(
214 std::declval<const _Pointer&>().operator->()))
222 _LIBCPP_HIDE_FROM_ABI
223 _LIBCPP_CONSTEXPR static decltype(std::__to_address(std::declval<const _Pointer&>().operator->()))
215224 __call(const _Pointer& __p) _NOEXCEPT {
216225 return std::__to_address(__p.operator->());
217226 }
......@@ -220,8 +229,8 @@ struct __to_address_helper {
220229template <class _Pointer>
221230struct __to_address_helper<_Pointer,
222231 decltype((void)pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))> {
223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR static decltype(pointer_traits<_Pointer>::to_address(
224 std::declval<const _Pointer&>()))
232 _LIBCPP_HIDE_FROM_ABI
233 _LIBCPP_CONSTEXPR static decltype(pointer_traits<_Pointer>::to_address(std::declval<const _Pointer&>()))
225234 __call(const _Pointer& __p) _NOEXCEPT {
226235 return pointer_traits<_Pointer>::to_address(__p);
227236 }
......@@ -234,12 +243,65 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(_Tp* __p) noexcept {
234243}
235244
236245template <class _Pointer>
237inline _LIBCPP_HIDE_FROM_ABI constexpr auto to_address(const _Pointer& __p) noexcept
238 -> decltype(std::__to_address(__p)) {
246inline _LIBCPP_HIDE_FROM_ABI constexpr auto
247to_address(const _Pointer& __p) noexcept -> decltype(std::__to_address(__p)) {
239248 return std::__to_address(__p);
240249}
241250#endif
242251
252#if _LIBCPP_STD_VER >= 23
253
254template <class _Tp>
255struct __pointer_of {};
256
257template <class _Tp>
258 requires(__has_pointer<_Tp>::value)
259struct __pointer_of<_Tp> {
260 using type = typename _Tp::pointer;
261};
262
263template <class _Tp>
264 requires(!__has_pointer<_Tp>::value && __has_element_type<_Tp>::value)
265struct __pointer_of<_Tp> {
266 using type = typename _Tp::element_type*;
267};
268
269template <class _Tp>
270 requires(!__has_pointer<_Tp>::value && !__has_element_type<_Tp>::value &&
271 __has_element_type<pointer_traits<_Tp>>::value)
272struct __pointer_of<_Tp> {
273 using type = typename pointer_traits<_Tp>::element_type*;
274};
275
276template <typename _Tp>
277using __pointer_of_t = typename __pointer_of<_Tp>::type;
278
279template <class _Tp, class _Up>
280struct __pointer_of_or {
281 using type _LIBCPP_NODEBUG = _Up;
282};
283
284template <class _Tp, class _Up>
285 requires requires { typename __pointer_of_t<_Tp>; }
286struct __pointer_of_or<_Tp, _Up> {
287 using type _LIBCPP_NODEBUG = __pointer_of_t<_Tp>;
288};
289
290template <typename _Tp, typename _Up>
291using __pointer_of_or_t = typename __pointer_of_or<_Tp, _Up>::type;
292
293template <class _Smart>
294concept __resettable_smart_pointer = requires(_Smart __s) { __s.reset(); };
295
296template <class _Smart, class _Pointer, class... _Args>
297concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p, _Args... __args) {
298 __s.reset(static_cast<__pointer_of_or_t<_Smart, _Pointer>>(__p), std::forward<_Args>(__args)...);
299};
300
301#endif
302
243303_LIBCPP_END_NAMESPACE_STD
244304
305_LIBCPP_POP_MACROS
306
245307#endif // _LIBCPP___MEMORY_POINTER_TRAITS_H
lib/libcxx/include/__memory/shared_ptr.h+73-49
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___MEMORY_SHARED_PTR_H
1111#define _LIBCPP___MEMORY_SHARED_PTR_H
1212
13#include <__availability>
1413#include <__compare/compare_three_way.h>
1514#include <__compare/ordering.h>
1615#include <__config>
......@@ -37,8 +36,8 @@
3736#include <__type_traits/disjunction.h>
3837#include <__type_traits/is_array.h>
3938#include <__type_traits/is_bounded_array.h>
39#include <__type_traits/is_constructible.h>
4040#include <__type_traits/is_convertible.h>
41#include <__type_traits/is_move_constructible.h>
4241#include <__type_traits/is_reference.h>
4342#include <__type_traits/is_unbounded_array.h>
4443#include <__type_traits/nat.h>
......@@ -260,7 +259,7 @@ struct __shared_ptr_emplace : __shared_weak_count {
260259 class _Allocator = _Alloc,
261260 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
262261 _LIBCPP_HIDE_FROM_ABI explicit __shared_ptr_emplace(_Alloc __a, _Args&&... __args) : __storage_(std::move(__a)) {
263 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, _Tp>::type;
262 using _TpAlloc = typename __allocator_traits_rebind<_Alloc, __remove_cv_t<_Tp> >::type;
264263 _TpAlloc __tmp(*__get_alloc());
265264 allocator_traits<_TpAlloc>::construct(__tmp, __get_elem(), std::forward<_Args>(__args)...);
266265 }
......@@ -279,7 +278,7 @@ private:
279278 template <class _Allocator = _Alloc,
280279 __enable_if_t<!is_same<typename _Allocator::value_type, __for_overwrite_tag>::value, int> = 0>
281280 _LIBCPP_HIDE_FROM_ABI void __on_zero_shared_impl() _NOEXCEPT {
282 using _TpAlloc = typename __allocator_traits_rebind<_Allocator, _Tp>::type;
281 using _TpAlloc = typename __allocator_traits_rebind<_Allocator, __remove_cv_t<_Tp> >::type;
283282 _TpAlloc __tmp(*__get_alloc());
284283 allocator_traits<_TpAlloc>::destroy(__tmp, __get_elem());
285284 }
......@@ -404,6 +403,9 @@ struct __shared_ptr_deleter_ctor_reqs {
404403 __well_formed_deleter<_Dp, _Yp*>::value;
405404};
406405
406template <class _Dp>
407using __shared_ptr_nullptr_deleter_ctor_reqs = _And<is_move_constructible<_Dp>, __well_formed_deleter<_Dp, nullptr_t> >;
408
407409#if defined(_LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI)
408410# define _LIBCPP_SHARED_PTR_TRIVIAL_ABI __attribute__((__trivial_abi__))
409411#else
......@@ -412,6 +414,8 @@ struct __shared_ptr_deleter_ctor_reqs {
412414
413415template <class _Tp>
414416class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {
417 struct __nullptr_sfinae_tag {};
418
415419public:
416420#if _LIBCPP_STD_VER >= 17
417421 typedef weak_ptr<_Tp> weak_type;
......@@ -420,6 +424,10 @@ public:
420424 typedef _Tp element_type;
421425#endif
422426
427 // A shared_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
428 // any bookkeeping, so it's always trivially relocatable.
429 using __trivially_relocatable = shared_ptr;
430
423431private:
424432 element_type* __ptr_;
425433 __shared_weak_count* __cntrl_;
......@@ -430,15 +438,16 @@ public:
430438 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(nullptr), __cntrl_(nullptr) {}
431439
432440 template <class _Yp,
433 class = __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp>
441 __enable_if_t< _And< __raw_pointer_compatible_with<_Yp, _Tp>
434442 // In C++03 we get errors when trying to do SFINAE with the
435443 // delete operator, so we always pretend that it's deletable.
436444 // The same happens on GCC.
437445#if !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_COMPILER_GCC)
438 ,
439 _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
446 ,
447 _If<is_array<_Tp>::value, __is_array_deletable<_Yp*>, __is_deletable<_Yp*> >
440448#endif
441 >::value > >
449 >::value,
450 int> = 0>
442451 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(_Yp* __p) : __ptr_(__p) {
443452 unique_ptr<_Yp> __hold(__p);
444453 typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
......@@ -448,7 +457,7 @@ public:
448457 __enable_weak_this(__p, __p);
449458 }
450459
451 template <class _Yp, class _Dp, class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> >
460 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
452461 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) {
453462#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
454463 try {
......@@ -472,7 +481,7 @@ public:
472481 template <class _Yp,
473482 class _Dp,
474483 class _Alloc,
475 class = __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> >
484 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
476485 _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) {
477486#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
478487 try {
......@@ -499,7 +508,11 @@ public:
499508 }
500509
501510 template <class _Dp>
502 _LIBCPP_HIDE_FROM_ABI shared_ptr(nullptr_t __p, _Dp __d) : __ptr_(nullptr) {
511 _LIBCPP_HIDE_FROM_ABI shared_ptr(
512 nullptr_t __p,
513 _Dp __d,
514 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
515 : __ptr_(nullptr) {
503516#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
504517 try {
505518#endif // _LIBCPP_HAS_NO_EXCEPTIONS
......@@ -519,7 +532,12 @@ public:
519532 }
520533
521534 template <class _Dp, class _Alloc>
522 _LIBCPP_HIDE_FROM_ABI shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) : __ptr_(nullptr) {
535 _LIBCPP_HIDE_FROM_ABI shared_ptr(
536 nullptr_t __p,
537 _Dp __d,
538 _Alloc __a,
539 __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag())
540 : __ptr_(nullptr) {
523541#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
524542 try {
525543#endif // _LIBCPP_HAS_NO_EXCEPTIONS
......@@ -567,7 +585,7 @@ public:
567585 __cntrl_->__add_shared();
568586 }
569587
570 template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
588 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
571589 _LIBCPP_HIDE_FROM_ABI shared_ptr(const shared_ptr<_Yp>& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
572590 if (__cntrl_)
573591 __cntrl_->__add_shared();
......@@ -578,13 +596,13 @@ public:
578596 __r.__cntrl_ = nullptr;
579597 }
580598
581 template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
599 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
582600 _LIBCPP_HIDE_FROM_ABI shared_ptr(shared_ptr<_Yp>&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) {
583601 __r.__ptr_ = nullptr;
584602 __r.__cntrl_ = nullptr;
585603 }
586604
587 template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
605 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
588606 _LIBCPP_HIDE_FROM_ABI explicit shared_ptr(const weak_ptr<_Yp>& __r)
589607 : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_ ? __r.__cntrl_->lock() : __r.__cntrl_) {
590608 if (__cntrl_ == nullptr)
......@@ -592,10 +610,10 @@ public:
592610 }
593611
594612#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
595 template <class _Yp, class = __enable_if_t<is_convertible<_Yp*, element_type*>::value> >
613 template <class _Yp, __enable_if_t<is_convertible<_Yp*, element_type*>::value, int> = 0>
596614 _LIBCPP_HIDE_FROM_ABI shared_ptr(auto_ptr<_Yp>&& __r) : __ptr_(__r.get()) {
597 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
598 __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<_Yp>());
615 typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<__remove_cv_t<_Yp> > > _CntrlBlk;
616 __cntrl_ = new _CntrlBlk(__r.get(), default_delete<_Yp>(), allocator<__remove_cv_t<_Yp> >());
599617 __enable_weak_this(__r.get(), __r.get());
600618 __r.release();
601619 }
......@@ -603,8 +621,9 @@ public:
603621
604622 template <class _Yp,
605623 class _Dp,
606 class = __enable_if_t< !is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
607 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value > >
624 __enable_if_t<!is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
625 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
626 int> = 0>
608627 _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
609628#if _LIBCPP_STD_VER >= 14
610629 if (__ptr_ == nullptr)
......@@ -622,9 +641,10 @@ public:
622641
623642 template <class _Yp,
624643 class _Dp,
625 class = void,
626 class = __enable_if_t< is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
627 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value > >
644 class = void,
645 __enable_if_t<is_lvalue_reference<_Dp>::value && __compatible_with<_Yp, _Tp>::value &&
646 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*>::value,
647 int> = 0>
628648 _LIBCPP_HIDE_FROM_ABI shared_ptr(unique_ptr<_Yp, _Dp>&& __r) : __ptr_(__r.get()) {
629649#if _LIBCPP_STD_VER >= 14
630650 if (__ptr_ == nullptr)
......@@ -653,7 +673,7 @@ public:
653673 return *this;
654674 }
655675
656 template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
676 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
657677 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT {
658678 shared_ptr(__r).swap(*this);
659679 return *this;
......@@ -664,7 +684,7 @@ public:
664684 return *this;
665685 }
666686
667 template <class _Yp, class = __enable_if_t<__compatible_with<_Yp, _Tp>::value> >
687 template <class _Yp, __enable_if_t<__compatible_with<_Yp, _Tp>::value, int> = 0>
668688 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(shared_ptr<_Yp>&& __r) {
669689 shared_ptr(std::move(__r)).swap(*this);
670690 return *this;
......@@ -672,19 +692,19 @@ public:
672692
673693#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
674694 template <class _Yp,
675 class = __enable_if_t< !is_array<_Yp>::value &&
676 is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value > >
695 __enable_if_t<!is_array<_Yp>::value && is_convertible<_Yp*, typename shared_ptr<_Tp>::element_type*>::value,
696 int> = 0>
677697 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(auto_ptr<_Yp>&& __r) {
678698 shared_ptr(std::move(__r)).swap(*this);
679699 return *this;
680700 }
681701#endif
682702
683 template <
684 class _Yp,
685 class _Dp,
686 class = __enable_if_t<_And< __compatible_with<_Yp, _Tp>,
687 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*> >::value> >
703 template <class _Yp,
704 class _Dp,
705 __enable_if_t<_And< __compatible_with<_Yp, _Tp>,
706 is_convertible<typename unique_ptr<_Yp, _Dp>::pointer, element_type*> >::value,
707 int> = 0>
688708 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>& operator=(unique_ptr<_Yp, _Dp>&& __r) {
689709 shared_ptr(std::move(__r)).swap(*this);
690710 return *this;
......@@ -697,12 +717,12 @@ public:
697717
698718 _LIBCPP_HIDE_FROM_ABI void reset() _NOEXCEPT { shared_ptr().swap(*this); }
699719
700 template <class _Yp, class = __enable_if_t< __raw_pointer_compatible_with<_Yp, _Tp>::value > >
720 template <class _Yp, __enable_if_t<__raw_pointer_compatible_with<_Yp, _Tp>::value, int> = 0>
701721 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p) {
702722 shared_ptr(__p).swap(*this);
703723 }
704724
705 template <class _Yp, class _Dp, class = __enable_if_t< __shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> >
725 template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
706726 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d) {
707727 shared_ptr(__p, __d).swap(*this);
708728 }
......@@ -710,7 +730,7 @@ public:
710730 template <class _Yp,
711731 class _Dp,
712732 class _Alloc,
713 class = __enable_if_t< __shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value> >
733 __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::value, int> = 0>
714734 _LIBCPP_HIDE_FROM_ABI void reset(_Yp* __p, _Dp __d, _Alloc __a) {
715735 shared_ptr(__p, __d, __a).swap(*this);
716736 }
......@@ -770,7 +790,7 @@ public:
770790private:
771791 template <class _Yp, bool = is_function<_Yp>::value>
772792 struct __shared_ptr_default_allocator {
773 typedef allocator<_Yp> type;
793 typedef allocator<__remove_cv_t<_Yp> > type;
774794 };
775795
776796 template <class _Yp>
......@@ -780,7 +800,7 @@ private:
780800
781801 template <class _Yp,
782802 class _OrigPtr,
783 class = __enable_if_t< is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value > >
803 __enable_if_t<is_convertible<_OrigPtr*, const enable_shared_from_this<_Yp>*>::value, int> = 0>
784804 _LIBCPP_HIDE_FROM_ABI void __enable_weak_this(const enable_shared_from_this<_Yp>* __e, _OrigPtr* __ptr) _NOEXCEPT {
785805 typedef __remove_cv_t<_Yp> _RawYp;
786806 if (__e && __e->__weak_this_.expired()) {
......@@ -815,7 +835,7 @@ shared_ptr(unique_ptr<_Tp, _Dp>) -> shared_ptr<_Tp>;
815835//
816836// std::allocate_shared and std::make_shared
817837//
818template <class _Tp, class _Alloc, class... _Args, class = __enable_if_t<!is_array<_Tp>::value> >
838template <class _Tp, class _Alloc, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
819839_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&... __args) {
820840 using _ControlBlock = __shared_ptr_emplace<_Tp, _Alloc>;
821841 using _ControlBlockAllocator = typename __allocator_traits_rebind<_Alloc, _ControlBlock>::type;
......@@ -826,9 +846,9 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, _Args&&
826846 (*__control_block).__get_elem(), std::addressof(*__control_block));
827847}
828848
829template <class _Tp, class... _Args, class = __enable_if_t<!is_array<_Tp>::value> >
849template <class _Tp, class... _Args, __enable_if_t<!is_array<_Tp>::value, int> = 0>
830850_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(_Args&&... __args) {
831 return std::allocate_shared<_Tp>(allocator<_Tp>(), std::forward<_Args>(__args)...);
851 return std::allocate_shared<_Tp>(allocator<__remove_cv_t<_Tp> >(), std::forward<_Args>(__args)...);
832852}
833853
834854#if _LIBCPP_STD_VER >= 20
......@@ -842,7 +862,7 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc
842862
843863template <class _Tp, __enable_if_t<!is_array<_Tp>::value, int> = 0>
844864_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() {
845 return std::allocate_shared_for_overwrite<_Tp>(allocator<_Tp>());
865 return std::allocate_shared_for_overwrite<_Tp>(allocator<__remove_cv_t<_Tp>>());
846866}
847867
848868#endif // _LIBCPP_STD_VER >= 20
......@@ -1032,12 +1052,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Array> __allocate_shared_bounded_array(const _
10321052#if _LIBCPP_STD_VER >= 20
10331053
10341054// bounded array variants
1035template <class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1055template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
10361056_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a) {
10371057 return std::__allocate_shared_bounded_array<_Tp>(__a);
10381058}
10391059
1040template <class _Tp, class _Alloc, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1060template <class _Tp, class _Alloc, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
10411061_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, const remove_extent_t<_Tp>& __u) {
10421062 return std::__allocate_shared_bounded_array<_Tp>(__a, __u);
10431063}
......@@ -1049,12 +1069,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc
10491069 return std::__allocate_shared_bounded_array<_Tp>(__alloc);
10501070}
10511071
1052template <class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1072template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
10531073_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared() {
10541074 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>());
10551075}
10561076
1057template <class _Tp, class = __enable_if_t<is_bounded_array<_Tp>::value>>
1077template <class _Tp, __enable_if_t<is_bounded_array<_Tp>::value, int> = 0>
10581078_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(const remove_extent_t<_Tp>& __u) {
10591079 return std::__allocate_shared_bounded_array<_Tp>(allocator<_Tp>(), __u);
10601080}
......@@ -1065,12 +1085,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared_for_overwrite() {
10651085}
10661086
10671087// unbounded array variants
1068template <class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1088template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
10691089_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n) {
10701090 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n);
10711091}
10721092
1073template <class _Tp, class _Alloc, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1093template <class _Tp, class _Alloc, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
10741094_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared(const _Alloc& __a, size_t __n, const remove_extent_t<_Tp>& __u) {
10751095 return std::__allocate_shared_unbounded_array<_Tp>(__a, __n, __u);
10761096}
......@@ -1082,12 +1102,12 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> allocate_shared_for_overwrite(const _Alloc
10821102 return std::__allocate_shared_unbounded_array<_Tp>(__alloc, __n);
10831103}
10841104
1085template <class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1105template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
10861106_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n) {
10871107 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n);
10881108}
10891109
1090template <class _Tp, class = __enable_if_t<is_unbounded_array<_Tp>::value>>
1110template <class _Tp, __enable_if_t<is_unbounded_array<_Tp>::value, int> = 0>
10911111_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> make_shared(size_t __n, const remove_extent_t<_Tp>& __u) {
10921112 return std::__allocate_shared_unbounded_array<_Tp>(allocator<_Tp>(), __n, __u);
10931113}
......@@ -1299,6 +1319,10 @@ public:
12991319 typedef _Tp element_type;
13001320#endif
13011321
1322 // A weak_ptr contains only two raw pointers which point to the heap and move constructing already doesn't require
1323 // any bookkeeping, so it's always trivially relocatable.
1324 using __trivially_relocatable = weak_ptr;
1325
13021326private:
13031327 element_type* __ptr_;
13041328 __shared_weak_count* __cntrl_;
lib/libcxx/include/__memory/swap_allocator.h+2-2
......@@ -26,7 +26,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator(_Alloc
2626#if _LIBCPP_STD_VER >= 14
2727 _NOEXCEPT
2828#else
29 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
29 _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
3030#endif
3131{
3232 using std::swap;
......@@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __swap_allocator
4242#if _LIBCPP_STD_VER >= 14
4343 _NOEXCEPT
4444#else
45 _NOEXCEPT_(__is_nothrow_swappable<_Alloc>::value)
45 _NOEXCEPT_(__is_nothrow_swappable_v<_Alloc>)
4646#endif
4747{
4848 std::__swap_allocator(
lib/libcxx/include/__memory/temporary_buffer.h+1-2
......@@ -11,7 +11,6 @@
1111#define _LIBCPP___MEMORY_TEMPORARY_BUFFER_H
1212
1313#include <__config>
14#include <__type_traits/alignment_of.h>
1514#include <__utility/pair.h>
1615#include <cstddef>
1716#include <new>
......@@ -23,7 +22,7 @@
2322_LIBCPP_BEGIN_NAMESPACE_STD
2423
2524template <class _Tp>
26_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>
25_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _LIBCPP_DEPRECATED_IN_CXX17 pair<_Tp*, ptrdiff_t>
2726get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {
2827 pair<_Tp*, ptrdiff_t> __r(0, 0);
2928 const ptrdiff_t __m =
lib/libcxx/include/__memory/uninitialized_algorithms.h+48-51
......@@ -25,10 +25,9 @@
2525#include <__type_traits/extent.h>
2626#include <__type_traits/is_array.h>
2727#include <__type_traits/is_constant_evaluated.h>
28#include <__type_traits/is_trivially_copy_assignable.h>
29#include <__type_traits/is_trivially_copy_constructible.h>
30#include <__type_traits/is_trivially_move_assignable.h>
31#include <__type_traits/is_trivially_move_constructible.h>
28#include <__type_traits/is_trivially_assignable.h>
29#include <__type_traits/is_trivially_constructible.h>
30#include <__type_traits/is_trivially_relocatable.h>
3231#include <__type_traits/is_unbounded_array.h>
3332#include <__type_traits/negation.h>
3433#include <__type_traits/remove_const.h>
......@@ -365,7 +364,7 @@ uninitialized_move_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofir
365364// the correct type.
366365template <class _Alloc,
367366 class _BidirIter,
368 class = __enable_if_t< __has_bidirectional_iterator_category<_BidirIter>::value >>
367 __enable_if_t<__has_bidirectional_iterator_category<_BidirIter>::value, int> = 0>
369368_LIBCPP_HIDE_FROM_ABI constexpr void
370369__allocator_destroy_multidimensional(_Alloc& __alloc, _BidirIter __first, _BidirIter __last) noexcept {
371370 using _ValueType = typename iterator_traits<_BidirIter>::value_type;
......@@ -568,8 +567,9 @@ template <class _Alloc,
568567 __enable_if_t<
569568 // using _RawTypeIn because of the allocator<T const> extension
570569 is_trivially_copy_constructible<_RawTypeIn>::value && is_trivially_copy_assignable<_RawTypeIn>::value &&
571 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
572 __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value>* = nullptr>
570 is_same<__remove_const_t<_In>, __remove_const_t<_Out> >::value &&
571 __allocator_has_trivial_copy_construct<_Alloc, _RawTypeIn>::value,
572 int> = 0>
573573_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Out*
574574__uninitialized_allocator_copy_impl(_Alloc&, _In* __first1, _In* __last1, _Out* __first2) {
575575 // TODO: Remove the const_cast once we drop support for std::allocator<T const>
......@@ -594,60 +594,57 @@ __uninitialized_allocator_copy(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1,
594594 return std::__rewrap_iter(__first2, __result);
595595}
596596
597// Move-construct the elements [__first1, __last1) into [__first2, __first2 + N)
598// if the move constructor is noexcept, where N is distance(__first1, __last1).
599//
600// Otherwise try to copy all elements. If an exception is thrown the already copied
601// elements are destroyed in reverse order of their construction.
602template <class _Alloc, class _Iter1, class _Sent1, class _Iter2>
603_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
604__uninitialized_allocator_move_if_noexcept(_Alloc& __alloc, _Iter1 __first1, _Sent1 __last1, _Iter2 __first2) {
605 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
606 "The specified type does not meet the requirements of Cpp17MoveInsertable");
607 auto __destruct_first = __first2;
608 auto __guard =
609 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Iter2>(__alloc, __destruct_first, __first2));
610 while (__first1 != __last1) {
611#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
612 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move_if_noexcept(*__first1));
613#else
614 allocator_traits<_Alloc>::construct(__alloc, std::__to_address(__first2), std::move(*__first1));
615#endif
616 ++__first1;
617 ++__first2;
618 }
619 __guard.__complete();
620 return __first2;
621}
622
623597template <class _Alloc, class _Type>
624598struct __allocator_has_trivial_move_construct : _Not<__has_construct<_Alloc, _Type*, _Type&&> > {};
625599
626600template <class _Type>
627601struct __allocator_has_trivial_move_construct<allocator<_Type>, _Type> : true_type {};
628602
629#ifndef _LIBCPP_COMPILER_GCC
630template <
631 class _Alloc,
632 class _Iter1,
633 class _Iter2,
634 class _Type = typename iterator_traits<_Iter1>::value_type,
635 class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
636 __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
637_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter2
638__uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
639 if (__libcpp_is_constant_evaluated()) {
640 while (__first1 != __last1) {
641 std::__construct_at(std::__to_address(__first2), std::move(*__first1));
642 ++__first1;
643 ++__first2;
603template <class _Alloc, class _Tp>
604struct __allocator_has_trivial_destroy : _Not<__has_destroy<_Alloc, _Tp*> > {};
605
606template <class _Tp, class _Up>
607struct __allocator_has_trivial_destroy<allocator<_Tp>, _Up> : true_type {};
608
609// __uninitialized_allocator_relocate relocates the objects in [__first, __last) into __result.
610// Relocation means that the objects in [__first, __last) are placed into __result as-if by move-construct and destroy,
611// except that the move constructor and destructor may never be called if they are known to be equivalent to a memcpy.
612//
613// Preconditions: __result doesn't contain any objects and [__first, __last) contains objects
614// Postconditions: __result contains the objects from [__first, __last) and
615// [__first, __last) doesn't contain any objects
616//
617// The strong exception guarantee is provided if any of the following are true:
618// - is_nothrow_move_constructible<_Tp>
619// - is_copy_constructible<_Tp>
620// - __libcpp_is_trivially_relocatable<_Tp>
621template <class _Alloc, class _Tp>
622_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
623__uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _Tp* __result) {
624 static_assert(__is_cpp17_move_insertable<_Alloc>::value,
625 "The specified type does not meet the requirements of Cpp17MoveInsertable");
626 if (__libcpp_is_constant_evaluated() || !__libcpp_is_trivially_relocatable<_Tp>::value ||
627 !__allocator_has_trivial_move_construct<_Alloc, _Tp>::value ||
628 !__allocator_has_trivial_destroy<_Alloc, _Tp>::value) {
629 auto __destruct_first = __result;
630 auto __guard =
631 std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Tp*>(__alloc, __destruct_first, __result));
632 auto __iter = __first;
633 while (__iter != __last) {
634#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
635 allocator_traits<_Alloc>::construct(__alloc, __result, std::move_if_noexcept(*__iter));
636#else
637 allocator_traits<_Alloc>::construct(__alloc, __result, std::move(*__iter));
638#endif
639 ++__iter;
640 ++__result;
644641 }
645 return __first2;
642 __guard.__complete();
643 std::__allocator_destroy(__alloc, __first, __last);
646644 } else {
647 return std::move(__first1, __last1, __first2);
645 __builtin_memcpy(const_cast<__remove_const_t<_Tp>*>(__result), __first, sizeof(_Tp) * (__last - __first));
648646 }
649647}
650#endif // _LIBCPP_COMPILER_GCC
651648
652649_LIBCPP_END_NAMESPACE_STD
653650
lib/libcxx/include/__memory/unique_ptr.h+46-9
......@@ -21,21 +21,24 @@
2121#include <__memory/compressed_pair.h>
2222#include <__type_traits/add_lvalue_reference.h>
2323#include <__type_traits/common_type.h>
24#include <__type_traits/conditional.h>
2425#include <__type_traits/dependent_type.h>
2526#include <__type_traits/integral_constant.h>
2627#include <__type_traits/is_array.h>
2728#include <__type_traits/is_assignable.h>
2829#include <__type_traits/is_constructible.h>
2930#include <__type_traits/is_convertible.h>
30#include <__type_traits/is_default_constructible.h>
3131#include <__type_traits/is_function.h>
3232#include <__type_traits/is_pointer.h>
3333#include <__type_traits/is_reference.h>
3434#include <__type_traits/is_same.h>
3535#include <__type_traits/is_swappable.h>
36#include <__type_traits/is_trivially_relocatable.h>
3637#include <__type_traits/is_void.h>
3738#include <__type_traits/remove_extent.h>
39#include <__type_traits/remove_pointer.h>
3840#include <__type_traits/type_identity.h>
41#include <__utility/declval.h>
3942#include <__utility/forward.h>
4043#include <__utility/move.h>
4144#include <cstddef>
......@@ -49,6 +52,17 @@ _LIBCPP_PUSH_MACROS
4952
5053_LIBCPP_BEGIN_NAMESPACE_STD
5154
55#ifndef _LIBCPP_CXX03_LANG
56
57template <class _Ptr>
58struct __is_noexcept_deref_or_void {
59 static constexpr bool value = noexcept(*std::declval<_Ptr>());
60};
61
62template <>
63struct __is_noexcept_deref_or_void<void*> : true_type {};
64#endif
65
5266template <class _Tp>
5367struct _LIBCPP_TEMPLATE_VIS default_delete {
5468 static_assert(!is_function<_Tp>::value, "default_delete cannot be instantiated for function types");
......@@ -129,6 +143,17 @@ public:
129143
130144 static_assert(!is_rvalue_reference<deleter_type>::value, "the specified deleter type cannot be an rvalue reference");
131145
146 // A unique_ptr contains the following members which may be trivially relocatable:
147 // - pointer : this may be trivially relocatable, so it's checked
148 // - deleter_type: this may be trivially relocatable, so it's checked
149 //
150 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no
151 // references to itself. This means that the entire structure is trivially relocatable if its members are.
152 using __trivially_relocatable = __conditional_t<
153 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
154 unique_ptr,
155 void>;
156
132157private:
133158 __compressed_pair<pointer, deleter_type> __ptr_;
134159
......@@ -171,8 +196,8 @@ public:
171196 : __ptr_(__value_init_tag(), __value_init_tag()) {}
172197
173198 template <bool _Dummy = true, class = _EnableIfDeleterDefaultConstructible<_Dummy> >
174 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT
175 : __ptr_(__p, __value_init_tag()) {}
199 _LIBCPP_HIDE_FROM_ABI
200 _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}
176201
177202 template <bool _Dummy = true, class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
178203 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
......@@ -240,7 +265,8 @@ public:
240265 return *this;
241266 }
242267
243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const {
268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 __add_lvalue_reference_t<_Tp> operator*() const
269 _NOEXCEPT_(__is_noexcept_deref_or_void<pointer>::value) {
244270 return *__ptr_.first();
245271 }
246272 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 pointer operator->() const _NOEXCEPT { return __ptr_.first(); }
......@@ -276,6 +302,17 @@ public:
276302 typedef _Dp deleter_type;
277303 typedef typename __pointer<_Tp, deleter_type>::type pointer;
278304
305 // A unique_ptr contains the following members which may be trivially relocatable:
306 // - pointer : this may be trivially relocatable, so it's checked
307 // - deleter_type: this may be trivially relocatable, so it's checked
308 //
309 // This unique_ptr implementation only contains a pointer to the unique object and a deleter, so there are no
310 // references to itself. This means that the entire structure is trivially relocatable if its members are.
311 using __trivially_relocatable = __conditional_t<
312 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<deleter_type>::value,
313 unique_ptr,
314 void>;
315
279316private:
280317 __compressed_pair<pointer, deleter_type> __ptr_;
281318
......@@ -336,8 +373,8 @@ public:
336373 bool _Dummy = true,
337374 class = _EnableIfDeleterDefaultConstructible<_Dummy>,
338375 class = _EnableIfPointerConvertible<_Pp> >
339 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT
340 : __ptr_(__p, __value_init_tag()) {}
376 _LIBCPP_HIDE_FROM_ABI
377 _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit unique_ptr(_Pp __p) _NOEXCEPT : __ptr_(__p, __value_init_tag()) {}
341378
342379 template <class _Pp,
343380 bool _Dummy = true,
......@@ -448,7 +485,7 @@ public:
448485 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void swap(unique_ptr& __u) _NOEXCEPT { __ptr_.swap(__u.__ptr_); }
449486};
450487
451template <class _Tp, class _Dp, __enable_if_t<__is_swappable<_Dp>::value, int> = 0>
488template <class _Tp, class _Dp, __enable_if_t<__is_swappable_v<_Dp>, int> = 0>
452489inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
453490swap(unique_ptr<_Tp, _Dp>& __x, unique_ptr<_Tp, _Dp>& __y) _NOEXCEPT {
454491 __x.swap(__y);
......@@ -494,8 +531,8 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const unique_ptr<_T1, _D1>& __x, co
494531template <class _T1, class _D1, class _T2, class _D2>
495532 requires three_way_comparable_with<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
496533_LIBCPP_HIDE_FROM_ABI
497 compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
498 operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
534compare_three_way_result_t<typename unique_ptr<_T1, _D1>::pointer, typename unique_ptr<_T2, _D2>::pointer>
535operator<=>(const unique_ptr<_T1, _D1>& __x, const unique_ptr<_T2, _D2>& __y) {
499536 return compare_three_way()(__x.get(), __y.get());
500537}
501538#endif
lib/libcxx/include/__memory/uses_allocator_construction.h+6-14
......@@ -12,7 +12,7 @@
1212#include <__config>
1313#include <__memory/construct_at.h>
1414#include <__memory/uses_allocator.h>
15#include <__tuple/pair_like.h>
15#include <__tuple/tuple_like_no_subrange.h>
1616#include <__type_traits/enable_if.h>
1717#include <__type_traits/is_same.h>
1818#include <__type_traits/remove_cv.h>
......@@ -128,11 +128,7 @@ __uses_allocator_construction_args(const _Alloc& __alloc, const pair<_Up, _Vp>&&
128128 std::forward_as_tuple(std::get<1>(std::move(__pair))));
129129}
130130
131template < class _Pair,
132 class _Alloc,
133 __pair_like _PairLike,
134 __enable_if_t<__is_cv_std_pair<_Pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value,
135 int> = 0>
131template <class _Pair, class _Alloc, __pair_like_no_subrange _PairLike, __enable_if_t<__is_cv_std_pair<_Pair>, int> = 0>
136132_LIBCPP_HIDE_FROM_ABI constexpr auto
137133__uses_allocator_construction_args(const _Alloc& __alloc, _PairLike&& __p) noexcept {
138134 return std::__uses_allocator_construction_args<_Pair>(
......@@ -161,9 +157,7 @@ inline constexpr bool __convertible_to_const_pair_ref =
161157# if _LIBCPP_STD_VER >= 23
162158template <class _Tp, class _Up>
163159inline constexpr bool __uses_allocator_constraints =
164 __is_cv_std_pair<_Tp> &&
165 (__is_specialization_of_subrange<remove_cvref_t<_Up>>::value ||
166 (!__pair_like<_Up> && !__convertible_to_const_pair_ref<_Up>));
160 __is_cv_std_pair<_Tp> && !__pair_like_no_subrange<_Up> && !__convertible_to_const_pair_ref<_Up>;
167161# else
168162template <class _Tp, class _Up>
169163inline constexpr bool __uses_allocator_constraints = __is_cv_std_pair<_Tp> && !__convertible_to_const_pair_ref<_Up>;
......@@ -190,20 +184,18 @@ __uses_allocator_construction_args(const _Alloc& __alloc, _Type&& __value) noexc
190184 struct __pair_constructor {
191185 using _PairMutable = remove_cv_t<_Pair>;
192186
193 _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(const _PairMutable& __pair) const {
187 _LIBCPP_HIDDEN constexpr auto __do_construct(const _PairMutable& __pair) const {
194188 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, __pair);
195189 }
196190
197 _LIBCPP_HIDE_FROM_ABI constexpr auto __do_construct(_PairMutable&& __pair) const {
191 _LIBCPP_HIDDEN constexpr auto __do_construct(_PairMutable&& __pair) const {
198192 return std::__make_obj_using_allocator<_PairMutable>(__alloc_, std::move(__pair));
199193 }
200194
201195 const _Alloc& __alloc_;
202196 _Type& __value_;
203197
204 _LIBCPP_HIDE_FROM_ABI constexpr operator _PairMutable() const {
205 return __do_construct(std::forward<_Type>(this->__value_));
206 }
198 _LIBCPP_HIDDEN constexpr operator _PairMutable() const { return __do_construct(std::forward<_Type>(__value_)); }
207199 };
208200
209201 return std::make_tuple(__pair_constructor{__alloc, __value});
lib/libcxx/include/__memory_resource/memory_resource.h+2-4
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
1010#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
1111
12#include <__availability>
1312#include <__config>
1413#include <__fwd/memory_resource.h>
1514#include <cstddef>
......@@ -32,9 +31,8 @@ class _LIBCPP_AVAILABILITY_PMR _LIBCPP_EXPORTED_FROM_ABI memory_resource {
3231public:
3332 virtual ~memory_resource();
3433
35 _LIBCPP_NODISCARD_AFTER_CXX17
36 [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]] _LIBCPP_HIDE_FROM_ABI void*
37 allocate(size_t __bytes, size_t __align = __max_align) {
34 [[nodiscard]] [[using __gnu__: __returns_nonnull__, __alloc_size__(2), __alloc_align__(3)]]
35 _LIBCPP_HIDE_FROM_ABI void* allocate(size_t __bytes, size_t __align = __max_align) {
3836 return do_allocate(__bytes, __align);
3937 }
4038
lib/libcxx/include/__memory_resource/monotonic_buffer_resource.h-1
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
1010#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
1111
12#include <__availability>
1312#include <__config>
1413#include <__memory/addressof.h>
1514#include <__memory_resource/memory_resource.h>
lib/libcxx/include/__memory_resource/polymorphic_allocator.h+2-2
......@@ -10,8 +10,8 @@
1010#define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
1111
1212#include <__assert>
13#include <__availability>
1413#include <__config>
14#include <__fwd/pair.h>
1515#include <__memory_resource/memory_resource.h>
1616#include <__utility/exception_guard.h>
1717#include <cstddef>
......@@ -60,7 +60,7 @@ public:
6060
6161 // [mem.poly.allocator.mem]
6262
63 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {
63 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _ValueType* allocate(size_t __n) {
6464 if (__n > __max_size()) {
6565 __throw_bad_array_new_length();
6666 }
lib/libcxx/include/__memory_resource/synchronized_pool_resource.h-1
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
1010#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
1111
12#include <__availability>
1312#include <__config>
1413#include <__memory_resource/memory_resource.h>
1514#include <__memory_resource/pool_options.h>
lib/libcxx/include/__memory_resource/unsynchronized_pool_resource.h-1
......@@ -9,7 +9,6 @@
99#ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
1010#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
1111
12#include <__availability>
1312#include <__config>
1413#include <__memory_resource/memory_resource.h>
1514#include <__memory_resource/pool_options.h>
lib/libcxx/include/__mutex/lock_guard.h+3-8
......@@ -16,8 +16,6 @@
1616# pragma GCC system_header
1717#endif
1818
19#ifndef _LIBCPP_HAS_NO_THREADS
20
2119_LIBCPP_BEGIN_NAMESPACE_STD
2220
2321template <class _Mutex>
......@@ -29,18 +27,17 @@ private:
2927 mutex_type& __m_;
3028
3129public:
32 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m)
33 _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
30 _LIBCPP_NODISCARD
31 _LIBCPP_HIDE_FROM_ABI explicit lock_guard(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
3432 : __m_(__m) {
3533 __m_.lock();
3634 }
3735
38 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t)
36 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI lock_guard(mutex_type& __m, adopt_lock_t)
3937 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
4038 : __m_(__m) {}
4139 _LIBCPP_HIDE_FROM_ABI ~lock_guard() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }
4240
43private:
4441 lock_guard(lock_guard const&) = delete;
4542 lock_guard& operator=(lock_guard const&) = delete;
4643};
......@@ -48,6 +45,4 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(lock_guard);
4845
4946_LIBCPP_END_NAMESPACE_STD
5047
51#endif // _LIBCPP_HAS_NO_THREADS
52
5348#endif // _LIBCPP___MUTEX_LOCK_GUARD_H
lib/libcxx/include/__mutex/mutex.h+2-2
......@@ -10,8 +10,8 @@
1010#define _LIBCPP___MUTEX_MUTEX_H
1111
1212#include <__config>
13#include <__threading_support>
14#include <__type_traits/is_nothrow_default_constructible.h>
13#include <__thread/support.h>
14#include <__type_traits/is_nothrow_constructible.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__mutex/tag_types.h+3-7
......@@ -15,8 +15,6 @@
1515# pragma GCC system_header
1616#endif
1717
18#ifndef _LIBCPP_HAS_NO_THREADS
19
2018_LIBCPP_BEGIN_NAMESPACE_STD
2119
2220struct _LIBCPP_EXPORTED_FROM_ABI defer_lock_t {
......@@ -31,18 +29,16 @@ struct _LIBCPP_EXPORTED_FROM_ABI adopt_lock_t {
3129 explicit adopt_lock_t() = default;
3230};
3331
34# if _LIBCPP_STD_VER >= 17
32#if _LIBCPP_STD_VER >= 17
3533inline constexpr defer_lock_t defer_lock = defer_lock_t();
3634inline constexpr try_to_lock_t try_to_lock = try_to_lock_t();
3735inline constexpr adopt_lock_t adopt_lock = adopt_lock_t();
38# elif !defined(_LIBCPP_CXX03_LANG)
36#elif !defined(_LIBCPP_CXX03_LANG)
3937constexpr defer_lock_t defer_lock = defer_lock_t();
4038constexpr try_to_lock_t try_to_lock = try_to_lock_t();
4139constexpr adopt_lock_t adopt_lock = adopt_lock_t();
42# endif
40#endif
4341
4442_LIBCPP_END_NAMESPACE_STD
4543
46#endif // _LIBCPP_HAS_NO_THREADS
47
4844#endif // _LIBCPP___MUTEX_TAG_TYPES_H
lib/libcxx/include/__mutex/unique_lock.h+12-8
......@@ -36,26 +36,28 @@ private:
3636 bool __owns_;
3737
3838public:
39 _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
40 _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m) : __m_(std::addressof(__m)), __owns_(true) {
39 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
40 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI explicit unique_lock(mutex_type& __m)
41 : __m_(std::addressof(__m)), __owns_(true) {
4142 __m_->lock();
4243 }
4344
44 _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
45 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
4546 : __m_(std::addressof(__m)),
4647 __owns_(false) {}
4748
48 _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t)
49 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, try_to_lock_t)
4950 : __m_(std::addressof(__m)), __owns_(__m.try_lock()) {}
5051
51 _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t) : __m_(std::addressof(__m)), __owns_(true) {}
52 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, adopt_lock_t)
53 : __m_(std::addressof(__m)), __owns_(true) {}
5254
5355 template <class _Clock, class _Duration>
54 _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
56 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::time_point<_Clock, _Duration>& __t)
5557 : __m_(std::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
5658
5759 template <class _Rep, class _Period>
58 _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
60 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& __d)
5961 : __m_(std::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
6062
6163 _LIBCPP_HIDE_FROM_ABI ~unique_lock() {
......@@ -66,7 +68,9 @@ public:
6668 unique_lock(unique_lock const&) = delete;
6769 unique_lock& operator=(unique_lock const&) = delete;
6870
69 _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT : __m_(__u.__m_), __owns_(__u.__owns_) {
71 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI unique_lock(unique_lock&& __u) _NOEXCEPT
72 : __m_(__u.__m_),
73 __owns_(__u.__owns_) {
7074 __u.__m_ = nullptr;
7175 __u.__owns_ = false;
7276 }
lib/libcxx/include/__node_handle+1-1
......@@ -147,7 +147,7 @@ public:
147147
148148 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ptr_ != nullptr; }
149149
150 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; }
150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; }
151151
152152 _LIBCPP_HIDE_FROM_ABI void swap(__basic_node_handle& __other) noexcept(
153153 __alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value) {
lib/libcxx/include/__numeric/gcd_lcm.h+58-16
......@@ -10,7 +10,9 @@
1010#ifndef _LIBCPP___NUMERIC_GCD_LCM_H
1111#define _LIBCPP___NUMERIC_GCD_LCM_H
1212
13#include <__algorithm/min.h>
1314#include <__assert>
15#include <__bit/countr.h>
1416#include <__config>
1517#include <__type_traits/common_type.h>
1618#include <__type_traits/is_integral.h>
......@@ -35,7 +37,7 @@ struct __ct_abs;
3537
3638template <typename _Result, typename _Source>
3739struct __ct_abs<_Result, _Source, true> {
38 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept {
40 constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept {
3941 if (__t >= 0)
4042 return __t;
4143 if (__t == numeric_limits<_Source>::min())
......@@ -46,20 +48,58 @@ struct __ct_abs<_Result, _Source, true> {
4648
4749template <typename _Result, typename _Source>
4850struct __ct_abs<_Result, _Source, false> {
49 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; }
51 constexpr _LIBCPP_HIDE_FROM_ABI _Result operator()(_Source __t) const noexcept { return __t; }
5052};
5153
5254template <class _Tp>
53_LIBCPP_CONSTEXPR _LIBCPP_HIDDEN _Tp __gcd(_Tp __m, _Tp __n) {
54 static_assert((!is_signed<_Tp>::value), "");
55 return __n == 0 ? __m : std::__gcd<_Tp>(__n, __m % __n);
55constexpr _LIBCPP_HIDDEN _Tp __gcd(_Tp __a, _Tp __b) {
56 static_assert(!is_signed<_Tp>::value, "");
57
58 // From: https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor
59 //
60 // If power of two divides both numbers, we can push it out.
61 // - gcd( 2^x * a, 2^x * b) = 2^x * gcd(a, b)
62 //
63 // If and only if exactly one number is even, we can divide that number by that power.
64 // - if a, b are odd, then gcd(2^x * a, b) = gcd(a, b)
65 //
66 // And standard gcd algorithm where instead of modulo, minus is used.
67
68 if (__a < __b) {
69 _Tp __tmp = __b;
70 __b = __a;
71 __a = __tmp;
72 }
73 if (__b == 0)
74 return __a;
75 __a %= __b; // Make both argument of the same size, and early result in the easy case.
76 if (__a == 0)
77 return __b;
78
79 int __az = std::__countr_zero(__a);
80 int __bz = std::__countr_zero(__b);
81 int __shift = std::min(__az, __bz);
82 __a >>= __az;
83 __b >>= __bz;
84 do {
85 _Tp __diff = __a - __b;
86 if (__a > __b) {
87 __a = __b;
88 __b = __diff;
89 } else {
90 __b = __b - __a;
91 }
92 if (__diff != 0)
93 __b >>= std::__countr_zero(__diff);
94 } while (__b != 0);
95 return __a << __shift;
5696}
5797
5898template <class _Tp, class _Up>
59_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) {
60 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to gcd must be integer types");
61 static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to gcd cannot be bool");
62 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to gcd cannot be bool");
99constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up __n) {
100 static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to gcd must be integer types");
101 static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to gcd cannot be bool");
102 static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to gcd cannot be bool");
63103 using _Rp = common_type_t<_Tp, _Up>;
64104 using _Wp = make_unsigned_t<_Rp>;
65105 return static_cast<_Rp>(
......@@ -67,21 +107,23 @@ _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> gcd(_Tp __m, _Up
67107}
68108
69109template <class _Tp, class _Up>
70_LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
71 static_assert((is_integral<_Tp>::value && is_integral<_Up>::value), "Arguments to lcm must be integer types");
72 static_assert((!is_same<__remove_cv_t<_Tp>, bool>::value), "First argument to lcm cannot be bool");
73 static_assert((!is_same<__remove_cv_t<_Up>, bool>::value), "Second argument to lcm cannot be bool");
110constexpr _LIBCPP_HIDE_FROM_ABI common_type_t<_Tp, _Up> lcm(_Tp __m, _Up __n) {
111 static_assert(is_integral<_Tp>::value && is_integral<_Up>::value, "Arguments to lcm must be integer types");
112 static_assert(!is_same<__remove_cv_t<_Tp>, bool>::value, "First argument to lcm cannot be bool");
113 static_assert(!is_same<__remove_cv_t<_Up>, bool>::value, "Second argument to lcm cannot be bool");
74114 if (__m == 0 || __n == 0)
75115 return 0;
76116
77117 using _Rp = common_type_t<_Tp, _Up>;
78118 _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / std::gcd(__m, __n);
79119 _Rp __val2 = __ct_abs<_Rp, _Up>()(__n);
80 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
81 return __val1 * __val2;
120 _Rp __res;
121 [[maybe_unused]] bool __overflow = __builtin_mul_overflow(__val1, __val2, &__res);
122 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__overflow, "Overflow in lcm");
123 return __res;
82124}
83125
84#endif // _LIBCPP_STD_VER
126#endif // _LIBCPP_STD_VER >= 17
85127
86128_LIBCPP_END_NAMESPACE_STD
87129
lib/libcxx/include/__numeric/midpoint.h+10-8
......@@ -67,14 +67,16 @@ template <class _Fp>
6767_LIBCPP_HIDE_FROM_ABI constexpr enable_if_t<is_floating_point_v<_Fp>, _Fp> midpoint(_Fp __a, _Fp __b) noexcept {
6868 constexpr _Fp __lo = numeric_limits<_Fp>::min() * 2;
6969 constexpr _Fp __hi = numeric_limits<_Fp>::max() / 2;
70 return std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi
71 ? // typical case: overflow is impossible
72 (__a + __b) / 2
73 : // always correctly rounded
74 std::__fp_abs(__a) < __lo ? __a + __b / 2 : // not safe to halve a
75 std::__fp_abs(__b) < __lo ? __a / 2 + __b
76 : // not safe to halve b
77 __a / 2 + __b / 2; // otherwise correctly rounded
70
71 // typical case: overflow is impossible
72 if (std::__fp_abs(__a) <= __hi && std::__fp_abs(__b) <= __hi)
73 return (__a + __b) / 2; // always correctly rounded
74 if (std::__fp_abs(__a) < __lo)
75 return __a + __b / 2; // not safe to halve a
76 if (std::__fp_abs(__b) < __lo)
77 return __a / 2 + __b; // not safe to halve b
78
79 return __a / 2 + __b / 2; // otherwise correctly rounded
7880}
7981
8082#endif // _LIBCPP_STD_VER >= 20
lib/libcxx/include/__numeric/pstl.h created+174
......@@ -0,0 +1,174 @@
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___NUMERIC_PSTL_H
10#define _LIBCPP___NUMERIC_PSTL_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_PUSH_MACROS
19#include <__undef_macros>
20
21#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
22
23# include <__functional/identity.h>
24# include <__functional/operations.h>
25# include <__iterator/cpp17_iterator_concepts.h>
26# include <__iterator/iterator_traits.h>
27# include <__pstl/backend.h>
28# include <__pstl/dispatch.h>
29# include <__pstl/handle_exception.h>
30# include <__type_traits/enable_if.h>
31# include <__type_traits/is_execution_policy.h>
32# include <__type_traits/remove_cvref.h>
33# include <__utility/forward.h>
34# include <__utility/move.h>
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37
38template <class _ExecutionPolicy,
39 class _ForwardIterator,
40 class _Tp,
41 class _BinaryOperation,
42 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
43 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
44_LIBCPP_HIDE_FROM_ABI _Tp reduce(
45 _ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init, _BinaryOperation __op) {
46 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
47 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
48 return __pstl::__handle_exception<_Implementation>(
49 std::forward<_ExecutionPolicy>(__policy),
50 std::move(__first),
51 std::move(__last),
52 std::move(__init),
53 std::move(__op));
54}
55
56template <class _ExecutionPolicy,
57 class _ForwardIterator,
58 class _Tp,
59 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
60 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
61_LIBCPP_HIDE_FROM_ABI _Tp
62reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init) {
63 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
64 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
65 return __pstl::__handle_exception<_Implementation>(
66 std::forward<_ExecutionPolicy>(__policy), std::move(__first), std::move(__last), std::move(__init), plus{});
67}
68
69template <class _ExecutionPolicy,
70 class _ForwardIterator,
71 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
72 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
73_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator>
74reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) {
75 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "reduce requires ForwardIterators");
76 using _Implementation = __pstl::__dispatch<__pstl::__reduce, __pstl::__current_configuration, _RawPolicy>;
77 return __pstl::__handle_exception<_Implementation>(
78 std::forward<_ExecutionPolicy>(__policy),
79 std::move(__first),
80 std::move(__last),
81 __iter_value_type<_ForwardIterator>(),
82 plus{});
83}
84
85template <class _ExecutionPolicy,
86 class _ForwardIterator1,
87 class _ForwardIterator2,
88 class _Tp,
89 class _BinaryOperation1,
90 class _BinaryOperation2,
91 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
92 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
93_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
94 _ExecutionPolicy&& __policy,
95 _ForwardIterator1 __first1,
96 _ForwardIterator1 __last1,
97 _ForwardIterator2 __first2,
98 _Tp __init,
99 _BinaryOperation1 __reduce,
100 _BinaryOperation2 __transform) {
101 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform_reduce requires ForwardIterators");
102 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform_reduce requires ForwardIterators");
103 using _Implementation =
104 __pstl::__dispatch<__pstl::__transform_reduce_binary, __pstl::__current_configuration, _RawPolicy>;
105 return __pstl::__handle_exception<_Implementation>(
106 std::forward<_ExecutionPolicy>(__policy),
107 std::move(__first1),
108 std::move(__last1),
109 std::move(__first2),
110 std::move(__init),
111 std::move(__reduce),
112 std::move(__transform));
113}
114
115// This overload doesn't get a customization point because it's trivial to detect (through e.g.
116// __desugars_to_v) when specializing the more general variant, which should always be preferred
117template <class _ExecutionPolicy,
118 class _ForwardIterator1,
119 class _ForwardIterator2,
120 class _Tp,
121 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
122 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
123_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
124 _ExecutionPolicy&& __policy,
125 _ForwardIterator1 __first1,
126 _ForwardIterator1 __last1,
127 _ForwardIterator2 __first2,
128 _Tp __init) {
129 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator1, "transform_reduce requires ForwardIterators");
130 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator2, "transform_reduce requires ForwardIterators");
131 using _Implementation =
132 __pstl::__dispatch<__pstl::__transform_reduce_binary, __pstl::__current_configuration, _RawPolicy>;
133 return __pstl::__handle_exception<_Implementation>(
134 std::forward<_ExecutionPolicy>(__policy),
135 std::move(__first1),
136 std::move(__last1),
137 std::move(__first2),
138 std::move(__init),
139 plus{},
140 multiplies{});
141}
142
143template <class _ExecutionPolicy,
144 class _ForwardIterator,
145 class _Tp,
146 class _BinaryOperation,
147 class _UnaryOperation,
148 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
149 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
150_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
151 _ExecutionPolicy&& __policy,
152 _ForwardIterator __first,
153 _ForwardIterator __last,
154 _Tp __init,
155 _BinaryOperation __reduce,
156 _UnaryOperation __transform) {
157 _LIBCPP_REQUIRE_CPP17_FORWARD_ITERATOR(_ForwardIterator, "transform_reduce requires ForwardIterators");
158 using _Implementation = __pstl::__dispatch<__pstl::__transform_reduce, __pstl::__current_configuration, _RawPolicy>;
159 return __pstl::__handle_exception<_Implementation>(
160 std::forward<_ExecutionPolicy>(__policy),
161 std::move(__first),
162 std::move(__last),
163 std::move(__init),
164 std::move(__reduce),
165 std::move(__transform));
166}
167
168_LIBCPP_END_NAMESPACE_STD
169
170#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
171
172_LIBCPP_POP_MACROS
173
174#endif // _LIBCPP___NUMERIC_PSTL_H
lib/libcxx/include/__numeric/pstl_reduce.h deleted-109
......@@ -1,109 +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___NUMERIC_PSTL_REDUCE_H
10#define _LIBCPP___NUMERIC_PSTL_REDUCE_H
11
12#include <__algorithm/pstl_frontend_dispatch.h>
13#include <__config>
14#include <__functional/identity.h>
15#include <__iterator/iterator_traits.h>
16#include <__numeric/pstl_transform_reduce.h>
17#include <__type_traits/is_execution_policy.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
26#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30template <class>
31void __pstl_reduce();
32
33template <class _ExecutionPolicy,
34 class _ForwardIterator,
35 class _Tp,
36 class _BinaryOperation = plus<>,
37 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
38 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
39[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp>
40__reduce(_ExecutionPolicy&& __policy,
41 _ForwardIterator&& __first,
42 _ForwardIterator&& __last,
43 _Tp&& __init,
44 _BinaryOperation&& __op = {}) noexcept {
45 return std::__pstl_frontend_dispatch(
46 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy),
47 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last, _Tp __g_init, _BinaryOperation __g_op) {
48 return std::__transform_reduce(
49 __policy, std::move(__g_first), std::move(__g_last), std::move(__g_init), std::move(__g_op), __identity{});
50 },
51 std::move(__first),
52 std::move(__last),
53 std::move(__init),
54 std::move(__op));
55}
56
57template <class _ExecutionPolicy,
58 class _ForwardIterator,
59 class _Tp,
60 class _BinaryOperation = plus<>,
61 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
62 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
63_LIBCPP_HIDE_FROM_ABI _Tp
64reduce(_ExecutionPolicy&& __policy,
65 _ForwardIterator __first,
66 _ForwardIterator __last,
67 _Tp __init,
68 _BinaryOperation __op = {}) {
69 auto __res = std::__reduce(__policy, std::move(__first), std::move(__last), std::move(__init), std::move(__op));
70 if (!__res)
71 std::__throw_bad_alloc();
72 return *std::move(__res);
73}
74
75template <class _ExecutionPolicy,
76 class _ForwardIterator,
77 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
78 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
79[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_value_type<_ForwardIterator>>
80__reduce(_ExecutionPolicy&& __policy, _ForwardIterator&& __first, _ForwardIterator&& __last) noexcept {
81 return std::__pstl_frontend_dispatch(
82 _LIBCPP_PSTL_CUSTOMIZATION_POINT(__pstl_reduce, _RawPolicy),
83 [&__policy](_ForwardIterator __g_first, _ForwardIterator __g_last) {
84 return std::__reduce(
85 __policy, std::move(__g_first), std::move(__g_last), __iter_value_type<_ForwardIterator>());
86 },
87 std::move(__first),
88 std::move(__last));
89}
90
91template <class _ExecutionPolicy,
92 class _ForwardIterator,
93 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
94 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
95_LIBCPP_HIDE_FROM_ABI __iter_value_type<_ForwardIterator>
96reduce(_ExecutionPolicy&& __policy, _ForwardIterator __first, _ForwardIterator __last) {
97 auto __res = std::__reduce(__policy, std::move(__first), std::move(__last));
98 if (!__res)
99 std::__throw_bad_alloc();
100 return *std::move(__res);
101}
102
103_LIBCPP_END_NAMESPACE_STD
104
105#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
106
107_LIBCPP_POP_MACROS
108
109#endif // _LIBCPP___NUMERIC_PSTL_REDUCE_H
lib/libcxx/include/__numeric/pstl_transform_reduce.h deleted-156
......@@ -1,156 +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___NUMERIC_PSTL_TRANSFORM_REDUCE_H
10#define _LIBCPP___NUMERIC_PSTL_TRANSFORM_REDUCE_H
11
12#include <__algorithm/pstl_backend.h>
13#include <__algorithm/pstl_frontend_dispatch.h>
14#include <__config>
15#include <__functional/operations.h>
16#include <__numeric/transform_reduce.h>
17#include <__type_traits/is_execution_policy.h>
18#include <__utility/move.h>
19#include <optional>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_PUSH_MACROS
26#include <__undef_macros>
27
28#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31
32template <class _ExecutionPolicy,
33 class _ForwardIterator1,
34 class _ForwardIterator2,
35 class _Tp,
36 class _BinaryOperation1,
37 class _BinaryOperation2,
38 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
39 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
40_LIBCPP_HIDE_FROM_ABI optional<_Tp> __transform_reduce(
41 _ExecutionPolicy&&,
42 _ForwardIterator1&& __first1,
43 _ForwardIterator1&& __last1,
44 _ForwardIterator2&& __first2,
45 _Tp&& __init,
46 _BinaryOperation1&& __reduce,
47 _BinaryOperation2&& __transform) noexcept {
48 using _Backend = typename __select_backend<_RawPolicy>::type;
49 return std::__pstl_transform_reduce<_RawPolicy>(
50 _Backend{},
51 std::move(__first1),
52 std::move(__last1),
53 std::move(__first2),
54 std::move(__init),
55 std::move(__reduce),
56 std::move(__transform));
57}
58
59template <class _ExecutionPolicy,
60 class _ForwardIterator1,
61 class _ForwardIterator2,
62 class _Tp,
63 class _BinaryOperation1,
64 class _BinaryOperation2,
65 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
66 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
67_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
68 _ExecutionPolicy&& __policy,
69 _ForwardIterator1 __first1,
70 _ForwardIterator1 __last1,
71 _ForwardIterator2 __first2,
72 _Tp __init,
73 _BinaryOperation1 __reduce,
74 _BinaryOperation2 __transform) {
75 auto __res = std::__transform_reduce(
76 __policy,
77 std::move(__first1),
78 std::move(__last1),
79 std::move(__first2),
80 std::move(__init),
81 std::move(__reduce),
82 std::move(__transform));
83
84 if (!__res)
85 std::__throw_bad_alloc();
86 return *std::move(__res);
87}
88
89// This overload doesn't get a customization point because it's trivial to detect (through e.g.
90// __desugars_to) when specializing the more general variant, which should always be preferred
91template <class _ExecutionPolicy,
92 class _ForwardIterator1,
93 class _ForwardIterator2,
94 class _Tp,
95 enable_if_t<is_execution_policy_v<__remove_cvref_t<_ExecutionPolicy>>, int> = 0>
96_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
97 _ExecutionPolicy&& __policy,
98 _ForwardIterator1 __first1,
99 _ForwardIterator1 __last1,
100 _ForwardIterator2 __first2,
101 _Tp __init) {
102 return std::transform_reduce(__policy, __first1, __last1, __first2, __init, plus{}, multiplies{});
103}
104
105template <class _ExecutionPolicy,
106 class _ForwardIterator,
107 class _Tp,
108 class _BinaryOperation,
109 class _UnaryOperation,
110 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
111 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
112[[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__remove_cvref_t<_Tp>> __transform_reduce(
113 _ExecutionPolicy&&,
114 _ForwardIterator&& __first,
115 _ForwardIterator&& __last,
116 _Tp&& __init,
117 _BinaryOperation&& __reduce,
118 _UnaryOperation&& __transform) noexcept {
119 using _Backend = typename __select_backend<_RawPolicy>::type;
120 return std::__pstl_transform_reduce<_RawPolicy>(
121 _Backend{},
122 std::move(__first),
123 std::move(__last),
124 std::move(__init),
125 std::move(__reduce),
126 std::move(__transform));
127}
128
129template <class _ExecutionPolicy,
130 class _ForwardIterator,
131 class _Tp,
132 class _BinaryOperation,
133 class _UnaryOperation,
134 class _RawPolicy = __remove_cvref_t<_ExecutionPolicy>,
135 enable_if_t<is_execution_policy_v<_RawPolicy>, int> = 0>
136_LIBCPP_HIDE_FROM_ABI _Tp transform_reduce(
137 _ExecutionPolicy&& __policy,
138 _ForwardIterator __first,
139 _ForwardIterator __last,
140 _Tp __init,
141 _BinaryOperation __reduce,
142 _UnaryOperation __transform) {
143 auto __res = std::__transform_reduce(
144 __policy, std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform));
145 if (!__res)
146 std::__throw_bad_alloc();
147 return *std::move(__res);
148}
149
150_LIBCPP_END_NAMESPACE_STD
151
152#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
153
154_LIBCPP_POP_MACROS
155
156#endif // _LIBCPP___NUMERIC_PSTL_TRANSFORM_REDUCE_H
lib/libcxx/include/__numeric/saturation_arithmetic.h+36-6
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H
1111#define _LIBCPP___NUMERIC_SATURATION_ARITHMETIC_H
1212
13#include <__assert>
1314#include <__concepts/arithmetic.h>
1415#include <__config>
1516#include <__utility/cmp.h>
......@@ -24,10 +25,10 @@ _LIBCPP_PUSH_MACROS
2425
2526_LIBCPP_BEGIN_NAMESPACE_STD
2627
27#if _LIBCPP_STD_VER >= 26
28#if _LIBCPP_STD_VER >= 20
2829
2930template <__libcpp_integer _Tp>
30_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
31_LIBCPP_HIDE_FROM_ABI constexpr _Tp __add_sat(_Tp __x, _Tp __y) noexcept {
3132 if (_Tp __sum; !__builtin_add_overflow(__x, __y, &__sum))
3233 return __sum;
3334 // Handle overflow
......@@ -45,7 +46,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
4546}
4647
4748template <__libcpp_integer _Tp>
48_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
49_LIBCPP_HIDE_FROM_ABI constexpr _Tp __sub_sat(_Tp __x, _Tp __y) noexcept {
4950 if (_Tp __sub; !__builtin_sub_overflow(__x, __y, &__sub))
5051 return __sub;
5152 // Handle overflow
......@@ -64,7 +65,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
6465}
6566
6667template <__libcpp_integer _Tp>
67_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
68_LIBCPP_HIDE_FROM_ABI constexpr _Tp __mul_sat(_Tp __x, _Tp __y) noexcept {
6869 if (_Tp __mul; !__builtin_mul_overflow(__x, __y, &__mul))
6970 return __mul;
7071 // Handle overflow
......@@ -80,7 +81,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
8081}
8182
8283template <__libcpp_integer _Tp>
83_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
84_LIBCPP_HIDE_FROM_ABI constexpr _Tp __div_sat(_Tp __x, _Tp __y) noexcept {
8485 _LIBCPP_ASSERT_UNCATEGORIZED(__y != 0, "Division by 0 is undefined");
8586 if constexpr (__libcpp_unsigned_integer<_Tp>) {
8687 return __x / __y;
......@@ -93,7 +94,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
9394}
9495
9596template <__libcpp_integer _Rp, __libcpp_integer _Tp>
96_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
97_LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
9798 // Saturation is impossible edge case when ((min _Rp) < (min _Tp) && (max _Rp) > (max _Tp)) and it is expected to be
9899 // optimized out by the compiler.
99100
......@@ -106,6 +107,35 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
106107 return static_cast<_Rp>(__x);
107108}
108109
110#endif // _LIBCPP_STD_VER >= 20
111
112#if _LIBCPP_STD_VER >= 26
113
114template <__libcpp_integer _Tp>
115_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
116 return std::__add_sat(__x, __y);
117}
118
119template <__libcpp_integer _Tp>
120_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
121 return std::__sub_sat(__x, __y);
122}
123
124template <__libcpp_integer _Tp>
125_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
126 return std::__mul_sat(__x, __y);
127}
128
129template <__libcpp_integer _Tp>
130_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
131 return std::__div_sat(__x, __y);
132}
133
134template <__libcpp_integer _Rp, __libcpp_integer _Tp>
135_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
136 return std::__saturate_cast<_Rp>(__x);
137}
138
109139#endif // _LIBCPP_STD_VER >= 26
110140
111141_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ostream/basic_ostream.h created+860
......@@ -0,0 +1,860 @@
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___OSTREAM_BASIC_OSTREAM_H
10#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
11
12#include <__config>
13#include <__exception/operations.h>
14#include <__memory/shared_ptr.h>
15#include <__memory/unique_ptr.h>
16#include <__system_error/error_code.h>
17#include <__type_traits/conjunction.h>
18#include <__type_traits/enable_if.h>
19#include <__type_traits/is_base_of.h>
20#include <__type_traits/void_t.h>
21#include <__utility/declval.h>
22#include <bitset>
23#include <cstddef>
24#include <ios>
25#include <locale>
26#include <new> // for __throw_bad_alloc
27#include <streambuf>
28#include <string_view>
29
30#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
31# pragma GCC system_header
32#endif
33
34_LIBCPP_PUSH_MACROS
35#include <__undef_macros>
36
37_LIBCPP_BEGIN_NAMESPACE_STD
38
39template <class _CharT, class _Traits>
40class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> {
41public:
42 // types (inherited from basic_ios (27.5.4)):
43 typedef _CharT char_type;
44 typedef _Traits traits_type;
45 typedef typename traits_type::int_type int_type;
46 typedef typename traits_type::pos_type pos_type;
47 typedef typename traits_type::off_type off_type;
48
49 // 27.7.2.2 Constructor/destructor:
50 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) {
51 this->init(__sb);
52 }
53 ~basic_ostream() override;
54
55 basic_ostream(const basic_ostream& __rhs) = delete;
56 basic_ostream& operator=(const basic_ostream& __rhs) = delete;
57
58protected:
59 inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs);
60
61 // 27.7.2.3 Assign/swap
62 inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs);
63
64 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) {
65 basic_ios<char_type, traits_type>::swap(__rhs);
66 }
67
68public:
69 // 27.7.2.4 Prefix/suffix:
70 class _LIBCPP_TEMPLATE_VIS sentry;
71
72 // 27.7.2.6 Formatted output:
73 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) {
74 return __pf(*this);
75 }
76
77 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream&
78 operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) {
79 __pf(*this);
80 return *this;
81 }
82
83 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) {
84 __pf(*this);
85 return *this;
86 }
87
88 basic_ostream& operator<<(bool __n);
89 basic_ostream& operator<<(short __n);
90 basic_ostream& operator<<(unsigned short __n);
91 basic_ostream& operator<<(int __n);
92 basic_ostream& operator<<(unsigned int __n);
93 basic_ostream& operator<<(long __n);
94 basic_ostream& operator<<(unsigned long __n);
95 basic_ostream& operator<<(long long __n);
96 basic_ostream& operator<<(unsigned long long __n);
97 basic_ostream& operator<<(float __f);
98 basic_ostream& operator<<(double __f);
99 basic_ostream& operator<<(long double __f);
100 basic_ostream& operator<<(const void* __p);
101
102#if _LIBCPP_STD_VER >= 23
103 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {
104 return operator<<(const_cast<const void*>(__p));
105 }
106#endif
107
108 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
109
110#if _LIBCPP_STD_VER >= 17
111 // LWG 2221 - nullptr. This is not backported to older standards modes.
112 // See https://reviews.llvm.org/D127033 for more info on the rationale.
113 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }
114#endif
115
116 // 27.7.2.7 Unformatted output:
117 basic_ostream& put(char_type __c);
118 basic_ostream& write(const char_type* __s, streamsize __n);
119 basic_ostream& flush();
120
121 // 27.7.2.5 seeks:
122 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp();
123 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos);
124 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
125
126protected:
127 _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize
128};
129
130template <class _CharT, class _Traits>
131class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry {
132 bool __ok_;
133 basic_ostream<_CharT, _Traits>& __os_;
134
135public:
136 explicit sentry(basic_ostream<_CharT, _Traits>& __os);
137 ~sentry();
138 sentry(const sentry&) = delete;
139 sentry& operator=(const sentry&) = delete;
140
141 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
142};
143
144template <class _CharT, class _Traits>
145basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) {
146 if (__os.good()) {
147 if (__os.tie())
148 __os.tie()->flush();
149 __ok_ = true;
150 }
151}
152
153template <class _CharT, class _Traits>
154basic_ostream<_CharT, _Traits>::sentry::~sentry() {
155 if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) {
156#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
157 try {
158#endif // _LIBCPP_HAS_NO_EXCEPTIONS
159 if (__os_.rdbuf()->pubsync() == -1)
160 __os_.setstate(ios_base::badbit);
161#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
162 } catch (...) {
163 }
164#endif // _LIBCPP_HAS_NO_EXCEPTIONS
165 }
166}
167
168template <class _CharT, class _Traits>
169basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) {
170 this->move(__rhs);
171}
172
173template <class _CharT, class _Traits>
174basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) {
175 swap(__rhs);
176 return *this;
177}
178
179template <class _CharT, class _Traits>
180basic_ostream<_CharT, _Traits>::~basic_ostream() {}
181
182template <class _CharT, class _Traits>
183basic_ostream<_CharT, _Traits>&
184basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {
185#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
186 try {
187#endif // _LIBCPP_HAS_NO_EXCEPTIONS
188 sentry __s(*this);
189 if (__s) {
190 if (__sb) {
191#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
192 try {
193#endif // _LIBCPP_HAS_NO_EXCEPTIONS
194 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
195 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
196 _Ip __i(__sb);
197 _Ip __eof;
198 _Op __o(*this);
199 size_t __c = 0;
200 for (; __i != __eof; ++__i, ++__o, ++__c) {
201 *__o = *__i;
202 if (__o.failed())
203 break;
204 }
205 if (__c == 0)
206 this->setstate(ios_base::failbit);
207#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
208 } catch (...) {
209 this->__set_failbit_and_consider_rethrow();
210 }
211#endif // _LIBCPP_HAS_NO_EXCEPTIONS
212 } else
213 this->setstate(ios_base::badbit);
214 }
215#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
216 } catch (...) {
217 this->__set_badbit_and_consider_rethrow();
218 }
219#endif // _LIBCPP_HAS_NO_EXCEPTIONS
220 return *this;
221}
222
223template <class _CharT, class _Traits>
224basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {
225#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
226 try {
227#endif // _LIBCPP_HAS_NO_EXCEPTIONS
228 sentry __s(*this);
229 if (__s) {
230 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
231 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
232 if (__f.put(*this, *this, this->fill(), __n).failed())
233 this->setstate(ios_base::badbit | ios_base::failbit);
234 }
235#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
236 } catch (...) {
237 this->__set_badbit_and_consider_rethrow();
238 }
239#endif // _LIBCPP_HAS_NO_EXCEPTIONS
240 return *this;
241}
242
243template <class _CharT, class _Traits>
244basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {
245#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
246 try {
247#endif // _LIBCPP_HAS_NO_EXCEPTIONS
248 sentry __s(*this);
249 if (__s) {
250 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
251 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
252 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
253 if (__f.put(*this,
254 *this,
255 this->fill(),
256 __flags == ios_base::oct || __flags == ios_base::hex
257 ? static_cast<long>(static_cast<unsigned short>(__n))
258 : static_cast<long>(__n))
259 .failed())
260 this->setstate(ios_base::badbit | ios_base::failbit);
261 }
262#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
263 } catch (...) {
264 this->__set_badbit_and_consider_rethrow();
265 }
266#endif // _LIBCPP_HAS_NO_EXCEPTIONS
267 return *this;
268}
269
270template <class _CharT, class _Traits>
271basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {
272#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
273 try {
274#endif // _LIBCPP_HAS_NO_EXCEPTIONS
275 sentry __s(*this);
276 if (__s) {
277 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
278 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
279 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
280 this->setstate(ios_base::badbit | ios_base::failbit);
281 }
282#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
283 } catch (...) {
284 this->__set_badbit_and_consider_rethrow();
285 }
286#endif // _LIBCPP_HAS_NO_EXCEPTIONS
287 return *this;
288}
289
290template <class _CharT, class _Traits>
291basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {
292#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
293 try {
294#endif // _LIBCPP_HAS_NO_EXCEPTIONS
295 sentry __s(*this);
296 if (__s) {
297 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
298 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
299 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
300 if (__f.put(*this,
301 *this,
302 this->fill(),
303 __flags == ios_base::oct || __flags == ios_base::hex
304 ? static_cast<long>(static_cast<unsigned int>(__n))
305 : static_cast<long>(__n))
306 .failed())
307 this->setstate(ios_base::badbit | ios_base::failbit);
308 }
309#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
310 } catch (...) {
311 this->__set_badbit_and_consider_rethrow();
312 }
313#endif // _LIBCPP_HAS_NO_EXCEPTIONS
314 return *this;
315}
316
317template <class _CharT, class _Traits>
318basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {
319#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
320 try {
321#endif // _LIBCPP_HAS_NO_EXCEPTIONS
322 sentry __s(*this);
323 if (__s) {
324 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
325 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
326 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
327 this->setstate(ios_base::badbit | ios_base::failbit);
328 }
329#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
330 } catch (...) {
331 this->__set_badbit_and_consider_rethrow();
332 }
333#endif // _LIBCPP_HAS_NO_EXCEPTIONS
334 return *this;
335}
336
337template <class _CharT, class _Traits>
338basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
339#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
340 try {
341#endif // _LIBCPP_HAS_NO_EXCEPTIONS
342 sentry __s(*this);
343 if (__s) {
344 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
345 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
346 if (__f.put(*this, *this, this->fill(), __n).failed())
347 this->setstate(ios_base::badbit | ios_base::failbit);
348 }
349#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
350 } catch (...) {
351 this->__set_badbit_and_consider_rethrow();
352 }
353#endif // _LIBCPP_HAS_NO_EXCEPTIONS
354 return *this;
355}
356
357template <class _CharT, class _Traits>
358basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {
359#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
360 try {
361#endif // _LIBCPP_HAS_NO_EXCEPTIONS
362 sentry __s(*this);
363 if (__s) {
364 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
365 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
366 if (__f.put(*this, *this, this->fill(), __n).failed())
367 this->setstate(ios_base::badbit | ios_base::failbit);
368 }
369#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
370 } catch (...) {
371 this->__set_badbit_and_consider_rethrow();
372 }
373#endif // _LIBCPP_HAS_NO_EXCEPTIONS
374 return *this;
375}
376
377template <class _CharT, class _Traits>
378basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {
379#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
380 try {
381#endif // _LIBCPP_HAS_NO_EXCEPTIONS
382 sentry __s(*this);
383 if (__s) {
384 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
385 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
386 if (__f.put(*this, *this, this->fill(), __n).failed())
387 this->setstate(ios_base::badbit | ios_base::failbit);
388 }
389#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
390 } catch (...) {
391 this->__set_badbit_and_consider_rethrow();
392 }
393#endif // _LIBCPP_HAS_NO_EXCEPTIONS
394 return *this;
395}
396
397template <class _CharT, class _Traits>
398basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {
399#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
400 try {
401#endif // _LIBCPP_HAS_NO_EXCEPTIONS
402 sentry __s(*this);
403 if (__s) {
404 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
405 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
406 if (__f.put(*this, *this, this->fill(), __n).failed())
407 this->setstate(ios_base::badbit | ios_base::failbit);
408 }
409#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
410 } catch (...) {
411 this->__set_badbit_and_consider_rethrow();
412 }
413#endif // _LIBCPP_HAS_NO_EXCEPTIONS
414 return *this;
415}
416
417template <class _CharT, class _Traits>
418basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {
419#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
420 try {
421#endif // _LIBCPP_HAS_NO_EXCEPTIONS
422 sentry __s(*this);
423 if (__s) {
424 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
425 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
426 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
427 this->setstate(ios_base::badbit | ios_base::failbit);
428 }
429#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
430 } catch (...) {
431 this->__set_badbit_and_consider_rethrow();
432 }
433#endif // _LIBCPP_HAS_NO_EXCEPTIONS
434 return *this;
435}
436
437template <class _CharT, class _Traits>
438basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {
439#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
440 try {
441#endif // _LIBCPP_HAS_NO_EXCEPTIONS
442 sentry __s(*this);
443 if (__s) {
444 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
445 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
446 if (__f.put(*this, *this, this->fill(), __n).failed())
447 this->setstate(ios_base::badbit | ios_base::failbit);
448 }
449#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
450 } catch (...) {
451 this->__set_badbit_and_consider_rethrow();
452 }
453#endif // _LIBCPP_HAS_NO_EXCEPTIONS
454 return *this;
455}
456
457template <class _CharT, class _Traits>
458basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {
459#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
460 try {
461#endif // _LIBCPP_HAS_NO_EXCEPTIONS
462 sentry __s(*this);
463 if (__s) {
464 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
465 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
466 if (__f.put(*this, *this, this->fill(), __n).failed())
467 this->setstate(ios_base::badbit | ios_base::failbit);
468 }
469#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
470 } catch (...) {
471 this->__set_badbit_and_consider_rethrow();
472 }
473#endif // _LIBCPP_HAS_NO_EXCEPTIONS
474 return *this;
475}
476
477template <class _CharT, class _Traits>
478basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {
479#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
480 try {
481#endif // _LIBCPP_HAS_NO_EXCEPTIONS
482 sentry __s(*this);
483 if (__s) {
484 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
485 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
486 if (__f.put(*this, *this, this->fill(), __n).failed())
487 this->setstate(ios_base::badbit | ios_base::failbit);
488 }
489#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
490 } catch (...) {
491 this->__set_badbit_and_consider_rethrow();
492 }
493#endif // _LIBCPP_HAS_NO_EXCEPTIONS
494 return *this;
495}
496
497template <class _CharT, class _Traits>
498_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
499__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) {
500#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
501 try {
502#endif // _LIBCPP_HAS_NO_EXCEPTIONS
503 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
504 if (__s) {
505 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
506 if (std::__pad_and_output(
507 _Ip(__os),
508 __str,
509 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
510 __str + __len,
511 __os,
512 __os.fill())
513 .failed())
514 __os.setstate(ios_base::badbit | ios_base::failbit);
515 }
516#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
517 } catch (...) {
518 __os.__set_badbit_and_consider_rethrow();
519 }
520#endif // _LIBCPP_HAS_NO_EXCEPTIONS
521 return __os;
522}
523
524template <class _CharT, class _Traits>
525_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
526 return std::__put_character_sequence(__os, &__c, 1);
527}
528
529template <class _CharT, class _Traits>
530_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {
531#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
532 try {
533#endif // _LIBCPP_HAS_NO_EXCEPTIONS
534 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
535 if (__s) {
536 _CharT __c = __os.widen(__cn);
537 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
538 if (std::__pad_and_output(
539 _Ip(__os),
540 &__c,
541 (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c,
542 &__c + 1,
543 __os,
544 __os.fill())
545 .failed())
546 __os.setstate(ios_base::badbit | ios_base::failbit);
547 }
548#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
549 } catch (...) {
550 __os.__set_badbit_and_consider_rethrow();
551 }
552#endif // _LIBCPP_HAS_NO_EXCEPTIONS
553 return __os;
554}
555
556template <class _Traits>
557_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, char __c) {
558 return std::__put_character_sequence(__os, &__c, 1);
559}
560
561template <class _Traits>
562_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
563 return std::__put_character_sequence(__os, (char*)&__c, 1);
564}
565
566template <class _Traits>
567_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
568 return std::__put_character_sequence(__os, (char*)&__c, 1);
569}
570
571template <class _CharT, class _Traits>
572_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
573operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
574 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
575}
576
577template <class _CharT, class _Traits>
578_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
579operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
580#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
581 try {
582#endif // _LIBCPP_HAS_NO_EXCEPTIONS
583 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
584 if (__s) {
585 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
586 size_t __len = char_traits<char>::length(__strn);
587 const int __bs = 100;
588 _CharT __wbb[__bs];
589 _CharT* __wb = __wbb;
590 unique_ptr<_CharT, void (*)(void*)> __h(0, free);
591 if (__len > __bs) {
592 __wb = (_CharT*)malloc(__len * sizeof(_CharT));
593 if (__wb == 0)
594 __throw_bad_alloc();
595 __h.reset(__wb);
596 }
597 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
598 *__p = __os.widen(*__strn);
599 if (std::__pad_and_output(
600 _Ip(__os),
601 __wb,
602 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __wb + __len : __wb,
603 __wb + __len,
604 __os,
605 __os.fill())
606 .failed())
607 __os.setstate(ios_base::badbit | ios_base::failbit);
608 }
609#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
610 } catch (...) {
611 __os.__set_badbit_and_consider_rethrow();
612 }
613#endif // _LIBCPP_HAS_NO_EXCEPTIONS
614 return __os;
615}
616
617template <class _Traits>
618_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, const char* __str) {
619 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
620}
621
622template <class _Traits>
623_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
624operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) {
625 const char* __s = (const char*)__str;
626 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
627}
628
629template <class _Traits>
630_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
631operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
632 const char* __s = (const char*)__str;
633 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
634}
635
636template <class _CharT, class _Traits>
637basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {
638#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
639 try {
640#endif // _LIBCPP_HAS_NO_EXCEPTIONS
641 sentry __s(*this);
642 if (__s) {
643 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
644 _Op __o(*this);
645 *__o = __c;
646 if (__o.failed())
647 this->setstate(ios_base::badbit);
648 }
649#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
650 } catch (...) {
651 this->__set_badbit_and_consider_rethrow();
652 }
653#endif // _LIBCPP_HAS_NO_EXCEPTIONS
654 return *this;
655}
656
657template <class _CharT, class _Traits>
658basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
659#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
660 try {
661#endif // _LIBCPP_HAS_NO_EXCEPTIONS
662 sentry __sen(*this);
663 if (__sen && __n) {
664 if (this->rdbuf()->sputn(__s, __n) != __n)
665 this->setstate(ios_base::badbit);
666 }
667#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
668 } catch (...) {
669 this->__set_badbit_and_consider_rethrow();
670 }
671#endif // _LIBCPP_HAS_NO_EXCEPTIONS
672 return *this;
673}
674
675template <class _CharT, class _Traits>
676basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
677#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
678 try {
679#endif // _LIBCPP_HAS_NO_EXCEPTIONS
680 if (this->rdbuf()) {
681 sentry __s(*this);
682 if (__s) {
683 if (this->rdbuf()->pubsync() == -1)
684 this->setstate(ios_base::badbit);
685 }
686 }
687#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
688 } catch (...) {
689 this->__set_badbit_and_consider_rethrow();
690 }
691#endif // _LIBCPP_HAS_NO_EXCEPTIONS
692 return *this;
693}
694
695template <class _CharT, class _Traits>
696typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() {
697 if (this->fail())
698 return pos_type(-1);
699 return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
700}
701
702template <class _CharT, class _Traits>
703basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) {
704 sentry __s(*this);
705 if (!this->fail()) {
706 if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
707 this->setstate(ios_base::failbit);
708 }
709 return *this;
710}
711
712template <class _CharT, class _Traits>
713basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) {
714 sentry __s(*this);
715 if (!this->fail()) {
716 if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
717 this->setstate(ios_base::failbit);
718 }
719 return *this;
720}
721
722template <class _CharT, class _Traits>
723_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) {
724 __os.put(__os.widen('\n'));
725 __os.flush();
726 return __os;
727}
728
729template <class _CharT, class _Traits>
730_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) {
731 __os.put(_CharT());
732 return __os;
733}
734
735template <class _CharT, class _Traits>
736_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) {
737 __os.flush();
738 return __os;
739}
740
741template <class _Stream, class _Tp, class = void>
742struct __is_ostreamable : false_type {};
743
744template <class _Stream, class _Tp>
745struct __is_ostreamable<_Stream, _Tp, decltype(std::declval<_Stream>() << std::declval<_Tp>(), void())> : true_type {};
746
747template <class _Stream,
748 class _Tp,
749 __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0>
750_LIBCPP_HIDE_FROM_ABI _Stream&& operator<<(_Stream&& __os, const _Tp& __x) {
751 __os << __x;
752 return std::move(__os);
753}
754
755template <class _CharT, class _Traits, class _Allocator>
756basic_ostream<_CharT, _Traits>&
757operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) {
758 return std::__put_character_sequence(__os, __str.data(), __str.size());
759}
760
761template <class _CharT, class _Traits>
762_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
763operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) {
764 return std::__put_character_sequence(__os, __sv.data(), __sv.size());
765}
766
767template <class _CharT, class _Traits>
768inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
769operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) {
770 return __os << __ec.category().name() << ':' << __ec.value();
771}
772
773template <class _CharT, class _Traits, class _Yp>
774inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
775operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) {
776 return __os << __p.get();
777}
778
779template <
780 class _CharT,
781 class _Traits,
782 class _Yp,
783 class _Dp,
784 __enable_if_t<is_same<void,
785 __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>()
786 << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
787 int> = 0>
788inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
789operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) {
790 return __os << __p.get();
791}
792
793template <class _CharT, class _Traits, size_t _Size>
794_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
795operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {
796 return __os << __x.template to_string<_CharT, _Traits>(std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
797 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
798}
799
800#if _LIBCPP_STD_VER >= 20
801
802# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
803template <class _Traits>
804basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
805
806template <class _Traits>
807basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
808
809template <class _Traits>
810basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
811
812template <class _Traits>
813basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
814
815template <class _Traits>
816basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
817
818template <class _Traits>
819basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
820
821# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
822
823# ifndef _LIBCPP_HAS_NO_CHAR8_T
824template <class _Traits>
825basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
826
827template <class _Traits>
828basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
829
830template <class _Traits>
831basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
832
833template <class _Traits>
834basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
835# endif
836
837template <class _Traits>
838basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
839
840template <class _Traits>
841basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
842
843template <class _Traits>
844basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
845
846template <class _Traits>
847basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
848
849#endif // _LIBCPP_STD_VER >= 20
850
851extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
852#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
853extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
854#endif
855
856_LIBCPP_END_NAMESPACE_STD
857
858_LIBCPP_POP_MACROS
859
860#endif // _LIBCPP___OSTREAM_BASIC_OSTREAM_H
lib/libcxx/include/__ostream/print.h created+179
......@@ -0,0 +1,179 @@
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___OSTREAM_PRINT_H
10#define _LIBCPP___OSTREAM_PRINT_H
11
12#include <__config>
13#include <__fwd/ostream.h>
14#include <__iterator/ostreambuf_iterator.h>
15#include <__ostream/basic_ostream.h>
16#include <format>
17#include <ios>
18#include <locale>
19#include <print>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER >= 23
28
29template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
30_LIBCPP_HIDE_FROM_ABI inline void
31__vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
32 // [ostream.formatted.print]/3
33 // Effects: Behaves as a formatted output function
34 // ([ostream.formatted.reqmts]) of os, except that:
35 // - failure to generate output is reported as specified below, and
36 // - any exception thrown by the call to vformat is propagated without regard
37 // to the value of os.exceptions() and without turning on ios_base::badbit
38 // in the error state of os.
39 // After constructing a sentry object, the function initializes an automatic
40 // variable via
41 // string out = vformat(os.getloc(), fmt, args);
42
43 ostream::sentry __s(__os);
44 if (__s) {
45 string __o = std::vformat(__os.getloc(), __fmt, __args);
46 if (__write_nl)
47 __o += '\n';
48
49 const char* __str = __o.data();
50 size_t __len = __o.size();
51
52# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
53 try {
54# endif // _LIBCPP_HAS_NO_EXCEPTIONS
55 typedef ostreambuf_iterator<char> _Ip;
56 if (std::__pad_and_output(
57 _Ip(__os),
58 __str,
59 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
60 __str + __len,
61 __os,
62 __os.fill())
63 .failed())
64 __os.setstate(ios_base::badbit | ios_base::failbit);
65
66# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
67 } catch (...) {
68 __os.__set_badbit_and_consider_rethrow();
69 }
70# endif // _LIBCPP_HAS_NO_EXCEPTIONS
71 }
72}
73
74template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
75_LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args) {
76 std::__vprint_nonunicode(__os, __fmt, __args, false);
77}
78
79// Returns the FILE* associated with the __os.
80// Returns a nullptr when no FILE* is associated with __os.
81// This function is in the dylib since the type of the buffer associated
82// with std::cout, std::cerr, and std::clog is only known in the dylib.
83//
84// This function implements part of the implementation-defined behavior
85// of [ostream.formatted.print]/3
86// If the function is vprint_unicode and os is a stream that refers to
87// a terminal capable of displaying Unicode which is determined in an
88// implementation-defined manner, writes out to the terminal using the
89// native Unicode API;
90// Whether the returned FILE* is "a terminal capable of displaying Unicode"
91// is determined in the same way as the print(FILE*, ...) overloads.
92_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
93
94# ifndef _LIBCPP_HAS_NO_UNICODE
95template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
96_LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
97# if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
98 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
99# else
100 FILE* __file = std::__get_ostream_file(__os);
101 if (!__file || !__print::__is_terminal(__file))
102 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
103
104 // [ostream.formatted.print]/3
105 // If the function is vprint_unicode and os is a stream that refers to a
106 // terminal capable of displaying Unicode which is determined in an
107 // implementation-defined manner, writes out to the terminal using the
108 // native Unicode API; if out contains invalid code units, the behavior is
109 // undefined and implementations are encouraged to diagnose it. If the
110 // native Unicode API is used, the function flushes os before writing out.
111 //
112 // This is the path for the native API, start with flushing.
113 __os.flush();
114
115# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
116 try {
117# endif // _LIBCPP_HAS_NO_EXCEPTIONS
118 ostream::sentry __s(__os);
119 if (__s) {
120# ifndef _LIBCPP_WIN32API
121 __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);
122# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
123 __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);
124# else
125# error "Windows builds with wchar_t disabled are not supported."
126# endif
127 }
128
129# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
130 } catch (...) {
131 __os.__set_badbit_and_consider_rethrow();
132 }
133# endif // _LIBCPP_HAS_NO_EXCEPTIONS
134# endif // _LIBCPP_AVAILABILITY_HAS_PRINT
135}
136
137template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
138_LIBCPP_HIDE_FROM_ABI inline void vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {
139 std::__vprint_unicode(__os, __fmt, __args, false);
140}
141# endif // _LIBCPP_HAS_NO_UNICODE
142
143template <class... _Args>
144_LIBCPP_HIDE_FROM_ABI void print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
145# ifndef _LIBCPP_HAS_NO_UNICODE
146 if constexpr (__print::__use_unicode_execution_charset)
147 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);
148 else
149 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
150# else // _LIBCPP_HAS_NO_UNICODE
151 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
152# endif // _LIBCPP_HAS_NO_UNICODE
153}
154
155template <class... _Args>
156_LIBCPP_HIDE_FROM_ABI void println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
157# ifndef _LIBCPP_HAS_NO_UNICODE
158 // Note the wording in the Standard is inefficient. The output of
159 // std::format is a std::string which is then copied. This solution
160 // just appends a newline at the end of the output.
161 if constexpr (__print::__use_unicode_execution_charset)
162 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);
163 else
164 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
165# else // _LIBCPP_HAS_NO_UNICODE
166 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
167# endif // _LIBCPP_HAS_NO_UNICODE
168}
169
170template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
171_LIBCPP_HIDE_FROM_ABI inline void println(ostream& __os) {
172 std::print(__os, "\n");
173}
174
175#endif // _LIBCPP_STD_VER >= 23
176
177_LIBCPP_END_NAMESPACE_STD
178
179#endif // _LIBCPP___OSTREAM_PRINT_H
lib/libcxx/include/__pstl/backend.h created+35
......@@ -0,0 +1,35 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___PSTL_BACKEND_H
10#define _LIBCPP___PSTL_BACKEND_H
11
12#include <__config>
13#include <__pstl/backend_fwd.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_PUSH_MACROS
20#include <__undef_macros>
21
22#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
23# include <__pstl/backends/default.h>
24# include <__pstl/backends/serial.h>
25#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
26# include <__pstl/backends/default.h>
27# include <__pstl/backends/std_thread.h>
28#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
29# include <__pstl/backends/default.h>
30# include <__pstl/backends/libdispatch.h>
31#endif
32
33_LIBCPP_POP_MACROS
34
35#endif // _LIBCPP___PSTL_BACKEND_H
lib/libcxx/include/__pstl/backend_fwd.h created+301
......@@ -0,0 +1,301 @@
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___PSTL_BACKEND_FWD_H
10#define _LIBCPP___PSTL_BACKEND_FWD_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_PUSH_MACROS
19#include <__undef_macros>
20
21//
22// This header declares available PSTL backends and the functions that must be implemented in order for the
23// PSTL algorithms to be provided.
24//
25// Backends often do not implement the full set of functions themselves -- a configuration of the PSTL is
26// usually a set of backends "stacked" together which each implement some algorithms under some execution
27// policies. It is only necessary for the "stack" of backends to implement all algorithms under all execution
28// policies, but a single backend is not required to implement everything on its own.
29//
30// The signatures used by each backend function are documented below.
31//
32// Exception handling
33// ==================
34//
35// PSTL backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from
36// their implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions
37// are turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the
38// frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to
39// the user.
40//
41
42_LIBCPP_BEGIN_NAMESPACE_STD
43namespace __pstl {
44
45template <class... _Backends>
46struct __backend_configuration;
47
48struct __default_backend_tag;
49struct __libdispatch_backend_tag;
50struct __serial_backend_tag;
51struct __std_thread_backend_tag;
52
53#if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
54using __current_configuration = __backend_configuration<__serial_backend_tag, __default_backend_tag>;
55#elif defined(_LIBCPP_PSTL_BACKEND_STD_THREAD)
56using __current_configuration = __backend_configuration<__std_thread_backend_tag, __default_backend_tag>;
57#elif defined(_LIBCPP_PSTL_BACKEND_LIBDISPATCH)
58using __current_configuration = __backend_configuration<__libdispatch_backend_tag, __default_backend_tag>;
59#else
60
61// ...New vendors can add parallel backends here...
62
63# error "Invalid PSTL backend configuration"
64#endif
65
66template <class _Backend, class _ExecutionPolicy>
67struct __find_if;
68// template <class _Policy, class _ForwardIterator, class _Predicate>
69// optional<_ForwardIterator>
70// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
71
72template <class _Backend, class _ExecutionPolicy>
73struct __find_if_not;
74// template <class _Policy, class _ForwardIterator, class _Predicate>
75// optional<_ForwardIterator>
76// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
77
78template <class _Backend, class _ExecutionPolicy>
79struct __find;
80// template <class _Policy, class _ForwardIterator, class _Tp>
81// optional<_ForwardIterator>
82// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept;
83
84template <class _Backend, class _ExecutionPolicy>
85struct __any_of;
86// template <class _Policy, class _ForwardIterator, class _Predicate>
87// optional<bool>
88// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
89
90template <class _Backend, class _ExecutionPolicy>
91struct __all_of;
92// template <class _Policy, class _ForwardIterator, class _Predicate>
93// optional<bool>
94// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
95
96template <class _Backend, class _ExecutionPolicy>
97struct __none_of;
98// template <class _Policy, class _ForwardIterator, class _Predicate>
99// optional<bool>
100// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
101
102template <class _Backend, class _ExecutionPolicy>
103struct __is_partitioned;
104// template <class _Policy, class _ForwardIterator, class _Predicate>
105// optional<bool>
106// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
107
108template <class _Backend, class _ExecutionPolicy>
109struct __for_each;
110// template <class _Policy, class _ForwardIterator, class _Function>
111// optional<__empty>
112// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Function __func) const noexcept;
113
114template <class _Backend, class _ExecutionPolicy>
115struct __for_each_n;
116// template <class _Policy, class _ForwardIterator, class _Size, class _Function>
117// optional<__empty>
118// operator()(_Policy&&, _ForwardIterator __first, _Size __size, _Function __func) const noexcept;
119
120template <class _Backend, class _ExecutionPolicy>
121struct __fill;
122// template <class _Policy, class _ForwardIterator, class _Tp>
123// optional<__empty>
124// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept;
125
126template <class _Backend, class _ExecutionPolicy>
127struct __fill_n;
128// template <class _Policy, class _ForwardIterator, class _Size, class _Tp>
129// optional<__empty>
130// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Tp const& __value) const noexcept;
131
132template <class _Backend, class _ExecutionPolicy>
133struct __replace;
134// template <class _Policy, class _ForwardIterator, class _Tp>
135// optional<__empty>
136// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
137// _Tp const& __old, _Tp const& __new) const noexcept;
138
139template <class _Backend, class _ExecutionPolicy>
140struct __replace_if;
141// template <class _Policy, class _ForwardIterator, class _Predicate, class _Tp>
142// optional<__empty>
143// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
144// _Predicate __pred, _Tp const& __new_value) const noexcept;
145
146template <class _Backend, class _ExecutionPolicy>
147struct __generate;
148// template <class _Policy, class _ForwardIterator, class _Generator>
149// optional<__empty>
150// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Generator __gen) const noexcept;
151
152template <class _Backend, class _ExecutionPolicy>
153struct __generate_n;
154// template <class _Policy, class _ForwardIterator, class _Size, class _Generator>
155// optional<__empty>
156// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _Generator __gen) const noexcept;
157
158template <class _Backend, class _ExecutionPolicy>
159struct __merge;
160// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp>
161// optional<_ForwardOutIterator>
162// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
163// _ForwardIterator2 __first2, _ForwardIterator2 __last2,
164// _ForwardOutIterator __result, _Comp __comp) const noexcept;
165
166template <class _Backend, class _ExecutionPolicy>
167struct __stable_sort;
168// template <class _Policy, class _RandomAccessIterator, class _Comp>
169// optional<__empty>
170// operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept;
171
172template <class _Backend, class _ExecutionPolicy>
173struct __sort;
174// template <class _Policy, class _RandomAccessIterator, class _Comp>
175// optional<__empty>
176// operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept;
177
178template <class _Backend, class _ExecutionPolicy>
179struct __transform;
180// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
181// optional<_ForwardOutIterator>
182// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
183// _ForwardOutIterator __result,
184// _UnaryOperation __op) const noexcept;
185
186template <class _Backend, class _ExecutionPolicy>
187struct __transform_binary;
188// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2,
189// class _ForwardOutIterator,
190// class _BinaryOperation>
191// optional<_ForwardOutIterator>
192// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
193// _ForwardIterator2 __first2,
194// _ForwardOutIterator __result,
195// _BinaryOperation __op) const noexcept;
196
197template <class _Backend, class _ExecutionPolicy>
198struct __replace_copy_if;
199// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Predicate, class _Tp>
200// optional<__empty>
201// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
202// _ForwardOutIterator __out_it,
203// _Predicate __pred,
204// _Tp const& __new_value) const noexcept;
205
206template <class _Backend, class _ExecutionPolicy>
207struct __replace_copy;
208// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Tp>
209// optional<__empty>
210// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
211// _ForwardOutIterator __out_it,
212// _Tp const& __old_value,
213// _Tp const& __new_value) const noexcept;
214
215template <class _Backend, class _ExecutionPolicy>
216struct __move;
217// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
218// optional<_ForwardOutIterator>
219// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
220// _ForwardOutIterator __out_it) const noexcept;
221
222template <class _Backend, class _ExecutionPolicy>
223struct __copy;
224// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
225// optional<_ForwardOutIterator>
226// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
227// _ForwardOutIterator __out_it) const noexcept;
228
229template <class _Backend, class _ExecutionPolicy>
230struct __copy_n;
231// template <class _Policy, class _ForwardIterator, class _Size, class _ForwardOutIterator>
232// optional<_ForwardOutIterator>
233// operator()(_Policy&&, _ForwardIterator __first, _Size __n, _ForwardOutIterator __out_it) const noexcept;
234
235template <class _Backend, class _ExecutionPolicy>
236struct __rotate_copy;
237// template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
238// optional<_ForwardOutIterator>
239// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last,
240// _ForwardOutIterator __out_it) const noexcept;
241
242template <class _Backend, class _ExecutionPolicy>
243struct __transform_reduce;
244// template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
245// optional<_Tp>
246// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
247// _Tp __init,
248// _BinaryOperation __reduce,
249// _UnaryOperation __transform) const noexcept;
250
251template <class _Backend, class _ExecutionPolicy>
252struct __transform_reduce_binary;
253// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2,
254// class _Tp, class _BinaryOperation1, class _BinaryOperation2>
255// optional<_Tp> operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
256// _ForwardIterator2 __first2,
257// _Tp __init,
258// _BinaryOperation1 __reduce,
259// _BinaryOperation2 __transform) const noexcept;
260
261template <class _Backend, class _ExecutionPolicy>
262struct __count_if;
263// template <class _Policy, class _ForwardIterator, class _Predicate>
264// optional<__iter_diff_t<_ForwardIterator>>
265// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept;
266
267template <class _Backend, class _ExecutionPolicy>
268struct __count;
269// template <class _Policy, class _ForwardIterator, class _Tp>
270// optional<__iter_diff_t<_ForwardIterator>>
271// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept;
272
273template <class _Backend, class _ExecutionPolicy>
274struct __equal_3leg;
275// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
276// optional<bool>
277// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
278// _ForwardIterator2 __first2,
279// _Predicate __pred) const noexcept;
280
281template <class _Backend, class _ExecutionPolicy>
282struct __equal;
283// template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
284// optional<bool>
285// operator()(_Policy&&, _ForwardIterator1 __first1, _ForwardIterator1 __last1,
286// _ForwardIterator2 __first2, _ForwardIterator2 __last2,
287// _Predicate __pred) const noexcept;
288
289template <class _Backend, class _ExecutionPolicy>
290struct __reduce;
291// template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation>
292// optional<_Tp>
293// operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last,
294// _Tp __init, _BinaryOperation __op) const noexcept;
295
296} // namespace __pstl
297_LIBCPP_END_NAMESPACE_STD
298
299_LIBCPP_POP_MACROS
300
301#endif // _LIBCPP___PSTL_BACKEND_FWD_H
lib/libcxx/include/__pstl/backends/default.h created+503
......@@ -0,0 +1,503 @@
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___PSTL_BACKENDS_DEFAULT_H
10#define _LIBCPP___PSTL_BACKENDS_DEFAULT_H
11
12#include <__algorithm/copy_n.h>
13#include <__algorithm/equal.h>
14#include <__algorithm/fill_n.h>
15#include <__algorithm/for_each_n.h>
16#include <__config>
17#include <__functional/identity.h>
18#include <__functional/not_fn.h>
19#include <__functional/operations.h>
20#include <__iterator/concepts.h>
21#include <__iterator/iterator_traits.h>
22#include <__pstl/backend_fwd.h>
23#include <__pstl/dispatch.h>
24#include <__utility/empty.h>
25#include <__utility/forward.h>
26#include <__utility/move.h>
27#include <optional>
28
29#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
30# pragma GCC system_header
31#endif
32
33_LIBCPP_PUSH_MACROS
34#include <__undef_macros>
35
36_LIBCPP_BEGIN_NAMESPACE_STD
37namespace __pstl {
38
39//
40// This file provides an incomplete PSTL backend that implements all of the PSTL algorithms
41// based on a smaller set of basis operations.
42//
43// It is intended as a building block for other PSTL backends that implement some operations more
44// efficiently but may not want to define the full set of PSTL algorithms.
45//
46// This backend implements all the PSTL algorithms based on the following basis operations:
47//
48// find_if family
49// --------------
50// - find
51// - find_if_not
52// - any_of
53// - all_of
54// - none_of
55// - is_partitioned
56//
57// for_each family
58// ---------------
59// - for_each_n
60// - fill
61// - fill_n
62// - replace
63// - replace_if
64// - generate
65// - generate_n
66//
67// merge family
68// ------------
69// No other algorithms based on merge
70//
71// stable_sort family
72// ------------------
73// - sort
74//
75// transform_reduce and transform_reduce_binary family
76// ---------------------------------------------------
77// - count_if
78// - count
79// - equal(3 legs)
80// - equal
81// - reduce
82//
83// transform and transform_binary family
84// -------------------------------------
85// - replace_copy_if
86// - replace_copy
87// - move
88// - copy
89// - copy_n
90// - rotate_copy
91//
92
93//////////////////////////////////////////////////////////////
94// find_if family
95//////////////////////////////////////////////////////////////
96template <class _ExecutionPolicy>
97struct __find<__default_backend_tag, _ExecutionPolicy> {
98 template <class _Policy, class _ForwardIterator, class _Tp>
99 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
100 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept {
101 using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>;
102 return _FindIf()(
103 __policy, std::move(__first), std::move(__last), [&](__iter_reference<_ForwardIterator> __element) {
104 return __element == __value;
105 });
106 }
107};
108
109template <class _ExecutionPolicy>
110struct __find_if_not<__default_backend_tag, _ExecutionPolicy> {
111 template <class _Policy, class _ForwardIterator, class _Pred>
112 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
113 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
114 using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>;
115 return _FindIf()(__policy, __first, __last, std::not_fn(std::forward<_Pred>(__pred)));
116 }
117};
118
119template <class _ExecutionPolicy>
120struct __any_of<__default_backend_tag, _ExecutionPolicy> {
121 template <class _Policy, class _ForwardIterator, class _Pred>
122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
123 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
124 using _FindIf = __dispatch<__find_if, __current_configuration, _ExecutionPolicy>;
125 auto __res = _FindIf()(__policy, __first, __last, std::forward<_Pred>(__pred));
126 if (!__res)
127 return nullopt;
128 return *__res != __last;
129 }
130};
131
132template <class _ExecutionPolicy>
133struct __all_of<__default_backend_tag, _ExecutionPolicy> {
134 template <class _Policy, class _ForwardIterator, class _Pred>
135 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
136 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
137 using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>;
138 auto __res = _AnyOf()(__policy, __first, __last, [&](__iter_reference<_ForwardIterator> __value) {
139 return !__pred(__value);
140 });
141 if (!__res)
142 return nullopt;
143 return !*__res;
144 }
145};
146
147template <class _ExecutionPolicy>
148struct __none_of<__default_backend_tag, _ExecutionPolicy> {
149 template <class _Policy, class _ForwardIterator, class _Pred>
150 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
151 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
152 using _AnyOf = __dispatch<__any_of, __current_configuration, _ExecutionPolicy>;
153 auto __res = _AnyOf()(__policy, __first, __last, std::forward<_Pred>(__pred));
154 if (!__res)
155 return nullopt;
156 return !*__res;
157 }
158};
159
160template <class _ExecutionPolicy>
161struct __is_partitioned<__default_backend_tag, _ExecutionPolicy> {
162 template <class _Policy, class _ForwardIterator, class _Pred>
163 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
164 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
165 using _FindIfNot = __dispatch<__find_if_not, __current_configuration, _ExecutionPolicy>;
166 auto __maybe_first = _FindIfNot()(__policy, std::move(__first), std::move(__last), __pred);
167 if (__maybe_first == nullopt)
168 return nullopt;
169
170 __first = *__maybe_first;
171 if (__first == __last)
172 return true;
173 ++__first;
174 using _NoneOf = __dispatch<__none_of, __current_configuration, _ExecutionPolicy>;
175 return _NoneOf()(__policy, std::move(__first), std::move(__last), __pred);
176 }
177};
178
179//////////////////////////////////////////////////////////////
180// for_each family
181//////////////////////////////////////////////////////////////
182template <class _ExecutionPolicy>
183struct __for_each_n<__default_backend_tag, _ExecutionPolicy> {
184 template <class _Policy, class _ForwardIterator, class _Size, class _Function>
185 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
186 operator()(_Policy&& __policy, _ForwardIterator __first, _Size __size, _Function __func) const noexcept {
187 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
188 using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>;
189 _ForwardIterator __last = __first + __size;
190 return _ForEach()(__policy, std::move(__first), std::move(__last), std::move(__func));
191 } else {
192 // Otherwise, use the serial algorithm to avoid doing two passes over the input
193 std::for_each_n(std::move(__first), __size, std::move(__func));
194 return __empty{};
195 }
196 }
197};
198
199template <class _ExecutionPolicy>
200struct __fill<__default_backend_tag, _ExecutionPolicy> {
201 template <class _Policy, class _ForwardIterator, class _Tp>
202 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
203 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept {
204 using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>;
205 using _Ref = __iter_reference<_ForwardIterator>;
206 return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __value; });
207 }
208};
209
210template <class _ExecutionPolicy>
211struct __fill_n<__default_backend_tag, _ExecutionPolicy> {
212 template <class _Policy, class _ForwardIterator, class _Size, class _Tp>
213 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
214 operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Tp const& __value) const noexcept {
215 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
216 using _Fill = __dispatch<__fill, __current_configuration, _ExecutionPolicy>;
217 _ForwardIterator __last = __first + __n;
218 return _Fill()(__policy, std::move(__first), std::move(__last), __value);
219 } else {
220 // Otherwise, use the serial algorithm to avoid doing two passes over the input
221 std::fill_n(std::move(__first), __n, __value);
222 return optional<__empty>{__empty{}};
223 }
224 }
225};
226
227template <class _ExecutionPolicy>
228struct __replace<__default_backend_tag, _ExecutionPolicy> {
229 template <class _Policy, class _ForwardIterator, class _Tp>
230 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
231 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __old, _Tp const& __new)
232 const noexcept {
233 using _ReplaceIf = __dispatch<__replace_if, __current_configuration, _ExecutionPolicy>;
234 using _Ref = __iter_reference<_ForwardIterator>;
235 return _ReplaceIf()(
236 __policy, std::move(__first), std::move(__last), [&](_Ref __element) { return __element == __old; }, __new);
237 }
238};
239
240template <class _ExecutionPolicy>
241struct __replace_if<__default_backend_tag, _ExecutionPolicy> {
242 template <class _Policy, class _ForwardIterator, class _Pred, class _Tp>
243 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty> operator()(
244 _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred, _Tp const& __new_value)
245 const noexcept {
246 using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>;
247 using _Ref = __iter_reference<_ForwardIterator>;
248 return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) {
249 if (__pred(__element))
250 __element = __new_value;
251 });
252 }
253};
254
255template <class _ExecutionPolicy>
256struct __generate<__default_backend_tag, _ExecutionPolicy> {
257 template <class _Policy, class _ForwardIterator, class _Generator>
258 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
259 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Generator&& __gen) const noexcept {
260 using _ForEach = __dispatch<__for_each, __current_configuration, _ExecutionPolicy>;
261 using _Ref = __iter_reference<_ForwardIterator>;
262 return _ForEach()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) { __element = __gen(); });
263 }
264};
265
266template <class _ExecutionPolicy>
267struct __generate_n<__default_backend_tag, _ExecutionPolicy> {
268 template <class _Policy, class _ForwardIterator, class _Size, class _Generator>
269 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
270 operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _Generator&& __gen) const noexcept {
271 using _ForEachN = __dispatch<__for_each_n, __current_configuration, _ExecutionPolicy>;
272 using _Ref = __iter_reference<_ForwardIterator>;
273 return _ForEachN()(__policy, std::move(__first), __n, [&](_Ref __element) { __element = __gen(); });
274 }
275};
276
277//////////////////////////////////////////////////////////////
278// stable_sort family
279//////////////////////////////////////////////////////////////
280template <class _ExecutionPolicy>
281struct __sort<__default_backend_tag, _ExecutionPolicy> {
282 template <class _Policy, class _RandomAccessIterator, class _Comp>
283 _LIBCPP_HIDE_FROM_ABI optional<__empty> operator()(
284 _Policy&& __policy, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp&& __comp) const noexcept {
285 using _StableSort = __dispatch<__stable_sort, __current_configuration, _ExecutionPolicy>;
286 return _StableSort()(__policy, std::move(__first), std::move(__last), std::forward<_Comp>(__comp));
287 }
288};
289
290//////////////////////////////////////////////////////////////
291// transform_reduce family
292//////////////////////////////////////////////////////////////
293template <class _ExecutionPolicy>
294struct __count_if<__default_backend_tag, _ExecutionPolicy> {
295 template <class _Policy, class _ForwardIterator, class _Predicate>
296 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>> operator()(
297 _Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate&& __pred) const noexcept {
298 using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>;
299 using _DiffT = __iter_diff_t<_ForwardIterator>;
300 using _Ref = __iter_reference<_ForwardIterator>;
301 return _TransformReduce()(
302 __policy, std::move(__first), std::move(__last), _DiffT{}, std::plus{}, [&](_Ref __element) -> _DiffT {
303 return __pred(__element) ? _DiffT(1) : _DiffT(0);
304 });
305 }
306};
307
308template <class _ExecutionPolicy>
309struct __count<__default_backend_tag, _ExecutionPolicy> {
310 template <class _Policy, class _ForwardIterator, class _Tp>
311 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__iter_diff_t<_ForwardIterator>>
312 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp const& __value) const noexcept {
313 using _CountIf = __dispatch<__count_if, __current_configuration, _ExecutionPolicy>;
314 using _Ref = __iter_reference<_ForwardIterator>;
315 return _CountIf()(__policy, std::move(__first), std::move(__last), [&](_Ref __element) -> bool {
316 return __element == __value;
317 });
318 }
319};
320
321template <class _ExecutionPolicy>
322struct __equal_3leg<__default_backend_tag, _ExecutionPolicy> {
323 template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
324 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
325 operator()(_Policy&& __policy,
326 _ForwardIterator1 __first1,
327 _ForwardIterator1 __last1,
328 _ForwardIterator2 __first2,
329 _Predicate&& __pred) const noexcept {
330 using _TransformReduce = __dispatch<__transform_reduce_binary, __current_configuration, _ExecutionPolicy>;
331 return _TransformReduce()(
332 __policy,
333 std::move(__first1),
334 std::move(__last1),
335 std::move(__first2),
336 true,
337 std::logical_and{},
338 std::forward<_Predicate>(__pred));
339 }
340};
341
342template <class _ExecutionPolicy>
343struct __equal<__default_backend_tag, _ExecutionPolicy> {
344 template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _Predicate>
345 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<bool>
346 operator()(_Policy&& __policy,
347 _ForwardIterator1 __first1,
348 _ForwardIterator1 __last1,
349 _ForwardIterator2 __first2,
350 _ForwardIterator2 __last2,
351 _Predicate&& __pred) const noexcept {
352 if constexpr (__has_random_access_iterator_category<_ForwardIterator1>::value &&
353 __has_random_access_iterator_category<_ForwardIterator2>::value) {
354 if (__last1 - __first1 != __last2 - __first2)
355 return false;
356 // Fall back to the 3 legged algorithm
357 using _Equal3Leg = __dispatch<__equal_3leg, __current_configuration, _ExecutionPolicy>;
358 return _Equal3Leg()(
359 __policy, std::move(__first1), std::move(__last1), std::move(__first2), std::forward<_Predicate>(__pred));
360 } else {
361 // If we don't have random access, fall back to the serial algorithm cause we can't do much
362 return std::equal(
363 std::move(__first1),
364 std::move(__last1),
365 std::move(__first2),
366 std::move(__last2),
367 std::forward<_Predicate>(__pred));
368 }
369 }
370};
371
372template <class _ExecutionPolicy>
373struct __reduce<__default_backend_tag, _ExecutionPolicy> {
374 template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation>
375 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_Tp>
376 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Tp __init, _BinaryOperation&& __op)
377 const noexcept {
378 using _TransformReduce = __dispatch<__transform_reduce, __current_configuration, _ExecutionPolicy>;
379 return _TransformReduce()(
380 __policy,
381 std::move(__first),
382 std::move(__last),
383 std::move(__init),
384 std::forward<_BinaryOperation>(__op),
385 __identity{});
386 }
387};
388
389//////////////////////////////////////////////////////////////
390// transform family
391//////////////////////////////////////////////////////////////
392template <class _ExecutionPolicy>
393struct __replace_copy_if<__default_backend_tag, _ExecutionPolicy> {
394 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Pred, class _Tp>
395 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
396 operator()(_Policy&& __policy,
397 _ForwardIterator __first,
398 _ForwardIterator __last,
399 _ForwardOutIterator __out_it,
400 _Pred&& __pred,
401 _Tp const& __new_value) const noexcept {
402 using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>;
403 using _Ref = __iter_reference<_ForwardIterator>;
404 auto __res =
405 _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](_Ref __element) {
406 return __pred(__element) ? __new_value : __element;
407 });
408 if (__res == nullopt)
409 return nullopt;
410 return __empty{};
411 }
412};
413
414template <class _ExecutionPolicy>
415struct __replace_copy<__default_backend_tag, _ExecutionPolicy> {
416 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _Tp>
417 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<__empty>
418 operator()(_Policy&& __policy,
419 _ForwardIterator __first,
420 _ForwardIterator __last,
421 _ForwardOutIterator __out_it,
422 _Tp const& __old_value,
423 _Tp const& __new_value) const noexcept {
424 using _ReplaceCopyIf = __dispatch<__replace_copy_if, __current_configuration, _ExecutionPolicy>;
425 using _Ref = __iter_reference<_ForwardIterator>;
426 return _ReplaceCopyIf()(
427 __policy,
428 std::move(__first),
429 std::move(__last),
430 std::move(__out_it),
431 [&](_Ref __element) { return __element == __old_value; },
432 __new_value);
433 }
434};
435
436// TODO: Use the std::copy/move shenanigans to forward to std::memmove
437// Investigate whether we want to still forward to std::transform(policy)
438// in that case for the execution::par part, or whether we actually want
439// to run everything serially in that case.
440template <class _ExecutionPolicy>
441struct __move<__default_backend_tag, _ExecutionPolicy> {
442 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
443 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
444 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __out_it)
445 const noexcept {
446 using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>;
447 return _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), [&](auto&& __element) {
448 return std::move(__element);
449 });
450 }
451};
452
453// TODO: Use the std::copy/move shenanigans to forward to std::memmove
454template <class _ExecutionPolicy>
455struct __copy<__default_backend_tag, _ExecutionPolicy> {
456 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
457 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
458 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __out_it)
459 const noexcept {
460 using _Transform = __dispatch<__transform, __current_configuration, _ExecutionPolicy>;
461 return _Transform()(__policy, std::move(__first), std::move(__last), std::move(__out_it), __identity());
462 }
463};
464
465template <class _ExecutionPolicy>
466struct __copy_n<__default_backend_tag, _ExecutionPolicy> {
467 template <class _Policy, class _ForwardIterator, class _Size, class _ForwardOutIterator>
468 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
469 operator()(_Policy&& __policy, _ForwardIterator __first, _Size __n, _ForwardOutIterator __out_it) const noexcept {
470 if constexpr (__has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
471 using _Copy = __dispatch<__copy, __current_configuration, _ExecutionPolicy>;
472 _ForwardIterator __last = __first + __n;
473 return _Copy()(__policy, std::move(__first), std::move(__last), std::move(__out_it));
474 } else {
475 // Otherwise, use the serial algorithm to avoid doing two passes over the input
476 return std::copy_n(std::move(__first), __n, std::move(__out_it));
477 }
478 }
479};
480
481template <class _ExecutionPolicy>
482struct __rotate_copy<__default_backend_tag, _ExecutionPolicy> {
483 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator>
484 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
485 operator()(_Policy&& __policy,
486 _ForwardIterator __first,
487 _ForwardIterator __middle,
488 _ForwardIterator __last,
489 _ForwardOutIterator __out_it) const noexcept {
490 using _Copy = __dispatch<__copy, __current_configuration, _ExecutionPolicy>;
491 auto __result_mid = _Copy()(__policy, __middle, std::move(__last), std::move(__out_it));
492 if (__result_mid == nullopt)
493 return nullopt;
494 return _Copy()(__policy, std::move(__first), std::move(__middle), *std::move(__result_mid));
495 }
496};
497
498} // namespace __pstl
499_LIBCPP_END_NAMESPACE_STD
500
501_LIBCPP_POP_MACROS
502
503#endif // _LIBCPP___PSTL_BACKENDS_DEFAULT_H
lib/libcxx/include/__pstl/backends/libdispatch.h created+397
......@@ -0,0 +1,397 @@
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___PSTL_BACKENDS_LIBDISPATCH_H
10#define _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H
11
12#include <__algorithm/inplace_merge.h>
13#include <__algorithm/lower_bound.h>
14#include <__algorithm/max.h>
15#include <__algorithm/merge.h>
16#include <__algorithm/upper_bound.h>
17#include <__atomic/atomic.h>
18#include <__config>
19#include <__exception/terminate.h>
20#include <__iterator/iterator_traits.h>
21#include <__iterator/move_iterator.h>
22#include <__memory/allocator.h>
23#include <__memory/construct_at.h>
24#include <__memory/unique_ptr.h>
25#include <__numeric/reduce.h>
26#include <__pstl/backend_fwd.h>
27#include <__pstl/cpu_algos/any_of.h>
28#include <__pstl/cpu_algos/cpu_traits.h>
29#include <__pstl/cpu_algos/fill.h>
30#include <__pstl/cpu_algos/find_if.h>
31#include <__pstl/cpu_algos/for_each.h>
32#include <__pstl/cpu_algos/merge.h>
33#include <__pstl/cpu_algos/stable_sort.h>
34#include <__pstl/cpu_algos/transform.h>
35#include <__pstl/cpu_algos/transform_reduce.h>
36#include <__utility/empty.h>
37#include <__utility/exception_guard.h>
38#include <__utility/move.h>
39#include <__utility/pair.h>
40#include <cstddef>
41#include <new>
42#include <optional>
43
44_LIBCPP_PUSH_MACROS
45#include <__undef_macros>
46
47_LIBCPP_BEGIN_NAMESPACE_STD
48namespace __pstl {
49
50namespace __libdispatch {
51// ::dispatch_apply is marked as __attribute__((nothrow)) because it doesn't let exceptions propagate, and neither do
52// we.
53// TODO: Do we want to add [[_Clang::__callback__(__func, __context, __)]]?
54_LIBCPP_EXPORTED_FROM_ABI void
55__dispatch_apply(size_t __chunk_count, void* __context, void (*__func)(void* __context, size_t __chunk)) noexcept;
56
57template <class _Func>
58_LIBCPP_HIDE_FROM_ABI void __dispatch_apply(size_t __chunk_count, _Func __func) noexcept {
59 __libdispatch::__dispatch_apply(__chunk_count, &__func, [](void* __context, size_t __chunk) {
60 (*static_cast<_Func*>(__context))(__chunk);
61 });
62}
63
64struct __chunk_partitions {
65 ptrdiff_t __chunk_count_; // includes the first chunk
66 ptrdiff_t __chunk_size_;
67 ptrdiff_t __first_chunk_size_;
68};
69
70[[__gnu__::__const__]] _LIBCPP_EXPORTED_FROM_ABI __chunk_partitions __partition_chunks(ptrdiff_t __size) noexcept;
71
72template <class _RandomAccessIterator, class _Functor>
73_LIBCPP_HIDE_FROM_ABI optional<__empty>
74__dispatch_parallel_for(__chunk_partitions __partitions, _RandomAccessIterator __first, _Functor __func) {
75 // Perform the chunked execution.
76 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) {
77 auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_;
78 auto __index =
79 __chunk == 0
80 ? 0
81 : (__chunk * __partitions.__chunk_size_) + (__partitions.__first_chunk_size_ - __partitions.__chunk_size_);
82 __func(__first + __index, __first + __index + __this_chunk_size);
83 });
84
85 return __empty{};
86}
87} // namespace __libdispatch
88
89template <>
90struct __cpu_traits<__libdispatch_backend_tag> {
91 template <class _RandomAccessIterator, class _Functor>
92 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
93 __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func) {
94 return __libdispatch::__dispatch_parallel_for(
95 __libdispatch::__partition_chunks(__last - __first), std::move(__first), std::move(__func));
96 }
97
98 template <class _RandomAccessIterator1, class _RandomAccessIterator2, class _RandomAccessIteratorOut>
99 struct __merge_range {
100 __merge_range(_RandomAccessIterator1 __mid1, _RandomAccessIterator2 __mid2, _RandomAccessIteratorOut __result)
101 : __mid1_(__mid1), __mid2_(__mid2), __result_(__result) {}
102
103 _RandomAccessIterator1 __mid1_;
104 _RandomAccessIterator2 __mid2_;
105 _RandomAccessIteratorOut __result_;
106 };
107
108 template <typename _RandomAccessIterator1,
109 typename _RandomAccessIterator2,
110 typename _RandomAccessIterator3,
111 typename _Compare,
112 typename _LeafMerge>
113 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
114 __merge(_RandomAccessIterator1 __first1,
115 _RandomAccessIterator1 __last1,
116 _RandomAccessIterator2 __first2,
117 _RandomAccessIterator2 __last2,
118 _RandomAccessIterator3 __result,
119 _Compare __comp,
120 _LeafMerge __leaf_merge) noexcept {
121 __libdispatch::__chunk_partitions __partitions =
122 __libdispatch::__partition_chunks(std::max<ptrdiff_t>(__last1 - __first1, __last2 - __first2));
123
124 if (__partitions.__chunk_count_ == 0)
125 return __empty{};
126
127 if (__partitions.__chunk_count_ == 1) {
128 __leaf_merge(__first1, __last1, __first2, __last2, __result, __comp);
129 return __empty{};
130 }
131
132 using __merge_range_t = __merge_range<_RandomAccessIterator1, _RandomAccessIterator2, _RandomAccessIterator3>;
133 auto const __n_ranges = __partitions.__chunk_count_ + 1;
134
135 // TODO: use __uninitialized_buffer
136 auto __destroy = [=](__merge_range_t* __ptr) {
137 std::destroy_n(__ptr, __n_ranges);
138 std::allocator<__merge_range_t>().deallocate(__ptr, __n_ranges);
139 };
140
141 unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges(
142 [&]() -> __merge_range_t* {
143#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
144 try {
145#endif
146 return std::allocator<__merge_range_t>().allocate(__n_ranges);
147#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
148 } catch (const std::bad_alloc&) {
149 return nullptr;
150 }
151#endif
152 }(),
153 __destroy);
154
155 if (!__ranges)
156 return nullopt;
157
158 // TODO: Improve the case where the smaller range is merged into just a few (or even one) chunks of the larger case
159 __merge_range_t* __r = __ranges.get();
160 std::__construct_at(__r++, __first1, __first2, __result);
161
162 bool __iterate_first_range = __last1 - __first1 > __last2 - __first2;
163
164 auto __compute_chunk = [&](size_t __chunk_size) -> __merge_range_t {
165 auto [__mid1, __mid2] = [&] {
166 if (__iterate_first_range) {
167 auto __m1 = __first1 + __chunk_size;
168 auto __m2 = std::lower_bound(__first2, __last2, __m1[-1], __comp);
169 return std::make_pair(__m1, __m2);
170 } else {
171 auto __m2 = __first2 + __chunk_size;
172 auto __m1 = std::lower_bound(__first1, __last1, __m2[-1], __comp);
173 return std::make_pair(__m1, __m2);
174 }
175 }();
176
177 __result += (__mid1 - __first1) + (__mid2 - __first2);
178 __first1 = __mid1;
179 __first2 = __mid2;
180 return {std::move(__mid1), std::move(__mid2), __result};
181 };
182
183 // handle first chunk
184 std::__construct_at(__r++, __compute_chunk(__partitions.__first_chunk_size_));
185
186 // handle 2 -> N - 1 chunks
187 for (ptrdiff_t __i = 0; __i != __partitions.__chunk_count_ - 2; ++__i)
188 std::__construct_at(__r++, __compute_chunk(__partitions.__chunk_size_));
189
190 // handle last chunk
191 std::__construct_at(__r, __last1, __last2, __result);
192
193 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __index) {
194 auto __first_iters = __ranges[__index];
195 auto __last_iters = __ranges[__index + 1];
196 __leaf_merge(
197 __first_iters.__mid1_,
198 __last_iters.__mid1_,
199 __first_iters.__mid2_,
200 __last_iters.__mid2_,
201 __first_iters.__result_,
202 __comp);
203 });
204
205 return __empty{};
206 }
207
208 template <class _RandomAccessIterator, class _Transform, class _Value, class _Combiner, class _Reduction>
209 _LIBCPP_HIDE_FROM_ABI static optional<_Value> __transform_reduce(
210 _RandomAccessIterator __first,
211 _RandomAccessIterator __last,
212 _Transform __transform,
213 _Value __init,
214 _Combiner __combiner,
215 _Reduction __reduction) {
216 if (__first == __last)
217 return __init;
218
219 auto __partitions = __libdispatch::__partition_chunks(__last - __first);
220
221 auto __destroy = [__count = __partitions.__chunk_count_](_Value* __ptr) {
222 std::destroy_n(__ptr, __count);
223 std::allocator<_Value>().deallocate(__ptr, __count);
224 };
225
226 // TODO: use __uninitialized_buffer
227 // TODO: allocate one element per worker instead of one element per chunk
228 unique_ptr<_Value[], decltype(__destroy)> __values(
229 std::allocator<_Value>().allocate(__partitions.__chunk_count_), __destroy);
230
231 // __dispatch_apply is noexcept
232 __libdispatch::__dispatch_apply(__partitions.__chunk_count_, [&](size_t __chunk) {
233 auto __this_chunk_size = __chunk == 0 ? __partitions.__first_chunk_size_ : __partitions.__chunk_size_;
234 auto __index = __chunk == 0 ? 0
235 : (__chunk * __partitions.__chunk_size_) +
236 (__partitions.__first_chunk_size_ - __partitions.__chunk_size_);
237 if (__this_chunk_size != 1) {
238 std::__construct_at(
239 __values.get() + __chunk,
240 __reduction(__first + __index + 2,
241 __first + __index + __this_chunk_size,
242 __combiner(__transform(__first + __index), __transform(__first + __index + 1))));
243 } else {
244 std::__construct_at(__values.get() + __chunk, __transform(__first + __index));
245 }
246 });
247
248 return std::reduce(
249 std::make_move_iterator(__values.get()),
250 std::make_move_iterator(__values.get() + __partitions.__chunk_count_),
251 std::move(__init),
252 __combiner);
253 }
254
255 template <class _RandomAccessIterator, class _Comp, class _LeafSort>
256 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
257 __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp, _LeafSort __leaf_sort) {
258 const auto __size = __last - __first;
259 auto __partitions = __libdispatch::__partition_chunks(__size);
260
261 if (__partitions.__chunk_count_ == 0)
262 return __empty{};
263
264 if (__partitions.__chunk_count_ == 1) {
265 __leaf_sort(__first, __last, __comp);
266 return __empty{};
267 }
268
269 using _Value = __iter_value_type<_RandomAccessIterator>;
270
271 auto __destroy = [__size](_Value* __ptr) {
272 std::destroy_n(__ptr, __size);
273 std::allocator<_Value>().deallocate(__ptr, __size);
274 };
275
276 // TODO: use __uninitialized_buffer
277 unique_ptr<_Value[], decltype(__destroy)> __values(std::allocator<_Value>().allocate(__size), __destroy);
278
279 // Initialize all elements to a moved-from state
280 // TODO: Don't do this - this can be done in the first merge - see https://llvm.org/PR63928
281 std::__construct_at(__values.get(), std::move(*__first));
282 for (__iter_diff_t<_RandomAccessIterator> __i = 1; __i != __size; ++__i) {
283 std::__construct_at(__values.get() + __i, std::move(__values.get()[__i - 1]));
284 }
285 *__first = std::move(__values.get()[__size - 1]);
286
287 __libdispatch::__dispatch_parallel_for(
288 __partitions,
289 __first,
290 [&__leaf_sort, &__comp](_RandomAccessIterator __chunk_first, _RandomAccessIterator __chunk_last) {
291 __leaf_sort(std::move(__chunk_first), std::move(__chunk_last), __comp);
292 });
293
294 bool __objects_are_in_buffer = false;
295 do {
296 const auto __old_chunk_size = __partitions.__chunk_size_;
297 if (__partitions.__chunk_count_ % 2 == 1) {
298 auto __inplace_merge_chunks = [&__comp, &__partitions](auto __first_chunk_begin) {
299 std::inplace_merge(
300 __first_chunk_begin,
301 __first_chunk_begin + __partitions.__first_chunk_size_,
302 __first_chunk_begin + __partitions.__first_chunk_size_ + __partitions.__chunk_size_,
303 __comp);
304 };
305 if (__objects_are_in_buffer)
306 __inplace_merge_chunks(__values.get());
307 else
308 __inplace_merge_chunks(__first);
309 __partitions.__first_chunk_size_ += 2 * __partitions.__chunk_size_;
310 } else {
311 __partitions.__first_chunk_size_ += __partitions.__chunk_size_;
312 }
313
314 __partitions.__chunk_size_ *= 2;
315 __partitions.__chunk_count_ /= 2;
316
317 auto __merge_chunks = [__partitions, __old_chunk_size, &__comp](auto __from_first, auto __to_first) {
318 __libdispatch::__dispatch_parallel_for(
319 __partitions,
320 __from_first,
321 [__old_chunk_size, &__from_first, &__to_first, &__comp](auto __chunk_first, auto __chunk_last) {
322 std::merge(std::make_move_iterator(__chunk_first),
323 std::make_move_iterator(__chunk_last - __old_chunk_size),
324 std::make_move_iterator(__chunk_last - __old_chunk_size),
325 std::make_move_iterator(__chunk_last),
326 __to_first + (__chunk_first - __from_first),
327 __comp);
328 });
329 };
330
331 if (__objects_are_in_buffer)
332 __merge_chunks(__values.get(), __first);
333 else
334 __merge_chunks(__first, __values.get());
335 __objects_are_in_buffer = !__objects_are_in_buffer;
336 } while (__partitions.__chunk_count_ > 1);
337
338 if (__objects_are_in_buffer) {
339 std::move(__values.get(), __values.get() + __size, __first);
340 }
341
342 return __empty{};
343 }
344
345 _LIBCPP_HIDE_FROM_ABI static void __cancel_execution() {}
346
347 static constexpr size_t __lane_size = 64;
348};
349
350// Mandatory implementations of the computational basis
351template <class _ExecutionPolicy>
352struct __find_if<__libdispatch_backend_tag, _ExecutionPolicy>
353 : __cpu_parallel_find_if<__libdispatch_backend_tag, _ExecutionPolicy> {};
354
355template <class _ExecutionPolicy>
356struct __for_each<__libdispatch_backend_tag, _ExecutionPolicy>
357 : __cpu_parallel_for_each<__libdispatch_backend_tag, _ExecutionPolicy> {};
358
359template <class _ExecutionPolicy>
360struct __merge<__libdispatch_backend_tag, _ExecutionPolicy>
361 : __cpu_parallel_merge<__libdispatch_backend_tag, _ExecutionPolicy> {};
362
363template <class _ExecutionPolicy>
364struct __stable_sort<__libdispatch_backend_tag, _ExecutionPolicy>
365 : __cpu_parallel_stable_sort<__libdispatch_backend_tag, _ExecutionPolicy> {};
366
367template <class _ExecutionPolicy>
368struct __transform<__libdispatch_backend_tag, _ExecutionPolicy>
369 : __cpu_parallel_transform<__libdispatch_backend_tag, _ExecutionPolicy> {};
370
371template <class _ExecutionPolicy>
372struct __transform_binary<__libdispatch_backend_tag, _ExecutionPolicy>
373 : __cpu_parallel_transform_binary<__libdispatch_backend_tag, _ExecutionPolicy> {};
374
375template <class _ExecutionPolicy>
376struct __transform_reduce<__libdispatch_backend_tag, _ExecutionPolicy>
377 : __cpu_parallel_transform_reduce<__libdispatch_backend_tag, _ExecutionPolicy> {};
378
379template <class _ExecutionPolicy>
380struct __transform_reduce_binary<__libdispatch_backend_tag, _ExecutionPolicy>
381 : __cpu_parallel_transform_reduce_binary<__libdispatch_backend_tag, _ExecutionPolicy> {};
382
383// Not mandatory, but better optimized
384template <class _ExecutionPolicy>
385struct __any_of<__libdispatch_backend_tag, _ExecutionPolicy>
386 : __cpu_parallel_any_of<__libdispatch_backend_tag, _ExecutionPolicy> {};
387
388template <class _ExecutionPolicy>
389struct __fill<__libdispatch_backend_tag, _ExecutionPolicy>
390 : __cpu_parallel_fill<__libdispatch_backend_tag, _ExecutionPolicy> {};
391
392} // namespace __pstl
393_LIBCPP_END_NAMESPACE_STD
394
395_LIBCPP_POP_MACROS
396
397#endif // _LIBCPP___PSTL_BACKENDS_LIBDISPATCH_H
lib/libcxx/include/__pstl/backends/serial.h created+181
......@@ -0,0 +1,181 @@
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___PSTL_BACKENDS_SERIAL_H
11#define _LIBCPP___PSTL_BACKENDS_SERIAL_H
12
13#include <__algorithm/find_if.h>
14#include <__algorithm/for_each.h>
15#include <__algorithm/merge.h>
16#include <__algorithm/stable_sort.h>
17#include <__algorithm/transform.h>
18#include <__config>
19#include <__numeric/transform_reduce.h>
20#include <__pstl/backend_fwd.h>
21#include <__utility/empty.h>
22#include <__utility/forward.h>
23#include <__utility/move.h>
24#include <optional>
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
34namespace __pstl {
35
36//
37// This partial PSTL backend runs everything serially.
38//
39// TODO: Right now, the serial backend must be used with another backend
40// like the "default backend" because it doesn't implement all the
41// necessary PSTL operations. It would be better to dispatch all
42// algorithms to their serial counterpart directly, since this can
43// often be more efficient than the "default backend"'s implementation
44// if we end up running serially anyways.
45//
46
47template <class _ExecutionPolicy>
48struct __find_if<__serial_backend_tag, _ExecutionPolicy> {
49 template <class _Policy, class _ForwardIterator, class _Pred>
50 _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
51 operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Pred&& __pred) const noexcept {
52 return std::find_if(std::move(__first), std::move(__last), std::forward<_Pred>(__pred));
53 }
54};
55
56template <class _ExecutionPolicy>
57struct __for_each<__serial_backend_tag, _ExecutionPolicy> {
58 template <class _Policy, class _ForwardIterator, class _Function>
59 _LIBCPP_HIDE_FROM_ABI optional<__empty>
60 operator()(_Policy&&, _ForwardIterator __first, _ForwardIterator __last, _Function&& __func) const noexcept {
61 std::for_each(std::move(__first), std::move(__last), std::forward<_Function>(__func));
62 return __empty{};
63 }
64};
65
66template <class _ExecutionPolicy>
67struct __merge<__serial_backend_tag, _ExecutionPolicy> {
68 template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp>
69 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()(
70 _Policy&&,
71 _ForwardIterator1 __first1,
72 _ForwardIterator1 __last1,
73 _ForwardIterator2 __first2,
74 _ForwardIterator2 __last2,
75 _ForwardOutIterator __outit,
76 _Comp&& __comp) const noexcept {
77 return std::merge(
78 std::move(__first1),
79 std::move(__last1),
80 std::move(__first2),
81 std::move(__last2),
82 std::move(__outit),
83 std::forward<_Comp>(__comp));
84 }
85};
86
87template <class _ExecutionPolicy>
88struct __stable_sort<__serial_backend_tag, _ExecutionPolicy> {
89 template <class _Policy, class _RandomAccessIterator, class _Comp>
90 _LIBCPP_HIDE_FROM_ABI optional<__empty>
91 operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp&& __comp) const noexcept {
92 std::stable_sort(std::move(__first), std::move(__last), std::forward<_Comp>(__comp));
93 return __empty{};
94 }
95};
96
97template <class _ExecutionPolicy>
98struct __transform<__serial_backend_tag, _ExecutionPolicy> {
99 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
100 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()(
101 _Policy&&, _ForwardIterator __first, _ForwardIterator __last, _ForwardOutIterator __outit, _UnaryOperation&& __op)
102 const noexcept {
103 return std::transform(
104 std::move(__first), std::move(__last), std::move(__outit), std::forward<_UnaryOperation>(__op));
105 }
106};
107
108template <class _ExecutionPolicy>
109struct __transform_binary<__serial_backend_tag, _ExecutionPolicy> {
110 template <class _Policy,
111 class _ForwardIterator1,
112 class _ForwardIterator2,
113 class _ForwardOutIterator,
114 class _BinaryOperation>
115 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
116 operator()(_Policy&&,
117 _ForwardIterator1 __first1,
118 _ForwardIterator1 __last1,
119 _ForwardIterator2 __first2,
120 _ForwardOutIterator __outit,
121 _BinaryOperation&& __op) const noexcept {
122 return std::transform(
123 std::move(__first1),
124 std::move(__last1),
125 std::move(__first2),
126 std::move(__outit),
127 std::forward<_BinaryOperation>(__op));
128 }
129};
130
131template <class _ExecutionPolicy>
132struct __transform_reduce<__serial_backend_tag, _ExecutionPolicy> {
133 template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
134 _LIBCPP_HIDE_FROM_ABI optional<_Tp>
135 operator()(_Policy&&,
136 _ForwardIterator __first,
137 _ForwardIterator __last,
138 _Tp __init,
139 _BinaryOperation&& __reduce,
140 _UnaryOperation&& __transform) const noexcept {
141 return std::transform_reduce(
142 std::move(__first),
143 std::move(__last),
144 std::move(__init),
145 std::forward<_BinaryOperation>(__reduce),
146 std::forward<_UnaryOperation>(__transform));
147 }
148};
149
150template <class _ExecutionPolicy>
151struct __transform_reduce_binary<__serial_backend_tag, _ExecutionPolicy> {
152 template <class _Policy,
153 class _ForwardIterator1,
154 class _ForwardIterator2,
155 class _Tp,
156 class _BinaryOperation1,
157 class _BinaryOperation2>
158 _LIBCPP_HIDE_FROM_ABI optional<_Tp> operator()(
159 _Policy&&,
160 _ForwardIterator1 __first1,
161 _ForwardIterator1 __last1,
162 _ForwardIterator2 __first2,
163 _Tp __init,
164 _BinaryOperation1&& __reduce,
165 _BinaryOperation2&& __transform) const noexcept {
166 return std::transform_reduce(
167 std::move(__first1),
168 std::move(__last1),
169 std::move(__first2),
170 std::move(__init),
171 std::forward<_BinaryOperation1>(__reduce),
172 std::forward<_BinaryOperation2>(__transform));
173 }
174};
175
176} // namespace __pstl
177_LIBCPP_END_NAMESPACE_STD
178
179_LIBCPP_POP_MACROS
180
181#endif // _LIBCPP___PSTL_BACKENDS_SERIAL_H
lib/libcxx/include/__pstl/backends/std_thread.h created+136
......@@ -0,0 +1,136 @@
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___PSTL_BACKENDS_STD_THREAD_H
10#define _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
11
12#include <__config>
13#include <__pstl/backend_fwd.h>
14#include <__pstl/cpu_algos/any_of.h>
15#include <__pstl/cpu_algos/cpu_traits.h>
16#include <__pstl/cpu_algos/fill.h>
17#include <__pstl/cpu_algos/find_if.h>
18#include <__pstl/cpu_algos/for_each.h>
19#include <__pstl/cpu_algos/merge.h>
20#include <__pstl/cpu_algos/stable_sort.h>
21#include <__pstl/cpu_algos/transform.h>
22#include <__pstl/cpu_algos/transform_reduce.h>
23#include <__utility/empty.h>
24#include <__utility/move.h>
25#include <cstddef>
26#include <optional>
27
28#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
29# pragma GCC system_header
30#endif
31
32_LIBCPP_PUSH_MACROS
33#include <__undef_macros>
34
35_LIBCPP_BEGIN_NAMESPACE_STD
36namespace __pstl {
37
38//
39// This partial backend implementation is for testing purposes only and not meant for production use. This will be
40// replaced by a proper implementation once the PSTL implementation is somewhat stable.
41//
42// This is intended to be used on top of the "default backend".
43//
44
45template <>
46struct __cpu_traits<__std_thread_backend_tag> {
47 template <class _RandomAccessIterator, class _Fp>
48 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
49 __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Fp __f) {
50 __f(__first, __last);
51 return __empty{};
52 }
53
54 template <class _Index, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduce>
55 _LIBCPP_HIDE_FROM_ABI static optional<_Tp>
56 __transform_reduce(_Index __first, _Index __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduce __reduce) {
57 return __reduce(std::move(__first), std::move(__last), std::move(__init));
58 }
59
60 template <class _RandomAccessIterator, class _Compare, class _LeafSort>
61 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
62 __stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, _LeafSort __leaf_sort) {
63 __leaf_sort(__first, __last, __comp);
64 return __empty{};
65 }
66
67 _LIBCPP_HIDE_FROM_ABI static void __cancel_execution() {}
68
69 template <class _RandomAccessIterator1,
70 class _RandomAccessIterator2,
71 class _RandomAccessIterator3,
72 class _Compare,
73 class _LeafMerge>
74 _LIBCPP_HIDE_FROM_ABI static optional<__empty>
75 __merge(_RandomAccessIterator1 __first1,
76 _RandomAccessIterator1 __last1,
77 _RandomAccessIterator2 __first2,
78 _RandomAccessIterator2 __last2,
79 _RandomAccessIterator3 __outit,
80 _Compare __comp,
81 _LeafMerge __leaf_merge) {
82 __leaf_merge(__first1, __last1, __first2, __last2, __outit, __comp);
83 return __empty{};
84 }
85
86 static constexpr size_t __lane_size = 64;
87};
88
89// Mandatory implementations of the computational basis
90template <class _ExecutionPolicy>
91struct __find_if<__std_thread_backend_tag, _ExecutionPolicy>
92 : __cpu_parallel_find_if<__std_thread_backend_tag, _ExecutionPolicy> {};
93
94template <class _ExecutionPolicy>
95struct __for_each<__std_thread_backend_tag, _ExecutionPolicy>
96 : __cpu_parallel_for_each<__std_thread_backend_tag, _ExecutionPolicy> {};
97
98template <class _ExecutionPolicy>
99struct __merge<__std_thread_backend_tag, _ExecutionPolicy>
100 : __cpu_parallel_merge<__std_thread_backend_tag, _ExecutionPolicy> {};
101
102template <class _ExecutionPolicy>
103struct __stable_sort<__std_thread_backend_tag, _ExecutionPolicy>
104 : __cpu_parallel_stable_sort<__std_thread_backend_tag, _ExecutionPolicy> {};
105
106template <class _ExecutionPolicy>
107struct __transform<__std_thread_backend_tag, _ExecutionPolicy>
108 : __cpu_parallel_transform<__std_thread_backend_tag, _ExecutionPolicy> {};
109
110template <class _ExecutionPolicy>
111struct __transform_binary<__std_thread_backend_tag, _ExecutionPolicy>
112 : __cpu_parallel_transform_binary<__std_thread_backend_tag, _ExecutionPolicy> {};
113
114template <class _ExecutionPolicy>
115struct __transform_reduce<__std_thread_backend_tag, _ExecutionPolicy>
116 : __cpu_parallel_transform_reduce<__std_thread_backend_tag, _ExecutionPolicy> {};
117
118template <class _ExecutionPolicy>
119struct __transform_reduce_binary<__std_thread_backend_tag, _ExecutionPolicy>
120 : __cpu_parallel_transform_reduce_binary<__std_thread_backend_tag, _ExecutionPolicy> {};
121
122// Not mandatory, but better optimized
123template <class _ExecutionPolicy>
124struct __any_of<__std_thread_backend_tag, _ExecutionPolicy>
125 : __cpu_parallel_any_of<__std_thread_backend_tag, _ExecutionPolicy> {};
126
127template <class _ExecutionPolicy>
128struct __fill<__std_thread_backend_tag, _ExecutionPolicy>
129 : __cpu_parallel_fill<__std_thread_backend_tag, _ExecutionPolicy> {};
130
131} // namespace __pstl
132_LIBCPP_END_NAMESPACE_STD
133
134_LIBCPP_POP_MACROS
135
136#endif // _LIBCPP___PSTL_BACKENDS_STD_THREAD_H
lib/libcxx/include/__pstl/cpu_algos/any_of.h created+99
......@@ -0,0 +1,99 @@
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___PSTL_CPU_ALGOS_ANY_OF_H
10#define _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
11
12#include <__algorithm/any_of.h>
13#include <__assert>
14#include <__atomic/atomic.h>
15#include <__atomic/memory_order.h>
16#include <__config>
17#include <__iterator/concepts.h>
18#include <__pstl/backend_fwd.h>
19#include <__pstl/cpu_algos/cpu_traits.h>
20#include <__type_traits/is_execution_policy.h>
21#include <__utility/move.h>
22#include <__utility/pair.h>
23#include <cstdint>
24#include <optional>
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __pstl {
31
32template <class _Backend, class _Index, class _Brick>
33_LIBCPP_HIDE_FROM_ABI optional<bool> __parallel_or(_Index __first, _Index __last, _Brick __f) {
34 std::atomic<bool> __found(false);
35 auto __ret = __cpu_traits<_Backend>::__for_each(__first, __last, [__f, &__found](_Index __i, _Index __j) {
36 if (!__found.load(std::memory_order_relaxed) && __f(__i, __j)) {
37 __found.store(true, std::memory_order_relaxed);
38 __cpu_traits<_Backend>::__cancel_execution();
39 }
40 });
41 if (!__ret)
42 return nullopt;
43 return static_cast<bool>(__found);
44}
45
46// TODO: check whether __simd_first() can be used here
47template <class _Index, class _DifferenceType, class _Pred>
48_LIBCPP_HIDE_FROM_ABI bool __simd_or(_Index __first, _DifferenceType __n, _Pred __pred) noexcept {
49 _DifferenceType __block_size = 4 < __n ? 4 : __n;
50 const _Index __last = __first + __n;
51 while (__last != __first) {
52 int32_t __flag = 1;
53 _PSTL_PRAGMA_SIMD_REDUCTION(& : __flag)
54 for (_DifferenceType __i = 0; __i < __block_size; ++__i)
55 if (__pred(*(__first + __i)))
56 __flag = 0;
57 if (!__flag)
58 return true;
59
60 __first += __block_size;
61 if (__last - __first >= __block_size << 1) {
62 // Double the block _Size. Any unnecessary iterations can be amortized against work done so far.
63 __block_size <<= 1;
64 } else {
65 __block_size = __last - __first;
66 }
67 }
68 return false;
69}
70
71template <class _Backend, class _RawExecutionPolicy>
72struct __cpu_parallel_any_of {
73 template <class _Policy, class _ForwardIterator, class _Predicate>
74 _LIBCPP_HIDE_FROM_ABI optional<bool>
75 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept {
76 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
77 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
78 return __pstl::__parallel_or<_Backend>(
79 __first, __last, [&__policy, &__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
80 using _AnyOfUnseq = __pstl::__any_of<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
81 auto __res = _AnyOfUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __pred);
82 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
83 return *std::move(__res);
84 });
85 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
86 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
87 return __pstl::__simd_or(__first, __last - __first, __pred);
88 } else {
89 return std::any_of(__first, __last, __pred);
90 }
91 }
92};
93
94} // namespace __pstl
95_LIBCPP_END_NAMESPACE_STD
96
97_LIBCPP_POP_MACROS
98
99#endif // _LIBCPP___PSTL_CPU_ALGOS_ANY_OF_H
lib/libcxx/include/__pstl/cpu_algos/cpu_traits.h created+86
......@@ -0,0 +1,86 @@
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___PSTL_CPU_ALGOS_CPU_TRAITS_H
10#define _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
11
12#include <__config>
13#include <cstddef>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_PUSH_MACROS
20#include <__undef_macros>
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23namespace __pstl {
24
25// __cpu_traits
26//
27// This traits class encapsulates the basis operations for a CPU-based implementation of the PSTL.
28// All the operations in the PSTL can be implemented from these basis operations, so a pure CPU backend
29// only needs to customize these traits in order to get an implementation of the whole PSTL.
30//
31// Basis operations
32// ================
33//
34// template <class _RandomAccessIterator, class _Functor>
35// optional<__empty> __for_each(_RandomAccessIterator __first, _RandomAccessIterator __last, _Functor __func);
36// - __func must take a subrange of [__first, __last) that should be executed in serial
37//
38// template <class _Iterator, class _UnaryOp, class _Tp, class _BinaryOp, class _Reduction>
39// optional<_Tp> __transform_reduce(_Iterator __first, _Iterator __last, _UnaryOp, _Tp __init, _BinaryOp, _Reduction);
40//
41// template <class _RandomAccessIterator1,
42// class _RandomAccessIterator2,
43// class _RandomAccessIterator3,
44// class _Compare,
45// class _LeafMerge>
46// optional<_RandomAccessIterator3> __merge(_RandomAccessIterator1 __first1,
47// _RandomAccessIterator1 __last1,
48// _RandomAccessIterator2 __first2,
49// _RandomAccessIterator2 __last2,
50// _RandomAccessIterator3 __outit,
51// _Compare __comp,
52// _LeafMerge __leaf_merge);
53//
54// template <class _RandomAccessIterator, class _Comp, class _LeafSort>
55// optional<__empty> __stable_sort(_RandomAccessIterator __first,
56// _RandomAccessIterator __last,
57// _Comp __comp,
58// _LeafSort __leaf_sort);
59//
60// void __cancel_execution();
61// Cancel the execution of other jobs - they aren't needed anymore. This is not a binding request,
62// some backends may not actually be able to cancel jobs.
63//
64// constexpr size_t __lane_size;
65// Size of SIMD lanes.
66// TODO: Merge this with __native_vector_size from __algorithm/simd_utils.h
67//
68//
69// Exception handling
70// ==================
71//
72// CPU backends are expected to report errors (i.e. failure to allocate) by returning a disengaged `optional` from their
73// implementation. Exceptions shouldn't be used to report an internal failure-to-allocate, since all exceptions are
74// turned into a program termination at the front-end level. When a backend returns a disengaged `optional` to the
75// frontend, the frontend will turn that into a call to `std::__throw_bad_alloc();` to report the internal failure to
76// the user.
77
78template <class _Backend>
79struct __cpu_traits;
80
81} // namespace __pstl
82_LIBCPP_END_NAMESPACE_STD
83
84_LIBCPP_POP_MACROS
85
86#endif // _LIBCPP___PSTL_CPU_ALGOS_CPU_TRAITS_H
lib/libcxx/include/__pstl/cpu_algos/fill.h created+66
......@@ -0,0 +1,66 @@
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___PSTL_CPU_ALGOS_FILL_H
10#define _LIBCPP___PSTL_CPU_ALGOS_FILL_H
11
12#include <__algorithm/fill.h>
13#include <__assert>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__pstl/backend_fwd.h>
17#include <__pstl/cpu_algos/cpu_traits.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__utility/empty.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {
28
29template <class _Index, class _DifferenceType, class _Tp>
30_LIBCPP_HIDE_FROM_ABI _Index __simd_fill_n(_Index __first, _DifferenceType __n, const _Tp& __value) noexcept {
31 _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
32 _PSTL_PRAGMA_SIMD
33 for (_DifferenceType __i = 0; __i < __n; ++__i)
34 __first[__i] = __value;
35 return __first + __n;
36}
37
38template <class _Backend, class _RawExecutionPolicy>
39struct __cpu_parallel_fill {
40 template <class _Policy, class _ForwardIterator, class _Tp>
41 _LIBCPP_HIDE_FROM_ABI optional<__empty>
42 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) const noexcept {
43 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
44 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
45 return __cpu_traits<_Backend>::__for_each(
46 __first, __last, [&__policy, &__value](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
47 using _FillUnseq = __pstl::__fill<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
48 [[maybe_unused]] auto __res =
49 _FillUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __value);
50 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
51 });
52 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
53 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
54 __pstl::__simd_fill_n(__first, __last - __first, __value);
55 return __empty{};
56 } else {
57 std::fill(__first, __last, __value);
58 return __empty{};
59 }
60 }
61};
62
63} // namespace __pstl
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP___PSTL_CPU_ALGOS_FILL_H
lib/libcxx/include/__pstl/cpu_algos/find_if.h created+137
......@@ -0,0 +1,137 @@
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___PSTL_CPU_ALGOS_FIND_IF_H
10#define _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
11
12#include <__algorithm/find_if.h>
13#include <__assert>
14#include <__atomic/atomic.h>
15#include <__config>
16#include <__functional/operations.h>
17#include <__iterator/concepts.h>
18#include <__iterator/iterator_traits.h>
19#include <__pstl/backend_fwd.h>
20#include <__pstl/cpu_algos/cpu_traits.h>
21#include <__type_traits/is_execution_policy.h>
22#include <__utility/move.h>
23#include <__utility/pair.h>
24#include <cstddef>
25#include <optional>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35namespace __pstl {
36
37template <class _Backend, class _Index, class _Brick, class _Compare>
38_LIBCPP_HIDE_FROM_ABI optional<_Index>
39__parallel_find(_Index __first, _Index __last, _Brick __f, _Compare __comp, bool __b_first) {
40 typedef typename std::iterator_traits<_Index>::difference_type _DifferenceType;
41 const _DifferenceType __n = __last - __first;
42 _DifferenceType __initial_dist = __b_first ? __n : -1;
43 std::atomic<_DifferenceType> __extremum(__initial_dist);
44 // TODO: find out what is better here: parallel_for or parallel_reduce
45 auto __res =
46 __cpu_traits<_Backend>::__for_each(__first, __last, [__comp, __f, __first, &__extremum](_Index __i, _Index __j) {
47 // See "Reducing Contention Through Priority Updates", PPoPP '13, for discussion of
48 // why using a shared variable scales fairly well in this situation.
49 if (__comp(__i - __first, __extremum)) {
50 _Index __result = __f(__i, __j);
51 // If not '__last' returned then we found what we want so put this to extremum
52 if (__result != __j) {
53 const _DifferenceType __k = __result - __first;
54 for (_DifferenceType __old = __extremum; __comp(__k, __old); __old = __extremum) {
55 __extremum.compare_exchange_weak(__old, __k);
56 }
57 }
58 }
59 });
60 if (!__res)
61 return nullopt;
62 return __extremum.load() != __initial_dist ? __first + __extremum.load() : __last;
63}
64
65template <class _Backend, class _Index, class _DifferenceType, class _Compare>
66_LIBCPP_HIDE_FROM_ABI _Index
67__simd_first(_Index __first, _DifferenceType __begin, _DifferenceType __end, _Compare __comp) noexcept {
68 // Experiments show good block sizes like this
69 const _DifferenceType __block_size = 8;
70 alignas(__cpu_traits<_Backend>::__lane_size) _DifferenceType __lane[__block_size] = {0};
71 while (__end - __begin >= __block_size) {
72 _DifferenceType __found = 0;
73 _PSTL_PRAGMA_SIMD_REDUCTION(| : __found) for (_DifferenceType __i = __begin; __i < __begin + __block_size; ++__i) {
74 const _DifferenceType __t = __comp(__first, __i);
75 __lane[__i - __begin] = __t;
76 __found |= __t;
77 }
78 if (__found) {
79 _DifferenceType __i;
80 // This will vectorize
81 for (__i = 0; __i < __block_size; ++__i) {
82 if (__lane[__i]) {
83 break;
84 }
85 }
86 return __first + __begin + __i;
87 }
88 __begin += __block_size;
89 }
90
91 // Keep remainder scalar
92 while (__begin != __end) {
93 if (__comp(__first, __begin)) {
94 return __first + __begin;
95 }
96 ++__begin;
97 }
98 return __first + __end;
99}
100
101template <class _Backend, class _RawExecutionPolicy>
102struct __cpu_parallel_find_if {
103 template <class _Policy, class _ForwardIterator, class _Predicate>
104 _LIBCPP_HIDE_FROM_ABI optional<_ForwardIterator>
105 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) const noexcept {
106 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
107 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
108 return __pstl::__parallel_find<_Backend>(
109 __first,
110 __last,
111 [&__policy, &__pred](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
112 using _FindIfUnseq = __pstl::__find_if<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
113 auto __res = _FindIfUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __pred);
114 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
115 return *std::move(__res);
116 },
117 less<>{},
118 true);
119 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
120 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
121 using __diff_t = __iter_diff_t<_ForwardIterator>;
122 return __pstl::__simd_first<_Backend>(
123 __first, __diff_t(0), __last - __first, [&__pred](_ForwardIterator __iter, __diff_t __i) {
124 return __pred(__iter[__i]);
125 });
126 } else {
127 return std::find_if(__first, __last, __pred);
128 }
129 }
130};
131
132} // namespace __pstl
133_LIBCPP_END_NAMESPACE_STD
134
135_LIBCPP_POP_MACROS
136
137#endif // _LIBCPP___PSTL_CPU_ALGOS_FIND_IF_H
lib/libcxx/include/__pstl/cpu_algos/for_each.h created+66
......@@ -0,0 +1,66 @@
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___PSTL_CPU_ALGOS_FOR_EACH_H
10#define _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
11
12#include <__algorithm/for_each.h>
13#include <__assert>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__pstl/backend_fwd.h>
17#include <__pstl/cpu_algos/cpu_traits.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__utility/empty.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {
28
29template <class _Iterator, class _DifferenceType, class _Function>
30_LIBCPP_HIDE_FROM_ABI _Iterator __simd_for_each(_Iterator __first, _DifferenceType __n, _Function __f) noexcept {
31 _PSTL_PRAGMA_SIMD
32 for (_DifferenceType __i = 0; __i < __n; ++__i)
33 __f(__first[__i]);
34
35 return __first + __n;
36}
37
38template <class _Backend, class _RawExecutionPolicy>
39struct __cpu_parallel_for_each {
40 template <class _Policy, class _ForwardIterator, class _Function>
41 _LIBCPP_HIDE_FROM_ABI optional<__empty>
42 operator()(_Policy&& __policy, _ForwardIterator __first, _ForwardIterator __last, _Function __func) const noexcept {
43 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
44 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
45 return __cpu_traits<_Backend>::__for_each(
46 __first, __last, [&__policy, __func](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
47 using _ForEachUnseq = __pstl::__for_each<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
48 [[maybe_unused]] auto __res =
49 _ForEachUnseq()(std::__remove_parallel_policy(__policy), __brick_first, __brick_last, __func);
50 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
51 });
52 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
53 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
54 __pstl::__simd_for_each(__first, __last - __first, __func);
55 return __empty{};
56 } else {
57 std::for_each(__first, __last, __func);
58 return __empty{};
59 }
60 }
61};
62
63} // namespace __pstl
64_LIBCPP_END_NAMESPACE_STD
65
66#endif // _LIBCPP___PSTL_CPU_ALGOS_FOR_EACH_H
lib/libcxx/include/__pstl/cpu_algos/merge.h created+85
......@@ -0,0 +1,85 @@
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___PSTL_CPU_ALGOS_MERGE_H
10#define _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
11
12#include <__algorithm/merge.h>
13#include <__assert>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__pstl/backend_fwd.h>
17#include <__pstl/cpu_algos/cpu_traits.h>
18#include <__type_traits/is_execution_policy.h>
19#include <__utility/move.h>
20#include <optional>
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_PUSH_MACROS
27#include <__undef_macros>
28
29_LIBCPP_BEGIN_NAMESPACE_STD
30namespace __pstl {
31
32template <class _Backend, class _RawExecutionPolicy>
33struct __cpu_parallel_merge {
34 template <class _Policy, class _ForwardIterator1, class _ForwardIterator2, class _ForwardOutIterator, class _Comp>
35 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator> operator()(
36 _Policy&& __policy,
37 _ForwardIterator1 __first1,
38 _ForwardIterator1 __last1,
39 _ForwardIterator2 __first2,
40 _ForwardIterator2 __last2,
41 _ForwardOutIterator __result,
42 _Comp __comp) const noexcept {
43 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
44 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
45 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
46 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
47 auto __res = __cpu_traits<_Backend>::__merge(
48 __first1,
49 __last1,
50 __first2,
51 __last2,
52 __result,
53 __comp,
54 [&__policy](_ForwardIterator1 __g_first1,
55 _ForwardIterator1 __g_last1,
56 _ForwardIterator2 __g_first2,
57 _ForwardIterator2 __g_last2,
58 _ForwardOutIterator __g_result,
59 _Comp __g_comp) {
60 using _MergeUnseq = __pstl::__merge<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
61 [[maybe_unused]] auto __g_res = _MergeUnseq()(
62 std::__remove_parallel_policy(__policy),
63 std::move(__g_first1),
64 std::move(__g_last1),
65 std::move(__g_first2),
66 std::move(__g_last2),
67 std::move(__g_result),
68 std::move(__g_comp));
69 _LIBCPP_ASSERT_INTERNAL(__g_res, "unsed/sed should never try to allocate!");
70 });
71 if (!__res)
72 return nullopt;
73 return __result + (__last1 - __first1) + (__last2 - __first2);
74 } else {
75 return std::merge(__first1, __last1, __first2, __last2, __result, __comp);
76 }
77 }
78};
79
80} // namespace __pstl
81_LIBCPP_END_NAMESPACE_STD
82
83_LIBCPP_POP_MACROS
84
85#endif // _LIBCPP___PSTL_CPU_ALGOS_MERGE_H
lib/libcxx/include/__pstl/cpu_algos/stable_sort.h created+47
......@@ -0,0 +1,47 @@
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___PSTL_CPU_ALGOS_STABLE_SORT_H
10#define _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
11
12#include <__algorithm/stable_sort.h>
13#include <__config>
14#include <__pstl/backend_fwd.h>
15#include <__pstl/cpu_algos/cpu_traits.h>
16#include <__type_traits/is_execution_policy.h>
17#include <__utility/empty.h>
18#include <optional>
19
20#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25namespace __pstl {
26
27template <class _Backend, class _RawExecutionPolicy>
28struct __cpu_parallel_stable_sort {
29 template <class _Policy, class _RandomAccessIterator, class _Comp>
30 _LIBCPP_HIDE_FROM_ABI optional<__empty>
31 operator()(_Policy&&, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp) const noexcept {
32 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy>) {
33 return __cpu_traits<_Backend>::__stable_sort(
34 __first, __last, __comp, [](_RandomAccessIterator __g_first, _RandomAccessIterator __g_last, _Comp __g_comp) {
35 std::stable_sort(__g_first, __g_last, __g_comp);
36 });
37 } else {
38 std::stable_sort(__first, __last, __comp);
39 return __empty{};
40 }
41 }
42};
43
44} // namespace __pstl
45_LIBCPP_END_NAMESPACE_STD
46
47#endif // _LIBCPP___PSTL_CPU_ALGOS_STABLE_SORT_H
lib/libcxx/include/__pstl/cpu_algos/transform.h created+153
......@@ -0,0 +1,153 @@
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___PSTL_CPU_ALGOS_TRANSFORM_H
10#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
11
12#include <__algorithm/transform.h>
13#include <__assert>
14#include <__config>
15#include <__iterator/concepts.h>
16#include <__iterator/iterator_traits.h>
17#include <__pstl/backend_fwd.h>
18#include <__pstl/cpu_algos/cpu_traits.h>
19#include <__type_traits/is_execution_policy.h>
20#include <__utility/move.h>
21#include <optional>
22
23#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
24# pragma GCC system_header
25#endif
26
27_LIBCPP_PUSH_MACROS
28#include <__undef_macros>
29
30_LIBCPP_BEGIN_NAMESPACE_STD
31namespace __pstl {
32
33template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Function>
34_LIBCPP_HIDE_FROM_ABI _Iterator2
35__simd_transform(_Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Function __f) noexcept {
36 _PSTL_PRAGMA_SIMD
37 for (_DifferenceType __i = 0; __i < __n; ++__i)
38 __f(__first1[__i], __first2[__i]);
39 return __first2 + __n;
40}
41
42template <class _Iterator1, class _DifferenceType, class _Iterator2, class _Iterator3, class _Function>
43_LIBCPP_HIDE_FROM_ABI _Iterator3 __simd_transform(
44 _Iterator1 __first1, _DifferenceType __n, _Iterator2 __first2, _Iterator3 __first3, _Function __f) noexcept {
45 _PSTL_PRAGMA_SIMD
46 for (_DifferenceType __i = 0; __i < __n; ++__i)
47 __f(__first1[__i], __first2[__i], __first3[__i]);
48 return __first3 + __n;
49}
50
51template <class _Backend, class _RawExecutionPolicy>
52struct __cpu_parallel_transform {
53 template <class _Policy, class _ForwardIterator, class _ForwardOutIterator, class _UnaryOperation>
54 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
55 operator()(_Policy&& __policy,
56 _ForwardIterator __first,
57 _ForwardIterator __last,
58 _ForwardOutIterator __result,
59 _UnaryOperation __op) const noexcept {
60 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
61 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
62 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
63 __cpu_traits<_Backend>::__for_each(
64 __first,
65 __last,
66 [&__policy, __op, __first, __result](_ForwardIterator __brick_first, _ForwardIterator __brick_last) {
67 using _TransformUnseq = __pstl::__transform<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
68 auto __res = _TransformUnseq()(
69 std::__remove_parallel_policy(__policy),
70 __brick_first,
71 __brick_last,
72 __result + (__brick_first - __first),
73 __op);
74 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
75 return *std::move(__res);
76 });
77 return __result + (__last - __first);
78 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
79 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value &&
80 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
81 return __pstl::__simd_transform(
82 __first,
83 __last - __first,
84 __result,
85 [&](__iter_reference<_ForwardIterator> __in_value, __iter_reference<_ForwardOutIterator> __out_value) {
86 __out_value = __op(__in_value);
87 });
88 } else {
89 return std::transform(__first, __last, __result, __op);
90 }
91 }
92};
93
94template <class _Backend, class _RawExecutionPolicy>
95struct __cpu_parallel_transform_binary {
96 template <class _Policy,
97 class _ForwardIterator1,
98 class _ForwardIterator2,
99 class _ForwardOutIterator,
100 class _BinaryOperation>
101 _LIBCPP_HIDE_FROM_ABI optional<_ForwardOutIterator>
102 operator()(_Policy&& __policy,
103 _ForwardIterator1 __first1,
104 _ForwardIterator1 __last1,
105 _ForwardIterator2 __first2,
106 _ForwardOutIterator __result,
107 _BinaryOperation __op) const noexcept {
108 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
109 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
110 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
111 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
112 auto __res = __cpu_traits<_Backend>::__for_each(
113 __first1,
114 __last1,
115 [&__policy, __op, __first1, __first2, __result](
116 _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last) {
117 using _TransformBinaryUnseq =
118 __pstl::__transform_binary<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
119 return _TransformBinaryUnseq()(
120 std::__remove_parallel_policy(__policy),
121 __brick_first,
122 __brick_last,
123 __first2 + (__brick_first - __first1),
124 __result + (__brick_first - __first1),
125 __op);
126 });
127 if (!__res)
128 return nullopt;
129 return __result + (__last1 - __first1);
130 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
131 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
132 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value &&
133 __has_random_access_iterator_category_or_concept<_ForwardOutIterator>::value) {
134 return __pstl::__simd_transform(
135 __first1,
136 __last1 - __first1,
137 __first2,
138 __result,
139 [&](__iter_reference<_ForwardIterator1> __in1,
140 __iter_reference<_ForwardIterator2> __in2,
141 __iter_reference<_ForwardOutIterator> __out_value) { __out_value = __op(__in1, __in2); });
142 } else {
143 return std::transform(__first1, __last1, __first2, __result, __op);
144 }
145 }
146};
147
148} // namespace __pstl
149_LIBCPP_END_NAMESPACE_STD
150
151_LIBCPP_POP_MACROS
152
153#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_H
lib/libcxx/include/__pstl/cpu_algos/transform_reduce.h created+216
......@@ -0,0 +1,216 @@
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___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
10#define _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
11
12#include <__assert>
13#include <__config>
14#include <__iterator/concepts.h>
15#include <__iterator/iterator_traits.h>
16#include <__numeric/transform_reduce.h>
17#include <__pstl/backend_fwd.h>
18#include <__pstl/cpu_algos/cpu_traits.h>
19#include <__type_traits/desugars_to.h>
20#include <__type_traits/is_arithmetic.h>
21#include <__type_traits/is_execution_policy.h>
22#include <__utility/move.h>
23#include <cstddef>
24#include <new>
25#include <optional>
26
27#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
28# pragma GCC system_header
29#endif
30
31_LIBCPP_PUSH_MACROS
32#include <__undef_macros>
33
34_LIBCPP_BEGIN_NAMESPACE_STD
35namespace __pstl {
36
37template <typename _Backend,
38 typename _DifferenceType,
39 typename _Tp,
40 typename _BinaryOperation,
41 typename _UnaryOperation,
42 typename _UnaryResult = invoke_result_t<_UnaryOperation, _DifferenceType>,
43 __enable_if_t<__desugars_to_v<__plus_tag, _BinaryOperation, _Tp, _UnaryResult> && is_arithmetic_v<_Tp> &&
44 is_arithmetic_v<_UnaryResult>,
45 int> = 0>
46_LIBCPP_HIDE_FROM_ABI _Tp
47__simd_transform_reduce(_DifferenceType __n, _Tp __init, _BinaryOperation, _UnaryOperation __f) noexcept {
48 _PSTL_PRAGMA_SIMD_REDUCTION(+ : __init)
49 for (_DifferenceType __i = 0; __i < __n; ++__i)
50 __init += __f(__i);
51 return __init;
52}
53
54template <typename _Backend,
55 typename _Size,
56 typename _Tp,
57 typename _BinaryOperation,
58 typename _UnaryOperation,
59 typename _UnaryResult = invoke_result_t<_UnaryOperation, _Size>,
60 __enable_if_t<!(__desugars_to_v<__plus_tag, _BinaryOperation, _Tp, _UnaryResult> && is_arithmetic_v<_Tp> &&
61 is_arithmetic_v<_UnaryResult>),
62 int> = 0>
63_LIBCPP_HIDE_FROM_ABI _Tp
64__simd_transform_reduce(_Size __n, _Tp __init, _BinaryOperation __binary_op, _UnaryOperation __f) noexcept {
65 constexpr size_t __lane_size = __cpu_traits<_Backend>::__lane_size;
66 const _Size __block_size = __lane_size / sizeof(_Tp);
67 if (__n > 2 * __block_size && __block_size > 1) {
68 alignas(__lane_size) char __lane_buffer[__lane_size];
69 _Tp* __lane = reinterpret_cast<_Tp*>(__lane_buffer);
70
71 // initializer
72 _PSTL_PRAGMA_SIMD
73 for (_Size __i = 0; __i < __block_size; ++__i) {
74 ::new (__lane + __i) _Tp(__binary_op(__f(__i), __f(__block_size + __i)));
75 }
76 // main loop
77 _Size __i = 2 * __block_size;
78 const _Size __last_iteration = __block_size * (__n / __block_size);
79 for (; __i < __last_iteration; __i += __block_size) {
80 _PSTL_PRAGMA_SIMD
81 for (_Size __j = 0; __j < __block_size; ++__j) {
82 __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__i + __j));
83 }
84 }
85 // remainder
86 _PSTL_PRAGMA_SIMD
87 for (_Size __j = 0; __j < __n - __last_iteration; ++__j) {
88 __lane[__j] = __binary_op(std::move(__lane[__j]), __f(__last_iteration + __j));
89 }
90 // combiner
91 for (_Size __j = 0; __j < __block_size; ++__j) {
92 __init = __binary_op(std::move(__init), std::move(__lane[__j]));
93 }
94 // destroyer
95 _PSTL_PRAGMA_SIMD
96 for (_Size __j = 0; __j < __block_size; ++__j) {
97 __lane[__j].~_Tp();
98 }
99 } else {
100 for (_Size __i = 0; __i < __n; ++__i) {
101 __init = __binary_op(std::move(__init), __f(__i));
102 }
103 }
104 return __init;
105}
106
107template <class _Backend, class _RawExecutionPolicy>
108struct __cpu_parallel_transform_reduce_binary {
109 template <class _Policy,
110 class _ForwardIterator1,
111 class _ForwardIterator2,
112 class _Tp,
113 class _BinaryOperation1,
114 class _BinaryOperation2>
115 _LIBCPP_HIDE_FROM_ABI optional<_Tp> operator()(
116 _Policy&& __policy,
117 _ForwardIterator1 __first1,
118 _ForwardIterator1 __last1,
119 _ForwardIterator2 __first2,
120 _Tp __init,
121 _BinaryOperation1 __reduce,
122 _BinaryOperation2 __transform) const noexcept {
123 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
124 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
125 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
126 return __cpu_traits<_Backend>::__transform_reduce(
127 __first1,
128 std::move(__last1),
129 [__first1, __first2, __transform](_ForwardIterator1 __iter) {
130 return __transform(*__iter, *(__first2 + (__iter - __first1)));
131 },
132 std::move(__init),
133 std::move(__reduce),
134 [&__policy, __first1, __first2, __reduce, __transform](
135 _ForwardIterator1 __brick_first, _ForwardIterator1 __brick_last, _Tp __brick_init) {
136 using _TransformReduceBinaryUnseq =
137 __pstl::__transform_reduce_binary<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
138 return *_TransformReduceBinaryUnseq()(
139 std::__remove_parallel_policy(__policy),
140 __brick_first,
141 std::move(__brick_last),
142 __first2 + (__brick_first - __first1),
143 std::move(__brick_init),
144 std::move(__reduce),
145 std::move(__transform));
146 });
147 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
148 __has_random_access_iterator_category_or_concept<_ForwardIterator1>::value &&
149 __has_random_access_iterator_category_or_concept<_ForwardIterator2>::value) {
150 return __pstl::__simd_transform_reduce<_Backend>(
151 __last1 - __first1, std::move(__init), std::move(__reduce), [&](__iter_diff_t<_ForwardIterator1> __i) {
152 return __transform(__first1[__i], __first2[__i]);
153 });
154 } else {
155 return std::transform_reduce(
156 std::move(__first1),
157 std::move(__last1),
158 std::move(__first2),
159 std::move(__init),
160 std::move(__reduce),
161 std::move(__transform));
162 }
163 }
164};
165
166template <class _Backend, class _RawExecutionPolicy>
167struct __cpu_parallel_transform_reduce {
168 template <class _Policy, class _ForwardIterator, class _Tp, class _BinaryOperation, class _UnaryOperation>
169 _LIBCPP_HIDE_FROM_ABI optional<_Tp>
170 operator()(_Policy&& __policy,
171 _ForwardIterator __first,
172 _ForwardIterator __last,
173 _Tp __init,
174 _BinaryOperation __reduce,
175 _UnaryOperation __transform) const noexcept {
176 if constexpr (__is_parallel_execution_policy_v<_RawExecutionPolicy> &&
177 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
178 return __cpu_traits<_Backend>::__transform_reduce(
179 std::move(__first),
180 std::move(__last),
181 [__transform](_ForwardIterator __iter) { return __transform(*__iter); },
182 std::move(__init),
183 __reduce,
184 [&__policy, __transform, __reduce](auto __brick_first, auto __brick_last, _Tp __brick_init) {
185 using _TransformReduceUnseq =
186 __pstl::__transform_reduce<_Backend, __remove_parallel_policy_t<_RawExecutionPolicy>>;
187 auto __res = _TransformReduceUnseq()(
188 std::__remove_parallel_policy(__policy),
189 std::move(__brick_first),
190 std::move(__brick_last),
191 std::move(__brick_init),
192 std::move(__reduce),
193 std::move(__transform));
194 _LIBCPP_ASSERT_INTERNAL(__res, "unseq/seq should never try to allocate!");
195 return *std::move(__res);
196 });
197 } else if constexpr (__is_unsequenced_execution_policy_v<_RawExecutionPolicy> &&
198 __has_random_access_iterator_category_or_concept<_ForwardIterator>::value) {
199 return __pstl::__simd_transform_reduce<_Backend>(
200 __last - __first,
201 std::move(__init),
202 std::move(__reduce),
203 [=, &__transform](__iter_diff_t<_ForwardIterator> __i) { return __transform(__first[__i]); });
204 } else {
205 return std::transform_reduce(
206 std::move(__first), std::move(__last), std::move(__init), std::move(__reduce), std::move(__transform));
207 }
208 }
209};
210
211} // namespace __pstl
212_LIBCPP_END_NAMESPACE_STD
213
214_LIBCPP_POP_MACROS
215
216#endif // _LIBCPP___PSTL_CPU_ALGOS_TRANSFORM_REDUCE_H
lib/libcxx/include/__pstl/dispatch.h created+66
......@@ -0,0 +1,66 @@
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___PSTL_DISPATCH_H
10#define _LIBCPP___PSTL_DISPATCH_H
11
12#include <__config>
13#include <__pstl/backend_fwd.h>
14#include <__type_traits/conditional.h>
15#include <__type_traits/enable_if.h>
16#include <__type_traits/integral_constant.h>
17#include <__type_traits/type_identity.h>
18
19#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20# pragma GCC system_header
21#endif
22
23_LIBCPP_PUSH_MACROS
24#include <__undef_macros>
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27namespace __pstl {
28
29template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy, class = void>
30constexpr bool __is_implemented_v = false;
31
32template <template <class, class> class _Algorithm, class _Backend, class _ExecutionPolicy>
33constexpr bool __is_implemented_v<_Algorithm,
34 _Backend,
35 _ExecutionPolicy,
36 __enable_if_t<sizeof(_Algorithm<_Backend, _ExecutionPolicy>)>> = true;
37
38// Helpful to provide better error messages. This will show the algorithm and the execution policy
39// in the compiler diagnostic.
40template <template <class, class> class _Algorithm, class _ExecutionPolicy>
41constexpr bool __cant_find_backend_for = false;
42
43template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
44struct __find_first_implemented;
45
46template <template <class, class> class _Algorithm, class _ExecutionPolicy>
47struct __find_first_implemented<_Algorithm, __backend_configuration<>, _ExecutionPolicy> {
48 static_assert(__cant_find_backend_for<_Algorithm, _ExecutionPolicy>,
49 "Could not find a PSTL backend for the given algorithm and execution policy");
50};
51
52template <template <class, class> class _Algorithm, class _B1, class... _Bn, class _ExecutionPolicy>
53struct __find_first_implemented<_Algorithm, __backend_configuration<_B1, _Bn...>, _ExecutionPolicy>
54 : _If<__is_implemented_v<_Algorithm, _B1, _ExecutionPolicy>,
55 __type_identity<_Algorithm<_B1, _ExecutionPolicy>>,
56 __find_first_implemented<_Algorithm, __backend_configuration<_Bn...>, _ExecutionPolicy> > {};
57
58template <template <class, class> class _Algorithm, class _BackendConfiguration, class _ExecutionPolicy>
59using __dispatch = typename __find_first_implemented<_Algorithm, _BackendConfiguration, _ExecutionPolicy>::type;
60
61} // namespace __pstl
62_LIBCPP_END_NAMESPACE_STD
63
64_LIBCPP_POP_MACROS
65
66#endif // _LIBCPP___PSTL_DISPATCH_H
lib/libcxx/include/__pstl/handle_exception.h created+57
......@@ -0,0 +1,57 @@
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___PSTL_HANDLE_EXCEPTION_H
10#define _LIBCPP___PSTL_HANDLE_EXCEPTION_H
11
12#include <__config>
13#include <__utility/forward.h>
14#include <__utility/move.h>
15#include <new> // __throw_bad_alloc
16#include <optional>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_PUSH_MACROS
23#include <__undef_macros>
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26namespace __pstl {
27
28template <class _BackendFunction, class... _Args>
29_LIBCPP_HIDE_FROM_ABI auto __handle_exception_impl(_Args&&... __args) noexcept {
30 return _BackendFunction{}(std::forward<_Args>(__args)...);
31}
32
33// This function is used to call a backend PSTL algorithm from a frontend algorithm.
34//
35// All PSTL backend algorithms return an optional denoting whether there was an
36// "infrastructure"-level failure (aka failure to allocate). This function takes
37// care of unwrapping that and throwing `bad_alloc()` in case there was a problem
38// in the underlying implementation.
39//
40// We must also be careful not to call any user code that could throw an exception
41// (such as moving or copying iterators) in here since that should terminate the
42// program, which is why we delegate to a noexcept helper below.
43template <class _BackendFunction, class... _Args>
44_LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {
45 auto __result = __pstl::__handle_exception_impl<_BackendFunction>(std::forward<_Args>(__args)...);
46 if (__result == nullopt)
47 std::__throw_bad_alloc();
48 else
49 return std::move(*__result);
50}
51
52} // namespace __pstl
53_LIBCPP_END_NAMESPACE_STD
54
55_LIBCPP_POP_MACROS
56
57#endif // _LIBCPP___PSTL_HANDLE_EXCEPTION_H
lib/libcxx/include/__random/discard_block_engine.h+2-2
......@@ -50,8 +50,8 @@ public:
5050 static const result_type _Min = _Engine::_Min;
5151 static const result_type _Max = _Engine::_Max;
5252#else
53 static _LIBCPP_CONSTEXPR const result_type _Min = _Engine::min();
54 static _LIBCPP_CONSTEXPR const result_type _Max = _Engine::max();
53 static constexpr result_type _Min = _Engine::min();
54 static constexpr result_type _Max = _Engine::max();
5555#endif
5656
5757 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Engine::min(); }
lib/libcxx/include/__random/linear_congruential_engine.h+82-21
......@@ -26,32 +26,60 @@ _LIBCPP_PUSH_MACROS
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
29enum __lce_alg_type {
30 _LCE_Full,
31 _LCE_Part,
32 _LCE_Schrage,
33 _LCE_Promote,
34};
35
2936template <unsigned long long __a,
3037 unsigned long long __c,
3138 unsigned long long __m,
3239 unsigned long long _Mp,
33 bool _MightOverflow = (__a != 0 && __m != 0 && __m - 1 > (_Mp - __c) / __a),
34 bool _OverflowOK = ((__m | (__m - 1)) > __m), // m = 2^n
35 bool _SchrageOK = (__a != 0 && __m != 0 && __m % __a <= __m / __a)> // r <= q
40 bool _HasOverflow = (__a != 0ull && (__m & (__m - 1ull)) != 0ull), // a != 0, m != 0, m != 2^n
41 bool _Full = (!_HasOverflow || __m - 1ull <= (_Mp - __c) / __a), // (a * x + c) % m works
42 bool _Part = (!_HasOverflow || __m - 1ull <= _Mp / __a), // (a * x) % m works
43 bool _Schrage = (_HasOverflow && __m % __a <= __m / __a)> // r <= q
3644struct __lce_alg_picker {
37 static_assert(__a != 0 || __m != 0 || !_MightOverflow || _OverflowOK || _SchrageOK,
38 "The current values of a, c, and m cannot generate a number "
39 "within bounds of linear_congruential_engine.");
40
41 static _LIBCPP_CONSTEXPR const bool __use_schrage = _MightOverflow && !_OverflowOK && _SchrageOK;
45 static _LIBCPP_CONSTEXPR const __lce_alg_type __mode =
46 _Full ? _LCE_Full
47 : _Part ? _LCE_Part
48 : _Schrage ? _LCE_Schrage
49 : _LCE_Promote;
50
51#ifdef _LIBCPP_HAS_NO_INT128
52 static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage,
53 "The current values for a, c, and m are not currently supported on platforms without __int128");
54#endif
4255};
4356
4457template <unsigned long long __a,
4558 unsigned long long __c,
4659 unsigned long long __m,
4760 unsigned long long _Mp,
48 bool _UseSchrage = __lce_alg_picker<__a, __c, __m, _Mp>::__use_schrage>
61 __lce_alg_type _Mode = __lce_alg_picker<__a, __c, __m, _Mp>::__mode>
4962struct __lce_ta;
5063
5164// 64
5265
66#ifndef _LIBCPP_HAS_NO_INT128
67template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
68struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> {
69 typedef unsigned long long result_type;
70 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __xp) {
71 __extension__ using __calc_type = unsigned __int128;
72 const __calc_type __a = static_cast<__calc_type>(_Ap);
73 const __calc_type __c = static_cast<__calc_type>(_Cp);
74 const __calc_type __m = static_cast<__calc_type>(_Mp);
75 const __calc_type __x = static_cast<__calc_type>(__xp);
76 return static_cast<result_type>((__a * __x + __c) % __m);
77 }
78};
79#endif
80
5381template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
54struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> {
82struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Schrage> {
5583 typedef unsigned long long result_type;
5684 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
5785 // Schrage's algorithm
......@@ -66,7 +94,7 @@ struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), true> {
6694};
6795
6896template <unsigned long long __a, unsigned long long __m>
69struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> {
97struct __lce_ta<__a, 0ull, __m, (unsigned long long)(-1), _LCE_Schrage> {
7098 typedef unsigned long long result_type;
7199 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
72100 // Schrage's algorithm
......@@ -80,21 +108,40 @@ struct __lce_ta<__a, 0, __m, (unsigned long long)(~0), true> {
80108};
81109
82110template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
83struct __lce_ta<__a, __c, __m, (unsigned long long)(~0), false> {
111struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Part> {
112 typedef unsigned long long result_type;
113 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
114 // Use (((a*x) % m) + c) % m
115 __x = (__a * __x) % __m;
116 __x += __c - (__x >= __m - __c) * __m;
117 return __x;
118 }
119};
120
121template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
122struct __lce_ta<__a, __c, __m, (unsigned long long)(-1), _LCE_Full> {
84123 typedef unsigned long long result_type;
85124 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return (__a * __x + __c) % __m; }
86125};
87126
88127template <unsigned long long __a, unsigned long long __c>
89struct __lce_ta<__a, __c, 0, (unsigned long long)(~0), false> {
128struct __lce_ta<__a, __c, 0ull, (unsigned long long)(-1), _LCE_Full> {
90129 typedef unsigned long long result_type;
91130 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) { return __a * __x + __c; }
92131};
93132
94133// 32
95134
135template <unsigned long long __a, unsigned long long __c, unsigned long long __m>
136struct __lce_ta<__a, __c, __m, unsigned(-1), _LCE_Promote> {
137 typedef unsigned result_type;
138 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
139 return static_cast<result_type>(__lce_ta<__a, __c, __m, (unsigned long long)(-1)>::next(__x));
140 }
141};
142
96143template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
97struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> {
144struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Schrage> {
98145 typedef unsigned result_type;
99146 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
100147 const result_type __a = static_cast<result_type>(_Ap);
......@@ -112,7 +159,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), true> {
112159};
113160
114161template <unsigned long long _Ap, unsigned long long _Mp>
115struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> {
162struct __lce_ta<_Ap, 0ull, _Mp, unsigned(-1), _LCE_Schrage> {
116163 typedef unsigned result_type;
117164 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
118165 const result_type __a = static_cast<result_type>(_Ap);
......@@ -128,7 +175,21 @@ struct __lce_ta<_Ap, 0, _Mp, unsigned(~0), true> {
128175};
129176
130177template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
131struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> {
178struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Part> {
179 typedef unsigned result_type;
180 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
181 const result_type __a = static_cast<result_type>(_Ap);
182 const result_type __c = static_cast<result_type>(_Cp);
183 const result_type __m = static_cast<result_type>(_Mp);
184 // Use (((a*x) % m) + c) % m
185 __x = (__a * __x) % __m;
186 __x += __c - (__x >= __m - __c) * __m;
187 return __x;
188 }
189};
190
191template <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
192struct __lce_ta<_Ap, _Cp, _Mp, unsigned(-1), _LCE_Full> {
132193 typedef unsigned result_type;
133194 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
134195 const result_type __a = static_cast<result_type>(_Ap);
......@@ -139,7 +200,7 @@ struct __lce_ta<_Ap, _Cp, _Mp, unsigned(~0), false> {
139200};
140201
141202template <unsigned long long _Ap, unsigned long long _Cp>
142struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> {
203struct __lce_ta<_Ap, _Cp, 0ull, unsigned(-1), _LCE_Full> {
143204 typedef unsigned result_type;
144205 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
145206 const result_type __a = static_cast<result_type>(_Ap);
......@@ -150,11 +211,11 @@ struct __lce_ta<_Ap, _Cp, 0, unsigned(~0), false> {
150211
151212// 16
152213
153template <unsigned long long __a, unsigned long long __c, unsigned long long __m, bool __b>
154struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> {
214template <unsigned long long __a, unsigned long long __c, unsigned long long __m, __lce_alg_type __mode>
215struct __lce_ta<__a, __c, __m, (unsigned short)(-1), __mode> {
155216 typedef unsigned short result_type;
156217 _LIBCPP_HIDE_FROM_ABI static result_type next(result_type __x) {
157 return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(~0)>::next(__x));
218 return static_cast<result_type>(__lce_ta<__a, __c, __m, unsigned(-1)>::next(__x));
158219 }
159220};
160221
......@@ -178,7 +239,7 @@ public:
178239private:
179240 result_type __x_;
180241
181 static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(~0);
242 static _LIBCPP_CONSTEXPR const result_type _Mp = result_type(-1);
182243
183244 static_assert(__m == 0 || __a < __m, "linear_congruential_engine invalid parameters");
184245 static_assert(__m == 0 || __c < __m, "linear_congruential_engine invalid parameters");
lib/libcxx/include/__random/negative_binomial_distribution.h+1
......@@ -9,6 +9,7 @@
99#ifndef _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H
1010#define _LIBCPP___RANDOM_NEGATIVE_BINOMIAL_DISTRIBUTION_H
1111
12#include <__assert>
1213#include <__config>
1314#include <__random/bernoulli_distribution.h>
1415#include <__random/gamma_distribution.h>
lib/libcxx/include/__random/seed_seq.h+7-1
......@@ -14,6 +14,7 @@
1414#include <__algorithm/max.h>
1515#include <__config>
1616#include <__iterator/iterator_traits.h>
17#include <__type_traits/is_unsigned.h>
1718#include <cstdint>
1819#include <initializer_list>
1920#include <vector>
......@@ -35,7 +36,7 @@ public:
3536 // constructors
3637 _LIBCPP_HIDE_FROM_ABI seed_seq() _NOEXCEPT {}
3738#ifndef _LIBCPP_CXX03_LANG
38 template <class _Tp, __enable_if_t<is_integral<_Tp>::value>* = nullptr>
39 template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
3940 _LIBCPP_HIDE_FROM_ABI seed_seq(initializer_list<_Tp> __il) {
4041 __init(__il.begin(), __il.end());
4142 }
......@@ -79,6 +80,11 @@ void seed_seq::__init(_InputIterator __first, _InputIterator __last) {
7980
8081template <class _RandomAccessIterator>
8182void seed_seq::generate(_RandomAccessIterator __first, _RandomAccessIterator __last) {
83 using _ValueType = typename iterator_traits<_RandomAccessIterator>::value_type;
84 static_assert(is_unsigned<_ValueType>::value && sizeof(_ValueType) >= sizeof(uint32_t),
85 "[rand.util.seedseq]/7 requires the value_type of the iterator to be an unsigned "
86 "integer capable of accommodating 32-bit quantities.");
87
8288 if (__first != __last) {
8389 std::fill(__first, __last, 0x8b8b8b8b);
8490 const size_t __n = static_cast<size_t>(__last - __first);
lib/libcxx/include/__ranges/access.h+6-9
......@@ -41,12 +41,11 @@ concept __can_borrow = is_lvalue_reference_v<_Tp> || enable_borrowed_range<remov
4141namespace ranges {
4242namespace __begin {
4343template <class _Tp>
44concept __member_begin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
44concept __member_begin = __can_borrow<_Tp> && requires(_Tp&& __t) {
4545 { _LIBCPP_AUTO_CAST(__t.begin()) } -> input_or_output_iterator;
4646};
4747
48void begin(auto&) = delete;
49void begin(const auto&) = delete;
48void begin() = delete;
5049
5150template <class _Tp>
5251concept __unqualified_begin =
......@@ -104,13 +103,12 @@ using iterator_t = decltype(ranges::begin(std::declval<_Tp&>()));
104103namespace ranges {
105104namespace __end {
106105template <class _Tp>
107concept __member_end = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
106concept __member_end = __can_borrow<_Tp> && requires(_Tp&& __t) {
108107 typename iterator_t<_Tp>;
109108 { _LIBCPP_AUTO_CAST(__t.end()) } -> sentinel_for<iterator_t<_Tp>>;
110109};
111110
112void end(auto&) = delete;
113void end(const auto&) = delete;
111void end() = delete;
114112
115113template <class _Tp>
116114concept __unqualified_end =
......@@ -193,9 +191,8 @@ struct __fn {
193191
194192 template <class _Tp>
195193 requires is_rvalue_reference_v<_Tp&&>
196 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
197 noexcept(noexcept(ranges::end(static_cast<const _Tp&&>(__t))))
198 -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
194 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
195 noexcept(ranges::end(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::end(static_cast<const _Tp&&>(__t))) {
199196 return ranges::end(static_cast<const _Tp&&>(__t));
200197 }
201198};
lib/libcxx/include/__ranges/all.h+2-3
......@@ -39,9 +39,8 @@ namespace __all {
3939struct __fn : __range_adaptor_closure<__fn> {
4040 template <class _Tp>
4141 requires ranges::view<decay_t<_Tp>>
42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
43 noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))))
44 -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) {
42 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
43 noexcept(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t)))) -> decltype(_LIBCPP_AUTO_CAST(std::forward<_Tp>(__t))) {
4544 return _LIBCPP_AUTO_CAST(std::forward<_Tp>(__t));
4645 }
4746
lib/libcxx/include/__ranges/as_rvalue_view.h+8-8
......@@ -111,18 +111,18 @@ namespace views {
111111namespace __as_rvalue {
112112struct __fn : __range_adaptor_closure<__fn> {
113113 template <class _Range>
114 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
115 noexcept(noexcept(/**/ as_rvalue_view(std::forward<_Range>(__range))))
116 -> decltype(/*--*/ as_rvalue_view(std::forward<_Range>(__range))) {
117 return /*-------------*/ as_rvalue_view(std::forward<_Range>(__range));
114 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
115 operator()(_Range&& __range) noexcept(noexcept(as_rvalue_view(std::forward<_Range>(__range))))
116 -> decltype(/*--------------------------*/ as_rvalue_view(std::forward<_Range>(__range))) {
117 return /*---------------------------------*/ as_rvalue_view(std::forward<_Range>(__range));
118118 }
119119
120120 template <class _Range>
121121 requires same_as<range_rvalue_reference_t<_Range>, range_reference_t<_Range>>
122 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
123 noexcept(noexcept(/**/ views::all(std::forward<_Range>(__range))))
124 -> decltype(/*--*/ views::all(std::forward<_Range>(__range))) {
125 return /*-------------*/ views::all(std::forward<_Range>(__range));
122 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto
123 operator()(_Range&& __range) noexcept(noexcept(views::all(std::forward<_Range>(__range))))
124 -> decltype(/*--------------------------*/ views::all(std::forward<_Range>(__range))) {
125 return /*---------------------------------*/ views::all(std::forward<_Range>(__range));
126126 }
127127};
128128} // namespace __as_rvalue
lib/libcxx/include/__ranges/chunk_by_view.h+2-2
......@@ -205,7 +205,7 @@ namespace views {
205205namespace __chunk_by {
206206struct __fn {
207207 template <class _Range, class _Pred>
208 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
208 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Pred&& __pred) const
209209 noexcept(noexcept(/**/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))))
210210 -> decltype(/*--*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred))) {
211211 return /*-------------*/ chunk_by_view(std::forward<_Range>(__range), std::forward<_Pred>(__pred));
......@@ -213,7 +213,7 @@ struct __fn {
213213
214214 template <class _Pred>
215215 requires constructible_from<decay_t<_Pred>, _Pred>
216 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
216 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pred&& __pred) const
217217 noexcept(is_nothrow_constructible_v<decay_t<_Pred>, _Pred>) {
218218 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pred>(__pred)));
219219 }
lib/libcxx/include/__ranges/common_view.h+4-6
......@@ -114,16 +114,14 @@ namespace __common {
114114struct __fn : __range_adaptor_closure<__fn> {
115115 template <class _Range>
116116 requires common_range<_Range>
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
118 noexcept(noexcept(views::all(std::forward<_Range>(__range))))
119 -> decltype(views::all(std::forward<_Range>(__range))) {
117 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept(
118 noexcept(views::all(std::forward<_Range>(__range)))) -> decltype(views::all(std::forward<_Range>(__range))) {
120119 return views::all(std::forward<_Range>(__range));
121120 }
122121
123122 template <class _Range>
124 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
125 noexcept(noexcept(common_view{std::forward<_Range>(__range)}))
126 -> decltype(common_view{std::forward<_Range>(__range)}) {
123 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept(noexcept(common_view{
124 std::forward<_Range>(__range)})) -> decltype(common_view{std::forward<_Range>(__range)}) {
127125 return common_view{std::forward<_Range>(__range)};
128126 }
129127};
lib/libcxx/include/__ranges/counted.h+2-3
......@@ -51,9 +51,8 @@ struct __fn {
5151 }
5252
5353 template <random_access_iterator _It>
54 _LIBCPP_HIDE_FROM_ABI static constexpr auto
55 __go(_It __it, iter_difference_t<_It> __count) noexcept(noexcept(subrange(__it, __it + __count)))
56 -> decltype(subrange(__it, __it + __count)) {
54 _LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_It __it, iter_difference_t<_It> __count) noexcept(
55 noexcept(subrange(__it, __it + __count))) -> decltype(subrange(__it, __it + __count)) {
5756 return subrange(__it, __it + __count);
5857 }
5958
lib/libcxx/include/__ranges/data.h+3-4
......@@ -40,7 +40,7 @@ template <class _Tp>
4040concept __ptr_to_object = is_pointer_v<_Tp> && is_object_v<remove_pointer_t<_Tp>>;
4141
4242template <class _Tp>
43concept __member_data = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
43concept __member_data = __can_borrow<_Tp> && requires(_Tp&& __t) {
4444 { _LIBCPP_AUTO_CAST(__t.data()) } -> __ptr_to_object;
4545};
4646
......@@ -83,9 +83,8 @@ struct __fn {
8383
8484 template <class _Tp>
8585 requires is_rvalue_reference_v<_Tp&&>
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
87 noexcept(noexcept(ranges::data(static_cast<const _Tp&&>(__t))))
88 -> decltype(ranges::data(static_cast<const _Tp&&>(__t))) {
86 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
87 noexcept(ranges::data(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::data(static_cast<const _Tp&&>(__t))) {
8988 return ranges::data(static_cast<const _Tp&&>(__t));
9089 }
9190};
lib/libcxx/include/__ranges/drop_view.h+8-8
......@@ -266,7 +266,7 @@ struct __fn {
266266 class _RawRange = remove_cvref_t<_Range>,
267267 class _Dist = range_difference_t<_Range>>
268268 requires (__is_repeat_specialization<_RawRange> && sized_range<_RawRange>)
269 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
269 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
270270 noexcept(noexcept(views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))))
271271 -> decltype( views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))
272272 { return views::repeat(*__range.__value_, ranges::distance(__range) - std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); }
......@@ -277,7 +277,7 @@ struct __fn {
277277 class _RawRange = remove_cvref_t<_Range>,
278278 class _Dist = range_difference_t<_Range>>
279279 requires (__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>)
280 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
280 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
281281 constexpr auto operator()(_Range&& __range, _Np&&) const
282282 noexcept(noexcept(_LIBCPP_AUTO_CAST(std::forward<_Range>(__range))))
283283 -> decltype( _LIBCPP_AUTO_CAST(std::forward<_Range>(__range)))
......@@ -289,14 +289,14 @@ struct __fn {
289289 template <class _Range, convertible_to<range_difference_t<_Range>> _Np, class _RawRange = remove_cvref_t<_Range>>
290290 // Note: without specifically excluding the other cases, GCC sees this overload as ambiguous with the other
291291 // overloads.
292 requires(
293 !(__is_empty_view<_RawRange> ||
292 requires(!(__is_empty_view<_RawRange> ||
294293# if _LIBCPP_STD_VER >= 23
295 __is_repeat_specialization<_RawRange> ||
294 __is_repeat_specialization<_RawRange> ||
296295# endif
297 (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> &&
298 random_access_range<_RawRange>) ||
299 (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> && random_access_range<_RawRange>)))
296 (__is_subrange_specialization_with_store_size<_RawRange> && sized_range<_RawRange> &&
297 random_access_range<_RawRange>) ||
298 (__is_passthrough_specialization<_RawRange> && sized_range<_RawRange> &&
299 random_access_range<_RawRange>)))
300300 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
301301 noexcept(noexcept(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))))
302302 -> decltype(drop_view(std::forward<_Range>(__range), std::forward<_Np>(__n))) {
lib/libcxx/include/__ranges/elements_view.h+1-1
......@@ -16,7 +16,7 @@
1616#include <__concepts/derived_from.h>
1717#include <__concepts/equality_comparable.h>
1818#include <__config>
19#include <__fwd/get.h>
19#include <__fwd/complex.h>
2020#include <__iterator/concepts.h>
2121#include <__iterator/iterator_traits.h>
2222#include <__ranges/access.h>
lib/libcxx/include/__ranges/empty.h+1-1
......@@ -29,7 +29,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2929namespace ranges {
3030namespace __empty {
3131template <class _Tp>
32concept __member_empty = __workaround_52970<_Tp> && requires(_Tp&& __t) { bool(__t.empty()); };
32concept __member_empty = requires(_Tp&& __t) { bool(__t.empty()); };
3333
3434template <class _Tp>
3535concept __can_invoke_size = !__member_empty<_Tp> && requires(_Tp&& __t) { ranges::size(__t); };
lib/libcxx/include/__ranges/iota_view.h+5-4
......@@ -22,7 +22,6 @@
2222#include <__concepts/semiregular.h>
2323#include <__concepts/totally_ordered.h>
2424#include <__config>
25#include <__functional/ranges_operations.h>
2625#include <__iterator/concepts.h>
2726#include <__iterator/incrementable_traits.h>
2827#include <__iterator/iterator_traits.h>
......@@ -31,7 +30,7 @@
3130#include <__ranges/movable_box.h>
3231#include <__ranges/view_interface.h>
3332#include <__type_traits/conditional.h>
34#include <__type_traits/is_nothrow_copy_constructible.h>
33#include <__type_traits/is_nothrow_constructible.h>
3534#include <__type_traits/make_unsigned.h>
3635#include <__type_traits/type_identity.h>
3736#include <__utility/forward.h>
......@@ -313,8 +312,8 @@ public:
313312 : __value_(std::move(__value)), __bound_sentinel_(std::move(__bound_sentinel)) {
314313 // Validate the precondition if possible.
315314 if constexpr (totally_ordered_with<_Start, _BoundSentinel>) {
316 _LIBCPP_ASSERT_UNCATEGORIZED(
317 ranges::less_equal()(__value_, __bound_sentinel_), "Precondition violated: value is greater than bound.");
315 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
316 bool(__value_ <= __bound_sentinel_), "iota_view: bound must be reachable from value");
318317 }
319318 }
320319
......@@ -345,6 +344,8 @@ public:
345344 return __iterator{__bound_sentinel_};
346345 }
347346
347 _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const { return __value_ == __bound_sentinel_; }
348
348349 _LIBCPP_HIDE_FROM_ABI constexpr auto size() const
349350 requires(same_as<_Start, _BoundSentinel> && __advanceable<_Start>) ||
350351 (integral<_Start> && integral<_BoundSentinel>) || sized_sentinel_for<_BoundSentinel, _Start>
lib/libcxx/include/__ranges/lazy_split_view.h+2-2
......@@ -403,8 +403,8 @@ template <class _Range, class _Pattern>
403403lazy_split_view(_Range&&, _Pattern&&) -> lazy_split_view<views::all_t<_Range>, views::all_t<_Pattern>>;
404404
405405template <input_range _Range>
406lazy_split_view(_Range&&, range_value_t<_Range>)
407 -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
406lazy_split_view(_Range&&,
407 range_value_t<_Range>) -> lazy_split_view<views::all_t<_Range>, single_view<range_value_t<_Range>>>;
408408
409409namespace views {
410410namespace __lazy_split_view {
lib/libcxx/include/__ranges/movable_box.h-2
......@@ -17,8 +17,6 @@
1717#include <__memory/addressof.h>
1818#include <__memory/construct_at.h>
1919#include <__type_traits/is_nothrow_constructible.h>
20#include <__type_traits/is_nothrow_copy_constructible.h>
21#include <__type_traits/is_nothrow_default_constructible.h>
2220#include <__utility/move.h>
2321#include <optional>
2422
lib/libcxx/include/__ranges/range_adaptor.h+36-17
......@@ -19,6 +19,7 @@
1919#include <__functional/invoke.h>
2020#include <__ranges/concepts.h>
2121#include <__type_traits/decay.h>
22#include <__type_traits/is_class.h>
2223#include <__type_traits/is_nothrow_constructible.h>
2324#include <__type_traits/remove_cvref.h>
2425#include <__utility/forward.h>
......@@ -35,12 +36,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3536
3637#if _LIBCPP_STD_VER >= 20
3738
39namespace ranges {
40
3841// CRTP base that one can derive from in order to be considered a range adaptor closure
3942// by the library. When deriving from this class, a pipe operator will be provided to
4043// make the following hold:
4144// - `x | f` is equivalent to `f(x)`
4245// - `f1 | f2` is an adaptor closure `g` such that `g(x)` is equivalent to `f2(f1(x))`
4346template <class _Tp>
47 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
4448struct __range_adaptor_closure;
4549
4650// Type that wraps an arbitrary function object and makes it into a range adaptor closure,
......@@ -52,27 +56,42 @@ struct __range_adaptor_closure_t : _Fn, __range_adaptor_closure<__range_adaptor_
5256_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__range_adaptor_closure_t);
5357
5458template <class _Tp>
55concept _RangeAdaptorClosure = derived_from<remove_cvref_t<_Tp>, __range_adaptor_closure<remove_cvref_t<_Tp>>>;
59_Tp __derived_from_range_adaptor_closure(__range_adaptor_closure<_Tp>*);
5660
5761template <class _Tp>
58struct __range_adaptor_closure {
59 template <ranges::viewable_range _View, _RangeAdaptorClosure _Closure>
60 requires same_as<_Tp, remove_cvref_t<_Closure>> && invocable<_Closure, _View>
61 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto)
62 operator|(_View&& __view, _Closure&& __closure) noexcept(is_nothrow_invocable_v<_Closure, _View>) {
63 return std::invoke(std::forward<_Closure>(__closure), std::forward<_View>(__view));
64 }
65
66 template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
67 requires same_as<_Tp, remove_cvref_t<_Closure>> && constructible_from<decay_t<_Closure>, _Closure> &&
68 constructible_from<decay_t<_OtherClosure>, _OtherClosure>
69 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(
70 is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
71 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {
72 return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
73 }
62concept _RangeAdaptorClosure = !ranges::range<remove_cvref_t<_Tp>> && requires {
63 // Ensure that `remove_cvref_t<_Tp>` is derived from `__range_adaptor_closure<remove_cvref_t<_Tp>>` and isn't derived
64 // from `__range_adaptor_closure<U>` for any other type `U`.
65 { ranges::__derived_from_range_adaptor_closure((remove_cvref_t<_Tp>*)nullptr) } -> same_as<remove_cvref_t<_Tp>>;
7466};
7567
68template <ranges::range _Range, _RangeAdaptorClosure _Closure>
69 requires invocable<_Closure, _Range>
70[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto)
71operator|(_Range&& __range, _Closure&& __closure) noexcept(is_nothrow_invocable_v<_Closure, _Range>) {
72 return std::invoke(std::forward<_Closure>(__closure), std::forward<_Range>(__range));
73}
74
75template <_RangeAdaptorClosure _Closure, _RangeAdaptorClosure _OtherClosure>
76 requires constructible_from<decay_t<_Closure>, _Closure> && constructible_from<decay_t<_OtherClosure>, _OtherClosure>
77[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator|(_Closure&& __c1, _OtherClosure&& __c2) noexcept(
78 is_nothrow_constructible_v<decay_t<_Closure>, _Closure> &&
79 is_nothrow_constructible_v<decay_t<_OtherClosure>, _OtherClosure>) {
80 return __range_adaptor_closure_t(std::__compose(std::forward<_OtherClosure>(__c2), std::forward<_Closure>(__c1)));
81}
82
83template <class _Tp>
84 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
85struct __range_adaptor_closure {};
86
87# if _LIBCPP_STD_VER >= 23
88template <class _Tp>
89 requires is_class_v<_Tp> && same_as<_Tp, remove_cv_t<_Tp>>
90class range_adaptor_closure : public __range_adaptor_closure<_Tp> {};
91# endif // _LIBCPP_STD_VER >= 23
92
93} // namespace ranges
94
7695#endif // _LIBCPP_STD_VER >= 20
7796
7897_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__ranges/rbegin.h+2-3
......@@ -36,12 +36,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3636namespace ranges {
3737namespace __rbegin {
3838template <class _Tp>
39concept __member_rbegin = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
39concept __member_rbegin = __can_borrow<_Tp> && requires(_Tp&& __t) {
4040 { _LIBCPP_AUTO_CAST(__t.rbegin()) } -> input_or_output_iterator;
4141};
4242
43void rbegin(auto&) = delete;
44void rbegin(const auto&) = delete;
43void rbegin() = delete;
4544
4645template <class _Tp>
4746concept __unqualified_rbegin =
lib/libcxx/include/__ranges/ref_view.h+1-1
......@@ -43,7 +43,7 @@ class ref_view : public view_interface<ref_view<_Range>> {
4343 _Range* __range_;
4444
4545 static void __fun(_Range&);
46 static void __fun(_Range&&) = delete;
46 static void __fun(_Range&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276
4747
4848public:
4949 template <class _Tp>
lib/libcxx/include/__ranges/rend.h+4-6
......@@ -37,13 +37,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3737namespace ranges {
3838namespace __rend {
3939template <class _Tp>
40concept __member_rend = __can_borrow<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
40concept __member_rend = __can_borrow<_Tp> && requires(_Tp&& __t) {
4141 ranges::rbegin(__t);
4242 { _LIBCPP_AUTO_CAST(__t.rend()) } -> sentinel_for<decltype(ranges::rbegin(__t))>;
4343};
4444
45void rend(auto&) = delete;
46void rend(const auto&) = delete;
45void rend() = delete;
4746
4847template <class _Tp>
4948concept __unqualified_rend =
......@@ -105,9 +104,8 @@ struct __fn {
105104
106105 template <class _Tp>
107106 requires is_rvalue_reference_v<_Tp&&>
108 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const
109 noexcept(noexcept(ranges::rend(static_cast<const _Tp&&>(__t))))
110 -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) {
107 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t) const noexcept(
108 noexcept(ranges::rend(static_cast<const _Tp&&>(__t)))) -> decltype(ranges::rend(static_cast<const _Tp&&>(__t))) {
111109 return ranges::rend(static_cast<const _Tp&&>(__t));
112110 }
113111};
lib/libcxx/include/__ranges/repeat_view.h+9-8
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP___RANGES_REPEAT_VIEW_H
1111#define _LIBCPP___RANGES_REPEAT_VIEW_H
1212
13#include <__assert>
1314#include <__concepts/constructible.h>
1415#include <__concepts/same_as.h>
1516#include <__concepts/semiregular.h>
......@@ -21,6 +22,7 @@
2122#include <__ranges/iota_view.h>
2223#include <__ranges/movable_box.h>
2324#include <__ranges/view_interface.h>
25#include <__type_traits/decay.h>
2426#include <__type_traits/is_object.h>
2527#include <__type_traits/make_unsigned.h>
2628#include <__type_traits/remove_cv.h>
......@@ -126,8 +128,8 @@ private:
126128 _LIBCPP_NO_UNIQUE_ADDRESS _Bound __bound_ = _Bound();
127129};
128130
129template <class _Tp, class _Bound>
130repeat_view(_Tp, _Bound) -> repeat_view<_Tp, _Bound>;
131template <class _Tp, class _Bound = unreachable_sentinel_t>
132repeat_view(_Tp, _Bound = _Bound()) -> repeat_view<_Tp, _Bound>;
131133
132134// [range.repeat.iterator]
133135template <move_constructible _Tp, semiregular _Bound>
......@@ -228,14 +230,13 @@ namespace views {
228230namespace __repeat {
229231struct __fn {
230232 template <class _Tp>
231 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value) const
232 noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value))))
233 -> decltype( ranges::repeat_view(std::forward<_Tp>(__value)))
234 { return ranges::repeat_view(std::forward<_Tp>(__value)); }
235
233 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value)
234 noexcept(noexcept(ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value))))
235 -> decltype( ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value)))
236 { return ranges::repeat_view<decay_t<_Tp>>(std::forward<_Tp>(__value)); }
236237
237238 template <class _Tp, class _Bound>
238 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel) const
239 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()(_Tp&& __value, _Bound&& __bound_sentinel)
239240 noexcept(noexcept(ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel))))
240241 -> decltype( ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)))
241242 { return ranges::repeat_view(std::forward<_Tp>(__value), std::forward<_Bound>(__bound_sentinel)); }
lib/libcxx/include/__ranges/reverse_view.h+2-3
......@@ -181,9 +181,8 @@ struct __fn : __range_adaptor_closure<__fn> {
181181 template <class _Range>
182182 requires(!__is_reverse_view<remove_cvref_t<_Range>> && !__is_sized_reverse_subrange<remove_cvref_t<_Range>> &&
183183 !__is_unsized_reverse_subrange<remove_cvref_t<_Range>>)
184 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const
185 noexcept(noexcept(reverse_view{std::forward<_Range>(__range)}))
186 -> decltype(reverse_view{std::forward<_Range>(__range)}) {
184 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range) const noexcept(noexcept(reverse_view{
185 std::forward<_Range>(__range)})) -> decltype(reverse_view{std::forward<_Range>(__range)}) {
187186 return reverse_view{std::forward<_Range>(__range)};
188187 }
189188};
lib/libcxx/include/__ranges/single_view.h+2
......@@ -70,6 +70,8 @@ public:
7070
7171 _LIBCPP_HIDE_FROM_ABI constexpr const _Tp* end() const noexcept { return data() + 1; }
7272
73 _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return false; }
74
7375 _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 1; }
7476
7577 _LIBCPP_HIDE_FROM_ABI constexpr _Tp* data() noexcept { return __value_.operator->(); }
lib/libcxx/include/__ranges/size.h+2-3
......@@ -41,14 +41,13 @@ inline constexpr bool disable_sized_range = false;
4141
4242namespace ranges {
4343namespace __size {
44void size(auto&) = delete;
45void size(const auto&) = delete;
44void size() = delete;
4645
4746template <class _Tp>
4847concept __size_enabled = !disable_sized_range<remove_cvref_t<_Tp>>;
4948
5049template <class _Tp>
51concept __member_size = __size_enabled<_Tp> && __workaround_52970<_Tp> && requires(_Tp&& __t) {
50concept __member_size = __size_enabled<_Tp> && requires(_Tp&& __t) {
5251 { _LIBCPP_AUTO_CAST(__t.size()) } -> __integer_like;
5352};
5453
lib/libcxx/include/__ranges/split_view.h+2-2
......@@ -200,7 +200,7 @@ namespace __split_view {
200200struct __fn {
201201 // clang-format off
202202 template <class _Range, class _Pattern>
203 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI
203 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI
204204 constexpr auto operator()(_Range&& __range, _Pattern&& __pattern) const
205205 noexcept(noexcept(split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern))))
206206 -> decltype( split_view(std::forward<_Range>(__range), std::forward<_Pattern>(__pattern)))
......@@ -209,7 +209,7 @@ struct __fn {
209209
210210 template <class _Pattern>
211211 requires constructible_from<decay_t<_Pattern>, _Pattern>
212 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
212 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Pattern&& __pattern) const
213213 noexcept(is_nothrow_constructible_v<decay_t<_Pattern>, _Pattern>) {
214214 return __range_adaptor_closure_t(std::__bind_back(*this, std::forward<_Pattern>(__pattern)));
215215 }
lib/libcxx/include/__ranges/subrange.h+8-11
......@@ -17,7 +17,6 @@
1717#include <__concepts/derived_from.h>
1818#include <__concepts/different_from.h>
1919#include <__config>
20#include <__fwd/get.h>
2120#include <__fwd/subrange.h>
2221#include <__iterator/advance.h>
2322#include <__iterator/concepts.h>
......@@ -29,8 +28,8 @@
2928#include <__ranges/enable_borrowed_range.h>
3029#include <__ranges/size.h>
3130#include <__ranges/view_interface.h>
32#include <__tuple/pair_like.h>
3331#include <__tuple/tuple_element.h>
32#include <__tuple/tuple_like_no_subrange.h>
3433#include <__tuple/tuple_size.h>
3534#include <__type_traits/conditional.h>
3635#include <__type_traits/decay.h>
......@@ -65,7 +64,7 @@ concept __convertible_to_non_slicing =
6564
6665template <class _Pair, class _Iter, class _Sent>
6766concept __pair_like_convertible_from =
68 !range<_Pair> && __pair_like<_Pair> && constructible_from<_Pair, _Iter, _Sent> &&
67 !range<_Pair> && __pair_like_no_subrange<_Pair> && constructible_from<_Pair, _Iter, _Sent> &&
6968 __convertible_to_non_slicing<_Iter, tuple_element_t<0, _Pair>> && convertible_to<_Sent, tuple_element_t<1, _Pair>>;
7069
7170template <input_or_output_iterator _Iter,
......@@ -126,8 +125,7 @@ public:
126125 requires(_Kind == subrange_kind::sized)
127126 : subrange(ranges::begin(__range), ranges::end(__range), __n) {}
128127
129 template <__different_from<subrange> _Pair>
130 requires __pair_like_convertible_from<_Pair, const _Iter&, const _Sent&>
128 template <__pair_like_convertible_from<const _Iter&, const _Sent&> _Pair>
131129 _LIBCPP_HIDE_FROM_ABI constexpr operator _Pair() const {
132130 return _Pair(__begin_, __end_);
133131 }
......@@ -202,12 +200,11 @@ template <input_or_output_iterator _Iter, sentinel_for<_Iter> _Sent>
202200subrange(_Iter, _Sent, make_unsigned_t<iter_difference_t<_Iter>>) -> subrange<_Iter, _Sent, subrange_kind::sized>;
203201
204202template <borrowed_range _Range>
205subrange(_Range&&)
206 -> subrange<iterator_t<_Range>,
207 sentinel_t<_Range>,
208 (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>)
209 ? subrange_kind::sized
210 : subrange_kind::unsized>;
203subrange(_Range&&) -> subrange<iterator_t<_Range>,
204 sentinel_t<_Range>,
205 (sized_range<_Range> || sized_sentinel_for<sentinel_t<_Range>, iterator_t<_Range>>)
206 ? subrange_kind::sized
207 : subrange_kind::unsized>;
211208
212209template <borrowed_range _Range>
213210subrange(_Range&&, make_unsigned_t<range_difference_t<_Range>>)
lib/libcxx/include/__ranges/take_view.h+2-2
......@@ -308,7 +308,7 @@ struct __fn {
308308 class _RawRange = remove_cvref_t<_Range>,
309309 class _Dist = range_difference_t<_Range>>
310310 requires(__is_repeat_specialization<_RawRange> && sized_range<_RawRange>)
311 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
311 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
312312 noexcept(noexcept(views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n)))))
313313 -> decltype( views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))))
314314 { return views::repeat(*__range.__value_, std::min<_Dist>(ranges::distance(__range), std::forward<_Np>(__n))); }
......@@ -319,7 +319,7 @@ struct __fn {
319319 class _RawRange = remove_cvref_t<_Range>,
320320 class _Dist = range_difference_t<_Range>>
321321 requires(__is_repeat_specialization<_RawRange> && !sized_range<_RawRange>)
322 _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
322 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Range&& __range, _Np&& __n) const
323323 noexcept(noexcept(views::repeat(*__range.__value_, static_cast<_Dist>(__n))))
324324 -> decltype( views::repeat(*__range.__value_, static_cast<_Dist>(__n)))
325325 { return views::repeat(*__range.__value_, static_cast<_Dist>(__n)); }
lib/libcxx/include/__ranges/to.h+8-7
......@@ -24,6 +24,7 @@
2424#include <__ranges/concepts.h>
2525#include <__ranges/from_range.h>
2626#include <__ranges/range_adaptor.h>
27#include <__ranges/ref_view.h>
2728#include <__ranges/size.h>
2829#include <__ranges/transform_view.h>
2930#include <__type_traits/add_pointer.h>
......@@ -85,7 +86,7 @@ concept __always_false = false;
8586// `ranges::to` base template -- the `_Container` type is a simple type template parameter.
8687template <class _Container, input_range _Range, class... _Args>
8788 requires(!view<_Container>)
88_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __range, _Args&&... __args) {
89[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __range, _Args&&... __args) {
8990 // Mandates: C is a cv-unqualified class type.
9091 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
9192 static_assert(
......@@ -129,7 +130,7 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Container to(_Range&& __r
129130 // Try the recursive case.
130131 } else if constexpr (input_range<range_reference_t<_Range>>) {
131132 return ranges::to<_Container>(
132 __range | views::transform([](auto&& __elem) {
133 ref_view(__range) | views::transform([](auto&& __elem) {
133134 return ranges::to<range_value_t<_Container>>(std::forward<decltype(__elem)>(__elem));
134135 }),
135136 std::forward<_Args>(__args)...);
......@@ -192,7 +193,7 @@ struct _Deducer {
192193// `ranges::to` specialization -- `_Container` is a template template parameter requiring deduction to figure out the
193194// container element type.
194195template <template <class...> class _Container, input_range _Range, class... _Args>
195_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, _Args&&... __args) {
196[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range, _Args&&... __args) {
196197 using _DeduceExpr = typename _Deducer<_Container, _Range, _Args...>::type;
197198 return ranges::to<_DeduceExpr>(std::forward<_Range>(__range), std::forward<_Args>(__args)...);
198199}
......@@ -201,13 +202,13 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Range&& __range,
201202// parameter.
202203template <class _Container, class... _Args>
203204 requires(!view<_Container>)
204_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) {
205[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) {
205206 // Mandates: C is a cv-unqualified class type.
206207 static_assert(!is_const_v<_Container>, "The target container cannot be const-qualified, please remove the const");
207208 static_assert(
208209 !is_volatile_v<_Container>, "The target container cannot be volatile-qualified, please remove the volatile");
209210
210 auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail)
211 auto __to_func = []<input_range _Range, class... _Tail>(_Range&& __range, _Tail&&... __tail) static
211212 requires requires { //
212213 /**/ ranges::to<_Container>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);
213214 }
......@@ -219,11 +220,11 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args)
219220// Range adaptor closure object 2 -- wrapping the `ranges::to` version where `_Container` is a template template
220221// parameter.
221222template <template <class...> class _Container, class... _Args>
222_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) {
223[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto to(_Args&&... __args) {
223224 // clang-format off
224225 auto __to_func = []<input_range _Range, class... _Tail,
225226 class _DeducedExpr = typename _Deducer<_Container, _Range, _Tail...>::type>
226 (_Range&& __range, _Tail&& ... __tail)
227 (_Range&& __range, _Tail&& ... __tail) static
227228 requires requires { //
228229 /**/ ranges::to<_DeducedExpr>(std::forward<_Range>(__range), std::forward<_Tail>(__tail)...);
229230 }
lib/libcxx/include/__ranges/transform_view.h-7
......@@ -326,13 +326,6 @@ public:
326326 {
327327 return __x.__current_ - __y.__current_;
328328 }
329
330 _LIBCPP_HIDE_FROM_ABI friend constexpr decltype(auto) iter_move(const __iterator& __i) noexcept(noexcept(*__i)) {
331 if constexpr (is_lvalue_reference_v<decltype(*__i)>)
332 return std::move(*__i);
333 else
334 return *__i;
335 }
336329};
337330
338331# if _LIBCPP_STD_VER >= 23
lib/libcxx/include/__ranges/view_interface.h+13-4
......@@ -21,6 +21,7 @@
2121#include <__ranges/access.h>
2222#include <__ranges/concepts.h>
2323#include <__ranges/empty.h>
24#include <__ranges/size.h>
2425#include <__type_traits/is_class.h>
2526#include <__type_traits/make_unsigned.h>
2627#include <__type_traits/remove_cv.h>
......@@ -51,16 +52,24 @@ class view_interface {
5152public:
5253 template <class _D2 = _Derived>
5354 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty()
54 requires forward_range<_D2>
55 requires sized_range<_D2> || forward_range<_D2>
5556 {
56 return ranges::begin(__derived()) == ranges::end(__derived());
57 if constexpr (sized_range<_D2>) {
58 return ranges::size(__derived()) == 0;
59 } else {
60 return ranges::begin(__derived()) == ranges::end(__derived());
61 }
5762 }
5863
5964 template <class _D2 = _Derived>
6065 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool empty() const
61 requires forward_range<const _D2>
66 requires sized_range<const _D2> || forward_range<const _D2>
6267 {
63 return ranges::begin(__derived()) == ranges::end(__derived());
68 if constexpr (sized_range<const _D2>) {
69 return ranges::size(__derived()) == 0;
70 } else {
71 return ranges::begin(__derived()) == ranges::end(__derived());
72 }
6473 }
6574
6675 template <class _D2 = _Derived>
lib/libcxx/include/__ranges/zip_view.h+6-5
......@@ -30,12 +30,13 @@
3030#include <__ranges/enable_borrowed_range.h>
3131#include <__ranges/size.h>
3232#include <__ranges/view_interface.h>
33#include <__type_traits/is_nothrow_move_constructible.h>
33#include <__type_traits/is_nothrow_constructible.h>
3434#include <__type_traits/make_unsigned.h>
3535#include <__utility/declval.h>
3636#include <__utility/forward.h>
3737#include <__utility/integer_sequence.h>
3838#include <__utility/move.h>
39#include <__utility/pair.h>
3940#include <tuple>
4041
4142#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -489,12 +490,12 @@ namespace views {
489490namespace __zip {
490491
491492struct __fn {
492 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()() const noexcept { return empty_view<tuple<>>{}; }
493 _LIBCPP_HIDE_FROM_ABI static constexpr auto operator()() noexcept { return empty_view<tuple<>>{}; }
493494
494495 template <class... _Ranges>
495 _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Ranges&&... __rs) const
496 noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
497 -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
496 _LIBCPP_HIDE_FROM_ABI static constexpr auto
497 operator()(_Ranges&&... __rs) noexcept(noexcept(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)))
498 -> decltype(zip_view<all_t<_Ranges&&>...>(std::forward<_Ranges>(__rs)...)) {
498499 return zip_view<all_t<_Ranges>...>(std::forward<_Ranges>(__rs)...);
499500 }
500501};
lib/libcxx/include/__split_buffer+17-7
......@@ -24,13 +24,14 @@
2424#include <__memory/pointer_traits.h>
2525#include <__memory/swap_allocator.h>
2626#include <__type_traits/add_lvalue_reference.h>
27#include <__type_traits/conditional.h>
2728#include <__type_traits/enable_if.h>
2829#include <__type_traits/integral_constant.h>
29#include <__type_traits/is_nothrow_default_constructible.h>
30#include <__type_traits/is_nothrow_move_assignable.h>
31#include <__type_traits/is_nothrow_move_constructible.h>
30#include <__type_traits/is_nothrow_assignable.h>
31#include <__type_traits/is_nothrow_constructible.h>
3232#include <__type_traits/is_swappable.h>
3333#include <__type_traits/is_trivially_destructible.h>
34#include <__type_traits/is_trivially_relocatable.h>
3435#include <__type_traits/remove_reference.h>
3536#include <__utility/forward.h>
3637#include <__utility/move.h>
......@@ -65,6 +66,15 @@ public:
6566 using iterator = pointer;
6667 using const_iterator = const_pointer;
6768
69 // A __split_buffer contains the following members which may be trivially relocatable:
70 // - pointer: may be trivially relocatable, so it's checked
71 // - allocator_type: may be trivially relocatable, so it's checked
72 // __split_buffer doesn't have any self-references, so it's trivially relocatable if its members are.
73 using __trivially_relocatable = __conditional_t<
74 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
75 __split_buffer,
76 void>;
77
6878 pointer __first_;
6979 pointer __begin_;
7080 pointer __end_;
......@@ -188,7 +198,7 @@ public:
188198 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
189199
190200 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void swap(__split_buffer& __x)
191 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value);
201 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>);
192202
193203 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
194204
......@@ -201,8 +211,8 @@ private:
201211 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT {}
202212
203213 struct _ConstructTransaction {
204 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(
205 pointer* __p, size_type __n) _NOEXCEPT
214 _LIBCPP_CONSTEXPR_SINCE_CXX20
215 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
206216 : __pos_(*__p),
207217 __end_(*__p + __n),
208218 __dest_(__p) {}
......@@ -410,7 +420,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
410420
411421template <class _Tp, class _Allocator>
412422_LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
413 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__alloc_rr>::value) {
423 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__alloc_rr>) {
414424 std::swap(__first_, __x.__first_);
415425 std::swap(__begin_, __x.__begin_);
416426 std::swap(__end_, __x.__end_);
lib/libcxx/include/__stop_token/stop_callback.h+4-6
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
1111#define _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
1212
13#include <__availability>
1413#include <__concepts/constructible.h>
1514#include <__concepts/destructible.h>
1615#include <__concepts/invocable.h>
......@@ -21,6 +20,7 @@
2120#include <__type_traits/is_nothrow_constructible.h>
2221#include <__utility/forward.h>
2322#include <__utility/move.h>
23#include <__utility/private_constructor_tag.h>
2424
2525#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2626# pragma GCC system_header
......@@ -49,13 +49,13 @@ public:
4949 requires constructible_from<_Callback, _Cb>
5050 _LIBCPP_HIDE_FROM_ABI explicit stop_callback(const stop_token& __st,
5151 _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>)
52 : stop_callback(__private_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {}
52 : stop_callback(__private_constructor_tag{}, __st.__state_, std::forward<_Cb>(__cb)) {}
5353
5454 template <class _Cb>
5555 requires constructible_from<_Callback, _Cb>
5656 _LIBCPP_HIDE_FROM_ABI explicit stop_callback(stop_token&& __st,
5757 _Cb&& __cb) noexcept(is_nothrow_constructible_v<_Callback, _Cb>)
58 : stop_callback(__private_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {}
58 : stop_callback(__private_constructor_tag{}, std::move(__st.__state_), std::forward<_Cb>(__cb)) {}
5959
6060 _LIBCPP_HIDE_FROM_ABI ~stop_callback() {
6161 if (__state_) {
......@@ -74,10 +74,8 @@ private:
7474
7575 friend __stop_callback_base;
7676
77 struct __private_tag {};
78
7977 template <class _StatePtr, class _Cb>
80 _LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_tag, _StatePtr&& __state, _Cb&& __cb) noexcept(
78 _LIBCPP_HIDE_FROM_ABI explicit stop_callback(__private_constructor_tag, _StatePtr&& __state, _Cb&& __cb) noexcept(
8179 is_nothrow_constructible_v<_Callback, _Cb>)
8280 : __stop_callback_base([](__stop_callback_base* __cb_base) noexcept {
8381 // stop callback is supposed to only be called once
lib/libcxx/include/__stop_token/stop_source.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
1111#define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__stop_token/intrusive_shared_ptr.h>
1615#include <__stop_token/stop_state.h>
lib/libcxx/include/__stop_token/stop_state.h+1-1
......@@ -10,7 +10,7 @@
1010#ifndef _LIBCPP___STOP_TOKEN_STOP_STATE_H
1111#define _LIBCPP___STOP_TOKEN_STOP_STATE_H
1212
13#include <__availability>
13#include <__assert>
1414#include <__config>
1515#include <__stop_token/atomic_unique_lock.h>
1616#include <__stop_token/intrusive_list_view.h>
lib/libcxx/include/__stop_token/stop_token.h-1
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
1111#define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__stop_token/intrusive_shared_ptr.h>
1615#include <__stop_token/stop_state.h>
lib/libcxx/include/__string/char_traits.h+88-346
......@@ -9,14 +9,16 @@
99#ifndef _LIBCPP___STRING_CHAR_TRAITS_H
1010#define _LIBCPP___STRING_CHAR_TRAITS_H
1111
12#include <__algorithm/copy_n.h>
1312#include <__algorithm/fill_n.h>
13#include <__algorithm/find.h>
1414#include <__algorithm/find_end.h>
1515#include <__algorithm/find_first_of.h>
1616#include <__algorithm/min.h>
17#include <__assert>
1718#include <__compare/ordering.h>
1819#include <__config>
1920#include <__functional/hash.h>
21#include <__functional/identity.h>
2022#include <__iterator/iterator_traits.h>
2123#include <__string/constexpr_c_functions.h>
2224#include <__type_traits/is_constant_evaluated.h>
......@@ -72,106 +74,6 @@ exposition-only to document what members a char_traits specialization should pro
7274};
7375*/
7476
75//
76// Temporary extension to provide a base template for std::char_traits.
77// TODO(LLVM-19): Remove this class.
78//
79#if !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION)
80template <class _CharT>
81struct _LIBCPP_DEPRECATED_(
82 "char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided "
83 "for a temporary period. It will be removed in LLVM 19, so please migrate off of it.") char_traits {
84 using char_type = _CharT;
85 using int_type = int;
86 using off_type = streamoff;
87 using pos_type = streampos;
88 using state_type = mbstate_t;
89
90 static inline void _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_HIDE_FROM_ABI
91 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {
92 __c1 = __c2;
93 }
94 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {
95 return __c1 == __c2;
96 }
97 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {
98 return __c1 < __c2;
99 }
100
101 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int
102 compare(const char_type* __s1, const char_type* __s2, size_t __n) {
103 for (; __n; --__n, ++__s1, ++__s2) {
104 if (lt(*__s1, *__s2))
105 return -1;
106 if (lt(*__s2, *__s1))
107 return 1;
108 }
109 return 0;
110 }
111 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) {
112 size_t __len = 0;
113 for (; !eq(*__s, char_type(0)); ++__s)
114 ++__len;
115 return __len;
116 }
117 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
118 find(const char_type* __s, size_t __n, const char_type& __a) {
119 for (; __n; --__n) {
120 if (eq(*__s, __a))
121 return __s;
122 ++__s;
123 }
124 return nullptr;
125 }
126 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
127 move(char_type* __s1, const char_type* __s2, size_t __n) {
128 if (__n == 0)
129 return __s1;
130 char_type* __r = __s1;
131 if (__s1 < __s2) {
132 for (; __n; --__n, ++__s1, ++__s2)
133 assign(*__s1, *__s2);
134 } else if (__s2 < __s1) {
135 __s1 += __n;
136 __s2 += __n;
137 for (; __n; --__n)
138 assign(*--__s1, *--__s2);
139 }
140 return __r;
141 }
142 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
143 copy(char_type* __s1, const char_type* __s2, size_t __n) {
144 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),
145 "char_traits::copy: source and destination ranges overlap");
146 char_type* __r = __s1;
147 for (; __n; --__n, ++__s1, ++__s2)
148 assign(*__s1, *__s2);
149 return __r;
150 }
151 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
152 assign(char_type* __s, size_t __n, char_type __a) {
153 char_type* __r = __s;
154 for (; __n; --__n, ++__s)
155 assign(*__s, __a);
156 return __r;
157 }
158
159 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {
160 return eq_int_type(__c, eof()) ? ~eof() : __c;
161 }
162 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {
163 return char_type(__c);
164 }
165 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {
166 return int_type(__c);
167 }
168 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {
169 return __c1 == __c2;
170 }
171 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); }
172};
173#endif // !defined(_LIBCPP_CHAR_TRAITS_REMOVE_BASE_SPECIALIZATION)
174
17577// char_traits<char>
17678
17779template <>
......@@ -243,7 +145,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> {
243145 copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
244146 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),
245147 "char_traits::copy: source and destination ranges overlap");
246 std::copy_n(__s2, __n, __s1);
148 std::__constexpr_memmove(__s1, __s2, __element_count(__n));
247149 return __s1;
248150 }
249151
......@@ -268,31 +170,72 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char> {
268170 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(EOF); }
269171};
270172
271// char_traits<wchar_t>
272
273#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
274template <>
275struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> {
276 using char_type = wchar_t;
277 using int_type = wint_t;
173template <class _CharT, class _IntT, _IntT _EOFVal>
174struct __char_traits_base {
175 using char_type = _CharT;
176 using int_type = _IntT;
278177 using off_type = streamoff;
279 using pos_type = streampos;
280178 using state_type = mbstate_t;
281# if _LIBCPP_STD_VER >= 20
179#if _LIBCPP_STD_VER >= 20
282180 using comparison_category = strong_ordering;
283# endif
181#endif
284182
285 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void
286 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {
287 __c1 = __c2;
183 // There are different aliases for the different char types, but they are all aliases to this type
184 using pos_type = fpos<mbstate_t>;
185
186 _LIBCPP_HIDE_FROM_ABI static inline _LIBCPP_CONSTEXPR_SINCE_CXX17 void
187 assign(char_type& __lhs, const char_type& __rhs) _NOEXCEPT {
188 __lhs = __rhs;
288189 }
289 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {
290 return __c1 == __c2;
190
191 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq(char_type __lhs, char_type __rhs) _NOEXCEPT {
192 return __lhs == __rhs;
291193 }
292 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {
293 return __c1 < __c2;
194
195 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool lt(char_type __lhs, char_type __rhs) _NOEXCEPT {
196 return __lhs < __rhs;
197 }
198
199 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
200 move(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {
201 return std::__constexpr_memmove(__dest, __src, __element_count(__n));
202 }
203
204 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
205 copy(char_type* __dest, const char_type* __src, size_t __n) _NOEXCEPT {
206 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__dest, __dest + __n, __src),
207 "char_traits::copy: source and destination ranges overlap");
208 return std::__constexpr_memmove(__dest, __src, __element_count(__n));
294209 }
295210
211 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
212 assign(char_type* __str, size_t __n, char_type __fill_char) _NOEXCEPT {
213 std::fill_n(__str, __n, __fill_char);
214 return __str;
215 }
216
217 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {
218 return char_type(__c);
219 }
220
221 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT { return int_type(__c); }
222
223 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __lhs, int_type __rhs) _NOEXCEPT {
224 return __lhs == __rhs;
225 }
226
227 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return _EOFVal; }
228
229 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {
230 return eq_int_type(__c, eof()) ? static_cast<int_type>(~eof()) : __c;
231 }
232};
233
234// char_traits<wchar_t>
235
236#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
237template <>
238struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, wint_t, static_cast<wint_t>(WEOF)> {
296239 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 int
297240 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
298241 if (__n == 0)
......@@ -310,184 +253,46 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> {
310253 return nullptr;
311254 return std::__constexpr_wmemchr(__s, __a, __n);
312255 }
313
314 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
315 move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
316 return std::__constexpr_memmove(__s1, __s2, __element_count(__n));
317 }
318
319 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
320 copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
321 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),
322 "char_traits::copy: source and destination ranges overlap");
323 std::copy_n(__s2, __n, __s1);
324 return __s1;
325 }
326
327 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
328 assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
329 std::fill_n(__s, __n, __a);
330 return __s;
331 }
332
333 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {
334 return eq_int_type(__c, eof()) ? ~eof() : __c;
335 }
336 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {
337 return char_type(__c);
338 }
339 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {
340 return int_type(__c);
341 }
342 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {
343 return __c1 == __c2;
344 }
345 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(WEOF); }
346256};
347257#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
348258
349259#ifndef _LIBCPP_HAS_NO_CHAR8_T
350260
351261template <>
352struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t> {
353 using char_type = char8_t;
354 using int_type = unsigned int;
355 using off_type = streamoff;
356 using pos_type = u8streampos;
357 using state_type = mbstate_t;
358# if _LIBCPP_STD_VER >= 20
359 using comparison_category = strong_ordering;
360# endif
361
362 static inline _LIBCPP_HIDE_FROM_ABI constexpr void assign(char_type& __c1, const char_type& __c2) noexcept {
363 __c1 = __c2;
364 }
365 static inline _LIBCPP_HIDE_FROM_ABI constexpr bool eq(char_type __c1, char_type __c2) noexcept {
366 return __c1 == __c2;
367 }
368 static inline _LIBCPP_HIDE_FROM_ABI constexpr bool lt(char_type __c1, char_type __c2) noexcept { return __c1 < __c2; }
369
262struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
263 : __char_traits_base<char8_t, unsigned int, static_cast<unsigned int>(EOF)> {
370264 static _LIBCPP_HIDE_FROM_ABI constexpr int
371 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
265 compare(const char_type* __s1, const char_type* __s2, size_t __n) noexcept {
372266 return std::__constexpr_memcmp(__s1, __s2, __element_count(__n));
373267 }
374268
375 static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __s) _NOEXCEPT;
376
377 _LIBCPP_HIDE_FROM_ABI static constexpr const char_type*
378 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
379
380 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
381 move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
382 return std::__constexpr_memmove(__s1, __s2, __element_count(__n));
383 }
384
385 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
386 copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
387 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),
388 "char_traits::copy: source and destination ranges overlap");
389 std::copy_n(__s2, __n, __s1);
390 return __s1;
391 }
392
393 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 char_type*
394 assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
395 std::fill_n(__s, __n, __a);
396 return __s;
269 static _LIBCPP_HIDE_FROM_ABI constexpr size_t length(const char_type* __str) noexcept {
270 return std::__constexpr_strlen(__str);
397271 }
398272
399 static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type not_eof(int_type __c) noexcept {
400 return eq_int_type(__c, eof()) ? ~eof() : __c;
401 }
402 static inline _LIBCPP_HIDE_FROM_ABI constexpr char_type to_char_type(int_type __c) noexcept { return char_type(__c); }
403 static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type to_int_type(char_type __c) noexcept { return int_type(__c); }
404 static inline _LIBCPP_HIDE_FROM_ABI constexpr bool eq_int_type(int_type __c1, int_type __c2) noexcept {
405 return __c1 == __c2;
273 _LIBCPP_HIDE_FROM_ABI static constexpr const char_type*
274 find(const char_type* __s, size_t __n, const char_type& __a) noexcept {
275 return std::__constexpr_memchr(__s, __a, __n);
406276 }
407 static inline _LIBCPP_HIDE_FROM_ABI constexpr int_type eof() noexcept { return int_type(EOF); }
408277};
409278
410// TODO use '__builtin_strlen' if it ever supports char8_t ??
411inline constexpr size_t char_traits<char8_t>::length(const char_type* __s) _NOEXCEPT {
412 size_t __len = 0;
413 for (; !eq(*__s, char_type(0)); ++__s)
414 ++__len;
415 return __len;
416}
417
418// TODO use '__builtin_char_memchr' if it ever supports char8_t ??
419inline constexpr const char8_t*
420char_traits<char8_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
421 for (; __n; --__n) {
422 if (eq(*__s, __a))
423 return __s;
424 ++__s;
425 }
426 return nullptr;
427}
428
429279#endif // _LIBCPP_HAS_NO_CHAR8_T
430280
431281template <>
432struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t> {
433 using char_type = char16_t;
434 using int_type = uint_least16_t;
435 using off_type = streamoff;
436 using pos_type = u16streampos;
437 using state_type = mbstate_t;
438#if _LIBCPP_STD_VER >= 20
439 using comparison_category = strong_ordering;
440#endif
441
442 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void
443 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {
444 __c1 = __c2;
445 }
446 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {
447 return __c1 == __c2;
448 }
449 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {
450 return __c1 < __c2;
451 }
452
282struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
283 : __char_traits_base<char16_t, uint_least16_t, static_cast<uint_least16_t>(0xFFFF)> {
453284 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int
454285 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
455286 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;
456 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
457 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
458
459 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
460 move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
461 return std::__constexpr_memmove(__s1, __s2, __element_count(__n));
462 }
463287
464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
465 copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
466 _LIBCPP_ASSERT_NON_OVERLAPPING_RANGES(!std::__is_pointer_in_range(__s1, __s1 + __n, __s2),
467 "char_traits::copy: source and destination ranges overlap");
468 std::copy_n(__s2, __n, __s1);
469 return __s1;
470 }
471
472 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
473 assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
474 std::fill_n(__s, __n, __a);
475 return __s;
476 }
477
478 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {
479 return eq_int_type(__c, eof()) ? ~eof() : __c;
480 }
481 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {
482 return char_type(__c);
483 }
484 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {
485 return int_type(__c);
486 }
487 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {
488 return __c1 == __c2;
288 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
289 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
290 __identity __proj;
291 const char_type* __match = std::__find(__s, __s + __n, __a, __proj);
292 if (__match == __s + __n)
293 return nullptr;
294 return __match;
489295 }
490 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(0xFFFF); }
491296};
492297
493298inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int
......@@ -508,74 +313,21 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char16_t>::length(const
508313 return __len;
509314}
510315
511inline _LIBCPP_CONSTEXPR_SINCE_CXX17 const char16_t*
512char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
513 for (; __n; --__n) {
514 if (eq(*__s, __a))
515 return __s;
516 ++__s;
517 }
518 return nullptr;
519}
520
521316template <>
522struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t> {
523 using char_type = char32_t;
524 using int_type = uint_least32_t;
525 using off_type = streamoff;
526 using pos_type = u32streampos;
527 using state_type = mbstate_t;
528#if _LIBCPP_STD_VER >= 20
529 using comparison_category = strong_ordering;
530#endif
531
532 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 void
533 assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {
534 __c1 = __c2;
535 }
536 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {
537 return __c1 == __c2;
538 }
539 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {
540 return __c1 < __c2;
541 }
542
317struct _LIBCPP_TEMPLATE_VIS char_traits<char32_t>
318 : __char_traits_base<char32_t, uint_least32_t, static_cast<uint_least32_t>(0xFFFFFFFF)> {
543319 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 int
544320 compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
545321 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t length(const char_type* __s) _NOEXCEPT;
546 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
547 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
548
549 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
550 move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
551 return std::__constexpr_memmove(__s1, __s2, __element_count(__n));
552 }
553
554 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
555 copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT {
556 std::copy_n(__s2, __n, __s1);
557 return __s1;
558 }
559
560 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static char_type*
561 assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT {
562 std::fill_n(__s, __n, __a);
563 return __s;
564 }
565322
566 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {
567 return eq_int_type(__c, eof()) ? ~eof() : __c;
568 }
569 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {
570 return char_type(__c);
571 }
572 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {
573 return int_type(__c);
574 }
575 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {
576 return __c1 == __c2;
323 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX17 const char_type*
324 find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
325 __identity __proj;
326 const char_type* __match = std::__find(__s, __s + __n, __a, __proj);
327 if (__match == __s + __n)
328 return nullptr;
329 return __match;
577330 }
578 static inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT { return int_type(0xFFFFFFFF); }
579331};
580332
581333inline _LIBCPP_CONSTEXPR_SINCE_CXX17 int
......@@ -596,16 +348,6 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 size_t char_traits<char32_t>::length(const
596348 return __len;
597349}
598350
599inline _LIBCPP_CONSTEXPR_SINCE_CXX17 const char32_t*
600char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT {
601 for (; __n; --__n) {
602 if (eq(*__s, __a))
603 return __s;
604 ++__s;
605 }
606 return nullptr;
607}
608
609351// helper fns for basic_string and string_view
610352
611353// __str_find
lib/libcxx/include/__string/constexpr_c_functions.h+21-6
......@@ -35,18 +35,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3535// of elements as opposed to a number of bytes.
3636enum class __element_count : size_t {};
3737
38inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const char* __str) {
38template <class _Tp>
39inline const bool __is_char_type = false;
40
41template <>
42inline const bool __is_char_type<char> = true;
43
44#ifndef _LIBCPP_HAS_NO_CHAR8_T
45template <>
46inline const bool __is_char_type<char8_t> = true;
47#endif
48
49template <class _Tp>
50inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_strlen(const _Tp* __str) _NOEXCEPT {
51 static_assert(__is_char_type<_Tp>, "__constexpr_strlen only works with char and char8_t");
3952 // GCC currently doesn't support __builtin_strlen for heap-allocated memory during constant evaluation.
4053 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70816
41#ifdef _LIBCPP_COMPILER_GCC
4254 if (__libcpp_is_constant_evaluated()) {
55#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_COMPILER_CLANG_BASED)
56 if constexpr (is_same_v<_Tp, char>)
57 return __builtin_strlen(__str);
58#endif
4359 size_t __i = 0;
4460 for (; __str[__i] != '\0'; ++__i)
4561 ;
4662 return __i;
4763 }
48#endif
49 return __builtin_strlen(__str);
64 return __builtin_strlen(reinterpret_cast<const char*>(__str));
5065}
5166
5267// Because of __libcpp_is_trivially_lexicographically_comparable we know that comparing the object representations is
......@@ -108,7 +123,7 @@ __constexpr_memcmp_equal(const _Tp* __lhs, const _Up* __rhs, __element_count __n
108123 }
109124 return true;
110125 } else {
111 return __builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0;
126 return ::__builtin_memcmp(__lhs, __rhs, __count * sizeof(_Tp)) == 0;
112127 }
113128}
114129
......@@ -209,7 +224,7 @@ __constexpr_memmove(_Tp* __dest, _Up* __src, __element_count __n) {
209224 std::__assign_trivially_copyable(__dest[__i], __src[__i]);
210225 }
211226 } else if (__count > 0) {
212 ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __libcpp_datasizeof<_Tp>::value);
227 ::__builtin_memmove(__dest, __src, (__count - 1) * sizeof(_Tp) + __datasizeof_v<_Tp>);
213228 }
214229 return __dest;
215230}
lib/libcxx/include/__support/android/locale_bionic.h deleted-72
......@@ -1,72 +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_ANDROID_LOCALE_BIONIC_H
11#define _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
12
13#if defined(__BIONIC__)
14
15# ifdef __cplusplus
16extern "C" {
17# endif
18
19# include <stdlib.h>
20# include <xlocale.h>
21
22# ifdef __cplusplus
23}
24# endif
25
26# if defined(__ANDROID__)
27
28# include <android/api-level.h>
29# if __ANDROID_API__ < 21
30# include <__support/xlocale/__posix_l_fallback.h>
31# endif
32
33// If we do not have this header, we are in a platform build rather than an NDK
34// build, which will always be at least as new as the ToT NDK, in which case we
35// don't need any of the inlines below since libc provides them.
36# if __has_include(<android/ndk-version.h>)
37# include <android/ndk-version.h>
38// In NDK versions later than 16, locale-aware functions are provided by
39// legacy_stdlib_inlines.h
40# if __NDK_MAJOR__ <= 16
41# if __ANDROID_API__ < 21
42# include <__support/xlocale/__strtonum_fallback.h>
43# elif __ANDROID_API__ < 26
44
45# if defined(__cplusplus)
46extern "C" {
47# endif
48
49inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) {
50 return ::strtof(__nptr, __endptr);
51}
52
53inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) {
54 return ::strtod(__nptr, __endptr);
55}
56
57inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
58 return ::strtol(__nptr, __endptr, __base);
59}
60
61# if defined(__cplusplus)
62}
63# endif
64
65# endif // __ANDROID_API__ < 26
66
67# endif // __NDK_MAJOR__ <= 16
68# endif // __has_include(<android/ndk-version.h>)
69# endif // defined(__ANDROID__)
70
71#endif // defined(__BIONIC__)
72#endif // _LIBCPP___SUPPORT_ANDROID_LOCALE_BIONIC_H
lib/libcxx/include/__support/fuchsia/xlocale.h deleted-22
......@@ -1,22 +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_FUCHSIA_XLOCALE_H
11#define _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
12
13#if defined(__Fuchsia__)
14
15# include <__support/xlocale/__posix_l_fallback.h>
16# include <__support/xlocale/__strtonum_fallback.h>
17# include <cstdlib>
18# include <cwchar>
19
20#endif // defined(__Fuchsia__)
21
22#endif // _LIBCPP___SUPPORT_FUCHSIA_XLOCALE_H
lib/libcxx/include/__support/ibm/xlocale.h deleted-122
......@@ -1,122 +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_IBM_XLOCALE_H
11#define _LIBCPP___SUPPORT_IBM_XLOCALE_H
12
13#if defined(__MVS__)
14# include <__support/ibm/locale_mgmt_zos.h>
15#endif // defined(__MVS__)
16
17#include <stdarg.h>
18
19#include "cstdlib"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#if defined(__MVS__)
26# include <wctype.h>
27// POSIX routines
28# include <__support/xlocale/__posix_l_fallback.h>
29#endif // defined(__MVS__)
30
31namespace {
32
33struct __setAndRestore {
34 explicit __setAndRestore(locale_t locale) {
35 if (locale == (locale_t)0) {
36 __cloc = newlocale(LC_ALL_MASK, "C", /* base */ (locale_t)0);
37 __stored = uselocale(__cloc);
38 } else {
39 __stored = uselocale(locale);
40 }
41 }
42
43 ~__setAndRestore() {
44 uselocale(__stored);
45 if (__cloc)
46 freelocale(__cloc);
47 }
48
49private:
50 locale_t __stored = (locale_t)0;
51 locale_t __cloc = (locale_t)0;
52};
53
54} // namespace
55
56// The following are not POSIX routines. These are quick-and-dirty hacks
57// to make things pretend to work
58inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
59 __setAndRestore __newloc(locale);
60 return ::strtoll(__nptr, __endptr, __base);
61}
62
63inline _LIBCPP_HIDE_FROM_ABI long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
64 __setAndRestore __newloc(locale);
65 return ::strtol(__nptr, __endptr, __base);
66}
67
68inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t locale) {
69 __setAndRestore __newloc(locale);
70 return ::strtod(__nptr, __endptr);
71}
72
73inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t locale) {
74 __setAndRestore __newloc(locale);
75 return ::strtof(__nptr, __endptr);
76}
77
78inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t locale) {
79 __setAndRestore __newloc(locale);
80 return ::strtold(__nptr, __endptr);
81}
82
83inline _LIBCPP_HIDE_FROM_ABI unsigned long long
84strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
85 __setAndRestore __newloc(locale);
86 return ::strtoull(__nptr, __endptr, __base);
87}
88
89inline _LIBCPP_HIDE_FROM_ABI unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
90 __setAndRestore __newloc(locale);
91 return ::strtoul(__nptr, __endptr, __base);
92}
93
94inline _LIBCPP_HIDE_FROM_ABI int vasprintf(char** strp, const char* fmt, va_list ap) {
95 const size_t buff_size = 256;
96 if ((*strp = (char*)malloc(buff_size)) == NULL) {
97 return -1;
98 }
99
100 va_list ap_copy;
101 // va_copy may not be provided by the C library in C++ 03 mode.
102#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
103 __builtin_va_copy(ap_copy, ap);
104#else
105 va_copy(ap_copy, ap);
106#endif
107 int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
108 va_end(ap_copy);
109
110 if ((size_t)str_size >= buff_size) {
111 if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
112 return -1;
113 }
114 str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
115 }
116 return str_size;
117}
118
119#ifdef __cplusplus
120}
121#endif
122#endif // _LIBCPP___SUPPORT_IBM_XLOCALE_H
lib/libcxx/include/__support/musl/xlocale.h deleted-53
......@@ -1,53 +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___SUPPORT_MUSL_XLOCALE_H
18#define _LIBCPP___SUPPORT_MUSL_XLOCALE_H
19
20#include <cstdlib>
21#include <cwchar>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
28 return ::strtoll(__nptr, __endptr, __base);
29}
30
31inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
32strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
33 return ::strtoull(__nptr, __endptr, __base);
34}
35
36inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
37 return ::wcstoll(__nptr, __endptr, __base);
38}
39
40inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
41wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
42 return ::wcstoull(__nptr, __endptr, __base);
43}
44
45inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
46 return ::wcstold(__nptr, __endptr);
47}
48
49#ifdef __cplusplus
50}
51#endif
52
53#endif // _LIBCPP___SUPPORT_MUSL_XLOCALE_H
lib/libcxx/include/__support/newlib/xlocale.h deleted-22
......@@ -1,22 +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___SUPPORT_NEWLIB_XLOCALE_H
10#define _LIBCPP___SUPPORT_NEWLIB_XLOCALE_H
11
12#if defined(_NEWLIB_VERSION)
13
14# if !defined(__NEWLIB__) || __NEWLIB__ < 2 || __NEWLIB__ == 2 && __NEWLIB_MINOR__ < 5
15# include <__support/xlocale/__nop_locale_mgmt.h>
16# include <__support/xlocale/__posix_l_fallback.h>
17# include <__support/xlocale/__strtonum_fallback.h>
18# endif
19
20#endif // _NEWLIB_VERSION
21
22#endif
lib/libcxx/include/__support/openbsd/xlocale.h deleted-35
......@@ -1,35 +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_OPENBSD_XLOCALE_H
11#define _LIBCPP___SUPPORT_OPENBSD_XLOCALE_H
12
13#include <__support/xlocale/__strtonum_fallback.h>
14#include <clocale>
15#include <cstdlib>
16#include <ctype.h>
17#include <cwctype>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23inline _LIBCPP_HIDE_FROM_ABI_C long strtol_l(const char* __nptr, char** __endptr, int __base, locale_t) {
24 return ::strtol(__nptr, __endptr, __base);
25}
26
27inline _LIBCPP_HIDE_FROM_ABI_C unsigned long strtoul_l(const char* __nptr, char** __endptr, int __base, locale_t) {
28 return ::strtoul(__nptr, __endptr, __base);
29}
30
31#ifdef __cplusplus
32}
33#endif
34
35#endif
lib/libcxx/include/__support/win32/locale_win32.h deleted-239
......@@ -1,239 +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_WIN32_LOCALE_WIN32_H
11#define _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
12
13#include <__config>
14#include <cstddef>
15#include <locale.h> // _locale_t
16#include <stdio.h>
17#include <string>
18
19#define _X_ALL LC_ALL
20#define _X_COLLATE LC_COLLATE
21#define _X_CTYPE LC_CTYPE
22#define _X_MONETARY LC_MONETARY
23#define _X_NUMERIC LC_NUMERIC
24#define _X_TIME LC_TIME
25#define _X_MAX LC_MAX
26#define _X_MESSAGES 6
27#define _NCAT (_X_MESSAGES + 1)
28
29#define _CATMASK(n) ((1 << (n)) >> 1)
30#define _M_COLLATE _CATMASK(_X_COLLATE)
31#define _M_CTYPE _CATMASK(_X_CTYPE)
32#define _M_MONETARY _CATMASK(_X_MONETARY)
33#define _M_NUMERIC _CATMASK(_X_NUMERIC)
34#define _M_TIME _CATMASK(_X_TIME)
35#define _M_MESSAGES _CATMASK(_X_MESSAGES)
36#define _M_ALL (_CATMASK(_NCAT) - 1)
37
38#define LC_COLLATE_MASK _M_COLLATE
39#define LC_CTYPE_MASK _M_CTYPE
40#define LC_MONETARY_MASK _M_MONETARY
41#define LC_NUMERIC_MASK _M_NUMERIC
42#define LC_TIME_MASK _M_TIME
43#define LC_MESSAGES_MASK _M_MESSAGES
44#define LC_ALL_MASK \
45 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
46
47class __lconv_storage {
48public:
49 __lconv_storage(const lconv* __lc_input) {
50 __lc_ = *__lc_input;
51
52 __decimal_point_ = __lc_input->decimal_point;
53 __thousands_sep_ = __lc_input->thousands_sep;
54 __grouping_ = __lc_input->grouping;
55 __int_curr_symbol_ = __lc_input->int_curr_symbol;
56 __currency_symbol_ = __lc_input->currency_symbol;
57 __mon_decimal_point_ = __lc_input->mon_decimal_point;
58 __mon_thousands_sep_ = __lc_input->mon_thousands_sep;
59 __mon_grouping_ = __lc_input->mon_grouping;
60 __positive_sign_ = __lc_input->positive_sign;
61 __negative_sign_ = __lc_input->negative_sign;
62
63 __lc_.decimal_point = const_cast<char*>(__decimal_point_.c_str());
64 __lc_.thousands_sep = const_cast<char*>(__thousands_sep_.c_str());
65 __lc_.grouping = const_cast<char*>(__grouping_.c_str());
66 __lc_.int_curr_symbol = const_cast<char*>(__int_curr_symbol_.c_str());
67 __lc_.currency_symbol = const_cast<char*>(__currency_symbol_.c_str());
68 __lc_.mon_decimal_point = const_cast<char*>(__mon_decimal_point_.c_str());
69 __lc_.mon_thousands_sep = const_cast<char*>(__mon_thousands_sep_.c_str());
70 __lc_.mon_grouping = const_cast<char*>(__mon_grouping_.c_str());
71 __lc_.positive_sign = const_cast<char*>(__positive_sign_.c_str());
72 __lc_.negative_sign = const_cast<char*>(__negative_sign_.c_str());
73 }
74
75 lconv* __get() { return &__lc_; }
76
77private:
78 lconv __lc_;
79 std::string __decimal_point_;
80 std::string __thousands_sep_;
81 std::string __grouping_;
82 std::string __int_curr_symbol_;
83 std::string __currency_symbol_;
84 std::string __mon_decimal_point_;
85 std::string __mon_thousands_sep_;
86 std::string __mon_grouping_;
87 std::string __positive_sign_;
88 std::string __negative_sign_;
89};
90
91class locale_t {
92public:
93 locale_t() : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
94 locale_t(std::nullptr_t) : __locale_(nullptr), __locale_str_(nullptr), __lc_(nullptr) {}
95 locale_t(_locale_t __xlocale, const char* __xlocale_str)
96 : __locale_(__xlocale), __locale_str_(__xlocale_str), __lc_(nullptr) {}
97 locale_t(const locale_t& __l) : __locale_(__l.__locale_), __locale_str_(__l.__locale_str_), __lc_(nullptr) {}
98
99 ~locale_t() { delete __lc_; }
100
101 locale_t& operator=(const locale_t& __l) {
102 __locale_ = __l.__locale_;
103 __locale_str_ = __l.__locale_str_;
104 // __lc_ not copied
105 return *this;
106 }
107
108 friend bool operator==(const locale_t& __left, const locale_t& __right) {
109 return __left.__locale_ == __right.__locale_;
110 }
111
112 friend bool operator==(const locale_t& __left, int __right) { return __left.__locale_ == nullptr && __right == 0; }
113
114 friend bool operator==(const locale_t& __left, long long __right) {
115 return __left.__locale_ == nullptr && __right == 0;
116 }
117
118 friend bool operator==(const locale_t& __left, std::nullptr_t) { return __left.__locale_ == nullptr; }
119
120 friend bool operator==(int __left, const locale_t& __right) { return __left == 0 && nullptr == __right.__locale_; }
121
122 friend bool operator==(std::nullptr_t, const locale_t& __right) { return nullptr == __right.__locale_; }
123
124 friend bool operator!=(const locale_t& __left, const locale_t& __right) { return !(__left == __right); }
125
126 friend bool operator!=(const locale_t& __left, int __right) { return !(__left == __right); }
127
128 friend bool operator!=(const locale_t& __left, long long __right) { return !(__left == __right); }
129
130 friend bool operator!=(const locale_t& __left, std::nullptr_t __right) { return !(__left == __right); }
131
132 friend bool operator!=(int __left, const locale_t& __right) { return !(__left == __right); }
133
134 friend bool operator!=(std::nullptr_t __left, const locale_t& __right) { return !(__left == __right); }
135
136 operator bool() const { return __locale_ != nullptr; }
137
138 const char* __get_locale() const { return __locale_str_; }
139
140 operator _locale_t() const { return __locale_; }
141
142 lconv* __store_lconv(const lconv* __input_lc) {
143 delete __lc_;
144 __lc_ = new __lconv_storage(__input_lc);
145 return __lc_->__get();
146 }
147
148private:
149 _locale_t __locale_;
150 const char* __locale_str_;
151 __lconv_storage* __lc_ = nullptr;
152};
153
154// Locale management functions
155#define freelocale _free_locale
156// FIXME: base currently unused. Needs manual work to construct the new locale
157locale_t newlocale(int __mask, const char* __locale, locale_t __base);
158// uselocale can't be implemented on Windows because Windows allows partial modification
159// of thread-local locale and so _get_current_locale() returns a copy while uselocale does
160// not create any copies.
161// We can still implement raii even without uselocale though.
162
163lconv* localeconv_l(locale_t& __loc);
164size_t mbrlen_l(const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
165size_t mbsrtowcs_l(
166 wchar_t* __restrict __dst, const char** __restrict __src, size_t __len, mbstate_t* __restrict __ps, locale_t __loc);
167size_t wcrtomb_l(char* __restrict __s, wchar_t __wc, mbstate_t* __restrict __ps, locale_t __loc);
168size_t mbrtowc_l(
169 wchar_t* __restrict __pwc, const char* __restrict __s, size_t __n, mbstate_t* __restrict __ps, locale_t __loc);
170size_t mbsnrtowcs_l(wchar_t* __restrict __dst,
171 const char** __restrict __src,
172 size_t __nms,
173 size_t __len,
174 mbstate_t* __restrict __ps,
175 locale_t __loc);
176size_t wcsnrtombs_l(char* __restrict __dst,
177 const wchar_t** __restrict __src,
178 size_t __nwc,
179 size_t __len,
180 mbstate_t* __restrict __ps,
181 locale_t __loc);
182wint_t btowc_l(int __c, locale_t __loc);
183int wctob_l(wint_t __c, locale_t __loc);
184
185decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l);
186
187// the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
188#define mbtowc_l _mbtowc_l
189#define strtoll_l _strtoi64_l
190#define strtoull_l _strtoui64_l
191#define strtod_l _strtod_l
192#if defined(_LIBCPP_MSVCRT)
193# define strtof_l _strtof_l
194# define strtold_l _strtold_l
195#else
196_LIBCPP_EXPORTED_FROM_ABI float strtof_l(const char*, char**, locale_t);
197_LIBCPP_EXPORTED_FROM_ABI long double strtold_l(const char*, char**, locale_t);
198#endif
199inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, _locale_t __loc) { return _islower_l((int)__c, __loc); }
200
201inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, _locale_t __loc) { return _isupper_l((int)__c, __loc); }
202
203#define isdigit_l _isdigit_l
204#define isxdigit_l _isxdigit_l
205#define strcoll_l _strcoll_l
206#define strxfrm_l _strxfrm_l
207#define wcscoll_l _wcscoll_l
208#define wcsxfrm_l _wcsxfrm_l
209#define toupper_l _toupper_l
210#define tolower_l _tolower_l
211#define iswspace_l _iswspace_l
212#define iswprint_l _iswprint_l
213#define iswcntrl_l _iswcntrl_l
214#define iswupper_l _iswupper_l
215#define iswlower_l _iswlower_l
216#define iswalpha_l _iswalpha_l
217#define iswdigit_l _iswdigit_l
218#define iswpunct_l _iswpunct_l
219#define iswxdigit_l _iswxdigit_l
220#define towupper_l _towupper_l
221#define towlower_l _towlower_l
222#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
223_LIBCPP_EXPORTED_FROM_ABI size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc);
224#else
225# define strftime_l _strftime_l
226#endif
227#define sscanf_l(__s, __l, __f, ...) _sscanf_l(__s, __f, __l, __VA_ARGS__)
228#define sprintf_l(__s, __l, __f, ...) _sprintf_l(__s, __f, __l, __VA_ARGS__)
229#define vsprintf_l(__s, __l, __f, ...) _vsprintf_l(__s, __f, __l, __VA_ARGS__)
230#define vsnprintf_l(__s, __n, __l, __f, ...) _vsnprintf_l(__s, __n, __f, __l, __VA_ARGS__)
231_LIBCPP_EXPORTED_FROM_ABI int snprintf_l(char* __ret, size_t __n, locale_t __loc, const char* __format, ...);
232_LIBCPP_EXPORTED_FROM_ABI int asprintf_l(char** __ret, locale_t __loc, const char* __format, ...);
233_LIBCPP_EXPORTED_FROM_ABI int vasprintf_l(char** __ret, locale_t __loc, const char* __format, va_list __ap);
234
235// not-so-pressing FIXME: use locale to determine blank characters
236inline int isblank_l(int __c, locale_t /*loc*/) { return (__c == ' ' || __c == '\t'); }
237inline int iswblank_l(wint_t __c, locale_t /*loc*/) { return (__c == L' ' || __c == L'\t'); }
238
239#endif // _LIBCPP___SUPPORT_WIN32_LOCALE_WIN32_H
lib/libcxx/include/__support/xlocale/__nop_locale_mgmt.h+4-12
......@@ -12,20 +12,16 @@
1212
1313#include <__config>
1414
15#ifdef __cplusplus
16extern "C" {
17#endif
18
1915// Patch over lack of extended locale support
2016typedef void* locale_t;
2117
22inline _LIBCPP_HIDE_FROM_ABI_C locale_t duplocale(locale_t) { return NULL; }
18inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }
2319
24inline _LIBCPP_HIDE_FROM_ABI_C void freelocale(locale_t) {}
20inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
2521
26inline _LIBCPP_HIDE_FROM_ABI_C locale_t newlocale(int, const char*, locale_t) { return NULL; }
22inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }
2723
28inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; }
24inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }
2925
3026#define LC_COLLATE_MASK (1 << LC_COLLATE)
3127#define LC_CTYPE_MASK (1 << LC_CTYPE)
......@@ -36,8 +32,4 @@ inline _LIBCPP_HIDE_FROM_ABI_C locale_t uselocale(locale_t) { return NULL; }
3632#define LC_ALL_MASK \
3733 (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK | LC_MESSAGES_MASK)
3834
39#ifdef __cplusplus
40} // extern "C"
41#endif
42
4335#endif // _LIBCPP___SUPPORT_XLOCALE_NOP_LOCALE_MGMT_H
lib/libcxx/include/__support/xlocale/__posix_l_fallback.h+34-42
......@@ -17,99 +17,91 @@
1717
1818#include <__config>
1919#include <ctype.h>
20#include <string.h>
2021#include <time.h>
2122
2223#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
24# include <wchar.h>
2325# include <wctype.h>
2426#endif
2527
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30inline _LIBCPP_HIDE_FROM_ABI_C int isalnum_l(int __c, locale_t) { return ::isalnum(__c); }
31
32inline _LIBCPP_HIDE_FROM_ABI_C int isalpha_l(int __c, locale_t) { return ::isalpha(__c); }
28inline _LIBCPP_HIDE_FROM_ABI int isalnum_l(int __c, locale_t) { return ::isalnum(__c); }
3329
34inline _LIBCPP_HIDE_FROM_ABI_C int isblank_l(int __c, locale_t) { return ::isblank(__c); }
30inline _LIBCPP_HIDE_FROM_ABI int isalpha_l(int __c, locale_t) { return ::isalpha(__c); }
3531
36inline _LIBCPP_HIDE_FROM_ABI_C int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }
32inline _LIBCPP_HIDE_FROM_ABI int iscntrl_l(int __c, locale_t) { return ::iscntrl(__c); }
3733
38inline _LIBCPP_HIDE_FROM_ABI_C int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }
34inline _LIBCPP_HIDE_FROM_ABI int isdigit_l(int __c, locale_t) { return ::isdigit(__c); }
3935
40inline _LIBCPP_HIDE_FROM_ABI_C int isgraph_l(int __c, locale_t) { return ::isgraph(__c); }
36inline _LIBCPP_HIDE_FROM_ABI int isgraph_l(int __c, locale_t) { return ::isgraph(__c); }
4137
42inline _LIBCPP_HIDE_FROM_ABI_C int islower_l(int __c, locale_t) { return ::islower(__c); }
38inline _LIBCPP_HIDE_FROM_ABI int islower_l(int __c, locale_t) { return ::islower(__c); }
4339
44inline _LIBCPP_HIDE_FROM_ABI_C int isprint_l(int __c, locale_t) { return ::isprint(__c); }
40inline _LIBCPP_HIDE_FROM_ABI int isprint_l(int __c, locale_t) { return ::isprint(__c); }
4541
46inline _LIBCPP_HIDE_FROM_ABI_C int ispunct_l(int __c, locale_t) { return ::ispunct(__c); }
42inline _LIBCPP_HIDE_FROM_ABI int ispunct_l(int __c, locale_t) { return ::ispunct(__c); }
4743
48inline _LIBCPP_HIDE_FROM_ABI_C int isspace_l(int __c, locale_t) { return ::isspace(__c); }
44inline _LIBCPP_HIDE_FROM_ABI int isspace_l(int __c, locale_t) { return ::isspace(__c); }
4945
50inline _LIBCPP_HIDE_FROM_ABI_C int isupper_l(int __c, locale_t) { return ::isupper(__c); }
46inline _LIBCPP_HIDE_FROM_ABI int isupper_l(int __c, locale_t) { return ::isupper(__c); }
5147
52inline _LIBCPP_HIDE_FROM_ABI_C int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); }
48inline _LIBCPP_HIDE_FROM_ABI int isxdigit_l(int __c, locale_t) { return ::isxdigit(__c); }
5349
54inline _LIBCPP_HIDE_FROM_ABI_C int toupper_l(int __c, locale_t) { return ::toupper(__c); }
50inline _LIBCPP_HIDE_FROM_ABI int toupper_l(int __c, locale_t) { return ::toupper(__c); }
5551
56inline _LIBCPP_HIDE_FROM_ABI_C int tolower_l(int __c, locale_t) { return ::tolower(__c); }
52inline _LIBCPP_HIDE_FROM_ABI int tolower_l(int __c, locale_t) { return ::tolower(__c); }
5753
5854#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
59inline _LIBCPP_HIDE_FROM_ABI_C int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); }
55inline _LIBCPP_HIDE_FROM_ABI int iswalnum_l(wint_t __c, locale_t) { return ::iswalnum(__c); }
6056
61inline _LIBCPP_HIDE_FROM_ABI_C int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); }
57inline _LIBCPP_HIDE_FROM_ABI int iswalpha_l(wint_t __c, locale_t) { return ::iswalpha(__c); }
6258
63inline _LIBCPP_HIDE_FROM_ABI_C int iswblank_l(wint_t __c, locale_t) { return ::iswblank(__c); }
59inline _LIBCPP_HIDE_FROM_ABI int iswblank_l(wint_t __c, locale_t) { return ::iswblank(__c); }
6460
65inline _LIBCPP_HIDE_FROM_ABI_C int iswcntrl_l(wint_t __c, locale_t) { return ::iswcntrl(__c); }
61inline _LIBCPP_HIDE_FROM_ABI int iswcntrl_l(wint_t __c, locale_t) { return ::iswcntrl(__c); }
6662
67inline _LIBCPP_HIDE_FROM_ABI_C int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); }
63inline _LIBCPP_HIDE_FROM_ABI int iswdigit_l(wint_t __c, locale_t) { return ::iswdigit(__c); }
6864
69inline _LIBCPP_HIDE_FROM_ABI_C int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); }
65inline _LIBCPP_HIDE_FROM_ABI int iswgraph_l(wint_t __c, locale_t) { return ::iswgraph(__c); }
7066
71inline _LIBCPP_HIDE_FROM_ABI_C int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); }
67inline _LIBCPP_HIDE_FROM_ABI int iswlower_l(wint_t __c, locale_t) { return ::iswlower(__c); }
7268
73inline _LIBCPP_HIDE_FROM_ABI_C int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); }
69inline _LIBCPP_HIDE_FROM_ABI int iswprint_l(wint_t __c, locale_t) { return ::iswprint(__c); }
7470
75inline _LIBCPP_HIDE_FROM_ABI_C int iswpunct_l(wint_t __c, locale_t) { return ::iswpunct(__c); }
71inline _LIBCPP_HIDE_FROM_ABI int iswpunct_l(wint_t __c, locale_t) { return ::iswpunct(__c); }
7672
77inline _LIBCPP_HIDE_FROM_ABI_C int iswspace_l(wint_t __c, locale_t) { return ::iswspace(__c); }
73inline _LIBCPP_HIDE_FROM_ABI int iswspace_l(wint_t __c, locale_t) { return ::iswspace(__c); }
7874
79inline _LIBCPP_HIDE_FROM_ABI_C int iswupper_l(wint_t __c, locale_t) { return ::iswupper(__c); }
75inline _LIBCPP_HIDE_FROM_ABI int iswupper_l(wint_t __c, locale_t) { return ::iswupper(__c); }
8076
81inline _LIBCPP_HIDE_FROM_ABI_C int iswxdigit_l(wint_t __c, locale_t) { return ::iswxdigit(__c); }
77inline _LIBCPP_HIDE_FROM_ABI int iswxdigit_l(wint_t __c, locale_t) { return ::iswxdigit(__c); }
8278
83inline _LIBCPP_HIDE_FROM_ABI_C wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); }
79inline _LIBCPP_HIDE_FROM_ABI wint_t towupper_l(wint_t __c, locale_t) { return ::towupper(__c); }
8480
85inline _LIBCPP_HIDE_FROM_ABI_C wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); }
81inline _LIBCPP_HIDE_FROM_ABI wint_t towlower_l(wint_t __c, locale_t) { return ::towlower(__c); }
8682#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
8783
88inline _LIBCPP_HIDE_FROM_ABI_C int strcoll_l(const char* __s1, const char* __s2, locale_t) {
84inline _LIBCPP_HIDE_FROM_ABI int strcoll_l(const char* __s1, const char* __s2, locale_t) {
8985 return ::strcoll(__s1, __s2);
9086}
9187
92inline _LIBCPP_HIDE_FROM_ABI_C size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t) {
88inline _LIBCPP_HIDE_FROM_ABI size_t strxfrm_l(char* __dest, const char* __src, size_t __n, locale_t) {
9389 return ::strxfrm(__dest, __src, __n);
9490}
9591
96inline _LIBCPP_HIDE_FROM_ABI_C size_t
92inline _LIBCPP_HIDE_FROM_ABI size_t
9793strftime_l(char* __s, size_t __max, const char* __format, const struct tm* __tm, locale_t) {
9894 return ::strftime(__s, __max, __format, __tm);
9995}
10096
10197#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
102inline _LIBCPP_HIDE_FROM_ABI_C int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) {
98inline _LIBCPP_HIDE_FROM_ABI int wcscoll_l(const wchar_t* __ws1, const wchar_t* __ws2, locale_t) {
10399 return ::wcscoll(__ws1, __ws2);
104100}
105101
106inline _LIBCPP_HIDE_FROM_ABI_C size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) {
102inline _LIBCPP_HIDE_FROM_ABI size_t wcsxfrm_l(wchar_t* __dest, const wchar_t* __src, size_t __n, locale_t) {
107103 return ::wcsxfrm(__dest, __src, __n);
108104}
109105#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
110106
111#ifdef __cplusplus
112}
113#endif
114
115107#endif // _LIBCPP___SUPPORT_XLOCALE_POSIX_L_FALLBACK_H
lib/libcxx/include/__support/xlocale/__strtonum_fallback.h+5-29
......@@ -22,48 +22,24 @@
2222# include <wchar.h>
2323#endif
2424
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29inline _LIBCPP_HIDE_FROM_ABI_C float strtof_l(const char* __nptr, char** __endptr, locale_t) {
25inline _LIBCPP_HIDE_FROM_ABI float strtof_l(const char* __nptr, char** __endptr, locale_t) {
3026 return ::strtof(__nptr, __endptr);
3127}
3228
33inline _LIBCPP_HIDE_FROM_ABI_C double strtod_l(const char* __nptr, char** __endptr, locale_t) {
29inline _LIBCPP_HIDE_FROM_ABI double strtod_l(const char* __nptr, char** __endptr, locale_t) {
3430 return ::strtod(__nptr, __endptr);
3531}
3632
37inline _LIBCPP_HIDE_FROM_ABI_C long double strtold_l(const char* __nptr, char** __endptr, locale_t) {
33inline _LIBCPP_HIDE_FROM_ABI long double strtold_l(const char* __nptr, char** __endptr, locale_t) {
3834 return ::strtold(__nptr, __endptr);
3935}
4036
41inline _LIBCPP_HIDE_FROM_ABI_C long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
37inline _LIBCPP_HIDE_FROM_ABI long long strtoll_l(const char* __nptr, char** __endptr, int __base, locale_t) {
4238 return ::strtoll(__nptr, __endptr, __base);
4339}
4440
45inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
46strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
41inline _LIBCPP_HIDE_FROM_ABI unsigned long long strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t) {
4742 return ::strtoull(__nptr, __endptr, __base);
4843}
4944
50#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
51inline _LIBCPP_HIDE_FROM_ABI_C long long wcstoll_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
52 return ::wcstoll(__nptr, __endptr, __base);
53}
54
55inline _LIBCPP_HIDE_FROM_ABI_C unsigned long long
56wcstoull_l(const wchar_t* __nptr, wchar_t** __endptr, int __base, locale_t) {
57 return ::wcstoull(__nptr, __endptr, __base);
58}
59
60inline _LIBCPP_HIDE_FROM_ABI_C long double wcstold_l(const wchar_t* __nptr, wchar_t** __endptr, locale_t) {
61 return ::wcstold(__nptr, __endptr);
62}
63#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
64
65#ifdef __cplusplus
66}
67#endif
68
6945#endif // _LIBCPP___SUPPORT_XLOCALE_STRTONUM_FALLBACK_H
lib/libcxx/include/__system_error/errc.h+63-12
......@@ -58,18 +58,18 @@ enum class errc
5858 no_child_process, // ECHILD
5959 no_link, // ENOLINK
6060 no_lock_available, // ENOLCK
61 no_message_available, // ENODATA
61 no_message_available, // ENODATA // deprecated
6262 no_message, // ENOMSG
6363 no_protocol_option, // ENOPROTOOPT
6464 no_space_on_device, // ENOSPC
65 no_stream_resources, // ENOSR
65 no_stream_resources, // ENOSR // deprecated
6666 no_such_device_or_address, // ENXIO
6767 no_such_device, // ENODEV
6868 no_such_file_or_directory, // ENOENT
6969 no_such_process, // ESRCH
7070 not_a_directory, // ENOTDIR
7171 not_a_socket, // ENOTSOCK
72 not_a_stream, // ENOSTR
72 not_a_stream, // ENOSTR // deprecated
7373 not_connected, // ENOTCONN
7474 not_enough_memory, // ENOMEM
7575 not_supported, // ENOTSUP
......@@ -87,7 +87,7 @@ enum class errc
8787 resource_unavailable_try_again, // EAGAIN
8888 result_out_of_range, // ERANGE
8989 state_not_recoverable, // ENOTRECOVERABLE
90 stream_timeout, // ETIME
90 stream_timeout, // ETIME // deprecated
9191 text_file_busy, // ETXTBSY
9292 timed_out, // ETIMEDOUT
9393 too_many_files_open_in_system, // ENFILE
......@@ -107,12 +107,39 @@ enum class errc
107107# pragma GCC system_header
108108#endif
109109
110// The method of pushing and popping the diagnostics fails for GCC. GCC does
111// not recognize the pragma's used to generate deprecated diagnostics for
112// macros. So GCC does not need the pushing and popping.
113//
114// TODO Remove this when the deprecated constants are removed.
115//
116// Note based on the post-review comments in
117// https://github.com/llvm/llvm-project/pull/80542 libc++ no longer deprecates
118// the macros. Since C libraries may start to deprecate these POSIX macros the
119// deprecation warning avoidance is kept.
120#if defined(_LIBCPP_COMPILER_CLANG_BASED)
121# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH _LIBCPP_SUPPRESS_DEPRECATED_PUSH
122# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP _LIBCPP_SUPPRESS_DEPRECATED_POP
123#else
124# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
125# define _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
126#endif
127
110128_LIBCPP_BEGIN_NAMESPACE_STD
111129
112130// Some error codes are not present on all platforms, so we provide equivalents
113131// for them:
114132
115133// enum class errc
134//
135// LWG3869 deprecates the UNIX STREAMS macros and enum values.
136// This makes the code clumbersome:
137// - the enum value is deprecated and should show a diagnostic,
138// - the macro is deprecated and should _not_ show a diagnostic in this
139// context, and
140// - the macro is not always available.
141// This leads to the odd pushing and popping of the deprecated
142// diagnostic.
116143_LIBCPP_DECLARE_STRONG_ENUM(errc){
117144 address_family_not_supported = EAFNOSUPPORT,
118145 address_in_use = EADDRINUSE,
......@@ -154,30 +181,48 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
154181 no_child_process = ECHILD,
155182 no_link = ENOLINK,
156183 no_lock_available = ENOLCK,
184 // clang-format off
185 no_message_available _LIBCPP_DEPRECATED =
186 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
157187#ifdef ENODATA
158 no_message_available = ENODATA,
188 ENODATA
159189#else
160 no_message_available = ENOMSG,
190 ENOMSG
161191#endif
192 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
193 ,
194 // clang-format on
162195 no_message = ENOMSG,
163196 no_protocol_option = ENOPROTOOPT,
164197 no_space_on_device = ENOSPC,
198 // clang-format off
199 no_stream_resources _LIBCPP_DEPRECATED =
200 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
165201#ifdef ENOSR
166 no_stream_resources = ENOSR,
202 ENOSR
167203#else
168 no_stream_resources = ENOMEM,
204 ENOMEM
169205#endif
206 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
207 ,
208 // clang-format on
170209 no_such_device_or_address = ENXIO,
171210 no_such_device = ENODEV,
172211 no_such_file_or_directory = ENOENT,
173212 no_such_process = ESRCH,
174213 not_a_directory = ENOTDIR,
175214 not_a_socket = ENOTSOCK,
215 // clang-format off
216 not_a_stream _LIBCPP_DEPRECATED =
217 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
176218#ifdef ENOSTR
177 not_a_stream = ENOSTR,
219 ENOSTR
178220#else
179 not_a_stream = EINVAL,
221 EINVAL
180222#endif
223 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
224 ,
225 // clang-format on
181226 not_connected = ENOTCONN,
182227 not_enough_memory = ENOMEM,
183228 not_supported = ENOTSUP,
......@@ -195,11 +240,17 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc){
195240 resource_unavailable_try_again = EAGAIN,
196241 result_out_of_range = ERANGE,
197242 state_not_recoverable = ENOTRECOVERABLE,
243 // clang-format off
244 stream_timeout _LIBCPP_DEPRECATED =
245 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_PUSH
198246#ifdef ETIME
199 stream_timeout = ETIME,
247 ETIME
200248#else
201 stream_timeout = ETIMEDOUT,
249 ETIMEDOUT
202250#endif
251 _LIBCPP_SUPPRESS_DEPRECATED_ERRC_POP
252 ,
253 // clang-format on
203254 text_file_busy = ETXTBSY,
204255 timed_out = ETIMEDOUT,
205256 too_many_files_open_in_system = ENFILE,
lib/libcxx/include/__system_error/error_category.h+2-2
......@@ -67,8 +67,8 @@ public:
6767 string message(int __ev) const override;
6868};
6969
70_LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
71_LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
70__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& generic_category() _NOEXCEPT;
71__attribute__((__const__)) _LIBCPP_EXPORTED_FROM_ABI const error_category& system_category() _NOEXCEPT;
7272
7373_LIBCPP_END_NAMESPACE_STD
7474
lib/libcxx/include/__thread/formatter.h+1-1
......@@ -43,7 +43,7 @@ public:
4343
4444 template <class _FormatContext>
4545 _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator format(__thread_id __id, _FormatContext& __ctx) const {
46 // In __threading_support __libcpp_thread_id is either a
46 // In __thread/support/pthread.h, __libcpp_thread_id is either a
4747 // unsigned long long or a pthread_t.
4848 //
4949 // The type of pthread_t is left unspecified in POSIX so it can be any
lib/libcxx/include/__thread/id.h+2-2
......@@ -12,9 +12,9 @@
1212
1313#include <__compare/ordering.h>
1414#include <__config>
15#include <__fwd/hash.h>
15#include <__fwd/functional.h>
1616#include <__fwd/ostream.h>
17#include <__threading_support>
17#include <__thread/support.h>
1818
1919#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2020# pragma GCC system_header
lib/libcxx/include/__thread/jthread.h+1-2
......@@ -10,13 +10,12 @@
1010#ifndef _LIBCPP___THREAD_JTHREAD_H
1111#define _LIBCPP___THREAD_JTHREAD_H
1212
13#include <__availability>
1413#include <__config>
1514#include <__functional/invoke.h>
1615#include <__stop_token/stop_source.h>
1716#include <__stop_token/stop_token.h>
17#include <__thread/support.h>
1818#include <__thread/thread.h>
19#include <__threading_support>
2019#include <__type_traits/decay.h>
2120#include <__type_traits/is_constructible.h>
2221#include <__type_traits/is_same.h>
lib/libcxx/include/__thread/poll_with_backoff.h+8-9
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1111#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1212
13#include <__availability>
1413#include <__chrono/duration.h>
1514#include <__chrono/high_resolution_clock.h>
1615#include <__config>
......@@ -26,21 +25,21 @@ static _LIBCPP_CONSTEXPR const int __libcpp_polling_count = 64;
2625// Polls a thread for a condition given by a predicate, and backs off based on a backoff policy
2726// before polling again.
2827//
29// - __f is the "test function" that should return true if polling succeeded, and false if it failed.
28// - __poll is the "test function" that should return true if polling succeeded, and false if it failed.
3029//
31// - __bf is the "backoff policy", which is called with the duration since we started polling. It should
30// - __backoff is the "backoff policy", which is called with the duration since we started polling. It should
3231// return false in order to resume polling, and true if polling should stop entirely for some reason.
3332// In general, backoff policies sleep for some time before returning control to the polling loop.
3433//
3534// - __max_elapsed is the maximum duration to try polling for. If the maximum duration is exceeded,
3635// the polling loop will return false to report a timeout.
37template <class _Fn, class _BFn>
36template <class _Poll, class _Backoff>
3837_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_backoff(
39 _Fn&& __f, _BFn&& __bf, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
38 _Poll&& __poll, _Backoff&& __backoff, chrono::nanoseconds __max_elapsed = chrono::nanoseconds::zero()) {
4039 auto const __start = chrono::high_resolution_clock::now();
4140 for (int __count = 0;;) {
42 if (__f())
43 return true; // _Fn completion means success
41 if (__poll())
42 return true; // __poll completion means success
4443 if (__count < __libcpp_polling_count) {
4544 __count += 1;
4645 continue;
......@@ -48,8 +47,8 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_poll_with_b
4847 chrono::nanoseconds const __elapsed = chrono::high_resolution_clock::now() - __start;
4948 if (__max_elapsed != chrono::nanoseconds::zero() && __max_elapsed < __elapsed)
5049 return false; // timeout failure
51 if (__bf(__elapsed))
52 return false; // _BFn completion means failure
50 if (__backoff(__elapsed))
51 return false; // __backoff completion means failure
5352 }
5453}
5554
lib/libcxx/include/__thread/support.h created+123
......@@ -0,0 +1,123 @@
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___THREAD_SUPPORT_H
11#define _LIBCPP___THREAD_SUPPORT_H
12
13#include <__config>
14
15#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# pragma GCC system_header
17#endif
18
19/*
20
21//
22// The library supports multiple implementations of the basic threading functionality.
23// The following functionality must be provided by any implementation:
24//
25
26_LIBCPP_BEGIN_NAMESPACE_STD
27
28using __libcpp_timespec_t = ...;
29
30//
31// Mutex
32//
33using __libcpp_mutex_t = ...;
34#define _LIBCPP_MUTEX_INITIALIZER ...
35
36using __libcpp_recursive_mutex_t = ...;
37
38int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t*);
39_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t*);
40_LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t*);
41_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t*);
42int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t*);
43
44_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t*);
45_LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t*);
46_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t*);
47int __libcpp_mutex_destroy(__libcpp_mutex_t*);
48
49//
50// Condition Variable
51//
52using __libcpp_condvar_t = ...;
53#define _LIBCPP_CONDVAR_INITIALIZER ...
54
55int __libcpp_condvar_signal(__libcpp_condvar_t*);
56int __libcpp_condvar_broadcast(__libcpp_condvar_t*);
57_LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t*, __libcpp_mutex_t*);
58_LIBCPP_NO_THREAD_SAFETY_ANALYSIS
59int __libcpp_condvar_timedwait(__libcpp_condvar_t*, __libcpp_mutex_t*, __libcpp_timespec_t*);
60int __libcpp_condvar_destroy(__libcpp_condvar_t*);
61
62//
63// Execute once
64//
65using __libcpp_exec_once_flag = ...;
66#define _LIBCPP_EXEC_ONCE_INITIALIZER ...
67
68int __libcpp_execute_once(__libcpp_exec_once_flag*, void (*__init_routine)());
69
70//
71// Thread id
72//
73using __libcpp_thread_id = ...;
74
75bool __libcpp_thread_id_equal(__libcpp_thread_id, __libcpp_thread_id);
76bool __libcpp_thread_id_less(__libcpp_thread_id, __libcpp_thread_id);
77
78//
79// Thread
80//
81#define _LIBCPP_NULL_THREAD ...
82using __libcpp_thread_t = ...;
83
84bool __libcpp_thread_isnull(const __libcpp_thread_t*);
85int __libcpp_thread_create(__libcpp_thread_t*, void* (*__func)(void*), void* __arg);
86__libcpp_thread_id __libcpp_thread_get_current_id();
87__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t*);
88int __libcpp_thread_join(__libcpp_thread_t*);
89int __libcpp_thread_detach(__libcpp_thread_t*);
90void __libcpp_thread_yield();
91void __libcpp_thread_sleep_for(const chrono::nanoseconds&);
92
93//
94// Thread local storage
95//
96#define _LIBCPP_TLS_DESTRUCTOR_CC ...
97using __libcpp_tls_key = ...;
98
99int __libcpp_tls_create(__libcpp_tls_key*, void (*__at_exit)(void*));
100void* __libcpp_tls_get(__libcpp_tls_key);
101int __libcpp_tls_set(__libcpp_tls_key, void*);
102
103_LIBCPP_END_NAMESPACE_STD
104
105*/
106
107#if !defined(_LIBCPP_HAS_NO_THREADS)
108
109# if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
110# include <__thread/support/external.h>
111# elif defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
112# include <__thread/support/pthread.h>
113# elif defined(_LIBCPP_HAS_THREAD_API_C11)
114# include <__thread/support/c11.h>
115# elif defined(_LIBCPP_HAS_THREAD_API_WIN32)
116# include <__thread/support/windows.h>
117# else
118# error "No threading API was selected"
119# endif
120
121#endif // !_LIBCPP_HAS_NO_THREADS
122
123#endif // _LIBCPP___THREAD_SUPPORT_H
lib/libcxx/include/__thread/support/c11.h created+191
......@@ -0,0 +1,191 @@
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___THREAD_SUPPORT_C11_H
11#define _LIBCPP___THREAD_SUPPORT_C11_H
12
13#include <__chrono/convert_to_timespec.h>
14#include <__chrono/duration.h>
15#include <__config>
16#include <ctime>
17#include <errno.h>
18#include <threads.h>
19
20#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
21# pragma GCC system_header
22#endif
23
24_LIBCPP_BEGIN_NAMESPACE_STD
25
26using __libcpp_timespec_t = ::timespec;
27
28//
29// Mutex
30//
31typedef mtx_t __libcpp_mutex_t;
32// mtx_t is a struct so using {} for initialization is valid.
33#define _LIBCPP_MUTEX_INITIALIZER \
34 {}
35
36typedef mtx_t __libcpp_recursive_mutex_t;
37
38inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) {
39 return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL;
40}
41
42inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
43__libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) {
44 return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
45}
46
47inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool
48__libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) {
49 return mtx_trylock(__m) == thrd_success;
50}
51
52inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
53__libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) {
54 return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
55}
56
57inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) {
58 mtx_destroy(__m);
59 return 0;
60}
61
62inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) {
63 return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
64}
65
66inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) {
67 return mtx_trylock(__m) == thrd_success;
68}
69
70inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) {
71 return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
72}
73
74inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
75 mtx_destroy(__m);
76 return 0;
77}
78
79//
80// Condition Variable
81//
82typedef cnd_t __libcpp_condvar_t;
83// cnd_t is a struct so using {} for initialization is valid.
84#define _LIBCPP_CONDVAR_INITIALIZER \
85 {}
86
87inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) {
88 return cnd_signal(__cv) == thrd_success ? 0 : EINVAL;
89}
90
91inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) {
92 return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL;
93}
94
95inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
96__libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) {
97 return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL;
98}
99
100inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
101__libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) {
102 int __ec = cnd_timedwait(__cv, __m, __ts);
103 return __ec == thrd_timedout ? ETIMEDOUT : __ec;
104}
105
106inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) {
107 cnd_destroy(__cv);
108 return 0;
109}
110
111//
112// Execute once
113//
114typedef ::once_flag __libcpp_exec_once_flag;
115#define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT
116
117inline _LIBCPP_HIDE_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* flag, void (*init_routine)(void)) {
118 ::call_once(flag, init_routine);
119 return 0;
120}
121
122//
123// Thread id
124//
125typedef thrd_t __libcpp_thread_id;
126
127// Returns non-zero if the thread ids are equal, otherwise 0
128inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) {
129 return thrd_equal(t1, t2) != 0;
130}
131
132// Returns non-zero if t1 < t2, otherwise 0
133inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) {
134 return t1 < t2;
135}
136
137//
138// Thread
139//
140#define _LIBCPP_NULL_THREAD 0U
141
142typedef thrd_t __libcpp_thread_t;
143
144inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { return *__t; }
145
146inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) {
147 return __libcpp_thread_get_id(__t) == 0;
148}
149
150inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
151 int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg);
152 return __ec == thrd_nomem ? ENOMEM : __ec;
153}
154
155inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id() { return thrd_current(); }
156
157inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t) {
158 return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL;
159}
160
161inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t) {
162 return thrd_detach(*__t) == thrd_success ? 0 : EINVAL;
163}
164
165inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_yield() { thrd_yield(); }
166
167inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
168 __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns);
169 thrd_sleep(&__ts, nullptr);
170}
171
172//
173// Thread local storage
174//
175#define _LIBCPP_TLS_DESTRUCTOR_CC /* nothing */
176
177typedef tss_t __libcpp_tls_key;
178
179inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) {
180 return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL;
181}
182
183inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key) { return tss_get(__key); }
184
185inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) {
186 return tss_set(__key, __p) == thrd_success ? 0 : EINVAL;
187}
188
189_LIBCPP_END_NAMESPACE_STD
190
191#endif // _LIBCPP___THREAD_SUPPORT_C11_H
lib/libcxx/include/__thread/support/external.h created+21
......@@ -0,0 +1,21 @@
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___THREAD_SUPPORT_EXTERNAL_H
11#define _LIBCPP___THREAD_SUPPORT_EXTERNAL_H
12
13#include <__config>
14
15#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16# pragma GCC system_header
17#endif
18
19#include <__external_threading>
20
21#endif // _LIBCPP___THREAD_SUPPORT_EXTERNAL_H
lib/libcxx/include/__thread/support/pthread.h created+221
......@@ -0,0 +1,221 @@
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___THREAD_SUPPORT_PTHREAD_H
11#define _LIBCPP___THREAD_SUPPORT_PTHREAD_H
12
13#include <__chrono/convert_to_timespec.h>
14#include <__chrono/duration.h>
15#include <__config>
16#include <ctime>
17#include <errno.h>
18#include <pthread.h>
19#include <sched.h>
20
21#ifdef __MVS__
22# include <__support/ibm/nanosleep.h>
23#endif
24
25// Some platforms require <bits/atomic_wide_counter.h> in order for
26// PTHREAD_COND_INITIALIZER to be expanded. Normally that would come
27// in via <pthread.h>, but it's a non-modular header on those platforms,
28// so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the
29// module with <math.h> and makes atomic_wide_counter.h invisible.
30// Include <math.h> here to work around that.
31// This checks wheter a Clang module is built
32#if __building_module(std)
33# include <math.h>
34#endif
35
36#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
37# pragma GCC system_header
38#endif
39
40_LIBCPP_BEGIN_NAMESPACE_STD
41
42using __libcpp_timespec_t = ::timespec;
43
44//
45// Mutex
46//
47typedef pthread_mutex_t __libcpp_mutex_t;
48#define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
49
50typedef pthread_mutex_t __libcpp_recursive_mutex_t;
51
52inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) {
53 pthread_mutexattr_t __attr;
54 int __ec = pthread_mutexattr_init(&__attr);
55 if (__ec)
56 return __ec;
57 __ec = pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE);
58 if (__ec) {
59 pthread_mutexattr_destroy(&__attr);
60 return __ec;
61 }
62 __ec = pthread_mutex_init(__m, &__attr);
63 if (__ec) {
64 pthread_mutexattr_destroy(&__attr);
65 return __ec;
66 }
67 __ec = pthread_mutexattr_destroy(&__attr);
68 if (__ec) {
69 pthread_mutex_destroy(__m);
70 return __ec;
71 }
72 return 0;
73}
74
75inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
76__libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) {
77 return pthread_mutex_lock(__m);
78}
79
80inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool
81__libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) {
82 return pthread_mutex_trylock(__m) == 0;
83}
84
85inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
86__libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) {
87 return pthread_mutex_unlock(__m);
88}
89
90inline _LIBCPP_HIDE_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) {
91 return pthread_mutex_destroy(__m);
92}
93
94inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m) {
95 return pthread_mutex_lock(__m);
96}
97
98inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) {
99 return pthread_mutex_trylock(__m) == 0;
100}
101
102inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) {
103 return pthread_mutex_unlock(__m);
104}
105
106inline _LIBCPP_HIDE_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { return pthread_mutex_destroy(__m); }
107
108//
109// Condition Variable
110//
111typedef pthread_cond_t __libcpp_condvar_t;
112#define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
113
114inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return pthread_cond_signal(__cv); }
115
116inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) {
117 return pthread_cond_broadcast(__cv);
118}
119
120inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
121__libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) {
122 return pthread_cond_wait(__cv, __m);
123}
124
125inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
126__libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) {
127 return pthread_cond_timedwait(__cv, __m, __ts);
128}
129
130inline _LIBCPP_HIDE_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) {
131 return pthread_cond_destroy(__cv);
132}
133
134//
135// Execute once
136//
137typedef pthread_once_t __libcpp_exec_once_flag;
138#define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
139
140inline _LIBCPP_HIDE_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()) {
141 return pthread_once(__flag, __init_routine);
142}
143
144//
145// Thread id
146//
147#if defined(__MVS__)
148typedef unsigned long long __libcpp_thread_id;
149#else
150typedef pthread_t __libcpp_thread_id;
151#endif
152
153// Returns non-zero if the thread ids are equal, otherwise 0
154inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2) {
155 return __t1 == __t2;
156}
157
158// Returns non-zero if t1 < t2, otherwise 0
159inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2) {
160 return __t1 < __t2;
161}
162
163//
164// Thread
165//
166#define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
167typedef pthread_t __libcpp_thread_t;
168
169inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) {
170#if defined(__MVS__)
171 return __t->__;
172#else
173 return *__t;
174#endif
175}
176
177inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) {
178 return __libcpp_thread_get_id(__t) == 0;
179}
180
181inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
182 return pthread_create(__t, nullptr, __func, __arg);
183}
184
185inline _LIBCPP_HIDE_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id() {
186 const __libcpp_thread_t __current_thread = pthread_self();
187 return __libcpp_thread_get_id(&__current_thread);
188}
189
190inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t) { return pthread_join(*__t, nullptr); }
191
192inline _LIBCPP_HIDE_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t) { return pthread_detach(*__t); }
193
194inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_yield() { sched_yield(); }
195
196inline _LIBCPP_HIDE_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
197 __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns);
198 while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
199 ;
200}
201
202//
203// Thread local storage
204//
205#define _LIBCPP_TLS_DESTRUCTOR_CC /* nothing */
206
207typedef pthread_key_t __libcpp_tls_key;
208
209inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) {
210 return pthread_key_create(__key, __at_exit);
211}
212
213inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key) { return pthread_getspecific(__key); }
214
215inline _LIBCPP_HIDE_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) {
216 return pthread_setspecific(__key, __p);
217}
218
219_LIBCPP_END_NAMESPACE_STD
220
221#endif // _LIBCPP___THREAD_SUPPORT_PTHREAD_H
lib/libcxx/include/__thread/support/windows.h created+133
......@@ -0,0 +1,133 @@
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___THREAD_SUPPORT_WINDOWS_H
11#define _LIBCPP___THREAD_SUPPORT_WINDOWS_H
12
13#include <__chrono/duration.h>
14#include <__config>
15#include <ctime>
16
17#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
18# pragma GCC system_header
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23using __libcpp_timespec_t = ::timespec;
24
25//
26// Mutex
27//
28typedef void* __libcpp_mutex_t;
29#define _LIBCPP_MUTEX_INITIALIZER 0
30
31#if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
32typedef void* __libcpp_recursive_mutex_t[6];
33#elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
34typedef void* __libcpp_recursive_mutex_t[5];
35#else
36# error Unsupported architecture
37#endif
38
39_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);
40
41_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
42__libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m);
43
44_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool
45__libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m);
46
47_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
48__libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m);
49
50_LIBCPP_EXPORTED_FROM_ABI int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m);
51
52_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
53
54_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
55
56_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
57
58_LIBCPP_EXPORTED_FROM_ABI int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
59
60//
61// Condition variable
62//
63typedef void* __libcpp_condvar_t;
64#define _LIBCPP_CONDVAR_INITIALIZER 0
65
66_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
67
68_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
69
70_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
71__libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
72
73_LIBCPP_EXPORTED_FROM_ABI _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
74__libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts);
75
76_LIBCPP_EXPORTED_FROM_ABI int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
77
78//
79// Execute once
80//
81typedef void* __libcpp_exec_once_flag;
82#define _LIBCPP_EXEC_ONCE_INITIALIZER 0
83
84_LIBCPP_EXPORTED_FROM_ABI int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)());
85
86//
87// Thread id
88//
89typedef long __libcpp_thread_id;
90
91_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
92
93_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
94
95//
96// Thread
97//
98#define _LIBCPP_NULL_THREAD 0U
99typedef void* __libcpp_thread_t;
100
101_LIBCPP_EXPORTED_FROM_ABI bool __libcpp_thread_isnull(const __libcpp_thread_t* __t);
102
103_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg);
104
105_LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_current_id();
106
107_LIBCPP_EXPORTED_FROM_ABI __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
108
109_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_join(__libcpp_thread_t* __t);
110
111_LIBCPP_EXPORTED_FROM_ABI int __libcpp_thread_detach(__libcpp_thread_t* __t);
112
113_LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_yield();
114
115_LIBCPP_EXPORTED_FROM_ABI void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);
116
117//
118// Thread local storage
119//
120typedef long __libcpp_tls_key;
121
122#define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
123
124_LIBCPP_EXPORTED_FROM_ABI int
125__libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
126
127_LIBCPP_EXPORTED_FROM_ABI void* __libcpp_tls_get(__libcpp_tls_key __key);
128
129_LIBCPP_EXPORTED_FROM_ABI int __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
130
131_LIBCPP_END_NAMESPACE_STD
132
133#endif // _LIBCPP___THREAD_SUPPORT_WINDOWS_H
lib/libcxx/include/__thread/this_thread.h+1-1
......@@ -16,7 +16,7 @@
1616#include <__config>
1717#include <__mutex/mutex.h>
1818#include <__mutex/unique_lock.h>
19#include <__threading_support>
19#include <__thread/support.h>
2020
2121#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2222# pragma GCC system_header
lib/libcxx/include/__thread/thread.h+6-7
......@@ -19,7 +19,7 @@
1919#include <__mutex/mutex.h>
2020#include <__system_error/system_error.h>
2121#include <__thread/id.h>
22#include <__threading_support>
22#include <__thread/support.h>
2323#include <__utility/forward.h>
2424#include <tuple>
2525
......@@ -65,18 +65,17 @@ class __thread_specific_ptr {
6565
6666 // Only __thread_local_data() may construct a __thread_specific_ptr
6767 // and only with _Tp == __thread_struct.
68 static_assert((is_same<_Tp, __thread_struct>::value), "");
68 static_assert(is_same<_Tp, __thread_struct>::value, "");
6969 __thread_specific_ptr();
7070 friend _LIBCPP_EXPORTED_FROM_ABI __thread_specific_ptr<__thread_struct>& __thread_local_data();
7171
72 __thread_specific_ptr(const __thread_specific_ptr&);
73 __thread_specific_ptr& operator=(const __thread_specific_ptr&);
74
7572 _LIBCPP_HIDDEN static void _LIBCPP_TLS_DESTRUCTOR_CC __at_thread_exit(void*);
7673
7774public:
7875 typedef _Tp* pointer;
7976
77 __thread_specific_ptr(const __thread_specific_ptr&) = delete;
78 __thread_specific_ptr& operator=(const __thread_specific_ptr&) = delete;
8079 ~__thread_specific_ptr();
8180
8281 _LIBCPP_HIDE_FROM_ABI pointer get() const { return static_cast<_Tp*>(__libcpp_tls_get(__key_)); }
......@@ -157,7 +156,7 @@ public:
157156
158157 _LIBCPP_HIDE_FROM_ABI thread() _NOEXCEPT : __t_(_LIBCPP_NULL_THREAD) {}
159158#ifndef _LIBCPP_CXX03_LANG
160 template <class _Fp, class... _Args, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value> >
159 template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> = 0>
161160 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS explicit thread(_Fp&& __f, _Args&&... __args);
162161#else // _LIBCPP_CXX03_LANG
163162 template <class _Fp>
......@@ -203,7 +202,7 @@ _LIBCPP_HIDE_FROM_ABI void* __thread_proxy(void* __vp) {
203202 return nullptr;
204203}
205204
206template <class _Fp, class... _Args, class >
205template <class _Fp, class... _Args, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, thread>::value, int> >
207206thread::thread(_Fp&& __f, _Args&&... __args) {
208207 typedef unique_ptr<__thread_struct> _TSPtr;
209208 _TSPtr __tsp(new __thread_struct);
lib/libcxx/include/__thread/timed_backoff_policy.h+1-1
......@@ -15,7 +15,7 @@
1515#ifndef _LIBCPP_HAS_NO_THREADS
1616
1717# include <__chrono/duration.h>
18# include <__threading_support>
18# include <__thread/support.h>
1919
2020# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2121# pragma GCC system_header
lib/libcxx/include/__threading_support deleted-456
......@@ -1,456 +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___THREADING_SUPPORT
11#define _LIBCPP___THREADING_SUPPORT
12
13#include <__availability>
14#include <__chrono/convert_to_timespec.h>
15#include <__chrono/duration.h>
16#include <__config>
17#include <__fwd/hash.h>
18#include <ctime>
19#include <errno.h>
20
21#ifdef __MVS__
22# include <__support/ibm/nanosleep.h>
23#endif
24
25#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
26# pragma GCC system_header
27#endif
28
29#if defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
30# include <__external_threading>
31#elif !defined(_LIBCPP_HAS_NO_THREADS)
32
33# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
34// Some platforms require <bits/atomic_wide_counter.h> in order for
35// PTHREAD_COND_INITIALIZER to be expanded. Normally that would come
36// in via <pthread.h>, but it's a non-modular header on those platforms,
37// so libc++'s <math.h> usually absorbs atomic_wide_counter.h into the
38// module with <math.h> and makes atomic_wide_counter.h invisible.
39// Include <math.h> here to work around that.
40# include <math.h>
41
42# include <pthread.h>
43# include <sched.h>
44# elif defined(_LIBCPP_HAS_THREAD_API_C11)
45# include <threads.h>
46# endif
47
48# if defined(_LIBCPP_HAS_THREAD_API_WIN32)
49# define _LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_EXPORTED_FROM_ABI
50# else
51# define _LIBCPP_THREAD_ABI_VISIBILITY inline _LIBCPP_HIDE_FROM_ABI
52# endif
53
54typedef ::timespec __libcpp_timespec_t;
55#endif // !defined(_LIBCPP_HAS_NO_THREADS)
56
57_LIBCPP_BEGIN_NAMESPACE_STD
58
59#if !defined(_LIBCPP_HAS_NO_THREADS)
60
61# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
62// Mutex
63typedef pthread_mutex_t __libcpp_mutex_t;
64# define _LIBCPP_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
65
66typedef pthread_mutex_t __libcpp_recursive_mutex_t;
67
68// Condition Variable
69typedef pthread_cond_t __libcpp_condvar_t;
70# define _LIBCPP_CONDVAR_INITIALIZER PTHREAD_COND_INITIALIZER
71
72// Execute once
73typedef pthread_once_t __libcpp_exec_once_flag;
74# define _LIBCPP_EXEC_ONCE_INITIALIZER PTHREAD_ONCE_INIT
75
76// Thread id
77# if defined(__MVS__)
78typedef unsigned long long __libcpp_thread_id;
79# else
80typedef pthread_t __libcpp_thread_id;
81# endif
82
83// Thread
84# define _LIBCPP_NULL_THREAD ((__libcpp_thread_t()))
85typedef pthread_t __libcpp_thread_t;
86
87// Thread Local Storage
88typedef pthread_key_t __libcpp_tls_key;
89
90# define _LIBCPP_TLS_DESTRUCTOR_CC
91# elif defined(_LIBCPP_HAS_THREAD_API_C11)
92// Mutex
93typedef mtx_t __libcpp_mutex_t;
94// mtx_t is a struct so using {} for initialization is valid.
95# define _LIBCPP_MUTEX_INITIALIZER \
96 {}
97
98typedef mtx_t __libcpp_recursive_mutex_t;
99
100// Condition Variable
101typedef cnd_t __libcpp_condvar_t;
102// cnd_t is a struct so using {} for initialization is valid.
103# define _LIBCPP_CONDVAR_INITIALIZER \
104 {}
105
106// Execute once
107typedef ::once_flag __libcpp_exec_once_flag;
108# define _LIBCPP_EXEC_ONCE_INITIALIZER ONCE_FLAG_INIT
109
110// Thread id
111typedef thrd_t __libcpp_thread_id;
112
113// Thread
114# define _LIBCPP_NULL_THREAD 0U
115
116typedef thrd_t __libcpp_thread_t;
117
118// Thread Local Storage
119typedef tss_t __libcpp_tls_key;
120
121# define _LIBCPP_TLS_DESTRUCTOR_CC
122# elif !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
123// Mutex
124typedef void* __libcpp_mutex_t;
125# define _LIBCPP_MUTEX_INITIALIZER 0
126
127# if defined(_M_IX86) || defined(__i386__) || defined(_M_ARM) || defined(__arm__)
128typedef void* __libcpp_recursive_mutex_t[6];
129# elif defined(_M_AMD64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__)
130typedef void* __libcpp_recursive_mutex_t[5];
131# else
132# error Unsupported architecture
133# endif
134
135// Condition Variable
136typedef void* __libcpp_condvar_t;
137# define _LIBCPP_CONDVAR_INITIALIZER 0
138
139// Execute Once
140typedef void* __libcpp_exec_once_flag;
141# define _LIBCPP_EXEC_ONCE_INITIALIZER 0
142
143// Thread ID
144typedef long __libcpp_thread_id;
145
146// Thread
147# define _LIBCPP_NULL_THREAD 0U
148
149typedef void* __libcpp_thread_t;
150
151// Thread Local Storage
152typedef long __libcpp_tls_key;
153
154# define _LIBCPP_TLS_DESTRUCTOR_CC __stdcall
155# endif // !defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
156
157# if !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
158// Mutex
159_LIBCPP_THREAD_ABI_VISIBILITY
160int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m);
161
162_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
163__libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m);
164
165_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool
166__libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m);
167
168_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
169__libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m);
170
171_LIBCPP_THREAD_ABI_VISIBILITY
172int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m);
173
174_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t* __m);
175
176_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m);
177
178_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t* __m);
179
180_LIBCPP_THREAD_ABI_VISIBILITY
181int __libcpp_mutex_destroy(__libcpp_mutex_t* __m);
182
183// Condition variable
184_LIBCPP_THREAD_ABI_VISIBILITY
185int __libcpp_condvar_signal(__libcpp_condvar_t* __cv);
186
187_LIBCPP_THREAD_ABI_VISIBILITY
188int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv);
189
190_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
191__libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
192
193_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int
194__libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts);
195
196_LIBCPP_THREAD_ABI_VISIBILITY
197int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
198
199// Execute once
200_LIBCPP_THREAD_ABI_VISIBILITY
201int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)());
202
203// Thread id
204_LIBCPP_THREAD_ABI_VISIBILITY
205bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
206
207_LIBCPP_THREAD_ABI_VISIBILITY
208bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2);
209
210// Thread
211_LIBCPP_THREAD_ABI_VISIBILITY
212bool __libcpp_thread_isnull(const __libcpp_thread_t* __t);
213
214_LIBCPP_THREAD_ABI_VISIBILITY
215int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg);
216
217_LIBCPP_THREAD_ABI_VISIBILITY
218__libcpp_thread_id __libcpp_thread_get_current_id();
219
220_LIBCPP_THREAD_ABI_VISIBILITY
221__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t);
222
223_LIBCPP_THREAD_ABI_VISIBILITY
224int __libcpp_thread_join(__libcpp_thread_t* __t);
225
226_LIBCPP_THREAD_ABI_VISIBILITY
227int __libcpp_thread_detach(__libcpp_thread_t* __t);
228
229_LIBCPP_THREAD_ABI_VISIBILITY
230void __libcpp_thread_yield();
231
232_LIBCPP_THREAD_ABI_VISIBILITY
233void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns);
234
235// Thread local storage
236_LIBCPP_THREAD_ABI_VISIBILITY
237int __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*));
238
239_LIBCPP_THREAD_ABI_VISIBILITY
240void* __libcpp_tls_get(__libcpp_tls_key __key);
241
242_LIBCPP_THREAD_ABI_VISIBILITY
243int __libcpp_tls_set(__libcpp_tls_key __key, void* __p);
244
245# endif // !defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
246
247# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
248
249int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) {
250 pthread_mutexattr_t __attr;
251 int __ec = pthread_mutexattr_init(&__attr);
252 if (__ec)
253 return __ec;
254 __ec = pthread_mutexattr_settype(&__attr, PTHREAD_MUTEX_RECURSIVE);
255 if (__ec) {
256 pthread_mutexattr_destroy(&__attr);
257 return __ec;
258 }
259 __ec = pthread_mutex_init(__m, &__attr);
260 if (__ec) {
261 pthread_mutexattr_destroy(&__attr);
262 return __ec;
263 }
264 __ec = pthread_mutexattr_destroy(&__attr);
265 if (__ec) {
266 pthread_mutex_destroy(__m);
267 return __ec;
268 }
269 return 0;
270}
271
272int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_lock(__m); }
273
274bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_trylock(__m) == 0; }
275
276int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_unlock(__m); }
277
278int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) { return pthread_mutex_destroy(__m); }
279
280int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { return pthread_mutex_lock(__m); }
281
282bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { return pthread_mutex_trylock(__m) == 0; }
283
284int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { return pthread_mutex_unlock(__m); }
285
286int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) { return pthread_mutex_destroy(__m); }
287
288// Condition Variable
289int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return pthread_cond_signal(__cv); }
290
291int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { return pthread_cond_broadcast(__cv); }
292
293int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) { return pthread_cond_wait(__cv, __m); }
294
295int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) {
296 return pthread_cond_timedwait(__cv, __m, __ts);
297}
298
299int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) { return pthread_cond_destroy(__cv); }
300
301// Execute once
302int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)()) {
303 return pthread_once(__flag, __init_routine);
304}
305
306// Thread id
307// Returns non-zero if the thread ids are equal, otherwise 0
308bool __libcpp_thread_id_equal(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { return __t1 == __t2; }
309
310// Returns non-zero if t1 < t2, otherwise 0
311bool __libcpp_thread_id_less(__libcpp_thread_id __t1, __libcpp_thread_id __t2) { return __t1 < __t2; }
312
313// Thread
314bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { return __libcpp_thread_get_id(__t) == 0; }
315
316int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
317 return pthread_create(__t, nullptr, __func, __arg);
318}
319
320__libcpp_thread_id __libcpp_thread_get_current_id() {
321 const __libcpp_thread_t __current_thread = pthread_self();
322 return __libcpp_thread_get_id(&__current_thread);
323}
324
325__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) {
326# if defined(__MVS__)
327 return __t->__;
328# else
329 return *__t;
330# endif
331}
332
333int __libcpp_thread_join(__libcpp_thread_t* __t) { return pthread_join(*__t, nullptr); }
334
335int __libcpp_thread_detach(__libcpp_thread_t* __t) { return pthread_detach(*__t); }
336
337void __libcpp_thread_yield() { sched_yield(); }
338
339void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
340 __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns);
341 while (nanosleep(&__ts, &__ts) == -1 && errno == EINTR)
342 ;
343}
344
345// Thread local storage
346int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) {
347 return pthread_key_create(__key, __at_exit);
348}
349
350void* __libcpp_tls_get(__libcpp_tls_key __key) { return pthread_getspecific(__key); }
351
352int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { return pthread_setspecific(__key, __p); }
353
354# elif defined(_LIBCPP_HAS_THREAD_API_C11)
355
356int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) {
357 return mtx_init(__m, mtx_plain | mtx_recursive) == thrd_success ? 0 : EINVAL;
358}
359
360int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) {
361 return mtx_lock(__m) == thrd_success ? 0 : EINVAL;
362}
363
364bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) { return mtx_trylock(__m) == thrd_success; }
365
366int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) {
367 return mtx_unlock(__m) == thrd_success ? 0 : EINVAL;
368}
369
370int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) {
371 mtx_destroy(__m);
372 return 0;
373}
374
375int __libcpp_mutex_lock(__libcpp_mutex_t* __m) { return mtx_lock(__m) == thrd_success ? 0 : EINVAL; }
376
377bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { return mtx_trylock(__m) == thrd_success; }
378
379int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) { return mtx_unlock(__m) == thrd_success ? 0 : EINVAL; }
380
381int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
382 mtx_destroy(__m);
383 return 0;
384}
385
386// Condition Variable
387int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) { return cnd_signal(__cv) == thrd_success ? 0 : EINVAL; }
388
389int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) { return cnd_broadcast(__cv) == thrd_success ? 0 : EINVAL; }
390
391int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) {
392 return cnd_wait(__cv, __m) == thrd_success ? 0 : EINVAL;
393}
394
395int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, timespec* __ts) {
396 int __ec = cnd_timedwait(__cv, __m, __ts);
397 return __ec == thrd_timedout ? ETIMEDOUT : __ec;
398}
399
400int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) {
401 cnd_destroy(__cv);
402 return 0;
403}
404
405// Execute once
406int __libcpp_execute_once(__libcpp_exec_once_flag* flag, void (*init_routine)(void)) {
407 ::call_once(flag, init_routine);
408 return 0;
409}
410
411// Thread id
412// Returns non-zero if the thread ids are equal, otherwise 0
413bool __libcpp_thread_id_equal(__libcpp_thread_id t1, __libcpp_thread_id t2) { return thrd_equal(t1, t2) != 0; }
414
415// Returns non-zero if t1 < t2, otherwise 0
416bool __libcpp_thread_id_less(__libcpp_thread_id t1, __libcpp_thread_id t2) { return t1 < t2; }
417
418// Thread
419bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { return __libcpp_thread_get_id(__t) == 0; }
420
421int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
422 int __ec = thrd_create(__t, reinterpret_cast<thrd_start_t>(__func), __arg);
423 return __ec == thrd_nomem ? ENOMEM : __ec;
424}
425
426__libcpp_thread_id __libcpp_thread_get_current_id() { return thrd_current(); }
427
428__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { return *__t; }
429
430int __libcpp_thread_join(__libcpp_thread_t* __t) { return thrd_join(*__t, nullptr) == thrd_success ? 0 : EINVAL; }
431
432int __libcpp_thread_detach(__libcpp_thread_t* __t) { return thrd_detach(*__t) == thrd_success ? 0 : EINVAL; }
433
434void __libcpp_thread_yield() { thrd_yield(); }
435
436void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
437 __libcpp_timespec_t __ts = std::__convert_to_timespec<__libcpp_timespec_t>(__ns);
438 thrd_sleep(&__ts, nullptr);
439}
440
441// Thread local storage
442int __libcpp_tls_create(__libcpp_tls_key* __key, void (*__at_exit)(void*)) {
443 return tss_create(__key, __at_exit) == thrd_success ? 0 : EINVAL;
444}
445
446void* __libcpp_tls_get(__libcpp_tls_key __key) { return tss_get(__key); }
447
448int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) { return tss_set(__key, __p) == thrd_success ? 0 : EINVAL; }
449
450# endif
451
452#endif // !_LIBCPP_HAS_NO_THREADS
453
454_LIBCPP_END_NAMESPACE_STD
455
456#endif // _LIBCPP___THREADING_SUPPORT
lib/libcxx/include/__tree+19-26
......@@ -26,11 +26,9 @@
2626#include <__type_traits/can_extract_key.h>
2727#include <__type_traits/conditional.h>
2828#include <__type_traits/is_const.h>
29#include <__type_traits/is_copy_constructible.h>
30#include <__type_traits/is_nothrow_copy_constructible.h>
31#include <__type_traits/is_nothrow_default_constructible.h>
32#include <__type_traits/is_nothrow_move_assignable.h>
33#include <__type_traits/is_nothrow_move_constructible.h>
29#include <__type_traits/is_constructible.h>
30#include <__type_traits/is_nothrow_assignable.h>
31#include <__type_traits/is_nothrow_constructible.h>
3432#include <__type_traits/is_pointer.h>
3533#include <__type_traits/is_same.h>
3634#include <__type_traits/is_swappable.h>
......@@ -547,10 +545,8 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > {
547545 return __t.__get_value();
548546 }
549547
550 template <class _Up>
551 _LIBCPP_HIDE_FROM_ABI static __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value,
552 __container_value_type const&>
553 __get_value(_Up& __t) {
548 template <class _Up, __enable_if_t<__is_same_uncvref<_Up, __container_value_type>::value, int> = 0>
549 _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) {
554550 return __t;
555551 }
556552
......@@ -578,7 +574,7 @@ struct __tree_node_base_types {
578574#endif
579575
580576private:
581 static_assert((is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value),
577 static_assert(is_same<typename pointer_traits<_VoidPtr>::element_type, void>::value,
582578 "_VoidPtr does not point to unqualified void type");
583579};
584580
......@@ -618,7 +614,7 @@ public:
618614
619615private:
620616 static_assert(!is_const<__node_type>::value, "_NodePtr should never be a pointer to const");
621 static_assert((is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value),
617 static_assert(is_same<__rebind_pointer_t<_VoidPtr, __node_type>, _NodePtr>::value,
622618 "_VoidPtr does not rebind to _NodePtr.");
623619};
624620
......@@ -655,7 +651,6 @@ public:
655651
656652 _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); }
657653
658private:
659654 ~__tree_node_base() = delete;
660655 __tree_node_base(__tree_node_base const&) = delete;
661656 __tree_node_base& operator=(__tree_node_base const&) = delete;
......@@ -670,7 +665,6 @@ public:
670665
671666 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
672667
673private:
674668 ~__tree_node() = delete;
675669 __tree_node(__tree_node const&) = delete;
676670 __tree_node& operator=(__tree_node const&) = delete;
......@@ -929,11 +923,11 @@ private:
929923 // check for sane allocator pointer rebinding semantics. Rebinding the
930924 // allocator for a new pointer type should be exactly the same as rebinding
931925 // the pointer using 'pointer_traits'.
932 static_assert((is_same<__node_pointer, typename __node_traits::pointer>::value),
926 static_assert(is_same<__node_pointer, typename __node_traits::pointer>::value,
933927 "Allocator does not rebind pointers in a sane manner.");
934928 typedef __rebind_alloc<__node_traits, __node_base> __node_base_allocator;
935929 typedef allocator_traits<__node_base_allocator> __node_base_traits;
936 static_assert((is_same<__node_base_pointer, typename __node_base_traits::pointer>::value),
930 static_assert(is_same<__node_base_pointer, typename __node_base_traits::pointer>::value,
937931 "Allocator does not rebind pointers in a sane manner.");
938932
939933private:
......@@ -1010,11 +1004,10 @@ public:
10101004
10111005 _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t)
10121006#if _LIBCPP_STD_VER <= 11
1013 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value &&
1014 (!__node_traits::propagate_on_container_swap::value ||
1015 __is_nothrow_swappable<__node_allocator>::value));
1007 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
1008 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
10161009#else
1017 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value);
1010 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>);
10181011#endif
10191012
10201013 template <class _Key, class... _Args>
......@@ -1117,12 +1110,12 @@ public:
11171110 return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first;
11181111 }
11191112
1120 template <class _Vp, class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
1113 template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>
11211114 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __insert_unique(_Vp&& __v) {
11221115 return __emplace_unique(std::forward<_Vp>(__v));
11231116 }
11241117
1125 template <class _Vp, class = __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value> >
1118 template <class _Vp, __enable_if_t<!is_same<__remove_const_ref_t<_Vp>, __container_value_type>::value, int> = 0>
11261119 _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) {
11271120 return __emplace_hint_unique(__p, std::forward<_Vp>(__v));
11281121 }
......@@ -1405,7 +1398,7 @@ template <class _ForwardIterator>
14051398void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {
14061399 typedef iterator_traits<_ForwardIterator> _ITraits;
14071400 typedef typename _ITraits::value_type _ItValueType;
1408 static_assert((is_same<_ItValueType, __container_value_type>::value),
1401 static_assert(is_same<_ItValueType, __container_value_type>::value,
14091402 "__assign_unique may only be called with the containers value type");
14101403 static_assert(
14111404 __has_forward_iterator_category<_ForwardIterator>::value, "__assign_unique requires a forward iterator");
......@@ -1535,7 +1528,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
15351528
15361529template <class _Tp, class _Compare, class _Allocator>
15371530__tree<_Tp, _Compare, _Allocator>::~__tree() {
1538 static_assert((is_copy_constructible<value_compare>::value), "Comparator must be copy-constructible.");
1531 static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
15391532 destroy(__root());
15401533}
15411534
......@@ -1553,10 +1546,10 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
15531546template <class _Tp, class _Compare, class _Allocator>
15541547void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
15551548#if _LIBCPP_STD_VER <= 11
1556 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value &&
1557 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value))
1549 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
1550 (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
15581551#else
1559 _NOEXCEPT_(__is_nothrow_swappable<value_compare>::value)
1552 _NOEXCEPT_(__is_nothrow_swappable_v<value_compare>)
15601553#endif
15611554{
15621555 using std::swap;
lib/libcxx/include/__tuple/find_index.h created+62
......@@ -0,0 +1,62 @@
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_FIND_INDEX_H
10#define _LIBCPP___TUPLE_FIND_INDEX_H
11
12#include <__config>
13#include <__type_traits/is_same.h>
14#include <cstddef>
15
16#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17# pragma GCC system_header
18#endif
19
20#if _LIBCPP_STD_VER >= 14
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24namespace __find_detail {
25
26static constexpr size_t __not_found = static_cast<size_t>(-1);
27static constexpr size_t __ambiguous = __not_found - 1;
28
29inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
30 return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous);
31}
32
33template <size_t _Nx>
34inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
35 return __i == _Nx
36 ? __not_found
37 : __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
38}
39
40template <class _T1, class... _Args>
41struct __find_exactly_one_checked {
42 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
43 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
44 static_assert(value != __not_found, "type not found in type list");
45 static_assert(value != __ambiguous, "type occurs more than once in type list");
46};
47
48template <class _T1>
49struct __find_exactly_one_checked<_T1> {
50 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
51};
52
53} // namespace __find_detail
54
55template <typename _T1, typename... _Args>
56struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {};
57
58_LIBCPP_END_NAMESPACE_STD
59
60#endif // _LIBCPP_STD_VER >= 14
61
62#endif // _LIBCPP___TUPLE_FIND_INDEX_H
lib/libcxx/include/__tuple/ignore.h created+39
......@@ -0,0 +1,39 @@
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_IGNORE_H
10#define _LIBCPP___TUPLE_IGNORE_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18#ifndef _LIBCPP_CXX03_LANG
19
20_LIBCPP_BEGIN_NAMESPACE_STD
21
22struct __ignore_type {
23 template <class _Tp>
24 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_type& operator=(const _Tp&) const noexcept {
25 return *this;
26 }
27};
28
29# if _LIBCPP_STD_VER >= 17
30inline constexpr __ignore_type ignore;
31# else
32constexpr __ignore_type ignore;
33# endif
34
35_LIBCPP_END_NAMESPACE_STD
36
37#endif // _LIBCPP_CXX03_LANG
38
39#endif // _LIBCPP___TUPLE_IGNORE_H
lib/libcxx/include/__tuple/make_tuple_types.h+3-3
......@@ -16,7 +16,7 @@
1616#include <__tuple/tuple_indices.h>
1717#include <__tuple/tuple_size.h>
1818#include <__tuple/tuple_types.h>
19#include <__type_traits/apply_cv.h>
19#include <__type_traits/copy_cvref.h>
2020#include <__type_traits/remove_cv.h>
2121#include <__type_traits/remove_reference.h>
2222#include <cstddef>
......@@ -41,7 +41,7 @@ template <template <class...> class _Tuple, class... _Types, size_t... _Idx>
4141struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
4242 // Specialization for pair, tuple, and __tuple_types
4343 template <class _Tp>
44 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__apply_cv_t<_Tp, __type_pack_element<_Idx, _Types...>>...>;
44 using __apply_quals _LIBCPP_NODEBUG = __tuple_types<__copy_cvref_t<_Tp, __type_pack_element<_Idx, _Types...>>...>;
4545};
4646
4747template <class _Vt, size_t _Np, size_t... _Idx>
......@@ -49,7 +49,7 @@ struct __make_tuple_types_flat<array<_Vt, _Np>, __tuple_indices<_Idx...>> {
4949 template <size_t>
5050 using __value_type = _Vt;
5151 template <class _Tp>
52 using __apply_quals = __tuple_types<__apply_cv_t<_Tp, __value_type<_Idx>>...>;
52 using __apply_quals = __tuple_types<__copy_cvref_t<_Tp, __value_type<_Idx>>...>;
5353};
5454
5555template <class _Tp,
lib/libcxx/include/__tuple/pair_like.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___TUPLE_PAIR_LIKE_H
10#define _LIBCPP___TUPLE_PAIR_LIKE_H
11
12#include <__config>
13#include <__tuple/tuple_like.h>
14#include <__tuple/tuple_size.h>
15#include <__type_traits/remove_cvref.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
23#if _LIBCPP_STD_VER >= 20
24
25template <class _Tp>
26concept __pair_like = __tuple_like<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
27
28#endif // _LIBCPP_STD_VER >= 20
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TUPLE_PAIR_LIKE_H
lib/libcxx/include/__tuple/sfinae_helpers.h+3-40
......@@ -16,11 +16,10 @@
1616#include <__tuple/tuple_like_ext.h>
1717#include <__tuple/tuple_size.h>
1818#include <__tuple/tuple_types.h>
19#include <__type_traits/conjunction.h>
1920#include <__type_traits/enable_if.h>
2021#include <__type_traits/integral_constant.h>
21#include <__type_traits/is_assignable.h>
2222#include <__type_traits/is_constructible.h>
23#include <__type_traits/is_convertible.h>
2423#include <__type_traits/is_same.h>
2524#include <__type_traits/remove_cvref.h>
2625#include <__type_traits/remove_reference.h>
......@@ -34,40 +33,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3433
3534#ifndef _LIBCPP_CXX03_LANG
3635
37template <bool... _Preds>
38struct __all_dummy;
39
40template <bool... _Pred>
41struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>> {};
42
4336struct __tuple_sfinae_base {
4437 template <template <class, class...> class _Trait, class... _LArgs, class... _RArgs>
45 static auto __do_test(__tuple_types<_LArgs...>, __tuple_types<_RArgs...>)
46 -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
38 static auto __do_test(__tuple_types<_LArgs...>,
39 __tuple_types<_RArgs...>) -> __all<__enable_if_t<_Trait<_LArgs, _RArgs>::value, bool>{true}...>;
4740 template <template <class...> class>
4841 static auto __do_test(...) -> false_type;
4942
5043 template <class _FromArgs, class _ToArgs>
5144 using __constructible = decltype(__do_test<is_constructible>(_ToArgs{}, _FromArgs{}));
52 template <class _FromArgs, class _ToArgs>
53 using __convertible = decltype(__do_test<is_convertible>(_FromArgs{}, _ToArgs{}));
54 template <class _FromArgs, class _ToArgs>
55 using __assignable = decltype(__do_test<is_assignable>(_ToArgs{}, _FromArgs{}));
5645};
5746
58// __tuple_convertible
59
60template <class _Tp,
61 class _Up,
62 bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
63 bool = __tuple_like_ext<_Up>::value>
64struct __tuple_convertible : public false_type {};
65
66template <class _Tp, class _Up>
67struct __tuple_convertible<_Tp, _Up, true, true>
68 : public __tuple_sfinae_base::__convertible< typename __make_tuple_types<_Tp>::type,
69 typename __make_tuple_types<_Up>::type > {};
70
7147// __tuple_constructible
7248
7349template <class _Tp,
......@@ -81,19 +57,6 @@ struct __tuple_constructible<_Tp, _Up, true, true>
8157 : public __tuple_sfinae_base::__constructible< typename __make_tuple_types<_Tp>::type,
8258 typename __make_tuple_types<_Up>::type > {};
8359
84// __tuple_assignable
85
86template <class _Tp,
87 class _Up,
88 bool = __tuple_like_ext<__libcpp_remove_reference_t<_Tp> >::value,
89 bool = __tuple_like_ext<_Up>::value>
90struct __tuple_assignable : public false_type {};
91
92template <class _Tp, class _Up>
93struct __tuple_assignable<_Tp, _Up, true, true>
94 : public __tuple_sfinae_base::__assignable< typename __make_tuple_types<_Tp>::type,
95 typename __make_tuple_types<_Up&>::type > {};
96
9760template <size_t _Ip, class... _Tp>
9861struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> > {
9962 typedef _LIBCPP_NODEBUG typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
lib/libcxx/include/__tuple/tuple_element.h+3-32
......@@ -12,9 +12,6 @@
1212#include <__config>
1313#include <__tuple/tuple_indices.h>
1414#include <__tuple/tuple_types.h>
15#include <__type_traits/add_const.h>
16#include <__type_traits/add_cv.h>
17#include <__type_traits/add_volatile.h>
1815#include <cstddef>
1916
2017#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -28,47 +25,21 @@ struct _LIBCPP_TEMPLATE_VIS tuple_element;
2825
2926template <size_t _Ip, class _Tp>
3027struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp> {
31 typedef _LIBCPP_NODEBUG typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
28 typedef _LIBCPP_NODEBUG const typename tuple_element<_Ip, _Tp>::type type;
3229};
3330
3431template <size_t _Ip, class _Tp>
3532struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp> {
36 typedef _LIBCPP_NODEBUG typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
33 typedef _LIBCPP_NODEBUG volatile typename tuple_element<_Ip, _Tp>::type type;
3734};
3835
3936template <size_t _Ip, class _Tp>
4037struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp> {
41 typedef _LIBCPP_NODEBUG typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
38 typedef _LIBCPP_NODEBUG const volatile typename tuple_element<_Ip, _Tp>::type type;
4239};
4340
4441#ifndef _LIBCPP_CXX03_LANG
4542
46# if !__has_builtin(__type_pack_element)
47
48namespace __indexer_detail {
49
50template <size_t _Idx, class _Tp>
51struct __indexed {
52 using type _LIBCPP_NODEBUG = _Tp;
53};
54
55template <class _Types, class _Indexes>
56struct __indexer;
57
58template <class... _Types, size_t... _Idx>
59struct __indexer<__tuple_types<_Types...>, __tuple_indices<_Idx...>> : __indexed<_Idx, _Types>... {};
60
61template <size_t _Idx, class _Tp>
62__indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
63
64} // namespace __indexer_detail
65
66template <size_t _Idx, class... _Types>
67using __type_pack_element _LIBCPP_NODEBUG = typename decltype(__indexer_detail::__at_index<_Idx>(
68 __indexer_detail::__indexer< __tuple_types<_Types...>,
69 typename __make_tuple_indices<sizeof...(_Types)>::type >{}))::type;
70# endif
71
7243template <size_t _Ip, class... _Types>
7344struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...> > {
7445 static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
lib/libcxx/include/__tuple/tuple_like.h+9-18
......@@ -10,13 +10,10 @@
1010#define _LIBCPP___TUPLE_TUPLE_LIKE_H
1111
1212#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/pair.h>
1513#include <__fwd/subrange.h>
16#include <__fwd/tuple.h>
17#include <__type_traits/integral_constant.h>
14#include <__tuple/tuple_like_no_subrange.h>
15#include <__tuple/tuple_size.h>
1816#include <__type_traits/remove_cvref.h>
19#include <cstddef>
2017
2118#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2219# pragma GCC system_header
......@@ -27,22 +24,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2724#if _LIBCPP_STD_VER >= 20
2825
2926template <class _Tp>
30struct __tuple_like_impl : false_type {};
27inline constexpr bool __is_ranges_subrange_v = false;
3128
32template <class... _Tp>
33struct __tuple_like_impl<tuple<_Tp...> > : true_type {};
34
35template <class _T1, class _T2>
36struct __tuple_like_impl<pair<_T1, _T2> > : true_type {};
37
38template <class _Tp, size_t _Size>
39struct __tuple_like_impl<array<_Tp, _Size> > : true_type {};
40
41template <class _Ip, class _Sp, ranges::subrange_kind _Kp>
42struct __tuple_like_impl<ranges::subrange<_Ip, _Sp, _Kp> > : true_type {};
29template <class _Iter, class _Sent, ranges::subrange_kind _Kind>
30inline constexpr bool __is_ranges_subrange_v<ranges::subrange<_Iter, _Sent, _Kind>> = true;
4331
4432template <class _Tp>
45concept __tuple_like = __tuple_like_impl<remove_cvref_t<_Tp>>::value;
33concept __tuple_like = __tuple_like_no_subrange<_Tp> || __is_ranges_subrange_v<remove_cvref_t<_Tp>>;
34
35// As of writing this comment every use of `pair-like` in the standard excludes `ranges::subrange`, so
36// you most likely want to use `__pair_like_no_subrange` if you're looking for `pair-like`.
4637
4738#endif // _LIBCPP_STD_VER >= 20
4839
lib/libcxx/include/__tuple/tuple_like_no_subrange.h created+61
......@@ -0,0 +1,61 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
10#define _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
11
12#include <__config>
13#include <__fwd/array.h>
14#include <__fwd/complex.h>
15#include <__fwd/pair.h>
16#include <__fwd/tuple.h>
17#include <__tuple/tuple_size.h>
18#include <__type_traits/remove_cvref.h>
19#include <cstddef>
20
21#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
22# pragma GCC system_header
23#endif
24
25_LIBCPP_BEGIN_NAMESPACE_STD
26
27#if _LIBCPP_STD_VER >= 20
28
29template <class _Tp>
30inline constexpr bool __tuple_like_no_subrange_impl = false;
31
32template <class... _Tp>
33inline constexpr bool __tuple_like_no_subrange_impl<tuple<_Tp...>> = true;
34
35template <class _T1, class _T2>
36inline constexpr bool __tuple_like_no_subrange_impl<pair<_T1, _T2>> = true;
37
38template <class _Tp, size_t _Size>
39inline constexpr bool __tuple_like_no_subrange_impl<array<_Tp, _Size>> = true;
40
41# if _LIBCPP_STD_VER >= 26
42
43template <class _Tp>
44inline constexpr bool __tuple_like_no_subrange_impl<complex<_Tp>> = true;
45
46# endif
47
48template <class _Tp>
49concept __tuple_like_no_subrange = __tuple_like_no_subrange_impl<remove_cvref_t<_Tp>>;
50
51// This is equivalent to the exposition-only type trait `pair-like`, except that it is false for specializations of
52// `ranges::subrange`. This is more useful than the pair-like concept in the standard because every use of `pair-like`
53// excludes `ranges::subrange`.
54template <class _Tp>
55concept __pair_like_no_subrange = __tuple_like_no_subrange<_Tp> && tuple_size<remove_cvref_t<_Tp>>::value == 2;
56
57#endif // _LIBCPP_STD_VER >= 20
58
59_LIBCPP_END_NAMESPACE_STD
60
61#endif // _LIBCPP___TUPLE_TUPLE_LIKE_NO_SUBRANGE_H
lib/libcxx/include/__tuple/tuple_size.h+6-1
......@@ -43,7 +43,7 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<__enable_if_tuple_size_imp< volatile _Tp,
4343
4444template <class _Tp>
4545struct _LIBCPP_TEMPLATE_VIS
46 tuple_size<__enable_if_tuple_size_imp< const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
46tuple_size<__enable_if_tuple_size_imp<const volatile _Tp, integral_constant<size_t, sizeof(tuple_size<_Tp>)>>>
4747 : public integral_constant<size_t, tuple_size<_Tp>::value> {};
4848
4949#else
......@@ -63,6 +63,11 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<tuple<_Tp...> > : public integral_constan
6363template <class... _Tp>
6464struct _LIBCPP_TEMPLATE_VIS tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> {};
6565
66# if _LIBCPP_STD_VER >= 17
67template <class _Tp>
68inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
69# endif
70
6671#endif // _LIBCPP_CXX03_LANG
6772
6873_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/add_pointer.h-2
......@@ -11,9 +11,7 @@
1111
1212#include <__config>
1313#include <__type_traits/is_referenceable.h>
14#include <__type_traits/is_same.h>
1514#include <__type_traits/is_void.h>
16#include <__type_traits/remove_cv.h>
1715#include <__type_traits/remove_reference.h>
1816
1917#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/__type_traits/apply_cv.h deleted-78
......@@ -1,78 +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_APPLY_CV_H
10#define _LIBCPP___TYPE_TRAITS_APPLY_CV_H
11
12#include <__config>
13#include <__type_traits/is_const.h>
14#include <__type_traits/is_volatile.h>
15#include <__type_traits/remove_reference.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,
24 bool = is_const<__libcpp_remove_reference_t<_Tp> >::value,
25 bool = is_volatile<__libcpp_remove_reference_t<_Tp> >::value>
26struct __apply_cv_impl {
27 template <class _Up>
28 using __apply _LIBCPP_NODEBUG = _Up;
29};
30
31template <class _Tp>
32struct __apply_cv_impl<_Tp, true, false> {
33 template <class _Up>
34 using __apply _LIBCPP_NODEBUG = const _Up;
35};
36
37template <class _Tp>
38struct __apply_cv_impl<_Tp, false, true> {
39 template <class _Up>
40 using __apply _LIBCPP_NODEBUG = volatile _Up;
41};
42
43template <class _Tp>
44struct __apply_cv_impl<_Tp, true, true> {
45 template <class _Up>
46 using __apply _LIBCPP_NODEBUG = const volatile _Up;
47};
48
49template <class _Tp>
50struct __apply_cv_impl<_Tp&, false, false> {
51 template <class _Up>
52 using __apply _LIBCPP_NODEBUG = _Up&;
53};
54
55template <class _Tp>
56struct __apply_cv_impl<_Tp&, true, false> {
57 template <class _Up>
58 using __apply _LIBCPP_NODEBUG = const _Up&;
59};
60
61template <class _Tp>
62struct __apply_cv_impl<_Tp&, false, true> {
63 template <class _Up>
64 using __apply _LIBCPP_NODEBUG = volatile _Up&;
65};
66
67template <class _Tp>
68struct __apply_cv_impl<_Tp&, true, true> {
69 template <class _Up>
70 using __apply _LIBCPP_NODEBUG = const volatile _Up&;
71};
72
73template <class _Tp, class _Up>
74using __apply_cv_t _LIBCPP_NODEBUG = typename __apply_cv_impl<_Tp>::template __apply<_Up>;
75
76_LIBCPP_END_NAMESPACE_STD
77
78#endif // _LIBCPP___TYPE_TRAITS_APPLY_CV_H
lib/libcxx/include/__type_traits/common_type.h+3-3
......@@ -82,9 +82,9 @@ struct _LIBCPP_TEMPLATE_VIS common_type<_Tp> : public common_type<_Tp, _Tp> {};
8282// sub-bullet 1 - "If is_same_v<T1, D1> is false or ..."
8383template <class _Tp, class _Up>
8484struct _LIBCPP_TEMPLATE_VIS common_type<_Tp, _Up>
85 : conditional<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,
86 __common_type2_imp<_Tp, _Up>,
87 common_type<__decay_t<_Tp>, __decay_t<_Up> > >::type {};
85 : __conditional_t<_IsSame<_Tp, __decay_t<_Tp> >::value && _IsSame<_Up, __decay_t<_Up> >::value,
86 __common_type2_imp<_Tp, _Up>,
87 common_type<__decay_t<_Tp>, __decay_t<_Up> > > {};
8888
8989// bullet 4 - sizeof...(Tp) > 2
9090
lib/libcxx/include/__type_traits/conjunction.h+7
......@@ -13,6 +13,7 @@
1313#include <__type_traits/conditional.h>
1414#include <__type_traits/enable_if.h>
1515#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_same.h>
1617
1718#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1819# pragma GCC system_header
......@@ -37,6 +38,12 @@ false_type __and_helper(...);
3738template <class... _Pred>
3839using _And _LIBCPP_NODEBUG = decltype(std::__and_helper<_Pred...>(0));
3940
41template <bool... _Preds>
42struct __all_dummy;
43
44template <bool... _Pred>
45struct __all : _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...> > {};
46
4047#if _LIBCPP_STD_VER >= 17
4148
4249template <class...>
lib/libcxx/include/__type_traits/copy_cv.h+16-15
......@@ -10,9 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_COPY_CV_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_cv.h>
15#include <__type_traits/add_volatile.h>
1613
1714#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1815# pragma GCC system_header
......@@ -22,28 +19,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2219
2320// Let COPYCV(FROM, TO) be an alias for type TO with the addition of FROM's
2421// top-level cv-qualifiers.
25template <class _From, class _To>
22template <class _From>
2623struct __copy_cv {
27 using type = _To;
24 template <class _To>
25 using __apply = _To;
2826};
2927
30template <class _From, class _To>
31struct __copy_cv<const _From, _To> {
32 using type = typename add_const<_To>::type;
28template <class _From>
29struct __copy_cv<const _From> {
30 template <class _To>
31 using __apply = const _To;
3332};
3433
35template <class _From, class _To>
36struct __copy_cv<volatile _From, _To> {
37 using type = typename add_volatile<_To>::type;
34template <class _From>
35struct __copy_cv<volatile _From> {
36 template <class _To>
37 using __apply = volatile _To;
3838};
3939
40template <class _From, class _To>
41struct __copy_cv<const volatile _From, _To> {
42 using type = typename add_cv<_To>::type;
40template <class _From>
41struct __copy_cv<const volatile _From> {
42 template <class _To>
43 using __apply = const volatile _To;
4344};
4445
4546template <class _From, class _To>
46using __copy_cv_t = typename __copy_cv<_From, _To>::type;
47using __copy_cv_t = typename __copy_cv<_From>::template __apply<_To>;
4748
4849_LIBCPP_END_NAMESPACE_STD
4950
lib/libcxx/include/__type_traits/datasizeof.h+24-24
......@@ -26,39 +26,39 @@
2626
2727_LIBCPP_BEGIN_NAMESPACE_STD
2828
29#if __has_keyword(__datasizeof) || __has_extension(datasizeof)
2930template <class _Tp>
30struct __libcpp_datasizeof {
31#if __has_extension(datasizeof)
32 static const size_t value = __datasizeof(_Tp);
31inline const size_t __datasizeof_v = __datasizeof(_Tp);
3332#else
3433// NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825
3534# if __has_cpp_attribute(__no_unique_address__)
36 template <class = char>
37 struct _FirstPaddingByte {
38 [[__no_unique_address__]] _Tp __v_;
39 char __first_padding_byte_;
40 };
35template <class _Tp>
36struct _FirstPaddingByte {
37 [[__no_unique_address__]] _Tp __v_;
38 char __first_padding_byte_;
39};
4140# else
42 template <bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value>
43 struct _FirstPaddingByte : _Tp {
44 char __first_padding_byte_;
45 };
41template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value>
42struct _FirstPaddingByte : _Tp {
43 char __first_padding_byte_;
44};
4645
47 template <>
48 struct _FirstPaddingByte<true> {
49 _Tp __v_;
50 char __first_padding_byte_;
51 };
46template <class _Tp>
47struct _FirstPaddingByte<_Tp, true> {
48 _Tp __v_;
49 char __first_padding_byte_;
50};
5251# endif // __has_cpp_attribute(__no_unique_address__)
5352
54 // _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow
55 // the use as an extension.
56 _LIBCPP_DIAGNOSTIC_PUSH
57 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
58 static const size_t value = offsetof(_FirstPaddingByte<>, __first_padding_byte_);
59 _LIBCPP_DIAGNOSTIC_POP
53// _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow
54// the use as an extension.
55_LIBCPP_DIAGNOSTIC_PUSH
56_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
57_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Winvalid-offsetof")
58template <class _Tp>
59inline const size_t __datasizeof_v = offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_);
60_LIBCPP_DIAGNOSTIC_POP
6061#endif // __has_extension(datasizeof)
61};
6262
6363_LIBCPP_END_NAMESPACE_STD
6464
lib/libcxx/include/__type_traits/decay.h+5-5
......@@ -43,11 +43,11 @@ struct __decay {
4343template <class _Up>
4444struct __decay<_Up, true> {
4545public:
46 typedef _LIBCPP_NODEBUG typename conditional<
47 is_array<_Up>::value,
48 __add_pointer_t<__remove_extent_t<_Up> >,
49 typename conditional<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> >::type >::type
50 type;
46 typedef _LIBCPP_NODEBUG
47 __conditional_t<is_array<_Up>::value,
48 __add_pointer_t<__remove_extent_t<_Up> >,
49 __conditional_t<is_function<_Up>::value, typename add_pointer<_Up>::type, __remove_cv_t<_Up> > >
50 type;
5151};
5252
5353template <class _Tp>
lib/libcxx/include/__type_traits/desugars_to.h created+40
......@@ -0,0 +1,40 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H
10#define _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H
11
12#include <__config>
13
14#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
15# pragma GCC system_header
16#endif
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20// Tags to represent the canonical operations
21struct __equal_tag {};
22struct __plus_tag {};
23struct __less_tag {};
24
25// This class template is used to determine whether an operation "desugars"
26// (or boils down) to a given canonical operation.
27//
28// For example, `std::equal_to<>`, our internal `std::__equal_to` helper and
29// `ranges::equal_to` are all just fancy ways of representing a transparent
30// equality operation, so they all desugar to `__equal_tag`.
31//
32// This is useful to optimize some functions in cases where we know e.g. the
33// predicate being passed is actually going to call a builtin operator, or has
34// some specific semantics.
35template <class _CanonicalTag, class _Operation, class... _Args>
36inline const bool __desugars_to_v = false;
37
38_LIBCPP_END_NAMESPACE_STD
39
40#endif // _LIBCPP___TYPE_TRAITS_DESUGARS_TO_H
lib/libcxx/include/__type_traits/has_unique_object_representation.h+7-3
......@@ -12,7 +12,6 @@
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
1414#include <__type_traits/remove_all_extents.h>
15#include <__type_traits/remove_cv.h>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1817# pragma GCC system_header
......@@ -24,10 +23,15 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2423
2524template <class _Tp>
2625struct _LIBCPP_TEMPLATE_VIS has_unique_object_representations
27 : public integral_constant<bool, __has_unique_object_representations(remove_cv_t<remove_all_extents_t<_Tp>>)> {};
26 // TODO: We work around a Clang and GCC bug in __has_unique_object_representations by using remove_all_extents
27 // even though it should not be necessary. This was reported to the compilers:
28 // - Clang: https://github.com/llvm/llvm-project/issues/95311
29 // - GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115476
30 // remove_all_extents_t can be removed once all the compilers we support have fixed this bug.
31 : public integral_constant<bool, __has_unique_object_representations(remove_all_extents_t<_Tp>)> {};
2832
2933template <class _Tp>
30inline constexpr bool has_unique_object_representations_v = has_unique_object_representations<_Tp>::value;
34inline constexpr bool has_unique_object_representations_v = __has_unique_object_representations(_Tp);
3135
3236#endif
3337
lib/libcxx/include/__type_traits/invoke.h+4-199
......@@ -11,21 +11,17 @@
1111#define _LIBCPP___TYPE_TRAITS_INVOKE_H
1212
1313#include <__config>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/apply_cv.h>
1614#include <__type_traits/conditional.h>
1715#include <__type_traits/decay.h>
1816#include <__type_traits/enable_if.h>
1917#include <__type_traits/integral_constant.h>
2018#include <__type_traits/is_base_of.h>
2119#include <__type_traits/is_core_convertible.h>
22#include <__type_traits/is_member_function_pointer.h>
23#include <__type_traits/is_member_object_pointer.h>
20#include <__type_traits/is_member_pointer.h>
2421#include <__type_traits/is_reference_wrapper.h>
2522#include <__type_traits/is_same.h>
2623#include <__type_traits/is_void.h>
2724#include <__type_traits/nat.h>
28#include <__type_traits/remove_cv.h>
2925#include <__utility/declval.h>
3026#include <__utility/forward.h>
3127
......@@ -35,197 +31,6 @@
3531
3632_LIBCPP_BEGIN_NAMESPACE_STD
3733
38struct __any {
39 __any(...);
40};
41
42template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr>
43struct __member_pointer_traits_imp {};
44
45template <class _Rp, class _Class, class... _Param>
46struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...), true, false> {
47 typedef _Class _ClassType;
48 typedef _Rp _ReturnType;
49 typedef _Rp(_FnType)(_Param...);
50};
51
52template <class _Rp, class _Class, class... _Param>
53struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...), true, false> {
54 typedef _Class _ClassType;
55 typedef _Rp _ReturnType;
56 typedef _Rp(_FnType)(_Param..., ...);
57};
58
59template <class _Rp, class _Class, class... _Param>
60struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const, true, false> {
61 typedef _Class const _ClassType;
62 typedef _Rp _ReturnType;
63 typedef _Rp(_FnType)(_Param...);
64};
65
66template <class _Rp, class _Class, class... _Param>
67struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const, true, false> {
68 typedef _Class const _ClassType;
69 typedef _Rp _ReturnType;
70 typedef _Rp(_FnType)(_Param..., ...);
71};
72
73template <class _Rp, class _Class, class... _Param>
74struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile, true, false> {
75 typedef _Class volatile _ClassType;
76 typedef _Rp _ReturnType;
77 typedef _Rp(_FnType)(_Param...);
78};
79
80template <class _Rp, class _Class, class... _Param>
81struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile, true, false> {
82 typedef _Class volatile _ClassType;
83 typedef _Rp _ReturnType;
84 typedef _Rp(_FnType)(_Param..., ...);
85};
86
87template <class _Rp, class _Class, class... _Param>
88struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile, true, false> {
89 typedef _Class const volatile _ClassType;
90 typedef _Rp _ReturnType;
91 typedef _Rp(_FnType)(_Param...);
92};
93
94template <class _Rp, class _Class, class... _Param>
95struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile, true, false> {
96 typedef _Class const volatile _ClassType;
97 typedef _Rp _ReturnType;
98 typedef _Rp(_FnType)(_Param..., ...);
99};
100
101template <class _Rp, class _Class, class... _Param>
102struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...)&, true, false> {
103 typedef _Class& _ClassType;
104 typedef _Rp _ReturnType;
105 typedef _Rp(_FnType)(_Param...);
106};
107
108template <class _Rp, class _Class, class... _Param>
109struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...)&, true, false> {
110 typedef _Class& _ClassType;
111 typedef _Rp _ReturnType;
112 typedef _Rp(_FnType)(_Param..., ...);
113};
114
115template <class _Rp, class _Class, class... _Param>
116struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&, true, false> {
117 typedef _Class const& _ClassType;
118 typedef _Rp _ReturnType;
119 typedef _Rp(_FnType)(_Param...);
120};
121
122template <class _Rp, class _Class, class... _Param>
123struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&, true, false> {
124 typedef _Class const& _ClassType;
125 typedef _Rp _ReturnType;
126 typedef _Rp(_FnType)(_Param..., ...);
127};
128
129template <class _Rp, class _Class, class... _Param>
130struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&, true, false> {
131 typedef _Class volatile& _ClassType;
132 typedef _Rp _ReturnType;
133 typedef _Rp(_FnType)(_Param...);
134};
135
136template <class _Rp, class _Class, class... _Param>
137struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&, true, false> {
138 typedef _Class volatile& _ClassType;
139 typedef _Rp _ReturnType;
140 typedef _Rp(_FnType)(_Param..., ...);
141};
142
143template <class _Rp, class _Class, class... _Param>
144struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&, true, false> {
145 typedef _Class const volatile& _ClassType;
146 typedef _Rp _ReturnType;
147 typedef _Rp(_FnType)(_Param...);
148};
149
150template <class _Rp, class _Class, class... _Param>
151struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&, true, false> {
152 typedef _Class const volatile& _ClassType;
153 typedef _Rp _ReturnType;
154 typedef _Rp(_FnType)(_Param..., ...);
155};
156
157template <class _Rp, class _Class, class... _Param>
158struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...)&&, true, false> {
159 typedef _Class&& _ClassType;
160 typedef _Rp _ReturnType;
161 typedef _Rp(_FnType)(_Param...);
162};
163
164template <class _Rp, class _Class, class... _Param>
165struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...)&&, true, false> {
166 typedef _Class&& _ClassType;
167 typedef _Rp _ReturnType;
168 typedef _Rp(_FnType)(_Param..., ...);
169};
170
171template <class _Rp, class _Class, class... _Param>
172struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const&&, true, false> {
173 typedef _Class const&& _ClassType;
174 typedef _Rp _ReturnType;
175 typedef _Rp(_FnType)(_Param...);
176};
177
178template <class _Rp, class _Class, class... _Param>
179struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const&&, true, false> {
180 typedef _Class const&& _ClassType;
181 typedef _Rp _ReturnType;
182 typedef _Rp(_FnType)(_Param..., ...);
183};
184
185template <class _Rp, class _Class, class... _Param>
186struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) volatile&&, true, false> {
187 typedef _Class volatile&& _ClassType;
188 typedef _Rp _ReturnType;
189 typedef _Rp(_FnType)(_Param...);
190};
191
192template <class _Rp, class _Class, class... _Param>
193struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) volatile&&, true, false> {
194 typedef _Class volatile&& _ClassType;
195 typedef _Rp _ReturnType;
196 typedef _Rp(_FnType)(_Param..., ...);
197};
198
199template <class _Rp, class _Class, class... _Param>
200struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param...) const volatile&&, true, false> {
201 typedef _Class const volatile&& _ClassType;
202 typedef _Rp _ReturnType;
203 typedef _Rp(_FnType)(_Param...);
204};
205
206template <class _Rp, class _Class, class... _Param>
207struct __member_pointer_traits_imp<_Rp (_Class::*)(_Param..., ...) const volatile&&, true, false> {
208 typedef _Class const volatile&& _ClassType;
209 typedef _Rp _ReturnType;
210 typedef _Rp(_FnType)(_Param..., ...);
211};
212
213template <class _Rp, class _Class>
214struct __member_pointer_traits_imp<_Rp _Class::*, false, true> {
215 typedef _Class _ClassType;
216 typedef _Rp _ReturnType;
217};
218
219template <class _MP>
220struct __member_pointer_traits
221 : public __member_pointer_traits_imp<__remove_cv_t<_MP>,
222 is_member_function_pointer<_MP>::value,
223 is_member_object_pointer<_MP>::value> {
224 // typedef ... _ClassType;
225 // typedef ... _ReturnType;
226 // typedef ... _FnType;
227};
228
22934template <class _DecayedFp>
23035struct __member_pointer_class_type {};
23136
......@@ -285,7 +90,7 @@ using __enable_if_bullet6 =
28590// fall back - none of the bullets
28691
28792template <class... _Args>
288__nat __invoke(__any, _Args&&... __args);
93__nat __invoke(_Args&&... __args);
28994
29095// bullets 1, 2 and 3
29196
......@@ -357,8 +162,8 @@ struct __invokable_r {
357162 using _Result = decltype(__try_call<_Fp, _Args...>(0));
358163
359164 using type = __conditional_t<_IsNotSame<_Result, __nat>::value,
360 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
361 false_type>;
165 __conditional_t<is_void<_Ret>::value, true_type, __is_core_convertible<_Result, _Ret> >,
166 false_type>;
362167 static const bool value = type::value;
363168};
364169template <class _Fp, class... _Args>
lib/libcxx/include/__type_traits/is_array.h+2-3
......@@ -19,9 +19,8 @@
1919
2020_LIBCPP_BEGIN_NAMESPACE_STD
2121
22// TODO: Clang incorrectly reports that __is_array is true for T[0].
23// Re-enable the branch once https://llvm.org/PR54705 is fixed.
24#if __has_builtin(__is_array) && 0
22#if __has_builtin(__is_array) && \
23 (!defined(_LIBCPP_COMPILER_CLANG_BASED) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1900))
2524
2625template <class _Tp>
2726struct _LIBCPP_TEMPLATE_VIS is_array : _BoolConstant<__is_array(_Tp)> {};
lib/libcxx/include/__type_traits/is_assignable.h+21
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
1111
1212#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
1315#include <__type_traits/integral_constant.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -26,6 +28,25 @@ template <class _Tp, class _Arg>
2628inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg);
2729#endif
2830
31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
33 : public integral_constant<bool,
34 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
35
36#if _LIBCPP_STD_VER >= 17
37template <class _Tp>
38inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
39#endif
40
41template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_move_assignable
43 : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
44
45#if _LIBCPP_STD_VER >= 17
46template <class _Tp>
47inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
48#endif
49
2950_LIBCPP_END_NAMESPACE_STD
3051
3152#endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_constructible.h+28
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
1111
1212#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
1315#include <__type_traits/integral_constant.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -26,6 +28,32 @@ template <class _Tp, class... _Args>
2628inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...);
2729#endif
2830
31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
33 : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
34
35#if _LIBCPP_STD_VER >= 17
36template <class _Tp>
37inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
38#endif
39
40template <class _Tp>
41struct _LIBCPP_TEMPLATE_VIS is_move_constructible
42 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
43
44#if _LIBCPP_STD_VER >= 17
45template <class _Tp>
46inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
47#endif
48
49template <class _Tp>
50struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {};
51
52#if _LIBCPP_STD_VER >= 17
53template <class _Tp>
54inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
55#endif
56
2957_LIBCPP_END_NAMESPACE_STD
3058
3159#endif // _LIBCPP___TYPE_IS_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_convertible.h-6
......@@ -11,12 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_array.h>
15#include <__type_traits/is_function.h>
16#include <__type_traits/is_void.h>
17#include <__type_traits/remove_reference.h>
18#include <__utility/declval.h>
19#include <cstddef>
2014
2115#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2216# pragma GCC system_header
lib/libcxx/include/__type_traits/is_copy_assignable.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_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_copy_assignable
25 : public integral_constant<
26 bool,
27 __is_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
28
29#if _LIBCPP_STD_VER >= 17
30template <class _Tp>
31inline constexpr bool is_copy_assignable_v = is_copy_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_copy_constructible.h deleted-35
......@@ -1,35 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_copy_constructible
25 : public integral_constant<bool, __is_constructible(_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {
26};
27
28#if _LIBCPP_STD_VER >= 17
29template <class _Tp>
30inline constexpr bool is_copy_constructible_v = is_copy_constructible<_Tp>::value;
31#endif
32
33_LIBCPP_END_NAMESPACE_STD
34
35#endif // _LIBCPP___TYPE_TRAITS_IS_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_default_constructible.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_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_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>
22struct _LIBCPP_TEMPLATE_VIS is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {};
23
24#if _LIBCPP_STD_VER >= 17
25template <class _Tp>
26inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);
27#endif
28
29_LIBCPP_END_NAMESPACE_STD
30
31#endif // _LIBCPP___TYPE_TRAITS_IS_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_enum.h+10
......@@ -26,6 +26,16 @@ template <class _Tp>
2626inline constexpr bool is_enum_v = __is_enum(_Tp);
2727#endif
2828
29#if _LIBCPP_STD_VER >= 23
30
31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : bool_constant<__is_scoped_enum(_Tp)> {};
33
34template <class _Tp>
35inline constexpr bool is_scoped_enum_v = __is_scoped_enum(_Tp);
36
37#endif // _LIBCPP_STD_VER >= 23
38
2939_LIBCPP_END_NAMESPACE_STD
3040
3141#endif // _LIBCPP___TYPE_TRAITS_IS_ENUM_H
lib/libcxx/include/__type_traits/is_equality_comparable.h+2-1
......@@ -17,7 +17,6 @@
1717#include <__type_traits/is_signed.h>
1818#include <__type_traits/is_void.h>
1919#include <__type_traits/remove_cv.h>
20#include <__type_traits/remove_cvref.h>
2120#include <__type_traits/void_t.h>
2221#include <__utility/declval.h>
2322
......@@ -45,6 +44,8 @@ struct __is_equality_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>()
4544// pointers that don't have the same type (ignoring cv-qualifiers): pointers to virtual bases are equality comparable,
4645// but don't have the same bit-pattern. An exception to this is comparing to a void-pointer. There the bit-pattern is
4746// always compared.
47// objects with padding bytes: since objects with padding bytes may compare equal, even though their object
48// representation may not be equivalent.
4849
4950template <class _Tp, class _Up, class = void>
5051struct __libcpp_is_trivially_equality_comparable_impl : false_type {};
lib/libcxx/include/__type_traits/is_function.h+1-13
......@@ -11,8 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_const.h>
15#include <__type_traits/is_reference.h>
1614
1715#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1816# pragma GCC system_header
......@@ -20,22 +18,12 @@
2018
2119_LIBCPP_BEGIN_NAMESPACE_STD
2220
23#if __has_builtin(__is_function)
24
2521template <class _Tp>
2622struct _LIBCPP_TEMPLATE_VIS is_function : integral_constant<bool, __is_function(_Tp)> {};
2723
28#else
29
30template <class _Tp>
31struct _LIBCPP_TEMPLATE_VIS is_function
32 : public integral_constant<bool, !(is_reference<_Tp>::value || is_const<const _Tp>::value)> {};
33
34#endif // __has_builtin(__is_function)
35
3624#if _LIBCPP_STD_VER >= 17
3725template <class _Tp>
38inline constexpr bool is_function_v = is_function<_Tp>::value;
26inline constexpr bool is_function_v = __is_function(_Tp);
3927#endif
4028
4129_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_fundamental.h+1-1
......@@ -34,7 +34,7 @@ inline constexpr bool is_fundamental_v = __is_fundamental(_Tp);
3434
3535template <class _Tp>
3636struct _LIBCPP_TEMPLATE_VIS is_fundamental
37 : public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {};
37 : public integral_constant<bool, is_void<_Tp>::value || __is_null_pointer_v<_Tp> || is_arithmetic<_Tp>::value> {};
3838
3939# if _LIBCPP_STD_VER >= 17
4040template <class _Tp>
lib/libcxx/include/__type_traits/is_implicitly_default_constructible.h+1-1
......@@ -11,7 +11,7 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_default_constructible.h>
14#include <__type_traits/is_constructible.h>
1515
1616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1717# pragma GCC system_header
lib/libcxx/include/__type_traits/is_literal_type.h+2-2
......@@ -20,8 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020
2121#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS)
2222template <class _Tp>
23struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 is_literal_type
24 : public integral_constant<bool, __is_literal_type(_Tp)> {};
23struct _LIBCPP_TEMPLATE_VIS
24_LIBCPP_DEPRECATED_IN_CXX17 is_literal_type : public integral_constant<bool, __is_literal_type(_Tp)> {};
2525
2626# if _LIBCPP_STD_VER >= 17
2727template <class _Tp>
lib/libcxx/include/__type_traits/is_member_function_pointer.h deleted-62
......@@ -1,62 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_function.h>
15#include <__type_traits/remove_cv.h>
16#include <cstddef>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
24template <class _Tp>
25struct __libcpp_is_member_pointer {
26 enum { __is_member = false, __is_func = false, __is_obj = false };
27};
28template <class _Tp, class _Up>
29struct __libcpp_is_member_pointer<_Tp _Up::*> {
30 enum {
31 __is_member = true,
32 __is_func = is_function<_Tp>::value,
33 __is_obj = !__is_func,
34 };
35};
36
37#if __has_builtin(__is_member_function_pointer)
38
39template <class _Tp>
40struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
41
42# if _LIBCPP_STD_VER >= 17
43template <class _Tp>
44inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
45# endif
46
47#else // __has_builtin(__is_member_function_pointer)
48
49template <class _Tp>
50struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer
51 : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_func> {};
52
53# if _LIBCPP_STD_VER >= 17
54template <class _Tp>
55inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<_Tp>::value;
56# endif
57
58#endif // __has_builtin(__is_member_function_pointer)
59
60_LIBCPP_END_NAMESPACE_STD
61
62#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_object_pointer.h deleted-46
......@@ -1,46 +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_MEMBER_OBJECT_POINTER_H
10#define _LIBCPP___TYPE_TRAITS_IS_MEMBER_OBJECT_POINTER_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21#if __has_builtin(__is_member_object_pointer)
22
23template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
25
26# if _LIBCPP_STD_VER >= 17
27template <class _Tp>
28inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
29# endif
30
31#else // __has_builtin(__is_member_object_pointer)
32
33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer
35 : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_obj> {};
36
37# if _LIBCPP_STD_VER >= 17
38template <class _Tp>
39inline constexpr bool is_member_object_pointer_v = is_member_object_pointer<_Tp>::value;
40# endif
41
42#endif // __has_builtin(__is_member_object_pointer)
43
44_LIBCPP_END_NAMESPACE_STD
45
46#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_FUNCTION_POINTER_H
lib/libcxx/include/__type_traits/is_member_pointer.h+8-12
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_member_function_pointer.h>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1716# pragma GCC system_header
......@@ -19,29 +18,26 @@
1918
2019_LIBCPP_BEGIN_NAMESPACE_STD
2120
22#if __has_builtin(__is_member_pointer)
23
2421template <class _Tp>
2522struct _LIBCPP_TEMPLATE_VIS is_member_pointer : _BoolConstant<__is_member_pointer(_Tp)> {};
2623
24template <class _Tp>
25struct _LIBCPP_TEMPLATE_VIS is_member_object_pointer : _BoolConstant<__is_member_object_pointer(_Tp)> {};
26
27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_member_function_pointer : _BoolConstant<__is_member_function_pointer(_Tp)> {};
29
2730# if _LIBCPP_STD_VER >= 17
2831template <class _Tp>
2932inline constexpr bool is_member_pointer_v = __is_member_pointer(_Tp);
30# endif
31
32#else // __has_builtin(__is_member_pointer)
3333
3434template <class _Tp>
35struct _LIBCPP_TEMPLATE_VIS is_member_pointer
36 : public _BoolConstant<__libcpp_is_member_pointer<__remove_cv_t<_Tp> >::__is_member> {};
35inline constexpr bool is_member_object_pointer_v = __is_member_object_pointer(_Tp);
3736
38# if _LIBCPP_STD_VER >= 17
3937template <class _Tp>
40inline constexpr bool is_member_pointer_v = is_member_pointer<_Tp>::value;
38inline constexpr bool is_member_function_pointer_v = __is_member_function_pointer(_Tp);
4139# endif
4240
43#endif // __has_builtin(__is_member_pointer)
44
4541_LIBCPP_END_NAMESPACE_STD
4642
4743#endif // _LIBCPP___TYPE_TRAITS_IS_MEMBER_POINTER_H
lib/libcxx/include/__type_traits/is_move_assignable.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_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_move_assignable
25 : public integral_constant<bool, __is_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
26
27#if _LIBCPP_STD_VER >= 17
28template <class _Tp>
29inline constexpr bool is_move_assignable_v = is_move_assignable<_Tp>::value;
30#endif
31
32_LIBCPP_END_NAMESPACE_STD
33
34#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_move_constructible.h deleted-33
......@@ -1,33 +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_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.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>
23struct _LIBCPP_TEMPLATE_VIS is_move_constructible
24 : public integral_constant<bool, __is_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
25
26#if _LIBCPP_STD_VER >= 17
27template <class _Tp>
28inline constexpr bool is_move_constructible_v = is_move_constructible<_Tp>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_assignable.h+24
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
1111
1212#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
1315#include <__type_traits/integral_constant.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -27,6 +29,28 @@ template <class _Tp, class _Arg>
2729inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg);
2830#endif
2931
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
34 : public integral_constant<
35 bool,
36 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
37
38#if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
41#endif
42
43template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
45 : public integral_constant<bool,
46 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
47};
48
49#if _LIBCPP_STD_VER >= 17
50template <class _Tp>
51inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
52#endif
53
3054_LIBCPP_END_NAMESPACE_STD
3155
3256#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_constructible.h+23-33
......@@ -10,11 +10,9 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_H
1111
1212#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
1315#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_constructible.h>
15#include <__type_traits/is_reference.h>
16#include <__utility/declval.h>
17#include <cstddef>
1816
1917#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2018# pragma GCC system_header
......@@ -22,48 +20,40 @@
2220
2321_LIBCPP_BEGIN_NAMESPACE_STD
2422
25// GCC is disabled due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611
26#if __has_builtin(__is_nothrow_constructible) && !defined(_LIBCPP_COMPILER_GCC)
27
2823template < class _Tp, class... _Args>
2924struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
3025 : public integral_constant<bool, __is_nothrow_constructible(_Tp, _Args...)> {};
31#else
32
33template <bool, bool, class _Tp, class... _Args>
34struct __libcpp_is_nothrow_constructible;
3526
27#if _LIBCPP_STD_VER >= 17
3628template <class _Tp, class... _Args>
37struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ false, _Tp, _Args...>
38 : public integral_constant<bool, noexcept(_Tp(std::declval<_Args>()...))> {};
29inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
30#endif
3931
4032template <class _Tp>
41void __implicit_conversion_to(_Tp) noexcept {}
33struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
34 : public integral_constant< bool, __is_nothrow_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
4235
43template <class _Tp, class _Arg>
44struct __libcpp_is_nothrow_constructible</*is constructible*/ true, /*is reference*/ true, _Tp, _Arg>
45 : public integral_constant<bool, noexcept(std::__implicit_conversion_to<_Tp>(std::declval<_Arg>()))> {};
46
47template <class _Tp, bool _IsReference, class... _Args>
48struct __libcpp_is_nothrow_constructible</*is constructible*/ false, _IsReference, _Tp, _Args...> : public false_type {
49};
36#if _LIBCPP_STD_VER >= 17
37template <class _Tp>
38inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
39#endif
5040
51template <class _Tp, class... _Args>
52struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible
53 : __libcpp_is_nothrow_constructible<is_constructible<_Tp, _Args...>::value,
54 is_reference<_Tp>::value,
55 _Tp,
56 _Args...> {};
41template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
43 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
5744
58template <class _Tp, size_t _Ns>
59struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible<_Tp[_Ns]>
60 : __libcpp_is_nothrow_constructible<is_constructible<_Tp>::value, is_reference<_Tp>::value, _Tp> {};
45#if _LIBCPP_STD_VER >= 17
46template <class _Tp>
47inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
48#endif
6149
62#endif // __has_builtin(__is_nothrow_constructible)
50template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
52 : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {};
6353
6454#if _LIBCPP_STD_VER >= 17
65template <class _Tp, class... _Args>
66inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<_Tp, _Args...>::value;
55template <class _Tp>
56inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
6757#endif
6858
6959_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_convertible.h+12
......@@ -26,6 +26,16 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2626
2727#if _LIBCPP_STD_VER >= 20
2828
29# if __has_builtin(__is_nothrow_convertible)
30
31template <class _Tp, class _Up>
32struct is_nothrow_convertible : bool_constant<__is_nothrow_convertible(_Tp, _Up)> {};
33
34template <class _Tp, class _Up>
35inline constexpr bool is_nothrow_convertible_v = __is_nothrow_convertible(_Tp, _Up);
36
37# else // __has_builtin(__is_nothrow_convertible)
38
2939template <typename _Tp>
3040void __test_noexcept(_Tp) noexcept;
3141
......@@ -43,6 +53,8 @@ struct is_nothrow_convertible
4353template <typename _Fm, typename _To>
4454inline constexpr bool is_nothrow_convertible_v = is_nothrow_convertible<_Fm, _To>::value;
4555
56# endif // __has_builtin(__is_nothrow_convertible)
57
4658#endif // _LIBCPP_STD_VER >= 20
4759
4860_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__type_traits/is_nothrow_copy_assignable.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_NOTHROW_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable
25 : public integral_constant<bool,
26 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>,
27 __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
28
29#if _LIBCPP_STD_VER >= 17
30template <class _Tp>
31inline constexpr bool is_nothrow_copy_assignable_v = is_nothrow_copy_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_copy_constructible.h deleted-48
......@@ -1,48 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.h>
16#include <__type_traits/is_nothrow_constructible.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// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
25#ifdef _LIBCPP_COMPILER_GCC
26
27template <class _Tp>
28struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
29 : public is_nothrow_constructible<_Tp, __add_lvalue_reference_t<typename add_const<_Tp>::type> > {};
30
31#else // _LIBCPP_COMPILER_GCC
32
33template <class _Tp>
34struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible
35 : public integral_constant<
36 bool,
37 __is_nothrow_constructible(_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type)> {};
38
39#endif // _LIBCPP_COMPILER_GCC
40
41#if _LIBCPP_STD_VER >= 17
42template <class _Tp>
43inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value;
44#endif
45
46_LIBCPP_END_NAMESPACE_STD
47
48#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_default_constructible.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_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_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>
22struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible
23 : public integral_constant<bool, __is_nothrow_constructible(_Tp)> {};
24
25#if _LIBCPP_STD_VER >= 17
26template <class _Tp>
27inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_nothrow_destructible.h+7-18
......@@ -12,9 +12,6 @@
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
1414#include <__type_traits/is_destructible.h>
15#include <__type_traits/is_reference.h>
16#include <__type_traits/is_scalar.h>
17#include <__type_traits/remove_all_extents.h>
1815#include <__utility/declval.h>
1916#include <cstddef>
2017
......@@ -24,7 +21,12 @@
2421
2522_LIBCPP_BEGIN_NAMESPACE_STD
2623
27#if !defined(_LIBCPP_CXX03_LANG)
24#if __has_builtin(__is_nothrow_destructible)
25
26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : integral_constant<bool, __is_nothrow_destructible(_Tp)> {};
28
29#else
2830
2931template <bool, class _Tp>
3032struct __libcpp_is_nothrow_destructible;
......@@ -49,20 +51,7 @@ struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&> : public true_type {};
4951template <class _Tp>
5052struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp&&> : public true_type {};
5153
52#else
53
54template <class _Tp>
55struct __libcpp_nothrow_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> {
56};
57
58template <class _Tp>
59struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible : public __libcpp_nothrow_destructor<__remove_all_extents_t<_Tp> > {
60};
61
62template <class _Tp>
63struct _LIBCPP_TEMPLATE_VIS is_nothrow_destructible<_Tp[]> : public false_type {};
64
65#endif
54#endif // __has_builtin(__is_nothrow_destructible)
6655
6756#if _LIBCPP_STD_VER >= 17
6857template <class _Tp>
lib/libcxx/include/__type_traits/is_nothrow_move_assignable.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_NOTHROW_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable
25 : public integral_constant<bool,
26 __is_nothrow_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {
27};
28
29#if _LIBCPP_STD_VER >= 17
30template <class _Tp>
31inline constexpr bool is_nothrow_move_assignable_v = is_nothrow_move_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_nothrow_move_constructible.h deleted-45
......@@ -1,45 +0,0 @@
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_nothrow_constructible.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
23// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed
24#ifndef _LIBCPP_COMPILER_GCC
25
26template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
28 : public integral_constant<bool, __is_nothrow_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
29
30#else // _LIBCPP_COMPILER_GCC
31
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible
34 : public is_nothrow_constructible<_Tp, __add_rvalue_reference_t<_Tp> > {};
35
36#endif // _LIBCPP_COMPILER_GCC
37
38#if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value;
41#endif
42
43_LIBCPP_END_NAMESPACE_STD
44
45#endif // _LIBCPP___TYPE_TRAITS_IS_NOTHROW_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_null_pointer.h+3-9
......@@ -11,7 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/remove_cv.h>
1514#include <cstddef>
1615
1716#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -21,20 +20,15 @@
2120_LIBCPP_BEGIN_NAMESPACE_STD
2221
2322template <class _Tp>
24struct __is_nullptr_t_impl : public false_type {};
25template <>
26struct __is_nullptr_t_impl<nullptr_t> : public true_type {};
27
28template <class _Tp>
29struct _LIBCPP_TEMPLATE_VIS __is_nullptr_t : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
23inline const bool __is_null_pointer_v = __is_same(__remove_cv(_Tp), nullptr_t);
3024
3125#if _LIBCPP_STD_VER >= 14
3226template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_null_pointer : public __is_nullptr_t_impl<__remove_cv_t<_Tp> > {};
27struct _LIBCPP_TEMPLATE_VIS is_null_pointer : integral_constant<bool, __is_null_pointer_v<_Tp>> {};
3428
3529# if _LIBCPP_STD_VER >= 17
3630template <class _Tp>
37inline constexpr bool is_null_pointer_v = is_null_pointer<_Tp>::value;
31inline constexpr bool is_null_pointer_v = __is_null_pointer_v<_Tp>;
3832# endif
3933#endif // _LIBCPP_STD_VER >= 14
4034
lib/libcxx/include/__type_traits/is_object.h+2-23
......@@ -11,10 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_array.h>
15#include <__type_traits/is_class.h>
16#include <__type_traits/is_scalar.h>
17#include <__type_traits/is_union.h>
1814
1915#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2016# pragma GCC system_header
......@@ -22,30 +18,13 @@
2218
2319_LIBCPP_BEGIN_NAMESPACE_STD
2420
25#if __has_builtin(__is_object)
26
2721template <class _Tp>
2822struct _LIBCPP_TEMPLATE_VIS is_object : _BoolConstant<__is_object(_Tp)> {};
2923
30# if _LIBCPP_STD_VER >= 17
24#if _LIBCPP_STD_VER >= 17
3125template <class _Tp>
3226inline constexpr bool is_object_v = __is_object(_Tp);
33# endif
34
35#else // __has_builtin(__is_object)
36
37template <class _Tp>
38struct _LIBCPP_TEMPLATE_VIS is_object
39 : public integral_constant<bool,
40 is_scalar<_Tp>::value || is_array<_Tp>::value || is_union<_Tp>::value ||
41 is_class<_Tp>::value > {};
42
43# if _LIBCPP_STD_VER >= 17
44template <class _Tp>
45inline constexpr bool is_object_v = is_object<_Tp>::value;
46# endif
47
48#endif // __has_builtin(__is_object)
27#endif
4928
5029_LIBCPP_END_NAMESPACE_STD
5130
lib/libcxx/include/__type_traits/is_reference.h+11-18
......@@ -18,27 +18,30 @@
1818
1919_LIBCPP_BEGIN_NAMESPACE_STD
2020
21#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference) && __has_builtin(__is_reference)
21template <class _Tp>
22struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {};
2223
24#if _LIBCPP_STD_VER >= 17
2325template <class _Tp>
24struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};
26inline constexpr bool is_reference_v = __is_reference(_Tp);
27#endif
28
29#if __has_builtin(__is_lvalue_reference) && __has_builtin(__is_rvalue_reference)
2530
2631template <class _Tp>
27struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {};
32struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : _BoolConstant<__is_lvalue_reference(_Tp)> {};
2833
2934template <class _Tp>
30struct _LIBCPP_TEMPLATE_VIS is_reference : _BoolConstant<__is_reference(_Tp)> {};
35struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : _BoolConstant<__is_rvalue_reference(_Tp)> {};
3136
3237# if _LIBCPP_STD_VER >= 17
3338template <class _Tp>
34inline constexpr bool is_reference_v = __is_reference(_Tp);
35template <class _Tp>
3639inline constexpr bool is_lvalue_reference_v = __is_lvalue_reference(_Tp);
3740template <class _Tp>
3841inline constexpr bool is_rvalue_reference_v = __is_rvalue_reference(_Tp);
3942# endif
4043
41#else // __has_builtin(__is_lvalue_reference) && etc...
44#else // __has_builtin(__is_lvalue_reference)
4245
4346template <class _Tp>
4447struct _LIBCPP_TEMPLATE_VIS is_lvalue_reference : public false_type {};
......@@ -50,17 +53,7 @@ struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference : public false_type {};
5053template <class _Tp>
5154struct _LIBCPP_TEMPLATE_VIS is_rvalue_reference<_Tp&&> : public true_type {};
5255
53template <class _Tp>
54struct _LIBCPP_TEMPLATE_VIS is_reference : public false_type {};
55template <class _Tp>
56struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&> : public true_type {};
57template <class _Tp>
58struct _LIBCPP_TEMPLATE_VIS is_reference<_Tp&&> : public true_type {};
59
6056# if _LIBCPP_STD_VER >= 17
61template <class _Tp>
62inline constexpr bool is_reference_v = is_reference<_Tp>::value;
63
6457template <class _Tp>
6558inline constexpr bool is_lvalue_reference_v = is_lvalue_reference<_Tp>::value;
6659
......@@ -68,7 +61,7 @@ template <class _Tp>
6861inline constexpr bool is_rvalue_reference_v = is_rvalue_reference<_Tp>::value;
6962# endif
7063
71#endif // __has_builtin(__is_lvalue_reference) && etc...
64#endif // __has_builtin(__is_lvalue_reference)
7265
7366_LIBCPP_END_NAMESPACE_STD
7467
lib/libcxx/include/__type_traits/is_reference_wrapper.h+1-3
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_REFERENCE_WRAPPER_H
1111
1212#include <__config>
13#include <__fwd/functional.h>
1314#include <__type_traits/integral_constant.h>
1415#include <__type_traits/remove_cv.h>
1516
......@@ -19,9 +20,6 @@
1920
2021_LIBCPP_BEGIN_NAMESPACE_STD
2122
22template <class _Tp>
23class _LIBCPP_TEMPLATE_VIS reference_wrapper;
24
2523template <class _Tp>
2624struct __is_reference_wrapper_impl : public false_type {};
2725template <class _Tp>
lib/libcxx/include/__type_traits/is_scalar.h+1-1
......@@ -49,7 +49,7 @@ struct _LIBCPP_TEMPLATE_VIS is_scalar
4949 bool, is_arithmetic<_Tp>::value ||
5050 is_member_pointer<_Tp>::value ||
5151 is_pointer<_Tp>::value ||
52 __is_nullptr_t<_Tp>::value ||
52 __is_null_pointer_v<_Tp> ||
5353 __is_block<_Tp>::value ||
5454 is_enum<_Tp>::value> {};
5555// clang-format on
lib/libcxx/include/__type_traits/is_scoped_enum.h deleted-40
......@@ -1,40 +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_SCOPED_ENUM_H
10#define _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_convertible.h>
15#include <__type_traits/is_enum.h>
16#include <__type_traits/underlying_type.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#if _LIBCPP_STD_VER >= 23
25template <class _Tp, bool = is_enum_v<_Tp> >
26struct __is_scoped_enum_helper : false_type {};
27
28template <class _Tp>
29struct __is_scoped_enum_helper<_Tp, true> : public bool_constant<!is_convertible_v<_Tp, underlying_type_t<_Tp> > > {};
30
31template <class _Tp>
32struct _LIBCPP_TEMPLATE_VIS is_scoped_enum : public __is_scoped_enum_helper<_Tp> {};
33
34template <class _Tp>
35inline constexpr bool is_scoped_enum_v = is_scoped_enum<_Tp>::value;
36#endif
37
38_LIBCPP_END_NAMESPACE_STD
39
40#endif // _LIBCPP___TYPE_TRAITS_IS_SCOPED_ENUM_H
lib/libcxx/include/__type_traits/is_swappable.h+39-69
......@@ -11,16 +11,12 @@
1111
1212#include <__config>
1313#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/conditional.h>
1514#include <__type_traits/enable_if.h>
16#include <__type_traits/is_move_assignable.h>
17#include <__type_traits/is_move_constructible.h>
18#include <__type_traits/is_nothrow_move_assignable.h>
19#include <__type_traits/is_nothrow_move_constructible.h>
20#include <__type_traits/is_referenceable.h>
21#include <__type_traits/is_same.h>
22#include <__type_traits/is_void.h>
23#include <__type_traits/nat.h>
15#include <__type_traits/is_assignable.h>
16#include <__type_traits/is_constructible.h>
17#include <__type_traits/is_nothrow_assignable.h>
18#include <__type_traits/is_nothrow_constructible.h>
19#include <__type_traits/void_t.h>
2420#include <__utility/declval.h>
2521#include <cstddef>
2622
......@@ -30,10 +26,17 @@
3026
3127_LIBCPP_BEGIN_NAMESPACE_STD
3228
29template <class _Tp, class _Up, class = void>
30inline const bool __is_swappable_with_v = false;
31
3332template <class _Tp>
34struct __is_swappable;
33inline const bool __is_swappable_v = __is_swappable_with_v<_Tp&, _Tp&>;
34
35template <class _Tp, class _Up, bool = __is_swappable_with_v<_Tp, _Up> >
36inline const bool __is_nothrow_swappable_with_v = false;
37
3538template <class _Tp>
36struct __is_nothrow_swappable;
39inline const bool __is_nothrow_swappable_v = __is_nothrow_swappable_with_v<_Tp&, _Tp&>;
3740
3841#ifndef _LIBCPP_CXX03_LANG
3942template <class _Tp>
......@@ -47,85 +50,52 @@ template <class _Tp>
4750inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __swap_result_t<_Tp> swap(_Tp& __x, _Tp& __y)
4851 _NOEXCEPT_(is_nothrow_move_constructible<_Tp>::value&& is_nothrow_move_assignable<_Tp>::value);
4952
50template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> = 0>
51inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np])
52 _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value);
53template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> = 0>
54inline _LIBCPP_HIDE_FROM_ABI
55_LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np]) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>);
5356
54namespace __detail {
5557// ALL generic swap overloads MUST already have a declaration available at this point.
5658
57template <class _Tp, class _Up = _Tp, bool _NotVoid = !is_void<_Tp>::value && !is_void<_Up>::value>
58struct __swappable_with {
59 template <class _LHS, class _RHS>
60 static decltype(swap(std::declval<_LHS>(), std::declval<_RHS>())) __test_swap(int);
61 template <class, class>
62 static __nat __test_swap(long);
63
64 // Extra parens are needed for the C++03 definition of decltype.
65 typedef decltype((__test_swap<_Tp, _Up>(0))) __swap1;
66 typedef decltype((__test_swap<_Up, _Tp>(0))) __swap2;
67
68 static const bool value = _IsNotSame<__swap1, __nat>::value && _IsNotSame<__swap2, __nat>::value;
69};
59template <class _Tp, class _Up>
60inline const bool __is_swappable_with_v<_Tp,
61 _Up,
62 __void_t<decltype(swap(std::declval<_Tp>(), std::declval<_Up>())),
63 decltype(swap(std::declval<_Up>(), std::declval<_Tp>()))> > = true;
7064
65#ifndef _LIBCPP_CXX03_LANG // C++03 doesn't have noexcept, so things are never nothrow swappable
7166template <class _Tp, class _Up>
72struct __swappable_with<_Tp, _Up, false> : false_type {};
73
74template <class _Tp, class _Up = _Tp, bool _Swappable = __swappable_with<_Tp, _Up>::value>
75struct __nothrow_swappable_with {
76 static const bool value =
77#ifndef _LIBCPP_HAS_NO_NOEXCEPT
78 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>()))&& noexcept(
79 swap(std::declval<_Up>(), std::declval<_Tp>()));
80#else
81 false;
67inline const bool __is_nothrow_swappable_with_v<_Tp, _Up, true> =
68 noexcept(swap(std::declval<_Tp>(), std::declval<_Up>())) &&
69 noexcept(swap(std::declval<_Up>(), std::declval<_Tp>()));
8270#endif
83};
8471
85template <class _Tp, class _Up>
86struct __nothrow_swappable_with<_Tp, _Up, false> : false_type {};
72#if _LIBCPP_STD_VER >= 17
8773
88} // namespace __detail
74template <class _Tp, class _Up>
75inline constexpr bool is_swappable_with_v = __is_swappable_with_v<_Tp, _Up>;
8976
90template <class _Tp>
91struct __is_swappable : public integral_constant<bool, __detail::__swappable_with<_Tp&>::value> {};
77template <class _Tp, class _Up>
78struct _LIBCPP_TEMPLATE_VIS is_swappable_with : bool_constant<is_swappable_with_v<_Tp, _Up>> {};
9279
9380template <class _Tp>
94struct __is_nothrow_swappable : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp&>::value> {};
95
96#if _LIBCPP_STD_VER >= 17
97
98template <class _Tp, class _Up>
99struct _LIBCPP_TEMPLATE_VIS is_swappable_with
100 : public integral_constant<bool, __detail::__swappable_with<_Tp, _Up>::value> {};
81inline constexpr bool is_swappable_v =
82 is_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
10183
10284template <class _Tp>
103struct _LIBCPP_TEMPLATE_VIS is_swappable
104 : public __conditional_t<__libcpp_is_referenceable<_Tp>::value,
105 is_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >,
106 false_type> {};
85struct _LIBCPP_TEMPLATE_VIS is_swappable : bool_constant<is_swappable_v<_Tp>> {};
10786
10887template <class _Tp, class _Up>
109struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with
110 : public integral_constant<bool, __detail::__nothrow_swappable_with<_Tp, _Up>::value> {};
111
112template <class _Tp>
113struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable
114 : public __conditional_t<__libcpp_is_referenceable<_Tp>::value,
115 is_nothrow_swappable_with<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp> >,
116 false_type> {};
88inline constexpr bool is_nothrow_swappable_with_v = __is_nothrow_swappable_with_v<_Tp, _Up>;
11789
11890template <class _Tp, class _Up>
119inline constexpr bool is_swappable_with_v = is_swappable_with<_Tp, _Up>::value;
91struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable_with : bool_constant<is_nothrow_swappable_with_v<_Tp, _Up>> {};
12092
12193template <class _Tp>
122inline constexpr bool is_swappable_v = is_swappable<_Tp>::value;
123
124template <class _Tp, class _Up>
125inline constexpr bool is_nothrow_swappable_with_v = is_nothrow_swappable_with<_Tp, _Up>::value;
94inline constexpr bool is_nothrow_swappable_v =
95 is_nothrow_swappable_with_v<__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<_Tp>>;
12696
12797template <class _Tp>
128inline constexpr bool is_nothrow_swappable_v = is_nothrow_swappable<_Tp>::value;
98struct _LIBCPP_TEMPLATE_VIS is_nothrow_swappable : bool_constant<is_nothrow_swappable_v<_Tp>> {};
12999
130100#endif // _LIBCPP_STD_VER >= 17
131101
lib/libcxx/include/__type_traits/is_trivially_assignable.h+25
......@@ -10,6 +10,9 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
1111
1212#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/add_rvalue_reference.h>
1316#include <__type_traits/integral_constant.h>
1417
1518#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -26,6 +29,28 @@ template <class _Tp, class _Arg>
2629inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg);
2730#endif
2831
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
34 : public integral_constant<
35 bool,
36 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_lvalue_reference_t<const _Tp>)> {};
37
38#if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
41#endif
42
43template <class _Tp>
44struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
45 : public integral_constant<
46 bool,
47 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
48
49#if _LIBCPP_STD_VER >= 17
50template <class _Tp>
51inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
52#endif
53
2954_LIBCPP_END_NAMESPACE_STD
3055
3156#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_constructible.h+29
......@@ -10,6 +10,8 @@
1010#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
1111
1212#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
1315#include <__type_traits/integral_constant.h>
1416
1517#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -27,6 +29,33 @@ template <class _Tp, class... _Args>
2729inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...);
2830#endif
2931
32template <class _Tp>
33struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
34 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
35
36#if _LIBCPP_STD_VER >= 17
37template <class _Tp>
38inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
39#endif
40
41template <class _Tp>
42struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
43 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
44
45#if _LIBCPP_STD_VER >= 17
46template <class _Tp>
47inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
48#endif
49
50template <class _Tp>
51struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
52 : public integral_constant<bool, __is_trivially_constructible(_Tp)> {};
53
54#if _LIBCPP_STD_VER >= 17
55template <class _Tp>
56inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp);
57#endif
58
3059_LIBCPP_END_NAMESPACE_STD
3160
3261#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_assignable.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_TRIVIALLY_COPY_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_const.h>
14#include <__type_traits/add_lvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable
25 : public integral_constant<bool,
26 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>,
27 __add_lvalue_reference_t<typename add_const<_Tp>::type>)> {};
28
29#if _LIBCPP_STD_VER >= 17
30template <class _Tp>
31inline constexpr bool is_trivially_copy_assignable_v = is_trivially_copy_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_copy_constructible.h deleted-33
......@@ -1,33 +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_TRIVIALLY_COPY_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/integral_constant.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>
23struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible
24 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_lvalue_reference_t<const _Tp>)> {};
25
26#if _LIBCPP_STD_VER >= 17
27template <class _Tp>
28inline constexpr bool is_trivially_copy_constructible_v = is_trivially_copy_constructible<_Tp>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_COPY_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_default_constructible.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_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_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>
22struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible
23 : public integral_constant<bool, __is_trivially_constructible(_Tp)> {};
24
25#if _LIBCPP_STD_VER >= 17
26template <class _Tp>
27inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp);
28#endif
29
30_LIBCPP_END_NAMESPACE_STD
31
32#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_DEFAULT_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_move_assignable.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_TRIVIALLY_MOVE_ASSIGNABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
11
12#include <__config>
13#include <__type_traits/add_lvalue_reference.h>
14#include <__type_traits/add_rvalue_reference.h>
15#include <__type_traits/integral_constant.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>
24struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable
25 : public integral_constant<
26 bool,
27 __is_trivially_assignable(__add_lvalue_reference_t<_Tp>, __add_rvalue_reference_t<_Tp>)> {};
28
29#if _LIBCPP_STD_VER >= 17
30template <class _Tp>
31inline constexpr bool is_trivially_move_assignable_v = is_trivially_move_assignable<_Tp>::value;
32#endif
33
34_LIBCPP_END_NAMESPACE_STD
35
36#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_ASSIGNABLE_H
lib/libcxx/include/__type_traits/is_trivially_move_constructible.h deleted-33
......@@ -1,33 +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_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
11
12#include <__config>
13#include <__type_traits/add_rvalue_reference.h>
14#include <__type_traits/integral_constant.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>
23struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible
24 : public integral_constant<bool, __is_trivially_constructible(_Tp, __add_rvalue_reference_t<_Tp>)> {};
25
26#if _LIBCPP_STD_VER >= 17
27template <class _Tp>
28inline constexpr bool is_trivially_move_constructible_v = is_trivially_move_constructible<_Tp>::value;
29#endif
30
31_LIBCPP_END_NAMESPACE_STD
32
33#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_MOVE_CONSTRUCTIBLE_H
lib/libcxx/include/__type_traits/is_trivially_relocatable.h created+42
......@@ -0,0 +1,42 @@
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_TRIVIALLY_RELOCATABLE_H
10#define _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_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 trivially relocatable if a move construct + destroy of the original object is equivalent to
25// `memcpy(dst, src, sizeof(T))`.
26
27#if __has_builtin(__is_trivially_relocatable)
28template <class _Tp, class = void>
29struct __libcpp_is_trivially_relocatable : integral_constant<bool, __is_trivially_relocatable(_Tp)> {};
30#else
31template <class _Tp, class = void>
32struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {};
33#endif
34
35template <class _Tp>
36struct __libcpp_is_trivially_relocatable<_Tp,
37 __enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> >
38 : true_type {};
39
40_LIBCPP_END_NAMESPACE_STD
41
42#endif // _LIBCPP___TYPE_TRAITS_IS_TRIVIALLY_RELOCATABLE_H
lib/libcxx/include/__type_traits/is_void.h+2-18
......@@ -11,8 +11,6 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>
15#include <__type_traits/remove_cv.h>
1614
1715#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1816# pragma GCC system_header
......@@ -20,28 +18,14 @@
2018
2119_LIBCPP_BEGIN_NAMESPACE_STD
2220
23#if __has_builtin(__is_void)
24
2521template <class _Tp>
26struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_void(_Tp)> {};
22struct _LIBCPP_TEMPLATE_VIS is_void : _BoolConstant<__is_same(__remove_cv(_Tp), void)> {};
2723
2824# if _LIBCPP_STD_VER >= 17
2925template <class _Tp>
30inline constexpr bool is_void_v = __is_void(_Tp);
26inline constexpr bool is_void_v = __is_same(__remove_cv(_Tp), void);
3127# endif
3228
33#else
34
35template <class _Tp>
36struct _LIBCPP_TEMPLATE_VIS is_void : public is_same<__remove_cv_t<_Tp>, void> {};
37
38# if _LIBCPP_STD_VER >= 17
39template <class _Tp>
40inline constexpr bool is_void_v = is_void<_Tp>::value;
41# endif
42
43#endif // __has_builtin(__is_void)
44
4529_LIBCPP_END_NAMESPACE_STD
4630
4731#endif // _LIBCPP___TYPE_TRAITS_IS_VOID_H
lib/libcxx/include/__type_traits/make_signed.h+2-2
......@@ -10,7 +10,7 @@
1010#define _LIBCPP___TYPE_TRAITS_MAKE_SIGNED_H
1111
1212#include <__config>
13#include <__type_traits/apply_cv.h>
13#include <__type_traits/copy_cv.h>
1414#include <__type_traits/is_enum.h>
1515#include <__type_traits/is_integral.h>
1616#include <__type_traits/nat.h>
......@@ -70,7 +70,7 @@ template <> struct __make_signed<__uint128_t, true> {typedef __int128_t t
7070// clang-format on
7171
7272template <class _Tp>
73using __make_signed_t = __apply_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>;
73using __make_signed_t = __copy_cv_t<_Tp, typename __make_signed<__remove_cv_t<_Tp> >::type>;
7474
7575#endif // __has_builtin(__make_signed)
7676
lib/libcxx/include/__type_traits/make_unsigned.h+2-2
......@@ -10,8 +10,8 @@
1010#define _LIBCPP___TYPE_TRAITS_MAKE_UNSIGNED_H
1111
1212#include <__config>
13#include <__type_traits/apply_cv.h>
1413#include <__type_traits/conditional.h>
14#include <__type_traits/copy_cv.h>
1515#include <__type_traits/is_enum.h>
1616#include <__type_traits/is_integral.h>
1717#include <__type_traits/is_unsigned.h>
......@@ -72,7 +72,7 @@ template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_
7272// clang-format on
7373
7474template <class _Tp>
75using __make_unsigned_t = __apply_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>;
75using __make_unsigned_t = __copy_cv_t<_Tp, typename __make_unsigned<__remove_cv_t<_Tp> >::type>;
7676
7777#endif // __has_builtin(__make_unsigned)
7878
lib/libcxx/include/__type_traits/noexcept_move_assign_container.h+1-1
......@@ -12,7 +12,7 @@
1212#include <__config>
1313#include <__memory/allocator_traits.h>
1414#include <__type_traits/integral_constant.h>
15#include <__type_traits/is_nothrow_move_assignable.h>
15#include <__type_traits/is_nothrow_assignable.h>
1616
1717#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1818# pragma GCC system_header
lib/libcxx/include/__type_traits/operation_traits.h deleted-40
......@@ -1,40 +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_OPERATION_TRAITS_H
10#define _LIBCPP___TYPE_TRAITS_OPERATION_TRAITS_H
11
12#include <__config>
13#include <__type_traits/integral_constant.h>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21// Tags to represent the canonical operations
22struct __equal_tag {};
23struct __plus_tag {};
24
25// This class template is used to determine whether an operation "desugars"
26// (or boils down) to a given canonical operation.
27//
28// For example, `std::equal_to<>`, our internal `std::__equal_to` helper and
29// `ranges::equal_to` are all just fancy ways of representing a transparent
30// equality operation, so they all desugar to `__equal_tag`.
31//
32// This is useful to optimize some functions in cases where we know e.g. the
33// predicate being passed is actually going to call a builtin operator, or has
34// some specific semantics.
35template <class _CanonicalTag, class _Operation, class... _Args>
36struct __desugars_to : false_type {};
37
38_LIBCPP_END_NAMESPACE_STD
39
40#endif // _LIBCPP___TYPE_TRAITS_OPERATION_TRAITS_H
lib/libcxx/include/__type_traits/promote.h+38-4
......@@ -11,8 +11,12 @@
1111
1212#include <__config>
1313#include <__type_traits/integral_constant.h>
14#include <__type_traits/is_same.h>
15#include <__utility/declval.h>
14#include <__type_traits/is_arithmetic.h>
15
16#if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER == 1700
17# include <__type_traits/is_same.h>
18# include <__utility/declval.h>
19#endif
1620
1721#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1822# pragma GCC system_header
......@@ -20,6 +24,34 @@
2024
2125_LIBCPP_BEGIN_NAMESPACE_STD
2226
27// TODO(LLVM-20): Remove this workaround
28#if !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER != 1700
29
30template <class... _Args>
31class __promote {
32 static_assert((is_arithmetic<_Args>::value && ...));
33
34 static float __test(float);
35 static double __test(char);
36 static double __test(int);
37 static double __test(unsigned);
38 static double __test(long);
39 static double __test(unsigned long);
40 static double __test(long long);
41 static double __test(unsigned long long);
42# ifndef _LIBCPP_HAS_NO_INT128
43 static double __test(__int128_t);
44 static double __test(__uint128_t);
45# endif
46 static double __test(double);
47 static long double __test(long double);
48
49public:
50 using type = decltype((__test(_Args()) + ...));
51};
52
53#else
54
2355template <class _Tp>
2456struct __numeric_type {
2557 static void __test(...);
......@@ -31,10 +63,10 @@ struct __numeric_type {
3163 static double __test(unsigned long);
3264 static double __test(long long);
3365 static double __test(unsigned long long);
34#ifndef _LIBCPP_HAS_NO_INT128
66# ifndef _LIBCPP_HAS_NO_INT128
3567 static double __test(__int128_t);
3668 static double __test(__uint128_t);
37#endif
69# endif
3870 static double __test(double);
3971 static long double __test(long double);
4072
......@@ -89,6 +121,8 @@ public:
89121template <class _A1, class _A2 = void, class _A3 = void>
90122class __promote : public __promote_imp<_A1, _A2, _A3> {};
91123
124#endif // !defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1700
125
92126_LIBCPP_END_NAMESPACE_STD
93127
94128#endif // _LIBCPP___TYPE_TRAITS_PROMOTE_H
lib/libcxx/include/__type_traits/remove_pointer.h+5
......@@ -23,8 +23,13 @@ struct remove_pointer {
2323 using type _LIBCPP_NODEBUG = __remove_pointer(_Tp);
2424};
2525
26# ifdef _LIBCPP_COMPILER_GCC
27template <class _Tp>
28using __remove_pointer_t = typename remove_pointer<_Tp>::type;
29# else
2630template <class _Tp>
2731using __remove_pointer_t = __remove_pointer(_Tp);
32# endif
2833#else
2934// clang-format off
3035template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_pointer {typedef _LIBCPP_NODEBUG _Tp type;};
lib/libcxx/include/__type_traits/remove_reference.h+7-7
......@@ -10,7 +10,6 @@
1010#define _LIBCPP___TYPE_TRAITS_REMOVE_REFERENCE_H
1111
1212#include <__config>
13#include <cstddef>
1413
1514#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1615# pragma GCC system_header
......@@ -26,15 +25,16 @@ struct remove_reference {
2625
2726template <class _Tp>
2827using __libcpp_remove_reference_t = __remove_reference_t(_Tp);
29#else
30// clang-format off
31template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference {typedef _LIBCPP_NODEBUG _Tp type;};
32template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&> {typedef _LIBCPP_NODEBUG _Tp type;};
33template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_reference<_Tp&&> {typedef _LIBCPP_NODEBUG _Tp type;};
34// clang-format on
28#elif __has_builtin(__remove_reference)
29template <class _Tp>
30struct remove_reference {
31 using type _LIBCPP_NODEBUG = __remove_reference(_Tp);
32};
3533
3634template <class _Tp>
3735using __libcpp_remove_reference_t = typename remove_reference<_Tp>::type;
36#else
37# error "remove_reference not implemented!"
3838#endif // __has_builtin(__remove_reference_t)
3939
4040#if _LIBCPP_STD_VER >= 14
lib/libcxx/include/__type_traits/unwrap_ref.h+1-6
......@@ -10,6 +10,7 @@
1010#define _LIBCPP___TYPE_TRAITS_UNWRAP_REF_H
1111
1212#include <__config>
13#include <__fwd/functional.h>
1314#include <__type_traits/decay.h>
1415
1516#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -23,17 +24,11 @@ struct __unwrap_reference {
2324 typedef _LIBCPP_NODEBUG _Tp type;
2425};
2526
26template <class _Tp>
27class reference_wrapper;
28
2927template <class _Tp>
3028struct __unwrap_reference<reference_wrapper<_Tp> > {
3129 typedef _LIBCPP_NODEBUG _Tp& type;
3230};
3331
34template <class _Tp>
35struct decay;
36
3732#if _LIBCPP_STD_VER >= 20
3833template <class _Tp>
3934struct unwrap_reference : __unwrap_reference<_Tp> {};
lib/libcxx/include/__utility/as_const.h+1-1
......@@ -22,7 +22,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2222
2323#if _LIBCPP_STD_VER >= 17
2424template <class _Tp>
25_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept {
25[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept {
2626 return __t;
2727}
2828
lib/libcxx/include/__utility/exception_guard.h+3-3
......@@ -11,7 +11,7 @@
1111
1212#include <__assert>
1313#include <__config>
14#include <__type_traits/is_nothrow_move_constructible.h>
14#include <__type_traits/is_nothrow_constructible.h>
1515#include <__utility/exchange.h>
1616#include <__utility/move.h>
1717
......@@ -96,8 +96,8 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_exceptions);
9696template <class _Rollback>
9797struct __exception_guard_noexceptions {
9898 __exception_guard_noexceptions() = delete;
99 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
100 _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {}
99 _LIBCPP_HIDE_FROM_ABI
100 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG explicit __exception_guard_noexceptions(_Rollback) {}
101101
102102 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_NODEBUG
103103 __exception_guard_noexceptions(__exception_guard_noexceptions&& __other)
lib/libcxx/include/__utility/exchange.h+1-1
......@@ -11,7 +11,7 @@
1111
1212#include <__config>
1313#include <__type_traits/is_nothrow_assignable.h>
14#include <__type_traits/is_nothrow_move_constructible.h>
14#include <__type_traits/is_nothrow_constructible.h>
1515#include <__utility/forward.h>
1616#include <__utility/move.h>
1717
lib/libcxx/include/__utility/forward.h+2-2
......@@ -21,13 +21,13 @@
2121_LIBCPP_BEGIN_NAMESPACE_STD
2222
2323template <class _Tp>
24_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
24_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
2525forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>& __t) _NOEXCEPT {
2626 return static_cast<_Tp&&>(__t);
2727}
2828
2929template <class _Tp>
30_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
30_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&&
3131forward(_LIBCPP_LIFETIMEBOUND __libcpp_remove_reference_t<_Tp>&& __t) _NOEXCEPT {
3232 static_assert(!is_lvalue_reference<_Tp>::value, "cannot forward an rvalue as an lvalue");
3333 return static_cast<_Tp&&>(__t);
lib/libcxx/include/__utility/forward_like.h+2-2
......@@ -34,8 +34,8 @@ template <class _Ap, class _Bp>
3434using _ForwardLike = _OverrideRef<_Ap&&, _CopyConst<remove_reference_t<_Ap>, remove_reference_t<_Bp>>>;
3535
3636template <class _Tp, class _Up>
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept
38 -> _ForwardLike<_Tp, _Up> {
37[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto
38forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {
3939 return static_cast<_ForwardLike<_Tp, _Up>>(__ux);
4040}
4141
lib/libcxx/include/__utility/integer_sequence.h+12-75
......@@ -31,65 +31,16 @@ struct __integer_sequence {
3131 using __to_tuple_indices = __tuple_indices<(_Values + _Sp)...>;
3232};
3333
34#if !__has_builtin(__make_integer_seq) || defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
35
36namespace __detail {
37
38template <typename _Tp, size_t... _Extra>
39struct __repeat;
40template <typename _Tp, _Tp... _Np, size_t... _Extra>
41struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
42 typedef _LIBCPP_NODEBUG __integer_sequence<
43 _Tp,
44 _Np...,
45 sizeof...(_Np) + _Np...,
46 2 * sizeof...(_Np) + _Np...,
47 3 * sizeof...(_Np) + _Np...,
48 4 * sizeof...(_Np) + _Np...,
49 5 * sizeof...(_Np) + _Np...,
50 6 * sizeof...(_Np) + _Np...,
51 7 * sizeof...(_Np) + _Np...,
52 _Extra...>
53 type;
54};
55
56template <size_t _Np>
57struct __parity;
58template <size_t _Np>
59struct __make : __parity<_Np % 8>::template __pmake<_Np> {};
60
61// clang-format off
62template<> struct __make<0> { typedef __integer_sequence<size_t> type; };
63template<> struct __make<1> { typedef __integer_sequence<size_t, 0> type; };
64template<> struct __make<2> { typedef __integer_sequence<size_t, 0, 1> type; };
65template<> struct __make<3> { typedef __integer_sequence<size_t, 0, 1, 2> type; };
66template<> struct __make<4> { typedef __integer_sequence<size_t, 0, 1, 2, 3> type; };
67template<> struct __make<5> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4> type; };
68template<> struct __make<6> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5> type; };
69template<> struct __make<7> { typedef __integer_sequence<size_t, 0, 1, 2, 3, 4, 5, 6> type; };
70
71template<> struct __parity<0> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type> {}; };
72template<> struct __parity<1> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 1> {}; };
73template<> struct __parity<2> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 2, _Np - 1> {}; };
74template<> struct __parity<3> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 3, _Np - 2, _Np - 1> {}; };
75template<> struct __parity<4> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
76template<> struct __parity<5> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
77template<> struct __parity<6> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
78template<> struct __parity<7> { template<size_t _Np> struct __pmake : __repeat<typename __make<_Np / 8>::type, _Np - 7, _Np - 6, _Np - 5, _Np - 4, _Np - 3, _Np - 2, _Np - 1> {}; };
79// clang-format on
80
81} // namespace __detail
82
83#endif
84
8534#if __has_builtin(__make_integer_seq)
8635template <size_t _Ep, size_t _Sp>
8736using __make_indices_imp =
8837 typename __make_integer_seq<__integer_sequence, size_t, _Ep - _Sp>::template __to_tuple_indices<_Sp>;
89#else
38#elif __has_builtin(__integer_pack)
9039template <size_t _Ep, size_t _Sp>
91using __make_indices_imp = typename __detail::__make<_Ep - _Sp>::type::template __to_tuple_indices<_Sp>;
92
40using __make_indices_imp =
41 typename __integer_sequence<size_t, __integer_pack(_Ep - _Sp)...>::template __to_tuple_indices<_Sp>;
42#else
43# error "No known way to get an integer pack from the compiler"
9344#endif
9445
9546#if _LIBCPP_STD_VER >= 14
......@@ -104,34 +55,20 @@ struct _LIBCPP_TEMPLATE_VIS integer_sequence {
10455template <size_t... _Ip>
10556using index_sequence = integer_sequence<size_t, _Ip...>;
10657
107# if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE)
58# if __has_builtin(__make_integer_seq)
10859
10960template <class _Tp, _Tp _Ep>
110using __make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>;
111
112# else
61using make_integer_sequence _LIBCPP_NODEBUG = __make_integer_seq<integer_sequence, _Tp, _Ep>;
11362
114template <typename _Tp, _Tp _Np>
115using __make_integer_sequence_unchecked _LIBCPP_NODEBUG =
116 typename __detail::__make<_Np>::type::template __convert<integer_sequence, _Tp>;
63# elif __has_builtin(__integer_pack)
11764
118template <class _Tp, _Tp _Ep>
119struct __make_integer_sequence_checked {
120 static_assert(is_integral<_Tp>::value, "std::make_integer_sequence can only be instantiated with an integral type");
121 static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length");
122 // Workaround GCC bug by preventing bad installations when 0 <= _Ep
123 // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929
124 typedef _LIBCPP_NODEBUG __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type;
125};
126
127template <class _Tp, _Tp _Ep>
128using __make_integer_sequence _LIBCPP_NODEBUG = typename __make_integer_sequence_checked<_Tp, _Ep>::type;
65template <class _Tp, _Tp _SequenceSize>
66using make_integer_sequence _LIBCPP_NODEBUG = integer_sequence<_Tp, __integer_pack(_SequenceSize)...>;
12967
68# else
69# error "No known way to get an integer pack from the compiler"
13070# endif
13171
132template <class _Tp, _Tp _Np>
133using make_integer_sequence = __make_integer_sequence<_Tp, _Np>;
134
13572template <size_t _Np>
13673using make_index_sequence = make_integer_sequence<size_t, _Np>;
13774
lib/libcxx/include/__utility/is_pointer_in_range.h+7-7
......@@ -17,6 +17,7 @@
1717#include <__type_traits/is_constant_evaluated.h>
1818#include <__type_traits/void_t.h>
1919#include <__utility/declval.h>
20#include <__utility/is_valid_range.h>
2021
2122#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2223# pragma GCC system_header
......@@ -32,24 +33,23 @@ struct __is_less_than_comparable<_Tp, _Up, __void_t<decltype(std::declval<_Tp>()
3233};
3334
3435template <class _Tp, class _Up, __enable_if_t<__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0>
35_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range(
36 const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
37 if (__libcpp_is_constant_evaluated()) {
38 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__builtin_constant_p(__begin <= __end), "__begin and __end do not form a range");
36_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
37__is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
38 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__begin, __end), "[__begin, __end) is not a valid range");
3939
40 if (__libcpp_is_constant_evaluated()) {
4041 // If this is not a constant during constant evaluation we know that __ptr is not part of the allocation where
4142 // [__begin, __end) is.
4243 if (!__builtin_constant_p(__begin <= __ptr && __ptr < __end))
4344 return false;
4445 }
4546
46 // Checking this for unrelated pointers is technically UB, but no compiler optimizes based on it (currently).
4747 return !__less<>()(__ptr, __begin) && __less<>()(__ptr, __end);
4848}
4949
5050template <class _Tp, class _Up, __enable_if_t<!__is_less_than_comparable<const _Tp*, const _Up*>::value, int> = 0>
51_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool __is_pointer_in_range(
52 const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
51_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_SANITIZE("address") bool
52__is_pointer_in_range(const _Tp* __begin, const _Tp* __end, const _Up* __ptr) {
5353 if (__libcpp_is_constant_evaluated())
5454 return false;
5555
lib/libcxx/include/__utility/is_valid_range.h created+37
......@@ -0,0 +1,37 @@
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/move.h+4-4
......@@ -12,8 +12,8 @@
1212
1313#include <__config>
1414#include <__type_traits/conditional.h>
15#include <__type_traits/is_copy_constructible.h>
16#include <__type_traits/is_nothrow_move_constructible.h>
15#include <__type_traits/is_constructible.h>
16#include <__type_traits/is_nothrow_constructible.h>
1717#include <__type_traits/remove_reference.h>
1818
1919#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -26,7 +26,7 @@ _LIBCPP_PUSH_MACROS
2626_LIBCPP_BEGIN_NAMESPACE_STD
2727
2828template <class _Tp>
29_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
29_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __libcpp_remove_reference_t<_Tp>&&
3030move(_LIBCPP_LIFETIMEBOUND _Tp&& __t) _NOEXCEPT {
3131 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tp> _Up;
3232 return static_cast<_Up&&>(__t);
......@@ -37,7 +37,7 @@ using __move_if_noexcept_result_t =
3737 __conditional_t<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&, _Tp&&>;
3838
3939template <class _Tp>
40_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
40_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __move_if_noexcept_result_t<_Tp>
4141move_if_noexcept(_LIBCPP_LIFETIMEBOUND _Tp& __x) _NOEXCEPT {
4242 return std::move(__x);
4343}
lib/libcxx/include/__utility/no_destroy.h+10-19
......@@ -12,6 +12,7 @@
1212#include <__config>
1313#include <__type_traits/is_constant_evaluated.h>
1414#include <__utility/forward.h>
15#include <new>
1516
1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1718# pragma GCC system_header
......@@ -29,33 +30,23 @@ struct __uninitialized_tag {};
2930// initialization using __emplace.
3031template <class _Tp>
3132struct __no_destroy {
32 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(__uninitialized_tag) : __dummy_() {
33 if (__libcpp_is_constant_evaluated()) {
34 __dummy_ = char();
35 }
36 }
37 _LIBCPP_HIDE_FROM_ABI ~__no_destroy() {
38 // nothing
39 }
33 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit __no_destroy(__uninitialized_tag) : __obj_() {}
4034
4135 template <class... _Args>
42 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args)
43 : __obj_(std::forward<_Args>(__args)...) {}
36 _LIBCPP_HIDE_FROM_ABI explicit __no_destroy(_Args&&... __args) {
37 ::new ((void*)__obj_) _Tp(std::forward<_Args>(__args)...);
38 }
4439
4540 template <class... _Args>
46 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __emplace(_Args&&... __args) {
47 new (&__obj_) _Tp(std::forward<_Args>(__args)...);
48 return __obj_;
41 _LIBCPP_HIDE_FROM_ABI _Tp& __emplace(_Args&&... __args) {
42 return *(::new ((void*)__obj_) _Tp(std::forward<_Args>(__args)...));
4943 }
5044
51 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp& __get() { return __obj_; }
52 _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp const& __get() const { return __obj_; }
45 _LIBCPP_HIDE_FROM_ABI _Tp& __get() { return *reinterpret_cast<_Tp*>(__obj_); }
46 _LIBCPP_HIDE_FROM_ABI _Tp const& __get() const { return *reinterpret_cast<const _Tp*>(__obj_); }
5347
5448private:
55 union {
56 _Tp __obj_;
57 char __dummy_; // so we can initialize a member even with __uninitialized_tag for constexpr-friendliness
58 };
49 _ALIGNAS_TYPE(_Tp) char __obj_[sizeof(_Tp)];
5950};
6051
6152_LIBCPP_END_NAMESPACE_STD
lib/libcxx/include/__utility/pair.h+143-167
......@@ -14,14 +14,12 @@
1414#include <__concepts/different_from.h>
1515#include <__config>
1616#include <__fwd/array.h>
17#include <__fwd/get.h>
1817#include <__fwd/pair.h>
19#include <__fwd/subrange.h>
2018#include <__fwd/tuple.h>
21#include <__tuple/pair_like.h>
2219#include <__tuple/sfinae_helpers.h>
2320#include <__tuple/tuple_element.h>
2421#include <__tuple/tuple_indices.h>
22#include <__tuple/tuple_like_no_subrange.h>
2523#include <__tuple/tuple_size.h>
2624#include <__type_traits/common_reference.h>
2725#include <__type_traits/common_type.h>
......@@ -31,18 +29,13 @@
3129#include <__type_traits/is_assignable.h>
3230#include <__type_traits/is_constructible.h>
3331#include <__type_traits/is_convertible.h>
34#include <__type_traits/is_copy_assignable.h>
35#include <__type_traits/is_default_constructible.h>
3632#include <__type_traits/is_implicitly_default_constructible.h>
37#include <__type_traits/is_move_assignable.h>
3833#include <__type_traits/is_nothrow_assignable.h>
3934#include <__type_traits/is_nothrow_constructible.h>
40#include <__type_traits/is_nothrow_copy_assignable.h>
41#include <__type_traits/is_nothrow_copy_constructible.h>
42#include <__type_traits/is_nothrow_default_constructible.h>
43#include <__type_traits/is_nothrow_move_assignable.h>
35#include <__type_traits/is_reference.h>
4436#include <__type_traits/is_same.h>
4537#include <__type_traits/is_swappable.h>
38#include <__type_traits/is_trivially_relocatable.h>
4639#include <__type_traits/nat.h>
4740#include <__type_traits/remove_cvref.h>
4841#include <__type_traits/unwrap_ref.h>
......@@ -68,14 +61,6 @@ struct __non_trivially_copyable_base {
6861 __non_trivially_copyable_base(__non_trivially_copyable_base const&) _NOEXCEPT {}
6962};
7063
71#if _LIBCPP_STD_VER >= 23
72template <class _Tp>
73struct __is_specialization_of_subrange : false_type {};
74
75template <class _Iter, class _Sent, ranges::subrange_kind _Kind>
76struct __is_specialization_of_subrange<ranges::subrange<_Iter, _Sent, _Kind>> : true_type {};
77#endif
78
7964template <class _T1, class _T2>
8065struct _LIBCPP_TEMPLATE_VIS pair
8166#if defined(_LIBCPP_DEPRECATED_ABI_DISABLE_PAIR_TRIVIAL_COPY_CTOR)
......@@ -88,9 +73,46 @@ struct _LIBCPP_TEMPLATE_VIS pair
8873 _T1 first;
8974 _T2 second;
9075
76 using __trivially_relocatable =
77 __conditional_t<__libcpp_is_trivially_relocatable<_T1>::value && __libcpp_is_trivially_relocatable<_T2>::value,
78 pair,
79 void>;
80
9181 _LIBCPP_HIDE_FROM_ABI pair(pair const&) = default;
9282 _LIBCPP_HIDE_FROM_ABI pair(pair&&) = default;
9383
84 // When we are requested for pair to be trivially copyable by the ABI macro, we use defaulted members
85 // if it is both legal to do it (i.e. no references) and we have a way to actually implement it, which requires
86 // the __enable_if__ attribute before C++20.
87#ifdef _LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR
88 // FIXME: This should really just be a static constexpr variable. It's in a struct to avoid gdb printing the value
89 // when printing a pair
90 struct __has_defaulted_members {
91 static const bool value = !is_reference<first_type>::value && !is_reference<second_type>::value;
92 };
93# if _LIBCPP_STD_VER >= 20
94 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(const pair&)
95 requires __has_defaulted_members::value
96 = default;
97
98 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(pair&&)
99 requires __has_defaulted_members::value
100 = default;
101# elif __has_attribute(__enable_if__)
102 _LIBCPP_HIDE_FROM_ABI pair& operator=(const pair&)
103 __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;
104
105 _LIBCPP_HIDE_FROM_ABI pair& operator=(pair&&)
106 __attribute__((__enable_if__(__has_defaulted_members::value, ""))) = default;
107# else
108# error "_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR isn't supported with this compiler"
109# endif
110#else
111 struct __has_defaulted_members {
112 static const bool value = false;
113 };
114#endif // defined(_LIBCPP_ABI_TRIVIALLY_COPYABLE_PAIR) && __has_attribute(__enable_if__)
115
94116#ifdef _LIBCPP_CXX03_LANG
95117 _LIBCPP_HIDE_FROM_ABI pair() : first(), second() {}
96118
......@@ -108,10 +130,11 @@ struct _LIBCPP_TEMPLATE_VIS pair
108130 // Extension: This is provided in C++03 because it allows properly handling the
109131 // assignment to a pair containing references, which would be a hard
110132 // error otherwise.
111 template <class _U1,
112 class _U2,
113 class = __enable_if_t< is_assignable<first_type&, _U1 const&>::value &&
114 is_assignable<second_type&, _U2 const&>::value > >
133 template <
134 class _U1,
135 class _U2,
136 __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,
137 int> = 0>
115138 _LIBCPP_HIDE_FROM_ABI pair& operator=(pair<_U1, _U2> const& __p) {
116139 first = __p.first;
117140 second = __p.second;
......@@ -120,14 +143,13 @@ struct _LIBCPP_TEMPLATE_VIS pair
120143#else
121144 struct _CheckArgs {
122145 template <int&...>
123 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit_default() {
124 return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value &&
125 !__enable_implicit_default<>();
146 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {
147 return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
126148 }
127149
128150 template <int&...>
129 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit_default() {
130 return __is_implicitly_default_constructible<_T1>::value && __is_implicitly_default_constructible<_T2>::value;
151 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_default() {
152 return is_default_constructible<_T1>::value && is_default_constructible<_T2>::value;
131153 }
132154
133155 template <class _U1, class _U2>
......@@ -139,42 +161,23 @@ struct _LIBCPP_TEMPLATE_VIS pair
139161 static _LIBCPP_HIDE_FROM_ABI constexpr bool __is_implicit() {
140162 return is_convertible<_U1, first_type>::value && is_convertible<_U2, second_type>::value;
141163 }
142
143 template <class _U1, class _U2>
144 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_explicit() {
145 return __is_pair_constructible<_U1, _U2>() && !__is_implicit<_U1, _U2>();
146 }
147
148 template <class _U1, class _U2>
149 static _LIBCPP_HIDE_FROM_ABI constexpr bool __enable_implicit() {
150 return __is_pair_constructible<_U1, _U2>() && __is_implicit<_U1, _U2>();
151 }
152164 };
153165
154166 template <bool _MaybeEnable>
155167 using _CheckArgsDep _LIBCPP_NODEBUG =
156168 typename conditional< _MaybeEnable, _CheckArgs, __check_tuple_constructor_fail>::type;
157169
158 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_explicit_default(), int> = 0>
159 explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(
160 is_nothrow_default_constructible<first_type>::value&& is_nothrow_default_constructible<second_type>::value)
161 : first(), second() {}
162
163 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_implicit_default(), int> = 0>
164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR pair() _NOEXCEPT_(
165 is_nothrow_default_constructible<first_type>::value&& is_nothrow_default_constructible<second_type>::value)
170 template <bool _Dummy = true, __enable_if_t<_CheckArgsDep<_Dummy>::__enable_default(), int> = 0>
171 explicit(!_CheckArgsDep<_Dummy>::__enable_implicit_default()) _LIBCPP_HIDE_FROM_ABI constexpr pair() noexcept(
172 is_nothrow_default_constructible<first_type>::value && is_nothrow_default_constructible<second_type>::value)
166173 : first(), second() {}
167174
168 template <bool _Dummy = true,
169 __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_explicit<_T1 const&, _T2 const&>(), int> = 0>
170 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_T1 const& __t1, _T2 const& __t2)
171 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value&& is_nothrow_copy_constructible<second_type>::value)
172 : first(__t1), second(__t2) {}
173
174 template <bool _Dummy = true,
175 __enable_if_t<_CheckArgsDep<_Dummy>::template __enable_implicit<_T1 const&, _T2 const&>(), int> = 0>
176 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_T1 const& __t1, _T2 const& __t2)
177 _NOEXCEPT_(is_nothrow_copy_constructible<first_type>::value&& is_nothrow_copy_constructible<second_type>::value)
175 template <bool _Dummy = true,
176 __enable_if_t<_CheckArgsDep<_Dummy>::template __is_pair_constructible<_T1 const&, _T2 const&>(), int> = 0>
177 _LIBCPP_HIDE_FROM_ABI
178 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgsDep<_Dummy>::template __is_implicit<_T1 const&, _T2 const&>())
179 pair(_T1 const& __t1, _T2 const& __t2) noexcept(is_nothrow_copy_constructible<first_type>::value &&
180 is_nothrow_copy_constructible<second_type>::value)
178181 : first(__t1), second(__t2) {}
179182
180183 template <
......@@ -185,32 +188,15 @@ struct _LIBCPP_TEMPLATE_VIS pair
185188 class _U1,
186189 class _U2,
187190# endif
188 __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0 >
189 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(_U1&& __u1, _U2&& __u2)
190 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
191 is_nothrow_constructible<second_type, _U2>::value))
192 : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {
193 }
194
195 template <
196# if _LIBCPP_STD_VER >= 23 // http://wg21.link/P1951
197 class _U1 = _T1,
198 class _U2 = _T2,
199# else
200 class _U1,
201 class _U2,
202# endif
203 __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0 >
204 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(_U1&& __u1, _U2&& __u2)
205 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1>::value &&
206 is_nothrow_constructible<second_type, _U2>::value))
191 __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0 >
192 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())
193 pair(_U1&& __u1, _U2&& __u2) noexcept(is_nothrow_constructible<first_type, _U1>::value &&
194 is_nothrow_constructible<second_type, _U2>::value)
207195 : first(std::forward<_U1>(__u1)), second(std::forward<_U2>(__u2)) {
208196 }
209197
210198# if _LIBCPP_STD_VER >= 23
211 template <class _U1,
212 class _U2,
213 __enable_if_t< _CheckArgs::template __is_pair_constructible<_U1&, _U2&>() >* = nullptr>
199 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1&, _U2&>(), int> = 0>
214200 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<_U1&, _U2&>())
215201 pair(pair<_U1, _U2>& __p) noexcept((is_nothrow_constructible<first_type, _U1&>::value &&
216202 is_nothrow_constructible<second_type, _U2&>::value))
......@@ -219,36 +205,23 @@ struct _LIBCPP_TEMPLATE_VIS pair
219205
220206 template <class _U1,
221207 class _U2,
222 __enable_if_t<_CheckArgs::template __enable_explicit<_U1 const&, _U2 const&>(), int> = 0>
223 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2> const& __p)
224 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
225 is_nothrow_constructible<second_type, _U2 const&>::value))
226 : first(__p.first), second(__p.second) {}
227
228 template <class _U1,
229 class _U2,
230 __enable_if_t<_CheckArgs::template __enable_implicit<_U1 const&, _U2 const&>(), int> = 0>
231 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2> const& __p)
232 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1 const&>::value &&
233 is_nothrow_constructible<second_type, _U2 const&>::value))
208 __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1 const&, _U2 const&>(), int> = 0>
209 _LIBCPP_HIDE_FROM_ABI
210 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1 const&, _U2 const&>())
211 pair(pair<_U1, _U2> const& __p) noexcept(is_nothrow_constructible<first_type, _U1 const&>::value &&
212 is_nothrow_constructible<second_type, _U2 const&>::value)
234213 : first(__p.first), second(__p.second) {}
235214
236 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_explicit<_U1, _U2>(), int> = 0>
237 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(pair<_U1, _U2>&& __p)
238 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
239 is_nothrow_constructible<second_type, _U2&&>::value))
240 : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}
241
242 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __enable_implicit<_U1, _U2>(), int> = 0>
243 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(pair<_U1, _U2>&& __p)
244 _NOEXCEPT_((is_nothrow_constructible<first_type, _U1&&>::value &&
245 is_nothrow_constructible<second_type, _U2&&>::value))
215 template <class _U1, class _U2, __enable_if_t<_CheckArgs::template __is_pair_constructible<_U1, _U2>(), int> = 0>
216 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(!_CheckArgs::template __is_implicit<_U1, _U2>())
217 pair(pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, _U1&&>::value &&
218 is_nothrow_constructible<second_type, _U2&&>::value)
246219 : first(std::forward<_U1>(__p.first)), second(std::forward<_U2>(__p.second)) {}
247220
248221# if _LIBCPP_STD_VER >= 23
249222 template <class _U1,
250223 class _U2,
251 __enable_if_t< _CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>() >* = nullptr>
224 __enable_if_t<_CheckArgs::template __is_pair_constructible<const _U1&&, const _U2&&>(), int> = 0>
252225 _LIBCPP_HIDE_FROM_ABI constexpr explicit(!_CheckArgs::template __is_implicit<const _U1&&, const _U2&&>())
253226 pair(const pair<_U1, _U2>&& __p) noexcept(is_nothrow_constructible<first_type, const _U1&&>::value &&
254227 is_nothrow_constructible<second_type, const _U2&&>::value)
......@@ -256,19 +229,19 @@ struct _LIBCPP_TEMPLATE_VIS pair
256229# endif
257230
258231# if _LIBCPP_STD_VER >= 23
232 // TODO: Remove this workaround in LLVM 20. The bug got fixed in Clang 18.
259233 // This is a workaround for http://llvm.org/PR60710. We should be able to remove it once Clang is fixed.
260234 template <class _PairLike>
261235 _LIBCPP_HIDE_FROM_ABI static constexpr bool __pair_like_explicit_wknd() {
262 if constexpr (__pair_like<_PairLike>) {
236 if constexpr (__pair_like_no_subrange<_PairLike>) {
263237 return !is_convertible_v<decltype(std::get<0>(std::declval<_PairLike&&>())), first_type> ||
264238 !is_convertible_v<decltype(std::get<1>(std::declval<_PairLike&&>())), second_type>;
265239 }
266240 return false;
267241 }
268242
269 template <__pair_like _PairLike>
270 requires(!__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value &&
271 is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&
243 template <__pair_like_no_subrange _PairLike>
244 requires(is_constructible_v<first_type, decltype(std::get<0>(std::declval<_PairLike &&>()))> &&
272245 is_constructible_v<second_type, decltype(std::get<1>(std::declval<_PairLike &&>()))>)
273246 _LIBCPP_HIDE_FROM_ABI constexpr explicit(__pair_like_explicit_wknd<_PairLike>()) pair(_PairLike&& __p)
274247 : first(std::get<0>(std::forward<_PairLike>(__p))), second(std::get<1>(std::forward<_PairLike>(__p))) {}
......@@ -276,9 +249,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
276249
277250 template <class... _Args1, class... _Args2>
278251 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
279 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args)
280 _NOEXCEPT_((is_nothrow_constructible<first_type, _Args1...>::value &&
281 is_nothrow_constructible<second_type, _Args2...>::value))
252 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept(
253 is_nothrow_constructible<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value)
282254 : pair(__pc,
283255 __first_args,
284256 __second_args,
......@@ -286,38 +258,41 @@ struct _LIBCPP_TEMPLATE_VIS pair
286258 typename __make_tuple_indices<sizeof...(_Args2) >::type()) {}
287259
288260 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
289 operator=(__conditional_t< is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
290 pair,
291 __nat> const& __p)
292 _NOEXCEPT_(is_nothrow_copy_assignable<first_type>::value&& is_nothrow_copy_assignable<second_type>::value) {
261 operator=(__conditional_t<!__has_defaulted_members::value && is_copy_assignable<first_type>::value &&
262 is_copy_assignable<second_type>::value,
263 pair,
264 __nat> const& __p) noexcept(is_nothrow_copy_assignable<first_type>::value &&
265 is_nothrow_copy_assignable<second_type>::value) {
293266 first = __p.first;
294267 second = __p.second;
295268 return *this;
296269 }
297270
298 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(
299 __conditional_t< is_move_assignable<first_type>::value && is_move_assignable<second_type>::value, pair, __nat>&&
300 __p)
301 _NOEXCEPT_(is_nothrow_move_assignable<first_type>::value&& is_nothrow_move_assignable<second_type>::value) {
271 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair&
272 operator=(__conditional_t<!__has_defaulted_members::value && is_move_assignable<first_type>::value &&
273 is_move_assignable<second_type>::value,
274 pair,
275 __nat>&& __p) noexcept(is_nothrow_move_assignable<first_type>::value &&
276 is_nothrow_move_assignable<second_type>::value) {
302277 first = std::forward<first_type>(__p.first);
303278 second = std::forward<second_type>(__p.second);
304279 return *this;
305280 }
306281
307 template <class _U1,
308 class _U2,
309 __enable_if_t< is_assignable<first_type&, _U1 const&>::value &&
310 is_assignable<second_type&, _U2 const&>::value >* = nullptr>
282 template <
283 class _U1,
284 class _U2,
285 __enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,
286 int> = 0>
311287 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) {
312288 first = __p.first;
313289 second = __p.second;
314290 return *this;
315291 }
316292
317 template <
318 class _U1,
319 class _U2,
320 __enable_if_t< is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value >* = nullptr>
293 template <class _U1,
294 class _U2,
295 __enable_if_t<is_assignable<first_type&, _U1>::value && is_assignable<second_type&, _U2>::value, int> = 0>
321296 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2>&& __p) {
322297 first = std::forward<_U1>(__p.first);
323298 second = std::forward<_U2>(__p.second);
......@@ -325,6 +300,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
325300 }
326301
327302# if _LIBCPP_STD_VER >= 23
303 template <class = void>
328304 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair const& __p) const
329305 noexcept(is_nothrow_copy_assignable_v<const first_type> && is_nothrow_copy_assignable_v<const second_type>)
330306 requires(is_copy_assignable_v<const first_type> && is_copy_assignable_v<const second_type>)
......@@ -334,6 +310,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
334310 return *this;
335311 }
336312
313 template <class = void>
337314 _LIBCPP_HIDE_FROM_ABI constexpr const pair& operator=(pair&& __p) const
338315 noexcept(is_nothrow_assignable_v<const first_type&, first_type> &&
339316 is_nothrow_assignable_v<const second_type&, second_type>)
......@@ -362,8 +339,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
362339 return *this;
363340 }
364341
365 template <__pair_like _PairLike>
366 requires(__different_from<_PairLike, pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value &&
342 template <__pair_like_no_subrange _PairLike>
343 requires(__different_from<_PairLike, pair> &&
367344 is_assignable_v<first_type&, decltype(std::get<0>(std::declval<_PairLike>()))> &&
368345 is_assignable_v<second_type&, decltype(std::get<1>(std::declval<_PairLike>()))>)
369346 _LIBCPP_HIDE_FROM_ABI constexpr pair& operator=(_PairLike&& __p) {
......@@ -372,8 +349,8 @@ struct _LIBCPP_TEMPLATE_VIS pair
372349 return *this;
373350 }
374351
375 template <__pair_like _PairLike>
376 requires(__different_from<_PairLike, pair> && !__is_specialization_of_subrange<remove_cvref_t<_PairLike>>::value &&
352 template <__pair_like_no_subrange _PairLike>
353 requires(__different_from<_PairLike, pair> &&
377354 is_assignable_v<first_type const&, decltype(std::get<0>(std::declval<_PairLike>()))> &&
378355 is_assignable_v<second_type const&, decltype(std::get<1>(std::declval<_PairLike>()))>)
379356 _LIBCPP_HIDE_FROM_ABI constexpr pair const& operator=(_PairLike&& __p) const {
......@@ -387,38 +364,36 @@ struct _LIBCPP_TEMPLATE_VIS pair
387364 // pair-like types. This was historically provided as an extension.
388365# if _LIBCPP_STD_VER < 23
389366 // from std::tuple
390 template <
391 class _U1,
392 class _U2,
393 __enable_if_t< is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value >* = nullptr>
367 template <class _U1,
368 class _U2,
369 __enable_if_t<is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value, int> = 0>
394370 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2> const& __p)
395371 : first(std::get<0>(__p)), second(std::get<1>(__p)) {}
396372
397 template <
398 class _U1,
399 class _U2,
400 __enable_if_t< is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value &&
401 !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value) >* = nullptr>
373 template < class _U1,
374 class _U2,
375 __enable_if_t<is_constructible<_T1, _U1 const&>::value && is_constructible<_T2, _U2 const&>::value &&
376 !(is_convertible<_U1 const&, _T1>::value && is_convertible<_U2 const&, _T2>::value),
377 int> = 0>
402378 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2> const& __p)
403379 : first(std::get<0>(__p)), second(std::get<1>(__p)) {}
404380
405381 template <class _U1,
406382 class _U2,
407 __enable_if_t< is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value >* = nullptr>
383 __enable_if_t<is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value, int> = 0>
408384 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(tuple<_U1, _U2>&& __p)
409385 : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}
410386
411387 template <class _U1,
412388 class _U2,
413 __enable_if_t< is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value &&
414 !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) >* = nullptr>
389 __enable_if_t<is_constructible<_T1, _U1>::value && is_constructible<_T2, _U2>::value &&
390 !(is_convertible<_U1, _T1>::value && is_convertible<_U2, _T2>::value) > = 0>
415391 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(tuple<_U1, _U2>&& __p)
416392 : first(std::get<0>(std::move(__p))), second(std::get<1>(std::move(__p))) {}
417393
418 template <
419 class _U1,
420 class _U2,
421 __enable_if_t< is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value >* = nullptr>
394 template <class _U1,
395 class _U2,
396 __enable_if_t<is_assignable<_T1&, _U1 const&>::value && is_assignable<_T2&, _U2 const&>::value, int> = 0>
422397 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2> const& __p) {
423398 first = std::get<0>(__p);
424399 second = std::get<1>(__p);
......@@ -427,7 +402,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
427402
428403 template <class _U1,
429404 class _U2,
430 __enable_if_t< is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value >* = nullptr>
405 __enable_if_t<is_assignable<_T1&, _U1&&>::value && is_assignable<_T2&, _U2&&>::value, int> = 0>
431406 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(tuple<_U1, _U2>&& __p) {
432407 first = std::get<0>(std::move(__p));
433408 second = std::get<1>(std::move(__p));
......@@ -435,38 +410,37 @@ struct _LIBCPP_TEMPLATE_VIS pair
435410 }
436411
437412 // from std::array
438 template <
439 class _Up,
440 __enable_if_t< is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value >* = nullptr>
413 template <class _Up,
414 __enable_if_t<is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value, int> = 0>
441415 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2> const& __p) : first(__p[0]), second(__p[1]) {}
442416
443 template <
444 class _Up,
445 __enable_if_t< is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value &&
446 !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value) >* = nullptr>
417 template <class _Up,
418 __enable_if_t<is_constructible<_T1, _Up const&>::value && is_constructible<_T2, _Up const&>::value &&
419 !(is_convertible<_Up const&, _T1>::value && is_convertible<_Up const&, _T2>::value),
420 int> = 0>
447421 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2> const& __p)
448422 : first(__p[0]), second(__p[1]) {}
449423
450 template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value >* = nullptr>
424 template <class _Up, __enable_if_t< is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value, int> = 0>
451425 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair(array<_Up, 2>&& __p)
452426 : first(std::move(__p)[0]), second(std::move(__p)[1]) {}
453427
454428 template <class _Up,
455 __enable_if_t< is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value &&
456 !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value) >* = nullptr>
429 __enable_if_t<is_constructible<_T1, _Up>::value && is_constructible<_T2, _Up>::value &&
430 !(is_convertible<_Up, _T1>::value && is_convertible<_Up, _T2>::value),
431 int> = 0>
457432 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit pair(array<_Up, 2>&& __p)
458433 : first(std::move(__p)[0]), second(std::move(__p)[1]) {}
459434
460 template <
461 class _Up,
462 __enable_if_t< is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value >* = nullptr>
435 template <class _Up,
436 __enable_if_t<is_assignable<_T1&, _Up const&>::value && is_assignable<_T2&, _Up const&>::value, int> = 0>
463437 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2> const& __p) {
464438 first = std::get<0>(__p);
465439 second = std::get<1>(__p);
466440 return *this;
467441 }
468442
469 template <class _Up, __enable_if_t< is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value >* = nullptr>
443 template <class _Up, __enable_if_t<is_assignable<_T1&, _Up>::value && is_assignable<_T2&, _Up>::value, int> = 0>
470444 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair& operator=(array<_Up, 2>&& __p) {
471445 first = std::get<0>(std::move(__p));
472446 second = std::get<1>(std::move(__p));
......@@ -476,7 +450,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
476450#endif // _LIBCPP_CXX03_LANG
477451
478452 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair& __p)
479 _NOEXCEPT_(__is_nothrow_swappable<first_type>::value&& __is_nothrow_swappable<second_type>::value) {
453 _NOEXCEPT_(__is_nothrow_swappable_v<first_type>&& __is_nothrow_swappable_v<second_type>) {
480454 using std::swap;
481455 swap(first, __p.first);
482456 swap(second, __p.second);
......@@ -484,7 +458,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
484458
485459#if _LIBCPP_STD_VER >= 23
486460 _LIBCPP_HIDE_FROM_ABI constexpr void swap(const pair& __p) const
487 noexcept(__is_nothrow_swappable<const first_type>::value && __is_nothrow_swappable<const second_type>::value) {
461 noexcept(__is_nothrow_swappable_v<const first_type> && __is_nothrow_swappable_v<const second_type>) {
488462 using std::swap;
489463 swap(first, __p.first);
490464 swap(second, __p.second);
......@@ -499,7 +473,9 @@ private:
499473 tuple<_Args1...>& __first_args,
500474 tuple<_Args2...>& __second_args,
501475 __tuple_indices<_I1...>,
502 __tuple_indices<_I2...>);
476 __tuple_indices<_I2...>)
477 : first(std::forward<_Args1>(std::get<_I1>(__first_args))...),
478 second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
503479#endif
504480};
505481
......@@ -578,15 +554,15 @@ struct common_type<pair<_T1, _T2>, pair<_U1, _U2>> {
578554};
579555#endif // _LIBCPP_STD_VER >= 23
580556
581template <class _T1, class _T2, __enable_if_t<__is_swappable<_T1>::value && __is_swappable<_T2>::value, int> = 0>
557template <class _T1, class _T2, __enable_if_t<__is_swappable_v<_T1> && __is_swappable_v<_T2>, int> = 0>
582558inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
583 _NOEXCEPT_((__is_nothrow_swappable<_T1>::value && __is_nothrow_swappable<_T2>::value)) {
559 _NOEXCEPT_(__is_nothrow_swappable_v<_T1>&& __is_nothrow_swappable_v<_T2>) {
584560 __x.swap(__y);
585561}
586562
587563#if _LIBCPP_STD_VER >= 23
588564template <class _T1, class _T2>
589 requires(__is_swappable<const _T1>::value && __is_swappable<const _T2>::value)
565 requires(__is_swappable_v<const _T1> && __is_swappable_v<const _T2>)
590566_LIBCPP_HIDE_FROM_ABI constexpr void
591567swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x.swap(__y))) {
592568 __x.swap(__y);
......@@ -594,9 +570,9 @@ swap(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) noexcept(noexcept(__x
594570#endif
595571
596572template <class _T1, class _T2>
597inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
598 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
599 make_pair(_T1&& __t1, _T2&& __t2) {
573inline _LIBCPP_HIDE_FROM_ABI
574_LIBCPP_CONSTEXPR_SINCE_CXX14 pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>
575make_pair(_T1&& __t1, _T2&& __t2) {
600576 return pair<typename __unwrap_ref_decay<_T1>::type, typename __unwrap_ref_decay<_T2>::type>(
601577 std::forward<_T1>(__t1), std::forward<_T2>(__t2));
602578}
lib/libcxx/include/__utility/private_constructor_tag.h created+28
......@@ -0,0 +1,28 @@
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__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H
11#define _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H
12
13#include <__config>
14
15#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16# pragma GCC system_header
17#endif
18
19_LIBCPP_BEGIN_NAMESPACE_STD
20
21// This tag allows defining non-standard exposition-only constructors while
22// preventing users from being able to use them, since this reserved-name tag
23// needs to be used.
24struct __private_constructor_tag {};
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP__UTILITY_PRIVATE_CONSTRUCTOR_TAG_H
lib/libcxx/include/__utility/rel_ops.h+4-4
......@@ -20,22 +20,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2020namespace rel_ops {
2121
2222template <class _Tp>
23inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
23inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator!=(const _Tp& __x, const _Tp& __y) {
2424 return !(__x == __y);
2525}
2626
2727template <class _Tp>
28inline _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
28inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>(const _Tp& __x, const _Tp& __y) {
2929 return __y < __x;
3030}
3131
3232template <class _Tp>
33inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
33inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator<=(const _Tp& __x, const _Tp& __y) {
3434 return !(__y < __x);
3535}
3636
3737template <class _Tp>
38inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
38inline _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool operator>=(const _Tp& __x, const _Tp& __y) {
3939 return !(__x < __y);
4040}
4141
lib/libcxx/include/__utility/small_buffer.h+1-1
......@@ -12,8 +12,8 @@
1212#include <__config>
1313#include <__memory/construct_at.h>
1414#include <__type_traits/decay.h>
15#include <__type_traits/is_trivially_constructible.h>
1516#include <__type_traits/is_trivially_destructible.h>
16#include <__type_traits/is_trivially_move_constructible.h>
1717#include <__utility/exception_guard.h>
1818#include <__utility/forward.h>
1919#include <cstddef>
lib/libcxx/include/__utility/swap.h+6-6
......@@ -10,10 +10,10 @@
1010#define _LIBCPP___UTILITY_SWAP_H
1111
1212#include <__config>
13#include <__type_traits/is_move_assignable.h>
14#include <__type_traits/is_move_constructible.h>
15#include <__type_traits/is_nothrow_move_assignable.h>
16#include <__type_traits/is_nothrow_move_constructible.h>
13#include <__type_traits/is_assignable.h>
14#include <__type_traits/is_constructible.h>
15#include <__type_traits/is_nothrow_assignable.h>
16#include <__type_traits/is_nothrow_constructible.h>
1717#include <__type_traits/is_swappable.h>
1818#include <__utility/declval.h>
1919#include <__utility/move.h>
......@@ -44,9 +44,9 @@ inline _LIBCPP_HIDE_FROM_ABI __swap_result_t<_Tp> _LIBCPP_CONSTEXPR_SINCE_CXX20
4444 __y = std::move(__t);
4545}
4646
47template <class _Tp, size_t _Np, __enable_if_t<__is_swappable<_Tp>::value, int> >
47template <class _Tp, size_t _Np, __enable_if_t<__is_swappable_v<_Tp>, int> >
4848inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(_Tp (&__a)[_Np], _Tp (&__b)[_Np])
49 _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
49 _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
5050 for (size_t __i = 0; __i != _Np; ++__i) {
5151 swap(__a[__i], __b[__i]);
5252 }
lib/libcxx/include/__utility/to_underlying.h+1-1
......@@ -28,7 +28,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr typename underlying_type<_Tp>::type __to_underly
2828
2929#if _LIBCPP_STD_VER >= 23
3030template <class _Tp>
31_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept {
31[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr underlying_type_t<_Tp> to_underlying(_Tp __val) noexcept {
3232 return std::__to_underlying(__val);
3333}
3434#endif
lib/libcxx/include/__verbose_abort+1-2
......@@ -10,7 +10,6 @@
1010#ifndef _LIBCPP___VERBOSE_ABORT
1111#define _LIBCPP___VERBOSE_ABORT
1212
13#include <__availability>
1413#include <__config>
1514
1615#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -22,7 +21,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
2221// This function should never be called directly from the code -- it should only be called through
2322// the _LIBCPP_VERBOSE_ABORT macro.
2423_LIBCPP_NORETURN _LIBCPP_AVAILABILITY_VERBOSE_ABORT _LIBCPP_OVERRIDABLE_FUNC_VIS
25 _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...);
24_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) void __libcpp_verbose_abort(const char* __format, ...);
2625
2726// _LIBCPP_VERBOSE_ABORT(format, args...)
2827//
lib/libcxx/include/algorithm+158-125
......@@ -102,6 +102,31 @@ namespace ranges {
102102 constexpr borrowed_iterator_t<R>
103103 find_if_not(R&& r, Pred pred, Proj proj = {}); // since C++20
104104
105 template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity>
106 requires indirect_binary_predicate<ranges::equal_to, projected<I, Proj>, const T*>
107 constexpr subrange<I> find_last(I first, S last, const T& value, Proj proj = {}); // since C++23
108
109 template<forward_range R, class T, class Proj = identity>
110 requires
111 indirect_binary_predicate<ranges::equal_to, projected<iterator_t<R>, Proj>, const T*>
112 constexpr borrowed_subrange_t<R> find_last(R&& r, const T& value, Proj proj = {}); // since C++23
113
114 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
115 indirect_unary_predicate<projected<I, Proj>> Pred>
116 constexpr subrange<I> find_last_if(I first, S last, Pred pred, Proj proj = {}); // since C++23
117
118 template<forward_range R, class Proj = identity,
119 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
120 constexpr borrowed_subrange_t<R> find_last_if(R&& r, Pred pred, Proj proj = {}); // since C++23
121
122 template<forward_iterator I, sentinel_for<I> S, class Proj = identity,
123 indirect_unary_predicate<projected<I, Proj>> Pred>
124 constexpr subrange<I> find_last_if_not(I first, S last, Pred pred, Proj proj = {}); // since C++23
125
126 template<forward_range R, class Proj = identity,
127 indirect_unary_predicate<projected<iterator_t<R>, Proj>> Pred>
128 constexpr borrowed_subrange_t<R> find_last_if_not(R&& r, Pred pred, Proj proj = {}); // since C++23
129
105130 template<class T, class Proj = identity,
106131 indirect_strict_weak_order<projected<const T*, Proj>> Comp = ranges::less>
107132 constexpr const T& min(const T& a, const T& b, Comp comp = {}, Proj proj = {}); // since C++20
......@@ -217,6 +242,19 @@ namespace ranges {
217242 constexpr ranges::minmax_element_result<borrowed_iterator_t<R>>
218243 minmax_element(R&& r, Comp comp = {}, Proj proj = {}); // since C++20
219244
245 template<forward_iterator I1, sentinel_for<I1> S1,
246 forward_iterator I2, sentinel_for<I2> S2,
247 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
248 requires indirectly_comparable<I1, I2, Pred, Proj1, Proj2>
249 constexpr bool contains_subrange(I1 first1, S1 last1, I2 first2, S2 last2,
250 Pred pred = {}, Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
251
252 template<forward_range R1, forward_range R2,
253 class Pred = ranges::equal_to, class Proj1 = identity, class Proj2 = identity>
254 requires indirectly_comparable<iterator_t<R1>, iterator_t<R2>, Pred, Proj1, Proj2>
255 constexpr bool contains_subrange(R1&& r1, R2&& r2, Pred pred = {},
256 Proj1 proj1 = {}, Proj2 proj2 = {}); // since C++23
257
220258 template<class I, class O>
221259 using copy_result = in_out_result<I, O>; // since C++20
222260
......@@ -1780,17 +1818,12 @@ template <class BidirectionalIterator, class Compare>
17801818
17811819*/
17821820
1783#include <__assert> // all public C++ headers provide the assertion handler
17841821#include <__config>
1785#include <version>
17861822
17871823#include <__algorithm/adjacent_find.h>
17881824#include <__algorithm/all_of.h>
17891825#include <__algorithm/any_of.h>
17901826#include <__algorithm/binary_search.h>
1791#include <__algorithm/clamp.h>
1792#include <__algorithm/comp.h>
1793#include <__algorithm/comp_ref_type.h>
17941827#include <__algorithm/copy.h>
17951828#include <__algorithm/copy_backward.h>
17961829#include <__algorithm/copy_if.h>
......@@ -1806,18 +1839,9 @@ template <class BidirectionalIterator, class Compare>
18061839#include <__algorithm/find_first_of.h>
18071840#include <__algorithm/find_if.h>
18081841#include <__algorithm/find_if_not.h>
1809#include <__algorithm/fold.h>
18101842#include <__algorithm/for_each.h>
1811#include <__algorithm/for_each_n.h>
18121843#include <__algorithm/generate.h>
18131844#include <__algorithm/generate_n.h>
1814#include <__algorithm/half_positive.h>
1815#include <__algorithm/in_found_result.h>
1816#include <__algorithm/in_fun_result.h>
1817#include <__algorithm/in_in_out_result.h>
1818#include <__algorithm/in_in_result.h>
1819#include <__algorithm/in_out_out_result.h>
1820#include <__algorithm/in_out_result.h>
18211845#include <__algorithm/includes.h>
18221846#include <__algorithm/inplace_merge.h>
18231847#include <__algorithm/is_heap.h>
......@@ -1828,7 +1852,6 @@ template <class BidirectionalIterator, class Compare>
18281852#include <__algorithm/is_sorted_until.h>
18291853#include <__algorithm/iter_swap.h>
18301854#include <__algorithm/lexicographical_compare.h>
1831#include <__algorithm/lexicographical_compare_three_way.h>
18321855#include <__algorithm/lower_bound.h>
18331856#include <__algorithm/make_heap.h>
18341857#include <__algorithm/max.h>
......@@ -1836,7 +1859,6 @@ template <class BidirectionalIterator, class Compare>
18361859#include <__algorithm/merge.h>
18371860#include <__algorithm/min.h>
18381861#include <__algorithm/min_element.h>
1839#include <__algorithm/min_max_result.h>
18401862#include <__algorithm/minmax.h>
18411863#include <__algorithm/minmax_element.h>
18421864#include <__algorithm/mismatch.h>
......@@ -1852,111 +1874,7 @@ template <class BidirectionalIterator, class Compare>
18521874#include <__algorithm/partition_point.h>
18531875#include <__algorithm/pop_heap.h>
18541876#include <__algorithm/prev_permutation.h>
1855#include <__algorithm/pstl_any_all_none_of.h>
1856#include <__algorithm/pstl_copy.h>
1857#include <__algorithm/pstl_count.h>
1858#include <__algorithm/pstl_equal.h>
1859#include <__algorithm/pstl_fill.h>
1860#include <__algorithm/pstl_find.h>
1861#include <__algorithm/pstl_for_each.h>
1862#include <__algorithm/pstl_generate.h>
1863#include <__algorithm/pstl_is_partitioned.h>
1864#include <__algorithm/pstl_merge.h>
1865#include <__algorithm/pstl_move.h>
1866#include <__algorithm/pstl_replace.h>
1867#include <__algorithm/pstl_rotate_copy.h>
1868#include <__algorithm/pstl_sort.h>
1869#include <__algorithm/pstl_stable_sort.h>
1870#include <__algorithm/pstl_transform.h>
18711877#include <__algorithm/push_heap.h>
1872#include <__algorithm/ranges_adjacent_find.h>
1873#include <__algorithm/ranges_all_of.h>
1874#include <__algorithm/ranges_any_of.h>
1875#include <__algorithm/ranges_binary_search.h>
1876#include <__algorithm/ranges_clamp.h>
1877#include <__algorithm/ranges_contains.h>
1878#include <__algorithm/ranges_copy.h>
1879#include <__algorithm/ranges_copy_backward.h>
1880#include <__algorithm/ranges_copy_if.h>
1881#include <__algorithm/ranges_copy_n.h>
1882#include <__algorithm/ranges_count.h>
1883#include <__algorithm/ranges_count_if.h>
1884#include <__algorithm/ranges_ends_with.h>
1885#include <__algorithm/ranges_equal.h>
1886#include <__algorithm/ranges_equal_range.h>
1887#include <__algorithm/ranges_fill.h>
1888#include <__algorithm/ranges_fill_n.h>
1889#include <__algorithm/ranges_find.h>
1890#include <__algorithm/ranges_find_end.h>
1891#include <__algorithm/ranges_find_first_of.h>
1892#include <__algorithm/ranges_find_if.h>
1893#include <__algorithm/ranges_find_if_not.h>
1894#include <__algorithm/ranges_for_each.h>
1895#include <__algorithm/ranges_for_each_n.h>
1896#include <__algorithm/ranges_generate.h>
1897#include <__algorithm/ranges_generate_n.h>
1898#include <__algorithm/ranges_includes.h>
1899#include <__algorithm/ranges_inplace_merge.h>
1900#include <__algorithm/ranges_is_heap.h>
1901#include <__algorithm/ranges_is_heap_until.h>
1902#include <__algorithm/ranges_is_partitioned.h>
1903#include <__algorithm/ranges_is_permutation.h>
1904#include <__algorithm/ranges_is_sorted.h>
1905#include <__algorithm/ranges_is_sorted_until.h>
1906#include <__algorithm/ranges_lexicographical_compare.h>
1907#include <__algorithm/ranges_lower_bound.h>
1908#include <__algorithm/ranges_make_heap.h>
1909#include <__algorithm/ranges_max.h>
1910#include <__algorithm/ranges_max_element.h>
1911#include <__algorithm/ranges_merge.h>
1912#include <__algorithm/ranges_min.h>
1913#include <__algorithm/ranges_min_element.h>
1914#include <__algorithm/ranges_minmax.h>
1915#include <__algorithm/ranges_minmax_element.h>
1916#include <__algorithm/ranges_mismatch.h>
1917#include <__algorithm/ranges_move.h>
1918#include <__algorithm/ranges_move_backward.h>
1919#include <__algorithm/ranges_next_permutation.h>
1920#include <__algorithm/ranges_none_of.h>
1921#include <__algorithm/ranges_nth_element.h>
1922#include <__algorithm/ranges_partial_sort.h>
1923#include <__algorithm/ranges_partial_sort_copy.h>
1924#include <__algorithm/ranges_partition.h>
1925#include <__algorithm/ranges_partition_copy.h>
1926#include <__algorithm/ranges_partition_point.h>
1927#include <__algorithm/ranges_pop_heap.h>
1928#include <__algorithm/ranges_prev_permutation.h>
1929#include <__algorithm/ranges_push_heap.h>
1930#include <__algorithm/ranges_remove.h>
1931#include <__algorithm/ranges_remove_copy.h>
1932#include <__algorithm/ranges_remove_copy_if.h>
1933#include <__algorithm/ranges_remove_if.h>
1934#include <__algorithm/ranges_replace.h>
1935#include <__algorithm/ranges_replace_copy.h>
1936#include <__algorithm/ranges_replace_copy_if.h>
1937#include <__algorithm/ranges_replace_if.h>
1938#include <__algorithm/ranges_reverse.h>
1939#include <__algorithm/ranges_reverse_copy.h>
1940#include <__algorithm/ranges_rotate.h>
1941#include <__algorithm/ranges_rotate_copy.h>
1942#include <__algorithm/ranges_sample.h>
1943#include <__algorithm/ranges_search.h>
1944#include <__algorithm/ranges_search_n.h>
1945#include <__algorithm/ranges_set_difference.h>
1946#include <__algorithm/ranges_set_intersection.h>
1947#include <__algorithm/ranges_set_symmetric_difference.h>
1948#include <__algorithm/ranges_set_union.h>
1949#include <__algorithm/ranges_shuffle.h>
1950#include <__algorithm/ranges_sort.h>
1951#include <__algorithm/ranges_sort_heap.h>
1952#include <__algorithm/ranges_stable_partition.h>
1953#include <__algorithm/ranges_stable_sort.h>
1954#include <__algorithm/ranges_starts_with.h>
1955#include <__algorithm/ranges_swap_ranges.h>
1956#include <__algorithm/ranges_transform.h>
1957#include <__algorithm/ranges_unique.h>
1958#include <__algorithm/ranges_unique_copy.h>
1959#include <__algorithm/ranges_upper_bound.h>
19601878#include <__algorithm/remove.h>
19611879#include <__algorithm/remove_copy.h>
19621880#include <__algorithm/remove_copy_if.h>
......@@ -1969,17 +1887,13 @@ template <class BidirectionalIterator, class Compare>
19691887#include <__algorithm/reverse_copy.h>
19701888#include <__algorithm/rotate.h>
19711889#include <__algorithm/rotate_copy.h>
1972#include <__algorithm/sample.h>
19731890#include <__algorithm/search.h>
19741891#include <__algorithm/search_n.h>
19751892#include <__algorithm/set_difference.h>
19761893#include <__algorithm/set_intersection.h>
19771894#include <__algorithm/set_symmetric_difference.h>
19781895#include <__algorithm/set_union.h>
1979#include <__algorithm/shift_left.h>
1980#include <__algorithm/shift_right.h>
19811896#include <__algorithm/shuffle.h>
1982#include <__algorithm/sift_down.h>
19831897#include <__algorithm/sort.h>
19841898#include <__algorithm/sort_heap.h>
19851899#include <__algorithm/stable_partition.h>
......@@ -1988,9 +1902,124 @@ template <class BidirectionalIterator, class Compare>
19881902#include <__algorithm/transform.h>
19891903#include <__algorithm/unique.h>
19901904#include <__algorithm/unique_copy.h>
1991#include <__algorithm/unwrap_iter.h>
19921905#include <__algorithm/upper_bound.h>
19931906
1907#if _LIBCPP_STD_VER >= 17
1908# include <__algorithm/clamp.h>
1909# include <__algorithm/for_each_n.h>
1910# include <__algorithm/pstl.h>
1911# include <__algorithm/sample.h>
1912#endif // _LIBCPP_STD_VER >= 17
1913
1914#if _LIBCPP_STD_VER >= 20
1915# include <__algorithm/in_found_result.h>
1916# include <__algorithm/in_fun_result.h>
1917# include <__algorithm/in_in_out_result.h>
1918# include <__algorithm/in_in_result.h>
1919# include <__algorithm/in_out_out_result.h>
1920# include <__algorithm/in_out_result.h>
1921# include <__algorithm/lexicographical_compare_three_way.h>
1922# include <__algorithm/min_max_result.h>
1923# include <__algorithm/ranges_adjacent_find.h>
1924# include <__algorithm/ranges_all_of.h>
1925# include <__algorithm/ranges_any_of.h>
1926# include <__algorithm/ranges_binary_search.h>
1927# include <__algorithm/ranges_clamp.h>
1928# include <__algorithm/ranges_contains.h>
1929# include <__algorithm/ranges_copy.h>
1930# include <__algorithm/ranges_copy_backward.h>
1931# include <__algorithm/ranges_copy_if.h>
1932# include <__algorithm/ranges_copy_n.h>
1933# include <__algorithm/ranges_count.h>
1934# include <__algorithm/ranges_count_if.h>
1935# include <__algorithm/ranges_equal.h>
1936# include <__algorithm/ranges_equal_range.h>
1937# include <__algorithm/ranges_fill.h>
1938# include <__algorithm/ranges_fill_n.h>
1939# include <__algorithm/ranges_find.h>
1940# include <__algorithm/ranges_find_end.h>
1941# include <__algorithm/ranges_find_first_of.h>
1942# include <__algorithm/ranges_find_if.h>
1943# include <__algorithm/ranges_find_if_not.h>
1944# include <__algorithm/ranges_for_each.h>
1945# include <__algorithm/ranges_for_each_n.h>
1946# include <__algorithm/ranges_generate.h>
1947# include <__algorithm/ranges_generate_n.h>
1948# include <__algorithm/ranges_includes.h>
1949# include <__algorithm/ranges_inplace_merge.h>
1950# include <__algorithm/ranges_is_heap.h>
1951# include <__algorithm/ranges_is_heap_until.h>
1952# include <__algorithm/ranges_is_partitioned.h>
1953# include <__algorithm/ranges_is_permutation.h>
1954# include <__algorithm/ranges_is_sorted.h>
1955# include <__algorithm/ranges_is_sorted_until.h>
1956# include <__algorithm/ranges_lexicographical_compare.h>
1957# include <__algorithm/ranges_lower_bound.h>
1958# include <__algorithm/ranges_make_heap.h>
1959# include <__algorithm/ranges_max.h>
1960# include <__algorithm/ranges_max_element.h>
1961# include <__algorithm/ranges_merge.h>
1962# include <__algorithm/ranges_min.h>
1963# include <__algorithm/ranges_min_element.h>
1964# include <__algorithm/ranges_minmax.h>
1965# include <__algorithm/ranges_minmax_element.h>
1966# include <__algorithm/ranges_mismatch.h>
1967# include <__algorithm/ranges_move.h>
1968# include <__algorithm/ranges_move_backward.h>
1969# include <__algorithm/ranges_next_permutation.h>
1970# include <__algorithm/ranges_none_of.h>
1971# include <__algorithm/ranges_nth_element.h>
1972# include <__algorithm/ranges_partial_sort.h>
1973# include <__algorithm/ranges_partial_sort_copy.h>
1974# include <__algorithm/ranges_partition.h>
1975# include <__algorithm/ranges_partition_copy.h>
1976# include <__algorithm/ranges_partition_point.h>
1977# include <__algorithm/ranges_pop_heap.h>
1978# include <__algorithm/ranges_prev_permutation.h>
1979# include <__algorithm/ranges_push_heap.h>
1980# include <__algorithm/ranges_remove.h>
1981# include <__algorithm/ranges_remove_copy.h>
1982# include <__algorithm/ranges_remove_copy_if.h>
1983# include <__algorithm/ranges_remove_if.h>
1984# include <__algorithm/ranges_replace.h>
1985# include <__algorithm/ranges_replace_copy.h>
1986# include <__algorithm/ranges_replace_copy_if.h>
1987# include <__algorithm/ranges_replace_if.h>
1988# include <__algorithm/ranges_reverse.h>
1989# include <__algorithm/ranges_reverse_copy.h>
1990# include <__algorithm/ranges_rotate.h>
1991# include <__algorithm/ranges_rotate_copy.h>
1992# include <__algorithm/ranges_sample.h>
1993# include <__algorithm/ranges_search.h>
1994# include <__algorithm/ranges_search_n.h>
1995# include <__algorithm/ranges_set_difference.h>
1996# include <__algorithm/ranges_set_intersection.h>
1997# include <__algorithm/ranges_set_symmetric_difference.h>
1998# include <__algorithm/ranges_set_union.h>
1999# include <__algorithm/ranges_shuffle.h>
2000# include <__algorithm/ranges_sort.h>
2001# include <__algorithm/ranges_sort_heap.h>
2002# include <__algorithm/ranges_stable_partition.h>
2003# include <__algorithm/ranges_stable_sort.h>
2004# include <__algorithm/ranges_swap_ranges.h>
2005# include <__algorithm/ranges_transform.h>
2006# include <__algorithm/ranges_unique.h>
2007# include <__algorithm/ranges_unique_copy.h>
2008# include <__algorithm/ranges_upper_bound.h>
2009# include <__algorithm/shift_left.h>
2010# include <__algorithm/shift_right.h>
2011#endif
2012
2013#if _LIBCPP_STD_VER >= 23
2014# include <__algorithm/fold.h>
2015# include <__algorithm/ranges_contains_subrange.h>
2016# include <__algorithm/ranges_ends_with.h>
2017# include <__algorithm/ranges_find_last.h>
2018# include <__algorithm/ranges_starts_with.h>
2019#endif // _LIBCPP_STD_VER >= 23
2020
2021#include <version>
2022
19942023// standard-mandated includes
19952024
19962025// [algorithm.syn]
......@@ -2000,6 +2029,10 @@ template <class BidirectionalIterator, class Compare>
20002029# pragma GCC system_header
20012030#endif
20022031
2032#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 14
2033# include <execution>
2034#endif
2035
20032036#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
20042037# include <atomic>
20052038# include <bit>
lib/libcxx/include/any+4-7
......@@ -80,8 +80,6 @@ namespace std {
8080
8181*/
8282
83#include <__assert> // all public C++ headers provide the assertion handler
84#include <__availability>
8583#include <__config>
8684#include <__memory/allocator.h>
8785#include <__memory/allocator_destructor.h>
......@@ -93,9 +91,8 @@ namespace std {
9391#include <__type_traits/conditional.h>
9492#include <__type_traits/decay.h>
9593#include <__type_traits/is_constructible.h>
96#include <__type_traits/is_copy_constructible.h>
9794#include <__type_traits/is_function.h>
98#include <__type_traits/is_nothrow_move_constructible.h>
95#include <__type_traits/is_nothrow_constructible.h>
9996#include <__type_traits/is_reference.h>
10097#include <__type_traits/is_same.h>
10198#include <__type_traits/is_void.h>
......@@ -208,7 +205,7 @@ public:
208205 template < class _ValueType,
209206 class _Tp = decay_t<_ValueType>,
210207 class = enable_if_t< !is_same<_Tp, any>::value && !__is_inplace_type<_ValueType>::value &&
211 is_copy_constructible<_Tp>::value> >
208 is_copy_constructible<_Tp>::value> >
212209 _LIBCPP_HIDE_FROM_ABI any(_ValueType&& __value);
213210
214211 template <class _ValueType,
......@@ -222,7 +219,7 @@ public:
222219 class... _Args,
223220 class _Tp = decay_t<_ValueType>,
224221 class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
225 is_copy_constructible<_Tp>::value> >
222 is_copy_constructible<_Tp>::value> >
226223 _LIBCPP_HIDE_FROM_ABI explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
227224
228225 _LIBCPP_HIDE_FROM_ABI ~any() { this->reset(); }
......@@ -254,7 +251,7 @@ public:
254251 class... _Args,
255252 class _Tp = decay_t<_ValueType>,
256253 class = enable_if_t< is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
257 is_copy_constructible<_Tp>::value> >
254 is_copy_constructible<_Tp>::value> >
258255 _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up>, _Args&&...);
259256
260257 // 6.3.3 any modifiers
lib/libcxx/include/array+24-19
......@@ -116,20 +116,21 @@ template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexce
116116#include <__algorithm/lexicographical_compare.h>
117117#include <__algorithm/lexicographical_compare_three_way.h>
118118#include <__algorithm/swap_ranges.h>
119#include <__assert> // all public C++ headers provide the assertion handler
119#include <__assert>
120120#include <__config>
121121#include <__fwd/array.h>
122122#include <__iterator/reverse_iterator.h>
123#include <__iterator/wrap_iter.h>
123124#include <__tuple/sfinae_helpers.h>
124125#include <__type_traits/conditional.h>
126#include <__type_traits/conjunction.h>
125127#include <__type_traits/is_array.h>
126128#include <__type_traits/is_const.h>
127129#include <__type_traits/is_constructible.h>
128#include <__type_traits/is_move_constructible.h>
129130#include <__type_traits/is_nothrow_constructible.h>
130#include <__type_traits/is_nothrow_move_constructible.h>
131131#include <__type_traits/is_same.h>
132132#include <__type_traits/is_swappable.h>
133#include <__type_traits/is_trivially_relocatable.h>
133134#include <__type_traits/remove_cv.h>
134135#include <__utility/empty.h>
135136#include <__utility/integer_sequence.h>
......@@ -166,15 +167,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
166167
167168template <class _Tp, size_t _Size>
168169struct _LIBCPP_TEMPLATE_VIS array {
170 using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>;
171
169172 // types:
170 using __self = array;
171 using value_type = _Tp;
172 using reference = value_type&;
173 using const_reference = const value_type&;
174 using iterator = value_type*;
175 using const_iterator = const value_type*;
176 using pointer = value_type*;
177 using const_pointer = const value_type*;
173 using __self = array;
174 using value_type = _Tp;
175 using reference = value_type&;
176 using const_reference = const value_type&;
177 using pointer = value_type*;
178 using const_pointer = const value_type*;
179#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY)
180 using iterator = __wrap_iter<pointer>;
181 using const_iterator = __wrap_iter<const_pointer>;
182#else
183 using iterator = pointer;
184 using const_iterator = const_pointer;
185#endif
178186 using size_type = size_t;
179187 using difference_type = ptrdiff_t;
180188 using reverse_iterator = std::reverse_iterator<iterator>;
......@@ -187,8 +195,7 @@ struct _LIBCPP_TEMPLATE_VIS array {
187195 std::fill_n(data(), _Size, __u);
188196 }
189197
190 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a)
191 _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
198 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable_v<_Tp>) {
192199 std::swap_ranges(data(), data() + _Size, __a.data());
193200 }
194201
......@@ -225,9 +232,7 @@ struct _LIBCPP_TEMPLATE_VIS array {
225232 // capacity:
226233 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return _Size; }
227234 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return _Size; }
228 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {
229 return _Size == 0;
230 }
235 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return _Size == 0; }
231236
232237 // element access:
233238 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type __n) _NOEXCEPT {
......@@ -330,7 +335,7 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> {
330335 // capacity:
331336 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT { return 0; }
332337 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT { return 0; }
333 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }
338 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return true; }
334339
335340 // element access:
336341 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 reference operator[](size_type) _NOEXCEPT {
......@@ -418,12 +423,12 @@ template <class _Tp, size_t _Size>
418423_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
419424operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
420425 return std::lexicographical_compare_three_way(
421 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
426 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
422427}
423428
424429#endif // _LIBCPP_STD_VER <= 17
425430
426template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable<_Tp>::value, int> = 0>
431template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
427432inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
428433 _NOEXCEPT_(noexcept(__x.swap(__y))) {
429434 __x.swap(__y);
lib/libcxx/include/atomic+11-6
......@@ -587,7 +587,12 @@ template <class T>
587587
588588*/
589589
590#include <__assert> // all public C++ headers provide the assertion handler
590#include <__config>
591
592#if _LIBCPP_STD_VER < 23 && defined(_LIBCPP_STDATOMIC_H)
593# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
594#endif
595
591596#include <__atomic/aliases.h>
592597#include <__atomic/atomic.h>
593598#include <__atomic/atomic_base.h>
......@@ -602,9 +607,12 @@ template <class T>
602607#include <__atomic/is_always_lock_free.h>
603608#include <__atomic/kill_dependency.h>
604609#include <__atomic/memory_order.h>
605#include <__config>
606610#include <version>
607611
612#if _LIBCPP_STD_VER >= 20
613# include <__atomic/atomic_ref.h>
614#endif
615
608616#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
609617# pragma GCC system_header
610618#endif
......@@ -613,13 +621,10 @@ template <class T>
613621# error <atomic> is not implemented
614622#endif
615623
616#ifdef kill_dependency
617# error <atomic> is incompatible with <stdatomic.h> before C++23. Please compile with -std=c++23.
618#endif
619
620624#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
621625# include <cmath>
622626# include <compare>
627# include <cstdlib>
623628# include <cstring>
624629# include <type_traits>
625630#endif
lib/libcxx/include/barrier+32-33
......@@ -47,31 +47,28 @@ namespace std
4747
4848#include <__config>
4949
50#ifdef _LIBCPP_HAS_NO_THREADS
51# error "<barrier> is not supported since libc++ has been configured without support for threads."
52#endif
53
54#include <__assert> // all public C++ headers provide the assertion handler
55#include <__atomic/atomic_base.h>
56#include <__atomic/memory_order.h>
57#include <__availability>
58#include <__memory/unique_ptr.h>
59#include <__thread/poll_with_backoff.h>
60#include <__thread/timed_backoff_policy.h>
61#include <__utility/move.h>
62#include <cstddef>
63#include <cstdint>
64#include <limits>
65#include <version>
66
67#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69#endif
50#if !defined(_LIBCPP_HAS_NO_THREADS)
51
52# include <__assert>
53# include <__atomic/atomic_base.h>
54# include <__atomic/memory_order.h>
55# include <__memory/unique_ptr.h>
56# include <__thread/poll_with_backoff.h>
57# include <__thread/timed_backoff_policy.h>
58# include <__utility/move.h>
59# include <cstddef>
60# include <cstdint>
61# include <limits>
62# include <version>
63
64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
65# pragma GCC system_header
66# endif
7067
7168_LIBCPP_PUSH_MACROS
72#include <__undef_macros>
69# include <__undef_macros>
7370
74#if _LIBCPP_STD_VER >= 14
71# if _LIBCPP_STD_VER >= 14
7572
7673_LIBCPP_BEGIN_NAMESPACE_STD
7774
......@@ -79,7 +76,7 @@ struct __empty_completion {
7976 inline _LIBCPP_HIDE_FROM_ABI void operator()() noexcept {}
8077};
8178
82# ifndef _LIBCPP_HAS_NO_TREE_BARRIER
79# ifndef _LIBCPP_HAS_NO_TREE_BARRIER
8380
8481/*
8582
......@@ -103,10 +100,10 @@ _LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base*
103100__construct_barrier_algorithm_base(ptrdiff_t& __expected);
104101
105102_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI bool
106__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase);
103__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept;
107104
108105_LIBCPP_AVAILABILITY_SYNC _LIBCPP_EXPORTED_FROM_ABI void
109__destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier);
106__destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept;
110107
111108template <class _CompletionF>
112109class __barrier_base {
......@@ -128,7 +125,7 @@ public:
128125 __expected_adjustment_(0),
129126 __completion_(std::move(__completion)),
130127 __phase_(0) {}
131 [[__nodiscard__]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) {
128 _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update) {
132129 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
133130 __update <= __expected_, "update is greater than the expected count for the current barrier phase");
134131
......@@ -153,7 +150,7 @@ public:
153150 }
154151};
155152
156# else
153# else
157154
158155/*
159156
......@@ -254,10 +251,10 @@ public:
254251 }
255252};
256253
257# endif // !_LIBCPP_HAS_NO_TREE_BARRIER
254# endif // !_LIBCPP_HAS_NO_TREE_BARRIER
258255
259256template <class _CompletionF = __empty_completion>
260class barrier {
257class _LIBCPP_DEPRECATED_ATOMIC_SYNC barrier {
261258 __barrier_base<_CompletionF> __b_;
262259
263260public:
......@@ -265,8 +262,8 @@ public:
265262
266263 static _LIBCPP_HIDE_FROM_ABI constexpr ptrdiff_t max() noexcept { return __barrier_base<_CompletionF>::max(); }
267264
268 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI explicit barrier(
269 ptrdiff_t __count, _CompletionF __completion = _CompletionF())
265 _LIBCPP_AVAILABILITY_SYNC
266 _LIBCPP_HIDE_FROM_ABI explicit barrier(ptrdiff_t __count, _CompletionF __completion = _CompletionF())
270267 : __b_(__count, std::move(__completion)) {
271268 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
272269 __count >= 0,
......@@ -280,7 +277,7 @@ public:
280277 barrier(barrier const&) = delete;
281278 barrier& operator=(barrier const&) = delete;
282279
283 [[__nodiscard__]] _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) {
280 _LIBCPP_NODISCARD _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI arrival_token arrive(ptrdiff_t __update = 1) {
284281 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update > 0, "barrier:arrive must be called with a value greater than 0");
285282 return __b_.arrive(__update);
286283 }
......@@ -293,10 +290,12 @@ public:
293290
294291_LIBCPP_END_NAMESPACE_STD
295292
296#endif // _LIBCPP_STD_VER >= 14
293# endif // _LIBCPP_STD_VER >= 14
297294
298295_LIBCPP_POP_MACROS
299296
297#endif // !defined(_LIBCPP_HAS_NO_THREADS)
298
300299#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
301300# include <atomic>
302301# include <concepts>
lib/libcxx/include/bit+23-14
......@@ -61,27 +61,36 @@ namespace std {
6161
6262*/
6363
64#include <__assert> // all public C++ headers provide the assertion handler
65#include <__bit/bit_cast.h>
66#include <__bit/bit_ceil.h>
67#include <__bit/bit_floor.h>
68#include <__bit/bit_log2.h>
69#include <__bit/bit_width.h>
70#include <__bit/blsr.h>
71#include <__bit/byteswap.h>
72#include <__bit/countl.h>
73#include <__bit/countr.h>
74#include <__bit/endian.h>
75#include <__bit/has_single_bit.h>
76#include <__bit/popcount.h>
77#include <__bit/rotate.h>
7864#include <__config>
65
66#if _LIBCPP_STD_VER >= 20
67# include <__bit/bit_cast.h>
68# include <__bit/bit_ceil.h>
69# include <__bit/bit_floor.h>
70# include <__bit/bit_log2.h>
71# include <__bit/bit_width.h>
72# include <__bit/countl.h>
73# include <__bit/countr.h>
74# include <__bit/endian.h>
75# include <__bit/has_single_bit.h>
76# include <__bit/popcount.h>
77# include <__bit/rotate.h>
78#endif
79
80#if _LIBCPP_STD_VER >= 23
81# include <__bit/byteswap.h>
82#endif
83
7984#include <version>
8085
8186#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
8287# pragma GCC system_header
8388#endif
8489
90#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
91# include <cstdint>
92#endif
93
8594#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
8695# include <cstdlib>
8796# include <iosfwd>
lib/libcxx/include/bitset+4-2
......@@ -129,7 +129,6 @@ template <size_t N> struct hash<std::bitset<N>>;
129129#include <__algorithm/count.h>
130130#include <__algorithm/fill.h>
131131#include <__algorithm/find.h>
132#include <__assert> // all public C++ headers provide the assertion handler
133132#include <__bit_reference>
134133#include <__config>
135134#include <__functional/hash.h>
......@@ -376,8 +375,11 @@ template <size_t _N_words, size_t _Size>
376375_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
377376__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
378377 unsigned long long __r = __first_[0];
378 _LIBCPP_DIAGNOSTIC_PUSH
379 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
379380 for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
380381 __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
382 _LIBCPP_DIAGNOSTIC_POP
381383 return __r;
382384}
383385
......@@ -618,7 +620,7 @@ public:
618620 // 23.3.5.1 constructors:
619621 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
620622 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
621 template <class _CharT, class = __enable_if_t<_IsCharLikeType<_CharT>::value> >
623 template <class _CharT, __enable_if_t<_IsCharLikeType<_CharT>::value, int> = 0>
622624 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset(
623625 const _CharT* __str,
624626#if _LIBCPP_STD_VER >= 26
lib/libcxx/include/cassert-1
......@@ -16,7 +16,6 @@ Macros:
1616
1717*/
1818
19#include <__assert> // all public C++ headers provide the assertion handler
2019#include <__config>
2120
2221// <assert.h> is not provided by libc++
lib/libcxx/include/ccomplex-1
......@@ -17,7 +17,6 @@
1717
1818*/
1919
20#include <__assert> // all public C++ headers provide the assertion handler
2120#include <complex>
2221
2322#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cctype-1
......@@ -34,7 +34,6 @@ int toupper(int c);
3434} // std
3535*/
3636
37#include <__assert> // all public C++ headers provide the assertion handler
3837#include <__config>
3938
4039#include <ctype.h>
lib/libcxx/include/cerrno+7-1
......@@ -22,7 +22,6 @@ Macros:
2222
2323*/
2424
25#include <__assert> // all public C++ headers provide the assertion handler
2625#include <__config>
2726
2827#include <errno.h>
......@@ -39,4 +38,11 @@ Macros:
3938# pragma GCC system_header
4039#endif
4140
41// LWG3869 Deprecate std::errc constants related to UNIX STREAMS
42//
43// This LWG issue deprecates the POSIX macros ENODATA, ENOSR, ENOSTR, and ETIME. These were
44// deprecated in libc++ in https://github.com/llvm/llvm-project/pull/80542.
45// Based on the post commit feedback the macro are no longer deprecated.
46// Instead libc++ leaves the deprecation to the provider of errno.h.
47
4248#endif // _LIBCPP_CERRNO
lib/libcxx/include/cfenv-1
......@@ -52,7 +52,6 @@ int feupdateenv(const fenv_t* envp);
5252} // std
5353*/
5454
55#include <__assert> // all public C++ headers provide the assertion handler
5655#include <__config>
5756
5857#include <fenv.h>
lib/libcxx/include/cfloat-1
......@@ -69,7 +69,6 @@ Macros:
6969 LDBL_TRUE_MIN // C11
7070*/
7171
72#include <__assert> // all public C++ headers provide the assertion handler
7372#include <__config>
7473
7574#include <float.h>
lib/libcxx/include/charconv+21-12
......@@ -69,19 +69,21 @@ namespace std {
6969
7070*/
7171
72#include <__assert> // all public C++ headers provide the assertion handler
73#include <__charconv/chars_format.h>
74#include <__charconv/from_chars_integral.h>
75#include <__charconv/from_chars_result.h>
76#include <__charconv/tables.h>
77#include <__charconv/to_chars.h>
78#include <__charconv/to_chars_base_10.h>
79#include <__charconv/to_chars_floating_point.h>
80#include <__charconv/to_chars_integral.h>
81#include <__charconv/to_chars_result.h>
82#include <__charconv/traits.h>
8372#include <__config>
84#include <__system_error/errc.h>
73
74#if _LIBCPP_STD_VER >= 17
75# include <__charconv/chars_format.h>
76# include <__charconv/from_chars_integral.h>
77# include <__charconv/from_chars_result.h>
78# include <__charconv/tables.h>
79# include <__charconv/to_chars.h>
80# include <__charconv/to_chars_base_10.h>
81# include <__charconv/to_chars_floating_point.h>
82# include <__charconv/to_chars_integral.h>
83# include <__charconv/to_chars_result.h>
84# include <__charconv/traits.h>
85#endif // _LIBCPP_STD_VER >= 17
86
8587#include <version>
8688
8789#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -92,6 +94,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
9294
9395_LIBCPP_END_NAMESPACE_STD
9496
97#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
98# include <cerrno>
99# include <cstddef>
100# include <initializer_list>
101# include <new>
102#endif
103
95104#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
96105# include <cmath>
97106# include <concepts>
lib/libcxx/include/chrono+195-38
......@@ -58,7 +58,7 @@ public:
5858 constexpr explicit duration(const Rep2& r,
5959 typename enable_if
6060 <
61 is_convertible<Rep2, rep>::value &&
61 is_convertible<const Rep2&, rep>::value &&
6262 (treat_as_floating_point<rep>::value ||
6363 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
6464 >::type* = 0);
......@@ -686,6 +686,12 @@ constexpr hours make24(const hours& h, bool is_pm) noexcept;
686686// [time.zone.db], time zone database
687687struct tzdb { // C++20
688688 string version;
689 vector<time_zone> zones;
690 vector<time_zone_link> links;
691 vector<leap_second> leap_seconds;
692
693 const time_zone* locate_zone(string_view tz_name) const;
694 const time_zone* current_zone() const;
689695};
690696
691697class tzdb_list { // C++20
......@@ -711,20 +717,145 @@ public:
711717// [time.zone.db.access], time zone database access
712718const tzdb& get_tzdb(); // C++20
713719tzdb_list& get_tzdb_list(); // C++20
720const time_zone* locate_zone(string_view tz_name); // C++20
721const time_zone* current_zone() // C++20
714722
715723// [time.zone.db.remote], remote time zone database support
716724const tzdb& reload_tzdb(); // C++20
717725string remote_version(); // C++20
718726
719// 25.10.5, class time_zone // C++20
727// [time.zone.exception], exception classes
728class nonexistent_local_time; // C++20
729class ambiguous_local_time; // C++20
730
731// [time.zone.info], information classes
732struct sys_info { // C++20
733 sys_seconds begin;
734 sys_seconds end;
735 seconds offset;
736 minutes save;
737 string abbrev;
738};
739
740template<class charT, class traits> // C++20
741 basic_ostream<charT, traits>&
742 operator<<(basic_ostream<charT, traits>& os, const sys_info& si);
743
744struct local_info { // C++20
745 static constexpr int unique = 0;
746 static constexpr int nonexistent = 1;
747 static constexpr int ambiguous = 2;
748
749 int result;
750 sys_info first;
751 sys_info second;
752};
753
754template<class charT, class traits> // C++20
755 basic_ostream<charT, traits>&
756 operator<<(basic_ostream<charT, traits>& os, const local_info& li);
757
758// 25.10.5, class time_zone // C++20
720759enum class choose {earliest, latest};
721class time_zone;
722bool operator==(const time_zone& x, const time_zone& y) noexcept;
723bool operator!=(const time_zone& x, const time_zone& y) noexcept;
724bool operator<(const time_zone& x, const time_zone& y) noexcept;
725bool operator>(const time_zone& x, const time_zone& y) noexcept;
726bool operator<=(const time_zone& x, const time_zone& y) noexcept;
727bool operator>=(const time_zone& x, const time_zone& y) noexcept;
760class time_zone {
761 time_zone(time_zone&&) = default;
762 time_zone& operator=(time_zone&&) = default;
763
764 // unspecified additional constructors
765
766 string_view name() const noexcept;
767
768 template<class Duration>
769 sys_info get_info(const sys_time<Duration>& st) const;
770
771 template<class Duration>
772 local_info get_info(const local_time<Duration>& tp) const;
773
774 template<class Duration>
775 sys_time<common_type_t<Duration, seconds>>
776 to_sys(const local_time<Duration>& tp) const;
777
778 template<class Duration>
779 sys_time<common_type_t<Duration, seconds>>
780 to_sys(const local_time<Duration>& tp, choose z) const;
781
782 template<class Duration>
783 local_time<common_type_t<Duration, seconds>>
784 to_local(const sys_time<Duration>& tp) const;
785};
786bool operator==(const time_zone& x, const time_zone& y) noexcept; // C++20
787strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // C++20
788
789// [time.zone.zonedtraits], class template zoned_traits
790template<class T> struct zoned_traits; // C++20
791
792// [time.zone.zonedtime], class template zoned_time
793template<class Duration, class TimeZonePtr = const time_zone*> // C++20
794class zoned_time;
795
796using zoned_seconds = zoned_time<seconds>; // C++20
797
798template<class Duration1, class Duration2, class TimeZonePtr> // C++20
799 bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
800 const zoned_time<Duration2, TimeZonePtr>& y);
801
802template<class charT, class traits, class Duration, class TimeZonePtr> // C++20
803 basic_ostream<charT, traits>&
804 operator<<(basic_ostream<charT, traits>& os,
805 const zoned_time<Duration, TimeZonePtr>& t);
806
807// [time.zone.leap], leap second support
808class leap_second { // C++20
809public:
810 leap_second(const leap_second&) = default;
811 leap_second& operator=(const leap_second&) = default;
812
813 // unspecified additional constructors
814
815 constexpr sys_seconds date() const noexcept;
816 constexpr seconds value() const noexcept;
817};
818
819constexpr bool operator==(const leap_second& x, const leap_second& y); // C++20
820constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y);
821
822template<class Duration> // C++20
823 constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y);
824template<class Duration> // C++20
825 constexpr bool operator< (const leap_second& x, const sys_time<Duration>& y);
826template<class Duration> // C++20
827 constexpr bool operator< (const sys_time<Duration>& x, const leap_second& y);
828template<class Duration> // C++20
829 constexpr bool operator> (const leap_second& x, const sys_time<Duration>& y);
830template<class Duration> // C++20
831 constexpr bool operator> (const sys_time<Duration>& x, const leap_second& y);
832template<class Duration> // C++20
833 constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y);
834template<class Duration> // C++20
835 constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y);
836template<class Duration> // C++20
837 constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y);
838template<class Duration> // C++20
839 constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y);
840template<class Duration> // C++20
841 requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
842 constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y);
843
844// [time.zone.link], class time_zone_link
845class time_zone_link { // C++20
846public:
847 time_zone_link(time_zone_link&&) = default;
848 time_zone_link& operator=(time_zone_link&&) = default;
849
850 // unspecified additional constructors
851
852 string_view name() const noexcept;
853 string_view target() const noexcept;
854};
855
856bool operator==(const time_zone_link& x, const time_zone_link& y); // C++20
857strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); // C++20
858
728859} // chrono
729860
730861namespace std {
......@@ -753,6 +884,10 @@ namespace std {
753884 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
754885 template<class Rep, class Period, class charT>
755886 struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20
887 template<class charT> struct formatter<chrono::sys_info, charT>; // C++20
888 template<class charT> struct formatter<chrono::local_info, charT>; // C++20
889 template<class Duration, class TimeZonePtr, class charT> // C++20
890 struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>;
756891} // namespace std
757892
758893namespace chrono {
......@@ -804,28 +939,51 @@ constexpr chrono::year operator ""y(unsigned lo
804939
805940// clang-format on
806941
807#include <__assert> // all public C++ headers provide the assertion handler
808#include <__chrono/calendar.h>
809#include <__chrono/convert_to_timespec.h>
810#include <__chrono/convert_to_tm.h>
811#include <__chrono/day.h>
942#include <__config>
943
812944#include <__chrono/duration.h>
813945#include <__chrono/file_clock.h>
814#include <__chrono/hh_mm_ss.h>
815946#include <__chrono/high_resolution_clock.h>
816#include <__chrono/literals.h>
817#include <__chrono/month.h>
818#include <__chrono/month_weekday.h>
819#include <__chrono/monthday.h>
820947#include <__chrono/steady_clock.h>
821948#include <__chrono/system_clock.h>
822949#include <__chrono/time_point.h>
823#include <__chrono/weekday.h>
824#include <__chrono/year.h>
825#include <__chrono/year_month.h>
826#include <__chrono/year_month_day.h>
827#include <__chrono/year_month_weekday.h>
828#include <__config>
950
951#if _LIBCPP_STD_VER >= 20
952# include <__chrono/calendar.h>
953# include <__chrono/day.h>
954# include <__chrono/exception.h>
955# include <__chrono/hh_mm_ss.h>
956# include <__chrono/literals.h>
957# include <__chrono/local_info.h>
958# include <__chrono/month.h>
959# include <__chrono/month_weekday.h>
960# include <__chrono/monthday.h>
961# include <__chrono/sys_info.h>
962# include <__chrono/weekday.h>
963# include <__chrono/year.h>
964# include <__chrono/year_month.h>
965# include <__chrono/year_month_day.h>
966# include <__chrono/year_month_weekday.h>
967
968# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
969# include <__chrono/formatter.h>
970# include <__chrono/ostream.h>
971# include <__chrono/parser_std_format_spec.h>
972# include <__chrono/statically_widen.h>
973# endif
974
975# if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
976 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
977# include <__chrono/leap_second.h>
978# include <__chrono/time_zone.h>
979# include <__chrono/time_zone_link.h>
980# include <__chrono/tzdb.h>
981# include <__chrono/tzdb_list.h>
982# include <__chrono/zoned_time.h>
983# endif
984
985#endif
986
829987#include <version>
830988
831989// standard-mandated includes
......@@ -833,33 +991,32 @@ constexpr chrono::year operator ""y(unsigned lo
833991// [time.syn]
834992#include <compare>
835993
836#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && _LIBCPP_STD_VER >= 20
837# include <__chrono/formatter.h>
838# include <__chrono/ostream.h>
839# include <__chrono/parser_std_format_spec.h>
840# include <__chrono/statically_widen.h>
841#endif
842
843#if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
844 !defined(_LIBCPP_HAS_NO_LOCALIZATION)
845# include <__chrono/tzdb.h>
846# include <__chrono/tzdb_list.h>
847#endif
848
849994#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
850995# pragma GCC system_header
851996#endif
852997
998#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
999# include <cstdint>
1000# include <stdexcept>
1001# include <string_view>
1002# include <vector>
1003#endif
1004
8531005#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
8541006# include <bit>
8551007# include <concepts>
8561008# include <cstring>
8571009# include <forward_list>
8581010# include <string>
1011# include <tuple>
8591012#endif
8601013
8611014#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
8621015# include <charconv>
1016# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
1017# include <locale>
1018# endif
1019# include <ostream>
8631020#endif
8641021
8651022#endif // _LIBCPP_CHRONO
lib/libcxx/include/cinttypes-1
......@@ -234,7 +234,6 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
234234} // std
235235*/
236236
237#include <__assert> // all public C++ headers provide the assertion handler
238237#include <__config>
239238
240239// standard-mandated includes
lib/libcxx/include/ciso646-1
......@@ -15,7 +15,6 @@
1515
1616*/
1717
18#include <__assert> // all public C++ headers provide the assertion handler
1918#include <__config>
2019
2120#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/climits-1
......@@ -37,7 +37,6 @@ Macros:
3737
3838*/
3939
40#include <__assert> // all public C++ headers provide the assertion handler
4140#include <__config>
4241
4342#include <limits.h>
lib/libcxx/include/clocale-1
......@@ -34,7 +34,6 @@ lconv* localeconv();
3434
3535*/
3636
37#include <__assert> // all public C++ headers provide the assertion handler
3837#include <__config>
3938
4039#include <locale.h>
lib/libcxx/include/cmath+10-180
......@@ -204,6 +204,14 @@ floating_point fmin (arithmetic x, arithmetic y);
204204float fminf(float x, float y);
205205long double fminl(long double x, long double y);
206206
207double hermite(unsigned n, double x); // C++17
208float hermite(unsigned n, float x); // C++17
209long double hermite(unsigned n, long double x); // C++17
210float hermitef(unsigned n, float x); // C++17
211long double hermitel(unsigned n, long double x); // C++17
212template <class Integer>
213double hermite(unsigned n, Integer x); // C++17
214
207215floating_point hypot (arithmetic x, arithmetic y);
208216float hypotf(float x, float y);
209217long double hypotl(long double x, long double y);
......@@ -304,8 +312,8 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
304312
305313*/
306314
307#include <__assert> // all public C++ headers provide the assertion handler
308315#include <__config>
316#include <__math/hypot.h>
309317#include <__type_traits/enable_if.h>
310318#include <__type_traits/is_arithmetic.h>
311319#include <__type_traits/is_constant_evaluated.h>
......@@ -316,6 +324,7 @@ constexpr long double lerp(long double a, long double b, long double t) noexcept
316324#include <limits>
317325#include <version>
318326
327#include <__math/special_functions.h>
319328#include <math.h>
320329
321330#ifndef _LIBCPP_MATH_H
......@@ -545,30 +554,6 @@ using ::scalbnl _LIBCPP_USING_IF_EXISTS;
545554using ::tgammal _LIBCPP_USING_IF_EXISTS;
546555using ::truncl _LIBCPP_USING_IF_EXISTS;
547556
548#if _LIBCPP_STD_VER >= 17
549inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y, float __z) {
550 return sqrt(__x * __x + __y * __y + __z * __z);
551}
552inline _LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y, double __z) {
553 return sqrt(__x * __x + __y * __y + __z * __z);
554}
555inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y, long double __z) {
556 return sqrt(__x * __x + __y * __y + __z * __z);
557}
558
559template <class _A1, class _A2, class _A3>
560inline _LIBCPP_HIDE_FROM_ABI
561 typename enable_if_t< is_arithmetic<_A1>::value && is_arithmetic<_A2>::value && is_arithmetic<_A3>::value,
562 __promote<_A1, _A2, _A3> >::type
563 hypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT {
564 typedef typename __promote<_A1, _A2, _A3>::type __result_type;
565 static_assert((!(is_same<_A1, __result_type>::value && is_same<_A2, __result_type>::value &&
566 is_same<_A3, __result_type>::value)),
567 "");
568 return std::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
569}
570#endif
571
572557template <class _A1, __enable_if_t<is_floating_point<_A1>::value, int> = 0>
573558_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isnan(_A1 __lcpp_x) _NOEXCEPT {
574559#if __has_builtin(__builtin_isnan)
......@@ -611,161 +596,6 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool __constexpr_isfinite(_A1 __lcpp_x)
611596 return __builtin_isfinite(__lcpp_x);
612597}
613598
614_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI float __constexpr_copysign(float __x, float __y) _NOEXCEPT {
615 return __builtin_copysignf(__x, __y);
616}
617
618_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI double __constexpr_copysign(double __x, double __y) _NOEXCEPT {
619 return __builtin_copysign(__x, __y);
620}
621
622_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI long double
623__constexpr_copysign(long double __x, long double __y) _NOEXCEPT {
624 return __builtin_copysignl(__x, __y);
625}
626
627template <class _A1,
628 class _A2,
629 __enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int> = 0>
630_LIBCPP_CONSTEXPR inline _LIBCPP_HIDE_FROM_ABI typename __promote<_A1, _A2>::type
631__constexpr_copysign(_A1 __x, _A2 __y) _NOEXCEPT {
632 typedef typename std::__promote<_A1, _A2>::type __result_type;
633 static_assert((!(std::_IsSame<_A1, __result_type>::value && std::_IsSame<_A2, __result_type>::value)), "");
634 return __builtin_copysign((__result_type)__x, (__result_type)__y);
635}
636
637inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR float __constexpr_fabs(float __x) _NOEXCEPT {
638 return __builtin_fabsf(__x);
639}
640
641inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(double __x) _NOEXCEPT {
642 return __builtin_fabs(__x);
643}
644
645inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long double __constexpr_fabs(long double __x) _NOEXCEPT {
646 return __builtin_fabsl(__x);
647}
648
649template <class _Tp, __enable_if_t<is_integral<_Tp>::value, int> = 0>
650_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR double __constexpr_fabs(_Tp __x) _NOEXCEPT {
651 return __builtin_fabs(static_cast<double>(__x));
652}
653
654inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 float __constexpr_fmax(float __x, float __y) _NOEXCEPT {
655#if !__has_constexpr_builtin(__builtin_fmaxf)
656 if (__libcpp_is_constant_evaluated()) {
657 if (std::__constexpr_isnan(__x))
658 return __y;
659 if (std::__constexpr_isnan(__y))
660 return __x;
661 return __x < __y ? __y : __x;
662 }
663#endif
664 return __builtin_fmaxf(__x, __y);
665}
666
667inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 double __constexpr_fmax(double __x, double __y) _NOEXCEPT {
668#if !__has_constexpr_builtin(__builtin_fmax)
669 if (__libcpp_is_constant_evaluated()) {
670 if (std::__constexpr_isnan(__x))
671 return __y;
672 if (std::__constexpr_isnan(__y))
673 return __x;
674 return __x < __y ? __y : __x;
675 }
676#endif
677 return __builtin_fmax(__x, __y);
678}
679
680inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 long double
681__constexpr_fmax(long double __x, long double __y) _NOEXCEPT {
682#if !__has_constexpr_builtin(__builtin_fmaxl)
683 if (__libcpp_is_constant_evaluated()) {
684 if (std::__constexpr_isnan(__x))
685 return __y;
686 if (std::__constexpr_isnan(__y))
687 return __x;
688 return __x < __y ? __y : __x;
689 }
690#endif
691 return __builtin_fmaxl(__x, __y);
692}
693
694template <class _Tp, class _Up, __enable_if_t<is_arithmetic<_Tp>::value && is_arithmetic<_Up>::value, int> = 0>
695_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __promote<_Tp, _Up>::type
696__constexpr_fmax(_Tp __x, _Up __y) _NOEXCEPT {
697 using __result_type = typename __promote<_Tp, _Up>::type;
698 return std::__constexpr_fmax(static_cast<__result_type>(__x), static_cast<__result_type>(__y));
699}
700
701template <class _Tp>
702_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp __constexpr_logb(_Tp __x) {
703#if !__has_constexpr_builtin(__builtin_logb)
704 if (__libcpp_is_constant_evaluated()) {
705 if (__x == _Tp(0)) {
706 // raise FE_DIVBYZERO
707 return -numeric_limits<_Tp>::infinity();
708 }
709
710 if (std::__constexpr_isinf(__x))
711 return numeric_limits<_Tp>::infinity();
712
713 if (std::__constexpr_isnan(__x))
714 return numeric_limits<_Tp>::quiet_NaN();
715
716 __x = std::__constexpr_fabs(__x);
717 unsigned long long __exp = 0;
718 while (__x >= numeric_limits<_Tp>::radix) {
719 __x /= numeric_limits<_Tp>::radix;
720 __exp += 1;
721 }
722 return _Tp(__exp);
723 }
724#endif // !__has_constexpr_builtin(__builtin_logb)
725 return __builtin_logb(__x);
726}
727
728template <class _Tp>
729_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp __constexpr_scalbn(_Tp __x, int __exp) {
730#if !__has_constexpr_builtin(__builtin_scalbln)
731 if (__libcpp_is_constant_evaluated()) {
732 if (__x == _Tp(0))
733 return __x;
734
735 if (std::__constexpr_isinf(__x))
736 return __x;
737
738 if (__exp == _Tp(0))
739 return __x;
740
741 if (std::__constexpr_isnan(__x))
742 return numeric_limits<_Tp>::quiet_NaN();
743
744 _Tp __mult(1);
745 if (__exp > 0) {
746 __mult = numeric_limits<_Tp>::radix;
747 --__exp;
748 } else {
749 ++__exp;
750 __exp = -__exp;
751 __mult /= numeric_limits<_Tp>::radix;
752 }
753
754 while (__exp > 0) {
755 if (!(__exp & 1)) {
756 __mult *= __mult;
757 __exp >>= 1;
758 } else {
759 __x *= __mult;
760 --__exp;
761 }
762 }
763 return __x;
764 }
765#endif // !__has_constexpr_builtin(__builtin_scalbln)
766 return __builtin_scalbn(__x, __exp);
767}
768
769599#if _LIBCPP_STD_VER >= 20
770600template <typename _Fp>
771601_LIBCPP_HIDE_FROM_ABI constexpr _Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
lib/libcxx/include/codecvt+2-3
......@@ -54,7 +54,6 @@ class codecvt_utf8_utf16
5454
5555*/
5656
57#include <__assert> // all public C++ headers provide the assertion handler
5857#include <__config>
5958#include <__locale>
6059#include <version>
......@@ -434,8 +433,8 @@ protected:
434433
435434_LIBCPP_SUPPRESS_DEPRECATED_PUSH
436435template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0>
437class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16
438 : public __codecvt_utf16<_Elem, _Mode & little_endian> {
436class _LIBCPP_TEMPLATE_VIS
437_LIBCPP_DEPRECATED_IN_CXX17 codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> {
439438public:
440439 _LIBCPP_HIDE_FROM_ABI explicit codecvt_utf16(size_t __refs = 0)
441440 : __codecvt_utf16<_Elem, _Mode & little_endian>(__refs, _Maxcode, _Mode) {}
lib/libcxx/include/compare+24-14
......@@ -140,28 +140,38 @@ namespace std {
140140}
141141*/
142142
143#include <__assert> // all public C++ headers provide the assertion handler
144#include <__compare/common_comparison_category.h>
145#include <__compare/compare_partial_order_fallback.h>
146#include <__compare/compare_strong_order_fallback.h>
147#include <__compare/compare_three_way.h>
148#include <__compare/compare_three_way_result.h>
149#include <__compare/compare_weak_order_fallback.h>
150#include <__compare/is_eq.h>
151#include <__compare/ordering.h>
152#include <__compare/partial_order.h>
153#include <__compare/strong_order.h>
154#include <__compare/synth_three_way.h>
155#include <__compare/three_way_comparable.h>
156#include <__compare/weak_order.h>
157143#include <__config>
144
145#if _LIBCPP_STD_VER >= 20
146# include <__compare/common_comparison_category.h>
147# include <__compare/compare_partial_order_fallback.h>
148# include <__compare/compare_strong_order_fallback.h>
149# include <__compare/compare_three_way.h>
150# include <__compare/compare_three_way_result.h>
151# include <__compare/compare_weak_order_fallback.h>
152# include <__compare/is_eq.h>
153# include <__compare/ordering.h>
154# include <__compare/partial_order.h>
155# include <__compare/strong_order.h>
156# include <__compare/synth_three_way.h>
157# include <__compare/three_way_comparable.h>
158# include <__compare/weak_order.h>
159#endif // _LIBCPP_STD_VER >= 20
160
158161#include <version>
159162
160163#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
161164# pragma GCC system_header
162165#endif
163166
167#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
168# include <cstddef>
169# include <cstdint>
170# include <limits>
171#endif
172
164173#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
174# include <cmath>
165175# include <type_traits>
166176#endif
167177
lib/libcxx/include/complex+234-146
......@@ -227,12 +227,42 @@ template<class T> complex<T> sqrt (const complex<T>&);
227227template<class T> complex<T> tan (const complex<T>&);
228228template<class T> complex<T> tanh (const complex<T>&);
229229
230 // [complex.tuple], tuple interface
231 template<class T> struct tuple_size; // Since C++26
232 template<size_t I, class T> struct tuple_element; // Since C++26
233 template<class T> struct tuple_size<complex<T>>; // Since C++26
234 template<size_t I, class T> struct tuple_element<I, complex<T>>; // Since C++26
235 template<size_t I, class T>
236 constexpr T& get(complex<T>&) noexcept; // Since C++26
237 template<size_t I, class T>
238 constexpr T&& get(complex<T>&&) noexcept; // Since C++26
239 template<size_t I, class T>
240 constexpr const T& get(const complex<T>&) noexcept; // Since C++26
241 template<size_t I, class T>
242 constexpr const T&& get(const complex<T>&&) noexcept; // Since C++26
243
244 // [complex.literals], complex literals
245 inline namespace literals {
246 inline namespace complex_literals {
247 constexpr complex<long double> operator""il(long double); // Since C++14
248 constexpr complex<long double> operator""il(unsigned long long); // Since C++14
249 constexpr complex<double> operator""i(long double); // Since C++14
250 constexpr complex<double> operator""i(unsigned long long); // Since C++14
251 constexpr complex<float> operator""if(long double); // Since C++14
252 constexpr complex<float> operator""if(unsigned long long); // Since C++14
253 }
254 }
230255} // std
231256
232257*/
233258
234#include <__assert> // all public C++ headers provide the assertion handler
235259#include <__config>
260#include <__fwd/complex.h>
261#include <__fwd/tuple.h>
262#include <__tuple/tuple_element.h>
263#include <__tuple/tuple_size.h>
264#include <__type_traits/conditional.h>
265#include <__utility/move.h>
236266#include <cmath>
237267#include <version>
238268
......@@ -244,15 +274,27 @@ template<class T> complex<T> tanh (const complex<T>&);
244274# pragma GCC system_header
245275#endif
246276
277_LIBCPP_PUSH_MACROS
278#include <__undef_macros>
279
247280_LIBCPP_BEGIN_NAMESPACE_STD
248281
249282template <class _Tp>
250283class _LIBCPP_TEMPLATE_VIS complex;
251284
252template <class _Tp>
285template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
253286_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
254287operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
255template <class _Tp>
288
289template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
290_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
291operator*(const complex<_Tp>& __z, const complex<_Tp>& __w);
292
293template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> = 0>
294_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
295operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
296
297template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> = 0>
256298_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
257299operator/(const complex<_Tp>& __x, const complex<_Tp>& __y);
258300
......@@ -331,6 +373,20 @@ public:
331373 *this = *this / complex(__c.real(), __c.imag());
332374 return *this;
333375 }
376
377#if _LIBCPP_STD_VER >= 26
378 template <size_t _Ip, class _Xp>
379 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
380
381 template <size_t _Ip, class _Xp>
382 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
383
384 template <size_t _Ip, class _Xp>
385 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
386
387 template <size_t _Ip, class _Xp>
388 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
389#endif
334390};
335391
336392template <>
......@@ -338,6 +394,23 @@ class _LIBCPP_TEMPLATE_VIS complex<double>;
338394template <>
339395class _LIBCPP_TEMPLATE_VIS complex<long double>;
340396
397struct __from_builtin_tag {};
398
399template <class _Tp>
400using __complex_t =
401 __conditional_t<is_same<_Tp, float>::value,
402 _Complex float,
403 __conditional_t<is_same<_Tp, double>::value, _Complex double, _Complex long double> >;
404
405template <class _Tp>
406_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __complex_t<_Tp> __make_complex(_Tp __re, _Tp __im) {
407#if __has_builtin(__builtin_complex)
408 return __builtin_complex(__re, __im);
409#else
410 return __complex_t<_Tp>{__re, __im};
411#endif
412}
413
341414template <>
342415class _LIBCPP_TEMPLATE_VIS complex<float> {
343416 float __re_;
......@@ -347,6 +420,11 @@ public:
347420 typedef float value_type;
348421
349422 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(float __re = 0.0f, float __im = 0.0f) : __re_(__re), __im_(__im) {}
423
424 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
425 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex float __v)
426 : __re_(__real__ __v), __im_(__imag__ __v) {}
427
350428 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
351429 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
352430
......@@ -356,6 +434,12 @@ public:
356434 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
357435 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
358436
437 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex float __builtin() const { return std::__make_complex(__re_, __im_); }
438 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex float __f) {
439 __re_ = __real__ __f;
440 __im_ = __imag__ __f;
441 }
442
359443 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(float __re) {
360444 __re_ = __re;
361445 __im_ = value_type();
......@@ -408,6 +492,20 @@ public:
408492 *this = *this / complex(__c.real(), __c.imag());
409493 return *this;
410494 }
495
496#if _LIBCPP_STD_VER >= 26
497 template <size_t _Ip, class _Xp>
498 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
499
500 template <size_t _Ip, class _Xp>
501 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
502
503 template <size_t _Ip, class _Xp>
504 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
505
506 template <size_t _Ip, class _Xp>
507 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
508#endif
411509};
412510
413511template <>
......@@ -419,6 +517,11 @@ public:
419517 typedef double value_type;
420518
421519 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(double __re = 0.0, double __im = 0.0) : __re_(__re), __im_(__im) {}
520
521 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
522 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex double __v)
523 : __re_(__real__ __v), __im_(__imag__ __v) {}
524
422525 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
423526 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR complex(const complex<long double>& __c);
424527
......@@ -428,6 +531,15 @@ public:
428531 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
429532 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
430533
534 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex double __builtin() const {
535 return std::__make_complex(__re_, __im_);
536 }
537
538 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex double __f) {
539 __re_ = __real__ __f;
540 __im_ = __imag__ __f;
541 }
542
431543 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(double __re) {
432544 __re_ = __re;
433545 __im_ = value_type();
......@@ -480,6 +592,20 @@ public:
480592 *this = *this / complex(__c.real(), __c.imag());
481593 return *this;
482594 }
595
596#if _LIBCPP_STD_VER >= 26
597 template <size_t _Ip, class _Xp>
598 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
599
600 template <size_t _Ip, class _Xp>
601 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
602
603 template <size_t _Ip, class _Xp>
604 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
605
606 template <size_t _Ip, class _Xp>
607 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
608#endif
483609};
484610
485611template <>
......@@ -492,6 +618,11 @@ public:
492618
493619 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(long double __re = 0.0L, long double __im = 0.0L)
494620 : __re_(__re), __im_(__im) {}
621
622 template <class _Tag, __enable_if_t<_IsSame<_Tag, __from_builtin_tag>::value, int> = 0>
623 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit complex(_Tag, _Complex long double __v)
624 : __re_(__real__ __v), __im_(__imag__ __v) {}
625
495626 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<float>& __c);
496627 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR complex(const complex<double>& __c);
497628
......@@ -501,6 +632,15 @@ public:
501632 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void real(value_type __re) { __re_ = __re; }
502633 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void imag(value_type __im) { __im_ = __im; }
503634
635 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Complex long double __builtin() const {
636 return std::__make_complex(__re_, __im_);
637 }
638
639 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __builtin(_Complex long double __f) {
640 __re_ = __real__ __f;
641 __im_ = __imag__ __f;
642 }
643
504644 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex& operator=(long double __re) {
505645 __re_ = __re;
506646 __im_ = value_type();
......@@ -553,6 +693,20 @@ public:
553693 *this = *this / complex(__c.real(), __c.imag());
554694 return *this;
555695 }
696
697#if _LIBCPP_STD_VER >= 26
698 template <size_t _Ip, class _Xp>
699 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>&) noexcept;
700
701 template <size_t _Ip, class _Xp>
702 friend _LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&&) noexcept;
703
704 template <size_t _Ip, class _Xp>
705 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>&) noexcept;
706
707 template <size_t _Ip, class _Xp>
708 friend _LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&&) noexcept;
709#endif
556710};
557711
558712inline _LIBCPP_CONSTEXPR complex<float>::complex(const complex<double>& __c) : __re_(__c.real()), __im_(__c.imag()) {}
......@@ -621,7 +775,13 @@ operator-(const _Tp& __x, const complex<_Tp>& __y) {
621775 return __t;
622776}
623777
624template <class _Tp>
778template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
779_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
780operator*(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) {
781 return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() * __rhs.__builtin());
782}
783
784template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
625785_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
626786operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) {
627787 _Tp __a = __z.real();
......@@ -629,78 +789,7 @@ operator*(const complex<_Tp>& __z, const complex<_Tp>& __w) {
629789 _Tp __c = __w.real();
630790 _Tp __d = __w.imag();
631791
632 // Avoid floating point operations that are invalid during constant evaluation
633 if (__libcpp_is_constant_evaluated()) {
634 bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
635 bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
636 bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
637 bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
638 bool __z_nan =
639 !__z_inf && ((std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b)) ||
640 (std::__constexpr_isnan(__a) && __b == _Tp(0)) || (__a == _Tp(0) && std::__constexpr_isnan(__b)));
641 bool __w_nan =
642 !__w_inf && ((std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d)) ||
643 (std::__constexpr_isnan(__c) && __d == _Tp(0)) || (__c == _Tp(0) && std::__constexpr_isnan(__d)));
644 if (__z_nan || __w_nan) {
645 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
646 }
647 if (__z_inf || __w_inf) {
648 if (__z_zero || __w_zero) {
649 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
650 }
651 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
652 }
653 bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
654 bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
655 if (__z_nonzero_nan || __w_nonzero_nan) {
656 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
657 }
658 }
659
660 _Tp __ac = __a * __c;
661 _Tp __bd = __b * __d;
662 _Tp __ad = __a * __d;
663 _Tp __bc = __b * __c;
664 _Tp __x = __ac - __bd;
665 _Tp __y = __ad + __bc;
666 if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y)) {
667 bool __recalc = false;
668 if (std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) {
669 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
670 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
671 if (std::__constexpr_isnan(__c))
672 __c = std::__constexpr_copysign(_Tp(0), __c);
673 if (std::__constexpr_isnan(__d))
674 __d = std::__constexpr_copysign(_Tp(0), __d);
675 __recalc = true;
676 }
677 if (std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d)) {
678 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
679 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
680 if (std::__constexpr_isnan(__a))
681 __a = std::__constexpr_copysign(_Tp(0), __a);
682 if (std::__constexpr_isnan(__b))
683 __b = std::__constexpr_copysign(_Tp(0), __b);
684 __recalc = true;
685 }
686 if (!__recalc && (std::__constexpr_isinf(__ac) || std::__constexpr_isinf(__bd) || std::__constexpr_isinf(__ad) ||
687 std::__constexpr_isinf(__bc))) {
688 if (std::__constexpr_isnan(__a))
689 __a = std::__constexpr_copysign(_Tp(0), __a);
690 if (std::__constexpr_isnan(__b))
691 __b = std::__constexpr_copysign(_Tp(0), __b);
692 if (std::__constexpr_isnan(__c))
693 __c = std::__constexpr_copysign(_Tp(0), __c);
694 if (std::__constexpr_isnan(__d))
695 __d = std::__constexpr_copysign(_Tp(0), __d);
696 __recalc = true;
697 }
698 if (__recalc) {
699 __x = _Tp(INFINITY) * (__a * __c - __b * __d);
700 __y = _Tp(INFINITY) * (__a * __d + __b * __c);
701 }
702 }
703 return complex<_Tp>(__x, __y);
792 return complex<_Tp>((__a * __c) - (__b * __d), (__a * __d) + (__b * __c));
704793}
705794
706795template <class _Tp>
......@@ -719,80 +808,22 @@ operator*(const _Tp& __x, const complex<_Tp>& __y) {
719808 return __t;
720809}
721810
722template <class _Tp>
811template <class _Tp, __enable_if_t<is_floating_point<_Tp>::value, int> >
812_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
813operator/(const complex<_Tp>& __lhs, const complex<_Tp>& __rhs) {
814 return complex<_Tp>(__from_builtin_tag(), __lhs.__builtin() / __rhs.__builtin());
815}
816
817template <class _Tp, __enable_if_t<!is_floating_point<_Tp>::value, int> >
723818_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 complex<_Tp>
724819operator/(const complex<_Tp>& __z, const complex<_Tp>& __w) {
725 int __ilogbw = 0;
726 _Tp __a = __z.real();
727 _Tp __b = __z.imag();
728 _Tp __c = __w.real();
729 _Tp __d = __w.imag();
730 _Tp __logbw = std::__constexpr_logb(std::__constexpr_fmax(std::__constexpr_fabs(__c), std::__constexpr_fabs(__d)));
731 if (std::__constexpr_isfinite(__logbw)) {
732 __ilogbw = static_cast<int>(__logbw);
733 __c = std::__constexpr_scalbn(__c, -__ilogbw);
734 __d = std::__constexpr_scalbn(__d, -__ilogbw);
735 }
736
737 // Avoid floating point operations that are invalid during constant evaluation
738 if (__libcpp_is_constant_evaluated()) {
739 bool __z_zero = __a == _Tp(0) && __b == _Tp(0);
740 bool __w_zero = __c == _Tp(0) && __d == _Tp(0);
741 bool __z_inf = std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b);
742 bool __w_inf = std::__constexpr_isinf(__c) || std::__constexpr_isinf(__d);
743 bool __z_nan =
744 !__z_inf && ((std::__constexpr_isnan(__a) && std::__constexpr_isnan(__b)) ||
745 (std::__constexpr_isnan(__a) && __b == _Tp(0)) || (__a == _Tp(0) && std::__constexpr_isnan(__b)));
746 bool __w_nan =
747 !__w_inf && ((std::__constexpr_isnan(__c) && std::__constexpr_isnan(__d)) ||
748 (std::__constexpr_isnan(__c) && __d == _Tp(0)) || (__c == _Tp(0) && std::__constexpr_isnan(__d)));
749 if ((__z_nan || __w_nan) || (__z_inf && __w_inf)) {
750 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
751 }
752 bool __z_nonzero_nan = !__z_inf && !__z_nan && (std::__constexpr_isnan(__a) || std::__constexpr_isnan(__b));
753 bool __w_nonzero_nan = !__w_inf && !__w_nan && (std::__constexpr_isnan(__c) || std::__constexpr_isnan(__d));
754 if (__z_nonzero_nan || __w_nonzero_nan) {
755 if (__w_zero) {
756 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
757 }
758 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
759 }
760 if (__w_inf) {
761 return complex<_Tp>(_Tp(0), _Tp(0));
762 }
763 if (__z_inf) {
764 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
765 }
766 if (__w_zero) {
767 if (__z_zero) {
768 return complex<_Tp>(_Tp(numeric_limits<_Tp>::quiet_NaN()), _Tp(0));
769 }
770 return complex<_Tp>(_Tp(numeric_limits<_Tp>::infinity()), _Tp(numeric_limits<_Tp>::infinity()));
771 }
772 }
820 _Tp __a = __z.real();
821 _Tp __b = __z.imag();
822 _Tp __c = __w.real();
823 _Tp __d = __w.imag();
773824
774825 _Tp __denom = __c * __c + __d * __d;
775 _Tp __x = std::__constexpr_scalbn((__a * __c + __b * __d) / __denom, -__ilogbw);
776 _Tp __y = std::__constexpr_scalbn((__b * __c - __a * __d) / __denom, -__ilogbw);
777 if (std::__constexpr_isnan(__x) && std::__constexpr_isnan(__y)) {
778 if ((__denom == _Tp(0)) && (!std::__constexpr_isnan(__a) || !std::__constexpr_isnan(__b))) {
779 __x = std::__constexpr_copysign(_Tp(INFINITY), __c) * __a;
780 __y = std::__constexpr_copysign(_Tp(INFINITY), __c) * __b;
781 } else if ((std::__constexpr_isinf(__a) || std::__constexpr_isinf(__b)) && std::__constexpr_isfinite(__c) &&
782 std::__constexpr_isfinite(__d)) {
783 __a = std::__constexpr_copysign(std::__constexpr_isinf(__a) ? _Tp(1) : _Tp(0), __a);
784 __b = std::__constexpr_copysign(std::__constexpr_isinf(__b) ? _Tp(1) : _Tp(0), __b);
785 __x = _Tp(INFINITY) * (__a * __c + __b * __d);
786 __y = _Tp(INFINITY) * (__b * __c - __a * __d);
787 } else if (std::__constexpr_isinf(__logbw) && __logbw > _Tp(0) && std::__constexpr_isfinite(__a) &&
788 std::__constexpr_isfinite(__b)) {
789 __c = std::__constexpr_copysign(std::__constexpr_isinf(__c) ? _Tp(1) : _Tp(0), __c);
790 __d = std::__constexpr_copysign(std::__constexpr_isinf(__d) ? _Tp(1) : _Tp(0), __d);
791 __x = _Tp(0) * (__a * __c + __b * __d);
792 __y = _Tp(0) * (__b * __c - __a * __d);
793 }
794 }
795 return complex<_Tp>(__x, __y);
826 return complex<_Tp>((__a * __c + __b * __d) / __denom, (__b * __c - __a * __d) / __denom);
796827}
797828
798829template <class _Tp>
......@@ -1352,6 +1383,61 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) {
13521383}
13531384#endif // !_LIBCPP_HAS_NO_LOCALIZATION
13541385
1386#if _LIBCPP_STD_VER >= 26
1387
1388// [complex.tuple], tuple interface
1389
1390template <class _Tp>
1391struct tuple_size<complex<_Tp>> : integral_constant<size_t, 2> {};
1392
1393template <size_t _Ip, class _Tp>
1394struct tuple_element<_Ip, complex<_Tp>> {
1395 static_assert(_Ip < 2, "Index value is out of range.");
1396 using type = _Tp;
1397};
1398
1399template <size_t _Ip, class _Xp>
1400_LIBCPP_HIDE_FROM_ABI constexpr _Xp& get(complex<_Xp>& __z) noexcept {
1401 static_assert(_Ip < 2, "Index value is out of range.");
1402 if constexpr (_Ip == 0) {
1403 return __z.__re_;
1404 } else {
1405 return __z.__im_;
1406 }
1407}
1408
1409template <size_t _Ip, class _Xp>
1410_LIBCPP_HIDE_FROM_ABI constexpr _Xp&& get(complex<_Xp>&& __z) noexcept {
1411 static_assert(_Ip < 2, "Index value is out of range.");
1412 if constexpr (_Ip == 0) {
1413 return std::move(__z.__re_);
1414 } else {
1415 return std::move(__z.__im_);
1416 }
1417}
1418
1419template <size_t _Ip, class _Xp>
1420_LIBCPP_HIDE_FROM_ABI constexpr const _Xp& get(const complex<_Xp>& __z) noexcept {
1421 static_assert(_Ip < 2, "Index value is out of range.");
1422 if constexpr (_Ip == 0) {
1423 return __z.__re_;
1424 } else {
1425 return __z.__im_;
1426 }
1427}
1428
1429template <size_t _Ip, class _Xp>
1430_LIBCPP_HIDE_FROM_ABI constexpr const _Xp&& get(const complex<_Xp>&& __z) noexcept {
1431 static_assert(_Ip < 2, "Index value is out of range.");
1432 if constexpr (_Ip == 0) {
1433 return std::move(__z.__re_);
1434 } else {
1435 return std::move(__z.__im_);
1436 }
1437}
1438
1439#endif // _LIBCPP_STD_VER >= 26
1440
13551441#if _LIBCPP_STD_VER >= 14
13561442// Literal suffix for complex number literals [complex.literals]
13571443inline namespace literals {
......@@ -1383,6 +1469,8 @@ _LIBCPP_HIDE_FROM_ABI inline constexpr complex<float> operator""if(unsigned long
13831469
13841470_LIBCPP_END_NAMESPACE_STD
13851471
1472_LIBCPP_POP_MACROS
1473
13861474#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
13871475# include <iosfwd>
13881476# include <stdexcept>
lib/libcxx/include/concepts+30-23
......@@ -129,32 +129,39 @@ namespace std {
129129
130130*/
131131
132#include <__assert> // all public C++ headers provide the assertion handler
133#include <__concepts/arithmetic.h>
134#include <__concepts/assignable.h>
135#include <__concepts/boolean_testable.h>
136#include <__concepts/class_or_enum.h>
137#include <__concepts/common_reference_with.h>
138#include <__concepts/common_with.h>
139#include <__concepts/constructible.h>
140#include <__concepts/convertible_to.h>
141#include <__concepts/copyable.h>
142#include <__concepts/derived_from.h>
143#include <__concepts/destructible.h>
144#include <__concepts/different_from.h>
145#include <__concepts/equality_comparable.h>
146#include <__concepts/invocable.h>
147#include <__concepts/movable.h>
148#include <__concepts/predicate.h>
149#include <__concepts/regular.h>
150#include <__concepts/relation.h>
151#include <__concepts/same_as.h>
152#include <__concepts/semiregular.h>
153#include <__concepts/swappable.h>
154#include <__concepts/totally_ordered.h>
155132#include <__config>
133
134#if _LIBCPP_STD_VER >= 20
135# include <__concepts/arithmetic.h>
136# include <__concepts/assignable.h>
137# include <__concepts/boolean_testable.h>
138# include <__concepts/class_or_enum.h>
139# include <__concepts/common_reference_with.h>
140# include <__concepts/common_with.h>
141# include <__concepts/constructible.h>
142# include <__concepts/convertible_to.h>
143# include <__concepts/copyable.h>
144# include <__concepts/derived_from.h>
145# include <__concepts/destructible.h>
146# include <__concepts/different_from.h>
147# include <__concepts/equality_comparable.h>
148# include <__concepts/invocable.h>
149# include <__concepts/movable.h>
150# include <__concepts/predicate.h>
151# include <__concepts/regular.h>
152# include <__concepts/relation.h>
153# include <__concepts/same_as.h>
154# include <__concepts/semiregular.h>
155# include <__concepts/swappable.h>
156# include <__concepts/totally_ordered.h>
157#endif // _LIBCPP_STD_VER >= 20
158
156159#include <version>
157160
161#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
162# include <cstddef>
163#endif
164
158165#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
159166# include <type_traits>
160167#endif
lib/libcxx/include/condition_variable-2
......@@ -118,8 +118,6 @@ public:
118118
119119*/
120120
121#include <__assert> // all public C++ headers provide the assertion handler
122#include <__availability>
123121#include <__chrono/duration.h>
124122#include <__chrono/steady_clock.h>
125123#include <__chrono/time_point.h>
lib/libcxx/include/coroutine+9-5
......@@ -38,12 +38,15 @@ struct suspend_always;
3838
3939 */
4040
41#include <__assert> // all public C++ headers provide the assertion handler
4241#include <__config>
43#include <__coroutine/coroutine_handle.h>
44#include <__coroutine/coroutine_traits.h>
45#include <__coroutine/noop_coroutine_handle.h>
46#include <__coroutine/trivial_awaitables.h>
42
43#if _LIBCPP_STD_VER >= 20
44# include <__coroutine/coroutine_handle.h>
45# include <__coroutine/coroutine_traits.h>
46# include <__coroutine/noop_coroutine_handle.h>
47# include <__coroutine/trivial_awaitables.h>
48#endif // _LIBCPP_STD_VER >= 20
49
4750#include <version>
4851
4952// standard-mandated includes
......@@ -57,6 +60,7 @@ struct suspend_always;
5760
5861#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
5962# include <iosfwd>
63# include <limits>
6064# include <type_traits>
6165#endif
6266
lib/libcxx/include/csetjmp-1
......@@ -30,7 +30,6 @@ void longjmp(jmp_buf env, int val);
3030
3131*/
3232
33#include <__assert> // all public C++ headers provide the assertion handler
3433#include <__config>
3534
3635// <setjmp.h> is not provided by libc++
lib/libcxx/include/csignal-1
......@@ -39,7 +39,6 @@ int raise(int sig);
3939
4040*/
4141
42#include <__assert> // all public C++ headers provide the assertion handler
4342#include <__config>
4443
4544// <signal.h> is not provided by libc++
lib/libcxx/include/cstdarg-1
......@@ -31,7 +31,6 @@ Types:
3131
3232*/
3333
34#include <__assert> // all public C++ headers provide the assertion handler
3534#include <__config>
3635
3736// <stdarg.h> is not provided by libc++
lib/libcxx/include/cstdbool-1
......@@ -19,7 +19,6 @@ Macros:
1919
2020*/
2121
22#include <__assert> // all public C++ headers provide the assertion handler
2322#include <__config>
2423
2524#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/cstddef+1-2
......@@ -33,7 +33,6 @@ Types:
3333
3434*/
3535
36#include <__assert> // all public C++ headers provide the assertion handler
3736#include <__config>
3837#include <__type_traits/enable_if.h>
3938#include <__type_traits/integral_constant.h>
......@@ -123,7 +122,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr byte operator>>(byte __lhs, _Integer __shift) no
123122}
124123
125124template <class _Integer, __enable_if_t<is_integral<_Integer>::value, int> = 0>
126_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
125[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Integer to_integer(byte __b) noexcept {
127126 return static_cast<_Integer>(__b);
128127}
129128
lib/libcxx/include/cstdint-1
......@@ -140,7 +140,6 @@ Types:
140140} // std
141141*/
142142
143#include <__assert> // all public C++ headers provide the assertion handler
144143#include <__config>
145144
146145#include <stdint.h>
lib/libcxx/include/cstdio-1
......@@ -95,7 +95,6 @@ void perror(const char* s);
9595} // std
9696*/
9797
98#include <__assert> // all public C++ headers provide the assertion handler
9998#include <__config>
10099
101100#include <stdio.h>
lib/libcxx/include/cstdlib-1
......@@ -81,7 +81,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11
8181
8282*/
8383
84#include <__assert> // all public C++ headers provide the assertion handler
8584#include <__config>
8685
8786#include <stdlib.h>
lib/libcxx/include/cstring-1
......@@ -56,7 +56,6 @@ size_t strlen(const char* s);
5656
5757*/
5858
59#include <__assert> // all public C++ headers provide the assertion handler
6059#include <__config>
6160#include <__type_traits/is_constant_evaluated.h>
6261
lib/libcxx/include/ctgmath-1
......@@ -18,7 +18,6 @@
1818
1919*/
2020
21#include <__assert> // all public C++ headers provide the assertion handler
2221#include <ccomplex>
2322#include <cmath>
2423
lib/libcxx/include/ctime-1
......@@ -45,7 +45,6 @@ int timespec_get( struct timespec *ts, int base); // C++17
4545
4646*/
4747
48#include <__assert> // all public C++ headers provide the assertion handler
4948#include <__config>
5049
5150// <time.h> is not provided by libc++
lib/libcxx/include/cuchar-1
......@@ -36,7 +36,6 @@ size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
3636
3737*/
3838
39#include <__assert> // all public C++ headers provide the assertion handler
4039#include <__config>
4140
4241#include <uchar.h>
lib/libcxx/include/cwchar+6-3
......@@ -102,9 +102,8 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
102102
103103*/
104104
105#include <__assert> // all public C++ headers provide the assertion handler
106105#include <__config>
107#include <__type_traits/apply_cv.h>
106#include <__type_traits/copy_cv.h>
108107#include <__type_traits/is_constant_evaluated.h>
109108#include <__type_traits/is_equality_comparable.h>
110109#include <__type_traits/is_same.h>
......@@ -237,7 +236,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
237236 wchar_t __value_buffer = 0;
238237 __builtin_memcpy(&__value_buffer, &__value, sizeof(wchar_t));
239238 return reinterpret_cast<_Tp*>(
240 __builtin_wmemchr(reinterpret_cast<__apply_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
239 __builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
241240 }
242241# if _LIBCPP_STD_VER >= 17
243242 else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)
......@@ -255,4 +254,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
255254
256255_LIBCPP_END_NAMESPACE_STD
257256
257#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
258# include <cstddef>
259#endif
260
258261#endif // _LIBCPP_CWCHAR
lib/libcxx/include/cwctype-1
......@@ -49,7 +49,6 @@ wctrans_t wctrans(const char* property);
4949
5050*/
5151
52#include <__assert> // all public C++ headers provide the assertion handler
5352#include <__config>
5453#include <cctype>
5554
lib/libcxx/include/deque+74-62
......@@ -188,10 +188,11 @@ template <class T, class Allocator, class Predicate>
188188#include <__algorithm/remove.h>
189189#include <__algorithm/remove_if.h>
190190#include <__algorithm/unwrap_iter.h>
191#include <__assert> // all public C++ headers provide the assertion handler
192#include <__availability>
191#include <__assert>
193192#include <__config>
193#include <__debug_utils/sanitizers.h>
194194#include <__format/enable_insertable.h>
195#include <__fwd/deque.h>
195196#include <__iterator/distance.h>
196197#include <__iterator/iterator_traits.h>
197198#include <__iterator/next.h>
......@@ -213,6 +214,7 @@ template <class T, class Allocator, class Predicate>
213214#include <__type_traits/is_allocator.h>
214215#include <__type_traits/is_convertible.h>
215216#include <__type_traits/is_same.h>
217#include <__type_traits/is_swappable.h>
216218#include <__type_traits/type_identity.h>
217219#include <__utility/forward.h>
218220#include <__utility/move.h>
......@@ -244,9 +246,6 @@ _LIBCPP_PUSH_MACROS
244246
245247_LIBCPP_BEGIN_NAMESPACE_STD
246248
247template <class _Tp, class _Allocator = allocator<_Tp> >
248class _LIBCPP_TEMPLATE_VIS deque;
249
250249template <class _ValueType, class _DiffType>
251250struct __deque_block_size {
252251 static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
......@@ -377,10 +376,13 @@ public:
377376 return __x.__ptr_ == __y.__ptr_;
378377 }
379378
379#if _LIBCPP_STD_VER <= 17
380380 _LIBCPP_HIDE_FROM_ABI friend bool operator!=(const __deque_iterator& __x, const __deque_iterator& __y) {
381381 return !(__x == __y);
382382 }
383#endif
383384
385 // TODO(mordante) disable these overloads in the LLVM 20 release.
384386 _LIBCPP_HIDE_FROM_ABI friend bool operator<(const __deque_iterator& __x, const __deque_iterator& __y) {
385387 return __x.__m_iter_ < __y.__m_iter_ || (__x.__m_iter_ == __y.__m_iter_ && __x.__ptr_ < __y.__ptr_);
386388 }
......@@ -397,6 +399,29 @@ public:
397399 return !(__x < __y);
398400 }
399401
402#if _LIBCPP_STD_VER >= 20
403 _LIBCPP_HIDE_FROM_ABI friend strong_ordering operator<=>(const __deque_iterator& __x, const __deque_iterator& __y) {
404 if (__x.__m_iter_ < __y.__m_iter_)
405 return strong_ordering::less;
406
407 if (__x.__m_iter_ == __y.__m_iter_) {
408 if constexpr (three_way_comparable<pointer, strong_ordering>) {
409 return __x.__ptr_ <=> __y.__ptr_;
410 } else {
411 if (__x.__ptr_ < __y.__ptr_)
412 return strong_ordering::less;
413
414 if (__x.__ptr_ == __y.__ptr_)
415 return strong_ordering::equal;
416
417 return strong_ordering::greater;
418 }
419 }
420
421 return strong_ordering::greater;
422 }
423#endif // _LIBCPP_STD_VER >= 20
424
400425private:
401426 _LIBCPP_HIDE_FROM_ABI explicit __deque_iterator(__map_iterator __m, pointer __p) _NOEXCEPT
402427 : __m_iter_(__m),
......@@ -450,11 +475,11 @@ public:
450475
451476 using value_type = _Tp;
452477
453 static_assert((is_same<typename _Allocator::value_type, value_type>::value),
454 "Allocator::value_type must be same type as value_type");
455
456478 using allocator_type = _Allocator;
457479 using __alloc_traits = allocator_traits<allocator_type>;
480 static_assert(__check_valid_allocator<allocator_type>::value, "");
481 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
482 "Allocator::value_type must be same type as value_type");
458483
459484 using size_type = typename __alloc_traits::size_type;
460485 using difference_type = typename __alloc_traits::difference_type;
......@@ -479,15 +504,22 @@ public:
479504 using reverse_iterator = std::reverse_iterator<iterator>;
480505 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
481506
482 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
483 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
484 "original allocator");
507 // A deque contains the following members which may be trivially relocatable:
508 // - __map: is a `__split_buffer`, see `__split_buffer` for more information on when it is trivially relocatable
509 // - size_type: is always trivially relocatable, since it is required to be an integral type
510 // - allocator_type: may not be trivially relocatable, so it's checked
511 // None of these are referencing the `deque` itself, so if all of them are trivially relocatable, `deque` is too.
512 using __trivially_relocatable = __conditional_t<
513 __libcpp_is_trivially_relocatable<__map>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
514 deque,
515 void>;
516
485517 static_assert(is_nothrow_default_constructible<allocator_type>::value ==
486518 is_nothrow_default_constructible<__pointer_allocator>::value,
487 "rebinding an allocator should not change excpetion guarantees");
519 "rebinding an allocator should not change exception guarantees");
488520 static_assert(is_nothrow_move_constructible<allocator_type>::value ==
489521 is_nothrow_move_constructible<typename __map::allocator_type>::value,
490 "rebinding an allocator should not change excpetion guarantees");
522 "rebinding an allocator should not change exception guarantees");
491523
492524private:
493525 struct __deque_block_range {
......@@ -581,7 +613,7 @@ public:
581613#endif
582614 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v);
583615
584 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
616 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
585617 _LIBCPP_HIDE_FROM_ABI deque(size_type __n, const value_type& __v, const allocator_type& __a)
586618 : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {
587619 __annotate_new(0);
......@@ -623,11 +655,11 @@ public:
623655 return *this;
624656 }
625657
626 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
658 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value);
627659 _LIBCPP_HIDE_FROM_ABI deque(deque&& __c, const __type_identity_t<allocator_type>& __a);
628 _LIBCPP_HIDE_FROM_ABI deque& operator=(deque&& __c)
629 _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value&&
630 is_nothrow_move_assignable<allocator_type>::value);
660 _LIBCPP_HIDE_FROM_ABI deque&
661 operator=(deque&& __c) noexcept(__alloc_traits::propagate_on_container_move_assignment::value &&
662 is_nothrow_move_assignable<allocator_type>::value);
631663
632664 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
633665#endif // _LIBCPP_CXX03_LANG
......@@ -709,7 +741,7 @@ public:
709741 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
710742 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __v);
711743 _LIBCPP_HIDE_FROM_ABI void shrink_to_fit() _NOEXCEPT;
712 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
744 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
713745
714746 // element access:
715747 _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __i) _NOEXCEPT;
......@@ -796,7 +828,7 @@ public:
796828#if _LIBCPP_STD_VER >= 14
797829 _NOEXCEPT;
798830#else
799 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
831 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
800832#endif
801833 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
802834
......@@ -866,33 +898,6 @@ private:
866898 __asan_back_moved,
867899 };
868900
869 // The following functions are no-ops outside of AddressSanitizer mode.
870 // We call annotations for every allocator, unless explicitly disabled.
871 //
872 // To disable annotations for a particular allocator, change value of
873 // __asan_annotate_container_with_allocator to false.
874 // For more details, see the "Using libc++" documentation page or
875 // the documentation for __sanitizer_annotate_contiguous_container.
876 _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
877 const void* __beg,
878 const void* __end,
879 const void* __old_con_beg,
880 const void* __old_con_end,
881 const void* __new_con_beg,
882 const void* __new_con_end) const {
883 (void)__beg;
884 (void)__end;
885 (void)__old_con_beg;
886 (void)__old_con_end;
887 (void)__new_con_beg;
888 (void)__new_con_end;
889#ifndef _LIBCPP_HAS_NO_ASAN
890 if (__beg != nullptr && __asan_annotate_container_with_allocator<_Allocator>::value)
891 __sanitizer_annotate_double_ended_contiguous_container(
892 __beg, __end, __old_con_beg, __old_con_end, __new_con_beg, __new_con_end);
893#endif
894 }
895
896901 _LIBCPP_HIDE_FROM_ABI void __annotate_from_to(
897902 size_type __beg,
898903 size_type __end,
......@@ -992,7 +997,8 @@ private:
992997 const void* __new_beg = __front ? __new_edge : __old_edge;
993998 const void* __new_end = __front ? __old_edge : __new_edge;
994999
995 __annotate_double_ended_contiguous_container(__mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);
1000 std::__annotate_double_ended_contiguous_container<_Allocator>(
1001 __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end);
9961002 }
9971003#endif // !_LIBCPP_HAS_NO_ASAN
9981004 }
......@@ -1053,11 +1059,7 @@ private:
10531059 }
10541060
10551061 _LIBCPP_HIDE_FROM_ABI void __annotate_poison_block(const void* __beginning, const void* __end) const _NOEXCEPT {
1056 (void)__beginning;
1057 (void)__end;
1058#ifndef _LIBCPP_HAS_NO_ASAN
1059 __annotate_double_ended_contiguous_container(__beginning, __end, __beginning, __end, __end, __end);
1060#endif
1062 std::__annotate_double_ended_contiguous_container<_Allocator>(__beginning, __end, __beginning, __end, __end, __end);
10611063 }
10621064
10631065 _LIBCPP_HIDE_FROM_ABI void
......@@ -1072,7 +1074,7 @@ private:
10721074 if (__annotation_type == __asan_poison)
10731075 __annotate_poison_block(__block_start, __block_end);
10741076 else {
1075 __annotate_double_ended_contiguous_container(
1077 std::__annotate_double_ended_contiguous_container<_Allocator>(
10761078 __block_start, __block_end, __block_start, __block_start, __block_start, __block_end);
10771079 }
10781080#endif
......@@ -1330,7 +1332,7 @@ deque<_Tp, _Allocator>::deque(initializer_list<value_type> __il, const allocator
13301332}
13311333
13321334template <class _Tp, class _Allocator>
1333inline deque<_Tp, _Allocator>::deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
1335inline deque<_Tp, _Allocator>::deque(deque&& __c) noexcept(is_nothrow_move_constructible<allocator_type>::value)
13341336 : __map_(std::move(__c.__map_)), __start_(std::move(__c.__start_)), __size_(std::move(__c.__size_)) {
13351337 __c.__start_ = 0;
13361338 __c.__size() = 0;
......@@ -1354,8 +1356,9 @@ inline deque<_Tp, _Allocator>::deque(deque&& __c, const __type_identity_t<alloca
13541356}
13551357
13561358template <class _Tp, class _Allocator>
1357inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) _NOEXCEPT_(
1358 __alloc_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value) {
1359inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) noexcept(
1360 __alloc_traits::propagate_on_container_move_assignment::value &&
1361 is_nothrow_move_assignable<allocator_type>::value) {
13591362 __move_assign(__c, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
13601363 return *this;
13611364}
......@@ -1370,8 +1373,8 @@ void deque<_Tp, _Allocator>::__move_assign(deque& __c, false_type) {
13701373}
13711374
13721375template <class _Tp, class _Allocator>
1373void deque<_Tp, _Allocator>::__move_assign(deque& __c, true_type)
1374 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) {
1376void deque<_Tp, _Allocator>::__move_assign(deque& __c,
1377 true_type) noexcept(is_nothrow_move_assignable<allocator_type>::value) {
13751378 clear();
13761379 shrink_to_fit();
13771380 __move_assign(__c);
......@@ -1487,6 +1490,7 @@ void deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT {
14871490
14881491template <class _Tp, class _Allocator>
14891492inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT {
1493 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "deque::operator[] index out of bounds");
14901494 size_type __p = __start_ + __i;
14911495 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
14921496}
......@@ -1494,6 +1498,7 @@ inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operat
14941498template <class _Tp, class _Allocator>
14951499inline typename deque<_Tp, _Allocator>::const_reference
14961500deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT {
1501 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < size(), "deque::operator[] index out of bounds");
14971502 size_type __p = __start_ + __i;
14981503 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
14991504}
......@@ -1516,22 +1521,26 @@ inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::
15161521
15171522template <class _Tp, class _Allocator>
15181523inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() _NOEXCEPT {
1524 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::front called on an empty deque");
15191525 return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size);
15201526}
15211527
15221528template <class _Tp, class _Allocator>
15231529inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const _NOEXCEPT {
1530 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::front called on an empty deque");
15241531 return *(*(__map_.begin() + __start_ / __block_size) + __start_ % __block_size);
15251532}
15261533
15271534template <class _Tp, class _Allocator>
15281535inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() _NOEXCEPT {
1536 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::back called on an empty deque");
15291537 size_type __p = size() + __start_ - 1;
15301538 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
15311539}
15321540
15331541template <class _Tp, class _Allocator>
15341542inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const _NOEXCEPT {
1543 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::back called on an empty deque");
15351544 size_type __p = size() + __start_ - 1;
15361545 return *(*(__map_.begin() + __p / __block_size) + __p % __block_size);
15371546}
......@@ -2255,6 +2264,7 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
22552264
22562265template <class _Tp, class _Allocator>
22572266void deque<_Tp, _Allocator>::pop_front() {
2267 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "deque::pop_front called on an empty deque");
22582268 size_type __old_sz = size();
22592269 size_type __old_start = __start_;
22602270 allocator_type& __a = __alloc();
......@@ -2395,6 +2405,8 @@ void deque<_Tp, _Allocator>::__move_construct_backward_and_check(
23952405
23962406template <class _Tp, class _Allocator>
23972407typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f) {
2408 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(
2409 __f != end(), "deque::erase(iterator) called with a non-dereferenceable iterator");
23982410 size_type __old_sz = size();
23992411 size_type __old_start = __start_;
24002412 iterator __b = begin();
......@@ -2420,6 +2432,7 @@ typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_it
24202432
24212433template <class _Tp, class _Allocator>
24222434typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f, const_iterator __l) {
2435 _LIBCPP_ASSERT_VALID_INPUT_RANGE(__f <= __l, "deque::erase(first, last) called with an invalid range");
24232436 size_type __old_sz = size();
24242437 size_type __old_start = __start_;
24252438 difference_type __n = __l - __f;
......@@ -2474,7 +2487,7 @@ inline void deque<_Tp, _Allocator>::swap(deque& __c)
24742487#if _LIBCPP_STD_VER >= 14
24752488 _NOEXCEPT
24762489#else
2477 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
2490 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
24782491#endif
24792492{
24802493 __map_.swap(__c.__map_);
......@@ -2543,8 +2556,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const deque<_Tp, _Allocator>& __x,
25432556template <class _Tp, class _Allocator>
25442557_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
25452558operator<=>(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) {
2546 return std::lexicographical_compare_three_way(
2547 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
2559 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
25482560}
25492561
25502562#endif // _LIBCPP_STD_VER <= 17
lib/libcxx/include/exception-1
......@@ -76,7 +76,6 @@ template <class E> void rethrow_if_nested(const E& e);
7676
7777*/
7878
79#include <__assert> // all public C++ headers provide the assertion handler
8079#include <__config>
8180#include <__exception/exception.h>
8281#include <__exception/exception_ptr.h>
lib/libcxx/include/execution+4-1
......@@ -32,7 +32,6 @@ namespace std {
3232}
3333*/
3434
35#include <__assert> // all public C++ headers provide the assertion handler
3635#include <__config>
3736#include <__type_traits/is_execution_policy.h>
3837#include <__type_traits/is_same.h>
......@@ -143,4 +142,8 @@ _LIBCPP_END_NAMESPACE_STD
143142
144143#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_PSTL) && _LIBCPP_STD_VER >= 17
145144
145#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
146# include <cstddef>
147#endif
148
146149#endif // _LIBCPP_EXECUTION
lib/libcxx/include/expected+14-5
......@@ -38,16 +38,25 @@ namespace std {
3838
3939*/
4040
41#include <__assert> // all public C++ headers provide the assertion handler
4241#include <__config>
43#include <__expected/bad_expected_access.h>
44#include <__expected/expected.h>
45#include <__expected/unexpect.h>
46#include <__expected/unexpected.h>
42
43#if _LIBCPP_STD_VER >= 23
44# include <__expected/bad_expected_access.h>
45# include <__expected/expected.h>
46# include <__expected/unexpect.h>
47# include <__expected/unexpected.h>
48#endif
49
4750#include <version>
4851
4952#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5053# pragma GCC system_header
5154#endif
5255
56#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
57# include <cstddef>
58# include <initializer_list>
59# include <new>
60#endif
61
5362#endif // _LIBCPP_EXPECTED
lib/libcxx/include/experimental/__memory deleted-94
......@@ -1,94 +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_EXPERIMENTAL___MEMORY
11#define _LIBCPP_EXPERIMENTAL___MEMORY
12
13#include <__memory/allocator_arg_t.h>
14#include <__memory/uses_allocator.h>
15#include <__type_traits/conditional.h>
16#include <__type_traits/is_constructible.h>
17#include <__type_traits/is_convertible.h>
18#include <__type_traits/is_same.h>
19#include <experimental/__config>
20#include <experimental/utility> // for erased_type
21
22#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
23# pragma GCC system_header
24#endif
25
26_LIBCPP_BEGIN_NAMESPACE_LFTS
27
28template < class _Tp, class _Alloc, bool = uses_allocator<_Tp, _Alloc>::value, bool = __has_allocator_type<_Tp>::value >
29struct __lfts_uses_allocator : public false_type {};
30
31template <class _Tp, class _Alloc>
32struct __lfts_uses_allocator<_Tp, _Alloc, false, false> : public false_type {};
33
34template <class _Tp, class _Alloc, bool HasAlloc>
35struct __lfts_uses_allocator<_Tp, _Alloc, true, HasAlloc> : public true_type {};
36
37template <class _Tp, class _Alloc>
38struct __lfts_uses_allocator<_Tp, _Alloc, false, true>
39 : public integral_constant<bool,
40 is_convertible<_Alloc, typename _Tp::allocator_type>::value ||
41 is_same<erased_type, typename _Tp::allocator_type>::value > {};
42
43template <bool _UsesAlloc, class _Tp, class _Alloc, class... _Args>
44struct __lfts_uses_alloc_ctor_imp {
45 static const int value = 0;
46};
47
48template <class _Tp, class _Alloc, class... _Args>
49struct __lfts_uses_alloc_ctor_imp<true, _Tp, _Alloc, _Args...> {
50 static const bool __ic_first = is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
51
52 static const bool __ic_second =
53 __conditional_t< __ic_first, false_type, is_constructible<_Tp, _Args..., _Alloc> >::value;
54
55 static_assert(__ic_first || __ic_second, "Request for uses allocator construction is ill-formed");
56
57 static const int value = __ic_first ? 1 : 2;
58};
59
60template <class _Tp, class _Alloc, class... _Args>
61struct __lfts_uses_alloc_ctor
62 : integral_constant<
63 int,
64 __lfts_uses_alloc_ctor_imp< __lfts_uses_allocator<_Tp, _Alloc>::value, _Tp, _Alloc, _Args... >::value > {};
65
66template <class _Tp, class _Allocator, class... _Args>
67inline _LIBCPP_HIDE_FROM_ABI void
68__user_alloc_construct_impl(integral_constant<int, 0>, _Tp* __storage, const _Allocator&, _Args&&... __args) {
69 new (__storage) _Tp(std::forward<_Args>(__args)...);
70}
71
72// FIXME: This should have a version which takes a non-const alloc.
73template <class _Tp, class _Allocator, class... _Args>
74inline _LIBCPP_HIDE_FROM_ABI void
75__user_alloc_construct_impl(integral_constant<int, 1>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
76 new (__storage) _Tp(allocator_arg_t(), __a, std::forward<_Args>(__args)...);
77}
78
79// FIXME: This should have a version which takes a non-const alloc.
80template <class _Tp, class _Allocator, class... _Args>
81inline _LIBCPP_HIDE_FROM_ABI void
82__user_alloc_construct_impl(integral_constant<int, 2>, _Tp* __storage, const _Allocator& __a, _Args&&... __args) {
83 new (__storage) _Tp(std::forward<_Args>(__args)..., __a);
84}
85
86template <class _Tp, class _Alloc, class... _Args>
87inline _LIBCPP_HIDE_FROM_ABI void __lfts_user_alloc_construct(_Tp* __store, const _Alloc& __a, _Args&&... __args) {
88 ::std::experimental::fundamentals_v1::__user_alloc_construct_impl(
89 typename __lfts_uses_alloc_ctor<_Tp, _Alloc, _Args...>::type(), __store, __a, std::forward<_Args>(__args)...);
90}
91
92_LIBCPP_END_NAMESPACE_LFTS
93
94#endif /* _LIBCPP_EXPERIMENTAL___MEMORY */
lib/libcxx/include/experimental/__simd/reference.h+41
......@@ -13,10 +13,14 @@
1313#include <__type_traits/is_assignable.h>
1414#include <__type_traits/is_same.h>
1515#include <__utility/forward.h>
16#include <__utility/move.h>
1617#include <cstddef>
1718#include <experimental/__config>
1819#include <experimental/__simd/utility.h>
1920
21_LIBCPP_PUSH_MACROS
22#include <__undef_macros>
23
2024#if _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
2125
2226_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
......@@ -55,10 +59,47 @@ public:
5559 __set(static_cast<value_type>(std::forward<_Up>(__v)));
5660 return {__s_, __idx_};
5761 }
62
63 // Note: This approach might not fully align with the specification,
64 // which might be a wording defect. (https://wg21.link/N4808 section 9.6.3)
65 template <class _Tp1, class _Storage1, class _Vp1>
66 friend void
67 swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, __simd_reference<_Tp1, _Storage1, _Vp1>&& __b) noexcept;
68
69 template <class _Tp1, class _Storage1, class _Vp1>
70 friend void swap(_Vp1& __a, __simd_reference<_Tp1, _Storage1, _Vp1>&& __b) noexcept;
71
72 template <class _Tp1, class _Storage1, class _Vp1>
73 friend void swap(__simd_reference<_Tp1, _Storage1, _Vp1>&& __a, _Vp1& __b) noexcept;
5874};
5975
76template <class _Tp, class _Storage, class _Vp>
77_LIBCPP_HIDE_FROM_ABI void
78swap(__simd_reference<_Tp, _Storage, _Vp>&& __a, __simd_reference<_Tp, _Storage, _Vp>&& __b) noexcept {
79 _Vp __tmp(std::move(__a));
80 std::move(__a) = std::move(__b);
81 std::move(__b) = std::move(__tmp);
82}
83
84template <class _Tp, class _Storage, class _Vp>
85_LIBCPP_HIDE_FROM_ABI void swap(_Vp& __a, __simd_reference<_Tp, _Storage, _Vp>&& __b) noexcept {
86 _Vp __tmp(std::move(__a));
87 __a = std::move(__b);
88 std::move(__b) = std::move(__tmp);
89}
90
91template <class _Tp, class _Storage, class _Vp>
92_LIBCPP_HIDE_FROM_ABI void swap(__simd_reference<_Tp, _Storage, _Vp>&& __a, _Vp& __b) noexcept {
93 _Vp __tmp(std::move(__a));
94 std::move(__a) = std::move(__b);
95 __b = std::move(__tmp);
96}
97
6098} // namespace parallelism_v2
6199_LIBCPP_END_NAMESPACE_EXPERIMENTAL
62100
63101#endif // _LIBCPP_STD_VER >= 17 && defined(_LIBCPP_ENABLE_EXPERIMENTAL)
102
103_LIBCPP_POP_MACROS
104
64105#endif // _LIBCPP_EXPERIMENTAL___SIMD_REFERENCE_H
lib/libcxx/include/experimental/__simd/scalar.h+8
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H
1111#define _LIBCPP_EXPERIMENTAL___SIMD_SCALAR_H
1212
13#include <__assert>
1314#include <cstddef>
1415#include <experimental/__config>
1516#include <experimental/__simd/declaration.h>
......@@ -61,6 +62,11 @@ struct __simd_operations<_Tp, simd_abi::__scalar> {
6162 static _LIBCPP_HIDE_FROM_ABI void __load(_SimdStorage& __s, const _Up* __mem) noexcept {
6263 __s.__data = static_cast<_Tp>(__mem[0]);
6364 }
65
66 template <class _Up>
67 static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept {
68 *__mem = static_cast<_Up>(__s.__data);
69 }
6470};
6571
6672template <class _Tp>
......@@ -70,6 +76,8 @@ struct __mask_operations<_Tp, simd_abi::__scalar> {
7076 static _LIBCPP_HIDE_FROM_ABI _MaskStorage __broadcast(bool __v) noexcept { return {__v}; }
7177
7278 static _LIBCPP_HIDE_FROM_ABI void __load(_MaskStorage& __s, const bool* __mem) noexcept { __s.__data = __mem[0]; }
79
80 static _LIBCPP_HIDE_FROM_ABI void __store(_MaskStorage __s, bool* __mem) noexcept { __mem[0] = __s.__data; }
7381};
7482
7583} // namespace parallelism_v2
lib/libcxx/include/experimental/__simd/simd.h+11
......@@ -70,6 +70,17 @@ public:
7070 _Impl::__load(__s_, _Flags::template __apply<simd>(__mem));
7171 }
7272
73 // copy functions
74 template <class _Up, class _Flags, enable_if_t<__is_vectorizable_v<_Up> && is_simd_flag_type_v<_Flags>, int> = 0>
75 _LIBCPP_HIDE_FROM_ABI void copy_from(const _Up* __mem, _Flags) {
76 _Impl::__load(__s_, _Flags::template __apply<simd>(__mem));
77 }
78
79 template <class _Up, class _Flags, enable_if_t<__is_vectorizable_v<_Up> && is_simd_flag_type_v<_Flags>, int> = 0>
80 _LIBCPP_HIDE_FROM_ABI void copy_to(_Up* __mem, _Flags) const {
81 _Impl::__store(__s_, _Flags::template __apply<simd>(__mem));
82 }
83
7384 // scalar access [simd.subscr]
7485 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); }
7586 _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); }
lib/libcxx/include/experimental/__simd/simd_mask.h+11
......@@ -58,6 +58,17 @@ public:
5858 _Impl::__load(__s_, _Flags::template __apply<simd_mask>(__mem));
5959 }
6060
61 // copy functions
62 template <class _Flags, enable_if_t<is_simd_flag_type_v<_Flags>, int> = 0>
63 _LIBCPP_HIDE_FROM_ABI void copy_from(const value_type* __mem, _Flags) {
64 _Impl::__load(__s_, _Flags::template __apply<simd_mask>(__mem));
65 }
66
67 template <class _Flags, enable_if_t<is_simd_flag_type_v<_Flags>, int> = 0>
68 _LIBCPP_HIDE_FROM_ABI void copy_to(value_type* __mem, _Flags) const {
69 _Impl::__store(__s_, _Flags::template __apply<simd_mask>(__mem));
70 }
71
6172 // scalar access [simd.mask.subscr]
6273 _LIBCPP_HIDE_FROM_ABI reference operator[](size_t __i) noexcept { return reference(__s_, __i); }
6374 _LIBCPP_HIDE_FROM_ABI value_type operator[](size_t __i) const noexcept { return __s_.__get(__i); }
lib/libcxx/include/experimental/__simd/vec_ext.h+12
......@@ -10,6 +10,7 @@
1010#ifndef _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H
1111#define _LIBCPP_EXPERIMENTAL___SIMD_VEC_EXT_H
1212
13#include <__assert>
1314#include <__bit/bit_ceil.h>
1415#include <__utility/forward.h>
1516#include <__utility/integer_sequence.h>
......@@ -79,6 +80,12 @@ struct __simd_operations<_Tp, simd_abi::__vec_ext<_Np>> {
7980 for (size_t __i = 0; __i < _Np; __i++)
8081 __s.__data[__i] = static_cast<_Tp>(__mem[__i]);
8182 }
83
84 template <class _Up>
85 static _LIBCPP_HIDE_FROM_ABI void __store(_SimdStorage __s, _Up* __mem) noexcept {
86 for (size_t __i = 0; __i < _Np; __i++)
87 __mem[__i] = static_cast<_Up>(__s.__data[__i]);
88 }
8289};
8390
8491template <class _Tp, int _Np>
......@@ -98,6 +105,11 @@ struct __mask_operations<_Tp, simd_abi::__vec_ext<_Np>> {
98105 for (size_t __i = 0; __i < _Np; __i++)
99106 __s.__data[__i] = experimental::__set_all_bits<_Tp>(__mem[__i]);
100107 }
108
109 static _LIBCPP_HIDE_FROM_ABI void __store(_MaskStorage __s, bool* __mem) noexcept {
110 for (size_t __i = 0; __i < _Np; __i++)
111 __mem[__i] = static_cast<bool>(__s.__data[__i]);
112 }
101113};
102114
103115} // namespace parallelism_v2
lib/libcxx/include/experimental/iterator-1
......@@ -52,7 +52,6 @@ namespace std {
5252
5353*/
5454
55#include <__assert> // all public C++ headers provide the assertion handler
5655#include <__memory/addressof.h>
5756#include <__type_traits/decay.h>
5857#include <__utility/forward.h>
lib/libcxx/include/experimental/memory+5-1
......@@ -79,7 +79,7 @@ public:
7979 _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(nullptr_t) noexcept : __ptr_(nullptr) {}
8080 _LIBCPP_HIDE_FROM_ABI constexpr explicit observer_ptr(element_type* __p) noexcept : __ptr_(__p) {}
8181
82 template <class _W2, class = __enable_if_t<is_convertible<_W2*, _Wp*>::value>>
82 template <class _W2, __enable_if_t<is_convertible<_W2*, _Wp*>::value, int> = 0>
8383 _LIBCPP_HIDE_FROM_ABI constexpr observer_ptr(observer_ptr<_W2> __other) noexcept : __ptr_(__other.get()) {}
8484
8585 // observers
......@@ -191,4 +191,8 @@ _LIBCPP_END_NAMESPACE_STD
191191
192192#endif // _LIBCPP_ENABLE_EXPERIMENTAL
193193
194#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
195# include <limits>
196#endif
197
194198#endif /* _LIBCPP_EXPERIMENTAL_MEMORY */
lib/libcxx/include/experimental/propagate_const+54-63
......@@ -107,9 +107,8 @@
107107
108108*/
109109
110#include <__assert> // all public C++ headers provide the assertion handler
111110#include <__functional/operations.h>
112#include <__fwd/hash.h>
111#include <__fwd/functional.h>
113112#include <__type_traits/conditional.h>
114113#include <__type_traits/decay.h>
115114#include <__type_traits/enable_if.h>
......@@ -146,10 +145,10 @@ template <class _Tp>
146145class propagate_const;
147146
148147template <class _Up>
149inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
148inline _LIBCPP_HIDE_FROM_ABI constexpr const _Up& get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
150149
151150template <class _Up>
152inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
151inline _LIBCPP_HIDE_FROM_ABI constexpr _Up& get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
153152
154153template <class _Tp>
155154class propagate_const {
......@@ -165,22 +164,22 @@ public:
165164
166165private:
167166 template <class _Up>
168 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up* __u) {
167 static _LIBCPP_HIDE_FROM_ABI constexpr element_type* __get_pointer(_Up* __u) {
169168 return __u;
170169 }
171170
172171 template <class _Up>
173 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* __get_pointer(_Up& __u) {
172 static _LIBCPP_HIDE_FROM_ABI constexpr element_type* __get_pointer(_Up& __u) {
174173 return __get_pointer(__u.get());
175174 }
176175
177176 template <class _Up>
178 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up* __u) {
177 static _LIBCPP_HIDE_FROM_ABI constexpr const element_type* __get_pointer(const _Up* __u) {
179178 return __u;
180179 }
181180
182181 template <class _Up>
183 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* __get_pointer(const _Up& __u) {
182 static _LIBCPP_HIDE_FROM_ABI constexpr const element_type* __get_pointer(const _Up& __u) {
184183 return __get_pointer(__u.get());
185184 }
186185
......@@ -194,215 +193,207 @@ private:
194193
195194public:
196195 template <class _Up>
197 friend _LIBCPP_CONSTEXPR const _Up&
198 experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
196 friend constexpr const _Up& experimental::fundamentals_v2::get_underlying(const propagate_const<_Up>& __pu) _NOEXCEPT;
199197 template <class _Up>
200 friend _LIBCPP_CONSTEXPR _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
198 friend constexpr _Up& experimental::fundamentals_v2::get_underlying(propagate_const<_Up>& __pu) _NOEXCEPT;
201199
202 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const() = default;
200 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const() = default;
203201
204202 propagate_const(const propagate_const&) = delete;
205203
206 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const&&) = default;
204 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const&&) = default;
207205
208206 template <class _Up,
209207 enable_if_t<!is_convertible<_Up, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = true>
210 explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
208 explicit _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const<_Up>&& __pu)
211209 : __t_(std::move(experimental::get_underlying(__pu))) {}
212210
213211 template <class _Up,
214212 enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value, bool> = false>
215 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(propagate_const<_Up>&& __pu)
213 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(propagate_const<_Up>&& __pu)
216214 : __t_(std::move(experimental::get_underlying(__pu))) {}
217215
218216 template <class _Up,
219217 enable_if_t<!is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value &&
220218 !__is_propagate_const<decay_t<_Up>>::value,
221219 bool> = true>
222 explicit _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
220 explicit _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
223221
224222 template <class _Up,
225223 enable_if_t<is_convertible<_Up&&, _Tp>::value && is_constructible<_Tp, _Up&&>::value &&
226224 !__is_propagate_const<decay_t<_Up>>::value,
227225 bool> = false>
228 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
226 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const(_Up&& __u) : __t_(std::forward<_Up>(__u)) {}
229227
230228 propagate_const& operator=(const propagate_const&) = delete;
231229
232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const&&) = default;
230 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(propagate_const&&) = default;
233231
234232 template <class _Up>
235 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(propagate_const<_Up>&& __pu) {
233 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(propagate_const<_Up>&& __pu) {
236234 __t_ = std::move(experimental::get_underlying(__pu));
237235 return *this;
238236 }
239237
240238 template <class _Up, class _Vp = enable_if_t<!__is_propagate_const<decay_t<_Up>>::value>>
241 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR propagate_const& operator=(_Up&& __u) {
239 _LIBCPP_HIDE_FROM_ABI constexpr propagate_const& operator=(_Up&& __u) {
242240 __t_ = std::forward<_Up>(__u);
243241 return *this;
244242 }
245243
246 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* get() const { return __get_pointer(__t_); }
244 _LIBCPP_HIDE_FROM_ABI constexpr const element_type* get() const { return __get_pointer(__t_); }
247245
248 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* get() { return __get_pointer(__t_); }
246 _LIBCPP_HIDE_FROM_ABI constexpr element_type* get() { return __get_pointer(__t_); }
249247
250 _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR operator bool() const { return get() != nullptr; }
248 _LIBCPP_HIDE_FROM_ABI explicit constexpr operator bool() const { return get() != nullptr; }
251249
252 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type* operator->() const { return get(); }
250 _LIBCPP_HIDE_FROM_ABI constexpr const element_type* operator->() const { return get(); }
253251
254252 template <class _Dummy = _Tp, class _Up = enable_if_t<is_convertible< const _Dummy, const element_type*>::value>>
255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator const element_type*() const {
253 _LIBCPP_HIDE_FROM_ABI constexpr operator const element_type*() const {
256254 return get();
257255 }
258256
259 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR const element_type& operator*() const { return *get(); }
257 _LIBCPP_HIDE_FROM_ABI constexpr const element_type& operator*() const { return *get(); }
260258
261 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type* operator->() { return get(); }
259 _LIBCPP_HIDE_FROM_ABI constexpr element_type* operator->() { return get(); }
262260
263261 template <class _Dummy = _Tp, class _Up = enable_if_t< is_convertible<_Dummy, element_type*>::value>>
264 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator element_type*() {
262 _LIBCPP_HIDE_FROM_ABI constexpr operator element_type*() {
265263 return get();
266264 }
267265
268 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR element_type& operator*() { return *get(); }
266 _LIBCPP_HIDE_FROM_ABI constexpr element_type& operator*() { return *get(); }
269267
270 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const& __pt)
271 _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
268 _LIBCPP_HIDE_FROM_ABI constexpr void swap(propagate_const& __pt) noexcept(__is_nothrow_swappable_v<_Tp>) {
272269 using std::swap;
273270 swap(__t_, __pt.__t_);
274271 }
275272};
276273
277274template <class _Tp>
278_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) {
275_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, nullptr_t) {
279276 return experimental::get_underlying(__pt) == nullptr;
280277}
281278
282279template <class _Tp>
283_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) {
280_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(nullptr_t, const propagate_const<_Tp>& __pt) {
284281 return nullptr == experimental::get_underlying(__pt);
285282}
286283
287284template <class _Tp>
288_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) {
285_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, nullptr_t) {
289286 return experimental::get_underlying(__pt) != nullptr;
290287}
291288
292289template <class _Tp>
293_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) {
290_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(nullptr_t, const propagate_const<_Tp>& __pt) {
294291 return nullptr != experimental::get_underlying(__pt);
295292}
296293
297294template <class _Tp, class _Up>
298_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
299operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
295_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
300296 return experimental::get_underlying(__pt) == experimental::get_underlying(__pu);
301297}
302298
303299template <class _Tp, class _Up>
304_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
305operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
300_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
306301 return experimental::get_underlying(__pt) != experimental::get_underlying(__pu);
307302}
308303
309304template <class _Tp, class _Up>
310_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
311operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
305_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
312306 return experimental::get_underlying(__pt) < experimental::get_underlying(__pu);
313307}
314308
315309template <class _Tp, class _Up>
316_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
317operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
310_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
318311 return experimental::get_underlying(__pt) > experimental::get_underlying(__pu);
319312}
320313
321314template <class _Tp, class _Up>
322_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
323operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
315_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
324316 return experimental::get_underlying(__pt) <= experimental::get_underlying(__pu);
325317}
326318
327319template <class _Tp, class _Up>
328_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool
329operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
320_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const propagate_const<_Tp>& __pt, const propagate_const<_Up>& __pu) {
330321 return experimental::get_underlying(__pt) >= experimental::get_underlying(__pu);
331322}
332323
333324template <class _Tp, class _Up>
334_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) {
325_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const propagate_const<_Tp>& __pt, const _Up& __u) {
335326 return experimental::get_underlying(__pt) == __u;
336327}
337328
338329template <class _Tp, class _Up>
339_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) {
330_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const propagate_const<_Tp>& __pt, const _Up& __u) {
340331 return experimental::get_underlying(__pt) != __u;
341332}
342333
343334template <class _Tp, class _Up>
344_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) {
335_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const propagate_const<_Tp>& __pt, const _Up& __u) {
345336 return experimental::get_underlying(__pt) < __u;
346337}
347338
348339template <class _Tp, class _Up>
349_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) {
340_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const propagate_const<_Tp>& __pt, const _Up& __u) {
350341 return experimental::get_underlying(__pt) > __u;
351342}
352343
353344template <class _Tp, class _Up>
354_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) {
345_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const propagate_const<_Tp>& __pt, const _Up& __u) {
355346 return experimental::get_underlying(__pt) <= __u;
356347}
357348
358349template <class _Tp, class _Up>
359_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) {
350_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const propagate_const<_Tp>& __pt, const _Up& __u) {
360351 return experimental::get_underlying(__pt) >= __u;
361352}
362353
363354template <class _Tp, class _Up>
364_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) {
355_LIBCPP_HIDE_FROM_ABI constexpr bool operator==(const _Tp& __t, const propagate_const<_Up>& __pu) {
365356 return __t == experimental::get_underlying(__pu);
366357}
367358
368359template <class _Tp, class _Up>
369_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) {
360_LIBCPP_HIDE_FROM_ABI constexpr bool operator!=(const _Tp& __t, const propagate_const<_Up>& __pu) {
370361 return __t != experimental::get_underlying(__pu);
371362}
372363
373364template <class _Tp, class _Up>
374_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) {
365_LIBCPP_HIDE_FROM_ABI constexpr bool operator<(const _Tp& __t, const propagate_const<_Up>& __pu) {
375366 return __t < experimental::get_underlying(__pu);
376367}
377368
378369template <class _Tp, class _Up>
379_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) {
370_LIBCPP_HIDE_FROM_ABI constexpr bool operator>(const _Tp& __t, const propagate_const<_Up>& __pu) {
380371 return __t > experimental::get_underlying(__pu);
381372}
382373
383374template <class _Tp, class _Up>
384_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) {
375_LIBCPP_HIDE_FROM_ABI constexpr bool operator<=(const _Tp& __t, const propagate_const<_Up>& __pu) {
385376 return __t <= experimental::get_underlying(__pu);
386377}
387378
388379template <class _Tp, class _Up>
389_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) {
380_LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const _Tp& __t, const propagate_const<_Up>& __pu) {
390381 return __t >= experimental::get_underlying(__pu);
391382}
392383
393384template <class _Tp>
394_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR void swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2)
395 _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
385_LIBCPP_HIDE_FROM_ABI constexpr void
386swap(propagate_const<_Tp>& __pc1, propagate_const<_Tp>& __pc2) noexcept(__is_nothrow_swappable_v<_Tp>) {
396387 __pc1.swap(__pc2);
397388}
398389
399390template <class _Tp>
400_LIBCPP_CONSTEXPR const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT {
391constexpr const _Tp& get_underlying(const propagate_const<_Tp>& __pt) _NOEXCEPT {
401392 return __pt.__t_;
402393}
403394
404395template <class _Tp>
405_LIBCPP_CONSTEXPR _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT {
396constexpr _Tp& get_underlying(propagate_const<_Tp>& __pt) _NOEXCEPT {
406397 return __pt.__t_;
407398}
408399
lib/libcxx/include/experimental/simd+1-2
......@@ -71,8 +71,6 @@ inline namespace parallelism_v2 {
7171
7272*/
7373
74#include <__assert> // all public C++ headers provide the assertion handler
75
7674#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
7775# pragma GCC system_header
7876#endif
......@@ -80,6 +78,7 @@ inline namespace parallelism_v2 {
8078#include <experimental/__config>
8179#include <experimental/__simd/aligned_tag.h>
8280#include <experimental/__simd/declaration.h>
81#include <experimental/__simd/reference.h>
8382#include <experimental/__simd/scalar.h>
8483#include <experimental/__simd/simd.h>
8584#include <experimental/__simd/simd_mask.h>
lib/libcxx/include/experimental/type_traits+3-4
......@@ -68,7 +68,6 @@ inline namespace fundamentals_v1 {
6868
6969 */
7070
71#include <__assert> // all public C++ headers provide the assertion handler
7271#include <experimental/__config>
7372
7473#if _LIBCPP_STD_VER >= 14
......@@ -130,7 +129,7 @@ using is_detected = typename _DETECTOR<nonesuch, void, _Op, _Args...>::value_t;
130129template <template <class...> class _Op, class... _Args>
131130using detected_t = typename _DETECTOR<nonesuch, void, _Op, _Args...>::type;
132131template <template <class...> class _Op, class... _Args>
133_LIBCPP_CONSTEXPR bool is_detected_v = is_detected<_Op, _Args...>::value;
132constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
134133
135134template <class _Default, template <class...> class _Op, class... _Args>
136135using detected_or = _DETECTOR<_Default, void, _Op, _Args...>;
......@@ -140,12 +139,12 @@ using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
140139template <class _Expected, template <class...> class _Op, class... _Args>
141140using is_detected_exact = is_same<_Expected, detected_t<_Op, _Args...>>;
142141template <class _Expected, template <class...> class _Op, class... _Args>
143_LIBCPP_CONSTEXPR bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value;
142constexpr bool is_detected_exact_v = is_detected_exact<_Expected, _Op, _Args...>::value;
144143
145144template <class _To, template <class...> class _Op, class... _Args>
146145using is_detected_convertible = is_convertible<detected_t<_Op, _Args...>, _To>;
147146template <class _To, template <class...> class _Op, class... _Args>
148_LIBCPP_CONSTEXPR bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value;
147constexpr bool is_detected_convertible_v = is_detected_convertible<_To, _Op, _Args...>::value;
149148
150149_LIBCPP_END_NAMESPACE_LFTS
151150
lib/libcxx/include/experimental/utility-1
......@@ -30,7 +30,6 @@ inline namespace fundamentals_v1 {
3030
3131 */
3232
33#include <__assert> // all public C++ headers provide the assertion handler
3433#include <experimental/__config>
3534#include <utility>
3635
lib/libcxx/include/ext/hash_map-1
......@@ -201,7 +201,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
201201
202202*/
203203
204#include <__assert> // all public C++ headers provide the assertion handler
205204#include <__config>
206205#include <__hash_table>
207206#include <algorithm>
lib/libcxx/include/ext/hash_set-1
......@@ -192,7 +192,6 @@ template <class Value, class Hash, class Pred, class Alloc>
192192
193193*/
194194
195#include <__assert> // all public C++ headers provide the assertion handler
196195#include <__config>
197196#include <__hash_table>
198197#include <algorithm>
lib/libcxx/include/filesystem+21-17
......@@ -533,24 +533,27 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
533533
534534*/
535535
536#include <__assert> // all public C++ headers provide the assertion handler
537536#include <__config>
538#include <__filesystem/copy_options.h>
539#include <__filesystem/directory_entry.h>
540#include <__filesystem/directory_iterator.h>
541#include <__filesystem/directory_options.h>
542#include <__filesystem/file_status.h>
543#include <__filesystem/file_time_type.h>
544#include <__filesystem/file_type.h>
545#include <__filesystem/filesystem_error.h>
546#include <__filesystem/operations.h>
547#include <__filesystem/path.h>
548#include <__filesystem/path_iterator.h>
549#include <__filesystem/perm_options.h>
550#include <__filesystem/perms.h>
551#include <__filesystem/recursive_directory_iterator.h>
552#include <__filesystem/space_info.h>
553#include <__filesystem/u8path.h>
537
538#if _LIBCPP_STD_VER >= 17
539# include <__filesystem/copy_options.h>
540# include <__filesystem/directory_entry.h>
541# include <__filesystem/directory_iterator.h>
542# include <__filesystem/directory_options.h>
543# include <__filesystem/file_status.h>
544# include <__filesystem/file_time_type.h>
545# include <__filesystem/file_type.h>
546# include <__filesystem/filesystem_error.h>
547# include <__filesystem/operations.h>
548# include <__filesystem/path.h>
549# include <__filesystem/path_iterator.h>
550# include <__filesystem/perm_options.h>
551# include <__filesystem/perms.h>
552# include <__filesystem/recursive_directory_iterator.h>
553# include <__filesystem/space_info.h>
554# include <__filesystem/u8path.h>
555#endif
556
554557#include <version>
555558
556559// standard-mandated includes
......@@ -565,6 +568,7 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
565568#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
566569# include <concepts>
567570# include <cstdlib>
571# include <cstring>
568572# include <iosfwd>
569573# include <new>
570574# include <system_error>
lib/libcxx/include/format+60-28
......@@ -170,7 +170,7 @@ namespace std {
170170 template<class Context> class basic_format_arg;
171171
172172 template<class Visitor, class Context>
173 see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg);
173 see below visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // Deprecated in C++26
174174
175175 // [format.arg.store], class template format-arg-store
176176 template<class Context, class... Args> struct format-arg-store; // exposition only
......@@ -188,38 +188,70 @@ namespace std {
188188
189189*/
190190
191#include <__assert> // all public C++ headers provide the assertion handler
192191#include <__config>
193#include <__format/buffer.h>
194#include <__format/concepts.h>
195#include <__format/container_adaptor.h>
196#include <__format/enable_insertable.h>
197#include <__format/format_arg.h>
198#include <__format/format_arg_store.h>
199#include <__format/format_args.h>
200#include <__format/format_context.h>
201#include <__format/format_error.h>
202#include <__format/format_functions.h>
203#include <__format/format_fwd.h>
204#include <__format/format_parse_context.h>
205#include <__format/format_string.h>
206#include <__format/format_to_n_result.h>
207#include <__format/formatter.h>
208#include <__format/formatter_bool.h>
209#include <__format/formatter_char.h>
210#include <__format/formatter_floating_point.h>
211#include <__format/formatter_integer.h>
212#include <__format/formatter_pointer.h>
213#include <__format/formatter_string.h>
214#include <__format/formatter_tuple.h>
215#include <__format/parser_std_format_spec.h>
216#include <__format/range_default_formatter.h>
217#include <__format/range_formatter.h>
218#include <__format/unicode.h>
192
193#if _LIBCPP_STD_VER >= 20
194# include <__format/buffer.h>
195# include <__format/concepts.h>
196# include <__format/container_adaptor.h>
197# include <__format/enable_insertable.h>
198# include <__format/escaped_output_table.h>
199# include <__format/extended_grapheme_cluster_table.h>
200# include <__format/format_arg.h>
201# include <__format/format_arg_store.h>
202# include <__format/format_args.h>
203# include <__format/format_context.h>
204# include <__format/format_error.h>
205# include <__format/format_functions.h>
206# include <__format/format_parse_context.h>
207# include <__format/format_string.h>
208# include <__format/format_to_n_result.h>
209# include <__format/formatter.h>
210# include <__format/formatter_bool.h>
211# include <__format/formatter_char.h>
212# include <__format/formatter_floating_point.h>
213# include <__format/formatter_integer.h>
214# include <__format/formatter_pointer.h>
215# include <__format/formatter_string.h>
216# include <__format/formatter_tuple.h>
217# include <__format/parser_std_format_spec.h>
218# include <__format/range_default_formatter.h>
219# include <__format/range_formatter.h>
220# include <__format/unicode.h>
221# include <__fwd/format.h>
222#endif
223
219224#include <version>
220225
221226#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
222227# pragma GCC system_header
223228#endif
224229
230#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
231# include <array>
232# include <cctype>
233# include <cerrno>
234# include <clocale>
235# include <cmath>
236# include <cstddef>
237# include <cstdint>
238# include <cstdlib>
239# include <cstring>
240# include <cwchar>
241# include <initializer_list>
242# include <limits>
243# include <new>
244# include <optional>
245# include <stdexcept>
246# include <string>
247# include <string_view>
248# include <tuple>
249#endif
250
251#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
252# include <locale>
253# include <queue>
254# include <stack>
255#endif
256
225257#endif // _LIBCPP_FORMAT
lib/libcxx/include/forward_list+34-53
......@@ -199,8 +199,6 @@ template <class T, class Allocator, class Predicate>
199199#include <__algorithm/lexicographical_compare.h>
200200#include <__algorithm/lexicographical_compare_three_way.h>
201201#include <__algorithm/min.h>
202#include <__assert> // all public C++ headers provide the assertion handler
203#include <__availability>
204202#include <__config>
205203#include <__iterator/distance.h>
206204#include <__iterator/iterator_traits.h>
......@@ -222,11 +220,11 @@ template <class T, class Allocator, class Predicate>
222220#include <__type_traits/conditional.h>
223221#include <__type_traits/is_allocator.h>
224222#include <__type_traits/is_const.h>
225#include <__type_traits/is_nothrow_default_constructible.h>
226#include <__type_traits/is_nothrow_move_assignable.h>
227#include <__type_traits/is_nothrow_move_constructible.h>
223#include <__type_traits/is_nothrow_assignable.h>
224#include <__type_traits/is_nothrow_constructible.h>
228225#include <__type_traits/is_pointer.h>
229226#include <__type_traits/is_same.h>
227#include <__type_traits/is_swappable.h>
230228#include <__type_traits/type_identity.h>
231229#include <__utility/forward.h>
232230#include <__utility/move.h>
......@@ -410,7 +408,7 @@ public:
410408
411409template <class _NodeConstPtr>
412410class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {
413 static_assert((!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value), "");
411 static_assert(!is_const<typename pointer_traits<_NodeConstPtr>::element_type>::value, "");
414412 typedef _NodeConstPtr _NodePtr;
415413
416414 typedef __forward_node_traits<_NodePtr> __traits;
......@@ -513,19 +511,17 @@ protected:
513511 : __before_begin_(__begin_node(), __node_allocator(__a)) {}
514512 _LIBCPP_HIDE_FROM_ABI explicit __forward_list_base(const __node_allocator& __a)
515513 : __before_begin_(__begin_node(), __a) {}
516#ifndef _LIBCPP_CXX03_LANG
517514
518515public:
519 _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x)
520 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
516#ifndef _LIBCPP_CXX03_LANG
517 _LIBCPP_HIDE_FROM_ABI
518 __forward_list_base(__forward_list_base&& __x) noexcept(is_nothrow_move_constructible<__node_allocator>::value);
521519 _LIBCPP_HIDE_FROM_ABI __forward_list_base(__forward_list_base&& __x, const allocator_type& __a);
522520#endif // _LIBCPP_CXX03_LANG
523521
524private:
525 __forward_list_base(const __forward_list_base&);
526 __forward_list_base& operator=(const __forward_list_base&);
522 __forward_list_base(const __forward_list_base&) = delete;
523 __forward_list_base& operator=(const __forward_list_base&) = delete;
527524
528public:
529525 _LIBCPP_HIDE_FROM_ABI ~__forward_list_base();
530526
531527protected:
......@@ -556,7 +552,6 @@ protected:
556552 return __guard.__release_ptr();
557553 }
558554
559 template <class... _Args>
560555 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
561556 // For the same reason as above, we use the allocator's destroy() method for the value_type,
562557 // but not for the node itself.
......@@ -571,7 +566,7 @@ public:
571566#if _LIBCPP_STD_VER >= 14
572567 _NOEXCEPT;
573568#else
574 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value);
569 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>);
575570#endif
576571
577572protected:
......@@ -595,8 +590,8 @@ private:
595590#ifndef _LIBCPP_CXX03_LANG
596591
597592template <class _Tp, class _Alloc>
598inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x)
599 _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
593inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x) noexcept(
594 is_nothrow_move_constructible<__node_allocator>::value)
600595 : __before_begin_(std::move(__x.__before_begin_)) {
601596 __x.__before_begin()->__next_ = nullptr;
602597}
......@@ -622,7 +617,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
622617#if _LIBCPP_STD_VER >= 14
623618 _NOEXCEPT
624619#else
625 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value)
620 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
626621#endif
627622{
628623 std::__swap_allocator(
......@@ -654,16 +649,13 @@ public:
654649 typedef _Tp value_type;
655650 typedef _Alloc allocator_type;
656651
652 static_assert(__check_valid_allocator<allocator_type>::value, "");
653
657654 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
658655 "Allocator::value_type must be same type as value_type");
659656
660 static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
661 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
662 "original allocator");
663
664 static_assert((!is_same<allocator_type, __node_allocator>::value),
665 "internal allocator type must differ from user-specified "
666 "type; otherwise overload resolution breaks");
657 static_assert(!is_same<allocator_type, __node_allocator>::value,
658 "internal allocator type must differ from user-specified type; otherwise overload resolution breaks");
667659
668660 typedef value_type& reference;
669661 typedef const value_type& const_reference;
......@@ -689,22 +681,16 @@ public:
689681#endif
690682 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v);
691683
692 template <class = __enable_if_t<__is_allocator<_Alloc>::value> >
684 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
693685 _LIBCPP_HIDE_FROM_ABI forward_list(size_type __n, const value_type& __v, const allocator_type& __a) : base(__a) {
694686 insert_after(cbefore_begin(), __n, __v);
695687 }
696688
697 template <class _InputIterator>
698 _LIBCPP_HIDE_FROM_ABI
699 forward_list(_InputIterator __f,
700 _InputIterator __l,
701 __enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr);
702 template <class _InputIterator>
703 _LIBCPP_HIDE_FROM_ABI
704 forward_list(_InputIterator __f,
705 _InputIterator __l,
706 const allocator_type& __a,
707 __enable_if_t<__has_input_iterator_category<_InputIterator>::value>* = nullptr);
689 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
690 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l);
691
692 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
693 _LIBCPP_HIDE_FROM_ABI forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a);
708694
709695#if _LIBCPP_STD_VER >= 23
710696 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -720,15 +706,16 @@ public:
720706 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(const forward_list& __x);
721707
722708#ifndef _LIBCPP_CXX03_LANG
723 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) _NOEXCEPT_(is_nothrow_move_constructible<base>::value)
709 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x) noexcept(is_nothrow_move_constructible<base>::value)
724710 : base(std::move(__x)) {}
725711 _LIBCPP_HIDE_FROM_ABI forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a);
726712
727713 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il);
728714 _LIBCPP_HIDE_FROM_ABI forward_list(initializer_list<value_type> __il, const allocator_type& __a);
729715
730 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) _NOEXCEPT_(
731 __node_traits::propagate_on_container_move_assignment::value&& is_nothrow_move_assignable<allocator_type>::value);
716 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(forward_list&& __x) noexcept(
717 __node_traits::propagate_on_container_move_assignment::value &&
718 is_nothrow_move_assignable<allocator_type>::value);
732719
733720 _LIBCPP_HIDE_FROM_ABI forward_list& operator=(initializer_list<value_type> __il);
734721
......@@ -769,7 +756,7 @@ public:
769756 return const_iterator(base::__before_begin());
770757 }
771758
772 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
759 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
773760 return base::__before_begin()->__next_ == nullptr;
774761 }
775762 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
......@@ -831,7 +818,7 @@ public:
831818#if _LIBCPP_STD_VER >= 14
832819 _NOEXCEPT
833820#else
834 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value)
821 _NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
835822#endif
836823 {
837824 base::swap(__x);
......@@ -938,20 +925,14 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) {
938925}
939926
940927template <class _Tp, class _Alloc>
941template <class _InputIterator>
942forward_list<_Tp, _Alloc>::forward_list(
943 _InputIterator __f, _InputIterator __l, __enable_if_t<__has_input_iterator_category<_InputIterator>::value>*) {
928template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
929forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l) {
944930 insert_after(cbefore_begin(), __f, __l);
945931}
946932
947933template <class _Tp, class _Alloc>
948template <class _InputIterator>
949forward_list<_Tp, _Alloc>::forward_list(
950 _InputIterator __f,
951 _InputIterator __l,
952 const allocator_type& __a,
953 __enable_if_t<__has_input_iterator_category<_InputIterator>::value>*)
954 : base(__a) {
934template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> >
935forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : base(__a) {
955936 insert_after(cbefore_begin(), __f, __l);
956937}
957938
......@@ -1538,7 +1519,7 @@ template <class _Tp, class _Allocator>
15381519_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
15391520operator<=>(const forward_list<_Tp, _Allocator>& __x, const forward_list<_Tp, _Allocator>& __y) {
15401521 return std::lexicographical_compare_three_way(
1541 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
1522 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
15421523}
15431524
15441525#endif // #if _LIBCPP_STD_VER <= 17
lib/libcxx/include/fstream+173-135
......@@ -78,8 +78,8 @@ public:
7878 basic_ifstream();
7979 explicit basic_ifstream(const char* s, ios_base::openmode mode = ios_base::in);
8080 explicit basic_ifstream(const string& s, ios_base::openmode mode = ios_base::in);
81 explicit basic_ifstream(const filesystem::path& p,
82 ios_base::openmode mode = ios_base::in); // C++17
81 template<class T>
82 explicit basic_ifstream(const T& s, ios_base::openmode mode = ios_base::in); // Since C++17
8383 basic_ifstream(basic_ifstream&& rhs);
8484
8585 basic_ifstream& operator=(basic_ifstream&& rhs);
......@@ -117,8 +117,8 @@ public:
117117 basic_ofstream();
118118 explicit basic_ofstream(const char* s, ios_base::openmode mode = ios_base::out);
119119 explicit basic_ofstream(const string& s, ios_base::openmode mode = ios_base::out);
120 explicit basic_ofstream(const filesystem::path& p,
121 ios_base::openmode mode = ios_base::out); // C++17
120 template<class T>
121 explicit basic_ofstream(const T& s, ios_base::openmode mode = ios_base::out); // Since C++17
122122 basic_ofstream(basic_ofstream&& rhs);
123123
124124 basic_ofstream& operator=(basic_ofstream&& rhs);
......@@ -158,8 +158,8 @@ public:
158158 basic_fstream();
159159 explicit basic_fstream(const char* s, ios_base::openmode mode = ios_base::in|ios_base::out);
160160 explicit basic_fstream(const string& s, ios_base::openmode mode = ios_base::in|ios_base::out);
161 explicit basic_fstream(const filesystem::path& p,
162 ios_base::openmode mode = ios_base::in|ios_base::out); C++17
161 template<class T>
162 explicit basic_fstream(const T& s, ios_base::openmode mode = ios_base::in | ios_base::out); // Since C++17
163163 basic_fstream(basic_fstream&& rhs);
164164
165165 basic_fstream& operator=(basic_fstream&& rhs);
......@@ -187,11 +187,12 @@ typedef basic_fstream<wchar_t> wfstream;
187187*/
188188
189189#include <__algorithm/max.h>
190#include <__assert> // all public C++ headers provide the assertion handler
191#include <__availability>
190#include <__assert>
192191#include <__config>
193192#include <__fwd/fstream.h>
194193#include <__locale>
194#include <__type_traits/enable_if.h>
195#include <__type_traits/is_same.h>
195196#include <__utility/move.h>
196197#include <__utility/swap.h>
197198#include <__utility/unreachable.h>
......@@ -279,6 +280,9 @@ public:
279280# endif // _LIBCPP_STD_VER >= 26
280281
281282 _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT;
283# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
284 _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT;
285# endif
282286
283287protected:
284288 // 27.9.1.5 Overridden virtual functions:
......@@ -305,6 +309,43 @@ private:
305309 state_type __st_;
306310 state_type __st_last_;
307311 ios_base::openmode __om_;
312 // There have been no file operations yet, which allows setting unbuffered
313 // I/O mode.
314 static const ios_base::openmode __no_io_operations = ios_base::trunc;
315 // Unbuffered I/O mode has been requested.
316 static const ios_base::openmode __use_unbuffered_io = ios_base::ate;
317 // Used to track the currently used mode and track whether the output should
318 // be unbuffered.
319 // [filebuf.virtuals]/12
320 // If setbuf(0, 0) is called on a stream before any I/O has occurred on
321 // that stream, the stream becomes unbuffered. Otherwise the results are
322 // implementation-defined.
323 // This allows calling setbuf(0, 0)
324 // - before opening a file,
325 // - after opening a file, before
326 // - a read
327 // - a write
328 // - a seek.
329 // Note that opening a file with ios_base::ate does a seek operation.
330 // Normally underflow, overflow, and sync change this flag to ios_base::in,
331 // ios_base_out, or 0.
332 //
333 // The ios_base::trunc and ios_base::ate flags are not used in __cm_. They
334 // are used to track the state of the unbuffered request. For readability
335 // they have the aliases __no_io_operations and __use_unbuffered_io
336 // respectively.
337 //
338 // The __no_io_operations and __use_unbuffered_io flags are used in the
339 // following way:
340 // - __no_io_operations is set upon construction to indicate the unbuffered
341 // state can be set.
342 // - When requesting unbuffered output:
343 // - If the file is open it sets the mode.
344 // - Else places a request by adding the __use_unbuffered_io flag.
345 // - When a file is opened it checks whether both __no_io_operations and
346 // __use_unbuffered_io are set. If so switches to unbuffered mode.
347 // - All file I/O operations change the mode effectively clearing the
348 // __no_io_operations and __use_unbuffered_io flags.
308349 ios_base::openmode __cm_;
309350 bool __owns_eb_;
310351 bool __owns_ib_;
......@@ -314,6 +355,46 @@ private:
314355 void __write_mode();
315356
316357 _LIBCPP_EXPORTED_FROM_ABI friend FILE* __get_ostream_file(ostream&);
358
359 // There are multiple (__)open function, they use different C-API open
360 // function. After that call these functions behave the same. This function
361 // does that part and determines the final return value.
362 _LIBCPP_HIDE_FROM_ABI basic_filebuf* __do_open(FILE* __file, ios_base::openmode __mode) {
363 __file_ = __file;
364 if (!__file_)
365 return nullptr;
366
367 __om_ = __mode;
368 if (__cm_ == (__no_io_operations | __use_unbuffered_io)) {
369 std::setbuf(__file_, nullptr);
370 __cm_ = 0;
371 }
372
373 if (__mode & ios_base::ate) {
374 __cm_ = 0;
375 if (fseek(__file_, 0, SEEK_END)) {
376 fclose(__file_);
377 __file_ = nullptr;
378 return nullptr;
379 }
380 }
381
382 return this;
383 }
384
385 // If the file is already open, switch to unbuffered mode. Otherwise, record
386 // the request to use unbuffered mode so that we use that mode when we
387 // eventually open the file.
388 _LIBCPP_HIDE_FROM_ABI void __request_unbuffered_mode(char_type* __s, streamsize __n) {
389 if (__cm_ == __no_io_operations && __s == nullptr && __n == 0) {
390 if (__file_) {
391 std::setbuf(__file_, nullptr);
392 __cm_ = 0;
393 } else {
394 __cm_ = __no_io_operations | __use_unbuffered_io;
395 }
396 }
397 }
317398};
318399
319400template <class _CharT, class _Traits>
......@@ -329,7 +410,7 @@ basic_filebuf<_CharT, _Traits>::basic_filebuf()
329410 __st_(),
330411 __st_last_(),
331412 __om_(0),
332 __cm_(0),
413 __cm_(__no_io_operations),
333414 __owns_eb_(false),
334415 __owns_ib_(false),
335416 __always_noconv_(false) {
......@@ -548,50 +629,79 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _
548629 __libcpp_unreachable();
549630}
550631
632# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
551633template <class _CharT, class _Traits>
552basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) {
553 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
554 if (__file_ == nullptr) {
555 if (const char* __mdstr = __make_mdstring(__mode)) {
556 __rt = this;
557 __file_ = fopen(__s, __mdstr);
558 if (__file_) {
559 __om_ = __mode;
560 if (__mode & ios_base::ate) {
561 if (fseek(__file_, 0, SEEK_END)) {
562 fclose(__file_);
563 __file_ = nullptr;
564 __rt = nullptr;
565 }
566 }
567 } else
568 __rt = nullptr;
569 }
634const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT {
635 switch (__mode & ~ios_base::ate) {
636 case ios_base::out:
637 case ios_base::out | ios_base::trunc:
638 return L"w";
639 case ios_base::out | ios_base::app:
640 case ios_base::app:
641 return L"a";
642 case ios_base::in:
643 return L"r";
644 case ios_base::in | ios_base::out:
645 return L"r+";
646 case ios_base::in | ios_base::out | ios_base::trunc:
647 return L"w+";
648 case ios_base::in | ios_base::out | ios_base::app:
649 case ios_base::in | ios_base::app:
650 return L"a+";
651 case ios_base::out | ios_base::binary:
652 case ios_base::out | ios_base::trunc | ios_base::binary:
653 return L"wb";
654 case ios_base::out | ios_base::app | ios_base::binary:
655 case ios_base::app | ios_base::binary:
656 return L"ab";
657 case ios_base::in | ios_base::binary:
658 return L"rb";
659 case ios_base::in | ios_base::out | ios_base::binary:
660 return L"r+b";
661 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
662 return L"w+b";
663 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
664 case ios_base::in | ios_base::app | ios_base::binary:
665 return L"a+b";
666# if _LIBCPP_STD_VER >= 23
667 case ios_base::out | ios_base::noreplace:
668 case ios_base::out | ios_base::trunc | ios_base::noreplace:
669 return L"wx";
670 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::noreplace:
671 return L"w+x";
672 case ios_base::out | ios_base::binary | ios_base::noreplace:
673 case ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
674 return L"wbx";
675 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
676 return L"w+bx";
677# endif // _LIBCPP_STD_VER >= 23
678 default:
679 return nullptr;
570680 }
571 return __rt;
681 __libcpp_unreachable();
682}
683# endif
684
685template <class _CharT, class _Traits>
686basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode) {
687 if (__file_)
688 return nullptr;
689 const char* __mdstr = __make_mdstring(__mode);
690 if (!__mdstr)
691 return nullptr;
692
693 return __do_open(fopen(__s, __mdstr), __mode);
572694}
573695
574696template <class _CharT, class _Traits>
575697inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
576 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
577 if (__file_ == nullptr) {
578 if (const char* __mdstr = __make_mdstring(__mode)) {
579 __rt = this;
580 __file_ = fdopen(__fd, __mdstr);
581 if (__file_) {
582 __om_ = __mode;
583 if (__mode & ios_base::ate) {
584 if (fseek(__file_, 0, SEEK_END)) {
585 fclose(__file_);
586 __file_ = nullptr;
587 __rt = nullptr;
588 }
589 }
590 } else
591 __rt = nullptr;
592 }
593 }
594 return __rt;
698 if (__file_)
699 return nullptr;
700 const char* __mdstr = __make_mdstring(__mode);
701 if (!__mdstr)
702 return nullptr;
703
704 return __do_open(fdopen(__fd, __mdstr), __mode);
595705}
596706
597707# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
......@@ -599,89 +709,13 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in
599709// and long mode strings.
600710template <class _CharT, class _Traits>
601711basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) {
602 basic_filebuf<_CharT, _Traits>* __rt = nullptr;
603 if (__file_ == nullptr) {
604 __rt = this;
605 const wchar_t* __mdstr;
606 switch (__mode & ~ios_base::ate) {
607 case ios_base::out:
608 case ios_base::out | ios_base::trunc:
609 __mdstr = L"w";
610 break;
611 case ios_base::out | ios_base::app:
612 case ios_base::app:
613 __mdstr = L"a";
614 break;
615 case ios_base::in:
616 __mdstr = L"r";
617 break;
618 case ios_base::in | ios_base::out:
619 __mdstr = L"r+";
620 break;
621 case ios_base::in | ios_base::out | ios_base::trunc:
622 __mdstr = L"w+";
623 break;
624 case ios_base::in | ios_base::out | ios_base::app:
625 case ios_base::in | ios_base::app:
626 __mdstr = L"a+";
627 break;
628 case ios_base::out | ios_base::binary:
629 case ios_base::out | ios_base::trunc | ios_base::binary:
630 __mdstr = L"wb";
631 break;
632 case ios_base::out | ios_base::app | ios_base::binary:
633 case ios_base::app | ios_base::binary:
634 __mdstr = L"ab";
635 break;
636 case ios_base::in | ios_base::binary:
637 __mdstr = L"rb";
638 break;
639 case ios_base::in | ios_base::out | ios_base::binary:
640 __mdstr = L"r+b";
641 break;
642 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary:
643 __mdstr = L"w+b";
644 break;
645 case ios_base::in | ios_base::out | ios_base::app | ios_base::binary:
646 case ios_base::in | ios_base::app | ios_base::binary:
647 __mdstr = L"a+b";
648 break;
649# if _LIBCPP_STD_VER >= 23
650 case ios_base::out | ios_base::noreplace:
651 case ios_base::out | ios_base::trunc | ios_base::noreplace:
652 __mdstr = L"wx";
653 break;
654 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::noreplace:
655 __mdstr = L"w+x";
656 break;
657 case ios_base::out | ios_base::binary | ios_base::noreplace:
658 case ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
659 __mdstr = L"wbx";
660 break;
661 case ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary | ios_base::noreplace:
662 __mdstr = L"w+bx";
663 break;
664# endif // _LIBCPP_STD_VER >= 23
665 default:
666 __rt = nullptr;
667 break;
668 }
669 if (__rt) {
670 __file_ = _wfopen(__s, __mdstr);
671 if (__file_) {
672 __om_ = __mode;
673 if (__mode & ios_base::ate) {
674 if (fseek(__file_, 0, SEEK_END)) {
675 fclose(__file_);
676 __file_ = nullptr;
677 __rt = nullptr;
678 }
679 }
680 } else
681 __rt = nullptr;
682 }
683 }
684 return __rt;
712 if (__file_)
713 return nullptr;
714 const wchar_t* __mdstr = __make_mdwstring(__mode);
715 if (!__mdstr)
716 return nullptr;
717
718 return __do_open(_wfopen(__s, __mdstr), __mode);
685719}
686720# endif
687721
......@@ -834,6 +868,7 @@ template <class _CharT, class _Traits>
834868basic_streambuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n) {
835869 this->setg(nullptr, nullptr, nullptr);
836870 this->setp(nullptr, nullptr);
871 __request_unbuffered_mode(__s, __n);
837872 if (__owns_eb_)
838873 delete[] __extbuf_;
839874 if (__owns_ib_)
......@@ -1067,8 +1102,9 @@ public:
10671102# endif
10681103 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
10691104# if _LIBCPP_STD_VER >= 17
1070 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(
1071 const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
1105 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
1106 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
1107 _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const _Tp& __p, ios_base::openmode __mode = ios_base::in)
10721108 : basic_ifstream(__p.c_str(), __mode) {}
10731109# endif // _LIBCPP_STD_VER >= 17
10741110 _LIBCPP_HIDE_FROM_ABI basic_ifstream(basic_ifstream&& __rhs);
......@@ -1221,8 +1257,9 @@ public:
12211257 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
12221258
12231259# if _LIBCPP_STD_VER >= 17
1224 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(
1225 const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
1260 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
1261 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY
1262 _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const _Tp& __p, ios_base::openmode __mode = ios_base::out)
12261263 : basic_ofstream(__p.c_str(), __mode) {}
12271264# endif // _LIBCPP_STD_VER >= 17
12281265
......@@ -1380,8 +1417,9 @@ public:
13801417 ios_base::openmode __mode = ios_base::in | ios_base::out);
13811418
13821419# if _LIBCPP_STD_VER >= 17
1420 template <class _Tp, class = enable_if_t<is_same_v<_Tp, filesystem::path>>>
13831421 _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(
1384 const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
1422 const _Tp& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
13851423 : basic_fstream(__p.c_str(), __mode) {}
13861424# endif // _LIBCPP_STD_VER >= 17
13871425
lib/libcxx/include/functional+48-15
......@@ -77,6 +77,15 @@ template <class T> struct unwrap_ref_decay : unwrap_reference<decay_t<T>> { };
7777template <class T> using unwrap_reference_t = typename unwrap_reference<T>::type; // since C++20
7878template <class T> using unwrap_ref_decay_t = typename unwrap_ref_decay<T>::type; // since C++20
7979
80// [refwrap.comparisons], comparisons
81friend constexpr bool operator==(reference_wrapper, reference_wrapper); // Since C++26
82friend constexpr bool operator==(reference_wrapper, const T&); // Since C++26
83friend constexpr bool operator==(reference_wrapper, reference_wrapper<const T>); // Since C++26
84
85friend constexpr auto operator<=>(reference_wrapper, reference_wrapper); // Since C++26
86friend constexpr auto operator<=>(reference_wrapper, const T&); // Since C++26
87friend constexpr auto operator<=>(reference_wrapper, reference_wrapper<const T>); // Since C++26
88
8089template <class T> // <class T=void> in C++14
8190struct plus {
8291 T operator()(const T& x, const T& y) const;
......@@ -207,6 +216,12 @@ binary_negate<Predicate> not2(const Predicate& pred);
207216template <class F>
208217constexpr unspecified not_fn(F&& f); // C++17, constexpr in C++20
209218
219// [func.bind.partial], function templates bind_front and bind_back
220template<class F, class... Args>
221 constexpr unspecified bind_front(F&&, Args&&...); // C++20
222template<class F, class... Args>
223 constexpr unspecified bind_back(F&&, Args&&...); // C++23
224
210225template<class T> struct is_bind_expression;
211226template<class T> struct is_placeholder;
212227
......@@ -512,42 +527,60 @@ POLICY: For non-variadic implementations, the number of arguments is limited
512527
513528*/
514529
515#include <__algorithm/search.h>
516#include <__assert> // all public C++ headers provide the assertion handler
517#include <__compare/compare_three_way.h>
518530#include <__config>
531
519532#include <__functional/binary_function.h>
520533#include <__functional/binary_negate.h>
521534#include <__functional/bind.h>
522#include <__functional/bind_back.h>
523#include <__functional/bind_front.h>
524535#include <__functional/binder1st.h>
525536#include <__functional/binder2nd.h>
526#include <__functional/boyer_moore_searcher.h>
527#include <__functional/compose.h>
528#include <__functional/default_searcher.h>
529#include <__functional/function.h>
530537#include <__functional/hash.h>
531#include <__functional/identity.h>
532#include <__functional/invoke.h>
533538#include <__functional/mem_fn.h> // TODO: deprecate
534539#include <__functional/mem_fun_ref.h>
535#include <__functional/not_fn.h>
536540#include <__functional/operations.h>
537541#include <__functional/pointer_to_binary_function.h>
538542#include <__functional/pointer_to_unary_function.h>
539#include <__functional/ranges_operations.h>
540543#include <__functional/reference_wrapper.h>
541544#include <__functional/unary_function.h>
542545#include <__functional/unary_negate.h>
543#include <__type_traits/unwrap_ref.h>
544#include <__utility/forward.h>
546
547#ifndef _LIBCPP_CXX03_LANG
548# include <__functional/function.h>
549#endif
550
551#if _LIBCPP_STD_VER >= 17
552# include <__functional/boyer_moore_searcher.h>
553# include <__functional/default_searcher.h>
554# include <__functional/invoke.h>
555# include <__functional/not_fn.h>
556#endif
557
558#if _LIBCPP_STD_VER >= 20
559# include <__functional/bind_back.h>
560# include <__functional/bind_front.h>
561# include <__functional/identity.h>
562# include <__functional/ranges_operations.h>
563# include <__type_traits/unwrap_ref.h>
564#endif
565
545566#include <version>
546567
547568#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
548569# pragma GCC system_header
549570#endif
550571
572#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && defined(_LIBCPP_CXX03_LANG)
573# include <limits>
574# include <new>
575#endif
576
577#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
578# include <array>
579# include <initializer_list>
580# include <unordered_map>
581# include <vector>
582#endif
583
551584#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
552585# include <atomic>
553586# include <concepts>
lib/libcxx/include/future+101-103
......@@ -364,45 +364,42 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
364364
365365#include <__config>
366366
367#ifdef _LIBCPP_HAS_NO_THREADS
368# error "<future> is not supported since libc++ has been configured without support for threads."
369#endif
370
371#include <__assert> // all public C++ headers provide the assertion handler
372#include <__availability>
373#include <__chrono/duration.h>
374#include <__chrono/time_point.h>
375#include <__exception/exception_ptr.h>
376#include <__memory/addressof.h>
377#include <__memory/allocator.h>
378#include <__memory/allocator_arg_t.h>
379#include <__memory/allocator_destructor.h>
380#include <__memory/allocator_traits.h>
381#include <__memory/compressed_pair.h>
382#include <__memory/pointer_traits.h>
383#include <__memory/shared_ptr.h>
384#include <__memory/unique_ptr.h>
385#include <__memory/uses_allocator.h>
386#include <__system_error/error_category.h>
387#include <__system_error/error_code.h>
388#include <__system_error/error_condition.h>
389#include <__type_traits/aligned_storage.h>
390#include <__type_traits/strip_signature.h>
391#include <__utility/auto_cast.h>
392#include <__utility/forward.h>
393#include <__utility/move.h>
394#include <mutex>
395#include <new>
396#include <stdexcept>
397#include <thread>
398#include <version>
399
400#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
401# pragma GCC system_header
402#endif
367#if !defined(_LIBCPP_HAS_NO_THREADS)
368
369# include <__assert>
370# include <__chrono/duration.h>
371# include <__chrono/time_point.h>
372# include <__exception/exception_ptr.h>
373# include <__memory/addressof.h>
374# include <__memory/allocator.h>
375# include <__memory/allocator_arg_t.h>
376# include <__memory/allocator_destructor.h>
377# include <__memory/allocator_traits.h>
378# include <__memory/compressed_pair.h>
379# include <__memory/pointer_traits.h>
380# include <__memory/shared_ptr.h>
381# include <__memory/unique_ptr.h>
382# include <__memory/uses_allocator.h>
383# include <__system_error/error_category.h>
384# include <__system_error/error_code.h>
385# include <__system_error/error_condition.h>
386# include <__type_traits/aligned_storage.h>
387# include <__type_traits/strip_signature.h>
388# include <__utility/auto_cast.h>
389# include <__utility/forward.h>
390# include <__utility/move.h>
391# include <mutex>
392# include <new>
393# include <stdexcept>
394# include <thread>
395# include <version>
396
397# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
398# pragma GCC system_header
399# endif
403400
404401_LIBCPP_PUSH_MACROS
405#include <__undef_macros>
402# include <__undef_macros>
406403
407404_LIBCPP_BEGIN_NAMESPACE_STD
408405
......@@ -414,32 +411,32 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc)
414411template <>
415412struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc> : public true_type {};
416413
417#ifdef _LIBCPP_CXX03_LANG
414# ifdef _LIBCPP_CXX03_LANG
418415template <>
419416struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<future_errc::__lx> : public true_type {};
420#endif
417# endif
421418
422419// enum class launch
423420_LIBCPP_DECLARE_STRONG_ENUM(launch){async = 1, deferred = 2, any = async | deferred};
424421_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
425422
426#ifndef _LIBCPP_CXX03_LANG
423# ifndef _LIBCPP_CXX03_LANG
427424
428425typedef underlying_type<launch>::type __launch_underlying_type;
429426
430inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator&(launch __x, launch __y) {
427inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator&(launch __x, launch __y) {
431428 return static_cast<launch>(static_cast<__launch_underlying_type>(__x) & static_cast<__launch_underlying_type>(__y));
432429}
433430
434inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator|(launch __x, launch __y) {
431inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator|(launch __x, launch __y) {
435432 return static_cast<launch>(static_cast<__launch_underlying_type>(__x) | static_cast<__launch_underlying_type>(__y));
436433}
437434
438inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator^(launch __x, launch __y) {
435inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator^(launch __x, launch __y) {
439436 return static_cast<launch>(static_cast<__launch_underlying_type>(__x) ^ static_cast<__launch_underlying_type>(__y));
440437}
441438
442inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator~(launch __x) {
439inline _LIBCPP_HIDE_FROM_ABI constexpr launch operator~(launch __x) {
443440 return static_cast<launch>(~static_cast<__launch_underlying_type>(__x) & 3);
444441}
445442
......@@ -458,7 +455,7 @@ inline _LIBCPP_HIDE_FROM_ABI launch& operator^=(launch& __x, launch __y) {
458455 return __x;
459456}
460457
461#endif // !_LIBCPP_CXX03_LANG
458# endif // !_LIBCPP_CXX03_LANG
462459
463460// enum class future_status
464461_LIBCPP_DECLARE_STRONG_ENUM(future_status){ready, timeout, deferred};
......@@ -485,9 +482,9 @@ class _LIBCPP_EXPORTED_FROM_ABI future_error : public logic_error {
485482 friend class promise;
486483
487484public:
488#if _LIBCPP_STD_VER >= 17
485# if _LIBCPP_STD_VER >= 17
489486 _LIBCPP_HIDE_FROM_ABI explicit future_error(future_errc __ec) : future_error(std::make_error_code(__ec)) {}
490#endif
487# endif
491488
492489 _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
493490
......@@ -497,12 +494,12 @@ public:
497494
498495// Declared above std::future_error
499496void __throw_future_error(future_errc __ev) {
500#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
497# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
501498 throw future_error(make_error_code(__ev));
502#else
499# else
503500 (void)__ev;
504501 _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode");
505#endif
502# endif
506503}
507504
508505class _LIBCPP_EXPORTED_FROM_ABI __assoc_sub_state : public __shared_count {
......@@ -776,15 +773,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f
776773
777774template <class _Rp, class _Fp>
778775void __deferred_assoc_state<_Rp, _Fp>::__execute() {
779#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
776# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
780777 try {
781#endif // _LIBCPP_HAS_NO_EXCEPTIONS
778# endif // _LIBCPP_HAS_NO_EXCEPTIONS
782779 this->set_value(__func_());
783#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
780# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
784781 } catch (...) {
785782 this->set_exception(current_exception());
786783 }
787#endif // _LIBCPP_HAS_NO_EXCEPTIONS
784# endif // _LIBCPP_HAS_NO_EXCEPTIONS
788785}
789786
790787template <class _Fp>
......@@ -806,16 +803,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __
806803
807804template <class _Fp>
808805void __deferred_assoc_state<void, _Fp>::__execute() {
809#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
806# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
810807 try {
811#endif // _LIBCPP_HAS_NO_EXCEPTIONS
808# endif // _LIBCPP_HAS_NO_EXCEPTIONS
812809 __func_();
813810 this->set_value();
814#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
811# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
815812 } catch (...) {
816813 this->set_exception(current_exception());
817814 }
818#endif // _LIBCPP_HAS_NO_EXCEPTIONS
815# endif // _LIBCPP_HAS_NO_EXCEPTIONS
819816}
820817
821818template <class _Rp, class _Fp>
......@@ -837,15 +834,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s
837834
838835template <class _Rp, class _Fp>
839836void __async_assoc_state<_Rp, _Fp>::__execute() {
840#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
837# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
841838 try {
842#endif // _LIBCPP_HAS_NO_EXCEPTIONS
839# endif // _LIBCPP_HAS_NO_EXCEPTIONS
843840 this->set_value(__func_());
844#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
841# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
845842 } catch (...) {
846843 this->set_exception(current_exception());
847844 }
848#endif // _LIBCPP_HAS_NO_EXCEPTIONS
845# endif // _LIBCPP_HAS_NO_EXCEPTIONS
849846}
850847
851848template <class _Rp, class _Fp>
......@@ -873,16 +870,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(
873870
874871template <class _Fp>
875872void __async_assoc_state<void, _Fp>::__execute() {
876#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
873# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
877874 try {
878#endif // _LIBCPP_HAS_NO_EXCEPTIONS
875# endif // _LIBCPP_HAS_NO_EXCEPTIONS
879876 __func_();
880877 this->set_value();
881#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
878# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
882879 } catch (...) {
883880 this->set_exception(current_exception());
884881 }
885#endif // _LIBCPP_HAS_NO_EXCEPTIONS
882# endif // _LIBCPP_HAS_NO_EXCEPTIONS
886883}
887884
888885template <class _Fp>
......@@ -1385,11 +1382,10 @@ class __packaged_task_base;
13851382
13861383template <class _Rp, class... _ArgTypes>
13871384class __packaged_task_base<_Rp(_ArgTypes...)> {
1388 __packaged_task_base(const __packaged_task_base&);
1389 __packaged_task_base& operator=(const __packaged_task_base&);
1390
13911385public:
13921386 _LIBCPP_HIDE_FROM_ABI __packaged_task_base() {}
1387 __packaged_task_base(const __packaged_task_base&) = delete;
1388 __packaged_task_base& operator=(const __packaged_task_base&) = delete;
13931389 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
13941390 virtual ~__packaged_task_base() {}
13951391 virtual void __move_to(__packaged_task_base*) _NOEXCEPT = 0;
......@@ -1605,9 +1601,11 @@ private:
16051601public:
16061602 // construction and destruction
16071603 _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {}
1608 template <class _Fp, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
1604
1605 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
16091606 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}
1610 template <class _Fp, class _Allocator, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
1607
1608 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
16111609 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
16121610 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}
16131611 // ~packaged_task() = default;
......@@ -1648,15 +1646,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {
16481646 __throw_future_error(future_errc::no_state);
16491647 if (__p_.__state_->__has_value())
16501648 __throw_future_error(future_errc::promise_already_satisfied);
1651#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1649# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
16521650 try {
1653#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1651# endif // _LIBCPP_HAS_NO_EXCEPTIONS
16541652 __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...));
1655#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1653# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
16561654 } catch (...) {
16571655 __p_.set_exception(current_exception());
16581656 }
1659#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1657# endif // _LIBCPP_HAS_NO_EXCEPTIONS
16601658}
16611659
16621660template <class _Rp, class... _ArgTypes>
......@@ -1665,15 +1663,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __
16651663 __throw_future_error(future_errc::no_state);
16661664 if (__p_.__state_->__has_value())
16671665 __throw_future_error(future_errc::promise_already_satisfied);
1668#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1666# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
16691667 try {
1670#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1668# endif // _LIBCPP_HAS_NO_EXCEPTIONS
16711669 __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...));
1672#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1670# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
16731671 } catch (...) {
16741672 __p_.set_exception_at_thread_exit(current_exception());
16751673 }
1676#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1674# endif // _LIBCPP_HAS_NO_EXCEPTIONS
16771675}
16781676
16791677template <class _Rp, class... _ArgTypes>
......@@ -1695,9 +1693,9 @@ private:
16951693public:
16961694 // construction and destruction
16971695 _LIBCPP_HIDE_FROM_ABI packaged_task() _NOEXCEPT : __p_(nullptr) {}
1698 template <class _Fp, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
1696 template <class _Fp, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
16991697 _LIBCPP_HIDE_FROM_ABI explicit packaged_task(_Fp&& __f) : __f_(std::forward<_Fp>(__f)) {}
1700 template <class _Fp, class _Allocator, class = __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value> >
1698 template <class _Fp, class _Allocator, __enable_if_t<!is_same<__remove_cvref_t<_Fp>, packaged_task>::value, int> = 0>
17011699 _LIBCPP_HIDE_FROM_ABI packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
17021700 : __f_(allocator_arg_t(), __a, std::forward<_Fp>(__f)), __p_(allocator_arg_t(), __a) {}
17031701 // ~packaged_task() = default;
......@@ -1732,7 +1730,7 @@ public:
17321730 _LIBCPP_HIDE_FROM_ABI void reset();
17331731};
17341732
1735#if _LIBCPP_STD_VER >= 17
1733# if _LIBCPP_STD_VER >= 17
17361734
17371735template <class _Rp, class... _Args>
17381736packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
......@@ -1740,7 +1738,7 @@ packaged_task(_Rp (*)(_Args...)) -> packaged_task<_Rp(_Args...)>;
17401738template <class _Fp, class _Stripped = typename __strip_signature<decltype(&_Fp::operator())>::type>
17411739packaged_task(_Fp) -> packaged_task<_Stripped>;
17421740
1743#endif
1741# endif
17441742
17451743template <class... _ArgTypes>
17461744void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
......@@ -1748,16 +1746,16 @@ void packaged_task<void(_ArgTypes...)>::operator()(_ArgTypes... __args) {
17481746 __throw_future_error(future_errc::no_state);
17491747 if (__p_.__state_->__has_value())
17501748 __throw_future_error(future_errc::promise_already_satisfied);
1751#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1749# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
17521750 try {
1753#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1751# endif // _LIBCPP_HAS_NO_EXCEPTIONS
17541752 __f_(std::forward<_ArgTypes>(__args)...);
17551753 __p_.set_value();
1756#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1754# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
17571755 } catch (...) {
17581756 __p_.set_exception(current_exception());
17591757 }
1760#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1758# endif // _LIBCPP_HAS_NO_EXCEPTIONS
17611759}
17621760
17631761template <class... _ArgTypes>
......@@ -1766,16 +1764,16 @@ void packaged_task<void(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... _
17661764 __throw_future_error(future_errc::no_state);
17671765 if (__p_.__state_->__has_value())
17681766 __throw_future_error(future_errc::promise_already_satisfied);
1769#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1767# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
17701768 try {
1771#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1769# endif // _LIBCPP_HAS_NO_EXCEPTIONS
17721770 __f_(std::forward<_ArgTypes>(__args)...);
17731771 __p_.set_value_at_thread_exit();
1774#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1772# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
17751773 } catch (...) {
17761774 __p_.set_exception_at_thread_exit(current_exception());
17771775 }
1778#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1776# endif // _LIBCPP_HAS_NO_EXCEPTIONS
17791777}
17801778
17811779template <class... _ArgTypes>
......@@ -1809,7 +1807,7 @@ _LIBCPP_HIDE_FROM_ABI future<_Rp> __make_async_assoc_state(_Fp&& __f) {
18091807 return future<_Rp>(__h.get());
18101808}
18111809
1812#ifndef _LIBCPP_CXX03_LANG
1810# ifndef _LIBCPP_CXX03_LANG
18131811
18141812template <class _Fp, class... _Args>
18151813class _LIBCPP_HIDDEN __async_func {
......@@ -1840,24 +1838,23 @@ inline _LIBCPP_HIDE_FROM_ABI bool __does_policy_contain(launch __policy, launch
18401838}
18411839
18421840template <class _Fp, class... _Args>
1843_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
1844 future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1845 async(launch __policy, _Fp&& __f, _Args&&... __args) {
1841_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1842async(launch __policy, _Fp&& __f, _Args&&... __args) {
18461843 typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF;
18471844 typedef typename _BF::_Rp _Rp;
18481845
1849# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1846# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
18501847 try {
1851# endif
1848# endif
18521849 if (__does_policy_contain(__policy, launch::async))
18531850 return std::__make_async_assoc_state<_Rp>(
18541851 _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));
1855# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1852# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
18561853 } catch (...) {
18571854 if (__policy == launch::async)
18581855 throw;
18591856 }
1860# endif
1857# endif
18611858
18621859 if (__does_policy_contain(__policy, launch::deferred))
18631860 return std::__make_deferred_assoc_state<_Rp>(
......@@ -1866,13 +1863,12 @@ _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI
18661863}
18671864
18681865template <class _Fp, class... _Args>
1869_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI
1870 future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1871 async(_Fp&& __f, _Args&&... __args) {
1866_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI future<typename __invoke_of<__decay_t<_Fp>, __decay_t<_Args>...>::type>
1867async(_Fp&& __f, _Args&&... __args) {
18721868 return std::async(launch::any, std::forward<_Fp>(__f), std::forward<_Args>(__args)...);
18731869}
18741870
1875#endif // C++03
1871# endif // C++03
18761872
18771873// shared_future
18781874
......@@ -2049,6 +2045,8 @@ _LIBCPP_END_NAMESPACE_STD
20492045
20502046_LIBCPP_POP_MACROS
20512047
2048#endif // !defined(_LIBCPP_HAS_NO_THREADS)
2049
20522050#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
20532051# include <chrono>
20542052#endif
lib/libcxx/include/initializer_list-1
......@@ -42,7 +42,6 @@ template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in
4242
4343*/
4444
45#include <__assert> // all public C++ headers provide the assertion handler
4645#include <__config>
4746#include <cstddef>
4847
lib/libcxx/include/iomanip+1-2
......@@ -42,7 +42,6 @@ template <class charT, class traits, class Allocator>
4242
4343*/
4444
45#include <__assert> // all public C++ headers provide the assertion handler
4645#include <__config>
4746#include <istream>
4847#include <version>
......@@ -464,7 +463,7 @@ struct _LIBCPP_HIDDEN __quoted_output_proxy {
464463 _LIBCPP_HIDE_FROM_ABI explicit __quoted_output_proxy(const _CharT* __f, const _CharT* __l, _CharT __d, _CharT __e)
465464 : __first_(__f), __last_(__l), __delim_(__d), __escape_(__e) {}
466465
467 template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value>* = nullptr>
466 template <class _T2, __enable_if_t<_IsSame<_Traits, void>::value || _IsSame<_Traits, _T2>::value, int> = 0>
468467 friend _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _T2>&
469468 operator<<(basic_ostream<_CharT, _T2>& __os, const __quoted_output_proxy& __p) {
470469 return std::__quoted_output(__os, __p.__first_, __p.__last_, __p.__delim_, __p.__escape_);
lib/libcxx/include/ios+94-49
......@@ -213,37 +213,34 @@ storage-class-specifier const error_category& iostream_category() noexcept;
213213
214214#include <__config>
215215
216#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
217# error "The iostreams library is not supported since libc++ has been configured without support for localization."
218#endif
219
220#include <__assert> // all public C++ headers provide the assertion handler
221#include <__fwd/ios.h>
222#include <__ios/fpos.h>
223#include <__locale>
224#include <__system_error/error_category.h>
225#include <__system_error/error_code.h>
226#include <__system_error/error_condition.h>
227#include <__system_error/system_error.h>
228#include <__utility/swap.h>
229#include <__verbose_abort>
230#include <version>
216#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
217
218# include <__fwd/ios.h>
219# include <__ios/fpos.h>
220# include <__locale>
221# include <__system_error/error_category.h>
222# include <__system_error/error_code.h>
223# include <__system_error/error_condition.h>
224# include <__system_error/system_error.h>
225# include <__utility/swap.h>
226# include <__verbose_abort>
227# include <version>
231228
232229// standard-mandated includes
233230
234231// [ios.syn]
235#include <iosfwd>
232# include <iosfwd>
236233
237#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
238# include <__atomic/atomic.h> // for __xindex_
239#endif
234# if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
235# include <__atomic/atomic.h> // for __xindex_
236# endif
240237
241#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
242# pragma GCC system_header
243#endif
238# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
239# pragma GCC system_header
240# endif
244241
245242_LIBCPP_PUSH_MACROS
246#include <__undef_macros>
243# include <__undef_macros>
247244
248245_LIBCPP_BEGIN_NAMESPACE_STD
249246
......@@ -286,20 +283,20 @@ public:
286283 static const openmode in = 0x08;
287284 static const openmode out = 0x10;
288285 static const openmode trunc = 0x20;
289#if _LIBCPP_STD_VER >= 23
286# if _LIBCPP_STD_VER >= 23
290287 static const openmode noreplace = 0x40;
291#endif
288# endif
292289
293290 enum seekdir { beg, cur, end };
294291
295#if _LIBCPP_STD_VER <= 14
292# if _LIBCPP_STD_VER <= 14
296293 typedef iostate io_state;
297294 typedef openmode open_mode;
298295 typedef seekdir seek_dir;
299296
300297 typedef std::streamoff streamoff;
301298 typedef std::streampos streampos;
302#endif
299# endif
303300
304301 class _LIBCPP_EXPORTED_FROM_ABI Init;
305302
......@@ -360,7 +357,13 @@ public:
360357 }
361358
362359protected:
363 _LIBCPP_HIDE_FROM_ABI ios_base() { // purposefully does no initialization
360 _LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(nullptr) {
361 // Purposefully does no initialization
362 //
363 // Except for the locale, this is a sentinel to avoid destroying
364 // an uninitialized object. See
365 // test/libcxx/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
366 // for the details.
364367 }
365368
366369 void init(void* __sb);
......@@ -393,11 +396,11 @@ private:
393396 size_t __event_cap_;
394397// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
395398// enabled with clang.
396#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
399# if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
397400 static atomic<int> __xindex_;
398#else
401# else
399402 static int __xindex_;
400#endif
403# endif
401404 long* __iarray_;
402405 size_t __iarray_size_;
403406 size_t __iarray_cap_;
......@@ -413,10 +416,10 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
413416template <>
414417struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};
415418
416#ifdef _LIBCPP_CXX03_LANG
419# ifdef _LIBCPP_CXX03_LANG
417420template <>
418421struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};
419#endif
422# endif
420423
421424_LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;
422425
......@@ -437,11 +440,11 @@ public:
437440};
438441
439442_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {
440#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
443# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
441444 throw ios_base::failure(__msg);
442#else
445# else
443446 _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
444#endif
447# endif
445448}
446449
447450class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {
......@@ -516,6 +519,38 @@ inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) {
516519 clear(__rdstate_);
517520}
518521
522template <class _Traits>
523// Attribute 'packed' is used to keep the layout compatible with the previous
524// definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS.
525struct _LIBCPP_PACKED _FillHelper {
526 _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; }
527 _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) {
528 __set_ = true;
529 __fill_val_ = __x;
530 return *this;
531 }
532 _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __set_; }
533 _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; }
534
535private:
536 typename _Traits::int_type __fill_val_;
537 bool __set_;
538};
539
540template <class _Traits>
541struct _LIBCPP_PACKED _SentinelValueFill {
542 _LIBCPP_HIDE_FROM_ABI void __init() { __fill_val_ = _Traits::eof(); }
543 _LIBCPP_HIDE_FROM_ABI _SentinelValueFill& operator=(typename _Traits::int_type __x) {
544 __fill_val_ = __x;
545 return *this;
546 }
547 _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __fill_val_ != _Traits::eof(); }
548 _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; }
549
550private:
551 typename _Traits::int_type __fill_val_;
552};
553
519554template <class _CharT, class _Traits>
520555class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base {
521556public:
......@@ -527,16 +562,16 @@ public:
527562 typedef typename traits_type::pos_type pos_type;
528563 typedef typename traits_type::off_type off_type;
529564
530 static_assert((is_same<_CharT, typename traits_type::char_type>::value),
565 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
531566 "traits_type::char_type must be the same type as CharT");
532567
533#ifdef _LIBCPP_CXX03_LANG
568# ifdef _LIBCPP_CXX03_LANG
534569 // Preserve the ability to compare with literal 0,
535570 // and implicitly convert to bool, but not implicitly convert to int.
536571 _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
537#else
572# else
538573 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
539#endif
574# endif
540575
541576 _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
542577 _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
......@@ -572,7 +607,9 @@ public:
572607 _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const;
573608
574609protected:
575 _LIBCPP_HIDE_FROM_ABI basic_ios() { // purposefully does no initialization
610 _LIBCPP_HIDE_FROM_ABI basic_ios() {
611 // purposefully does no initialization
612 // since the destructor does nothing this does not have ios_base issues.
576613 }
577614 _LIBCPP_HIDE_FROM_ABI void init(basic_streambuf<char_type, traits_type>* __sb);
578615
......@@ -583,7 +620,13 @@ protected:
583620
584621private:
585622 basic_ostream<char_type, traits_type>* __tie_;
586 mutable int_type __fill_;
623
624#if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE)
625 using _FillType = _FillHelper<traits_type>;
626#else
627 using _FillType = _SentinelValueFill<traits_type>;
628#endif
629 mutable _FillType __fill_;
587630};
588631
589632template <class _CharT, class _Traits>
......@@ -598,7 +641,7 @@ template <class _CharT, class _Traits>
598641inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {
599642 ios_base::init(__sb);
600643 __tie_ = nullptr;
601 __fill_ = traits_type::eof();
644 __fill_.__init();
602645}
603646
604647template <class _CharT, class _Traits>
......@@ -648,16 +691,16 @@ inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c)
648691
649692template <class _CharT, class _Traits>
650693inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const {
651 if (traits_type::eq_int_type(traits_type::eof(), __fill_))
694 if (!__fill_.__is_set())
652695 __fill_ = widen(' ');
653 return __fill_;
696 return __fill_.__get();
654697}
655698
656699template <class _CharT, class _Traits>
657700inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) {
658 if (traits_type::eq_int_type(traits_type::eof(), __fill_))
701 if (!__fill_.__is_set())
659702 __fill_ = widen(' ');
660 char_type __r = __fill_;
703 char_type __r = __fill_.__get();
661704 __fill_ = __ch;
662705 return __r;
663706}
......@@ -697,9 +740,9 @@ inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_st
697740
698741extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
699742
700#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
743# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
701744extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
702#endif
745# endif
703746
704747_LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {
705748 __str.setf(ios_base::boolalpha);
......@@ -825,6 +868,8 @@ _LIBCPP_END_NAMESPACE_STD
825868
826869_LIBCPP_POP_MACROS
827870
871#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
872
828873#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
829874# include <atomic>
830875# include <concepts>
lib/libcxx/include/iosfwd+6-13
......@@ -25,7 +25,6 @@ template<> struct char_traits<wchar_t>;
2525
2626template<class T> class allocator;
2727
28class ios_base;
2928template <class charT, class traits = char_traits<charT> > class basic_ios;
3029
3130template <class charT, class traits = char_traits<charT> > class basic_streambuf;
......@@ -106,11 +105,11 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20
106105
107106*/
108107
109#include <__assert> // all public C++ headers provide the assertion handler
110108#include <__config>
111109#include <__fwd/fstream.h>
112110#include <__fwd/ios.h>
113111#include <__fwd/istream.h>
112#include <__fwd/memory.h>
114113#include <__fwd/ostream.h>
115114#include <__fwd/sstream.h>
116115#include <__fwd/streambuf.h>
......@@ -124,8 +123,6 @@ using wosyncstream = basic_osyncstream<wchar_t>; // C++20
124123
125124_LIBCPP_BEGIN_NAMESPACE_STD
126125
127class _LIBCPP_EXPORTED_FROM_ABI ios_base;
128
129126template <class _CharT, class _Traits = char_traits<_CharT> >
130127class _LIBCPP_TEMPLATE_VIS istreambuf_iterator;
131128template <class _CharT, class _Traits = char_traits<_CharT> >
......@@ -143,7 +140,7 @@ typedef fpos<mbstate_t> u8streampos;
143140typedef fpos<mbstate_t> u16streampos;
144141typedef fpos<mbstate_t> u32streampos;
145142
146#if _LIBCPP_STD_VER >= 20
143#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
147144
148145template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT>>
149146class basic_syncbuf;
......@@ -161,11 +158,7 @@ using osyncstream = basic_osyncstream<char>;
161158using wosyncstream = basic_osyncstream<wchar_t>;
162159# endif
163160
164#endif // _LIBCPP_STD_VER >=20
165
166// Include other forward declarations here
167template <class _Tp, class _Alloc = allocator<_Tp> >
168class _LIBCPP_TEMPLATE_VIS vector;
161#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
169162
170163template <class _CharT, class _Traits>
171164class __save_flags {
......@@ -176,10 +169,10 @@ class __save_flags {
176169 fmtflags __fmtflags_;
177170 _CharT __fill_;
178171
179 __save_flags(const __save_flags&);
180 __save_flags& operator=(const __save_flags&);
181
182172public:
173 __save_flags(const __save_flags&) = delete;
174 __save_flags& operator=(const __save_flags&) = delete;
175
183176 _LIBCPP_HIDE_FROM_ABI explicit __save_flags(__stream_type& __stream)
184177 : __stream_(__stream), __fmtflags_(__stream.flags()), __fill_(__stream.fill()) {}
185178 _LIBCPP_HIDE_FROM_ABI ~__save_flags() {
lib/libcxx/include/iostream-1
......@@ -33,7 +33,6 @@ extern wostream wclog;
3333
3434*/
3535
36#include <__assert> // all public C++ headers provide the assertion handler
3736#include <__config>
3837#include <version>
3938
lib/libcxx/include/istream+11-7
......@@ -158,16 +158,18 @@ template <class Stream, class T>
158158
159159*/
160160
161#include <__assert> // all public C++ headers provide the assertion handler
162161#include <__config>
163162#include <__fwd/istream.h>
164163#include <__iterator/istreambuf_iterator.h>
164#include <__ostream/basic_ostream.h>
165165#include <__type_traits/conjunction.h>
166166#include <__type_traits/enable_if.h>
167167#include <__type_traits/is_base_of.h>
168168#include <__utility/declval.h>
169169#include <__utility/forward.h>
170#include <ostream>
170#include <bitset>
171#include <ios>
172#include <locale>
171173#include <version>
172174
173175#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -214,10 +216,10 @@ protected:
214216 basic_ios<char_type, traits_type>::swap(__rhs);
215217 }
216218
219public:
217220 basic_istream(const basic_istream& __rhs) = delete;
218221 basic_istream& operator=(const basic_istream& __rhs) = delete;
219222
220public:
221223 // 27.7.1.1.3 Prefix/suffix:
222224 class _LIBCPP_TEMPLATE_VIS sentry;
223225
......@@ -1009,17 +1011,18 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() {
10091011template <class _CharT, class _Traits>
10101012int basic_istream<_CharT, _Traits>::sync() {
10111013 ios_base::iostate __state = ios_base::goodbit;
1012 int __r = 0;
10131014 sentry __sen(*this, true);
1015 if (this->rdbuf() == nullptr)
1016 return -1;
1017
1018 int __r = 0;
10141019 if (__sen) {
10151020#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
10161021 try {
10171022#endif // _LIBCPP_HAS_NO_EXCEPTIONS
1018 if (this->rdbuf() == nullptr)
1019 return -1;
10201023 if (this->rdbuf()->pubsync() == -1) {
10211024 __state |= ios_base::badbit;
1022 return -1;
1025 __r = -1;
10231026 }
10241027#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
10251028 } catch (...) {
......@@ -1361,6 +1364,7 @@ _LIBCPP_END_NAMESPACE_STD
13611364#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
13621365# include <concepts>
13631366# include <iosfwd>
1367# include <ostream>
13641368# include <type_traits>
13651369#endif
13661370
lib/libcxx/include/iterator+38-24
......@@ -475,6 +475,11 @@ constexpr move_iterator<Iterator> operator+( // constexpr in C++17
475475template <class Iterator> // constexpr in C++17
476476constexpr move_iterator<Iterator> make_move_iterator(const Iterator& i);
477477
478template<class Iterator1, class Iterator2>
479 requires (!sized_sentinel_for<Iterator1, Iterator2>)
480 inline constexpr bool disable_sized_sentinel_for<move_iterator<Iterator1>, // since C++20
481 move_iterator<Iterator2>> = true;
482
478483template<semiregular S>
479484class move_sentinel {
480485public:
......@@ -674,48 +679,53 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
674679
675680*/
676681
677#include <__assert> // all public C++ headers provide the assertion handler
678682#include <__config>
679683#include <__iterator/access.h>
680684#include <__iterator/advance.h>
681685#include <__iterator/back_insert_iterator.h>
682#include <__iterator/bounded_iter.h>
683#include <__iterator/common_iterator.h>
684#include <__iterator/concepts.h>
685#include <__iterator/counted_iterator.h>
686#include <__iterator/data.h>
687#include <__iterator/default_sentinel.h>
688686#include <__iterator/distance.h>
689#include <__iterator/empty.h>
690#include <__iterator/erase_if_container.h>
691687#include <__iterator/front_insert_iterator.h>
692#include <__iterator/incrementable_traits.h>
693#include <__iterator/indirectly_comparable.h>
694688#include <__iterator/insert_iterator.h>
695689#include <__iterator/istream_iterator.h>
696690#include <__iterator/istreambuf_iterator.h>
697#include <__iterator/iter_move.h>
698#include <__iterator/iter_swap.h>
699691#include <__iterator/iterator.h>
700692#include <__iterator/iterator_traits.h>
701#include <__iterator/mergeable.h>
702693#include <__iterator/move_iterator.h>
703#include <__iterator/move_sentinel.h>
704694#include <__iterator/next.h>
705695#include <__iterator/ostream_iterator.h>
706696#include <__iterator/ostreambuf_iterator.h>
707#include <__iterator/permutable.h>
708697#include <__iterator/prev.h>
709#include <__iterator/projected.h>
710#include <__iterator/readable_traits.h>
711#include <__iterator/reverse_access.h>
712698#include <__iterator/reverse_iterator.h>
713#include <__iterator/size.h>
714#include <__iterator/sortable.h>
715#include <__iterator/unreachable_sentinel.h>
716699#include <__iterator/wrap_iter.h>
717#include <__memory/addressof.h>
718#include <__memory/pointer_traits.h>
700
701#if _LIBCPP_STD_VER >= 14
702# include <__iterator/reverse_access.h>
703#endif
704
705#if _LIBCPP_STD_VER >= 17
706# include <__iterator/data.h>
707# include <__iterator/empty.h>
708# include <__iterator/size.h>
709#endif
710
711#if _LIBCPP_STD_VER >= 20
712# include <__iterator/common_iterator.h>
713# include <__iterator/concepts.h>
714# include <__iterator/counted_iterator.h>
715# include <__iterator/default_sentinel.h>
716# include <__iterator/incrementable_traits.h>
717# include <__iterator/indirectly_comparable.h>
718# include <__iterator/iter_move.h>
719# include <__iterator/iter_swap.h>
720# include <__iterator/mergeable.h>
721# include <__iterator/move_sentinel.h>
722# include <__iterator/permutable.h>
723# include <__iterator/projected.h>
724# include <__iterator/readable_traits.h>
725# include <__iterator/sortable.h>
726# include <__iterator/unreachable_sentinel.h>
727#endif
728
719729#include <version>
720730
721731// standard-mandated includes
......@@ -728,6 +738,10 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
728738# pragma GCC system_header
729739#endif
730740
741#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
742# include <variant>
743#endif
744
731745#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
732746# include <cstdlib>
733747# include <exception>
lib/libcxx/include/latch+27-21
......@@ -42,31 +42,28 @@ namespace std
4242
4343#include <__config>
4444
45#ifdef _LIBCPP_HAS_NO_THREADS
46# error "<latch> is not supported since libc++ has been configured without support for threads."
47#endif
45#if !defined(_LIBCPP_HAS_NO_THREADS)
4846
49#include <__assert> // all public C++ headers provide the assertion handler
50#include <__atomic/atomic_base.h>
51#include <__atomic/atomic_sync.h>
52#include <__atomic/memory_order.h>
53#include <__availability>
54#include <cstddef>
55#include <limits>
56#include <version>
57
58#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59# pragma GCC system_header
60#endif
47# include <__assert>
48# include <__atomic/atomic_base.h>
49# include <__atomic/atomic_sync.h>
50# include <__atomic/memory_order.h>
51# include <cstddef>
52# include <limits>
53# include <version>
54
55# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56# pragma GCC system_header
57# endif
6158
6259_LIBCPP_PUSH_MACROS
63#include <__undef_macros>
60# include <__undef_macros>
6461
65#if _LIBCPP_STD_VER >= 14
62# if _LIBCPP_STD_VER >= 14
6663
6764_LIBCPP_BEGIN_NAMESPACE_STD
6865
69class latch {
66class _LIBCPP_DEPRECATED_ATOMIC_SYNC latch {
7067 __atomic_base<ptrdiff_t> __a_;
7168
7269public:
......@@ -97,9 +94,13 @@ public:
9794 if (__old == __update)
9895 __a_.notify_all();
9996 }
100 inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept { return 0 == __a_.load(memory_order_acquire); }
97 inline _LIBCPP_HIDE_FROM_ABI bool try_wait() const noexcept {
98 auto __value = __a_.load(memory_order_acquire);
99 return try_wait_impl(__value);
100 }
101101 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void wait() const {
102 __cxx_atomic_wait(&__a_.__a_, [this]() -> bool { return try_wait(); });
102 std::__atomic_wait_unless(
103 __a_, [this](ptrdiff_t& __value) -> bool { return try_wait_impl(__value); }, memory_order_acquire);
103104 }
104105 inline _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void arrive_and_wait(ptrdiff_t __update = 1) {
105106 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__update >= 0, "latch::arrive_and_wait called with a negative value");
......@@ -108,14 +109,19 @@ public:
108109 count_down(__update);
109110 wait();
110111 }
112
113private:
114 _LIBCPP_HIDE_FROM_ABI bool try_wait_impl(ptrdiff_t& __value) const noexcept { return __value == 0; }
111115};
112116
113117_LIBCPP_END_NAMESPACE_STD
114118
115#endif // _LIBCPP_STD_VER >= 14
119# endif // _LIBCPP_STD_VER >= 14
116120
117121_LIBCPP_POP_MACROS
118122
123#endif // !defined(_LIBCPP_HAS_NO_THREADS)
124
119125#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
120126# include <atomic>
121127#endif
lib/libcxx/include/limits+104-342
......@@ -102,7 +102,6 @@ template<> class numeric_limits<cv long double>;
102102
103103*/
104104
105#include <__assert> // all public C++ headers provide the assertion handler
106105#include <__config>
107106#include <__type_traits/is_arithmetic.h>
108107#include <__type_traits/is_signed.h>
......@@ -138,9 +137,9 @@ protected:
138137 typedef _Tp type;
139138
140139 static _LIBCPP_CONSTEXPR const bool is_specialized = false;
141 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }
142 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }
143 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }
140 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return type(); }
141 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return type(); }
142 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return type(); }
144143
145144 static _LIBCPP_CONSTEXPR const int digits = 0;
146145 static _LIBCPP_CONSTEXPR const int digits10 = 0;
......@@ -149,8 +148,8 @@ protected:
149148 static _LIBCPP_CONSTEXPR const bool is_integer = false;
150149 static _LIBCPP_CONSTEXPR const bool is_exact = false;
151150 static _LIBCPP_CONSTEXPR const int radix = 0;
152 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }
153 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }
151 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(); }
152 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(); }
154153
155154 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
156155 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
......@@ -162,10 +161,10 @@ protected:
162161 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
163162 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
164163 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
165 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }
166 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }
167 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }
168 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }
164 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(); }
165 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(); }
166 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(); }
167 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(); }
169168
170169 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
171170 static _LIBCPP_CONSTEXPR const bool is_bounded = false;
......@@ -199,15 +198,15 @@ protected:
199198 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
200199 static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value;
201200 static _LIBCPP_CONSTEXPR const type __max = is_signed ? type(type(~0) ^ __min) : type(~0);
202 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
203 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
204 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
201 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
202 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
203 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
205204
206205 static _LIBCPP_CONSTEXPR const bool is_integer = true;
207206 static _LIBCPP_CONSTEXPR const bool is_exact = true;
208207 static _LIBCPP_CONSTEXPR const int radix = 2;
209 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
210 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
208 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
209 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
211210
212211 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
213212 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
......@@ -219,10 +218,10 @@ protected:
219218 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
220219 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
221220 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
222 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
223 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
224 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
225 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
221 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
222 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
223 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
224 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
226225
227226 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
228227 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
......@@ -250,15 +249,15 @@ protected:
250249 static _LIBCPP_CONSTEXPR const int max_digits10 = 0;
251250 static _LIBCPP_CONSTEXPR const type __min = false;
252251 static _LIBCPP_CONSTEXPR const type __max = true;
253 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
254 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
255 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
252 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __min; }
253 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __max; }
254 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return min(); }
256255
257256 static _LIBCPP_CONSTEXPR const bool is_integer = true;
258257 static _LIBCPP_CONSTEXPR const bool is_exact = true;
259258 static _LIBCPP_CONSTEXPR const int radix = 2;
260 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
261 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
259 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return type(0); }
260 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return type(0); }
262261
263262 static _LIBCPP_CONSTEXPR const int min_exponent = 0;
264263 static _LIBCPP_CONSTEXPR const int min_exponent10 = 0;
......@@ -270,10 +269,10 @@ protected:
270269 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false;
271270 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent;
272271 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
273 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
274 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
275 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
276 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
272 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return type(0); }
273 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return type(0); }
274 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return type(0); }
275 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return type(0); }
277276
278277 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
279278 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
......@@ -295,15 +294,15 @@ protected:
295294 static _LIBCPP_CONSTEXPR const int digits = __FLT_MANT_DIG__;
296295 static _LIBCPP_CONSTEXPR const int digits10 = __FLT_DIG__;
297296 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
298 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }
299 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }
300 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
297 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __FLT_MIN__; }
298 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __FLT_MAX__; }
299 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
301300
302301 static _LIBCPP_CONSTEXPR const bool is_integer = false;
303302 static _LIBCPP_CONSTEXPR const bool is_exact = false;
304303 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
305 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }
306 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }
304 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __FLT_EPSILON__; }
305 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5F; }
307306
308307 static _LIBCPP_CONSTEXPR const int min_exponent = __FLT_MIN_EXP__;
309308 static _LIBCPP_CONSTEXPR const int min_exponent10 = __FLT_MIN_10_EXP__;
......@@ -315,10 +314,18 @@ protected:
315314 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
316315 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
317316 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
318 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_valf(); }
319 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanf(""); }
320 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansf(""); }
321 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __FLT_DENORM_MIN__; }
317 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
318 return __builtin_huge_valf();
319 }
320 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
321 return __builtin_nanf("");
322 }
323 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
324 return __builtin_nansf("");
325 }
326 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
327 return __FLT_DENORM_MIN__;
328 }
322329
323330 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
324331 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
......@@ -344,15 +351,15 @@ protected:
344351 static _LIBCPP_CONSTEXPR const int digits = __DBL_MANT_DIG__;
345352 static _LIBCPP_CONSTEXPR const int digits10 = __DBL_DIG__;
346353 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
347 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }
348 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }
349 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
354 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __DBL_MIN__; }
355 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __DBL_MAX__; }
356 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
350357
351358 static _LIBCPP_CONSTEXPR const bool is_integer = false;
352359 static _LIBCPP_CONSTEXPR const bool is_exact = false;
353360 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
354 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }
355 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }
361 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __DBL_EPSILON__; }
362 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5; }
356363
357364 static _LIBCPP_CONSTEXPR const int min_exponent = __DBL_MIN_EXP__;
358365 static _LIBCPP_CONSTEXPR const int min_exponent10 = __DBL_MIN_10_EXP__;
......@@ -364,10 +371,18 @@ protected:
364371 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
365372 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
366373 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
367 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_val(); }
368 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nan(""); }
369 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nans(""); }
370 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __DBL_DENORM_MIN__; }
374 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
375 return __builtin_huge_val();
376 }
377 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
378 return __builtin_nan("");
379 }
380 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
381 return __builtin_nans("");
382 }
383 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
384 return __DBL_DENORM_MIN__;
385 }
371386
372387 static _LIBCPP_CONSTEXPR const bool is_iec559 = true;
373388 static _LIBCPP_CONSTEXPR const bool is_bounded = true;
......@@ -393,15 +408,15 @@ protected:
393408 static _LIBCPP_CONSTEXPR const int digits = __LDBL_MANT_DIG__;
394409 static _LIBCPP_CONSTEXPR const int digits10 = __LDBL_DIG__;
395410 static _LIBCPP_CONSTEXPR const int max_digits10 = 2 + (digits * 30103l) / 100000l;
396 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }
397 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }
398 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
411 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __LDBL_MIN__; }
412 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __LDBL_MAX__; }
413 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return -max(); }
399414
400415 static _LIBCPP_CONSTEXPR const bool is_integer = false;
401416 static _LIBCPP_CONSTEXPR const bool is_exact = false;
402417 static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
403 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }
404 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }
418 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __LDBL_EPSILON__; }
419 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return 0.5L; }
405420
406421 static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
407422 static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
......@@ -413,10 +428,18 @@ protected:
413428 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = true;
414429 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_present;
415430 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = false;
416 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __builtin_huge_vall(); }
417 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __builtin_nanl(""); }
418 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __builtin_nansl(""); }
419 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __LDBL_DENORM_MIN__; }
431 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
432 return __builtin_huge_vall();
433 }
434 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
435 return __builtin_nanl("");
436 }
437 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
438 return __builtin_nansl("");
439 }
440 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
441 return __LDBL_DENORM_MIN__;
442 }
420443
421444#if defined(__powerpc__) && defined(__LONG_DOUBLE_IBM128__)
422445 static _LIBCPP_CONSTEXPR const bool is_iec559 = false;
......@@ -436,15 +459,15 @@ protected:
436459};
437460
438461template <class _Tp>
439class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<__remove_cv_t<_Tp> > {
440 typedef __libcpp_numeric_limits<__remove_cv_t<_Tp> > __base;
462class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp> {
463 typedef __libcpp_numeric_limits<_Tp> __base;
441464 typedef typename __base::type type;
442465
443466public:
444467 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
445 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
446 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
447 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
468 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
469 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
470 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
448471
449472 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
450473 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
......@@ -453,8 +476,12 @@ public:
453476 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
454477 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
455478 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
456 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); }
457 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); }
479 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
480 return __base::epsilon();
481 }
482 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
483 return __base::round_error();
484 }
458485
459486 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
460487 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
......@@ -468,10 +495,18 @@ public:
468495 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
469496 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
470497 _LIBCPP_SUPPRESS_DEPRECATED_POP
471 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); }
472 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); }
473 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); }
474 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); }
498 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
499 return __base::infinity();
500 }
501 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT {
502 return __base::quiet_NaN();
503 }
504 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT {
505 return __base::signaling_NaN();
506 }
507 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT {
508 return __base::denorm_min();
509 }
475510
476511 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
477512 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
......@@ -530,286 +565,13 @@ template <class _Tp>
530565_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
531566
532567template <class _Tp>
533class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : private numeric_limits<_Tp> {
534 typedef numeric_limits<_Tp> __base;
535 typedef _Tp type;
536
537public:
538 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
539 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
540 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
541 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
542
543 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
544 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
545 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
546 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
547 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
548 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
549 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
550 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); }
551 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); }
552
553 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
554 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
555 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
556 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
557
558 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
559 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
560 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
561 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
562 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
563 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
564 _LIBCPP_SUPPRESS_DEPRECATED_POP
565 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); }
566 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); }
567 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); }
568 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); }
569
570 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
571 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
572 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
573
574 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
575 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
576 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
577};
578
579template <class _Tp>
580_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_specialized;
581template <class _Tp>
582_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits;
583template <class _Tp>
584_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::digits10;
585template <class _Tp>
586_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_digits10;
587template <class _Tp>
588_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_signed;
589template <class _Tp>
590_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_integer;
591template <class _Tp>
592_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_exact;
593template <class _Tp>
594_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::radix;
595template <class _Tp>
596_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent;
597template <class _Tp>
598_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::min_exponent10;
599template <class _Tp>
600_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent;
601template <class _Tp>
602_LIBCPP_CONSTEXPR const int numeric_limits<const _Tp>::max_exponent10;
603template <class _Tp>
604_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_infinity;
605template <class _Tp>
606_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_quiet_NaN;
607template <class _Tp>
608_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_signaling_NaN;
609template <class _Tp>
610_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const _Tp>::has_denorm;
611template <class _Tp>
612_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::has_denorm_loss;
613template <class _Tp>
614_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_iec559;
615template <class _Tp>
616_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_bounded;
617template <class _Tp>
618_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::is_modulo;
619template <class _Tp>
620_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::traps;
621template <class _Tp>
622_LIBCPP_CONSTEXPR const bool numeric_limits<const _Tp>::tinyness_before;
623template <class _Tp>
624_LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style;
625
626template <class _Tp>
627class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : private numeric_limits<_Tp> {
628 typedef numeric_limits<_Tp> __base;
629 typedef _Tp type;
630
631public:
632 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
633 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
634 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
635 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
636
637 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
638 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
639 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
640 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
641 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
642 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
643 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
644 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); }
645 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); }
646
647 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
648 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
649 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
650 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
651
652 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
653 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
654 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
655 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
656 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
657 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
658 _LIBCPP_SUPPRESS_DEPRECATED_POP
659 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); }
660 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); }
661 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); }
662 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); }
663
664 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
665 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
666 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
667
668 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
669 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
670 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
671};
672
673template <class _Tp>
674_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_specialized;
675template <class _Tp>
676_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits;
677template <class _Tp>
678_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::digits10;
679template <class _Tp>
680_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_digits10;
681template <class _Tp>
682_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_signed;
683template <class _Tp>
684_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_integer;
685template <class _Tp>
686_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_exact;
687template <class _Tp>
688_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::radix;
689template <class _Tp>
690_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent;
691template <class _Tp>
692_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::min_exponent10;
693template <class _Tp>
694_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent;
695template <class _Tp>
696_LIBCPP_CONSTEXPR const int numeric_limits<volatile _Tp>::max_exponent10;
697template <class _Tp>
698_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_infinity;
699template <class _Tp>
700_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_quiet_NaN;
701template <class _Tp>
702_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_signaling_NaN;
703template <class _Tp>
704_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<volatile _Tp>::has_denorm;
705template <class _Tp>
706_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::has_denorm_loss;
707template <class _Tp>
708_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_iec559;
709template <class _Tp>
710_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_bounded;
711template <class _Tp>
712_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::is_modulo;
713template <class _Tp>
714_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::traps;
715template <class _Tp>
716_LIBCPP_CONSTEXPR const bool numeric_limits<volatile _Tp>::tinyness_before;
717template <class _Tp>
718_LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style;
568class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
719569
720570template <class _Tp>
721class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : private numeric_limits<_Tp> {
722 typedef numeric_limits<_Tp> __base;
723 typedef _Tp type;
724
725public:
726 static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
727 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
728 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
729 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
571class _LIBCPP_TEMPLATE_VIS numeric_limits<volatile _Tp> : public numeric_limits<_Tp> {};
730572
731 static _LIBCPP_CONSTEXPR const int digits = __base::digits;
732 static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
733 static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
734 static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
735 static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
736 static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
737 static _LIBCPP_CONSTEXPR const int radix = __base::radix;
738 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT { return __base::epsilon(); }
739 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT { return __base::round_error(); }
740
741 static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
742 static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
743 static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
744 static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
745
746 static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
747 static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
748 static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
749 _LIBCPP_SUPPRESS_DEPRECATED_PUSH
750 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
751 static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
752 _LIBCPP_SUPPRESS_DEPRECATED_POP
753 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT { return __base::infinity(); }
754 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type quiet_NaN() _NOEXCEPT { return __base::quiet_NaN(); }
755 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type signaling_NaN() _NOEXCEPT { return __base::signaling_NaN(); }
756 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type denorm_min() _NOEXCEPT { return __base::denorm_min(); }
757
758 static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
759 static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
760 static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
761
762 static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
763 static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
764 static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
765};
766
767template <class _Tp>
768_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_specialized;
769template <class _Tp>
770_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits;
771template <class _Tp>
772_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::digits10;
773template <class _Tp>
774_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_digits10;
775template <class _Tp>
776_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_signed;
777template <class _Tp>
778_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_integer;
779template <class _Tp>
780_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_exact;
781template <class _Tp>
782_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::radix;
783template <class _Tp>
784_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent;
785template <class _Tp>
786_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::min_exponent10;
787template <class _Tp>
788_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent;
789template <class _Tp>
790_LIBCPP_CONSTEXPR const int numeric_limits<const volatile _Tp>::max_exponent10;
791template <class _Tp>
792_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_infinity;
793template <class _Tp>
794_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_quiet_NaN;
795template <class _Tp>
796_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_signaling_NaN;
797template <class _Tp>
798_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<const volatile _Tp>::has_denorm;
799template <class _Tp>
800_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::has_denorm_loss;
801template <class _Tp>
802_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_iec559;
803template <class _Tp>
804_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_bounded;
805template <class _Tp>
806_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::is_modulo;
807template <class _Tp>
808_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::traps;
809template <class _Tp>
810_LIBCPP_CONSTEXPR const bool numeric_limits<const volatile _Tp>::tinyness_before;
811573template <class _Tp>
812_LIBCPP_CONSTEXPR const float_round_style numeric_limits<const volatile _Tp>::round_style;
574class _LIBCPP_TEMPLATE_VIS numeric_limits<const volatile _Tp> : public numeric_limits<_Tp> {};
813575
814576_LIBCPP_END_NAMESPACE_STD
815577
lib/libcxx/include/list+40-62
......@@ -202,8 +202,7 @@ template <class T, class Allocator, class Predicate>
202202#include <__algorithm/lexicographical_compare.h>
203203#include <__algorithm/lexicographical_compare_three_way.h>
204204#include <__algorithm/min.h>
205#include <__assert> // all public C++ headers provide the assertion handler
206#include <__availability>
205#include <__assert>
207206#include <__config>
208207#include <__format/enable_insertable.h>
209208#include <__iterator/distance.h>
......@@ -227,9 +226,8 @@ template <class T, class Allocator, class Predicate>
227226#include <__ranges/from_range.h>
228227#include <__type_traits/conditional.h>
229228#include <__type_traits/is_allocator.h>
230#include <__type_traits/is_nothrow_default_constructible.h>
231#include <__type_traits/is_nothrow_move_assignable.h>
232#include <__type_traits/is_nothrow_move_constructible.h>
229#include <__type_traits/is_nothrow_assignable.h>
230#include <__type_traits/is_nothrow_constructible.h>
233231#include <__type_traits/is_pointer.h>
234232#include <__type_traits/is_same.h>
235233#include <__type_traits/type_identity.h>
......@@ -467,10 +465,10 @@ public:
467465
468466template <class _Tp, class _Alloc>
469467class __list_imp {
470 __list_imp(const __list_imp&);
471 __list_imp& operator=(const __list_imp&);
472
473468public:
469 __list_imp(const __list_imp&) = delete;
470 __list_imp& operator=(const __list_imp&) = delete;
471
474472 typedef _Alloc allocator_type;
475473 typedef allocator_traits<allocator_type> __alloc_traits;
476474 typedef typename __alloc_traits::size_type size_type;
......@@ -495,9 +493,8 @@ protected:
495493
496494 typedef __rebind_alloc<__alloc_traits, __node_base> __node_base_allocator;
497495 typedef typename allocator_traits<__node_base_allocator>::pointer __node_base_pointer;
498 static_assert((!is_same<allocator_type, __node_allocator>::value),
499 "internal allocator type must differ from user-specified "
500 "type; otherwise overload resolution breaks");
496 static_assert(!is_same<allocator_type, __node_allocator>::value,
497 "internal allocator type must differ from user-specified type; otherwise overload resolution breaks");
501498
502499 __node_base __end_;
503500 __compressed_pair<size_type, __node_allocator> __size_alloc_;
......@@ -535,7 +532,7 @@ protected:
535532#if _LIBCPP_STD_VER >= 14
536533 _NOEXCEPT;
537534#else
538 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
535 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
539536#endif
540537
541538 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
......@@ -568,7 +565,6 @@ protected:
568565 return __guard.__release_ptr();
569566 }
570567
571 template <class... _Args>
572568 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
573569 // For the same reason as above, we use the allocator's destroy() method for the value_type,
574570 // but not for the node itself.
......@@ -642,7 +638,7 @@ void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
642638#if _LIBCPP_STD_VER >= 14
643639 _NOEXCEPT
644640#else
645 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
641 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
646642#endif
647643{
648644 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
......@@ -677,7 +673,8 @@ class _LIBCPP_TEMPLATE_VIS list : private __list_imp<_Tp, _Alloc> {
677673public:
678674 typedef _Tp value_type;
679675 typedef _Alloc allocator_type;
680 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
676 static_assert(__check_valid_allocator<allocator_type>::value);
677 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
681678 "Allocator::value_type must be same type as value_type");
682679 typedef value_type& reference;
683680 typedef const value_type& const_reference;
......@@ -695,10 +692,6 @@ public:
695692 typedef void __remove_return_type;
696693#endif
697694
698 static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
699 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
700 "original allocator");
701
702695 _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
703696 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : base(__a) {}
704697 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
......@@ -706,21 +699,17 @@ public:
706699 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
707700#endif
708701 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
709 template <class = __enable_if_t<__is_allocator<_Alloc>::value> >
702 template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
710703 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : base(__a) {
711704 for (; __n > 0; --__n)
712705 push_back(__x);
713706 }
714707
715 template <class _InpIter>
716 _LIBCPP_HIDE_FROM_ABI
717 list(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0);
718 template <class _InpIter>
719 _LIBCPP_HIDE_FROM_ABI
720 list(_InpIter __f,
721 _InpIter __l,
722 const allocator_type& __a,
723 __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0);
708 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
709 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);
710
711 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
712 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
724713
725714#if _LIBCPP_STD_VER >= 23
726715 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -750,9 +739,8 @@ public:
750739 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
751740#endif // _LIBCPP_CXX03_LANG
752741
753 template <class _InpIter>
754 _LIBCPP_HIDE_FROM_ABI void
755 assign(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0);
742 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
743 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
756744
757745#if _LIBCPP_STD_VER >= 23
758746 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -766,7 +754,7 @@ public:
766754 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
767755
768756 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return base::__sz(); }
769 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); }
757 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return base::empty(); }
770758 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
771759 return std::min<size_type>(base::__node_alloc_max_size(), numeric_limits<difference_type >::max());
772760 }
......@@ -854,12 +842,9 @@ public:
854842
855843 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
856844 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);
857 template <class _InpIter>
858 _LIBCPP_HIDE_FROM_ABI iterator
859 insert(const_iterator __p,
860 _InpIter __f,
861 _InpIter __l,
862 __enable_if_t<__has_input_iterator_category<_InpIter>::value>* = 0);
845
846 template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
847 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
863848
864849#if _LIBCPP_STD_VER >= 23
865850 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -872,8 +857,7 @@ public:
872857#if _LIBCPP_STD_VER >= 14
873858 _NOEXCEPT
874859#else
875 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
876 __is_nothrow_swappable<__node_allocator>::value)
860 _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
877861#endif
878862 {
879863 base::swap(__c);
......@@ -1024,19 +1008,15 @@ list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
10241008}
10251009
10261010template <class _Tp, class _Alloc>
1027template <class _InpIter>
1028list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) {
1011template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1012list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
10291013 for (; __f != __l; ++__f)
10301014 __emplace_back(*__f);
10311015}
10321016
10331017template <class _Tp, class _Alloc>
1034template <class _InpIter>
1035list<_Tp, _Alloc>::list(_InpIter __f,
1036 _InpIter __l,
1037 const allocator_type& __a,
1038 __enable_if_t<__has_input_iterator_category<_InpIter>::value>*)
1039 : base(__a) {
1018template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1019list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : base(__a) {
10401020 for (; __f != __l; ++__f)
10411021 __emplace_back(*__f);
10421022}
......@@ -1069,7 +1049,7 @@ list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
10691049}
10701050
10711051template <class _Tp, class _Alloc>
1072inline list<_Tp, _Alloc>::list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value)
1052inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)
10731053 : base(std::move(__c.__node_alloc())) {
10741054 splice(end(), __c);
10751055}
......@@ -1085,9 +1065,9 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ
10851065}
10861066
10871067template <class _Tp, class _Alloc>
1088inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c)
1089 _NOEXCEPT_(__node_alloc_traits::propagate_on_container_move_assignment::value&&
1090 is_nothrow_move_assignable<__node_allocator>::value) {
1068inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
1069 __node_alloc_traits::propagate_on_container_move_assignment::value &&
1070 is_nothrow_move_assignable<__node_allocator>::value) {
10911071 __move_assign(__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_move_assignment::value>());
10921072 return *this;
10931073}
......@@ -1102,8 +1082,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
11021082}
11031083
11041084template <class _Tp, class _Alloc>
1105void list<_Tp, _Alloc>::__move_assign(list& __c, true_type)
1106 _NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
1085void list<_Tp, _Alloc>::__move_assign(list& __c,
1086 true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
11071087 clear();
11081088 base::__move_assign_alloc(__c);
11091089 splice(end(), __c);
......@@ -1121,9 +1101,8 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
11211101}
11221102
11231103template <class _Tp, class _Alloc>
1124template <class _InpIter>
1125void list<_Tp, _Alloc>::assign(
1126 _InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) {
1104template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1105void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {
11271106 __assign_with_sentinel(__f, __l);
11281107}
11291108
......@@ -1201,9 +1180,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
12011180}
12021181
12031182template <class _Tp, class _Alloc>
1204template <class _InpIter>
1205typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(
1206 const_iterator __p, _InpIter __f, _InpIter __l, __enable_if_t<__has_input_iterator_category<_InpIter>::value>*) {
1183template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
1184typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {
12071185 return __insert_with_sentinel(__p, __f, __l);
12081186}
12091187
......@@ -1702,7 +1680,7 @@ template <class _Tp, class _Allocator>
17021680_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
17031681operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
17041682 return std::lexicographical_compare_three_way(
1705 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
1683 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
17061684}
17071685
17081686#endif // _LIBCPP_STD_VER <= 17
lib/libcxx/include/locale+195-160
......@@ -84,7 +84,7 @@ template <class charT> charT tolower(charT c, const locale& loc);
8484template<class Codecvt, class Elem = wchar_t,
8585 class Wide_alloc = allocator<Elem>,
8686 class Byte_alloc = allocator<char>>
87class wstring_convert
87class wstring_convert // Removed in C++26
8888{
8989public:
9090 typedef basic_string<char, char_traits<char>, Byte_alloc> byte_string;
......@@ -119,7 +119,7 @@ public:
119119};
120120
121121template <class Codecvt, class Elem = wchar_t, class Tr = char_traits<Elem>>
122class wbuffer_convert
122class wbuffer_convert // Removed in C++26
123123 : public basic_streambuf<Elem, Tr>
124124{
125125public:
......@@ -187,67 +187,74 @@ template <class charT> class messages_byname;
187187
188188*/
189189
190#include <__algorithm/copy.h>
191#include <__algorithm/equal.h>
192#include <__algorithm/find.h>
193#include <__algorithm/max.h>
194#include <__algorithm/reverse.h>
195#include <__algorithm/unwrap_iter.h>
196#include <__assert> // all public C++ headers provide the assertion handler
197190#include <__config>
198#include <__iterator/access.h>
199#include <__iterator/back_insert_iterator.h>
200#include <__iterator/istreambuf_iterator.h>
201#include <__iterator/ostreambuf_iterator.h>
202#include <__locale>
203#include <__memory/unique_ptr.h>
204#include <__type_traits/make_unsigned.h>
205#include <cerrno>
206#include <cstdio>
207#include <cstdlib>
208#include <ctime>
209#include <ios>
210#include <limits>
211#include <new>
212#include <streambuf>
213#include <version>
191
192#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
193
194# include <__algorithm/copy.h>
195# include <__algorithm/equal.h>
196# include <__algorithm/find.h>
197# include <__algorithm/max.h>
198# include <__algorithm/reverse.h>
199# include <__algorithm/unwrap_iter.h>
200# include <__assert>
201# include <__iterator/access.h>
202# include <__iterator/back_insert_iterator.h>
203# include <__iterator/istreambuf_iterator.h>
204# include <__iterator/ostreambuf_iterator.h>
205# include <__locale>
206# include <__memory/unique_ptr.h>
207# include <__type_traits/make_unsigned.h>
208# include <cerrno>
209# include <cstdio>
210# include <cstdlib>
211# include <ctime>
212# include <ios>
213# include <limits>
214# include <new>
215# include <streambuf>
216# include <version>
214217
215218// TODO: Fix __bsd_locale_defaults.h
216219// NOLINTBEGIN(libcpp-robust-against-adl)
217220
218#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
221# if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
219222// Most unix variants have catopen. These are the specific ones that don't.
220# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
221# define _LIBCPP_HAS_CATOPEN 1
222# include <nl_types.h>
223# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
224# define _LIBCPP_HAS_CATOPEN 1
225# include <nl_types.h>
226# endif
223227# endif
224#endif
225228
226#ifdef _LIBCPP_LOCALE__L_EXTENSIONS
227# include <__locale_dir/locale_base_api/bsd_locale_defaults.h>
228#else
229# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
230#endif
229# ifdef _LIBCPP_LOCALE__L_EXTENSIONS
230# include <__locale_dir/locale_base_api/bsd_locale_defaults.h>
231# else
232# include <__locale_dir/locale_base_api/bsd_locale_fallbacks.h>
233# endif
231234
232#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
233# pragma GCC system_header
234#endif
235# if defined(__APPLE__) || defined(__FreeBSD__)
236# include <xlocale.h>
237# endif
238
239# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
240# pragma GCC system_header
241# endif
235242
236243_LIBCPP_PUSH_MACROS
237#include <__undef_macros>
244# include <__undef_macros>
238245
239246_LIBCPP_BEGIN_NAMESPACE_STD
240247
241#if defined(__APPLE__) || defined(__FreeBSD__)
242# define _LIBCPP_GET_C_LOCALE 0
243#elif defined(__NetBSD__)
244# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
245#else
246# define _LIBCPP_GET_C_LOCALE __cloc()
248# if defined(__APPLE__) || defined(__FreeBSD__)
249# define _LIBCPP_GET_C_LOCALE 0
250# elif defined(__NetBSD__)
251# define _LIBCPP_GET_C_LOCALE LC_C_LOCALE
252# else
253# define _LIBCPP_GET_C_LOCALE __cloc()
247254// Get the C locale object
248255_LIBCPP_EXPORTED_FROM_ABI locale_t __cloc();
249# define __cloc_defined
250#endif
256# define __cloc_defined
257# endif
251258
252259// __scan_keyword
253260// Scans [__b, __e) until a match is found in the basic_strings range
......@@ -368,7 +375,11 @@ struct _LIBCPP_EXPORTED_FROM_ABI __num_get_base {
368375 static const int __num_get_buf_sz = 40;
369376
370377 static int __get_base(ios_base&);
371 static const char __src[33];
378 static const char __src[33]; // "0123456789abcdefABCDEFxX+-pPiInN"
379 // count of leading characters in __src used for parsing integers ("012..X+-")
380 static const size_t __int_chr_cnt = 26;
381 // count of leading characters in __src used for parsing floating-point values ("012..-pP")
382 static const size_t __fp_chr_cnt = 28;
372383};
373384
374385_LIBCPP_EXPORTED_FROM_ABI void
......@@ -391,7 +402,7 @@ struct __num_get : protected __num_get_base {
391402 unsigned*& __g_end,
392403 unsigned& __dc,
393404 _CharT* __atoms);
394#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
405# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
395406 static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
396407 static int __stage2_int_loop(
397408 _CharT __ct,
......@@ -405,7 +416,7 @@ struct __num_get : protected __num_get_base {
405416 unsigned*& __g_end,
406417 _CharT* __atoms);
407418
408#else
419# else
409420 static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep) {
410421 locale __loc = __iob.getloc();
411422 const numpunct<_CharT>& __np = use_facet<numpunct<_CharT> >(__loc);
......@@ -431,7 +442,7 @@ private:
431442 template <typename _Tp>
432443 const _Tp* __do_widen_p(ios_base& __iob, _Tp* __atoms) const {
433444 locale __loc = __iob.getloc();
434 use_facet<ctype<_Tp> >(__loc).widen(__src, __src + 26, __atoms);
445 use_facet<ctype<_Tp> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
435446 return __atoms;
436447 }
437448
......@@ -440,25 +451,25 @@ private:
440451 (void)__atoms;
441452 return __src;
442453 }
443#endif
454# endif
444455};
445456
446#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
457# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
447458template <class _CharT>
448459string __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep) {
449460 locale __loc = __iob.getloc();
450 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 26, __atoms);
461 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __int_chr_cnt, __atoms);
451462 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
452463 __thousands_sep = __np.thousands_sep();
453464 return __np.grouping();
454465}
455#endif
466# endif
456467
457468template <class _CharT>
458469string __num_get<_CharT>::__stage2_float_prep(
459470 ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point, _CharT& __thousands_sep) {
460471 locale __loc = __iob.getloc();
461 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + 32, __atoms);
472 std::use_facet<ctype<_CharT> >(__loc).widen(__src, __src + __fp_chr_cnt, __atoms);
462473 const numpunct<_CharT>& __np = std::use_facet<numpunct<_CharT> >(__loc);
463474 __decimal_point = __np.decimal_point();
464475 __thousands_sep = __np.thousands_sep();
......@@ -467,16 +478,16 @@ string __num_get<_CharT>::__stage2_float_prep(
467478
468479template <class _CharT>
469480int
470#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
481# ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
471482__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
472483 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
473484 unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
474#else
485# else
475486__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
476487 unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
477488 unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
478489
479#endif
490# endif
480491{
481492 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25])) {
482493 *__a_end++ = __ct == __atoms[24] ? '+' : '-';
......@@ -490,7 +501,7 @@ __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*&
490501 }
491502 return 0;
492503 }
493 ptrdiff_t __f = std::find(__atoms, __atoms + 26, __ct) - __atoms;
504 ptrdiff_t __f = std::find(__atoms, __atoms + __int_chr_cnt, __ct) - __atoms;
494505 if (__f >= 24)
495506 return -1;
496507 switch (__base) {
......@@ -546,8 +557,8 @@ int __num_get<_CharT>::__stage2_float_loop(
546557 }
547558 return 0;
548559 }
549 ptrdiff_t __f = std::find(__atoms, __atoms + 32, __ct) - __atoms;
550 if (__f >= 32)
560 ptrdiff_t __f = std::find(__atoms, __atoms + __num_get_base::__fp_chr_cnt, __ct) - __atoms;
561 if (__f >= static_cast<ptrdiff_t>(__num_get_base::__fp_chr_cnt))
551562 return -1;
552563 char __x = __src[__f];
553564 if (__x == '-' || __x == '+') {
......@@ -575,9 +586,9 @@ int __num_get<_CharT>::__stage2_float_loop(
575586}
576587
577588extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<char>;
578#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
589# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
579590extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_get<wchar_t>;
580#endif
591# endif
581592
582593template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
583594class _LIBCPP_TEMPLATE_VIS num_get : public locale::facet, private __num_get<_CharT> {
......@@ -846,15 +857,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_signed(
846857 int __base = this->__get_base(__iob);
847858 // Stage 2
848859 char_type __thousands_sep;
849 const int __atoms_size = 26;
850#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
860 const int __atoms_size = __num_get_base::__int_chr_cnt;
861# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
851862 char_type __atoms1[__atoms_size];
852863 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
853864 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
854#else
865# else
855866 char_type __atoms[__atoms_size];
856867 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
857#endif
868# endif
858869 string __buf;
859870 __buf.resize(__buf.capacity());
860871 char* __a = &__buf[0];
......@@ -895,15 +906,15 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_unsigned(
895906 int __base = this->__get_base(__iob);
896907 // Stage 2
897908 char_type __thousands_sep;
898 const int __atoms_size = 26;
899#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
909 const int __atoms_size = __num_get_base::__int_chr_cnt;
910# ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
900911 char_type __atoms1[__atoms_size];
901912 const char_type* __atoms = this->__do_widen(__iob, __atoms1);
902913 string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
903#else
914# else
904915 char_type __atoms[__atoms_size];
905916 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
906#endif
917# endif
907918 string __buf;
908919 __buf.resize(__buf.capacity());
909920 char* __a = &__buf[0];
......@@ -942,7 +953,7 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point(
942953 iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, _Fp& __v) const {
943954 // Stage 1, nothing to do
944955 // Stage 2
945 char_type __atoms[32];
956 char_type __atoms[__num_get_base::__fp_chr_cnt];
946957 char_type __decimal_point;
947958 char_type __thousands_sep;
948959 string __grouping = this->__stage2_float_prep(__iob, __atoms, __decimal_point, __thousands_sep);
......@@ -951,10 +962,11 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point(
951962 char* __a = &__buf[0];
952963 char* __a_end = __a;
953964 unsigned __g[__num_get_base::__num_get_buf_sz];
954 unsigned* __g_end = __g;
955 unsigned __dc = 0;
956 bool __in_units = true;
957 char __exp = 'E';
965 unsigned* __g_end = __g;
966 unsigned __dc = 0;
967 bool __in_units = true;
968 char __exp = 'E';
969 bool __is_leading_parsed = false;
958970 for (; __b != __e; ++__b) {
959971 if (__a_end == __a + __buf.size()) {
960972 size_t __tmp = __buf.size();
......@@ -977,6 +989,21 @@ _InputIterator num_get<_CharT, _InputIterator>::__do_get_floating_point(
977989 __dc,
978990 __atoms))
979991 break;
992
993 // the leading character excluding the sign must be a decimal digit
994 if (!__is_leading_parsed) {
995 if (__a_end - __a >= 1 && __a[0] != '-' && __a[0] != '+') {
996 if (('0' <= __a[0] && __a[0] <= '9') || __a[0] == '.')
997 __is_leading_parsed = true;
998 else
999 break;
1000 } else if (__a_end - __a >= 2 && (__a[0] == '-' || __a[0] == '+')) {
1001 if (('0' <= __a[1] && __a[1] <= '9') || __a[1] == '.')
1002 __is_leading_parsed = true;
1003 else
1004 break;
1005 }
1006 }
9801007 }
9811008 if (__grouping.size() != 0 && __in_units && __g_end - __g < __num_get_base::__num_get_buf_sz)
9821009 *__g_end++ = __dc;
......@@ -996,10 +1023,11 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(
9961023 // Stage 1
9971024 int __base = 16;
9981025 // Stage 2
999 char_type __atoms[26];
1026 char_type __atoms[__num_get_base::__int_chr_cnt];
10001027 char_type __thousands_sep = char_type();
10011028 string __grouping;
1002 std::use_facet<ctype<_CharT> >(__iob.getloc()).widen(__num_get_base::__src, __num_get_base::__src + 26, __atoms);
1029 std::use_facet<ctype<_CharT> >(__iob.getloc())
1030 .widen(__num_get_base::__src, __num_get_base::__src + __num_get_base::__int_chr_cnt, __atoms);
10031031 string __buf;
10041032 __buf.resize(__buf.capacity());
10051033 char* __a = &__buf[0];
......@@ -1029,9 +1057,9 @@ _InputIterator num_get<_CharT, _InputIterator>::do_get(
10291057}
10301058
10311059extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<char>;
1032#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1060# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
10331061extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_get<wchar_t>;
1034#endif
1062# endif
10351063
10361064struct _LIBCPP_EXPORTED_FROM_ABI __num_put_base {
10371065protected:
......@@ -1147,9 +1175,9 @@ void __num_put<_CharT>::__widen_and_group_float(
11471175}
11481176
11491177extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<char>;
1150#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1178# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
11511179extern template struct _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __num_put<wchar_t>;
1152#endif
1180# endif
11531181
11541182template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
11551183class _LIBCPP_TEMPLATE_VIS num_put : public locale::facet, private __num_put<_CharT> {
......@@ -1434,9 +1462,9 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, char_ty
14341462}
14351463
14361464extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<char>;
1437#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1465# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
14381466extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS num_put<wchar_t>;
1439#endif
1467# endif
14401468
14411469template <class _CharT, class _InputIterator>
14421470_LIBCPP_HIDE_FROM_ABI int __get_up_to_n_digits(
......@@ -1501,7 +1529,7 @@ _LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__x() const;
15011529template <>
15021530_LIBCPP_EXPORTED_FROM_ABI const string& __time_get_c_storage<char>::__X() const;
15031531
1504#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1532# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
15051533template <>
15061534_LIBCPP_EXPORTED_FROM_ABI const wstring* __time_get_c_storage<wchar_t>::__weeks() const;
15071535template <>
......@@ -1516,7 +1544,7 @@ template <>
15161544_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__x() const;
15171545template <>
15181546_LIBCPP_EXPORTED_FROM_ABI const wstring& __time_get_c_storage<wchar_t>::__X() const;
1519#endif
1547# endif
15201548
15211549template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
15221550class _LIBCPP_TEMPLATE_VIS time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> {
......@@ -1970,9 +1998,9 @@ _InputIterator time_get<_CharT, _InputIterator>::do_get(
19701998}
19711999
19722000extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<char>;
1973#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2001# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
19742002extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get<wchar_t>;
1975#endif
2003# endif
19762004
19772005class _LIBCPP_EXPORTED_FROM_ABI __time_get {
19782006protected:
......@@ -2008,31 +2036,32 @@ private:
20082036 string_type __analyze(char __fmt, const ctype<_CharT>&);
20092037};
20102038
2011#define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
2012 template <> \
2013 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
2014 template <> \
2015 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2016 template <> \
2017 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2018 template <> \
2019 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2020 template <> \
2021 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \
2022 char, const ctype<_CharT>&); \
2023 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
2024 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2025 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2026 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2027 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \
2028 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
2029 /**/
2039# define _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(_CharT) \
2040 template <> \
2041 _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() const; \
2042 template <> \
2043 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2044 template <> \
2045 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2046 template <> \
2047 _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2048 template <> \
2049 _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type __time_get_storage<_CharT>::__analyze( \
2050 char, const ctype<_CharT>&); \
2051 extern template _LIBCPP_EXPORTED_FROM_ABI time_base::dateorder __time_get_storage<_CharT>::__do_date_order() \
2052 const; \
2053 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const char*); \
2054 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::__time_get_storage(const string&); \
2055 extern template _LIBCPP_EXPORTED_FROM_ABI void __time_get_storage<_CharT>::init(const ctype<_CharT>&); \
2056 extern template _LIBCPP_EXPORTED_FROM_ABI __time_get_storage<_CharT>::string_type \
2057 __time_get_storage<_CharT>::__analyze(char, const ctype<_CharT>&); \
2058 /**/
20302059
20312060_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
2032#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2061# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
20332062_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2034#endif
2035#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
2063# endif
2064# undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
20362065
20372066template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
20382067class _LIBCPP_TEMPLATE_VIS time_get_byname
......@@ -2065,9 +2094,9 @@ private:
20652094};
20662095
20672096extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<char>;
2068#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2097# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
20692098extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_get_byname<wchar_t>;
2070#endif
2099# endif
20712100
20722101class _LIBCPP_EXPORTED_FROM_ABI __time_put {
20732102 locale_t __loc_;
......@@ -2078,9 +2107,9 @@ protected:
20782107 __time_put(const string& __nm);
20792108 ~__time_put();
20802109 void __do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const;
2081#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2110# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
20822111 void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const;
2083#endif
2112# endif
20842113};
20852114
20862115template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
......@@ -2154,9 +2183,9 @@ _OutputIterator time_put<_CharT, _OutputIterator>::do_put(
21542183}
21552184
21562185extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<char>;
2157#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2186# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
21582187extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put<wchar_t>;
2159#endif
2188# endif
21602189
21612190template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
21622191class _LIBCPP_TEMPLATE_VIS time_put_byname : public time_put<_CharT, _OutputIterator> {
......@@ -2172,9 +2201,9 @@ protected:
21722201};
21732202
21742203extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<char>;
2175#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2204# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
21762205extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS time_put_byname<wchar_t>;
2177#endif
2206# endif
21782207
21792208// money_base
21802209
......@@ -2239,10 +2268,10 @@ const bool moneypunct<_CharT, _International>::intl;
22392268
22402269extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, false>;
22412270extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<char, true>;
2242#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2271# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
22432272extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, false>;
22442273extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct<wchar_t, true>;
2245#endif
2274# endif
22462275
22472276// moneypunct_byname
22482277
......@@ -2297,14 +2326,14 @@ _LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<char, true>::init(const char*);
22972326extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, false>;
22982327extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<char, true>;
22992328
2300#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2329# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23012330template <>
23022331_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, false>::init(const char*);
23032332template <>
23042333_LIBCPP_EXPORTED_FROM_ABI void moneypunct_byname<wchar_t, true>::init(const char*);
23052334extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, false>;
23062335extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS moneypunct_byname<wchar_t, true>;
2307#endif
2336# endif
23082337
23092338// money_get
23102339
......@@ -2365,9 +2394,9 @@ void __money_get<_CharT>::__gather_info(
23652394}
23662395
23672396extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<char>;
2368#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2397# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23692398extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_get<wchar_t>;
2370#endif
2399# endif
23712400
23722401template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
23732402class _LIBCPP_TEMPLATE_VIS money_get : public locale::facet, private __money_get<_CharT> {
......@@ -2675,9 +2704,9 @@ _InputIterator money_get<_CharT, _InputIterator>::do_get(
26752704}
26762705
26772706extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<char>;
2678#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2707# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
26792708extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_get<wchar_t>;
2680#endif
2709# endif
26812710
26822711// money_put
26832712
......@@ -2853,9 +2882,9 @@ void __money_put<_CharT>::__format(
28532882}
28542883
28552884extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<char>;
2856#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
2885# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
28572886extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS __money_put<wchar_t>;
2858#endif
2887# endif
28592888
28602889template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >
28612890class _LIBCPP_TEMPLATE_VIS money_put : public locale::facet, private __money_put<_CharT> {
......@@ -2999,9 +3028,9 @@ _OutputIterator money_put<_CharT, _OutputIterator>::do_put(
29993028}
30003029
30013030extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<char>;
3002#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3031# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
30033032extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS money_put<wchar_t>;
3004#endif
3033# endif
30053034
30063035// messages
30073036
......@@ -3045,18 +3074,18 @@ locale::id messages<_CharT>::id;
30453074
30463075template <class _CharT>
30473076typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __nm, const locale&) const {
3048#ifdef _LIBCPP_HAS_CATOPEN
3077# ifdef _LIBCPP_HAS_CATOPEN
30493078 return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE);
3050#else // !_LIBCPP_HAS_CATOPEN
3079# else // !_LIBCPP_HAS_CATOPEN
30513080 (void)__nm;
30523081 return -1;
3053#endif // _LIBCPP_HAS_CATOPEN
3082# endif // _LIBCPP_HAS_CATOPEN
30543083}
30553084
30563085template <class _CharT>
30573086typename messages<_CharT>::string_type
30583087messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const {
3059#ifdef _LIBCPP_HAS_CATOPEN
3088# ifdef _LIBCPP_HAS_CATOPEN
30603089 string __ndflt;
30613090 __narrow_to_utf8<sizeof(char_type) * __CHAR_BIT__>()(
30623091 std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());
......@@ -3066,27 +3095,27 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type&
30663095 string_type __w;
30673096 __widen_from_utf8<sizeof(char_type) * __CHAR_BIT__>()(std::back_inserter(__w), __n, __n + std::strlen(__n));
30683097 return __w;
3069#else // !_LIBCPP_HAS_CATOPEN
3098# else // !_LIBCPP_HAS_CATOPEN
30703099 (void)__c;
30713100 (void)__set;
30723101 (void)__msgid;
30733102 return __dflt;
3074#endif // _LIBCPP_HAS_CATOPEN
3103# endif // _LIBCPP_HAS_CATOPEN
30753104}
30763105
30773106template <class _CharT>
30783107void messages<_CharT>::do_close(catalog __c) const {
3079#ifdef _LIBCPP_HAS_CATOPEN
3108# ifdef _LIBCPP_HAS_CATOPEN
30803109 catclose((nl_catd)__c);
3081#else // !_LIBCPP_HAS_CATOPEN
3110# else // !_LIBCPP_HAS_CATOPEN
30823111 (void)__c;
3083#endif // _LIBCPP_HAS_CATOPEN
3112# endif // _LIBCPP_HAS_CATOPEN
30843113}
30853114
30863115extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<char>;
3087#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3116# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
30883117extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages<wchar_t>;
3089#endif
3118# endif
30903119
30913120template <class _CharT>
30923121class _LIBCPP_TEMPLATE_VIS messages_byname : public messages<_CharT> {
......@@ -3103,9 +3132,11 @@ protected:
31033132};
31043133
31053134extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<char>;
3106#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
3135# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
31073136extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS messages_byname<wchar_t>;
3108#endif
3137# endif
3138
3139# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
31093140
31103141template <class _Codecvt,
31113142 class _Elem = wchar_t,
......@@ -3125,25 +3156,25 @@ private:
31253156 state_type __cvtstate_;
31263157 size_t __cvtcount_;
31273158
3128 wstring_convert(const wstring_convert& __wc);
3129 wstring_convert& operator=(const wstring_convert& __wc);
3130
31313159public:
3132#ifndef _LIBCPP_CXX03_LANG
3160# ifndef _LIBCPP_CXX03_LANG
31333161 _LIBCPP_HIDE_FROM_ABI wstring_convert() : wstring_convert(new _Codecvt) {}
31343162 _LIBCPP_HIDE_FROM_ABI explicit wstring_convert(_Codecvt* __pcvt);
3135#else
3163# else
31363164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_EXPLICIT_SINCE_CXX14 wstring_convert(_Codecvt* __pcvt = new _Codecvt);
3137#endif
3165# endif
31383166
31393167 _LIBCPP_HIDE_FROM_ABI wstring_convert(_Codecvt* __pcvt, state_type __state);
31403168 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
31413169 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string());
3142#ifndef _LIBCPP_CXX03_LANG
3170# ifndef _LIBCPP_CXX03_LANG
31433171 _LIBCPP_HIDE_FROM_ABI wstring_convert(wstring_convert&& __wc);
3144#endif
3172# endif
31453173 _LIBCPP_HIDE_FROM_ABI ~wstring_convert();
31463174
3175 wstring_convert(const wstring_convert& __wc) = delete;
3176 wstring_convert& operator=(const wstring_convert& __wc) = delete;
3177
31473178 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(char __byte) { return from_bytes(&__byte, &__byte + 1); }
31483179 _LIBCPP_HIDE_FROM_ABI wide_string from_bytes(const char* __ptr) {
31493180 return from_bytes(__ptr, __ptr + char_traits<char>::length(__ptr));
......@@ -3183,7 +3214,7 @@ wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(
31833214 __cvtptr_ = new _Codecvt;
31843215}
31853216
3186#ifndef _LIBCPP_CXX03_LANG
3217# ifndef _LIBCPP_CXX03_LANG
31873218
31883219template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
31893220inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert(wstring_convert&& __wc)
......@@ -3195,7 +3226,7 @@ inline wstring_convert<_Codecvt, _Elem, _WideAlloc, _ByteAlloc>::wstring_convert
31953226 __wc.__cvtptr_ = nullptr;
31963227}
31973228
3198#endif // _LIBCPP_CXX03_LANG
3229# endif // _LIBCPP_CXX03_LANG
31993230
32003231_LIBCPP_SUPPRESS_DEPRECATED_PUSH
32013232template <class _Codecvt, class _Elem, class _WideAlloc, class _ByteAlloc>
......@@ -3348,18 +3379,15 @@ private:
33483379 bool __owns_ib_;
33493380 bool __always_noconv_;
33503381
3351 wbuffer_convert(const wbuffer_convert&);
3352 wbuffer_convert& operator=(const wbuffer_convert&);
3353
33543382public:
3355#ifndef _LIBCPP_CXX03_LANG
3383# ifndef _LIBCPP_CXX03_LANG
33563384 _LIBCPP_HIDE_FROM_ABI wbuffer_convert() : wbuffer_convert(nullptr) {}
33573385 explicit _LIBCPP_HIDE_FROM_ABI
33583386 wbuffer_convert(streambuf* __bytebuf, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3359#else
3387# else
33603388 _LIBCPP_EXPLICIT_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI
33613389 wbuffer_convert(streambuf* __bytebuf = nullptr, _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
3362#endif
3390# endif
33633391
33643392 _LIBCPP_HIDE_FROM_ABI ~wbuffer_convert();
33653393
......@@ -3370,6 +3398,9 @@ public:
33703398 return __r;
33713399 }
33723400
3401 wbuffer_convert(const wbuffer_convert&) = delete;
3402 wbuffer_convert& operator=(const wbuffer_convert&) = delete;
3403
33733404 _LIBCPP_HIDE_FROM_ABI state_type state() const { return __st_; }
33743405
33753406protected:
......@@ -3712,12 +3743,16 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>* wbuffer_convert<_Codecvt, _Elem, _Tr>::__
37123743
37133744_LIBCPP_SUPPRESS_DEPRECATED_POP
37143745
3746# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT)
3747
37153748_LIBCPP_END_NAMESPACE_STD
37163749
37173750_LIBCPP_POP_MACROS
37183751
37193752// NOLINTEND(libcpp-robust-against-adl)
37203753
3754#endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3755
37213756#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
37223757# include <atomic>
37233758# include <concepts>
lib/libcxx/include/locale.h-4
......@@ -35,10 +35,6 @@ Functions:
3535
3636#include <__config>
3737
38#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
39# error "<locale.h> is not supported since libc++ has been configured without support for localization."
40#endif
41
4238#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4339# pragma GCC system_header
4440#endif
lib/libcxx/include/map+58-76
......@@ -574,8 +574,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
574574#include <__algorithm/equal.h>
575575#include <__algorithm/lexicographical_compare.h>
576576#include <__algorithm/lexicographical_compare_three_way.h>
577#include <__assert> // all public C++ headers provide the assertion handler
578#include <__availability>
577#include <__assert>
579578#include <__config>
580579#include <__functional/binary_function.h>
581580#include <__functional/is_transparent.h>
......@@ -642,7 +641,7 @@ public:
642641 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {
643642 return static_cast<const _Compare&>(*this)(__x, __y.__get_value().first);
644643 }
645 _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) {
644 _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
646645 using std::swap;
647646 swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y));
648647 }
......@@ -680,7 +679,7 @@ public:
680679 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const {
681680 return __comp_(__x, __y.__get_value().first);
682681 }
683 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable<_Compare>::value) {
682 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) {
684683 using std::swap;
685684 swap(__comp_, __y.__comp_);
686685 }
......@@ -716,8 +715,6 @@ public:
716715private:
717716 allocator_type& __na_;
718717
719 __map_node_destructor& operator=(const __map_node_destructor&);
720
721718public:
722719 bool __first_constructed;
723720 bool __second_constructed;
......@@ -736,6 +733,8 @@ public:
736733 }
737734#endif // _LIBCPP_CXX03_LANG
738735
736 __map_node_destructor& operator=(const __map_node_destructor&) = delete;
737
739738 _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
740739 if (__second_constructed)
741740 __alloc_traits::destroy(__na_, std::addressof(__p->__value_.__get_value().second));
......@@ -803,13 +802,12 @@ public:
803802 return *this;
804803 }
805804
806 template <class _ValueTp, class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> >
805 template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>
807806 _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) {
808807 __ref() = std::forward<_ValueTp>(__v);
809808 return *this;
810809 }
811810
812private:
813811 __value_type() = delete;
814812 ~__value_type() = delete;
815813 __value_type(const __value_type&) = delete;
......@@ -831,11 +829,10 @@ public:
831829 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
832830 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
833831
834private:
835 __value_type();
836 __value_type(__value_type const&);
837 __value_type& operator=(__value_type const&);
838 ~__value_type();
832 __value_type() = delete;
833 __value_type(__value_type const&) = delete;
834 __value_type& operator=(__value_type const&) = delete;
835 ~__value_type() = delete;
839836};
840837
841838#endif // _LIBCPP_CXX03_LANG
......@@ -975,7 +972,7 @@ public:
975972 typedef value_type& reference;
976973 typedef const value_type& const_reference;
977974
978 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
975 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
979976 "Allocator::value_type must be same type as value_type");
980977
981978 class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {
......@@ -1000,9 +997,7 @@ private:
1000997 typedef typename __base::__node_traits __node_traits;
1001998 typedef allocator_traits<allocator_type> __alloc_traits;
1002999
1003 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1004 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1005 "original allocator");
1000 static_assert(__check_valid_allocator<allocator_type>::value, "");
10061001
10071002 __base __tree_;
10081003
......@@ -1093,12 +1088,12 @@ public:
10931088
10941089#ifndef _LIBCPP_CXX03_LANG
10951090
1096 _LIBCPP_HIDE_FROM_ABI map(map&& __m) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
1091 _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value)
10971092 : __tree_(std::move(__m.__tree_)) {}
10981093
10991094 _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a);
11001095
1101 _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) {
1096 _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {
11021097 __tree_ = std::move(__m.__tree_);
11031098 return *this;
11041099 }
......@@ -1149,7 +1144,7 @@ public:
11491144 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
11501145 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
11511146
1152 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1147 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
11531148 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
11541149 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
11551150
......@@ -1176,12 +1171,12 @@ public:
11761171 return __tree_.__emplace_hint_unique(__p.__i_, std::forward<_Args>(__args)...);
11771172 }
11781173
1179 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1174 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
11801175 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __p) {
11811176 return __tree_.__insert_unique(std::forward<_Pp>(__p));
11821177 }
11831178
1184 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1179 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
11851180 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
11861181 return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p));
11871182 }
......@@ -1360,18 +1355,16 @@ public:
13601355 }
13611356#endif
13621357
1363 _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) {
1364 __tree_.swap(__m.__tree_);
1365 }
1358 _LIBCPP_HIDE_FROM_ABI void swap(map& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); }
13661359
13671360 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
13681361 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
13691362#if _LIBCPP_STD_VER >= 14
1370 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1363 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13711364 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
13721365 return __tree_.find(__k);
13731366 }
1374 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1367 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13751368 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
13761369 return __tree_.find(__k);
13771370 }
......@@ -1379,7 +1372,7 @@ public:
13791372
13801373 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
13811374#if _LIBCPP_STD_VER >= 14
1382 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1375 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13831376 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
13841377 return __tree_.__count_multi(__k);
13851378 }
......@@ -1387,7 +1380,7 @@ public:
13871380
13881381#if _LIBCPP_STD_VER >= 20
13891382 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1390 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1383 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13911384 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
13921385 return find(__k) != end();
13931386 }
......@@ -1396,12 +1389,12 @@ public:
13961389 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
13971390 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
13981391#if _LIBCPP_STD_VER >= 14
1399 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1392 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14001393 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
14011394 return __tree_.lower_bound(__k);
14021395 }
14031396
1404 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1397 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14051398 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
14061399 return __tree_.lower_bound(__k);
14071400 }
......@@ -1410,11 +1403,11 @@ public:
14101403 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
14111404 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
14121405#if _LIBCPP_STD_VER >= 14
1413 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1406 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14141407 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
14151408 return __tree_.upper_bound(__k);
14161409 }
1417 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1410 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14181411 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
14191412 return __tree_.upper_bound(__k);
14201413 }
......@@ -1427,11 +1420,11 @@ public:
14271420 return __tree_.__equal_range_unique(__k);
14281421 }
14291422#if _LIBCPP_STD_VER >= 14
1430 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1423 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14311424 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
14321425 return __tree_.__equal_range_multi(__k);
14331426 }
1434 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1427 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
14351428 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
14361429 return __tree_.__equal_range_multi(__k);
14371430 }
......@@ -1478,8 +1471,9 @@ template <class _Key,
14781471 class _Allocator = allocator<pair<const _Key, _Tp>>,
14791472 class = enable_if_t<!__is_allocator<_Compare>::value, void>,
14801473 class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1481map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
1482 -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
1474map(initializer_list<pair<_Key, _Tp>>,
1475 _Compare = _Compare(),
1476 _Allocator = _Allocator()) -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
14831477
14841478template <class _InputIterator,
14851479 class _Allocator,
......@@ -1498,8 +1492,8 @@ map(from_range_t, _Range&&, _Allocator)
14981492# endif
14991493
15001494template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1501map(initializer_list<pair<_Key, _Tp>>, _Allocator)
1502 -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
1495map(initializer_list<pair<_Key, _Tp>>,
1496 _Allocator) -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
15031497#endif
15041498
15051499#ifndef _LIBCPP_CXX03_LANG
......@@ -1623,12 +1617,7 @@ operator<=(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp,
16231617template <class _Key, class _Tp, class _Compare, class _Allocator>
16241618_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
16251619operator<=>(const map<_Key, _Tp, _Compare, _Allocator>& __x, const map<_Key, _Tp, _Compare, _Allocator>& __y) {
1626 return std::lexicographical_compare_three_way(
1627 __x.begin(),
1628 __x.end(),
1629 __y.begin(),
1630 __y.end(),
1631 std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
1620 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
16321621}
16331622
16341623#endif // #if _LIBCPP_STD_VER <= 17
......@@ -1660,7 +1649,8 @@ public:
16601649 typedef value_type& reference;
16611650 typedef const value_type& const_reference;
16621651
1663 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1652 static_assert(__check_valid_allocator<allocator_type>::value, "");
1653 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
16641654 "Allocator::value_type must be same type as value_type");
16651655
16661656 class _LIBCPP_TEMPLATE_VIS value_compare : public __binary_function<value_type, value_type, bool> {
......@@ -1685,10 +1675,6 @@ private:
16851675 typedef typename __base::__node_traits __node_traits;
16861676 typedef allocator_traits<allocator_type> __alloc_traits;
16871677
1688 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1689 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1690 "original allocator");
1691
16921678 __base __tree_;
16931679
16941680public:
......@@ -1781,12 +1767,12 @@ public:
17811767
17821768#ifndef _LIBCPP_CXX03_LANG
17831769
1784 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
1770 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m) noexcept(is_nothrow_move_constructible<__base>::value)
17851771 : __tree_(std::move(__m.__tree_)) {}
17861772
17871773 _LIBCPP_HIDE_FROM_ABI multimap(multimap&& __m, const allocator_type& __a);
17881774
1789 _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) {
1775 _LIBCPP_HIDE_FROM_ABI multimap& operator=(multimap&& __m) noexcept(is_nothrow_move_assignable<__base>::value) {
17901776 __tree_ = std::move(__m.__tree_);
17911777 return *this;
17921778 }
......@@ -1838,7 +1824,7 @@ public:
18381824 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
18391825 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
18401826
1841 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1827 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
18421828 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
18431829 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
18441830
......@@ -1858,12 +1844,12 @@ public:
18581844 return __tree_.__emplace_hint_multi(__p.__i_, std::forward<_Args>(__args)...);
18591845 }
18601846
1861 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
1847 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
18621848 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) {
18631849 return __tree_.__insert_multi(std::forward<_Pp>(__p));
18641850 }
18651851
1866 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value>>
1852 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
18671853 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) {
18681854 return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p));
18691855 }
......@@ -1952,18 +1938,18 @@ public:
19521938
19531939 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
19541940
1955 _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) {
1941 _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
19561942 __tree_.swap(__m.__tree_);
19571943 }
19581944
19591945 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
19601946 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
19611947#if _LIBCPP_STD_VER >= 14
1962 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1948 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19631949 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
19641950 return __tree_.find(__k);
19651951 }
1966 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1952 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19671953 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
19681954 return __tree_.find(__k);
19691955 }
......@@ -1971,7 +1957,7 @@ public:
19711957
19721958 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
19731959#if _LIBCPP_STD_VER >= 14
1974 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1960 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19751961 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
19761962 return __tree_.__count_multi(__k);
19771963 }
......@@ -1979,7 +1965,7 @@ public:
19791965
19801966#if _LIBCPP_STD_VER >= 20
19811967 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1982 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1968 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19831969 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
19841970 return find(__k) != end();
19851971 }
......@@ -1988,12 +1974,12 @@ public:
19881974 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
19891975 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
19901976#if _LIBCPP_STD_VER >= 14
1991 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1977 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19921978 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
19931979 return __tree_.lower_bound(__k);
19941980 }
19951981
1996 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1982 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
19971983 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
19981984 return __tree_.lower_bound(__k);
19991985 }
......@@ -2002,11 +1988,11 @@ public:
20021988 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
20031989 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
20041990#if _LIBCPP_STD_VER >= 14
2005 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1991 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20061992 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
20071993 return __tree_.upper_bound(__k);
20081994 }
2009 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1995 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20101996 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
20111997 return __tree_.upper_bound(__k);
20121998 }
......@@ -2019,11 +2005,11 @@ public:
20192005 return __tree_.__equal_range_multi(__k);
20202006 }
20212007#if _LIBCPP_STD_VER >= 14
2022 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2008 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20232009 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
20242010 return __tree_.__equal_range_multi(__k);
20252011 }
2026 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
2012 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
20272013 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
20282014 return __tree_.__equal_range_multi(__k);
20292015 }
......@@ -2064,8 +2050,9 @@ template <class _Key,
20642050 class _Allocator = allocator<pair<const _Key, _Tp>>,
20652051 class = enable_if_t<!__is_allocator<_Compare>::value, void>,
20662052 class = enable_if_t<__is_allocator<_Allocator>::value, void>>
2067multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
2068 -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
2053multimap(initializer_list<pair<_Key, _Tp>>,
2054 _Compare = _Compare(),
2055 _Allocator = _Allocator()) -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
20692056
20702057template <class _InputIterator,
20712058 class _Allocator,
......@@ -2084,8 +2071,8 @@ multimap(from_range_t, _Range&&, _Allocator)
20842071# endif
20852072
20862073template <class _Key, class _Tp, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
2087multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
2088 -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
2074multimap(initializer_list<pair<_Key, _Tp>>,
2075 _Allocator) -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
20892076#endif
20902077
20912078#ifndef _LIBCPP_CXX03_LANG
......@@ -2144,12 +2131,7 @@ template <class _Key, class _Tp, class _Compare, class _Allocator>
21442131_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<pair<const _Key, _Tp>>
21452132operator<=>(const multimap<_Key, _Tp, _Compare, _Allocator>& __x,
21462133 const multimap<_Key, _Tp, _Compare, _Allocator>& __y) {
2147 return std::lexicographical_compare_three_way(
2148 __x.begin(),
2149 __x.end(),
2150 __y.begin(),
2151 __y.end(),
2152 std::__synth_three_way<pair<const _Key, _Tp>, pair<const _Key, _Tp>>);
2134 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
21532135}
21542136
21552137#endif // #if _LIBCPP_STD_VER <= 17
lib/libcxx/include/math.h+4-4
......@@ -388,22 +388,22 @@ namespace __math {
388388
389389// template on non-double overloads to make them weaker than same overloads from MSVC runtime
390390template <class = int>
391_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
391_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(float __x) _NOEXCEPT {
392392 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
393393}
394394
395395template <class = int>
396_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {
396_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(double __x) _NOEXCEPT {
397397 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
398398}
399399
400400template <class = int>
401_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {
401_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(long double __x) _NOEXCEPT {
402402 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, __x);
403403}
404404
405405template <class _A1, std::__enable_if_t<std::is_integral<_A1>::value, int> = 0>
406_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
406_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI int fpclassify(_A1 __x) _NOEXCEPT {
407407 return __x == 0 ? FP_ZERO : FP_NORMAL;
408408}
409409
lib/libcxx/include/mdspan+29-8
......@@ -20,6 +20,10 @@ namespace std {
2020 template<class IndexType, size_t Rank>
2121 using dextents = see below;
2222
23 // [mdspan.extents.dims], alias template dims
24 template<size_t Rank, class IndexType = size_t>
25 using dims = see below; // since C++26
26
2327 // [mdspan.layout], layout mapping
2428 struct layout_left;
2529 struct layout_right;
......@@ -370,7 +374,11 @@ namespace std {
370374 template<class ElementType, class... Integrals>
371375 requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
372376 explicit mdspan(ElementType*, Integrals...)
373 -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>;
377 -> mdspan<ElementType, dextents<size_t, sizeof...(Integrals)>>; // until C++26
378 template<class ElementType, class... Integrals>
379 requires((is_convertible_v<Integrals, size_t> && ...) && sizeof...(Integrals) > 0)
380 explicit mdspan(ElementType*, Integrals...)
381 -> mdspan<ElementType, extents<size_t, maybe-static-ext<Integrals>...>>; // since C++26
374382
375383 template<class ElementType, class OtherIndexType, size_t N>
376384 mdspan(ElementType*, span<OtherIndexType, N>)
......@@ -401,17 +409,30 @@ namespace std {
401409#define _LIBCPP_MDSPAN
402410
403411#include <__config>
404#include <__fwd/mdspan.h>
405#include <__mdspan/default_accessor.h>
406#include <__mdspan/extents.h>
407#include <__mdspan/layout_left.h>
408#include <__mdspan/layout_right.h>
409#include <__mdspan/layout_stride.h>
410#include <__mdspan/mdspan.h>
412
413#if _LIBCPP_STD_VER >= 23
414# include <__fwd/mdspan.h>
415# include <__mdspan/default_accessor.h>
416# include <__mdspan/extents.h>
417# include <__mdspan/layout_left.h>
418# include <__mdspan/layout_right.h>
419# include <__mdspan/layout_stride.h>
420# include <__mdspan/mdspan.h>
421#endif
422
411423#include <version>
412424
413425#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
414426# pragma GCC system_header
415427#endif
416428
429#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
430# include <array>
431# include <cinttypes>
432# include <concepts>
433# include <cstddef>
434# include <limits>
435# include <span>
436#endif
437
417438#endif // _LIBCPP_MDSPAN
lib/libcxx/include/memory+44-19
......@@ -88,6 +88,9 @@ struct allocator_traits
8888 static pointer allocate(allocator_type& a, size_type n); // constexpr and [[nodiscard]] in C++20
8989 static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); // constexpr and [[nodiscard]] in C++20
9090
91 [[nodiscard]] static constexpr allocation_result<pointer, size_type>
92 allocate_at_least(Alloc& a, size_type n); // Since C++23
93
9194 static void deallocate(allocator_type& a, pointer p, size_type n) noexcept; // constexpr in C++20
9295
9396 template <class T, class... Args>
......@@ -100,15 +103,11 @@ struct allocator_traits
100103 static allocator_type select_on_container_copy_construction(const allocator_type& a); // constexpr in C++20
101104};
102105
103template<class Pointer>
106template<class Pointer, class SizeType = size_t>
104107struct allocation_result {
105108 Pointer ptr;
106 size_t count;
107}; // since C++23
108
109template<class Allocator>
110[[nodiscard]] constexpr allocation_result<typename allocator_traits<Allocator>::pointer>
111 allocate_at_least(Allocator& a, size_t n); // since C++23
109 SizeType count;
110}; // Since C++23
112111
113112template <>
114113class allocator<void> // removed in C++20
......@@ -452,7 +451,8 @@ public:
452451 constexpr unique_ptr& operator=(nullptr_t) noexcept; // constexpr since C++23
453452
454453 // observers
455 typename constexpr add_lvalue_reference<T>::type operator*() const; // constexpr since C++23
454 constexpr
455 add_lvalue_reference<T>::type operator*() const noexcept(see below); // constexpr since C++23
456456 constexpr pointer operator->() const noexcept; // constexpr since C++23
457457 constexpr pointer get() const noexcept; // constexpr since C++23
458458 constexpr deleter_type& get_deleter() noexcept; // constexpr since C++23
......@@ -912,40 +912,65 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space);
912912template<size_t N, class T>
913913[[nodiscard]] constexpr T* assume_aligned(T* ptr); // since C++20
914914
915// [out.ptr.t], class template out_ptr_t
916template<class Smart, class Pointer, class... Args>
917 class out_ptr_t; // since c++23
918
919// [out.ptr], function template out_ptr
920template<class Pointer = void, class Smart, class... Args>
921 auto out_ptr(Smart& s, Args&&... args); // since c++23
922
923// [inout.ptr.t], class template inout_ptr_t
924template<class Smart, class Pointer, class... Args>
925 class inout_ptr_t; // since c++23
926
927// [inout.ptr], function template inout_ptr
928template<class Pointer = void, class Smart, class... Args>
929 auto inout_ptr(Smart& s, Args&&... args); // since c++23
930
915931} // std
916932
917933*/
918934
919935// clang-format on
920936
921#include <__assert> // all public C++ headers provide the assertion handler
922937#include <__config>
923938#include <__memory/addressof.h>
924939#include <__memory/align.h>
925#include <__memory/allocate_at_least.h>
926#include <__memory/allocation_guard.h>
927940#include <__memory/allocator.h>
928941#include <__memory/allocator_arg_t.h>
929942#include <__memory/allocator_traits.h>
930#include <__memory/assume_aligned.h>
931943#include <__memory/auto_ptr.h>
932#include <__memory/compressed_pair.h>
933#include <__memory/concepts.h>
934#include <__memory/construct_at.h>
944#include <__memory/inout_ptr.h>
945#include <__memory/out_ptr.h>
935946#include <__memory/pointer_traits.h>
936#include <__memory/ranges_construct_at.h>
937#include <__memory/ranges_uninitialized_algorithms.h>
938947#include <__memory/raw_storage_iterator.h>
939948#include <__memory/shared_ptr.h>
940949#include <__memory/temporary_buffer.h>
941950#include <__memory/uninitialized_algorithms.h>
942951#include <__memory/unique_ptr.h>
943952#include <__memory/uses_allocator.h>
944#include <__memory/uses_allocator_construction.h>
945#include <version>
946953
947954// standard-mandated includes
948955
956#if _LIBCPP_STD_VER >= 17
957# include <__memory/construct_at.h>
958#endif
959
960#if _LIBCPP_STD_VER >= 20
961# include <__memory/assume_aligned.h>
962# include <__memory/concepts.h>
963# include <__memory/ranges_construct_at.h>
964# include <__memory/ranges_uninitialized_algorithms.h>
965# include <__memory/uses_allocator_construction.h>
966#endif
967
968#if _LIBCPP_STD_VER >= 23
969# include <__memory/allocate_at_least.h>
970#endif
971
972#include <version>
973
949974// [memory.syn]
950975#include <compare>
951976
lib/libcxx/include/memory_resource+20-6
......@@ -50,18 +50,32 @@ namespace std::pmr {
5050 */
5151
5252#include <__config>
53#include <__memory_resource/memory_resource.h>
54#include <__memory_resource/monotonic_buffer_resource.h>
55#include <__memory_resource/polymorphic_allocator.h>
56#include <__memory_resource/pool_options.h>
57#include <__memory_resource/synchronized_pool_resource.h>
58#include <__memory_resource/unsynchronized_pool_resource.h>
53
54#if _LIBCPP_STD_VER >= 17
55# include <__memory_resource/memory_resource.h>
56# include <__memory_resource/monotonic_buffer_resource.h>
57# include <__memory_resource/polymorphic_allocator.h>
58# include <__memory_resource/pool_options.h>
59# include <__memory_resource/synchronized_pool_resource.h>
60# include <__memory_resource/unsynchronized_pool_resource.h>
61#endif
62
5963#include <version>
6064
6165#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
6266# pragma GCC system_header
6367#endif
6468
69#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
70# include <cstddef>
71# include <cstdint>
72# include <limits>
73# include <mutex>
74# include <new>
75# include <stdexcept>
76# include <tuple>
77#endif
78
6579#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
6680# include <stdexcept>
6781#endif
lib/libcxx/include/mutex+12-27
......@@ -186,7 +186,6 @@ template<class Callable, class ...Args>
186186
187187*/
188188
189#include <__assert> // all public C++ headers provide the assertion handler
190189#include <__chrono/steady_clock.h>
191190#include <__chrono/time_point.h>
192191#include <__condition_variable/condition_variable.h>
......@@ -198,7 +197,7 @@ template<class Callable, class ...Args>
198197#include <__mutex/tag_types.h>
199198#include <__mutex/unique_lock.h>
200199#include <__thread/id.h>
201#include <__threading_support>
200#include <__thread/support.h>
202201#include <__utility/forward.h>
203202#include <cstddef>
204203#include <limits>
......@@ -419,24 +418,6 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&...
419418 std::__lock_first(0, __l0, __l1, __l2, __l3...);
420419}
421420
422template <class _L0>
423inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0) {
424 __l0.unlock();
425}
426
427template <class _L0, class _L1>
428inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1) {
429 __l0.unlock();
430 __l1.unlock();
431}
432
433template <class _L0, class _L1, class _L2, class... _L3>
434inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
435 __l0.unlock();
436 __l1.unlock();
437 std::__unlock(__l2, __l3...);
438}
439
440421# endif // _LIBCPP_CXX03_LANG
441422
442423# if _LIBCPP_STD_VER >= 17
......@@ -446,10 +427,10 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock;
446427template <>
447428class _LIBCPP_TEMPLATE_VIS scoped_lock<> {
448429public:
449 explicit scoped_lock() {}
430 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {}
450431 ~scoped_lock() = default;
451432
452 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t) {}
433 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t) {}
453434
454435 scoped_lock(scoped_lock const&) = delete;
455436 scoped_lock& operator=(scoped_lock const&) = delete;
......@@ -464,13 +445,15 @@ private:
464445 mutex_type& __m_;
465446
466447public:
467 explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m)) : __m_(__m) {
448 [[nodiscard]]
449 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
450 : __m_(__m) {
468451 __m_.lock();
469452 }
470453
471454 ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }
472455
473 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m)
456 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m)
474457 _LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
475458 : __m_(__m) {}
476459
......@@ -484,9 +467,11 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock {
484467 typedef tuple<_MArgs&...> _MutexTuple;
485468
486469public:
487 _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) { std::lock(__margs...); }
470 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) {
471 std::lock(__margs...);
472 }
488473
489 _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {}
474 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {}
490475
491476 _LIBCPP_HIDE_FROM_ABI ~scoped_lock() {
492477 typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices;
......@@ -499,7 +484,7 @@ public:
499484private:
500485 template <size_t... _Indx>
501486 _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
502 std::__unlock(std::get<_Indx>(__mt)...);
487 (std::get<_Indx>(__mt).unlock(), ...);
503488 }
504489
505490 _MutexTuple __t_;
lib/libcxx/include/new+15-21
......@@ -86,13 +86,12 @@ void operator delete[](void* ptr, void*) noexcept;
8686
8787*/
8888
89#include <__assert> // all public C++ headers provide the assertion handler
90#include <__availability>
9189#include <__config>
9290#include <__exception/exception.h>
9391#include <__type_traits/is_function.h>
9492#include <__type_traits/is_same.h>
9593#include <__type_traits/remove_cv.h>
94#include <__verbose_abort>
9695#include <cstddef>
9796#include <version>
9897
......@@ -204,18 +203,18 @@ inline constexpr destroying_delete_t destroying_delete{};
204203
205204#if !defined(_LIBCPP_ABI_VCRUNTIME)
206205
207_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
208_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
209operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
206_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
207_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
208 _LIBCPP_NOALIAS;
210209_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
211210_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
212211# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
213212_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
214213# endif
215214
216_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
217_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
218operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
215_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
216_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
217 _LIBCPP_NOALIAS;
219218_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
220219_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
221220# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
......@@ -223,9 +222,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz)
223222# endif
224223
225224# ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
226_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
227operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
228_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
225_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
226_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*
229227operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
230228_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
231229_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
......@@ -233,9 +231,9 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, c
233231_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
234232# endif
235233
236_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
234_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*
237235operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
238_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void*
236_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void*
239237operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
240238_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
241239_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
......@@ -244,12 +242,8 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz,
244242# endif
245243# endif
246244
247_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT {
248 return __p;
249}
250_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT {
251 return __p;
252}
245_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new(std::size_t, void* __p) _NOEXCEPT { return __p; }
246_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI void* operator new[](std::size_t, void* __p) _NOEXCEPT { return __p; }
253247inline _LIBCPP_HIDE_FROM_ABI void operator delete(void*, void*) _NOEXCEPT {}
254248inline _LIBCPP_HIDE_FROM_ABI void operator delete[](void*, void*) _NOEXCEPT {}
255249
......@@ -334,7 +328,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_
334328}
335329
336330template <class _Tp>
337_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT {
331_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __launder(_Tp* __p) _NOEXCEPT {
338332 static_assert(!(is_function<_Tp>::value), "can't launder functions");
339333 static_assert(!(is_same<void, __remove_cv_t<_Tp> >::value), "can't launder cv-void");
340334 return __builtin_launder(__p);
......@@ -342,7 +336,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp
342336
343337#if _LIBCPP_STD_VER >= 17
344338template <class _Tp>
345_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {
339[[nodiscard]] inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp* launder(_Tp* __p) noexcept {
346340 return std::__launder(__p);
347341}
348342#endif
lib/libcxx/include/numbers-1
......@@ -58,7 +58,6 @@ namespace std::numbers {
5858}
5959*/
6060
61#include <__assert> // all public C++ headers provide the assertion handler
6261#include <__concepts/arithmetic.h>
6362#include <__config>
6463#include <version>
lib/libcxx/include/numeric+28-13
......@@ -156,36 +156,51 @@ constexpr T saturate_cast(U x) noexcept; // freestanding, Sin
156156
157157*/
158158
159#include <__assert> // all public C++ headers provide the assertion handler
160159#include <__config>
161#include <version>
162160
163161#include <__numeric/accumulate.h>
164162#include <__numeric/adjacent_difference.h>
165#include <__numeric/exclusive_scan.h>
166#include <__numeric/gcd_lcm.h>
167#include <__numeric/inclusive_scan.h>
168163#include <__numeric/inner_product.h>
169164#include <__numeric/iota.h>
170#include <__numeric/midpoint.h>
171165#include <__numeric/partial_sum.h>
172#include <__numeric/pstl_reduce.h>
173#include <__numeric/pstl_transform_reduce.h>
174#include <__numeric/reduce.h>
175#include <__numeric/saturation_arithmetic.h>
176#include <__numeric/transform_exclusive_scan.h>
177#include <__numeric/transform_inclusive_scan.h>
178#include <__numeric/transform_reduce.h>
166
167#if _LIBCPP_STD_VER >= 17
168# include <__numeric/exclusive_scan.h>
169# include <__numeric/gcd_lcm.h>
170# include <__numeric/inclusive_scan.h>
171# include <__numeric/pstl.h>
172# include <__numeric/reduce.h>
173# include <__numeric/transform_exclusive_scan.h>
174# include <__numeric/transform_inclusive_scan.h>
175# include <__numeric/transform_reduce.h>
176#endif
177
178#if _LIBCPP_STD_VER >= 20
179# include <__numeric/midpoint.h>
180# include <__numeric/saturation_arithmetic.h>
181#endif
182
183#include <version>
179184
180185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
181186# pragma GCC system_header
182187#endif
183188
189#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 14
190# include <initializer_list>
191# include <limits>
192#endif
193
184194#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
195# include <climits>
185196# include <cmath>
186197# include <concepts>
198# include <cstdint>
199# include <execution>
187200# include <functional>
188201# include <iterator>
202# include <new>
203# include <optional>
189204# include <type_traits>
190205#endif
191206
lib/libcxx/include/optional+30-30
......@@ -136,12 +136,12 @@ namespace std {
136136 void swap(optional &) noexcept(see below ); // constexpr in C++20
137137
138138 // [optional.observe], observers
139 constexpr T const *operator->() const;
140 constexpr T *operator->();
141 constexpr T const &operator*() const &;
142 constexpr T &operator*() &;
143 constexpr T &&operator*() &&;
144 constexpr const T &&operator*() const &&;
139 constexpr T const *operator->() const noexcept;
140 constexpr T *operator->() noexcept;
141 constexpr T const &operator*() const & noexcept;
142 constexpr T &operator*() & noexcept;
143 constexpr T &&operator*() && noexcept;
144 constexpr const T &&operator*() const && noexcept;
145145 constexpr explicit operator bool() const noexcept;
146146 constexpr bool has_value() const noexcept;
147147 constexpr T const &value() const &;
......@@ -177,8 +177,7 @@ namespace std {
177177
178178*/
179179
180#include <__assert> // all public C++ headers provide the assertion handler
181#include <__availability>
180#include <__assert>
182181#include <__compare/compare_three_way_result.h>
183182#include <__compare/three_way_comparable.h>
184183#include <__concepts/invocable.h>
......@@ -186,8 +185,8 @@ namespace std {
186185#include <__exception/exception.h>
187186#include <__functional/hash.h>
188187#include <__functional/invoke.h>
189#include <__functional/reference_wrapper.h>
190188#include <__functional/unary_function.h>
189#include <__fwd/functional.h>
191190#include <__memory/addressof.h>
192191#include <__memory/construct_at.h>
193192#include <__tuple/sfinae_helpers.h>
......@@ -200,22 +199,17 @@ namespace std {
200199#include <__type_traits/is_assignable.h>
201200#include <__type_traits/is_constructible.h>
202201#include <__type_traits/is_convertible.h>
203#include <__type_traits/is_copy_assignable.h>
204#include <__type_traits/is_copy_constructible.h>
205202#include <__type_traits/is_destructible.h>
206#include <__type_traits/is_move_assignable.h>
207#include <__type_traits/is_move_constructible.h>
208#include <__type_traits/is_nothrow_move_assignable.h>
209#include <__type_traits/is_nothrow_move_constructible.h>
203#include <__type_traits/is_nothrow_assignable.h>
204#include <__type_traits/is_nothrow_constructible.h>
210205#include <__type_traits/is_object.h>
211206#include <__type_traits/is_reference.h>
212207#include <__type_traits/is_scalar.h>
213208#include <__type_traits/is_swappable.h>
214#include <__type_traits/is_trivially_copy_assignable.h>
215#include <__type_traits/is_trivially_copy_constructible.h>
209#include <__type_traits/is_trivially_assignable.h>
210#include <__type_traits/is_trivially_constructible.h>
216211#include <__type_traits/is_trivially_destructible.h>
217#include <__type_traits/is_trivially_move_assignable.h>
218#include <__type_traits/is_trivially_move_constructible.h>
212#include <__type_traits/is_trivially_relocatable.h>
219213#include <__type_traits/negation.h>
220214#include <__type_traits/remove_const.h>
221215#include <__type_traits/remove_cvref.h>
......@@ -307,7 +301,7 @@ struct __optional_destruct_base<_Tp, false> {
307301
308302# if _LIBCPP_STD_VER >= 23
309303 template <class _Fp, class... _Args>
310 _LIBCPP_HIDE_FROM_ABI constexpr __optional_destruct_base(
304 _LIBCPP_HIDE_FROM_ABI constexpr explicit __optional_destruct_base(
311305 __optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
312306 : __val_(std::invoke(std::forward<_Fp>(__f), std::forward<_Args>(__args)...)), __engaged_(true) {}
313307# endif
......@@ -587,6 +581,8 @@ class _LIBCPP_DECLSPEC_EMPTY_BASES optional
587581public:
588582 using value_type = _Tp;
589583
584 using __trivially_relocatable = conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, optional, void>;
585
590586private:
591587 // Disable the reference extension using this static assert.
592588 static_assert(!is_same_v<__remove_cvref_t<value_type>, in_place_t>,
......@@ -711,8 +707,11 @@ public:
711707 }
712708
713709# if _LIBCPP_STD_VER >= 23
714 template <class _Fp, class... _Args>
715 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(__optional_construct_from_invoke_tag, _Fp&& __f, _Args&&... __args)
710 template <class _Tag,
711 class _Fp,
712 class... _Args,
713 __enable_if_t<_IsSame<_Tag, __optional_construct_from_invoke_tag>::value, int> = 0>
714 _LIBCPP_HIDE_FROM_ABI constexpr explicit optional(_Tag, _Fp&& __f, _Args&&... __args)
716715 : __base(__optional_construct_from_invoke_tag{}, std::forward<_Fp>(__f), std::forward<_Args>(__args)...) {}
717716# endif
718717
......@@ -728,9 +727,9 @@ public:
728727 template <
729728 class _Up = value_type,
730729 class = enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Up>, optional>,
731 _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >,
732 is_constructible<value_type, _Up>,
733 is_assignable<value_type&, _Up> >::value> >
730 _Or< _IsNotSame<__remove_cvref_t<_Up>, value_type>, _Not<is_scalar<value_type>> >,
731 is_constructible<value_type, _Up>,
732 is_assignable<value_type&, _Up> >::value> >
734733 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 optional& operator=(_Up&& __v) {
735734 if (this->has_value())
736735 this->__get() = std::forward<_Up>(__v);
......@@ -787,12 +786,12 @@ public:
787786 }
788787 }
789788
790 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const {
789 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type const> operator->() const noexcept {
791790 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
792791 return std::addressof(this->__get());
793792 }
794793
795 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() {
794 _LIBCPP_HIDE_FROM_ABI constexpr add_pointer_t<value_type> operator->() noexcept {
796795 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(this->has_value(), "optional operator-> called on a disengaged value");
797796 return std::addressof(this->__get());
798797 }
......@@ -1246,9 +1245,9 @@ operator<=>(const optional<_Tp>& __x, const _Up& __v) {
12461245# endif // _LIBCPP_STD_VER >= 20
12471246
12481247template <class _Tp>
1249inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
1250 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void >
1251 swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {
1248inline _LIBCPP_HIDE_FROM_ABI
1249_LIBCPP_CONSTEXPR_SINCE_CXX20 enable_if_t< is_move_constructible_v<_Tp> && is_swappable_v<_Tp>, void >
1250swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) {
12521251 __x.swap(__y);
12531252}
12541253
......@@ -1291,6 +1290,7 @@ _LIBCPP_POP_MACROS
12911290# include <concepts>
12921291# include <ctime>
12931292# include <iterator>
1293# include <limits>
12941294# include <memory>
12951295# include <ratio>
12961296# include <stdexcept>
lib/libcxx/include/ostream+9-994
......@@ -164,6 +164,7 @@ template<class... Args>
164164 void print(ostream& os, format_string<Args...> fmt, Args&&... args);
165165template<class... Args> // since C++23
166166 void println(ostream& os, format_string<Args...> fmt, Args&&... args);
167void println(ostream& os); // since C++26
167168
168169void vprint_unicode(ostream& os, string_view fmt, format_args args); // since C++23
169170void vprint_nonunicode(ostream& os, string_view fmt, format_args args); // since C++23
......@@ -171,1015 +172,29 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
171172
172173*/
173174
174#include <__assert> // all public C++ headers provide the assertion handler
175#include <__availability>
176175#include <__config>
177#include <__exception/operations.h>
178#include <__fwd/ostream.h>
179#include <__memory/shared_ptr.h>
180#include <__memory/unique_ptr.h>
181#include <__system_error/error_code.h>
182#include <__type_traits/conjunction.h>
183#include <__type_traits/enable_if.h>
184#include <__type_traits/is_base_of.h>
185#include <__type_traits/void_t.h>
186#include <__utility/declval.h>
187#include <bitset>
188#include <cstdio>
189#include <format>
190#include <ios>
191#include <locale>
192#include <new>
193#include <print>
194#include <streambuf>
195#include <string_view>
196#include <version>
197
198#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
199# pragma GCC system_header
200#endif
201
202_LIBCPP_PUSH_MACROS
203#include <__undef_macros>
204
205_LIBCPP_BEGIN_NAMESPACE_STD
206
207template <class _CharT, class _Traits>
208class _LIBCPP_TEMPLATE_VIS basic_ostream : virtual public basic_ios<_CharT, _Traits> {
209public:
210 // types (inherited from basic_ios (27.5.4)):
211 typedef _CharT char_type;
212 typedef _Traits traits_type;
213 typedef typename traits_type::int_type int_type;
214 typedef typename traits_type::pos_type pos_type;
215 typedef typename traits_type::off_type off_type;
216
217 // 27.7.2.2 Constructor/destructor:
218 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 explicit basic_ostream(basic_streambuf<char_type, traits_type>* __sb) {
219 this->init(__sb);
220 }
221 ~basic_ostream() override;
222
223protected:
224 inline _LIBCPP_HIDE_FROM_ABI basic_ostream(basic_ostream&& __rhs);
225
226 // 27.7.2.3 Assign/swap
227 inline _LIBCPP_HIDE_FROM_ABI basic_ostream& operator=(basic_ostream&& __rhs);
228
229 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void swap(basic_ostream& __rhs) {
230 basic_ios<char_type, traits_type>::swap(__rhs);
231 }
232
233 basic_ostream(const basic_ostream& __rhs) = delete;
234 basic_ostream& operator=(const basic_ostream& __rhs) = delete;
235176
236public:
237 // 27.7.2.4 Prefix/suffix:
238 class _LIBCPP_TEMPLATE_VIS sentry;
239
240 // 27.7.2.6 Formatted output:
241 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)) {
242 return __pf(*this);
243 }
244
245 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream&
246 operator<<(basic_ios<char_type, traits_type>& (*__pf)(basic_ios<char_type, traits_type>&)) {
247 __pf(*this);
248 return *this;
249 }
250
251 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& operator<<(ios_base& (*__pf)(ios_base&)) {
252 __pf(*this);
253 return *this;
254 }
255
256 basic_ostream& operator<<(bool __n);
257 basic_ostream& operator<<(short __n);
258 basic_ostream& operator<<(unsigned short __n);
259 basic_ostream& operator<<(int __n);
260 basic_ostream& operator<<(unsigned int __n);
261 basic_ostream& operator<<(long __n);
262 basic_ostream& operator<<(unsigned long __n);
263 basic_ostream& operator<<(long long __n);
264 basic_ostream& operator<<(unsigned long long __n);
265 basic_ostream& operator<<(float __f);
266 basic_ostream& operator<<(double __f);
267 basic_ostream& operator<<(long double __f);
268 basic_ostream& operator<<(const void* __p);
177#include <__ostream/basic_ostream.h>
269178
270179#if _LIBCPP_STD_VER >= 23
271 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(const volatile void* __p) {
272 return operator<<(const_cast<const void*>(__p));
273 }
274#endif
275
276 basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
277
278#if _LIBCPP_STD_VER >= 17
279 // LWG 2221 - nullptr. This is not backported to older standards modes.
280 // See https://reviews.llvm.org/D127033 for more info on the rationale.
281 _LIBCPP_HIDE_FROM_ABI basic_ostream& operator<<(nullptr_t) { return *this << "nullptr"; }
180# include <__ostream/print.h>
282181#endif
283182
284 // 27.7.2.7 Unformatted output:
285 basic_ostream& put(char_type __c);
286 basic_ostream& write(const char_type* __s, streamsize __n);
287 basic_ostream& flush();
288
289 // 27.7.2.5 seeks:
290 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type tellp();
291 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(pos_type __pos);
292 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_ostream& seekp(off_type __off, ios_base::seekdir __dir);
293
294protected:
295 _LIBCPP_HIDE_FROM_ABI basic_ostream() {} // extension, intentially does not initialize
296};
297
298template <class _CharT, class _Traits>
299class _LIBCPP_TEMPLATE_VIS basic_ostream<_CharT, _Traits>::sentry {
300 bool __ok_;
301 basic_ostream<_CharT, _Traits>& __os_;
302
303public:
304 explicit sentry(basic_ostream<_CharT, _Traits>& __os);
305 ~sentry();
306 sentry(const sentry&) = delete;
307 sentry& operator=(const sentry&) = delete;
308
309 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ok_; }
310};
311
312template <class _CharT, class _Traits>
313basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& __os) : __ok_(false), __os_(__os) {
314 if (__os.good()) {
315 if (__os.tie())
316 __os.tie()->flush();
317 __ok_ = true;
318 }
319}
320
321template <class _CharT, class _Traits>
322basic_ostream<_CharT, _Traits>::sentry::~sentry() {
323 if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && !uncaught_exception()) {
324#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
325 try {
326#endif // _LIBCPP_HAS_NO_EXCEPTIONS
327 if (__os_.rdbuf()->pubsync() == -1)
328 __os_.setstate(ios_base::badbit);
329#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
330 } catch (...) {
331 }
332#endif // _LIBCPP_HAS_NO_EXCEPTIONS
333 }
334}
335
336template <class _CharT, class _Traits>
337basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) {
338 this->move(__rhs);
339}
340
341template <class _CharT, class _Traits>
342basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) {
343 swap(__rhs);
344 return *this;
345}
346
347template <class _CharT, class _Traits>
348basic_ostream<_CharT, _Traits>::~basic_ostream() {}
349
350template <class _CharT, class _Traits>
351basic_ostream<_CharT, _Traits>&
352basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __sb) {
353#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
354 try {
355#endif // _LIBCPP_HAS_NO_EXCEPTIONS
356 sentry __s(*this);
357 if (__s) {
358 if (__sb) {
359#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
360 try {
361#endif // _LIBCPP_HAS_NO_EXCEPTIONS
362 typedef istreambuf_iterator<_CharT, _Traits> _Ip;
363 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
364 _Ip __i(__sb);
365 _Ip __eof;
366 _Op __o(*this);
367 size_t __c = 0;
368 for (; __i != __eof; ++__i, ++__o, ++__c) {
369 *__o = *__i;
370 if (__o.failed())
371 break;
372 }
373 if (__c == 0)
374 this->setstate(ios_base::failbit);
375#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
376 } catch (...) {
377 this->__set_failbit_and_consider_rethrow();
378 }
379#endif // _LIBCPP_HAS_NO_EXCEPTIONS
380 } else
381 this->setstate(ios_base::badbit);
382 }
383#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
384 } catch (...) {
385 this->__set_badbit_and_consider_rethrow();
386 }
387#endif // _LIBCPP_HAS_NO_EXCEPTIONS
388 return *this;
389}
390
391template <class _CharT, class _Traits>
392basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) {
393#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
394 try {
395#endif // _LIBCPP_HAS_NO_EXCEPTIONS
396 sentry __s(*this);
397 if (__s) {
398 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
399 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
400 if (__f.put(*this, *this, this->fill(), __n).failed())
401 this->setstate(ios_base::badbit | ios_base::failbit);
402 }
403#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
404 } catch (...) {
405 this->__set_badbit_and_consider_rethrow();
406 }
407#endif // _LIBCPP_HAS_NO_EXCEPTIONS
408 return *this;
409}
410
411template <class _CharT, class _Traits>
412basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) {
413#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
414 try {
415#endif // _LIBCPP_HAS_NO_EXCEPTIONS
416 sentry __s(*this);
417 if (__s) {
418 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
419 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
420 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
421 if (__f.put(*this,
422 *this,
423 this->fill(),
424 __flags == ios_base::oct || __flags == ios_base::hex
425 ? static_cast<long>(static_cast<unsigned short>(__n))
426 : static_cast<long>(__n))
427 .failed())
428 this->setstate(ios_base::badbit | ios_base::failbit);
429 }
430#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
431 } catch (...) {
432 this->__set_badbit_and_consider_rethrow();
433 }
434#endif // _LIBCPP_HAS_NO_EXCEPTIONS
435 return *this;
436}
437
438template <class _CharT, class _Traits>
439basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) {
440#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
441 try {
442#endif // _LIBCPP_HAS_NO_EXCEPTIONS
443 sentry __s(*this);
444 if (__s) {
445 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
446 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
447 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
448 this->setstate(ios_base::badbit | ios_base::failbit);
449 }
450#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
451 } catch (...) {
452 this->__set_badbit_and_consider_rethrow();
453 }
454#endif // _LIBCPP_HAS_NO_EXCEPTIONS
455 return *this;
456}
457
458template <class _CharT, class _Traits>
459basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) {
460#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
461 try {
462#endif // _LIBCPP_HAS_NO_EXCEPTIONS
463 sentry __s(*this);
464 if (__s) {
465 ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield;
466 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
467 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
468 if (__f.put(*this,
469 *this,
470 this->fill(),
471 __flags == ios_base::oct || __flags == ios_base::hex
472 ? static_cast<long>(static_cast<unsigned int>(__n))
473 : static_cast<long>(__n))
474 .failed())
475 this->setstate(ios_base::badbit | ios_base::failbit);
476 }
477#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
478 } catch (...) {
479 this->__set_badbit_and_consider_rethrow();
480 }
481#endif // _LIBCPP_HAS_NO_EXCEPTIONS
482 return *this;
483}
484
485template <class _CharT, class _Traits>
486basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) {
487#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
488 try {
489#endif // _LIBCPP_HAS_NO_EXCEPTIONS
490 sentry __s(*this);
491 if (__s) {
492 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
493 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
494 if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__n)).failed())
495 this->setstate(ios_base::badbit | ios_base::failbit);
496 }
497#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
498 } catch (...) {
499 this->__set_badbit_and_consider_rethrow();
500 }
501#endif // _LIBCPP_HAS_NO_EXCEPTIONS
502 return *this;
503}
504
505template <class _CharT, class _Traits>
506basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) {
507#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
508 try {
509#endif // _LIBCPP_HAS_NO_EXCEPTIONS
510 sentry __s(*this);
511 if (__s) {
512 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
513 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
514 if (__f.put(*this, *this, this->fill(), __n).failed())
515 this->setstate(ios_base::badbit | ios_base::failbit);
516 }
517#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
518 } catch (...) {
519 this->__set_badbit_and_consider_rethrow();
520 }
521#endif // _LIBCPP_HAS_NO_EXCEPTIONS
522 return *this;
523}
524
525template <class _CharT, class _Traits>
526basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) {
527#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
528 try {
529#endif // _LIBCPP_HAS_NO_EXCEPTIONS
530 sentry __s(*this);
531 if (__s) {
532 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
533 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
534 if (__f.put(*this, *this, this->fill(), __n).failed())
535 this->setstate(ios_base::badbit | ios_base::failbit);
536 }
537#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
538 } catch (...) {
539 this->__set_badbit_and_consider_rethrow();
540 }
541#endif // _LIBCPP_HAS_NO_EXCEPTIONS
542 return *this;
543}
544
545template <class _CharT, class _Traits>
546basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) {
547#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
548 try {
549#endif // _LIBCPP_HAS_NO_EXCEPTIONS
550 sentry __s(*this);
551 if (__s) {
552 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
553 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
554 if (__f.put(*this, *this, this->fill(), __n).failed())
555 this->setstate(ios_base::badbit | ios_base::failbit);
556 }
557#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
558 } catch (...) {
559 this->__set_badbit_and_consider_rethrow();
560 }
561#endif // _LIBCPP_HAS_NO_EXCEPTIONS
562 return *this;
563}
564
565template <class _CharT, class _Traits>
566basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) {
567#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
568 try {
569#endif // _LIBCPP_HAS_NO_EXCEPTIONS
570 sentry __s(*this);
571 if (__s) {
572 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
573 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
574 if (__f.put(*this, *this, this->fill(), __n).failed())
575 this->setstate(ios_base::badbit | ios_base::failbit);
576 }
577#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
578 } catch (...) {
579 this->__set_badbit_and_consider_rethrow();
580 }
581#endif // _LIBCPP_HAS_NO_EXCEPTIONS
582 return *this;
583}
584
585template <class _CharT, class _Traits>
586basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) {
587#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
588 try {
589#endif // _LIBCPP_HAS_NO_EXCEPTIONS
590 sentry __s(*this);
591 if (__s) {
592 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
593 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
594 if (__f.put(*this, *this, this->fill(), static_cast<double>(__n)).failed())
595 this->setstate(ios_base::badbit | ios_base::failbit);
596 }
597#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
598 } catch (...) {
599 this->__set_badbit_and_consider_rethrow();
600 }
601#endif // _LIBCPP_HAS_NO_EXCEPTIONS
602 return *this;
603}
604
605template <class _CharT, class _Traits>
606basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) {
607#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
608 try {
609#endif // _LIBCPP_HAS_NO_EXCEPTIONS
610 sentry __s(*this);
611 if (__s) {
612 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
613 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
614 if (__f.put(*this, *this, this->fill(), __n).failed())
615 this->setstate(ios_base::badbit | ios_base::failbit);
616 }
617#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
618 } catch (...) {
619 this->__set_badbit_and_consider_rethrow();
620 }
621#endif // _LIBCPP_HAS_NO_EXCEPTIONS
622 return *this;
623}
624
625template <class _CharT, class _Traits>
626basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) {
627#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
628 try {
629#endif // _LIBCPP_HAS_NO_EXCEPTIONS
630 sentry __s(*this);
631 if (__s) {
632 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
633 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
634 if (__f.put(*this, *this, this->fill(), __n).failed())
635 this->setstate(ios_base::badbit | ios_base::failbit);
636 }
637#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
638 } catch (...) {
639 this->__set_badbit_and_consider_rethrow();
640 }
641#endif // _LIBCPP_HAS_NO_EXCEPTIONS
642 return *this;
643}
644
645template <class _CharT, class _Traits>
646basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) {
647#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
648 try {
649#endif // _LIBCPP_HAS_NO_EXCEPTIONS
650 sentry __s(*this);
651 if (__s) {
652 typedef num_put<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
653 const _Fp& __f = std::use_facet<_Fp>(this->getloc());
654 if (__f.put(*this, *this, this->fill(), __n).failed())
655 this->setstate(ios_base::badbit | ios_base::failbit);
656 }
657#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
658 } catch (...) {
659 this->__set_badbit_and_consider_rethrow();
660 }
661#endif // _LIBCPP_HAS_NO_EXCEPTIONS
662 return *this;
663}
664
665template <class _CharT, class _Traits>
666_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
667__put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) {
668#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
669 try {
670#endif // _LIBCPP_HAS_NO_EXCEPTIONS
671 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
672 if (__s) {
673 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
674 if (std::__pad_and_output(
675 _Ip(__os),
676 __str,
677 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
678 __str + __len,
679 __os,
680 __os.fill())
681 .failed())
682 __os.setstate(ios_base::badbit | ios_base::failbit);
683 }
684#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
685 } catch (...) {
686 __os.__set_badbit_and_consider_rethrow();
687 }
688#endif // _LIBCPP_HAS_NO_EXCEPTIONS
689 return __os;
690}
691
692template <class _CharT, class _Traits>
693_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
694 return std::__put_character_sequence(__os, &__c, 1);
695}
696
697template <class _CharT, class _Traits>
698_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) {
699#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
700 try {
701#endif // _LIBCPP_HAS_NO_EXCEPTIONS
702 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
703 if (__s) {
704 _CharT __c = __os.widen(__cn);
705 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
706 if (std::__pad_and_output(
707 _Ip(__os),
708 &__c,
709 (__os.flags() & ios_base::adjustfield) == ios_base::left ? &__c + 1 : &__c,
710 &__c + 1,
711 __os,
712 __os.fill())
713 .failed())
714 __os.setstate(ios_base::badbit | ios_base::failbit);
715 }
716#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
717 } catch (...) {
718 __os.__set_badbit_and_consider_rethrow();
719 }
720#endif // _LIBCPP_HAS_NO_EXCEPTIONS
721 return __os;
722}
723
724template <class _Traits>
725_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, char __c) {
726 return std::__put_character_sequence(__os, &__c, 1);
727}
728
729template <class _Traits>
730_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, signed char __c) {
731 return std::__put_character_sequence(__os, (char*)&__c, 1);
732}
733
734template <class _Traits>
735_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c) {
736 return std::__put_character_sequence(__os, (char*)&__c, 1);
737}
738
739template <class _CharT, class _Traits>
740_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
741operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
742 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
743}
744
745template <class _CharT, class _Traits>
746_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
747operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) {
748#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
749 try {
750#endif // _LIBCPP_HAS_NO_EXCEPTIONS
751 typename basic_ostream<_CharT, _Traits>::sentry __s(__os);
752 if (__s) {
753 typedef ostreambuf_iterator<_CharT, _Traits> _Ip;
754 size_t __len = char_traits<char>::length(__strn);
755 const int __bs = 100;
756 _CharT __wbb[__bs];
757 _CharT* __wb = __wbb;
758 unique_ptr<_CharT, void (*)(void*)> __h(0, free);
759 if (__len > __bs) {
760 __wb = (_CharT*)malloc(__len * sizeof(_CharT));
761 if (__wb == 0)
762 __throw_bad_alloc();
763 __h.reset(__wb);
764 }
765 for (_CharT* __p = __wb; *__strn != '\0'; ++__strn, ++__p)
766 *__p = __os.widen(*__strn);
767 if (std::__pad_and_output(
768 _Ip(__os),
769 __wb,
770 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __wb + __len : __wb,
771 __wb + __len,
772 __os,
773 __os.fill())
774 .failed())
775 __os.setstate(ios_base::badbit | ios_base::failbit);
776 }
777#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
778 } catch (...) {
779 __os.__set_badbit_and_consider_rethrow();
780 }
781#endif // _LIBCPP_HAS_NO_EXCEPTIONS
782 return __os;
783}
784
785template <class _Traits>
786_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& __os, const char* __str) {
787 return std::__put_character_sequence(__os, __str, _Traits::length(__str));
788}
789
790template <class _Traits>
791_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
792operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str) {
793 const char* __s = (const char*)__str;
794 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
795}
796
797template <class _Traits>
798_LIBCPP_HIDE_FROM_ABI basic_ostream<char, _Traits>&
799operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
800 const char* __s = (const char*)__str;
801 return std::__put_character_sequence(__os, __s, _Traits::length(__s));
802}
803
804template <class _CharT, class _Traits>
805basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) {
806#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
807 try {
808#endif // _LIBCPP_HAS_NO_EXCEPTIONS
809 sentry __s(*this);
810 if (__s) {
811 typedef ostreambuf_iterator<_CharT, _Traits> _Op;
812 _Op __o(*this);
813 *__o = __c;
814 if (__o.failed())
815 this->setstate(ios_base::badbit);
816 }
817#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
818 } catch (...) {
819 this->__set_badbit_and_consider_rethrow();
820 }
821#endif // _LIBCPP_HAS_NO_EXCEPTIONS
822 return *this;
823}
824
825template <class _CharT, class _Traits>
826basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) {
827#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
828 try {
829#endif // _LIBCPP_HAS_NO_EXCEPTIONS
830 sentry __sen(*this);
831 if (__sen && __n) {
832 if (this->rdbuf()->sputn(__s, __n) != __n)
833 this->setstate(ios_base::badbit);
834 }
835#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
836 } catch (...) {
837 this->__set_badbit_and_consider_rethrow();
838 }
839#endif // _LIBCPP_HAS_NO_EXCEPTIONS
840 return *this;
841}
842
843template <class _CharT, class _Traits>
844basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() {
845#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
846 try {
847#endif // _LIBCPP_HAS_NO_EXCEPTIONS
848 if (this->rdbuf()) {
849 sentry __s(*this);
850 if (__s) {
851 if (this->rdbuf()->pubsync() == -1)
852 this->setstate(ios_base::badbit);
853 }
854 }
855#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
856 } catch (...) {
857 this->__set_badbit_and_consider_rethrow();
858 }
859#endif // _LIBCPP_HAS_NO_EXCEPTIONS
860 return *this;
861}
862
863template <class _CharT, class _Traits>
864typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() {
865 if (this->fail())
866 return pos_type(-1);
867 return this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::out);
868}
869
870template <class _CharT, class _Traits>
871basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) {
872 sentry __s(*this);
873 if (!this->fail()) {
874 if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1))
875 this->setstate(ios_base::failbit);
876 }
877 return *this;
878}
879
880template <class _CharT, class _Traits>
881basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) {
882 sentry __s(*this);
883 if (!this->fail()) {
884 if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1))
885 this->setstate(ios_base::failbit);
886 }
887 return *this;
888}
889
890template <class _CharT, class _Traits>
891_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) {
892 __os.put(__os.widen('\n'));
893 __os.flush();
894 return __os;
895}
896
897template <class _CharT, class _Traits>
898_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) {
899 __os.put(_CharT());
900 return __os;
901}
902
903template <class _CharT, class _Traits>
904_LIBCPP_HIDE_FROM_ABI inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) {
905 __os.flush();
906 return __os;
907}
908
909template <class _Stream, class _Tp, class = void>
910struct __is_ostreamable : false_type {};
911
912template <class _Stream, class _Tp>
913struct __is_ostreamable<_Stream, _Tp, decltype(std::declval<_Stream>() << std::declval<_Tp>(), void())> : true_type {};
914
915template <class _Stream,
916 class _Tp,
917 __enable_if_t<_And<is_base_of<ios_base, _Stream>, __is_ostreamable<_Stream&, const _Tp&> >::value, int> = 0>
918_LIBCPP_HIDE_FROM_ABI _Stream&& operator<<(_Stream&& __os, const _Tp& __x) {
919 __os << __x;
920 return std::move(__os);
921}
922
923template <class _CharT, class _Traits, class _Allocator>
924basic_ostream<_CharT, _Traits>&
925operator<<(basic_ostream<_CharT, _Traits>& __os, const basic_string<_CharT, _Traits, _Allocator>& __str) {
926 return std::__put_character_sequence(__os, __str.data(), __str.size());
927}
928
929template <class _CharT, class _Traits>
930_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
931operator<<(basic_ostream<_CharT, _Traits>& __os, basic_string_view<_CharT, _Traits> __sv) {
932 return std::__put_character_sequence(__os, __sv.data(), __sv.size());
933}
934
935template <class _CharT, class _Traits>
936inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
937operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) {
938 return __os << __ec.category().name() << ':' << __ec.value();
939}
940
941template <class _CharT, class _Traits, class _Yp>
942inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
943operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) {
944 return __os << __p.get();
945}
946
947template <
948 class _CharT,
949 class _Traits,
950 class _Yp,
951 class _Dp,
952 __enable_if_t<is_same<void,
953 __void_t<decltype((std::declval<basic_ostream<_CharT, _Traits>&>()
954 << std::declval<typename unique_ptr<_Yp, _Dp>::pointer>()))> >::value,
955 int> = 0>
956inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
957operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p) {
958 return __os << __p.get();
959}
960
961template <class _CharT, class _Traits, size_t _Size>
962_LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>&
963operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) {
964 return __os << __x.template to_string<_CharT, _Traits>(std::use_facet<ctype<_CharT> >(__os.getloc()).widen('0'),
965 std::use_facet<ctype<_CharT> >(__os.getloc()).widen('1'));
966}
967
968#if _LIBCPP_STD_VER >= 20
969
970# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
971template <class _Traits>
972basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, wchar_t) = delete;
973
974template <class _Traits>
975basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const wchar_t*) = delete;
976
977template <class _Traits>
978basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char16_t) = delete;
979
980template <class _Traits>
981basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char32_t) = delete;
982
983template <class _Traits>
984basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char16_t*) = delete;
985
986template <class _Traits>
987basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char32_t*) = delete;
988
989# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
990
991# ifndef _LIBCPP_HAS_NO_CHAR8_T
992template <class _Traits>
993basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
994
995template <class _Traits>
996basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, char8_t) = delete;
997
998template <class _Traits>
999basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char8_t*) = delete;
1000
1001template <class _Traits>
1002basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, const char8_t*) = delete;
1003# endif
1004
1005template <class _Traits>
1006basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char16_t) = delete;
1007
1008template <class _Traits>
1009basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char32_t) = delete;
1010
1011template <class _Traits>
1012basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char16_t*) = delete;
1013
1014template <class _Traits>
1015basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, const char32_t*) = delete;
1016
1017#endif // _LIBCPP_STD_VER >= 20
183#include <version>
1018184
1019extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<char>;
1020#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
1021extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ostream<wchar_t>;
185#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
186# pragma GCC system_header
1022187#endif
1023188
1024#if _LIBCPP_STD_VER >= 23
1025
1026template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1027_LIBCPP_HIDE_FROM_ABI inline void
1028__vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
1029 // [ostream.formatted.print]/3
1030 // Effects: Behaves as a formatted output function
1031 // ([ostream.formatted.reqmts]) of os, except that:
1032 // - failure to generate output is reported as specified below, and
1033 // - any exception thrown by the call to vformat is propagated without regard
1034 // to the value of os.exceptions() and without turning on ios_base::badbit
1035 // in the error state of os.
1036 // After constructing a sentry object, the function initializes an automatic
1037 // variable via
1038 // string out = vformat(os.getloc(), fmt, args);
1039
1040 ostream::sentry __s(__os);
1041 if (__s) {
1042 string __o = std::vformat(__os.getloc(), __fmt, __args);
1043 if (__write_nl)
1044 __o += '\n';
1045
1046 const char* __str = __o.data();
1047 size_t __len = __o.size();
1048
1049# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1050 try {
1051# endif // _LIBCPP_HAS_NO_EXCEPTIONS
1052 typedef ostreambuf_iterator<char> _Ip;
1053 if (std::__pad_and_output(
1054 _Ip(__os),
1055 __str,
1056 (__os.flags() & ios_base::adjustfield) == ios_base::left ? __str + __len : __str,
1057 __str + __len,
1058 __os,
1059 __os.fill())
1060 .failed())
1061 __os.setstate(ios_base::badbit | ios_base::failbit);
1062
1063# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1064 } catch (...) {
1065 __os.__set_badbit_and_consider_rethrow();
1066 }
1067# endif // _LIBCPP_HAS_NO_EXCEPTIONS
1068 }
1069}
1070
1071template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1072_LIBCPP_HIDE_FROM_ABI inline void vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args) {
1073 std::__vprint_nonunicode(__os, __fmt, __args, false);
1074}
1075
1076// Returns the FILE* associated with the __os.
1077// Returns a nullptr when no FILE* is associated with __os.
1078// This function is in the dylib since the type of the buffer associated
1079// with std::cout, std::cerr, and std::clog is only known in the dylib.
1080//
1081// This function implements part of the implementation-defined behavior
1082// of [ostream.formatted.print]/3
1083// If the function is vprint_unicode and os is a stream that refers to
1084// a terminal capable of displaying Unicode which is determined in an
1085// implementation-defined manner, writes out to the terminal using the
1086// native Unicode API;
1087// Whether the returned FILE* is "a terminal capable of displaying Unicode"
1088// is determined in the same way as the print(FILE*, ...) overloads.
1089_LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os);
1090
1091# ifndef _LIBCPP_HAS_NO_UNICODE
1092template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1093_LIBCPP_HIDE_FROM_ABI void
1094__vprint_unicode(ostream& __os, string_view __fmt, format_args __args, bool __write_nl) {
1095#if _LIBCPP_AVAILABILITY_HAS_PRINT == 0
1096 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
1097#else
1098 FILE* __file = std::__get_ostream_file(__os);
1099 if (!__file || !__print::__is_terminal(__file))
1100 return std::__vprint_nonunicode(__os, __fmt, __args, __write_nl);
1101
1102 // [ostream.formatted.print]/3
1103 // If the function is vprint_unicode and os is a stream that refers to a
1104 // terminal capable of displaying Unicode which is determined in an
1105 // implementation-defined manner, writes out to the terminal using the
1106 // native Unicode API; if out contains invalid code units, the behavior is
1107 // undefined and implementations are encouraged to diagnose it. If the
1108 // native Unicode API is used, the function flushes os before writing out.
1109 //
1110 // This is the path for the native API, start with flushing.
1111 __os.flush();
1112
1113# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1114 try {
1115# endif // _LIBCPP_HAS_NO_EXCEPTIONS
1116 ostream::sentry __s(__os);
1117 if (__s) {
1118# ifndef _LIBCPP_WIN32API
1119 __print::__vprint_unicode_posix(__file, __fmt, __args, __write_nl, true);
1120# elif !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
1121 __print::__vprint_unicode_windows(__file, __fmt, __args, __write_nl, true);
1122# else
1123# error "Windows builds with wchar_t disabled are not supported."
1124# endif
1125 }
1126
1127# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
1128 } catch (...) {
1129 __os.__set_badbit_and_consider_rethrow();
1130 }
1131# endif // _LIBCPP_HAS_NO_EXCEPTIONS
1132#endif // _LIBCPP_AVAILABILITY_HAS_PRINT
1133}
1134
1135template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
1136_LIBCPP_HIDE_FROM_ABI inline void
1137vprint_unicode(ostream& __os, string_view __fmt, format_args __args) {
1138 std::__vprint_unicode(__os, __fmt, __args, false);
1139}
1140# endif // _LIBCPP_HAS_NO_UNICODE
1141
1142template <class... _Args>
1143_LIBCPP_HIDE_FROM_ABI void
1144print(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
1145# ifndef _LIBCPP_HAS_NO_UNICODE
1146 if constexpr (__print::__use_unicode_execution_charset)
1147 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), false);
1148 else
1149 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
1150# else // _LIBCPP_HAS_NO_UNICODE
1151 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), false);
1152# endif // _LIBCPP_HAS_NO_UNICODE
1153}
1154
1155template <class... _Args>
1156_LIBCPP_HIDE_FROM_ABI void
1157println(ostream& __os, format_string<_Args...> __fmt, _Args&&... __args) {
1158# ifndef _LIBCPP_HAS_NO_UNICODE
1159 // Note the wording in the Standard is inefficient. The output of
1160 // std::format is a std::string which is then copied. This solution
1161 // just appends a newline at the end of the output.
1162 if constexpr (__print::__use_unicode_execution_charset)
1163 std::__vprint_unicode(__os, __fmt.get(), std::make_format_args(__args...), true);
1164 else
1165 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
1166# else // _LIBCPP_HAS_NO_UNICODE
1167 std::__vprint_nonunicode(__os, __fmt.get(), std::make_format_args(__args...), true);
1168# endif // _LIBCPP_HAS_NO_UNICODE
1169}
1170
1171#endif // _LIBCPP_STD_VER >= 23
1172
1173_LIBCPP_END_NAMESPACE_STD
1174
1175_LIBCPP_POP_MACROS
1176
1177189#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1178190# include <atomic>
1179191# include <concepts>
192# include <cstdio>
1180193# include <cstdlib>
194# include <format>
1181195# include <iosfwd>
1182196# include <iterator>
197# include <print>
1183198# include <stdexcept>
1184199# include <type_traits>
1185200#endif
lib/libcxx/include/print+13-2
......@@ -15,8 +15,10 @@ namespace std {
1515 // [print.fun], print functions
1616 template<class... Args>
1717 void print(format_string<Args...> fmt, Args&&... args);
18 void println(); // Since C++26
1819 template<class... Args>
1920 void print(FILE* stream, format_string<Args...> fmt, Args&&... args);
21 void println(FILE* stream); // Since C++26
2022
2123 template<class... Args>
2224 void println(format_string<Args...> fmt, Args&&... args);
......@@ -31,8 +33,7 @@ namespace std {
3133}
3234*/
3335
34#include <__assert> // all public C++ headers provide the assertion handler
35#include <__availability>
36#include <__assert>
3637#include <__concepts/same_as.h>
3738#include <__config>
3839#include <__system_error/system_error.h>
......@@ -356,6 +357,16 @@ _LIBCPP_HIDE_FROM_ABI void println(FILE* __stream, format_string<_Args...> __fmt
356357# endif // _LIBCPP_HAS_NO_UNICODE
357358}
358359
360template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
361_LIBCPP_HIDE_FROM_ABI inline void println(FILE* __stream) {
362 std::print(__stream, "\n");
363}
364
365template <class = void> // TODO PRINT template or availability markup fires too eagerly (http://llvm.org/PR61563).
366_LIBCPP_HIDE_FROM_ABI inline void println() {
367 println(stdout);
368}
369
359370template <class... _Args>
360371_LIBCPP_HIDE_FROM_ABI void println(format_string<_Args...> __fmt, _Args&&... __args) {
361372 std::println(stdout, __fmt, std::forward<_Args>(__args)...);
lib/libcxx/include/queue+135-165
......@@ -258,9 +258,10 @@ template <class T, class Container, class Compare>
258258#include <__algorithm/pop_heap.h>
259259#include <__algorithm/push_heap.h>
260260#include <__algorithm/ranges_copy.h>
261#include <__assert> // all public C++ headers provide the assertion handler
262261#include <__config>
263262#include <__functional/operations.h>
263#include <__fwd/deque.h>
264#include <__fwd/queue.h>
264265#include <__iterator/back_insert_iterator.h>
265266#include <__iterator/iterator_traits.h>
266267#include <__memory/uses_allocator.h>
......@@ -288,9 +289,6 @@ _LIBCPP_PUSH_MACROS
288289
289290_LIBCPP_BEGIN_NAMESPACE_STD
290291
291template <class _Tp, class _Container = deque<_Tp> >
292class _LIBCPP_TEMPLATE_VIS queue;
293
294292template <class _Tp, class _Container>
295293_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y);
296294
......@@ -305,7 +303,7 @@ public:
305303 typedef typename container_type::reference reference;
306304 typedef typename container_type::const_reference const_reference;
307305 typedef typename container_type::size_type size_type;
308 static_assert((is_same<_Tp, value_type>::value), "");
306 static_assert(is_same<_Tp, value_type>::value, "");
309307
310308protected:
311309 container_type c;
......@@ -316,7 +314,7 @@ public:
316314 _LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {}
317315
318316#if _LIBCPP_STD_VER >= 23
319 template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
317 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
320318 _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
321319
322320 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -324,14 +322,14 @@ public:
324322
325323 template <class _InputIterator,
326324 class _Alloc,
327 class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
328 class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
325 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
326 __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
329327 _LIBCPP_HIDE_FROM_ABI queue(_InputIterator __first, _InputIterator __second, const _Alloc& __alloc)
330328 : c(__first, __second, __alloc) {}
331329
332330 template <_ContainerCompatibleRange<_Tp> _Range,
333331 class _Alloc,
334 class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
332 __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
335333 _LIBCPP_HIDE_FROM_ABI queue(from_range_t, _Range&& __range, const _Alloc& __alloc)
336334 : c(from_range, std::forward<_Range>(__range), __alloc) {}
337335
......@@ -343,10 +341,10 @@ public:
343341 }
344342
345343#ifndef _LIBCPP_CXX03_LANG
346 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
344 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)
347345 : c(std::move(__q.c)) {}
348346
349 _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) {
347 _LIBCPP_HIDE_FROM_ABI queue& operator=(queue&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) {
350348 c = std::move(__q.c);
351349 return *this;
352350 }
......@@ -356,31 +354,25 @@ public:
356354#ifndef _LIBCPP_CXX03_LANG
357355 _LIBCPP_HIDE_FROM_ABI explicit queue(container_type&& __c) : c(std::move(__c)) {}
358356#endif // _LIBCPP_CXX03_LANG
359 template <class _Alloc>
360 _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a,
361 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
362 : c(__a) {}
363 template <class _Alloc>
364 _LIBCPP_HIDE_FROM_ABI
365 queue(const queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
366 : c(__q.c, __a) {}
367 template <class _Alloc>
368 _LIBCPP_HIDE_FROM_ABI
369 queue(const container_type& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
370 : c(__c, __a) {}
357
358 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
359 _LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {}
360
361 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
362 _LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {}
363
364 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
365 _LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {}
366
371367#ifndef _LIBCPP_CXX03_LANG
372 template <class _Alloc>
373 _LIBCPP_HIDE_FROM_ABI
374 queue(container_type&& __c, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
375 : c(std::move(__c), __a) {}
376 template <class _Alloc>
377 _LIBCPP_HIDE_FROM_ABI
378 queue(queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0)
379 : c(std::move(__q.c), __a) {}
368 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
369 _LIBCPP_HIDE_FROM_ABI queue(container_type&& __c, const _Alloc& __a) : c(std::move(__c), __a) {}
380370
371 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
372 _LIBCPP_HIDE_FROM_ABI queue(queue&& __q, const _Alloc& __a) : c(std::move(__q.c), __a) {}
381373#endif // _LIBCPP_CXX03_LANG
382374
383 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
375 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
384376 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
385377
386378 _LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); }
......@@ -406,20 +398,20 @@ public:
406398 template <class... _Args>
407399 _LIBCPP_HIDE_FROM_ABI
408400# if _LIBCPP_STD_VER >= 17
409 decltype(auto)
410 emplace(_Args&&... __args) {
401 decltype(auto)
402 emplace(_Args&&... __args) {
411403 return c.emplace_back(std::forward<_Args>(__args)...);
412404 }
413405# else
414 void
415 emplace(_Args&&... __args) {
406 void
407 emplace(_Args&&... __args) {
416408 c.emplace_back(std::forward<_Args>(__args)...);
417409 }
418410# endif
419411#endif // _LIBCPP_CXX03_LANG
420412 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); }
421413
422 _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) {
414 _LIBCPP_HIDE_FROM_ABI void swap(queue& __q) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) {
423415 using std::swap;
424416 swap(c, __q.c);
425417 }
......@@ -447,7 +439,7 @@ queue(_Container, _Alloc) -> queue<typename _Container::value_type, _Container>;
447439#endif
448440
449441#if _LIBCPP_STD_VER >= 23
450template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
442template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
451443queue(_InputIterator, _InputIterator) -> queue<__iter_value_type<_InputIterator>>;
452444
453445template <ranges::input_range _Range>
......@@ -455,14 +447,16 @@ queue(from_range_t, _Range&&) -> queue<ranges::range_value_t<_Range>>;
455447
456448template <class _InputIterator,
457449 class _Alloc,
458 class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
459 class = __enable_if_t<__is_allocator<_Alloc>::value>>
460queue(_InputIterator, _InputIterator, _Alloc)
461 -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
462
463template <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>>
464queue(from_range_t, _Range&&, _Alloc)
465 -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
450 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
451 __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
452queue(_InputIterator,
453 _InputIterator,
454 _Alloc) -> queue<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
455
456template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
457queue(from_range_t,
458 _Range&&,
459 _Alloc) -> queue<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
466460#endif
467461
468462template <class _Tp, class _Container>
......@@ -506,7 +500,7 @@ operator<=>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y
506500
507501#endif
508502
509template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
503template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
510504inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)
511505 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
512506 __x.swap(__y);
......@@ -516,7 +510,7 @@ template <class _Tp, class _Container, class _Alloc>
516510struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> {
517511};
518512
519template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> >
513template <class _Tp, class _Container, class _Compare>
520514class _LIBCPP_TEMPLATE_VIS priority_queue {
521515public:
522516 typedef _Container container_type;
......@@ -525,7 +519,7 @@ public:
525519 typedef typename container_type::reference reference;
526520 typedef typename container_type::const_reference const_reference;
527521 typedef typename container_type::size_type size_type;
528 static_assert((is_same<_Tp, value_type>::value), "");
522 static_assert(is_same<_Tp, value_type>::value, "");
529523
530524protected:
531525 container_type c;
......@@ -545,12 +539,12 @@ public:
545539 }
546540
547541#ifndef _LIBCPP_CXX03_LANG
548 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) _NOEXCEPT_(
549 is_nothrow_move_constructible<container_type>::value&& is_nothrow_move_constructible<value_compare>::value)
542 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q) noexcept(
543 is_nothrow_move_constructible<container_type>::value && is_nothrow_move_constructible<value_compare>::value)
550544 : c(std::move(__q.c)), comp(std::move(__q.comp)) {}
551545
552 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q)
553 _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value&& is_nothrow_move_assignable<value_compare>::value) {
546 _LIBCPP_HIDE_FROM_ABI priority_queue& operator=(priority_queue&& __q) noexcept(
547 is_nothrow_move_assignable<container_type>::value && is_nothrow_move_assignable<value_compare>::value) {
554548 c = std::move(__q.c);
555549 comp = std::move(__q.comp);
556550 return *this;
......@@ -562,13 +556,15 @@ public:
562556#ifndef _LIBCPP_CXX03_LANG
563557 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c);
564558#endif
565 template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
559 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
566560 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare());
567 template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
561
562 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
568563 _LIBCPP_HIDE_FROM_ABI
569564 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c);
565
570566#ifndef _LIBCPP_CXX03_LANG
571 template <class _InputIter, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
567 template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0>
572568 _LIBCPP_HIDE_FROM_ABI
573569 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c);
574570#endif // _LIBCPP_CXX03_LANG
......@@ -581,68 +577,56 @@ public:
581577 }
582578#endif
583579
584 template <class _Alloc>
585 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a,
586 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
587 template <class _Alloc>
588 _LIBCPP_HIDE_FROM_ABI
589 priority_queue(const value_compare& __comp,
590 const _Alloc& __a,
591 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
592 template <class _Alloc>
593 _LIBCPP_HIDE_FROM_ABI
594 priority_queue(const value_compare& __comp,
595 const container_type& __c,
596 const _Alloc& __a,
597 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
598 template <class _Alloc>
599 _LIBCPP_HIDE_FROM_ABI priority_queue(
600 const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
601#ifndef _LIBCPP_CXX03_LANG
602 template <class _Alloc>
603 _LIBCPP_HIDE_FROM_ABI
604 priority_queue(const value_compare& __comp,
605 container_type&& __c,
606 const _Alloc& __a,
607 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
608 template <class _Alloc>
609 _LIBCPP_HIDE_FROM_ABI priority_queue(
610 priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
611#endif // _LIBCPP_CXX03_LANG
580 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
581 _LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a);
612582
613 template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
614 _LIBCPP_HIDE_FROM_ABI
615 priority_queue(_InputIter __f,
616 _InputIter __l,
617 const _Alloc& __a,
618 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
583 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
584 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a);
619585
620 template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
621 _LIBCPP_HIDE_FROM_ABI priority_queue(
622 _InputIter __f,
623 _InputIter __l,
624 const value_compare& __comp,
625 const _Alloc& __a,
626 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
586 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
587 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a);
627588
628 template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
629 _LIBCPP_HIDE_FROM_ABI priority_queue(
630 _InputIter __f,
631 _InputIter __l,
632 const value_compare& __comp,
633 const container_type& __c,
634 const _Alloc& __a,
635 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
589 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
590 _LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a);
636591
637592#ifndef _LIBCPP_CXX03_LANG
638 template <class _InputIter, class _Alloc, class = __enable_if_t<__has_input_iterator_category<_InputIter>::value> >
593 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
594 _LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, container_type&& __c, const _Alloc& __a);
595
596 template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
597 _LIBCPP_HIDE_FROM_ABI priority_queue(priority_queue&& __q, const _Alloc& __a);
598#endif // _LIBCPP_CXX03_LANG
599
600 template <
601 class _InputIter,
602 class _Alloc,
603 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
604 int> = 0>
605 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a);
606
607 template <
608 class _InputIter,
609 class _Alloc,
610 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
611 int> = 0>
612 _LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a);
613
614 template <
615 class _InputIter,
616 class _Alloc,
617 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
618 int> = 0>
639619 _LIBCPP_HIDE_FROM_ABI priority_queue(
640 _InputIter __f,
641 _InputIter __l,
642 const value_compare& __comp,
643 container_type&& __c,
644 const _Alloc& __a,
645 __enable_if_t<uses_allocator<container_type, _Alloc>::value>* = 0);
620 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a);
621
622#ifndef _LIBCPP_CXX03_LANG
623 template <
624 class _InputIter,
625 class _Alloc,
626 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value,
627 int> = 0>
628 _LIBCPP_HIDE_FROM_ABI
629 priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a);
646630#endif // _LIBCPP_CXX03_LANG
647631
648632#if _LIBCPP_STD_VER >= 23
......@@ -665,7 +649,7 @@ public:
665649
666650#endif
667651
668 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
652 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
669653 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
670654 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); }
671655
......@@ -692,7 +676,7 @@ public:
692676 _LIBCPP_HIDE_FROM_ABI void pop();
693677
694678 _LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q)
695 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value);
679 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>);
696680
697681 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; }
698682};
......@@ -792,7 +776,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_com
792776#endif // _LIBCPP_CXX03_LANG
793777
794778template <class _Tp, class _Container, class _Compare>
795template <class _InputIter, class>
779template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
796780inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
797781 _InputIter __f, _InputIter __l, const value_compare& __comp)
798782 : c(__f, __l), comp(__comp) {
......@@ -800,7 +784,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
800784}
801785
802786template <class _Tp, class _Container, class _Compare>
803template <class _InputIter, class>
787template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
804788inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
805789 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c)
806790 : c(__c), comp(__comp) {
......@@ -811,7 +795,7 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
811795#ifndef _LIBCPP_CXX03_LANG
812796
813797template <class _Tp, class _Container, class _Compare>
814template <class _InputIter, class>
798template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> >
815799inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
816800 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c)
817801 : c(std::move(__c)), comp(__comp) {
......@@ -822,84 +806,72 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
822806#endif // _LIBCPP_CXX03_LANG
823807
824808template <class _Tp, class _Container, class _Compare>
825template <class _Alloc>
826inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
827 const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
828 : c(__a) {}
809template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
810inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {}
829811
830812template <class _Tp, class _Container, class _Compare>
831template <class _Alloc>
832inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
833 const value_compare& __comp, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
813template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
814inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a)
834815 : c(__a), comp(__comp) {}
835816
836817template <class _Tp, class _Container, class _Compare>
837template <class _Alloc>
818template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
838819inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
839 const value_compare& __comp,
840 const container_type& __c,
841 const _Alloc& __a,
842 __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
820 const value_compare& __comp, const container_type& __c, const _Alloc& __a)
843821 : c(__c, __a), comp(__comp) {
844822 std::make_heap(c.begin(), c.end(), comp);
845823}
846824
847825template <class _Tp, class _Container, class _Compare>
848template <class _Alloc>
849inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
850 const priority_queue& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
826template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
827inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a)
851828 : c(__q.c, __a), comp(__q.comp) {}
852829
853830#ifndef _LIBCPP_CXX03_LANG
854831
855832template <class _Tp, class _Container, class _Compare>
856template <class _Alloc>
833template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
857834inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
858 const value_compare& __comp,
859 container_type&& __c,
860 const _Alloc& __a,
861 __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
835 const value_compare& __comp, container_type&& __c, const _Alloc& __a)
862836 : c(std::move(__c), __a), comp(__comp) {
863837 std::make_heap(c.begin(), c.end(), comp);
864838}
865839
866840template <class _Tp, class _Container, class _Compare>
867template <class _Alloc>
868inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
869 priority_queue&& __q, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
841template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> >
842inline priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, const _Alloc& __a)
870843 : c(std::move(__q.c), __a), comp(std::move(__q.comp)) {}
871844
872845#endif // _LIBCPP_CXX03_LANG
873846
874847template <class _Tp, class _Container, class _Compare>
875template <class _InputIter, class _Alloc, class>
876inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
877 _InputIter __f, _InputIter __l, const _Alloc& __a, __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
848template <
849 class _InputIter,
850 class _Alloc,
851 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
852inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a)
878853 : c(__f, __l, __a), comp() {
879854 std::make_heap(c.begin(), c.end(), comp);
880855}
881856
882857template <class _Tp, class _Container, class _Compare>
883template <class _InputIter, class _Alloc, class>
858template <
859 class _InputIter,
860 class _Alloc,
861 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
884862inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
885 _InputIter __f,
886 _InputIter __l,
887 const value_compare& __comp,
888 const _Alloc& __a,
889 __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
863 _InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a)
890864 : c(__f, __l, __a), comp(__comp) {
891865 std::make_heap(c.begin(), c.end(), comp);
892866}
893867
894868template <class _Tp, class _Container, class _Compare>
895template <class _InputIter, class _Alloc, class>
869template <
870 class _InputIter,
871 class _Alloc,
872 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
896873inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
897 _InputIter __f,
898 _InputIter __l,
899 const value_compare& __comp,
900 const container_type& __c,
901 const _Alloc& __a,
902 __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
874 _InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a)
903875 : c(__c, __a), comp(__comp) {
904876 c.insert(c.end(), __f, __l);
905877 std::make_heap(c.begin(), c.end(), comp);
......@@ -907,14 +879,12 @@ inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
907879
908880#ifndef _LIBCPP_CXX03_LANG
909881template <class _Tp, class _Container, class _Compare>
910template <class _InputIter, class _Alloc, class>
882template <
883 class _InputIter,
884 class _Alloc,
885 __enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> >
911886inline priority_queue<_Tp, _Container, _Compare>::priority_queue(
912 _InputIter __f,
913 _InputIter __l,
914 const value_compare& __comp,
915 container_type&& __c,
916 const _Alloc& __a,
917 __enable_if_t<uses_allocator<container_type, _Alloc>::value>*)
887 _InputIter __f, _InputIter __l, const value_compare& __comp, container_type&& __c, const _Alloc& __a)
918888 : c(std::move(__c), __a), comp(__comp) {
919889 c.insert(c.end(), __f, __l);
920890 std::make_heap(c.begin(), c.end(), comp);
......@@ -952,7 +922,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::pop() {
952922
953923template <class _Tp, class _Container, class _Compare>
954924inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
955 _NOEXCEPT_(__is_nothrow_swappable<container_type>::value&& __is_nothrow_swappable<value_compare>::value) {
925 _NOEXCEPT_(__is_nothrow_swappable_v<container_type>&& __is_nothrow_swappable_v<value_compare>) {
956926 using std::swap;
957927 swap(c, __q.c);
958928 swap(comp, __q.comp);
......@@ -961,7 +931,7 @@ inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)
961931template <class _Tp,
962932 class _Container,
963933 class _Compare,
964 __enable_if_t<__is_swappable<_Container>::value && __is_swappable<_Compare>::value, int> = 0>
934 __enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0>
965935inline _LIBCPP_HIDE_FROM_ABI void
966936swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y)
967937 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
lib/libcxx/include/random-4
......@@ -1677,13 +1677,11 @@ class piecewise_linear_distribution
16771677} // std
16781678*/
16791679
1680#include <__assert> // all public C++ headers provide the assertion handler
16811680#include <__config>
16821681#include <__random/bernoulli_distribution.h>
16831682#include <__random/binomial_distribution.h>
16841683#include <__random/cauchy_distribution.h>
16851684#include <__random/chi_squared_distribution.h>
1686#include <__random/clamp_to_integral.h>
16871685#include <__random/default_random_engine.h>
16881686#include <__random/discard_block_engine.h>
16891687#include <__random/discrete_distribution.h>
......@@ -1695,10 +1693,8 @@ class piecewise_linear_distribution
16951693#include <__random/geometric_distribution.h>
16961694#include <__random/independent_bits_engine.h>
16971695#include <__random/is_seed_sequence.h>
1698#include <__random/is_valid.h>
16991696#include <__random/knuth_b.h>
17001697#include <__random/linear_congruential_engine.h>
1701#include <__random/log2.h>
17021698#include <__random/lognormal_distribution.h>
17031699#include <__random/mersenne_twister_engine.h>
17041700#include <__random/negative_binomial_distribution.h>
lib/libcxx/include/ranges+60-41
......@@ -93,6 +93,11 @@ namespace std::ranges {
9393 template<class T>
9494 concept viewable_range = see below;
9595
96 // [range.adaptor.object], range adaptor objects
97 template<class D>
98 requires is_class_v<D> && same_as<D, remove_cv_t<D>>
99 class range_adaptor_closure { }; // Since c++23
100
96101 // [view.interface], class template view_interface
97102 template<class D>
98103 requires is_class_v<D> && same_as<D, remove_cv_t<D>>
......@@ -375,51 +380,57 @@ namespace std {
375380}
376381*/
377382
378#include <__assert> // all public C++ headers provide the assertion handler
379383#include <__config>
380#include <__ranges/access.h>
381#include <__ranges/all.h>
382#include <__ranges/as_rvalue_view.h>
383#include <__ranges/chunk_by_view.h>
384#include <__ranges/common_view.h>
385#include <__ranges/concepts.h>
386#include <__ranges/counted.h>
387#include <__ranges/dangling.h>
388#include <__ranges/data.h>
389#include <__ranges/drop_view.h>
390#include <__ranges/drop_while_view.h>
391#include <__ranges/elements_view.h>
392#include <__ranges/empty.h>
393#include <__ranges/empty_view.h>
394#include <__ranges/enable_borrowed_range.h>
395#include <__ranges/enable_view.h>
396#include <__ranges/filter_view.h>
397#include <__ranges/from_range.h>
398#include <__ranges/iota_view.h>
399#include <__ranges/join_view.h>
400#include <__ranges/lazy_split_view.h>
401#include <__ranges/rbegin.h>
402#include <__ranges/ref_view.h>
403#include <__ranges/rend.h>
404#include <__ranges/repeat_view.h>
405#include <__ranges/reverse_view.h>
406#include <__ranges/single_view.h>
407#include <__ranges/size.h>
408#include <__ranges/split_view.h>
409#include <__ranges/subrange.h>
410#include <__ranges/take_view.h>
411#include <__ranges/take_while_view.h>
412#include <__ranges/to.h>
413#include <__ranges/transform_view.h>
414#include <__ranges/view_interface.h>
415#include <__ranges/views.h>
416#include <__ranges/zip_view.h>
417#include <version>
418384
419#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
420# include <__ranges/istream_view.h>
385#if _LIBCPP_STD_VER >= 20
386# include <__ranges/access.h>
387# include <__ranges/all.h>
388# include <__ranges/common_view.h>
389# include <__ranges/concepts.h>
390# include <__ranges/counted.h>
391# include <__ranges/dangling.h>
392# include <__ranges/data.h>
393# include <__ranges/drop_view.h>
394# include <__ranges/drop_while_view.h>
395# include <__ranges/elements_view.h>
396# include <__ranges/empty.h>
397# include <__ranges/empty_view.h>
398# include <__ranges/enable_borrowed_range.h>
399# include <__ranges/enable_view.h>
400# include <__ranges/filter_view.h>
401# include <__ranges/iota_view.h>
402# include <__ranges/join_view.h>
403# include <__ranges/lazy_split_view.h>
404# include <__ranges/rbegin.h>
405# include <__ranges/ref_view.h>
406# include <__ranges/rend.h>
407# include <__ranges/reverse_view.h>
408# include <__ranges/single_view.h>
409# include <__ranges/size.h>
410# include <__ranges/split_view.h>
411# include <__ranges/subrange.h>
412# include <__ranges/take_view.h>
413# include <__ranges/take_while_view.h>
414# include <__ranges/transform_view.h>
415# include <__ranges/view_interface.h>
416# include <__ranges/views.h>
417
418# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
419# include <__ranges/istream_view.h>
420# endif
421#endif
422
423#if _LIBCPP_STD_VER >= 23
424# include <__ranges/as_rvalue_view.h>
425# include <__ranges/chunk_by_view.h>
426# include <__ranges/from_range.h>
427# include <__ranges/repeat_view.h>
428# include <__ranges/to.h>
429# include <__ranges/zip_view.h>
421430#endif
422431
432#include <version>
433
423434// standard-mandated includes
424435
425436// [ranges.syn]
......@@ -435,6 +446,14 @@ namespace std {
435446# pragma GCC system_header
436447#endif
437448
449#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
450# include <cstddef>
451# include <limits>
452# include <optional>
453# include <span>
454# include <tuple>
455#endif
456
438457#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
439458# include <cstdlib>
440459# include <iosfwd>
lib/libcxx/include/ratio+36-7
......@@ -81,7 +81,6 @@ using quetta = ratio <1'000'000'000'000'000'000'000'000'000'000, 1>; // Since C+
8181}
8282*/
8383
84#include <__assert> // all public C++ headers provide the assertion handler
8584#include <__config>
8685#include <__type_traits/integral_constant.h>
8786#include <climits>
......@@ -289,6 +288,9 @@ private:
289288 static const intmax_t __gcd_n1_d2 = __static_gcd<_R1::num, _R2::den>::value;
290289 static const intmax_t __gcd_d1_n2 = __static_gcd<_R1::den, _R2::num>::value;
291290
291 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
292 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
293
292294public:
293295 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_d2, _R2::num / __gcd_d1_n2>::value,
294296 __ll_mul<_R2::den / __gcd_n1_d2, _R1::den / __gcd_d1_n2>::value >::type type;
......@@ -312,6 +314,9 @@ private:
312314 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
313315 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
314316
317 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
318 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
319
315320public:
316321 typedef typename ratio< __ll_mul<_R1::num / __gcd_n1_n2, _R2::den / __gcd_d1_d2>::value,
317322 __ll_mul<_R2::num / __gcd_n1_n2, _R1::den / __gcd_d1_d2>::value >::type type;
......@@ -335,6 +340,9 @@ private:
335340 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
336341 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
337342
343 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
344 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
345
338346public:
339347 typedef typename ratio_multiply<
340348 ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
......@@ -361,6 +369,9 @@ private:
361369 static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value;
362370 static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value;
363371
372 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
373 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
374
364375public:
365376 typedef typename ratio_multiply<
366377 ratio<__gcd_n1_n2, _R1::den / __gcd_d1_d2>,
......@@ -384,10 +395,16 @@ struct _LIBCPP_TEMPLATE_VIS ratio_subtract : public __ratio_subtract<_R1, _R2>::
384395// ratio_equal
385396
386397template <class _R1, class _R2>
387struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {};
398struct _LIBCPP_TEMPLATE_VIS ratio_equal : _BoolConstant<(_R1::num == _R2::num && _R1::den == _R2::den)> {
399 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
400 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
401};
388402
389403template <class _R1, class _R2>
390struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {};
404struct _LIBCPP_TEMPLATE_VIS ratio_not_equal : _BoolConstant<!ratio_equal<_R1, _R2>::value> {
405 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
406 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
407};
391408
392409// ratio_less
393410
......@@ -441,16 +458,28 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> {
441458};
442459
443460template <class _R1, class _R2>
444struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {};
461struct _LIBCPP_TEMPLATE_VIS ratio_less : _BoolConstant<__ratio_less<_R1, _R2>::value> {
462 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
463 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
464};
445465
446466template <class _R1, class _R2>
447struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {};
467struct _LIBCPP_TEMPLATE_VIS ratio_less_equal : _BoolConstant<!ratio_less<_R2, _R1>::value> {
468 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
469 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
470};
448471
449472template <class _R1, class _R2>
450struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {};
473struct _LIBCPP_TEMPLATE_VIS ratio_greater : _BoolConstant<ratio_less<_R2, _R1>::value> {
474 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
475 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
476};
451477
452478template <class _R1, class _R2>
453struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {};
479struct _LIBCPP_TEMPLATE_VIS ratio_greater_equal : _BoolConstant<!ratio_less<_R1, _R2>::value> {
480 static_assert(__is_ratio<_R1>::value, "[ratio.general]/2 requires R1 to be a specialisation of the ratio template");
481 static_assert(__is_ratio<_R2>::value, "[ratio.general]/2 requires R2 to be a specialisation of the ratio template");
482};
454483
455484template <class _R1, class _R2>
456485struct __ratio_gcd {
lib/libcxx/include/regex+39-28
......@@ -791,8 +791,7 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
791791
792792#include <__algorithm/find.h>
793793#include <__algorithm/search.h>
794#include <__assert> // all public C++ headers provide the assertion handler
795#include <__availability>
794#include <__assert>
796795#include <__config>
797796#include <__iterator/back_insert_iterator.h>
798797#include <__iterator/default_sentinel.h>
......@@ -1346,13 +1345,12 @@ struct __state {
13461345
13471346template <class _CharT>
13481347class __node {
1349 __node(const __node&);
1350 __node& operator=(const __node&);
1351
13521348public:
13531349 typedef std::__state<_CharT> __state;
13541350
13551351 _LIBCPP_HIDE_FROM_ABI __node() {}
1352 __node(const __node&) = delete;
1353 __node& operator=(const __node&) = delete;
13561354 _LIBCPP_HIDE_FROM_ABI_VIRTUAL
13571355 virtual ~__node() {}
13581356
......@@ -1953,14 +1951,14 @@ class __match_char : public __owns_one_state<_CharT> {
19531951
19541952 _CharT __c_;
19551953
1956 __match_char(const __match_char&);
1957 __match_char& operator=(const __match_char&);
1958
19591954public:
19601955 typedef std::__state<_CharT> __state;
19611956
19621957 _LIBCPP_HIDE_FROM_ABI __match_char(_CharT __c, __node<_CharT>* __s) : base(__s), __c_(__c) {}
19631958
1959 __match_char(const __match_char&) = delete;
1960 __match_char& operator=(const __match_char&) = delete;
1961
19641962 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const;
19651963};
19661964
......@@ -1985,15 +1983,15 @@ class __match_char_icase : public __owns_one_state<_CharT> {
19851983 _Traits __traits_;
19861984 _CharT __c_;
19871985
1988 __match_char_icase(const __match_char_icase&);
1989 __match_char_icase& operator=(const __match_char_icase&);
1990
19911986public:
19921987 typedef std::__state<_CharT> __state;
19931988
19941989 _LIBCPP_HIDE_FROM_ABI __match_char_icase(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
19951990 : base(__s), __traits_(__traits), __c_(__traits.translate_nocase(__c)) {}
19961991
1992 __match_char_icase(const __match_char_icase&) = delete;
1993 __match_char_icase& operator=(const __match_char_icase&) = delete;
1994
19971995 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const;
19981996};
19991997
......@@ -2018,15 +2016,15 @@ class __match_char_collate : public __owns_one_state<_CharT> {
20182016 _Traits __traits_;
20192017 _CharT __c_;
20202018
2021 __match_char_collate(const __match_char_collate&);
2022 __match_char_collate& operator=(const __match_char_collate&);
2023
20242019public:
20252020 typedef std::__state<_CharT> __state;
20262021
20272022 _LIBCPP_HIDE_FROM_ABI __match_char_collate(const _Traits& __traits, _CharT __c, __node<_CharT>* __s)
20282023 : base(__s), __traits_(__traits), __c_(__traits.translate(__c)) {}
20292024
2025 __match_char_collate(const __match_char_collate&) = delete;
2026 __match_char_collate& operator=(const __match_char_collate&) = delete;
2027
20302028 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const;
20312029};
20322030
......@@ -2062,9 +2060,6 @@ class __bracket_expression : public __owns_one_state<_CharT> {
20622060 bool __collate_;
20632061 bool __might_have_digraph_;
20642062
2065 __bracket_expression(const __bracket_expression&);
2066 __bracket_expression& operator=(const __bracket_expression&);
2067
20682063public:
20692064 typedef std::__state<_CharT> __state;
20702065
......@@ -2079,6 +2074,9 @@ public:
20792074 __collate_(__collate),
20802075 __might_have_digraph_(__traits_.getloc().name() != "C") {}
20812076
2077 __bracket_expression(const __bracket_expression&) = delete;
2078 __bracket_expression& operator=(const __bracket_expression&) = delete;
2079
20822080 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const;
20832081
20842082 _LIBCPP_HIDE_FROM_ABI bool __negated() const { return __negate_; }
......@@ -2700,9 +2698,6 @@ class __lookahead : public __owns_one_state<_CharT> {
27002698 unsigned __mexp_;
27012699 bool __invert_;
27022700
2703 __lookahead(const __lookahead&);
2704 __lookahead& operator=(const __lookahead&);
2705
27062701public:
27072702 typedef std::__state<_CharT> __state;
27082703
......@@ -2710,6 +2705,9 @@ public:
27102705 __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp)
27112706 : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {}
27122707
2708 __lookahead(const __lookahead&) = delete;
2709 __lookahead& operator=(const __lookahead&) = delete;
2710
27132711 _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __exec(__state&) const;
27142712};
27152713
......@@ -4215,11 +4213,7 @@ public:
42154213 _LIBCPP_HIDE_FROM_ABI int compare(const string_type& __s) const { return str().compare(__s); }
42164214 _LIBCPP_HIDE_FROM_ABI int compare(const value_type* __s) const { return str().compare(__s); }
42174215
4218 _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s)
4219#ifndef _LIBCPP_CXX03_LANG
4220 _NOEXCEPT(__is_nothrow_swappable<_BidirectionalIterator>::value)
4221#endif // _LIBCPP_CXX03_LANG
4222 {
4216 _LIBCPP_HIDE_FROM_ABI void swap(sub_match& __s) _NOEXCEPT_(__is_nothrow_swappable_v<_BidirectionalIterator>) {
42234217 this->pair<_BidirectionalIterator, _BidirectionalIterator>::swap(__s);
42244218 std::swap(matched, __s.matched);
42254219 }
......@@ -4583,7 +4577,7 @@ public:
45834577 // size:
45844578 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __matches_.size(); }
45854579 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __matches_.max_size(); }
4586 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
4580 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return size() == 0; }
45874581
45884582 // element access:
45894583 _LIBCPP_HIDE_FROM_ABI difference_type length(size_type __sub = 0) const {
......@@ -4701,6 +4695,9 @@ private:
47014695
47024696 template <class, class>
47034697 friend class __lookahead;
4698
4699 template <class, class, class>
4700 friend class regex_iterator;
47044701};
47054702
47064703template <class _BidirectionalIterator, class _Allocator>
......@@ -5411,7 +5408,9 @@ template <class _BidirectionalIterator, class _CharT, class _Traits>
54115408regex_iterator<_BidirectionalIterator, _CharT, _Traits>&
54125409regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {
54135410 __flags_ |= regex_constants::__no_update_pos;
5414 _BidirectionalIterator __start = __match_[0].second;
5411 _BidirectionalIterator __start = __match_[0].second;
5412 _BidirectionalIterator __prefix_start = __start;
5413
54155414 if (__match_[0].first == __match_[0].second) {
54165415 if (__start == __end_) {
54175416 __match_ = value_type();
......@@ -5425,9 +5424,21 @@ regex_iterator<_BidirectionalIterator, _CharT, _Traits>::operator++() {
54255424 else
54265425 ++__start;
54275426 }
5427
54285428 __flags_ |= regex_constants::match_prev_avail;
5429 if (!std::regex_search(__start, __end_, __match_, *__pregex_, __flags_))
5429 if (!std::regex_search(__start, __end_, __match_, *__pregex_, __flags_)) {
54305430 __match_ = value_type();
5431
5432 } else {
5433 // The Standard mandates that if `regex_search` returns true ([re.regiter.incr]), "`match.prefix().first` shall be
5434 // equal to the previous value of `match[0].second`... It is unspecified how the implementation makes these
5435 // adjustments." The adjustment is necessary if we incremented `__start` above (the branch that deals with
5436 // zero-length matches).
5437 auto& __prefix = __match_.__prefix_;
5438 __prefix.first = __prefix_start;
5439 __prefix.matched = __prefix.first != __prefix.second;
5440 }
5441
54315442 return *this;
54325443}
54335444
lib/libcxx/include/scoped_allocator+15-17
......@@ -109,7 +109,6 @@ template <class OuterA1, class OuterA2, class... InnerAllocs>
109109
110110*/
111111
112#include <__assert> // all public C++ headers provide the assertion handler
113112#include <__config>
114113#include <__memory/allocator_traits.h>
115114#include <__memory/uses_allocator_construction.h>
......@@ -314,7 +313,7 @@ false_type __has_outer_allocator_test(const volatile _Alloc& __a);
314313
315314template <class _Alloc>
316315struct __has_outer_allocator
317 : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>())) >::type {};
316 : public common_type< decltype(std::__has_outer_allocator_test(std::declval<_Alloc&>()))>::type {};
318317
319318template <class _Alloc, bool = __has_outer_allocator<_Alloc>::value>
320319struct __outermost {
......@@ -334,12 +333,12 @@ struct __outermost<_Alloc, true> {
334333template <class _OuterAlloc, class... _InnerAllocs>
335334class _LIBCPP_TEMPLATE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...>
336335 : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> {
337 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base;
336 typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> _Base;
338337 typedef allocator_traits<_OuterAlloc> _OuterTraits;
339338
340339public:
341340 typedef _OuterAlloc outer_allocator_type;
342 typedef typename base::inner_allocator_type inner_allocator_type;
341 typedef typename _Base::inner_allocator_type inner_allocator_type;
343342 typedef typename _OuterTraits::size_type size_type;
344343 typedef typename _OuterTraits::difference_type difference_type;
345344 typedef typename _OuterTraits::pointer pointer;
......@@ -365,35 +364,35 @@ public:
365364 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
366365 _LIBCPP_HIDE_FROM_ABI
367366 scoped_allocator_adaptor(_OuterA2&& __outer_alloc, const _InnerAllocs&... __inner_allocs) _NOEXCEPT
368 : base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
367 : _Base(std::forward<_OuterA2>(__outer_alloc), __inner_allocs...) {}
369368 // scoped_allocator_adaptor(const scoped_allocator_adaptor& __other) = default;
370369 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, const _OuterA2&>::value, int> = 0>
371370 _LIBCPP_HIDE_FROM_ABI
372371 scoped_allocator_adaptor(const scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>& __other) _NOEXCEPT
373 : base(__other) {}
372 : _Base(__other) {}
374373 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
375374 _LIBCPP_HIDE_FROM_ABI
376375 scoped_allocator_adaptor(scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT
377 : base(std::move(__other)) {}
376 : _Base(std::move(__other)) {}
378377
379378 // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default;
380379 // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default;
381380 // ~scoped_allocator_adaptor() = default;
382381
383 _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return base::inner_allocator(); }
382 _LIBCPP_HIDE_FROM_ABI inner_allocator_type& inner_allocator() _NOEXCEPT { return _Base::inner_allocator(); }
384383 _LIBCPP_HIDE_FROM_ABI const inner_allocator_type& inner_allocator() const _NOEXCEPT {
385 return base::inner_allocator();
384 return _Base::inner_allocator();
386385 }
387386
388 _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return base::outer_allocator(); }
387 _LIBCPP_HIDE_FROM_ABI outer_allocator_type& outer_allocator() _NOEXCEPT { return _Base::outer_allocator(); }
389388 _LIBCPP_HIDE_FROM_ABI const outer_allocator_type& outer_allocator() const _NOEXCEPT {
390 return base::outer_allocator();
389 return _Base::outer_allocator();
391390 }
392391
393 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
392 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n) {
394393 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n);
395394 }
396 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {
395 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, const_void_pointer __hint) {
397396 return allocator_traits<outer_allocator_type>::allocate(outer_allocator(), __n, __hint);
398397 }
399398
......@@ -472,13 +471,12 @@ public:
472471 }
473472
474473 _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor select_on_container_copy_construction() const _NOEXCEPT {
475 return base::select_on_container_copy_construction();
474 return _Base::select_on_container_copy_construction();
476475 }
477476
478477private:
479 template <class _OuterA2, __enable_if_t<is_constructible<outer_allocator_type, _OuterA2>::value, int> = 0>
480 _LIBCPP_HIDE_FROM_ABI scoped_allocator_adaptor(_OuterA2&& __o, const inner_allocator_type& __i) _NOEXCEPT
481 : base(std::forward<_OuterA2>(__o), __i) {}
478 _LIBCPP_HIDE_FROM_ABI explicit scoped_allocator_adaptor(
479 outer_allocator_type&& __o, inner_allocator_type&& __i) _NOEXCEPT : _Base(std::move(__o), std::move(__i)) {}
482480
483481 template <class _Tp, class... _Args>
484482 _LIBCPP_HIDE_FROM_ABI void __construct(integral_constant<int, 0>, _Tp* __p, _Args&&... __args) {
lib/libcxx/include/semaphore+40-41
......@@ -47,31 +47,28 @@ using binary_semaphore = counting_semaphore<1>;
4747
4848#include <__config>
4949
50#ifdef _LIBCPP_HAS_NO_THREADS
51# error "<semaphore> is not supported since libc++ has been configured without support for threads."
52#endif
53
54#include <__assert> // all public C++ headers provide the assertion handler
55#include <__atomic/atomic_base.h>
56#include <__atomic/atomic_sync.h>
57#include <__atomic/memory_order.h>
58#include <__availability>
59#include <__chrono/time_point.h>
60#include <__thread/poll_with_backoff.h>
61#include <__thread/timed_backoff_policy.h>
62#include <__threading_support>
63#include <cstddef>
64#include <limits>
65#include <version>
66
67#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
68# pragma GCC system_header
69#endif
50#if !defined(_LIBCPP_HAS_NO_THREADS)
51
52# include <__assert>
53# include <__atomic/atomic_base.h>
54# include <__atomic/atomic_sync.h>
55# include <__atomic/memory_order.h>
56# include <__chrono/time_point.h>
57# include <__thread/poll_with_backoff.h>
58# include <__thread/support.h>
59# include <__thread/timed_backoff_policy.h>
60# include <cstddef>
61# include <limits>
62# include <version>
63
64# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
65# pragma GCC system_header
66# endif
7067
7168_LIBCPP_PUSH_MACROS
72#include <__undef_macros>
69# include <__undef_macros>
7370
74#if _LIBCPP_STD_VER >= 14
71# if _LIBCPP_STD_VER >= 14
7572
7673_LIBCPP_BEGIN_NAMESPACE_STD
7774
......@@ -83,7 +80,7 @@ functions. It avoids contention against users' own use of those facilities.
8380
8481*/
8582
86# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max())
83# define _LIBCPP_SEMAPHORE_MAX (numeric_limits<ptrdiff_t>::max())
8784
8885class __atomic_semaphore_base {
8986 __atomic_base<ptrdiff_t> __a_;
......@@ -94,42 +91,40 @@ public:
9491 auto __old = __a_.fetch_add(__update, memory_order_release);
9592 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
9693 __update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value");
97
98 if (__old > 0) {
99 // Nothing to do
100 } else if (__update > 1)
94 if (__old == 0) {
10195 __a_.notify_all();
102 else
103 __a_.notify_one();
96 }
10497 }
10598 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI void acquire() {
106 auto const __test_fn = [this]() -> bool {
107 auto __old = __a_.load(memory_order_relaxed);
108 return (__old != 0) && __a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed);
109 };
110 __cxx_atomic_wait(&__a_.__a_, __test_fn);
99 std::__atomic_wait_unless(
100 __a_, [this](ptrdiff_t& __old) { return __try_acquire_impl(__old); }, memory_order_relaxed);
111101 }
112102 template <class _Rep, class _Period>
113103 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool
114104 try_acquire_for(chrono::duration<_Rep, _Period> const& __rel_time) {
115105 if (__rel_time == chrono::duration<_Rep, _Period>::zero())
116106 return try_acquire();
117 auto const __test_fn = [this]() { return try_acquire(); };
118 return std::__libcpp_thread_poll_with_backoff(__test_fn, __libcpp_timed_backoff_policy(), __rel_time);
107 auto const __poll_fn = [this]() { return try_acquire(); };
108 return std::__libcpp_thread_poll_with_backoff(__poll_fn, __libcpp_timed_backoff_policy(), __rel_time);
119109 }
120110 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool try_acquire() {
121 auto __old = __a_.load(memory_order_acquire);
111 auto __old = __a_.load(memory_order_relaxed);
112 return __try_acquire_impl(__old);
113 }
114
115private:
116 _LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool __try_acquire_impl(ptrdiff_t& __old) {
122117 while (true) {
123118 if (__old == 0)
124119 return false;
125 if (__a_.compare_exchange_strong(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
120 if (__a_.compare_exchange_weak(__old, __old - 1, memory_order_acquire, memory_order_relaxed))
126121 return true;
127122 }
128123 }
129124};
130125
131126template <ptrdiff_t __least_max_value = _LIBCPP_SEMAPHORE_MAX>
132class counting_semaphore {
127class _LIBCPP_DEPRECATED_ATOMIC_SYNC counting_semaphore {
133128 __atomic_semaphore_base __semaphore_;
134129
135130public:
......@@ -174,14 +169,18 @@ public:
174169 }
175170};
176171
177using binary_semaphore = counting_semaphore<1>;
172_LIBCPP_SUPPRESS_DEPRECATED_PUSH
173using binary_semaphore _LIBCPP_DEPRECATED_ATOMIC_SYNC = counting_semaphore<1>;
174_LIBCPP_SUPPRESS_DEPRECATED_POP
178175
179176_LIBCPP_END_NAMESPACE_STD
180177
181#endif // _LIBCPP_STD_VER >= 14
178# endif // _LIBCPP_STD_VER >= 14
182179
183180_LIBCPP_POP_MACROS
184181
182#endif // !defined(_LIBCPP_HAS_NO_THREADS)
183
185184#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
186185# include <atomic>
187186#endif
lib/libcxx/include/set+46-50
......@@ -515,8 +515,7 @@ erase_if(multiset<Key, Compare, Allocator>& c, Predicate pred); // C++20
515515#include <__algorithm/equal.h>
516516#include <__algorithm/lexicographical_compare.h>
517517#include <__algorithm/lexicographical_compare_three_way.h>
518#include <__assert> // all public C++ headers provide the assertion handler
519#include <__availability>
518#include <__assert>
520519#include <__config>
521520#include <__functional/is_transparent.h>
522521#include <__functional/operations.h>
......@@ -572,16 +571,14 @@ public:
572571 typedef value_type& reference;
573572 typedef const value_type& const_reference;
574573
575 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
574 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
576575 "Allocator::value_type must be same type as value_type");
577576
578577private:
579578 typedef __tree<value_type, value_compare, allocator_type> __base;
580579 typedef allocator_traits<allocator_type> __alloc_traits;
581580
582 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
583 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
584 "original allocator");
581 static_assert(__check_valid_allocator<allocator_type>::value, "");
585582
586583 __base __tree_;
587584
......@@ -660,7 +657,7 @@ public:
660657 }
661658
662659#ifndef _LIBCPP_CXX03_LANG
663 _LIBCPP_HIDE_FROM_ABI set(set&& __s) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
660 _LIBCPP_HIDE_FROM_ABI set(set&& __s) noexcept(is_nothrow_move_constructible<__base>::value)
664661 : __tree_(std::move(__s.__tree_)) {}
665662#endif // _LIBCPP_CXX03_LANG
666663
......@@ -693,7 +690,7 @@ public:
693690 return *this;
694691 }
695692
696 _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) _NOEXCEPT_(is_nothrow_move_assignable<__base>::value) {
693 _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) noexcept(is_nothrow_move_assignable<__base>::value) {
697694 __tree_ = std::move(__s.__tree_);
698695 return *this;
699696 }
......@@ -716,7 +713,7 @@ public:
716713 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
717714 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
718715
719 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
716 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
720717 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
721718 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
722719
......@@ -813,9 +810,7 @@ public:
813810 }
814811#endif
815812
816 _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) {
817 __tree_.swap(__s.__tree_);
818 }
813 _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }
819814
820815 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
821816 _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
......@@ -825,11 +820,11 @@ public:
825820 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
826821 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
827822#if _LIBCPP_STD_VER >= 14
828 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
823 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
829824 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
830825 return __tree_.find(__k);
831826 }
832 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
827 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
833828 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
834829 return __tree_.find(__k);
835830 }
......@@ -837,7 +832,7 @@ public:
837832
838833 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
839834#if _LIBCPP_STD_VER >= 14
840 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
835 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
841836 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
842837 return __tree_.__count_multi(__k);
843838 }
......@@ -845,7 +840,7 @@ public:
845840
846841#if _LIBCPP_STD_VER >= 20
847842 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
848 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
843 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
849844 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
850845 return find(__k) != end();
851846 }
......@@ -854,12 +849,12 @@ public:
854849 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
855850 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
856851#if _LIBCPP_STD_VER >= 14
857 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
852 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
858853 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
859854 return __tree_.lower_bound(__k);
860855 }
861856
862 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
857 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
863858 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
864859 return __tree_.lower_bound(__k);
865860 }
......@@ -868,11 +863,11 @@ public:
868863 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
869864 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
870865#if _LIBCPP_STD_VER >= 14
871 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
866 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
872867 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
873868 return __tree_.upper_bound(__k);
874869 }
875 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
870 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
876871 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
877872 return __tree_.upper_bound(__k);
878873 }
......@@ -885,11 +880,11 @@ public:
885880 return __tree_.__equal_range_unique(__k);
886881 }
887882#if _LIBCPP_STD_VER >= 14
888 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
883 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
889884 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
890885 return __tree_.__equal_range_multi(__k);
891886 }
892 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
887 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
893888 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
894889 return __tree_.__equal_range_multi(__k);
895890 }
......@@ -927,13 +922,15 @@ template <class _InputIterator,
927922 class _Allocator,
928923 class = enable_if_t<__has_input_iterator_category<_InputIterator>::value, void>,
929924 class = enable_if_t<__is_allocator<_Allocator>::value, void>>
930set(_InputIterator, _InputIterator, _Allocator)
931 -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
925set(_InputIterator,
926 _InputIterator,
927 _Allocator) -> set<__iter_value_type<_InputIterator>, less<__iter_value_type<_InputIterator>>, _Allocator>;
932928
933929# if _LIBCPP_STD_VER >= 23
934930template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
935set(from_range_t, _Range&&, _Allocator)
936 -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
931set(from_range_t,
932 _Range&&,
933 _Allocator) -> set<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
937934# endif
938935
939936template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
......@@ -996,8 +993,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
996993template <class _Key, class _Allocator>
997994_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
998995operator<=>(const set<_Key, _Allocator>& __x, const set<_Key, _Allocator>& __y) {
999 return std::lexicographical_compare_three_way(
1000 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
996 return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
1001997}
1002998
1003999#endif // _LIBCPP_STD_VER <= 17
......@@ -1029,16 +1025,14 @@ public:
10291025 typedef value_type& reference;
10301026 typedef const value_type& const_reference;
10311027
1032 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
1028 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
10331029 "Allocator::value_type must be same type as value_type");
10341030
10351031private:
10361032 typedef __tree<value_type, value_compare, allocator_type> __base;
10371033 typedef allocator_traits<allocator_type> __alloc_traits;
10381034
1039 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1040 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1041 "original allocator");
1035 static_assert(__check_valid_allocator<allocator_type>::value, "");
10421036
10431037 __base __tree_;
10441038
......@@ -1120,7 +1114,7 @@ public:
11201114 }
11211115
11221116#ifndef _LIBCPP_CXX03_LANG
1123 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value)
1117 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s) noexcept(is_nothrow_move_constructible<__base>::value)
11241118 : __tree_(std::move(__s.__tree_)) {}
11251119
11261120 _LIBCPP_HIDE_FROM_ABI multiset(multiset&& __s, const allocator_type& __a);
......@@ -1176,7 +1170,7 @@ public:
11761170 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
11771171 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
11781172
1179 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
1173 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
11801174 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
11811175 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
11821176
......@@ -1271,7 +1265,7 @@ public:
12711265 }
12721266#endif
12731267
1274 _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable<__base>::value) {
1268 _LIBCPP_HIDE_FROM_ABI void swap(multiset& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
12751269 __tree_.swap(__s.__tree_);
12761270 }
12771271
......@@ -1283,11 +1277,11 @@ public:
12831277 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
12841278 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
12851279#if _LIBCPP_STD_VER >= 14
1286 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1280 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12871281 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
12881282 return __tree_.find(__k);
12891283 }
1290 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1284 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12911285 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
12921286 return __tree_.find(__k);
12931287 }
......@@ -1295,7 +1289,7 @@ public:
12951289
12961290 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_multi(__k); }
12971291#if _LIBCPP_STD_VER >= 14
1298 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1292 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
12991293 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
13001294 return __tree_.__count_multi(__k);
13011295 }
......@@ -1303,7 +1297,7 @@ public:
13031297
13041298#if _LIBCPP_STD_VER >= 20
13051299 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
1306 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1300 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13071301 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
13081302 return find(__k) != end();
13091303 }
......@@ -1312,12 +1306,12 @@ public:
13121306 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.lower_bound(__k); }
13131307 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); }
13141308#if _LIBCPP_STD_VER >= 14
1315 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1309 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13161310 _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
13171311 return __tree_.lower_bound(__k);
13181312 }
13191313
1320 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1314 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13211315 _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
13221316 return __tree_.lower_bound(__k);
13231317 }
......@@ -1326,11 +1320,11 @@ public:
13261320 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); }
13271321 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); }
13281322#if _LIBCPP_STD_VER >= 14
1329 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1323 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13301324 _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
13311325 return __tree_.upper_bound(__k);
13321326 }
1333 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1327 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13341328 _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
13351329 return __tree_.upper_bound(__k);
13361330 }
......@@ -1343,11 +1337,11 @@ public:
13431337 return __tree_.__equal_range_multi(__k);
13441338 }
13451339#if _LIBCPP_STD_VER >= 14
1346 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1340 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13471341 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
13481342 return __tree_.__equal_range_multi(__k);
13491343 }
1350 template <typename _K2, enable_if_t<__is_transparent<_Compare, _K2>::value, int> = 0>
1344 template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
13511345 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
13521346 return __tree_.__equal_range_multi(__k);
13531347 }
......@@ -1379,8 +1373,9 @@ template <class _Key,
13791373 class _Allocator = allocator<_Key>,
13801374 class = enable_if_t<__is_allocator<_Allocator>::value, void>,
13811375 class = enable_if_t<!__is_allocator<_Compare>::value, void>>
1382multiset(initializer_list<_Key>, _Compare = _Compare(), _Allocator = _Allocator())
1383 -> multiset<_Key, _Compare, _Allocator>;
1376multiset(initializer_list<_Key>,
1377 _Compare = _Compare(),
1378 _Allocator = _Allocator()) -> multiset<_Key, _Compare, _Allocator>;
13841379
13851380template <class _InputIterator,
13861381 class _Allocator,
......@@ -1391,8 +1386,9 @@ multiset(_InputIterator, _InputIterator, _Allocator)
13911386
13921387# if _LIBCPP_STD_VER >= 23
13931388template <ranges::input_range _Range, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
1394multiset(from_range_t, _Range&&, _Allocator)
1395 -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
1389multiset(from_range_t,
1390 _Range&&,
1391 _Allocator) -> multiset<ranges::range_value_t<_Range>, less<ranges::range_value_t<_Range>>, _Allocator>;
13961392# endif
13971393
13981394template <class _Key, class _Allocator, class = enable_if_t<__is_allocator<_Allocator>::value, void>>
......@@ -1457,7 +1453,7 @@ template <class _Key, class _Allocator>
14571453_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
14581454operator<=>(const multiset<_Key, _Allocator>& __x, const multiset<_Key, _Allocator>& __y) {
14591455 return std::lexicographical_compare_three_way(
1460 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Key, _Key>);
1456 __x.begin(), __x.end(), __y.begin(), __y.end(), __synth_three_way);
14611457}
14621458
14631459#endif // _LIBCPP_STD_VER <= 17
lib/libcxx/include/shared_mutex+26-28
......@@ -124,33 +124,29 @@ template <class Mutex>
124124
125125#include <__config>
126126
127# ifdef _LIBCPP_HAS_NO_THREADS
128# error "<shared_mutex> is not supported since libc++ has been configured without support for threads."
129# endif
130
131#include <__assert> // all public C++ headers provide the assertion handler
132#include <__availability>
133#include <__chrono/duration.h>
134#include <__chrono/steady_clock.h>
135#include <__chrono/time_point.h>
136#include <__condition_variable/condition_variable.h>
137#include <__memory/addressof.h>
138#include <__mutex/mutex.h>
139#include <__mutex/tag_types.h>
140#include <__mutex/unique_lock.h>
141#include <__system_error/system_error.h>
142#include <__utility/swap.h>
143#include <cerrno>
144#include <version>
127#if !defined(_LIBCPP_HAS_NO_THREADS)
128
129# include <__chrono/duration.h>
130# include <__chrono/steady_clock.h>
131# include <__chrono/time_point.h>
132# include <__condition_variable/condition_variable.h>
133# include <__memory/addressof.h>
134# include <__mutex/mutex.h>
135# include <__mutex/tag_types.h>
136# include <__mutex/unique_lock.h>
137# include <__system_error/system_error.h>
138# include <__utility/swap.h>
139# include <cerrno>
140# include <version>
145141
146142_LIBCPP_PUSH_MACROS
147#include <__undef_macros>
143# include <__undef_macros>
148144
149#if _LIBCPP_STD_VER >= 14
145# if _LIBCPP_STD_VER >= 14
150146
151# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
152# pragma GCC system_header
153# endif
147# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
148# pragma GCC system_header
149# endif
154150
155151_LIBCPP_BEGIN_NAMESPACE_STD
156152
......@@ -183,7 +179,7 @@ struct _LIBCPP_EXPORTED_FROM_ABI __shared_mutex_base {
183179 // native_handle_type native_handle(); // See 30.2.3
184180};
185181
186# if _LIBCPP_STD_VER >= 17
182# if _LIBCPP_STD_VER >= 17
187183class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_mutex")) shared_mutex {
188184 __shared_mutex_base __base_;
189185
......@@ -220,10 +216,10 @@ public:
220216 // typedef __shared_mutex_base::native_handle_type native_handle_type;
221217 // _LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return __base::unlock_shared(); }
222218};
223# endif
219# endif
224220
225class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex"))
226 shared_timed_mutex {
221class _LIBCPP_EXPORTED_FROM_ABI
222_LIBCPP_THREAD_SAFETY_ANNOTATION(__capability__("shared_timed_mutex")) shared_timed_mutex {
227223 __shared_mutex_base __base_;
228224
229225public:
......@@ -455,10 +451,12 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(shared_lock<_Mutex>& __x, shared_lock<_Mu
455451
456452_LIBCPP_END_NAMESPACE_STD
457453
458#endif // _LIBCPP_STD_VER >= 14
454# endif // _LIBCPP_STD_VER >= 14
459455
460456_LIBCPP_POP_MACROS
461457
458#endif // !defined(_LIBCPP_HAS_NO_THREADS)
459
462460#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
463461# include <system_error>
464462#endif
lib/libcxx/include/span+59-20
......@@ -18,6 +18,20 @@ namespace std {
1818// constants
1919inline constexpr size_t dynamic_extent = numeric_limits<size_t>::max();
2020
21template<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)>> &&
25 convertible_to<T, decltype(T::value)> &&
26 equality_comparable_with<T, decltype(T::value)> &&
27 bool_constant<T() == T::value>::value &&
28 bool_constant<static_cast<decltype(T::value)>(T()) == T::value>::value;
29
30template<class T>
31 constexpr size_t maybe-static-ext = dynamic_extent; // exposition only, since C++26
32template<integral-constant-like T>
33 constexpr size_t maybe-static-ext<T> = {T::value};
34
2135// [views.span], class template span
2236template <class ElementType, size_t Extent = dynamic_extent>
2337 class span;
......@@ -110,7 +124,9 @@ private:
110124};
111125
112126template<class It, class EndOrSize>
113 span(It, EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
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
114130
115131template<class T, size_t N>
116132 span(T (&)[N]) -> span<T, N>;
......@@ -128,12 +144,16 @@ template<class R>
128144
129145*/
130146
131#include <__assert> // all public C++ headers provide the assertion handler
147#include <__assert>
148#include <__concepts/convertible_to.h>
149#include <__concepts/equality_comparable.h>
132150#include <__config>
151#include <__fwd/array.h>
133152#include <__fwd/span.h>
134153#include <__iterator/bounded_iter.h>
135154#include <__iterator/concepts.h>
136155#include <__iterator/iterator_traits.h>
156#include <__iterator/reverse_iterator.h>
137157#include <__iterator/wrap_iter.h>
138158#include <__memory/pointer_traits.h>
139159#include <__ranges/concepts.h>
......@@ -141,13 +161,20 @@ template<class R>
141161#include <__ranges/enable_borrowed_range.h>
142162#include <__ranges/enable_view.h>
143163#include <__ranges/size.h>
164#include <__type_traits/integral_constant.h>
165#include <__type_traits/is_array.h>
166#include <__type_traits/is_const.h>
144167#include <__type_traits/is_convertible.h>
168#include <__type_traits/is_integral.h>
169#include <__type_traits/is_same.h>
170#include <__type_traits/remove_const.h>
171#include <__type_traits/remove_cv.h>
145172#include <__type_traits/remove_cvref.h>
146173#include <__type_traits/remove_reference.h>
147174#include <__type_traits/type_identity.h>
148175#include <__utility/forward.h>
149#include <array> // for array
150176#include <cstddef> // for byte
177#include <initializer_list>
151178#include <stdexcept>
152179#include <version>
153180
......@@ -171,12 +198,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD
171198
172199#if _LIBCPP_STD_VER >= 20
173200
174template <class _Tp>
175struct __is_std_array : false_type {};
176
177template <class _Tp, size_t _Sz>
178struct __is_std_array<array<_Tp, _Sz>> : true_type {};
179
180201template <class _Tp>
181202struct __is_std_span : false_type {};
182203
......@@ -185,12 +206,12 @@ struct __is_std_span<span<_Tp, _Sz>> : true_type {};
185206
186207template <class _Range, class _ElementType>
187208concept __span_compatible_range =
188 ranges::contiguous_range<_Range> && //
189 ranges::sized_range<_Range> && //
190 (ranges::borrowed_range<_Range> || is_const_v<_ElementType>)&& //
191 !__is_std_span<remove_cvref_t<_Range>>::value && //
192 !__is_std_array<remove_cvref_t<_Range>>::value && //
193 !is_array_v<remove_cvref_t<_Range>> && //
209 !__is_std_span<remove_cvref_t<_Range>>::value && //
210 ranges::contiguous_range<_Range> && //
211 ranges::sized_range<_Range> && //
212 (ranges::borrowed_range<_Range> || is_const_v<_ElementType>) && //
213 !__is_std_array<remove_cvref_t<_Range>>::value && //
214 !is_array_v<remove_cvref_t<_Range>> && //
194215 is_convertible_v<remove_reference_t<ranges::range_reference_t<_Range>> (*)[], _ElementType (*)[]>;
195216
196217template <class _From, class _To>
......@@ -273,7 +294,8 @@ public:
273294 }
274295
275296 template <__span_array_convertible<element_type> _OtherElementType>
276 _LIBCPP_HIDE_FROM_ABI constexpr span(const span<_OtherElementType, _Extent>& __other) : __data_{__other.data()} {}
297 _LIBCPP_HIDE_FROM_ABI constexpr span(const span<_OtherElementType, _Extent>& __other) noexcept
298 : __data_{__other.data()} {}
277299
278300 template <__span_array_convertible<element_type> _OtherElementType>
279301 _LIBCPP_HIDE_FROM_ABI constexpr explicit span(const span<_OtherElementType, dynamic_extent>& __other) noexcept
......@@ -304,8 +326,8 @@ public:
304326 }
305327
306328 template <size_t _Offset, size_t _Count = dynamic_extent>
307 _LIBCPP_HIDE_FROM_ABI constexpr auto subspan() const noexcept
308 -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> {
329 _LIBCPP_HIDE_FROM_ABI constexpr auto
330 subspan() const noexcept -> span<element_type, _Count != dynamic_extent ? _Count : _Extent - _Offset> {
309331 static_assert(_Offset <= _Extent, "span<T, N>::subspan<Offset, Count>(): Offset out of range");
310332 static_assert(_Count == dynamic_extent || _Count <= _Extent - _Offset,
311333 "span<T, N>::subspan<Offset, Count>(): Offset + Count out of range");
......@@ -564,10 +586,26 @@ _LIBCPP_HIDE_FROM_ABI auto as_writable_bytes(span<_Tp, _Extent> __s) noexcept {
564586 return __s.__as_writable_bytes();
565587}
566588
567# if _LIBCPP_STD_VER >= 20
589# if _LIBCPP_STD_VER >= 26
590template <class _Tp>
591concept __integral_constant_like =
592 is_integral_v<decltype(_Tp::value)> && !is_same_v<bool, remove_const_t<decltype(_Tp::value)>> &&
593 convertible_to<_Tp, decltype(_Tp::value)> && equality_comparable_with<_Tp, decltype(_Tp::value)> &&
594 bool_constant<_Tp() == _Tp::value>::value &&
595 bool_constant<static_cast<decltype(_Tp::value)>(_Tp()) == _Tp::value>::value;
596
597template <class _Tp>
598inline constexpr size_t __maybe_static_ext = dynamic_extent;
599
600template <__integral_constant_like _Tp>
601inline constexpr size_t __maybe_static_ext<_Tp> = {_Tp::value};
602
603template <contiguous_iterator _It, class _EndOrSize>
604span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>, __maybe_static_ext<_EndOrSize>>;
605# else
568606template <contiguous_iterator _It, class _EndOrSize>
569607span(_It, _EndOrSize) -> span<remove_reference_t<iter_reference_t<_It>>>;
570# endif // _LIBCPP_STD_VER >= 20
608# endif
571609
572610template <class _Tp, size_t _Sz>
573611span(_Tp (&)[_Sz]) -> span<_Tp, _Sz>;
......@@ -588,6 +626,7 @@ _LIBCPP_END_NAMESPACE_STD
588626_LIBCPP_POP_MACROS
589627
590628#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
629# include <array>
591630# include <concepts>
592631# include <functional>
593632# include <iterator>
lib/libcxx/include/sstream+180-19
......@@ -48,10 +48,19 @@ public:
4848 template <class SAlloc>
4949 explicit basic_stringbuf(const basic_string<char_type, traits_type, SAlloc>& s,
5050 ios_base::openmode which = ios_base::in | ios_base::out); // C++20
51 template<class T>
52 explicit basic_stringbuf(const T& t,
53 ios_base::openmode which = ios_base::in | ios_base::out); // Since C++26
54 template<class T>
55 basic_stringbuf(const T& t, const Allocator& a); // Since C++26
56 template<class T>
57 basic_stringbuf(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
58 basic_stringbuf(const basic_stringbuf&) = delete;
5159 basic_stringbuf(basic_stringbuf&& rhs);
5260 basic_stringbuf(basic_stringbuf&& rhs, const allocator_type& a); // C++20
5361
5462 // [stringbuf.assign] Assign and swap:
63 basic_stringbuf& operator=(const basic_stringbuf&) = delete;
5564 basic_stringbuf& operator=(basic_stringbuf&& rhs);
5665 void swap(basic_stringbuf& rhs) noexcept(see below); // conditionally noexcept since C++20
5766
......@@ -67,6 +76,8 @@ public:
6776 template <class SAlloc>
6877 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
6978 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
79 template<class T>
80 void str(const T& t); // Since C++26
7081
7182protected:
7283 // [stringbuf.virtuals] Overridden virtual functions:
......@@ -119,9 +130,17 @@ public:
119130 template <class SAlloc>
120131 explicit basic_istringstream(const basic_string<char_type, traits_type, SAlloc>& s,
121132 ios_base::openmode which = ios_base::in); // C++20
133 template<class T>
134 explicit basic_istringstream(const T& t, ios_base::openmode which = ios_base::in); // Since C++26
135 template<class T>
136 basic_istringstream(const T& t, const Allocator& a); // Since C++26
137 template<class T>
138 basic_istringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
139 basic_istringstream(const basic_istringstream&) = delete;
122140 basic_istringstream(basic_istringstream&& rhs);
123141
124142 // [istringstream.assign] Assign and swap:
143 basic_istringstream& operator=(const basic_istringstream&) = delete;
125144 basic_istringstream& operator=(basic_istringstream&& rhs);
126145 void swap(basic_istringstream& rhs);
127146
......@@ -137,6 +156,8 @@ public:
137156 template <class SAlloc>
138157 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
139158 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
159 template<class T>
160 void str(const T& t); // Since C++26
140161};
141162
142163template <class charT, class traits, class Allocator>
......@@ -178,9 +199,17 @@ public:
178199 template <class SAlloc>
179200 explicit basic_ostringstream(const basic_string<char_type, traits_type, SAlloc>& s,
180201 ios_base::openmode which = ios_base::out); // C++20
202 template<class T>
203 explicit basic_ostringstream(const T& t, ios_base::openmode which = ios_base::out); // Since C++26
204 template<class T>
205 basic_ostringstream(const T& t, const Allocator& a); // Since C++26
206 template<class T>
207 basic_ostringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
208 basic_ostringstream(const basic_ostringstream&) = delete;
181209 basic_ostringstream(basic_ostringstream&& rhs);
182210
183211 // [ostringstream.assign] Assign and swap:
212 basic_ostringstream& operator=(const basic_ostringstream&) = delete;
184213 basic_ostringstream& operator=(basic_ostringstream&& rhs);
185214 void swap(basic_ostringstream& rhs);
186215
......@@ -196,6 +225,8 @@ public:
196225 template <class SAlloc>
197226 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
198227 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
228 template<class T>
229 void str(const T& t); // Since C++26
199230};
200231
201232template <class charT, class traits, class Allocator>
......@@ -237,9 +268,18 @@ public:
237268 template <class SAlloc>
238269 explicit basic_stringstream(const basic_string<char_type, traits_type, SAlloc>& s,
239270 ios_base::openmode which = ios_base::out | ios_base::in); // C++20
271 template<class T>
272 explicit basic_stringstream(const T& t,
273 ios_base::openmode which = ios_base::out | ios_base::in); // Since C++26
274 template<class T>
275 basic_stringstream(const T& t, const Allocator& a); // Since C++26
276 template<class T>
277 basic_stringstream(const T& t, ios_base::openmode which, const Allocator& a); // Since C++26
278 basic_stringstream(const basic_stringstream&) = delete;
240279 basic_stringstream(basic_stringstream&& rhs);
241280
242281 // [stringstream.assign] Assign and swap:
282 basic_stringstream& operator=(const basic_stringstream&) = delete;
243283 basic_stringstream& operator=(basic_stringstream&& rhs);
244284 void swap(basic_stringstream& rhs);
245285
......@@ -255,6 +295,8 @@ public:
255295 template <class SAlloc>
256296 void str(const basic_string<char_type, traits_type, SAlloc>& s); // C++20
257297 void str(basic_string<char_type, traits_type, allocator_type>&& s); // C++20
298 template<class T>
299 void str(const T& t); // Since C++26
258300};
259301
260302template <class charT, class traits, class Allocator>
......@@ -270,14 +312,14 @@ typedef basic_stringstream<wchar_t> wstringstream;
270312
271313// clang-format on
272314
273#include <__assert> // all public C++ headers provide the assertion handler
274#include <__availability>
275315#include <__config>
276316#include <__fwd/sstream.h>
317#include <__ostream/basic_ostream.h>
318#include <__type_traits/is_convertible.h>
277319#include <__utility/swap.h>
278320#include <istream>
279#include <ostream>
280321#include <string>
322#include <string_view>
281323#include <version>
282324
283325#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -287,14 +329,6 @@ typedef basic_stringstream<wchar_t> wstringstream;
287329_LIBCPP_PUSH_MACROS
288330#include <__undef_macros>
289331
290// TODO(LLVM-19): Remove this once we drop support for Clang 16,
291// which had this bug: https://github.com/llvm/llvm-project/issues/40363
292#ifdef _WIN32
293# define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_ALWAYS_INLINE
294#else
295# define _LIBCPP_HIDE_FROM_ABI_SSTREAM _LIBCPP_HIDE_FROM_ABI
296#endif
297
298332_LIBCPP_BEGIN_NAMESPACE_STD
299333
300334// Class template basic_stringbuf [stringbuf]
......@@ -364,6 +398,31 @@ public:
364398 }
365399#endif // _LIBCPP_STD_VER >= 20
366400
401#if _LIBCPP_STD_VER >= 26
402
403 template <class _Tp>
404 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
405 _LIBCPP_HIDE_FROM_ABI explicit basic_stringbuf(const _Tp& __t,
406 ios_base::openmode __which = ios_base::in | ios_base::out)
407 : basic_stringbuf(__t, __which, _Allocator()) {}
408
409 template <class _Tp>
410 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
411 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, const _Allocator& __a)
412 : basic_stringbuf(__t, ios_base::in | ios_base::out, __a) {}
413
414 template <class _Tp>
415 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
416 _LIBCPP_HIDE_FROM_ABI basic_stringbuf(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
417 : __hm_(nullptr), __mode_(__which) {
418 basic_string_view<_CharT, _Traits> __sv = __t;
419 __str_ = string_type(__sv, __a);
420 __init_buf_ptrs();
421 }
422
423#endif // _LIBCPP_STD_VER >= 26
424
425 basic_stringbuf(const basic_stringbuf&) = delete;
367426 basic_stringbuf(basic_stringbuf&& __rhs) : __mode_(__rhs.__mode_) { __move_init(std::move(__rhs)); }
368427
369428#if _LIBCPP_STD_VER >= 20
......@@ -374,6 +433,7 @@ public:
374433#endif
375434
376435 // [stringbuf.assign] Assign and swap:
436 basic_stringbuf& operator=(const basic_stringbuf&) = delete;
377437 basic_stringbuf& operator=(basic_stringbuf&& __rhs);
378438 void swap(basic_stringbuf& __rhs)
379439#if _LIBCPP_STD_VER >= 20
......@@ -391,9 +451,9 @@ public:
391451#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
392452 string_type str() const;
393453#else
394 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return str(__str_.get_allocator()); }
454 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return str(__str_.get_allocator()); }
395455
396 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && {
456 _LIBCPP_HIDE_FROM_ABI string_type str() && {
397457 const basic_string_view<_CharT, _Traits> __view = view();
398458 typename string_type::size_type __pos = __view.empty() ? 0 : __view.data() - __str_.data();
399459 // In C++23, this is just string_type(std::move(__str_), __pos, __view.size(), __str_.get_allocator());
......@@ -435,6 +495,18 @@ public:
435495 }
436496#endif // _LIBCPP_STD_VER >= 20
437497
498#if _LIBCPP_STD_VER >= 26
499
500 template <class _Tp>
501 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
502 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
503 basic_string_view<_CharT, _Traits> __sv = __t;
504 __str_ = __sv;
505 __init_buf_ptrs();
506 }
507
508#endif // _LIBCPP_STD_VER >= 26
509
438510protected:
439511 // [stringbuf.virtuals] Overridden virtual functions:
440512 int_type underflow() override;
......@@ -822,12 +894,33 @@ public:
822894 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::in) {}
823895#endif // _LIBCPP_STD_VER >= 20
824896
897#if _LIBCPP_STD_VER >= 26
898
899 template <class _Tp>
900 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
901 _LIBCPP_HIDE_FROM_ABI explicit basic_istringstream(const _Tp& __t, ios_base::openmode __which = ios_base::in)
902 : basic_istringstream(__t, __which, _Allocator()) {}
903
904 template <class _Tp>
905 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
906 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, const _Allocator& __a)
907 : basic_istringstream(__t, ios_base::in, __a) {}
908
909 template <class _Tp>
910 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
911 _LIBCPP_HIDE_FROM_ABI basic_istringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
912 : basic_istream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::in, __a) {}
913
914#endif // _LIBCPP_STD_VER >= 26
915
916 basic_istringstream(const basic_istringstream&) = delete;
825917 _LIBCPP_HIDE_FROM_ABI basic_istringstream(basic_istringstream&& __rhs)
826918 : basic_istream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
827919 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
828920 }
829921
830922 // [istringstream.assign] Assign and swap:
923 basic_istringstream& operator=(const basic_istringstream&) = delete;
831924 basic_istringstream& operator=(basic_istringstream&& __rhs) {
832925 basic_istream<char_type, traits_type>::operator=(std::move(__rhs));
833926 __sb_ = std::move(__rhs.__sb_);
......@@ -846,9 +939,9 @@ public:
846939#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
847940 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
848941#else
849 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); }
942 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
850943
851 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
944 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
852945#endif
853946
854947#if _LIBCPP_STD_VER >= 20
......@@ -871,6 +964,14 @@ public:
871964
872965 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
873966#endif // _LIBCPP_STD_VER >= 20
967
968#if _LIBCPP_STD_VER >= 26
969 template <class _Tp>
970 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
971 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
972 rdbuf()->str(__t);
973 }
974#endif // _LIBCPP_STD_VER >= 26
874975};
875976
876977template <class _CharT, class _Traits, class _Allocator>
......@@ -929,12 +1030,33 @@ public:
9291030 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch | ios_base::out) {}
9301031#endif // _LIBCPP_STD_VER >= 20
9311032
1033#if _LIBCPP_STD_VER >= 26
1034
1035 template <class _Tp>
1036 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1037 _LIBCPP_HIDE_FROM_ABI explicit basic_ostringstream(const _Tp& __t, ios_base::openmode __which = ios_base::out)
1038 : basic_ostringstream(__t, __which | ios_base::out, _Allocator()) {}
1039
1040 template <class _Tp>
1041 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1042 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, const _Allocator& __a)
1043 : basic_ostringstream(__t, ios_base::out, __a) {}
1044
1045 template <class _Tp>
1046 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1047 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1048 : basic_ostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which | ios_base::out, __a) {}
1049
1050#endif // _LIBCPP_STD_VER >= 26
1051
1052 basic_ostringstream(const basic_ostringstream&) = delete;
9321053 _LIBCPP_HIDE_FROM_ABI basic_ostringstream(basic_ostringstream&& __rhs)
9331054 : basic_ostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
9341055 basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
9351056 }
9361057
9371058 // [ostringstream.assign] Assign and swap:
1059 basic_ostringstream& operator=(const basic_ostringstream&) = delete;
9381060 basic_ostringstream& operator=(basic_ostringstream&& __rhs) {
9391061 basic_ostream<char_type, traits_type>::operator=(std::move(__rhs));
9401062 __sb_ = std::move(__rhs.__sb_);
......@@ -954,9 +1076,9 @@ public:
9541076#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
9551077 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
9561078#else
957 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); }
1079 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
9581080
959 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
1081 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
9601082#endif
9611083
9621084#if _LIBCPP_STD_VER >= 20
......@@ -979,6 +1101,14 @@ public:
9791101
9801102 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
9811103#endif // _LIBCPP_STD_VER >= 20
1104
1105#if _LIBCPP_STD_VER >= 26
1106 template <class _Tp>
1107 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1108 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1109 rdbuf()->str(__t);
1110 }
1111#endif // _LIBCPP_STD_VER >= 26
9821112};
9831113
9841114template <class _CharT, class _Traits, class _Allocator>
......@@ -1040,12 +1170,34 @@ public:
10401170 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__s, __wch) {}
10411171#endif // _LIBCPP_STD_VER >= 20
10421172
1173#if _LIBCPP_STD_VER >= 26
1174
1175 template <class _Tp>
1176 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1177 _LIBCPP_HIDE_FROM_ABI explicit basic_stringstream(const _Tp& __t,
1178 ios_base::openmode __which = ios_base::out | ios_base::in)
1179 : basic_stringstream(__t, __which, _Allocator()) {}
1180
1181 template <class _Tp>
1182 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1183 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, const _Allocator& __a)
1184 : basic_stringstream(__t, ios_base::out | ios_base::in, __a) {}
1185
1186 template <class _Tp>
1187 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1188 _LIBCPP_HIDE_FROM_ABI basic_stringstream(const _Tp& __t, ios_base::openmode __which, const _Allocator& __a)
1189 : basic_iostream<_CharT, _Traits>(std::addressof(__sb_)), __sb_(__t, __which, __a) {}
1190
1191#endif // _LIBCPP_STD_VER >= 26
1192
1193 basic_stringstream(const basic_stringstream&) = delete;
10431194 _LIBCPP_HIDE_FROM_ABI basic_stringstream(basic_stringstream&& __rhs)
10441195 : basic_iostream<_CharT, _Traits>(std::move(__rhs)), __sb_(std::move(__rhs.__sb_)) {
10451196 basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
10461197 }
10471198
10481199 // [stringstream.assign] Assign and swap:
1200 basic_stringstream& operator=(const basic_stringstream&) = delete;
10491201 basic_stringstream& operator=(basic_stringstream&& __rhs) {
10501202 basic_iostream<char_type, traits_type>::operator=(std::move(__rhs));
10511203 __sb_ = std::move(__rhs.__sb_);
......@@ -1064,9 +1216,9 @@ public:
10641216#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_BUILDING_LIBRARY)
10651217 _LIBCPP_HIDE_FROM_ABI string_type str() const { return __sb_.str(); }
10661218#else
1067 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() const& { return __sb_.str(); }
1219 _LIBCPP_HIDE_FROM_ABI string_type str() const& { return __sb_.str(); }
10681220
1069 _LIBCPP_HIDE_FROM_ABI_SSTREAM string_type str() && { return std::move(__sb_).str(); }
1221 _LIBCPP_HIDE_FROM_ABI string_type str() && { return std::move(__sb_).str(); }
10701222#endif
10711223
10721224#if _LIBCPP_STD_VER >= 20
......@@ -1089,6 +1241,14 @@ public:
10891241
10901242 _LIBCPP_HIDE_FROM_ABI void str(string_type&& __s) { __sb_.str(std::move(__s)); }
10911243#endif // _LIBCPP_STD_VER >= 20
1244
1245#if _LIBCPP_STD_VER >= 26
1246 template <class _Tp>
1247 requires is_convertible_v<const _Tp&, basic_string_view<_CharT, _Traits>>
1248 _LIBCPP_HIDE_FROM_ABI void str(const _Tp& __t) {
1249 rdbuf()->str(__t);
1250 }
1251#endif // _LIBCPP_STD_VER >= 26
10921252};
10931253
10941254template <class _CharT, class _Traits, class _Allocator>
......@@ -1109,6 +1269,7 @@ _LIBCPP_END_NAMESPACE_STD
11091269_LIBCPP_POP_MACROS
11101270
11111271#if _LIBCPP_STD_VER <= 20 && !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
1272# include <ostream>
11121273# include <type_traits>
11131274#endif
11141275
lib/libcxx/include/stack+25-26
......@@ -114,8 +114,8 @@ template <class T, class Container>
114114*/
115115
116116#include <__algorithm/ranges_copy.h>
117#include <__assert> // all public C++ headers provide the assertion handler
118117#include <__config>
118#include <__fwd/stack.h>
119119#include <__iterator/back_insert_iterator.h>
120120#include <__iterator/iterator_traits.h>
121121#include <__memory/uses_allocator.h>
......@@ -143,9 +143,6 @@ _LIBCPP_PUSH_MACROS
143143
144144_LIBCPP_BEGIN_NAMESPACE_STD
145145
146template <class _Tp, class _Container = deque<_Tp> >
147class _LIBCPP_TEMPLATE_VIS stack;
148
149146template <class _Tp, class _Container>
150147_LIBCPP_HIDE_FROM_ABI bool operator==(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y);
151148
......@@ -160,7 +157,7 @@ public:
160157 typedef typename container_type::reference reference;
161158 typedef typename container_type::const_reference const_reference;
162159 typedef typename container_type::size_type size_type;
163 static_assert((is_same<_Tp, value_type>::value), "");
160 static_assert(is_same<_Tp, value_type>::value, "");
164161
165162protected:
166163 container_type c;
......@@ -176,10 +173,10 @@ public:
176173 }
177174
178175#ifndef _LIBCPP_CXX03_LANG
179 _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value)
176 _LIBCPP_HIDE_FROM_ABI stack(stack&& __q) noexcept(is_nothrow_move_constructible<container_type>::value)
180177 : c(std::move(__q.c)) {}
181178
182 _LIBCPP_HIDE_FROM_ABI stack& operator=(stack&& __q) _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) {
179 _LIBCPP_HIDE_FROM_ABI stack& operator=(stack&& __q) noexcept(is_nothrow_move_assignable<container_type>::value) {
183180 c = std::move(__q.c);
184181 return *this;
185182 }
......@@ -213,7 +210,7 @@ public:
213210#endif // _LIBCPP_CXX03_LANG
214211
215212#if _LIBCPP_STD_VER >= 23
216 template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
213 template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
217214 _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last) : c(__first, __last) {}
218215
219216 template <_ContainerCompatibleRange<_Tp> _Range>
......@@ -221,20 +218,20 @@ public:
221218
222219 template <class _InputIterator,
223220 class _Alloc,
224 class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
225 class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
221 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
222 __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
226223 _LIBCPP_HIDE_FROM_ABI stack(_InputIterator __first, _InputIterator __last, const _Alloc& __alloc)
227224 : c(__first, __last, __alloc) {}
228225
229226 template <_ContainerCompatibleRange<_Tp> _Range,
230227 class _Alloc,
231 class = __enable_if_t<uses_allocator<container_type, _Alloc>::value>>
228 __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0>
232229 _LIBCPP_HIDE_FROM_ABI stack(from_range_t, _Range&& __range, const _Alloc& __alloc)
233230 : c(from_range, std::forward<_Range>(__range), __alloc) {}
234231
235232#endif
236233
237 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
234 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); }
238235 _LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); }
239236 _LIBCPP_HIDE_FROM_ABI reference top() { return c.back(); }
240237 _LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.back(); }
......@@ -257,13 +254,13 @@ public:
257254 template <class... _Args>
258255 _LIBCPP_HIDE_FROM_ABI
259256# if _LIBCPP_STD_VER >= 17
260 decltype(auto)
261 emplace(_Args&&... __args) {
257 decltype(auto)
258 emplace(_Args&&... __args) {
262259 return c.emplace_back(std::forward<_Args>(__args)...);
263260 }
264261# else
265 void
266 emplace(_Args&&... __args) {
262 void
263 emplace(_Args&&... __args) {
267264 c.emplace_back(std::forward<_Args>(__args)...);
268265 }
269266# endif
......@@ -271,7 +268,7 @@ public:
271268
272269 _LIBCPP_HIDE_FROM_ABI void pop() { c.pop_back(); }
273270
274 _LIBCPP_HIDE_FROM_ABI void swap(stack& __s) _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) {
271 _LIBCPP_HIDE_FROM_ABI void swap(stack& __s) _NOEXCEPT_(__is_nothrow_swappable_v<container_type>) {
275272 using std::swap;
276273 swap(c, __s.c);
277274 }
......@@ -297,7 +294,7 @@ stack(_Container, _Alloc) -> stack<typename _Container::value_type, _Container>;
297294#endif
298295
299296#if _LIBCPP_STD_VER >= 23
300template <class _InputIterator, class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>>
297template <class _InputIterator, __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0>
301298stack(_InputIterator, _InputIterator) -> stack<__iter_value_type<_InputIterator>>;
302299
303300template <ranges::input_range _Range>
......@@ -305,14 +302,16 @@ stack(from_range_t, _Range&&) -> stack<ranges::range_value_t<_Range>>;
305302
306303template <class _InputIterator,
307304 class _Alloc,
308 class = __enable_if_t<__has_input_iterator_category<_InputIterator>::value>,
309 class = __enable_if_t<__is_allocator<_Alloc>::value>>
310stack(_InputIterator, _InputIterator, _Alloc)
311 -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
305 __enable_if_t<__has_input_iterator_category<_InputIterator>::value, int> = 0,
306 __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
307stack(_InputIterator,
308 _InputIterator,
309 _Alloc) -> stack<__iter_value_type<_InputIterator>, deque<__iter_value_type<_InputIterator>, _Alloc>>;
312310
313template <ranges::input_range _Range, class _Alloc, class = __enable_if_t<__is_allocator<_Alloc>::value>>
314stack(from_range_t, _Range&&, _Alloc)
315 -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
311template <ranges::input_range _Range, class _Alloc, __enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
312stack(from_range_t,
313 _Range&&,
314 _Alloc) -> stack<ranges::range_value_t<_Range>, deque<ranges::range_value_t<_Range>, _Alloc>>;
316315
317316#endif
318317
......@@ -357,7 +356,7 @@ operator<=>(const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y
357356
358357#endif
359358
360template <class _Tp, class _Container, __enable_if_t<__is_swappable<_Container>::value, int> = 0>
359template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0>
361360inline _LIBCPP_HIDE_FROM_ABI void swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y)
362361 _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
363362 __x.swap(__y);
lib/libcxx/include/stdexcept+7-8
......@@ -17,14 +17,14 @@ namespace std
1717{
1818
1919class logic_error;
20 class domain_error;
21 class invalid_argument;
22 class length_error;
23 class out_of_range;
20class domain_error;
21class invalid_argument;
22class length_error;
23class out_of_range;
2424class runtime_error;
25 class range_error;
26 class overflow_error;
27 class underflow_error;
25class range_error;
26class overflow_error;
27class underflow_error;
2828
2929for each class xxx_error:
3030
......@@ -41,7 +41,6 @@ public:
4141
4242*/
4343
44#include <__assert> // all public C++ headers provide the assertion handler
4544#include <__config>
4645#include <__exception/exception.h>
4746#include <__fwd/string.h>
lib/libcxx/include/stdlib.h+5-7
......@@ -110,21 +110,19 @@ extern "C++" {
110110
111111// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
112112# if !defined(_LIBCPP_MSVCRT)
113_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }
114_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT {
115 return __builtin_llabs(__x);
116}
113_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long abs(long __x) _NOEXCEPT { return __builtin_labs(__x); }
114_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long long abs(long long __x) _NOEXCEPT { return __builtin_llabs(__x); }
117115# endif // !defined(_LIBCPP_MSVCRT)
118116
119_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {
117_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI float abs(float __lcpp_x) _NOEXCEPT {
120118 return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
121119}
122120
123_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {
121_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI double abs(double __lcpp_x) _NOEXCEPT {
124122 return __builtin_fabs(__lcpp_x);
125123}
126124
127_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {
125_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI long double abs(long double __lcpp_x) _NOEXCEPT {
128126 return __builtin_fabsl(__lcpp_x);
129127}
130128
lib/libcxx/include/stop_token+13-11
......@@ -33,19 +33,21 @@ namespace std {
3333
3434#include <__config>
3535
36#ifdef _LIBCPP_HAS_NO_THREADS
37# error "<stop_token> is not supported since libc++ has been configured without support for threads."
38#endif
36#if !defined(_LIBCPP_HAS_NO_THREADS)
3937
40#include <__assert> // all public C++ headers provide the assertion handler
41#include <__stop_token/stop_callback.h>
42#include <__stop_token/stop_source.h>
43#include <__stop_token/stop_token.h>
44#include <version>
38# if _LIBCPP_STD_VER >= 20
39# include <__stop_token/stop_callback.h>
40# include <__stop_token/stop_source.h>
41# include <__stop_token/stop_token.h>
42# endif
4543
46#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
47# pragma GCC system_header
48#endif
44# include <version>
45
46# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
47# pragma GCC system_header
48# endif
49
50#endif // !defined(_LIBCPP_HAS_NO_THREADS)
4951
5052#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
5153# include <iosfwd>
lib/libcxx/include/streambuf+9-2
......@@ -107,9 +107,12 @@ protected:
107107
108108*/
109109
110#include <__assert> // all public C++ headers provide the assertion handler
110#include <__assert>
111111#include <__config>
112112#include <__fwd/streambuf.h>
113#include <__locale>
114#include <__type_traits/is_same.h>
115#include <__utility/is_valid_range.h>
113116#include <climits>
114117#include <ios>
115118#include <iosfwd>
......@@ -134,7 +137,7 @@ public:
134137 typedef typename traits_type::pos_type pos_type;
135138 typedef typename traits_type::off_type off_type;
136139
137 static_assert((is_same<_CharT, typename traits_type::char_type>::value),
140 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
138141 "traits_type::char_type must be the same type as CharT");
139142
140143 virtual ~basic_streambuf();
......@@ -233,6 +236,9 @@ protected:
233236 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; }
234237
235238 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) {
239 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gnext), "[gbeg, gnext) must be a valid range");
240 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gbeg, __gend), "[gbeg, gend) must be a valid range");
241 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__gnext, __gend), "[gnext, gend) must be a valid range");
236242 __binp_ = __gbeg;
237243 __ninp_ = __gnext;
238244 __einp_ = __gend;
......@@ -248,6 +254,7 @@ protected:
248254 _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; }
249255
250256 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setp(char_type* __pbeg, char_type* __pend) {
257 _LIBCPP_ASSERT_VALID_INPUT_RANGE(std::__is_valid_range(__pbeg, __pend), "[pbeg, pend) must be a valid range");
251258 __bout_ = __nout_ = __pbeg;
252259 __eout_ = __pend;
253260 }
lib/libcxx/include/string+302-124
......@@ -407,6 +407,24 @@ template<class charT, class traits, class Allocator>
407407basic_string<charT, traits, Allocator>
408408operator+(const basic_string<charT, traits, Allocator>& lhs, charT rhs); // constexpr since C++20
409409
410template<class charT, class traits, class Allocator>
411 constexpr basic_string<charT, traits, Allocator>
412 operator+(const basic_string<charT, traits, Allocator>& lhs,
413 type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26
414template<class charT, class traits, class Allocator>
415 constexpr basic_string<charT, traits, Allocator>
416 operator+(basic_string<charT, traits, Allocator>&& lhs,
417 type_identity_t<basic_string_view<charT, traits>> rhs); // Since C++26
418template<class charT, class traits, class Allocator>
419 constexpr basic_string<charT, traits, Allocator>
420 operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
421 const basic_string<charT, traits, Allocator>& rhs); // Since C++26
422template<class charT, class traits, class Allocator>
423 constexpr basic_string<charT, traits, Allocator>
424 operator+(type_identity_t<basic_string_view<charT, traits>> lhs,
425 basic_string<charT, traits, Allocator>&& rhs); // Since C++26
426
427
410428template<class charT, class traits, class Allocator>
411429bool operator==(const basic_string<charT, traits, Allocator>& lhs,
412430 const basic_string<charT, traits, Allocator>& rhs) noexcept; // constexpr since C++20
......@@ -572,13 +590,15 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
572590#include <__algorithm/min.h>
573591#include <__algorithm/remove.h>
574592#include <__algorithm/remove_if.h>
575#include <__assert> // all public C++ headers provide the assertion handler
593#include <__assert>
576594#include <__config>
595#include <__debug_utils/sanitizers.h>
577596#include <__format/enable_insertable.h>
578597#include <__functional/hash.h>
579598#include <__functional/unary_function.h>
580599#include <__fwd/string.h>
581600#include <__ios/fpos.h>
601#include <__iterator/bounded_iter.h>
582602#include <__iterator/distance.h>
583603#include <__iterator/iterator_traits.h>
584604#include <__iterator/reverse_iterator.h>
......@@ -599,14 +619,16 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
599619#include <__ranges/size.h>
600620#include <__string/char_traits.h>
601621#include <__string/extern_template_lists.h>
622#include <__type_traits/conditional.h>
602623#include <__type_traits/is_allocator.h>
603624#include <__type_traits/is_array.h>
604625#include <__type_traits/is_convertible.h>
605#include <__type_traits/is_nothrow_default_constructible.h>
606#include <__type_traits/is_nothrow_move_assignable.h>
626#include <__type_traits/is_nothrow_assignable.h>
627#include <__type_traits/is_nothrow_constructible.h>
607628#include <__type_traits/is_same.h>
608629#include <__type_traits/is_standard_layout.h>
609630#include <__type_traits/is_trivial.h>
631#include <__type_traits/is_trivially_relocatable.h>
610632#include <__type_traits/noexcept_move_assign_container.h>
611633#include <__type_traits/remove_cvref.h>
612634#include <__type_traits/void_t.h>
......@@ -659,7 +681,6 @@ _LIBCPP_PUSH_MACROS
659681#else
660682# define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
661683#endif
662#define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED false
663684
664685_LIBCPP_BEGIN_NAMESPACE_STD
665686
......@@ -685,6 +706,28 @@ template <class _CharT, class _Traits, class _Allocator>
685706_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string<_CharT, _Traits, _Allocator>
686707operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y);
687708
709#if _LIBCPP_STD_VER >= 26
710
711template <class _CharT, class _Traits, class _Allocator>
712_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
713operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
714 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);
715
716template <class _CharT, class _Traits, class _Allocator>
717_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
718operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, type_identity_t<basic_string_view<_CharT, _Traits>> __rhs);
719
720template <class _CharT, class _Traits, class _Allocator>
721_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
722operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
723 const basic_string<_CharT, _Traits, _Allocator>& __rhs);
724
725template <class _CharT, class _Traits, class _Allocator>
726_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
727operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs);
728
729#endif
730
688731extern template _LIBCPP_EXPORTED_FROM_ABI string operator+
689732 <char, char_traits<char>, allocator<char> >(char const*, string const&);
690733
......@@ -724,21 +767,72 @@ public:
724767 typedef typename __alloc_traits::pointer pointer;
725768 typedef typename __alloc_traits::const_pointer const_pointer;
726769
727 static_assert((!is_array<value_type>::value), "Character type of basic_string must not be an array");
728 static_assert((is_standard_layout<value_type>::value), "Character type of basic_string must be standard-layout");
729 static_assert((is_trivial<value_type>::value), "Character type of basic_string must be trivial");
730 static_assert((is_same<_CharT, typename traits_type::char_type>::value),
731 "traits_type::char_type must be the same type as CharT");
732 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
733 "Allocator::value_type must be same type as value_type");
770 // A basic_string contains the following members which may be trivially relocatable:
771 // - pointer: is currently assumed to be trivially relocatable, but is still checked in case that changes
772 // - size_type: is always trivially relocatable, since it has to be an integral type
773 // - value_type: is always trivially relocatable, since it has to be trivial
774 // - unsigned char: is a fundamental type, so it's trivially relocatable
775 // - allocator_type: may or may not be trivially relocatable, so it's checked
776 //
777 // This string implementation doesn't contain any references into itself. It only contains a bit that says whether
778 // it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
779#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
780 // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
781 // relocatable. Because the object's memory might be poisoned when its content
782 // is kept inside objects memory (short string optimization), instead of in allocated
783 // external memory. In such cases, the destructor is responsible for unpoisoning
784 // the memory to avoid triggering false positives.
785 // Therefore it's crucial to ensure the destructor is called.
786 using __trivially_relocatable = void;
787#else
788 using __trivially_relocatable = __conditional_t<
789 __libcpp_is_trivially_relocatable<allocator_type>::value && __libcpp_is_trivially_relocatable<pointer>::value,
790 basic_string,
791 void>;
792#endif
793#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
794 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
795 if (__libcpp_is_constant_evaluated())
796 return __ptr;
797
798 pointer volatile __copy_ptr = __ptr;
799
800 return const_cast<pointer&>(__copy_ptr);
801 }
734802
735 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
736 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
737 "original allocator");
803 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer
804 __asan_volatile_wrapper(const_pointer const& __ptr) const {
805 if (__libcpp_is_constant_evaluated())
806 return __ptr;
738807
739 // TODO: Implement iterator bounds checking without requiring the global database.
808 const_pointer volatile __copy_ptr = __ptr;
809
810 return const_cast<const_pointer&>(__copy_ptr);
811 }
812# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) __asan_volatile_wrapper(PTR)
813#else
814# define _LIBCPP_ASAN_VOLATILE_WRAPPER(PTR) PTR
815#endif
816
817 static_assert(!is_array<value_type>::value, "Character type of basic_string must not be an array");
818 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string must be standard-layout");
819 static_assert(is_trivial<value_type>::value, "Character type of basic_string must be trivial");
820 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
821 "traits_type::char_type must be the same type as CharT");
822 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
823 "Allocator::value_type must be same type as value_type");
824 static_assert(__check_valid_allocator<allocator_type>::value, "");
825
826#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
827 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
828 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
829 // considered contiguous.
830 typedef __bounded_iter<__wrap_iter<pointer>> iterator;
831 typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator;
832#else
740833 typedef __wrap_iter<pointer> iterator;
741834 typedef __wrap_iter<const_pointer> const_iterator;
835#endif
742836 typedef std::reverse_iterator<iterator> reverse_iterator;
743837 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
744838
......@@ -818,23 +912,9 @@ private:
818912
819913 static_assert(sizeof(__short) == (sizeof(value_type) * (__min_cap + 1)), "__short has an unexpected size.");
820914
821 union __ulx {
822 __long __lx;
823 __short __lxx;
824 };
825
826 enum { __n_words = sizeof(__ulx) / sizeof(size_type) };
827
828 struct __raw {
829 size_type __words[__n_words];
830 };
831
832 struct __rep {
833 union {
834 __short __s;
835 __long __l;
836 __raw __r;
837 };
915 union __rep {
916 __short __s;
917 __long __l;
838918 };
839919
840920 __compressed_pair<__rep, allocator_type> __r_;
......@@ -868,10 +948,33 @@ private:
868948 __init_with_sentinel(std::move(__first), std::move(__last));
869949 }
870950
871 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) { return iterator(__p); }
951 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator __make_iterator(pointer __p) {
952#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
953 // Bound the iterator according to the size (and not the capacity, unlike vector).
954 //
955 // By the Standard, string iterators are generally not guaranteed to stay valid when the container is modified,
956 // regardless of whether reallocation occurs. This allows us to check for out-of-bounds accesses using logical size,
957 // a stricter check, since correct code can never rely on being able to access newly-added elements via an existing
958 // iterator.
959 return std::__make_bounded_iter(
960 std::__wrap_iter<pointer>(__p),
961 std::__wrap_iter<pointer>(__get_pointer()),
962 std::__wrap_iter<pointer>(__get_pointer() + size()));
963#else
964 return iterator(__p);
965#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
966 }
872967
873968 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_iterator __make_const_iterator(const_pointer __p) const {
969#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
970 // Bound the iterator according to the size (and not the capacity, unlike vector).
971 return std::__make_bounded_iter(
972 std::__wrap_iter<const_pointer>(__p),
973 std::__wrap_iter<const_pointer>(__get_pointer()),
974 std::__wrap_iter<const_pointer>(__get_pointer() + size()));
975#else
874976 return const_iterator(__p);
977#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
875978 }
876979
877980public:
......@@ -922,7 +1025,11 @@ public:
9221025 // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
9231026 // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.
9241027 // __str's memory needs to be unpoisoned only in the case where it's a short string.
925 : __r_([](basic_string &__s) -> decltype(__s.__r_)&& { if(!__s.__is_long()) __s.__annotate_delete(); return std::move(__s.__r_); }(__str)) {
1028 : __r_([](basic_string& __s) -> decltype(__s.__r_)&& {
1029 if (!__s.__is_long())
1030 __s.__annotate_delete();
1031 return std::move(__s.__r_);
1032 }(__str)) {
9261033 __str.__r_.first() = __rep();
9271034 __str.__annotate_new(0);
9281035 if (!__is_long())
......@@ -1054,8 +1161,8 @@ public:
10541161 __enable_if_t<__can_be_converted_to_string_view<_CharT, _Traits, _Tp>::value &&
10551162 !__is_same_uncvref<_Tp, basic_string>::value,
10561163 int> = 0>
1057 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(
1058 const _Tp& __t, const allocator_type& __a)
1164 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS
1165 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit basic_string(const _Tp& __t, const allocator_type& __a)
10591166 : __r_(__default_init_tag(), __a) {
10601167 __self_view __sv = __t;
10611168 __init(__sv.data(), __sv.size());
......@@ -1122,8 +1229,8 @@ public:
11221229 }
11231230
11241231#ifndef _LIBCPP_CXX03_LANG
1125 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(basic_string&& __str)
1126 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
1232 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1233 operator=(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
11271234 __move_assign(__str, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
11281235 return *this;
11291236 }
......@@ -1138,7 +1245,7 @@ public:
11381245#if _LIBCPP_STD_VER >= 23
11391246 basic_string& operator=(nullptr_t) = delete;
11401247#endif
1141 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS basic_string& operator=(value_type __c);
1248 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& operator=(value_type __c);
11421249
11431250 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 iterator begin() _NOEXCEPT {
11441251 return __make_iterator(__get_pointer());
......@@ -1213,7 +1320,7 @@ public:
12131320 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void shrink_to_fit() _NOEXCEPT;
12141321 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void clear() _NOEXCEPT;
12151322
1216 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
1323 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
12171324 return size() == 0;
12181325 }
12191326
......@@ -1287,8 +1394,8 @@ public:
12871394 int> = 0>
12881395 _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS _LIBCPP_CONSTEXPR_SINCE_CXX20
12891396
1290 basic_string&
1291 append(const _Tp& __t, size_type __pos, size_type __n = npos);
1397 basic_string&
1398 append(const _Tp& __t, size_type __pos, size_type __n = npos);
12921399
12931400 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s, size_type __n);
12941401 _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& append(const value_type* __s);
......@@ -1379,8 +1486,8 @@ public:
13791486 return *this = __str;
13801487 }
13811488#ifndef _LIBCPP_CXX03_LANG
1382 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string& assign(basic_string&& __str)
1383 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
1489 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string&
1490 assign(basic_string&& __str) noexcept(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
13841491 *this = std::move(__str);
13851492 return *this;
13861493 }
......@@ -1589,7 +1696,7 @@ public:
15891696#if _LIBCPP_STD_VER >= 14
15901697 _NOEXCEPT;
15911698#else
1592 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
1699 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
15931700#endif
15941701
15951702 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const value_type* c_str() const _NOEXCEPT { return data(); }
......@@ -1794,6 +1901,23 @@ private:
17941901 template <class _Iterator, class _Sentinel>
17951902 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __first, _Sentinel __last);
17961903
1904 // Copy [__first, __last) into [__dest, __dest + (__last - __first)). Assumes that the ranges don't overlap.
1905 template <class _ForwardIter, class _Sent>
1906 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 static value_type*
1907 __copy_non_overlapping_range(_ForwardIter __first, _Sent __last, value_type* __dest) {
1908#ifndef _LIBCPP_CXX03_LANG
1909 if constexpr (__libcpp_is_contiguous_iterator<_ForwardIter>::value &&
1910 is_same<value_type, __iter_value_type<_ForwardIter>>::value && is_same<_ForwardIter, _Sent>::value) {
1911 traits_type::copy(__dest, std::__to_address(__first), __last - __first);
1912 return __dest + (__last - __first);
1913 }
1914#endif
1915
1916 for (; __first != __last; ++__first)
1917 traits_type::assign(*__dest++, *__first);
1918 return __dest;
1919 }
1920
17971921 template <class _ForwardIterator, class _Sentinel>
17981922 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 iterator
17991923 __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _Sentinel __last) {
......@@ -1813,8 +1937,7 @@ private:
18131937 __sz += __n;
18141938 __set_size(__sz);
18151939 traits_type::assign(__p[__sz], value_type());
1816 for (__p += __ip; __first != __last; ++__p, ++__first)
1817 traits_type::assign(*__p, *__first);
1940 __copy_non_overlapping_range(__first, __last, __p + __ip);
18181941
18191942 return begin() + __ip;
18201943 }
......@@ -1865,16 +1988,18 @@ private:
18651988 __r_.first().__l.__data_ = __p;
18661989 }
18671990 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_long_pointer() _NOEXCEPT {
1868 return __r_.first().__l.__data_;
1991 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);
18691992 }
18701993 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_long_pointer() const _NOEXCEPT {
1871 return __r_.first().__l.__data_;
1994 return _LIBCPP_ASAN_VOLATILE_WRAPPER(__r_.first().__l.__data_);
18721995 }
1873 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_short_pointer() _NOEXCEPT {
1874 return pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]);
1996 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS pointer
1997 __get_short_pointer() _NOEXCEPT {
1998 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<pointer>::pointer_to(__r_.first().__s.__data_[0]));
18751999 }
1876 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 const_pointer __get_short_pointer() const _NOEXCEPT {
1877 return pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]);
2000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS const_pointer
2001 __get_short_pointer() const _NOEXCEPT {
2002 return _LIBCPP_ASAN_VOLATILE_WRAPPER(pointer_traits<const_pointer>::pointer_to(__r_.first().__s.__data_[0]));
18782003 }
18792004 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __get_pointer() _NOEXCEPT {
18802005 return __is_long() ? __get_long_pointer() : __get_short_pointer();
......@@ -1889,45 +2014,42 @@ private:
18892014 (void)__old_mid;
18902015 (void)__new_mid;
18912016#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
1892 const void* __begin = data();
1893 const void* __end = data() + capacity() + 1;
1894 if (__asan_annotate_container_with_allocator<allocator_type>::value && !__libcpp_is_constant_evaluated())
1895 __sanitizer_annotate_contiguous_container(__begin, __end, __old_mid, __new_mid);
2017 #if defined(__APPLE__)
2018 // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
2019 if(!__is_long())
2020 return;
2021 #endif
2022 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity() + 1, __old_mid, __new_mid);
18962023#endif
18972024 }
18982025
1899 // ASan: short string is poisoned if and only if this function returns true.
1900 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool __asan_short_string_is_annotated() const _NOEXCEPT {
1901 return _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED && !__libcpp_is_constant_evaluated();
1902 }
1903
19042026 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT {
1905 (void) __current_size;
2027 (void)__current_size;
19062028#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
1907 if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
2029 if (!__libcpp_is_constant_evaluated())
19082030 __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1);
19092031#endif
19102032 }
19112033
19122034 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT {
19132035#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
1914 if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
2036 if (!__libcpp_is_constant_evaluated())
19152037 __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1);
19162038#endif
19172039 }
19182040
19192041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT {
1920 (void) __n;
2042 (void)__n;
19212043#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
1922 if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
2044 if (!__libcpp_is_constant_evaluated())
19232045 __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n);
19242046#endif
19252047 }
19262048
19272049 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT {
1928 (void) __old_size;
2050 (void)__old_size;
19292051#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
1930 if (!__libcpp_is_constant_evaluated() && (__asan_short_string_is_annotated() || __is_long()))
2052 if (!__libcpp_is_constant_evaluated())
19312053 __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1);
19322054#endif
19332055 }
......@@ -1936,17 +2058,15 @@ private:
19362058 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __align_it(size_type __s) _NOEXCEPT {
19372059 return (__s + (__a - 1)) & ~(__a - 1);
19382060 }
1939 enum {
1940 __alignment = 8
1941 };
2061 enum { __alignment = 8 };
19422062 static _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type __recommend(size_type __s) _NOEXCEPT {
19432063 if (__s < __min_cap) {
19442064 return static_cast<size_type>(__min_cap) - 1;
19452065 }
1946 size_type __guess =
1947 __align_it < sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : 1 > (__s + 1) - 1;
2066 const size_type __boundary = sizeof(value_type) < __alignment ? __alignment / sizeof(value_type) : __endian_factor;
2067 size_type __guess = __align_it<__boundary>(__s + 1) - 1;
19482068 if (__guess == __min_cap)
1949 ++__guess;
2069 __guess += __endian_factor;
19502070 return __guess;
19512071 }
19522072
......@@ -1979,15 +2099,15 @@ private:
19792099
19802100 _LIBCPP_CONSTEXPR_SINCE_CXX20
19812101#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
1982 _LIBCPP_HIDE_FROM_ABI
2102 _LIBCPP_HIDE_FROM_ABI
19832103#endif
1984 _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(
1985 size_type __old_cap,
1986 size_type __delta_cap,
1987 size_type __old_sz,
1988 size_type __n_copy,
1989 size_type __n_del,
1990 size_type __n_add = 0);
2104 _LIBCPP_DEPRECATED_("use __grow_by_without_replace") void __grow_by(
2105 size_type __old_cap,
2106 size_type __delta_cap,
2107 size_type __old_sz,
2108 size_type __n_copy,
2109 size_type __n_del,
2110 size_type __n_add = 0);
19912111 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __grow_by_without_replace(
19922112 size_type __old_cap,
19932113 size_type __delta_cap,
......@@ -2050,14 +2170,14 @@ private:
20502170 __copy_assign_alloc(const basic_string&, false_type) _NOEXCEPT {}
20512171
20522172#ifndef _LIBCPP_CXX03_LANG
2053 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __move_assign(basic_string& __str, false_type)
2054 _NOEXCEPT_(__alloc_traits::is_always_equal::value);
2173 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2174 __move_assign(basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value);
20552175 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
20562176 __move_assign(basic_string& __str, true_type)
20572177# if _LIBCPP_STD_VER >= 17
2058 _NOEXCEPT;
2178 noexcept;
20592179# else
2060 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
2180 noexcept(is_nothrow_move_assignable<allocator_type>::value);
20612181# endif
20622182#endif
20632183
......@@ -2122,6 +2242,10 @@ private:
21222242 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(value_type, const basic_string&);
21232243 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, const value_type*);
21242244 friend _LIBCPP_CONSTEXPR_SINCE_CXX20 basic_string operator+ <>(const basic_string&, value_type);
2245#if _LIBCPP_STD_VER >= 26
2246 friend constexpr basic_string operator+ <>(const basic_string&, type_identity_t<__self_view>);
2247 friend constexpr basic_string operator+ <>(type_identity_t<__self_view>, const basic_string&);
2248#endif
21252249};
21262250
21272251// These declarations must appear before any functions are implicitly used
......@@ -2153,8 +2277,8 @@ template <class _CharT,
21532277 class _Traits,
21542278 class _Allocator = allocator<_CharT>,
21552279 class = enable_if_t<__is_allocator<_Allocator>::value> >
2156explicit basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
2157 -> basic_string<_CharT, _Traits, _Allocator>;
2280explicit basic_string(basic_string_view<_CharT, _Traits>,
2281 const _Allocator& = _Allocator()) -> basic_string<_CharT, _Traits, _Allocator>;
21582282
21592283template <class _CharT,
21602284 class _Traits,
......@@ -2333,9 +2457,8 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir
23332457#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
23342458 try {
23352459#endif // _LIBCPP_HAS_NO_EXCEPTIONS
2336 for (; __first != __last; ++__first, (void)++__p)
2337 traits_type::assign(*__p, *__first);
2338 traits_type::assign(*__p, value_type());
2460 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p));
2461 traits_type::assign(*__end, value_type());
23392462#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
23402463 } catch (...) {
23412464 if (__is_long())
......@@ -2380,7 +2503,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
23802503 __old_sz = __n_copy + __n_add + __sec_cp_sz;
23812504 __set_long_size(__old_sz);
23822505 traits_type::assign(__p[__old_sz], value_type());
2383 __annotate_new(__old_cap + __delta_cap);
2506 __annotate_new(__old_sz);
23842507}
23852508
23862509// __grow_by is deprecated because it does not set the size. It may not update the size when the size is changed, and it
......@@ -2389,15 +2512,15 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__
23892512template <class _CharT, class _Traits, class _Allocator>
23902513void _LIBCPP_CONSTEXPR_SINCE_CXX20
23912514#if _LIBCPP_ABI_VERSION >= 2 // We want to use the function in the dylib in ABIv1
2392 _LIBCPP_HIDE_FROM_ABI
2515_LIBCPP_HIDE_FROM_ABI
23932516#endif
2394 _LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(
2395 size_type __old_cap,
2396 size_type __delta_cap,
2397 size_type __old_sz,
2398 size_type __n_copy,
2399 size_type __n_del,
2400 size_type __n_add) {
2517_LIBCPP_DEPRECATED_("use __grow_by_without_replace") basic_string<_CharT, _Traits, _Allocator>::__grow_by(
2518 size_type __old_cap,
2519 size_type __delta_cap,
2520 size_type __old_sz,
2521 size_type __n_copy,
2522 size_type __n_del,
2523 size_type __n_add) {
24012524 size_type __ms = max_size();
24022525 if (__delta_cap > __ms - __old_cap)
24032526 __throw_length_error();
......@@ -2548,9 +2671,8 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str)
25482671#ifndef _LIBCPP_CXX03_LANG
25492672
25502673template <class _CharT, class _Traits, class _Allocator>
2551inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void
2552basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type)
2553 _NOEXCEPT_(__alloc_traits::is_always_equal::value) {
2674inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocator>::__move_assign(
2675 basic_string& __str, false_type) noexcept(__alloc_traits::is_always_equal::value) {
25542676 if (__alloc() != __str.__alloc())
25552677 assign(__str);
25562678 else
......@@ -2561,9 +2683,9 @@ template <class _CharT, class _Traits, class _Allocator>
25612683inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS void
25622684basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type)
25632685# if _LIBCPP_STD_VER >= 17
2564 _NOEXCEPT
2686 noexcept
25652687# else
2566 _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
2688 noexcept(is_nothrow_move_assignable<allocator_type>::value)
25672689# endif
25682690{
25692691 __annotate_delete();
......@@ -2802,10 +2924,8 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For
28022924 if (__cap - __sz < __n)
28032925 __grow_by_without_replace(__cap, __sz + __n - __cap, __sz, __sz, 0);
28042926 __annotate_increase(__n);
2805 pointer __p = __get_pointer() + __sz;
2806 for (; __first != __last; ++__p, (void)++__first)
2807 traits_type::assign(*__p, *__first);
2808 traits_type::assign(*__p, value_type());
2927 auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__get_pointer() + __sz));
2928 traits_type::assign(*__end, value_type());
28092929 __set_size(__sz + __n);
28102930 } else {
28112931 const basic_string __temp(__first, __last, __alloc());
......@@ -3238,23 +3358,34 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
32383358 __p = __get_long_pointer();
32393359 } else {
32403360 if (__target_capacity > __cap) {
3361 // Extend
3362 // - called from reserve should propagate the exception thrown.
32413363 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
32423364 __new_data = __allocation.ptr;
32433365 __target_capacity = __allocation.count - 1;
32443366 } else {
3367 // Shrink
3368 // - called from shrink_to_fit should not throw.
3369 // - called from reserve may throw but is not required to.
32453370#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
32463371 try {
32473372#endif // _LIBCPP_HAS_NO_EXCEPTIONS
32483373 auto __allocation = std::__allocate_at_least(__alloc(), __target_capacity + 1);
3374
3375 // The Standard mandates shrink_to_fit() does not increase the capacity.
3376 // With equal capacity keep the existing buffer. This avoids extra work
3377 // due to swapping the elements.
3378 if (__allocation.count - 1 > __target_capacity) {
3379 __alloc_traits::deallocate(__alloc(), __allocation.ptr, __allocation.count);
3380 __annotate_new(__sz); // Undoes the __annotate_delete()
3381 return;
3382 }
32493383 __new_data = __allocation.ptr;
32503384 __target_capacity = __allocation.count - 1;
32513385#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
32523386 } catch (...) {
32533387 return;
32543388 }
3255#else // _LIBCPP_HAS_NO_EXCEPTIONS
3256 if (__new_data == nullptr)
3257 return;
32583389#endif // _LIBCPP_HAS_NO_EXCEPTIONS
32593390 }
32603391 __begin_lifetime(__new_data, __target_capacity + 1);
......@@ -3306,7 +3437,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX20 void basic_string<_CharT, _Traits, _Allocat
33063437#if _LIBCPP_STD_VER >= 14
33073438 _NOEXCEPT
33083439#else
3309 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
3440 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
33103441#endif
33113442{
33123443 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
......@@ -3702,17 +3833,10 @@ template <class _Allocator>
37023833inline _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool
37033834operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
37043835 const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT {
3705 size_t __lhs_sz = __lhs.size();
3706 if (__lhs_sz != __rhs.size())
3836 size_t __sz = __lhs.size();
3837 if (__sz != __rhs.size())
37073838 return false;
3708 const char* __lp = __lhs.data();
3709 const char* __rp = __rhs.data();
3710 if (__lhs.__is_long())
3711 return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
3712 for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
3713 if (*__lp != *__rp)
3714 return false;
3715 return true;
3839 return char_traits<char>::compare(__lhs.data(), __rhs.data(), __sz) == 0;
37163840}
37173841
37183842#if _LIBCPP_STD_VER <= 17
......@@ -3987,6 +4111,60 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) {
39874111
39884112#endif // _LIBCPP_CXX03_LANG
39894113
4114#if _LIBCPP_STD_VER >= 26
4115
4116template <class _CharT, class _Traits, class _Allocator>
4117_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4118operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
4119 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {
4120 using _String = basic_string<_CharT, _Traits, _Allocator>;
4121 typename _String::size_type __lhs_sz = __lhs.size();
4122 typename _String::size_type __rhs_sz = __rhs.size();
4123 _String __r(__uninitialized_size_tag(),
4124 __lhs_sz + __rhs_sz,
4125 _String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator()));
4126 auto __ptr = std::__to_address(__r.__get_pointer());
4127 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4128 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4129 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4130 return __r;
4131}
4132
4133template <class _CharT, class _Traits, class _Allocator>
4134_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4135operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs,
4136 type_identity_t<basic_string_view<_CharT, _Traits>> __rhs) {
4137 __lhs.append(__rhs);
4138 return std::move(__lhs);
4139}
4140
4141template <class _CharT, class _Traits, class _Allocator>
4142_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4143operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
4144 const basic_string<_CharT, _Traits, _Allocator>& __rhs) {
4145 using _String = basic_string<_CharT, _Traits, _Allocator>;
4146 typename _String::size_type __lhs_sz = __lhs.size();
4147 typename _String::size_type __rhs_sz = __rhs.size();
4148 _String __r(__uninitialized_size_tag(),
4149 __lhs_sz + __rhs_sz,
4150 _String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator()));
4151 auto __ptr = std::__to_address(__r.__get_pointer());
4152 _Traits::copy(__ptr, __lhs.data(), __lhs_sz);
4153 _Traits::copy(__ptr + __lhs_sz, __rhs.data(), __rhs_sz);
4154 _Traits::assign(__ptr + __lhs_sz + __rhs_sz, 1, _CharT());
4155 return __r;
4156}
4157
4158template <class _CharT, class _Traits, class _Allocator>
4159_LIBCPP_HIDE_FROM_ABI constexpr basic_string<_CharT, _Traits, _Allocator>
4160operator+(type_identity_t<basic_string_view<_CharT, _Traits>> __lhs,
4161 basic_string<_CharT, _Traits, _Allocator>&& __rhs) {
4162 __rhs.insert(0, __lhs);
4163 return std::move(__rhs);
4164}
4165
4166#endif // _LIBCPP_STD_VER >= 26
4167
39904168// swap
39914169
39924170template <class _CharT, class _Traits, class _Allocator>
lib/libcxx/include/string_view+27-25
......@@ -206,15 +206,17 @@ namespace std {
206206// clang-format on
207207
208208#include <__algorithm/min.h>
209#include <__assert> // all public C++ headers provide the assertion handler
209#include <__assert>
210210#include <__config>
211211#include <__functional/hash.h>
212212#include <__functional/unary_function.h>
213#include <__fwd/ostream.h>
213214#include <__fwd/string_view.h>
214215#include <__iterator/bounded_iter.h>
215216#include <__iterator/concepts.h>
216217#include <__iterator/iterator_traits.h>
217218#include <__iterator/reverse_iterator.h>
219#include <__iterator/wrap_iter.h>
218220#include <__memory/pointer_traits.h>
219221#include <__ranges/concepts.h>
220222#include <__ranges/data.h>
......@@ -278,10 +280,12 @@ public:
278280 using const_pointer = const _CharT*;
279281 using reference = _CharT&;
280282 using const_reference = const _CharT&;
281#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
283#if defined(_LIBCPP_ABI_BOUNDED_ITERATORS)
282284 using const_iterator = __bounded_iter<const_pointer>;
285#elif defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW)
286 using const_iterator = __wrap_iter<const_pointer>;
283287#else
284 using const_iterator = const_pointer; // See [string.view.iterators]
288 using const_iterator = const_pointer;
285289#endif
286290 using iterator = const_iterator;
287291 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
......@@ -290,10 +294,10 @@ public:
290294 using difference_type = ptrdiff_t;
291295 static _LIBCPP_CONSTEXPR const size_type npos = -1; // size_type(-1);
292296
293 static_assert((!is_array<value_type>::value), "Character type of basic_string_view must not be an array");
294 static_assert((is_standard_layout<value_type>::value), "Character type of basic_string_view must be standard-layout");
295 static_assert((is_trivial<value_type>::value), "Character type of basic_string_view must be trivial");
296 static_assert((is_same<_CharT, typename traits_type::char_type>::value),
297 static_assert(!is_array<value_type>::value, "Character type of basic_string_view must not be an array");
298 static_assert(is_standard_layout<value_type>::value, "Character type of basic_string_view must be standard-layout");
299 static_assert(is_trivial<value_type>::value, "Character type of basic_string_view must be trivial");
300 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
297301 "traits_type::char_type must be the same type as CharT");
298302
299303 // [string.view.cons], construct/copy
......@@ -307,9 +311,10 @@ public:
307311 : __data_(__s),
308312 __size_(__len) {
309313#if _LIBCPP_STD_VER >= 14
310 // This will result in creating an invalid `string_view` object -- some calculations involving `size` would
311 // overflow, making it effectively truncated.
312 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
314 // Allocations must fit in `ptrdiff_t` for pointer arithmetic to work. If `__len` exceeds it, the input
315 // range could not have been valid. Most likely the caller underflowed some arithmetic and inadvertently
316 // passed in a negative length.
317 _LIBCPP_ASSERT_VALID_INPUT_RANGE(
313318 __len <= static_cast<size_type>(numeric_limits<difference_type>::max()),
314319 "string_view::string_view(_CharT *, size_t): length does not fit in difference_type");
315320 _LIBCPP_ASSERT_NON_NULL(
......@@ -353,7 +358,7 @@ public:
353358#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
354359 return std::__make_bounded_iter(data(), data(), data() + size());
355360#else
356 return __data_;
361 return const_iterator(__data_);
357362#endif
358363 }
359364
......@@ -361,7 +366,7 @@ public:
361366#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS
362367 return std::__make_bounded_iter(data() + size(), data(), data() + size());
363368#else
364 return __data_ + __size_;
369 return const_iterator(__data_ + __size_);
365370#endif
366371 }
367372
......@@ -390,9 +395,7 @@ public:
390395 return numeric_limits<size_type>::max() / sizeof(value_type);
391396 }
392397
393 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {
394 return __size_ == 0;
395 }
398 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT { return __size_ == 0; }
396399
397400 // [string.view.access], element access
398401 _LIBCPP_CONSTEXPR _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __pos) const _NOEXCEPT {
......@@ -900,32 +903,31 @@ struct hash<basic_string_view<wchar_t, char_traits<wchar_t> > > : __string_view_
900903#if _LIBCPP_STD_VER >= 14
901904inline namespace literals {
902905inline namespace string_view_literals {
903inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char>
904operator""sv(const char* __str, size_t __len) _NOEXCEPT {
906inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char> operator""sv(const char* __str, size_t __len) noexcept {
905907 return basic_string_view<char>(__str, __len);
906908}
907909
908910# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
909inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<wchar_t>
910operator""sv(const wchar_t* __str, size_t __len) _NOEXCEPT {
911inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<wchar_t>
912operator""sv(const wchar_t* __str, size_t __len) noexcept {
911913 return basic_string_view<wchar_t>(__str, __len);
912914}
913915# endif
914916
915917# ifndef _LIBCPP_HAS_NO_CHAR8_T
916inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char8_t>
917operator""sv(const char8_t* __str, size_t __len) _NOEXCEPT {
918inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char8_t>
919operator""sv(const char8_t* __str, size_t __len) noexcept {
918920 return basic_string_view<char8_t>(__str, __len);
919921}
920922# endif
921923
922inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char16_t>
923operator""sv(const char16_t* __str, size_t __len) _NOEXCEPT {
924inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char16_t>
925operator""sv(const char16_t* __str, size_t __len) noexcept {
924926 return basic_string_view<char16_t>(__str, __len);
925927}
926928
927inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR basic_string_view<char32_t>
928operator""sv(const char32_t* __str, size_t __len) _NOEXCEPT {
929inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view<char32_t>
930operator""sv(const char32_t* __str, size_t __len) noexcept {
929931 return basic_string_view<char32_t>(__str, __len);
930932}
931933} // namespace string_view_literals
lib/libcxx/include/strstream+22-19
......@@ -13,7 +13,7 @@
1313/*
1414 strstream synopsis
1515
16class strstreambuf
16class strstreambuf // Removed in C++26
1717 : public basic_streambuf<char>
1818{
1919public:
......@@ -63,7 +63,7 @@ private:
6363 void (*pfree)(void*); // exposition only
6464};
6565
66class istrstream
66class istrstream // Removed in C++26
6767 : public basic_istream<char>
6868{
6969public:
......@@ -81,7 +81,7 @@ private:
8181 strstreambuf sb; // exposition only
8282};
8383
84class ostrstream
84class ostrstream // Removed in C++26
8585 : public basic_ostream<char>
8686{
8787public:
......@@ -99,7 +99,7 @@ private:
9999 strstreambuf sb; // exposition only
100100};
101101
102class strstream
102class strstream // Removed in C++26
103103 : public basic_iostream<char>
104104{
105105public:
......@@ -129,7 +129,6 @@ private:
129129
130130*/
131131
132#include <__assert> // all public C++ headers provide the assertion handler
133132#include <__config>
134133#include <istream>
135134#include <ostream>
......@@ -139,19 +138,21 @@ private:
139138# pragma GCC system_header
140139#endif
141140
141#if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)
142
142143_LIBCPP_PUSH_MACROS
143#include <__undef_macros>
144# include <__undef_macros>
144145
145146_LIBCPP_BEGIN_NAMESPACE_STD
146147
147148class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {
148149public:
149#ifndef _LIBCPP_CXX03_LANG
150# ifndef _LIBCPP_CXX03_LANG
150151 _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}
151152 explicit strstreambuf(streamsize __alsize);
152#else
153# else
153154 explicit strstreambuf(streamsize __alsize = 0);
154#endif
155# endif
155156 strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
156157 strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
157158 strstreambuf(const char* __gnext, streamsize __n);
......@@ -161,10 +162,10 @@ public:
161162 strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
162163 strstreambuf(const unsigned char* __gnext, streamsize __n);
163164
164#ifndef _LIBCPP_CXX03_LANG
165# ifndef _LIBCPP_CXX03_LANG
165166 _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);
166167 _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);
167#endif // _LIBCPP_CXX03_LANG
168# endif // _LIBCPP_CXX03_LANG
168169
169170 ~strstreambuf() override;
170171
......@@ -198,7 +199,7 @@ private:
198199 void __init(char* __gnext, streamsize __n, char* __pbeg);
199200};
200201
201#ifndef _LIBCPP_CXX03_LANG
202# ifndef _LIBCPP_CXX03_LANG
202203
203204inline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)
204205 : streambuf(__rhs),
......@@ -227,7 +228,7 @@ inline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&
227228 return *this;
228229}
229230
230#endif // _LIBCPP_CXX03_LANG
231# endif // _LIBCPP_CXX03_LANG
231232
232233class _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {
233234public:
......@@ -236,7 +237,7 @@ public:
236237 _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
237238 _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
238239
239#ifndef _LIBCPP_CXX03_LANG
240# ifndef _LIBCPP_CXX03_LANG
240241 _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension
241242 : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
242243 istream::set_rdbuf(&__sb_);
......@@ -247,7 +248,7 @@ public:
247248 istream::operator=(std::move(__rhs));
248249 return *this;
249250 }
250#endif // _LIBCPP_CXX03_LANG
251# endif // _LIBCPP_CXX03_LANG
251252
252253 ~istrstream() override;
253254
......@@ -269,7 +270,7 @@ public:
269270 _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
270271 : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
271272
272#ifndef _LIBCPP_CXX03_LANG
273# ifndef _LIBCPP_CXX03_LANG
273274 _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension
274275 : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
275276 ostream::set_rdbuf(&__sb_);
......@@ -280,7 +281,7 @@ public:
280281 ostream::operator=(std::move(__rhs));
281282 return *this;
282283 }
283#endif // _LIBCPP_CXX03_LANG
284# endif // _LIBCPP_CXX03_LANG
284285
285286 ~ostrstream() override;
286287
......@@ -311,7 +312,7 @@ public:
311312 _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
312313 : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
313314
314#ifndef _LIBCPP_CXX03_LANG
315# ifndef _LIBCPP_CXX03_LANG
315316 _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension
316317 : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
317318 iostream::set_rdbuf(&__sb_);
......@@ -322,7 +323,7 @@ public:
322323 iostream::operator=(std::move(__rhs));
323324 return *this;
324325 }
325#endif // _LIBCPP_CXX03_LANG
326# endif // _LIBCPP_CXX03_LANG
326327
327328 ~strstream() override;
328329
......@@ -345,4 +346,6 @@ _LIBCPP_END_NAMESPACE_STD
345346
346347_LIBCPP_POP_MACROS
347348
349#endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM) || defined(_LIBCPP_BUILDING_LIBRARY)
350
348351#endif // _LIBCPP_STRSTREAM
lib/libcxx/include/syncstream+2
......@@ -117,7 +117,9 @@ namespace std {
117117
118118#include <__config>
119119#include <__utility/move.h>
120#include <ios>
120121#include <iosfwd> // required for declaration of default arguments
122#include <streambuf>
121123#include <string>
122124
123125#ifndef _LIBCPP_HAS_NO_THREADS
lib/libcxx/include/system_error-1
......@@ -144,7 +144,6 @@ template <> struct hash<std::error_condition>;
144144
145145*/
146146
147#include <__assert> // all public C++ headers provide the assertion handler
148147#include <__config>
149148#include <__system_error/errc.h>
150149#include <__system_error/error_category.h>
lib/libcxx/include/thread+13-15
......@@ -88,27 +88,25 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
8888
8989#include <__config>
9090
91#ifdef _LIBCPP_HAS_NO_THREADS
92# error "<thread> is not supported since libc++ has been configured without support for threads."
93#endif
91#if !defined(_LIBCPP_HAS_NO_THREADS)
9492
95#include <__assert> // all public C++ headers provide the assertion handler
96#include <__availability>
97#include <__thread/formatter.h>
98#include <__thread/jthread.h>
99#include <__thread/this_thread.h>
100#include <__thread/thread.h>
101#include <__threading_support>
102#include <version>
93# include <__thread/formatter.h>
94# include <__thread/jthread.h>
95# include <__thread/support.h>
96# include <__thread/this_thread.h>
97# include <__thread/thread.h>
98# include <version>
10399
104100// standard-mandated includes
105101
106102// [thread.syn]
107#include <compare>
103# include <compare>
108104
109#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
110# pragma GCC system_header
111#endif
105# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
106# pragma GCC system_header
107# endif
108
109#endif // !defined(_LIBCPP_HAS_NO_THREADS)
112110
113111#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES)
114112# include <cstddef>
lib/libcxx/include/tuple+127-171
......@@ -132,7 +132,12 @@ tuple(allocator_arg_t, Alloc, pair<T1, T2>) -> tuple<T1, T2>; // since C++
132132template <class Alloc, class ...T>
133133tuple(allocator_arg_t, Alloc, tuple<T...>) -> tuple<T...>; // since C++17
134134
135inline constexpr unspecified ignore;
135struct ignore-type { // exposition only // Since C++26
136 constexpr const ignore-type&
137 operator=(const auto &) const noexcept
138 { return *this; }
139};
140inline constexpr ignore-type ignore;
136141
137142template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14
138143template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14
......@@ -205,16 +210,17 @@ template <class... Types>
205210
206211// clang-format on
207212
208#include <__assert> // all public C++ headers provide the assertion handler
209213#include <__compare/common_comparison_category.h>
210214#include <__compare/synth_three_way.h>
211215#include <__config>
212216#include <__functional/invoke.h>
213217#include <__fwd/array.h>
214#include <__fwd/get.h>
218#include <__fwd/pair.h>
215219#include <__fwd/tuple.h>
216220#include <__memory/allocator_arg_t.h>
217221#include <__memory/uses_allocator.h>
222#include <__tuple/find_index.h>
223#include <__tuple/ignore.h>
218224#include <__tuple/make_tuple_types.h>
219225#include <__tuple/sfinae_helpers.h>
220226#include <__tuple/tuple_element.h>
......@@ -222,7 +228,6 @@ template <class... Types>
222228#include <__tuple/tuple_like_ext.h>
223229#include <__tuple/tuple_size.h>
224230#include <__tuple/tuple_types.h>
225#include <__type_traits/apply_cv.h>
226231#include <__type_traits/common_reference.h>
227232#include <__type_traits/common_type.h>
228233#include <__type_traits/conditional.h>
......@@ -233,23 +238,15 @@ template <class... Types>
233238#include <__type_traits/is_assignable.h>
234239#include <__type_traits/is_constructible.h>
235240#include <__type_traits/is_convertible.h>
236#include <__type_traits/is_copy_assignable.h>
237#include <__type_traits/is_copy_constructible.h>
238#include <__type_traits/is_default_constructible.h>
239241#include <__type_traits/is_empty.h>
240242#include <__type_traits/is_final.h>
241243#include <__type_traits/is_implicitly_default_constructible.h>
242#include <__type_traits/is_move_assignable.h>
243#include <__type_traits/is_move_constructible.h>
244244#include <__type_traits/is_nothrow_assignable.h>
245245#include <__type_traits/is_nothrow_constructible.h>
246#include <__type_traits/is_nothrow_copy_assignable.h>
247#include <__type_traits/is_nothrow_copy_constructible.h>
248#include <__type_traits/is_nothrow_default_constructible.h>
249#include <__type_traits/is_nothrow_move_assignable.h>
250246#include <__type_traits/is_reference.h>
251247#include <__type_traits/is_same.h>
252248#include <__type_traits/is_swappable.h>
249#include <__type_traits/is_trivially_relocatable.h>
253250#include <__type_traits/lazy.h>
254251#include <__type_traits/maybe_const.h>
255252#include <__type_traits/nat.h>
......@@ -260,7 +257,6 @@ template <class... Types>
260257#include <__utility/forward.h>
261258#include <__utility/integer_sequence.h>
262259#include <__utility/move.h>
263#include <__utility/pair.h>
264260#include <__utility/piecewise_construct.h>
265261#include <__utility/swap.h>
266262#include <cstddef>
......@@ -289,15 +285,14 @@ class __tuple_leaf;
289285
290286template <size_t _Ip, class _Hp, bool _Ep>
291287inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
292swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y)
293 _NOEXCEPT_(__is_nothrow_swappable<_Hp>::value) {
288swap(__tuple_leaf<_Ip, _Hp, _Ep>& __x, __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<_Hp>) {
294289 swap(__x.get(), __y.get());
295290}
296291
297292template <size_t _Ip, class _Hp, bool _Ep>
298293_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
299swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x, const __tuple_leaf<_Ip, _Hp, _Ep>& __y)
300 _NOEXCEPT_(__is_nothrow_swappable<const _Hp>::value) {
294swap(const __tuple_leaf<_Ip, _Hp, _Ep>& __x,
295 const __tuple_leaf<_Ip, _Hp, _Ep>& __y) noexcept(__is_nothrow_swappable_v<const _Hp>) {
301296 swap(__x.get(), __y.get());
302297}
303298
......@@ -314,10 +309,10 @@ class __tuple_leaf {
314309# endif
315310 }
316311
317 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&);
318
319312public:
320 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) : __value_() {
313 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
314
315 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) : __value_() {
321316 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
322317 }
323318
......@@ -337,34 +332,34 @@ public:
337332 static_assert(!is_reference<_Hp>::value, "Attempted to default construct a reference element in a tuple");
338333 }
339334
340 template <class _Tp,
341 class = __enable_if_t<
342 _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > >
343 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t)
344 _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
335 template <
336 class _Tp,
337 __enable_if_t<_And<_IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value, int> = 0>
338 _LIBCPP_HIDE_FROM_ABI
339 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
345340 : __value_(std::forward<_Tp>(__t)) {
346341 static_assert(__can_bind_reference<_Tp&&>(),
347342 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
348343 }
349344
350345 template <class _Tp, class _Alloc>
351 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(
352 integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
346 _LIBCPP_HIDE_FROM_ABI
347 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 0>, const _Alloc&, _Tp&& __t)
353348 : __value_(std::forward<_Tp>(__t)) {
354349 static_assert(__can_bind_reference<_Tp&&>(),
355350 "Attempted construction of reference element binds to a temporary whose lifetime has ended");
356351 }
357352
358353 template <class _Tp, class _Alloc>
359 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(
360 integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
354 _LIBCPP_HIDE_FROM_ABI
355 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 1>, const _Alloc& __a, _Tp&& __t)
361356 : __value_(allocator_arg_t(), __a, std::forward<_Tp>(__t)) {
362357 static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
363358 }
364359
365360 template <class _Tp, class _Alloc>
366 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(
367 integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
361 _LIBCPP_HIDE_FROM_ABI
362 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a, _Tp&& __t)
368363 : __value_(std::forward<_Tp>(__t), __a) {
369364 static_assert(!is_reference<_Hp>::value, "Attempted to uses-allocator construct a reference element in a tuple");
370365 }
......@@ -372,14 +367,14 @@ public:
372367 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(const __tuple_leaf& __t) = default;
373368 _LIBCPP_HIDE_FROM_ABI __tuple_leaf(__tuple_leaf&& __t) = default;
374369
375 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t)
376 _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) {
370 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
371 swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
377372 std::swap(*this, __t);
378373 return 0;
379374 }
380375
381376 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __t) const
382 _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
377 noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
383378 std::swap(*this, __t);
384379 return 0;
385380 }
......@@ -390,10 +385,10 @@ public:
390385
391386template <size_t _Ip, class _Hp>
392387class __tuple_leaf<_Ip, _Hp, true> : private _Hp {
393 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&);
394
395388public:
396 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() _NOEXCEPT_(is_nothrow_default_constructible<_Hp>::value) {}
389 _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_leaf& operator=(const __tuple_leaf&) = delete;
390
391 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible<_Hp>::value) {}
397392
398393 template <class _Alloc>
399394 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 0>, const _Alloc&) {}
......@@ -406,10 +401,10 @@ public:
406401 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_leaf(integral_constant<int, 2>, const _Alloc& __a) : _Hp(__a) {}
407402
408403 template <class _Tp,
409 class = __enable_if_t<
410 _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value > >
411 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t)
412 _NOEXCEPT_((is_nothrow_constructible<_Hp, _Tp>::value))
404 __enable_if_t< _And< _IsNotSame<__remove_cvref_t<_Tp>, __tuple_leaf>, is_constructible<_Hp, _Tp> >::value,
405 int> = 0>
406 _LIBCPP_HIDE_FROM_ABI
407 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_leaf(_Tp&& __t) noexcept(is_nothrow_constructible<_Hp, _Tp>::value)
413408 : _Hp(std::forward<_Tp>(__t)) {}
414409
415410 template <class _Tp, class _Alloc>
......@@ -427,14 +422,14 @@ public:
427422 __tuple_leaf(__tuple_leaf const&) = default;
428423 __tuple_leaf(__tuple_leaf&&) = default;
429424
430 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(__tuple_leaf& __t)
431 _NOEXCEPT_(__is_nothrow_swappable<__tuple_leaf>::value) {
425 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
426 swap(__tuple_leaf& __t) noexcept(__is_nothrow_swappable_v<__tuple_leaf>) {
432427 std::swap(*this, __t);
433428 return 0;
434429 }
435430
436431 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int swap(const __tuple_leaf& __rhs) const
437 _NOEXCEPT_(__is_nothrow_swappable<const __tuple_leaf>::value) {
432 noexcept(__is_nothrow_swappable_v<const __tuple_leaf>) {
438433 std::swap(*this, __rhs);
439434 return 0;
440435 }
......@@ -462,14 +457,17 @@ struct __tuple_impl;
462457template <size_t... _Indx, class... _Tp>
463458struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp...>
464459 : public __tuple_leaf<_Indx, _Tp>... {
465 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl()
466 _NOEXCEPT_(__all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
460 _LIBCPP_HIDE_FROM_ABI constexpr __tuple_impl() noexcept(
461 __all<is_nothrow_default_constructible<_Tp>::value...>::value) {}
467462
468463 template <size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
469464 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit __tuple_impl(
470 __tuple_indices<_Uf...>, __tuple_types<_Tf...>, __tuple_indices<_Ul...>, __tuple_types<_Tl...>, _Up&&... __u)
471 _NOEXCEPT_((__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
472 __all<is_nothrow_default_constructible<_Tl>::value...>::value))
465 __tuple_indices<_Uf...>,
466 __tuple_types<_Tf...>,
467 __tuple_indices<_Ul...>,
468 __tuple_types<_Tl...>,
469 _Up&&... __u) noexcept(__all<is_nothrow_constructible<_Tf, _Up>::value...>::value &&
470 __all<is_nothrow_default_constructible<_Tl>::value...>::value)
473471 : __tuple_leaf<_Uf, _Tf>(std::forward<_Up>(__u))..., __tuple_leaf<_Ul, _Tl>()... {}
474472
475473 template <class _Alloc, size_t... _Uf, class... _Tf, size_t... _Ul, class... _Tl, class... _Up>
......@@ -484,8 +482,8 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
484482 : __tuple_leaf<_Uf, _Tf>(__uses_alloc_ctor<_Tf, _Alloc, _Up>(), __a, std::forward<_Up>(__u))...,
485483 __tuple_leaf<_Ul, _Tl>(__uses_alloc_ctor<_Tl, _Alloc>(), __a)... {}
486484
487 template <class _Tuple, class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> >
488 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) _NOEXCEPT_(
485 template <class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
486 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(_Tuple&& __t) noexcept(
489487 (__all<is_nothrow_constructible<
490488 _Tp,
491489 typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>::value...>::value))
......@@ -493,7 +491,7 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
493491 std::forward<typename tuple_element<_Indx, typename __make_tuple_types<_Tuple>::type>::type>(
494492 std::get<_Indx>(__t)))... {}
495493
496 template <class _Alloc, class _Tuple, class = __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value> >
494 template <class _Alloc, class _Tuple, __enable_if_t<__tuple_constructible<_Tuple, tuple<_Tp...> >::value, int> = 0>
497495 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 __tuple_impl(allocator_arg_t, const _Alloc& __a, _Tuple&& __t)
498496 : __tuple_leaf<_Indx, _Tp>(
499497 __uses_alloc_ctor<_Tp,
......@@ -506,13 +504,13 @@ struct _LIBCPP_DECLSPEC_EMPTY_BASES __tuple_impl<__tuple_indices<_Indx...>, _Tp.
506504 __tuple_impl(const __tuple_impl&) = default;
507505 __tuple_impl(__tuple_impl&&) = default;
508506
509 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(__tuple_impl& __t)
510 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {
507 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void
508 swap(__tuple_impl& __t) noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
511509 std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t))...);
512510 }
513511
514512 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void swap(const __tuple_impl& __t) const
515 _NOEXCEPT_(__all<__is_nothrow_swappable<const _Tp>::value...>::value) {
513 noexcept(__all<__is_nothrow_swappable_v<const _Tp>...>::value) {
516514 std::__swallow(__tuple_leaf<_Indx, _Tp>::swap(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t))...);
517515 }
518516};
......@@ -548,18 +546,16 @@ class _LIBCPP_TEMPLATE_VIS tuple {
548546 get(const tuple<_Up...>&&) _NOEXCEPT;
549547
550548public:
551 // [tuple.cnstr]
549 using __trivially_relocatable = __conditional_t<_And<__libcpp_is_trivially_relocatable<_Tp>...>::value, tuple, void>;
552550
553 _LIBCPP_DIAGNOSTIC_PUSH
554 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
555 _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wc++20-extensions")
551 // [tuple.cnstr]
556552
557553 // tuple() constructors (including allocator_arg_t variants)
558554 template <template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
559555 template <class...> class _IsDefault = is_default_constructible,
560556 __enable_if_t< _And< _IsDefault<_Tp>... >::value, int> = 0>
561 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value) tuple()
562 _NOEXCEPT_(_And<is_nothrow_default_constructible<_Tp>...>::value) {}
557 _LIBCPP_HIDE_FROM_ABI constexpr explicit(_Not<_Lazy<_And, _IsImpDefault<_Tp>...> >::value)
558 tuple() noexcept(_And<is_nothrow_default_constructible<_Tp>...>::value) {}
563559
564560 template <class _Alloc,
565561 template <class...> class _IsImpDefault = __is_implicitly_default_constructible,
......@@ -577,9 +573,9 @@ public:
577573 // tuple(const T&...) constructors (including allocator_arg_t variants)
578574 template <template <class...> class _And = _And,
579575 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
580 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
581 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value) tuple(const _Tp&... __t)
582 _NOEXCEPT_(_And<is_nothrow_copy_constructible<_Tp>...>::value)
576 _LIBCPP_HIDE_FROM_ABI
577 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
578 tuple(const _Tp&... __t) noexcept(_And<is_nothrow_copy_constructible<_Tp>...>::value)
583579 : __base_(typename __make_tuple_indices<sizeof...(_Tp)>::type(),
584580 typename __make_tuple_types<tuple, sizeof...(_Tp)>::type(),
585581 typename __make_tuple_indices<0>::type(),
......@@ -589,8 +585,8 @@ public:
589585 template <class _Alloc,
590586 template <class...> class _And = _And,
591587 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) >= 1>, is_copy_constructible<_Tp>... >::value, int> = 0>
592 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(
593 _Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
588 _LIBCPP_HIDE_FROM_ABI
589 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Tp&, _Tp>...> >::value)
594590 tuple(allocator_arg_t, const _Alloc& __a, const _Tp&... __t)
595591 : __base_(allocator_arg_t(),
596592 __a,
......@@ -616,7 +612,7 @@ public:
616612 __enable_if_t< _And< _BoolConstant<sizeof...(_Up) == sizeof...(_Tp)>, _EnableUTypesCtor<_Up...> >::value,
617613 int> = 0>
618614 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
619 tuple(_Up&&... __u) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
615 tuple(_Up&&... __u) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
620616 : __base_(typename __make_tuple_indices<sizeof...(_Up)>::type(),
621617 typename __make_tuple_types<tuple, sizeof...(_Up)>::type(),
622618 typename __make_tuple_indices<sizeof...(_Tp), sizeof...(_Up)>::type(),
......@@ -681,16 +677,16 @@ public:
681677 _Not<is_constructible<_Tp, _OtherTuple> >... > > > {};
682678
683679 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
684 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
685 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value) tuple(const tuple<_Up...>& __t)
686 _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, const _Up&>...>::value))
680 _LIBCPP_HIDE_FROM_ABI
681 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
682 tuple(const tuple<_Up...>& __t) noexcept(_And<is_nothrow_constructible<_Tp, const _Up&>...>::value)
687683 : __base_(__t) {}
688684
689685 template <class... _Up,
690686 class _Alloc,
691687 __enable_if_t< _And< _EnableCtorFromUTypesTuple<const tuple<_Up...>&> >::value, int> = 0>
692 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(
693 _Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
688 _LIBCPP_HIDE_FROM_ABI
689 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_Lazy<_And, is_convertible<const _Up&, _Tp>...> >::value)
694690 tuple(allocator_arg_t, const _Alloc& __a, const tuple<_Up...>& __t)
695691 : __base_(allocator_arg_t(), __a, __t) {}
696692
......@@ -710,7 +706,7 @@ public:
710706 // tuple(tuple<U...>&&) constructors (including allocator_arg_t variants)
711707 template <class... _Up, __enable_if_t< _And< _EnableCtorFromUTypesTuple<tuple<_Up...>&&> >::value, int> = 0>
712708 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_Lazy<_And, is_convertible<_Up, _Tp>...> >::value)
713 tuple(tuple<_Up...>&& __t) _NOEXCEPT_((_And<is_nothrow_constructible<_Tp, _Up>...>::value))
709 tuple(tuple<_Up...>&& __t) noexcept(_And<is_nothrow_constructible<_Tp, _Up>...>::value)
714710 : __base_(std::move(__t)) {}
715711
716712 template <class _Alloc,
......@@ -765,9 +761,9 @@ public:
765761 class _Up2,
766762 template <class...> class _And = _And,
767763 __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
768 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
769 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value) tuple(const pair<_Up1, _Up2>& __p)
770 _NOEXCEPT_((_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value))
764 _LIBCPP_HIDE_FROM_ABI
765 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
766 tuple(const pair<_Up1, _Up2>& __p) noexcept(_NothrowConstructibleFromPair<const pair<_Up1, _Up2>&>::value)
771767 : __base_(__p) {}
772768
773769 template <class _Alloc,
......@@ -775,8 +771,8 @@ public:
775771 class _Up2,
776772 template <class...> class _And = _And,
777773 __enable_if_t< _And< _EnableCtorFromPair<const pair<_Up1, _Up2>&> >::value, int> = 0>
778 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(
779 _Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
774 _LIBCPP_HIDE_FROM_ABI
775 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<const pair<_Up1, _Up2>&> >::value)
780776 tuple(allocator_arg_t, const _Alloc& __a, const pair<_Up1, _Up2>& __p)
781777 : __base_(allocator_arg_t(), __a, __p) {}
782778
......@@ -803,9 +799,9 @@ public:
803799 class _Up2,
804800 template <class...> class _And = _And,
805801 __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
806 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(
807 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value) tuple(pair<_Up1, _Up2>&& __p)
808 _NOEXCEPT_((_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value))
802 _LIBCPP_HIDE_FROM_ABI
803 _LIBCPP_CONSTEXPR_SINCE_CXX14 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
804 tuple(pair<_Up1, _Up2>&& __p) noexcept(_NothrowConstructibleFromPair<pair<_Up1, _Up2>&&>::value)
809805 : __base_(std::move(__p)) {}
810806
811807 template <class _Alloc,
......@@ -813,8 +809,8 @@ public:
813809 class _Up2,
814810 template <class...> class _And = _And,
815811 __enable_if_t< _And< _EnableCtorFromPair<pair<_Up1, _Up2>&&> >::value, int> = 0>
816 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(
817 _Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
812 _LIBCPP_HIDE_FROM_ABI
813 _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit(_Not<_BothImplicitlyConvertible<pair<_Up1, _Up2>&&> >::value)
818814 tuple(allocator_arg_t, const _Alloc& __a, pair<_Up1, _Up2>&& __p)
819815 : __base_(allocator_arg_t(), __a, std::move(__p)) {}
820816
......@@ -835,12 +831,10 @@ public:
835831 : __base_(allocator_arg_t(), __alloc, std::move(__p)) {}
836832# endif // _LIBCPP_STD_VER >= 23
837833
838 _LIBCPP_DIAGNOSTIC_POP
839
840834 // [tuple.assign]
841835 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
842836 operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple)
843 _NOEXCEPT_((_And<is_nothrow_copy_assignable<_Tp>...>::value)) {
837 noexcept(_And<is_nothrow_copy_assignable<_Tp>...>::value) {
844838 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
845839 return *this;
846840 }
......@@ -864,7 +858,7 @@ public:
864858
865859 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
866860 operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple)
867 _NOEXCEPT_((_And<is_nothrow_move_assignable<_Tp>...>::value)) {
861 noexcept(_And<is_nothrow_move_assignable<_Tp>...>::value) {
868862 std::__memberwise_forward_assign(
869863 *this, std::move(__tuple), __tuple_types<_Tp...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
870864 return *this;
......@@ -875,7 +869,7 @@ public:
875869 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up const&>... >::value,
876870 int> = 0>
877871 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple)
878 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value)) {
872 noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
879873 std::__memberwise_copy_assign(*this, __tuple, typename __make_tuple_indices<sizeof...(_Tp)>::type());
880874 return *this;
881875 }
......@@ -884,7 +878,7 @@ public:
884878 __enable_if_t< _And< _BoolConstant<sizeof...(_Tp) == sizeof...(_Up)>, is_assignable<_Tp&, _Up>... >::value,
885879 int> = 0>
886880 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple)
887 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value)) {
881 noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
888882 std::__memberwise_forward_assign(
889883 *this, std::move(__tuple), __tuple_types<_Up...>(), typename __make_tuple_indices<sizeof...(_Tp)>::type());
890884 return *this;
......@@ -949,7 +943,7 @@ public:
949943 class _Up2,
950944 __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2> const&>::value, int> = 0>
951945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2> const& __pair)
952 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value)) {
946 noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2> const&>::value) {
953947 std::get<0>(*this) = __pair.first;
954948 std::get<1>(*this) = __pair.second;
955949 return *this;
......@@ -957,7 +951,7 @@ public:
957951
958952 template <class _Up1, class _Up2, __enable_if_t< _EnableAssignFromPair<false, pair<_Up1, _Up2>&&>::value, int> = 0>
959953 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(pair<_Up1, _Up2>&& __pair)
960 _NOEXCEPT_((_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value)) {
954 noexcept(_NothrowAssignFromPair<false, pair<_Up1, _Up2>&&>::value) {
961955 std::get<0>(*this) = std::forward<_Up1>(__pair.first);
962956 std::get<1>(*this) = std::forward<_Up2>(__pair.second);
963957 return *this;
......@@ -967,9 +961,9 @@ public:
967961 template <
968962 class _Up,
969963 size_t _Np,
970 class = __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value > >
964 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0>
971965 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array)
972 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value)) {
966 noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
973967 std::__memberwise_copy_assign(*this, __array, typename __make_tuple_indices<sizeof...(_Tp)>::type());
974968 return *this;
975969 }
......@@ -978,9 +972,9 @@ public:
978972 template <class _Up,
979973 size_t _Np,
980974 class = void,
981 class = __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value > >
975 __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up>... >::value, int> = 0>
982976 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array)
983 _NOEXCEPT_((_And<is_nothrow_assignable<_Tp&, _Up>...>::value)) {
977 noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
984978 std::__memberwise_forward_assign(
985979 *this,
986980 std::move(__array),
......@@ -991,7 +985,7 @@ public:
991985
992986 // [tuple.swap]
993987 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple& __t)
994 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {
988 noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
995989 __base_.swap(__t.__base_);
996990 }
997991
......@@ -1048,9 +1042,9 @@ template <class _Alloc, class... _Tp>
10481042tuple(allocator_arg_t, _Alloc, tuple<_Tp...>) -> tuple<_Tp...>;
10491043# endif
10501044
1051template <class... _Tp, __enable_if_t<__all<__is_swappable<_Tp>::value...>::value, int> = 0>
1045template <class... _Tp, __enable_if_t<__all<__is_swappable_v<_Tp>...>::value, int> = 0>
10521046inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(tuple<_Tp...>& __t, tuple<_Tp...>& __u)
1053 _NOEXCEPT_(__all<__is_nothrow_swappable<_Tp>::value...>::value) {
1047 noexcept(__all<__is_nothrow_swappable_v<_Tp>...>::value) {
10541048 __t.swap(__u);
10551049}
10561050
......@@ -1095,40 +1089,6 @@ get(const tuple<_Tp...>&& __t) _NOEXCEPT {
10951089
10961090# if _LIBCPP_STD_VER >= 14
10971091
1098namespace __find_detail {
1099
1100static constexpr size_t __not_found = static_cast<size_t>(-1);
1101static constexpr size_t __ambiguous = __not_found - 1;
1102
1103inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx_return(size_t __curr_i, size_t __res, bool __matches) {
1104 return !__matches ? __res : (__res == __not_found ? __curr_i : __ambiguous);
1105}
1106
1107template <size_t _Nx>
1108inline _LIBCPP_HIDE_FROM_ABI constexpr size_t __find_idx(size_t __i, const bool (&__matches)[_Nx]) {
1109 return __i == _Nx
1110 ? __not_found
1111 : __find_detail::__find_idx_return(__i, __find_detail::__find_idx(__i + 1, __matches), __matches[__i]);
1112}
1113
1114template <class _T1, class... _Args>
1115struct __find_exactly_one_checked {
1116 static constexpr bool __matches[sizeof...(_Args)] = {is_same<_T1, _Args>::value...};
1117 static constexpr size_t value = __find_detail::__find_idx(0, __matches);
1118 static_assert(value != __not_found, "type not found in type list");
1119 static_assert(value != __ambiguous, "type occurs more than once in type list");
1120};
1121
1122template <class _T1>
1123struct __find_exactly_one_checked<_T1> {
1124 static_assert(!is_same<_T1, _T1>::value, "type not in empty type list");
1125};
1126
1127} // namespace __find_detail
1128
1129template <typename _T1, typename... _Args>
1130struct __find_exactly_one_t : public __find_detail::__find_exactly_one_checked<_T1, _Args...> {};
1131
11321092template <class _T1, class... _Args>
11331093inline _LIBCPP_HIDE_FROM_ABI constexpr _T1& get(tuple<_Args...>& __tup) noexcept {
11341094 return std::get<__find_exactly_one_t<_T1, _Args...>::value>(__tup);
......@@ -1158,22 +1118,6 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<_Tp&...> tie(_T
11581118 return tuple<_Tp&...>(__t...);
11591119}
11601120
1161template <class _Up>
1162struct __ignore_t {
1163 template <class _Tp>
1164 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const __ignore_t& operator=(_Tp&&) const {
1165 return *this;
1166 }
1167};
1168
1169# if _LIBCPP_STD_VER >= 17
1170inline constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1171# else
1172namespace {
1173constexpr __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>();
1174} // namespace
1175# endif
1176
11771121template <class... _Tp>
11781122inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 tuple<typename __unwrap_ref_decay<_Tp>::type...>
11791123make_tuple(_Tp&&... __t) {
......@@ -1336,14 +1280,14 @@ struct __tuple_cat_return_ref_imp;
13361280template <class... _Types, size_t... _I0, class _Tuple0>
13371281struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0> {
13381282 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
1339 typedef tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
1283 typedef tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_I0, _T0>::type>&&...> type;
13401284};
13411285
13421286template <class... _Types, size_t... _I0, class _Tuple0, class _Tuple1, class... _Tuples>
13431287struct __tuple_cat_return_ref_imp<tuple<_Types...>, __tuple_indices<_I0...>, _Tuple0, _Tuple1, _Tuples...>
13441288 : public __tuple_cat_return_ref_imp<
13451289 tuple<_Types...,
1346 __apply_cv_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
1290 __copy_cvref_t<_Tuple0, typename tuple_element<_I0, __libcpp_remove_reference_t<_Tuple0>>::type>&&...>,
13471291 typename __make_tuple_indices<tuple_size<__libcpp_remove_reference_t<_Tuple1> >::value>::type,
13481292 _Tuple1,
13491293 _Tuples...> {};
......@@ -1363,8 +1307,8 @@ template <class... _Types, size_t... _I0, size_t... _J0>
13631307struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J0...> > {
13641308 template <class _Tuple0>
13651309 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1366 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1367 operator()(tuple<_Types...> __t, _Tuple0&& __t0) {
1310 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
1311 operator()(tuple<_Types...> __t, _Tuple0&& __t0) {
13681312 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
13691313 return std::forward_as_tuple(
13701314 std::forward<_Types>(std::get<_I0>(__t))..., std::get<_J0>(std::forward<_Tuple0>(__t0))...);
......@@ -1372,12 +1316,12 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
13721316
13731317 template <class _Tuple0, class _Tuple1, class... _Tuples>
13741318 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14
1375 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1376 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {
1319 typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&, _Tuple1&&, _Tuples&&...>::type
1320 operator()(tuple<_Types...> __t, _Tuple0&& __t0, _Tuple1&& __t1, _Tuples&&... __tpls) {
13771321 (void)__t; // avoid unused parameter warning on GCC when _I0 is empty
13781322 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple0> _T0;
13791323 typedef _LIBCPP_NODEBUG __libcpp_remove_reference_t<_Tuple1> _T1;
1380 return __tuple_cat<tuple<_Types..., __apply_cv_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
1324 return __tuple_cat<tuple<_Types..., __copy_cvref_t<_Tuple0, typename tuple_element<_J0, _T0>::type>&&...>,
13811325 typename __make_tuple_indices<sizeof...(_Types) + tuple_size<_T0>::value>::type,
13821326 typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
13831327 std::forward_as_tuple(
......@@ -1398,21 +1342,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
13981342template <class... _Tp, class _Alloc>
13991343struct _LIBCPP_TEMPLATE_VIS uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
14001344
1401template <class _T1, class _T2>
1402template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
1403inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_T1, _T2>::pair(
1404 piecewise_construct_t,
1405 tuple<_Args1...>& __first_args,
1406 tuple<_Args2...>& __second_args,
1407 __tuple_indices<_I1...>,
1408 __tuple_indices<_I2...>)
1409 : first(std::forward<_Args1>(std::get<_I1>(__first_args))...),
1410 second(std::forward<_Args2>(std::get<_I2>(__second_args))...) {}
1411
14121345# if _LIBCPP_STD_VER >= 17
1413template <class _Tp>
1414inline constexpr size_t tuple_size_v = tuple_size<_Tp>::value;
1415
14161346# define _LIBCPP_NOEXCEPT_RETURN(...) \
14171347 noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
14181348
......@@ -1430,15 +1360,41 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&&
14301360 std::forward<_Tuple>(__t),
14311361 typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
14321362
1363#if _LIBCPP_STD_VER >= 20
14331364template <class _Tp, class _Tuple, size_t... _Idx>
14341365inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>)
1366 noexcept(noexcept(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...)))
1367 requires is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...> {
1368 return _Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...);
1369}
1370#else
1371template <class _Tp, class _Tuple, size_t... _Idx>
1372inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>,
1373 enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::forward<_Tuple>(__t)))...>> * = nullptr)
14351374 _LIBCPP_NOEXCEPT_RETURN(_Tp(std::get<_Idx>(std::forward<_Tuple>(__t))...))
1375#endif // _LIBCPP_STD_VER >= 20
1376
1377template <class _Tp, class _Tuple,
1378 class _Seq = typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type, class = void>
1379inline constexpr bool __can_make_from_tuple = false;
14361380
1381template <class _Tp, class _Tuple, size_t... _Idx>
1382inline constexpr bool __can_make_from_tuple<_Tp, _Tuple, __tuple_indices<_Idx...>,
1383 enable_if_t<is_constructible_v<_Tp, decltype(std::get<_Idx>(std::declval<_Tuple>()))...>>> = true;
1384
1385// Based on LWG3528(https://wg21.link/LWG3528) and http://eel.is/c++draft/description#structure.requirements-9,
1386// the standard allows to impose requirements, we constraint std::make_from_tuple to make std::make_from_tuple
1387// SFINAE friendly and also avoid worse diagnostic messages. We still keep the constraints of std::__make_from_tuple_impl
1388// so that std::__make_from_tuple_impl will have the same advantages when used alone.
1389#if _LIBCPP_STD_VER >= 20
14371390template <class _Tp, class _Tuple>
1391 requires __can_make_from_tuple<_Tp, _Tuple> // strengthen
1392#else
1393template <class _Tp, class _Tuple, class = enable_if_t<__can_make_from_tuple<_Tp, _Tuple>>> // strengthen
1394#endif // _LIBCPP_STD_VER >= 20
14381395inline _LIBCPP_HIDE_FROM_ABI constexpr _Tp make_from_tuple(_Tuple&& __t)
14391396 _LIBCPP_NOEXCEPT_RETURN(std::__make_from_tuple_impl<_Tp>(
14401397 std::forward<_Tuple>(__t), typename __make_tuple_indices<tuple_size_v<remove_reference_t<_Tuple>>>::type{}))
1441
14421398# undef _LIBCPP_NOEXCEPT_RETURN
14431399
14441400# endif // _LIBCPP_STD_VER >= 17
lib/libcxx/include/type_traits+29-52
......@@ -416,9 +416,9 @@ namespace std
416416}
417417
418418*/
419#include <__assert> // all public C++ headers provide the assertion handler
419
420420#include <__config>
421#include <__fwd/hash.h> // This is https://llvm.org/PR56938
421#include <__fwd/functional.h> // This is https://llvm.org/PR56938
422422#include <__type_traits/add_const.h>
423423#include <__type_traits/add_cv.h>
424424#include <__type_traits/add_lvalue_reference.h>
......@@ -428,115 +428,92 @@ namespace std
428428#include <__type_traits/aligned_storage.h>
429429#include <__type_traits/aligned_union.h>
430430#include <__type_traits/alignment_of.h>
431#include <__type_traits/apply_cv.h>
432#include <__type_traits/can_extract_key.h>
433#include <__type_traits/common_reference.h>
434431#include <__type_traits/common_type.h>
435432#include <__type_traits/conditional.h>
436#include <__type_traits/conjunction.h>
437433#include <__type_traits/decay.h>
438#include <__type_traits/dependent_type.h>
439#include <__type_traits/disjunction.h>
440434#include <__type_traits/enable_if.h>
441435#include <__type_traits/extent.h>
442#include <__type_traits/has_unique_object_representation.h>
443436#include <__type_traits/has_virtual_destructor.h>
444437#include <__type_traits/integral_constant.h>
445#include <__type_traits/invoke.h>
446438#include <__type_traits/is_abstract.h>
447#include <__type_traits/is_aggregate.h>
448439#include <__type_traits/is_arithmetic.h>
449440#include <__type_traits/is_array.h>
450441#include <__type_traits/is_assignable.h>
451442#include <__type_traits/is_base_of.h>
452#include <__type_traits/is_bounded_array.h>
453#include <__type_traits/is_callable.h>
454#include <__type_traits/is_char_like_type.h>
455443#include <__type_traits/is_class.h>
456444#include <__type_traits/is_compound.h>
457445#include <__type_traits/is_const.h>
458#include <__type_traits/is_constant_evaluated.h>
459446#include <__type_traits/is_constructible.h>
460447#include <__type_traits/is_convertible.h>
461#include <__type_traits/is_copy_assignable.h>
462#include <__type_traits/is_copy_constructible.h>
463#include <__type_traits/is_default_constructible.h>
464448#include <__type_traits/is_destructible.h>
465449#include <__type_traits/is_empty.h>
466450#include <__type_traits/is_enum.h>
467#include <__type_traits/is_final.h>
468451#include <__type_traits/is_floating_point.h>
469452#include <__type_traits/is_function.h>
470453#include <__type_traits/is_fundamental.h>
471#include <__type_traits/is_implicitly_default_constructible.h>
472454#include <__type_traits/is_integral.h>
473455#include <__type_traits/is_literal_type.h>
474#include <__type_traits/is_member_function_pointer.h>
475#include <__type_traits/is_member_object_pointer.h>
476456#include <__type_traits/is_member_pointer.h>
477#include <__type_traits/is_move_assignable.h>
478#include <__type_traits/is_move_constructible.h>
479457#include <__type_traits/is_nothrow_assignable.h>
480458#include <__type_traits/is_nothrow_constructible.h>
481#include <__type_traits/is_nothrow_convertible.h>
482#include <__type_traits/is_nothrow_copy_assignable.h>
483#include <__type_traits/is_nothrow_copy_constructible.h>
484#include <__type_traits/is_nothrow_default_constructible.h>
485459#include <__type_traits/is_nothrow_destructible.h>
486#include <__type_traits/is_nothrow_move_assignable.h>
487#include <__type_traits/is_nothrow_move_constructible.h>
488#include <__type_traits/is_null_pointer.h>
489460#include <__type_traits/is_object.h>
490461#include <__type_traits/is_pod.h>
491462#include <__type_traits/is_pointer.h>
492463#include <__type_traits/is_polymorphic.h>
493464#include <__type_traits/is_reference.h>
494#include <__type_traits/is_reference_wrapper.h>
495#include <__type_traits/is_referenceable.h>
496465#include <__type_traits/is_same.h>
497466#include <__type_traits/is_scalar.h>
498#include <__type_traits/is_scoped_enum.h>
499467#include <__type_traits/is_signed.h>
500#include <__type_traits/is_specialization.h>
501468#include <__type_traits/is_standard_layout.h>
502#include <__type_traits/is_swappable.h>
503469#include <__type_traits/is_trivial.h>
504470#include <__type_traits/is_trivially_assignable.h>
505471#include <__type_traits/is_trivially_constructible.h>
506#include <__type_traits/is_trivially_copy_assignable.h>
507#include <__type_traits/is_trivially_copy_constructible.h>
508472#include <__type_traits/is_trivially_copyable.h>
509#include <__type_traits/is_trivially_default_constructible.h>
510473#include <__type_traits/is_trivially_destructible.h>
511#include <__type_traits/is_trivially_move_assignable.h>
512#include <__type_traits/is_trivially_move_constructible.h>
513#include <__type_traits/is_unbounded_array.h>
514474#include <__type_traits/is_union.h>
515475#include <__type_traits/is_unsigned.h>
516476#include <__type_traits/is_void.h>
517477#include <__type_traits/is_volatile.h>
518#include <__type_traits/make_const_lvalue_ref.h>
519478#include <__type_traits/make_signed.h>
520479#include <__type_traits/make_unsigned.h>
521#include <__type_traits/maybe_const.h>
522#include <__type_traits/negation.h>
523480#include <__type_traits/rank.h>
524481#include <__type_traits/remove_all_extents.h>
525482#include <__type_traits/remove_const.h>
526#include <__type_traits/remove_const_ref.h>
527483#include <__type_traits/remove_cv.h>
528484#include <__type_traits/remove_extent.h>
529485#include <__type_traits/remove_pointer.h>
530486#include <__type_traits/remove_reference.h>
531487#include <__type_traits/remove_volatile.h>
532488#include <__type_traits/result_of.h>
533#include <__type_traits/type_identity.h>
534489#include <__type_traits/underlying_type.h>
535#include <__type_traits/unwrap_ref.h>
536#include <__type_traits/void_t.h>
537#include <__utility/declval.h>
538#include <cstddef>
539#include <cstdint>
490
491#if _LIBCPP_STD_VER >= 14
492# include <__type_traits/is_final.h>
493# include <__type_traits/is_null_pointer.h>
494#endif
495
496#if _LIBCPP_STD_VER >= 17
497# include <__type_traits/conjunction.h>
498# include <__type_traits/disjunction.h>
499# include <__type_traits/has_unique_object_representation.h>
500# include <__type_traits/invoke.h>
501# include <__type_traits/is_aggregate.h>
502# include <__type_traits/is_swappable.h>
503# include <__type_traits/negation.h>
504# include <__type_traits/void_t.h>
505#endif
506
507#if _LIBCPP_STD_VER >= 20
508# include <__type_traits/common_reference.h>
509# include <__type_traits/is_bounded_array.h>
510# include <__type_traits/is_constant_evaluated.h>
511# include <__type_traits/is_nothrow_convertible.h>
512# include <__type_traits/is_unbounded_array.h>
513# include <__type_traits/type_identity.h>
514# include <__type_traits/unwrap_ref.h>
515#endif
516
540517#include <version>
541518
542519#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
lib/libcxx/include/typeindex-1
......@@ -45,7 +45,6 @@ struct hash<type_index>
4545
4646*/
4747
48#include <__assert> // all public C++ headers provide the assertion handler
4948#include <__config>
5049#include <__functional/unary_function.h>
5150#include <typeinfo>
lib/libcxx/include/typeinfo+14-3
......@@ -56,8 +56,6 @@ public:
5656
5757*/
5858
59#include <__assert> // all public C++ headers provide the assertion handler
60#include <__availability>
6159#include <__config>
6260#include <__exception/exception.h>
6361#include <__type_traits/is_constant_evaluated.h>
......@@ -277,7 +275,20 @@ struct __type_info_implementations {
277275 __impl;
278276};
279277
280class _LIBCPP_EXPORTED_FROM_ABI type_info {
278# if __has_cpp_attribute(_Clang::__ptrauth_vtable_pointer__)
279# if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)
280# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \
281 [[_Clang::__ptrauth_vtable_pointer__(process_independent, address_discrimination, type_discrimination)]]
282# else
283# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH \
284 [[_Clang::__ptrauth_vtable_pointer__( \
285 process_independent, no_address_discrimination, no_extra_discrimination)]]
286# endif
287# else
288# define _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH
289# endif
290
291class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info {
281292 type_info& operator=(const type_info&);
282293 type_info(const type_info&);
283294
lib/libcxx/include/unordered_map+42-62
......@@ -584,8 +584,7 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
584584*/
585585
586586#include <__algorithm/is_permutation.h>
587#include <__assert> // all public C++ headers provide the assertion handler
588#include <__availability>
587#include <__assert>
589588#include <__config>
590589#include <__functional/is_transparent.h>
591590#include <__functional/operations.h>
......@@ -651,7 +650,7 @@ public:
651650 return static_cast<const _Hash&>(*this)(__x);
652651 }
653652#endif
654 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) {
653 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {
655654 using std::swap;
656655 swap(static_cast<_Hash&>(*this), static_cast<_Hash&>(__y));
657656 }
......@@ -675,7 +674,7 @@ public:
675674 return __hash_(__x);
676675 }
677676#endif
678 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable<_Hash>::value) {
677 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_hasher& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Hash>) {
679678 using std::swap;
680679 swap(__hash_, __y.__hash_);
681680 }
......@@ -726,7 +725,7 @@ public:
726725 return static_cast<const _Pred&>(*this)(__x, __y);
727726 }
728727#endif
729 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) {
728 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {
730729 using std::swap;
731730 swap(static_cast<_Pred&>(*this), static_cast<_Pred&>(__y));
732731 }
......@@ -769,7 +768,7 @@ public:
769768 return __pred_(__x, __y);
770769 }
771770#endif
772 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable<_Pred>::value) {
771 _LIBCPP_HIDE_FROM_ABI void swap(__unordered_map_equal& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Pred>) {
773772 using std::swap;
774773 swap(__pred_, __y.__pred_);
775774 }
......@@ -793,12 +792,12 @@ public:
793792private:
794793 allocator_type& __na_;
795794
796 __hash_map_node_destructor& operator=(const __hash_map_node_destructor&);
797
798795public:
799796 bool __first_constructed;
800797 bool __second_constructed;
801798
799 __hash_map_node_destructor& operator=(const __hash_map_node_destructor&) = delete;
800
802801 _LIBCPP_HIDE_FROM_ABI explicit __hash_map_node_destructor(allocator_type& __na) _NOEXCEPT
803802 : __na_(__na),
804803 __first_constructed(false),
......@@ -877,13 +876,12 @@ public:
877876 return *this;
878877 }
879878
880 template <class _ValueTp, class = __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value> >
879 template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>
881880 _LIBCPP_HIDE_FROM_ABI __hash_value_type& operator=(_ValueTp&& __v) {
882881 __ref() = std::forward<_ValueTp>(__v);
883882 return *this;
884883 }
885884
886private:
887885 __hash_value_type(const __hash_value_type& __v) = delete;
888886 __hash_value_type(__hash_value_type&& __v) = delete;
889887 template <class... _Args>
......@@ -907,8 +905,7 @@ public:
907905 _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; }
908906 _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; }
909907
910private:
911 ~__hash_value_type();
908 ~__hash_value_type() = delete;
912909};
913910
914911#endif
......@@ -1037,7 +1034,7 @@ public:
10371034 typedef pair<const key_type, mapped_type> value_type;
10381035 typedef value_type& reference;
10391036 typedef const value_type& const_reference;
1040 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1037 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
10411038 "Allocator::value_type must be same type as value_type");
10421039
10431040private:
......@@ -1060,12 +1057,10 @@ private:
10601057 typedef unique_ptr<__node, _Dp> __node_holder;
10611058 typedef allocator_traits<allocator_type> __alloc_traits;
10621059
1063 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1064 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1065 "original allocator");
1060 static_assert(__check_valid_allocator<allocator_type>::value, "");
10661061
1067 static_assert((is_same<typename __table::__container_value_type, value_type>::value), "");
1068 static_assert((is_same<typename __table::__node_value_type, __value_type>::value), "");
1062 static_assert(is_same<typename __table::__container_value_type, value_type>::value, "");
1063 static_assert(is_same<typename __table::__node_value_type, __value_type>::value, "");
10691064
10701065public:
10711066 typedef typename __alloc_traits::pointer pointer;
......@@ -1207,7 +1202,7 @@ public:
12071202 return allocator_type(__table_.__node_alloc());
12081203 }
12091204
1210 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1205 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
12111206 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
12121207 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
12131208
......@@ -1245,12 +1240,12 @@ public:
12451240 return __table_.__insert_unique(std::move(__x)).first;
12461241 }
12471242
1248 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1243 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
12491244 _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(_Pp&& __x) {
12501245 return __table_.__insert_unique(std::forward<_Pp>(__x));
12511246 }
12521247
1253 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
1248 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
12541249 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator, _Pp&& __x) {
12551250 return insert(std::forward<_Pp>(__x)).first;
12561251 }
......@@ -1374,7 +1369,7 @@ public:
13741369 }
13751370#endif
13761371
1377 _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
1372 _LIBCPP_HIDE_FROM_ABI void swap(unordered_map& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
13781373 __table_.swap(__u.__table_);
13791374 }
13801375
......@@ -1384,13 +1379,11 @@ public:
13841379 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
13851380 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
13861381#if _LIBCPP_STD_VER >= 20
1387 template <class _K2,
1388 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1382 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
13891383 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
13901384 return __table_.find(__k);
13911385 }
1392 template <class _K2,
1393 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1386 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
13941387 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
13951388 return __table_.find(__k);
13961389 }
......@@ -1398,8 +1391,7 @@ public:
13981391
13991392 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
14001393#if _LIBCPP_STD_VER >= 20
1401 template <class _K2,
1402 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1394 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14031395 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
14041396 return __table_.__count_unique(__k);
14051397 }
......@@ -1408,8 +1400,7 @@ public:
14081400#if _LIBCPP_STD_VER >= 20
14091401 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
14101402
1411 template <class _K2,
1412 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1403 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14131404 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
14141405 return find(__k) != end();
14151406 }
......@@ -1422,13 +1413,11 @@ public:
14221413 return __table_.__equal_range_unique(__k);
14231414 }
14241415#if _LIBCPP_STD_VER >= 20
1425 template <class _K2,
1426 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1416 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14271417 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
14281418 return __table_.__equal_range_unique(__k);
14291419 }
1430 template <class _K2,
1431 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1420 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14321421 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
14331422 return __table_.__equal_range_unique(__k);
14341423 }
......@@ -1848,7 +1837,8 @@ public:
18481837 typedef pair<const key_type, mapped_type> value_type;
18491838 typedef value_type& reference;
18501839 typedef const value_type& const_reference;
1851 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1840 static_assert(__check_valid_allocator<allocator_type>::value, "");
1841 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
18521842 "Allocator::value_type must be same type as value_type");
18531843
18541844private:
......@@ -1868,13 +1858,9 @@ private:
18681858 typedef __hash_map_node_destructor<__node_allocator> _Dp;
18691859 typedef unique_ptr<__node, _Dp> __node_holder;
18701860 typedef allocator_traits<allocator_type> __alloc_traits;
1871 static_assert((is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value),
1861 static_assert(is_same<typename __node_traits::size_type, typename __alloc_traits::size_type>::value,
18721862 "Allocator uses different size_type for different types");
18731863
1874 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
1875 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
1876 "original allocator");
1877
18781864public:
18791865 typedef typename __alloc_traits::pointer pointer;
18801866 typedef typename __alloc_traits::const_pointer const_pointer;
......@@ -2015,7 +2001,7 @@ public:
20152001 return allocator_type(__table_.__node_alloc());
20162002 }
20172003
2018 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
2004 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
20192005 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
20202006 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
20212007
......@@ -2052,12 +2038,12 @@ public:
20522038 return __table_.__insert_multi(__p.__i_, std::move(__x));
20532039 }
20542040
2055 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2041 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
20562042 _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __x) {
20572043 return __table_.__insert_multi(std::forward<_Pp>(__x));
20582044 }
20592045
2060 template <class _Pp, class = __enable_if_t<is_constructible<value_type, _Pp>::value> >
2046 template <class _Pp, __enable_if_t<is_constructible<value_type, _Pp>::value, int> = 0>
20612047 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _Pp&& __x) {
20622048 return __table_.__insert_multi(__p.__i_, std::forward<_Pp>(__x));
20632049 }
......@@ -2125,7 +2111,7 @@ public:
21252111 }
21262112#endif
21272113
2128 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
2114 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multimap& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
21292115 __table_.swap(__u.__table_);
21302116 }
21312117
......@@ -2135,13 +2121,11 @@ public:
21352121 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
21362122 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
21372123#if _LIBCPP_STD_VER >= 20
2138 template <class _K2,
2139 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2124 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21402125 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
21412126 return __table_.find(__k);
21422127 }
2143 template <class _K2,
2144 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2128 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21452129 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
21462130 return __table_.find(__k);
21472131 }
......@@ -2149,8 +2133,7 @@ public:
21492133
21502134 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
21512135#if _LIBCPP_STD_VER >= 20
2152 template <class _K2,
2153 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2136 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21542137 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
21552138 return __table_.__count_multi(__k);
21562139 }
......@@ -2159,8 +2142,7 @@ public:
21592142#if _LIBCPP_STD_VER >= 20
21602143 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
21612144
2162 template <class _K2,
2163 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2145 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21642146 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
21652147 return find(__k) != end();
21662148 }
......@@ -2173,13 +2155,11 @@ public:
21732155 return __table_.__equal_range_multi(__k);
21742156 }
21752157#if _LIBCPP_STD_VER >= 20
2176 template <class _K2,
2177 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2158 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21782159 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
21792160 return __table_.__equal_range_multi(__k);
21802161 }
2181 template <class _K2,
2182 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
2162 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
21832163 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
21842164 return __table_.__equal_range_multi(__k);
21852165 }
......@@ -2254,12 +2234,12 @@ template <class _Key,
22542234 class = enable_if_t<!is_integral<_Hash>::value>,
22552235 class = enable_if_t<!__is_allocator<_Pred>::value>,
22562236 class = enable_if_t<__is_allocator<_Allocator>::value>>
2257unordered_multimap(initializer_list<pair<_Key, _Tp>>,
2258 typename allocator_traits<_Allocator>::size_type = 0,
2259 _Hash = _Hash(),
2260 _Pred = _Pred(),
2261 _Allocator = _Allocator())
2262 -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
2237unordered_multimap(
2238 initializer_list<pair<_Key, _Tp>>,
2239 typename allocator_traits<_Allocator>::size_type = 0,
2240 _Hash = _Hash(),
2241 _Pred = _Pred(),
2242 _Allocator = _Allocator()) -> unordered_multimap<remove_const_t<_Key>, _Tp, _Hash, _Pred, _Allocator>;
22632243
22642244template <class _InputIterator,
22652245 class _Allocator,
lib/libcxx/include/unordered_set+27-43
......@@ -532,8 +532,7 @@ template <class Value, class Hash, class Pred, class Alloc>
532532// clang-format on
533533
534534#include <__algorithm/is_permutation.h>
535#include <__assert> // all public C++ headers provide the assertion handler
536#include <__availability>
535#include <__assert>
537536#include <__config>
538537#include <__functional/is_transparent.h>
539538#include <__functional/operations.h>
......@@ -589,13 +588,10 @@ public:
589588 typedef __type_identity_t<_Alloc> allocator_type;
590589 typedef value_type& reference;
591590 typedef const value_type& const_reference;
592 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
591 static_assert(__check_valid_allocator<allocator_type>::value, "");
592 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
593593 "Allocator::value_type must be same type as value_type");
594594
595 static_assert(is_same<allocator_type, __rebind_alloc<allocator_traits<allocator_type>, value_type> >::value,
596 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
597 "original allocator");
598
599595private:
600596 typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
601597
......@@ -735,7 +731,7 @@ public:
735731 return allocator_type(__table_.__node_alloc());
736732 }
737733
738 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
734 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
739735 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
740736 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
741737
......@@ -829,7 +825,7 @@ public:
829825 }
830826#endif
831827
832 _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
828 _LIBCPP_HIDE_FROM_ABI void swap(unordered_set& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
833829 __table_.swap(__u.__table_);
834830 }
835831
......@@ -839,13 +835,11 @@ public:
839835 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
840836 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
841837#if _LIBCPP_STD_VER >= 20
842 template <class _K2,
843 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
838 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
844839 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
845840 return __table_.find(__k);
846841 }
847 template <class _K2,
848 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
842 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
849843 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
850844 return __table_.find(__k);
851845 }
......@@ -853,8 +847,7 @@ public:
853847
854848 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_unique(__k); }
855849#if _LIBCPP_STD_VER >= 20
856 template <class _K2,
857 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
850 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
858851 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
859852 return __table_.__count_unique(__k);
860853 }
......@@ -863,8 +856,7 @@ public:
863856#if _LIBCPP_STD_VER >= 20
864857 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
865858
866 template <class _K2,
867 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
859 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
868860 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
869861 return find(__k) != end();
870862 }
......@@ -877,13 +869,11 @@ public:
877869 return __table_.__equal_range_unique(__k);
878870 }
879871#if _LIBCPP_STD_VER >= 20
880 template <class _K2,
881 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
872 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
882873 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
883874 return __table_.__equal_range_unique(__k);
884875 }
885 template <class _K2,
886 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
876 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
887877 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
888878 return __table_.__equal_range_unique(__k);
889879 }
......@@ -935,13 +925,13 @@ template <ranges::input_range _Range,
935925 class = enable_if_t<!is_integral<_Hash>::value>,
936926 class = enable_if_t<!__is_allocator<_Pred>::value>,
937927 class = enable_if_t<__is_allocator<_Allocator>::value>>
938unordered_set(from_range_t,
939 _Range&&,
940 typename allocator_traits<_Allocator>::size_type = 0,
941 _Hash = _Hash(),
942 _Pred = _Pred(),
943 _Allocator = _Allocator())
944 -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
928unordered_set(
929 from_range_t,
930 _Range&&,
931 typename allocator_traits<_Allocator>::size_type = 0,
932 _Hash = _Hash(),
933 _Pred = _Pred(),
934 _Allocator = _Allocator()) -> unordered_set<ranges::range_value_t<_Range>, _Hash, _Pred, _Allocator>; // C++23
945935# endif
946936
947937template <class _Tp,
......@@ -1193,7 +1183,7 @@ public:
11931183 typedef __type_identity_t<_Alloc> allocator_type;
11941184 typedef value_type& reference;
11951185 typedef const value_type& const_reference;
1196 static_assert((is_same<value_type, typename allocator_type::value_type>::value),
1186 static_assert(is_same<value_type, typename allocator_type::value_type>::value,
11971187 "Allocator::value_type must be same type as value_type");
11981188
11991189private:
......@@ -1335,7 +1325,7 @@ public:
13351325 return allocator_type(__table_.__node_alloc());
13361326 }
13371327
1338 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
1328 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __table_.size() == 0; }
13391329 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __table_.size(); }
13401330 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __table_.max_size(); }
13411331
......@@ -1432,7 +1422,7 @@ public:
14321422 }
14331423 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __table_.clear(); }
14341424
1435 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable<__table>::value) {
1425 _LIBCPP_HIDE_FROM_ABI void swap(unordered_multiset& __u) _NOEXCEPT_(__is_nothrow_swappable_v<__table>) {
14361426 __table_.swap(__u.__table_);
14371427 }
14381428
......@@ -1442,13 +1432,11 @@ public:
14421432 _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __table_.find(__k); }
14431433 _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __table_.find(__k); }
14441434#if _LIBCPP_STD_VER >= 20
1445 template <class _K2,
1446 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1435 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14471436 _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
14481437 return __table_.find(__k);
14491438 }
1450 template <class _K2,
1451 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1439 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14521440 _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
14531441 return __table_.find(__k);
14541442 }
......@@ -1456,8 +1444,7 @@ public:
14561444
14571445 _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __table_.__count_multi(__k); }
14581446#if _LIBCPP_STD_VER >= 20
1459 template <class _K2,
1460 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1447 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14611448 _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
14621449 return __table_.__count_multi(__k);
14631450 }
......@@ -1466,8 +1453,7 @@ public:
14661453#if _LIBCPP_STD_VER >= 20
14671454 _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
14681455
1469 template <class _K2,
1470 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1456 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14711457 _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
14721458 return find(__k) != end();
14731459 }
......@@ -1480,13 +1466,11 @@ public:
14801466 return __table_.__equal_range_multi(__k);
14811467 }
14821468#if _LIBCPP_STD_VER >= 20
1483 template <class _K2,
1484 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1469 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14851470 _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
14861471 return __table_.__equal_range_multi(__k);
14871472 }
1488 template <class _K2,
1489 enable_if_t<__is_transparent<hasher, _K2>::value && __is_transparent<key_equal, _K2>::value>* = nullptr>
1473 template <class _K2, enable_if_t<__is_transparent_v<hasher, _K2> && __is_transparent_v<key_equal, _K2>>* = nullptr>
14901474 _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
14911475 return __table_.__equal_range_multi(__k);
14921476 }
lib/libcxx/include/utility+30-13
......@@ -246,27 +246,36 @@ template <class T>
246246
247247*/
248248
249#include <__assert> // all public C++ headers provide the assertion handler
250249#include <__config>
251#include <__utility/as_const.h>
252#include <__utility/as_lvalue.h>
253#include <__utility/auto_cast.h>
254#include <__utility/cmp.h>
250
255251#include <__utility/declval.h>
256#include <__utility/exception_guard.h>
257#include <__utility/exchange.h>
258252#include <__utility/forward.h>
259#include <__utility/forward_like.h>
260#include <__utility/in_place.h>
261#include <__utility/integer_sequence.h>
262253#include <__utility/move.h>
263254#include <__utility/pair.h>
264255#include <__utility/piecewise_construct.h>
265#include <__utility/priority_tag.h>
266256#include <__utility/rel_ops.h>
267257#include <__utility/swap.h>
268#include <__utility/to_underlying.h>
269#include <__utility/unreachable.h>
258
259#if _LIBCPP_STD_VER >= 14
260# include <__utility/exchange.h>
261# include <__utility/integer_sequence.h>
262#endif
263
264#if _LIBCPP_STD_VER >= 17
265# include <__utility/as_const.h>
266# include <__utility/in_place.h>
267#endif
268
269#if _LIBCPP_STD_VER >= 20
270# include <__utility/cmp.h>
271#endif
272
273#if _LIBCPP_STD_VER >= 23
274# include <__utility/forward_like.h>
275# include <__utility/to_underlying.h>
276# include <__utility/unreachable.h>
277#endif
278
270279#include <version>
271280
272281// standard-mandated includes
......@@ -275,6 +284,10 @@ template <class T>
275284#include <compare>
276285#include <initializer_list>
277286
287// [tuple.creation]
288
289#include <__tuple/ignore.h>
290
278291// [tuple.helper]
279292#include <__tuple/tuple_element.h>
280293#include <__tuple/tuple_size.h>
......@@ -283,6 +296,10 @@ template <class T>
283296# pragma GCC system_header
284297#endif
285298
299#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
300# include <limits>
301#endif
302
286303#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
287304# include <cstdlib>
288305# include <iosfwd>
lib/libcxx/include/valarray+169-89
......@@ -350,7 +350,7 @@ template <class T> unspecified2 end(const valarray<T>& v);
350350#include <__algorithm/min.h>
351351#include <__algorithm/min_element.h>
352352#include <__algorithm/unwrap_iter.h>
353#include <__assert> // all public C++ headers provide the assertion handler
353#include <__assert>
354354#include <__config>
355355#include <__functional/operations.h>
356356#include <__memory/addressof.h>
......@@ -733,6 +733,50 @@ struct __is_val_expr<__val_expr<_ValExpr> > : true_type {};
733733template <class _Tp>
734734struct __is_val_expr<valarray<_Tp> > : true_type {};
735735
736template <class _Tp>
737struct __is_val_expr<slice_array<_Tp> > : true_type {};
738
739template <class _Tp>
740struct __is_val_expr<gslice_array<_Tp> > : true_type {};
741
742template <class _Tp>
743struct __is_val_expr<mask_array<_Tp> > : true_type {};
744
745template <class _Tp>
746struct __is_val_expr<indirect_array<_Tp> > : true_type {};
747
748// The functions using a __val_expr access the elements by their index.
749// valarray and the libc++ lazy proxies have an operator[]. The
750// Standard proxy array's don't have this operator, instead they have a
751// implementation specific accessor
752// __get(size_t)
753//
754// The functions use the non-member function
755// __get(__val_expr, size_t)
756//
757// If the __val_expr is a specialization of __val_expr_use_member_functions it
758// uses the __val_expr's member function
759// __get(size_t)
760// else it uses the __val_expr's member function
761// operator[](size_t)
762template <class _ValExpr>
763struct __val_expr_use_member_functions;
764
765template <class>
766struct __val_expr_use_member_functions : false_type {};
767
768template <class _Tp>
769struct __val_expr_use_member_functions<slice_array<_Tp> > : true_type {};
770
771template <class _Tp>
772struct __val_expr_use_member_functions<gslice_array<_Tp> > : true_type {};
773
774template <class _Tp>
775struct __val_expr_use_member_functions<mask_array<_Tp> > : true_type {};
776
777template <class _Tp>
778struct __val_expr_use_member_functions<indirect_array<_Tp> > : true_type {};
779
736780template <class _Tp>
737781class _LIBCPP_TEMPLATE_VIS valarray {
738782public:
......@@ -903,6 +947,18 @@ template <class _Tp, size_t _Size>
903947valarray(const _Tp (&)[_Size], size_t) -> valarray<_Tp>;
904948#endif
905949
950template <class _Expr,
951 __enable_if_t<__is_val_expr<_Expr>::value && __val_expr_use_member_functions<_Expr>::value, int> = 0>
952_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
953 return __v.__get(__i);
954}
955
956template <class _Expr,
957 __enable_if_t<__is_val_expr<_Expr>::value && !__val_expr_use_member_functions<_Expr>::value, int> = 0>
958_LIBCPP_HIDE_FROM_ABI typename _Expr::value_type __get(const _Expr& __v, size_t __i) {
959 return __v[__i];
960}
961
906962extern template _LIBCPP_EXPORTED_FROM_ABI void valarray<size_t>::resize(size_t, size_t);
907963
908964template <class _Op, class _Tp>
......@@ -1025,6 +1081,12 @@ public:
10251081
10261082 _LIBCPP_HIDE_FROM_ABI void operator=(const valarray<value_type>& __va) const;
10271083
1084 // Behaves like __val_expr::operator[], which returns by value.
1085 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1086 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __size_, "slice_array.__get() index out of bounds");
1087 return __vp_[__i * __stride_];
1088 }
1089
10281090private:
10291091 _LIBCPP_HIDE_FROM_ABI slice_array(const slice& __sl, const valarray<value_type>& __v)
10301092 : __vp_(const_cast<value_type*>(__v.__begin_ + __sl.start())), __size_(__sl.size()), __stride_(__sl.stride()) {}
......@@ -1246,6 +1308,12 @@ public:
12461308
12471309 gslice_array(const gslice_array&) = default;
12481310
1311 // Behaves like __val_expr::operator[], which returns by value.
1312 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1313 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "gslice_array.__get() index out of bounds");
1314 return __vp_[__1d_[__i]];
1315 }
1316
12491317private:
12501318 gslice_array(const gslice& __gs, const valarray<value_type>& __v)
12511319 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__gs.__1d_) {}
......@@ -1425,6 +1493,12 @@ public:
14251493
14261494 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
14271495
1496 // Behaves like __val_expr::operator[], which returns by value.
1497 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1498 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "mask_array.__get() index out of bounds");
1499 return __vp_[__1d_[__i]];
1500 }
1501
14281502private:
14291503 _LIBCPP_HIDE_FROM_ABI mask_array(const valarray<bool>& __vb, const valarray<value_type>& __v)
14301504 : __vp_(const_cast<value_type*>(__v.__begin_)),
......@@ -1624,6 +1698,12 @@ public:
16241698
16251699 _LIBCPP_HIDE_FROM_ABI void operator=(const value_type& __x) const;
16261700
1701 // Behaves like __val_expr::operator[], which returns by value.
1702 _LIBCPP_HIDE_FROM_ABI value_type __get(size_t __i) const {
1703 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__i < __1d_.size(), "indirect_array.__get() index out of bounds");
1704 return __vp_[__1d_[__i]];
1705 }
1706
16271707private:
16281708 _LIBCPP_HIDE_FROM_ABI indirect_array(const valarray<size_t>& __ia, const valarray<value_type>& __v)
16291709 : __vp_(const_cast<value_type*>(__v.__begin_)), __1d_(__ia) {}
......@@ -2355,7 +2435,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
23552435inline valarray<_Tp>& valarray<_Tp>::operator*=(const _Expr& __v) {
23562436 size_t __i = 0;
23572437 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2358 *__t *= __v[__i];
2438 *__t *= std::__get(__v, __i);
23592439 return *this;
23602440}
23612441
......@@ -2364,7 +2444,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
23642444inline valarray<_Tp>& valarray<_Tp>::operator/=(const _Expr& __v) {
23652445 size_t __i = 0;
23662446 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2367 *__t /= __v[__i];
2447 *__t /= std::__get(__v, __i);
23682448 return *this;
23692449}
23702450
......@@ -2373,7 +2453,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
23732453inline valarray<_Tp>& valarray<_Tp>::operator%=(const _Expr& __v) {
23742454 size_t __i = 0;
23752455 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2376 *__t %= __v[__i];
2456 *__t %= std::__get(__v, __i);
23772457 return *this;
23782458}
23792459
......@@ -2382,7 +2462,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
23822462inline valarray<_Tp>& valarray<_Tp>::operator+=(const _Expr& __v) {
23832463 size_t __i = 0;
23842464 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2385 *__t += __v[__i];
2465 *__t += std::__get(__v, __i);
23862466 return *this;
23872467}
23882468
......@@ -2391,7 +2471,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
23912471inline valarray<_Tp>& valarray<_Tp>::operator-=(const _Expr& __v) {
23922472 size_t __i = 0;
23932473 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2394 *__t -= __v[__i];
2474 *__t -= std::__get(__v, __i);
23952475 return *this;
23962476}
23972477
......@@ -2400,7 +2480,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
24002480inline valarray<_Tp>& valarray<_Tp>::operator^=(const _Expr& __v) {
24012481 size_t __i = 0;
24022482 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2403 *__t ^= __v[__i];
2483 *__t ^= std::__get(__v, __i);
24042484 return *this;
24052485}
24062486
......@@ -2409,7 +2489,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
24092489inline valarray<_Tp>& valarray<_Tp>::operator|=(const _Expr& __v) {
24102490 size_t __i = 0;
24112491 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2412 *__t |= __v[__i];
2492 *__t |= std::__get(__v, __i);
24132493 return *this;
24142494}
24152495
......@@ -2418,7 +2498,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
24182498inline valarray<_Tp>& valarray<_Tp>::operator&=(const _Expr& __v) {
24192499 size_t __i = 0;
24202500 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2421 *__t &= __v[__i];
2501 *__t &= std::__get(__v, __i);
24222502 return *this;
24232503}
24242504
......@@ -2427,7 +2507,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
24272507inline valarray<_Tp>& valarray<_Tp>::operator<<=(const _Expr& __v) {
24282508 size_t __i = 0;
24292509 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2430 *__t <<= __v[__i];
2510 *__t <<= std::__get(__v, __i);
24312511 return *this;
24322512}
24332513
......@@ -2436,7 +2516,7 @@ template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> >
24362516inline valarray<_Tp>& valarray<_Tp>::operator>>=(const _Expr& __v) {
24372517 size_t __i = 0;
24382518 for (value_type* __t = __begin_; __t != __end_; ++__t, ++__i)
2439 *__t >>= __v[__i];
2519 *__t >>= std::__get(__v, __i);
24402520 return *this;
24412521}
24422522
......@@ -2587,8 +2667,8 @@ operator*(const _Expr1& __x, const _Expr2& __y) {
25872667
25882668template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
25892669inline _LIBCPP_HIDE_FROM_ABI
2590 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2591 operator*(const _Expr& __x, const typename _Expr::value_type& __y) {
2670__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2671operator*(const _Expr& __x, const typename _Expr::value_type& __y) {
25922672 typedef typename _Expr::value_type value_type;
25932673 typedef _BinaryOp<multiplies<value_type>, _Expr, __scalar_expr<value_type> > _Op;
25942674 return __val_expr<_Op>(_Op(multiplies<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2596,8 +2676,8 @@ inline _LIBCPP_HIDE_FROM_ABI
25962676
25972677template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
25982678inline _LIBCPP_HIDE_FROM_ABI
2599 __val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2600 operator*(const typename _Expr::value_type& __x, const _Expr& __y) {
2679__val_expr<_BinaryOp<multiplies<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2680operator*(const typename _Expr::value_type& __x, const _Expr& __y) {
26012681 typedef typename _Expr::value_type value_type;
26022682 typedef _BinaryOp<multiplies<value_type>, __scalar_expr<value_type>, _Expr> _Op;
26032683 return __val_expr<_Op>(_Op(multiplies<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2615,8 +2695,8 @@ operator/(const _Expr1& __x, const _Expr2& __y) {
26152695
26162696template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26172697inline _LIBCPP_HIDE_FROM_ABI
2618 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2619 operator/(const _Expr& __x, const typename _Expr::value_type& __y) {
2698__val_expr<_BinaryOp<divides<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2699operator/(const _Expr& __x, const typename _Expr::value_type& __y) {
26202700 typedef typename _Expr::value_type value_type;
26212701 typedef _BinaryOp<divides<value_type>, _Expr, __scalar_expr<value_type> > _Op;
26222702 return __val_expr<_Op>(_Op(divides<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2624,8 +2704,8 @@ inline _LIBCPP_HIDE_FROM_ABI
26242704
26252705template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26262706inline _LIBCPP_HIDE_FROM_ABI
2627 __val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2628 operator/(const typename _Expr::value_type& __x, const _Expr& __y) {
2707__val_expr<_BinaryOp<divides<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2708operator/(const typename _Expr::value_type& __x, const _Expr& __y) {
26292709 typedef typename _Expr::value_type value_type;
26302710 typedef _BinaryOp<divides<value_type>, __scalar_expr<value_type>, _Expr> _Op;
26312711 return __val_expr<_Op>(_Op(divides<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2643,8 +2723,8 @@ operator%(const _Expr1& __x, const _Expr2& __y) {
26432723
26442724template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26452725inline _LIBCPP_HIDE_FROM_ABI
2646 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2647 operator%(const _Expr& __x, const typename _Expr::value_type& __y) {
2726__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2727operator%(const _Expr& __x, const typename _Expr::value_type& __y) {
26482728 typedef typename _Expr::value_type value_type;
26492729 typedef _BinaryOp<modulus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
26502730 return __val_expr<_Op>(_Op(modulus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2652,8 +2732,8 @@ inline _LIBCPP_HIDE_FROM_ABI
26522732
26532733template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26542734inline _LIBCPP_HIDE_FROM_ABI
2655 __val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2656 operator%(const typename _Expr::value_type& __x, const _Expr& __y) {
2735__val_expr<_BinaryOp<modulus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2736operator%(const typename _Expr::value_type& __x, const _Expr& __y) {
26572737 typedef typename _Expr::value_type value_type;
26582738 typedef _BinaryOp<modulus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
26592739 return __val_expr<_Op>(_Op(modulus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2671,8 +2751,8 @@ operator+(const _Expr1& __x, const _Expr2& __y) {
26712751
26722752template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26732753inline _LIBCPP_HIDE_FROM_ABI
2674 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2675 operator+(const _Expr& __x, const typename _Expr::value_type& __y) {
2754__val_expr<_BinaryOp<plus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2755operator+(const _Expr& __x, const typename _Expr::value_type& __y) {
26762756 typedef typename _Expr::value_type value_type;
26772757 typedef _BinaryOp<plus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
26782758 return __val_expr<_Op>(_Op(plus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2680,8 +2760,8 @@ inline _LIBCPP_HIDE_FROM_ABI
26802760
26812761template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
26822762inline _LIBCPP_HIDE_FROM_ABI
2683 __val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2684 operator+(const typename _Expr::value_type& __x, const _Expr& __y) {
2763__val_expr<_BinaryOp<plus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2764operator+(const typename _Expr::value_type& __x, const _Expr& __y) {
26852765 typedef typename _Expr::value_type value_type;
26862766 typedef _BinaryOp<plus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
26872767 return __val_expr<_Op>(_Op(plus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2699,8 +2779,8 @@ operator-(const _Expr1& __x, const _Expr2& __y) {
26992779
27002780template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27012781inline _LIBCPP_HIDE_FROM_ABI
2702 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2703 operator-(const _Expr& __x, const typename _Expr::value_type& __y) {
2782__val_expr<_BinaryOp<minus<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2783operator-(const _Expr& __x, const typename _Expr::value_type& __y) {
27042784 typedef typename _Expr::value_type value_type;
27052785 typedef _BinaryOp<minus<value_type>, _Expr, __scalar_expr<value_type> > _Op;
27062786 return __val_expr<_Op>(_Op(minus<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2708,8 +2788,8 @@ inline _LIBCPP_HIDE_FROM_ABI
27082788
27092789template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27102790inline _LIBCPP_HIDE_FROM_ABI
2711 __val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2712 operator-(const typename _Expr::value_type& __x, const _Expr& __y) {
2791__val_expr<_BinaryOp<minus<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2792operator-(const typename _Expr::value_type& __x, const _Expr& __y) {
27132793 typedef typename _Expr::value_type value_type;
27142794 typedef _BinaryOp<minus<value_type>, __scalar_expr<value_type>, _Expr> _Op;
27152795 return __val_expr<_Op>(_Op(minus<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2727,8 +2807,8 @@ operator^(const _Expr1& __x, const _Expr2& __y) {
27272807
27282808template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27292809inline _LIBCPP_HIDE_FROM_ABI
2730 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2731 operator^(const _Expr& __x, const typename _Expr::value_type& __y) {
2810__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2811operator^(const _Expr& __x, const typename _Expr::value_type& __y) {
27322812 typedef typename _Expr::value_type value_type;
27332813 typedef _BinaryOp<bit_xor<value_type>, _Expr, __scalar_expr<value_type> > _Op;
27342814 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2736,8 +2816,8 @@ inline _LIBCPP_HIDE_FROM_ABI
27362816
27372817template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27382818inline _LIBCPP_HIDE_FROM_ABI
2739 __val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2740 operator^(const typename _Expr::value_type& __x, const _Expr& __y) {
2819__val_expr<_BinaryOp<bit_xor<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2820operator^(const typename _Expr::value_type& __x, const _Expr& __y) {
27412821 typedef typename _Expr::value_type value_type;
27422822 typedef _BinaryOp<bit_xor<value_type>, __scalar_expr<value_type>, _Expr> _Op;
27432823 return __val_expr<_Op>(_Op(bit_xor<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2755,8 +2835,8 @@ operator&(const _Expr1& __x, const _Expr2& __y) {
27552835
27562836template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27572837inline _LIBCPP_HIDE_FROM_ABI
2758 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2759 operator&(const _Expr& __x, const typename _Expr::value_type& __y) {
2838__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2839operator&(const _Expr& __x, const typename _Expr::value_type& __y) {
27602840 typedef typename _Expr::value_type value_type;
27612841 typedef _BinaryOp<bit_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
27622842 return __val_expr<_Op>(_Op(bit_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2764,8 +2844,8 @@ inline _LIBCPP_HIDE_FROM_ABI
27642844
27652845template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27662846inline _LIBCPP_HIDE_FROM_ABI
2767 __val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2768 operator&(const typename _Expr::value_type& __x, const _Expr& __y) {
2847__val_expr<_BinaryOp<bit_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2848operator&(const typename _Expr::value_type& __x, const _Expr& __y) {
27692849 typedef typename _Expr::value_type value_type;
27702850 typedef _BinaryOp<bit_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
27712851 return __val_expr<_Op>(_Op(bit_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2783,8 +2863,8 @@ operator|(const _Expr1& __x, const _Expr2& __y) {
27832863
27842864template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27852865inline _LIBCPP_HIDE_FROM_ABI
2786 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2787 operator|(const _Expr& __x, const typename _Expr::value_type& __y) {
2866__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2867operator|(const _Expr& __x, const typename _Expr::value_type& __y) {
27882868 typedef typename _Expr::value_type value_type;
27892869 typedef _BinaryOp<bit_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
27902870 return __val_expr<_Op>(_Op(bit_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2792,8 +2872,8 @@ inline _LIBCPP_HIDE_FROM_ABI
27922872
27932873template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
27942874inline _LIBCPP_HIDE_FROM_ABI
2795 __val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2796 operator|(const typename _Expr::value_type& __x, const _Expr& __y) {
2875__val_expr<_BinaryOp<bit_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2876operator|(const typename _Expr::value_type& __x, const _Expr& __y) {
27972877 typedef typename _Expr::value_type value_type;
27982878 typedef _BinaryOp<bit_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
27992879 return __val_expr<_Op>(_Op(bit_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2810,8 +2890,8 @@ operator<<(const _Expr1& __x, const _Expr2& __y) {
28102890}
28112891
28122892template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2813inline _LIBCPP_HIDE_FROM_ABI __val_expr<
2814 _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2893inline _LIBCPP_HIDE_FROM_ABI
2894__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
28152895operator<<(const _Expr& __x, const typename _Expr::value_type& __y) {
28162896 typedef typename _Expr::value_type value_type;
28172897 typedef _BinaryOp<__bit_shift_left<value_type>, _Expr, __scalar_expr<value_type> > _Op;
......@@ -2819,8 +2899,8 @@ operator<<(const _Expr& __x, const typename _Expr::value_type& __y) {
28192899}
28202900
28212901template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2822inline _LIBCPP_HIDE_FROM_ABI __val_expr<
2823 _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2902inline _LIBCPP_HIDE_FROM_ABI
2903__val_expr< _BinaryOp<__bit_shift_left<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
28242904operator<<(const typename _Expr::value_type& __x, const _Expr& __y) {
28252905 typedef typename _Expr::value_type value_type;
28262906 typedef _BinaryOp<__bit_shift_left<value_type>, __scalar_expr<value_type>, _Expr> _Op;
......@@ -2847,8 +2927,8 @@ operator>>(const _Expr& __x, const typename _Expr::value_type& __y) {
28472927}
28482928
28492929template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
2850inline _LIBCPP_HIDE_FROM_ABI __val_expr<
2851 _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2930inline _LIBCPP_HIDE_FROM_ABI
2931__val_expr< _BinaryOp<__bit_shift_right<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
28522932operator>>(const typename _Expr::value_type& __x, const _Expr& __y) {
28532933 typedef typename _Expr::value_type value_type;
28542934 typedef _BinaryOp<__bit_shift_right<value_type>, __scalar_expr<value_type>, _Expr> _Op;
......@@ -2867,8 +2947,8 @@ operator&&(const _Expr1& __x, const _Expr2& __y) {
28672947
28682948template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
28692949inline _LIBCPP_HIDE_FROM_ABI
2870 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2871 operator&&(const _Expr& __x, const typename _Expr::value_type& __y) {
2950__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2951operator&&(const _Expr& __x, const typename _Expr::value_type& __y) {
28722952 typedef typename _Expr::value_type value_type;
28732953 typedef _BinaryOp<logical_and<value_type>, _Expr, __scalar_expr<value_type> > _Op;
28742954 return __val_expr<_Op>(_Op(logical_and<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2876,8 +2956,8 @@ inline _LIBCPP_HIDE_FROM_ABI
28762956
28772957template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
28782958inline _LIBCPP_HIDE_FROM_ABI
2879 __val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2880 operator&&(const typename _Expr::value_type& __x, const _Expr& __y) {
2959__val_expr<_BinaryOp<logical_and<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2960operator&&(const typename _Expr::value_type& __x, const _Expr& __y) {
28812961 typedef typename _Expr::value_type value_type;
28822962 typedef _BinaryOp<logical_and<value_type>, __scalar_expr<value_type>, _Expr> _Op;
28832963 return __val_expr<_Op>(_Op(logical_and<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2895,8 +2975,8 @@ operator||(const _Expr1& __x, const _Expr2& __y) {
28952975
28962976template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
28972977inline _LIBCPP_HIDE_FROM_ABI
2898 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2899 operator||(const _Expr& __x, const typename _Expr::value_type& __y) {
2978__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2979operator||(const _Expr& __x, const typename _Expr::value_type& __y) {
29002980 typedef typename _Expr::value_type value_type;
29012981 typedef _BinaryOp<logical_or<value_type>, _Expr, __scalar_expr<value_type> > _Op;
29022982 return __val_expr<_Op>(_Op(logical_or<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2904,8 +2984,8 @@ inline _LIBCPP_HIDE_FROM_ABI
29042984
29052985template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29062986inline _LIBCPP_HIDE_FROM_ABI
2907 __val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2908 operator||(const typename _Expr::value_type& __x, const _Expr& __y) {
2987__val_expr<_BinaryOp<logical_or<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2988operator||(const typename _Expr::value_type& __x, const _Expr& __y) {
29092989 typedef typename _Expr::value_type value_type;
29102990 typedef _BinaryOp<logical_or<value_type>, __scalar_expr<value_type>, _Expr> _Op;
29112991 return __val_expr<_Op>(_Op(logical_or<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2923,8 +3003,8 @@ operator==(const _Expr1& __x, const _Expr2& __y) {
29233003
29243004template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29253005inline _LIBCPP_HIDE_FROM_ABI
2926 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2927 operator==(const _Expr& __x, const typename _Expr::value_type& __y) {
3006__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3007operator==(const _Expr& __x, const typename _Expr::value_type& __y) {
29283008 typedef typename _Expr::value_type value_type;
29293009 typedef _BinaryOp<equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
29303010 return __val_expr<_Op>(_Op(equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2932,8 +3012,8 @@ inline _LIBCPP_HIDE_FROM_ABI
29323012
29333013template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29343014inline _LIBCPP_HIDE_FROM_ABI
2935 __val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2936 operator==(const typename _Expr::value_type& __x, const _Expr& __y) {
3015__val_expr<_BinaryOp<equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3016operator==(const typename _Expr::value_type& __x, const _Expr& __y) {
29373017 typedef typename _Expr::value_type value_type;
29383018 typedef _BinaryOp<equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
29393019 return __val_expr<_Op>(_Op(equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2951,8 +3031,8 @@ operator!=(const _Expr1& __x, const _Expr2& __y) {
29513031
29523032template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29533033inline _LIBCPP_HIDE_FROM_ABI
2954 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2955 operator!=(const _Expr& __x, const typename _Expr::value_type& __y) {
3034__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3035operator!=(const _Expr& __x, const typename _Expr::value_type& __y) {
29563036 typedef typename _Expr::value_type value_type;
29573037 typedef _BinaryOp<not_equal_to<value_type>, _Expr, __scalar_expr<value_type> > _Op;
29583038 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2960,8 +3040,8 @@ inline _LIBCPP_HIDE_FROM_ABI
29603040
29613041template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29623042inline _LIBCPP_HIDE_FROM_ABI
2963 __val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2964 operator!=(const typename _Expr::value_type& __x, const _Expr& __y) {
3043__val_expr<_BinaryOp<not_equal_to<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3044operator!=(const typename _Expr::value_type& __x, const _Expr& __y) {
29653045 typedef typename _Expr::value_type value_type;
29663046 typedef _BinaryOp<not_equal_to<value_type>, __scalar_expr<value_type>, _Expr> _Op;
29673047 return __val_expr<_Op>(_Op(not_equal_to<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -2979,8 +3059,8 @@ operator<(const _Expr1& __x, const _Expr2& __y) {
29793059
29803060template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29813061inline _LIBCPP_HIDE_FROM_ABI
2982 __val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
2983 operator<(const _Expr& __x, const typename _Expr::value_type& __y) {
3062__val_expr<_BinaryOp<less<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3063operator<(const _Expr& __x, const typename _Expr::value_type& __y) {
29843064 typedef typename _Expr::value_type value_type;
29853065 typedef _BinaryOp<less<value_type>, _Expr, __scalar_expr<value_type> > _Op;
29863066 return __val_expr<_Op>(_Op(less<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -2988,8 +3068,8 @@ inline _LIBCPP_HIDE_FROM_ABI
29883068
29893069template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
29903070inline _LIBCPP_HIDE_FROM_ABI
2991 __val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
2992 operator<(const typename _Expr::value_type& __x, const _Expr& __y) {
3071__val_expr<_BinaryOp<less<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3072operator<(const typename _Expr::value_type& __x, const _Expr& __y) {
29933073 typedef typename _Expr::value_type value_type;
29943074 typedef _BinaryOp<less<value_type>, __scalar_expr<value_type>, _Expr> _Op;
29953075 return __val_expr<_Op>(_Op(less<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -3007,8 +3087,8 @@ operator>(const _Expr1& __x, const _Expr2& __y) {
30073087
30083088template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30093089inline _LIBCPP_HIDE_FROM_ABI
3010 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3011 operator>(const _Expr& __x, const typename _Expr::value_type& __y) {
3090__val_expr<_BinaryOp<greater<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3091operator>(const _Expr& __x, const typename _Expr::value_type& __y) {
30123092 typedef typename _Expr::value_type value_type;
30133093 typedef _BinaryOp<greater<value_type>, _Expr, __scalar_expr<value_type> > _Op;
30143094 return __val_expr<_Op>(_Op(greater<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -3016,8 +3096,8 @@ inline _LIBCPP_HIDE_FROM_ABI
30163096
30173097template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30183098inline _LIBCPP_HIDE_FROM_ABI
3019 __val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3020 operator>(const typename _Expr::value_type& __x, const _Expr& __y) {
3099__val_expr<_BinaryOp<greater<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3100operator>(const typename _Expr::value_type& __x, const _Expr& __y) {
30213101 typedef typename _Expr::value_type value_type;
30223102 typedef _BinaryOp<greater<value_type>, __scalar_expr<value_type>, _Expr> _Op;
30233103 return __val_expr<_Op>(_Op(greater<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -3035,8 +3115,8 @@ operator<=(const _Expr1& __x, const _Expr2& __y) {
30353115
30363116template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30373117inline _LIBCPP_HIDE_FROM_ABI
3038 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3039 operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {
3118__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3119operator<=(const _Expr& __x, const typename _Expr::value_type& __y) {
30403120 typedef typename _Expr::value_type value_type;
30413121 typedef _BinaryOp<less_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
30423122 return __val_expr<_Op>(_Op(less_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -3044,8 +3124,8 @@ inline _LIBCPP_HIDE_FROM_ABI
30443124
30453125template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30463126inline _LIBCPP_HIDE_FROM_ABI
3047 __val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3048 operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {
3127__val_expr<_BinaryOp<less_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3128operator<=(const typename _Expr::value_type& __x, const _Expr& __y) {
30493129 typedef typename _Expr::value_type value_type;
30503130 typedef _BinaryOp<less_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
30513131 return __val_expr<_Op>(_Op(less_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -3063,8 +3143,8 @@ operator>=(const _Expr1& __x, const _Expr2& __y) {
30633143
30643144template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30653145inline _LIBCPP_HIDE_FROM_ABI
3066 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3067 operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {
3146__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3147operator>=(const _Expr& __x, const typename _Expr::value_type& __y) {
30683148 typedef typename _Expr::value_type value_type;
30693149 typedef _BinaryOp<greater_equal<value_type>, _Expr, __scalar_expr<value_type> > _Op;
30703150 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -3072,8 +3152,8 @@ inline _LIBCPP_HIDE_FROM_ABI
30723152
30733153template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
30743154inline _LIBCPP_HIDE_FROM_ABI
3075 __val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3076 operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {
3155__val_expr<_BinaryOp<greater_equal<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3156operator>=(const typename _Expr::value_type& __x, const _Expr& __y) {
30773157 typedef typename _Expr::value_type value_type;
30783158 typedef _BinaryOp<greater_equal<value_type>, __scalar_expr<value_type>, _Expr> _Op;
30793159 return __val_expr<_Op>(_Op(greater_equal<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -3123,8 +3203,8 @@ atan2(const _Expr1& __x, const _Expr2& __y) {
31233203
31243204template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
31253205inline _LIBCPP_HIDE_FROM_ABI
3126 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3127 atan2(const _Expr& __x, const typename _Expr::value_type& __y) {
3206__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3207atan2(const _Expr& __x, const typename _Expr::value_type& __y) {
31283208 typedef typename _Expr::value_type value_type;
31293209 typedef _BinaryOp<__atan2_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
31303210 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -3132,8 +3212,8 @@ inline _LIBCPP_HIDE_FROM_ABI
31323212
31333213template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
31343214inline _LIBCPP_HIDE_FROM_ABI
3135 __val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3136 atan2(const typename _Expr::value_type& __x, const _Expr& __y) {
3215__val_expr<_BinaryOp<__atan2_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3216atan2(const typename _Expr::value_type& __x, const _Expr& __y) {
31373217 typedef typename _Expr::value_type value_type;
31383218 typedef _BinaryOp<__atan2_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
31393219 return __val_expr<_Op>(_Op(__atan2_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
......@@ -3191,8 +3271,8 @@ pow(const _Expr1& __x, const _Expr2& __y) {
31913271
31923272template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
31933273inline _LIBCPP_HIDE_FROM_ABI
3194 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3195 pow(const _Expr& __x, const typename _Expr::value_type& __y) {
3274__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, _Expr, __scalar_expr<typename _Expr::value_type> > >
3275pow(const _Expr& __x, const typename _Expr::value_type& __y) {
31963276 typedef typename _Expr::value_type value_type;
31973277 typedef _BinaryOp<__pow_expr<value_type>, _Expr, __scalar_expr<value_type> > _Op;
31983278 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __x, __scalar_expr<value_type>(__y, __x.size())));
......@@ -3200,8 +3280,8 @@ inline _LIBCPP_HIDE_FROM_ABI
32003280
32013281template <class _Expr, __enable_if_t<__is_val_expr<_Expr>::value, int> = 0>
32023282inline _LIBCPP_HIDE_FROM_ABI
3203 __val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3204 pow(const typename _Expr::value_type& __x, const _Expr& __y) {
3283__val_expr<_BinaryOp<__pow_expr<typename _Expr::value_type>, __scalar_expr<typename _Expr::value_type>, _Expr> >
3284pow(const typename _Expr::value_type& __x, const _Expr& __y) {
32053285 typedef typename _Expr::value_type value_type;
32063286 typedef _BinaryOp<__pow_expr<value_type>, __scalar_expr<value_type>, _Expr> _Op;
32073287 return __val_expr<_Op>(_Op(__pow_expr<value_type>(), __scalar_expr<value_type>(__x, __y.size()), __y));
lib/libcxx/include/variant+170-154
......@@ -42,26 +42,28 @@ namespace std {
4242 in_place_index_t<I>, initializer_list<U>, Args&&...);
4343
4444 // 20.7.2.2, destructor
45 ~variant();
45 constexpr ~variant(); // constexpr since c++20
4646
4747 // 20.7.2.3, assignment
4848 constexpr variant& operator=(const variant&);
4949 constexpr variant& operator=(variant&&) noexcept(see below);
5050
51 template <class T> variant& operator=(T&&) noexcept(see below);
51 template <class T>
52 constexpr variant& operator=(T&&) noexcept(see below); // constexpr since c++20
5253
5354 // 20.7.2.4, modifiers
5455 template <class T, class... Args>
55 T& emplace(Args&&...);
56 constexpr T& emplace(Args&&...); // constexpr since c++20
5657
5758 template <class T, class U, class... Args>
58 T& emplace(initializer_list<U>, Args&&...);
59 constexpr T& emplace(initializer_list<U>, Args&&...); // constexpr since c++20
5960
6061 template <size_t I, class... Args>
61 variant_alternative_t<I, variant>& emplace(Args&&...);
62 constexpr variant_alternative_t<I, variant>& emplace(Args&&...); // constexpr since c++20
6263
6364 template <size_t I, class U, class... Args>
64 variant_alternative_t<I, variant>& emplace(initializer_list<U>, Args&&...);
65 constexpr variant_alternative_t<I, variant>&
66 emplace(initializer_list<U>, Args&&...); // constexpr since c++20
6567
6668 // 20.7.2.5, value status
6769 constexpr bool valueless_by_exception() const noexcept;
......@@ -210,8 +212,6 @@ namespace std {
210212
211213*/
212214
213#include <__assert> // all public C++ headers provide the assertion handler
214#include <__availability>
215215#include <__compare/common_comparison_category.h>
216216#include <__compare/compare_three_way_result.h>
217217#include <__compare/three_way_comparable.h>
......@@ -222,27 +222,36 @@ namespace std {
222222#include <__functional/operations.h>
223223#include <__functional/unary_function.h>
224224#include <__memory/addressof.h>
225#include <__memory/construct_at.h>
226#include <__tuple/find_index.h>
227#include <__tuple/sfinae_helpers.h>
225228#include <__type_traits/add_const.h>
226229#include <__type_traits/add_cv.h>
227230#include <__type_traits/add_pointer.h>
228231#include <__type_traits/add_volatile.h>
232#include <__type_traits/common_type.h>
233#include <__type_traits/conjunction.h>
229234#include <__type_traits/dependent_type.h>
230235#include <__type_traits/is_array.h>
236#include <__type_traits/is_constructible.h>
231237#include <__type_traits/is_destructible.h>
232#include <__type_traits/is_nothrow_move_constructible.h>
233#include <__type_traits/is_trivially_copy_assignable.h>
234#include <__type_traits/is_trivially_copy_constructible.h>
238#include <__type_traits/is_nothrow_assignable.h>
239#include <__type_traits/is_nothrow_constructible.h>
240#include <__type_traits/is_reference.h>
241#include <__type_traits/is_trivially_assignable.h>
242#include <__type_traits/is_trivially_constructible.h>
235243#include <__type_traits/is_trivially_destructible.h>
236#include <__type_traits/is_trivially_move_assignable.h>
237#include <__type_traits/is_trivially_move_constructible.h>
244#include <__type_traits/is_trivially_relocatable.h>
238245#include <__type_traits/is_void.h>
239246#include <__type_traits/remove_const.h>
247#include <__type_traits/remove_cvref.h>
240248#include <__type_traits/type_identity.h>
241249#include <__type_traits/void_t.h>
242250#include <__utility/declval.h>
243251#include <__utility/forward.h>
244252#include <__utility/forward_like.h>
245253#include <__utility/in_place.h>
254#include <__utility/integer_sequence.h>
246255#include <__utility/move.h>
247256#include <__utility/swap.h>
248257#include <__variant/monostate.h>
......@@ -250,7 +259,6 @@ namespace std {
250259#include <initializer_list>
251260#include <limits>
252261#include <new>
253#include <tuple>
254262#include <version>
255263
256264// standard-mandated includes
......@@ -341,21 +349,20 @@ struct _LIBCPP_TEMPLATE_VIS variant_alternative<_Ip, variant<_Types...>> {
341349
342350inline constexpr size_t variant_npos = static_cast<size_t>(-1);
343351
344_LIBCPP_HIDE_FROM_ABI constexpr int __choose_index_type(unsigned int __num_elem) {
345 if (__num_elem < numeric_limits<unsigned char>::max())
346 return 0;
347 if (__num_elem < numeric_limits<unsigned short>::max())
348 return 1;
349 return 2;
352template <size_t _NumAlternatives>
353_LIBCPP_HIDE_FROM_ABI constexpr auto __choose_index_type() {
354# ifdef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
355 if constexpr (_NumAlternatives < numeric_limits<unsigned char>::max())
356 return static_cast<unsigned char>(0);
357 else if constexpr (_NumAlternatives < numeric_limits<unsigned short>::max())
358 return static_cast<unsigned short>(0);
359 else
360# endif // _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
361 return static_cast<unsigned int>(0);
350362}
351363
352364template <size_t _NumAlts>
353using __variant_index_t =
354# ifndef _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
355 unsigned int;
356# else
357 std::tuple_element_t< __choose_index_type(_NumAlts), std::tuple<unsigned char, unsigned short, unsigned int> >;
358# endif
365using __variant_index_t = decltype(std::__choose_index_type<_NumAlts>());
359366
360367template <class _IndexType>
361368constexpr _IndexType __variant_npos = static_cast<_IndexType>(-1);
......@@ -653,9 +660,14 @@ private:
653660
654661} // namespace __visitation
655662
663// Adding semi-colons in macro expansions helps clang-format to do a better job.
664// This macro is used to avoid compilation errors due to "stray" semi-colons.
665# define _LIBCPP_EAT_SEMICOLON static_assert(true, "")
666
656667template <size_t _Index, class _Tp>
657668struct _LIBCPP_TEMPLATE_VIS __alt {
658 using __value_type = _Tp;
669 using __value_type = _Tp;
670 static constexpr size_t __index = _Index;
659671
660672 template <class... _Args>
661673 _LIBCPP_HIDE_FROM_ABI explicit constexpr __alt(in_place_t, _Args&&... __args)
......@@ -670,7 +682,7 @@ union _LIBCPP_TEMPLATE_VIS __union;
670682template <_Trait _DestructibleTrait, size_t _Index>
671683union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
672684
673# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor) \
685# define _LIBCPP_VARIANT_UNION(destructible_trait, destructor_definition) \
674686 template <size_t _Index, class _Tp, class... _Types> \
675687 union _LIBCPP_TEMPLATE_VIS __union<destructible_trait, _Index, _Tp, _Types...> { \
676688 public: \
......@@ -684,14 +696,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
684696 _LIBCPP_HIDE_FROM_ABI explicit constexpr __union(in_place_index_t<_Ip>, _Args&&... __args) \
685697 : __tail(in_place_index<_Ip - 1>, std::forward<_Args>(__args)...) {} \
686698 \
687 __union(const __union&) = default; \
688 __union(__union&&) = default; \
689 \
690 destructor \
691 \
692 __union& \
693 operator=(const __union&) = default; \
694 __union& operator=(__union&&) = default; \
699 _LIBCPP_HIDE_FROM_ABI __union(const __union&) = default; \
700 _LIBCPP_HIDE_FROM_ABI __union(__union&&) = default; \
701 _LIBCPP_HIDE_FROM_ABI __union& operator=(const __union&) = default; \
702 _LIBCPP_HIDE_FROM_ABI __union& operator=(__union&&) = default; \
703 destructor_definition; \
695704 \
696705 private: \
697706 char __dummy; \
......@@ -701,9 +710,11 @@ union _LIBCPP_TEMPLATE_VIS __union<_DestructibleTrait, _Index> {};
701710 friend struct __access::__union; \
702711 }
703712
704_LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable, ~__union() = default;);
705_LIBCPP_VARIANT_UNION(_Trait::_Available, ~__union(){});
706_LIBCPP_VARIANT_UNION(_Trait::_Unavailable, ~__union() = delete;);
713_LIBCPP_VARIANT_UNION(_Trait::_TriviallyAvailable,
714 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = default);
715_LIBCPP_VARIANT_UNION(
716 _Trait::_Available, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() {} _LIBCPP_EAT_SEMICOLON);
717_LIBCPP_VARIANT_UNION(_Trait::_Unavailable, _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__union() = delete);
707718
708719# undef _LIBCPP_VARIANT_UNION
709720
......@@ -746,7 +757,7 @@ protected:
746757template <class _Traits, _Trait = _Traits::__destructible_trait>
747758class _LIBCPP_TEMPLATE_VIS __dtor;
748759
749# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor, destroy) \
760# define _LIBCPP_VARIANT_DESTRUCTOR(destructible_trait, destructor_definition, destroy) \
750761 template <class... _Types> \
751762 class _LIBCPP_TEMPLATE_VIS __dtor<__traits<_Types...>, destructible_trait> \
752763 : public __base<destructible_trait, _Types...> { \
......@@ -756,24 +767,27 @@ class _LIBCPP_TEMPLATE_VIS __dtor;
756767 public: \
757768 using __base_type::__base_type; \
758769 using __base_type::operator=; \
759 \
760 __dtor(const __dtor&) = default; \
761 __dtor(__dtor&&) = default; \
762 destructor __dtor& operator=(const __dtor&) = default; \
763 __dtor& operator=(__dtor&&) = default; \
770 _LIBCPP_HIDE_FROM_ABI __dtor(const __dtor&) = default; \
771 _LIBCPP_HIDE_FROM_ABI __dtor(__dtor&&) = default; \
772 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(const __dtor&) = default; \
773 _LIBCPP_HIDE_FROM_ABI __dtor& operator=(__dtor&&) = default; \
774 destructor_definition; \
764775 \
765776 protected: \
766 inline _LIBCPP_HIDE_FROM_ABI destroy \
777 destroy; \
767778 }
768779
769780_LIBCPP_VARIANT_DESTRUCTOR(
770 _Trait::_TriviallyAvailable, ~__dtor() = default;
771 , void __destroy() noexcept { this->__index = __variant_npos<__index_t>; });
781 _Trait::_TriviallyAvailable,
782 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = default,
783 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept {
784 this->__index = __variant_npos<__index_t>;
785 } _LIBCPP_EAT_SEMICOLON);
772786
773787_LIBCPP_VARIANT_DESTRUCTOR(
774788 _Trait::_Available,
775 ~__dtor() { __destroy(); },
776 void __destroy() noexcept {
789 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() { __destroy(); } _LIBCPP_EAT_SEMICOLON,
790 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept {
777791 if (!this->valueless_by_exception()) {
778792 __visitation::__base::__visit_alt(
779793 [](auto& __alt) noexcept {
......@@ -783,9 +797,11 @@ _LIBCPP_VARIANT_DESTRUCTOR(
783797 *this);
784798 }
785799 this->__index = __variant_npos<__index_t>;
786 });
800 } _LIBCPP_EAT_SEMICOLON);
787801
788_LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable, ~__dtor() = delete;, void __destroy() noexcept = delete;);
802_LIBCPP_VARIANT_DESTRUCTOR(_Trait::_Unavailable,
803 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~__dtor() = delete,
804 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __destroy() noexcept = delete);
789805
790806# undef _LIBCPP_VARIANT_DESTRUCTOR
791807
......@@ -798,23 +814,18 @@ public:
798814 using __base_type::operator=;
799815
800816protected:
801 template <size_t _Ip, class _Tp, class... _Args>
802 _LIBCPP_HIDE_FROM_ABI static _Tp& __construct_alt(__alt<_Ip, _Tp>& __a, _Args&&... __args) {
803 ::new ((void*)std::addressof(__a)) __alt<_Ip, _Tp>(in_place, std::forward<_Args>(__args)...);
804 return __a.__value;
805 }
806
807817 template <class _Rhs>
808 _LIBCPP_HIDE_FROM_ABI static void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
818 _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR_SINCE_CXX20 void __generic_construct(__ctor& __lhs, _Rhs&& __rhs) {
809819 __lhs.__destroy();
810820 if (!__rhs.valueless_by_exception()) {
811821 auto __rhs_index = __rhs.index();
812822 __visitation::__base::__visit_alt_at(
813823 __rhs_index,
814 [](auto& __lhs_alt, auto&& __rhs_alt) {
815 __construct_alt(__lhs_alt, std::forward<decltype(__rhs_alt)>(__rhs_alt).__value);
824 [&__lhs](auto&& __rhs_alt) {
825 std::__construct_at(std::addressof(__lhs.__data),
826 in_place_index<__decay_t<decltype(__rhs_alt)>::__index>,
827 std::forward<decltype(__rhs_alt)>(__rhs_alt).__value);
816828 },
817 __lhs,
818829 std::forward<_Rhs>(__rhs));
819830 __lhs.__index = __rhs_index;
820831 }
......@@ -824,7 +835,7 @@ protected:
824835template <class _Traits, _Trait = _Traits::__move_constructible_trait>
825836class _LIBCPP_TEMPLATE_VIS __move_constructor;
826837
827# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor) \
838# define _LIBCPP_VARIANT_MOVE_CONSTRUCTOR(move_constructible_trait, move_constructor_definition) \
828839 template <class... _Types> \
829840 class _LIBCPP_TEMPLATE_VIS __move_constructor<__traits<_Types...>, move_constructible_trait> \
830841 : public __ctor<__traits<_Types...>> { \
......@@ -834,28 +845,35 @@ class _LIBCPP_TEMPLATE_VIS __move_constructor;
834845 using __base_type::__base_type; \
835846 using __base_type::operator=; \
836847 \
837 __move_constructor(const __move_constructor&) = default; \
838 move_constructor ~__move_constructor() = default; \
839 __move_constructor& operator=(const __move_constructor&) = default; \
840 __move_constructor& operator=(__move_constructor&&) = default; \
848 _LIBCPP_HIDE_FROM_ABI __move_constructor(const __move_constructor&) = default; \
849 _LIBCPP_HIDE_FROM_ABI ~__move_constructor() = default; \
850 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(const __move_constructor&) = default; \
851 _LIBCPP_HIDE_FROM_ABI __move_constructor& operator=(__move_constructor&&) = default; \
852 move_constructor_definition; \
841853 }
842854
843_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(_Trait::_TriviallyAvailable,
844 __move_constructor(__move_constructor&& __that) = default;);
855_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
856 _Trait::_TriviallyAvailable,
857 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) = default);
845858
846859_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
847860 _Trait::_Available,
848 __move_constructor(__move_constructor&& __that) noexcept(__all<is_nothrow_move_constructible_v<_Types>...>::value)
849 : __move_constructor(__valueless_t{}) { this->__generic_construct(*this, std::move(__that)); });
861 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&& __that) noexcept(
862 __all<is_nothrow_move_constructible_v<_Types>...>::value)
863 : __move_constructor(__valueless_t{}) {
864 this->__generic_construct(*this, std::move(__that));
865 } _LIBCPP_EAT_SEMICOLON);
850866
851_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(_Trait::_Unavailable, __move_constructor(__move_constructor&&) = delete;);
867_LIBCPP_VARIANT_MOVE_CONSTRUCTOR(
868 _Trait::_Unavailable,
869 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_constructor(__move_constructor&&) = delete);
852870
853871# undef _LIBCPP_VARIANT_MOVE_CONSTRUCTOR
854872
855873template <class _Traits, _Trait = _Traits::__copy_constructible_trait>
856874class _LIBCPP_TEMPLATE_VIS __copy_constructor;
857875
858# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor) \
876# define _LIBCPP_VARIANT_COPY_CONSTRUCTOR(copy_constructible_trait, copy_constructor_definition) \
859877 template <class... _Types> \
860878 class _LIBCPP_TEMPLATE_VIS __copy_constructor<__traits<_Types...>, copy_constructible_trait> \
861879 : public __move_constructor<__traits<_Types...>> { \
......@@ -865,20 +883,25 @@ class _LIBCPP_TEMPLATE_VIS __copy_constructor;
865883 using __base_type::__base_type; \
866884 using __base_type::operator=; \
867885 \
868 copy_constructor __copy_constructor(__copy_constructor&&) = default; \
869 ~__copy_constructor() = default; \
870 __copy_constructor& operator=(const __copy_constructor&) = default; \
871 __copy_constructor& operator=(__copy_constructor&&) = default; \
886 _LIBCPP_HIDE_FROM_ABI __copy_constructor(__copy_constructor&&) = default; \
887 _LIBCPP_HIDE_FROM_ABI ~__copy_constructor() = default; \
888 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(const __copy_constructor&) = default; \
889 _LIBCPP_HIDE_FROM_ABI __copy_constructor& operator=(__copy_constructor&&) = default; \
890 copy_constructor_definition; \
872891 }
873892
874_LIBCPP_VARIANT_COPY_CONSTRUCTOR(_Trait::_TriviallyAvailable,
875 __copy_constructor(const __copy_constructor& __that) = default;);
893_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
894 _Trait::_TriviallyAvailable,
895 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that) = default);
876896
877897_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
878 _Trait::_Available, __copy_constructor(const __copy_constructor& __that)
879 : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); });
898 _Trait::_Available,
899 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor& __that)
900 : __copy_constructor(__valueless_t{}) { this->__generic_construct(*this, __that); } _LIBCPP_EAT_SEMICOLON);
880901
881_LIBCPP_VARIANT_COPY_CONSTRUCTOR(_Trait::_Unavailable, __copy_constructor(const __copy_constructor&) = delete;);
902_LIBCPP_VARIANT_COPY_CONSTRUCTOR(
903 _Trait::_Unavailable,
904 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_constructor(const __copy_constructor&) = delete);
882905
883906# undef _LIBCPP_VARIANT_COPY_CONSTRUCTOR
884907
......@@ -891,22 +914,24 @@ public:
891914 using __base_type::operator=;
892915
893916 template <size_t _Ip, class... _Args>
894 _LIBCPP_HIDE_FROM_ABI auto& __emplace(_Args&&... __args) {
917 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto& __emplace(_Args&&... __args) {
895918 this->__destroy();
896 auto& __res = this->__construct_alt(__access::__base::__get_alt<_Ip>(*this), std::forward<_Args>(__args)...);
919 std::__construct_at(std::addressof(this->__data), in_place_index<_Ip>, std::forward<_Args>(__args)...);
897920 this->__index = _Ip;
898 return __res;
921 return __access::__base::__get_alt<_Ip>(*this).__value;
899922 }
900923
901924protected:
902925 template <size_t _Ip, class _Tp, class _Arg>
903 _LIBCPP_HIDE_FROM_ABI void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
926 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign_alt(__alt<_Ip, _Tp>& __a, _Arg&& __arg) {
904927 if (this->index() == _Ip) {
905928 __a.__value = std::forward<_Arg>(__arg);
906929 } else {
907930 struct {
908 _LIBCPP_HIDE_FROM_ABI void operator()(true_type) const { __this->__emplace<_Ip>(std::forward<_Arg>(__arg)); }
909 _LIBCPP_HIDE_FROM_ABI void operator()(false_type) const {
931 _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(true_type) const {
932 __this->__emplace<_Ip>(std::forward<_Arg>(__arg));
933 }
934 _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX20 void operator()(false_type) const {
910935 __this->__emplace<_Ip>(_Tp(std::forward<_Arg>(__arg)));
911936 }
912937 __assignment* __this;
......@@ -917,7 +942,7 @@ protected:
917942 }
918943
919944 template <class _That>
920 _LIBCPP_HIDE_FROM_ABI void __generic_assign(_That&& __that) {
945 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __generic_assign(_That&& __that) {
921946 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
922947 // do nothing.
923948 } else if (__that.valueless_by_exception()) {
......@@ -937,7 +962,7 @@ protected:
937962template <class _Traits, _Trait = _Traits::__move_assignable_trait>
938963class _LIBCPP_TEMPLATE_VIS __move_assignment;
939964
940# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment) \
965# define _LIBCPP_VARIANT_MOVE_ASSIGNMENT(move_assignable_trait, move_assignment_definition) \
941966 template <class... _Types> \
942967 class _LIBCPP_TEMPLATE_VIS __move_assignment<__traits<_Types...>, move_assignable_trait> \
943968 : public __assignment<__traits<_Types...>> { \
......@@ -947,33 +972,36 @@ class _LIBCPP_TEMPLATE_VIS __move_assignment;
947972 using __base_type::__base_type; \
948973 using __base_type::operator=; \
949974 \
950 __move_assignment(const __move_assignment&) = default; \
951 __move_assignment(__move_assignment&&) = default; \
952 ~__move_assignment() = default; \
953 __move_assignment& operator=(const __move_assignment&) = default; \
954 move_assignment \
975 _LIBCPP_HIDE_FROM_ABI __move_assignment(const __move_assignment&) = default; \
976 _LIBCPP_HIDE_FROM_ABI __move_assignment(__move_assignment&&) = default; \
977 _LIBCPP_HIDE_FROM_ABI ~__move_assignment() = default; \
978 _LIBCPP_HIDE_FROM_ABI __move_assignment& operator=(const __move_assignment&) = default; \
979 move_assignment_definition; \
955980 }
956981
957982_LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_TriviallyAvailable,
958 __move_assignment& operator=(__move_assignment&& __that) = default;);
983 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(
984 __move_assignment&& __that) = default);
959985
960986_LIBCPP_VARIANT_MOVE_ASSIGNMENT(
961987 _Trait::_Available,
962 __move_assignment&
988 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment&
963989 operator=(__move_assignment&& __that) noexcept(
964990 __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_move_assignable_v<_Types>)...>::value) {
965991 this->__generic_assign(std::move(__that));
966992 return *this;
967 });
993 } _LIBCPP_EAT_SEMICOLON);
968994
969_LIBCPP_VARIANT_MOVE_ASSIGNMENT(_Trait::_Unavailable, __move_assignment& operator=(__move_assignment&&) = delete;);
995_LIBCPP_VARIANT_MOVE_ASSIGNMENT(
996 _Trait::_Unavailable,
997 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __move_assignment& operator=(__move_assignment&&) = delete);
970998
971999# undef _LIBCPP_VARIANT_MOVE_ASSIGNMENT
9721000
9731001template <class _Traits, _Trait = _Traits::__copy_assignable_trait>
9741002class _LIBCPP_TEMPLATE_VIS __copy_assignment;
9751003
976# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment) \
1004# define _LIBCPP_VARIANT_COPY_ASSIGNMENT(copy_assignable_trait, copy_assignment_definition) \
9771005 template <class... _Types> \
9781006 class _LIBCPP_TEMPLATE_VIS __copy_assignment<__traits<_Types...>, copy_assignable_trait> \
9791007 : public __move_assignment<__traits<_Types...>> { \
......@@ -983,22 +1011,28 @@ class _LIBCPP_TEMPLATE_VIS __copy_assignment;
9831011 using __base_type::__base_type; \
9841012 using __base_type::operator=; \
9851013 \
986 __copy_assignment(const __copy_assignment&) = default; \
987 __copy_assignment(__copy_assignment&&) = default; \
988 ~__copy_assignment() = default; \
989 copy_assignment __copy_assignment& operator=(__copy_assignment&&) = default; \
1014 _LIBCPP_HIDE_FROM_ABI __copy_assignment(const __copy_assignment&) = default; \
1015 _LIBCPP_HIDE_FROM_ABI __copy_assignment(__copy_assignment&&) = default; \
1016 _LIBCPP_HIDE_FROM_ABI ~__copy_assignment() = default; \
1017 _LIBCPP_HIDE_FROM_ABI __copy_assignment& operator=(__copy_assignment&&) = default; \
1018 copy_assignment_definition; \
9901019 }
9911020
9921021_LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_TriviallyAvailable,
993 __copy_assignment& operator=(const __copy_assignment& __that) = default;);
1022 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(
1023 const __copy_assignment& __that) = default);
9941024
9951025_LIBCPP_VARIANT_COPY_ASSIGNMENT(
996 _Trait::_Available, __copy_assignment& operator=(const __copy_assignment& __that) {
1026 _Trait::_Available,
1027 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment&
1028 operator=(const __copy_assignment& __that) {
9971029 this->__generic_assign(__that);
9981030 return *this;
999 });
1031 } _LIBCPP_EAT_SEMICOLON);
10001032
1001_LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable, __copy_assignment& operator=(const __copy_assignment&) = delete;);
1033_LIBCPP_VARIANT_COPY_ASSIGNMENT(_Trait::_Unavailable,
1034 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __copy_assignment& operator=(
1035 const __copy_assignment&) = delete);
10021036
10031037# undef _LIBCPP_VARIANT_COPY_ASSIGNMENT
10041038
......@@ -1014,11 +1048,11 @@ public:
10141048 _LIBCPP_HIDE_FROM_ABI __impl& operator=(__impl&&) = default;
10151049
10161050 template <size_t _Ip, class _Arg>
1017 _LIBCPP_HIDE_FROM_ABI void __assign(_Arg&& __arg) {
1051 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __assign(_Arg&& __arg) {
10181052 this->__assign_alt(__access::__base::__get_alt<_Ip>(*this), std::forward<_Arg>(__arg));
10191053 }
10201054
1021 inline _LIBCPP_HIDE_FROM_ABI void __swap(__impl& __that) {
1055 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __swap(__impl& __that) {
10221056 if (this->valueless_by_exception() && __that.valueless_by_exception()) {
10231057 // do nothing.
10241058 } else if (this->index() == __that.index()) {
......@@ -1063,7 +1097,7 @@ public:
10631097 }
10641098
10651099private:
1066 inline _LIBCPP_HIDE_FROM_ABI bool __move_nothrow() const {
1100 constexpr inline _LIBCPP_HIDE_FROM_ABI bool __move_nothrow() const {
10671101 constexpr bool __results[] = {is_nothrow_move_constructible_v<_Types>...};
10681102 return this->valueless_by_exception() || __results[this->index()];
10691103 }
......@@ -1082,13 +1116,9 @@ struct __narrowing_check {
10821116};
10831117
10841118template <class _Dest, class _Source>
1085using __check_for_narrowing _LIBCPP_NODEBUG = typename _If<
1086# ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
1087 false &&
1088# endif
1089 is_arithmetic<_Dest>::value,
1090 __narrowing_check,
1091 __no_narrowing_check >::template _Apply<_Dest, _Source>;
1119using __check_for_narrowing _LIBCPP_NODEBUG =
1120 typename _If< is_arithmetic<_Dest>::value, __narrowing_check, __no_narrowing_check >::template _Apply<_Dest,
1121 _Source>;
10921122
10931123template <class _Tp, size_t _Idx>
10941124struct __overload {
......@@ -1096,24 +1126,6 @@ struct __overload {
10961126 auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>;
10971127};
10981128
1099// TODO(LLVM-19): Remove all occurrences of this macro.
1100# ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
1101template <class _Tp, size_t>
1102struct __overload_bool {
1103 template <class _Up, class _Ap = __remove_cvref_t<_Up>>
1104 auto operator()(bool, _Up&&) const -> enable_if_t<is_same_v<_Ap, bool>, __type_identity<_Tp>>;
1105};
1106
1107template <size_t _Idx>
1108struct __overload<bool, _Idx> : __overload_bool<bool, _Idx> {};
1109template <size_t _Idx>
1110struct __overload<bool const, _Idx> : __overload_bool<bool const, _Idx> {};
1111template <size_t _Idx>
1112struct __overload<bool volatile, _Idx> : __overload_bool<bool volatile, _Idx> {};
1113template <size_t _Idx>
1114struct __overload<bool const volatile, _Idx> : __overload_bool<bool const volatile, _Idx> {};
1115# endif
1116
11171129template <class... _Bases>
11181130struct __all_overloads : _Bases... {
11191131 void operator()() const;
......@@ -1169,6 +1181,9 @@ class _LIBCPP_TEMPLATE_VIS _LIBCPP_DECLSPEC_EMPTY_BASES variant
11691181 using __first_type = variant_alternative_t<0, variant>;
11701182
11711183public:
1184 using __trivially_relocatable =
1185 conditional_t<_And<__libcpp_is_trivially_relocatable<_Types>...>::value, variant, void>;
1186
11721187 template <bool _Dummy = true,
11731188 enable_if_t<__dependent_type<is_default_constructible<__first_type>, _Dummy>::value, int> = 0>
11741189 _LIBCPP_HIDE_FROM_ABI constexpr variant() noexcept(is_nothrow_default_constructible_v<__first_type>)
......@@ -1227,7 +1242,7 @@ public:
12271242 _Args&&... __args) noexcept(is_nothrow_constructible_v<_Tp, initializer_list< _Up>&, _Args...>)
12281243 : __impl_(in_place_index<_Ip>, __il, std::forward<_Args>(__args)...) {}
12291244
1230 _LIBCPP_HIDE_FROM_ABI ~variant() = default;
1245 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 ~variant() = default;
12311246
12321247 _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(const variant&) = default;
12331248 _LIBCPP_HIDE_FROM_ABI constexpr variant& operator=(variant&&) = default;
......@@ -1237,7 +1252,7 @@ public:
12371252 class _Tp = __variant_detail::__best_match_t<_Arg, _Types...>,
12381253 size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
12391254 enable_if_t<is_assignable_v<_Tp&, _Arg> && is_constructible_v<_Tp, _Arg>, int> = 0>
1240 _LIBCPP_HIDE_FROM_ABI variant&
1255 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 variant&
12411256 operator=(_Arg&& __arg) noexcept(is_nothrow_assignable_v<_Tp&, _Arg> && is_nothrow_constructible_v<_Tp, _Arg>) {
12421257 __impl_.template __assign<_Ip>(std::forward<_Arg>(__arg));
12431258 return *this;
......@@ -1248,7 +1263,7 @@ public:
12481263 enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
12491264 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
12501265 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1251 _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&... __args) {
1266 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {
12521267 return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...);
12531268 }
12541269
......@@ -1258,7 +1273,7 @@ public:
12581273 enable_if_t<(_Ip < sizeof...(_Types)), int> = 0,
12591274 class _Tp = variant_alternative_t<_Ip, variant<_Types...>>,
12601275 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0>
1261 _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
1276 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
12621277 return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...);
12631278 }
12641279
......@@ -1266,7 +1281,7 @@ public:
12661281 class... _Args,
12671282 size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
12681283 enable_if_t<is_constructible_v<_Tp, _Args...>, int> = 0>
1269 _LIBCPP_HIDE_FROM_ABI _Tp& emplace(_Args&&... __args) {
1284 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(_Args&&... __args) {
12701285 return __impl_.template __emplace<_Ip>(std::forward<_Args>(__args)...);
12711286 }
12721287
......@@ -1275,7 +1290,7 @@ public:
12751290 class... _Args,
12761291 size_t _Ip = __find_detail::__find_unambiguous_index_sfinae<_Tp, _Types...>::value,
12771292 enable_if_t<is_constructible_v<_Tp, initializer_list<_Up>&, _Args...>, int> = 0>
1278 _LIBCPP_HIDE_FROM_ABI _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
1293 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& emplace(initializer_list<_Up> __il, _Args&&... __args) {
12791294 return __impl_.template __emplace<_Ip>(__il, std::forward<_Args>(__args)...);
12801295 }
12811296
......@@ -1289,7 +1304,7 @@ public:
12891304 enable_if_t< __all<(__dependent_type<is_move_constructible<_Types>, _Dummy>::value &&
12901305 __dependent_type<is_swappable<_Types>, _Dummy>::value)...>::value,
12911306 int> = 0>
1292 _LIBCPP_HIDE_FROM_ABI void swap(variant& __that) noexcept(
1307 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(variant& __that) noexcept(
12931308 __all<(is_nothrow_move_constructible_v<_Types> && is_nothrow_swappable_v<_Types>)...>::value) {
12941309 __impl_.__swap(__that.__impl_);
12951310 }
......@@ -1343,8 +1358,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr au
13431358
13441359template <size_t _Ip, class... _Types>
13451360_LIBCPP_HIDE_FROM_ABI
1346 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
1347 get(variant<_Types...>& __v) {
1361_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
1362get(variant<_Types...>& __v) {
13481363 static_assert(_Ip < sizeof...(_Types));
13491364 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
13501365 return std::__generic_get<_Ip>(__v);
......@@ -1352,8 +1367,8 @@ _LIBCPP_HIDE_FROM_ABI
13521367
13531368template <size_t _Ip, class... _Types>
13541369_LIBCPP_HIDE_FROM_ABI
1355 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
1356 get(variant<_Types...>&& __v) {
1370_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
1371get(variant<_Types...>&& __v) {
13571372 static_assert(_Ip < sizeof...(_Types));
13581373 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
13591374 return std::__generic_get<_Ip>(std::move(__v));
......@@ -1361,8 +1376,8 @@ _LIBCPP_HIDE_FROM_ABI
13611376
13621377template <size_t _Ip, class... _Types>
13631378_LIBCPP_HIDE_FROM_ABI
1364 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
1365 get(const variant<_Types...>& __v) {
1379_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
1380get(const variant<_Types...>& __v) {
13661381 static_assert(_Ip < sizeof...(_Types));
13671382 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
13681383 return std::__generic_get<_Ip>(__v);
......@@ -1370,8 +1385,8 @@ _LIBCPP_HIDE_FROM_ABI
13701385
13711386template <size_t _Ip, class... _Types>
13721387_LIBCPP_HIDE_FROM_ABI
1373 _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
1374 get(const variant<_Types...>&& __v) {
1388_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
1389get(const variant<_Types...>&& __v) {
13751390 static_assert(_Ip < sizeof...(_Types));
13761391 static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
13771392 return std::__generic_get<_Ip>(std::move(__v));
......@@ -1572,9 +1587,9 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
15721587# endif
15731588
15741589template <class... _Types>
1575_LIBCPP_HIDE_FROM_ABI auto
1576swap(variant<_Types...>& __lhs, variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs)))
1577 -> decltype(__lhs.swap(__rhs)) {
1590_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto
1591swap(variant<_Types...>& __lhs,
1592 variant<_Types...>& __rhs) noexcept(noexcept(__lhs.swap(__rhs))) -> decltype(__lhs.swap(__rhs)) {
15781593 return __lhs.swap(__rhs);
15791594}
15801595
......@@ -1626,6 +1641,7 @@ _LIBCPP_POP_MACROS
16261641
16271642#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
16281643# include <exception>
1644# include <tuple>
16291645# include <type_traits>
16301646# include <typeinfo>
16311647# include <utility>
lib/libcxx/include/vector+140-89
......@@ -315,17 +315,19 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
315315#include <__algorithm/remove_if.h>
316316#include <__algorithm/rotate.h>
317317#include <__algorithm/unwrap_iter.h>
318#include <__assert> // all public C++ headers provide the assertion handler
319#include <__availability>
318#include <__assert>
320319#include <__bit_reference>
321320#include <__concepts/same_as.h>
322321#include <__config>
322#include <__debug_utils/sanitizers.h>
323323#include <__format/enable_insertable.h>
324324#include <__format/formatter.h>
325325#include <__format/formatter_bool.h>
326326#include <__functional/hash.h>
327327#include <__functional/unary_function.h>
328#include <__fwd/vector.h>
328329#include <__iterator/advance.h>
330#include <__iterator/bounded_iter.h>
329331#include <__iterator/distance.h>
330332#include <__iterator/iterator_traits.h>
331333#include <__iterator/reverse_iterator.h>
......@@ -346,17 +348,17 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
346348#include <__split_buffer>
347349#include <__type_traits/is_allocator.h>
348350#include <__type_traits/is_constructible.h>
349#include <__type_traits/is_nothrow_move_assignable.h>
351#include <__type_traits/is_nothrow_assignable.h>
350352#include <__type_traits/noexcept_move_assign_container.h>
351353#include <__type_traits/type_identity.h>
352354#include <__utility/exception_guard.h>
353355#include <__utility/forward.h>
356#include <__utility/is_pointer_in_range.h>
354357#include <__utility/move.h>
355358#include <__utility/pair.h>
356359#include <__utility/swap.h>
357360#include <climits>
358361#include <cstring>
359#include <iosfwd> // for forward declaration of vector
360362#include <limits>
361363#include <stdexcept>
362364#include <version>
......@@ -399,19 +401,32 @@ public:
399401 typedef typename __alloc_traits::difference_type difference_type;
400402 typedef typename __alloc_traits::pointer pointer;
401403 typedef typename __alloc_traits::const_pointer const_pointer;
402 // TODO: Implement iterator bounds checking without requiring the global database.
404#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
405 // Users might provide custom allocators, and prior to C++20 we have no existing way to detect whether the allocator's
406 // pointer type is contiguous (though it has to be by the Standard). Using the wrapper type ensures the iterator is
407 // considered contiguous.
408 typedef __bounded_iter<__wrap_iter<pointer>> iterator;
409 typedef __bounded_iter<__wrap_iter<const_pointer>> const_iterator;
410#else
403411 typedef __wrap_iter<pointer> iterator;
404412 typedef __wrap_iter<const_pointer> const_iterator;
413#endif
405414 typedef std::reverse_iterator<iterator> reverse_iterator;
406415 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
407416
408 static_assert((is_same<typename allocator_type::value_type, value_type>::value),
417 // A vector containers the following members which may be trivially relocatable:
418 // - pointer: may be trivially relocatable, so it's checked
419 // - allocator_type: may be trivially relocatable, so it's checked
420 // vector doesn't contain any self-references, so it's trivially relocatable if its members are.
421 using __trivially_relocatable = __conditional_t<
422 __libcpp_is_trivially_relocatable<pointer>::value && __libcpp_is_trivially_relocatable<allocator_type>::value,
423 vector,
424 void>;
425
426 static_assert(__check_valid_allocator<allocator_type>::value, "");
427 static_assert(is_same<typename allocator_type::value_type, value_type>::value,
409428 "Allocator::value_type must be same type as value_type");
410429
411 static_assert(is_same<allocator_type, __rebind_alloc<__alloc_traits, value_type> >::value,
412 "[allocator.requirements] states that rebinding an allocator to the same type should result in the "
413 "original allocator");
414
415430 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector()
416431 _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) {}
417432 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(const allocator_type& __a)
......@@ -422,13 +437,38 @@ public:
422437#endif
423438 : __end_cap_(nullptr, __a) {
424439 }
425 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n);
440
441 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n) {
442 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
443 if (__n > 0) {
444 __vallocate(__n);
445 __construct_at_end(__n);
446 }
447 __guard.__complete();
448 }
449
426450#if _LIBCPP_STD_VER >= 14
427 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a);
451 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit vector(size_type __n, const allocator_type& __a)
452 : __end_cap_(nullptr, __a) {
453 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
454 if (__n > 0) {
455 __vallocate(__n);
456 __construct_at_end(__n);
457 }
458 __guard.__complete();
459 }
428460#endif
429 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x);
430461
431 template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
462 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector(size_type __n, const value_type& __x) {
463 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
464 if (__n > 0) {
465 __vallocate(__n);
466 __construct_at_end(__n, __x);
467 }
468 __guard.__complete();
469 }
470
471 template <__enable_if_t<__is_allocator<_Allocator>::value, int> = 0>
432472 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
433473 vector(size_type __n, const value_type& __x, const allocator_type& __a)
434474 : __end_cap_(nullptr, __a) {
......@@ -527,7 +567,7 @@ public:
527567 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
528568 vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
529569 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI vector& operator=(vector&& __x)
530 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
570 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);
531571
532572 template <class _InputIterator,
533573 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
......@@ -597,7 +637,7 @@ public:
597637 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type capacity() const _NOEXCEPT {
598638 return static_cast<size_type>(__end_cap() - this->__begin_);
599639 }
600 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
640 _LIBCPP_NODISCARD _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
601641 return this->__begin_ == this->__end_;
602642 }
603643 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT;
......@@ -641,11 +681,11 @@ public:
641681 template <class... _Args>
642682 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
643683#if _LIBCPP_STD_VER >= 17
644 reference
645 emplace_back(_Args&&... __args);
684 reference
685 emplace_back(_Args&&... __args);
646686#else
647 void
648 emplace_back(_Args&&... __args);
687 void
688 emplace_back(_Args&&... __args);
649689#endif
650690
651691#if _LIBCPP_STD_VER >= 23
......@@ -717,7 +757,7 @@ public:
717757#if _LIBCPP_STD_VER >= 14
718758 _NOEXCEPT;
719759#else
720 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
760 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
721761#endif
722762
723763 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
......@@ -795,12 +835,39 @@ private:
795835
796836 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n);
797837 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __append(size_type __n, const_reference __x);
838
798839 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI iterator __make_iter(pointer __p) _NOEXCEPT {
840#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
841 // Bound the iterator according to the capacity, rather than the size.
842 //
843 // Vector guarantees that iterators stay valid as long as no reallocation occurs even if new elements are inserted
844 // into the container; for these cases, we need to make sure that the newly-inserted elements can be accessed
845 // through the bounded iterator without failing checks. The downside is that the bounded iterator won't catch
846 // access that is logically out-of-bounds, i.e., goes beyond the size, but is still within the capacity. With the
847 // current implementation, there is no connection between a bounded iterator and its associated container, so we
848 // don't have a way to update existing valid iterators when the container is resized and thus have to go with
849 // a laxer approach.
850 return std::__make_bounded_iter(
851 std::__wrap_iter<pointer>(__p),
852 std::__wrap_iter<pointer>(this->__begin_),
853 std::__wrap_iter<pointer>(this->__end_cap()));
854#else
799855 return iterator(__p);
856#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
800857 }
858
801859 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_iterator __make_iter(const_pointer __p) const _NOEXCEPT {
860#ifdef _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
861 // Bound the iterator according to the capacity, rather than the size.
862 return std::__make_bounded_iter(
863 std::__wrap_iter<const_pointer>(__p),
864 std::__wrap_iter<const_pointer>(this->__begin_),
865 std::__wrap_iter<const_pointer>(this->__end_cap()));
866#else
802867 return const_iterator(__p);
868#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
803869 }
870
804871 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
805872 __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
806873 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
......@@ -831,17 +898,9 @@ private:
831898 // For more details, see the "Using libc++" documentation page or
832899 // the documentation for __sanitizer_annotate_contiguous_container.
833900
834 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_contiguous_container(
835 const void* __old_mid, const void* __new_mid) const {
836 (void)__old_mid;
837 (void)__new_mid;
838#ifndef _LIBCPP_HAS_NO_ASAN
839 const void* __beg = data();
840 const void* __end = data() + capacity();
841 if (!__libcpp_is_constant_evaluated() && __beg != nullptr &&
842 __asan_annotate_container_with_allocator<_Allocator>::value)
843 __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
844#endif
901 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
902 __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
903 std::__annotate_contiguous_container<_Allocator>(data(), data() + capacity(), __old_mid, __new_mid);
845904 }
846905
847906 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT {
......@@ -878,6 +937,7 @@ private:
878937 __v_.__annotate_increase(__n);
879938#endif
880939 }
940
881941 _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() {
882942 __v_.__end_ = __pos_;
883943#ifndef _LIBCPP_HAS_NO_ASAN
......@@ -891,7 +951,6 @@ private:
891951 pointer __pos_;
892952 const_pointer const __new_end_;
893953
894 private:
895954 _ConstructTransaction(_ConstructTransaction const&) = delete;
896955 _ConstructTransaction& operator=(_ConstructTransaction const&) = delete;
897956 };
......@@ -982,14 +1041,18 @@ template <ranges::input_range _Range,
9821041vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_t<_Range>, _Alloc>;
9831042#endif
9841043
1044// __swap_out_circular_buffer relocates the objects in [__begin_, __end_) into the front of __v and swaps the buffers of
1045// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
1046// function has a strong exception guarantee.
9851047template <class _Tp, class _Allocator>
9861048_LIBCPP_CONSTEXPR_SINCE_CXX20 void
9871049vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v) {
9881050 __annotate_delete();
989 using _RevIter = std::reverse_iterator<pointer>;
990 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
991 __alloc(), _RevIter(__end_), _RevIter(__begin_), _RevIter(__v.__begin_))
992 .base();
1051 auto __new_begin = __v.__begin_ - (__end_ - __begin_);
1052 std::__uninitialized_allocator_relocate(
1053 __alloc(), std::__to_address(__begin_), std::__to_address(__end_), std::__to_address(__new_begin));
1054 __v.__begin_ = __new_begin;
1055 __end_ = __begin_; // All the objects have been destroyed by relocating them.
9931056 std::swap(this->__begin_, __v.__begin_);
9941057 std::swap(this->__end_, __v.__end_);
9951058 std::swap(this->__end_cap(), __v.__end_cap());
......@@ -997,22 +1060,35 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
9971060 __annotate_new(size());
9981061}
9991062
1063// __swap_out_circular_buffer relocates the objects in [__begin_, __p) into the front of __v, the objects in
1064// [__p, __end_) into the back of __v and swaps the buffers of *this and __v. It is assumed that __v provides space for
1065// exactly (__p - __begin_) objects in the front and space for at least (__end_ - __p) objects in the back. This
1066// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
10001067template <class _Tp, class _Allocator>
10011068_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
10021069vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p) {
10031070 __annotate_delete();
1004 pointer __r = __v.__begin_;
1005 using _RevIter = std::reverse_iterator<pointer>;
1006 __v.__begin_ = std::__uninitialized_allocator_move_if_noexcept(
1007 __alloc(), _RevIter(__p), _RevIter(__begin_), _RevIter(__v.__begin_))
1008 .base();
1009 __v.__end_ = std::__uninitialized_allocator_move_if_noexcept(__alloc(), __p, __end_, __v.__end_);
1071 pointer __ret = __v.__begin_;
1072
1073 // Relocate [__p, __end_) first to avoid having a hole in [__begin_, __end_)
1074 // in case something in [__begin_, __p) throws.
1075 std::__uninitialized_allocator_relocate(
1076 __alloc(), std::__to_address(__p), std::__to_address(__end_), std::__to_address(__v.__end_));
1077 __v.__end_ += (__end_ - __p);
1078 __end_ = __p; // The objects in [__p, __end_) have been destroyed by relocating them.
1079 auto __new_begin = __v.__begin_ - (__p - __begin_);
1080
1081 std::__uninitialized_allocator_relocate(
1082 __alloc(), std::__to_address(__begin_), std::__to_address(__p), std::__to_address(__new_begin));
1083 __v.__begin_ = __new_begin;
1084 __end_ = __begin_; // All the objects have been destroyed by relocating them.
1085
10101086 std::swap(this->__begin_, __v.__begin_);
10111087 std::swap(this->__end_, __v.__end_);
10121088 std::swap(this->__end_cap(), __v.__end_cap());
10131089 __v.__first_ = __v.__begin_;
10141090 __annotate_new(size());
1015 return __r;
1091 return __ret;
10161092}
10171093
10181094template <class _Tp, class _Allocator>
......@@ -1114,39 +1190,6 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__append(size_type _
11141190 }
11151191}
11161192
1117template <class _Tp, class _Allocator>
1118_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n) {
1119 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1120 if (__n > 0) {
1121 __vallocate(__n);
1122 __construct_at_end(__n);
1123 }
1124 __guard.__complete();
1125}
1126
1127#if _LIBCPP_STD_VER >= 14
1128template <class _Tp, class _Allocator>
1129_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
1130 : __end_cap_(nullptr, __a) {
1131 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1132 if (__n > 0) {
1133 __vallocate(__n);
1134 __construct_at_end(__n);
1135 }
1136 __guard.__complete();
1137}
1138#endif
1139
1140template <class _Tp, class _Allocator>
1141_LIBCPP_CONSTEXPR_SINCE_CXX20 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x) {
1142 auto __guard = std::__make_exception_guard(__destroy_vector(*this));
1143 if (__n > 0) {
1144 __vallocate(__n);
1145 __construct_at_end(__n, __x);
1146 }
1147 __guard.__complete();
1148}
1149
11501193template <class _Tp, class _Allocator>
11511194template <class _InputIterator,
11521195 __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value &&
......@@ -1263,7 +1306,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
12631306template <class _Tp, class _Allocator>
12641307_LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI vector<_Tp, _Allocator>&
12651308vector<_Tp, _Allocator>::operator=(vector&& __x)
1266 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
1309 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
12671310 __move_assign(__x, integral_constant<bool, __alloc_traits::propagate_on_container_move_assignment::value>());
12681311 return *this;
12691312}
......@@ -1435,7 +1478,11 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE
14351478#endif // _LIBCPP_HAS_NO_EXCEPTIONS
14361479 allocator_type& __a = this->__alloc();
14371480 __split_buffer<value_type, allocator_type&> __v(size(), size(), __a);
1438 __swap_out_circular_buffer(__v);
1481 // The Standard mandates shrink_to_fit() does not increase the capacity.
1482 // With equal capacity keep the existing buffer. This avoids extra work
1483 // due to swapping the elements.
1484 if (__v.capacity() < capacity())
1485 __swap_out_circular_buffer(__v);
14391486#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
14401487 } catch (...) {
14411488 }
......@@ -1563,14 +1610,13 @@ template <class _Tp, class _Allocator>
15631610_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::iterator
15641611vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x) {
15651612 pointer __p = this->__begin_ + (__position - begin());
1566 // We can't compare unrelated pointers inside constant expressions
1567 if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap()) {
1613 if (this->__end_ < this->__end_cap()) {
15681614 if (__p == this->__end_) {
15691615 __construct_one_at_end(__x);
15701616 } else {
15711617 __move_range(__p, this->__end_, __p + 1);
15721618 const_pointer __xr = pointer_traits<const_pointer>::pointer_to(__x);
1573 if (__p <= __xr && __xr < this->__end_)
1619 if (std::__is_pointer_in_range(std::__to_address(__p), std::__to_address(__end_), std::addressof(__x)))
15741620 ++__xr;
15751621 *__p = *__xr;
15761622 }
......@@ -1766,7 +1812,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::swap(vector& __x)
17661812#if _LIBCPP_STD_VER >= 14
17671813 _NOEXCEPT
17681814#else
1769 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
1815 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
17701816#endif
17711817{
17721818 _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
......@@ -1952,7 +1998,7 @@ public:
19521998 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
19531999 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
19542000 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector& operator=(vector&& __v)
1955 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
2001 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value);
19562002
19572003 template <class _InputIterator, __enable_if_t<__has_exactly_input_iterator_category<_InputIterator>::value, int> = 0>
19582004 void _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 assign(_InputIterator __first, _InputIterator __last);
......@@ -1989,7 +2035,7 @@ public:
19892035 return __internal_cap_to_external(__cap());
19902036 }
19912037 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type size() const _NOEXCEPT { return __size_; }
1992 _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
2038 _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool empty() const _NOEXCEPT {
19932039 return __size_ == 0;
19942040 }
19952041 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void reserve(size_type __n);
......@@ -2107,7 +2153,7 @@ public:
21072153#if _LIBCPP_STD_VER >= 14
21082154 _NOEXCEPT;
21092155#else
2110 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value);
2156 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
21112157#endif
21122158 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static void swap(reference __x, reference __y) _NOEXCEPT {
21132159 std::swap(__x, __y);
......@@ -2499,7 +2545,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
24992545template <class _Allocator>
25002546inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>&
25012547vector<bool, _Allocator>::operator=(vector&& __v)
2502 _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {
2548 _NOEXCEPT_(__noexcept_move_assign_container<_Allocator, __alloc_traits>::value) {
25032549 __move_assign(__v, integral_constant<bool, __storage_traits::propagate_on_container_move_assignment::value>());
25042550 return *this;
25052551}
......@@ -2769,7 +2815,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::swap(vector& __x)
27692815#if _LIBCPP_STD_VER >= 14
27702816 _NOEXCEPT
27712817#else
2772 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value)
2818 _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>)
27732819#endif
27742820{
27752821 std::swap(this->__begin_, __x.__begin_);
......@@ -2896,7 +2942,7 @@ template <class _Tp, class _Allocator>
28962942_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
28972943operator<=>(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) {
28982944 return std::lexicographical_compare_three_way(
2899 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way<_Tp, _Tp>);
2945 __x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
29002946}
29012947
29022948#endif // _LIBCPP_STD_VER <= 17
......@@ -2972,6 +3018,11 @@ _LIBCPP_POP_MACROS
29723018# include <atomic>
29733019# include <concepts>
29743020# include <cstdlib>
3021# include <iosfwd>
3022# if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
3023# include <locale>
3024# endif
3025# include <tuple>
29753026# include <type_traits>
29763027# include <typeinfo>
29773028# include <utility>
lib/libcxx/include/version+63-26
......@@ -16,7 +16,7 @@
1616Macro name Value Headers
1717__cpp_lib_adaptor_iterator_pair_constructor 202106L <queue> <stack>
1818__cpp_lib_addressof_constexpr 201603L <memory>
19__cpp_lib_allocate_at_least 202106L <memory>
19__cpp_lib_allocate_at_least 202302L <memory>
2020__cpp_lib_allocator_traits_is_always_equal 201411L <deque> <forward_list> <list>
2121 <map> <memory> <scoped_allocator>
2222 <set> <string> <unordered_map>
......@@ -35,13 +35,13 @@ __cpp_lib_atomic_flag_test 201907L <atomic>
3535__cpp_lib_atomic_float 201711L <atomic>
3636__cpp_lib_atomic_is_always_lock_free 201603L <atomic>
3737__cpp_lib_atomic_lock_free_type_aliases 201907L <atomic>
38__cpp_lib_atomic_min_max 202403L <atomic>
3839__cpp_lib_atomic_ref 201806L <atomic>
3940__cpp_lib_atomic_shared_ptr 201711L <atomic>
4041__cpp_lib_atomic_value_initialization 201911L <atomic> <memory>
4142__cpp_lib_atomic_wait 201907L <atomic>
4243__cpp_lib_barrier 201907L <barrier>
43__cpp_lib_bind_back 202306L <functional>
44 202202L // C++23
44__cpp_lib_bind_back 202202L <functional>
4545__cpp_lib_bind_front 202306L <functional>
4646 201907L // C++20
4747__cpp_lib_bit_cast 201806L <bit>
......@@ -70,6 +70,7 @@ __cpp_lib_constexpr_functional 201907L <functional>
7070__cpp_lib_constexpr_iterator 201811L <iterator>
7171__cpp_lib_constexpr_memory 202202L <memory>
7272 201811L // C++20
73__cpp_lib_constexpr_new 202406L <new>
7374__cpp_lib_constexpr_numeric 201911L <numeric>
7475__cpp_lib_constexpr_string 201907L <string>
7576__cpp_lib_constexpr_string_view 201811L <string_view>
......@@ -77,9 +78,18 @@ __cpp_lib_constexpr_tuple 201811L <tuple>
7778__cpp_lib_constexpr_typeinfo 202106L <typeinfo>
7879__cpp_lib_constexpr_utility 201811L <utility>
7980__cpp_lib_constexpr_vector 201907L <vector>
81__cpp_lib_constrained_equality 202403L <optional> <tuple> <utility>
82 <variant>
83__cpp_lib_containers_ranges 202202L <deque> <forward_list> <list>
84 <map> <queue> <set>
85 <stack> <string> <unordered_map>
86 <unordered_set> <vector>
8087__cpp_lib_copyable_function 202306L <functional>
8188__cpp_lib_coroutine 201902L <coroutine>
8289__cpp_lib_debugging 202311L <debugging>
90__cpp_lib_default_template_type_for_algorithm_values 202403L <algorithm> <deque> <forward_list>
91 <list> <ranges> <string>
92 <vector>
8393__cpp_lib_destroying_delete 201806L <new>
8494__cpp_lib_enable_shared_from_this 201603L <memory>
8595__cpp_lib_endian 201907L <bit>
......@@ -91,7 +101,8 @@ __cpp_lib_execution 201902L <execution>
91101 201603L // C++17
92102__cpp_lib_expected 202211L <expected>
93103__cpp_lib_filesystem 201703L <filesystem>
94__cpp_lib_format 202106L <format>
104__cpp_lib_format 202110L <format>
105__cpp_lib_format_path 202403L <filesystem>
95106__cpp_lib_format_ranges 202207L <format>
96107__cpp_lib_format_uchar 202311L <format>
97108__cpp_lib_formatters 202302L <stacktrace> <thread>
......@@ -107,6 +118,7 @@ __cpp_lib_freestanding_variant 202311L <variant>
107118__cpp_lib_fstream_native_handle 202306L <fstream>
108119__cpp_lib_function_ref 202306L <functional>
109120__cpp_lib_gcd_lcm 201606L <numeric>
121__cpp_lib_generate_random 202403L <random>
110122__cpp_lib_generic_associative_lookup 201304L <map> <set>
111123__cpp_lib_generic_unordered_lookup 201811L <unordered_map> <unordered_set>
112124__cpp_lib_hardware_interference_size 201703L <new>
......@@ -114,6 +126,7 @@ __cpp_lib_has_unique_object_representations 201606L <type_traits>
114126__cpp_lib_hazard_pointer 202306L <hazard_pointer>
115127__cpp_lib_hypot 201603L <cmath>
116128__cpp_lib_incomplete_container_elements 201505L <forward_list> <list> <vector>
129__cpp_lib_inplace_vector 202406L <inplace_vector>
117130__cpp_lib_int_pow2 202002L <bit>
118131__cpp_lib_integer_comparison_functions 202002L <utility>
119132__cpp_lib_integer_sequence 201304L <utility>
......@@ -132,6 +145,8 @@ __cpp_lib_is_null_pointer 201309L <type_traits>
132145__cpp_lib_is_pointer_interconvertible 201907L <type_traits>
133146__cpp_lib_is_scoped_enum 202011L <type_traits>
134147__cpp_lib_is_swappable 201603L <type_traits>
148__cpp_lib_is_virtual_base_of 202406L <type_traits>
149__cpp_lib_is_within_lifetime 202306L <type_traits>
135150__cpp_lib_jthread 201911L <stop_token> <thread>
136151__cpp_lib_latch 201907L <latch>
137152__cpp_lib_launder 201606L <new>
......@@ -144,7 +159,8 @@ __cpp_lib_make_unique 201304L <memory>
144159__cpp_lib_map_try_emplace 201411L <map>
145160__cpp_lib_math_constants 201907L <numbers>
146161__cpp_lib_math_special_functions 201603L <cmath>
147__cpp_lib_mdspan 202207L <mdspan>
162__cpp_lib_mdspan 202406L <mdspan>
163 202207L // C++23
148164__cpp_lib_memory_resource 201603L <memory_resource>
149165__cpp_lib_move_iterator_concept 202207L <iterator>
150166__cpp_lib_move_only_function 202110L <functional>
......@@ -158,9 +174,11 @@ __cpp_lib_not_fn 201603L <functional>
158174__cpp_lib_null_iterators 201304L <iterator>
159175__cpp_lib_optional 202110L <optional>
160176 201606L // C++17
177__cpp_lib_optional_range_support 202406L <optional>
161178__cpp_lib_out_ptr 202311L <memory>
162179 202106L // C++23
163180__cpp_lib_parallel_algorithm 201603L <algorithm> <numeric>
181__cpp_lib_philox_engine 202406L <random>
164182__cpp_lib_polymorphic_allocator 201902L <memory_resource>
165183__cpp_lib_print 202207L <ostream> <print>
166184__cpp_lib_quoted_string_io 201304L <iomanip>
......@@ -170,20 +188,21 @@ __cpp_lib_ranges_as_const 202207L <ranges>
170188__cpp_lib_ranges_as_rvalue 202207L <ranges>
171189__cpp_lib_ranges_chunk 202202L <ranges>
172190__cpp_lib_ranges_chunk_by 202202L <ranges>
191__cpp_lib_ranges_concat 202403L <ranges>
192__cpp_lib_ranges_contains 202207L <algorithm>
193__cpp_lib_ranges_find_last 202207L <algorithm>
173194__cpp_lib_ranges_iota 202202L <numeric>
174195__cpp_lib_ranges_join_with 202202L <ranges>
175196__cpp_lib_ranges_repeat 202207L <ranges>
176197__cpp_lib_ranges_slide 202202L <ranges>
177198__cpp_lib_ranges_starts_ends_with 202106L <algorithm>
178__cpp_lib_ranges_to_container 202202L <deque> <forward_list> <list>
179 <map> <queue> <ranges>
180 <set> <stack> <string>
181 <unordered_map> <unordered_set> <vector>
199__cpp_lib_ranges_to_container 202202L <ranges>
182200__cpp_lib_ranges_zip 202110L <ranges> <tuple> <utility>
183201__cpp_lib_ratio 202306L <ratio>
184202__cpp_lib_raw_memory_algorithms 201606L <memory>
185203__cpp_lib_rcu 202306L <rcu>
186204__cpp_lib_reference_from_temporary 202202L <type_traits>
205__cpp_lib_reference_wrapper 202403L <functional>
187206__cpp_lib_remove_cvref 201711L <type_traits>
188207__cpp_lib_result_of_sfinae 201210L <functional> <type_traits>
189208__cpp_lib_robust_nonmodifying_seq_ops 201304L <algorithm>
......@@ -191,6 +210,7 @@ __cpp_lib_sample 201603L <algorithm>
191210__cpp_lib_saturation_arithmetic 202311L <numeric>
192211__cpp_lib_scoped_lock 201703L <mutex>
193212__cpp_lib_semaphore 201907L <semaphore>
213__cpp_lib_senders 202406L <execution>
194214__cpp_lib_shared_mutex 201505L <shared_mutex>
195215__cpp_lib_shared_ptr_arrays 201707L <memory>
196216 201611L // C++17
......@@ -212,7 +232,8 @@ __cpp_lib_stdatomic_h 202011L <stdatomic.h>
212232__cpp_lib_string_contains 202011L <string> <string_view>
213233__cpp_lib_string_resize_and_overwrite 202110L <string>
214234__cpp_lib_string_udls 201304L <string>
215__cpp_lib_string_view 201803L <string> <string_view>
235__cpp_lib_string_view 202403L <string> <string_view>
236 201803L // C++20
216237 201606L // C++17
217238__cpp_lib_submdspan 202306L <mdspan>
218239__cpp_lib_syncbuf 201803L <syncstream>
......@@ -240,12 +261,9 @@ __cpp_lib_unreachable 202202L <utility>
240261__cpp_lib_unwrap_ref 201811L <functional>
241262__cpp_lib_variant 202102L <variant>
242263__cpp_lib_void_t 201411L <type_traits>
243__cpp_lib_within_lifetime 202306L <type_traits>
244264
245265*/
246266
247#include <__assert> // all public C++ headers provide the assertion handler
248#include <__availability>
249267#include <__config>
250268
251269#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
......@@ -351,7 +369,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
351369# define __cpp_lib_atomic_flag_test 201907L
352370// # define __cpp_lib_atomic_float 201711L
353371# define __cpp_lib_atomic_lock_free_type_aliases 201907L
354// # define __cpp_lib_atomic_ref 201806L
372# define __cpp_lib_atomic_ref 201806L
355373// # define __cpp_lib_atomic_shared_ptr 201711L
356374# define __cpp_lib_atomic_value_initialization 201911L
357375# if _LIBCPP_AVAILABILITY_HAS_SYNC
......@@ -388,7 +406,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
388406# define __cpp_lib_erase_if 202002L
389407# undef __cpp_lib_execution
390408// # define __cpp_lib_execution 201902L
391// # define __cpp_lib_format 202106L
409# define __cpp_lib_format 202110L
392410# define __cpp_lib_format_uchar 202311L
393411# define __cpp_lib_generic_unordered_lookup 201811L
394412# define __cpp_lib_int_pow2 202002L
......@@ -428,7 +446,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
428446# if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM)
429447# define __cpp_lib_syncbuf 201803L
430448# endif
431// # define __cpp_lib_three_way_comparison 201907L
449# define __cpp_lib_three_way_comparison 201907L
432450# define __cpp_lib_to_address 201711L
433451# define __cpp_lib_to_array 201907L
434452# define __cpp_lib_type_identity 201806L
......@@ -437,9 +455,9 @@ __cpp_lib_within_lifetime 202306L <type_traits>
437455
438456#if _LIBCPP_STD_VER >= 23
439457# define __cpp_lib_adaptor_iterator_pair_constructor 202106L
440# define __cpp_lib_allocate_at_least 202106L
458# define __cpp_lib_allocate_at_least 202302L
441459// # define __cpp_lib_associative_heterogeneous_erasure 202110L
442// # define __cpp_lib_bind_back 202202L
460# define __cpp_lib_bind_back 202202L
443461# define __cpp_lib_byteswap 202110L
444462# define __cpp_lib_constexpr_bitset 202207L
445463# define __cpp_lib_constexpr_charconv 202207L
......@@ -447,6 +465,7 @@ __cpp_lib_within_lifetime 202306L <type_traits>
447465# undef __cpp_lib_constexpr_memory
448466# define __cpp_lib_constexpr_memory 202202L
449467# define __cpp_lib_constexpr_typeinfo 202106L
468# define __cpp_lib_containers_ranges 202202L
450469# define __cpp_lib_expected 202211L
451470# define __cpp_lib_format_ranges 202207L
452471// # define __cpp_lib_formatters 202302L
......@@ -455,20 +474,23 @@ __cpp_lib_within_lifetime 202306L <type_traits>
455474# define __cpp_lib_ios_noreplace 202207L
456475# define __cpp_lib_is_scoped_enum 202011L
457476# define __cpp_lib_mdspan 202207L
477# define __cpp_lib_modules 202207L
458478// # define __cpp_lib_move_only_function 202110L
459479# undef __cpp_lib_optional
460480# define __cpp_lib_optional 202110L
461// # define __cpp_lib_out_ptr 202106L
481# define __cpp_lib_out_ptr 202106L
462482# define __cpp_lib_print 202207L
463483// # define __cpp_lib_ranges_as_const 202207L
464484# define __cpp_lib_ranges_as_rvalue 202207L
465485// # define __cpp_lib_ranges_chunk 202202L
466486# define __cpp_lib_ranges_chunk_by 202202L
487# define __cpp_lib_ranges_contains 202207L
488# define __cpp_lib_ranges_find_last 202207L
467489// # define __cpp_lib_ranges_iota 202202L
468490// # define __cpp_lib_ranges_join_with 202202L
469491# define __cpp_lib_ranges_repeat 202207L
470492// # define __cpp_lib_ranges_slide 202202L
471// # define __cpp_lib_ranges_starts_ends_with 202106L
493# define __cpp_lib_ranges_starts_ends_with 202106L
472494# define __cpp_lib_ranges_to_container 202202L
473495// # define __cpp_lib_ranges_zip 202110L
474496// # define __cpp_lib_reference_from_temporary 202202L
......@@ -477,7 +499,6 @@ __cpp_lib_within_lifetime 202306L <type_traits>
477499# define __cpp_lib_stdatomic_h 202011L
478500# define __cpp_lib_string_contains 202011L
479501# define __cpp_lib_string_resize_and_overwrite 202110L
480// # define __cpp_lib_to_string 202306L
481502# define __cpp_lib_to_underlying 202102L
482503// # define __cpp_lib_tuple_like 202207L
483504# define __cpp_lib_unreachable 202202L
......@@ -485,13 +506,16 @@ __cpp_lib_within_lifetime 202306L <type_traits>
485506
486507#if _LIBCPP_STD_VER >= 26
487508// # define __cpp_lib_associative_heterogeneous_insertion 202306L
488# undef __cpp_lib_bind_back
489// # define __cpp_lib_bind_back 202306L
509// # define __cpp_lib_atomic_min_max 202403L
490510# undef __cpp_lib_bind_front
491511# define __cpp_lib_bind_front 202306L
492512# define __cpp_lib_bitset 202306L
513// # define __cpp_lib_constexpr_new 202406L
514// # define __cpp_lib_constrained_equality 202403L
493515// # define __cpp_lib_copyable_function 202306L
494516// # define __cpp_lib_debugging 202311L
517// # define __cpp_lib_default_template_type_for_algorithm_values 202403L
518// # define __cpp_lib_format_path 202403L
495519// # define __cpp_lib_freestanding_algorithm 202311L
496520// # define __cpp_lib_freestanding_array 202311L
497521// # define __cpp_lib_freestanding_cstring 202306L
......@@ -504,24 +528,37 @@ __cpp_lib_within_lifetime 202306L <type_traits>
504528# define __cpp_lib_fstream_native_handle 202306L
505529# endif
506530// # define __cpp_lib_function_ref 202306L
531// # define __cpp_lib_generate_random 202403L
507532// # define __cpp_lib_hazard_pointer 202306L
533// # define __cpp_lib_inplace_vector 202406L
534// # define __cpp_lib_is_virtual_base_of 202406L
535// # define __cpp_lib_is_within_lifetime 202306L
508536// # define __cpp_lib_linalg 202311L
537# undef __cpp_lib_mdspan
538# define __cpp_lib_mdspan 202406L
539// # define __cpp_lib_optional_range_support 202406L
509540# undef __cpp_lib_out_ptr
510// # define __cpp_lib_out_ptr 202311L
541# define __cpp_lib_out_ptr 202311L
542// # define __cpp_lib_philox_engine 202406L
543// # define __cpp_lib_ranges_concat 202403L
511544# define __cpp_lib_ratio 202306L
512545// # define __cpp_lib_rcu 202306L
546# define __cpp_lib_reference_wrapper 202403L
513547# define __cpp_lib_saturation_arithmetic 202311L
548// # define __cpp_lib_senders 202406L
514549// # define __cpp_lib_smart_ptr_owner_equality 202306L
515550# define __cpp_lib_span_at 202311L
516551# define __cpp_lib_span_initializer_list 202311L
517// # define __cpp_lib_sstream_from_string_view 202306L
552# define __cpp_lib_sstream_from_string_view 202306L
553# undef __cpp_lib_string_view
554# define __cpp_lib_string_view 202403L
518555// # define __cpp_lib_submdspan 202306L
519556// # define __cpp_lib_text_encoding 202306L
520557# undef __cpp_lib_to_chars
521558// # define __cpp_lib_to_chars 202306L
559// # define __cpp_lib_to_string 202306L
522560# undef __cpp_lib_tuple_like
523561// # define __cpp_lib_tuple_like 202311L
524// # define __cpp_lib_within_lifetime 202306L
525562#endif
526563
527564// clang-format on
lib/libcxx/src/atomic.cpp+16-11
......@@ -69,17 +69,20 @@ extern "C" int __ulock_wait(
6969 uint32_t operation, void* addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */
7070extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value);
7171
72# define UL_COMPARE_AND_WAIT 1
72// https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ulock.h#L82
73# define UL_COMPARE_AND_WAIT64 5
7374# define ULF_WAKE_ALL 0x00000100
7475
7576static void
7677__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
77 __ulock_wait(UL_COMPARE_AND_WAIT, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0);
78 static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waiting on 8 bytes value");
79 __ulock_wait(UL_COMPARE_AND_WAIT64, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0);
7880}
7981
8082static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
83 static_assert(sizeof(__cxx_atomic_contention_t) == 8, "Waking up on 8 bytes value");
8184 __ulock_wake(
82 UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
85 UL_COMPARE_AND_WAIT64 | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
8386}
8487
8588#elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8
......@@ -166,17 +169,18 @@ static void __libcpp_atomic_notify(void const volatile* __location) {
166169 &__entry->__platform_state,
167170 false /* when laundering, we can't handle notify_one */);
168171}
169_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) {
172_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) noexcept {
170173 __libcpp_atomic_notify(__location);
171174}
172_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) {
175_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) noexcept {
173176 __libcpp_atomic_notify(__location);
174177}
175_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) {
178_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) noexcept {
176179 auto const __entry = __libcpp_contention_state(__location);
177180 return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state);
178181}
179_LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) {
182_LIBCPP_EXPORTED_FROM_ABI void
183__libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) noexcept {
180184 auto const __entry = __libcpp_contention_state(__location);
181185 __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value);
182186}
......@@ -184,18 +188,19 @@ _LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __locat
184188/* When the incoming atomic happens to be the platform wait size, we still need to use the
185189 table for the contention detection, but we can use the atomic directly for the wait. */
186190
187_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) {
191_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) noexcept {
188192 __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true);
189193}
190_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) {
194_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) noexcept {
191195 __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false);
192196}
197// This function is never used, but still exported for ABI compatibility.
193198_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
194__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) {
199__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) noexcept {
195200 return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location);
196201}
197202_LIBCPP_EXPORTED_FROM_ABI void
198__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) {
203__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) noexcept {
199204 __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value);
200205}
201206
lib/libcxx/src/barrier.cpp+11-11
......@@ -21,17 +21,17 @@ public:
2121 } __tickets[64];
2222 };
2323
24 ptrdiff_t& __expected;
25 unique_ptr<__state_t[]> __state;
24 ptrdiff_t& __expected_;
25 unique_ptr<__state_t[]> __state_;
2626
27 _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) {
27 _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected_(__expected) {
2828 size_t const __count = (__expected + 1) >> 1;
29 __state = unique_ptr<__state_t[]>(new __state_t[__count]);
29 __state_ = unique_ptr<__state_t[]>(new __state_t[__count]);
3030 }
3131 _LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) {
3232 __barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2;
33 size_t __current_expected = __expected,
34 __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
33 size_t __current_expected = __expected_,
34 __current = hash<thread::id>()(this_thread::get_id()) % ((__expected_ + 1) >> 1);
3535 for (int __round = 0;; ++__round) {
3636 if (__current_expected <= 1)
3737 return true;
......@@ -41,14 +41,14 @@ public:
4141 __current = 0;
4242 __barrier_phase_t expect = __old_phase;
4343 if (__current == __last_node && (__current_expected & 1)) {
44 if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
44 if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
4545 expect, __full_step, memory_order_acq_rel))
4646 break; // I'm 1 in 1, go to next __round
47 } else if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
47 } else if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
4848 expect, __half_step, memory_order_acq_rel)) {
4949 return false; // I'm 1 in 2, done with arrival
5050 } else if (expect == __half_step) {
51 if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
51 if (__state_[__current].__tickets[__round].__phase.compare_exchange_strong(
5252 expect, __full_step, memory_order_acq_rel))
5353 break; // I'm 2 in 2, go to next __round
5454 }
......@@ -63,10 +63,10 @@ _LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorith
6363 return new __barrier_algorithm_base(__expected);
6464}
6565_LIBCPP_EXPORTED_FROM_ABI bool
66__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) {
66__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) noexcept {
6767 return __barrier->__arrive(__old_phase);
6868}
69_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) {
69_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) noexcept {
7070 delete __barrier;
7171}
7272
lib/libcxx/src/call_once.cpp+1-1
......@@ -10,7 +10,7 @@
1010#include <__utility/exception_guard.h>
1111
1212#ifndef _LIBCPP_HAS_NO_THREADS
13# include <__threading_support>
13# include <__thread/support.h>
1414#endif
1515
1616#include "include/atomic_support.h"
lib/libcxx/src/chrono.cpp+2-2
......@@ -77,8 +77,8 @@ typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME);
7777class GetSystemTimeInit {
7878public:
7979 GetSystemTimeInit() {
80 fp =
81 (GetSystemTimeAsFileTimePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
80 fp = (GetSystemTimeAsFileTimePtr)(void*)GetProcAddress(
81 GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
8282 if (fp == nullptr)
8383 fp = GetSystemTimeAsFileTime;
8484 }
lib/libcxx/src/condition_variable_destructor.cpp+1-1
......@@ -12,7 +12,7 @@
1212// definition is only provided for ABI compatibility.
1313
1414#include <__config>
15#include <__threading_support>
15#include <__thread/support.h>
1616
1717#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION)
1818# define NEEDS_CONDVAR_DESTRUCTOR
lib/libcxx/src/expected.cpp created+13
......@@ -0,0 +1,13 @@
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 <expected>
10
11_LIBCPP_BEGIN_NAMESPACE_STD
12const char* bad_expected_access<void>::what() const noexcept { return "bad access to std::expected"; }
13_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/chrono_exception.cpp created+22
......@@ -0,0 +1,22 @@
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 <chrono>
10
11_LIBCPP_BEGIN_NAMESPACE_STD
12
13namespace chrono {
14
15_LIBCPP_AVAILABILITY_TZDB
16_LIBCPP_EXPORTED_FROM_ABI nonexistent_local_time::~nonexistent_local_time() = default; // key function
17_LIBCPP_AVAILABILITY_TZDB
18_LIBCPP_EXPORTED_FROM_ABI ambiguous_local_time::~ambiguous_local_time() = default; // key function
19
20} // namespace chrono
21
22_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/include/tzdb/time_zone_private.h created+57
......@@ -0,0 +1,57 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
13#define _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
14
15#include <chrono>
16#include <string>
17#include <vector>
18
19#include "types_private.h"
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace chrono {
24
25class time_zone::__impl {
26public:
27 explicit _LIBCPP_HIDE_FROM_ABI __impl(string&& __name, const __tz::__rules_storage_type& __rules_db)
28 : __name_(std::move(__name)), __rules_db_(__rules_db) {}
29
30 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI string_view __name() const noexcept { return __name_; }
31
32 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI vector<__tz::__continuation>& __continuations() { return __continuations_; }
33 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const vector<__tz::__continuation>& __continuations() const {
34 return __continuations_;
35 }
36
37 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI const __tz::__rules_storage_type& __rules_db() const { return __rules_db_; }
38
39private:
40 string __name_;
41 // Note the first line has a name + __continuation, the other lines
42 // are just __continuations. So there is always at least one item in
43 // the vector.
44 vector<__tz::__continuation> __continuations_;
45
46 // Continuations often depend on a set of rules. The rules are stored in
47 // parallel data structurs in tzdb_list. From the time_zone it's not possible
48 // to find its associated tzdb entry and thus not possible to find its
49 // associated rules. Therefore a link to the rules in stored in this class.
50 const __tz::__rules_storage_type& __rules_db_;
51};
52
53} // namespace chrono
54
55_LIBCPP_END_NAMESPACE_STD
56
57#endif // _LIBCPP_SRC_INCLUDE_TZDB_TIME_ZONE_PRIVATE_H
lib/libcxx/src/experimental/include/tzdb/types_private.h created+117
......@@ -0,0 +1,117 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
11
12#ifndef __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H
13#define __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H
14
15#include <chrono>
16#include <string>
17#include <utility>
18#include <variant>
19#include <vector>
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23// TODO TZDB
24// The helper classes in this header have no constructor but are loaded with
25// dedicated parse functions. In the original design this header was public and
26// the parsing was done in the dylib. In that design having constructors would
27// expand the ABI interface. Since this header is now in the dylib that design
28// should be reconsidered. (For now the design is kept as is, in case this
29// header needs to be public for unforseen reasons.)
30
31namespace chrono::__tz {
32
33// Sun>=8 first Sunday on or after the eighth
34// Sun<=25 last Sunday on or before the 25th
35struct __constrained_weekday {
36 [[nodiscard]] _LIBCPP_HIDE_FROM_ABI year_month_day operator()(year __year, month __month) const {
37 auto __result = static_cast<sys_days>(year_month_day{__year, __month, __day});
38 weekday __wd{static_cast<sys_days>(__result)};
39
40 if (__comparison == __le)
41 __result -= __wd - __weekday;
42 else
43 __result += __weekday - __wd;
44
45 return __result;
46 }
47
48 weekday __weekday;
49 enum __comparison_t { __le, __ge } __comparison;
50 day __day;
51};
52
53// The on field has a few alternative presentations
54// 5 the fifth of the month
55// lastSun the last Sunday in the month
56// lastMon the last Monday in the month
57// Sun>=8 first Sunday on or after the eighth
58// Sun<=25 last Sunday on or before the 25th
59using __on = variant<day, weekday_last, __constrained_weekday>;
60
61enum class __clock { __local, __standard, __universal };
62
63struct __at {
64 seconds __time{0};
65 __tz::__clock __clock{__tz::__clock::__local};
66};
67
68struct __save {
69 seconds __time;
70 bool __is_dst;
71};
72
73// The names of the fields match the fields of a Rule.
74struct __rule {
75 year __from;
76 year __to;
77 month __in;
78 __tz::__on __on;
79 __tz::__at __at;
80 __tz::__save __save;
81 string __letters;
82};
83
84using __rules_storage_type = std::vector<std::pair<string, vector<__tz::__rule>>>; // TODO TZDB use flat_map;
85
86struct __continuation {
87 // Non-owning link to the RULE entries.
88 __tz::__rules_storage_type* __rule_database_;
89
90 seconds __stdoff;
91
92 // The RULES is either a SAVE or a NAME.
93 // The size_t is used as cache. After loading the rules they are
94 // sorted and remain stable, then an index in the vector can be
95 // used.
96 // If this field contains - then standard time always
97 // applies. This is indicated by the monostate.
98 // TODO TZDB Investigate implantation the size_t based caching.
99 using __rules_t = variant<monostate, __tz::__save, string /*, size_t*/>;
100
101 __rules_t __rules;
102
103 string __format;
104 // TODO TZDB the until field can contain more than just a year.
105 // Parts of the UNTIL, the optional parts are default initialized
106 // optional<year> __until_;
107 year __year = chrono::year::min();
108 month __in{January};
109 __tz::__on __on{chrono::day{1}};
110 __tz::__at __at{chrono::seconds{0}, __tz::__clock::__local};
111};
112
113} // namespace chrono::__tz
114
115_LIBCPP_END_NAMESPACE_STD
116
117#endif // __LIBCPP_SRC_INCLUDE_TZDB_TYPES_PRIVATE_H
lib/libcxx/src/experimental/include/tzdb/tzdb_list_private.h created+104
......@@ -0,0 +1,104 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#ifndef _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H
12#define _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H
13
14#include <__mutex/unique_lock.h>
15#include <forward_list>
16
17// When threads are not available the locking is not required.
18// When threads are available, we use std::mutex over std::shared_mutex
19// due to the increased overhead of std::shared_mutex.
20// See shared_mutex_vs_mutex.bench.cpp
21#ifndef _LIBCPP_HAS_NO_THREADS
22# include <mutex>
23#endif
24
25#include "types_private.h"
26#include "tzdb_private.h"
27
28_LIBCPP_BEGIN_NAMESPACE_STD
29
30namespace chrono {
31
32//===----------------------------------------------------------------------===//
33// Private API
34//===----------------------------------------------------------------------===//
35
36// The tzdb_list stores a list of "tzdb" entries.
37//
38// The public tzdb database does not store the RULE entries of the IANA
39// database. These entries are considered an implementation detail. Since most
40// of the tzdb_list interface is exposed as "a list of tzdb entries" it's not
41// possible to use a helper struct that stores a tzdb and the RULE database.
42// Instead this class stores these in parallel forward lists.
43//
44// Since the nodes of a forward_list are stable it's possible to store pointers
45// and references to these nodes.
46class tzdb_list::__impl {
47public:
48 __impl() { __load_no_lock(); }
49
50 [[nodiscard]] const tzdb& __load() {
51#ifndef _LIBCPP_HAS_NO_THREADS
52 unique_lock __lock{__mutex_};
53#endif
54 __load_no_lock();
55 return __tzdb_.front();
56 }
57
58 using const_iterator = tzdb_list::const_iterator;
59
60 const tzdb& __front() const noexcept {
61#ifndef _LIBCPP_HAS_NO_THREADS
62 unique_lock __lock{__mutex_};
63#endif
64 return __tzdb_.front();
65 }
66
67 const_iterator __erase_after(const_iterator __p) {
68#ifndef _LIBCPP_HAS_NO_THREADS
69 unique_lock __lock{__mutex_};
70#endif
71
72 __rules_.erase_after(std::next(__rules_.cbegin(), std::distance(__tzdb_.cbegin(), __p)));
73 return __tzdb_.erase_after(__p);
74 }
75
76 const_iterator __begin() const noexcept {
77#ifndef _LIBCPP_HAS_NO_THREADS
78 unique_lock __lock{__mutex_};
79#endif
80 return __tzdb_.begin();
81 }
82 const_iterator __end() const noexcept {
83 // forward_list<T>::end does not access the list, so no need to take a lock.
84 return __tzdb_.end();
85 }
86
87private:
88 // Loads the tzdbs
89 // pre: The caller ensures the locking, if needed, is done.
90 void __load_no_lock() { chrono::__init_tzdb(__tzdb_.emplace_front(), __rules_.emplace_front()); }
91
92#ifndef _LIBCPP_HAS_NO_THREADS
93 mutable mutex __mutex_;
94#endif
95 forward_list<tzdb> __tzdb_;
96
97 forward_list<__tz::__rules_storage_type> __rules_;
98};
99
100} // namespace chrono
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // _LIBCPP_SRC_INCLUDE_TZDB_TZDB_LIST_PRIVATE_H
lib/libcxx/src/experimental/include/tzdb/tzdb_private.h created+28
......@@ -0,0 +1,28 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#ifndef _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H
12#define _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H
13
14#include <chrono>
15
16#include "types_private.h"
17
18_LIBCPP_BEGIN_NAMESPACE_STD
19
20namespace chrono {
21
22void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules);
23
24} // namespace chrono
25
26_LIBCPP_END_NAMESPACE_STD
27
28#endif // _LIBCPP_SRC_INCLUDE_TZDB_TZ_PRIVATE_H
lib/libcxx/src/experimental/time_zone.cpp created+1055
......@@ -0,0 +1,1055 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11// TODO TZDB look at optimizations
12//
13// The current algorithm is correct but not efficient. For example, in a named
14// rule based continuation finding the next rule does quite a bit of work,
15// returns the next rule and "forgets" its state. This could be better.
16//
17// It would be possible to cache lookups. If a time for a zone is calculated its
18// sys_info could be kept and the next lookup could test whether the time is in
19// a "known" sys_info. The wording in the Standard hints at this slowness by
20// "suggesting" this could be implemented on the user's side.
21
22// TODO TZDB look at removing quirks
23//
24// The code has some special rules to adjust the timing at the continuation
25// switches. This works correctly, but some of the places feel odd. It would be
26// good to investigate this further and see whether all quirks are needed or
27// that there are better fixes.
28//
29// These quirks often use a 12h interval; this is the scan interval of zdump,
30// which implies there are no sys_info objects with a duration of less than 12h.
31
32#include <algorithm>
33#include <cctype>
34#include <chrono>
35#include <expected>
36#include <map>
37#include <numeric>
38#include <ranges>
39
40#include "include/tzdb/time_zone_private.h"
41#include "include/tzdb/tzdb_list_private.h"
42
43// TODO TZDB remove debug printing
44#ifdef PRINT
45# include <print>
46#endif
47
48_LIBCPP_BEGIN_NAMESPACE_STD
49
50#ifdef PRINT
51template <>
52struct formatter<chrono::sys_info, char> {
53 template <class ParseContext>
54 constexpr typename ParseContext::iterator parse(ParseContext& ctx) {
55 return ctx.begin();
56 }
57
58 template <class FormatContext>
59 typename FormatContext::iterator format(const chrono::sys_info& info, FormatContext& ctx) const {
60 return std::format_to(
61 ctx.out(), "[{}, {}) {:%Q%q} {:%Q%q} {}", info.begin, info.end, info.offset, info.save, info.abbrev);
62 }
63};
64#endif
65
66namespace chrono {
67
68//===----------------------------------------------------------------------===//
69// Details
70//===----------------------------------------------------------------------===//
71
72struct __sys_info {
73 sys_info __info;
74 bool __can_merge; // Can the returned sys_info object be merged with
75};
76
77// Return type for helper function to get a sys_info.
78// - The expected result returns the "best" sys_info object. This object can be
79// before the requested time. Sometimes sys_info objects from different
80// continuations share their offset, save, and abbrev and these objects are
81// merged to one sys_info object. The __can_merge flag determines whether the
82// current result can be merged with the next result.
83// - The unexpected result means no sys_info object was found and the time is
84// the time to be used for the next search iteration.
85using __sys_info_result = expected<__sys_info, sys_seconds>;
86
87template <ranges::forward_range _Range,
88 class _Type,
89 class _Proj = identity,
90 indirect_strict_weak_order<const _Type*, projected<ranges::iterator_t<_Range>, _Proj>> _Comp = ranges::less>
91[[nodiscard]] static ranges::borrowed_iterator_t<_Range>
92__binary_find(_Range&& __r, const _Type& __value, _Comp __comp = {}, _Proj __proj = {}) {
93 auto __end = ranges::end(__r);
94 auto __ret = ranges::lower_bound(ranges::begin(__r), __end, __value, __comp, __proj);
95 if (__ret == __end)
96 return __end;
97
98 // When the value does not match the predicate it's equal and a valid result
99 // was found.
100 return !std::invoke(__comp, __value, std::invoke(__proj, *__ret)) ? __ret : __end;
101}
102
103// Format based on https://data.iana.org/time-zones/tz-how-to.html
104//
105// 1 a time zone abbreviation that is a string of three or more characters that
106// are either ASCII alphanumerics, "+", or "-"
107// 2 the string "%z", in which case the "%z" will be replaced by a numeric time
108// zone abbreviation
109// 3 a pair of time zone abbreviations separated by a slash ('/'), in which
110// case the first string is the abbreviation for the standard time name and
111// the second string is the abbreviation for the daylight saving time name
112// 4 a string containing "%s", in which case the "%s" will be replaced by the
113// text in the appropriate Rule's LETTER column, and the resulting string
114// should be a time zone abbreviation
115//
116// Rule 1 is not strictly validated since America/Barbados uses a two letter
117// abbreviation AT.
118[[nodiscard]] static string
119__format(const __tz::__continuation& __continuation, const string& __letters, seconds __save) {
120 bool __shift = false;
121 string __result;
122 for (char __c : __continuation.__format) {
123 if (__shift) {
124 switch (__c) {
125 case 's':
126 std::ranges::copy(__letters, std::back_inserter(__result));
127 break;
128
129 case 'z': {
130 if (__continuation.__format.size() != 2)
131 std::__throw_runtime_error(
132 std::format("corrupt tzdb FORMAT field: %z should be the entire contents, instead contains '{}'",
133 __continuation.__format)
134 .c_str());
135 chrono::hh_mm_ss __offset{__continuation.__stdoff + __save};
136 if (__offset.is_negative()) {
137 __result += '-';
138 __offset = chrono::hh_mm_ss{-(__continuation.__stdoff + __save)};
139 } else
140 __result += '+';
141
142 if (__offset.minutes() != 0min)
143 std::format_to(std::back_inserter(__result), "{:%H%M}", __offset);
144 else
145 std::format_to(std::back_inserter(__result), "{:%H}", __offset);
146 } break;
147
148 default:
149 std::__throw_runtime_error(
150 std::format("corrupt tzdb FORMAT field: invalid sequence '%{}' found, expected %s or %z", __c).c_str());
151 }
152 __shift = false;
153
154 } else if (__c == '/') {
155 if (__save != 0s)
156 __result.clear();
157 else
158 break;
159
160 } else if (__c == '%') {
161 __shift = true;
162 } else if (__c == '+' || __c == '-' || std::isalnum(__c)) {
163 __result.push_back(__c);
164 } else {
165 std::__throw_runtime_error(
166 std::format(
167 "corrupt tzdb FORMAT field: invalid character '{}' found, expected +, -, or an alphanumeric value", __c)
168 .c_str());
169 }
170 }
171
172 if (__shift)
173 std::__throw_runtime_error("corrupt tzdb FORMAT field: input ended with the start of the escape sequence '%'");
174
175 if (__result.empty())
176 std::__throw_runtime_error("corrupt tzdb FORMAT field: result is empty");
177
178 return __result;
179}
180
181[[nodiscard]] static sys_seconds __to_sys_seconds(year_month_day __ymd, seconds __seconds) {
182 seconds __result = static_cast<sys_days>(__ymd).time_since_epoch() + __seconds;
183 return sys_seconds{__result};
184}
185
186[[nodiscard]] static seconds __at_to_sys_seconds(const __tz::__continuation& __continuation) {
187 switch (__continuation.__at.__clock) {
188 case __tz::__clock::__local:
189 return __continuation.__at.__time - __continuation.__stdoff -
190 std::visit(
191 [](const auto& __value) {
192 using _Tp = decay_t<decltype(__value)>;
193 if constexpr (same_as<_Tp, monostate>)
194 return chrono::seconds{0};
195 else if constexpr (same_as<_Tp, __tz::__save>)
196 return chrono::duration_cast<seconds>(__value.__time);
197 else if constexpr (same_as<_Tp, std::string>)
198 // For a named rule based continuation the SAVE depends on the RULE
199 // active at the end. This should be determined separately.
200 return chrono::seconds{0};
201 else
202 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support
203
204 std::__libcpp_unreachable();
205 },
206 __continuation.__rules);
207
208 case __tz::__clock::__universal:
209 return __continuation.__at.__time;
210
211 case __tz::__clock::__standard:
212 return __continuation.__at.__time - __continuation.__stdoff;
213 }
214 std::__libcpp_unreachable();
215}
216
217[[nodiscard]] static year_month_day __to_year_month_day(year __year, month __month, __tz::__on __on) {
218 return std::visit(
219 [&](const auto& __value) {
220 using _Tp = decay_t<decltype(__value)>;
221 if constexpr (same_as<_Tp, chrono::day>)
222 return year_month_day{__year, __month, __value};
223 else if constexpr (same_as<_Tp, weekday_last>)
224 return year_month_day{static_cast<sys_days>(year_month_weekday_last{__year, __month, __value})};
225 else if constexpr (same_as<_Tp, __tz::__constrained_weekday>)
226 return __value(__year, __month);
227 else
228 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support
229
230 std::__libcpp_unreachable();
231 },
232 __on);
233}
234
235[[nodiscard]] static sys_seconds __until_to_sys_seconds(const __tz::__continuation& __continuation) {
236 // Does UNTIL contain the magic value for the last continuation?
237 if (__continuation.__year == chrono::year::min())
238 return sys_seconds::max();
239
240 year_month_day __ymd = chrono::__to_year_month_day(__continuation.__year, __continuation.__in, __continuation.__on);
241 return chrono::__to_sys_seconds(__ymd, chrono::__at_to_sys_seconds(__continuation));
242}
243
244// Holds the UNTIL time for a continuation with a named rule.
245//
246// Unlike continuations with an fixed SAVE named rules have a variable SAVE.
247// This means when the UNTIL uses the local wall time the actual UNTIL value can
248// only be determined when the SAVE is known. This class holds that abstraction.
249class __named_rule_until {
250public:
251 explicit __named_rule_until(const __tz::__continuation& __continuation)
252 : __until_{chrono::__until_to_sys_seconds(__continuation)},
253 __needs_adjustment_{
254 // The last continuation of a ZONE has no UNTIL which basically is
255 // until the end of _local_ time. This value is expressed by
256 // sys_seconds::max(). Subtracting the SAVE leaves large value.
257 // However SAVE can be negative, which would add a value to maximum
258 // leading to undefined behaviour. In practice this often results in
259 // an overflow to a very small value.
260 __until_ != sys_seconds::max() && __continuation.__at.__clock == __tz::__clock::__local} {}
261
262 // Gives the unadjusted until value, this is useful when the SAVE is not known
263 // at all.
264 sys_seconds __until() const noexcept { return __until_; }
265
266 bool __needs_adjustment() const noexcept { return __needs_adjustment_; }
267
268 // Returns the UNTIL adjusted for SAVE.
269 sys_seconds operator()(seconds __save) const noexcept { return __until_ - __needs_adjustment_ * __save; }
270
271private:
272 sys_seconds __until_;
273 bool __needs_adjustment_;
274};
275
276[[nodiscard]] static seconds __at_to_seconds(seconds __stdoff, const __tz::__rule& __rule) {
277 switch (__rule.__at.__clock) {
278 case __tz::__clock::__local:
279 // Local time and standard time behave the same. This is not
280 // correct. Local time needs to adjust for the current saved time.
281 // To know the saved time the rules need to be known and sorted.
282 // This needs a time so to avoid the chicken and egg adjust the
283 // saving of the local time later.
284 return __rule.__at.__time - __stdoff;
285
286 case __tz::__clock::__universal:
287 return __rule.__at.__time;
288
289 case __tz::__clock::__standard:
290 return __rule.__at.__time - __stdoff;
291 }
292 std::__libcpp_unreachable();
293}
294
295[[nodiscard]] static sys_seconds __from_to_sys_seconds(seconds __stdoff, const __tz::__rule& __rule, year __year) {
296 year_month_day __ymd = chrono::__to_year_month_day(__year, __rule.__in, __rule.__on);
297
298 seconds __at = chrono::__at_to_seconds(__stdoff, __rule);
299 return chrono::__to_sys_seconds(__ymd, __at);
300}
301
302[[nodiscard]] static sys_seconds __from_to_sys_seconds(seconds __stdoff, const __tz::__rule& __rule) {
303 return chrono::__from_to_sys_seconds(__stdoff, __rule, __rule.__from);
304}
305
306[[nodiscard]] static const vector<__tz::__rule>&
307__get_rules(const __tz::__rules_storage_type& __rules_db, const string& __rule_name) {
308 auto __result = chrono::__binary_find(__rules_db, __rule_name, {}, [](const auto& __p) { return __p.first; });
309 if (__result == std::end(__rules_db))
310 std::__throw_runtime_error(("corrupt tzdb: rule '" + __rule_name + " 'does not exist").c_str());
311
312 return __result->second;
313}
314
315// Returns the letters field for a time before the first rule.
316//
317// Per https://data.iana.org/time-zones/tz-how-to.html
318// One wrinkle, not fully explained in zic.8.txt, is what happens when switching
319// to a named rule. To what values should the SAVE and LETTER data be
320// initialized?
321//
322// 1 If at least one transition has happened, use the SAVE and LETTER data from
323// the most recent.
324// 2 If switching to a named rule before any transition has happened, assume
325// standard time (SAVE zero), and use the LETTER data from the earliest
326// transition with a SAVE of zero.
327//
328// This function implements case 2.
329[[nodiscard]] static string __letters_before_first_rule(const vector<__tz::__rule>& __rules) {
330 auto __letters =
331 __rules //
332 | views::filter([](const __tz::__rule& __rule) { return __rule.__save.__time == 0s; }) //
333 | views::transform([](const __tz::__rule& __rule) { return __rule.__letters; }) //
334 | views::take(1);
335
336 if (__letters.empty())
337 std::__throw_runtime_error("corrupt tzdb: rule has zero entries");
338
339 return __letters.front();
340}
341
342// Determines the information based on the continuation and the rules.
343//
344// There are several special cases to take into account
345//
346// === Entries before the first rule becomes active ===
347// Asia/Hong_Kong
348// 9 - JST 1945 N 18 2 // (1)
349// 8 HK HK%sT // (2)
350// R HK 1946 o - Ap 21 0 1 S // (3)
351// There (1) is active until Novemer 18th 1945 at 02:00, after this time
352// (2) becomes active. The first rule entry for HK (3) becomes active
353// from April 21st 1945 at 01:00. In the period between (2) is active.
354// This entry has an offset.
355// This entry has no save, letters, or dst flag. So in the period
356// after (1) and until (3) no rule entry is associated with the time.
357
358[[nodiscard]] static sys_info __get_sys_info_before_first_rule(
359 sys_seconds __begin,
360 sys_seconds __end,
361 const __tz::__continuation& __continuation,
362 const vector<__tz::__rule>& __rules) {
363 return sys_info{
364 __begin,
365 __end,
366 __continuation.__stdoff,
367 chrono::minutes(0),
368 chrono::__format(__continuation, __letters_before_first_rule(__rules), 0s)};
369}
370
371// Returns the sys_info object for a time before the first rule.
372// When this first rule has a SAVE of 0s the sys_info for the time before the
373// first rule and for the first rule are identical and will be merged.
374[[nodiscard]] static sys_info __get_sys_info_before_first_rule(
375 sys_seconds __begin,
376 sys_seconds __rule_end, // The end used when SAVE != 0s
377 sys_seconds __next_end, // The end used when SAVE == 0s the times are merged
378 const __tz::__continuation& __continuation,
379 const vector<__tz::__rule>& __rules,
380 vector<__tz::__rule>::const_iterator __rule) {
381 if (__rule->__save.__time != 0s)
382 return __get_sys_info_before_first_rule(__begin, __rule_end, __continuation, __rules);
383
384 return sys_info{
385 __begin, __next_end, __continuation.__stdoff, 0min, chrono::__format(__continuation, __rule->__letters, 0s)};
386}
387
388[[nodiscard]] static seconds __at_to_seconds(seconds __stdoff, seconds __save, const __tz::__rule& __rule) {
389 switch (__rule.__at.__clock) {
390 case __tz::__clock::__local:
391 return __rule.__at.__time - __stdoff - __save;
392
393 case __tz::__clock::__universal:
394 return __rule.__at.__time;
395
396 case __tz::__clock::__standard:
397 return __rule.__at.__time - __stdoff;
398 }
399 std::__libcpp_unreachable();
400}
401
402[[nodiscard]] static sys_seconds
403__rule_to_sys_seconds(seconds __stdoff, seconds __save, const __tz::__rule& __rule, year __year) {
404 year_month_day __ymd = chrono::__to_year_month_day(__year, __rule.__in, __rule.__on);
405
406 seconds __at = chrono::__at_to_seconds(__stdoff, __save, __rule);
407 return chrono::__to_sys_seconds(__ymd, __at);
408}
409
410// Returns the first rule after __time.
411// Note that a rule can be "active" in multiple years, this may result in an
412// infinite loop where the same rule is returned every time, use __current to
413// guard against that.
414//
415// When no next rule exists the returned time will be sys_seconds::max(). This
416// can happen in practice. For example,
417//
418// R So 1945 o - May 24 2 2 M
419// R So 1945 o - S 24 3 1 S
420// R So 1945 o - N 18 2s 0 -
421//
422// Has 3 rules that are all only active in 1945.
423[[nodiscard]] static pair<sys_seconds, vector<__tz::__rule>::const_iterator>
424__next_rule(sys_seconds __time,
425 seconds __stdoff,
426 seconds __save,
427 const vector<__tz::__rule>& __rules,
428 vector<__tz::__rule>::const_iterator __current) {
429 year __year = year_month_day{chrono::floor<days>(__time)}.year();
430
431 // Note it would probably be better to store the pairs in a vector and then
432 // use min() to get the smallest element
433 map<sys_seconds, vector<__tz::__rule>::const_iterator> __candidates;
434 // Note this evaluates all rules which is a waste of effort; when the entries
435 // are beyond the current year's "next year" (where "next year" is not always
436 // year + 1) the algorithm should end.
437 for (auto __it = __rules.begin(); __it != __rules.end(); ++__it) {
438 for (year __y = __it->__from; __y <= __it->__to; ++__y) {
439 // Adding the current entry for the current year may lead to infinite
440 // loops due to the SAVE adjustment. Skip these entries.
441 if (__y == __year && __it == __current)
442 continue;
443
444 sys_seconds __t = chrono::__rule_to_sys_seconds(__stdoff, __save, *__it, __y);
445 if (__t <= __time)
446 continue;
447
448 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__candidates.contains(__t), "duplicated rule");
449 __candidates[__t] = __it;
450 break;
451 }
452 }
453
454 if (!__candidates.empty()) [[likely]] {
455 auto __it = __candidates.begin();
456
457 // When no rule is selected the time before the first rule and the first rule
458 // should not be merged.
459 if (__time == sys_seconds::min())
460 return *__it;
461
462 // There can be two constitutive rules that are the same. For example,
463 // Hong Kong
464 //
465 // R HK 1973 o - D 30 3:30 1 S (R1)
466 // R HK 1965 1976 - Ap Su>=16 3:30 1 S (R2)
467 //
468 // 1973-12-29 19:30:00 R1 becomes active.
469 // 1974-04-20 18:30:00 R2 becomes active.
470 // Both rules have a SAVE of 1 hour and LETTERS are S for both of them.
471 while (__it != __candidates.end()) {
472 if (__current->__save.__time != __it->second->__save.__time || __current->__letters != __it->second->__letters)
473 return *__it;
474
475 ++__it;
476 }
477 }
478
479 return {sys_seconds::max(), __rules.end()};
480}
481
482// Returns the first rule of a set of rules.
483// This is not always the first of the listed rules. For example
484// R Sa 2008 2009 - Mar Su>=8 0 0 -
485// R Sa 2007 2008 - O Su>=8 0 1 -
486// The transition in October 2007 happens before the transition in March 2008.
487[[nodiscard]] static vector<__tz::__rule>::const_iterator
488__first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) {
489 return chrono::__next_rule(sys_seconds::min(), __stdoff, 0s, __rules, __rules.end()).second;
490}
491
492[[nodiscard]] static __sys_info_result __get_sys_info_rule(
493 sys_seconds __time,
494 sys_seconds __continuation_begin,
495 const __tz::__continuation& __continuation,
496 const vector<__tz::__rule>& __rules) {
497 auto __rule = chrono::__first_rule(__continuation.__stdoff, __rules);
498 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(__rule != __rules.end(), "the set of rules has no first rule");
499
500 // Avoid selecting a time before the start of the continuation
501 __time = std::max(__time, __continuation_begin);
502
503 sys_seconds __rule_begin = chrono::__from_to_sys_seconds(__continuation.__stdoff, *__rule);
504
505 // The time sought is very likely inside the current rule.
506 // When the continuation's UNTIL uses the local clock there are edge cases
507 // where this is not true.
508 //
509 // Start to walk the rules to find the proper one.
510 //
511 // For now we just walk all the rules TODO TZDB investigate whether a smarter
512 // algorithm would work.
513 auto __next = chrono::__next_rule(__rule_begin, __continuation.__stdoff, __rule->__save.__time, __rules, __rule);
514
515 // Ignore small steps, this happens with America/Punta_Arenas for the
516 // transition
517 // -4:42:46 - SMT 1927 S
518 // -5 x -05/-04 1932 S
519 // ...
520 //
521 // R x 1927 1931 - S 1 0 1 -
522 // R x 1928 1932 - Ap 1 0 0 -
523 //
524 // America/Punta_Arenas Thu Sep 1 04:42:45 1927 UT = Thu Sep 1 00:42:45 1927 -04 isdst=1 gmtoff=-14400
525 // America/Punta_Arenas Sun Apr 1 03:59:59 1928 UT = Sat Mar 31 23:59:59 1928 -04 isdst=1 gmtoff=-14400
526 // America/Punta_Arenas Sun Apr 1 04:00:00 1928 UT = Sat Mar 31 23:00:00 1928 -05 isdst=0 gmtoff=-18000
527 //
528 // Without this there will be a transition
529 // [1927-09-01 04:42:45, 1927-09-01 05:00:00) -05:00:00 0min -05
530
531 if (sys_seconds __begin = __rule->__save.__time != 0s ? __rule_begin : __next.first; __time < __begin) {
532 if (__continuation_begin == sys_seconds::min() || __begin - __continuation_begin > 12h)
533 return __sys_info{__get_sys_info_before_first_rule(
534 __continuation_begin, __rule_begin, __next.first, __continuation, __rules, __rule),
535 false};
536
537 // Europe/Berlin
538 // 1 c CE%sT 1945 May 24 2 (C1)
539 // 1 So CE%sT 1946 (C2)
540 //
541 // R c 1944 1945 - Ap M>=1 2s 1 S (R1)
542 //
543 // R So 1945 o - May 24 2 2 M (R2)
544 //
545 // When C2 becomes active the time would be before the first rule R2,
546 // giving a 1 hour sys_info.
547 seconds __save = __rule->__save.__time;
548 __named_rule_until __continuation_end{__continuation};
549 sys_seconds __sys_info_end = std::min(__continuation_end(__save), __next.first);
550
551 return __sys_info{
552 sys_info{__continuation_begin,
553 __sys_info_end,
554 __continuation.__stdoff + __save,
555 chrono::duration_cast<minutes>(__save),
556 chrono::__format(__continuation, __rule->__letters, __save)},
557 __sys_info_end == __continuation_end(__save)};
558 }
559
560 // See above for America/Asuncion
561 if (__rule->__save.__time == 0s && __time < __next.first) {
562 return __sys_info{
563 sys_info{__continuation_begin,
564 __next.first,
565 __continuation.__stdoff,
566 0min,
567 chrono::__format(__continuation, __rule->__letters, 0s)},
568 false};
569 }
570
571 if (__rule->__save.__time != 0s) {
572 // another fix for America/Punta_Arenas when not at the start of the
573 // sys_info object.
574 seconds __save = __rule->__save.__time;
575 if (__continuation_begin >= __rule_begin - __save && __time < __next.first) {
576 return __sys_info{
577 sys_info{__continuation_begin,
578 __next.first,
579 __continuation.__stdoff + __save,
580 chrono::duration_cast<minutes>(__save),
581 chrono::__format(__continuation, __rule->__letters, __save)},
582 false};
583 }
584 }
585
586 __named_rule_until __continuation_end{__continuation};
587 while (__next.second != __rules.end()) {
588#ifdef PRINT
589 std::print(
590 stderr,
591 "Rule for {}: [{}, {}) off={} save={} duration={}\n",
592 __time,
593 __rule_begin,
594 __next.first,
595 __continuation.__stdoff,
596 __rule->__save.__time,
597 __next.first - __rule_begin);
598#endif
599
600 sys_seconds __end = __continuation_end(__rule->__save.__time);
601
602 sys_seconds __sys_info_begin = std::max(__continuation_begin, __rule_begin);
603 sys_seconds __sys_info_end = std::min(__end, __next.first);
604 seconds __diff = chrono::abs(__sys_info_end - __sys_info_begin);
605
606 if (__diff < 12h) {
607 // Z America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 O 31
608 // -4:16:48 - CMT 1920 May
609 // -4 - -04 1930 D
610 // -4 A -04/-03 1969 O 5
611 // -3 A -03/-02 1999 O 3
612 // -4 A -04/-03 2000 Mar 3
613 // ...
614 //
615 // ...
616 // R A 1989 1992 - O Su>=15 0 1 -
617 // R A 1999 o - O Su>=1 0 1 -
618 // R A 2000 o - Mar 3 0 0 -
619 // R A 2007 o - D 30 0 1 -
620 // ...
621
622 // The 1999 switch uses the same rule, but with a different stdoff.
623 // R A 1999 o - O Su>=1 0 1 -
624 // stdoff -3 -> 1999-10-03 03:00:00
625 // stdoff -4 -> 1999-10-03 04:00:00
626 // This generates an invalid entry and this is evaluated as a transition.
627 // Looking at the zdump like output in libc++ this generates jumps in
628 // the UTC time.
629
630 __rule = __next.second;
631 __next = __next_rule(__next.first, __continuation.__stdoff, __rule->__save.__time, __rules, __rule);
632 __end = __continuation_end(__rule->__save.__time);
633 __sys_info_end = std::min(__end, __next.first);
634 }
635
636 if ((__time >= __rule_begin && __time < __next.first) || __next.first >= __end) {
637 __sys_info_begin = std::max(__continuation_begin, __rule_begin);
638 __sys_info_end = std::min(__end, __next.first);
639
640 return __sys_info{
641 sys_info{__sys_info_begin,
642 __sys_info_end,
643 __continuation.__stdoff + __rule->__save.__time,
644 chrono::duration_cast<minutes>(__rule->__save.__time),
645 chrono::__format(__continuation, __rule->__letters, __rule->__save.__time)},
646 __sys_info_end == __end};
647 }
648
649 __rule_begin = __next.first;
650 __rule = __next.second;
651 __next = __next_rule(__rule_begin, __continuation.__stdoff, __rule->__save.__time, __rules, __rule);
652 }
653
654 return __sys_info{
655 sys_info{std::max(__continuation_begin, __rule_begin),
656 __continuation_end(__rule->__save.__time),
657 __continuation.__stdoff + __rule->__save.__time,
658 chrono::duration_cast<minutes>(__rule->__save.__time),
659 chrono::__format(__continuation, __rule->__letters, __rule->__save.__time)},
660 true};
661}
662
663[[nodiscard]] static __sys_info_result __get_sys_info_basic(
664 sys_seconds __time, sys_seconds __continuation_begin, const __tz::__continuation& __continuation, seconds __save) {
665 sys_seconds __continuation_end = chrono::__until_to_sys_seconds(__continuation);
666 return __sys_info{
667 sys_info{__continuation_begin,
668 __continuation_end,
669 __continuation.__stdoff + __save,
670 chrono::duration_cast<minutes>(__save),
671 __continuation.__format},
672 true};
673}
674
675[[nodiscard]] static __sys_info_result
676__get_sys_info(sys_seconds __time,
677 sys_seconds __continuation_begin,
678 const __tz::__continuation& __continuation,
679 const __tz::__rules_storage_type& __rules_db) {
680 return std::visit(
681 [&](const auto& __value) {
682 using _Tp = decay_t<decltype(__value)>;
683 if constexpr (same_as<_Tp, std::string>)
684 return chrono::__get_sys_info_rule(
685 __time, __continuation_begin, __continuation, __get_rules(__rules_db, __value));
686 else if constexpr (same_as<_Tp, monostate>)
687 return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, chrono::seconds(0));
688 else if constexpr (same_as<_Tp, __tz::__save>)
689 return chrono::__get_sys_info_basic(__time, __continuation_begin, __continuation, __value.__time);
690 else
691 static_assert(sizeof(_Tp) == 0); // TODO TZDB static_assert(false); after droping clang-16 support
692
693 std::__libcpp_unreachable();
694 },
695 __continuation.__rules);
696}
697
698// The transition from one continuation to the next continuation may result in
699// two constitutive continuations with the same "offset" information.
700// [time.zone.info.sys]/3
701// The begin and end data members indicate that, for the associated time_zone
702// and time_point, the offset and abbrev are in effect in the range
703// [begin, end). This information can be used to efficiently iterate the
704// transitions of a time_zone.
705//
706// Note that this does considers a change in the SAVE field not to be a
707// different sys_info, zdump does consider this different.
708// LWG XXXX The sys_info range should be affected by save
709// matches the behaviour of the Standard and zdump.
710//
711// Iff the "offsets" are the same '__current.__end' is replaced with
712// '__next.__end', which effectively merges the two objects in one object. The
713// function returns true if a merge occurred.
714[[nodiscard]] bool __merge_continuation(sys_info& __current, const sys_info& __next) {
715 if (__current.end != __next.begin)
716 return false;
717
718 if (__current.offset != __next.offset || __current.abbrev != __next.abbrev || __current.save != __next.save)
719 return false;
720
721 __current.end = __next.end;
722 return true;
723}
724
725//===----------------------------------------------------------------------===//
726// Public API
727//===----------------------------------------------------------------------===//
728
729[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI time_zone time_zone::__create(unique_ptr<time_zone::__impl>&& __p) {
730 _LIBCPP_ASSERT_NON_NULL(__p != nullptr, "initialized time_zone without a valid pimpl object");
731 time_zone result;
732 result.__impl_ = std::move(__p);
733 return result;
734}
735
736_LIBCPP_EXPORTED_FROM_ABI time_zone::~time_zone() = default;
737
738[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI string_view time_zone::__name() const noexcept { return __impl_->__name(); }
739
740[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI sys_info
741time_zone::__get_info(sys_seconds __time) const {
742 optional<sys_info> __result;
743 bool __valid_result = false; // true iff __result.has_value() is true and
744 // __result.begin <= __time < __result.end is true.
745 bool __can_merge = false;
746 sys_seconds __continuation_begin = sys_seconds::min();
747 // Iterates over the Zone entry and its continuations. Internally the Zone
748 // entry is split in a Zone information and the first continuation. The last
749 // continuation has no UNTIL field. This means the loop should always find a
750 // continuation.
751 //
752 // For more information on background of zone information please consult the
753 // following information
754 // [zic manual](https://www.man7.org/linux/man-pages/man8/zic.8.html)
755 // [tz source info](https://data.iana.org/time-zones/tz-how-to.html)
756 // On POSIX systems the zdump tool can be useful:
757 // zdump -v Asia/Hong_Kong
758 // Gives all transitions in the Hong Kong time zone.
759 //
760 // During iteration the result for the current continuation is returned. If
761 // no continuation is applicable it will return the end time as "error". When
762 // two continuations are contiguous and contain the "same" information these
763 // ranges are merged as one range.
764 // The merging requires keeping any result that occurs before __time,
765 // likewise when a valid result is found the algorithm needs to test the next
766 // continuation to see whether it can be merged. For example, Africa/Ceuta
767 // Continuations
768 // 0 s WE%sT 1929 (C1)
769 // 0 - WET 1967 (C2)
770 // 0 Sp WE%sT 1984 Mar 16 (C3)
771 //
772 // Rules
773 // R s 1926 1929 - O Sa>=1 24s 0 - (R1)
774 //
775 // R Sp 1967 o - Jun 3 12 1 S (R2)
776 //
777 // The rule R1 is the last rule used in C1. The rule R2 is the first rule in
778 // C3. Since R2 is the first rule this means when a continuation uses this
779 // rule its value prior to R2 will be SAVE 0 LETTERS of the first entry with a
780 // SAVE of 0, in this case WET.
781 // This gives the following changes in the information.
782 // 1928-10-07 00:00:00 C1 R1 becomes active: offset 0 save 0 abbrev WET
783 // 1929-01-01 00:00:00 C2 becomes active: offset 0 save 0 abbrev WET
784 // 1967-01-01 00:00:00 C3 becomes active: offset 0 save 0 abbrev WET
785 // 1967-06-03 12:00:00 C3 R2 becomes active: offset 0 save 1 abbrev WEST
786 //
787 // The first 3 entries are contiguous and contain the same information, this
788 // means the period [1928-10-07 00:00:00, 1967-06-03 12:00:00) should be
789 // returned in one sys_info object.
790
791 const auto& __continuations = __impl_->__continuations();
792 const __tz::__rules_storage_type& __rules_db = __impl_->__rules_db();
793 for (auto __it = __continuations.begin(); __it != __continuations.end(); ++__it) {
794 const auto& __continuation = *__it;
795 __sys_info_result __sys_info = chrono::__get_sys_info(__time, __continuation_begin, __continuation, __rules_db);
796
797 if (__sys_info) {
798 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
799 __sys_info->__info.begin < __sys_info->__info.end, "invalid sys_info range");
800
801 // Filters out dummy entries
802 // Z America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 O 31
803 // ...
804 // -4 A -04/-03 2000 Mar 3 (C1)
805 // -3 A -03/-02 (C2)
806 //
807 // ...
808 // R A 2000 o - Mar 3 0 0 -
809 // R A 2007 o - D 30 0 1 -
810 // ...
811 //
812 // This results in an entry
813 // [2000-03-03 03:00:00, 2000-03-03 04:00:00) -10800s 60min -03
814 // for [C1 & R1, C1, R2) which due to the end of the continuation is an
815 // one hour "sys_info". Instead the entry should be ignored and replaced
816 // by [C2 & R1, C2 & R2) which is the proper range
817 // "[2000-03-03 03:00:00, 2007-12-30 03:00:00) -02:00:00 60min -02
818
819 if (std::holds_alternative<string>(__continuation.__rules) && __sys_info->__can_merge &&
820 __sys_info->__info.begin + 12h > __sys_info->__info.end) {
821 __continuation_begin = __sys_info->__info.begin;
822 continue;
823 }
824
825 if (!__result) {
826 // First entry found, always keep it.
827 __result = __sys_info->__info;
828
829 __valid_result = __time >= __result->begin && __time < __result->end;
830 __can_merge = __sys_info->__can_merge;
831 } else if (__can_merge && chrono::__merge_continuation(*__result, __sys_info->__info)) {
832 // The results are merged, update the result state. This may
833 // "overwrite" a valid sys_info object with another valid sys_info
834 // object.
835 __valid_result = __time >= __result->begin && __time < __result->end;
836 __can_merge = __sys_info->__can_merge;
837 } else {
838 // Here things get interesting:
839 // For example, America/Argentina/San_Luis
840 //
841 // -3 A -03/-02 2008 Ja 21 (C1)
842 // -4 Sa -04/-03 2009 O 11 (C2)
843 //
844 // R A 2007 o - D 30 0 1 - (R1)
845 //
846 // R Sa 2007 2008 - O Su>=8 0 1 - (R2)
847 //
848 // Based on C1 & R1 the end time of C1 is 2008-01-21 03:00:00
849 // Based on C2 & R2 the end time of C1 is 2008-01-21 02:00:00
850 // In this case the earlier time is the real time of the transition.
851 // However the algorithm used gives 2008-01-21 03:00:00.
852 //
853 // So we need to calculate the previous UNTIL in the current context and
854 // see whether it's earlier.
855
856 // The results could not be merged.
857 // - When we have a valid result that result is the final result.
858 // - Otherwise the result we had is before __time and the result we got
859 // is at a later time (possibly valid). This result is always better
860 // than the previous result.
861 if (__valid_result) {
862 return *__result;
863 } else {
864 _LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(
865 __it != __continuations.begin(), "the first rule should always seed the result");
866 const auto& __last = *(__it - 1);
867 if (std::holds_alternative<string>(__last.__rules)) {
868 // Europe/Berlin
869 // 1 c CE%sT 1945 May 24 2 (C1)
870 // 1 So CE%sT 1946 (C2)
871 //
872 // R c 1944 1945 - Ap M>=1 2s 1 S (R1)
873 //
874 // R So 1945 o - May 24 2 2 M (R2)
875 //
876 // When C2 becomes active the time would be before the first rule R2,
877 // giving a 1 hour sys_info. This is not valid and the results need
878 // merging.
879
880 if (__result->end != __sys_info->__info.begin) {
881 // When the UTC gap between the rules is due to the change of
882 // offsets adjust the new time to remove the gap.
883 sys_seconds __end = __result->end - __result->offset;
884 sys_seconds __begin = __sys_info->__info.begin - __sys_info->__info.offset;
885 if (__end == __begin) {
886 __sys_info->__info.begin = __result->end;
887 }
888 }
889 }
890
891 __result = __sys_info->__info;
892 __valid_result = __time >= __result->begin && __time < __result->end;
893 __can_merge = __sys_info->__can_merge;
894 }
895 }
896 __continuation_begin = __result->end;
897 } else {
898 __continuation_begin = __sys_info.error();
899 }
900 }
901 if (__valid_result)
902 return *__result;
903
904 std::__throw_runtime_error("tzdb: corrupt db");
905}
906
907// Is the "__local_time" present in "__first" and "__second". If so the
908// local_info has an ambiguous result.
909[[nodiscard]] static bool
910__is_ambiguous(local_seconds __local_time, const sys_info& __first, const sys_info& __second) {
911 std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + __first.offset};
912 std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() + __second.offset};
913
914 return __local_time < __end_first && __local_time >= __begin_second;
915}
916
917// Determines the result of the "__local_time". This expects the object
918// "__first" to be earlier in time than "__second".
919[[nodiscard]] static local_info
920__get_info(local_seconds __local_time, const sys_info& __first, const sys_info& __second) {
921 std::chrono::local_seconds __end_first{__first.end.time_since_epoch() + __first.offset};
922 std::chrono::local_seconds __begin_second{__second.begin.time_since_epoch() + __second.offset};
923
924 if (__local_time < __end_first) {
925 if (__local_time >= __begin_second)
926 // |--------|
927 // |------|
928 // ^
929 return {local_info::ambiguous, __first, __second};
930
931 // |--------|
932 // |------|
933 // ^
934 return {local_info::unique, __first, sys_info{}};
935 }
936
937 if (__local_time < __begin_second)
938 // |--------|
939 // |------|
940 // ^
941 return {local_info::nonexistent, __first, __second};
942
943 // |--------|
944 // |------|
945 // ^
946 return {local_info::unique, __second, sys_info{}};
947}
948
949[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI local_info
950time_zone::__get_info(local_seconds __local_time) const {
951 seconds __local_seconds = __local_time.time_since_epoch();
952
953 /* An example of a typical year with a DST switch displayed in local time.
954 *
955 * At the first of April the time goes forward one hour. This means the
956 * time marked with ~~ is not a valid local time. This is represented by the
957 * nonexistent value in local_info.result.
958 *
959 * At the first of November the time goes backward one hour. This means the
960 * time marked with ^^ happens twice. This is represented by the ambiguous
961 * value in local_info.result.
962 *
963 * 2020.11.01 2021.04.01 2021.11.01
964 * offset +05 offset +05 offset +05
965 * save 0s save 1h save 0s
966 * |------------//----------|
967 * |---------//--------------|
968 * |-------------
969 * ~~ ^^
970 *
971 * These shifts can happen due to changes in the current time zone for a
972 * location. For example, Indian/Kerguelen switched only once. In 1950 from an
973 * offset of 0 hours to an offset of +05 hours.
974 *
975 * During all these shifts the UTC time will not have gaps.
976 */
977
978 // The code needs to determine the system time for the local time. There is no
979 // information available. Assume the offset between system time and local time
980 // is 0s. This gives an initial estimate.
981 sys_seconds __guess{__local_seconds};
982 sys_info __info = __get_info(__guess);
983
984 // At this point the offset can be used to determine an estimate for the local
985 // time. Before doing that, determine the offset and validate whether the
986 // local time is the range [chrono::local_seconds::min(),
987 // chrono::local_seconds::max()).
988 if (__local_seconds < 0s && __info.offset > 0s)
989 if (__local_seconds - chrono::local_seconds::min().time_since_epoch() < __info.offset)
990 return {-1, __info, {}};
991
992 if (__local_seconds > 0s && __info.offset < 0s)
993 if (chrono::local_seconds::max().time_since_epoch() - __local_seconds < -__info.offset)
994 return {-2, __info, {}};
995
996 // Based on the information found in the sys_info, the local time can be
997 // converted to a system time. This resulting time can be in the following
998 // locations of the sys_info:
999 //
1000 // |---------//--------------|
1001 // 1 2.1 2.2 2.3 3
1002 //
1003 // 1. The estimate is before the returned sys_info object.
1004 // The result is either non-existent or unique in the previous sys_info.
1005 // 2. The estimate is in the sys_info object
1006 // - If the sys_info begin is not sys_seconds::min(), then it might be at
1007 // 2.1 and could be ambiguous with the previous or unique.
1008 // - If sys_info end is not sys_seconds::max(), then it might be at 2.3
1009 // and could be ambiguous with the next or unique.
1010 // - Else it is at 2.2 and always unique. This case happens when a
1011 // time zone has no transitions. For example, UTC or GMT+1.
1012 // 3. The estimate is after the returned sys_info object.
1013 // The result is either non-existent or unique in the next sys_info.
1014 //
1015 // There is no specification where the "middle" starts. Similar issues can
1016 // happen when sys_info objects are "short", then "unique in the next" could
1017 // become "ambiguous in the next and the one following". Theoretically there
1018 // is the option of the following time-line
1019 //
1020 // |------------|
1021 // |----|
1022 // |-----------------|
1023 //
1024 // However the local_info object only has 2 sys_info objects, so this option
1025 // is not tested.
1026
1027 sys_seconds __sys_time{__local_seconds - __info.offset};
1028 if (__sys_time < __info.begin)
1029 // Case 1 before __info
1030 return chrono::__get_info(__local_time, __get_info(__info.begin - 1s), __info);
1031
1032 if (__sys_time >= __info.end)
1033 // Case 3 after __info
1034 return chrono::__get_info(__local_time, __info, __get_info(__info.end));
1035
1036 // Case 2 in __info
1037 if (__info.begin != sys_seconds::min()) {
1038 // Case 2.1 Not at the beginning, when not ambiguous the result should test
1039 // case 2.3.
1040 sys_info __prev = __get_info(__info.begin - 1s);
1041 if (__is_ambiguous(__local_time, __prev, __info))
1042 return {local_info::ambiguous, __prev, __info};
1043 }
1044
1045 if (__info.end == sys_seconds::max())
1046 // At the end so it's case 2.2
1047 return {local_info::unique, __info, sys_info{}};
1048
1049 // This tests case 2.2 or case 2.3.
1050 return chrono::__get_info(__local_time, __info, __get_info(__info.end));
1051}
1052
1053} // namespace chrono
1054
1055_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/tzdb.cpp created+781
......@@ -0,0 +1,781 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#include <algorithm>
12#include <chrono>
13#include <filesystem>
14#include <fstream>
15#include <stdexcept>
16#include <string>
17
18#include "include/tzdb/time_zone_private.h"
19#include "include/tzdb/types_private.h"
20#include "include/tzdb/tzdb_list_private.h"
21#include "include/tzdb/tzdb_private.h"
22
23// Contains a parser for the IANA time zone data files.
24//
25// These files can be found at https://data.iana.org/time-zones/ and are in the
26// public domain. Information regarding the input can be found at
27// https://data.iana.org/time-zones/tz-how-to.html and
28// https://man7.org/linux/man-pages/man8/zic.8.html.
29//
30// As indicated at https://howardhinnant.github.io/date/tz.html#Installation
31// For Windows another file seems to be required
32// https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml
33// This file seems to contain the mapping of Windows time zone name to IANA
34// time zone names.
35//
36// However this article mentions another way to do the mapping on Windows
37// https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255
38// This requires Windows 10 Version 1903, which was released in May of 2019
39// and considered end of life in December 2020
40// https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1903-end-of-servicing
41//
42// TODO TZDB Implement the Windows mapping in tzdb::current_zone
43
44_LIBCPP_BEGIN_NAMESPACE_STD
45
46namespace chrono {
47
48// This function is weak so it can be overriden in the tests. The
49// declaration is in the test header test/support/test_tzdb.h
50_LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
51#if defined(__linux__)
52 return "/usr/share/zoneinfo/";
53#else
54// Zig patch: change this compilation error into a runtime crash.
55//# error "unknown path to the IANA Time Zone Database"
56 abort();
57#endif
58}
59
60//===----------------------------------------------------------------------===//
61// Details
62//===----------------------------------------------------------------------===//
63
64[[nodiscard]] static bool __is_whitespace(int __c) { return __c == ' ' || __c == '\t'; }
65
66static void __skip_optional_whitespace(istream& __input) {
67 while (chrono::__is_whitespace(__input.peek()))
68 __input.get();
69}
70
71static void __skip_mandatory_whitespace(istream& __input) {
72 if (!chrono::__is_whitespace(__input.get()))
73 std::__throw_runtime_error("corrupt tzdb: expected whitespace");
74
75 chrono::__skip_optional_whitespace(__input);
76}
77
78[[nodiscard]] static bool __is_eol(int __c) { return __c == '\n' || __c == std::char_traits<char>::eof(); }
79
80static void __skip_line(istream& __input) {
81 while (!chrono::__is_eol(__input.peek())) {
82 __input.get();
83 }
84 __input.get();
85}
86
87static void __skip(istream& __input, char __suffix) {
88 if (std::tolower(__input.peek()) == __suffix)
89 __input.get();
90}
91
92static void __skip(istream& __input, string_view __suffix) {
93 for (auto __c : __suffix)
94 if (std::tolower(__input.peek()) == __c)
95 __input.get();
96}
97
98static void __matches(istream& __input, char __expected) {
99 if (std::tolower(__input.get()) != __expected)
100 std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str());
101}
102
103static void __matches(istream& __input, string_view __expected) {
104 for (auto __c : __expected)
105 if (std::tolower(__input.get()) != __c)
106 std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str());
107}
108
109[[nodiscard]] static string __parse_string(istream& __input) {
110 string __result;
111 while (true) {
112 int __c = __input.get();
113 switch (__c) {
114 case ' ':
115 case '\t':
116 case '\n':
117 __input.unget();
118 [[fallthrough]];
119 case istream::traits_type::eof():
120 if (__result.empty())
121 std::__throw_runtime_error("corrupt tzdb: expected a string");
122
123 return __result;
124
125 default:
126 __result.push_back(__c);
127 }
128 }
129}
130
131[[nodiscard]] static int64_t __parse_integral(istream& __input, bool __leading_zero_allowed) {
132 int64_t __result = __input.get();
133 if (__leading_zero_allowed) {
134 if (__result < '0' || __result > '9')
135 std::__throw_runtime_error("corrupt tzdb: expected a digit");
136 } else {
137 if (__result < '1' || __result > '9')
138 std::__throw_runtime_error("corrupt tzdb: expected a non-zero digit");
139 }
140 __result -= '0';
141 while (true) {
142 if (__input.peek() < '0' || __input.peek() > '9')
143 return __result;
144
145 // In order to avoid possible overflows we limit the accepted range.
146 // Most values parsed are expected to be very small:
147 // - 8784 hours in a year
148 // - 31 days in a month
149 // - year no real maximum, these values are expected to be less than
150 // the range of the year type.
151 //
152 // However the leapseconds use a seconds after epoch value. Using an
153 // int would run into an overflow in 2038. By using a 64-bit value
154 // the range is large enough for the bilions of years. Limiting that
155 // range slightly to make the code easier is not an issue.
156 if (__result > (std::numeric_limits<int64_t>::max() / 16))
157 std::__throw_runtime_error("corrupt tzdb: integral too large");
158
159 __result *= 10;
160 __result += __input.get() - '0';
161 }
162}
163
164//===----------------------------------------------------------------------===//
165// Calendar
166//===----------------------------------------------------------------------===//
167
168[[nodiscard]] static day __parse_day(istream& __input) {
169 unsigned __result = chrono::__parse_integral(__input, false);
170 if (__result > 31)
171 std::__throw_runtime_error("corrupt tzdb day: value too large");
172 return day{__result};
173}
174
175[[nodiscard]] static weekday __parse_weekday(istream& __input) {
176 // TZDB allows the shortest unique name.
177 switch (std::tolower(__input.get())) {
178 case 'f':
179 chrono::__skip(__input, "riday");
180 return Friday;
181
182 case 'm':
183 chrono::__skip(__input, "onday");
184 return Monday;
185
186 case 's':
187 switch (std::tolower(__input.get())) {
188 case 'a':
189 chrono::__skip(__input, "turday");
190 return Saturday;
191
192 case 'u':
193 chrono::__skip(__input, "nday");
194 return Sunday;
195 }
196 break;
197
198 case 't':
199 switch (std::tolower(__input.get())) {
200 case 'h':
201 chrono::__skip(__input, "ursday");
202 return Thursday;
203
204 case 'u':
205 chrono::__skip(__input, "esday");
206 return Tuesday;
207 }
208 break;
209 case 'w':
210 chrono::__skip(__input, "ednesday");
211 return Wednesday;
212 }
213
214 std::__throw_runtime_error("corrupt tzdb weekday: invalid name");
215}
216
217[[nodiscard]] static month __parse_month(istream& __input) {
218 // TZDB allows the shortest unique name.
219 switch (std::tolower(__input.get())) {
220 case 'a':
221 switch (std::tolower(__input.get())) {
222 case 'p':
223 chrono::__skip(__input, "ril");
224 return April;
225
226 case 'u':
227 chrono::__skip(__input, "gust");
228 return August;
229 }
230 break;
231
232 case 'd':
233 chrono::__skip(__input, "ecember");
234 return December;
235
236 case 'f':
237 chrono::__skip(__input, "ebruary");
238 return February;
239
240 case 'j':
241 switch (std::tolower(__input.get())) {
242 case 'a':
243 chrono::__skip(__input, "nuary");
244 return January;
245
246 case 'u':
247 switch (std::tolower(__input.get())) {
248 case 'n':
249 chrono::__skip(__input, 'e');
250 return June;
251
252 case 'l':
253 chrono::__skip(__input, 'y');
254 return July;
255 }
256 }
257 break;
258
259 case 'm':
260 if (std::tolower(__input.get()) == 'a')
261 switch (std::tolower(__input.get())) {
262 case 'y':
263 return May;
264
265 case 'r':
266 chrono::__skip(__input, "ch");
267 return March;
268 }
269 break;
270
271 case 'n':
272 chrono::__skip(__input, "ovember");
273 return November;
274
275 case 'o':
276 chrono::__skip(__input, "ctober");
277 return October;
278
279 case 's':
280 chrono::__skip(__input, "eptember");
281 return September;
282 }
283 std::__throw_runtime_error("corrupt tzdb month: invalid name");
284}
285
286[[nodiscard]] static year __parse_year_value(istream& __input) {
287 bool __negative = __input.peek() == '-';
288 if (__negative) [[unlikely]]
289 __input.get();
290
291 int64_t __result = __parse_integral(__input, true);
292 if (__result > static_cast<int>(year::max())) {
293 if (__negative)
294 std::__throw_runtime_error("corrupt tzdb year: year is less than the minimum");
295
296 std::__throw_runtime_error("corrupt tzdb year: year is greater than the maximum");
297 }
298
299 return year{static_cast<int>(__negative ? -__result : __result)};
300}
301
302[[nodiscard]] static year __parse_year(istream& __input) {
303 if (std::tolower(__input.peek()) != 'm') [[likely]]
304 return chrono::__parse_year_value(__input);
305
306 __input.get();
307 switch (std::tolower(__input.peek())) {
308 case 'i':
309 __input.get();
310 chrono::__skip(__input, 'n');
311 [[fallthrough]];
312
313 case ' ':
314 // The m is minimum, even when that is ambiguous.
315 return year::min();
316
317 case 'a':
318 __input.get();
319 chrono::__skip(__input, 'x');
320 return year::max();
321 }
322
323 std::__throw_runtime_error("corrupt tzdb year: expected 'min' or 'max'");
324}
325
326//===----------------------------------------------------------------------===//
327// TZDB fields
328//===----------------------------------------------------------------------===//
329
330[[nodiscard]] static year __parse_to(istream& __input, year __only) {
331 if (std::tolower(__input.peek()) != 'o')
332 return chrono::__parse_year(__input);
333
334 __input.get();
335 chrono::__skip(__input, "nly");
336 return __only;
337}
338
339[[nodiscard]] static __tz::__constrained_weekday::__comparison_t __parse_comparison(istream& __input) {
340 switch (__input.get()) {
341 case '>':
342 chrono::__matches(__input, '=');
343 return __tz::__constrained_weekday::__ge;
344
345 case '<':
346 chrono::__matches(__input, '=');
347 return __tz::__constrained_weekday::__le;
348 }
349 std::__throw_runtime_error("corrupt tzdb on: expected '>=' or '<='");
350}
351
352[[nodiscard]] static __tz::__on __parse_on(istream& __input) {
353 if (std::isdigit(__input.peek()))
354 return chrono::__parse_day(__input);
355
356 if (std::tolower(__input.peek()) == 'l') {
357 chrono::__matches(__input, "last");
358 return weekday_last(chrono::__parse_weekday(__input));
359 }
360
361 return __tz::__constrained_weekday{
362 chrono::__parse_weekday(__input), chrono::__parse_comparison(__input), chrono::__parse_day(__input)};
363}
364
365[[nodiscard]] static seconds __parse_duration(istream& __input) {
366 seconds __result{0};
367 int __c = __input.peek();
368 bool __negative = __c == '-';
369 if (__negative) {
370 __input.get();
371 // Negative is either a negative value or a single -.
372 // The latter means 0 and the parsing is complete.
373 if (!std::isdigit(__input.peek()))
374 return __result;
375 }
376
377 __result += hours(__parse_integral(__input, true));
378 if (__input.peek() != ':')
379 return __negative ? -__result : __result;
380
381 __input.get();
382 __result += minutes(__parse_integral(__input, true));
383 if (__input.peek() != ':')
384 return __negative ? -__result : __result;
385
386 __input.get();
387 __result += seconds(__parse_integral(__input, true));
388 if (__input.peek() != '.')
389 return __negative ? -__result : __result;
390
391 __input.get();
392 (void)__parse_integral(__input, true); // Truncate the digits.
393
394 return __negative ? -__result : __result;
395}
396
397[[nodiscard]] static __tz::__clock __parse_clock(istream& __input) {
398 switch (__input.get()) { // case sensitive
399 case 'w':
400 return __tz::__clock::__local;
401 case 's':
402 return __tz::__clock::__standard;
403
404 case 'u':
405 case 'g':
406 case 'z':
407 return __tz::__clock::__universal;
408 }
409
410 __input.unget();
411 return __tz::__clock::__local;
412}
413
414[[nodiscard]] static bool __parse_dst(istream& __input, seconds __offset) {
415 switch (__input.get()) { // case sensitive
416 case 's':
417 return false;
418
419 case 'd':
420 return true;
421 }
422
423 __input.unget();
424 return __offset != 0s;
425}
426
427[[nodiscard]] static __tz::__at __parse_at(istream& __input) {
428 return {__parse_duration(__input), __parse_clock(__input)};
429}
430
431[[nodiscard]] static __tz::__save __parse_save(istream& __input) {
432 seconds __time = chrono::__parse_duration(__input);
433 return {__time, chrono::__parse_dst(__input, __time)};
434}
435
436[[nodiscard]] static string __parse_letters(istream& __input) {
437 string __result = __parse_string(__input);
438 // Canonicalize "-" to "" since they are equivalent in the specification.
439 return __result != "-" ? __result : "";
440}
441
442[[nodiscard]] static __tz::__continuation::__rules_t __parse_rules(istream& __input) {
443 int __c = __input.peek();
444 // A single - is not a SAVE but a special case.
445 if (__c == '-') {
446 __input.get();
447 if (chrono::__is_whitespace(__input.peek()))
448 return monostate{};
449 __input.unget();
450 return chrono::__parse_save(__input);
451 }
452
453 if (std::isdigit(__c) || __c == '+')
454 return chrono::__parse_save(__input);
455
456 return chrono::__parse_string(__input);
457}
458
459[[nodiscard]] static __tz::__continuation __parse_continuation(__tz::__rules_storage_type& __rules, istream& __input) {
460 __tz::__continuation __result;
461
462 __result.__rule_database_ = std::addressof(__rules);
463
464 // Note STDOFF is specified as
465 // This field has the same format as the AT and SAVE fields of rule lines;
466 // These fields have different suffix letters, these letters seem
467 // not to be used so do not allow any of them.
468
469 __result.__stdoff = chrono::__parse_duration(__input);
470 chrono::__skip_mandatory_whitespace(__input);
471 __result.__rules = chrono::__parse_rules(__input);
472 chrono::__skip_mandatory_whitespace(__input);
473 __result.__format = chrono::__parse_string(__input);
474 chrono::__skip_optional_whitespace(__input);
475
476 if (chrono::__is_eol(__input.peek()))
477 return __result;
478 __result.__year = chrono::__parse_year(__input);
479 chrono::__skip_optional_whitespace(__input);
480
481 if (chrono::__is_eol(__input.peek()))
482 return __result;
483 __result.__in = chrono::__parse_month(__input);
484 chrono::__skip_optional_whitespace(__input);
485
486 if (chrono::__is_eol(__input.peek()))
487 return __result;
488 __result.__on = chrono::__parse_on(__input);
489 chrono::__skip_optional_whitespace(__input);
490
491 if (chrono::__is_eol(__input.peek()))
492 return __result;
493 __result.__at = __parse_at(__input);
494
495 return __result;
496}
497
498//===----------------------------------------------------------------------===//
499// Time Zone Database entries
500//===----------------------------------------------------------------------===//
501
502static string __parse_version(istream& __input) {
503 // The first line in tzdata.zi contains
504 // # version YYYYw
505 // The parser expects this pattern
506 // #\s*version\s*\(.*)
507 // This part is not documented.
508 chrono::__matches(__input, '#');
509 chrono::__skip_optional_whitespace(__input);
510 chrono::__matches(__input, "version");
511 chrono::__skip_mandatory_whitespace(__input);
512 return chrono::__parse_string(__input);
513}
514
515[[nodiscard]]
516static __tz::__rule& __create_entry(__tz::__rules_storage_type& __rules, const string& __name) {
517 auto __result = [&]() -> __tz::__rule& {
518 auto& __rule = __rules.emplace_back(__name, vector<__tz::__rule>{});
519 return __rule.second.emplace_back();
520 };
521
522 if (__rules.empty())
523 return __result();
524
525 // Typically rules are in contiguous order in the database.
526 // But there are exceptions, some rules are interleaved.
527 if (__rules.back().first == __name)
528 return __rules.back().second.emplace_back();
529
530 if (auto __it = ranges::find(__rules, __name, [](const auto& __r) { return __r.first; });
531 __it != ranges::end(__rules))
532 return __it->second.emplace_back();
533
534 return __result();
535}
536
537static void __parse_rule(tzdb& __tzdb, __tz::__rules_storage_type& __rules, istream& __input) {
538 chrono::__skip_mandatory_whitespace(__input);
539 string __name = chrono::__parse_string(__input);
540
541 __tz::__rule& __rule = __create_entry(__rules, __name);
542
543 chrono::__skip_mandatory_whitespace(__input);
544 __rule.__from = chrono::__parse_year(__input);
545 chrono::__skip_mandatory_whitespace(__input);
546 __rule.__to = chrono::__parse_to(__input, __rule.__from);
547 chrono::__skip_mandatory_whitespace(__input);
548 chrono::__matches(__input, '-');
549 chrono::__skip_mandatory_whitespace(__input);
550 __rule.__in = chrono::__parse_month(__input);
551 chrono::__skip_mandatory_whitespace(__input);
552 __rule.__on = chrono::__parse_on(__input);
553 chrono::__skip_mandatory_whitespace(__input);
554 __rule.__at = __parse_at(__input);
555 chrono::__skip_mandatory_whitespace(__input);
556 __rule.__save = __parse_save(__input);
557 chrono::__skip_mandatory_whitespace(__input);
558 __rule.__letters = chrono::__parse_letters(__input);
559 chrono::__skip_line(__input);
560}
561
562static void __parse_zone(tzdb& __tzdb, __tz::__rules_storage_type& __rules, istream& __input) {
563 chrono::__skip_mandatory_whitespace(__input);
564 auto __p = std::make_unique<time_zone::__impl>(chrono::__parse_string(__input), __rules);
565 vector<__tz::__continuation>& __continuations = __p->__continuations();
566 chrono::__skip_mandatory_whitespace(__input);
567
568 do {
569 // The first line must be valid, continuations are optional.
570 __continuations.emplace_back(__parse_continuation(__rules, __input));
571 chrono::__skip_line(__input);
572 chrono::__skip_optional_whitespace(__input);
573 } while (std::isdigit(__input.peek()) || __input.peek() == '-');
574
575 __tzdb.zones.emplace_back(time_zone::__create(std::move(__p)));
576}
577
578static void __parse_link(tzdb& __tzdb, istream& __input) {
579 chrono::__skip_mandatory_whitespace(__input);
580 string __target = chrono::__parse_string(__input);
581 chrono::__skip_mandatory_whitespace(__input);
582 string __name = chrono::__parse_string(__input);
583 chrono::__skip_line(__input);
584
585 __tzdb.links.emplace_back(std::__private_constructor_tag{}, std::move(__name), std::move(__target));
586}
587
588static void __parse_tzdata(tzdb& __db, __tz::__rules_storage_type& __rules, istream& __input) {
589 while (true) {
590 int __c = std::tolower(__input.get());
591
592 switch (__c) {
593 case istream::traits_type::eof():
594 return;
595
596 case ' ':
597 case '\t':
598 case '\n':
599 break;
600
601 case '#':
602 chrono::__skip_line(__input);
603 break;
604
605 case 'r':
606 chrono::__skip(__input, "ule");
607 chrono::__parse_rule(__db, __rules, __input);
608 break;
609
610 case 'z':
611 chrono::__skip(__input, "one");
612 chrono::__parse_zone(__db, __rules, __input);
613 break;
614
615 case 'l':
616 chrono::__skip(__input, "ink");
617 chrono::__parse_link(__db, __input);
618 break;
619
620 default:
621 std::__throw_runtime_error("corrupt tzdb: unexpected input");
622 }
623 }
624}
625
626static void __parse_leap_seconds(vector<leap_second>& __leap_seconds, istream&& __input) {
627 // The file stores dates since 1 January 1900, 00:00:00, we want
628 // seconds since 1 January 1970.
629 constexpr auto __offset = sys_days{1970y / January / 1} - sys_days{1900y / January / 1};
630
631 struct __entry {
632 sys_seconds __timestamp;
633 seconds __value;
634 };
635 vector<__entry> __entries;
636 [&] {
637 while (true) {
638 switch (__input.peek()) {
639 case istream::traits_type::eof():
640 return;
641
642 case ' ':
643 case '\t':
644 case '\n':
645 __input.get();
646 continue;
647
648 case '#':
649 chrono::__skip_line(__input);
650 continue;
651 }
652
653 sys_seconds __date = sys_seconds{seconds{chrono::__parse_integral(__input, false)}} - __offset;
654 chrono::__skip_mandatory_whitespace(__input);
655 seconds __value{chrono::__parse_integral(__input, false)};
656 chrono::__skip_line(__input);
657
658 __entries.emplace_back(__date, __value);
659 }
660 }();
661 // The Standard requires the leap seconds to be sorted. The file
662 // leap-seconds.list usually provides them in sorted order, but that is not
663 // guaranteed so we ensure it here.
664 ranges::sort(__entries, {}, &__entry::__timestamp);
665
666 // The database should contain the number of seconds inserted by a leap
667 // second (1 or -1). So the difference between the two elements is stored.
668 // std::ranges::views::adjacent has not been implemented yet.
669 (void)ranges::adjacent_find(__entries, [&](const __entry& __first, const __entry& __second) {
670 __leap_seconds.emplace_back(
671 std::__private_constructor_tag{}, __second.__timestamp, __second.__value - __first.__value);
672 return false;
673 });
674}
675
676void __init_tzdb(tzdb& __tzdb, __tz::__rules_storage_type& __rules) {
677 filesystem::path __root = chrono::__libcpp_tzdb_directory();
678 ifstream __tzdata{__root / "tzdata.zi"};
679
680 __tzdb.version = chrono::__parse_version(__tzdata);
681 chrono::__parse_tzdata(__tzdb, __rules, __tzdata);
682 ranges::sort(__tzdb.zones);
683 ranges::sort(__tzdb.links);
684 ranges::sort(__rules, {}, [](const auto& p) { return p.first; });
685
686 // There are two files with the leap second information
687 // - leapseconds as specified by zic
688 // - leap-seconds.list the source data
689 // The latter is much easier to parse, it seems Howard shares that
690 // opinion.
691 chrono::__parse_leap_seconds(__tzdb.leap_seconds, ifstream{__root / "leap-seconds.list"});
692}
693
694#ifdef _WIN32
695[[nodiscard]] static const time_zone* __current_zone_windows(const tzdb& tzdb) {
696 // TODO TZDB Implement this on Windows.
697 std::__throw_runtime_error("unknown time zone");
698}
699#else // ifdef _WIN32
700[[nodiscard]] static const time_zone* __current_zone_posix(const tzdb& tzdb) {
701 // On POSIX systems there are several ways to configure the time zone.
702 // In order of priority they are:
703 // - TZ environment variable
704 // https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08
705 // The documentation is unclear whether or not it's allowed to
706 // change time zone information. For example the TZ string
707 // MST7MDT
708 // this is an entry in tzdata.zi. The value
709 // MST
710 // is also an entry. Is it allowed to use the following?
711 // MST-3
712 // Even when this is valid there is no time_zone record in the
713 // database. Since the library would need to return a valid pointer,
714 // this means the library needs to allocate and leak a pointer.
715 //
716 // - The time zone name is the target of the symlink /etc/localtime
717 // relative to /usr/share/zoneinfo/
718
719 // The algorithm is like this:
720 // - If the environment variable TZ is set and points to a valid
721 // record use this value.
722 // - Else use the name based on the `/etc/localtime` symlink.
723
724 if (const char* __tz = getenv("TZ"))
725 if (const time_zone* __result = tzdb.__locate_zone(__tz))
726 return __result;
727
728 filesystem::path __path = "/etc/localtime";
729 if (!filesystem::exists(__path))
730 std::__throw_runtime_error("tzdb: the symlink '/etc/localtime' does not exist");
731
732 if (!filesystem::is_symlink(__path))
733 std::__throw_runtime_error("tzdb: the path '/etc/localtime' is not a symlink");
734
735 filesystem::path __tz = filesystem::read_symlink(__path);
736 // The path may be a relative path, in that case convert it to an absolute
737 // path based on the proper initial directory.
738 if (__tz.is_relative())
739 __tz = filesystem::canonical("/etc" / __tz);
740
741 string __name = filesystem::relative(__tz, "/usr/share/zoneinfo/");
742 if (const time_zone* __result = tzdb.__locate_zone(__name))
743 return __result;
744
745 std::__throw_runtime_error(("tzdb: the time zone '" + __name + "' is not found in the database").c_str());
746}
747#endif // ifdef _WIN32
748
749//===----------------------------------------------------------------------===//
750// Public API
751//===----------------------------------------------------------------------===//
752
753_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list() {
754 static tzdb_list __result{new tzdb_list::__impl()};
755 return __result;
756}
757
758[[nodiscard]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const time_zone* tzdb::__current_zone() const {
759#ifdef _WIN32
760 return chrono::__current_zone_windows(*this);
761#else
762 return chrono::__current_zone_posix(*this);
763#endif
764}
765
766_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb() {
767 if (chrono::remote_version() == chrono::get_tzdb().version)
768 return chrono::get_tzdb();
769
770 return chrono::get_tzdb_list().__implementation().__load();
771}
772
773_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() {
774 filesystem::path __root = chrono::__libcpp_tzdb_directory();
775 ifstream __tzdata{__root / "tzdata.zi"};
776 return chrono::__parse_version(__tzdata);
777}
778
779} // namespace chrono
780
781_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/experimental/tzdb_list.cpp created+43
......@@ -0,0 +1,43 @@
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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#include <chrono>
12
13#include "include/tzdb/tzdb_list_private.h"
14
15_LIBCPP_BEGIN_NAMESPACE_STD
16
17namespace chrono {
18
19_LIBCPP_EXPORTED_FROM_ABI tzdb_list::~tzdb_list() { delete __impl_; }
20
21[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI const tzdb& tzdb_list::__front() const noexcept { return __impl_->__front(); }
22
23_LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__erase_after(const_iterator __p) {
24 return __impl_->__erase_after(__p);
25}
26
27[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__begin() const noexcept {
28 return __impl_->__begin();
29}
30[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__end() const noexcept {
31 return __impl_->__end();
32}
33
34[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__cbegin() const noexcept {
35 return __impl_->__begin();
36}
37[[nodiscard]] _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::__cend() const noexcept {
38 return __impl_->__end();
39}
40
41} // namespace chrono
42
43_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/filesystem/operations.cpp+22-19
......@@ -109,26 +109,23 @@ void __copy(const path& from, const path& to, copy_options options, error_code*
109109 const bool sym_status2 = bool(options & copy_options::copy_symlinks);
110110
111111 error_code m_ec1;
112 StatT f_st = {};
112 StatT f_st;
113113 const file_status f =
114114 sym_status || sym_status2 ? detail::posix_lstat(from, f_st, &m_ec1) : detail::posix_stat(from, f_st, &m_ec1);
115115 if (m_ec1)
116116 return err.report(m_ec1);
117117
118 StatT t_st = {};
118 StatT t_st;
119119 const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1) : detail::posix_stat(to, t_st, &m_ec1);
120120
121121 if (not status_known(t))
122122 return err.report(m_ec1);
123123
124124 if (!exists(f) || is_other(f) || is_other(t) || (is_directory(f) && is_regular_file(t)) ||
125 detail::stat_equivalent(f_st, t_st)) {
125 (exists(t) && detail::stat_equivalent(f_st, t_st))) {
126126 return err.report(errc::function_not_supported);
127127 }
128128
129 if (ec)
130 ec->clear();
131
132129 if (is_symlink(f)) {
133130 if (bool(copy_options::skip_symlinks & options)) {
134131 // do nothing
......@@ -166,15 +163,15 @@ void __copy(const path& from, const path& to, copy_options options, error_code*
166163 return;
167164 }
168165 error_code m_ec2;
169 for (; it != directory_iterator(); it.increment(m_ec2)) {
170 if (m_ec2) {
171 return err.report(m_ec2);
172 }
166 for (; !m_ec2 && it != directory_iterator(); it.increment(m_ec2)) {
173167 __copy(it->path(), to / it->path().filename(), options | copy_options::__in_recursive_copy, ec);
174168 if (ec && *ec) {
175169 return;
176170 }
177171 }
172 if (m_ec2) {
173 return err.report(m_ec2);
174 }
178175 }
179176}
180177
......@@ -815,8 +812,9 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
815812
816813 // If opening `p` failed because it wasn't a directory, remove it as
817814 // a normal file instead. Note that `openat()` can return either ENOTDIR
818 // or ELOOP depending on the exact reason of the failure.
819 if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) {
815 // or ELOOP depending on the exact reason of the failure. On FreeBSD it
816 // may return EMLINK instead of ELOOP, contradicting POSIX.
817 if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels || ec == errc::too_many_links) {
820818 ec.clear();
821819 if (::unlinkat(parent_directory, p.c_str(), /* flags = */ 0) == -1) {
822820 ec = detail::capture_errno();
......@@ -935,23 +933,28 @@ path __weakly_canonical(const path& p, error_code* ec) {
935933 --PP;
936934 vector<string_view_t> DNEParts;
937935
938 while (PP.State != PathParser::PS_BeforeBegin) {
936 error_code m_ec;
937 while (PP.State_ != PathParser::PS_BeforeBegin) {
939938 tmp.assign(createView(p.native().data(), &PP.RawEntry.back()));
940 error_code m_ec;
941939 file_status st = __status(tmp, &m_ec);
942940 if (!status_known(st)) {
943941 return err.report(m_ec);
944942 } else if (exists(st)) {
945 result = __canonical(tmp, ec);
943 result = __canonical(tmp, &m_ec);
944 if (m_ec) {
945 return err.report(m_ec);
946 }
946947 break;
947948 }
948949 DNEParts.push_back(*PP);
949950 --PP;
950951 }
951 if (PP.State == PathParser::PS_BeforeBegin)
952 result = __canonical("", ec);
953 if (ec)
954 ec->clear();
952 if (PP.State_ == PathParser::PS_BeforeBegin) {
953 result = __canonical("", &m_ec);
954 if (m_ec) {
955 return err.report(m_ec);
956 }
957 }
955958 if (DNEParts.empty())
956959 return result;
957960 for (auto It = DNEParts.rbegin(); It != DNEParts.rend(); ++It)
lib/libcxx/src/filesystem/path.cpp+14-14
......@@ -45,23 +45,23 @@ path& path::replace_extension(path const& replacement) {
4545
4646string_view_t path::__root_name() const {
4747 auto PP = PathParser::CreateBegin(__pn_);
48 if (PP.State == PathParser::PS_InRootName)
48 if (PP.State_ == PathParser::PS_InRootName)
4949 return *PP;
5050 return {};
5151}
5252
5353string_view_t path::__root_directory() const {
5454 auto PP = PathParser::CreateBegin(__pn_);
55 if (PP.State == PathParser::PS_InRootName)
55 if (PP.State_ == PathParser::PS_InRootName)
5656 ++PP;
57 if (PP.State == PathParser::PS_InRootDir)
57 if (PP.State_ == PathParser::PS_InRootDir)
5858 return *PP;
5959 return {};
6060}
6161
6262string_view_t path::__root_path_raw() const {
6363 auto PP = PathParser::CreateBegin(__pn_);
64 if (PP.State == PathParser::PS_InRootName) {
64 if (PP.State_ == PathParser::PS_InRootName) {
6565 auto NextCh = PP.peek();
6666 if (NextCh && isSeparator(*NextCh)) {
6767 ++PP;
......@@ -69,24 +69,24 @@ string_view_t path::__root_path_raw() const {
6969 }
7070 return PP.RawEntry;
7171 }
72 if (PP.State == PathParser::PS_InRootDir)
72 if (PP.State_ == PathParser::PS_InRootDir)
7373 return *PP;
7474 return {};
7575}
7676
7777static bool ConsumeRootName(PathParser* PP) {
7878 static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2, "Values for enums are incorrect");
79 while (PP->State <= PathParser::PS_InRootName)
79 while (PP->State_ <= PathParser::PS_InRootName)
8080 ++(*PP);
81 return PP->State == PathParser::PS_AtEnd;
81 return PP->State_ == PathParser::PS_AtEnd;
8282}
8383
8484static bool ConsumeRootDir(PathParser* PP) {
8585 static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2 && PathParser::PS_InRootDir == 3,
8686 "Values for enums are incorrect");
87 while (PP->State <= PathParser::PS_InRootDir)
87 while (PP->State_ <= PathParser::PS_InRootDir)
8888 ++(*PP);
89 return PP->State == PathParser::PS_AtEnd;
89 return PP->State_ == PathParser::PS_AtEnd;
9090}
9191
9292string_view_t path::__relative_path() const {
......@@ -248,7 +248,7 @@ path path::lexically_relative(const path& base) const {
248248 auto PP = PathParser::CreateBegin(__pn_);
249249 auto PPBase = PathParser::CreateBegin(base.__pn_);
250250 auto CheckIterMismatchAtBase = [&]() {
251 return PP.State != PPBase.State && (PP.inRootPath() || PPBase.inRootPath());
251 return PP.State_ != PPBase.State_ && (PP.inRootPath() || PPBase.inRootPath());
252252 };
253253 if (PP.inRootName() && PPBase.inRootName()) {
254254 if (*PP != *PPBase)
......@@ -267,7 +267,7 @@ path path::lexically_relative(const path& base) const {
267267 // Find the first mismatching element
268268 auto PP = PathParser::CreateBegin(__pn_);
269269 auto PPBase = PathParser::CreateBegin(base.__pn_);
270 while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) {
270 while (PP && PPBase && PP.State_ == PPBase.State_ && *PP == *PPBase) {
271271 ++PP;
272272 ++PPBase;
273273 }
......@@ -380,7 +380,7 @@ path::iterator path::begin() const {
380380 auto PP = PathParser::CreateBegin(__pn_);
381381 iterator it;
382382 it.__path_ptr_ = this;
383 it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
383 it.__state_ = static_cast<path::iterator::_ParserState>(PP.State_);
384384 it.__entry_ = PP.RawEntry;
385385 it.__stashed_elem_.__assign_view(*PP);
386386 return it;
......@@ -396,7 +396,7 @@ path::iterator path::end() const {
396396path::iterator& path::iterator::__increment() {
397397 PathParser PP(__path_ptr_->native(), __entry_, __state_);
398398 ++PP;
399 __state_ = static_cast<_ParserState>(PP.State);
399 __state_ = static_cast<_ParserState>(PP.State_);
400400 __entry_ = PP.RawEntry;
401401 __stashed_elem_.__assign_view(*PP);
402402 return *this;
......@@ -405,7 +405,7 @@ path::iterator& path::iterator::__increment() {
405405path::iterator& path::iterator::__decrement() {
406406 PathParser PP(__path_ptr_->native(), __entry_, __state_);
407407 --PP;
408 __state_ = static_cast<_ParserState>(PP.State);
408 __state_ = static_cast<_ParserState>(PP.State_);
409409 __entry_ = PP.RawEntry;
410410 __stashed_elem_.__assign_view(*PP);
411411 return *this;
lib/libcxx/src/filesystem/path_parser.h+14-14
......@@ -50,14 +50,14 @@ struct PathParser {
5050
5151 const string_view_t Path;
5252 string_view_t RawEntry;
53 ParserState State;
53 ParserState State_;
5454
5555private:
56 PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {}
56 PathParser(string_view_t P, ParserState State) noexcept : Path(P), State_(State) {}
5757
5858public:
5959 PathParser(string_view_t P, string_view_t E, unsigned char S)
60 : Path(P), RawEntry(E), State(static_cast<ParserState>(S)) {
60 : Path(P), RawEntry(E), State_(static_cast<ParserState>(S)) {
6161 // S cannot be '0' or PS_BeforeBegin.
6262 }
6363
......@@ -84,7 +84,7 @@ public:
8484 if (Start == End)
8585 return makeState(PS_AtEnd);
8686
87 switch (State) {
87 switch (State_) {
8888 case PS_BeforeBegin: {
8989 PosPtr TkEnd = consumeRootName(Start, End);
9090 if (TkEnd)
......@@ -125,7 +125,7 @@ public:
125125 if (RStart == REnd) // we're decrementing the begin
126126 return makeState(PS_BeforeBegin);
127127
128 switch (State) {
128 switch (State_) {
129129 case PS_AtEnd: {
130130 // Try to consume a trailing separator or root directory first.
131131 if (PosPtr SepEnd = consumeAllSeparators(RStart, REnd)) {
......@@ -169,7 +169,7 @@ public:
169169 /// \brief Return a view with the "preferred representation" of the current
170170 /// element. For example trailing separators are represented as a '.'
171171 string_view_t operator*() const noexcept {
172 switch (State) {
172 switch (State_) {
173173 case PS_BeforeBegin:
174174 case PS_AtEnd:
175175 return PATHSTR("");
......@@ -187,7 +187,7 @@ public:
187187 __libcpp_unreachable();
188188 }
189189
190 explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; }
190 explicit operator bool() const noexcept { return State_ != PS_BeforeBegin && State_ != PS_AtEnd; }
191191
192192 PathParser& operator++() noexcept {
193193 increment();
......@@ -199,21 +199,21 @@ public:
199199 return *this;
200200 }
201201
202 bool atEnd() const noexcept { return State == PS_AtEnd; }
202 bool atEnd() const noexcept { return State_ == PS_AtEnd; }
203203
204 bool inRootDir() const noexcept { return State == PS_InRootDir; }
204 bool inRootDir() const noexcept { return State_ == PS_InRootDir; }
205205
206 bool inRootName() const noexcept { return State == PS_InRootName; }
206 bool inRootName() const noexcept { return State_ == PS_InRootName; }
207207
208208 bool inRootPath() const noexcept { return inRootName() || inRootDir(); }
209209
210210private:
211211 void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
212 State = NewState;
212 State_ = NewState;
213213 RawEntry = string_view_t(Start, End - Start);
214214 }
215215 void makeState(ParserState NewState) noexcept {
216 State = NewState;
216 State_ = NewState;
217217 RawEntry = {};
218218 }
219219
......@@ -224,7 +224,7 @@ private:
224224 /// \brief Return a pointer to the first character after the currently
225225 /// lexed element.
226226 PosPtr getNextTokenStartPos() const noexcept {
227 switch (State) {
227 switch (State_) {
228228 case PS_BeforeBegin:
229229 return Path.data();
230230 case PS_InRootName:
......@@ -241,7 +241,7 @@ private:
241241 /// \brief Return a pointer to the first character in the currently lexed
242242 /// element.
243243 PosPtr getCurrentTokenStartPos() const noexcept {
244 switch (State) {
244 switch (State_) {
245245 case PS_BeforeBegin:
246246 case PS_InRootName:
247247 return &Path.front();
lib/libcxx/src/functional.cpp-2
......@@ -10,9 +10,7 @@
1010
1111_LIBCPP_BEGIN_NAMESPACE_STD
1212
13#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
1413bad_function_call::~bad_function_call() noexcept {}
15#endif
1614
1715#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
1816const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }
lib/libcxx/src/include/overridable_function.h+12-2
......@@ -13,6 +13,10 @@
1313#include <__config>
1414#include <cstdint>
1515
16#if __has_feature(ptrauth_calls)
17# include <ptrauth.h>
18#endif
19
1620#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1721# pragma GCC system_header
1822#endif
......@@ -57,8 +61,6 @@
5761// This mechanism should never be used outside of the libc++ built library. In particular,
5862// attempting to use this within the libc++ headers will not work at all because we don't
5963// want to be defining special sections inside user's executables which use our headers.
60// This is provided inside libc++'s include tree solely to make it easier to share with
61// libc++abi, which needs the same mechanism.
6264//
6365
6466#if defined(_LIBCPP_OBJECT_FORMAT_MACHO)
......@@ -81,6 +83,14 @@ _LIBCPP_HIDE_FROM_ABI bool __is_function_overridden(_Ret (*__fptr)(_Args...)) no
8183 uintptr_t __end = reinterpret_cast<uintptr_t>(&__lcxx_override_end);
8284 uintptr_t __ptr = reinterpret_cast<uintptr_t>(__fptr);
8385
86# if __has_feature(ptrauth_calls)
87 // We must pass a void* to ptrauth_strip since it only accepts a pointer type. Also, in particular,
88 // we must NOT pass a function pointer, otherwise we will strip the function pointer, and then attempt
89 // to authenticate and re-sign it when casting it to a uintptr_t again, which will fail because we just
90 // stripped the function pointer. See rdar://122927845.
91 __ptr = reinterpret_cast<uintptr_t>(ptrauth_strip(reinterpret_cast<void*>(__ptr), ptrauth_key_function_pointer));
92# endif
93
8494 // Finally, the function was overridden if it falls outside of the section's bounds.
8595 return __ptr < __start || __ptr > __end;
8696}
lib/libcxx/src/ios.cpp+4
......@@ -195,6 +195,10 @@ void ios_base::register_callback(event_callback fn, int index) {
195195}
196196
197197ios_base::~ios_base() {
198 // Avoid UB when not properly initialized. See ios_base::ios_base for
199 // more information.
200 if (!__loc_)
201 return;
198202 __call_callbacks(erase_event);
199203 locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
200204 loc_storage.~locale();
lib/libcxx/src/iostream.cpp+14-22
......@@ -21,74 +21,67 @@
2121
2222_LIBCPP_BEGIN_NAMESPACE_STD
2323
24_ALIGNAS_TYPE(istream)
25_LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]
24alignas(istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]
2625#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
2726 __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
2827 "@std@@@12@A")
2928#endif
3029 ;
31_ALIGNAS_TYPE(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];
30alignas(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];
3231static mbstate_t mb_cin;
3332
3433#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
35_ALIGNAS_TYPE(wistream)
36_LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
34alignas(wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
3735# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
3836 __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
3937 "@std@@@12@A")
4038# endif
4139 ;
42_ALIGNAS_TYPE(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];
40alignas(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];
4341static mbstate_t mb_wcin;
4442#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
4543
46_ALIGNAS_TYPE(ostream)
47_LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
44alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
4845#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
4946 __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
5047 "@std@@@12@A")
5148#endif
5249 ;
53_ALIGNAS_TYPE(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
50alignas(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
5451static mbstate_t mb_cout;
5552
5653#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
57_ALIGNAS_TYPE(wostream)
58_LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
54alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
5955# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
6056 __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
6157 "@std@@@12@A")
6258# endif
6359 ;
64_ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
60alignas(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
6561static mbstate_t mb_wcout;
6662#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
6763
68_ALIGNAS_TYPE(ostream)
69_LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
64alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
7065#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
7166 __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
7267 "@std@@@12@A")
7368#endif
7469 ;
75_ALIGNAS_TYPE(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
70alignas(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
7671static mbstate_t mb_cerr;
7772
7873#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
79_ALIGNAS_TYPE(wostream)
80_LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
74alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
8175# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
8276 __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
8377 "@std@@@12@A")
8478# endif
8579 ;
86_ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
80alignas(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
8781static mbstate_t mb_wcerr;
8882#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
8983
90_ALIGNAS_TYPE(ostream)
91_LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
84alignas(ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
9285#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
9386 __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
9487 "@std@@@12@A")
......@@ -96,8 +89,7 @@ _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
9689 ;
9790
9891#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
99_ALIGNAS_TYPE(wostream)
100_LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
92alignas(wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
10193# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
10294 __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
10395 "@std@@@12@A")
lib/libcxx/src/locale.cpp+6-8
......@@ -34,9 +34,7 @@
3434# define _CTYPE_DISABLE_MACROS
3535#endif
3636
37#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
38# include "__support/win32/locale_win32.h"
39#elif !defined(__BIONIC__) && !defined(__NuttX__)
37#if !defined(_LIBCPP_MSVCRT) && !defined(__MINGW32__) && !defined(__BIONIC__) && !defined(__NuttX__)
4038# include <langinfo.h>
4139#endif
4240
......@@ -104,8 +102,6 @@ inline constexpr size_t countof(const T* const begin, const T* const end) {
104102 return static_cast<size_t>(end - begin);
105103}
106104
107} // namespace
108
109105string build_name(const string& other, const string& one, locale::category c) {
110106 if (other == "*" || one == "*")
111107 return "*";
......@@ -117,6 +113,8 @@ string build_name(const string& other, const string& one, locale::category c) {
117113 return "*";
118114}
119115
116} // namespace
117
120118const locale::category locale::none;
121119const locale::category locale::collate;
122120const locale::category locale::ctype;
......@@ -499,7 +497,7 @@ constinit __no_destroy<locale::__imp>
499497 locale::__imp::classic_locale_imp_(__uninitialized_tag{}); // initialized below in classic()
500498
501499const locale& locale::classic() {
502 static const __no_destroy<locale> classic_locale(__private_tag{}, [] {
500 static const __no_destroy<locale> classic_locale(__private_constructor_tag{}, [] {
503501 // executed exactly once on first initialization of `classic_locale`
504502 locale::__imp::classic_locale_imp_.__emplace(1u);
505503 return &locale::__imp::classic_locale_imp_.__get();
......@@ -559,9 +557,9 @@ locale::locale(const locale& other, const locale& one, category c)
559557
560558string locale::name() const { return __locale_->name(); }
561559
562void locale::__install_ctor(const locale& other, facet* f, long id) {
560void locale::__install_ctor(const locale& other, facet* f, long facet_id) {
563561 if (f)
564 __locale_ = new __imp(*other.__locale_, f, id);
562 __locale_ = new __imp(*other.__locale_, f, facet_id);
565563 else
566564 __locale_ = other.__locale_;
567565 __locale_->acquire();
lib/libcxx/src/mutex_destructor.cpp+1-1
......@@ -17,7 +17,7 @@
1717// _LIBCPP_BUILDING_LIBRARY to change the definition in the headers.
1818
1919#include <__config>
20#include <__threading_support>
20#include <__thread/support.h>
2121
2222#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
2323# define NEEDS_MUTEX_DESTRUCTOR
lib/libcxx/src/new.cpp+1
......@@ -7,6 +7,7 @@
77//===----------------------------------------------------------------------===//
88
99#include "include/overridable_function.h"
10#include <__assert>
1011#include <__memory/aligned_alloc.h>
1112#include <cstddef>
1213#include <cstdlib>
lib/libcxx/src/optional.cpp-1
......@@ -6,7 +6,6 @@
66//
77//===----------------------------------------------------------------------===//
88
9#include <__availability>
109#include <optional>
1110#include <stdexcept>
1211
lib/libcxx/src/ostream.cpp-1
......@@ -6,7 +6,6 @@
66//
77//===----------------------------------------------------------------------===//
88
9#include <__availability>
109#include <__config>
1110#ifndef _LIBCPP_HAS_NO_FILESYSTEM
1211# include <fstream>
lib/libcxx/src/pstl/libdispatch.cpp+3-6
......@@ -7,13 +7,12 @@
77//===----------------------------------------------------------------------===//
88
99#include <__algorithm/min.h>
10#include <__algorithm/pstl_backends/cpu_backends/libdispatch.h>
1110#include <__config>
11#include <__pstl/backends/libdispatch.h>
1212#include <dispatch/dispatch.h>
1313
1414_LIBCPP_BEGIN_NAMESPACE_STD
15
16namespace __par_backend::inline __libdispatch {
15namespace __pstl::__libdispatch {
1716
1817void __dispatch_apply(size_t chunk_count, void* context, void (*func)(void* context, size_t chunk)) noexcept {
1918 ::dispatch_apply_f(chunk_count, DISPATCH_APPLY_AUTO, context, func);
......@@ -29,7 +28,5 @@ __chunk_partitions __partition_chunks(ptrdiff_t element_count) noexcept {
2928 return partitions;
3029}
3130
32// NOLINTNEXTLINE(llvm-namespace-comment) // This is https://llvm.org/PR56804
33} // namespace __par_backend::inline __libdispatch
34
31} // namespace __pstl::__libdispatch
3532_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/random.cpp+1-1
......@@ -80,7 +80,7 @@ unsigned random_device::operator()() {
8080 while (n > 0) {
8181 ssize_t s = read(__f_, p, n);
8282 if (s == 0)
83 __throw_system_error(ENODATA, "random_device got EOF");
83 __throw_system_error(ENOMSG, "random_device got EOF");
8484 if (s == -1) {
8585 if (errno != EINTR)
8686 __throw_system_error(errno, "random_device got an unexpected error");
lib/libcxx/src/support/win32/thread_win32.cpp+1-1
......@@ -6,7 +6,7 @@
66//
77//===----------------------------------------------------------------------===//
88
9#include <__threading_support>
9#include <__thread/support/windows.h>
1010#include <chrono>
1111
1212#define NOMINMAX
lib/libcxx/src/tz.cpp deleted-148
......@@ -1,148 +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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#include <chrono>
12#include <filesystem>
13#include <fstream>
14#include <stdexcept>
15#include <string>
16
17// Contains a parser for the IANA time zone data files.
18//
19// These files can be found at https://data.iana.org/time-zones/ and are in the
20// public domain. Information regarding the input can be found at
21// https://data.iana.org/time-zones/tz-how-to.html and
22// https://man7.org/linux/man-pages/man8/zic.8.html.
23//
24// As indicated at https://howardhinnant.github.io/date/tz.html#Installation
25// For Windows another file seems to be required
26// https://raw.githubusercontent.com/unicode-org/cldr/master/common/supplemental/windowsZones.xml
27// This file seems to contain the mapping of Windows time zone name to IANA
28// time zone names.
29//
30// However this article mentions another way to do the mapping on Windows
31// https://devblogs.microsoft.com/oldnewthing/20210527-00/?p=105255
32// This requires Windows 10 Version 1903, which was released in May of 2019
33// and considered end of life in December 2020
34// https://learn.microsoft.com/en-us/lifecycle/announcements/windows-10-1903-end-of-servicing
35//
36// TODO TZDB Implement the Windows mapping in tzdb::current_zone
37
38_LIBCPP_BEGIN_NAMESPACE_STD
39
40namespace chrono {
41
42// This function is weak so it can be overriden in the tests. The
43// declaration is in the test header test/support/test_tzdb.h
44_LIBCPP_WEAK string_view __libcpp_tzdb_directory() {
45#if defined(__linux__)
46 return "/usr/share/zoneinfo/";
47#else
48// Zig patch: change this compilation error into a runtime crash.
49//# error "unknown path to the IANA Time Zone Database"
50 abort();
51#endif
52}
53
54[[nodiscard]] static bool __is_whitespace(int __c) { return __c == ' ' || __c == '\t'; }
55
56static void __skip_optional_whitespace(istream& __input) {
57 while (chrono::__is_whitespace(__input.peek()))
58 __input.get();
59}
60
61static void __skip_mandatory_whitespace(istream& __input) {
62 if (!chrono::__is_whitespace(__input.get()))
63 std::__throw_runtime_error("corrupt tzdb: expected whitespace");
64
65 chrono::__skip_optional_whitespace(__input);
66}
67
68static void __matches(istream& __input, char __expected) {
69 if (std::tolower(__input.get()) != __expected)
70 std::__throw_runtime_error((string("corrupt tzdb: expected character '") + __expected + '\'').c_str());
71}
72
73static void __matches(istream& __input, string_view __expected) {
74 for (auto __c : __expected)
75 if (std::tolower(__input.get()) != __c)
76 std::__throw_runtime_error((string("corrupt tzdb: expected string '") + string(__expected) + '\'').c_str());
77}
78
79[[nodiscard]] static string __parse_string(istream& __input) {
80 string __result;
81 while (true) {
82 int __c = __input.get();
83 switch (__c) {
84 case ' ':
85 case '\t':
86 case '\n':
87 __input.unget();
88 [[fallthrough]];
89 case istream::traits_type::eof():
90 if (__result.empty())
91 std::__throw_runtime_error("corrupt tzdb: expected a string");
92
93 return __result;
94
95 default:
96 __result.push_back(__c);
97 }
98 }
99}
100
101static string __parse_version(istream& __input) {
102 // The first line in tzdata.zi contains
103 // # version YYYYw
104 // The parser expects this pattern
105 // #\s*version\s*\(.*)
106 // This part is not documented.
107 chrono::__matches(__input, '#');
108 chrono::__skip_optional_whitespace(__input);
109 chrono::__matches(__input, "version");
110 chrono::__skip_mandatory_whitespace(__input);
111 return chrono::__parse_string(__input);
112}
113
114static tzdb __make_tzdb() {
115 tzdb __result;
116
117 filesystem::path __root = chrono::__libcpp_tzdb_directory();
118 ifstream __tzdata{__root / "tzdata.zi"};
119
120 __result.version = chrono::__parse_version(__tzdata);
121 return __result;
122}
123
124//===----------------------------------------------------------------------===//
125// Public API
126//===----------------------------------------------------------------------===//
127
128_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI tzdb_list& get_tzdb_list() {
129 static tzdb_list __result{chrono::__make_tzdb()};
130 return __result;
131}
132
133_LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI const tzdb& reload_tzdb() {
134 if (chrono::remote_version() == chrono::get_tzdb().version)
135 return chrono::get_tzdb();
136
137 return chrono::get_tzdb_list().__emplace_front(chrono::__make_tzdb());
138}
139
140_LIBCPP_NODISCARD_EXT _LIBCPP_AVAILABILITY_TZDB _LIBCPP_EXPORTED_FROM_ABI string remote_version() {
141 filesystem::path __root = chrono::__libcpp_tzdb_directory();
142 ifstream __tzdata{__root / "tzdata.zi"};
143 return chrono::__parse_version(__tzdata);
144}
145
146} // namespace chrono
147
148_LIBCPP_END_NAMESPACE_STD
lib/libcxx/src/tzdb_list.cpp deleted-113
......@@ -1,113 +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// For information see https://libcxx.llvm.org/DesignDocs/TimeZone.html
10
11#include <chrono>
12
13#include <__mutex/unique_lock.h>
14#include <forward_list>
15
16// When threads are not available the locking is not required.
17#ifndef _LIBCPP_HAS_NO_THREADS
18# include <shared_mutex>
19#endif
20
21_LIBCPP_BEGIN_NAMESPACE_STD
22
23namespace chrono {
24
25//===----------------------------------------------------------------------===//
26// Private API
27//===----------------------------------------------------------------------===//
28
29class tzdb_list::__impl {
30public:
31 explicit __impl(tzdb&& __tzdb) { __tzdb_.push_front(std::move(__tzdb)); }
32
33 using const_iterator = tzdb_list::const_iterator;
34
35 const tzdb& front() const noexcept {
36#ifndef _LIBCPP_HAS_NO_THREADS
37 shared_lock __lock{__mutex_};
38#endif
39 return __tzdb_.front();
40 }
41
42 const_iterator erase_after(const_iterator __p) {
43#ifndef _LIBCPP_HAS_NO_THREADS
44 unique_lock __lock{__mutex_};
45#endif
46 return __tzdb_.erase_after(__p);
47 }
48
49 tzdb& __emplace_front(tzdb&& __tzdb) {
50#ifndef _LIBCPP_HAS_NO_THREADS
51 unique_lock __lock{__mutex_};
52#endif
53 return __tzdb_.emplace_front(std::move(__tzdb));
54 }
55
56 const_iterator begin() const noexcept {
57#ifndef _LIBCPP_HAS_NO_THREADS
58 shared_lock __lock{__mutex_};
59#endif
60 return __tzdb_.begin();
61 }
62 const_iterator end() const noexcept {
63 // forward_list<T>::end does not access the list, so no need to take a lock.
64 return __tzdb_.end();
65 }
66
67 const_iterator cbegin() const noexcept { return begin(); }
68 const_iterator cend() const noexcept { return end(); }
69
70private:
71#ifndef _LIBCPP_HAS_NO_THREADS
72 mutable shared_mutex __mutex_;
73#endif
74 forward_list<tzdb> __tzdb_;
75};
76
77//===----------------------------------------------------------------------===//
78// Public API
79//===----------------------------------------------------------------------===//
80
81_LIBCPP_EXPORTED_FROM_ABI tzdb_list::tzdb_list(tzdb&& __tzdb) : __impl_{new __impl(std::move(__tzdb))} {}
82
83_LIBCPP_EXPORTED_FROM_ABI tzdb_list::~tzdb_list() { delete __impl_; }
84
85_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI const tzdb& tzdb_list::front() const noexcept {
86 return __impl_->front();
87}
88
89_LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::erase_after(const_iterator __p) {
90 return __impl_->erase_after(__p);
91}
92
93_LIBCPP_EXPORTED_FROM_ABI tzdb& tzdb_list::__emplace_front(tzdb&& __tzdb) {
94 return __impl_->__emplace_front(std::move(__tzdb));
95}
96
97_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::begin() const noexcept {
98 return __impl_->begin();
99}
100_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::end() const noexcept {
101 return __impl_->end();
102}
103
104_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cbegin() const noexcept {
105 return __impl_->cbegin();
106}
107_LIBCPP_NODISCARD_EXT _LIBCPP_EXPORTED_FROM_ABI tzdb_list::const_iterator tzdb_list::cend() const noexcept {
108 return __impl_->cend();
109}
110
111} // namespace chrono
112
113_LIBCPP_END_NAMESPACE_STD
src/libcxx.zig+1-3
......@@ -46,7 +46,7 @@ const libcxx_base_files = [_][]const u8{
4646 "src/chrono.cpp",
4747 "src/error_category.cpp",
4848 "src/exception.cpp",
49 "src/experimental/keep.cpp",
49 "src/expected.cpp",
5050 "src/filesystem/directory_entry.cpp",
5151 "src/filesystem/directory_iterator.cpp",
5252 "src/filesystem/filesystem_clock.cpp",
......@@ -89,8 +89,6 @@ const libcxx_base_files = [_][]const u8{
8989 "src/support/win32/support.cpp",
9090 "src/system_error.cpp",
9191 "src/typeinfo.cpp",
92 "src/tz.cpp",
93 "src/tzdb_list.cpp",
9492 "src/valarray.cpp",
9593 "src/variant.cpp",
9694 "src/vector.cpp",